From 5bd1a492bed67052277dde495817b3b30040b56f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 16 Feb 2025 18:47:53 +1000 Subject: [PATCH] GameDatabase: Turn PGXPPreserveProjFP into a boolean setting --- data/resources/gamedb.yaml | 28 ++++++++--------- src/core/game_database.cpp | 31 ++++++++++++------- src/core/game_database.h | 2 +- src/duckstation-qt/graphicssettingswidget.cpp | 8 +++-- src/duckstation-qt/settingswindow.h | 2 ++ 5 files changed, 41 insertions(+), 30 deletions(-) diff --git a/data/resources/gamedb.yaml b/data/resources/gamedb.yaml index 9e9507ce7..63fc557e7 100644 --- a/data/resources/gamedb.yaml +++ b/data/resources/gamedb.yaml @@ -21455,8 +21455,8 @@ SCES-02105: - DigitalController - NeGcon - JogCon - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. libcrypt: true metadata: publisher: "Sony" @@ -21487,8 +21487,8 @@ SCUS-94426: - DigitalController - NeGcon - JogCon - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. metadata: publisher: "Sony" developer: "Naughty Dog" @@ -21507,8 +21507,8 @@ SCUS-94459: name: "CTR - Crash Team Racing (USA) (Demo)" metadata: genre: "** DEMO **" - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. SLUS-01391: name: "Cabela's Big Game Hunter - Ultimate Challenge (USA)" controllers: @@ -30751,8 +30751,8 @@ SCPS-45470: - AnalogController - DigitalController - NeGcon - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. metadata: publisher: "Sony" developer: "Naughty Dog" @@ -30773,8 +30773,8 @@ SCPS-10118: - AnalogController - DigitalController - NeGcon - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. codes: - SCPS-10118 - SCPS-91328 @@ -30796,16 +30796,16 @@ PCPX-96183: name: "Crash Bandicoot Racing (Japan) (Demo)" metadata: genre: "** DEMO **" - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. SCPS-91230: name: "Crash Bandicoot Racing [Playstation the Best for Family]" controllers: - AnalogController - DigitalController - NeGcon - traits: - - DisablePGXPPreserveProjFP + settings: + gpuPGXPPreserveProjFP: false # Causes holes in geometry. metadata: publisher: "Sony" developer: "Naughty Dog" diff --git a/src/core/game_database.cpp b/src/core/game_database.cpp index 75583d54d..9fd1e7f81 100644 --- a/src/core/game_database.cpp +++ b/src/core/game_database.cpp @@ -40,7 +40,7 @@ namespace GameDatabase { enum : u32 { GAME_DATABASE_CACHE_SIGNATURE = 0x45434C48, - GAME_DATABASE_CACHE_VERSION = 20, + GAME_DATABASE_CACHE_VERSION = 21, }; static const Entry* GetEntryForId(std::string_view code); @@ -95,7 +95,6 @@ static constexpr const std::array(Trait::MaxCou "DisablePGXPTextureCorrection", "DisablePGXPColorCorrection", "DisablePGXPDepthBuffer", - "DisablePGXPPreserveProjFP", "DisablePGXPOn2DPolygons", "ForcePGXPVertexCache", "ForcePGXPCPUMode", @@ -125,7 +124,6 @@ static constexpr const std::array(Trait::MaxCou TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Texture Correction", "GameDatabase::Trait"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Color Correction", "GameDatabase::Trait"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Depth Buffer", "GameDatabase::Trait"), - TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Preserve Projection Floating Point", "GameDatabase::Trait"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP on 2D Polygons", "GameDatabase::Trait"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force PGXP Vertex Cache", "GameDatabase::Trait"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force PGXP CPU Mode", "GameDatabase::Trait"), @@ -616,14 +614,6 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes settings.gpu_pgxp_color_correction = false; } - if (HasTrait(Trait::DisablePGXPPreserveProjFP)) - { - if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_preserve_proj_fp) - APPEND_MESSAGE(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) @@ -682,6 +672,20 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes g_settings.gpu_pgxp_disable_2d = true; } + if (gpu_pgxp_preserve_proj_fp.has_value()) + { + if (display_osd_messages) + { + INFO_LOG("GameDB: GPU preserve projection precision set to {}.", + gpu_pgxp_preserve_proj_fp.value() ? "true" : "false"); + + if (settings.gpu_pgxp_enable && settings.gpu_pgxp_preserve_proj_fp && !gpu_pgxp_preserve_proj_fp.value()) + APPEND_MESSAGE(TRANSLATE_SV("GameDatabase", "PGXP preserve projection precision disabled.")); + } + + settings.gpu_pgxp_preserve_proj_fp = gpu_pgxp_preserve_proj_fp.value(); + } + if (HasTrait(Trait::ForceRecompilerICache)) { WARNING_LOG("ICache for recompiler forced by compatibility settings."); @@ -955,7 +959,8 @@ bool GameDatabase::LoadFromCache() !reader.ReadOptionalT(&entry.display_deinterlacing_mode) || !reader.ReadOptionalT(&entry.dma_max_slice_ticks) || !reader.ReadOptionalT(&entry.dma_halt_ticks) || !reader.ReadOptionalT(&entry.gpu_fifo_size) || !reader.ReadOptionalT(&entry.gpu_max_run_ahead) || !reader.ReadOptionalT(&entry.gpu_pgxp_tolerance) || - !reader.ReadOptionalT(&entry.gpu_pgxp_depth_threshold) || !reader.ReadOptionalT(&entry.gpu_line_detect_mode) || + !reader.ReadOptionalT(&entry.gpu_pgxp_depth_threshold) || + !reader.ReadOptionalT(&entry.gpu_pgxp_preserve_proj_fp) || !reader.ReadOptionalT(&entry.gpu_line_detect_mode) || !reader.ReadSizePrefixedString(&entry.disc_set_name) || !reader.ReadU32(&num_disc_set_serials)) { DEV_LOG("Cache entry is corrupted."); @@ -1074,6 +1079,7 @@ bool GameDatabase::SaveToCache() writer.WriteOptionalT(entry.gpu_max_run_ahead); writer.WriteOptionalT(entry.gpu_pgxp_tolerance); writer.WriteOptionalT(entry.gpu_pgxp_depth_threshold); + writer.WriteOptionalT(entry.gpu_pgxp_preserve_proj_fp); writer.WriteOptionalT(entry.gpu_line_detect_mode); writer.WriteSizePrefixedString(entry.disc_set_name); @@ -1335,6 +1341,7 @@ bool GameDatabase::ParseYamlEntry(Entry* entry, const ryml::ConstNodeRef& value) entry->gpu_max_run_ahead = GetOptionalTFromObject(settings, "gpuMaxRunAhead"); entry->gpu_pgxp_tolerance = GetOptionalTFromObject(settings, "gpuPGXPTolerance"); entry->gpu_pgxp_depth_threshold = GetOptionalTFromObject(settings, "gpuPGXPDepthThreshold"); + entry->gpu_pgxp_preserve_proj_fp = GetOptionalTFromObject(settings, "gpuPGXPPreserveProjFP"); entry->gpu_line_detect_mode = ParseOptionalTFromObject(settings, "gpuLineDetectMode", &Settings::ParseLineDetectModeName); } diff --git a/src/core/game_database.h b/src/core/game_database.h index 604cdd2e2..57b2e92e9 100644 --- a/src/core/game_database.h +++ b/src/core/game_database.h @@ -53,7 +53,6 @@ enum class Trait : u32 DisablePGXPTextureCorrection, DisablePGXPColorCorrection, DisablePGXPDepthBuffer, - DisablePGXPPreserveProjFP, DisablePGXPOn2DPolygons, ForcePGXPVertexCache, ForcePGXPCPUMode, @@ -125,6 +124,7 @@ struct Entry std::optional gpu_max_run_ahead; std::optional gpu_pgxp_tolerance; std::optional gpu_pgxp_depth_threshold; + std::optional gpu_pgxp_preserve_proj_fp; std::string disc_set_name; std::vector disc_set_serials; diff --git a/src/duckstation-qt/graphicssettingswidget.cpp b/src/duckstation-qt/graphicssettingswidget.cpp index f6f5811f8..6e7ba33bb 100644 --- a/src/duckstation-qt/graphicssettingswidget.cpp +++ b/src/duckstation-qt/graphicssettingswidget.cpp @@ -184,7 +184,8 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* SettingWidgetBinder::SetAvailability(m_ui.pgxpCulling, !m_dialog->hasGameTrait(GameDatabase::Trait::DisablePGXPCulling)); SettingWidgetBinder::SetAvailability(m_ui.pgxpPreserveProjPrecision, - !m_dialog->hasGameTrait(GameDatabase::Trait::DisablePGXPPreserveProjFP)); + !m_dialog->hasDatabaseEntry() || + m_dialog->getDatabaseEntry()->gpu_pgxp_preserve_proj_fp.value_or(true)); // OSD Tab @@ -1024,8 +1025,9 @@ void GraphicsSettingsWidget::updatePGXPSettingsEnabled() m_ui.pgxpColorCorrection->setEnabled(tc_enabled && !m_dialog->hasGameTrait(GameDatabase::Trait::DisablePGXPColorCorrection)); m_ui.pgxpDepthBuffer->setEnabled(enabled && !m_dialog->hasGameTrait(GameDatabase::Trait::DisablePGXPDepthBuffer)); - m_ui.pgxpPreserveProjPrecision->setEnabled(enabled && - !m_dialog->hasGameTrait(GameDatabase::Trait::DisablePGXPPreserveProjFP)); + m_ui.pgxpPreserveProjPrecision->setEnabled( + enabled && + (!m_dialog->hasDatabaseEntry() || m_dialog->getDatabaseEntry()->gpu_pgxp_preserve_proj_fp.value_or(true))); m_ui.pgxpCPU->setEnabled(enabled); m_ui.pgxpVertexCache->setEnabled(enabled); m_ui.pgxpGeometryTolerance->setEnabled(enabled); diff --git a/src/duckstation-qt/settingswindow.h b/src/duckstation-qt/settingswindow.h index ae0d90982..228bac7e9 100644 --- a/src/duckstation-qt/settingswindow.h +++ b/src/duckstation-qt/settingswindow.h @@ -63,6 +63,8 @@ public: ALWAYS_INLINE const std::string& getGameTitle() const { return m_title; } ALWAYS_INLINE const std::string& getGameSerial() const { return m_serial; } ALWAYS_INLINE const std::optional& getGameHash() const { return m_hash; } + ALWAYS_INLINE const GameDatabase::Entry* getDatabaseEntry() const { return m_database_entry; } + ALWAYS_INLINE bool hasDatabaseEntry() const { return (m_database_entry != nullptr); } ALWAYS_INLINE InterfaceSettingsWidget* getInterfaceSettingsWidget() const { return m_interface_settings; } ALWAYS_INLINE BIOSSettingsWidget* getBIOSSettingsWidget() const { return m_bios_settings; }