[Mesa-dev] [PATCH 13/22] nvir/nir: implement nir_intrinsic_store_output
Karol Herbst
kherbst at redhat.com
Thu Dec 21 15:51:31 UTC 2017
Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
.../drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 43 ++++++++++++++++++++++
1 file changed, 43 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 9ccd84bc20..896a02af96 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -487,6 +487,11 @@ Converter::visit(nir_function *function)
setPosition(entry, true);
+ if (info->io.genUserClip > 0) {
+ for (int c = 0; c < 4; ++c)
+ clipVtx[c] = getScratch();
+ }
+
switch (prog->getType()) {
case Program::TYPE_TESSELLATION_CONTROL:
outBase = mkOp2v(
@@ -513,6 +518,8 @@ Converter::visit(nir_function *function)
bb->cfg.attach(&exit->cfg, Graph::Edge::TREE);
setPosition(exit, true);
+ if (info->io.genUserClip > 0)
+ handleUserClipPlanes();
// TODO: for non main function this needs to be a OP_RETURN
mkOp(OP_EXIT, TYPE_NONE, NULL)->terminator = 1;
return true;
@@ -736,6 +743,42 @@ Converter::visit(nir_intrinsic_instr *insn)
}
break;
}
+ case nir_intrinsic_store_output: {
+ nir_const_value *const_offset = nir_src_as_const_value(insn->src[1]);
+ auto idx = nir_intrinsic_base(insn) + const_offset->u32[0];
+ uint8_t offset = insn->const_index[2];
+ for (auto i = 0u; i < insn->num_components; ++i) {
+ Value *src = getSrc(&insn->src[0], i);
+ switch (prog->getType()) {
+ case Program::TYPE_FRAGMENT: {
+ if (info->out[idx].sn == TGSI_SEMANTIC_POSITION) {
+ // TGSI uses a different interface than NIR, TGSI stores that value in the z component, NIR in X
+ offset += 2;
+ src = mkOp1v(OP_SAT, TYPE_F32, getScratch(), src);
+ }
+ break;
+ }
+ case Program::TYPE_VERTEX: {
+ if (info->io.genUserClip > 0) {
+ mkMov(clipVtx[i], src);
+ src = clipVtx[i];
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ assert(i + offset < 4);
+ uint32_t address = info->out[idx].slot[i + offset];
+ mkStore(OP_EXPORT,
+ TYPE_F32,
+ mkSymbol(FILE_SHADER_OUTPUT, 0, TYPE_U32, address * 4),
+ nullptr,
+ src);
+ }
+ 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