From f4cf5565fa209e388e2f8f8a0fa1eee33099744b Mon Sep 17 00:00:00 2001 From: Myra Date: Fri, 10 Oct 2025 20:43:28 +0200 Subject: [PATCH] Add linux wayland support to claudia (#6249) * Add linux wayland support to claudia Could not do x11 because quote "oh my god x11 support might be a hecking nightmare" -pjb but the skeleton is there i guess * Review * Ok massivly misunderstood pjb --- .../WebGpu/RhiWebGpu.Window.cs | 32 +++++++++++++------ .../Graphics/Clyde/Windowing/Sdl3.Window.cs | 26 ++++++++------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs b/Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs index a761b4b7a..0927fefe3 100644 --- a/Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs +++ b/Robust.Client.Graphics.Rhi/WebGpu/RhiWebGpu.Window.cs @@ -44,26 +44,38 @@ internal sealed unsafe partial class RhiWebGpu surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescMetal); #elif LINUX - // TODO: Linux surface creation - /* + WGPUSurfaceSourceWaylandSurface surfaceDescWayland; WGPUSurfaceSourceXlibWindow surfaceDescX11; - var xDisplay = _clyde._windowing.WindowGetX11Display(window); - var xWindow = _clyde._windowing.WindowGetX11Id(window); - if (xDisplay != null && xWindow != null) + if (surfaceParams.Wayland) { - surfaceDescX11 = new WGPUSurfaceSourceXlibWindow + surfaceDescWayland = new WGPUSurfaceSourceWaylandSurface + { + chain = + { + sType = WGPUSType.WGPUSType_SurfaceSourceWaylandSurface + }, + display = surfaceParams.WaylandDisplay, + surface = surfaceParams.WaylandSurface, + }; + + surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescWayland); + } + else + { + surfaceDescX11 = new WGPUSurfaceSourceXlibWindow() { chain = { sType = WGPUSType.WGPUSType_SurfaceSourceXlibWindow }, - display = ((IntPtr)xDisplay.Value).ToPointer(), - window = xWindow.Value + display = surfaceParams.X11Display, + // TODO "Oh my god x11 support might be a nightmare this is outside of your ability to deal with -pjb" + // window = surfaceParams.X11Window, }; - surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescX11); - */ + surfaceDesc.nextInChain = (WGPUChainedStruct*)(&surfaceDescX11); + } #endif var surface = wgpuInstanceCreateSurface(_wgpuInstance, &surfaceDesc); diff --git a/Robust.Client/Graphics/Clyde/Windowing/Sdl3.Window.cs b/Robust.Client/Graphics/Clyde/Windowing/Sdl3.Window.cs index f84edad56..b9dd1150d 100644 --- a/Robust.Client/Graphics/Clyde/Windowing/Sdl3.Window.cs +++ b/Robust.Client/Graphics/Clyde/Windowing/Sdl3.Window.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; using System.Threading.Tasks; @@ -480,24 +481,27 @@ internal partial class Clyde { return new RhiBase.RhiWindowSurfaceParams { - X11Display = SDL.SDL_GetPointerProperty(windowProps, SDL.SDL_PROP_WINDOW_X11_DISPLAY_POINTER, 0), - X11Id = SDL.SDL_GetPointerProperty(windowProps, SDL.SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0), + Wayland = true, + WaylandDisplay = (void*)SDL.SDL_GetPointerProperty( + props, + SDL.SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, + 0), + WaylandSurface = (void*)SDL.SDL_GetPointerProperty(props, + SDL.SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, + 0), }; } else { - Debug.Assert(_videoDriver == _sdlVideoDriver.X11); return new RhiBase.RhiWindowSurfaceParams { - Wayland = true, - WaylandDisplay = SDL.SDL_GetPointerProperty( - windowProps, - SDL.SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, - 0), - WaylandSurface = SDL.SDL_GetPointerProperty( - windowProps, - SDL.SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, + X11Display = (void*)SDL.SDL_GetPointerProperty(props, + SDL.SDL_PROP_WINDOW_X11_DISPLAY_POINTER, 0), + // TODO "Oh my god x11 support might be a nightmare this is outside of your ability to deal with -pjb" + // X11Window = SDL.SDL_GetPointerProperty(props, + // SDL.SDL_PROP_WINDOW_X11_WINDOW_NUMBER, + // 0), }; } #endif