OSDN Git Service

glsl: do not set the 'smooth' qualifier by default on ES shaders
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 11 Sep 2017 14:40:37 +0000 (16:40 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 2 Oct 2017 13:07:42 +0000 (15:07 +0200)
It leads to surprising states with integer inputs and outputs on
vertex processing stages (e.g. geometry stages). Instead, rely on the
driver to choose smooth interpolation by default.

We still allow varyings to match when one stage declares it as smooth
and the other declares it without interpolation qualifiers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/link_varyings.cpp
src/mesa/main/shader_query.cpp

index c464549..1999e68 100644 (file)
@@ -3126,17 +3126,6 @@ interpret_interpolation_qualifier(const struct ast_type_qualifier *qual,
       interpolation = INTERP_MODE_NOPERSPECTIVE;
    else if (qual->flags.q.smooth)
       interpolation = INTERP_MODE_SMOOTH;
-   else if (state->es_shader &&
-            ((mode == ir_var_shader_in &&
-              state->stage != MESA_SHADER_VERTEX) ||
-             (mode == ir_var_shader_out &&
-              state->stage != MESA_SHADER_FRAGMENT)))
-      /* Section 4.3.9 (Interpolation) of the GLSL ES 3.00 spec says:
-       *
-       *    "When no interpolation qualifier is present, smooth interpolation
-       *    is used."
-       */
-      interpolation = INTERP_MODE_SMOOTH;
    else
       interpolation = INTERP_MODE_NONE;
 
index 656bf79..ed3bf41 100644 (file)
@@ -325,8 +325,23 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
     *     "It is a link-time error if, within the same stage, the interpolation
     *     qualifiers of variables of the same name do not match.
     *
+    * Section 4.3.9 (Interpolation) of the GLSL ES 3.00 spec says:
+    *
+    *    "When no interpolation qualifier is present, smooth interpolation
+    *    is used."
+    *
+    * So we match variables where one is smooth and the other has no explicit
+    * qualifier.
     */
-   if (input->data.interpolation != output->data.interpolation &&
+   unsigned input_interpolation = input->data.interpolation;
+   unsigned output_interpolation = output->data.interpolation;
+   if (prog->IsES) {
+      if (input_interpolation == INTERP_MODE_NONE)
+         input_interpolation = INTERP_MODE_SMOOTH;
+      if (output_interpolation == INTERP_MODE_NONE)
+         output_interpolation = INTERP_MODE_SMOOTH;
+   }
+   if (input_interpolation != output_interpolation &&
        prog->data->Version < 440) {
       linker_error(prog,
                    "%s shader output `%s' specifies %s "
index 64e68b4..6712bb4 100644 (file)
@@ -1634,7 +1634,13 @@ validate_io(struct gl_program *producer, struct gl_program *consumer)
        * Note that location mismatches are detected by the loops above that
        * find the producer variable that goes with the consumer variable.
        */
-      if (producer_var->interpolation != consumer_var->interpolation) {
+      unsigned producer_interpolation = producer_var->interpolation;
+      unsigned consumer_interpolation = consumer_var->interpolation;
+      if (producer_interpolation == INTERP_MODE_NONE)
+         producer_interpolation = INTERP_MODE_SMOOTH;
+      if (consumer_interpolation == INTERP_MODE_NONE)
+         consumer_interpolation = INTERP_MODE_SMOOTH;
+      if (producer_interpolation != consumer_interpolation) {
          valid = false;
          goto out;
       }