mirror of
https://github.com/glfw/glfw.git
synced 2025-08-31 19:11:49 +00:00
Add WebGPU support to X11
This commit is contained in:
parent
37812b7e36
commit
205bf6c768
@ -1246,7 +1246,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
|
|||||||
.getEGLNativeWindow = _glfwGetEGLNativeWindowX11,
|
.getEGLNativeWindow = _glfwGetEGLNativeWindowX11,
|
||||||
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11,
|
.getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11,
|
||||||
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11,
|
.getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11,
|
||||||
.createWindowSurface = _glfwCreateWindowSurfaceX11
|
.createWindowSurface = _glfwCreateWindowSurfaceX11,
|
||||||
|
.createWindowWGPUSurface = _glfwCreateWindowWGPUSurfaceX11
|
||||||
};
|
};
|
||||||
|
|
||||||
// HACK: If the application has left the locale as "C" then both wide
|
// HACK: If the application has left the locale as "C" then both wide
|
||||||
|
@ -963,6 +963,8 @@ void _glfwGetRequiredInstanceExtensionsX11(char** extensions);
|
|||||||
GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
GLFWbool _glfwGetPhysicalDevicePresentationSupportX11(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
|
||||||
VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
VkResult _glfwCreateWindowSurfaceX11(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
WGPUSurface _glfwCreateWindowWGPUSurfaceX11(WGPUInstance instance, _GLFWwindow* window);
|
||||||
|
|
||||||
void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
void _glfwFreeMonitorX11(_GLFWmonitor* monitor);
|
||||||
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||||
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale);
|
||||||
|
@ -3282,6 +3282,53 @@ VkResult _glfwCreateWindowSurfaceX11(VkInstance instance,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct WGPUSurfaceSourceXCBWindow {
|
||||||
|
WGPUChainedStruct chain;
|
||||||
|
void * connection;
|
||||||
|
uint32_t window;
|
||||||
|
} WGPUSurfaceSourceXCBWindow;
|
||||||
|
|
||||||
|
typedef struct WGPUSurfaceSourceXlibWindow {
|
||||||
|
WGPUChainedStruct chain;
|
||||||
|
void * display;
|
||||||
|
uint64_t window;
|
||||||
|
} WGPUSurfaceSourceXlibWindow;
|
||||||
|
|
||||||
|
WGPUSurface _glfwCreateWindowWGPUSurfaceX11(WGPUInstance instance, _GLFWwindow* window)
|
||||||
|
{
|
||||||
|
WGPUSurfaceDescriptor surfaceDescriptor;
|
||||||
|
|
||||||
|
if (_glfw.x11.x11xcb.handle)
|
||||||
|
{
|
||||||
|
WGPUSurfaceSourceXCBWindow xcbSurface;
|
||||||
|
xcbSurface.chain.sType = WGPUSType_SurfaceSourceXCBWindow;
|
||||||
|
xcbSurface.chain.next = NULL;
|
||||||
|
xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
|
||||||
|
if (!connection)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"X11: Failed to retrieve XCB connection");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
xcbSurface.connection = connection;
|
||||||
|
xcbSurface.window = window->x11.handle;
|
||||||
|
surfaceDescriptor.nextInChain = &xcbSurface.chain;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WGPUSurfaceSourceXlibWindow xlibSurface;
|
||||||
|
xlibSurface.chain.sType = WGPUSType_SurfaceSourceXlibWindow;
|
||||||
|
xlibSurface.chain.next = NULL;
|
||||||
|
xlibSurface.display = _glfw.x11.display;
|
||||||
|
xlibSurface.window = window->x11.handle;
|
||||||
|
surfaceDescriptor.nextInChain = &xlibSurface.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