mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 16:50:13 +01:00
draw: make sure constant buffer data is aligned before passing to aos.c
This commit is contained in:
parent
82605d7bcd
commit
bb2e13b9e8
8 changed files with 43 additions and 13 deletions
|
|
@ -217,10 +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 );
|
||||
draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ 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 );
|
||||
|
|
|
|||
|
|
@ -190,6 +190,12 @@ struct draw_context
|
|||
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;
|
||||
struct translate *emit;
|
||||
|
|
@ -225,7 +231,8 @@ 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] );
|
||||
const float (*constants)[4],
|
||||
unsigned size );
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,22 @@
|
|||
|
||||
|
||||
void draw_vs_set_constants( struct draw_context *draw,
|
||||
const float (*constants)[4] )
|
||||
const float (*constants)[4],
|
||||
unsigned size )
|
||||
{
|
||||
if (((unsigned)constants) & 0xf) {
|
||||
if (size > draw->vs.const_storage_size) {
|
||||
if (draw->vs.aligned_constant_storage)
|
||||
align_free(draw->vs.aligned_constant_storage);
|
||||
draw->vs.aligned_constant_storage = align_malloc( size, 16 );
|
||||
}
|
||||
memcpy( draw->vs.aligned_constant_storage,
|
||||
constants,
|
||||
size );
|
||||
constants = draw->vs.aligned_constant_storage;
|
||||
}
|
||||
|
||||
draw->vs.aligned_constants = constants;
|
||||
draw_vs_aos_machine_constants( draw->vs.aos_machine, constants );
|
||||
}
|
||||
|
||||
|
|
@ -159,6 +173,9 @@ draw_vs_destroy( struct draw_context *draw )
|
|||
if (draw->vs.aos_machine)
|
||||
draw_vs_aos_machine_destroy(draw->vs.aos_machine);
|
||||
|
||||
if (draw->vs.aligned_constant_storage)
|
||||
align_free(draw->vs.aligned_constant_storage);
|
||||
|
||||
tgsi_exec_machine_free_data(&draw->vs.machine);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1957,7 +1957,7 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient,
|
|||
struct aos_machine *machine = vaos->draw->vs.aos_machine;
|
||||
|
||||
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
|
||||
machine->constants = (const float (*)[4])vaos->draw->pt.user.constants;
|
||||
machine->constants = vaos->draw->vs.aligned_constants;
|
||||
machine->immediates = vaos->base.vs->immediates;
|
||||
machine->attrib = vaos->attrib;
|
||||
|
||||
|
|
@ -1976,7 +1976,7 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient,
|
|||
struct aos_machine *machine = vaos->draw->vs.aos_machine;
|
||||
|
||||
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
|
||||
machine->constants = (const float (*)[4])vaos->draw->pt.user.constants;
|
||||
machine->constants = vaos->draw->vs.aligned_constants;
|
||||
machine->immediates = vaos->base.vs->immediates;
|
||||
machine->attrib = vaos->attrib;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,9 @@ i915_draw_elements( struct pipe_context *pipe,
|
|||
|
||||
|
||||
draw_set_mapped_constant_buffer(draw,
|
||||
i915->current.constants[PIPE_SHADER_VERTEX]);
|
||||
i915->current.constants[PIPE_SHADER_VERTEX],
|
||||
( i915->current.num_user_constants[PIPE_SHADER_VERTEX] *
|
||||
4 * sizeof(float) ));
|
||||
|
||||
/* draw! */
|
||||
draw_arrays(i915->draw, prim, start, count);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
|
|||
}
|
||||
|
||||
draw_set_mapped_constant_buffer(sp->draw,
|
||||
sp->mapped_constants[PIPE_SHADER_VERTEX]);
|
||||
sp->mapped_constants[PIPE_SHADER_VERTEX],
|
||||
sp->constants[i].size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -68,7 +69,7 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
|
|||
*/
|
||||
draw_flush(sp->draw);
|
||||
|
||||
draw_set_mapped_constant_buffer(sp->draw, NULL);
|
||||
draw_set_mapped_constant_buffer(sp->draw, NULL, 0);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (sp->constants[i].size)
|
||||
|
|
|
|||
|
|
@ -596,9 +596,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
|
|||
|
||||
/* map constant buffers */
|
||||
mapped_constants = pipe_buffer_map(pipe,
|
||||
st->state.constants[PIPE_SHADER_VERTEX].buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
draw_set_mapped_constant_buffer(st->draw, mapped_constants);
|
||||
st->state.constants[PIPE_SHADER_VERTEX].buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
draw_set_mapped_constant_buffer(st->draw, mapped_constants,
|
||||
st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
|
||||
|
||||
|
||||
/* draw here */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue