[Mesa-dev] [PATCH v5 28/34] nvir/nir: implement geometry shader nir_intrinsics

Karol Herbst kherbst at redhat.com
Tue Feb 20 21:02:46 UTC 2018


v4: use smarter getIndirect helper
    use new getSlotAddress helper
    use loadFrom helper

Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp   | 25 ++++++++++++++++++++++
 1 file changed, 25 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 a0dcd69280..6997879ddf 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -402,6 +402,10 @@ operation
 Converter::getOperation(nir_intrinsic_op op)
 {
    switch (op) {
+   case nir_intrinsic_emit_vertex:
+      return OP_EMIT;
+   case nir_intrinsic_end_primitive:
+      return OP_RESTART;
    default:
       ERROR("couldn't get operation for nir_intrinsic_op %u\n", op);
       assert(false);
@@ -1797,6 +1801,27 @@ Converter::visit(nir_intrinsic_instr *insn)
       mkOp3(OP_SHFL, dType, newDefs[0], getSrc(&insn->src[0], 0), tmp, mkImm(0x1f))->subOp = NV50_IR_SUBOP_SHFL_IDX;
       break;
    }
+   case nir_intrinsic_load_per_vertex_input: {
+      const DataType dType = getDType(insn);
+      LValues &newDefs = convert(&insn->dest);
+      Value *indirectVertex;
+      Value *indirectOffset;
+      auto baseVertex = getIndirect(&insn->src[0], 0, &indirectVertex);
+      auto idx = getIndirect(insn, 1, 0, &indirectOffset);
+
+      Value *vtxBase = mkOp2v(OP_PFETCH, TYPE_U32, getSSA(4, FILE_ADDRESS), mkImm(baseVertex), indirectVertex);
+      for (auto i = 0u; i < insn->num_components; ++i) {
+         uint32_t address = getSlotAddress(insn, idx, i);
+         loadFrom(FILE_SHADER_INPUT, 0, dType, newDefs[i], address, 0, indirectOffset, vtxBase, info->in[idx].patch);
+      }
+      break;
+   }
+   case nir_intrinsic_emit_vertex:
+   case nir_intrinsic_end_primitive: {
+      auto idx = nir_intrinsic_stream_id(insn);
+      mkOp1(getOperation(op), TYPE_U32, NULL, mkImm(idx))->fixed = 1;
+      break;
+   }
    default:
       ERROR("unknown nir_intrinsic_op %s\n", nir_intrinsic_infos[op].name);
       return false;
-- 
2.14.3



More information about the mesa-dev mailing list