mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 15:11:22 +00:00
Restore graphics backend switching
This commit is contained in:
parent
d1bcc1d8b5
commit
5b6744e188
@ -186,33 +186,8 @@ public:
|
|||||||
void onAppLaunched(const AuroraInfo& info) noexcept {
|
void onAppLaunched(const AuroraInfo& info) noexcept {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
std::string_view backend;
|
VISetWindowTitle(
|
||||||
switch (info.backend) {
|
fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend_name(info.backend)).c_str());
|
||||||
case BACKEND_D3D12:
|
|
||||||
backend = "D3D12"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_METAL:
|
|
||||||
backend = "Metal"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_VULKAN:
|
|
||||||
backend = "Vulkan"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_OPENGL:
|
|
||||||
backend = "OpenGL"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_OPENGLES:
|
|
||||||
backend = "OpenGL ES"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_WEBGPU:
|
|
||||||
backend = "WebGPU"sv;
|
|
||||||
break;
|
|
||||||
case BACKEND_NULL:
|
|
||||||
backend = "Null"sv;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
VISetWindowTitle(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend).c_str());
|
|
||||||
|
|
||||||
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
|
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
|
||||||
m_voiceEngine->setVolume(0.7f);
|
m_voiceEngine->setVolume(0.7f);
|
||||||
@ -449,8 +424,6 @@ static bool IsClientLoggingEnabled(int argc, char** argv) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupLogging() {}
|
|
||||||
|
|
||||||
static std::unique_ptr<metaforce::Application> g_app;
|
static std::unique_ptr<metaforce::Application> g_app;
|
||||||
static SDL_Window* g_window;
|
static SDL_Window* g_window;
|
||||||
static bool g_paused;
|
static bool g_paused;
|
||||||
@ -539,7 +512,7 @@ int main(int argc, char** argv) {
|
|||||||
const AuroraConfig config{
|
const AuroraConfig config{
|
||||||
.appName = "Metaforce",
|
.appName = "Metaforce",
|
||||||
.configPath = configPath.c_str(),
|
.configPath = configPath.c_str(),
|
||||||
// .desiredBackend = TODO
|
.desiredBackend = metaforce::backend_from_string(cvarCmns.getGraphicsApi()),
|
||||||
.msaa = cvarCmns.getSamples(),
|
.msaa = cvarCmns.getSamples(),
|
||||||
.maxTextureAnisotropy = static_cast<uint16_t>(cvarCmns.getAnisotropy()),
|
.maxTextureAnisotropy = static_cast<uint16_t>(cvarCmns.getAnisotropy()),
|
||||||
.startFullscreen = cvarCmns.getFullscreen(),
|
.startFullscreen = cvarCmns.getFullscreen(),
|
||||||
@ -554,7 +527,7 @@ int main(int argc, char** argv) {
|
|||||||
g_app->onImGuiAddTextures();
|
g_app->onImGuiAddTextures();
|
||||||
g_app->onAppLaunched(info);
|
g_app->onAppLaunched(info);
|
||||||
g_app->onAppWindowResized(info.windowSize);
|
g_app->onAppWindowResized(info.windowSize);
|
||||||
while (true) {
|
while (!cvarMgr.restartRequired()) {
|
||||||
const auto* event = aurora_update();
|
const auto* event = aurora_update();
|
||||||
bool exiting = false;
|
bool exiting = false;
|
||||||
while (event != nullptr && event->type != AURORA_NONE) {
|
while (event != nullptr && event->type != AURORA_NONE) {
|
||||||
|
@ -1892,28 +1892,27 @@ void ImGuiConsole::ShowPreLaunchSettingsWindow() {
|
|||||||
if (ImGui::Begin("Settings", &m_showPreLaunchSettingsWindow, ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::Begin("Settings", &m_showPreLaunchSettingsWindow, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
if (ImGui::BeginTabBar("Settings")) {
|
if (ImGui::BeginTabBar("Settings")) {
|
||||||
if (ImGui::BeginTabItem("Graphics")) {
|
if (ImGui::BeginTabItem("Graphics")) {
|
||||||
// TODO
|
size_t backendCount = 0;
|
||||||
// static auto AvailableBackends = aurora::get_available_backends();
|
const auto* backends = aurora_get_available_backends(&backendCount);
|
||||||
// ImGuiStringViewText(fmt::format(FMT_STRING("Current backend: {}"), aurora::get_backend_string()));
|
ImGuiStringViewText(fmt::format(FMT_STRING("Current backend: {}"), backend_name(aurora_get_backend())));
|
||||||
// auto desiredBackend = static_cast<int>(aurora::Backend::Invalid);
|
auto desiredBackend = static_cast<int>(BACKEND_AUTO);
|
||||||
// if (auto* cvar = m_cvarMgr.findCVar("graphicsApi")) {
|
if (auto* cvar = m_cvarMgr.findCVar("graphicsApi")) {
|
||||||
// bool valid = false;
|
bool valid = false;
|
||||||
// const auto name = cvar->toLiteral(&valid);
|
const auto name = cvar->toLiteral(&valid);
|
||||||
// if (valid) {
|
if (valid) {
|
||||||
// desiredBackend = static_cast<int>(aurora::backend_from_string(name));
|
desiredBackend = static_cast<int>(backend_from_string(name));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// bool modified = false;
|
bool modified = false;
|
||||||
// modified = ImGui::RadioButton("Auto", &desiredBackend, static_cast<int>(aurora::Backend::Invalid));
|
modified = ImGui::RadioButton("Auto", &desiredBackend, static_cast<int>(BACKEND_AUTO));
|
||||||
// for (const auto& item : AvailableBackends) {
|
for (size_t i = 0; i < backendCount; ++i, ++backends) {
|
||||||
// modified = ImGui::RadioButton(magic_enum::enum_name(item).data(), &desiredBackend,
|
const auto backend = *backends;
|
||||||
// static_cast<int>(item)) ||
|
modified =
|
||||||
// modified;
|
ImGui::RadioButton(backend_name(backend).data(), &desiredBackend, static_cast<int>(backend)) || modified;
|
||||||
// }
|
}
|
||||||
// if (modified) {
|
if (modified) {
|
||||||
// m_cvarCommons.m_graphicsApi->fromLiteral(
|
m_cvarCommons.m_graphicsApi->fromLiteral(backend_to_string(static_cast<AuroraBackend>(desiredBackend)));
|
||||||
// aurora::backend_to_string(static_cast<aurora::Backend>(desiredBackend)));
|
}
|
||||||
// }
|
|
||||||
ImGuiCVarCheckbox(m_cvarMgr, "fullscreen", "Fullscreen");
|
ImGuiCVarCheckbox(m_cvarMgr, "fullscreen", "Fullscreen");
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
@ -1934,4 +1933,78 @@ void ImGuiConsole::ShowPreLaunchSettingsWindow() {
|
|||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool eq(std::string_view a, std::string_view b) {
|
||||||
|
if (a.size() != b.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == b; });
|
||||||
|
}
|
||||||
|
|
||||||
|
AuroraBackend backend_from_string(const std::string& str) {
|
||||||
|
if (eq(str, "d3d12"sv) || eq(str, "d3d"sv)) {
|
||||||
|
return BACKEND_D3D12;
|
||||||
|
}
|
||||||
|
if (eq(str, "metal"sv)) {
|
||||||
|
return BACKEND_METAL;
|
||||||
|
}
|
||||||
|
if (eq(str, "vulkan"sv) || eq(str, "vk"sv)) {
|
||||||
|
return BACKEND_VULKAN;
|
||||||
|
}
|
||||||
|
if (eq(str, "opengl"sv) || eq(str, "gl"sv)) {
|
||||||
|
return BACKEND_OPENGL;
|
||||||
|
}
|
||||||
|
if (eq(str, "opengles"sv) || eq(str, "gles"sv)) {
|
||||||
|
return BACKEND_OPENGLES;
|
||||||
|
}
|
||||||
|
if (eq(str, "webgpu"sv) || eq(str, "wgpu"sv)) {
|
||||||
|
return BACKEND_WEBGPU;
|
||||||
|
}
|
||||||
|
if (eq(str, "null"sv) || eq(str, "none"sv)) {
|
||||||
|
return BACKEND_NULL;
|
||||||
|
}
|
||||||
|
return BACKEND_AUTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view backend_to_string(AuroraBackend backend) {
|
||||||
|
switch (backend) {
|
||||||
|
default:
|
||||||
|
return "auto"sv;
|
||||||
|
case BACKEND_D3D12:
|
||||||
|
return "d3d12"sv;
|
||||||
|
case BACKEND_METAL:
|
||||||
|
return "metal"sv;
|
||||||
|
case BACKEND_VULKAN:
|
||||||
|
return "vulkan"sv;
|
||||||
|
case BACKEND_OPENGL:
|
||||||
|
return "opengl"sv;
|
||||||
|
case BACKEND_OPENGLES:
|
||||||
|
return "opengles"sv;
|
||||||
|
case BACKEND_WEBGPU:
|
||||||
|
return "webgpu"sv;
|
||||||
|
case BACKEND_NULL:
|
||||||
|
return "null"sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string_view backend_name(AuroraBackend backend) {
|
||||||
|
switch (backend) {
|
||||||
|
default:
|
||||||
|
return "Auto"sv;
|
||||||
|
case BACKEND_D3D12:
|
||||||
|
return "D3D12"sv;
|
||||||
|
case BACKEND_METAL:
|
||||||
|
return "Metal"sv;
|
||||||
|
case BACKEND_VULKAN:
|
||||||
|
return "Vulkan"sv;
|
||||||
|
case BACKEND_OPENGL:
|
||||||
|
return "OpenGL"sv;
|
||||||
|
case BACKEND_OPENGLES:
|
||||||
|
return "OpenGL ES"sv;
|
||||||
|
case BACKEND_WEBGPU:
|
||||||
|
return "WebGPU"sv;
|
||||||
|
case BACKEND_NULL:
|
||||||
|
return "Null"sv;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
@ -159,4 +159,8 @@ private:
|
|||||||
void ShowPipelineProgress();
|
void ShowPipelineProgress();
|
||||||
void ShowPreLaunchSettingsWindow();
|
void ShowPreLaunchSettingsWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AuroraBackend backend_from_string(const std::string& str);
|
||||||
|
std::string_view backend_to_string(AuroraBackend backend);
|
||||||
|
std::string_view backend_name(AuroraBackend backend);
|
||||||
} // namespace metaforce
|
} // namespace metaforce
|
||||||
|
Loading…
x
Reference in New Issue
Block a user