<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/hlsl/float-literal-suffix.slang, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-02-20T08:42:15+00:00</updated>
<entry>
<title>HLSL: Add 'f' suffix to float literals in code generation (#6381)</title>
<updated>2025-02-20T08:42:15+00:00</updated>
<author>
<name>Mukund Keshava</name>
<email>mkeshava@nvidia.com</email>
</author>
<published>2025-02-20T08:42:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=9580e311e0cefb0f8e11afc316783a67201654eb'/>
<id>urn:sha1:9580e311e0cefb0f8e11afc316783a67201654eb</id>
<content type='text'>
* 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</content>
</entry>
</feed>
