void
draw_set_mapped_constant_buffer(struct draw_context *draw,
unsigned shader_type,
+ unsigned slot,
const void *buffer,
unsigned size )
{
debug_assert(shader_type == PIPE_SHADER_VERTEX ||
shader_type == PIPE_SHADER_GEOMETRY);
+ debug_assert(slot < PIPE_MAX_CONSTANT);
+
if (shader_type == PIPE_SHADER_VERTEX) {
- draw->pt.user.vs_constants = buffer;
- draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+ draw->pt.user.vs_constants[slot] = buffer;
+ draw_vs_set_constants(draw, slot, buffer, size);
} else if (shader_type == PIPE_SHADER_GEOMETRY) {
- draw->pt.user.gs_constants = buffer;
- draw_gs_set_constants( draw, (const float (*)[4])buffer, size );
+ draw->pt.user.gs_constants[slot] = buffer;
+ draw_gs_set_constants(draw, slot, buffer, size);
}
}
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,
- unsigned shader_type,
- const void *buffer,
- unsigned size );
+void
+draw_set_mapped_constant_buffer(struct draw_context *draw,
+ unsigned shader_type,
+ unsigned slot,
+ const void *buffer,
+ unsigned size);
/***********************************************************************
tgsi_exec_machine_destroy(draw->gs.machine);
}
-void draw_gs_set_constants( struct draw_context *draw,
- const float (*constants)[4],
- unsigned size )
+void
+draw_gs_set_constants(struct draw_context *draw,
+ unsigned slot,
+ const void *constants,
+ unsigned size)
{
}
void draw_geometry_shader_run(struct draw_geometry_shader *shader,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned vertex_size)
unsigned num_primitives = count/num_vertices;
unsigned inputs_from_vs = 0;
- machine->Consts[0] = constants;
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ machine->Consts[i] = constants[i];
+ }
for (i = 0; i < shader->info.num_inputs; ++i) {
if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID)
void draw_geometry_shader_run(struct draw_geometry_shader *shader,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride);
const void *vbuffer[PIPE_MAX_ATTRIBS];
/** constant buffer (for vertex/geometry shader) */
- const void *vs_constants;
- const void *gs_constants;
+ const void *vs_constants[PIPE_MAX_CONSTANT];
+ const void *gs_constants[PIPE_MAX_CONSTANT];
} user;
boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */
struct aos_machine *aos_machine;
- const float (*aligned_constants)[4];
+ const void *aligned_constants[PIPE_MAX_CONSTANT];
- const float (*aligned_constant_storage)[4];
- unsigned const_storage_size;
+ const void *aligned_constant_storage[PIPE_MAX_CONSTANT];
+ unsigned const_storage_size[PIPE_MAX_CONSTANT];
struct translate *fetch;
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],
- unsigned size );
+void
+draw_vs_set_constants(struct draw_context *,
+ unsigned slot,
+ const void *constants,
+ unsigned size);
* Geometry shading code:
*/
boolean draw_gs_init( struct draw_context *draw );
-void draw_gs_set_constants( struct draw_context *,
- const float (*constants)[4],
- unsigned size );
+
+void
+draw_gs_set_constants(struct draw_context *,
+ unsigned slot,
+ const void *constants,
+ unsigned size);
+
void draw_gs_destroy( struct draw_context *draw );
/*******************************************************************************
vshader->run_linear(vshader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.vs_constants,
+ draw->pt.user.vs_constants,
fetch_count,
fpme->vertex_size,
fpme->vertex_size);
draw_geometry_shader_run(gshader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.gs_constants,
+ draw->pt.user.gs_constants,
fetch_count,
fpme->vertex_size,
fpme->vertex_size);
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.vs_constants,
+ draw->pt.user.vs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
draw_geometry_shader_run(geometry_shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.gs_constants,
+ draw->pt.user.gs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
shader->run_linear(shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.vs_constants,
+ draw->pt.user.vs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
draw_geometry_shader_run(geometry_shader,
(const float (*)[4])pipeline_verts->data,
( float (*)[4])pipeline_verts->data,
- (const float (*)[4])draw->pt.user.gs_constants,
+ draw->pt.user.gs_constants,
count,
fpme->vertex_size,
fpme->vertex_size);
-void draw_vs_set_constants( struct draw_context *draw,
- const float (*constants)[4],
- unsigned size )
+void
+draw_vs_set_constants(struct draw_context *draw,
+ unsigned slot,
+ const void *constants,
+ unsigned size)
{
if (((uintptr_t)constants) & 0xf) {
- if (size > draw->vs.const_storage_size) {
- if (draw->vs.aligned_constant_storage)
- align_free((void *)draw->vs.aligned_constant_storage);
- draw->vs.aligned_constant_storage = align_malloc( size, 16 );
+ if (size > draw->vs.const_storage_size[slot]) {
+ if (draw->vs.aligned_constant_storage[slot]) {
+ align_free((void *)draw->vs.aligned_constant_storage[slot]);
+ }
+ draw->vs.aligned_constant_storage[slot] = align_malloc(size, 16);
}
- memcpy( (void*)draw->vs.aligned_constant_storage,
- constants,
- size );
- constants = draw->vs.aligned_constant_storage;
+ memcpy((void *)draw->vs.aligned_constant_storage[slot],
+ constants,
+ size);
+ constants = draw->vs.aligned_constant_storage[slot];
}
-
- draw->vs.aligned_constants = constants;
- draw_vs_aos_machine_constants( draw->vs.aos_machine, constants );
+
+ draw->vs.aligned_constants[slot] = constants;
+ draw_vs_aos_machine_constants(draw->vs.aos_machine, slot, constants);
}
void
draw_vs_destroy( struct draw_context *draw )
{
+ uint i;
+
if (draw->vs.fetch_cache)
translate_cache_destroy(draw->vs.fetch_cache);
if (draw->vs.aos_machine)
draw_vs_aos_machine_destroy(draw->vs.aos_machine);
- if (draw->vs.aligned_constant_storage)
- align_free((void*)draw->vs.aligned_constant_storage);
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ if (draw->vs.aligned_constant_storage[i]) {
+ align_free((void *)draw->vs.aligned_constant_storage[i]);
+ }
+ }
tgsi_exec_machine_destroy(draw->vs.machine);
}
void (*run_linear)( struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride );
struct aos_machine *draw_vs_aos_machine( void );
void draw_vs_aos_machine_destroy( struct aos_machine *machine );
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
- const float (*constants)[4] );
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+ unsigned slot,
+ const void *constants);
void draw_vs_aos_machine_viewport( struct aos_machine *machine,
const struct pipe_viewport_state *viewport );
{
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
struct aos_machine *machine = vaos->draw->vs.aos_machine;
+ unsigned i;
if (0) debug_printf("%s %d\n", __FUNCTION__, count);
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
- machine->constants = vaos->draw->vs.aligned_constants;
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ machine->constants[i] = vaos->draw->vs.aligned_constants[i];
+ }
machine->immediates = vaos->base.vs->immediates;
machine->buffer = vaos->buffer;
{
struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
struct aos_machine *machine = vaos->draw->vs.aos_machine;
+ unsigned i;
if (0) debug_printf("%s %d %d const: %x\n", __FUNCTION__, start, count,
vaos->base.key.const_vbuffers);
machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
- machine->constants = vaos->draw->vs.aligned_constants;
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ machine->constants[i] = vaos->draw->vs.aligned_constants[i];
+ }
machine->immediates = vaos->base.vs->immediates;
machine->buffer = vaos->buffer;
ushort fpucntl; /* one of FPU_* above */
const float (*immediates)[4]; /* points to shader data */
- const float (*constants)[4]; /* points to draw data */
+ const void *constants[PIPE_MAX_CONSTANT]; /* points to draw data */
const struct aos_buffer *buffer; /* points to ? */
};
}
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
- const float (*constants)[4] )
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+ unsigned slot,
+ const void *constants)
{
- machine->constants = constants;
+ machine->constants[slot] = constants;
{
unsigned i;
{
}
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
- const float (*constants)[4] )
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+ unsigned slot,
+ const void *constants)
{
}
vs_exec_run_linear( struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride )
unsigned int i, j;
unsigned slot;
- machine->Consts[0] = constants;
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ machine->Consts[i] = constants[i];
+ }
for (i = 0; i < count; i += MAX_TGSI_VERTICES) {
unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i);
vs_llvm_run_linear( struct draw_vertex_shader *base,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride )
gallivm_cpu_vs_exec(shader->llvm_prog, shader->machine,
input, base->info.num_inputs, output, base->info.num_outputs,
- constants, count, input_stride, output_stride);
+ (const float (*)[4])constants[0],
+ count, input_stride, output_stride);
}
vs_ppc_run_linear( struct draw_vertex_shader *base,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride )
*/
shader->func(inputs_soa, outputs_soa, temps_soa,
(float (*)[4]) shader->base.immediates,
- (float (*)[4]) constants,
+ (const float (*)[4])constants[0],
ppc_builtin_constants);
/* convert (up to) four output verts from SoA back to AoS format */
vs_sse_run_linear( struct draw_vertex_shader *base,
const float (*input)[4],
float (*output)[4],
- const float (*constants)[4],
+ const void *constants[PIPE_MAX_CONSTANT],
unsigned count,
unsigned input_stride,
unsigned output_stride )
/* run compiled shader
*/
shader->func(machine,
- constants,
+ (const float (*)[4])constants[0],
shader->base.immediates,
input,
base->info.num_inputs,
vsvg->base.vs->run_linear( vsvg->base.vs,
temp_buffer,
temp_buffer,
- (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
+ vsvg->base.vs->draw->pt.user.vs_constants,
count,
temp_vertex_stride,
temp_vertex_stride);
vsvg->base.vs->run_linear( vsvg->base.vs,
temp_buffer,
temp_buffer,
- (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
+ vsvg->base.vs->draw->pt.user.vs_constants,
count,
temp_vertex_stride,
temp_vertex_stride);
}
}
- draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, 0,
sp->mapped_constants[PIPE_SHADER_VERTEX],
sp->constants[PIPE_SHADER_VERTEX]->size);
}
}
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
i915->current.constants[PIPE_SHADER_VERTEX],
(i915->current.num_user_constants[PIPE_SHADER_VERTEX] *
4 * sizeof(float)));
}
if(shader == PIPE_SHADER_VERTEX) {
- draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, 0,
data, size);
}
draw_set_mapped_element_buffer(draw, 0, NULL);
}
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
nv04->constbuf[PIPE_SHADER_VERTEX],
nv04->constbuf_nr[PIPE_SHADER_VERTEX]);
draw_set_mapped_constant_buffer(draw,
PIPE_SHADER_VERTEX,
+ 0,
nv10->constbuf[PIPE_SHADER_VERTEX],
nv10->constbuf_nr[PIPE_SHADER_VERTEX]);
draw_set_mapped_element_buffer(draw, 0, NULL);
}
- draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
nv20->constbuf[PIPE_SHADER_VERTEX],
nv20->constbuf_nr[PIPE_SHADER_VERTEX]);
map = pipe_buffer_map(pscreen,
nv40->constbuf[PIPE_SHADER_VERTEX],
PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX, 0,
map, nr);
}
draw_set_mapped_constant_buffer(r300->draw,
PIPE_SHADER_VERTEX,
+ 0,
r300->shader_constants[PIPE_SHADER_VERTEX].constants,
r300->shader_constants[PIPE_SHADER_VERTEX].count *
(sizeof(float) * 4));
draw_set_mapped_constant_buffer(r300->draw,
PIPE_SHADER_VERTEX,
+ 0,
r300->shader_constants[PIPE_SHADER_VERTEX].constants,
r300->shader_constants[PIPE_SHADER_VERTEX].count *
(sizeof(float) * 4));
softpipe_map_constant_buffers(struct softpipe_context *sp)
{
struct pipe_winsys *ws = sp->pipe.winsys;
- uint i, vssize, gssize;
+ uint i;
for (i = 0; i < PIPE_SHADER_TYPES; i++) {
uint j;
}
}
- if (sp->constants[PIPE_SHADER_VERTEX][0])
- vssize = sp->constants[PIPE_SHADER_VERTEX][0]->size;
- else
- vssize = 0;
-
- if (sp->constants[PIPE_SHADER_GEOMETRY][0])
- gssize = sp->constants[PIPE_SHADER_GEOMETRY][0]->size;
- else
- gssize = 0;
-
- draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
- sp->mapped_constants[PIPE_SHADER_VERTEX][0],
- vssize);
- draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY,
- sp->mapped_constants[PIPE_SHADER_GEOMETRY][0],
- gssize);
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ if (sp->constants[PIPE_SHADER_VERTEX][i]) {
+ draw_set_mapped_constant_buffer(sp->draw,
+ PIPE_SHADER_VERTEX,
+ i,
+ sp->mapped_constants[PIPE_SHADER_VERTEX][i],
+ sp->constants[PIPE_SHADER_VERTEX][i]->size);
+ }
+ if (sp->constants[PIPE_SHADER_GEOMETRY][i]) {
+ draw_set_mapped_constant_buffer(sp->draw,
+ PIPE_SHADER_GEOMETRY,
+ i,
+ sp->mapped_constants[PIPE_SHADER_GEOMETRY][i],
+ sp->constants[PIPE_SHADER_GEOMETRY][i]->size);
+ }
+ }
}
*/
draw_flush(sp->draw);
- draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, NULL, 0);
- draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, NULL, 0);
+ for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+ draw_set_mapped_constant_buffer(sp->draw,
+ PIPE_SHADER_VERTEX,
+ i,
+ NULL,
+ 0);
+ draw_set_mapped_constant_buffer(sp->draw,
+ PIPE_SHADER_GEOMETRY,
+ i,
+ NULL,
+ 0);
+ }
for (i = 0; i < PIPE_SHADER_TYPES; i++) {
uint j;
PIPE_BUFFER_USAGE_CPU_READ);
assert(map);
draw_set_mapped_constant_buffer(
- draw, PIPE_SHADER_VERTEX,
+ draw, PIPE_SHADER_VERTEX, 0,
map,
svga->curr.cb[PIPE_SHADER_VERTEX]->size);
}
mapped_constants = pipe_buffer_map(pipe->screen,
st->state.constants[PIPE_SHADER_VERTEX],
PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX,
+ draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0,
mapped_constants,
st->state.constants[PIPE_SHADER_VERTEX]->size);