summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-12-13 12:24:27 -0800
committerGitHub <noreply@github.com>2023-12-13 12:24:27 -0800
commit1406aa2bc9e398e5e5565ba9c6adbb780c29fee1 (patch)
treeab284f85a72d77db7462d3f38a272a3966ed7c83 /source/slang/slang-emit-spirv.cpp
parent6cbe215e58eeb8edc53d71e8f315e2fb55c0eeee (diff)
Add spirv intrinsics for `ConstBufferPointer`. (#3407)
Fixes #3305. Fixes #3404. 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.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index d071328c4..5939754e0 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -429,6 +429,8 @@ struct SPIRVEmitContext
/// The next destination `<id>` to allocate.
SpvWord m_nextID = 1;
+ SpvAddressingModel m_addressingMode = SpvAddressingModelLogical;
+
// We will store the logical sections of the SPIR-V module
// in a single array so that we can easily look up a
// section by its `SpvLogicalSectionID`.
@@ -1200,7 +1202,7 @@ struct SPIRVEmitContext
emitOpMemoryModel(
getSection(SpvLogicalSectionID::MemoryModel),
nullptr,
- SpvAddressingModelLogical,
+ m_addressingMode,
SpvMemoryModelGLSL450
);
}
@@ -1394,6 +1396,14 @@ struct SPIRVEmitContext
requireSPIRVCapability(SpvCapabilityShaderInvocationReorderNV);
return emitOpTypeHitObject(inst);
+ case kIROp_HLSLConstBufferPointerType:
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_variable_pointers"));
+ requireSPIRVCapability(SpvCapabilityVariablePointers);
+ ensureExtensionDeclaration(UnownedStringSlice("SPV_KHR_physical_storage_buffer"));
+ requireSPIRVCapability(SpvCapabilityPhysicalStorageBufferAddresses);
+ m_addressingMode = SpvAddressingModelPhysicalStorageBuffer64;
+ return emitOpTypePointer(inst, SpvStorageClassPhysicalStorageBuffer, inst->getOperand(0));
+
case kIROp_FuncType:
// > OpTypeFunction
//
@@ -4908,7 +4918,6 @@ SlangResult emitSPIRVFromIR(
}
#endif
- context.emitFrontMatter();
for (auto inst : irModule->getGlobalInsts())
{
if (as<IRDebugSource>(inst))
@@ -4925,6 +4934,8 @@ SlangResult emitSPIRVFromIR(
{
context.ensureInst(irEntryPoint);
}
+ context.emitFrontMatter();
+
context.emitPhysicalLayout();
spirvOut.addRange(