From 9580e311e0cefb0f8e11afc316783a67201654eb Mon Sep 17 00:00:00 2001 From: Mukund Keshava Date: Thu, 20 Feb 2025 14:12:15 +0530 Subject: HLSL: Add 'f' suffix to float literals in code generation (#6381) * HLSL: Add 'f' suffix to float literals in code generation Fixes #6078 1) Previously, Slang would emit HLSL float literals without a suffix (e.g.,"1.5"), which caused DXC to interpret them as 64-bit doubles by default unless the -HV 202x flag was used. This could cause validation errors when these literals were used with intrinsics that only accept 32-bit floats (like ddx, ddy). This change modifies the HLSL emitter to explicitly add 'f' suffix to 32-bit float literals, ensuring they are correctly typed regardless of DXC's version or flags. For example: - "1.5" becomes "1.5f" - "(0.0 / 0.0)" becomes "(0.0f / 0.0f)" for NaN - "float4(1.0, 2.0, 3.0, 4.0)" becomes "float4(1.0f, 2.0f, 3.0f, 4.0f)" 2) Added a test case to verify the behavior with various float literal scenarios including basic literals, intrinsic calls, and vector construction. 3) Remove some tests that were marked as known failures * Add dxil test as suggested by jkwak-work --- tests/expected-failure-github.txt | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/expected-failure-github.txt') diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt index 60d632785..8a399b2e0 100644 --- a/tests/expected-failure-github.txt +++ b/tests/expected-failure-github.txt @@ -1,9 +1,7 @@ -tests/language-feature/spirv-asm/imageoperands-warning.slang (vk) tests/language-feature/saturated-cooperation/simple.slang (vk) tests/language-feature/saturated-cooperation/fuse3.slang (vk) tests/language-feature/saturated-cooperation/fuse-product.slang (vk) tests/language-feature/saturated-cooperation/fuse.slang (vk) -tests/bugs/byte-address-buffer-interlocked-add-f32.slang (vk) tests/render/render0.hlsl (mtl) tests/render/multiple-stage-io-locations.slang (mtl) tests/render/nointerpolation.hlsl (mtl) -- cgit v1.2.3