[Mesa-dev] [PATCH 10/28] glsl: fix cross validation for explicit locations on structs and arrays
Kenneth Graunke
kenneth at whitecape.org
Fri Feb 26 01:22:40 UTC 2016
On Tuesday, December 29, 2015 4:00:10 PM PST Timothy Arceri wrote:
> ---
> src/glsl/link_varyings.cpp | 43 ++++++++++++++++++++++++++++++-------------
> 1 file changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
> index ee7cae0..dea8741 100644
> --- a/src/glsl/link_varyings.cpp
> +++ b/src/glsl/link_varyings.cpp
> @@ -239,18 +239,24 @@ cross_validate_outputs_to_inputs(struct
gl_shader_program *prog,
> /* User-defined varyings with explicit locations are handled
> * differently because they do not need to have matching names.
> */
> - const unsigned idx = var->data.location - VARYING_SLOT_VAR0;
> + const glsl_type *type = get_varying_type(var, producer->Stage);
> + unsigned num_elements = type->count_attribute_slots(false);
> + unsigned idx = var->data.location - VARYING_SLOT_VAR0;
> + unsigned slot_limit = idx + num_elements;
>
> - if (explicit_locations[idx] != NULL) {
> - linker_error(prog,
> + while(idx < slot_limit) {
while (idx < slot_limit) {
[same comment below]
Patches 8-10 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> + if (explicit_locations[idx] != NULL) {
> + linker_error(prog,
> "%s shader has multiple outputs explicitly "
> "assigned to location %d\n",
> _mesa_shader_stage_to_string(producer->Stage),
> idx);
> - return;
> - }
> + return;
> + }
>
> - explicit_locations[idx] = var;
> + explicit_locations[idx] = var;
> + idx++;
> + }
> }
> }
>
> @@ -298,14 +304,25 @@ cross_validate_outputs_to_inputs(struct
gl_shader_program *prog,
> ir_variable *output = NULL;
> if (input->data.explicit_location
> && input->data.location >= VARYING_SLOT_VAR0) {
> - output = explicit_locations[input->data.location -
VARYING_SLOT_VAR0];
>
> - if (output == NULL) {
> - linker_error(prog,
> - "%s shader input `%s' with explicit location "
> - "has no matching output\n",
> - _mesa_shader_stage_to_string(consumer->Stage),
> - input->name);
> + const glsl_type *type = get_varying_type(input, consumer-
>Stage);
> + unsigned num_elements = type->count_attribute_slots(false);
> + unsigned idx = input->data.location - VARYING_SLOT_VAR0;
> + unsigned slot_limit = idx + num_elements;
> +
> + while(idx < slot_limit) {
> + output = explicit_locations[idx];
> +
> + if (output == NULL ||
> + input->data.location != output->data.location) {
> + linker_error(prog,
> + "%s shader input `%s' with explicit location
"
> + "has no matching output\n",
> + _mesa_shader_stage_to_string(consumer-
>Stage),
> + input->name);
> + break;
> + }
> + idx++;
> }
> } else {
> output = parameters.get_variable(input->name);
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160225/ab2324e1/attachment.sig>
More information about the mesa-dev
mailing list