From 1406aa2bc9e398e5e5565ba9c6adbb780c29fee1 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 13 Dec 2023 12:24:27 -0800 Subject: Add spirv intrinsics for `ConstBufferPointer`. (#3407) Fixes #3305. Fixes #3404. Co-authored-by: Yong He --- source/slang/slang-emit-spirv.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (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 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 `` 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(inst)) @@ -4925,6 +4934,8 @@ SlangResult emitSPIRVFromIR( { context.ensureInst(irEntryPoint); } + context.emitFrontMatter(); + context.emitPhysicalLayout(); spirvOut.addRange( -- cgit v1.2.3