Skip to content

Conversation

@johncurley
Copy link
Contributor

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.

@dpjudas
Copy link
Owner

dpjudas commented Nov 6, 2025

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 :)

@johncurley
Copy link
Contributor Author

johncurley commented Nov 6, 2025

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.

@dpjudas dpjudas merged commit f5f34e5 into dpjudas:master Nov 7, 2025
3 checks passed
@dpjudas
Copy link
Owner

dpjudas commented Nov 7, 2025

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.

@johncurley
Copy link
Contributor Author

johncurley commented Nov 7, 2025 via email

@johncurley
Copy link
Contributor Author

johncurley commented Nov 7, 2025 via email

@johncurley
Copy link
Contributor Author

johncurley commented Nov 7, 2025 via email

@dpjudas
Copy link
Owner

dpjudas commented Nov 7, 2025

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.

@johncurley
Copy link
Contributor Author

johncurley commented Nov 8, 2025 via email

@johncurley johncurley deleted the vulkan-headers branch November 11, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants