Mesa (main): iris: Do primitive ID overrides in 3DSTATE_SBE not SBE_SWIZ

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 19 01:56:25 UTC 2022


Module: Mesa
Branch: main
Commit: 0bc7562466cb6ad212caa7c2060c53c3b88ffc2d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0bc7562466cb6ad212caa7c2060c53c3b88ffc2d

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 14 15:25:26 2021 -0800

iris: Do primitive ID overrides in 3DSTATE_SBE not SBE_SWIZ

Broadwell introduced new fields in 3DSTATE_SBE which allow us to ask
the hardware to override Primitive ID for us, rather than requiring us
to turn on attribute swizzling and specify per-attribute overrides in
3DSTATE_SBE_SWIZ.  We unconditionally enable attribute swizzling today,
but this is a step toward letting us think about disabling it in the
future.

Reviewed-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14210>

---

 src/gallium/drivers/iris/iris_state.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 63812c464df..f07302d0382 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -4095,18 +4095,6 @@ iris_emit_sbe_swiz(struct iris_batch *batch,
             attr->ComponentOverrideZ = true;
          continue;
 
-      case VARYING_SLOT_PRIMITIVE_ID:
-         /* 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;
-         }
-         break;
-
       default:
          break;
       }
@@ -4231,6 +4219,19 @@ iris_emit_sbe(struct iris_batch *batch, const struct iris_context *ice)
          sbe.AttributeActiveComponentFormat[i] = ACTIVE_COMPONENT_XYZW;
       }
 #endif
+
+      /* Ask the hardware to supply PrimitiveID if the fragment shader
+       * reads it but a previous stage didn't write one.
+       */
+      if ((wm_prog_data->inputs & VARYING_BIT_PRIMITIVE_ID) &&
+          last_vue_map->varying_to_slot[VARYING_SLOT_PRIMITIVE_ID] == -1) {
+         sbe.PrimitiveIDOverrideAttributeSelect =
+            wm_prog_data->urb_setup[VARYING_SLOT_PRIMITIVE_ID];
+         sbe.PrimitiveIDOverrideComponentX = true;
+         sbe.PrimitiveIDOverrideComponentY = true;
+         sbe.PrimitiveIDOverrideComponentZ = true;
+         sbe.PrimitiveIDOverrideComponentW = true;
+      }
    }
 
    iris_emit_sbe_swiz(batch, ice, last_vue_map, urb_read_offset,



More information about the mesa-commit mailing list