From 80155dfa8c8fd3ebcdb304ab97e967d276014f74 Mon Sep 17 00:00:00 2001 From: Julian Sikorski Date: Thu, 28 Sep 2023 17:14:29 +0200 Subject: [PATCH] 3rdparty/bgfx: Cherry-picked upstream commits needed to support Wayland on Linux. (#11539) --- .../examples/00-helloworld/helloworld.cpp | 1 + 3rdparty/bgfx/examples/01-cubes/cubes.cpp | 1 + .../bgfx/examples/02-metaballs/metaballs.cpp | 1 + .../bgfx/examples/03-raymarch/raymarch.cpp | 1 + 3rdparty/bgfx/examples/04-mesh/mesh.cpp | 1 + .../examples/05-instancing/instancing.cpp | 1 + 3rdparty/bgfx/examples/06-bump/bump.cpp | 1 + .../bgfx/examples/07-callback/callback.cpp | 1 + 3rdparty/bgfx/examples/08-update/update.cpp | 1 + 3rdparty/bgfx/examples/09-hdr/hdr.cpp | 1 + 3rdparty/bgfx/examples/10-font/font.cpp | 1 + 3rdparty/bgfx/examples/11-fontsdf/fontsdf.cpp | 1 + 3rdparty/bgfx/examples/12-lod/lod.cpp | 1 + 3rdparty/bgfx/examples/13-stencil/stencil.cpp | 1 + .../14-shadowvolumes/shadowvolumes.cpp | 1 + .../shadowmaps_simple.cpp | 1 + .../examples/16-shadowmaps/shadowmaps.cpp | 1 + .../examples/17-drawstress/drawstress.cpp | 1 + 3rdparty/bgfx/examples/18-ibl/ibl.cpp | 1 + 3rdparty/bgfx/examples/19-oit/oit.cpp | 1 + 3rdparty/bgfx/examples/20-nanovg/nanovg.cpp | 1 + .../bgfx/examples/21-deferred/deferred.cpp | 1 + 3rdparty/bgfx/examples/22-windows/windows.cpp | 1 + 3rdparty/bgfx/examples/24-nbody/nbody.cpp | 1 + 3rdparty/bgfx/examples/25-c99/helloworld.c | 2 + .../bgfx/examples/26-occlusion/occlusion.cpp | 1 + 3rdparty/bgfx/examples/27-terrain/terrain.cpp | 1 + .../bgfx/examples/28-wireframe/wireframe.cpp | 1 + .../bgfx/examples/29-debugdraw/debugdraw.cpp | 1 + 3rdparty/bgfx/examples/30-picking/picking.cpp | 1 + .../examples/31-rsm/reflectiveshadowmap.cpp | 1 + .../bgfx/examples/32-particles/particles.cpp | 1 + 3rdparty/bgfx/examples/33-pom/pom.cpp | 1 + 3rdparty/bgfx/examples/34-mvs/mvs.cpp | 1 + 3rdparty/bgfx/examples/35-dynamic/dynamic.cpp | 1 + 3rdparty/bgfx/examples/36-sky/sky.cpp | 1 + .../gpudrivenrendering.cpp | 1 + 3rdparty/bgfx/examples/38-bloom/bloom.cpp | 1 + 3rdparty/bgfx/examples/39-assao/assao.cpp | 1 + 3rdparty/bgfx/examples/40-svt/svt.cpp | 1 + 3rdparty/bgfx/examples/41-tess/tess.cpp | 1 + .../bgfx/examples/42-bunnylod/bunnylod.cpp | 1 + 3rdparty/bgfx/examples/43-denoise/denoise.cpp | 1 + .../examples/44-sss/screen_space_shadows.cpp | 1 + 3rdparty/bgfx/examples/45-bokeh/bokeh.cpp | 1 + .../examples/47-pixelformats/pixelformats.cpp | 1 + .../examples/48-drawindirect/drawindirect.cpp | 1 + 3rdparty/bgfx/examples/49-hextile/hextile.cpp | 1 + 3rdparty/bgfx/examples/common/entry/entry.cpp | 5 + 3rdparty/bgfx/examples/common/entry/entry.h | 4 + .../examples/common/entry/entry_android.cpp | 6 + .../bgfx/examples/common/entry/entry_glfw.cpp | 13 + .../examples/common/entry/entry_html5.cpp | 6 + .../bgfx/examples/common/entry/entry_ios.mm | 6 + .../bgfx/examples/common/entry/entry_noop.cpp | 6 + .../bgfx/examples/common/entry/entry_osx.mm | 6 + .../bgfx/examples/common/entry/entry_sdl.cpp | 61 ++- .../examples/common/entry/entry_windows.cpp | 6 + .../bgfx/examples/common/entry/entry_x11.cpp | 6 + 3rdparty/bgfx/include/bgfx/bgfx.h | 35 +- 3rdparty/bgfx/include/bgfx/c99/bgfx.h | 18 + 3rdparty/bgfx/src/amalgamated.cpp | 1 - 3rdparty/bgfx/src/bgfx.cpp | 1 + 3rdparty/bgfx/src/glcontext_egl.cpp | 184 +++++--- 3rdparty/bgfx/src/glcontext_egl.h | 11 +- 3rdparty/bgfx/src/glcontext_glx.cpp | 393 ------------------ 3rdparty/bgfx/src/glcontext_glx.h | 58 --- 3rdparty/bgfx/src/renderer_gl.h | 38 +- 3rdparty/bgfx/src/renderer_vk.cpp | 70 ++-- 3rdparty/bgfx/src/renderer_vk.h | 42 +- scripts/src/3rdparty.lua | 1 - 71 files changed, 433 insertions(+), 593 deletions(-) delete mode 100644 3rdparty/bgfx/src/glcontext_glx.cpp delete mode 100644 3rdparty/bgfx/src/glcontext_glx.h diff --git a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp index 97a79463357..68815ba347d 100644 --- a/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp +++ b/3rdparty/bgfx/examples/00-helloworld/helloworld.cpp @@ -34,6 +34,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/01-cubes/cubes.cpp b/3rdparty/bgfx/examples/01-cubes/cubes.cpp index de4566739aa..a178f7379fd 100644 --- a/3rdparty/bgfx/examples/01-cubes/cubes.cpp +++ b/3rdparty/bgfx/examples/01-cubes/cubes.cpp @@ -149,6 +149,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp index 305bf53b329..293ed276ecc 100644 --- a/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp +++ b/3rdparty/bgfx/examples/02-metaballs/metaballs.cpp @@ -508,6 +508,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp index 6fb30b91a88..7478eec47f3 100644 --- a/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp +++ b/3rdparty/bgfx/examples/03-raymarch/raymarch.cpp @@ -121,6 +121,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/04-mesh/mesh.cpp b/3rdparty/bgfx/examples/04-mesh/mesh.cpp index 59c6c070618..3457a9f2f49 100644 --- a/3rdparty/bgfx/examples/04-mesh/mesh.cpp +++ b/3rdparty/bgfx/examples/04-mesh/mesh.cpp @@ -32,6 +32,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/05-instancing/instancing.cpp b/3rdparty/bgfx/examples/05-instancing/instancing.cpp index 6b066c16d9f..eac31fc25c0 100644 --- a/3rdparty/bgfx/examples/05-instancing/instancing.cpp +++ b/3rdparty/bgfx/examples/05-instancing/instancing.cpp @@ -84,6 +84,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/06-bump/bump.cpp b/3rdparty/bgfx/examples/06-bump/bump.cpp index bbfe793fea9..2725e65d971 100644 --- a/3rdparty/bgfx/examples/06-bump/bump.cpp +++ b/3rdparty/bgfx/examples/06-bump/bump.cpp @@ -104,6 +104,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/07-callback/callback.cpp b/3rdparty/bgfx/examples/07-callback/callback.cpp index 418b2a96eae..04b098a56c5 100644 --- a/3rdparty/bgfx/examples/07-callback/callback.cpp +++ b/3rdparty/bgfx/examples/07-callback/callback.cpp @@ -331,6 +331,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/08-update/update.cpp b/3rdparty/bgfx/examples/08-update/update.cpp index 9e9f63fcb3d..e7e54f56f78 100644 --- a/3rdparty/bgfx/examples/08-update/update.cpp +++ b/3rdparty/bgfx/examples/08-update/update.cpp @@ -247,6 +247,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/09-hdr/hdr.cpp b/3rdparty/bgfx/examples/09-hdr/hdr.cpp index 6184611b4c0..e76fbd61259 100644 --- a/3rdparty/bgfx/examples/09-hdr/hdr.cpp +++ b/3rdparty/bgfx/examples/09-hdr/hdr.cpp @@ -159,6 +159,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/10-font/font.cpp b/3rdparty/bgfx/examples/10-font/font.cpp index 34daca64e41..7d0921ddc41 100644 --- a/3rdparty/bgfx/examples/10-font/font.cpp +++ b/3rdparty/bgfx/examples/10-font/font.cpp @@ -73,6 +73,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/11-fontsdf/fontsdf.cpp b/3rdparty/bgfx/examples/11-fontsdf/fontsdf.cpp index a7e7362a577..4308a498116 100644 --- a/3rdparty/bgfx/examples/11-fontsdf/fontsdf.cpp +++ b/3rdparty/bgfx/examples/11-fontsdf/fontsdf.cpp @@ -56,6 +56,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/12-lod/lod.cpp b/3rdparty/bgfx/examples/12-lod/lod.cpp index b717c961e01..b429334a843 100644 --- a/3rdparty/bgfx/examples/12-lod/lod.cpp +++ b/3rdparty/bgfx/examples/12-lod/lod.cpp @@ -48,6 +48,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/13-stencil/stencil.cpp b/3rdparty/bgfx/examples/13-stencil/stencil.cpp index 3acd5d5019b..cfbf0615c9a 100644 --- a/3rdparty/bgfx/examples/13-stencil/stencil.cpp +++ b/3rdparty/bgfx/examples/13-stencil/stencil.cpp @@ -814,6 +814,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_viewState.m_width; init.resolution.height = m_viewState.m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp b/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp index 2df07dec053..48828eba6a1 100644 --- a/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/3rdparty/bgfx/examples/14-shadowvolumes/shadowvolumes.cpp @@ -1786,6 +1786,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_viewState.m_width; init.resolution.height = m_viewState.m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index 236b859e0ea..bfd4a75a0be 100644 --- a/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/3rdparty/bgfx/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -80,6 +80,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp b/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp index 4ab7b7e60dd..e85f6dfab81 100644 --- a/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp +++ b/3rdparty/bgfx/examples/16-shadowmaps/shadowmaps.cpp @@ -1159,6 +1159,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_viewState.m_width; init.resolution.height = m_viewState.m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/17-drawstress/drawstress.cpp b/3rdparty/bgfx/examples/17-drawstress/drawstress.cpp index 5dd17370c1f..9dc32cc299c 100644 --- a/3rdparty/bgfx/examples/17-drawstress/drawstress.cpp +++ b/3rdparty/bgfx/examples/17-drawstress/drawstress.cpp @@ -131,6 +131,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/18-ibl/ibl.cpp b/3rdparty/bgfx/examples/18-ibl/ibl.cpp index a2d15492e6d..96f2ff904fe 100644 --- a/3rdparty/bgfx/examples/18-ibl/ibl.cpp +++ b/3rdparty/bgfx/examples/18-ibl/ibl.cpp @@ -420,6 +420,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/19-oit/oit.cpp b/3rdparty/bgfx/examples/19-oit/oit.cpp index 576cd091f89..d1e17b3faaa 100644 --- a/3rdparty/bgfx/examples/19-oit/oit.cpp +++ b/3rdparty/bgfx/examples/19-oit/oit.cpp @@ -171,6 +171,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp b/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp index 144d21b8b9f..8330fb91fa0 100644 --- a/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp +++ b/3rdparty/bgfx/examples/20-nanovg/nanovg.cpp @@ -1404,6 +1404,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/21-deferred/deferred.cpp b/3rdparty/bgfx/examples/21-deferred/deferred.cpp index 6c379fd3fe1..546db681c97 100644 --- a/3rdparty/bgfx/examples/21-deferred/deferred.cpp +++ b/3rdparty/bgfx/examples/21-deferred/deferred.cpp @@ -213,6 +213,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/22-windows/windows.cpp b/3rdparty/bgfx/examples/22-windows/windows.cpp index 03a5259e90b..54d8671bf76 100644 --- a/3rdparty/bgfx/examples/22-windows/windows.cpp +++ b/3rdparty/bgfx/examples/22-windows/windows.cpp @@ -88,6 +88,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/24-nbody/nbody.cpp b/3rdparty/bgfx/examples/24-nbody/nbody.cpp index 6204705421e..b47469d8c04 100644 --- a/3rdparty/bgfx/examples/24-nbody/nbody.cpp +++ b/3rdparty/bgfx/examples/24-nbody/nbody.cpp @@ -132,6 +132,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/25-c99/helloworld.c b/3rdparty/bgfx/examples/25-c99/helloworld.c index 29b1a65d027..5954684ab9e 100644 --- a/3rdparty/bgfx/examples/25-c99/helloworld.c +++ b/3rdparty/bgfx/examples/25-c99/helloworld.c @@ -9,6 +9,7 @@ extern bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32_t* _debug, uint32_t* _reset); extern void* entry_get_default_native_window_handle(); extern void* entry_get_native_display_handle(); +extern bgfx_native_window_handle_type_t entry_get_native_window_handle_type(void); uint16_t uint16_max(uint16_t _a, uint16_t _b) { @@ -29,6 +30,7 @@ int32_t _main_(int32_t _argc, char** _argv) init.platformData.nwh = entry_get_default_native_window_handle(); init.platformData.ndt = entry_get_native_display_handle(); + init.platformData.type = entry_get_native_window_handle_type(); bgfx_init(&init); bgfx_reset(width, height, reset, init.resolution.format); diff --git a/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp b/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp index d0149838d36..f30dc44cf7b 100644 --- a/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp +++ b/3rdparty/bgfx/examples/26-occlusion/occlusion.cpp @@ -84,6 +84,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/27-terrain/terrain.cpp b/3rdparty/bgfx/examples/27-terrain/terrain.cpp index 3b493304a4c..77053b45d1d 100644 --- a/3rdparty/bgfx/examples/27-terrain/terrain.cpp +++ b/3rdparty/bgfx/examples/27-terrain/terrain.cpp @@ -80,6 +80,7 @@ ExampleTerrain(const char* _name, const char* _description, const char* _url) init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/28-wireframe/wireframe.cpp b/3rdparty/bgfx/examples/28-wireframe/wireframe.cpp index 905ab2c6a41..98bef8aedb5 100644 --- a/3rdparty/bgfx/examples/28-wireframe/wireframe.cpp +++ b/3rdparty/bgfx/examples/28-wireframe/wireframe.cpp @@ -293,6 +293,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp index fb13bb7e3c8..64a21d858c6 100644 --- a/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp +++ b/3rdparty/bgfx/examples/29-debugdraw/debugdraw.cpp @@ -780,6 +780,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/30-picking/picking.cpp b/3rdparty/bgfx/examples/30-picking/picking.cpp index a77395e8d71..9a5c36d8fd8 100644 --- a/3rdparty/bgfx/examples/30-picking/picking.cpp +++ b/3rdparty/bgfx/examples/30-picking/picking.cpp @@ -40,6 +40,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp b/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp index 358893f9bb8..65dfe345c2e 100644 --- a/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp +++ b/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp @@ -213,6 +213,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/32-particles/particles.cpp b/3rdparty/bgfx/examples/32-particles/particles.cpp index d5642b4b8d2..b9815ea7ea1 100644 --- a/3rdparty/bgfx/examples/32-particles/particles.cpp +++ b/3rdparty/bgfx/examples/32-particles/particles.cpp @@ -248,6 +248,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/33-pom/pom.cpp b/3rdparty/bgfx/examples/33-pom/pom.cpp index 71e7e1d85ea..2e07a1957eb 100644 --- a/3rdparty/bgfx/examples/33-pom/pom.cpp +++ b/3rdparty/bgfx/examples/33-pom/pom.cpp @@ -130,6 +130,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/34-mvs/mvs.cpp b/3rdparty/bgfx/examples/34-mvs/mvs.cpp index bbe469b9533..731a08f1bbc 100644 --- a/3rdparty/bgfx/examples/34-mvs/mvs.cpp +++ b/3rdparty/bgfx/examples/34-mvs/mvs.cpp @@ -126,6 +126,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/35-dynamic/dynamic.cpp b/3rdparty/bgfx/examples/35-dynamic/dynamic.cpp index 76544852ffa..0c82aca2457 100644 --- a/3rdparty/bgfx/examples/35-dynamic/dynamic.cpp +++ b/3rdparty/bgfx/examples/35-dynamic/dynamic.cpp @@ -104,6 +104,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/36-sky/sky.cpp b/3rdparty/bgfx/examples/36-sky/sky.cpp index 3648881c627..c82c9e502a1 100644 --- a/3rdparty/bgfx/examples/36-sky/sky.cpp +++ b/3rdparty/bgfx/examples/36-sky/sky.cpp @@ -420,6 +420,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/37-gpudrivenrendering/gpudrivenrendering.cpp b/3rdparty/bgfx/examples/37-gpudrivenrendering/gpudrivenrendering.cpp index 312ef4898b2..56f0141887a 100644 --- a/3rdparty/bgfx/examples/37-gpudrivenrendering/gpudrivenrendering.cpp +++ b/3rdparty/bgfx/examples/37-gpudrivenrendering/gpudrivenrendering.cpp @@ -330,6 +330,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/38-bloom/bloom.cpp b/3rdparty/bgfx/examples/38-bloom/bloom.cpp index 312eef0e72a..99dcb730730 100644 --- a/3rdparty/bgfx/examples/38-bloom/bloom.cpp +++ b/3rdparty/bgfx/examples/38-bloom/bloom.cpp @@ -200,6 +200,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/39-assao/assao.cpp b/3rdparty/bgfx/examples/39-assao/assao.cpp index 45d1e92b7b4..fbff0f29c98 100644 --- a/3rdparty/bgfx/examples/39-assao/assao.cpp +++ b/3rdparty/bgfx/examples/39-assao/assao.cpp @@ -271,6 +271,7 @@ namespace init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/40-svt/svt.cpp b/3rdparty/bgfx/examples/40-svt/svt.cpp index caab49c3416..3256f64952f 100644 --- a/3rdparty/bgfx/examples/40-svt/svt.cpp +++ b/3rdparty/bgfx/examples/40-svt/svt.cpp @@ -82,6 +82,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/41-tess/tess.cpp b/3rdparty/bgfx/examples/41-tess/tess.cpp index 45566ddcd5f..8f0ef16433a 100644 --- a/3rdparty/bgfx/examples/41-tess/tess.cpp +++ b/3rdparty/bgfx/examples/41-tess/tess.cpp @@ -339,6 +339,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/42-bunnylod/bunnylod.cpp b/3rdparty/bgfx/examples/42-bunnylod/bunnylod.cpp index bd44b1f8e82..67c276c2e3c 100644 --- a/3rdparty/bgfx/examples/42-bunnylod/bunnylod.cpp +++ b/3rdparty/bgfx/examples/42-bunnylod/bunnylod.cpp @@ -264,6 +264,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/43-denoise/denoise.cpp b/3rdparty/bgfx/examples/43-denoise/denoise.cpp index 3c9c2ef299b..f9ff556a001 100644 --- a/3rdparty/bgfx/examples/43-denoise/denoise.cpp +++ b/3rdparty/bgfx/examples/43-denoise/denoise.cpp @@ -253,6 +253,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/44-sss/screen_space_shadows.cpp b/3rdparty/bgfx/examples/44-sss/screen_space_shadows.cpp index 7a142baa373..1bf85b0e973 100644 --- a/3rdparty/bgfx/examples/44-sss/screen_space_shadows.cpp +++ b/3rdparty/bgfx/examples/44-sss/screen_space_shadows.cpp @@ -265,6 +265,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/45-bokeh/bokeh.cpp b/3rdparty/bgfx/examples/45-bokeh/bokeh.cpp index b1ed78f4240..965db747586 100644 --- a/3rdparty/bgfx/examples/45-bokeh/bokeh.cpp +++ b/3rdparty/bgfx/examples/45-bokeh/bokeh.cpp @@ -247,6 +247,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/47-pixelformats/pixelformats.cpp b/3rdparty/bgfx/examples/47-pixelformats/pixelformats.cpp index 7a78f36723d..98c27558b29 100644 --- a/3rdparty/bgfx/examples/47-pixelformats/pixelformats.cpp +++ b/3rdparty/bgfx/examples/47-pixelformats/pixelformats.cpp @@ -430,6 +430,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/48-drawindirect/drawindirect.cpp b/3rdparty/bgfx/examples/48-drawindirect/drawindirect.cpp index d8b4d6d58cf..65fffa123b7 100644 --- a/3rdparty/bgfx/examples/48-drawindirect/drawindirect.cpp +++ b/3rdparty/bgfx/examples/48-drawindirect/drawindirect.cpp @@ -146,6 +146,7 @@ public: init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/49-hextile/hextile.cpp b/3rdparty/bgfx/examples/49-hextile/hextile.cpp index ecef40bf261..58dc2c7e3a5 100644 --- a/3rdparty/bgfx/examples/49-hextile/hextile.cpp +++ b/3rdparty/bgfx/examples/49-hextile/hextile.cpp @@ -85,6 +85,7 @@ namespace init.vendorId = args.m_pciId; init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; diff --git a/3rdparty/bgfx/examples/common/entry/entry.cpp b/3rdparty/bgfx/examples/common/entry/entry.cpp index 58a671e6a70..07621f3cd25 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry.cpp @@ -1037,3 +1037,8 @@ extern "C" void* entry_get_native_display_handle() { return entry::getNativeDisplayHandle(); } + +extern "C" bgfx::NativeWindowHandleType::Enum entry_get_native_window_handle_type() +{ + return entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); +} diff --git a/3rdparty/bgfx/examples/common/entry/entry.h b/3rdparty/bgfx/examples/common/entry/entry.h index 2dc7acc7b56..443066e304f 100644 --- a/3rdparty/bgfx/examples/common/entry/entry.h +++ b/3rdparty/bgfx/examples/common/entry/entry.h @@ -7,6 +7,7 @@ #define ENTRY_H_HEADER_GUARD #include "dbg.h" +#include #include #include #include @@ -297,6 +298,9 @@ namespace entry /// void* getNativeDisplayHandle(); + /// + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle); + /// void setCurrentDir(const char* _dir); diff --git a/3rdparty/bgfx/examples/common/entry/entry_android.cpp b/3rdparty/bgfx/examples/common/entry/entry_android.cpp index 3a6ac8561d3..a99735b6df5 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_android.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_android.cpp @@ -550,6 +550,12 @@ namespace entry return NULL; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { BX_UNUSED(_thread); diff --git a/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp b/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp index da15502409c..d27745d1390 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_glfw.cpp @@ -875,6 +875,19 @@ namespace entry # endif // BX_PLATFORM_* } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD +# if ENTRY_CONFIG_USE_WAYLAND + return bgfx::NativeWindowHandleType::Wayland; +# else + return bgfx::NativeWindowHandleType::Default; +# endif // ENTRY_CONFIG_USE_WAYLAND +# else + return bgfx::NativeWindowHandleType::Default; +# endif // BX_PLATFORM_* + } + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { BX_UNUSED(_thread); diff --git a/3rdparty/bgfx/examples/common/entry/entry_html5.cpp b/3rdparty/bgfx/examples/common/entry/entry_html5.cpp index 884a563b783..d33879229f9 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_html5.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_html5.cpp @@ -427,6 +427,12 @@ namespace entry { return NULL; } + + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } } int main(int _argc, const char* const* _argv) diff --git a/3rdparty/bgfx/examples/common/entry/entry_ios.mm b/3rdparty/bgfx/examples/common/entry/entry_ios.mm index f123b6684ea..8592a33c43e 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_ios.mm +++ b/3rdparty/bgfx/examples/common/entry/entry_ios.mm @@ -161,6 +161,12 @@ namespace entry return NULL; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + } // namespace entry using namespace entry; diff --git a/3rdparty/bgfx/examples/common/entry/entry_noop.cpp b/3rdparty/bgfx/examples/common/entry/entry_noop.cpp index 22d160f592c..5e4bb0fafa4 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_noop.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_noop.cpp @@ -78,6 +78,12 @@ namespace entry return NULL; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + } // namespace entry int main(int _argc, const char* const* _argv) diff --git a/3rdparty/bgfx/examples/common/entry/entry_osx.mm b/3rdparty/bgfx/examples/common/entry/entry_osx.mm index 948483ca93e..98869d7df04 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_osx.mm +++ b/3rdparty/bgfx/examples/common/entry/entry_osx.mm @@ -725,6 +725,12 @@ namespace entry return NULL; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + } // namespace entry @implementation AppDelegate diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp index 8744b98e763..5a862c0ca05 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp @@ -50,21 +50,24 @@ namespace entry # if BX_PLATFORM_LINUX || BX_PLATFORM_BSD # if ENTRY_CONFIG_USE_WAYLAND - wl_egl_window *win_impl = (wl_egl_window*)SDL_GetWindowData(_window, "wl_egl_window"); - if(!win_impl) - { - int width, height; - SDL_GetWindowSize(_window, &width, &height); - struct wl_surface* surface = wmi.info.wl.surface; - if(!surface) - return nullptr; - win_impl = wl_egl_window_create(surface, width, height); - SDL_SetWindowData(_window, "wl_egl_window", win_impl); - } - return (void*)(uintptr_t)win_impl; -# else - return (void*)wmi.info.x11.window; -# endif + if (wmi.subsystem == SDL_SYSWM_WAYLAND) + { + wl_egl_window *win_impl = (wl_egl_window*)SDL_GetWindowData(_window, "wl_egl_window"); + if(!win_impl) + { + int width, height; + SDL_GetWindowSize(_window, &width, &height); + struct wl_surface* surface = wmi.info.wl.surface; + if(!surface) + return nullptr; + win_impl = wl_egl_window_create(surface, width, height); + SDL_SetWindowData(_window, "wl_egl_window", win_impl); + } + return (void*)(uintptr_t)win_impl; + } + else +# endif // ENTRY_CONFIG_USE_WAYLAND + return (void*)wmi.info.x11.window; # elif BX_PLATFORM_OSX || BX_PLATFORM_IOS return wmi.info.cocoa.window; # elif BX_PLATFORM_WINDOWS @@ -1145,18 +1148,38 @@ namespace entry { return NULL; } - # if BX_PLATFORM_LINUX || BX_PLATFORM_BSD # if ENTRY_CONFIG_USE_WAYLAND - return wmi.info.wl.display; -# else - return wmi.info.x11.display; + if (wmi.subsystem == SDL_SYSWM_WAYLAND) + return wmi.info.wl.display; + else # endif // ENTRY_CONFIG_USE_WAYLAND + return wmi.info.x11.display; # else return NULL; # endif // BX_PLATFORM_* } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + SDL_SysWMinfo wmi; + SDL_VERSION(&wmi.version); + if (!SDL_GetWindowWMInfo(s_ctx.m_window[_handle.idx], &wmi) ) + { + return bgfx::NativeWindowHandleType::Default; + } +# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD +# if ENTRY_CONFIG_USE_WAYLAND + if (wmi.subsystem == SDL_SYSWM_WAYLAND) + return bgfx::NativeWindowHandleType::Wayland; + else +# endif // ENTRY_CONFIG_USE_WAYLAND + return bgfx::NativeWindowHandleType::Default; +# else + return bgfx::NativeWindowHandleType::Default; +# endif // BX_PLATFORM_* + } + int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) { BX_UNUSED(_thread); diff --git a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp index 5d60573d08e..754039a6db7 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_windows.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_windows.cpp @@ -1169,6 +1169,12 @@ namespace entry return NULL; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + int32_t MainThreadEntry::threadFunc(bx::Thread* /*_thread*/, void* _userData) { MainThreadEntry* self = (MainThreadEntry*)_userData; diff --git a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp index a5f4b3fa6da..407a1d9e5dc 100644 --- a/3rdparty/bgfx/examples/common/entry/entry_x11.cpp +++ b/3rdparty/bgfx/examples/common/entry/entry_x11.cpp @@ -771,6 +771,12 @@ namespace entry return s_ctx.m_display; } + bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle) + { + BX_UNUSED(_handle); + return bgfx::NativeWindowHandleType::Default; + } + } // namespace entry int main(int _argc, const char* const* _argv) diff --git a/3rdparty/bgfx/include/bgfx/bgfx.h b/3rdparty/bgfx/include/bgfx/bgfx.h index 844337d8f77..ea061fe7e1b 100644 --- a/3rdparty/bgfx/include/bgfx/bgfx.h +++ b/3rdparty/bgfx/include/bgfx/bgfx.h @@ -403,6 +403,22 @@ namespace bgfx }; }; + /// Native window handle type. + /// + /// @attention C99's equivalent binding is `bgfx_native_window_handle_type_t`. + /// + + struct NativeWindowHandleType + { + enum Enum + { + Default = 0, //!< Platform default handle type (X11 on Linux). + Wayland, //!< Wayland. + + Count + }; + }; + static const uint16_t kInvalidHandle = UINT16_MAX; BGFX_HANDLE(DynamicIndexBufferHandle) @@ -622,15 +638,16 @@ namespace bgfx { PlatformData(); - void* ndt; //!< Native display type (*nix specific). - void* nwh; //!< Native window handle. If `NULL`, bgfx will create a headless - /// context/device, provided the rendering API supports it. - void* context; //!< GL context, D3D device, or Vulkan device. If `NULL`, bgfx - /// will create context/device. - void* backBuffer; //!< GL back-buffer, or D3D render target view. If `NULL` bgfx will - /// create back-buffer color surface. - void* backBufferDS; //!< Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer - /// depth/stencil surface. + void* ndt; //!< Native display type (*nix specific). + void* nwh; //!< Native window handle. If `NULL`, bgfx will create a headless + /// context/device, provided the rendering API supports it. + void* context; //!< GL context, D3D device, or Vulkan device. If `NULL`, bgfx + /// will create context/device. + void* backBuffer; //!< GL back-buffer, or D3D render target view. If `NULL` bgfx will + /// create back-buffer color surface. + void* backBufferDS; //!< Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer + /// depth/stencil surface. + NativeWindowHandleType::Enum type; //!< Handle type. Needed for platforms having more than one option. }; /// Backbuffer resolution and reset parameters. diff --git a/3rdparty/bgfx/include/bgfx/c99/bgfx.h b/3rdparty/bgfx/include/bgfx/c99/bgfx.h index 04d9bcebee7..511a39cad7f 100644 --- a/3rdparty/bgfx/include/bgfx/c99/bgfx.h +++ b/3rdparty/bgfx/include/bgfx/c99/bgfx.h @@ -391,6 +391,19 @@ typedef enum bgfx_view_mode } bgfx_view_mode_t; +/** + * Native window handle type.. + * + */ +typedef enum bgfx_native_window_handle_type +{ + BGFX_NATIVE_WINDOW_HANDLE_TYPE_DEFAULT, /** ( 0) Platform default handle type (X11 on Linux) */ + BGFX_NATIVE_WINDOW_HANDLE_TYPE_WAYLAND, /** ( 1) Wayland. */ + + BGFX_NATIVE_WINDOW_HANDLE_TYPE_COUNT + +} bgfx_native_window_handle_type_t; + /** * Render frame enum. * @@ -625,6 +638,11 @@ typedef struct bgfx_platform_data_s */ void* backBufferDS; + /** + * Handle type. Needed for platforms having more than one option. + */ + bgfx_native_window_handle_type_t type; + } bgfx_platform_data_t; /** diff --git a/3rdparty/bgfx/src/amalgamated.cpp b/3rdparty/bgfx/src/amalgamated.cpp index aa88b1c4898..deac46d36e7 100644 --- a/3rdparty/bgfx/src/amalgamated.cpp +++ b/3rdparty/bgfx/src/amalgamated.cpp @@ -7,7 +7,6 @@ #include "debug_renderdoc.cpp" #include "dxgi.cpp" #include "glcontext_egl.cpp" -#include "glcontext_glx.cpp" #include "glcontext_wgl.cpp" #include "glcontext_html5.cpp" #include "nvapi.cpp" diff --git a/3rdparty/bgfx/src/bgfx.cpp b/3rdparty/bgfx/src/bgfx.cpp index f9ef0a6e207..d2aa92ad8ad 100644 --- a/3rdparty/bgfx/src/bgfx.cpp +++ b/3rdparty/bgfx/src/bgfx.cpp @@ -3422,6 +3422,7 @@ namespace bgfx , context(NULL) , backBuffer(NULL) , backBufferDS(NULL) + , type(NativeWindowHandleType::Default) { } diff --git a/3rdparty/bgfx/src/glcontext_egl.cpp b/3rdparty/bgfx/src/glcontext_egl.cpp index fabddd5c663..54e0230b778 100644 --- a/3rdparty/bgfx/src/glcontext_egl.cpp +++ b/3rdparty/bgfx/src/glcontext_egl.cpp @@ -25,36 +25,44 @@ namespace bgfx { namespace gl typedef void (*EGLPROC)(void); - typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); - typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); - typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); - typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void); - typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id); - typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char *procname); - typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor); - typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); + typedef EGLBoolean (EGLAPIENTRY* PGNEGLBINDAPIPROC)(EGLenum api); + typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config); + typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list); + typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEPBUFFERSURFACEPROC)(EGLDisplay display, EGLConfig config, EGLint const* attrib_list); + typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list); typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx); typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface); - typedef const char* (EGLAPIENTRY* PGNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name); + typedef EGLContext (EGLAPIENTRY* PFNEGLGETCURRENTCONTEXTPROC)(void); + typedef EGLSurface (EGLAPIENTRY* PFNEGLGETCURRENTSURFACEPROC)(EGLint readdraw); + typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id); + typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void); + typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char* procname); + typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint* major, EGLint* minor); + typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface); typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval); typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy); + typedef const char* (EGLAPIENTRY* PGNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name); -#define EGL_IMPORT \ - EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \ - EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \ - EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \ - EGL_IMPORT_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); \ - EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \ - EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \ - EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \ - EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \ - EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \ - EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \ - EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \ - EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); \ - EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \ - EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate); +#define EGL_IMPORT \ + EGL_IMPORT_FUNC(PGNEGLBINDAPIPROC, eglBindAPI); \ + EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \ + EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \ + EGL_IMPORT_FUNC(PFNEGLCREATEPBUFFERSURFACEPROC, eglCreatePbufferSurface); \ + EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \ + EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \ + EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \ + EGL_IMPORT_FUNC(PFNEGLGETCURRENTCONTEXTPROC, eglGetCurrentContext); \ + EGL_IMPORT_FUNC(PFNEGLGETCURRENTSURFACEPROC, eglGetCurrentSurface); \ + EGL_IMPORT_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); \ + EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \ + EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \ + EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \ + EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \ + EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); \ + EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \ + EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate); \ + EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \ #define EGL_IMPORT_FUNC(_proto, _func) _proto _func EGL_IMPORT @@ -62,12 +70,19 @@ EGL_IMPORT void* eglOpen() { - void* handle = bx::dlopen("libEGL." BX_DL_EXT); + void* handle = bx::dlopen( +#if BX_PLATFORM_LINUX + "libEGL.so.1" +#else + "libEGL." BX_DL_EXT +#endif // BX_PLATFORM_* + ); + BGFX_FATAL(NULL != handle, Fatal::UnableToInitialize, "Failed to load libEGL dynamic library."); -#define EGL_IMPORT_FUNC(_proto, _func) \ - _func = (_proto)bx::dlsym(handle, #_func); \ - BX_TRACE("%p " #_func, _func); \ +#define EGL_IMPORT_FUNC(_proto, _func) \ + _func = (_proto)bx::dlsym(handle, #_func); \ + BX_TRACE("%p " #_func, _func); \ BGFX_FATAL(NULL != _func, Fatal::UnableToInitialize, "Failed get " #_func ".") EGL_IMPORT #undef EGL_IMPORT_FUNC @@ -107,9 +122,17 @@ EGL_IMPORT : m_nwh(_nwh) , m_display(_display) { - EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); + EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); + + if (EGLNativeWindowType(0) == _nwh) + { + m_surface = eglCreatePbufferSurface(m_display, _config, NULL); + } + else + { + m_surface = eglCreateWindowSurface(m_display, _config, _nwh, NULL); + } - m_surface = eglCreateWindowSurface(m_display, _config, _nwh, NULL); BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); m_context = eglCreateContext(m_display, _config, _context, s_contextAttrs); @@ -119,15 +142,17 @@ EGL_IMPORT GL_CHECK(glClearColor(0.0f, 0.0f, 0.0f, 0.0f) ); GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) ); swapBuffers(); + GL_CHECK(glClear(GL_COLOR_BUFFER_BIT) ); swapBuffers(); - eglMakeCurrent(m_display, defaultSurface, defaultSurface, _context); + + eglMakeCurrent(m_display, defaultSurface, defaultSurface, _context); } ~SwapChainGL() { - EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); - EGLContext defaultContext = eglGetCurrentContext(); + EGLSurface defaultSurface = eglGetCurrentSurface(EGL_DRAW); + EGLContext defaultContext = eglGetCurrentContext(); eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroyContext(m_display, m_context); @@ -157,6 +182,8 @@ EGL_IMPORT void GlContext::create(uint32_t _width, uint32_t _height, uint32_t _flags) { + BX_UNUSED(_flags); + # if BX_PLATFORM_RPI bcm_host_init(); # endif // BX_PLATFORM_RPI @@ -180,7 +207,7 @@ EGL_IMPORT } # endif // BX_PLATFORM_WINDOWS - m_display = eglGetDisplay(ndt); + m_display = eglGetDisplay(NULL == ndt ? EGL_DEFAULT_DISPLAY : ndt); BGFX_FATAL(m_display != EGL_NO_DISPLAY, Fatal::UnableToInitialize, "Failed to create display %p", m_display); EGLint major = 0; @@ -202,24 +229,39 @@ EGL_IMPORT BX_TRACE("Supported EGL extensions:"); dumpExtensions(extensions); - // https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_recordable.txt + if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) + { + EGLBoolean ok = eglBindAPI(EGL_OPENGL_API); + BGFX_FATAL(ok, Fatal::UnableToInitialize, "Could not set API! error: %d", eglGetError()); + } + const bool hasEglAndroidRecordable = !bx::findIdentifierMatch(extensions, "EGL_ANDROID_recordable").isEmpty(); - const uint32_t gles = BGFX_CONFIG_RENDERER_OPENGLES; + const uint32_t glVersion = !!BGFX_CONFIG_RENDERER_OPENGL + ? BGFX_CONFIG_RENDERER_OPENGL + : BGFX_CONFIG_RENDERER_OPENGLES + ; #if BX_PLATFORM_ANDROID - uint32_t msaa = (_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT; - uint32_t msaaSamples = msaa == 0 ? 0 : 1<>BGFX_RESET_MSAA_SHIFT; + const uint32_t msaaSamples = msaa == 0 ? 0 : 1<= 30) ? EGL_OPENGL_ES3_BIT_KHR : EGL_OPENGL_ES2_BIT, + EGL_RENDERABLE_TYPE, !!BGFX_CONFIG_RENDERER_OPENGL + ? EGL_OPENGL_BIT + : (glVersion >= 30) ? EGL_OPENGL_ES3_BIT_KHR : EGL_OPENGL_ES2_BIT + , - EGL_BLUE_SIZE, 8, + EGL_SURFACE_TYPE, headless ? EGL_PBUFFER_BIT : EGL_WINDOW_BIT, + + EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, - EGL_RED_SIZE, 8, + EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, # if BX_PLATFORM_ANDROID @@ -231,8 +273,8 @@ EGL_IMPORT EGL_STENCIL_SIZE, 8, // Android Recordable surface - hasEglAndroidRecordable ? 0x3142 : EGL_NONE, - hasEglAndroidRecordable ? 1 : EGL_NONE, + hasEglAndroidRecordable ? EGL_RECORDABLE_ANDROID : EGL_NONE, + hasEglAndroidRecordable ? 1 : EGL_NONE, EGL_NONE }; @@ -274,7 +316,23 @@ EGL_IMPORT vc_dispmanx_update_submit_sync(dispmanUpdate); # endif // BX_PLATFORM_ANDROID - m_surface = eglCreateWindowSurface(m_display, m_config, nwh, NULL); + if (headless) + { + EGLint pbAttribs[] = + { + EGL_WIDTH, EGLint(_width), + EGL_HEIGHT, EGLint(_height), + + EGL_NONE + }; + + m_surface = eglCreatePbufferSurface(m_display, m_config, pbAttribs); + } + else + { + m_surface = eglCreateWindowSurface(m_display, m_config, nwh, NULL); + } + BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); const bool hasEglKhrCreateContext = !bx::findIdentifierMatch(extensions, "EGL_KHR_create_context").isEmpty(); @@ -291,11 +349,17 @@ EGL_IMPORT # else if (hasEglKhrCreateContext) { - bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR), bx::ErrorAssert{} ); - bx::write(&writer, EGLint(gles / 10), bx::ErrorAssert{} ); + if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) ) + { + bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR), bx::ErrorAssert{}); + bx::write(&writer, EGLint(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR), bx::ErrorAssert{}); + } - bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR), bx::ErrorAssert{} ); - bx::write(&writer, EGLint(gles % 10), bx::ErrorAssert{} ); + bx::write(&writer, EGLint(EGL_CONTEXT_MAJOR_VERSION_KHR), bx::ErrorAssert{}); + bx::write(&writer, EGLint(glVersion / 10), bx::ErrorAssert{}); + + bx::write(&writer, EGLint(EGL_CONTEXT_MINOR_VERSION_KHR), bx::ErrorAssert{}); + bx::write(&writer, EGLint(glVersion % 10), bx::ErrorAssert{}); flags |= BGFX_CONFIG_DEBUG && hasEglKhrNoError ? 0 | EGL_CONTEXT_FLAG_NO_ERROR_BIT_KHR @@ -318,7 +382,7 @@ EGL_IMPORT # endif // BX_PLATFORM_RPI { bx::write(&writer, EGLint(EGL_CONTEXT_CLIENT_VERSION), bx::ErrorAssert{} ); - bx::write(&writer, EGLint(gles / 10), bx::ErrorAssert{} ); + bx::write(&writer, EGLint(glVersion / 10), bx::ErrorAssert{} ); } bx::write(&writer, EGLint(EGL_NONE), bx::ErrorAssert{} ); @@ -397,10 +461,10 @@ EGL_IMPORT uint64_t GlContext::getCaps() const { return BX_ENABLED(0 - | BX_PLATFORM_LINUX - | BX_PLATFORM_WINDOWS - | BX_PLATFORM_ANDROID - ) + | BX_PLATFORM_LINUX + | BX_PLATFORM_WINDOWS + | BX_PLATFORM_ANDROID + ) ? BGFX_CAPS_SWAP_CHAIN : 0 ; @@ -458,13 +522,23 @@ EGL_IMPORT BX_TRACE("Import:"); # if BX_PLATFORM_WINDOWS || BX_PLATFORM_LINUX - void* glesv2 = bx::dlopen("libGLESv2." BX_DL_EXT); +# if BX_PLATFORM_WINDOWS +# define LIBRARY_NAME "libGL.dll" +# elif BX_PLATFORM_LINUX +# if BGFX_CONFIG_RENDERER_OPENGL +# define LIBRARY_NAME "libGL.so.1" +# else +# define LIBRARY_NAME "libGLESv2.so.2" +# endif +# endif + + void* lib = bx::dlopen(LIBRARY_NAME); # define GL_EXTENSION(_optional, _proto, _func, _import) \ { \ if (NULL == _func) \ { \ - _func = bx::dlsym<_proto>(glesv2, #_import); \ + _func = bx::dlsym<_proto>(lib, #_import); \ BX_TRACE("\t%p " #_func " (" #_import ")", _func); \ BGFX_FATAL(_optional || NULL != _func \ , Fatal::UnableToInitialize \ diff --git a/3rdparty/bgfx/src/glcontext_egl.h b/3rdparty/bgfx/src/glcontext_egl.h index b2edb67ab3d..2f87a32e5eb 100644 --- a/3rdparty/bgfx/src/glcontext_egl.h +++ b/3rdparty/bgfx/src/glcontext_egl.h @@ -10,11 +10,20 @@ #include #include + +// EGL pulls X11 crap... +#if defined(None) +# undef None +#endif // defined(None) + #if defined(Success) -// X11 defines Success # undef Success #endif // defined(Success) +#if defined(Status) +# undef Status +#endif // defined(Status) + namespace bgfx { namespace gl { struct SwapChainGL; diff --git a/3rdparty/bgfx/src/glcontext_glx.cpp b/3rdparty/bgfx/src/glcontext_glx.cpp deleted file mode 100644 index 4dd21ca013a..00000000000 --- a/3rdparty/bgfx/src/glcontext_glx.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright 2011-2022 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE - */ - -#include "bgfx_p.h" - -#if (BX_PLATFORM_BSD || BX_PLATFORM_LINUX) && (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL) -# include "renderer_gl.h" - -# if BGFX_USE_GLX -# define GLX_GLXEXT_PROTOTYPES -# include - -// glxext will include X11 which #defines None, Status, etc. -#undef None -#undef Status - -namespace bgfx { namespace gl -{ - typedef int (*PFNGLXSWAPINTERVALMESAPROC)(uint32_t _interval); - - PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB; - PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; - PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA; - PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; - -# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func -# include "glimports.h" - - struct SwapChainGL - { - SwapChainGL(::Display* display, ::Window _window, XVisualInfo* _visualInfo, GLXContext _context) - : m_display(display) - , m_window(_window) - { - m_context = glXCreateContext(m_display, _visualInfo, _context, GL_TRUE); - } - - ~SwapChainGL() - { - glXMakeCurrent(m_display, 0, 0); - glXDestroyContext(m_display, m_context); - } - - void makeCurrent() - { - glXMakeCurrent(m_display, m_window, m_context); - } - - void swapBuffers() - { - glXSwapBuffers(m_display, m_window); - } - - ::Display* m_display; - Window m_window; - GLXContext m_context; - }; - - static bool haveGlxExtension(const char* _ext, const char* _extList) - { - // _extList is assumed to be a space-separated, null-terminated list of - // extension names, and no extension name ever contains a space. - const char* end = _extList + bx::strLen(_extList); - const char* searchStart = _extList; - for(;;) - { - bx::StringView found = bx::strFind(searchStart, _ext); - if (found.isEmpty() ) - { - return false; - } - - // We found the substring, but need an exact match, with a word - // boundary at both the front and back of the found spot. - if ((found.getPtr() == _extList || *(found.getPtr() - 1) == ' ') - && (found.getTerm() == end || *found.getTerm() == ' ') ) - { - return true; - } - // else, keep searching - searchStart = found.getTerm(); - } - } - - template - static ProtoT glXGetProcAddress(const char* _name) - { - return reinterpret_cast( (void*)::glXGetProcAddress( (const GLubyte*)_name) ); - } - - void GlContext::create(uint32_t _width, uint32_t _height, uint32_t /*_flags*/) - { - BX_UNUSED(_width, _height); - - m_context = (GLXContext)g_platformData.context; - m_display = (::Display*)g_platformData.ndt; - - // It's possible the user has provided the window handle, but not - // the display handle. If this is the case, try opening the default - // display - if (NULL == m_display) - { - m_display = XOpenDisplay(NULL); - BGFX_FATAL(m_display, Fatal::UnableToInitialize, "XOpenDisplay(NULL) : Failed to open default display"); - } - - if (NULL == g_platformData.context) - { - XLockDisplay(m_display); - - int major, minor; - bool version = glXQueryVersion(m_display, &major, &minor); - BGFX_FATAL(version, Fatal::UnableToInitialize, "Failed to query GLX version"); - BGFX_FATAL( (major == 1 && minor >= 2) || major > 1 - , Fatal::UnableToInitialize - , "GLX version is not >=1.2 (%d.%d)." - , major - , minor - ); - - int32_t screen = DefaultScreen(m_display); - - const char* extensions = glXQueryExtensionsString(m_display, screen); - BX_TRACE("GLX extensions:"); - dumpExtensions(extensions); - - const int attrsGlx[] = - { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_DOUBLEBUFFER, true, - GLX_RED_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_GREEN_SIZE, 8, - // GLX_ALPHA_SIZE, 8, - GLX_DEPTH_SIZE, 24, - GLX_STENCIL_SIZE, 8, - 0, - }; - - // Find suitable config - GLXFBConfig bestConfig = NULL; - - int numConfigs; - GLXFBConfig* configs = glXChooseFBConfig(m_display, screen, attrsGlx, &numConfigs); - - BX_TRACE("glX num configs %d", numConfigs); - - for (int ii = 0; ii < numConfigs; ++ii) - { - m_visualInfo = glXGetVisualFromFBConfig(m_display, configs[ii]); - if (NULL != m_visualInfo) - { - BX_TRACE("---"); - bool valid = true; - for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != 0; attr += 2) - { - int value; - glXGetFBConfigAttrib(m_display, configs[ii], attrsGlx[attr], &value); - BX_TRACE("glX %d/%d %2d: %4x, %8x (%8x%s)" - , ii - , numConfigs - , attr/2 - , attrsGlx[attr] - , value - , attrsGlx[attr + 1] - , value < attrsGlx[attr + 1] ? " *" : "" - ); - - if (value < attrsGlx[attr + 1]) - { - valid = false; -#if !BGFX_CONFIG_DEBUG - break; -#endif // BGFX_CONFIG_DEBUG - } - } - - if (valid) - { - bestConfig = configs[ii]; - BX_TRACE("Best config %d.", ii); - break; - } - } - - XFree(m_visualInfo); - m_visualInfo = NULL; - } - - XFree(configs); - BGFX_FATAL(m_visualInfo, Fatal::UnableToInitialize, "Failed to find a suitable X11 display configuration."); - - BX_TRACE("Create GL 2.1 context."); - m_context = glXCreateContext(m_display, m_visualInfo, 0, GL_TRUE); - BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create GL 2.1 context."); - - glXCreateContextAttribsARB = glXGetProcAddress("glXCreateContextAttribsARB"); - - if (NULL != glXCreateContextAttribsARB) - { - BX_TRACE("Create GL %d.%d context.", BGFX_CONFIG_RENDERER_OPENGL / 10, BGFX_CONFIG_RENDERER_OPENGL % 10); - int32_t flags = BGFX_CONFIG_DEBUG ? GLX_CONTEXT_DEBUG_BIT_ARB : 0; - const int contextAttrs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL / 10, - GLX_CONTEXT_MINOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL % 10, - GLX_CONTEXT_FLAGS_ARB, flags, - GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, - 0, - }; - - GLXContext context = glXCreateContextAttribsARB(m_display, bestConfig, 0, true, contextAttrs); - - if (NULL != context) - { - glXDestroyContext(m_display, m_context); - m_context = context; - } - } - - XUnlockDisplay(m_display); - } - - import(); - - glXMakeCurrent(m_display, (::Window)g_platformData.nwh, m_context); - m_current = NULL; - - const char* extensions = glXQueryExtensionsString(m_display, DefaultScreen(m_display) ); - - if (NULL != extensions) - { - bool foundSwapControl = false; - - if (haveGlxExtension("GLX_EXT_swap_control", extensions) ) - { - glXSwapIntervalEXT = glXGetProcAddress("glXSwapIntervalEXT"); - - if (NULL != glXSwapIntervalEXT) - { - BX_TRACE("Using glXSwapIntervalEXT."); - glXSwapIntervalEXT(m_display, (::Window)g_platformData.nwh, 0); - foundSwapControl = true; - } - } - - if (!foundSwapControl - && haveGlxExtension("GLX_MESA_swap_control", extensions) ) - { - glXSwapIntervalMESA = glXGetProcAddress("glXSwapIntervalMESA"); - - if (NULL != glXSwapIntervalMESA) - { - BX_TRACE("Using glXSwapIntervalMESA."); - glXSwapIntervalMESA(0); - foundSwapControl = true; - } - } - - if (!foundSwapControl - && haveGlxExtension("GLX_SGI_swap_control", extensions) ) - { - glXSwapIntervalSGI = glXGetProcAddress("glXSwapIntervalSGI"); - - if (NULL != glXSwapIntervalSGI) - { - BX_TRACE("Using glXSwapIntervalSGI."); - glXSwapIntervalSGI(0); - foundSwapControl = true; - } - } - } - - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glXSwapBuffers(m_display, (::Window)g_platformData.nwh); - - g_internalData.context = m_context; - } - - void GlContext::destroy() - { - glXMakeCurrent(m_display, 0, 0); - if (NULL == g_platformData.context) - { - glXDestroyContext(m_display, m_context); - XFree(m_visualInfo); - } - // If we opened the display, have to close it - if (NULL == g_platformData.ndt) - { - XCloseDisplay(m_display); - } - m_context = NULL; - m_visualInfo = NULL; - m_display = NULL; - } - - void GlContext::resize(uint32_t /*_width*/, uint32_t /*_height*/, uint32_t _flags) - { - bool vsync = !!(_flags&BGFX_RESET_VSYNC); - int32_t interval = vsync ? 1 : 0; - - if (NULL != glXSwapIntervalEXT) - { - glXSwapIntervalEXT(m_display, (::Window)g_platformData.nwh, interval); - } - else if (NULL != glXSwapIntervalMESA) - { - glXSwapIntervalMESA(interval); - } - else if (NULL != glXSwapIntervalSGI) - { - glXSwapIntervalSGI(interval); - } - } - - uint64_t GlContext::getCaps() const - { - return BGFX_CAPS_SWAP_CHAIN; - } - - SwapChainGL* GlContext::createSwapChain(void* _nwh) - { - return BX_NEW(g_allocator, SwapChainGL)(m_display, (::Window)_nwh, m_visualInfo, m_context); - } - - void GlContext::destroySwapChain(SwapChainGL* _swapChain) - { - BX_DELETE(g_allocator, _swapChain); - glXMakeCurrent(m_display, (::Window)g_platformData.nwh, m_context); - } - - void GlContext::swap(SwapChainGL* _swapChain) - { - makeCurrent(_swapChain); - - if (NULL == _swapChain) - { - glXSwapBuffers(m_display, (::Window)g_platformData.nwh); - } - else - { - _swapChain->swapBuffers(); - } - } - - void GlContext::makeCurrent(SwapChainGL* _swapChain) - { - if (m_current != _swapChain) - { - m_current = _swapChain; - - if (NULL == _swapChain) - { - glXMakeCurrent(m_display, (::Window)g_platformData.nwh, m_context); - } - else - { - _swapChain->makeCurrent(); - } - } - } - - void GlContext::import() - { - BX_TRACE("Import:"); - -# define GL_EXTENSION(_optional, _proto, _func, _import) \ - { \ - if (NULL == _func) \ - { \ - _func = glXGetProcAddress<_proto>(#_import); \ - BX_TRACE("%p " #_func " (" #_import ")", _func); \ - BGFX_FATAL(_optional || NULL != _func \ - , Fatal::UnableToInitialize \ - , "Failed to create OpenGL context. glXGetProcAddress %s", #_import); \ - } \ - } - -# include "glimports.h" - -# undef GL_EXTENSION - } - -} /* namespace gl */ } // namespace bgfx - -# endif // BGFX_USE_GLX - -#endif // (BX_PLATFORM_BSD || BX_PLATFORM_LINUX) && (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL) diff --git a/3rdparty/bgfx/src/glcontext_glx.h b/3rdparty/bgfx/src/glcontext_glx.h deleted file mode 100644 index df87406db01..00000000000 --- a/3rdparty/bgfx/src/glcontext_glx.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2011-2022 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE - */ - -#ifndef BGFX_GLCONTEXT_GLX_H_HEADER_GUARD -#define BGFX_GLCONTEXT_GLX_H_HEADER_GUARD - -#if BGFX_USE_GLX - -# include -# define GLX_GLXEXT_LEGACY -# include - -namespace bgfx { namespace gl -{ - struct SwapChainGL; - - struct GlContext - { - GlContext() - : m_current(NULL) - , m_context(0) - , m_visualInfo(NULL) - , m_display(NULL) - , m_msaaContext(false) - { - } - - void create(uint32_t _width, uint32_t _height, uint32_t _flags); - void destroy(); - void resize(uint32_t _width, uint32_t _height, uint32_t _flags); - - uint64_t getCaps() const; - SwapChainGL* createSwapChain(void* _nwh); - void destroySwapChain(SwapChainGL* _swapChain); - void swap(SwapChainGL* _swapChain = NULL); - void makeCurrent(SwapChainGL* _swapChain = NULL); - - void import(); - - bool isValid() const - { - return 0 != m_context; - } - - SwapChainGL* m_current; - GLXContext m_context; - XVisualInfo* m_visualInfo; - ::Display* m_display; - // true when MSAA is handled by the context instead of using MSAA FBO - bool m_msaaContext; - }; -} /* namespace gl */ } // namespace bgfx - -#endif // BGFX_USE_GLX - -#endif // BGFX_GLCONTEXT_GLX_H_HEADER_GUARD diff --git a/3rdparty/bgfx/src/renderer_gl.h b/3rdparty/bgfx/src/renderer_gl.h index 4c2942a03b8..6d0346f3f8b 100644 --- a/3rdparty/bgfx/src/renderer_gl.h +++ b/3rdparty/bgfx/src/renderer_gl.h @@ -6,13 +6,12 @@ #ifndef BGFX_RENDERER_GL_H_HEADER_GUARD #define BGFX_RENDERER_GL_H_HEADER_GUARD -#define BGFX_USE_EGL (BGFX_CONFIG_RENDERER_OPENGLES && (0 \ - || BX_PLATFORM_ANDROID \ - || BX_PLATFORM_BSD \ - || BX_PLATFORM_LINUX \ - || BX_PLATFORM_NX \ - || BX_PLATFORM_RPI \ - || BX_PLATFORM_WINDOWS \ +#define BGFX_USE_EGL ( (BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES) && (0 \ + || BX_PLATFORM_ANDROID \ + || BX_PLATFORM_BSD \ + || BX_PLATFORM_LINUX \ + || BX_PLATFORM_NX \ + || BX_PLATFORM_RPI \ ) ) #define BGFX_USE_HTML5 (BGFX_CONFIG_RENDERER_OPENGLES && (0 \ @@ -23,11 +22,6 @@ || BX_PLATFORM_WINDOWS \ ) ) -#define BGFX_USE_GLX (BGFX_CONFIG_RENDERER_OPENGL && (0 \ - || BX_PLATFORM_BSD \ - || BX_PLATFORM_LINUX \ - ) ) - #define BGFX_USE_GL_DYNAMIC_LIB (0 \ || BX_PLATFORM_BSD \ || BX_PLATFORM_LINUX \ @@ -144,14 +138,6 @@ typedef uint64_t GLuint64; # include # endif // BGFX_CONFIG_RENDERER_ -# if BGFX_USE_EGL -# include "glcontext_egl.h" -# endif // BGFX_USE_EGL - -# if BGFX_USE_HTML5 -# include "glcontext_html5.h" -# endif // BGFX_USE_EGL - #endif // BGFX_CONFIG_RENDERER_OPENGL #include "renderer.h" @@ -1162,18 +1148,18 @@ typedef uint64_t GLuint64; # define GL_TEXTURE_LOD_BIAS 0x8501 #endif // GL_TEXTURE_LOD_BIAS -#if BX_PLATFORM_LINUX || BX_PLATFORM_BSD -# include "glcontext_glx.h" +#if BGFX_USE_EGL +# include "glcontext_egl.h" +#elif BGFX_USE_HTML5 +# include "glcontext_html5.h" +#elif BGFX_USE_WGL +# include "glcontext_wgl.h" #elif BX_PLATFORM_OSX # include "glcontext_nsgl.h" #elif BX_PLATFORM_IOS # include "glcontext_eagl.h" #endif // BX_PLATFORM_ -#if BGFX_USE_WGL -# include "glcontext_wgl.h" -#endif // BGFX_USE_WGL - #ifndef GL_APIENTRY # define GL_APIENTRY APIENTRY #endif // GL_APIENTRY diff --git a/3rdparty/bgfx/src/renderer_vk.cpp b/3rdparty/bgfx/src/renderer_vk.cpp index 30c7b99f1ca..aba25e78512 100644 --- a/3rdparty/bgfx/src/renderer_vk.cpp +++ b/3rdparty/bgfx/src/renderer_vk.cpp @@ -17,6 +17,10 @@ # import #endif // BX_PLATFORM_OSX +#if defined(WL_EGL_PLATFORM) +# include +#endif // defined(WL_EGL_PLATFORM) + namespace bgfx { namespace vk { static char s_viewName[BGFX_CONFIG_MAX_VIEWS][BGFX_CONFIG_MAX_VIEW_NAME]; @@ -1220,7 +1224,7 @@ VK_IMPORT BX_TRACE("\t%s", layer.m_name); } } -#if BX_PLATFORM_OSX +#if BX_PLATFORM_OSX || defined(WL_EGL_PLATFORM) uint32_t numEnabledExtensions = headless ? 0 : 3; const char* enabledExtension[Extension::Count + 3] = @@ -6759,41 +6763,57 @@ VK_DESTROY } #elif BX_PLATFORM_LINUX { - if (NULL != vkCreateXlibSurfaceKHR) +#if defined(WL_EGL_PLATFORM) + if (g_platformData.type == bgfx::NativeWindowHandleType::Wayland) { - VkXlibSurfaceCreateInfoKHR sci; - sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; + VkWaylandSurfaceCreateInfoKHR sci; + sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; sci.pNext = NULL; - sci.flags = 0; - sci.dpy = (Display*)g_platformData.ndt; - sci.window = (Window)m_nwh; - result = vkCreateXlibSurfaceKHR(instance, &sci, allocatorCb, &m_surface); + sci.flags = 0; + sci.display = (wl_display*)g_platformData.ndt; + sci.surface = (wl_surface*)((wl_egl_window*)m_nwh)->surface; + result = vkCreateWaylandSurfaceKHR(instance, &sci, allocatorCb, &m_surface); } - - if (VK_SUCCESS != result) + else +#endif // defined(WL_EGL_PLATFORM) { - void* xcbdll = bx::dlopen("libX11-xcb.so.1"); - - if (NULL != xcbdll - && NULL != vkCreateXcbSurfaceKHR) + if (NULL != vkCreateXlibSurfaceKHR) { - typedef xcb_connection_t* (*PFN_XGETXCBCONNECTION)(Display*); - PFN_XGETXCBCONNECTION XGetXCBConnection = (PFN_XGETXCBCONNECTION)bx::dlsym(xcbdll, "XGetXCBConnection"); + VkXlibSurfaceCreateInfoKHR sci; + sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; + sci.pNext = NULL; + sci.flags = 0; + sci.dpy = (Display*)g_platformData.ndt; + sci.window = (Window)m_nwh; + result = vkCreateXlibSurfaceKHR(instance, &sci, allocatorCb, &m_surface); + } - union { void* ptr; xcb_window_t window; } cast = { m_nwh }; + if (VK_SUCCESS != result) + { + void* xcbdll = bx::dlopen("libX11-xcb.so.1"); - VkXcbSurfaceCreateInfoKHR sci; - sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; - sci.pNext = NULL; - sci.flags = 0; - sci.connection = XGetXCBConnection( (Display*)g_platformData.ndt); - sci.window = cast.window; - result = vkCreateXcbSurfaceKHR(instance, &sci, allocatorCb, &m_surface); + if (NULL != xcbdll + && NULL != vkCreateXcbSurfaceKHR) + { + typedef xcb_connection_t* (*PFN_XGETXCBCONNECTION)(Display*); + PFN_XGETXCBCONNECTION XGetXCBConnection = (PFN_XGETXCBCONNECTION)bx::dlsym(xcbdll, "XGetXCBConnection"); - bx::dlclose(xcbdll); + union { void* ptr; xcb_window_t window; } cast = { m_nwh }; + + VkXcbSurfaceCreateInfoKHR sci; + sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; + sci.pNext = NULL; + sci.flags = 0; + sci.connection = XGetXCBConnection( (Display*)g_platformData.ndt); + sci.window = cast.window; + result = vkCreateXcbSurfaceKHR(instance, &sci, allocatorCb, &m_surface); + + bx::dlclose(xcbdll); + } } } } + #elif BX_PLATFORM_OSX { if (NULL != vkCreateMacOSSurfaceMVK) diff --git a/3rdparty/bgfx/src/renderer_vk.h b/3rdparty/bgfx/src/renderer_vk.h index f14e60fc755..fdd51301ea0 100644 --- a/3rdparty/bgfx/src/renderer_vk.h +++ b/3rdparty/bgfx/src/renderer_vk.h @@ -11,10 +11,17 @@ # define KHR_SURFACE_EXTENSION_NAME VK_KHR_ANDROID_SURFACE_EXTENSION_NAME # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_ANDROID #elif BX_PLATFORM_LINUX +# if defined(WL_EGL_PLATFORM) +# define VK_USE_PLATFORM_WAYLAND_KHR +# endif // defined(WL_EGL_PLATFORM) # define VK_USE_PLATFORM_XLIB_KHR # define VK_USE_PLATFORM_XCB_KHR -//# define VK_USE_PLATFORM_WAYLAND_KHR -# define KHR_SURFACE_EXTENSION_NAME VK_KHR_XCB_SURFACE_EXTENSION_NAME +# if defined(WL_EGL_PLATFORM) +# define KHR_SURFACE_EXTENSION_NAME VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, \ + VK_KHR_XCB_SURFACE_EXTENSION_NAME +# else +# define KHR_SURFACE_EXTENSION_NAME VK_KHR_XCB_SURFACE_EXTENSION_NAME +# endif // defined(WL_EGL_PLATFORM) # define VK_IMPORT_INSTANCE_PLATFORM VK_IMPORT_INSTANCE_LINUX #elif BX_PLATFORM_WINDOWS # define VK_USE_PLATFORM_WIN32_KHR @@ -32,6 +39,20 @@ #define VK_NO_STDINT_H #define VK_NO_PROTOTYPES #include + +// vulkan.h pulls X11 crap... +#if defined(None) +# undef None +#endif // defined(None) + +#if defined(Success) +# undef Success +#endif // defined(Success) + +#if defined(Status) +# undef Status +#endif // defined(Status) + #include "renderer.h" #include "debug_renderdoc.h" @@ -48,6 +69,19 @@ /* VK_KHR_android_surface */ \ VK_IMPORT_INSTANCE_FUNC(true, vkCreateAndroidSurfaceKHR); \ +#if defined(WL_EGL_PLATFORM) +#define VK_IMPORT_INSTANCE_LINUX \ + /* VK_KHR_wayland_surface */ \ + VK_IMPORT_INSTANCE_FUNC(true, vkCreateWaylandSurfaceKHR); \ + VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWaylandPresentationSupportKHR); \ + /* VK_KHR_xlib_surface */ \ + VK_IMPORT_INSTANCE_FUNC(true, vkCreateXlibSurfaceKHR); \ + VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXlibPresentationSupportKHR); \ + /* VK_KHR_xcb_surface */ \ + VK_IMPORT_INSTANCE_FUNC(true, vkCreateXcbSurfaceKHR); \ + VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXcbPresentationSupportKHR); \ + +#else #define VK_IMPORT_INSTANCE_LINUX \ /* VK_KHR_xlib_surface */ \ VK_IMPORT_INSTANCE_FUNC(true, vkCreateXlibSurfaceKHR); \ @@ -56,9 +90,7 @@ VK_IMPORT_INSTANCE_FUNC(true, vkCreateXcbSurfaceKHR); \ VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceXcbPresentationSupportKHR); \ -// /* VK_KHR_wayland_surface */ -// VK_IMPORT_INSTANCE_FUNC(true, vkCreateWaylandSurfaceKHR); -// VK_IMPORT_INSTANCE_FUNC(true, vkGetPhysicalDeviceWaylandPresentationSupportKHR); +#endif // defined(WL_EGL_PLATFORM) #define VK_IMPORT_INSTANCE_WINDOWS \ /* VK_KHR_win32_surface */ \ diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index af84db53384..7b80101e973 100755 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -1484,7 +1484,6 @@ end MAME_DIR .. "3rdparty/bgfx/src/debug_renderdoc.cpp", MAME_DIR .. "3rdparty/bgfx/src/dxgi.cpp", MAME_DIR .. "3rdparty/bgfx/src/glcontext_egl.cpp", - MAME_DIR .. "3rdparty/bgfx/src/glcontext_glx.cpp", MAME_DIR .. "3rdparty/bgfx/src/glcontext_html5.cpp", MAME_DIR .. "3rdparty/bgfx/src/glcontext_wgl.cpp", MAME_DIR .. "3rdparty/bgfx/src/nvapi.cpp",