summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-06-16 10:17:56 +1000
committerTimothy Arceri <[email protected]>2018-03-20 14:17:33 +1100
commitedded1237607348683f492db313e823dc2e380c3 (patch)
tree1fb861be1d324eb309fbef50e6b353dfff4a0c83
parentb13b9eb432a3b67efb29ca25c3e244b467c3c4af (diff)
mesa: rework ParameterList to allow packing
Currently everything is padded to 4 components. Making the list more flexible will allow us to do uniform packing. V2 (suggestions from Nicolai): - always pass existing calls to _mesa_add_parameter() true for padd_and_align - fix bindless param value offsets - remove left over wip logic from pad and align code - zero out param value padding - whitespace fix Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/compiler/glsl/serialize.cpp14
-rw-r--r--src/mesa/drivers/dri/i915/i915_fragprog.c9
-rw-r--r--src/mesa/drivers/dri/i965/gen6_constant_state.c3
-rw-r--r--src/mesa/drivers/dri/r200/r200_vertprog.c10
-rw-r--r--src/mesa/main/uniform_query.cpp14
-rw-r--r--src/mesa/program/ir_to_mesa.cpp9
-rw-r--r--src/mesa/program/prog_execute.c6
-rw-r--r--src/mesa/program/prog_opt_constant_fold.c3
-rw-r--r--src/mesa/program/prog_parameter.c52
-rw-r--r--src/mesa/program/prog_parameter.h9
-rw-r--r--src/mesa/program/prog_parameter_layout.c21
-rw-r--r--src/mesa/program/prog_print.c4
-rw-r--r--src/mesa/program/prog_statevars.c3
-rw-r--r--src/mesa/program/prog_to_nir.c3
-rw-r--r--src/mesa/program/program_parse.y2
-rw-r--r--src/mesa/state_tracker/st_atifs_to_tgsi.c6
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c5
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp4
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c8
19 files changed, 125 insertions, 60 deletions
diff --git a/src/compiler/glsl/serialize.cpp b/src/compiler/glsl/serialize.cpp
index 1fdbaa990f4..727822633df 100644
--- a/src/compiler/glsl/serialize.cpp
+++ b/src/compiler/glsl/serialize.cpp
@@ -950,6 +950,7 @@ write_shader_parameters(struct blob *metadata,
struct gl_program_parameter_list *params)
{
blob_write_uint32(metadata, params->NumParameters);
+ blob_write_uint32(metadata, params->NumParameterValues);
uint32_t i = 0;
while (i < params->NumParameters) {
@@ -966,7 +967,10 @@ write_shader_parameters(struct blob *metadata,
}
blob_write_bytes(metadata, params->ParameterValues,
- sizeof(gl_constant_value) * 4 * params->NumParameters);
+ sizeof(gl_constant_value) * params->NumParameterValues);
+
+ blob_write_bytes(metadata, params->ParameterValueOffset,
+ sizeof(uint32_t) * params->NumParameters);
blob_write_uint32(metadata, params->StateFlags);
}
@@ -978,6 +982,7 @@ read_shader_parameters(struct blob_reader *metadata,
gl_state_index16 state_indexes[STATE_LENGTH];
uint32_t i = 0;
uint32_t num_parameters = blob_read_uint32(metadata);
+ uint32_t num_parameters_values = blob_read_uint32(metadata);
_mesa_reserve_parameter_storage(params, num_parameters);
while (i < num_parameters) {
@@ -989,13 +994,16 @@ read_shader_parameters(struct blob_reader *metadata,
sizeof(state_indexes));
_mesa_add_parameter(params, type, name, size, data_type,
- NULL, state_indexes);
+ NULL, state_indexes, false);
i++;
}
blob_copy_bytes(metadata, (uint8_t *) params->ParameterValues,
- sizeof(gl_constant_value) * 4 * params->NumParameters);
+ sizeof(gl_constant_value) * num_parameters_values);
+
+ blob_copy_bytes(metadata, (uint8_t *) params->ParameterValueOffset,
+ sizeof(uint32_t) * num_parameters);
params->StateFlags = blob_read_uint32(metadata);
}
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c
index 2e043195121..6493ab99b1e 100644
--- a/src/mesa/drivers/dri/i915/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -184,11 +184,12 @@ src_vector(struct i915_fragment_program *p,
*/
case PROGRAM_CONSTANT:
case PROGRAM_STATE_VAR:
- case PROGRAM_UNIFORM:
- src = i915_emit_param4fv(p,
- &program->Parameters->ParameterValues[source->Index][0].f);
+ case PROGRAM_UNIFORM: {
+ struct gl_program_parameter_list *params = program->Parameters;
+ unsigned offset = params->ParameterValueOffset[source->Index];
+ src = i915_emit_param4fv(p, &params->ParameterValues[offset].f);
break;
-
+ }
default:
i915_program_error(p, "Bad source->File: %d", source->File);
return 0;
diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
index afcd2bebd76..919aee49ade 100644
--- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
@@ -68,9 +68,10 @@ brw_param_value(struct brw_context *brw,
case BRW_PARAM_DOMAIN_PARAMETER: {
unsigned idx = BRW_PARAM_PARAMETER_IDX(param);
+ unsigned offset = prog->Parameters->ParameterValueOffset[idx];
unsigned comp = BRW_PARAM_PARAMETER_COMP(param);
assert(idx < prog->Parameters->NumParameters);
- return prog->Parameters->ParameterValues[idx][comp].u;
+ return prog->Parameters->ParameterValues[offset + comp].u;
}
case BRW_PARAM_DOMAIN_UNIFORM: {
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c
index 8599e478815..f69f4a0a1e2 100644
--- a/src/mesa/drivers/dri/r200/r200_vertprog.c
+++ b/src/mesa/drivers/dri/r200/r200_vertprog.c
@@ -120,14 +120,16 @@ static GLboolean r200VertexProgUpdateParams(struct gl_context *ctx, struct r200_
}
for(pi = 0; pi < paramList->NumParameters; pi++) {
+ unsigned pvo = paramList->ParameterValueOffset[pi];
+
switch(paramList->Parameters[pi].Type) {
case PROGRAM_STATE_VAR:
//fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
case PROGRAM_CONSTANT:
- *fcmd++ = paramList->ParameterValues[pi][0].f;
- *fcmd++ = paramList->ParameterValues[pi][1].f;
- *fcmd++ = paramList->ParameterValues[pi][2].f;
- *fcmd++ = paramList->ParameterValues[pi][3].f;
+ *fcmd++ = paramList->ParameterValues[pvo + 0].f;
+ *fcmd++ = paramList->ParameterValues[pvo + 1].f;
+ *fcmd++ = paramList->ParameterValues[pvo + 2].f;
+ *fcmd++ = paramList->ParameterValues[pvo + 3].f;
break;
default:
_mesa_problem(NULL, "Bad param type in %s", __func__);
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index a48b6d29218..52b04c92434 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -723,13 +723,15 @@ log_program_parameters(const struct gl_shader_program *shProg)
printf("Program %d %s shader parameters:\n",
shProg->Name, _mesa_shader_stage_to_string(i));
for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) {
- printf("%s: %p %f %f %f %f\n",
+ unsigned pvo = prog->Parameters->ParameterValueOffset[j];
+ printf("%s: %u %p %f %f %f %f\n",
prog->Parameters->Parameters[j].Name,
- prog->Parameters->ParameterValues[j],
- prog->Parameters->ParameterValues[j][0].f,
- prog->Parameters->ParameterValues[j][1].f,
- prog->Parameters->ParameterValues[j][2].f,
- prog->Parameters->ParameterValues[j][3].f);
+ pvo,
+ prog->Parameters->ParameterValues + pvo,
+ prog->Parameters->ParameterValues[pvo].f,
+ prog->Parameters->ParameterValues[pvo + 1].f,
+ prog->Parameters->ParameterValues[pvo + 2].f,
+ prog->Parameters->ParameterValues[pvo + 3].f);
}
}
fflush(stdout);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 29025d1c177..f26eddc9000 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2452,7 +2452,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
for (unsigned i = 0; i < num_params; i++) {
unsigned comps = 4;
_mesa_add_parameter(params, PROGRAM_UNIFORM, name, comps,
- type->gl_type, NULL, NULL);
+ type->gl_type, NULL, NULL, true);
}
/* The first part of the uniform that's processed determines the base
@@ -2582,9 +2582,10 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
break;
}
+ unsigned pvo = params->ParameterValueOffset[i];
_mesa_uniform_attach_driver_storage(storage, dmul * columns, dmul,
format,
- &params->ParameterValues[i]);
+ &params->ParameterValues[pvo]);
/* When a bindless sampler/image is bound to a texture/image unit, we
* have to overwrite the constant value by the resident handle
@@ -2601,11 +2602,11 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
if (storage->type->without_array()->is_sampler()) {
assert(unit >= 0 && unit < prog->sh.NumBindlessSamplers);
prog->sh.BindlessSamplers[unit].data =
- &params->ParameterValues[i] + j;
+ &params->ParameterValues[pvo] + 4 * j;
} else if (storage->type->without_array()->is_image()) {
assert(unit >= 0 && unit < prog->sh.NumBindlessImages);
prog->sh.BindlessImages[unit].data =
- &params->ParameterValues[i] + j;
+ &params->ParameterValues[pvo] + 4 * j;
}
}
}
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index 2c77538c2af..b5a7a692aeb 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -117,11 +117,13 @@ get_src_register_pointer(const struct prog_src_register *source,
/* Fallthrough */
case PROGRAM_CONSTANT:
/* Fallthrough */
- case PROGRAM_UNIFORM:
+ case PROGRAM_UNIFORM: {
if (reg >= (GLint) prog->Parameters->NumParameters)
return ZeroVec;
- return (GLfloat *) prog->Parameters->ParameterValues[reg];
+ unsigned pvo = prog->Parameters->ParameterValueOffset[reg];
+ return (GLfloat *) prog->Parameters->ParameterValues + pvo;
+ }
case PROGRAM_SYSTEM_VALUE:
assert(reg < (GLint) ARRAY_SIZE(machine->SystemValues));
return machine->SystemValues[reg];
diff --git a/src/mesa/program/prog_opt_constant_fold.c b/src/mesa/program/prog_opt_constant_fold.c
index ba4a954186a..638bdbd1507 100644
--- a/src/mesa/program/prog_opt_constant_fold.c
+++ b/src/mesa/program/prog_opt_constant_fold.c
@@ -90,8 +90,9 @@ src_regs_are_same(const struct prog_src_register *a,
static void
get_value(struct gl_program *prog, struct prog_src_register *r, float *data)
{
+ unsigned pvo = prog->Parameters->ParameterValueOffset[r->Index];
const gl_constant_value *const value =
- prog->Parameters->ParameterValues[r->Index];
+ prog->Parameters->ParameterValues + pvo;
data[0] = value[GET_SWZ(r->Swizzle, 0)].f;
data[1] = value[GET_SWZ(r->Swizzle, 1)].f;
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 6b6599d7453..af9bb37cd5c 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -66,11 +66,13 @@ lookup_parameter_constant(const struct gl_program_parameter_list *list,
for (i = 0; i < list->NumParameters; i++) {
if (list->Parameters[i].Type == PROGRAM_CONSTANT) {
+ unsigned offset = list->ParameterValueOffset[i];
+
if (!swizzleOut) {
/* swizzle not allowed */
GLuint j, match = 0;
for (j = 0; j < vSize; j++) {
- if (v[j].u == list->ParameterValues[i][j].u)
+ if (v[j].u == list->ParameterValues[offset + j].u)
match++;
}
if (match == vSize) {
@@ -84,7 +86,7 @@ lookup_parameter_constant(const struct gl_program_parameter_list *list,
/* look for v[0] anywhere within float[4] value */
GLuint j;
for (j = 0; j < list->Parameters[i].Size; j++) {
- if (list->ParameterValues[i][j].u == v[0].u) {
+ if (list->ParameterValues[offset + j].u == v[0].u) {
/* found it */
*posOut = i;
*swizzleOut = MAKE_SWIZZLE4(j, j, j, j);
@@ -97,13 +99,13 @@ lookup_parameter_constant(const struct gl_program_parameter_list *list,
GLuint swz[4];
GLuint match = 0, j, k;
for (j = 0; j < vSize; j++) {
- if (v[j].u == list->ParameterValues[i][j].u) {
+ if (v[j].u == list->ParameterValues[offset + j].u) {
swz[j] = j;
match++;
}
else {
for (k = 0; k < list->Parameters[i].Size; k++) {
- if (v[j].u == list->ParameterValues[i][k].u) {
+ if (v[j].u == list->ParameterValues[offset + k].u) {
swz[j] = k;
match++;
break;
@@ -149,7 +151,9 @@ _mesa_new_parameter_list_sized(unsigned size)
p->Parameters = (struct gl_program_parameter *)
calloc(size, sizeof(struct gl_program_parameter));
- p->ParameterValues = (gl_constant_value (*)[4])
+ p->ParameterValueOffset = (unsigned *) calloc(size, sizeof(unsigned));
+
+ p->ParameterValues = (gl_constant_value *)
_mesa_align_malloc(size * 4 *sizeof(gl_constant_value), 16);
@@ -203,7 +207,11 @@ _mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
realloc(paramList->Parameters,
paramList->Size * sizeof(struct gl_program_parameter));
- paramList->ParameterValues = (gl_constant_value (*)[4])
+ paramList->ParameterValueOffset =
+ realloc(paramList->ParameterValueOffset,
+ paramList->Size * sizeof(unsigned));
+
+ paramList->ParameterValues = (gl_constant_value *)
_mesa_align_realloc(paramList->ParameterValues, /* old buf */
oldNum * 4 * sizeof(gl_constant_value),/* old sz */
paramList->Size*4*sizeof(gl_constant_value),/*new*/
@@ -232,14 +240,17 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
gl_register_file type, const char *name,
GLuint size, GLenum datatype,
const gl_constant_value *values,
- const gl_state_index16 state[STATE_LENGTH])
+ const gl_state_index16 state[STATE_LENGTH],
+ bool pad_and_align)
{
assert(0 < size && size <=4);
const GLuint oldNum = paramList->NumParameters;
+ unsigned oldValNum = pad_and_align ?
+ align(paramList->NumParameterValues, 4) : paramList->NumParameterValues;
_mesa_reserve_parameter_storage(paramList, 1);
- if (!paramList->Parameters ||
+ if (!paramList->Parameters || !paramList->ParameterValueOffset ||
!paramList->ParameterValues) {
/* out of memory */
paramList->NumParameters = 0;
@@ -249,6 +260,9 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
paramList->NumParameters = oldNum + 1;
+ unsigned pad = pad_and_align ? align(size, 4) : size;
+ paramList->NumParameterValues = oldValNum + pad;
+
memset(&paramList->Parameters[oldNum], 0,
sizeof(struct gl_program_parameter));
@@ -258,19 +272,26 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
p->Size = size;
p->DataType = datatype;
+ paramList->ParameterValueOffset[oldNum] = oldValNum;
if (values) {
if (size >= 4) {
- COPY_4V(paramList->ParameterValues[oldNum], values);
+ COPY_4V(paramList->ParameterValues + oldValNum, values);
} else {
/* copy 1, 2 or 3 values */
assert(size < 4);
- for (unsigned j = 0; j < size; j++) {
- paramList->ParameterValues[oldNum][j].f = values[j].f;
+ unsigned j;
+ for (j = 0; j < size; j++) {
+ paramList->ParameterValues[oldValNum + j].f = values[j].f;
+ }
+
+ /* Zero out padding (if any) to avoid valgrind errors */
+ for (; j < pad; j++) {
+ paramList->ParameterValues[oldValNum + j].f = 0;
}
}
} else {
for (unsigned j = 0; j < 4; j++) {
- paramList->ParameterValues[oldNum][j].f = 0;
+ paramList->ParameterValues[oldValNum + j].f = 0;
}
}
@@ -316,9 +337,10 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
if (size == 1 && swizzleOut) {
for (pos = 0; pos < (GLint) paramList->NumParameters; pos++) {
struct gl_program_parameter *p = paramList->Parameters + pos;
+ unsigned offset = paramList->ParameterValueOffset[pos];
if (p->Type == PROGRAM_CONSTANT && p->Size + size <= 4) {
/* ok, found room */
- gl_constant_value *pVal = paramList->ParameterValues[pos];
+ gl_constant_value *pVal = paramList->ParameterValues + offset;
GLuint swz = p->Size; /* 1, 2 or 3 for Y, Z, W */
pVal[p->Size] = values[0];
p->Size++;
@@ -330,7 +352,7 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
/* add a new parameter to store this constant */
pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL,
- size, datatype, values, NULL);
+ size, datatype, values, NULL, true);
if (pos >= 0 && swizzleOut) {
if (size == 1)
*swizzleOut = SWIZZLE_XXXX;
@@ -369,7 +391,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
name = _mesa_program_state_string(stateTokens);
index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
- size, GL_NONE, NULL, stateTokens);
+ size, GL_NONE, NULL, stateTokens, true);
paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
/* free name string here since we duplicated it in add_parameter() */
diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h
index 41b3fe838a8..83eb0c5613a 100644
--- a/src/mesa/program/prog_parameter.h
+++ b/src/mesa/program/prog_parameter.h
@@ -82,9 +82,11 @@ struct gl_program_parameter
struct gl_program_parameter_list
{
GLuint Size; /**< allocated size of Parameters, ParameterValues */
- GLuint NumParameters; /**< number of parameters in arrays */
+ GLuint NumParameters; /**< number of used parameters in array */
+ unsigned NumParameterValues; /**< number of used parameter values array */
struct gl_program_parameter *Parameters; /**< Array [Size] */
- gl_constant_value (*ParameterValues)[4]; /**< Array [Size] of constant[4] */
+ unsigned *ParameterValueOffset;
+ gl_constant_value *ParameterValues; /**< Array [Size] of gl_constant_value */
GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
might invalidate ParameterValues[] */
};
@@ -108,7 +110,8 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
gl_register_file type, const char *name,
GLuint size, GLenum datatype,
const gl_constant_value *values,
- const gl_state_index16 state[STATE_LENGTH]);
+ const gl_state_index16 state[STATE_LENGTH],
+ bool pad_and_align);
extern GLint
_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
diff --git a/src/mesa/program/prog_parameter_layout.c b/src/mesa/program/prog_parameter_layout.c
index 282a367ad04..d28a6675c06 100644
--- a/src/mesa/program/prog_parameter_layout.c
+++ b/src/mesa/program/prog_parameter_layout.c
@@ -92,10 +92,20 @@ copy_indirect_accessed_array(struct gl_program_parameter_list *src,
assert(j == dst->NumParameters);
/* copy src parameter [i] to dest parameter [j] */
- memcpy(& dst->Parameters[j], curr,
+ memcpy(&dst->Parameters[j], curr,
sizeof(dst->Parameters[j]));
- memcpy(dst->ParameterValues[j], src->ParameterValues[i],
- sizeof(GLfloat) * 4);
+
+ dst->ParameterValueOffset[j] = dst->NumParameterValues;
+
+ gl_constant_value *pv_dst =
+ dst->ParameterValues + dst->ParameterValueOffset[j];
+ gl_constant_value *pv_src =
+ src->ParameterValues + src->ParameterValueOffset[i];
+
+ memcpy(pv_dst, pv_src, MIN2(src->Parameters[i].Size, 4) *
+ sizeof(GLfloat));
+ dst->NumParameterValues += MIN2(dst->Parameters[j].Size, 4);
+
/* Pointer to the string name was copied. Null-out src param name
* to prevent double free later.
@@ -183,8 +193,9 @@ _mesa_layout_parameters(struct asm_parser_state *state)
switch (p->Type) {
case PROGRAM_CONSTANT: {
- const gl_constant_value *const v =
- state->prog->Parameters->ParameterValues[idx];
+ unsigned pvo = state->prog->Parameters->ParameterValueOffset[idx];
+ const gl_constant_value *const v =
+ state->prog->Parameters->ParameterValues + pvo;
inst->Base.SrcReg[i].Index =
_mesa_add_unnamed_constant(layout, v, p->Size, & swizzle);
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index b273bbf4c86..e8d087c506b 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -931,7 +931,9 @@ _mesa_fprint_parameter_list(FILE *f,
fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags);
for (i = 0; i < list->NumParameters; i++){
struct gl_program_parameter *param = list->Parameters + i;
- const GLfloat *v = (GLfloat *) list->ParameterValues[i];
+ unsigned pvo = list->ParameterValueOffset[i];
+ const GLfloat *v = (GLfloat *) list->ParameterValues + pvo;
+
fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}",
i, param->Size,
_mesa_register_file_name(list->Parameters[i].Type),
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index e7fa72ce10e..4d7f388cfb0 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -1076,9 +1076,10 @@ _mesa_load_state_parameters(struct gl_context *ctx,
for (i = 0; i < paramList->NumParameters; i++) {
if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
+ unsigned pvo = paramList->ParameterValueOffset[i];
_mesa_fetch_state(ctx,
paramList->Parameters[i].StateIndexes,
- &paramList->ParameterValues[i][0]);
+ paramList->ParameterValues + pvo);
}
}
}
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index 851b3f2e5ea..b49616c0cf9 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -161,7 +161,8 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src)
case PROGRAM_CONSTANT:
if ((c->prog->arb.IndirectRegisterFiles &
(1 << PROGRAM_CONSTANT)) == 0) {
- float *v = (float *) plist->ParameterValues[prog_src->Index];
+ unsigned pvo = plist->ParameterValueOffset[prog_src->Index];
+ float *v = (float *) plist->ParameterValues + pvo;
src.src = nir_src_for_ssa(nir_imm_vec4(b, v[0], v[1], v[2], v[3]));
break;
}
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index 8adbbf0ac5b..9b63764f752 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -2307,7 +2307,7 @@ int add_state_reference(struct gl_program_parameter_list *param_list,
name = _mesa_program_state_string(tokens);
index = _mesa_add_parameter(param_list, PROGRAM_STATE_VAR, name,
- size, GL_NONE, NULL, tokens);
+ size, GL_NONE, NULL, tokens, true);
param_list->StateFlags |= _mesa_program_state_flags(tokens);
/* free name string here since we duplicated it in add_parameter() */
diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c b/src/mesa/state_tracker/st_atifs_to_tgsi.c
index 76236cf9656..1180ede35e6 100644
--- a/src/mesa/state_tracker/st_atifs_to_tgsi.c
+++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c
@@ -476,6 +476,8 @@ st_translate_atifs_program(
}
for (i = 0; i < program->Parameters->NumParameters; i++) {
+ unsigned pvo = program->Parameters->ParameterValueOffset[i];
+
switch (program->Parameters->Parameters[i].Type) {
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
@@ -484,7 +486,7 @@ st_translate_atifs_program(
case PROGRAM_CONSTANT:
t->constants[i] =
ureg_DECL_immediate(ureg,
- (const float*)program->Parameters->ParameterValues[i],
+ (const float*)program->Parameters->ParameterValues + pvo,
4);
break;
default:
@@ -601,7 +603,7 @@ st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
/* we always have the ATI_fs constants, and the fog params */
for (i = 0; i < MAX_NUM_FRAGMENT_CONSTANTS_ATI; i++) {
_mesa_add_parameter(prog->Parameters, PROGRAM_UNIFORM,
- NULL, 4, GL_FLOAT, NULL, NULL);
+ NULL, 4, GL_FLOAT, NULL, NULL, true);
}
_mesa_add_state_reference(prog->Parameters, fog_params_state);
_mesa_add_state_reference(prog->Parameters, fog_color);
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 0a6b23aff3b..87a72b2622c 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -71,11 +71,12 @@ void st_upload_constants(struct st_context *st, struct gl_program *prog)
unsigned c;
for (c = 0; c < MAX_NUM_FRAGMENT_CONSTANTS_ATI; c++) {
+ unsigned offset = params->ParameterValueOffset[c];
if (ati_fs->LocalConstDef & (1 << c))
- memcpy(params->ParameterValues[c],
+ memcpy(params->ParameterValues + offset,
ati_fs->Constants[c], sizeof(GLfloat) * 4);
else
- memcpy(params->ParameterValues[c],
+ memcpy(params->ParameterValues + offset,
st->ctx->ATIFragmentShader.GlobalConstants[c], sizeof(GLfloat) * 4);
}
}
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 911c855d43a..f0f68ac02c6 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6591,6 +6591,8 @@ st_translate_program(
t->num_constants = proginfo->Parameters->NumParameters;
for (i = 0; i < proginfo->Parameters->NumParameters; i++) {
+ unsigned pvo = proginfo->Parameters->ParameterValueOffset[i];
+
switch (proginfo->Parameters->Parameters[i].Type) {
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
@@ -6608,7 +6610,7 @@ st_translate_program(
t->constants[i] = ureg_DECL_constant(ureg, i);
else
t->constants[i] = emit_immediate(t,
- proginfo->Parameters->ParameterValues[i],
+ proginfo->Parameters->ParameterValues + pvo,
proginfo->Parameters->Parameters[i].DataType,
4);
break;
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 99cddd66282..0ea201fdd6a 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -1011,6 +1011,8 @@ st_translate_mesa_program(struct gl_context *ctx,
}
for (i = 0; i < program->Parameters->NumParameters; i++) {
+ unsigned pvo = program->Parameters->ParameterValueOffset[i];
+
switch (program->Parameters->Parameters[i].Type) {
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
@@ -1025,12 +1027,12 @@ st_translate_mesa_program(struct gl_context *ctx,
*/
case PROGRAM_CONSTANT:
if (program->arb.IndirectRegisterFiles & PROGRAM_ANY_CONST)
- t->constants[i] = ureg_DECL_constant(ureg, i);
+ t->constants[i] = ureg_DECL_constant( ureg, i );
else
- t->constants[i] =
+ t->constants[i] =
ureg_DECL_immediate(ureg,
(const float *)
- program->Parameters->ParameterValues[i],
+ program->Parameters->ParameterValues + pvo,
4);
break;
default: