summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-04-19 17:27:52 +0100
committerKeith Whitwell <[email protected]>2008-04-19 17:27:52 +0100
commit7d72607e142c0412b88183b849fd701e698b8f79 (patch)
tree53fe84cfb03756d5dd1d04c785ff4862113255c4
parentdcf6f776ce32b89b7ff784bb38030bd29698e005 (diff)
draw: move incoming vertex state into draw->pt
This state is effectively private to the vertex processing part of the draw module.
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c28
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h47
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_pt.h9
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_elts.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch.c20
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c2
-rw-r--r--src/mesa/state_tracker/st_draw.c6
10 files changed, 63 insertions, 71 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 3e69867d113..4988d67faa1 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -62,8 +62,6 @@ struct draw_context *draw_create( void )
draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
- draw_set_mapped_element_buffer( draw, 0, NULL );
-
tgsi_exec_machine_init(&draw->machine);
/* FIXME: give this machine thing a proper constructor:
@@ -188,8 +186,8 @@ draw_set_vertex_buffers(struct draw_context *draw,
{
assert(count <= PIPE_MAX_ATTRIBS);
- memcpy(draw->vertex_buffer, buffers, count * sizeof(buffers[0]));
- draw->nr_vertex_buffers = count;
+ memcpy(draw->pt.vertex_buffer, buffers, count * sizeof(buffers[0]));
+ draw->pt.nr_vertex_buffers = count;
}
@@ -200,8 +198,8 @@ draw_set_vertex_elements(struct draw_context *draw,
{
assert(count <= PIPE_MAX_ATTRIBS);
- memcpy(draw->vertex_element, elements, count * sizeof(elements[0]));
- draw->nr_vertex_elements = count;
+ memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0]));
+ draw->pt.nr_vertex_elements = count;
}
@@ -212,7 +210,7 @@ void
draw_set_mapped_vertex_buffer(struct draw_context *draw,
unsigned attr, const void *buffer)
{
- draw->user.vbuffer[attr] = buffer;
+ draw->pt.user.vbuffer[attr] = buffer;
}
@@ -220,7 +218,7 @@ void
draw_set_mapped_constant_buffer(struct draw_context *draw,
const void *buffer)
{
- draw->user.constants = buffer;
+ draw->pt.user.constants = buffer;
}
@@ -337,18 +335,10 @@ void draw_set_render( struct draw_context *draw,
void draw_set_edgeflags( struct draw_context *draw,
const unsigned *edgeflag )
{
- draw->user.edgeflag = edgeflag;
+ draw->pt.user.edgeflag = edgeflag;
}
-boolean draw_get_edgeflag( struct draw_context *draw,
- unsigned idx )
-{
- if (draw->user.edgeflag)
- return (draw->user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
- else
- return 1;
-}
/**
@@ -365,8 +355,8 @@ void
draw_set_mapped_element_buffer( struct draw_context *draw,
unsigned eltSize, void *elements )
{
- draw->user.elts = elements;
- draw->user.eltSize = eltSize;
+ draw->pt.user.elts = elements;
+ draw->pt.user.eltSize = eltSize;
}
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 6cf3e54e28d..27f61c2f40f 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -149,6 +149,29 @@ struct draw_context
struct {
struct draw_pt_front_end *vcache;
} front;
+
+ struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
+ unsigned nr_vertex_buffers;
+
+ struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
+ unsigned nr_vertex_elements;
+
+ /* user-space vertex data, buffers */
+ struct {
+ const unsigned *edgeflag;
+
+ /** vertex element/index buffer (ex: glDrawElements) */
+ const void *elts;
+ /** bytes per index (0, 1, 2 or 4) */
+ unsigned eltSize;
+
+ /** vertex arrays */
+ const void *vbuffer[PIPE_MAX_ATTRIBS];
+
+ /** constant buffer (for vertex shader) */
+ const void *constants;
+ } user;
+
} pt;
boolean flushing;
@@ -157,33 +180,12 @@ struct draw_context
const struct pipe_rasterizer_state *rasterizer;
struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
- unsigned nr_vertex_buffers;
-
- struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
- unsigned nr_vertex_elements;
-
struct draw_vertex_shader *vertex_shader;
boolean identity_viewport;
uint num_vs_outputs; /**< convenience, from vertex_shader */
- /* user-space vertex data, buffers */
- struct {
- const unsigned *edgeflag;
-
- /** vertex element/index buffer (ex: glDrawElements) */
- const void *elts;
- /** bytes per index (0, 1, 2 or 4) */
- unsigned eltSize;
-
- /** vertex arrays */
- const void *vbuffer[PIPE_MAX_ATTRIBS];
-
- /** constant buffer (for vertex shader) */
- const void *constants;
- } user;
/* Clip derived state:
*/
@@ -257,9 +259,6 @@ boolean draw_need_pipeline(const struct draw_context *draw,
void draw_do_flush( struct draw_context *draw, unsigned flags );
-boolean draw_get_edgeflag( struct draw_context *draw,
- unsigned idx );
-
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c
index 965269251f7..9f8e8d3d62e 100644
--- a/src/gallium/auxiliary/draw/draw_pt.c
+++ b/src/gallium/auxiliary/draw/draw_pt.c
@@ -165,3 +165,11 @@ draw_arrays(struct draw_context *draw, unsigned prim,
draw_pt_arrays(draw, prim, start, count);
}
+boolean draw_pt_get_edgeflag( struct draw_context *draw,
+ unsigned idx )
+{
+ if (draw->pt.user.edgeflag)
+ return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
+ else
+ return 1;
+}
diff --git a/src/gallium/auxiliary/draw/draw_pt.h b/src/gallium/auxiliary/draw/draw_pt.h
index eaf8e0374a4..fd0d158fcf7 100644
--- a/src/gallium/auxiliary/draw/draw_pt.h
+++ b/src/gallium/auxiliary/draw/draw_pt.h
@@ -141,13 +141,8 @@ struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *d
/* More helpers:
*/
-void draw_pt_run_pipeline( struct draw_context *draw,
- unsigned prim,
- struct vertex_header *verts,
- unsigned vertex_count,
- unsigned vertex_stride,
- const ushort *elts,
- unsigned count );
+boolean draw_pt_get_edgeflag( struct draw_context *draw,
+ unsigned idx );
/*******************************************************************************
diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c
index d49770e7b2d..2094c081ed4 100644
--- a/src/gallium/auxiliary/draw/draw_pt_elts.c
+++ b/src/gallium/auxiliary/draw/draw_pt_elts.c
@@ -59,7 +59,7 @@ static unsigned elt_vert( const void *elts, unsigned idx )
pt_elt_func draw_pt_elt_func( struct draw_context *draw )
{
- switch (draw->user.eltSize) {
+ switch (draw->pt.user.eltSize) {
case 0: return elt_vert;
case 1: return elt_ubyte;
case 2: return elt_ushort;
@@ -71,9 +71,9 @@ pt_elt_func draw_pt_elt_func( struct draw_context *draw )
const void *draw_pt_elt_ptr( struct draw_context *draw,
unsigned start )
{
- const char *elts = draw->user.elts;
+ const char *elts = draw->pt.user.elts;
- switch (draw->user.eltSize) {
+ switch (draw->pt.user.eltSize) {
case 0:
return (const void *)(((const ubyte *)NULL) + start);
case 1:
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 037e3765dad..c588710b756 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -76,7 +76,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
/* Need to set header->vertex_id = 0xffff somehow.
*/
key.element[nr].input_format = PIPE_FORMAT_R32_FLOAT;
- key.element[nr].input_buffer = draw->nr_vertex_buffers;
+ key.element[nr].input_buffer = draw->pt.nr_vertex_buffers;
key.element[nr].input_offset = 0;
key.element[nr].output_format = PIPE_FORMAT_R32_FLOAT;
key.element[nr].output_offset = dst_offset;
@@ -90,10 +90,10 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
}
- for (i = 0; i < draw->nr_vertex_elements; i++) {
- key.element[nr].input_format = draw->vertex_element[i].src_format;
- key.element[nr].input_buffer = draw->vertex_element[i].vertex_buffer_index;
- key.element[nr].input_offset = draw->vertex_element[i].src_offset;
+ for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
+ key.element[nr].input_format = draw->pt.vertex_element[i].src_format;
+ key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index;
+ key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset;
key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
key.element[nr].output_offset = dst_offset;
@@ -120,7 +120,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
{
static struct vertex_header vh = { 0, 0, 0, 0xffff };
fetch->translate->set_buffer(fetch->translate,
- draw->nr_vertex_buffers,
+ draw->pt.nr_vertex_buffers,
&vh,
0);
}
@@ -139,12 +139,12 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
struct translate *translate = fetch->translate;
unsigned i;
- for (i = 0; i < draw->nr_vertex_buffers; i++) {
+ for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
translate->set_buffer(translate,
i,
- ((char *)draw->user.vbuffer[i] +
- draw->vertex_buffer[i].buffer_offset),
- draw->vertex_buffer[i].pitch );
+ ((char *)draw->pt.user.vbuffer[i] +
+ draw->pt.vertex_buffer[i].buffer_offset),
+ draw->pt.vertex_buffer[i].pitch );
}
translate->run_elts( translate,
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index 6e4fea460b5..1b9b3bfaa68 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -117,7 +117,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
memset(&key, 0, sizeof(key));
for (i = 0; i < vinfo->num_attribs; i++) {
- const struct pipe_vertex_element *src = &draw->vertex_element[vinfo->src_index[i]];
+ const struct pipe_vertex_element *src = &draw->pt.vertex_element[vinfo->src_index[i]];
unsigned emit_sz = 0;
unsigned input_format = src->src_format;
@@ -144,7 +144,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
break;
case EMIT_1F_PSIZE:
input_format = PIPE_FORMAT_R32_FLOAT;
- input_buffer = draw->nr_vertex_buffers;
+ input_buffer = draw->pt.nr_vertex_buffers;
input_offset = 0;
output_format = PIPE_FORMAT_R32_FLOAT;
emit_sz = 1 * sizeof(float);
@@ -179,7 +179,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
feme->translate = translate_create( &key );
feme->translate->set_buffer(feme->translate,
- draw->nr_vertex_buffers,
+ draw->pt.nr_vertex_buffers,
&feme->point_size,
0);
}
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index e1df594035e..881e47d59d1 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -135,7 +135,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->user.constants,
+ (const float (*)[4])draw->pt.user.constants,
fetch_count,
fpme->vertex_size,
fpme->vertex_size);
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index 5561f2b6fb4..b61bb50664f 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -106,7 +106,7 @@ static unsigned add_edgeflag( struct vcache_frontend *vcache,
unsigned idx,
unsigned mask )
{
- if (mask && draw_get_edgeflag(vcache->draw, idx))
+ if (mask && draw_pt_get_edgeflag(vcache->draw, idx))
return idx | DRAW_PT_EDGEFLAG;
else
return idx;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index f0f62246ddc..befcb96bd89 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -611,10 +611,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
* unmap vertex/index buffers
*/
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (draw->vertex_buffer[i].buffer) {
+ if (draw->pt.vertex_buffer[i].buffer) {
pipe->winsys->buffer_unmap(pipe->winsys,
- draw->vertex_buffer[i].buffer);
- pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL);
+ draw->pt.vertex_buffer[i].buffer);
+ pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}