Skip to content
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

backend: Support Vulkan #11

Merged
merged 2 commits into from
Feb 2, 2025
Merged

backend: Support Vulkan #11

merged 2 commits into from
Feb 2, 2025

Conversation

nfginola
Copy link
Contributor

@nfginola nfginola commented Feb 1, 2025

Added backend support for Vulkan and GLFW. Changes mostly follow the structure of the DX12 implementation.
Vulkan implementation files grabbed from https://github.com/ocornut/imgui/tree/v1.91.0/backends.

Only other difference from the other implementations is adding a de-gamma'd vertex shader binary in the Vulkan implementation, which is toggled by introducing a custom C flag.

The per-vertex colors by ImGUI are in sRGB, but when they are passed from vert to frag, they are interpolated, and the colors should have been linearized before this operation. Since these are corrected colors, I didn't see a reason to add a build flag for on/off on zig side.

Minimal example can be found here (project consuming zgui)
https://github.com/nfginola/vk-zig/blob/main/src/vk_gui.zig

image

For platforms not supporting 1.3 and dynamic rendering, the init info
struct does not include the VkPipelineRenderingCreateInfoKHR.
Easiest solution for now is to ensure the structure is consistent by
adding a bogus structure which matches VkPipelineRenderingCreateInfoKHR
exactly.
@nfginola
Copy link
Contributor Author

nfginola commented Feb 1, 2025

Added an extra fix.
IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING changes the init info and breaks compatibility.
I'm not able to test on hardware with no 1.3 + no dynamic rendering support so I'll have to assume this is sufficient for now. Otherwise it should be noted somewhere in case someone hits this issue.

Copy link
Member

@hazeycode hazeycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hazeycode hazeycode merged commit 92b2df4 into zig-gamedev:main Feb 2, 2025
3 checks passed
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