Commit 3869c3c8 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz

Merge branch 'gallium-tex-surfaces' into gallium-0.1

Conflicts:

	src/gallium/drivers/i915simple/i915_context.h
parents 2ade5268 012c0dd6
#!/usr/bin/env python
##########################################################################
#
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
##########################################################################
import sys
import optparse
import re
import struct
__version__ = '0.1'
__version__ = '0.1'
verbose = False
......@@ -16,7 +43,7 @@ class ParseError(Exception):
class MsvcDemangler:
# http://www.kegel.com/mangle.html
# http://www.kegel.com/mangle.html
def __init__(self, symbol):
self._symbol = symbol
......
......@@ -37,6 +37,7 @@ C_SOURCES = \
draw_vs_varient.c \
draw_vs_aos.c \
draw_vs_aos_io.c \
draw_vs_aos_machine.c \
draw_vs_exec.c \
draw_vs_llvm.c \
draw_vs_sse.c
......
......@@ -15,7 +15,7 @@ draw = env.ConvenienceLibrary(
'draw_pipe_stipple.c',
'draw_pipe_twoside.c',
'draw_pipe_unfilled.c',
'draw_pipe_util.c',
'draw_pipe_util.c',
'draw_pipe_validate.c',
'draw_pipe_vbuf.c',
'draw_pipe_wide_line.c',
......@@ -25,15 +25,21 @@ draw = env.ConvenienceLibrary(
'draw_pt_emit.c',
'draw_pt_fetch.c',
'draw_pt_fetch_emit.c',
'draw_pt_fetch_shade_emit.c',
'draw_pt_fetch_shade_pipeline.c',
'draw_pt_post_vs.c',
'draw_pt_util.c',
'draw_pt_varray.c',
'draw_pt_vcache.c',
'draw_vertex.c',
'draw_vs.c',
'draw_vs_aos.c',
'draw_vs_aos_io.c',
'draw_vs_aos_machine.c',
'draw_vs_exec.c',
'draw_vs_llvm.c',
'draw_vs_sse.c',
'draw_vs_varient.c'
])
auxiliaries.insert(0, draw)
......@@ -174,6 +174,8 @@ void draw_set_viewport_state( struct draw_context *draw,
viewport->translate[1] == 0.0f &&
viewport->translate[2] == 0.0f &&
viewport->translate[3] == 0.0f);
draw_vs_set_viewport( draw, viewport );
}
......@@ -215,9 +217,11 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw,
void
draw_set_mapped_constant_buffer(struct draw_context *draw,
const void *buffer)
const void *buffer,
unsigned size )
{
draw->pt.user.constants = buffer;
draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
}
......@@ -345,14 +349,30 @@ void draw_set_edgeflags( struct draw_context *draw,
* \param elements the element buffer ptr
*/
void
draw_set_mapped_element_buffer( struct draw_context *draw,
unsigned eltSize, void *elements )
draw_set_mapped_element_buffer_range( struct draw_context *draw,
unsigned eltSize,
unsigned min_index,
unsigned max_index,
void *elements )
{
draw->pt.user.elts = elements;
draw->pt.user.eltSize = eltSize;
draw->pt.user.min_index = min_index;
draw->pt.user.max_index = max_index;
}
void
draw_set_mapped_element_buffer( struct draw_context *draw,
unsigned eltSize,
void *elements )
{
draw->pt.user.elts = elements;
draw->pt.user.eltSize = eltSize;
draw->pt.user.min_index = 0;
draw->pt.user.max_index = 0xffffffff;
}
/* Revamp me please:
*/
......
......@@ -118,14 +118,23 @@ void draw_set_vertex_elements(struct draw_context *draw,
unsigned count,
const struct pipe_vertex_element *elements);
void
draw_set_mapped_element_buffer_range( struct draw_context *draw,
unsigned eltSize,
unsigned min_index,
unsigned max_index,
void *elements );
void draw_set_mapped_element_buffer( struct draw_context *draw,
unsigned eltSize, void *elements );
unsigned eltSize,
void *elements );
void draw_set_mapped_vertex_buffer(struct draw_context *draw,
unsigned attr, const void *buffer);
void draw_set_mapped_constant_buffer(struct draw_context *draw,
const void *buffer);
const void *buffer,
unsigned size );
void draw_set_edgeflags( struct draw_context *draw,
const unsigned *edgeflag );
......
......@@ -175,6 +175,22 @@ reset_stipple_counter(struct draw_stage *stage)
stage->next->reset_stipple_counter( stage->next );
}
static void
stipple_reset_point(struct draw_stage *stage, struct prim_header *header)
{
struct stipple_stage *stipple = stipple_stage(stage);
stipple->counter = 0;
stage->next->point(stage->next, header);
}
static void
stipple_reset_tri(struct draw_stage *stage, struct prim_header *header)
{
struct stipple_stage *stipple = stipple_stage(stage);
stipple->counter = 0;
stage->next->tri(stage->next, header);
}
static void
stipple_first_line(struct draw_stage *stage,
......@@ -220,9 +236,9 @@ struct draw_stage *draw_stipple_stage( struct draw_context *draw )
stipple->stage.draw = draw;
stipple->stage.next = NULL;
stipple->stage.point = draw_pipe_passthrough_point;
stipple->stage.point = stipple_reset_point;
stipple->stage.line = stipple_first_line;
stipple->stage.tri = draw_pipe_passthrough_tri;
stipple->stage.tri = stipple_reset_tri;
stipple->stage.reset_stipple_counter = reset_stipple_counter;
stipple->stage.flush = stipple_flush;
stipple->stage.destroy = stipple_destroy;
......
......@@ -145,7 +145,7 @@ emit_vertex( struct vbuf_stage *vbuf,
vertex->vertex_id = vbuf->nr_vertices++;
}
return vertex->vertex_id;
return (ushort)vertex->vertex_id;
}
......
......@@ -147,6 +147,8 @@ struct draw_context
const void *elts;
/** bytes per index (0, 1, 2 or 4) */
unsigned eltSize;
unsigned min_index;
unsigned max_index;
/** vertex arrays */
const void *vbuffer[PIPE_MAX_ATTRIBS];
......@@ -155,7 +157,8 @@ struct draw_context
const void *constants;
} user;
boolean test_fse;
boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */
boolean no_fse; /* disable FSE even when it is correct */
} pt;
struct {
......@@ -183,6 +186,16 @@ struct draw_context
*/
struct gallivm_cpu_engine *engine;
/* Here's another one:
*/
struct aos_machine *aos_machine;
const float (*aligned_constants)[4];
const float (*aligned_constant_storage)[4];
unsigned const_storage_size;
struct translate *fetch;
struct translate_cache *fetch_cache;
......@@ -215,6 +228,12 @@ struct draw_context
boolean draw_vs_init( struct draw_context *draw );
void draw_vs_destroy( struct draw_context *draw );
void draw_vs_set_viewport( struct draw_context *,
const struct pipe_viewport_state * );
void draw_vs_set_constants( struct draw_context *,
const float (*constants)[4],
unsigned size );
......
......@@ -75,7 +75,7 @@ draw_pt_arrays(struct draw_context *draw,
if (opt == 0)
middle = draw->pt.middle.fetch_emit;
else if (opt == PT_SHADE && draw->pt.test_fse)
else if (opt == PT_SHADE && !draw->pt.no_fse)
middle = draw->pt.middle.fetch_shade_emit;
else
middle = draw->pt.middle.general;
......@@ -105,6 +105,7 @@ draw_pt_arrays(struct draw_context *draw,
boolean draw_pt_init( struct draw_context *draw )
{
draw->pt.test_fse = GETENV("DRAW_FSE") != NULL;
draw->pt.no_fse = GETENV("DRAW_NO_FSE") != NULL;
draw->pt.front.vcache = draw_pt_vcache( draw );
if (!draw->pt.front.vcache)
......@@ -118,12 +119,9 @@ boolean draw_pt_init( struct draw_context *draw )
if (!draw->pt.middle.fetch_emit)
return FALSE;
if (draw->pt.test_fse) {
draw->pt.middle.fetch_shade_emit = draw_pt_middle_fse( draw );
if (!draw->pt.middle.fetch_shade_emit)
return FALSE;
}
draw->pt.middle.fetch_shade_emit = draw_pt_middle_fse( draw );
if (!draw->pt.middle.fetch_shade_emit)
return FALSE;
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
if (!draw->pt.middle.general)
......
......@@ -96,6 +96,15 @@ struct draw_pt_middle_end {
unsigned start,
unsigned count);
/* Transform all vertices in a linear range and then draw them with
* the supplied element list.
*/
void (*run_linear_elts)( struct draw_pt_middle_end *,
unsigned fetch_start,
unsigned fetch_count,
const ushort *draw_elts,
unsigned draw_count );
void (*finish)( struct draw_pt_middle_end * );
void (*destroy)( struct draw_pt_middle_end * );
};
......
......@@ -311,6 +311,53 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
}
static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
unsigned draw_count )
{
struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle;
struct draw_context *draw = feme->draw;
void *hw_verts;
/* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
hw_verts = draw->render->allocate_vertices( draw->render,
(ushort)feme->translate->key.output_stride,
(ushort)count );
if (!hw_verts) {
assert(0);
return;
}
/* Single routine to fetch vertices and emit HW verts.
*/
feme->translate->run( feme->translate,
start,
count,
hw_verts );
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
draw->render->draw( draw->render,
draw_elts,
draw_count );
/* Done -- that was easy, wasn't it:
*/
draw->render->release_vertices( draw->render,
hw_verts,
feme->translate->key.output_stride,
count );
}
static void fetch_emit_finish( struct draw_pt_middle_end *middle )
{
......@@ -343,6 +390,7 @@ struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw )
fetch_emit->base.prepare = fetch_emit_prepare;
fetch_emit->base.run = fetch_emit_run;
fetch_emit->base.run_linear = fetch_emit_run_linear;
fetch_emit->base.run_linear_elts = fetch_emit_run_linear_elts;
fetch_emit->base.finish = fetch_emit_finish;
fetch_emit->base.destroy = fetch_emit_destroy;
......
......@@ -189,12 +189,6 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
draw->pt.vertex_buffer[buf].pitch );
}
fse->active->set_constants( fse->active,
(const float (*)[4])draw->pt.user.constants );
fse->active->set_viewport( fse->active,
&draw->viewport );
//return TRUE;
}
......@@ -316,6 +310,54 @@ fse_run(struct draw_pt_middle_end *middle,
}
static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
unsigned draw_count )
{
struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle;
struct draw_context *draw = fse->draw;
unsigned alloc_count = align(count, 4);
char *hw_verts;
/* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
hw_verts = draw->render->allocate_vertices( draw->render,
(ushort)fse->key.output_stride,
(ushort)alloc_count );
if (!hw_verts) {
assert(0);
return;
}
/* Single routine to fetch vertices, run shader and emit HW verts.
* Clipping is done elsewhere -- either by the API or on hardware,
* or for some other reason not required...
*/
fse->active->run_linear( fse->active,
start, count,
hw_verts );
draw->render->draw( draw->render,
draw_elts,
draw_count );
draw->render->release_vertices( draw->render,
hw_verts,
fse->key.output_stride,
count );
}
static void fse_finish( struct draw_pt_middle_end *middle )
{
}
......@@ -336,6 +378,7 @@ struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw )
fse->base.prepare = fse_prepare;
fse->base.run = fse_run;
fse->base.run_linear = fse_run_linear;
fse->base.run_linear_elts = fse_run_linear_elts;
fse->base.finish = fse_finish;
fse->base.destroy = fse_destroy;
fse->draw = draw;
......
......@@ -81,9 +81,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
* but gl vs dx9 clip spaces.
*/
draw_pt_post_vs_prepare( fpme->post_vs,
draw->bypass_clipping,
draw->identity_viewport,
draw->rasterizer->gl_rasterization_rules );
(boolean)draw->bypass_clipping,
(boolean)draw->identity_viewport,
(boolean)draw->rasterizer->gl_rasterization_rules );
if (!(opt & PT_PIPELINE))
......@@ -98,7 +98,6 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
const unsigned *fetch_elts,
unsigned fetch_count,
......@@ -251,6 +250,84 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
const ushort *draw_elts,
unsigned draw_count )
{
struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
struct draw_context *draw = fpme->draw;
struct draw_vertex_shader *shader = draw->vs.vertex_shader;
unsigned opt = fpme->opt;
unsigned alloc_count = align_int( count, 4 );
struct vertex_header *pipeline_verts =
(struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count);
if (!pipeline_verts) {
/* Not much we can do here - just skip the rendering.
*/
assert(0);
return;
}
/* Fetch into our vertex buffer
*/
draw_pt_fetch_run_linear( fpme->fetch,
start,
count,
(char *)pipeline_verts );
/* Run the shader, note that this overwrites the data[] parts of
* the pipeline verts. If there is no shader, ie a bypass shader,
* then the inputs == outputs, and are already in the correct
* place.
*/
if (opt & PT_SHADE)
{
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
(const float (*)[4])draw->pt.user.constants,
count,
fpme->vertex_size,
fpme->vertex_size);
}
if (draw_pt_post_vs_run( fpme->post_vs,
pipeline_verts,
count,
fpme->vertex_size ))
{
opt |= PT_PIPELINE;
}
/* Do we need to run the pipeline?
*/
if (opt & PT_PIPELINE) {
draw_pipeline_run( fpme->draw,
fpme->prim,
pipeline_verts,
count,
fpme->vertex_size,
draw_elts,
draw_count );
}
else {
draw_pt_emit( fpme->emit,
(const float (*)[4])pipeline_verts->data,
count,
fpme->vertex_size,
draw_elts,
draw_count );
}
FREE(pipeline_verts);
}
static void fetch_pipeline_finish( struct draw_pt_middle_end *middle )
{
/* nothing to do */
......@@ -282,6 +359,7 @@ struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit( struct draw_context *
fpme->base.prepare = fetch_pipeline_prepare;
fpme->base.run = fetch_pipeline_run;
fpme->base.run_linear = fetch_pipeline_linear_run;
fpme->base.run_linear_elts = fetch_pipeline_linear_run_elts;
fpme->base.finish = fetch_pipeline_finish;
fpme->base.destroy = fetch_pipeline_destroy;
......
......@@ -10,7 +10,8 @@ static void FUNC(struct draw_pt_front_end *frontend,
boolean flatfirst = (draw->rasterizer->flatshade &&
draw->rasterizer->flatshade_first);
unsigned i, j, flags;
unsigned i, j;
ushort flags;
unsigned first, incr;
varray->fetch_start = start;
......@@ -200,9 +201,9 @@ static void FUNC(struct draw_pt_front_end *frontend,
/* These bitflags look a little odd because we submit the
* vertices as (1,2,0) to satisfy flatshade requirements.
*/
const unsigned edge_first = DRAW_PIPE_EDGE_FLAG_2;
const unsigned edge_middle = DRAW_PIPE_EDGE_FLAG_0;
const unsigned edge_last = DRAW_PIPE_EDGE_FLAG_1;
const ushort edge_first = DRAW_PIPE_EDGE_FLAG_2;
const ushort edge_middle = DRAW_PIPE_EDGE_FLAG_0;
const ushort edge_last = DRAW_PIPE_EDGE_FLAG_1;
flags = DRAW_PIPE_RESET_STIPPLE | edge_first | edge_middle;
for (j = 0; j + first <= count; j += i) {
......
......@@ -36,8 +36,8 @@
#include "draw/draw_pt.h"
#define CACHE_MAX 32
#define FETCH_MAX 128
#define CACHE_MAX 1024
#define FETCH_MAX 4096
#define DRAW_MAX (16*1024)
struct vcache_frontend {
......@@ -201,7 +201,128 @@ static void vcache_ef_quad( struct vcache_frontend *vcache,
#define FUNC vcache_run
#include "draw_pt_vcache_tmp.h"