[Mesa-dev] [PATCH 09/22] nvir/nir: implement nir_load_const_instr

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


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp     | 20 ++++++++++++++++++++
 1 file changed, 20 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 5f0746055a..f13699a393 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -70,6 +70,7 @@ public:
    bool visit(nir_if *);
    bool visit(nir_instr *);
    bool visit(nir_jump_instr *);
+   bool visit(nir_load_const_instr*);
    bool visit(nir_loop *);
 
    bool run();
@@ -484,6 +485,10 @@ bool
 Converter::visit(nir_instr *insn)
 {
    switch (insn->type) {
+   case nir_instr_type_load_const:
+      if (!visit(nir_instr_as_load_const(insn)))
+         return false;
+      break;
    case nir_instr_type_jump:
       if (!visit(nir_instr_as_jump(insn)))
          return false;
@@ -495,6 +500,21 @@ Converter::visit(nir_instr *insn)
    return true;
 }
 
+bool
+Converter::visit(nir_load_const_instr *insn)
+{
+   assert(insn->def.bit_size <= 64);
+
+   LValues &newDefs = convert(&insn->def);
+   for (int i = 0; i < insn->def.num_components; i++) {
+      if (insn->def.bit_size > 32)
+         loadImm(newDefs[i], insn->value.u64[i]);
+      else
+         loadImm(newDefs[i], insn->value.u32[i]);
+   }
+   return true;
+}
+
 bool
 Converter::visit(nir_jump_instr *insn)
 {
-- 
2.14.3



More information about the mesa-dev mailing list