diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-14 16:23:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-14 16:23:19 -0700 |
| commit | 661d6198bbb9857d3fdc6df477e0742ed0b0765c (patch) | |
| tree | 974a57cfa2e43624e91502e9e652a0cc78105b3a /source/slang/slang-emit-spirv.cpp | |
| parent | 0403e0556b470f6b316153caea2dc6f5c314da5b (diff) | |
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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<IRLoad>(inst)); case kIROp_Store: return emitStore(parent, as<IRStore>(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<IRSwizzle>(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) |
