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 );
}
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 );
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;
const struct pipe_viewport_state * );
void draw_vs_set_constants( struct draw_context *,
- const float (*constants)[4] );
+ const float (*constants)[4],
+ unsigned size );
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 );
}
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);
}
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;
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;
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);
}
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
*/
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)
/* 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 */