Replies: 3 comments
-
I am adding a new section on our document to explain this behavior. In short, you can set the input language to be "slang" not "hlsl". |
Beta Was this translation helpful? Give feedback.
-
We recommend our users to not specify HLSL as the input language even if the source is in HLSL. It is not easy to define the exact behavior of HLSL that Slang should follow, and the current implementation of -lang HLSL will turn on some legacy HLSL behavior that not all users would want. In 99% of the case skipping the -lang setting should work just fine without introducing the true legacy HLSL behaviors. |
Beta Was this translation helpful? Give feedback.
-
When you are compiling HLSL files through slangc, we recommend setting -lang slang in the command line to opt out of legacy HLSL behavior. |
Beta Was this translation helpful? Give feedback.
-
When compiling hlsl shaders with slang this code:
produces the following error:
The same code is OK when the extension of the file being compiled is
.slang
instead of.hlsl
so I imagine there's some option to toggle that behavior. Is it possible to change this independently of the file extension?While in HLSL prior to version 2021, for variables were not scoped to the body of the for loop, that code was legal, because the second declaration would simply shadow the first one. So, slang's behavior is not particularly helpful.
Since HLSL 2021 for variable declarations are scoped differently. It would be very useful to be able to replicate the new behavior, which also appears to be Slang's default. See: https://devblogs.microsoft.com/directx/hlsl-2021-migration-guide/
Beta Was this translation helpful? Give feedback.
All reactions