[Mesa-dev] [PATCH] glsl/linker: outputs in the same location must share interpolation

Iago Toral Quiroga itoral at igalia.com
Thu Oct 19 05:57:37 UTC 2017


>From ARB_enhanced_layouts:

"[...]when location aliasing, the aliases sharing the location
 must have the same underlying numerical type (floating-point or
 integer) and the same auxiliary storage and
 interpolation qualification.[...]"

Add code to the linker to validate that aliased locations do
have the same interpolation.

Fixes:
KHR-GL45.enhanced_layouts.varying_location_aliasing_with_mixed_interpolation
---
 src/compiler/glsl/link_varyings.cpp | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 69c92bf53b..c888635e82 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -459,6 +459,41 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
 
          while (idx < slot_limit) {
             unsigned i = var->data.location_frac;
+
+            /* If there are other outputs assigned to the same location
+             * they must have the same interpolation
+             */
+            unsigned comp = 0;
+            while (comp < i) {
+               ir_variable *tmp = explicit_locations[idx][comp];
+               if (tmp && tmp->data.interpolation != var->data.interpolation) {
+                  linker_error(prog,
+                               "%s shader has multiple outputs at explicit "
+                               "location %u with different interpolation "
+                               "settings\n",
+                               _mesa_shader_stage_to_string(producer->Stage),
+                               idx);
+                  return;
+               }
+               comp++;
+            }
+
+            comp = last_comp + 1;
+            while (comp < 4) {
+               ir_variable *tmp = explicit_locations[idx][comp];
+               if (tmp && tmp->data.interpolation != var->data.interpolation) {
+                  linker_error(prog,
+                               "%s shader has multiple outputs at explicit "
+                               "location %u with different interpolation "
+                               "settings\n",
+                               _mesa_shader_stage_to_string(producer->Stage),
+                               idx);
+                  return;
+               }
+               comp++;
+            }
+
+            /* Component aliasing is not allowed */
             while (i < last_comp) {
                if (explicit_locations[idx][i] != NULL) {
                   linker_error(prog,
-- 
2.11.0



More information about the mesa-dev mailing list