[Mesa-dev] [PATCH v8 18/33] nvir/nir: implement nir_intrinsic_store_(per_vertex_)output

Karol Herbst kherbst at redhat.com
Fri Jun 29 22:32:05 UTC 2018


v3: add workaround for RA issues
    indirects have to be multiplied by 0x10
    fix indirect access
v4: use smarter getIndirect helper
    use storeTo helper
v5: don't use const_offset directly
v8: don't require C++11 features

Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../nouveau/codegen/nv50_ir_from_nir.cpp      | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index bcb2e8d28cc..32f33680bb4 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -1270,6 +1270,11 @@ Converter::visit(nir_function *function)
 
    setPosition(entry, true);
 
+   if (info->io.genUserClip > 0) {
+      for (int c = 0; c < 4; ++c)
+         clipVtx[c] = getScratch();
+   }
+
    switch (prog->getType()) {
    case Program::TYPE_TESSELLATION_CONTROL:
       outBase = mkOp2v(
@@ -1296,6 +1301,9 @@ Converter::visit(nir_function *function)
    bb->cfg.attach(&exit->cfg, Graph::Edge::TREE);
    setPosition(exit, true);
 
+   if (info->io.genUserClip > 0)
+      handleUserClipPlanes();
+
    /* TODO: for non main function this needs to be a OP_RETURN */
    mkOp(OP_EXIT, TYPE_NONE, NULL)->terminator = 1;
    return true;
@@ -1470,6 +1478,44 @@ Converter::visit(nir_intrinsic_instr *insn)
       }
       break;
    }
+   case nir_intrinsic_store_output:
+   case nir_intrinsic_store_per_vertex_output: {
+      Value *indirect;
+      DataType dType = getSType(insn->src[0], false, false);
+      uint32_t idx = getIndirect(insn, op == nir_intrinsic_store_output ? 1 : 2, 0, indirect);
+
+      for (uint8_t i = 0u; i < insn->num_components; ++i) {
+         if (!((1u << i) & nir_intrinsic_write_mask(insn)))
+            continue;
+
+         uint8_t offset = 0;
+         Value *src = getSrc(&insn->src[0], i);
+         switch (prog->getType()) {
+         case Program::TYPE_FRAGMENT: {
+            if (info->out[idx].sn == TGSI_SEMANTIC_POSITION) {
+               /* TGSI uses a different interface than NIR, TGSI stores that
+                * value in the z component, NIR in X
+                */
+               offset += 2;
+               src = mkOp1v(OP_SAT, TYPE_F32, getScratch(), src);
+            }
+            break;
+         }
+         case Program::TYPE_VERTEX: {
+            if (info->io.genUserClip > 0) {
+               mkMov(clipVtx[i], src);
+               src = clipVtx[i];
+            }
+            break;
+         }
+         default:
+            break;
+         }
+
+         storeTo(insn, FILE_SHADER_OUTPUT, OP_EXPORT, dType, src, idx, i + offset, indirect);
+      }
+      break;
+   }
    default:
       ERROR("unknown nir_intrinsic_op %s\n", nir_intrinsic_infos[op].name);
       return false;
-- 
2.17.1



More information about the mesa-dev mailing list