Please add HLSL 2021 for dxc compiler. Make it the default option or enable it by “pragma use_hlsl_2021”.
It has so many features to help developers to write cleaner shader code, for example, the template function are useful for functions that need to support different type of data. And the effort to support this feature is trivial, just add “-HV 2021” in compiler options.
It’s way harder than it sounds.
If we make it the default option, many shaders will break because of the language changes listed on the page you linked. Unity’s own shaders would need to be upgraded to support that. It would only be supported only by a subset of platforms as well, so we need to make sure that everything works after the upgrade on those that don’t.
We’d like to do that, and we’ll probably enable in in the future, but it’s not as trivial as it sounds. Even if we do it as an option that you have to opt in for, the priority of doing that needs to be weighted against other things we need to work on.
Implementing this feature is actually quite straightforward, as I have previously accomplished something similar when working with HDRP in the past. It only required a few lines of additional shader code, so on a technical level, it is relatively trivial.
The reason I am suggesting that Unity officially support this feature is because currently I have to use a workaround that involves modifying dxcompiler in order to enable it. This workaround is problematic because I have to re-apply the modification every time I update to a new version of Unity.
I have utilized the provided link to submit the feature request.
While I understand that it may not be feasible to switch HDRP/URP to HLSL 2021 immediately, could we explore the possibility of introducing customizable compiler options for shader compilation? Similar to how we have options for C#, this approach will avoid any disruption for most users while granting advanced users more control over the process.