diff options
author | Brian <[email protected]> | 2007-11-08 17:07:12 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-11-08 17:07:12 -0700 |
commit | 64469863212dcc41995c473032856096c4af12b3 (patch) | |
tree | 9b8ff1218b90fbeb3f056cf1713537dddb731c94 /src | |
parent | 990fe4c0bf735206c3cc7346d84adc782595bc3a (diff) |
Reorganize user-space vertex fields in draw_context into 'user' group.
This sub-struct collects the incoming user-provided data/pointers in one place.
Ex: draw->mapped_vbuffer becomes draw->user.vbuffer, etc.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/pipe/draw/draw_context.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_feedback.c | 8 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_prim.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_private.h | 30 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex_cache.c | 19 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex_fetch.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex_shader.c | 4 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex_shader_llvm.c | 4 |
8 files changed, 45 insertions, 32 deletions
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c index 0de8bed5297..4f6392605ec 100644 --- a/src/mesa/pipe/draw/draw_context.c +++ b/src/mesa/pipe/draw/draw_context.c @@ -196,7 +196,7 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw, { draw_flush( draw ); - draw->mapped_vbuffer[attr] = buffer; + draw->user.vbuffer[attr] = buffer; } @@ -206,7 +206,7 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, { draw_flush( draw ); - draw->mapped_constants = buffer; + draw->user.constants = buffer; } @@ -217,8 +217,8 @@ draw_set_mapped_feedback_buffer(struct draw_context *draw, uint index, draw_flush( draw ); assert(index < PIPE_MAX_FEEDBACK_ATTRIBS); - draw->mapped_feedback_buffer[index] = buffer; - draw->mapped_feedback_buffer_size[index] = size; /* in bytes */ + draw->user.feedback_buffer[index] = buffer; + draw->user.feedback_buffer_size[index] = size; /* in bytes */ } diff --git a/src/mesa/pipe/draw/draw_feedback.c b/src/mesa/pipe/draw/draw_feedback.c index ee54db0ad5c..b9906e5b4b0 100644 --- a/src/mesa/pipe/draw/draw_feedback.c +++ b/src/mesa/pipe/draw/draw_feedback.c @@ -128,20 +128,20 @@ static void feedback_begin( struct draw_stage *stage ) vertex_size += feedback->size[i]; } /* compute max number of vertices we can feedback */ - fs->max_vert_emit = stage->draw->mapped_feedback_buffer_size[0] + fs->max_vert_emit = stage->draw->user.feedback_buffer_size[0] / sizeof(float) / vertex_size; - fs->dest[0] = (float *) stage->draw->mapped_feedback_buffer[0]; + fs->dest[0] = (float *) stage->draw->user.feedback_buffer[0]; } else { uint i; uint max = ~0; for (i = 0; i < feedback->num_attribs; i++) { - uint n = stage->draw->mapped_feedback_buffer_size[i] + uint n = stage->draw->user.feedback_buffer_size[i] / sizeof(float) / feedback->size[i]; if (n < max) max = n; - fs->dest[i] = (float *) stage->draw->mapped_feedback_buffer[i]; + fs->dest[i] = (float *) stage->draw->user.feedback_buffer[i]; } fs->max_vert_emit = max; } diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index baae6e98c54..e4a65b9f243 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -64,7 +64,7 @@ static void draw_prim_queue_flush( struct draw_context *draw ) printf("Flushing with %d prims, %d verts\n", draw->pq.queue_nr, draw->vs.queue_nr); - /* Make sure all vertices are available: + /* Make sure all vertices are available/shaded: */ if (draw->vs.queue_nr) draw_vertex_shader_queue_flush(draw); diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h index 89d292901e9..03b48aa93ce 100644 --- a/src/mesa/pipe/draw/draw_private.h +++ b/src/mesa/pipe/draw/draw_private.h @@ -178,17 +178,23 @@ struct draw_context struct pipe_vertex_buffer feedback_buffer[PIPE_ATTRIB_MAX]; struct pipe_vertex_element feedback_element[PIPE_ATTRIB_MAX]; - /** The mapped vertex element/index buffer */ - const void *mapped_elts; - unsigned eltSize; /**< bytes per index (0, 1, 2 or 4) */ - /** The mapped vertex arrays */ - const void *mapped_vbuffer[PIPE_ATTRIB_MAX]; - /** The mapped constant buffers (for vertex shader) */ - const void *mapped_constants; - - /** The mapped vertex element/index buffer */ - void *mapped_feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; - uint mapped_feedback_buffer_size[PIPE_MAX_FEEDBACK_ATTRIBS]; /* in bytes */ + /* user-space vertex data, buffers */ + struct { + /** 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_ATTRIB_MAX]; + + /** constant buffer (for vertex shader) */ + const void *constants; + + /** The vertex feedback buffer */ + void *feedback_buffer[PIPE_MAX_FEEDBACK_ATTRIBS]; + uint feedback_buffer_size[PIPE_MAX_FEEDBACK_ATTRIBS]; /* in bytes */ + } user; /* Clip derived state: */ @@ -216,6 +222,7 @@ struct draw_context struct vertex_header *vertex[VCACHE_SIZE + VCACHE_OVERFLOW]; unsigned overflow; + /** To find space in the vertex cache: */ struct vertex_header *(*get_vertex)( struct draw_context *draw, unsigned i ); } vcache; @@ -233,7 +240,6 @@ struct draw_context /* Prim pipeline queue: */ struct { - /* Need to queue up primitives until their vertices have been * transformed by a vs queue flush. */ diff --git a/src/mesa/pipe/draw/draw_vertex_cache.c b/src/mesa/pipe/draw/draw_vertex_cache.c index 6689907ddfe..29993f14d2f 100644 --- a/src/mesa/pipe/draw/draw_vertex_cache.c +++ b/src/mesa/pipe/draw/draw_vertex_cache.c @@ -51,8 +51,15 @@ void draw_vertex_cache_invalidate( struct draw_context *draw ) } -/* Check if vertex is in cache, otherwise add it. It won't go through +/** + * Check if vertex is in cache, otherwise add it. It won't go through * VS yet, not until there is a flush operation or the VS queue fills up. + * + * Note that cache entries are basically just two pointers: the first + * an index into the user's vertex arrays, the second a location in + * the vertex shader cache for the post-transformed vertex. + * + * \return pointer to location of (post-transformed) vertex header in the cache */ static struct vertex_header *get_vertex( struct draw_context *draw, unsigned i ) @@ -104,7 +111,7 @@ static struct vertex_header *get_vertex( struct draw_context *draw, static struct vertex_header *get_uint_elt_vertex( struct draw_context *draw, unsigned i ) { - const unsigned *elts = (const unsigned *) draw->mapped_elts; + const unsigned *elts = (const unsigned *) draw->user.elts; return get_vertex( draw, elts[i] ); } @@ -112,7 +119,7 @@ static struct vertex_header *get_uint_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, unsigned i ) { - const ushort *elts = (const ushort *) draw->mapped_elts; + const ushort *elts = (const ushort *) draw->user.elts; return get_vertex( draw, elts[i] ); } @@ -120,7 +127,7 @@ static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw, static struct vertex_header *get_ubyte_elt_vertex( struct draw_context *draw, unsigned i ) { - const ubyte *elts = (const ubyte *) draw->mapped_elts; + const ubyte *elts = (const ubyte *) draw->user.elts; return get_vertex( draw, elts[i] ); } @@ -189,7 +196,7 @@ draw_set_mapped_element_buffer( struct draw_context *draw, default: assert(0); } - draw->mapped_elts = elements; - draw->eltSize = eltSize; + draw->user.elts = elements; + draw->user.eltSize = eltSize; } diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c index 5a7e6febe9d..eca10e89fbb 100644 --- a/src/mesa/pipe/draw/draw_vertex_fetch.c +++ b/src/mesa/pipe/draw/draw_vertex_fetch.c @@ -103,7 +103,7 @@ void draw_vertex_fetch( struct draw_context *draw, unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src - = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] + = (const void *) ((const ubyte *) draw->user.vbuffer[buf] + draw->vertex_buffer[buf].buffer_offset + draw->vertex_element[attr].src_offset + elts[j] * draw->vertex_buffer[buf].pitch); diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c index 529ed288eb1..e8801addac3 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader.c +++ b/src/mesa/pipe/draw/draw_vertex_shader.c @@ -93,7 +93,7 @@ run_vertex_program(struct draw_context *draw, == TGSI_SEMANTIC_POSITION); /* Consts does not require 16 byte alignment. */ - machine->Consts = (float (*)[4]) draw->mapped_constants; + machine->Consts = (float (*)[4]) draw->user.constants; machine->Inputs = ALIGN16_ASSIGN(inputs); machine->Outputs = ALIGN16_ASSIGN(outputs); @@ -179,8 +179,8 @@ run_vertex_program(struct draw_context *draw, /** + * Run the vertex shader on all vertices in the vertex queue. * Called by the draw module when the vertx cache needs to be flushed. - * This involves running the vertex shader. */ void draw_vertex_shader_queue_flush( struct draw_context *draw ) { diff --git a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c index c42e9bbd690..4f48db610fe 100644 --- a/src/mesa/pipe/draw/draw_vertex_shader_llvm.c +++ b/src/mesa/pipe/draw/draw_vertex_shader_llvm.c @@ -83,7 +83,7 @@ void vertex_fetch(struct draw_context *draw, unsigned buf = draw->vertex_element[attr].vertex_buffer_index; const void *src - = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf] + = (const void *) ((const ubyte *) draw->user.vbuffer[buf] + draw->vertex_buffer[buf].buffer_offset + draw->vertex_element[attr].src_offset + elt * draw->vertex_buffer[buf].pitch); @@ -124,7 +124,7 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw) struct vertex_header *dests[VS_QUEUE_LENGTH]; float inputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS][4]; float outputs[VS_QUEUE_LENGTH][PIPE_MAX_SHADER_INPUTS][4]; - float (*consts)[4] = (float (*)[4]) draw->mapped_constants; + float (*consts)[4] = (float (*)[4]) draw->user.constants; struct gallivm_prog *prog = draw->vertex_shader->llvm_prog; const float *scale = draw->viewport.scale; const float *trans = draw->viewport.translate; |