Compare commits

...

4 Commits

7 changed files with 50 additions and 43 deletions

View File

@ -84,7 +84,7 @@ endif ()
add_library(aurora_main STATIC lib/main.cpp)
target_include_directories(aurora_main PUBLIC include)
target_link_libraries(aurora_main PUBLIC SDL2::SDL2main)
target_link_libraries(aurora_main PUBLIC SDL2::SDL2-static SDL2::SDL2main)
add_library(aurora::main ALIAS aurora_main)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

2
extern/dawn vendored

@ -1 +1 @@
Subproject commit 0bd776df12d2f747b17437c6501751fdee70f14d
Subproject commit f10e70a26db00bb89f88be4204cf49ffc869e194

View File

@ -1,6 +1,8 @@
#include "BackendBinding.hpp"
#include <SDL_syswm.h>
#include <memory>
#if defined(DAWN_ENABLE_BACKEND_D3D12)
#include <dawn/native/D3D12Backend.h>
#endif
@ -63,15 +65,15 @@ bool DiscoverAdapter(dawn::native::Instance* instance, [[maybe_unused]] SDL_Wind
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
SDL_GLContext context = SDL_GL_CreateContext(window);
dawn::native::opengl::AdapterDiscoveryOptions adapterOptions{WGPUBackendType_OpenGL};
adapterOptions.getProc = SDL_GL_GetProcAddress;
adapterOptions.makeCurrent = GLMakeCurrent;
adapterOptions.destroy = GLDestroy;
adapterOptions.userData = new GLUserData{
dawn::native::opengl::PhysicalDeviceDiscoveryOptions options{WGPUBackendType_OpenGL};
options.getProc = SDL_GL_GetProcAddress;
options.makeCurrent = GLMakeCurrent;
options.destroy = GLDestroy;
options.userData = new GLUserData{
.window = window,
.context = context,
};
return instance->DiscoverAdapters(&adapterOptions);
return instance->DiscoverPhysicalDevices(&options);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_OPENGLES)
@ -81,15 +83,15 @@ bool DiscoverAdapter(dawn::native::Instance* instance, [[maybe_unused]] SDL_Wind
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GLContext context = SDL_GL_CreateContext(window);
dawn::native::opengl::AdapterDiscoveryOptions adapterOptions{WGPUBackendType_OpenGLES};
adapterOptions.getProc = SDL_GL_GetProcAddress;
adapterOptions.makeCurrent = GLMakeCurrent;
adapterOptions.destroy = GLDestroy;
adapterOptions.userData = new GLUserData{
dawn::native::opengl::PhysicalDeviceDiscoveryOptions options{WGPUBackendType_OpenGLES};
options.getProc = SDL_GL_GetProcAddress;
options.makeCurrent = GLMakeCurrent;
options.destroy = GLDestroy;
options.userData = new GLUserData{
.window = window,
.context = context,
};
return instance->DiscoverAdapters(&adapterOptions);
return instance->DiscoverPhysicalDevices(&options);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_NULL)
@ -105,40 +107,44 @@ bool DiscoverAdapter(dawn::native::Instance* instance, [[maybe_unused]] SDL_Wind
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorCocoa(SDL_Window* window);
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(SDL_Window* window) {
#if _WIN32
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
desc->hwnd = glfwGetWin32Window(window);
desc->hinstance = GetModuleHandle(nullptr);
return std::move(desc);
#elif defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(SDL_VIDEO_DRIVER_COCOA)
return SetupWindowAndGetSurfaceDescriptorCocoa(window);
#elif defined(DAWN_USE_WAYLAND) || defined(DAWN_USE_X11)
#if defined(GLFW_PLATFORM_WAYLAND) && defined(DAWN_USE_WAYLAND)
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
std::unique_ptr<wgpu::SurfaceDescriptorFromWaylandSurface> desc =
std::make_unique<wgpu::SurfaceDescriptorFromWaylandSurface>();
desc->display = glfwGetWaylandDisplay();
desc->surface = glfwGetWaylandWindow(window);
return std::move(desc);
} else // NOLINT(readability/braces)
#endif
#if defined(DAWN_USE_X11)
{
std::unique_ptr<wgpu::SurfaceDescriptorFromXlibWindow> desc =
std::make_unique<wgpu::SurfaceDescriptorFromXlibWindow>();
desc->display = glfwGetX11Display();
desc->window = glfwGetX11Window(window);
return std::move(desc);
}
#else
{
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (SDL_GetWindowWMInfo(window, &wmInfo) == SDL_FALSE) {
return nullptr;
}
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
desc->hwnd = wmInfo.info.window;
desc->hinstance = wmInfo.info.hinstance;
return std::move(desc);
#elif defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_X11)
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
if (wmInfo.subsystem == SDL_SYSWM_WAYLAND) {
std::unique_ptr<wgpu::SurfaceDescriptorFromWaylandSurface> desc =
std::make_unique<wgpu::SurfaceDescriptorFromWaylandSurface>();
desc->display = wmInfo.info.wl.display;
desc->surface = wmInfo.info.wl.surface;
return std::move(desc);
}
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
if (wmInfo.subsystem == 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);
}
#endif
return nullptr;
#else
return nullptr;
#endif
#endif
}
} // namespace aurora::webgpu::utils

View File

@ -1,6 +1,7 @@
#pragma once
#include <dawn/native/DawnNative.h>
#include <memory>
#include <webgpu/webgpu_cpp.h>
struct SDL_Window;

View File

@ -1330,7 +1330,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {{{8}{7}
}
wgpu::ShaderModuleWGSLDescriptor wgslDescriptor{};
wgslDescriptor.source = shaderSource.c_str();
wgslDescriptor.code = shaderSource.c_str();
const auto label = fmt::format(FMT_STRING("GX Shader {:x}"), hash);
const auto shaderDescriptor = wgpu::ShaderModuleDescriptor{
.nextInChain = &wgslDescriptor,

View File

@ -196,7 +196,7 @@ static WGPUShaderModule ImGui_ImplWGPU_CreateShaderModule(const char* source)
{
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
wgsl_desc.source = source;
wgsl_desc.code = source;
WGPUShaderModuleDescriptor desc = {};
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);

View File

@ -147,7 +147,7 @@ static TextureWithSampler create_depth_texture() {
void create_copy_pipeline() {
wgpu::ShaderModuleWGSLDescriptor sourceDescriptor{};
sourceDescriptor.source = R"""(
sourceDescriptor.code = R"""(
@group(0) @binding(0)
var efb_sampler: sampler;
@group(0) @binding(1)