mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 14:28:05 +02:00
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
This commit is contained in:
parent
871d39ec8c
commit
e330919785
6 changed files with 21 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue