bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
14.59k stars 1.92k forks source link

Allow one executable to run with Vulkan on Wayland and X11 #3263

Closed LDprg closed 3 months ago

LDprg commented 3 months ago

Describe the bug It is not currently possible to create one executable that can run Vulkan on Wayland and X11 without beeing recompiled

To Reproduce Steps to reproduce the behavior:

  1. Compile any bgfx app with -with-wayland
  2. Try to run app on X11 with Vulkan (app will switch to opengl)
  3. Try to run the same app on Wayland (app will run fine)
  4. Repeat without -with-wayland (X11 works, Wayland crashes)

I have been using Sdl2 in my tests (not sure if this matters).

Expected behavior App running fine on both desktop sessions without using opengl or any crashing.

Additional context It seems like a wayland header is causing the issue in the vulkan renderer. However having to compile two binaries (wayland and X11 versions) is not great.

bkaradzic commented 3 months ago

It's already possible you need to set appropriate bgfx::NativeWindowHandleType when initializing bgfx. https://github.com/bkaradzic/bgfx/blob/56ad576dcd94464c9a7164ff701bd7957e81e08e/include/bgfx/bgfx.h#L404-L418