mirror of https://github.com/AxioDL/metaforce.git
Restore graphicsApi, msaa, and textureAniso cvars, fix a few deserialization bugs in CVar.cpp
This commit is contained in:
parent
af1814d3c7
commit
46a93166ef
|
@ -568,7 +568,9 @@ int main(int argc, char** argv) {
|
||||||
.width = icon.width,
|
.width = icon.width,
|
||||||
.height = icon.height,
|
.height = icon.height,
|
||||||
};
|
};
|
||||||
aurora::app_run(std::move(app), std::move(data), argc, argv, fileMgr.getStoreRoot());
|
aurora::app_run(std::move(app), std::move(data), argc, argv, fileMgr.getStoreRoot(),
|
||||||
|
aurora::translate_backend(cvarCmns.getGraphicsApi()), cvarCmns.getSamples(),
|
||||||
|
cvarCmns.getAnisotropy());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -434,7 +434,7 @@ void CVar::dispatch() {
|
||||||
bool isReal(std::string_view v) {
|
bool isReal(std::string_view v) {
|
||||||
char* p;
|
char* p;
|
||||||
std::strtod(v.data(), &p);
|
std::strtod(v.data(), &p);
|
||||||
return *p == 0;
|
return p != nullptr && *p == 0;
|
||||||
}
|
}
|
||||||
bool isReal(const std::vector<std::string>& v) {
|
bool isReal(const std::vector<std::string>& v) {
|
||||||
for (auto& s : v) {
|
for (auto& s : v) {
|
||||||
|
@ -455,10 +455,10 @@ bool CVar::isValidInput(std::string_view input) const {
|
||||||
}
|
}
|
||||||
case EType::Signed:
|
case EType::Signed:
|
||||||
std::strtol(input.data(), &p, 0);
|
std::strtol(input.data(), &p, 0);
|
||||||
return p == nullptr;
|
return p != nullptr && *p == 0;
|
||||||
case EType::Unsigned:
|
case EType::Unsigned:
|
||||||
std::strtoul(input.data(), &p, 0);
|
std::strtoul(input.data(), &p, 0);
|
||||||
return p == nullptr;
|
return p != nullptr && *p == 0;
|
||||||
case EType::Real: {
|
case EType::Real: {
|
||||||
bool size = parts.size() == 1;
|
bool size = parts.size() == 1;
|
||||||
bool ret = isReal(input);
|
bool ret = isReal(input);
|
||||||
|
|
|
@ -751,7 +751,20 @@ IMGUI_ENTITY_INSPECT(MP1::CBouncyGrenade, CPhysicsActor, BouncyGrenade, {})
|
||||||
IMGUI_ENTITY_INSPECT(CCollisionActor, CPhysicsActor, CollisionActor, {})
|
IMGUI_ENTITY_INSPECT(CCollisionActor, CPhysicsActor, CollisionActor, {})
|
||||||
IMGUI_ENTITY_INSPECT(MP1::CGrenadeLauncher, CPhysicsActor, GrenadeLauncher, {})
|
IMGUI_ENTITY_INSPECT(MP1::CGrenadeLauncher, CPhysicsActor, GrenadeLauncher, {})
|
||||||
IMGUI_ENTITY_INSPECT(MP1::CMetroidPrimeExo::CPhysicsDummy, CPhysicsActor, MetroidPrimeExoPhysicsDummy, {})
|
IMGUI_ENTITY_INSPECT(MP1::CMetroidPrimeExo::CPhysicsDummy, CPhysicsActor, MetroidPrimeExoPhysicsDummy, {})
|
||||||
IMGUI_ENTITY_INSPECT(CPlayer, CPhysicsActor, Player, {})
|
IMGUI_ENTITY_INSPECT(CPlayer, CPhysicsActor, Player, {
|
||||||
|
if (ImGui::CollapsingHeader("Player Gun")) {
|
||||||
|
auto* gun = GetPlayerGun();
|
||||||
|
ImGui::Text("Last Fire Button States: 0x%08X", gun->x2ec_lastFireButtonStates);
|
||||||
|
ImGui::Text("Pressed Fire Button States: 0x%08X", gun->x2f0_pressedFireButtonStates);
|
||||||
|
ImGui::Text("Fire Button States: 0x%08X", gun->x2f4_fireButtonStates);
|
||||||
|
ImGui::Text("State Flags: 0x%08X", gun->x2f8_stateFlags);
|
||||||
|
ImGui::Text("Fidget Anim Bits: 0x%08X", gun->x2fc_fidgetAnimBits);
|
||||||
|
ImGui::Text("Remaining Missiles: %i", gun->x300_remainingMissiles);
|
||||||
|
ImGui::Text("Bomb Count: %i", gun->x308_bombCount);
|
||||||
|
ImGui::Text("Current Beam: %s", magic_enum::enum_name(gun->x310_currentBeam).data());
|
||||||
|
ImGui::Text("Next Beam: %s", magic_enum::enum_name(gun->x314_nextBeam).data());
|
||||||
|
}
|
||||||
|
})
|
||||||
IMGUI_ENTITY_INSPECT(CScriptActor, CPhysicsActor, ScriptActor, {
|
IMGUI_ENTITY_INSPECT(CScriptActor, CPhysicsActor, ScriptActor, {
|
||||||
if (ImGui::Button("Edit Damage Vulnerability")) {
|
if (ImGui::Button("Edit Damage Vulnerability")) {
|
||||||
m_editingDamageVulnerability = true;
|
m_editingDamageVulnerability = true;
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace metaforce {
|
||||||
struct CFinalInput;
|
struct CFinalInput;
|
||||||
|
|
||||||
class CPlayerGun {
|
class CPlayerGun {
|
||||||
|
// For ImGuiEntitySupport
|
||||||
|
friend class CPlayer;
|
||||||
public:
|
public:
|
||||||
static float skTractorBeamFactor;
|
static float skTractorBeamFactor;
|
||||||
enum class EMissileMode { Inactive, Active };
|
enum class EMissileMode { Inactive, Active };
|
||||||
|
|
|
@ -36,7 +36,7 @@ if (DAWN_ENABLE_D3D12)
|
||||||
target_sources(aurora PRIVATE lib/dawn/D3D12Binding.cpp)
|
target_sources(aurora PRIVATE lib/dawn/D3D12Binding.cpp)
|
||||||
endif ()
|
endif ()
|
||||||
if (DAWN_ENABLE_DESKTOP_GL)
|
if (DAWN_ENABLE_DESKTOP_GL)
|
||||||
target_compile_definitions(aurora PRIVATE DAWN_ENABLE_BACKEND_OPENGL DAWN_ENABLE_BACKEND_DESKTOP_GL)
|
target_compile_definitions(aurora PRIVATE DAWN_ENABLE_BACKEND_OPENGL DAWN_ENABLE_BACKEND_DESKTOP_GL DAWN_ENABLE_BACKEND_OPENGLES)
|
||||||
target_sources(aurora PRIVATE lib/dawn/OpenGLBinding.cpp)
|
target_sources(aurora PRIVATE lib/dawn/OpenGLBinding.cpp)
|
||||||
endif ()
|
endif ()
|
||||||
if (DAWN_ENABLE_NULL)
|
if (DAWN_ENABLE_NULL)
|
||||||
|
|
|
@ -191,17 +191,17 @@ enum class MouseButton {
|
||||||
ENABLE_BITWISE_ENUM(MouseButton);
|
ENABLE_BITWISE_ENUM(MouseButton);
|
||||||
|
|
||||||
enum class Backend : uint8_t {
|
enum class Backend : uint8_t {
|
||||||
Invalid,
|
Null,
|
||||||
Vulkan,
|
WebGPU,
|
||||||
Metal,
|
|
||||||
D3D12,
|
|
||||||
D3D11,
|
D3D11,
|
||||||
|
D3D12,
|
||||||
|
Metal,
|
||||||
|
Vulkan,
|
||||||
OpenGL,
|
OpenGL,
|
||||||
OpenGLES,
|
OpenGLES,
|
||||||
WebGPU,
|
Invalid = 0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct App;
|
|
||||||
struct AppDelegate {
|
struct AppDelegate {
|
||||||
AppDelegate() = default;
|
AppDelegate() = default;
|
||||||
virtual ~AppDelegate() noexcept = default;
|
virtual ~AppDelegate() noexcept = default;
|
||||||
|
@ -242,12 +242,14 @@ struct AppDelegate {
|
||||||
virtual void onControllerAxis(uint32_t which, ControllerAxis axis, int16_t value) noexcept = 0;
|
virtual void onControllerAxis(uint32_t which, ControllerAxis axis, int16_t value) noexcept = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv, std::string_view configPath) noexcept;
|
void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv, std::string_view configPath,
|
||||||
|
Backend desiredBackend = Backend::Invalid, uint32_t msaa = 1, uint16_t aniso = 16) noexcept;
|
||||||
[[nodiscard]] std::vector<std::string> get_args() noexcept;
|
[[nodiscard]] std::vector<std::string> get_args() noexcept;
|
||||||
[[nodiscard]] WindowSize get_window_size() noexcept;
|
[[nodiscard]] WindowSize get_window_size() noexcept;
|
||||||
void set_window_title(zstring_view title) noexcept;
|
void set_window_title(zstring_view title) noexcept;
|
||||||
[[nodiscard]] Backend get_backend() noexcept;
|
[[nodiscard]] Backend get_backend() noexcept;
|
||||||
[[nodiscard]] std::string_view get_backend_string() noexcept;
|
[[nodiscard]] std::string_view get_backend_string() noexcept;
|
||||||
|
[[nodiscard]] Backend translate_backend(std::string_view name);
|
||||||
void set_fullscreen(bool fullscreen) noexcept;
|
void set_fullscreen(bool fullscreen) noexcept;
|
||||||
[[nodiscard]] uint32_t get_which_controller_for_player(int32_t index) noexcept;
|
[[nodiscard]] uint32_t get_which_controller_for_player(int32_t index) noexcept;
|
||||||
[[nodiscard]] int32_t get_controller_player_index(uint32_t which) noexcept;
|
[[nodiscard]] int32_t get_controller_player_index(uint32_t which) noexcept;
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include <aurora/aurora.hpp>
|
#include <aurora/aurora.hpp>
|
||||||
|
|
||||||
#include "gfx/common.hpp"
|
#include "gfx/common.hpp"
|
||||||
#include "gfx/gx.hpp"
|
#include "gfx/gx.hpp"
|
||||||
#include "gpu.hpp"
|
#include "gpu.hpp"
|
||||||
#include "input.hpp"
|
#include "input.hpp"
|
||||||
#include "imgui.hpp"
|
#include "imgui.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <logvisor/logvisor.hpp>
|
#include <logvisor/logvisor.hpp>
|
||||||
|
@ -253,7 +255,29 @@ static SDL_Window* create_window(wgpu::BackendType type) {
|
||||||
return SDL_CreateWindow("Metaforce", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 960, flags);
|
return SDL_CreateWindow("Metaforce", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 960, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv, std::string_view configPath) noexcept {
|
wgpu::BackendType to_wgpu_backend(Backend backend) {
|
||||||
|
switch (backend) {
|
||||||
|
case Backend::WebGPU:
|
||||||
|
return wgpu::BackendType::WebGPU;
|
||||||
|
case Backend::D3D11:
|
||||||
|
return wgpu::BackendType::D3D11;
|
||||||
|
case Backend::D3D12:
|
||||||
|
return wgpu::BackendType::D3D12;
|
||||||
|
case Backend::Metal:
|
||||||
|
return wgpu::BackendType::Metal;
|
||||||
|
case Backend::Vulkan:
|
||||||
|
return wgpu::BackendType::Vulkan;
|
||||||
|
case Backend::OpenGL:
|
||||||
|
return wgpu::BackendType::OpenGL;
|
||||||
|
case Backend::OpenGLES:
|
||||||
|
return wgpu::BackendType::OpenGLES;
|
||||||
|
default:
|
||||||
|
case Backend::Null:
|
||||||
|
return wgpu::BackendType::Null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv, std::string_view configPath,
|
||||||
|
Backend desiredBackend, uint32_t msaa, uint16_t aniso) noexcept {
|
||||||
g_AppDelegate = std::move(app);
|
g_AppDelegate = std::move(app);
|
||||||
/* Lets gather arguments skipping the program filename */
|
/* Lets gather arguments skipping the program filename */
|
||||||
for (size_t i = 1; i < argc; ++i) {
|
for (size_t i = 1; i < argc; ++i) {
|
||||||
|
@ -280,18 +304,31 @@ void app_run(std::unique_ptr<AppDelegate> app, Icon icon, int argc, char** argv,
|
||||||
/* TODO: Make this an option rather than hard coding it */
|
/* TODO: Make this an option rather than hard coding it */
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
|
||||||
|
/* Attempt to create a window using the calling application's desired backend */
|
||||||
|
if (desiredBackend != Backend::Invalid) {
|
||||||
|
auto wgpuBackend = to_wgpu_backend(desiredBackend);
|
||||||
|
g_window = create_window(wgpuBackend);
|
||||||
|
if (g_window != nullptr && !gpu::initialize(g_window, wgpuBackend, msaa, aniso)) {
|
||||||
|
g_window = nullptr;
|
||||||
|
SDL_DestroyWindow(g_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_window == nullptr) {
|
||||||
for (const auto backendType : gpu::PreferredBackendOrder) {
|
for (const auto backendType : gpu::PreferredBackendOrder) {
|
||||||
auto* window = create_window(backendType);
|
auto* window = create_window(backendType);
|
||||||
if (window == nullptr) {
|
if (window == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
g_window = window;
|
g_window = window;
|
||||||
if (gpu::initialize(window, backendType)) {
|
if (gpu::initialize(window, backendType, msaa, aniso)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_window = nullptr;
|
g_window = nullptr;
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (g_window == nullptr) {
|
if (g_window == nullptr) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Error creating window: {}"), SDL_GetError());
|
Log.report(logvisor::Fatal, FMT_STRING("Error creating window: {}"), SDL_GetError());
|
||||||
unreachable();
|
unreachable();
|
||||||
|
@ -438,6 +475,55 @@ Backend get_backend() noexcept {
|
||||||
|
|
||||||
std::string_view get_backend_string() noexcept { return magic_enum::enum_name(gpu::g_backendType); }
|
std::string_view get_backend_string() noexcept { return magic_enum::enum_name(gpu::g_backendType); }
|
||||||
|
|
||||||
|
Backend translate_backend(std::string_view backend) {
|
||||||
|
if (backend.empty()) {
|
||||||
|
return Backend::Invalid;
|
||||||
|
}
|
||||||
|
std::string tmp = backend.data();
|
||||||
|
std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](unsigned char c) { return std::tolower(c); });
|
||||||
|
#if DAWN_ENABLE_BACKEND_WEBGPU
|
||||||
|
if (tmp == "webgpu" || tmp == "wgpu") {
|
||||||
|
return Backend::WebGPU;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_D3D11
|
||||||
|
if (tmp == "d3d11") {
|
||||||
|
return Backend::D3D11;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_D3D12
|
||||||
|
if (tmp == "d3d12") {
|
||||||
|
return Backend::D3D12;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_METAL
|
||||||
|
if (tmp == "metal") {
|
||||||
|
return Backend::Metal;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_DESKTOP_GL || DAWN_ENABLE_BACKEND_OPENGL
|
||||||
|
if (tmp == "gl" || tmp == "opengl") {
|
||||||
|
return Backend::OpenGL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_OPENGLES
|
||||||
|
if (tmp == "gles" || tmp == "opengles") {
|
||||||
|
return Backend::OpenGLES;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_VULKAN
|
||||||
|
if (tmp == "vulkan") {
|
||||||
|
return Backend::Vulkan;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if DAWN_ENABLE_BACKEND_NULL
|
||||||
|
if (tmp == "null") {
|
||||||
|
return Backend::Null;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Backend::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
void set_fullscreen(bool fullscreen) noexcept {
|
void set_fullscreen(bool fullscreen) noexcept {
|
||||||
SDL_SetWindowFullscreen(g_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
SDL_SetWindowFullscreen(g_window, fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,8 @@ static void pipeline_worker() {
|
||||||
|
|
||||||
void initialize() {
|
void initialize() {
|
||||||
// No async pipelines for OpenGL (ES)
|
// No async pipelines for OpenGL (ES)
|
||||||
if (gpu::g_backendType != wgpu::BackendType::OpenGL && gpu::g_backendType != wgpu::BackendType::OpenGLES) {
|
if (gpu::g_backendType != wgpu::BackendType::OpenGL && gpu::g_backendType != wgpu::BackendType::OpenGLES &&
|
||||||
|
gpu::g_backendType != wgpu::BackendType::Vulkan) {
|
||||||
g_pipelineThread = std::thread(pipeline_worker);
|
g_pipelineThread = std::thread(pipeline_worker);
|
||||||
g_hasPipelineThread = true;
|
g_hasPipelineThread = true;
|
||||||
}
|
}
|
||||||
|
@ -758,9 +759,7 @@ const wgpu::Sampler& sampler_ref(const wgpu::SamplerDescriptor& descriptor) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t align_uniform(uint32_t value) {
|
uint32_t align_uniform(uint32_t value) { return ALIGN(value, g_cachedLimits.limits.minUniformBufferOffsetAlignment); }
|
||||||
return ALIGN(value, g_cachedLimits.limits.minUniformBufferOffsetAlignment);
|
|
||||||
}
|
|
||||||
|
|
||||||
void push_debug_group(zstring_view label) noexcept {
|
void push_debug_group(zstring_view label) noexcept {
|
||||||
#ifdef AURORA_GFX_DEBUG_GROUPS
|
#ifdef AURORA_GFX_DEBUG_GROUPS
|
||||||
|
|
|
@ -240,7 +240,7 @@ static void device_callback(WGPURequestDeviceStatus status, WGPUDevice device, c
|
||||||
*static_cast<bool*>(userdata) = true;
|
*static_cast<bool*>(userdata) = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initialize(SDL_Window* window, wgpu::BackendType backendType) {
|
bool initialize(SDL_Window* window, wgpu::BackendType backendType, uint32_t msaa, uint16_t aniso) {
|
||||||
if (!g_Instance) {
|
if (!g_Instance) {
|
||||||
Log.report(logvisor::Info, FMT_STRING("Creating Dawn instance"));
|
Log.report(logvisor::Info, FMT_STRING("Creating Dawn instance"));
|
||||||
g_Instance = std::make_unique<dawn::native::Instance>();
|
g_Instance = std::make_unique<dawn::native::Instance>();
|
||||||
|
@ -343,6 +343,7 @@ bool initialize(SDL_Window* window, wgpu::BackendType backendType) {
|
||||||
}
|
}
|
||||||
g_device.SetUncapturedErrorCallback(&error_callback, nullptr);
|
g_device.SetUncapturedErrorCallback(&error_callback, nullptr);
|
||||||
}
|
}
|
||||||
|
g_device.SetDeviceLostCallback(nullptr, nullptr);
|
||||||
g_queue = g_device.GetQueue();
|
g_queue = g_device.GetQueue();
|
||||||
|
|
||||||
g_BackendBinding =
|
g_BackendBinding =
|
||||||
|
@ -372,8 +373,8 @@ bool initialize(SDL_Window* window, wgpu::BackendType backendType) {
|
||||||
.height = size.fb_height,
|
.height = size.fb_height,
|
||||||
.colorFormat = swapChainFormat,
|
.colorFormat = swapChainFormat,
|
||||||
.depthFormat = wgpu::TextureFormat::Depth32Float,
|
.depthFormat = wgpu::TextureFormat::Depth32Float,
|
||||||
.msaaSamples = 1,
|
.msaaSamples = msaa,
|
||||||
.textureAnisotropy = 16,
|
.textureAnisotropy = aniso,
|
||||||
};
|
};
|
||||||
create_copy_pipeline();
|
create_copy_pipeline();
|
||||||
resize_swapchain(size.fb_width, size.fb_height);
|
resize_swapchain(size.fb_width, size.fb_height);
|
||||||
|
|
|
@ -63,7 +63,7 @@ extern TextureWithSampler g_depthBuffer;
|
||||||
extern wgpu::RenderPipeline g_CopyPipeline;
|
extern wgpu::RenderPipeline g_CopyPipeline;
|
||||||
extern wgpu::BindGroup g_CopyBindGroup;
|
extern wgpu::BindGroup g_CopyBindGroup;
|
||||||
|
|
||||||
bool initialize(SDL_Window* window, wgpu::BackendType backendType);
|
bool initialize(SDL_Window* window, wgpu::BackendType backendType, uint32_t msaa, uint16_t aniso);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void resize_swapchain(uint32_t width, uint32_t height);
|
void resize_swapchain(uint32_t width, uint32_t height);
|
||||||
TextureWithSampler create_render_texture(bool multisampled);
|
TextureWithSampler create_render_texture(bool multisampled);
|
||||||
|
|
Loading…
Reference in New Issue