nir: Stop whacking gl_FrontFacing to a system value
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 31 Jul 2019 20:17:17 +0000 (15:17 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 1 Aug 2019 21:59:37 +0000 (21:59 +0000)
We have a cap bit for gallium and a GLSL compiler flag to control this.
Just trust what GLSL gives us and stop forcing it.  In order for this to
be safe, we have to advertise another cap in some of the gallium
drivers.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/glsl_to_nir.cpp
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/v3d/v3d_screen.c
src/gallium/drivers/vc4/vc4_screen.c
src/mesa/drivers/dri/i965/brw_context.c

index 7b454cab623332c3bb97f5fd599b72acadcc1304..3238c65cd9c210911debc14e430bc2335463113d 100644 (file)
@@ -460,13 +460,8 @@ nir_visitor::visit(ir_variable *ir)
       break;
 
    case ir_var_shader_in:
-      if (shader->info.stage == MESA_SHADER_FRAGMENT &&
-          ir->data.location == VARYING_SLOT_FACE) {
-         /* For whatever reason, GLSL IR makes gl_FrontFacing an input */
-         var->data.location = SYSTEM_VALUE_FRONT_FACE;
-         var->data.mode = nir_var_system_value;
-      } else if (shader->info.stage == MESA_SHADER_GEOMETRY &&
-                 ir->data.location == VARYING_SLOT_PRIMITIVE_ID) {
+      if (shader->info.stage == MESA_SHADER_GEOMETRY &&
+          ir->data.location == VARYING_SLOT_PRIMITIVE_ID) {
          /* For whatever reason, GLSL IR makes gl_PrimitiveIDIn an input */
          var->data.location = SYSTEM_VALUE_PRIMITIVE_ID;
          var->data.mode = nir_var_system_value;
index 4fbe6dd92238d00b61b6691c5ffed5bd74924467..2de02e31fe31d5c2a3e074ae1e759fc87a3ca26e 100644 (file)
@@ -365,6 +365,8 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                if (is_ir3(screen))
                        return 1;
                return 0;
+       case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
+               return 1;
        case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
        case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
                if (is_ir3(screen))
index 7fb63a4f38ce1c3e5b9260cc537835d2d7f2b770..083d2e96ee615c5cf2b79343e5ac05ef8b46a50f 100644 (file)
@@ -136,6 +136,7 @@ v3d_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
         case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
         case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
+        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
                 return 1;
 
         case PIPE_CAP_PACKED_UNIFORMS:
index d7325b885a4a330d06808a94f1739cb93d0867f8..4aeacc832b8b0622df6770a96d1f20d72055b532 100644 (file)
@@ -164,6 +164,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 
         case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
         case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
+        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
                 return 1;
 
         case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES:
index 91053842aa11dda3d6c9bae7c60d94e2ebe2e6d7..957be4006f89c90a97de9e7cf1d8016e68cb3712 100644 (file)
@@ -622,6 +622,7 @@ brw_initialize_context_constants(struct brw_context *brw)
       ctx->Const.MaxClipPlanes = 8;
 
    ctx->Const.GLSLFragCoordIsSysVal = true;
+   ctx->Const.GLSLFrontFacingIsSysVal = true;
    ctx->Const.GLSLTessLevelsAsInputs = true;
    ctx->Const.PrimitiveRestartForPatches = true;