diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-05-07 00:46:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-06 22:46:42 -0700 |
| commit | ccdb2e39da37753961f3694d0f90e676bf859006 (patch) | |
| tree | e4dd8cea8e54083283c7728df8654fa5ad4516b2 /tests/language-feature | |
| parent | 90ecf185a742efffc7e1fcf399961289b3e00d08 (diff) | |
bitcast require the input has same width with result type (#7018)
bitcast requires the input has same width with result type, this PR ensures that we always lower the bitcast IR instruction satisfies this requirement.
Close #7017.
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/bit-cast/float-bit-cast.slang | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/language-feature/bit-cast/float-bit-cast.slang b/tests/language-feature/bit-cast/float-bit-cast.slang new file mode 100644 index 000000000..66b6812c4 --- /dev/null +++ b/tests/language-feature/bit-cast/float-bit-cast.slang @@ -0,0 +1,32 @@ +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk + +struct MyStruct +{ + half a; + half b; +} + + + +//TEST_INPUT:set inputBuffer = ubuffer(data=[1.0 3.0 4.0], stride=4) +RWStructuredBuffer<float> inputBuffer; + + +//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +[shader("compute")] +void computeMain() +{ + vector<float, 1> a = {inputBuffer[0]}; + + outputBuffer[0] = bit_cast<uint>(a); + // BUF: 3F800000 + + MyStruct s = MyStruct(half(inputBuffer[1]), half(inputBuffer[2])); + outputBuffer[1] = bit_cast<uint>(s); + // 2.0 : 0x4000 + // 3.0 : 0x4200 + // BUF-NEXT: 44004200 + +} |
