diff options
author | Timothy Arceri <[email protected]> | 2017-06-16 09:56:56 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-11-29 21:50:48 +1100 |
commit | a39a3b4b76276160d99d7805109ecad9c1c95b1f (patch) | |
tree | bf6cba9daf03288443b41940ae4f770cb2eaf85c /src/mesa/program/ir_to_mesa.cpp | |
parent | f8a54c489d305010eb6c622bb4e4acd714ee7532 (diff) |
mesa: rework _mesa_add_parameter() to only add a single param
This is more inline with what the functions name suggests it should
do, and makes the code much easier to follow.
This will also make adding uniform packing support much simpler.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/program/ir_to_mesa.cpp')
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 19 |
1 files changed, 16 insertions, 3 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). |