Before reviewing this can we get a piglit test for the following scenario

Two "program" objects say:

1. vs->gs
2. fs

Where the interface between vs and gs has a used input that doesn't exist in the vs. The test should fail validation, the idea being the test would have failed on your v1 of this patch.

Thanks.


On 7/2/19 2:58 am, Andres Gomez wrote:
If there is no Static Use of an input variable, the linker shouldn't
fail whenever there is no defined matching output variable in the
previous stage.

 From page 47 (page 51 of the PDF) of the GLSL 4.60 v.5 spec:

   " Only the input variables that are statically read need to be
     written by the previous stage; it is allowed to have superfluous
     declarations of input variables."

Now, we complete this exception whenever the input variable has an
explicit location. Previously, 18004c338f6 ("glsl: fail when a
shader's input var has not an equivalent out var in previous") took
care of the cases in which the input variable didn't have an explicit
location.

v2: do the location based interface matching check regardless on
     whehter it is a separable program or not (Ilia).

Cc: Timothy Arceri <tarc...@itsqueeze.com>
Cc: Iago Toral Quiroga <ito...@igalia.com>
Cc: Samuel Iglesias Gonsálvez <sigles...@igalia.com>
Cc: Tapani Pälli <tapani.pa...@intel.com>
Cc: Ian Romanick <ian.d.roman...@intel.com>
Cc: Ilia Mirkin <imir...@alum.mit.edu>
Signed-off-by: Andres Gomez <ago...@igalia.com>
---
  src/compiler/glsl/link_varyings.cpp | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp
index e5f7d3e322a..36908d95263 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -808,8 +808,20 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
output = output_explicit_locations[idx][input->data.location_frac].var; - if (output == NULL ||
-                   input->data.location != output->data.location) {
+               if (output == NULL) {
+                  /* A linker failure should only happen when there is no
+                   * output declaration and there is Static Use of the
+                   * declared input.
+                   */
+                  if (input->data.used) {
+                     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;
+                  }
+               } else if (input->data.location != output->data.location) {
                    linker_error(prog,
                                 "%s shader input `%s' with explicit location "
                                 "has no matching output\n",

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to