nir: Add layer_id_written_agx sysval
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Wed, 16 Aug 2023 21:58:27 +0000 (17:58 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 1 Oct 2023 16:32:11 +0000 (12:32 -0400)
We'll implement layer ID reads in the frag shader with a varying read, but if
the VS doesn't write the varying we need to return 0 per the spec. Add a sysval
to detect that case so we can handle it at runtime without keys.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/compiler/nir/nir_intrinsics.py

index 50b25ed..f24df48 100644 (file)
@@ -1695,6 +1695,11 @@ intrinsic("load_coefficients_agx",
           indices=[COMPONENT, IO_SEMANTICS, INTERP_MODE],
           flags=[CAN_ELIMINATE, CAN_REORDER])
 
+# In a fragment shader, boolean system value that is true if the last vertex
+# stage writes the layer ID. If false, layer IDs are defined to read back zero.
+# This system value facilitates that. 16-bit 0/~0 bool allows easy masking.
+system_value("layer_id_written_agx", 1, bit_sizes=[16])
+
 # Load/store a pixel in local memory. This operation is formatted, with
 # conversion between the specified format and the implied register format of the
 # source/destination (for store/loads respectively). This mostly matters for