LukasBanana / XShaderCompiler

Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL
BSD 3-Clause "New" or "Revised" License
351 stars 48 forks source link

Metal target #73

Open BearishSun opened 7 years ago

BearishSun commented 7 years ago

Any plans for Metal output target?

Apple devices are stuck on OpenGL 4.1, which is fairly ancient at this point. They also seem to have zero interest in supporting Vulkan. The only way to create high-end and fully-cross platform graphical applications is to use Metal on Apple devices, which comes with its own shading language.

I'd love to see XShaderCompiler become a one-stop shop for shader cross compilation, and support Metal as well.

I'v noticed SPIR-V Cross project has added an experimental Metal target, but cross compiling through two (or even three, if starting with HLSL) intermedia languages feels really dirty. Unity also has glsloptimizer and Unreal hlslcc but neither are a match for XShaderCompiler's level of quality, by far.

LukasBanana commented 7 years ago

Thank you, I appreciate your taste for output quality. Interestingly, one of the major contributors of the SPIRV-Cross tool is the main consultant of my Master Thesis, so I've got some insights to the cross-compilation between SPIR-V and the Metal shading language.

I also agree with your concern about OpenGL 4.1 and macOS. Adding a back-end for Metal is indeed a desirable feature, but so far I can't tell when I have the time for it. I'm also stuck with the GLSL front-end.

The big advantage of SPIR-V compared to operating solely on the AST (as Xsc does it) is that it scales better when it comes to multiple front-ends and back-ends. Xsc needs to perform different transformations on the AST depending on the Input and Output code, while SPIR-V based cross-compilation has a well-defined common denominator (the IR itself) on which no further transformation needs to be done after glslang compiled it (with few exceptions).

However, supporting Metal as back-end is more likely feasible than as front-end, since it's based on C++14 and I will definitely not start writing a C++ parser by hand :o)

By the way: I will release my Master Thesis Cross-Compiling Shading Languages on this github page at the end of this week. Might be interseting to you ;)

BearishSun commented 7 years ago

Thanks for the detailed explanation and the insights!

I agree, supporting it as a backend shouldn't be nearly as much work as a front-end (let alone a c++-like one). I'm also strapped for time right now, but eventually it might be something I'd want to help with.

Great news about the thesis, I'll be sure to take a look :)

LukasBanana commented 7 years ago

Today I released my Master Thesis "Cross-Compiling Shading Languages" where I mentioned @BearishSun in the acknowledgment chapter for his support :) https://github.com/LukasBanana/XShaderCompiler/releases/tag/master-thesis

BearishSun commented 7 years ago

Awesome, thanks for the mention :) I skimmed it a bit, looks very nice, I might give it a more detailed read later.

LukasBanana commented 5 years ago

It's been a while, but I'm working on this project again. Just wanted to let you know that I started with a Metal backend.

BearishSun commented 5 years ago

Great news. I'm slowly in the process of researching Metal for integration in Banshee, so this is perfect timing :)