Mesa (main): ac/nir: skip gl_Layer/gl_ViewportIndex write for LS

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 7 02:12:42 UTC 2022


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

Author: Qiang Yu <yuq825 at gmail.com>
Date:   Mon May  9 21:42:47 2022 +0800

ac/nir: skip gl_Layer/gl_ViewportIndex write for LS

This is from radeonsi.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Signed-off-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16418>

---

 src/amd/common/ac_nir_lower_tess_io_to_mem.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/amd/common/ac_nir_lower_tess_io_to_mem.c b/src/amd/common/ac_nir_lower_tess_io_to_mem.c
index 0fe115f0493..8483f4609ee 100644
--- a/src/amd/common/ac_nir_lower_tess_io_to_mem.c
+++ b/src/amd/common/ac_nir_lower_tess_io_to_mem.c
@@ -207,6 +207,27 @@ lower_ls_output_store(nir_builder *b,
    if (intrin->intrinsic != nir_intrinsic_store_output)
       return false;
 
+   /* The ARB_shader_viewport_layer_array spec contains the
+    * following issue:
+    *
+    *    2) What happens if gl_ViewportIndex or gl_Layer is
+    *    written in the vertex shader and a geometry shader is
+    *    present?
+    *
+    *    RESOLVED: The value written by the last vertex processing
+    *    stage is used. If the last vertex processing stage
+    *    (vertex, tessellation evaluation or geometry) does not
+    *    statically assign to gl_ViewportIndex or gl_Layer, index
+    *    or layer zero is assumed.
+    *
+    * So writes to those outputs in VS-as-LS are simply ignored.
+    */
+   unsigned semantic = nir_intrinsic_io_semantics(intrin).location;
+   if (semantic == VARYING_SLOT_LAYER || semantic == VARYING_SLOT_VIEWPORT) {
+      nir_instr_remove(instr);
+      return true;
+   }
+
    lower_tess_io_state *st = (lower_tess_io_state *) state;
 
    /* If this is a temp-only TCS input, we don't need to use shared memory at all. */



More information about the mesa-commit mailing list