-
Notifications
You must be signed in to change notification settings - Fork 12
Added vulkan headers for macOS compilation #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Why does zwidget need to include the vulkan headers? There's nothing in the PR that seems to reference them - feels like I'm missing something here. Note that for the other platforms zwidget declares the vulkan definitions manually where it needs it just enough for it to initialize vulkan. Applications doing vulkan is expected to bring their own vulkan headers - either via volk or something like zvulkan. Here's how win32 backend does it: https://github.com/dpjudas/ZWidget/blob/master/src/window/win32/win32_display_window.cpp#L1000-L1079 Here's how x11 does it: https://github.com/dpjudas/ZWidget/blob/master/src/window/x11/x11_display_window.cpp#L1178-L1268 The way this was done was basically to grab the few definitions from the actual vulkan headers we need to create the surface. PS. The zvulkan SPIR-V thing sounds very interesting. If it works well maybe zvulkan could be upgraded to zgpu :) |
|
You are right, sorry I'll PR soon with the updated code. The library is called shader_translator and it uses the hard work you've already done for ZVulkan to map the shader code to msl or hlsl using the existing glslang library and adding spirv-cross. If you'd like I can take that out and put the library into shader-translator if you'd like a pure vulkan implementation and then shader_translator can depend on just the existing libraries for ZVulkan. n.b sorry didn't read that properly. That would be awesome to merge both the libraries into ZVulkan. If you'd like I'll do that and make a PR, then it will be possible(I haven't tested HLSL, need a Windows machine) to have both a DX12 renderer and Metal. |
|
Merged the PR - thanks! About shader_translator, does it generate HLSL (which then needs to be compiled by DX12's shader compiler), or does generate DXIL bytecode? Main reason I'm asking is that DX12's shader compiler requires all of LLVM, if I remember correctly. I can't promise I'll merge a PR for zvulkan as it really depends on how much extra dependencies it adds to zvulkan, but the idea certainly sounds interesting. |
|
I'm working on it now, thinking of adding the sources for dxc, glslang is
already included and spirv-cross. I got claude to generate a file for a
high level overview and it outputs either SPIR-V or DXIL. I guess when
shader model 7 comes out it can directly translate SPIR-V. However it can
output to all 3 different render systems, Metal, DX12 and Vulkan from HLSL.
And also the work you've done for GLSL to Vulkan which I assume is most of
the code for existing mods. I think making it self contained rather than
using the Vulkan sdk's binaries might be the best.
…On Fri, Nov 7, 2025 at 5:52 PM Magnus Norddahl ***@***.***> wrote:
*dpjudas* left a comment (dpjudas/ZWidget#46)
<#46 (comment)>
Merged the PR - thanks!
About shader_translator, does it generate HLSL (which then needs to be
compiled by DX12's shader compiler), or does generate DXIL bytecode? Main
reason I'm asking is that DX12's shader compiler requires all of LLVM, if I
remember correctly. I can't promise I'll merge a PR for zvulkan as it
really depends on how much extra dependencies it adds to zvulkan, but the
idea certainly sounds interesting.
—
Reply to this email directly, view it on GitHub
<#46 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZ24SIK3QEUPBTYA3HNSIL33QQRNAVCNFSM6AAAAACLMH7EUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBQG4YDMNBTGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
I guess on Windows, I think you're right in that it requires llvm which
macOS includes by default. For Linux it might require installing the
packages for llvm and I'm guessing the best way on Windows is to install
the Agility SDK or whatever it's called.
On Fri, Nov 7, 2025 at 6:09 PM John Curley ***@***.***>
wrote:
… I'm working on it now, thinking of adding the sources for dxc, glslang is
already included and spirv-cross. I got claude to generate a file for a
high level overview and it outputs either SPIR-V or DXIL. I guess when
shader model 7 comes out it can directly translate SPIR-V. However it can
output to all 3 different render systems, Metal, DX12 and Vulkan from HLSL.
And also the work you've done for GLSL to Vulkan which I assume is most of
the code for existing mods. I think making it self contained rather than
using the Vulkan sdk's binaries might be the best.
On Fri, Nov 7, 2025 at 5:52 PM Magnus Norddahl ***@***.***>
wrote:
> *dpjudas* left a comment (dpjudas/ZWidget#46)
> <#46 (comment)>
>
> Merged the PR - thanks!
>
> About shader_translator, does it generate HLSL (which then needs to be
> compiled by DX12's shader compiler), or does generate DXIL bytecode? Main
> reason I'm asking is that DX12's shader compiler requires all of LLVM, if I
> remember correctly. I can't promise I'll merge a PR for zvulkan as it
> really depends on how much extra dependencies it adds to zvulkan, but the
> idea certainly sounds interesting.
>
> —
> Reply to this email directly, view it on GitHub
> <#46 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AEZ24SIK3QEUPBTYA3HNSIL33QQRNAVCNFSM6AAAAACLMH7EUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBQG4YDMNBTGM>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
|
I guess anywhere the Vulkan SDK exists then the binaries for cross
compilation will be available as well. We could make it so that it's
dependent on these that way it wouldn't be so necessary to pull in the
source code for the libraries. But I'll let you make that decision as
ultimately it's your library. I'm easy either way but it's exciting that
all those options exist, except for MSL to SPIR-V because air. is
proprietary. It might be possible though.
On Fri, Nov 7, 2025 at 6:16 PM John Curley ***@***.***>
wrote:
… I guess on Windows, I think you're right in that it requires llvm which
macOS includes by default. For Linux it might require installing the
packages for llvm and I'm guessing the best way on Windows is to install
the Agility SDK or whatever it's called.
On Fri, Nov 7, 2025 at 6:09 PM John Curley ***@***.***>
wrote:
> I'm working on it now, thinking of adding the sources for dxc, glslang is
> already included and spirv-cross. I got claude to generate a file for a
> high level overview and it outputs either SPIR-V or DXIL. I guess when
> shader model 7 comes out it can directly translate SPIR-V. However it can
> output to all 3 different render systems, Metal, DX12 and Vulkan from HLSL.
> And also the work you've done for GLSL to Vulkan which I assume is most of
> the code for existing mods. I think making it self contained rather than
> using the Vulkan sdk's binaries might be the best.
>
> On Fri, Nov 7, 2025 at 5:52 PM Magnus Norddahl ***@***.***>
> wrote:
>
>> *dpjudas* left a comment (dpjudas/ZWidget#46)
>> <#46 (comment)>
>>
>> Merged the PR - thanks!
>>
>> About shader_translator, does it generate HLSL (which then needs to be
>> compiled by DX12's shader compiler), or does generate DXIL bytecode? Main
>> reason I'm asking is that DX12's shader compiler requires all of LLVM, if I
>> remember correctly. I can't promise I'll merge a PR for zvulkan as it
>> really depends on how much extra dependencies it adds to zvulkan, but the
>> idea certainly sounds interesting.
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <#46 (comment)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/AEZ24SIK3QEUPBTYA3HNSIL33QQRNAVCNFSM6AAAAACLMH7EUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBQG4YDMNBTGM>
>> .
>> You are receiving this because you authored the thread.Message ID:
>> ***@***.***>
>>
>
|
|
ZVulkan is meant to be a relatively small self-contained library. Its original purpose was to bring down the boilerplate needed to use vulkan for GZDoom's vulkan backend. GLSL to DX or Metal is interesting primarily due to GZDoom needs. The self contained nature of ZVulkan is there to try lessen the burden for other developers of GZDoom. As it is right now they don't need to do anything to get going, but if it gains dependencies on LLVM or the Vulkan SDK then suddenly you don't just git clone gzdoom to get going. For LLVM we can't really bundle it as its gigantic. We can't ask developers to compile it themselves (it literally takes over an hour to build on my 16 core Zen 3 CPU). Only option is to link against binaries from a SDK, but I don't think its worth it for zvulkan. Maybe GZDoom or UZDoom will be willing to make that tradeoff to get a Direct3D target? I don't know. But I think its better to keep it out of zvulkan itself for now. |
|
Upon further research, I don't think llvm is needed once spirv-cross,
dxc(available from Apple on homebrew.and I think on Linux as well) and
glslang are available as binary static/dynamic libraries. They can be
pulled in like any other dependency via package manager and often would be
available anyway if any development sdk is installed on the platform. I'll
develop a proof of concept library as I need it anyway for MSL support but
it would be nice to have HLSL to Vulkan/Metal cross compilation along with
GLSL to MSL/HLSL as I have at the moment given you're already loading that
via ZVulkan into SPIR-V.
…On Sat, Nov 8, 2025 at 2:26 AM Magnus Norddahl ***@***.***> wrote:
*dpjudas* left a comment (dpjudas/ZWidget#46)
<#46 (comment)>
ZVulkan is meant to be a relatively small self-contained library. Its
original purpose was to bring down the boilerplate needed to use vulkan for
GZDoom's vulkan backend. GLSL to DX or Metal is interesting primarily due
to GZDoom needs.
The self contained nature of ZVulkan is there to try lessen the burden for
other developers of GZDoom. As it is right now they don't need to do
anything to get going, but if it gains dependencies on LLVM or the Vulkan
SDK then suddenly you don't just git clone gzdoom to get going.
For LLVM we can't really bundle it as its gigantic. We can't ask
developers to compile it themselves (it literally takes over an hour to
build on my 16 core Zen 3 CPU). Only option is to link against binaries
from a SDK, but I don't think its worth it for zvulkan.
Maybe GZDoom or UZDoom will be willing to make that tradeoff to get a
Direct3D target? I don't know. But I think its better to keep it out of
zvulkan itself for now.
—
Reply to this email directly, view it on GitHub
<#46 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEZ24SIQKEPQKTLZAHK5M7333SMYXAVCNFSM6AAAAACLMH7EUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBSGU2TKNBYGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I had to add the headers from zvulkan to get vulkan to compile properly on macOS with ZWidget. I was also thinking of helping work on the Haiku port if I get some time. And also I have a library releasing soon based off your work for zvulkan converting SPIR-V to either MSL or HLSL using SPIR-V cross.