blob_write_bytes(metadata, param->StateIndexes,
sizeof(param->StateIndexes));
- i += (param->Size + 3) / 4;
+ i++;
}
blob_write_bytes(metadata, params->ParameterValues,
_mesa_add_parameter(params, type, name, size, data_type,
NULL, state_indexes);
- i += (size + 3) / 4;
+ i++;
}
blob_copy_bytes(metadata, (uint8_t *) params->ParameterValues,
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).
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) {
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];
}