mirror of
https://github.com/glfw/glfw.git
synced 2025-08-31 19:11:49 +00:00
Add WebGPU support for MacOS
This commit is contained in:
parent
4cbb4db70c
commit
44f8a80ade
@ -564,7 +564,8 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform)
|
|||||||
.getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa,
|
.getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa,
|
||||||
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa,
|
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa,
|
||||||
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa,
|
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa,
|
||||||
.createWindowSurface = _glfwCreateWindowSurfaceCocoa
|
.createWindowSurface = _glfwCreateWindowSurfaceCocoa,
|
||||||
|
.createWindowWGPUSurface = _glfwCreateWindowWGPUSurfaceCocoa
|
||||||
};
|
};
|
||||||
|
|
||||||
*platform = cocoa;
|
*platform = cocoa;
|
||||||
|
@ -276,6 +276,8 @@ void _glfwGetRequiredInstanceExtensionsCocoa(char** extensions);
|
|||||||
GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportCocoa(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
WGPUSurface _glfwCreateWindowWGPUSurfaceCocoa(WGPUInstance instance, _GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorCocoa(_GLFWmonitor* monitor);
|
||||||
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
|
@ -2020,6 +2020,26 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
|||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct WGPUSurfaceSourceMetalLayer {
|
||||||
|
WGPUChainedStruct chain;
|
||||||
|
void * layer;
|
||||||
|
} WGPUSurfaceSourceMetalLayer;
|
||||||
|
|
||||||
|
WGPUSurface _glfwCreateWindowWGPUSurfaceCocoa(WGPUInstance instance, _GLFWwindow* window) {
|
||||||
|
[window->ns.view setLayer:window->ns.layer];
|
||||||
|
[window->ns.view setWantsLayer:YES];
|
||||||
|
|
||||||
|
WGPUSurfaceSourceMetalLayer metalSurface;
|
||||||
|
metalSurface.chain.next = NULL;
|
||||||
|
metalSurface.chain.sType = WGPUSType_SurfaceSourceMetalLayer;
|
||||||
|
metalSurface.layer = window->ns.layer;
|
||||||
|
|
||||||
|
WGPUSurfaceDescriptor surfaceDescriptor;
|
||||||
|
surfaceDescriptor.nextInChain = &metalSurface.chain;
|
||||||
|
surfaceDescriptor.label = (WGPUStringView){ NULL, SIZE_MAX };
|
||||||
|
|
||||||
|
return wgpuInstanceCreateSurface(instance, &surfaceDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW native API //////
|
////// GLFW native API //////
|
||||||
|
Loading…
Reference in New Issue
Block a user