Added option in graphics config file to override graphics API selection

This commit is contained in:
Mr-Wiseguy 2024-04-14 16:57:11 -04:00
parent fe8f45eaf2
commit 38f813ae04
4 changed files with 30 additions and 1 deletions

View File

@ -212,7 +212,7 @@ if (WIN32)
PROPERTIES
LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE"
LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
# LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
)

View File

@ -21,6 +21,7 @@ constexpr std::u8string_view sound_filename = u8"sound.json";
constexpr auto res_default = ultramodern::Resolution::Auto;
constexpr auto wm_default = ultramodern::WindowMode::Windowed;
constexpr auto hr_default = ultramodern::HUDRatioMode::Clamp16x9;
constexpr auto api_default = ultramodern::GraphicsApi::Auto;
constexpr auto ar_default = RT64::UserConfiguration::AspectRatio::Expand;
constexpr auto msaa_default = RT64::UserConfiguration::Antialiasing::MSAA2X;
constexpr auto rr_default = RT64::UserConfiguration::RefreshRate::Display;
@ -58,6 +59,7 @@ namespace ultramodern {
{"res_option", config.res_option},
{"wm_option", config.wm_option},
{"hr_option", config.hr_option},
{"api_option", config.api_option},
{"ds_option", config.ds_option},
{"ar_option", config.ar_option},
{"msaa_option", config.msaa_option},
@ -71,6 +73,7 @@ namespace ultramodern {
config.res_option = from_or_default(j, "res_option", res_default);
config.wm_option = from_or_default(j, "wm_option", wm_default);
config.hr_option = from_or_default(j, "hr_option", hr_default);
config.api_option = from_or_default(j, "api_option", api_default);
config.ds_option = from_or_default(j, "ds_option", ds_default);
config.ar_option = from_or_default(j, "ar_option", ar_default);
config.msaa_option = from_or_default(j, "msaa_option", msaa_default);

View File

@ -21,11 +21,18 @@ namespace ultramodern {
Full,
OptionCount
};
enum class GraphicsApi {
Auto,
D3D12,
Vulkan,
OptionCount
};
struct GraphicsConfig {
Resolution res_option;
WindowMode wm_option;
HUDRatioMode hr_option;
GraphicsApi api_option;
RT64::UserConfiguration::AspectRatio ar_option;
RT64::UserConfiguration::Antialiasing msaa_option;
RT64::UserConfiguration::RefreshRate rr_option;
@ -55,6 +62,12 @@ namespace ultramodern {
{ultramodern::HUDRatioMode::Clamp16x9, "Clamp16x9"},
{ultramodern::HUDRatioMode::Full, "Full"},
});
NLOHMANN_JSON_SERIALIZE_ENUM(ultramodern::GraphicsApi, {
{ultramodern::GraphicsApi::Auto, "Auto"},
{ultramodern::GraphicsApi::D3D12, "D3D12"},
{ultramodern::GraphicsApi::Vulkan, "Vulkan"},
});
};
#endif

View File

@ -160,6 +160,19 @@ ultramodern::RT64Context::RT64Context(uint8_t* rdram, ultramodern::WindowHandle
app->enhancementConfig.f3dex.forceBranch = true;
// Scale LODs based on the output resolution.
app->enhancementConfig.textureLOD.scale = true;
// Pick an API if the user has set an override.
switch (cur_config.api_option) {
case ultramodern::GraphicsApi::D3D12:
app->userConfig.graphicsAPI = RT64::UserConfiguration::GraphicsAPI::D3D12;
break;
case ultramodern::GraphicsApi::Vulkan:
app->userConfig.graphicsAPI = RT64::UserConfiguration::GraphicsAPI::Vulkan;
break;
default:
case ultramodern::GraphicsApi::Auto:
// Don't override if auto is selected.
break;
}
// Set up the RT64 application.
if (!app->setup(window_handle.thread_id)) {