mirror of https://github.com/encounter/aurora.git
Compare commits
4 Commits
3edd2c0e58
...
7ed3f03c6b
Author | SHA1 | Date |
---|---|---|
Luke Street | 7ed3f03c6b | |
Luke Street | 74984bd1fe | |
Luke Street | 9c75c739e4 | |
Luke Street | fca51127a2 |
|
@ -84,7 +84,7 @@ endif ()
|
||||||
|
|
||||||
add_library(aurora_main STATIC lib/main.cpp)
|
add_library(aurora_main STATIC lib/main.cpp)
|
||||||
target_include_directories(aurora_main PUBLIC include)
|
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)
|
add_library(aurora::main ALIAS aurora_main)
|
||||||
|
|
||||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0bd776df12d2f747b17437c6501751fdee70f14d
|
Subproject commit f10e70a26db00bb89f88be4204cf49ffc869e194
|
|
@ -1,6 +1,8 @@
|
||||||
#include "BackendBinding.hpp"
|
#include "BackendBinding.hpp"
|
||||||
|
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
#include <dawn/native/D3D12Backend.h>
|
#include <dawn/native/D3D12Backend.h>
|
||||||
#endif
|
#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_MAJOR_VERSION, 4);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
|
||||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||||
dawn::native::opengl::AdapterDiscoveryOptions adapterOptions{WGPUBackendType_OpenGL};
|
dawn::native::opengl::PhysicalDeviceDiscoveryOptions options{WGPUBackendType_OpenGL};
|
||||||
adapterOptions.getProc = SDL_GL_GetProcAddress;
|
options.getProc = SDL_GL_GetProcAddress;
|
||||||
adapterOptions.makeCurrent = GLMakeCurrent;
|
options.makeCurrent = GLMakeCurrent;
|
||||||
adapterOptions.destroy = GLDestroy;
|
options.destroy = GLDestroy;
|
||||||
adapterOptions.userData = new GLUserData{
|
options.userData = new GLUserData{
|
||||||
.window = window,
|
.window = window,
|
||||||
.context = context,
|
.context = context,
|
||||||
};
|
};
|
||||||
return instance->DiscoverAdapters(&adapterOptions);
|
return instance->DiscoverPhysicalDevices(&options);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGLES)
|
#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_MAJOR_VERSION, 3);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||||
dawn::native::opengl::AdapterDiscoveryOptions adapterOptions{WGPUBackendType_OpenGLES};
|
dawn::native::opengl::PhysicalDeviceDiscoveryOptions options{WGPUBackendType_OpenGLES};
|
||||||
adapterOptions.getProc = SDL_GL_GetProcAddress;
|
options.getProc = SDL_GL_GetProcAddress;
|
||||||
adapterOptions.makeCurrent = GLMakeCurrent;
|
options.makeCurrent = GLMakeCurrent;
|
||||||
adapterOptions.destroy = GLDestroy;
|
options.destroy = GLDestroy;
|
||||||
adapterOptions.userData = new GLUserData{
|
options.userData = new GLUserData{
|
||||||
.window = window,
|
.window = window,
|
||||||
.context = context,
|
.context = context,
|
||||||
};
|
};
|
||||||
return instance->DiscoverAdapters(&adapterOptions);
|
return instance->DiscoverPhysicalDevices(&options);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
#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> SetupWindowAndGetSurfaceDescriptorCocoa(SDL_Window* window);
|
||||||
|
|
||||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(SDL_Window* window) {
|
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(SDL_Window* window) {
|
||||||
#if _WIN32
|
#if defined(SDL_VIDEO_DRIVER_COCOA)
|
||||||
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)
|
|
||||||
return SetupWindowAndGetSurfaceDescriptorCocoa(window);
|
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
|
#else
|
||||||
{
|
SDL_SysWMinfo wmInfo;
|
||||||
|
SDL_VERSION(&wmInfo.version);
|
||||||
|
if (SDL_GetWindowWMInfo(window, &wmInfo) == SDL_FALSE) {
|
||||||
return nullptr;
|
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
|
#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
|
#else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aurora::webgpu::utils
|
} // namespace aurora::webgpu::utils
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dawn/native/DawnNative.h>
|
#include <dawn/native/DawnNative.h>
|
||||||
|
#include <memory>
|
||||||
#include <webgpu/webgpu_cpp.h>
|
#include <webgpu/webgpu_cpp.h>
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
|
|
@ -1330,7 +1330,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {{{8}{7}
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::ShaderModuleWGSLDescriptor wgslDescriptor{};
|
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 label = fmt::format(FMT_STRING("GX Shader {:x}"), hash);
|
||||||
const auto shaderDescriptor = wgpu::ShaderModuleDescriptor{
|
const auto shaderDescriptor = wgpu::ShaderModuleDescriptor{
|
||||||
.nextInChain = &wgslDescriptor,
|
.nextInChain = &wgslDescriptor,
|
||||||
|
|
|
@ -196,7 +196,7 @@ static WGPUShaderModule ImGui_ImplWGPU_CreateShaderModule(const char* source)
|
||||||
{
|
{
|
||||||
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
WGPUShaderModuleWGSLDescriptor wgsl_desc = {};
|
||||||
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
wgsl_desc.chain.sType = WGPUSType_ShaderModuleWGSLDescriptor;
|
||||||
wgsl_desc.source = source;
|
wgsl_desc.code = source;
|
||||||
|
|
||||||
WGPUShaderModuleDescriptor desc = {};
|
WGPUShaderModuleDescriptor desc = {};
|
||||||
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&wgsl_desc);
|
||||||
|
|
|
@ -147,7 +147,7 @@ static TextureWithSampler create_depth_texture() {
|
||||||
|
|
||||||
void create_copy_pipeline() {
|
void create_copy_pipeline() {
|
||||||
wgpu::ShaderModuleWGSLDescriptor sourceDescriptor{};
|
wgpu::ShaderModuleWGSLDescriptor sourceDescriptor{};
|
||||||
sourceDescriptor.source = R"""(
|
sourceDescriptor.code = R"""(
|
||||||
@group(0) @binding(0)
|
@group(0) @binding(0)
|
||||||
var efb_sampler: sampler;
|
var efb_sampler: sampler;
|
||||||
@group(0) @binding(1)
|
@group(0) @binding(1)
|
||||||
|
|
Loading…
Reference in New Issue