[Mesa-dev] [PATCH 14/22] nvir/nir: implement nir_intrinsic_load_input

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


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp   | 30 ++++++++++++++++++++++
 1 file changed, 30 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 896a02af96..009f3df875 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -779,6 +779,36 @@ Converter::visit(nir_intrinsic_instr *insn)
       }
       break;
    }
+   case nir_intrinsic_load_input: {
+      nir_const_value *const_offset = nir_src_as_const_value(insn->src[0]);
+      const DataType dType = getDType(insn);
+
+      if (!const_offset) {
+         ERROR("nir_intrinsic_load_input without const_value not supported!\n");
+         return false;
+      }
+
+      LValues &newDefs = convert(&insn->dest);
+      auto idx = nir_intrinsic_base(insn) + const_offset->u32[0];
+      uint8_t offset = insn->const_index[1];
+      for (auto i = 0u; i < insn->num_components; ++i) {
+         assert(i + offset < 4);
+         uint32_t address = info->in[idx].slot[i + offset];
+         Symbol *sym = mkSymbol(FILE_SHADER_INPUT, 0, TYPE_U32, address * 4);
+         switch(prog->getType()) {
+         case Program::TYPE_FRAGMENT: {
+            operation op;
+            auto mode = translateInterpMode(&info->in[idx], op);
+            mkOp2(op, TYPE_F32, newDefs[i], sym, op == OP_PINTERP ? fp.position : nullptr)->setInterpolate(mode);
+            break;
+         }
+         default:
+            mkLoad(dType, newDefs[i], sym, nullptr);
+            break;
+         }
+      }
+      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