Recently I've been playing around with a prototype for compiling HLSL to Vulkan. This seems like a kind of useful thing to do, so I was wondering if anyone else has tried it (using this approach, or maybe some other approach).
My prototype uses James Jones' cross compiler for this. The cross compiler takes HLSL bytecode and generates GLSL code. So the compilation steps are:
- HLSL -> HLSL bytecode
- HLSL bytecode -> GLSL
- GLSL -> SPIR-V
In theory, it seems like a viable approach, because HLSL bytecode is a reasonably simple language. And while hand-optimising code would be difficult with this approach, the compiler optimisation should still be effective.
In practice, each compilation step has it's own set of idiosyncrasies. In particular, the cross compiler needs a bit of love and attention. I've been working on adding support for the Vulkan SDK's particular subset of GLSL. And also fixing translation errors as I come across them (my branch is here, btw)
Anyway, it's such a useful thing, my guess is that maybe other people have tried similar approaches? I'd love to hear about it if so.