Skip to content

Commit

Permalink
GameDatabase: Merge compatibility messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jul 22, 2024
1 parent fe55446 commit deed0c9
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 142 deletions.
146 changes: 45 additions & 101 deletions src/core/game_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ const char* GameDatabase::GetCompatibilityRatingDisplayName(CompatibilityRating

void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_messages) const
{
constexpr float osd_duration = Host::OSD_INFO_DURATION;

if (display_active_start_offset.has_value())
{
settings.display_active_start_offset = display_active_start_offset.value();
Expand Down Expand Up @@ -457,39 +455,34 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
}
}

SmallStackString<512> messages;
#define APPEND_MESSAGE(icon, msg) \
do \
{ \
messages.append("\n \u2022 "); \
messages.append(msg); \
} while (0)

if (HasTrait(Trait::ForceInterpreter))
{
if (display_osd_messages && settings.cpu_execution_mode != CPUExecutionMode::Interpreter)
{
Host::AddIconOSDMessage("gamedb_force_interpreter", ICON_FA_MICROCHIP,
TRANSLATE_STR("OSDMessage", "CPU interpreter forced by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MICROCHIP, TRANSLATE_SV("GameDatabase", "CPU recompiler disabled."));

settings.cpu_execution_mode = CPUExecutionMode::Interpreter;
}

if (HasTrait(Trait::ForceSoftwareRenderer))
{
if (display_osd_messages && settings.gpu_renderer != GPURenderer::Software)
{
Host::AddIconOSDMessage("gamedb_force_software", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "Software renderer forced by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_PAINT_ROLLER, TRANSLATE_SV("GameDatabase", "Hardware rendering disabled."));

settings.gpu_renderer = GPURenderer::Software;
}

if (HasTrait(Trait::ForceSoftwareRendererForReadbacks))
{
if (display_osd_messages && settings.gpu_renderer != GPURenderer::Software)
{
Host::AddIconOSDMessage(
"gamedb_force_software_rb", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "Using software renderer for readbacks based on compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "Software renderer readbacks enabled."));

settings.gpu_use_software_renderer_for_readbacks = true;
}
Expand All @@ -502,35 +495,23 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (HasTrait(Trait::ForceInterlacing))
{
if (display_osd_messages && settings.gpu_disable_interlacing)
{
Host::AddIconOSDMessage("gamedb_force_interlacing", ICON_FA_TV,
TRANSLATE_STR("OSDMessage", "Interlacing forced by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_TV, TRANSLATE_SV("GameDatabase", "Interlaced rendering enabled."));

settings.gpu_disable_interlacing = false;
}

if (HasTrait(Trait::DisableTrueColor))
{
if (display_osd_messages && settings.gpu_true_color)
{
Host::AddIconOSDMessage("gamedb_disable_true_color", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "True color disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "True color disabled."));

settings.gpu_true_color = false;
}

if (HasTrait(Trait::DisableUpscaling))
{
if (display_osd_messages && settings.gpu_resolution_scale > 1)
{
Host::AddIconOSDMessage("gamedb_disable_upscaling", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "Upscaling disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "Upscaling disabled."));

settings.gpu_resolution_scale = 1;
}
Expand All @@ -540,9 +521,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && (settings.gpu_texture_filter != GPUTextureFilter::Nearest ||
g_settings.gpu_sprite_texture_filter != GPUTextureFilter::Nearest))
{
Host::AddIconOSDMessage("gamedb_disable_upscaling", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "Texture filtering disabled by compatibility settings."),
osd_duration);
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "Texture filtering disabled."));
}

settings.gpu_texture_filter = GPUTextureFilter::Nearest;
Expand All @@ -552,72 +531,47 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (HasTrait(Trait::DisableScaledDithering))
{
if (display_osd_messages && settings.gpu_scaled_dithering)
{
Host::AddIconOSDMessage("gamedb_disable_scaled_dithering", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "Scaled dithering disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "Scaled dithering."));

settings.gpu_scaled_dithering = false;
}

if (HasTrait(Trait::DisableWidescreen))
{
if (display_osd_messages && settings.gpu_widescreen_hack)
{
Host::AddIconOSDMessage("gamedb_disable_widescreen", ICON_FA_TV,
TRANSLATE_STR("OSDMessage", "Widescreen rendering disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_TV, TRANSLATE_SV("GameDatabase", "Widescreen rendering disabled."));

settings.gpu_widescreen_hack = false;
}

if (HasTrait(Trait::DisableForceNTSCTimings))
{
if (display_osd_messages && settings.gpu_force_ntsc_timings)
{
Host::AddIconOSDMessage("gamedb_disable_force_ntsc_timings", ICON_FA_TV,
TRANSLATE_STR("OSDMessage", "Forcing NTSC Timings disallowed by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_TV, TRANSLATE_SV("GameDatabase", "Force NTSC timings disabled."));

settings.gpu_force_ntsc_timings = false;
}

if (HasTrait(Trait::DisablePGXP))
{
if (display_osd_messages && settings.gpu_pgxp_enable)
{
Host::AddIconOSDMessage(
"gamedb_disable_pgxp", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP geometry correction disabled by compatibility settings."), osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP geometry correction disabled."));

settings.gpu_pgxp_enable = false;
}

if (HasTrait(Trait::DisablePGXPCulling))
{
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_culling)
{
Host::AddIconOSDMessage("gamedb_disable_pgxp_culling", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP culling disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP culling correction disabled."));

settings.gpu_pgxp_culling = false;
}

if (HasTrait(Trait::DisablePGXPTextureCorrection))
{
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_texture_correction)
{
Host::AddIconOSDMessage(
"gamedb_disable_pgxp_texture", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP perspective corrected textures disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP perspective correct textures disabled."));

settings.gpu_pgxp_texture_correction = false;
}
Expand All @@ -627,10 +581,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_texture_correction &&
settings.gpu_pgxp_color_correction)
{
Host::AddIconOSDMessage(
"gamedb_disable_pgxp_texture", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP perspective corrected colors disabled by compatibility settings."),
osd_duration);
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP perspective correct colors disabled."));
}

settings.gpu_pgxp_color_correction = false;
Expand All @@ -639,45 +590,34 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (HasTrait(Trait::DisablePGXPPreserveProjFP))
{
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_preserve_proj_fp)
{
Host::AddIconOSDMessage(
"gamedb_disable_pgxp_texture", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP projection precision preservation disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP preserve projection precision disabled."));

settings.gpu_pgxp_preserve_proj_fp = false;
}

if (HasTrait(Trait::ForcePGXPVertexCache))
{
if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_vertex_cache)
{
Host::AddIconOSDMessage("gamedb_force_pgxp_vertex_cache", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP vertex cache forced by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP vertex cache enabled."));

settings.gpu_pgxp_vertex_cache = settings.gpu_pgxp_enable;
}
else if (settings.gpu_pgxp_enable && settings.gpu_pgxp_vertex_cache)
{
Host::AddIconOSDMessage(
"gamedb_force_pgxp_vertex_cache", ICON_FA_MICROCHIP,
"gamedb_force_pgxp_vertex_cache", ICON_FA_EXCLAMATION_TRIANGLE,
TRANSLATE_STR(
"OSDMessage",
"GameDatabase",
"PGXP Vertex Cache is enabled, but it is not required for this game. This may cause rendering errors."),
osd_duration);
Host::OSD_WARNING_DURATION);
}

if (HasTrait(Trait::ForcePGXPCPUMode))
{
if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_cpu)
{
#ifndef __ANDROID__
Host::AddIconOSDMessage("gamedb_force_pgxp_cpu", ICON_FA_MICROCHIP,
TRANSLATE_STR("OSDMessage", "PGXP CPU mode forced by compatibility settings."),
osd_duration);
APPEND_MESSAGE(ICON_FA_MICROCHIP, TRANSLATE_SV("GameDatabase", "PGXP CPU mode enabled."));
#else
Host::AddIconOSDMessage(
"gamedb_force_pgxp_cpu", ICON_FA_MICROCHIP,
Expand All @@ -693,31 +633,24 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddIconOSDMessage(
"gamedb_force_pgxp_cpu", ICON_FA_MICROCHIP,
TRANSLATE_STR("OSDMessage",
TRANSLATE_STR("GameDatabase",
"PGXP CPU mode is enabled, but it is not required for this game. This may cause rendering errors."),
osd_duration);
Host::OSD_WARNING_DURATION);
}

if (HasTrait(Trait::DisablePGXPDepthBuffer))
{
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_depth_buffer)
{
Host::AddIconOSDMessage("gamedb_disable_pgxp_depth", ICON_FA_MAGIC,
TRANSLATE_STR("OSDMessage", "PGXP Depth Buffer disabled by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MAGIC, TRANSLATE_SV("GameDatabase", "PGXP depth buffer disabled."));

settings.gpu_pgxp_depth_buffer = false;
}

if (HasTrait(Trait::DisablePGXPOn2DPolygons))
{
if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_disable_2d)
{
Host::AddIconOSDMessage("gamedb_disable_pgxp_2d", ICON_FA_MICROCHIP,
TRANSLATE_STR("OSDMessage", "PGXP disabled on 2D polygons by compatibility settings."),
osd_duration);
}
APPEND_MESSAGE(ICON_FA_MICROCHIP, TRANSLATE_SV("GameDatabase", "PGXP disabled on 2D polygons."));

g_settings.gpu_pgxp_disable_2d = true;
}

Expand All @@ -739,6 +672,17 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
settings.cpu_fastmem_mode = CPUFastmemMode::LUT;
}

if (!messages.empty())
{
Host::AddIconOSDMessage(
"GameDBCompatibility", ICON_FA_MICROCHIP,
fmt::format("{}{}", TRANSLATE_SV("GameDatabase", "Compatibility settings for this game have been applied:"),
messages.view()),
Host::OSD_WARNING_DURATION);
}

#undef APPEND_MESSAGE

#define BIT_FOR(ctype) (static_cast<u16>(1) << static_cast<u32>(ctype))

if (supported_controllers != 0 && supported_controllers != static_cast<u16>(-1))
Expand Down Expand Up @@ -777,7 +721,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes

Host::AddKeyedOSDMessage(
"gamedb_controller_unsupported",
fmt::format(TRANSLATE_FS("OSDMessage",
fmt::format(TRANSLATE_FS("GameDatabase",
"Controller in port {0} ({1}) is not supported for {2}.\nSupported controllers: "
"{3}\nPlease configure a supported controller from the list above."),
i + 1u, Controller::GetControllerInfo(ctype)->GetDisplayName(), System::GetGameTitle(),
Expand Down
8 changes: 4 additions & 4 deletions src/core/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool GPU::Initialize()
m_console_is_pal = System::IsPALRegion();
UpdateCRTCConfig();

if (!CompileDisplayPipelines(true, true, g_settings.gpu_24bit_chroma_smoothing))
if (!CompileDisplayPipelines(true, true, g_settings.display_24bit_chroma_smoothing))
{
Host::ReportErrorAsync("Error", "Failed to compile base GPU pipelines.");
return false;
Expand Down Expand Up @@ -130,15 +130,15 @@ void GPU::UpdateSettings(const Settings& old_settings)

if (g_settings.display_scaling != old_settings.display_scaling ||
g_settings.display_deinterlacing_mode != old_settings.display_deinterlacing_mode ||
g_settings.gpu_24bit_chroma_smoothing != old_settings.gpu_24bit_chroma_smoothing)
g_settings.display_24bit_chroma_smoothing != old_settings.display_24bit_chroma_smoothing)
{
// Toss buffers on mode change.
if (g_settings.display_deinterlacing_mode != old_settings.display_deinterlacing_mode)
DestroyDeinterlaceTextures();

if (!CompileDisplayPipelines(g_settings.display_scaling != old_settings.display_scaling,
g_settings.display_deinterlacing_mode != old_settings.display_deinterlacing_mode,
g_settings.gpu_24bit_chroma_smoothing != old_settings.gpu_24bit_chroma_smoothing))
g_settings.display_24bit_chroma_smoothing != old_settings.display_24bit_chroma_smoothing))
{
Panic("Failed to compile display pipeline on settings change.");
}
Expand Down Expand Up @@ -1886,7 +1886,7 @@ bool GPU::CompileDisplayPipelines(bool display, bool deinterlace, bool chroma_sm
m_chroma_smoothing_pipeline.reset();
g_gpu_device->RecycleTexture(std::move(m_chroma_smoothing_texture));

if (g_settings.gpu_24bit_chroma_smoothing)
if (g_settings.display_24bit_chroma_smoothing)
{
plconfig.layout = GPUPipeline::Layout::SingleTextureAndPushConstants;
plconfig.SetTargetFormats(GPUTexture::Format::RGBA8);
Expand Down
2 changes: 1 addition & 1 deletion src/core/gpu_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3527,7 +3527,7 @@ void GPU_HW::UpdateDisplay()

SetDisplayTexture(m_vram_extract_texture.get(), depth_source ? m_vram_extract_depth_texture.get() : nullptr, 0, 0,
scaled_display_width, read_height);
if (g_settings.gpu_24bit_chroma_smoothing)
if (g_settings.display_24bit_chroma_smoothing)
{
if (ApplyChromaSmoothing())
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/gpu_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void GPU_SW::UpdateDisplay()
if (CopyOut(vram_offset_x, vram_offset_y, skip_x, read_width, read_height, line_skip, is_24bit))
{
SetDisplayTexture(m_upload_texture.get(), nullptr, 0, 0, read_width, read_height);
if (is_24bit && g_settings.gpu_24bit_chroma_smoothing)
if (is_24bit && g_settings.display_24bit_chroma_smoothing)
{
if (ApplyChromaSmoothing())
Deinterlace(field, 0);
Expand All @@ -465,7 +465,7 @@ void GPU_SW::UpdateDisplay()
if (CopyOut(vram_offset_x, vram_offset_y, skip_x, read_width, read_height, 0, is_24bit))
{
SetDisplayTexture(m_upload_texture.get(), nullptr, 0, 0, read_width, read_height);
if (is_24bit && g_settings.gpu_24bit_chroma_smoothing)
if (is_24bit && g_settings.display_24bit_chroma_smoothing)
ApplyChromaSmoothing();
}
}
Expand Down
Loading

0 comments on commit deed0c9

Please sign in to comment.