Try loading surface creation function via dlsym instead

This commit is contained in:
Sebastian Emanuel Dawid 2025-08-15 23:38:04 +02:00
parent 8dc6a1f00b
commit cb0c28908f
4 changed files with 11 additions and 17 deletions

View File

@ -6531,19 +6531,6 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
#if defined(WEBGPU_H_) #if defined(WEBGPU_H_)
/*! @brief Provide the address of the `wgpuInstanceCreateSurface` function to GLFW.
*
* This function passes the address provided for the `wgpuInstanceCreateSurface` function
* to GLFW.
*
* @param[in] addr The address of the `wgpuInstanceCreateSurface` function.
*
* @since Added in version 3.5
*
* @ingroup webgpu
*/
GLFWAPI void glfwSetWGPUInstanceCreateSurfaceAddr(WGPUSurface (*addr)(WGPUInstance, const WGPUSurfaceDescriptor*));
/*! @brief Creates a WebGPU surface for the specified window. /*! @brief Creates a WebGPU surface for the specified window.
* *
* This function creates a WebGPU surface for the specified window. * This function creates a WebGPU surface for the specified window.

View File

@ -402,6 +402,8 @@ GLFWAPI int glfwInit(void)
if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform)) if (!_glfwSelectPlatform(_glfw.hints.init.platformID, &_glfw.platform))
return GLFW_FALSE; return GLFW_FALSE;
_glfwLoadWGPUInstanceCreateSurfaceAddr();
if (!_glfw.platform.init()) if (!_glfw.platform.init())
{ {
terminate(); terminate();

View File

@ -1051,6 +1051,8 @@ GLFWbool _glfwInitVulkan(int mode);
void _glfwTerminateVulkan(void); void _glfwTerminateVulkan(void);
const char* _glfwGetVulkanResultString(VkResult result); const char* _glfwGetVulkanResultString(VkResult result);
void _glfwLoadWGPUInstanceCreateSurfaceAddr(void);
size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); size_t _glfwEncodeUTF8(char* s, uint32_t codepoint);
char** _glfwParseUriList(char* text, int* count); char** _glfwParseUriList(char* text, int* count);

View File

@ -28,11 +28,14 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_GLFW_WIN32)
GLFWAPI void glfwSetWGPUInstanceCreateSurfaceAddr(WGPUSurface (*addr)(WGPUInstance, const WGPUSurfaceDescriptor*)) { // TODO: Implement Window version
_GLFW_REQUIRE_INIT() #else
_glfw.wgpu.instanceCreateSurface = addr; #include <dlfcn.h>
void _glfwLoadWGPUInstanceCreateSurfaceAddr() {
_glfw.wgpu.instanceCreateSurface = dlsym(RTLD_DEFAULT, "wgpuInstanceCreateSurface");
} }
#endif
GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle) { GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle) {
_GLFW_REQUIRE_INIT_OR_RETURN(NULL) _GLFW_REQUIRE_INIT_OR_RETURN(NULL)