From eb3970897049269602cc18cee644e437c0aff928 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 7 May 2024 21:50:41 -0700 Subject: Make sure pointer local vars have `AliasedPointer` decoration. (#4132) --- source/slang/slang-emit-spirv.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index a7cdfc8a3..8219d3534 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -4077,6 +4077,8 @@ struct SPIRVEmitContext return; if (ptrType->getAddressSpace() == SpvStorageClassPhysicalStorageBuffer) { + // If inst has a pointer type with PhysicalStorageBuffer address space, + // emit AliasedPointer decoration. emitOpDecorate( getSection(SpvLogicalSectionID::Annotations), nullptr, @@ -4084,6 +4086,23 @@ struct SPIRVEmitContext (as(inst) ? SpvDecorationAliasedPointer : SpvDecorationAliased) ); } + else + { + // If the pointee type is a pointer with StorageBuffer address space, + // we also want to emit AliasedPointer decoration. + ptrType = as(ptrType->getValueType()); + if (!ptrType) + return; + if (ptrType->getAddressSpace() == SpvStorageClassPhysicalStorageBuffer) + { + emitOpDecorate( + getSection(SpvLogicalSectionID::Annotations), + nullptr, + varInst, + (as(inst) ? SpvDecorationAliasedPointer : SpvDecorationAliased) + ); + } + } } SpvInst* emitParam(SpvInstParent* parent, IRInst* inst) -- cgit v1.2.3