#include "BackendBinding.hpp" #include #if defined(DAWN_ENABLE_BACKEND_D3D11) #include #endif #if defined(DAWN_ENABLE_BACKEND_D3D12) #include #endif #if defined(DAWN_ENABLE_BACKEND_METAL) #include #endif #if defined(DAWN_ENABLE_BACKEND_VULKAN) #include #endif #if defined(DAWN_ENABLE_BACKEND_OPENGL) #include #endif #if defined(DAWN_ENABLE_BACKEND_NULL) #include #endif #if !defined(SDL_PLATFORM_MACOS) #include #endif namespace aurora::webgpu::utils { std::unique_ptr SetupWindowAndGetSurfaceDescriptorCocoa(SDL_Window* window); std::unique_ptr SetupWindowAndGetSurfaceDescriptor(SDL_Window* window) { #if defined(SDL_PLATFORM_MACOS) return SetupWindowAndGetSurfaceDescriptorCocoa(window); #else const auto props = SDL_GetWindowProperties(window); #if defined(SDL_PLATFORM_WIN32) std::unique_ptr desc = std::make_unique(); desc->hwnd = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr); desc->hinstance = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER, nullptr); return std::move(desc); #elif defined(SDL_PLATFORM_LINUX) const char* driver = SDL_GetCurrentVideoDriver(); if (SDL_strcmp(driver, "wayland") == 0) { std::unique_ptr desc = std::make_unique(); desc->display = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nullptr); desc->surface = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr); return std::move(desc); } if (SDL_strcmp(driver, "x11") == 0) { std::unique_ptr desc = std::make_unique(); desc->display = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, nullptr); desc->window = SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0); return std::move(desc); } #endif return nullptr; #endif } } // namespace aurora::webgpu::utils