Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hlsl-out] Output is not HLSL 2021 compatible #4498

Open
fornwall opened this issue Aug 30, 2023 · 1 comment
Open

[hlsl-out] Output is not HLSL 2021 compatible #4498

fornwall opened this issue Aug 30, 2023 · 1 comment
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator type: enhancement New feature or request

Comments

@fornwall
Copy link
Contributor

Naga currently generates hlsl that is not valid HLSL 2021, as there binary logic operators can only be used with scalars, so we need to change generation:

-  doit = vec && (ShouldIDoIt(vec) || !ShouldINotDoIt(vec));
+  doit = and(vec, or(ShouldIDoIt(vec), !ShouldINotDoIt(vec)));

While possible (changing countLeadingZeros() and select() writing is enough to pass CI), fxc does not support HLSL 2021 (and the and(), or() and select() intrinsics are only available in HLSL 2021).

In gfx-rs/naga#2447 we worked around the DX Compiler release for August 2023 making HLSL 2021 the default by specifying -HV 2018 in CI, but:

Ideally we should be forward compatible. [..] I think we are running into this issue only for the select implementation; we can either take the language version as a parameter or inject a polyfill for vector conditions regardless of version.

This issue is tracking that.

@teoxoy teoxoy added area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language type: enhancement New feature or request labels Aug 30, 2023
@teoxoy
Copy link
Member

teoxoy commented Aug 30, 2023

Note that this is only an issue with the select built-in as that's the only one getting translated to the ternary op ?: with a vecN<bool> condition.

@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@daxpedda daxpedda mentioned this issue Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants