glsl: Fix gl_shader_stage enum unsigned comparison
authorRob Herring <robh@kernel.org>
Thu, 1 Jun 2017 00:56:56 +0000 (19:56 -0500)
committerRob Herring <robh@kernel.org>
Thu, 8 Jun 2017 12:26:04 +0000 (07:26 -0500)
Replace -1 with MESA_SHADER_NONE enum value to fix sign related warning:

external/mesa3d/src/compiler/glsl/link_varyings.cpp:1415:25: warning: comparison of constant -1 with expression of type 'gl_shader_stage' is always true [-Wtautological-constant-out-of-range-compare]
        (consumer_stage != -1 && consumer_stage != MESA_SHADER_FRAGMENT))) {
         ~~~~~~~~~~~~~~ ^  ~~

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Signed-off-by: Rob Herring <robh@kernel.org>
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/link_varyings.cpp
src/compiler/shader_enums.h
src/mesa/main/shaderobj.h
src/mesa/program/prog_print.c
src/mesa/state_tracker/st_context.h

index e451bda8016dd3a7497ea20e911aa85b518e612c..e07e5f509b583b1137961580ad004d5123cfd89f 100644 (file)
@@ -3245,6 +3245,9 @@ apply_explicit_location(const struct ast_type_qualifier *qual,
                        "compute shader variables cannot be given "
                        "explicit locations");
       return;
+   default:
+      fail = true;
+      break;
    };
 
    if (fail) {
@@ -3276,7 +3279,7 @@ apply_explicit_location(const struct ast_type_qualifier *qual,
             ? (qual_location + FRAG_RESULT_DATA0)
             : (qual_location + VARYING_SLOT_VAR0);
          break;
-      case MESA_SHADER_COMPUTE:
+      default:
          assert(!"Unexpected shader type");
          break;
       }
@@ -4089,6 +4092,8 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
       case MESA_SHADER_COMPUTE:
          /* Invariance isn't meaningful in compute shaders. */
          break;
+      default:
+         break;
       }
    }
 
index ce4dd43730c1c04796d61363ca3ad69040374a30..405502eb8a43628d4c5294f0ecf821d189bb976c 100644 (file)
@@ -1324,6 +1324,8 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type,
    case MESA_SHADER_COMPUTE:
       /* Compute shaders don't have varyings. */
       break;
+   default:
+      break;
    }
 }
 
@@ -1461,6 +1463,8 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
    case MESA_SHADER_COMPUTE:
       gen.generate_cs_special_vars();
       break;
+   default:
+      break;
    }
 }
 
index d04f546c2430b31283c818606903cfb5c3237527..910e2eda82b877c15a15b50c89f218cb3073805b 100644 (file)
@@ -1412,7 +1412,7 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
 
    if (!disable_varying_packing &&
        (needs_flat_qualifier ||
-        (consumer_stage != -1 && consumer_stage != MESA_SHADER_FRAGMENT))) {
+        (consumer_stage != MESA_SHADER_NONE && consumer_stage != MESA_SHADER_FRAGMENT))) {
       /* Since this varying is not being consumed by the fragment shader, its
        * interpolation type varying cannot possibly affect rendering.
        * Also, this variable is non-flat and is (or contains) an integer
@@ -2170,8 +2170,8 @@ assign_varying_locations(struct gl_context *ctx,
 
    varying_matches matches(disable_varying_packing, xfb_enabled,
                            ctx->Extensions.ARB_enhanced_layouts,
-                           producer ? producer->Stage : (gl_shader_stage)-1,
-                           consumer ? consumer->Stage : (gl_shader_stage)-1);
+                           producer ? producer->Stage : MESA_SHADER_NONE,
+                           consumer ? consumer->Stage : MESA_SHADER_NONE);
    hash_table *tfeedback_candidates =
          _mesa_hash_table_create(NULL, _mesa_key_hash_string,
                                  _mesa_key_string_equal);
index 07db4767f86235d4ce93fff2fb7602c69db17ce8..352f27040ce3aef689394ce6e61491c2e8f4e853 100644 (file)
@@ -39,6 +39,7 @@ extern "C" {
  */
 typedef enum
 {
+   MESA_SHADER_NONE = -1,
    MESA_SHADER_VERTEX = 0,
    MESA_SHADER_TESS_CTRL = 1,
    MESA_SHADER_TESS_EVAL = 2,
index b7dae62bcb4105c36ee539626757a0ffbcac515b..97b8ce7ac233f55c22561374ce4679cfbfd943f6 100644 (file)
@@ -216,6 +216,8 @@ _mesa_shader_stage_to_subroutine(gl_shader_stage stage)
       return GL_TESS_CONTROL_SUBROUTINE;
    case MESA_SHADER_TESS_EVAL:
       return GL_TESS_EVALUATION_SUBROUTINE;
+   case MESA_SHADER_NONE:
+      break;
    }
    unreachable("not reached");
 }
@@ -236,6 +238,8 @@ _mesa_shader_stage_to_subroutine_uniform(gl_shader_stage stage)
       return GL_TESS_CONTROL_SUBROUTINE_UNIFORM;
    case MESA_SHADER_TESS_EVAL:
       return GL_TESS_EVALUATION_SUBROUTINE_UNIFORM;
+   case MESA_SHADER_NONE:
+      break;
    }
    unreachable("not reached");
 }
index b32ce150da3c2756ed2eedcb32356d3c4a9c52db..4f85d14c41d8376425b286d737161e8cc51bc81d 100644 (file)
@@ -969,6 +969,8 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
    case MESA_SHADER_COMPUTE:
       type = "comp";
       break;
+   default:
+      break;
    }
 
    _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
index 631c3aee0accd936bf3d4a689f634df7f21a3aab..6dcf13352b9888397d24a5cc1f0bc9137e40390c 100644 (file)
@@ -363,6 +363,8 @@ st_shader_stage_to_ptarget(gl_shader_stage stage)
       return PIPE_SHADER_TESS_EVAL;
    case MESA_SHADER_COMPUTE:
       return PIPE_SHADER_COMPUTE;
+   default:
+      break;
    }
 
    assert(!"should not be reached");