summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-09-30 14:13:53 -0700
committerGitHub <noreply@github.com>2025-09-30 21:13:53 +0000
commitb6422e50cb19f7f790f29678ba22f31b0b305511 (patch)
tree6ef916eb589adda70e52d8cb3f83ca9b9363cf99 /source/slang
parent8086adc90b69f3199767c0617e2c429ce6b27f67 (diff)
Handle getEquivalentStructuredBuffer(castDynamicResource) in byte address legalization pass. (#8567)
This is crash that be triggered by providing custom `getDescriptorFromHandle` and use it to return access a ByteAddressBuffer from a bindless handle. Closes #8355.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-ir-byte-address-legalize.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/slang/slang-ir-byte-address-legalize.cpp b/source/slang/slang-ir-byte-address-legalize.cpp
index baafc7e7f..15cbb6ca0 100644
--- a/source/slang/slang-ir-byte-address-legalize.cpp
+++ b/source/slang/slang-ir-byte-address-legalize.cpp
@@ -941,6 +941,19 @@ struct ByteAddressBufferLegalizationContext
{
return getEquivalentStructuredBufferParam(elementType, byteAddressBufferParam);
}
+ else if (auto castDynamicResource = as<IRCastDynamicResource>(byteAddressBuffer))
+ {
+ // If the underlying structured buffer is a CastDynamicResource,
+ // we can simply cast the dynamic resource into the byte address buffer type instead.
+ auto arg = castDynamicResource->getOperand(0);
+ return m_builder.emitIntrinsicInst(
+ getEquivalentStructuredBufferParamType(
+ elementType,
+ byteAddressBuffer->getDataType()),
+ kIROp_CastDynamicResource,
+ 1,
+ &arg);
+ }
if (byteAddressBuffer->getOp() == kIROp_GetElement)
{