-
Notifications
You must be signed in to change notification settings - Fork 37
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
Specialization constants #16
Comments
Just for the record, HLSL does support specialization constants (As it can be compiled to SPIRV by both Microsoft compiler and GLSLang). The support is entirely lacking in DXIL. There are two main uses for specialization constants. The lack of them makes these use cases cumbersome:
There is zero effort in supporting them, since it should just be an extra argument to the pipeline compilation, like in Vulkan. |
@RandomShaper, thank you very much for filing this request! This request is not new to us. We've heard it and it is on our minds. Unfortunately this is not a feature we can develop publicly. As we state in the process docs:
Adding specialization constants requires altering the DXIL specification, the DirectX runtime, and the driver interface, so this feature would need to be part of a new Shader Model. We don't really have a good way to track that publicly, so I'll take an action item to discuss with my team how to best manage this so that we don't leave you completely hanging. @reduz, thank you for the extra context. The more context we have the easier it is for us to prioritize requests. I also would ask that you refrain from comments like:
This kind of generalization isn't constructive, and undermines the work of our team and our partners both inside Microsoft and across the industry. Your statement assumes that we would adopt the Vulkan syntax (which isn't a given), and then ignores that we would need to support code generation, runtime integration and work with hardware vendors to update drivers. I assure you if this required "zero effort", the feature would be available already. |
Sorry Chris, this is not what I intended to say and I apologize if it came through that way (I'm not a native English speaker), as I fully understand the effort and cost involved (I take part in such working groups too). My comment makes reference to the fact that, unlike other driver features, we guess that this one should not require doing significant driver modifications (bureaucracy aside). We experimented with @RandomShaper on patching DXIL code (in a manner similar of how the driver would do so) and observing native bytecode generated by the drivers afterwards, and all of them do the proper dead code removal. |
Pinging @jenatali as potential stakeholder within Microsoft. |
We moved the original DXC issue over to this repository and will track the feature request using the original issue: |
Is your feature request related to a problem? Please describe.
Yes. Currently the whole HLSL to DXIL to PSO flow must be re-run whenever certain key values that need to vary among variants of a given shader change.
Describe the solution you'd like
I'd like that there was a syntactic way to declare specialization constants in HLSL, similarly as it can be done in GLSL. For PSO creation non-default values could be specified, much like it currently works in Vulkan.
UPDATE: @reduz's comment reminded me that there are some compatibility annotations (https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#specialization-constants) that make it possible to have concepts from the Vulkan realm in HLSL. However, for first class support, a more native syntax, like
register()
in resource declarations would be what I'm suggesting; e.g.:Describe alternatives you've considered
Additional context
I'm aware that this change would span across the whole ecosystem, from HLSL parsing up to IHV drivers, but it would be worthy to do.
It was also requested in the DXC repo: #71.
The text was updated successfully, but these errors were encountered: