Jump to content
  • Advertisement
Sign in to follow this  
dpj

Vulkan Compiling HLSL to Vulkan

This topic is 818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement

It should be possible (and more useful) to remove GLSL entirely from this, and do HLSL bytecode directly to SPIR-V.

Share this post


Link to post
Share on other sites
I'd love to use OpenCL language for compute shaders in Vulkan.
It might be possible to use goodies like 2.0 workgroup functions (broadcast, reduce, scan...) that work without LDS.
It really hurts those features are still hidden from PC APIs.

Share this post


Link to post
Share on other sites

Apparently with the next version of HLSL, MS is moving over to using LLVM as the back-end for their compiler, which should make a direct HLSL->SPIR-V project a lot easier :)

I'd love to use OpenCL language for compute shaders in Vulkan.
It might be possible to use goodies like 2.0 workgroup functions (broadcast, reduce, scan...) that work without LDS.
It really hurts those features are still hidden from PC APIs.

These are apparently coming in the new HLSL too ;)
I haven't looked as to whether they exist in SPIR-V yet, but that would obviously be a requirement.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!