FI: Shader Compiler
What is the Problem?
Vulkan Samples currently does online shader compilation and has no strict API for handling shader resources other than resources which are reflected. This means that utilizing HLSL or offline compilation is not a trivial task in Vulkan Samples which has slowed the development of HLSL samples to a halt.
What is the proposed Solution?
Create a single Shader interface which can be used with all samples. Preferable generate headers for shader resources so that breaking shader changes can be found across samples easily.
The interface would be comprised of a Compiler, a Reflector and a Resource Pack/Shader Pack.
The GLSL Compiler and SPIRV Reflector already present in Samples can be ported to the new interface.
Eventually a small offline compiler binary can be written using the same libraries used for online compilation. This can be triaged with CMake Custom Commands to automatically compile shaders at compile time. Online compilation would then only be used for shader hot reloading.
@SaschaWillems as you have been working on a DXC compiler please add any input to this idea :)
What is a Shader Pack?
A generated header would contain a namespace composed from the shaders name and inside the namespace a selection of resource structs containing all needed information when making bindings or descriptor sets.
The alternative would be to "just use strings". Which is still a valid option in the short term but can become harder to debug in the long term with more and more samples which can be effected by shader changes.
Examples
No examples yet
Issues
- Hard to design. First start by porting online compilers and reflection to the new project structure
- We would need to agree on a schema for shader packs
- We may need to revisit past shaders and reorganize their resources or decide on a specific set of bindings used by all shaders.
We discussed the HLSL/GLSL topic at today's call. And the most pragmatic approach would be to compile shaders offline and just load the resulting SPIR-V. See #637 for more details.