[Mesa-dev] [PATCH 12/22] nvir/nir: implement nir_intrinsic_load_uniform

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


Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../drivers/nouveau/codegen/nv50_ir_from_nir.cpp    | 21 +++++++++++++++++++++
 1 file changed, 21 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 d2b2236c17..9ccd84bc20 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -715,6 +715,27 @@ bool
 Converter::visit(nir_intrinsic_instr *insn)
 {
    switch (insn->intrinsic) {
+   case nir_intrinsic_load_uniform: {
+      LValues &newDefs = convert(&insn->dest);
+      nir_const_value *const_offset = nir_src_as_const_value(insn->src[0]);
+      Value *indirect = nullptr;
+      auto offset = nir_intrinsic_base(insn);
+      const DataType dType = getDType(insn);
+      auto dTypeSize = std::max(4u, typeSizeof(dType));
+
+      if (const_offset)
+         offset += const_offset->u32[0];
+      else {
+         // because nir we have to multiply with 16
+         indirect = getSrc(&insn->src[0], 0);
+         mkOp2(OP_MUL, TYPE_U32, indirect, indirect, loadImm(getScratch(), 16));
+      }
+
+      for (auto i = 0; i < insn->num_components; ++i) {
+         mkLoad(dType, newDefs[i], mkSymbol(FILE_MEMORY_CONST, 0, TYPE_U32, (offset * 4 + i * (dTypeSize / 4)) * 4), nullptr)->setIndirect(0, 0, indirect);
+      }
+      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