This remodels things around a buffer object.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23487>
switch (shader_type) {
case PIPE_SHADER_VERTEX:
- draw->pt.user.vs_constants[slot] = buffer;
- draw->pt.user.vs_constants_size[slot] = size;
+ draw->pt.user.vs_constants[slot].ptr = buffer;
+ draw->pt.user.vs_constants[slot].size = size;
break;
case PIPE_SHADER_GEOMETRY:
- draw->pt.user.gs_constants[slot] = buffer;
- draw->pt.user.gs_constants_size[slot] = size;
+ draw->pt.user.gs_constants[slot].ptr = buffer;
+ draw->pt.user.gs_constants[slot].size = size;
break;
case PIPE_SHADER_TESS_CTRL:
- draw->pt.user.tcs_constants[slot] = buffer;
- draw->pt.user.tcs_constants_size[slot] = size;
+ draw->pt.user.tcs_constants[slot].ptr = buffer;
+ draw->pt.user.tcs_constants[slot].size = size;
break;
case PIPE_SHADER_TESS_EVAL:
- draw->pt.user.tes_constants[slot] = buffer;
- draw->pt.user.tes_constants_size[slot] = size;
+ draw->pt.user.tes_constants[slot].ptr = buffer;
+ draw->pt.user.tes_constants[slot].size = size;
break;
default:
assert(0 && "invalid shader type in draw_set_mapped_constant_buffer");
switch (shader_type) {
case PIPE_SHADER_VERTEX:
- draw->pt.user.vs_ssbos[slot] = buffer;
- draw->pt.user.vs_ssbos_size[slot] = size;
+ draw->pt.user.vs_ssbos[slot].ptr = buffer;
+ draw->pt.user.vs_ssbos[slot].size = size;
break;
case PIPE_SHADER_GEOMETRY:
- draw->pt.user.gs_ssbos[slot] = buffer;
- draw->pt.user.gs_ssbos_size[slot] = size;
+ draw->pt.user.gs_ssbos[slot].ptr = buffer;
+ draw->pt.user.gs_ssbos[slot].size = size;
break;
case PIPE_SHADER_TESS_CTRL:
- draw->pt.user.tcs_ssbos[slot] = buffer;
- draw->pt.user.tcs_ssbos_size[slot] = size;
+ draw->pt.user.tcs_ssbos[slot].ptr = buffer;
+ draw->pt.user.tcs_ssbos[slot].size = size;
break;
case PIPE_SHADER_TESS_EVAL:
- draw->pt.user.tes_ssbos[slot] = buffer;
- draw->pt.user.tes_ssbos_size[slot] = size;
+ draw->pt.user.tes_ssbos[slot].ptr = buffer;
+ draw->pt.user.tes_ssbos[slot].size = size;
break;
default:
assert(0 && "invalid shader type in draw_set_mapped_shader_buffer");
static void
tgsi_gs_prepare(struct draw_geometry_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS])
+ const struct draw_buffer_info *constants)
{
struct tgsi_exec_machine *machine = shader->machine;
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
- constants, constants_size);
+ (const struct tgsi_exec_consts_info *)constants);
}
static void
llvm_gs_prepare(struct draw_geometry_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS])
+ const struct draw_buffer_info *constants)
{
}
*/
void
draw_geometry_shader_run(struct draw_geometry_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
}
#endif
- shader->prepare(shader, constants, constants_size);
+ shader->prepare(shader, constants);
if (input_prim->linear)
gs_run(shader, input_prim, input_verts,
float (**p_output)[4]);
void (*prepare)(struct draw_geometry_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS]);
+ const struct draw_buffer_info *constants);
void (*run)(struct draw_geometry_shader *shader,
unsigned input_primitives, unsigned *out_prims);
};
*/
void
draw_geometry_shader_run(struct draw_geometry_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
/* maximum number of shader variants we can cache */
#define DRAW_MAX_SHADER_VARIANTS 512
+struct draw_buffer_info {
+ const void *ptr;
+ unsigned size;
+};
+
/**
* Private context for the drawing module.
*/
struct draw_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
/** constant buffers for each shader stage */
- const void *vs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *tcs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned tcs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *tes_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned tes_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
-
- /** shader buffers for each shader stage */
- const void *vs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned vs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *gs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned gs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *tcs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned tcs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *tes_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned tes_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
+ struct draw_buffer_info vs_constants[PIPE_MAX_CONSTANT_BUFFERS];
+ struct draw_buffer_info gs_constants[PIPE_MAX_CONSTANT_BUFFERS];
+ struct draw_buffer_info tcs_constants[PIPE_MAX_CONSTANT_BUFFERS];
+ struct draw_buffer_info tes_constants[PIPE_MAX_CONSTANT_BUFFERS];
+
+ struct draw_buffer_info vs_ssbos[PIPE_MAX_SHADER_BUFFERS];
+ struct draw_buffer_info gs_ssbos[PIPE_MAX_SHADER_BUFFERS];
+ struct draw_buffer_info tcs_ssbos[PIPE_MAX_SHADER_BUFFERS];
+ struct draw_buffer_info tes_ssbos[PIPE_MAX_SHADER_BUFFERS];
/* pointer to planes */
float (*planes)[DRAW_TOTAL_CLIP_PLANES][4];
static void
draw_vertex_shader_run(struct draw_vertex_shader *vshader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
const struct draw_fetch_info *fetch_info,
const struct draw_vertex_info *input_verts,
struct draw_vertex_info *output_verts)
(const float (*)[4])input_verts->verts->data,
( float (*)[4])output_verts->verts->data,
constants,
- const_size,
input_verts->count,
input_verts->vertex_size,
input_verts->vertex_size,
if (fpme->opt & PT_SHADE) {
draw_vertex_shader_run(vshader,
draw->pt.user.vs_constants,
- draw->pt.user.vs_constants_size,
fetch_info,
vert_info,
&vs_vert_info);
if ((fpme->opt & PT_SHADE) && gshader) {
draw_geometry_shader_run(gshader,
draw->pt.user.gs_constants,
- draw->pt.user.gs_constants_size,
vert_info,
prim_info,
&vshader->info,
static unsigned
-get_num_consts_robust(struct draw_context *draw, unsigned *sizes, unsigned idx)
+get_num_consts_robust(struct draw_context *draw, struct draw_buffer_info *bufs, unsigned idx)
{
- uint64_t const_bytes = sizes[idx];
+ uint64_t const_bytes = bufs[idx].size;
if (const_bytes < sizeof(float))
return 0;
return DIV_ROUND_UP(const_bytes, draw->constant_buffer_stride);
}
-
/**
* Bind/update constant buffer pointers, clip planes and viewport dims.
* These are "light weight" parameters which aren't baked into the
* shader expects 16-byte allocations, the fix is likely to move
* to LOAD intrinsic in the future and remove the vec4 constraint.
*/
- int num_consts = get_num_consts_robust(draw, draw->pt.user.vs_constants_size, i);
- llvm->vs_jit_resources.constants[i].f = draw->pt.user.vs_constants[i];
+ int num_consts = get_num_consts_robust(draw, draw->pt.user.vs_constants, i);
+ llvm->vs_jit_resources.constants[i].f = draw->pt.user.vs_constants[i].ptr;
llvm->vs_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->vs_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->vs_jit_resources.ssbos); ++i) {
- int num_ssbos = draw->pt.user.vs_ssbos_size[i];
- llvm->vs_jit_resources.ssbos[i].u = draw->pt.user.vs_ssbos[i];
+ int num_ssbos = draw->pt.user.vs_ssbos[i].size;
+ llvm->vs_jit_resources.ssbos[i].u = draw->pt.user.vs_ssbos[i].ptr;
llvm->vs_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->vs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_resources.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.gs_constants_size, i);
- llvm->gs_jit_resources.constants[i].f = draw->pt.user.gs_constants[i];
+ int num_consts = get_num_consts_robust(draw, draw->pt.user.gs_constants, i);
+ llvm->gs_jit_resources.constants[i].f = draw->pt.user.gs_constants[i].ptr;
llvm->gs_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->gs_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_resources.ssbos); ++i) {
- int num_ssbos = draw->pt.user.gs_ssbos_size[i];
- llvm->gs_jit_resources.ssbos[i].u = draw->pt.user.gs_ssbos[i];
+ int num_ssbos = draw->pt.user.gs_ssbos[i].size;
+ llvm->gs_jit_resources.ssbos[i].u = draw->pt.user.gs_ssbos[i].ptr;
llvm->gs_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->gs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_resources.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.tcs_constants_size, i);
- llvm->tcs_jit_resources.constants[i].f = draw->pt.user.tcs_constants[i];
+ int num_consts = get_num_consts_robust(draw, draw->pt.user.tcs_constants, i);
+ llvm->tcs_jit_resources.constants[i].f = draw->pt.user.tcs_constants[i].ptr;
llvm->tcs_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->tcs_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_resources.ssbos); ++i) {
- int num_ssbos = draw->pt.user.tcs_ssbos_size[i];
- llvm->tcs_jit_resources.ssbos[i].u = draw->pt.user.tcs_ssbos[i];
+ int num_ssbos = draw->pt.user.tcs_ssbos[i].size;
+ llvm->tcs_jit_resources.ssbos[i].u = draw->pt.user.tcs_ssbos[i].ptr;
llvm->tcs_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->tcs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_resources.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.tes_constants_size, i);
- llvm->tes_jit_resources.constants[i].f = draw->pt.user.tes_constants[i];
+ int num_consts = get_num_consts_robust(draw, draw->pt.user.tes_constants, i);
+ llvm->tes_jit_resources.constants[i].f = draw->pt.user.tes_constants[i].ptr;
llvm->tes_jit_resources.constants[i].num_elements = num_consts;
if (num_consts == 0) {
llvm->tes_jit_resources.constants[i].f = fake_const_buf;
}
}
for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_resources.ssbos); ++i) {
- int num_ssbos = draw->pt.user.tes_ssbos_size[i];
- llvm->tes_jit_resources.ssbos[i].u = draw->pt.user.tes_ssbos[i];
+ int num_ssbos = draw->pt.user.tes_ssbos[i].size;
+ llvm->tes_jit_resources.ssbos[i].u = draw->pt.user.tes_ssbos[i].ptr;
llvm->tes_jit_resources.ssbos[i].num_elements = num_ssbos;
if (num_ssbos == 0) {
llvm->tes_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf;
struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
draw_geometry_shader_run(gshader,
draw->pt.user.gs_constants,
- draw->pt.user.gs_constants_size,
vert_info,
prim_info,
tes_shader ? &tes_shader->info : &vshader->info,
void (*run_linear)(struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
unsigned count,
unsigned input_stride,
unsigned output_stride,
vs_exec_run_linear(struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
unsigned count,
unsigned input_stride,
unsigned output_stride,
assert(!shader->draw->llvm);
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
- constants, const_size);
+ (const struct tgsi_exec_consts_info *)constants);
if (shader->info.uses_instanceid) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INSTANCEID];
vs_llvm_run_linear(struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
unsigned count,
unsigned input_stride,
unsigned output_stride,
temp_buffer,
temp_buffer,
vsvg->base.vs->draw->pt.user.vs_constants,
- vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
temp_vertex_stride, NULL);
temp_buffer,
temp_buffer,
vsvg->base.vs->draw->pt.user.vs_constants,
- vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
temp_vertex_stride, NULL);
void
tgsi_exec_set_constant_buffers(struct tgsi_exec_machine *mach,
unsigned num_bufs,
- const void **bufs,
- const unsigned *buf_sizes)
+ const struct tgsi_exec_consts_info *bufs)
{
unsigned i;
for (i = 0; i < num_bufs; i++) {
- mach->Consts[i] = bufs[i];
- mach->ConstsSize[i] = buf_sizes[i];
+ mach->Consts[i] = bufs[i].ptr;
+ mach->ConstsSize[i] = bufs[i].size;
}
}
uint ReturnAddr;
};
+/* should match draw_buffer_info */
+struct tgsi_exec_consts_info {
+ const void *ptr;
+ unsigned size;
+};
/* Switch-case block state. */
struct tgsi_switch_record {
extern void
tgsi_exec_set_constant_buffers(struct tgsi_exec_machine *mach,
unsigned num_bufs,
- const void **bufs,
- const unsigned *buf_sizes);
+ const struct tgsi_exec_consts_info *bufs);
static inline int
(struct tgsi_image *)softpipe->tgsi.image[PIPE_SHADER_COMPUTE],
(struct tgsi_buffer *)softpipe->tgsi.buffer[PIPE_SHADER_COMPUTE]);
tgsi_exec_set_constant_buffers(machines[idx], PIPE_MAX_CONSTANT_BUFFERS,
- softpipe->mapped_constants[PIPE_SHADER_COMPUTE],
- softpipe->const_buffer_size[PIPE_SHADER_COMPUTE]);
+ softpipe->mapped_constants[PIPE_SHADER_COMPUTE]);
idx++;
}
}
#include "sp_quad_pipe.h"
#include "sp_setup.h"
+#include "tgsi/tgsi_exec.h"
struct softpipe_vbuf_render;
struct draw_context;
ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
/** Mapped constant buffers */
- const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
- unsigned const_buffer_size[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
+ struct tgsi_exec_consts_info mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
/** Vertex format */
struct sp_setup_info setup_info;
unsigned i, nr_quads = 0;
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
- softpipe->mapped_constants[PIPE_SHADER_FRAGMENT],
- softpipe->const_buffer_size[PIPE_SHADER_FRAGMENT]);
+ softpipe->mapped_constants[PIPE_SHADER_FRAGMENT]);
machine->InterpCoefs = quads[0]->coef;
draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
}
- softpipe->mapped_constants[shader][index] = data;
- softpipe->const_buffer_size[shader][index] = size;
+ softpipe->mapped_constants[shader][index].ptr = data;
+ softpipe->mapped_constants[shader][index].size = size;
softpipe->dirty |= SP_NEW_CONSTANTS;