Partially Revert "Remove function to pass address of wgpuInstanceCreateSurface."

This reverts commit 8c2f255906.
This commit is contained in:
Sebastian Emanuel Dawid 2025-09-29 15:30:00 +02:00
parent 044774dcee
commit 1471e07ceb
3 changed files with 23 additions and 8 deletions

View File

@ -6536,6 +6536,19 @@ 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

@ -367,9 +367,8 @@ typedef struct WGPUSurfaceDescriptor
WGPUStringView label; WGPUStringView label;
} WGPUSurfaceDescriptor; } WGPUSurfaceDescriptor;
#if !defined(_MSC_VER) typedef WGPUSurface (*PFN_wgpuInstanceCreateSurface)(WGPUInstance, const WGPUSurfaceDescriptor*);
WGPUSurface __attribute__((weak)) wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor); #define wgpuInstanceCreateSurface _glfw.wgpu.instanceCreateSurface
#endif
#include "platform.h" #include "platform.h"
@ -916,6 +915,10 @@ struct _GLFWlibrary
GLFWbool EXT_headless_surface; GLFWbool EXT_headless_surface;
} vk; } vk;
struct {
PFN_wgpuInstanceCreateSurface instanceCreateSurface;
} wgpu;
struct { struct {
GLFWmonitorfun monitor; GLFWmonitorfun monitor;
GLFWjoystickfun joystick; GLFWjoystickfun joystick;

View File

@ -29,12 +29,11 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#if !defined(_MSC_VER) GLFWAPI void glfwSetWGPUInstanceCreateSurfaceAddr(WGPUSurface (*addr)(WGPUInstance, const WGPUSurfaceDescriptor*))
WGPUSurface __attribute__((weak)) wgpuInstanceCreateSurface(WGPUInstance instance, const WGPUSurfaceDescriptor* descriptor)
{ {
return NULL; _GLFW_REQUIRE_INIT()
_glfw.wgpu.instanceCreateSurface = addr;
} }
#endif
GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle) GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindow* handle)
{ {
@ -44,7 +43,7 @@ GLFWAPI WGPUSurface glfwCreateWindowWGPUSurface(WGPUInstance instance, GLFWwindo
assert(window != NULL); assert(window != NULL);
assert(instance != NULL); assert(instance != NULL);
assert(&wgpuInstanceCreateSurface != NULL); assert(_glfw.wgpu.instanceCreateSurface != NULL);
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
{ {