HLSL to SPIR-V and back: DXC, SPIRV-Cross, dxil-spirv
11 steps · about 5 h 25 min · Intermediate
- What is SPIR-V :: Vulkan Documentation Project (doc, Vulkan Documentation Project, 10 min)
Start with why Vulkan takes a SPIR-V binary instead of source text, and which compilers produce it.
- An Introduction to SPIR-V: A Khronos-Defined Intermediate Language (article, Khronos Group, 25 min)
This gives the design goals and binary-form ideas that explain why SPIR-V suits a translation pipeline.
- HLSL in Vulkan :: Vulkan Documentation Project (doc, Vulkan Documentation Project, 20 min)
It shows the first real compile step, HLSL to SPIR-V with dxc -spirv, including the -T and -E flags.
- SPIR‐V CodeGen · microsoft/DirectXShaderCompiler Wiki (doc, Microsoft DirectXShaderCompiler, 15 min)
The compiler's own wiki covers building and invoking the SPIR-V backend and its Vulkan-specific options.
- Vulkan High Level Shader Language Comparison (doc, LunarG / Vulkan Documentation Project, 15 min)
It covers practical details such as the __spirv__ macro and vk::binding, so one HLSL file can target both D3D and Vulkan.
- HLSL to SPIR-V Feature Mapping Manual (reference, Microsoft DirectXShaderCompiler, 40 min)
Read this once you can compile a shader, to see how semantics, registers and resources map onto Vulkan locations and bindings.
- SPIRV-Cross: reflection and disassembly of SPIR-V back to high-level languages (repo, Khronos Group (GitHub), 40 min)
This is the 'and back' half: turning SPIR-V into GLSL, HLSL or MSL, with the caveats of descriptor sets and combined image samplers.
- SPIR-V Specification (reference, Khronos Registry, 1 h)
Use the spec to read disassembled output and check what each instruction, decoration and capability means.
- My personal hell of translating DXIL to SPIR-V – part 1 (blog, Hans-Kristian Arntzen (themaister.net), 35 min)
The author of dxil-spirv explains how DXIL, which is LLVM bitcode, differs from SPIR-V and how it is translated.
- My personal hell of translating DXIL to SPIR-V – part 3 (blog, Hans-Kristian Arntzen (themaister.net), 35 min)
It moves from shader code to the D3D12 binding model: root signatures, descriptors and heaps mapped onto Vulkan.
- dxil-spirv: DXIL conversion to SPIR-V for D3D12 translation libraries (repo, HansKristian-Work (GitHub), 30 min)
Finish with the production translator behind vkd3d-proton on Linux, including its roundtrip and test scripts.