summaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/language-feature/descriptor-handle/byte-address-buffer-handle.slang38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/language-feature/descriptor-handle/byte-address-buffer-handle.slang b/tests/language-feature/descriptor-handle/byte-address-buffer-handle.slang
new file mode 100644
index 000000000..eccba9723
--- /dev/null
+++ b/tests/language-feature/descriptor-handle/byte-address-buffer-handle.slang
@@ -0,0 +1,38 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK: OpAccessChain %_ptr_StorageBuffer_RWStructuredBuffer %resourceHandles
+
+[vk::binding(0, 0)]
+__DynamicResource<__DynamicResourceKind.General> resourceHandles[];
+
+[vk::binding(0, 1)]
+__DynamicResource<__DynamicResourceKind.Sampler> samplerHandles[];
+
+export T getDescriptorFromHandle<T>(DescriptorHandle<T> handle) where T : IOpaqueDescriptor
+{
+ __target_switch
+ {
+ case spirv:
+ if (T.kind == DescriptorKind.Sampler) {
+ return samplerHandles[((uint2)handle).x].asOpaqueDescriptor<T>();
+ }
+ else {
+ return resourceHandles[((uint2)handle).x].asOpaqueDescriptor<T>();
+ }
+ default:
+ return defaultGetDescriptorFromHandle(handle);
+ }
+}
+
+// test.slang
+struct PushConstant
+{
+ RWByteAddressBuffer.Handle test_buffer;
+};
+[[vk::push_constant]] PushConstant constant;
+
+[shader("fragment")]
+void main_test_fs(float2 fragment_coord: SV_Position, out float4 color: SV_Target)
+{
+ color = float4(constant.test_buffer.Load<uint3>(0), 1.0);
+}