mirror of https://github.com/AxioDL/metaforce.git
aurora: Refactor Dawn private API hacks
This commit is contained in:
parent
c33674b9ab
commit
693da0b59b
|
@ -21,6 +21,7 @@ add_library(aurora STATIC
|
||||||
lib/imgui.cpp
|
lib/imgui.cpp
|
||||||
lib/input.cpp
|
lib/input.cpp
|
||||||
lib/dawn/BackendBinding.cpp
|
lib/dawn/BackendBinding.cpp
|
||||||
|
lib/dawn/Hacks.cpp
|
||||||
lib/gfx/common.cpp
|
lib/gfx/common.cpp
|
||||||
lib/gfx/texture.cpp
|
lib/gfx/texture.cpp
|
||||||
lib/gfx/movie_player/shader.cpp
|
lib/gfx/movie_player/shader.cpp
|
||||||
|
@ -33,6 +34,10 @@ add_library(aurora STATIC
|
||||||
target_compile_definitions(aurora PRIVATE IMGUI_USER_CONFIG="imconfig_user.h") # IMGUI_USE_WCHAR32
|
target_compile_definitions(aurora PRIVATE IMGUI_USER_CONFIG="imconfig_user.h") # IMGUI_USE_WCHAR32
|
||||||
target_include_directories(aurora PUBLIC include ../Runtime)
|
target_include_directories(aurora PUBLIC include ../Runtime)
|
||||||
target_include_directories(aurora PRIVATE ../imgui ../extern/imgui)
|
target_include_directories(aurora PRIVATE ../imgui ../extern/imgui)
|
||||||
|
target_include_directories(aurora PRIVATE
|
||||||
|
../extern/dawn/src
|
||||||
|
../extern/dawn/third_party/abseil-cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/dawn/gen/src) # for hacks :)
|
||||||
target_link_libraries(aurora PRIVATE dawn_native dawncpp webgpu_dawn zeus logvisor SDL2-static xxhash)
|
target_link_libraries(aurora PRIVATE dawn_native dawncpp webgpu_dawn zeus logvisor SDL2-static xxhash)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
target_compile_definitions(aurora PRIVATE DAWN_ENABLE_BACKEND_METAL)
|
target_compile_definitions(aurora PRIVATE DAWN_ENABLE_BACKEND_METAL)
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "Hacks.hpp"
|
||||||
|
|
||||||
|
#include "dawn/native/Device.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "dawn/native/d3d12/AdapterD3D12.h"
|
||||||
|
#include "dawn/native/d3d12/BackendD3D12.h"
|
||||||
|
#include "dawn/native/d3d12/DeviceD3D12.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace dawn::native {
|
||||||
|
class HackedDevice : public DeviceBase {
|
||||||
|
public:
|
||||||
|
void _ForceSetToggle(Toggle toggle, bool isEnabled) { ForceSetToggle(toggle, isEnabled); }
|
||||||
|
};
|
||||||
|
} // namespace dawn::native
|
||||||
|
|
||||||
|
namespace aurora::gpu::hacks {
|
||||||
|
void apply_toggles(WGPUDevice device) {
|
||||||
|
auto* hack = static_cast<dawn::native::HackedDevice*>(static_cast<void*>(device));
|
||||||
|
hack->_ForceSetToggle(dawn::native::Toggle::UseUserDefinedLabelsInBackend, true);
|
||||||
|
#if _WIN32
|
||||||
|
hack->_ForceSetToggle(dawn::native::Toggle::UseDXC, true);
|
||||||
|
auto* backend = dawn::native::d3d12::ToBackend(hack->GetAdapter())->GetBackend();
|
||||||
|
backend->EnsureDxcCompiler();
|
||||||
|
backend->EnsureDxcLibrary();
|
||||||
|
backend->EnsureDxcValidator();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} // namespace aurora::gpu::hacks
|
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <dawn/webgpu.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helpers to expose private Dawn APIs
|
||||||
|
*/
|
||||||
|
namespace aurora::gpu::hacks {
|
||||||
|
void apply_toggles(WGPUDevice device);
|
||||||
|
} // namespace aurora::gpu::hacks
|
|
@ -8,18 +8,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "dawn/BackendBinding.hpp"
|
#include "dawn/BackendBinding.hpp"
|
||||||
|
#include "dawn/Hacks.hpp"
|
||||||
// TODO this hack doesn't link on Windows?
|
|
||||||
#ifndef _WIN32
|
|
||||||
// TODO HACK: dawn doesn't expose device toggles
|
|
||||||
#include "../extern/dawn/src/dawn/native/Toggles.h"
|
|
||||||
namespace dawn::native {
|
|
||||||
class DeviceBase {
|
|
||||||
public:
|
|
||||||
void SetToggle(Toggle toggle, bool isEnabled);
|
|
||||||
};
|
|
||||||
} // namespace dawn::native
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace aurora::gpu {
|
namespace aurora::gpu {
|
||||||
static logvisor::Module Log("aurora::gpu");
|
static logvisor::Module Log("aurora::gpu");
|
||||||
|
@ -151,11 +140,7 @@ void initialize(SDL_Window* window) {
|
||||||
};
|
};
|
||||||
g_device = wgpu::Device::Acquire(g_Adapter.CreateDevice(&deviceDescriptor));
|
g_device = wgpu::Device::Acquire(g_Adapter.CreateDevice(&deviceDescriptor));
|
||||||
g_device.SetUncapturedErrorCallback(&error_callback, nullptr);
|
g_device.SetUncapturedErrorCallback(&error_callback, nullptr);
|
||||||
#ifndef _WIN32
|
hacks::apply_toggles(g_device.Get());
|
||||||
// TODO HACK: dawn doesn't expose device toggles
|
|
||||||
static_cast<dawn::native::DeviceBase*>(static_cast<void*>(g_device.Get()))
|
|
||||||
->SetToggle(dawn::native::Toggle::UseUserDefinedLabelsInBackend, true);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
g_queue = g_device.GetQueue();
|
g_queue = g_device.GetQueue();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue