Description
Tested with v2025.5.1, compiling the following code:
Texture2D<float4> input;
RWTexture2D<float4> output;
float3 LoadSourceColor(uint2 pixelPos, int2 offset) {
return input.Load(int3(pixelPos, 0), offset).rgb;
}
[shader("compute")]
void Test(uint3 thread_index : SV_DispatchThreadID) {
float4 result = 0;
[unroll]
for (int i = 0; i < 3 * 3 - 1; i++) {
//result.rgb += input.Load(int3(thread_index.xy, 0), int2( i % 3, i / 3 )).rgb;
result.rgb += LoadSourceColor(thread_index.xy, int2( i % 3, i / 3 )).rgb;
}
output[thread_index.xy] = result;
}
- Slang fails to unroll the loop when a function is called inside the loop. Inlining the load correctly unrolls the loop.
- When the loop fails to unroll, invalid SPIR-V is generated for
OpImageFetch
withConstOffset
instead ofOffset
, using a non constant value.
Metadata
Metadata
Assignees
Labels
No labels