diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-18 12:48:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-18 12:48:46 -0700 |
| commit | f94b2f7a328a898c5e3dc1389d08e0b7ce6e092e (patch) | |
| tree | 129f39703b10b5684825ce8626d3a4e908970fad /tests/language-feature | |
| parent | 4de3d9b1987fddf8d95efe75aab592282b672a97 (diff) | |
Allow loop counters to be used as constexpr arguments. (#3139)
* Allow loop counters to be used as constexpr arguments.
* Fix.
* Fix.
* Fix.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/constants/constexpr-loop.slang | 24 | ||||
| -rw-r--r-- | tests/language-feature/constants/constexpr-loop.slang.expected.txt | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/language-feature/constants/constexpr-loop.slang b/tests/language-feature/constants/constexpr-loop.slang new file mode 100644 index 000000000..31b4294a5 --- /dev/null +++ b/tests/language-feature/constants/constexpr-loop.slang @@ -0,0 +1,24 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type + +//TEST_INPUT: set g_texture = Texture2D(size=8, content = one) +//TEST_INPUT: set g_sampler = Sampler +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer + +Texture2D g_texture; +SamplerState g_sampler; +RWStructuredBuffer<float> outputBuffer; + +float4 sample(float2 uv, constexpr int2 ofs ) +{ + return g_texture.SampleLevel(g_sampler, uv, 0.0, ofs); +} + +[numthreads(1, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + float4 result = 0; + for (int i = 0; i < 3; i++) + result += sample(float2(1.0), int2(i, i)); + outputBuffer[dispatchThreadID.x] = result.x; +} diff --git a/tests/language-feature/constants/constexpr-loop.slang.expected.txt b/tests/language-feature/constants/constexpr-loop.slang.expected.txt new file mode 100644 index 000000000..a6122d7ce --- /dev/null +++ b/tests/language-feature/constants/constexpr-loop.slang.expected.txt @@ -0,0 +1,2 @@ +type: float +3.000000 |
