diff options
| author | Yong He <yonghe@outlook.com> | 2024-01-09 12:41:07 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-09 12:41:07 -0800 |
| commit | 8dd04c8730327d7dc2fd29b43b8566fabbc3aa2c (patch) | |
| tree | feeb609fd142d1b404f16f8ecded37fb12655e75 /tests | |
| parent | 69f3d7917d66c370ff87832dbbe2d05c5795d5ce (diff) | |
Fix funcs w/ buffer load being treated as readnone. (#3441)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-3429.slang | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/bugs/gh-3429.slang b/tests/bugs/gh-3429.slang new file mode 100644 index 000000000..e4eda5b38 --- /dev/null +++ b/tests/bugs/gh-3429.slang @@ -0,0 +1,55 @@ +// This test checks that kIROp_StructuredBufferLoad and similar instructions +// are not movable. + +//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target hlsl + +[[vk::binding(0, 0)]] +StructuredBuffer<float> gSomeData; + +[[vk::binding(1, 0)]] +RWTexture2D<float4> gResultImage; + +struct PushConstants +{ + bool bufferHasOnlyOneElement; +}; + +[[vk::push_constant]] ConstantBuffer<PushConstants> gPushConstants; + +float loadDataConditionTrue() +{ + return gSomeData[0]; +} + +float loadDataConditionFalse() +{ + return gSomeData[1]; +} + +[ForceInline] +float getDataDependingOnCondition(bool condition) +{ + if (condition) + { + return loadDataConditionTrue(); + } + else + { + return loadDataConditionFalse(); + } + + return 0.0; +} + +[numthreads(1,1,1)] +void computeMain() +{ + // CHECK: if + // CHECK: loadDataConditionTrue + // CHECK: else + // CHECK: loadDataConditionFalse + float v = getDataDependingOnCondition(gPushConstants.bufferHasOnlyOneElement); + + int2 pixelIndex = int2(DispatchRaysIndex().xy); + gResultImage[pixelIndex] = float4(v, v, v, 1.0); +} |
