diff options
Diffstat (limited to 'src/mesa/program')
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 19 | ||||
-rw-r--r-- | src/mesa/program/prog_parameter.c | 57 |
2 files changed, 39 insertions, 37 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 327fd61d422..aa8b6d7084b 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2431,12 +2431,25 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name, if (type->contains_opaque() && !var->data.bindless) return; + /* Add the uniform to the param list */ assert(_mesa_lookup_parameter_index(params, name) < 0); + int index = _mesa_lookup_parameter_index(params, name); - unsigned size = storage_type_size(type, var->data.bindless) * 4; + unsigned num_params = type->arrays_of_arrays_size(); + num_params = MAX2(num_params, 1); + num_params *= type->without_array()->matrix_columns; - int index = _mesa_add_parameter(params, PROGRAM_UNIFORM, name, size, - type->gl_type, NULL, NULL); + bool is_dual_slot = type->without_array()->is_dual_slot(); + if (is_dual_slot) + num_params *= 2; + + _mesa_reserve_parameter_storage(params, num_params); + index = params->NumParameters; + for (unsigned i = 0; i < num_params; i++) { + unsigned comps = 4; + _mesa_add_parameter(params, PROGRAM_UNIFORM, name, comps, + type->gl_type, NULL, NULL); + } /* The first part of the uniform that's processed determines the base * location of the whole uniform (for structures). diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 40bc47de358..81609f5c5e1 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -234,12 +234,10 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, const gl_constant_value *values, const gl_state_index state[STATE_LENGTH]) { + assert(0 < size && size <=4); const GLuint oldNum = paramList->NumParameters; - const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */ - assert(size > 0); - - _mesa_reserve_parameter_storage(paramList, sz4); + _mesa_reserve_parameter_storage(paramList, 1); if (!paramList->Parameters || !paramList->ParameterValues) { @@ -249,44 +247,35 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, return -1; } - GLuint i, j; - - paramList->NumParameters = oldNum + sz4; + paramList->NumParameters = oldNum + 1; memset(¶mList->Parameters[oldNum], 0, - sz4 * sizeof(struct gl_program_parameter)); + sizeof(struct gl_program_parameter)); - for (i = 0; i < sz4; i++) { - struct gl_program_parameter *p = paramList->Parameters + oldNum + i; - p->Name = strdup(name ? name : ""); - p->Type = type; - p->Size = size; - p->DataType = datatype; - if (values) { - if (size >= 4) { - COPY_4V(paramList->ParameterValues[oldNum + i], values); - } else { - /* copy 1, 2 or 3 values */ - assert(size < 4); - for (j = 0; j < size; j++) { - paramList->ParameterValues[oldNum + i][j].f = values[j].f; - } - /* fill in remaining positions with zeros */ - for (; j < 4; j++) { - paramList->ParameterValues[oldNum + i][j].f = 0.0f; - } - } - values += 4; + struct gl_program_parameter *p = paramList->Parameters + oldNum; + p->Name = strdup(name ? name : ""); + p->Type = type; + p->Size = size; + p->DataType = datatype; + + if (values) { + if (size >= 4) { + COPY_4V(paramList->ParameterValues[oldNum], values); } else { - /* silence valgrind */ - for (j = 0; j < 4; j++) - paramList->ParameterValues[oldNum + i][j].f = 0; + /* copy 1, 2 or 3 values */ + assert(size < 4); + for (unsigned j = 0; j < size; j++) { + paramList->ParameterValues[oldNum][j].f = values[j].f; + } + } + } else { + for (unsigned j = 0; j < 4; j++) { + paramList->ParameterValues[oldNum][j].f = 0; } - size -= 4; } if (state) { - for (i = 0; i < STATE_LENGTH; i++) + for (unsigned i = 0; i < STATE_LENGTH; i++) paramList->Parameters[oldNum].StateIndexes[i] = state[i]; } |