From e420f2f980813559b186a6a6bcd5540f74310d02 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 9 Oct 2025 18:30:24 -0700 Subject: Defer `IRCastStorageToLogicalDeref` in lowerBufferElementType pass. (#8668) Fix a regression on metal test. In `lowerBufferElementTypeToStorageType` pass, not only we want to defer an argument that is `CastStorageToLogical` to the callee, but also apply the same defer logic to `CastStorageToLogicalDeref` as well. Because `CastStorageToLogicalDeref` will appear as argumnet if `lowerBufferElementTypeToStorageType` is run before we apply the `in->borrow` transformation pass, which is the case for metal parameter block legalization. --- tests/metal/sampler-array.slang | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/metal/sampler-array.slang (limited to 'tests') diff --git a/tests/metal/sampler-array.slang b/tests/metal/sampler-array.slang new file mode 100644 index 000000000..65476543e --- /dev/null +++ b/tests/metal/sampler-array.slang @@ -0,0 +1,34 @@ +//TEST:SIMPLE(filecheck=MTL): -target metal -stage compute -entry computeMain +//TEST:SIMPLE(filecheck=LIB): -target metallib -stage compute -entry computeMain + +// MTL: float S1_test{{.*}}(const S1_default{{.*}} constant* this{{.*}} +// LIB: computeMain + +struct S1 +{ + Texture2D tex[32]; + SamplerState samplers[32]; + float data; + float test(int i) + { + return tex[i].SampleLevel(samplers[i], float2(0.0, 0.0), 0.0).x + data; + } +} + +struct S0 +{ + float data; + RaytracingAccelerationStructure acc; + ParameterBlock s; +} + +ParameterBlock g; +RWStructuredBuffer buffer; + +[shader("compute")] +[numthreads(1,1,1)] +void computeMain( + uint3 sv_dispatchThreadID : SV_DispatchThreadID) +{ + buffer[0] = g.data * g.s.test(sv_dispatchThreadID.x); +} -- cgit v1.2.3