From 1653731718e75c297730dfb878e9f23895d1051d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 1 Aug 2023 15:39:28 -0400 Subject: Fix literals needing cast (#3039) * Cast integer literals. * Fix expected output. * For CUDA, search global instructions to see what types are used. Improve lookup for fp16 header in CUDA. * Fix issue with f16tof32 * Small improvement around finding used base types. --- tests/hlsl-intrinsic/asfloat16.slang | 25 +++++++++++++++++++++++ tests/hlsl-intrinsic/asfloat16.slang.expected.txt | 9 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/hlsl-intrinsic/asfloat16.slang create mode 100644 tests/hlsl-intrinsic/asfloat16.slang.expected.txt (limited to 'tests') diff --git a/tests/hlsl-intrinsic/asfloat16.slang b/tests/hlsl-intrinsic/asfloat16.slang new file mode 100644 index 000000000..1c1e8a085 --- /dev/null +++ b/tests/hlsl-intrinsic/asfloat16.slang @@ -0,0 +1,25 @@ +// Float16 not supported on CPU currently +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type +// Doesn't work on FXC +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile sm_6_2 -render-feature half -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature int16,half -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(8, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + // 1 + float16_t m = asfloat16(uint16_t(0x3c00)); + + float16_t v = asfloat16(uint16_t(0x3c00 + (idx << 8))) + m; + float f = v; + + outputBuffer[idx] = f; +} \ No newline at end of file diff --git a/tests/hlsl-intrinsic/asfloat16.slang.expected.txt b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt new file mode 100644 index 000000000..a63c5c85a --- /dev/null +++ b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt @@ -0,0 +1,9 @@ +type: float +2.000000 +2.250000 +2.500000 +2.750000 +3.000000 +3.500000 +4.000000 +4.500000 -- cgit v1.2.3