From 9c8338ec4cf6f76b123d95adbbfb48bd468ee7df Mon Sep 17 00:00:00 2001 From: iwubcode Date: Mon, 4 May 2020 23:07:06 -0500 Subject: [PATCH] DolphinQt / VideoCommon: Add additional texture dumping options. Specifically, this enables users to choose whether to dump mip maps, base level textures, or both. --- Source/Core/Core/Config/GraphicsSettings.cpp | 2 + Source/Core/Core/Config/GraphicsSettings.h | 2 + .../Config/Graphics/AdvancedWidget.cpp | 42 ++++++++++++++++--- .../Config/Graphics/AdvancedWidget.h | 6 ++- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 ++++ Source/Core/VideoCommon/VideoConfig.cpp | 2 + Source/Core/VideoCommon/VideoConfig.h | 2 + 7 files changed, 56 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index f8755042d7..d6f1f633dd 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -35,6 +35,8 @@ const Info GFX_LOG_RENDER_TIME_TO_FILE{{System::GFX, "Settings", "LogRende const Info GFX_OVERLAY_STATS{{System::GFX, "Settings", "OverlayStats"}, false}; const Info GFX_OVERLAY_PROJ_STATS{{System::GFX, "Settings", "OverlayProjStats"}, false}; const Info GFX_DUMP_TEXTURES{{System::GFX, "Settings", "DumpTextures"}, false}; +const Info GFX_DUMP_MIP_TEXTURES{{System::GFX, "Settings", "DumpMipTextures"}, true}; +const Info GFX_DUMP_BASE_TEXTURES{{System::GFX, "Settings", "DumpBaseTextures"}, true}; const Info GFX_HIRES_TEXTURES{{System::GFX, "Settings", "HiresTextures"}, false}; const Info GFX_CACHE_HIRES_TEXTURES{{System::GFX, "Settings", "CacheHiresTextures"}, false}; const Info GFX_DUMP_EFB_TARGET{{System::GFX, "Settings", "DumpEFBTarget"}, false}; diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index d70831e21b..228c2af3b9 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -36,6 +36,8 @@ extern const Info GFX_LOG_RENDER_TIME_TO_FILE; extern const Info GFX_OVERLAY_STATS; extern const Info GFX_OVERLAY_PROJ_STATS; extern const Info GFX_DUMP_TEXTURES; +extern const Info GFX_DUMP_MIP_TEXTURES; +extern const Info GFX_DUMP_BASE_TEXTURES; extern const Info GFX_HIRES_TEXTURES; extern const Info GFX_CACHE_HIRES_TEXTURES; extern const Info GFX_DUMP_EFB_TARGET; diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index 47a8f16c0d..05ddd8406f 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -65,7 +65,6 @@ void AdvancedWidget::CreateWidgets() auto* utility_layout = new QGridLayout(); utility_box->setLayout(utility_layout); - m_dump_textures = new GraphicsBool(tr("Dump Textures"), Config::GFX_DUMP_TEXTURES); m_load_custom_textures = new GraphicsBool(tr("Load Custom Textures"), Config::GFX_HIRES_TEXTURES); m_prefetch_custom_textures = new GraphicsBool(tr("Prefetch Custom Textures"), Config::GFX_CACHE_HIRES_TEXTURES); @@ -77,9 +76,8 @@ void AdvancedWidget::CreateWidgets() utility_layout->addWidget(m_prefetch_custom_textures, 0, 1); utility_layout->addWidget(m_disable_vram_copies, 1, 0); - utility_layout->addWidget(m_dump_textures, 1, 1); - utility_layout->addWidget(m_dump_efb_target, 2, 0); + utility_layout->addWidget(m_dump_efb_target, 1, 1); // Freelook auto* freelook_box = new QGroupBox(tr("Free Look")); @@ -94,6 +92,19 @@ void AdvancedWidget::CreateWidgets() freelook_layout->addWidget(new QLabel(tr("Control Type:")), 1, 0); freelook_layout->addWidget(m_freelook_control_type, 1, 1); + // Texture dumping + auto* texture_dump_box = new QGroupBox(tr("Texture Dumping")); + auto* texture_dump_layout = new QGridLayout(); + texture_dump_box->setLayout(texture_dump_layout); + m_dump_textures = new GraphicsBool(tr("Enable"), Config::GFX_DUMP_TEXTURES); + m_dump_base_textures = new GraphicsBool(tr("Dump Base Textures"), Config::GFX_DUMP_BASE_TEXTURES); + m_dump_mip_textures = new GraphicsBool(tr("Dump Mip Maps"), Config::GFX_DUMP_MIP_TEXTURES); + + texture_dump_layout->addWidget(m_dump_textures, 0, 0); + + texture_dump_layout->addWidget(m_dump_base_textures, 1, 0); + texture_dump_layout->addWidget(m_dump_mip_textures, 1, 1); + // Frame dumping auto* dump_box = new QGroupBox(tr("Frame Dumping")); auto* dump_layout = new QGridLayout(); @@ -144,6 +155,7 @@ void AdvancedWidget::CreateWidgets() main_layout->addWidget(debugging_box); main_layout->addWidget(utility_box); main_layout->addWidget(freelook_box); + main_layout->addWidget(texture_dump_box); main_layout->addWidget(dump_box); main_layout->addWidget(misc_box); main_layout->addWidget(experimental_box); @@ -158,6 +170,7 @@ void AdvancedWidget::ConnectWidgets() connect(m_dump_use_ffv1, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_enable_prog_scan, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_enable_freelook, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); + connect(m_dump_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); } void AdvancedWidget::LoadSettings() @@ -168,6 +181,8 @@ void AdvancedWidget::LoadSettings() m_enable_prog_scan->setChecked(Config::Get(Config::SYSCONF_PROGRESSIVE_SCAN)); m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK)); + m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); + m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); } void AdvancedWidget::SaveSettings() @@ -178,6 +193,8 @@ void AdvancedWidget::SaveSettings() Config::SetBase(Config::SYSCONF_PROGRESSIVE_SCAN, m_enable_prog_scan->isChecked()); m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK)); + m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); + m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); } void AdvancedWidget::OnBackendChanged() @@ -201,9 +218,20 @@ void AdvancedWidget::AddDescriptions() static const char TR_VALIDATION_LAYER_DESCRIPTION[] = QT_TR_NOOP("Enables validation of API calls made by the video backend, which may assist in " "debugging graphical issues.\n\nIf unsure, leave this unchecked."); - static const char TR_DUMP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( - "Dumps decoded game textures to User/Dump/Textures//.\n\nIf unsure, leave " - "this unchecked."); + static const char TR_DUMP_TEXTURE_DESCRIPTION[] = + QT_TR_NOOP("Dumps decoded game textures based on the other flags to " + "User/Dump/Textures//.\n\nIf unsure, leave " + "this unchecked."); + static const char TR_DUMP_MIP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( + "Whether to dump mipmapped game textures to " + "User/Dump/Textures//. This includes arbitrary mipmapped textures if 'Arbitrary " + "Mipmap Detection' is enabled in Enhancements.\n\nIf unsure, leave " + "this checked."); + static const char TR_DUMP_BASE_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( + "Whether to dump base game textures to " + "User/Dump/Textures//. This includes arbitrary base textures if 'Arbitrary " + "Mipmap Detection' is enabled in Enhancements.\n\nIf unsure, leave " + "this checked."); static const char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP( "Loads custom textures from User/Load/Textures//.\n\nIf unsure, leave this " "unchecked."); @@ -268,6 +296,8 @@ void AdvancedWidget::AddDescriptions() AddDescription(m_enable_format_overlay, TR_TEXTURE_FORMAT_DESCRIPTION); AddDescription(m_enable_api_validation, TR_VALIDATION_LAYER_DESCRIPTION); AddDescription(m_dump_textures, TR_DUMP_TEXTURE_DESCRIPTION); + AddDescription(m_dump_mip_textures, TR_DUMP_MIP_TEXTURE_DESCRIPTION); + AddDescription(m_dump_base_textures, TR_DUMP_BASE_TEXTURE_DESCRIPTION); AddDescription(m_load_custom_textures, TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION); AddDescription(m_prefetch_custom_textures, TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION); AddDescription(m_dump_efb_target, TR_DUMP_EFB_DESCRIPTION); diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index 11d33755e2..3cf5dce519 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -34,7 +34,6 @@ private: QCheckBox* m_enable_api_validation; // Utility - QCheckBox* m_dump_textures; QCheckBox* m_prefetch_custom_textures; QCheckBox* m_dump_efb_target; QCheckBox* m_disable_vram_copies; @@ -42,6 +41,11 @@ private: QCheckBox* m_enable_freelook; QComboBox* m_freelook_control_type; + // Texture dumping + QCheckBox* m_dump_textures; + QCheckBox* m_dump_mip_textures; + QCheckBox* m_dump_base_textures; + // Frame dumping QCheckBox* m_dump_use_ffv1; QCheckBox* m_use_fullres_framedumps; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 5a298273d3..fdf3c0e6b3 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -920,8 +920,15 @@ void TextureCacheBase::DumpTexture(TCacheEntry* entry, std::string basename, uns if (level > 0) { + if (!g_ActiveConfig.bDumpMipmapTextures) + return; basename += fmt::format("_mip{}", level); } + else + { + if (!g_ActiveConfig.bDumpBaseTextures) + return; + } const std::string filename = fmt::format("{}/{}.png", szDir, basename); if (File::Exists(filename)) diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 1514f22db8..b0ab912e6c 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -85,6 +85,8 @@ void VideoConfig::Refresh() bOverlayStats = Config::Get(Config::GFX_OVERLAY_STATS); bOverlayProjStats = Config::Get(Config::GFX_OVERLAY_PROJ_STATS); bDumpTextures = Config::Get(Config::GFX_DUMP_TEXTURES); + bDumpMipmapTextures = Config::Get(Config::GFX_DUMP_MIP_TEXTURES); + bDumpBaseTextures = Config::Get(Config::GFX_DUMP_BASE_TEXTURES); bHiresTextures = Config::Get(Config::GFX_HIRES_TEXTURES); bCacheHiresTextures = Config::Get(Config::GFX_CACHE_HIRES_TEXTURES); bDumpEFBTarget = Config::Get(Config::GFX_DUMP_EFB_TARGET); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index ee0951180a..dacb286ada 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -102,6 +102,8 @@ struct VideoConfig final // Utility bool bDumpTextures; + bool bDumpMipmapTextures; + bool bDumpBaseTextures; bool bHiresTextures; bool bCacheHiresTextures; bool bDumpEFBTarget;