summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2008-04-14 12:27:24 -0400
committerZack Rusin <zack@tungstengraphics.com>2008-04-14 12:27:24 -0400
commite3309197855b5caf7c4c167d1e7beedf33ed2fdd (patch)
tree62da46cce8915788cc5a1370c717f9e85a30b4e4
parent871d39ec8c168fa58d8758013e99da63fa58111d (diff)
pass vertex size to shaders so that callee can decide on the size
of the vertices and not always have to use the maximum vertex allocation size for them
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h7
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c3
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_cache.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_shader.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c5
6 files changed, 21 insertions, 12 deletions
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 3042d26847..c8cb96c8ba 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -78,6 +78,7 @@ struct vertex_header {
/* XXX This is too large */
#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
+#define MAX_VERTEX_ALLOCATION ((MAX_VERTEX_SIZE + 0x0f) & ~0x0f)
@@ -152,7 +153,8 @@ struct draw_vertex_shader {
struct draw_context *draw,
const unsigned *elts,
unsigned count,
- void *out );
+ void *out,
+ unsigned vertex_size);
void (*delete)( struct draw_vertex_shader * );
@@ -450,9 +452,8 @@ dot4(const float *a, const float *b)
}
static INLINE struct vertex_header *
-draw_header_from_block(char *block, int num)
+draw_header_from_block(char *block, int size, int num)
{
- static const unsigned size = (MAX_VERTEX_SIZE + 0x0f) & ~0x0f;
return (struct vertex_header*)(block + num * size);
}
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 427128f335..3fa6dcc5e7 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -157,7 +157,8 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
/* Shade
*/
shader->prepare(shader, draw);
- if (shader->run(shader, draw, fetch_elts, fetch_count, pipeline_verts)) {
+ if (shader->run(shader, draw, fetch_elts, fetch_count, pipeline_verts,
+ fpme->pipeline_vertex_size)) {
/* Run the pipeline */
draw_pt_run_pipeline( fpme->draw,
fpme->prim,
diff --git a/src/gallium/auxiliary/draw/draw_vertex_cache.c b/src/gallium/auxiliary/draw/draw_vertex_cache.c
index 9256dec4ea..730c18bcb3 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_cache.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_cache.c
@@ -74,6 +74,7 @@ static struct vertex_header *get_vertex( struct draw_context *draw,
/*debug_printf("HIT %d %d\n", slot, i);*/
assert(draw->vcache.idx[slot].out < draw->vs.queue_nr);
return draw_header_from_block(draw->vs.vertex_cache,
+ MAX_VERTEX_ALLOCATION,
draw->vcache.idx[slot].out);
}
@@ -101,7 +102,8 @@ static struct vertex_header *get_vertex( struct draw_context *draw,
*/
assert(draw->vs.queue_nr < VS_QUEUE_LENGTH);
- header = draw_header_from_block(draw->vs.vertex_cache, out);
+ header = draw_header_from_block(draw->vs.vertex_cache, MAX_VERTEX_ALLOCATION,
+ out);
draw->vs.elts[out] = i;
header->clipmask = 0;
header->edgeflag = draw_get_edgeflag(draw, i);
@@ -113,6 +115,7 @@ static struct vertex_header *get_vertex( struct draw_context *draw,
*/
return draw_header_from_block(draw->vs.vertex_cache,
+ MAX_VERTEX_ALLOCATION,
draw->vcache.idx[slot].out);
}
}
@@ -148,7 +151,8 @@ void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw )
for (i = 0; i < draw->vs.post_nr; i++) {
struct vertex_header * header =
- draw_header_from_block(draw->vs.vertex_cache, i);
+ draw_header_from_block(draw->vs.vertex_cache,
+ MAX_VERTEX_ALLOCATION, i);
header->vertex_id = UNDEFINED_VERTEX_ID;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vertex_shader.c b/src/gallium/auxiliary/draw/draw_vertex_shader.c
index 452d0175c3..8572a6d40c 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_shader.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_shader.c
@@ -60,7 +60,8 @@ draw_vertex_shader_queue_flush(struct draw_context *draw)
unsigned elts[MAX_SHADER_VERTICES];
int j, n = MIN2(MAX_SHADER_VERTICES, draw->vs.queue_nr - i);
struct vertex_header *dests =
- draw_header_from_block(draw->vs.vertex_cache, i);
+ draw_header_from_block(draw->vs.vertex_cache,
+ MAX_VERTEX_ALLOCATION, i);
for (j = 0; j < n; j++) {
elts[j] = draw->vs.elts[i + j];
@@ -73,7 +74,7 @@ draw_vertex_shader_queue_flush(struct draw_context *draw)
assert(n > 0);
assert(n <= MAX_SHADER_VERTICES);
- shader->run(shader, draw, elts, n, dests);
+ shader->run(shader, draw, elts, n, dests, MAX_VERTEX_ALLOCATION);
}
draw->vs.post_nr = draw->vs.queue_nr;
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 27cf060cc9..5c88c2e24e 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -69,7 +69,8 @@ vs_exec_run( struct draw_vertex_shader *shader,
struct draw_context *draw,
const unsigned *elts,
unsigned count,
- void *vOut )
+ void *vOut,
+ unsigned vertex_size)
{
struct tgsi_exec_machine *machine = &draw->machine;
unsigned int i, j;
@@ -107,7 +108,7 @@ vs_exec_run( struct draw_vertex_shader *shader,
unsigned slot;
float x, y, z, w;
struct vertex_header *out =
- draw_header_from_block(vOut, i + j);
+ draw_header_from_block(vOut, vertex_size, i + j);
/* Handle attr[0] (position) specially:
*
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 92b9947e9f..ee0a3105b9 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -83,7 +83,8 @@ vs_sse_run( struct draw_vertex_shader *base,
struct draw_context *draw,
const unsigned *elts,
unsigned count,
- void *vOut )
+ void *vOut,
+ unsigned vertex_size )
{
struct draw_sse_vertex_shader *shader = (struct draw_sse_vertex_shader *)base;
struct tgsi_exec_machine *machine = &draw->machine;
@@ -136,7 +137,7 @@ vs_sse_run( struct draw_vertex_shader *base,
unsigned slot;
float x, y, z, w;
struct vertex_header *out =
- draw_header_from_block(vOut, i + j);
+ draw_header_from_block(vOut, vertex_size, i + j);
x = out->clip[0] = machine->Outputs[0].xyzw[0].f[j];
y = out->clip[1] = machine->Outputs[0].xyzw[1].f[j];