Mesa (master): glsl/linker: generalize validate_explicit_variable_location for SSO

Iago Toral Quiroga itoral at kemper.freedesktop.org
Thu Oct 26 06:45:48 UTC 2017


Module: Mesa
Branch: master
Commit: bdaf0589785138f91cd485fd698274a33b7d33d5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bdaf0589785138f91cd485fd698274a33b7d33d5

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Fri Oct 20 10:46:10 2017 +0200

glsl/linker: generalize validate_explicit_variable_location for SSO

For non-SSO programs, we only need to validate outputs, since
the cross validation of outputs to inputs will ensure that we
produce linker errors for invalid inputs too.

Hoever, for the SSO path there is no output to input validation,
so we need to validate inputs explicitly. Generalize the function
so it can handle this as well.

Also, notice that vertex shader inputs and fragment shader outputs
are already validated in assign_attribute_or_color_locations()
for both SSO and non-SSO paths, so we should not try to validate
that here again (in fact, the function would require explicit
paths to handle these two cases properly).

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/compiler/glsl/link_varyings.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 64c9a28253..02a48f7199 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -545,8 +545,22 @@ validate_explicit_variable_location(struct gl_context *ctx,
    unsigned idx = compute_variable_location_slot(var, sh->Stage);
    unsigned slot_limit = idx + num_elements;
 
-   unsigned slot_max =
-      ctx->Const.Program[sh->Stage].MaxOutputComponents / 4;
+   /* Vertex shader inputs and fragment shader outputs are validated in
+    * assign_attribute_or_color_locations() so we should not attempt to
+    * validate them again here.
+    */
+   unsigned slot_max;
+   if (var->data.mode == ir_var_shader_out) {
+      assert(sh->Stage != MESA_SHADER_FRAGMENT);
+      slot_max =
+         ctx->Const.Program[sh->Stage].MaxOutputComponents / 4;
+   } else {
+      assert(var->data.mode == ir_var_shader_in);
+      assert(sh->Stage != MESA_SHADER_VERTEX);
+      slot_max =
+         ctx->Const.Program[sh->Stage].MaxInputComponents / 4;
+   }
+
    if (slot_limit > slot_max) {
       linker_error(prog,
                    "Invalid location %u in %s shader\n",




More information about the mesa-commit mailing list