Hi I’m very new to SDL and I’m trying to contribute to this project (GitHub - encounter/aurora: A source-level GameCube & Wii compatibility layer) that uses SDL. The project is stuck on a older version of WebGPU Dawn which removed a deprecated swapchain method which allowed the use of a surface created by SDL. The new method accepts a wpgu::Surface object which might be able to be created using the display, window, and surface properties of SDL_SysWMinfo. Currently I am just trying to get this working on X11, so all I need is the x11 display and window.
My code currently:
lib/webgpu/sdl.cpp
namespace aurora::webgpu {
wgpu::Surface CreateSurfaceForWindow(const wgpu::Instance& instance, SDL_Window* window){
std::unique_ptr<wgpu::ChainedStruct> const chainedDescriptor =
SetupWindowAndGetSurfaceDescriptor(window);
wgpu::SurfaceDescriptor descriptor;
descriptor.nextInChain = chainedDescriptor.get();
wgpu::Surface surface = instance.CreateSurface(&descriptor);
return surface;
}
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(SDL_Window* window){
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
SDL_GetWindowWMInfo(window, &wmInfo);
switch (wmInfo.subsystem) {
case SDL_SYSWM_X11:
{
std::unique_ptr<wgpu::SurfaceDescriptorFromXlibWindow> desc =
std::make_unique<wgpu::SurfaceDescriptorFromXlibWindow>();
desc->display = wmInfo.info.x11.display;
desc->window = wmInfo.info.x11.window;
return std::move(desc);
}
default:
return;
}
}
}
Compiler output:
/home/austin/Projects/metaforce/extern/aurora/lib/webgpu/sdl.cpp
/home/austin/Projects/metaforce/extern/aurora/lib/webgpu/sdl.cpp: In function ‘std::unique_ptr<wgpu::ChainedStruct> aurora::webgpu::SetupWindowAndGetSurfaceDescriptor(SDL_Window*)’:
/home/austin/Projects/metaforce/extern/aurora/lib/webgpu/sdl.cpp:30:33: error: ‘union SDL_SysWMinfo::<unnamed>’ has no member named ‘x11’
30 | desc->display = wmInfo.info.x11.display;
| ^~~
/home/austin/Projects/metaforce/extern/aurora/lib/webgpu/sdl.cpp:31:32: error: ‘union SDL_SysWMinfo::<unnamed>’ has no member named ‘x11’
31 | desc->window = wmInfo.info.x11.window;
| ^~~
/home/austin/Projects/metaforce/extern/aurora/lib/webgpu/sdl.cpp:35:5: error: return-statement with no value, in function returning ‘std::unique_ptr<wgpu::ChainedStruct>’ [-fpermissive]
35 | return;
| ^~~~~~
[678/1303] Building CXX object extern/aurora/CMakeFiles/aurora.dir/lib/dolphin/GXTransform.cpp.o
ninja: build stopped: subcommand failed.
It seems that only the dummy info is available. Not sure why other platforms such as x11 aren’t included in the union?
Note: This project builds SDL as a cmake subdirectory. It seems this build is not defining SDL_VIDEO_DRIVER_X11 or any of the other video drivers for the SDL_SysWMinfo struct.
Here is my fork of the project: GitHub - Austint30/aurora at dawn-upgrade