[Mesa-dev] [PATCH 1/2] nvc0/ir: Export viewport index in fragment shaders

Lyude lyude at redhat.com
Wed Apr 19 21:10:45 UTC 2017


Since ABR_vertex_shader_layer/viewport_index enables the ability to
interact with gl_ViewportIndex from the fragment shader, we don't want
to skip emitting the viewport index for fragment shaders.

As well, only save the viewport index into a scratch register for
Geometry shaders, since EMIT is not a thing elsewhere.

Signed-off-by: Lyude <lyude at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 92cc13d..5af0ac5 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -2150,18 +2150,16 @@ Converter::storeDst(const tgsi::Instruction::DstRegister dst, int c,
       assert(!ptr);
       mkOp2(OP_WRSV, TYPE_U32, NULL, dstToSym(dst, c), val);
    } else
-   if (f == TGSI_FILE_OUTPUT && prog->getType() != Program::TYPE_FRAGMENT) {
-
-      if (ptr || (info->out[idx].mask & (1 << c))) {
-         /* Save the viewport index into a scratch register so that it can be
-            exported at EMIT time */
-         if (info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
-             viewport != NULL)
-            mkOp1(OP_MOV, TYPE_U32, viewport, val);
-         else
-            mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, val)->perPatch =
-               info->out[idx].patch;
-      }
+   if (f == TGSI_FILE_OUTPUT && (ptr || (info->out[idx].mask & (1 << c)))) {
+      /* Save the viewport index into a scratch register so that it can be
+         exported at EMIT time */
+      if (prog->getType() == Program::TYPE_GEOMETRY &&
+          info->out[idx].sn == TGSI_SEMANTIC_VIEWPORT_INDEX &&
+          viewport != NULL)
+         mkOp1(OP_MOV, TYPE_U32, viewport, val);
+      else
+         mkStore(OP_EXPORT, TYPE_U32, dstToSym(dst, c), ptr, val)->perPatch =
+            info->out[idx].patch;
    } else
    if (f == TGSI_FILE_TEMPORARY ||
        f == TGSI_FILE_ADDRESS ||
-- 
2.9.3



More information about the mesa-dev mailing list