iris: Skip primitive ID overrides if the shader wrote a custom value
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 25 Aug 2018 07:11:24 +0000 (00:11 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
Fixes glsl-1.50/execution/geometry/primitive-id-out

src/gallium/drivers/iris/iris_state.c

index b9fbed8abba71028f16202d8cea6e7cf0cfe7072..5f17b067a5893a72f623764a72fd4dc2919d5892 100644 (file)
@@ -2400,6 +2400,7 @@ iris_emit_sbe_swiz(struct iris_batch *batch,
 
       struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) *attr =
          &attr_overrides[input_index];
+      int slot = vue_map->varying_to_slot[fs_attr];
 
       /* Viewport and Layer are stored in the VUE header.  We need to override
        * them to zero if earlier stages didn't write them, as GL requires that
@@ -2419,12 +2420,15 @@ iris_emit_sbe_swiz(struct iris_batch *batch,
          continue;
 
       case VARYING_SLOT_PRIMITIVE_ID:
-         attr->ComponentOverrideX = true;
-         attr->ComponentOverrideY = true;
-         attr->ComponentOverrideZ = true;
-         attr->ComponentOverrideW = true;
-         attr->ConstantSource = PRIM_ID;
-         continue;
+         /* Override if the previous shader stage didn't write gl_PrimitiveID. */
+         if (slot == -1) {
+            attr->ComponentOverrideX = true;
+            attr->ComponentOverrideY = true;
+            attr->ComponentOverrideZ = true;
+            attr->ComponentOverrideW = true;
+            attr->ConstantSource = PRIM_ID;
+            continue;
+         }
 
       default:
          break;
@@ -2433,8 +2437,6 @@ iris_emit_sbe_swiz(struct iris_batch *batch,
       if (sprite_coord_enables & (1 << input_index))
          continue;
 
-      int slot = vue_map->varying_to_slot[fs_attr];
-
       /* If there was only a back color written but not front, use back
        * as the color instead of undefined.
        */