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

Glad2 Vulkan support #7759

Open
CyberFlex1984 opened this issue Jun 30, 2024 · 3 comments
Open

Glad2 Vulkan support #7759

CyberFlex1984 opened this issue Jun 30, 2024 · 3 comments

Comments

@CyberFlex1984
Copy link

CyberFlex1984 commented Jun 30, 2024

Version/Branch of Dear ImGui:

master

Back-ends:

imgui_impl_vulkan.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Arch Linux GCC 14

Full config/build information:

No response

Details:

Add Vulkan glad2 support!

When I use glad2 for Vulkan I get errors that the imgui library cannot find Vulkan functions. I created this hotfix to resolve this issue.
Error example: imgui/backends/imgui_impl_vulkan.cpp:1582:(.text+0x4936): undefined reference to vkDestroySemaphore

In imgui_impl_vulkan.h we should change 56-66 lines to:

#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
#include <volk.h>
#else
#ifdef IMGUI_IMPL_VULKAN_USE_GLAD
#include <glad/vulkan.h>
#else
#include <vulkan/vulkan.h>
#endif
#endif

And also fix 96 line from VkPipelineRenderingCreateInfoKHR to VkPipelineRenderingCreateInfo

Thanks for attention!

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@ocornut
Copy link
Owner

ocornut commented Jul 1, 2024

(FFS, another Vulkan loader. Vulkan is going the route of OpenGL :( )

Linking to #6582

@mihaly-sisak
Copy link

mihaly-sisak commented Jul 7, 2024

You can actually use GLAD2 with VOLK, without touching ImGui sources. Volk has a compile time define VOLK_VULKAN_H_PATH we can use! I used the example_sdl2_vulkan with cmake as my starting point but I am sure you can make it work with glfw.

  1. Generate the interface with GLAD2 generator, I used vulkan 1.0 + VK_KHR_surface + VK_KHR_swapchain + VK_EXT_debug_report: https://gen.glad.sh/#generator=c&api=gl%3D4.3%2Cvulkan%3D1.0&profile=gl%3Dcore%2Cgles1%3Dcommon&extensions=VK_EXT_debug_report%2CVK_KHR_surface%2CVK_KHR_swapchain
  2. Add to cmake target_include_directories so it includes the unzipped GLAD2 include folder
  3. Download VOLK and add to target_include_directories so it includes volk.h. You actually have to edit the ImGui sources here a bit, but just replace <Volk/volk.h> to "volk.h" or use the specified directory name for the repo and include that, or whatever, but this should not be a problem here.
  4. Add to cmake target_compile_definitions so it defines -DIMGUI_IMPL_VULKAN_USE_VOLK and -DVOLK_VULKAN_H_PATH="glad/vulkan.h"
  5. Build with cmake, the example works without including the system <vulkan/vulkan.h>!

Also VkPipelineRenderingCreateInfoKHR will be available with VK_KHR_dynamic_rendering extension or vulkan 1.3 (can be vulkan 1.0-1.3).
In contrast VkPipelineRenderingCreateInfo will only be available in vulkan 1.3 so if you want to reach the widest audience I would suggest to use VkPipelineRenderingCreateInfoKHR.

@redbg
Copy link

redbg commented Aug 31, 2024

使用 glad2 将会方便很多

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants