From 661d6198bbb9857d3fdc6df477e0742ed0b0765c Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 14 Aug 2023 16:23:19 -0700 Subject: Support per field matrix layout (#3101) * Support per field matrix layout * Fix warnings. * Fix. * Fix tests. * Fix spiv gen. * Fix. * More test fixes. * Fix. * Run only GPU tests on self-hosted servers. * Remove -use-glsl-matrix-layout-modifier. * Fix. --------- Co-authored-by: Yong He --- source/slang/slang-emit-spirv.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index c16ee6a90..bafbb79f1 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1619,6 +1619,15 @@ struct SPIRVEmitContext return emitLoad(parent, as(inst)); case kIROp_Store: return emitStore(parent, as(inst)); + case kIROp_StructuredBufferLoad: + case kIROp_StructuredBufferLoadStatus: + case kIROp_RWStructuredBufferLoad: + case kIROp_RWStructuredBufferLoadStatus: + return emitStructuredBufferLoad(parent, inst); + case kIROp_RWStructuredBufferStore: + return emitStructuredBufferStore(parent, inst); + case kIROp_RWStructuredBufferGetElementPtr: + return emitStructuredBufferGetElementPtr(parent, inst); case kIROp_swizzle: return emitSwizzle(parent, as(inst)); case kIROp_IntCast: @@ -2645,6 +2654,30 @@ struct SPIRVEmitContext return emitInst(parent, inst, SpvOpStore, inst->getPtr(), inst->getVal()); } + SpvInst* emitStructuredBufferLoad(SpvInstParent* parent, IRInst* inst) + { + //"%addr = OpAccessChain resultType*StorageBuffer resultId _0 const(int, 0) _1; OpLoad resultType resultId %addr;" + IRBuilder builder(inst); + auto addr = emitInst(parent, inst, SpvOpAccessChain, inst->getOperand(0)->getDataType(), kResultID, inst->getOperand(0), emitIntConstant(0, builder.getIntType()), inst->getOperand(1)); + return emitInst(parent, inst, SpvOpLoad, inst->getFullType(), kResultID, addr); + } + + SpvInst* emitStructuredBufferStore(SpvInstParent* parent, IRInst* inst) + { + //"%addr = OpAccessChain resultType*StorageBuffer resultId _0 const(int, 0) _1; OpStore %addr _2;" + IRBuilder builder(inst); + auto addr = emitInst(parent, inst, SpvOpAccessChain, inst->getOperand(0)->getDataType(), kResultID, inst->getOperand(0), emitIntConstant(0, builder.getIntType()), inst->getOperand(1)); + return emitInst(parent, inst, SpvOpStore, addr, inst->getOperand(2)); + } + + SpvInst* emitStructuredBufferGetElementPtr(SpvInstParent* parent, IRInst* inst) + { + //"%addr = OpAccessChain resultType*StorageBuffer resultId _0 const(int, 0) _1;" + IRBuilder builder(inst); + auto addr = emitInst(parent, inst, SpvOpAccessChain, inst->getDataType(), kResultID, inst->getOperand(0), emitIntConstant(0, builder.getIntType()), inst->getOperand(1)); + return addr; + } + SpvInst* emitSwizzle(SpvInstParent* parent, IRSwizzle* inst) { if (inst->getElementCount() == 1) -- cgit v1.2.3