[Mesa-dev] [PATCH 18/22] nvir/nir: implement loading system values

Karol Herbst kherbst at redhat.com
Thu Dec 21 15:51:36 UTC 2017


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp   | 26 ++++++++++++++++++++++
 1 file changed, 26 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 412675fcb1..98cd73451e 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -55,6 +55,7 @@ public:
    LValues& convert(nir_alu_dest *);
    BasicBlock* convert(nir_block *);
    LValues& convert(nir_dest *);
+   SVSemantic convert(nir_intrinsic_op);
    LValues& convert(nir_register *);
    LValues& convert(nir_ssa_def *);
 
@@ -1161,6 +1162,14 @@ Converter::visit(nir_jump_instr *insn)
    return true;
 }
 
+SVSemantic
+Converter::convert(nir_intrinsic_op type)
+{
+   unsigned name, index;
+   system_val_to_tgsi_semantic(nir_system_value_from_intrinsic(type), &name, &index);
+   return translateSysVal(name);
+}
+
 bool
 Converter::visit(nir_intrinsic_instr *insn)
 {
@@ -1267,6 +1276,23 @@ Converter::visit(nir_intrinsic_instr *insn)
       mkOp(OP_DISCARD, TYPE_NONE, NULL)->setPredicate(CC_P, pred);
       break;
    }
+   case nir_intrinsic_load_base_vertex:
+   case nir_intrinsic_load_base_instance:
+   case nir_intrinsic_load_draw_id:
+   case nir_intrinsic_load_front_face:
+   case nir_intrinsic_load_instance_id:
+   case nir_intrinsic_load_sample_id:
+   case nir_intrinsic_load_vertex_id: {
+      if (insn->num_components > 1) {
+         ERROR("nir_intrinsic_front_face only with 1 component supported!\n");
+         assert(false);
+         return false;
+      }
+      Symbol *sym = mkSysVal(convert(insn->intrinsic), 0);
+      LValues &newDefs = convert(&insn->dest);
+      mkOp1(OP_RDSV, TYPE_U32, newDefs[0], sym);
+      break;
+   }
    default:
       ERROR("unknown nir_intrinsic_op %s\n", nir_intrinsic_infos[insn->intrinsic].name);
       return false;
-- 
2.14.3



More information about the mesa-dev mailing list