From 35e28fc0d0272ff8e38d5443a650be2dc9ea3e39 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 24 Dec 2022 13:46:11 +1000 Subject: [PATCH] GS: Get rid of GSApp for Qt --- pcsx2/CMakeLists.txt | 4 +- pcsx2/Config.h | 1 + pcsx2/GS/GS.cpp | 58 ++++------------- pcsx2/GS/GS.h | 16 +++-- pcsx2/GS/GSCrc.cpp | 8 +++ pcsx2/GS/GSState.cpp | 16 ++--- pcsx2/GS/GSState.h | 9 +-- pcsx2/GS/Renderers/Common/GSRenderer.cpp | 2 +- pcsx2/GS/Renderers/Common/GSTexture.cpp | 2 +- pcsx2/GS/Renderers/DX11/GSTexture11.cpp | 3 +- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 50 +++++++-------- .../HW/GSTextureReplacementLoaders.cpp | 2 +- pcsx2/GS/Renderers/Metal/GSDeviceMTL.h | 3 - pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm | 4 +- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 2 +- pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp | 3 +- pcsx2/GS/Renderers/SW/GSRasterizer.cpp | 2 +- pcsx2/GS/Renderers/SW/GSRendererSW.cpp | 62 +++++++++---------- pcsx2/GS/Renderers/SW/GSTextureSW.cpp | 2 +- pcsx2/Pcsx2Config.cpp | 2 + pcsx2/pcsx2core.vcxproj | 4 +- pcsx2/pcsx2core.vcxproj.filters | 6 -- 22 files changed, 107 insertions(+), 154 deletions(-) diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 792f581b07..f4acfaa99b 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -692,7 +692,6 @@ set(pcsx2GSSources GS/Renderers/SW/GSNewCodeGenerator.cpp GS/Renderers/SW/GSTextureCacheSW.cpp GS/Renderers/SW/GSTextureSW.cpp - GS/Window/GSSetting.cpp ) # GS headers @@ -757,7 +756,6 @@ set(pcsx2GSHeaders GS/Renderers/SW/GSTextureCacheSW.h GS/Renderers/SW/GSTextureSW.h GS/Renderers/SW/GSVertexSW.h - GS/Window/GSSetting.h ) if(USE_OPENGL) @@ -815,9 +813,11 @@ if(PCSX2_CORE) endif() else() list(APPEND pcsx2GSSources + GS/Window/GSSetting.cpp GS/Window/GSwxDialog.cpp ) list(APPEND pcsx2GSHeaders + GS/Window/GSSetting.h GS/Window/GSwxDialog.h ) if(WIN32) diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 4a0739dd58..516e6d83fb 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -734,6 +734,7 @@ struct Pcsx2Config int ShadeBoost_Brightness{50}; int ShadeBoost_Contrast{50}; int ShadeBoost_Saturation{50}; + int PNGCompressionLevel{1}; int SaveN{0}; int SaveL{5000}; diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 4d5ee3e2ec..90940649b3 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -111,6 +111,7 @@ int GSinit() void GSinitConfig() { +#ifndef PCSX2_CORE static bool config_inited = false; if (config_inited) return; @@ -118,6 +119,7 @@ void GSinitConfig() config_inited = true; theApp.SetConfigDir(); theApp.Init(); +#endif } void GSshutdown() @@ -258,8 +260,7 @@ static bool DoGSOpen(GSRendererType renderer, u8* basemem) } else { - const int threads = theApp.GetConfigI("extrathreads"); - g_gs_renderer = std::unique_ptr(MULTI_ISA_SELECT(makeGSRendererSW)(threads)); + g_gs_renderer = std::unique_ptr(MULTI_ISA_SELECT(makeGSRendererSW)(GSConfig.SWExtraThreads)); } } catch (std::exception& ex) @@ -720,9 +721,12 @@ void GSgetStats(std::string& info) void GSgetTitleStats(std::string& info) { + static constexpr const char* deinterlace_modes[] = { + "Automatic", "None", "Weave tff", "Weave bff", "Bob tff", "Bob bff", "Blend tff", "Blend bff", "Adaptive tff", "Adaptive bff"}; + const char* api_name = HostDisplay::RenderAPIToString(s_render_api); const char* hw_sw_name = (GSConfig.Renderer == GSRendererType::Null) ? " Null" : (GSConfig.UseHardwareRenderer() ? " HW" : " SW"); - const char* deinterlace_mode = theApp.m_gs_deinterlace[static_cast(GSConfig.InterlaceMode)].name.c_str(); + const char* deinterlace_mode = deinterlace_modes[static_cast(GSConfig.InterlaceMode)]; #ifndef PCSX2_CORE int iwidth, iheight; @@ -775,19 +779,10 @@ void GSUpdateConfig(const Pcsx2Config::GSOptions& new_config) // Options which aren't using the global struct yet, so we need to recreate all GS objects. if ( - GSConfig.DumpGSData != old_config.DumpGSData || - GSConfig.SaveRT != old_config.SaveRT || - GSConfig.SaveFrame != old_config.SaveFrame || - GSConfig.SaveTexture != old_config.SaveTexture || - GSConfig.SaveDepth != old_config.SaveDepth || - GSConfig.UpscaleMultiplier != old_config.UpscaleMultiplier || GSConfig.CRCHack != old_config.CRCHack || GSConfig.SWExtraThreads != old_config.SWExtraThreads || - GSConfig.SWExtraThreadsHeight != old_config.SWExtraThreadsHeight || - - GSConfig.SaveN != old_config.SaveN || - GSConfig.SaveL != old_config.SaveL) + GSConfig.SWExtraThreadsHeight != old_config.SWExtraThreadsHeight) { if (!GSreopen(false, old_config)) pxFailRel("Failed to do quick GS reopen"); @@ -1050,12 +1045,10 @@ void GSFreeWrappedMemory(void* ptr, size_t size, size_t repeat) #endif +#ifndef PCSX2_CORE + size_t GSApp::GetIniString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName) { -#ifdef PCSX2_CORE - std::string ret(Host::GetStringSettingValue("EmuCore/GS", lpKeyName, lpDefault)); - return StringUtil::Strlcpy(lpReturnedString, ret, nSize); -#else BuildConfigurationMap(lpFileName); std::string key(lpKeyName); @@ -1070,12 +1063,10 @@ size_t GSApp::GetIniString(const char* lpAppName, const char* lpKeyName, const c strcpy(lpReturnedString, value.c_str()); return 0; -#endif } bool GSApp::WriteIniString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName) { -#ifndef PCSX2_CORE BuildConfigurationMap(lpFileName); std::string key(lpKeyName); @@ -1104,12 +1095,10 @@ bool GSApp::WriteIniString(const char* lpAppName, const char* lpKeyName, const c fprintf(f, "%s = %s\n", entry.first.c_str(), entry.second.c_str()); } fclose(f); -#endif return false; } -#ifndef PCSX2_CORE int GSApp::GetIniInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName) { BuildConfigurationMap(lpFileName); @@ -1124,7 +1113,6 @@ int GSApp::GetIniInt(const char* lpAppName, const char* lpKeyName, int nDefault, else return atoi(value.c_str()); } -#endif GSApp theApp; @@ -1394,7 +1382,6 @@ void GSApp::Init() // clang-format on } -#ifndef PCSX2_CORE void GSApp::ReloadConfig() { if (m_configuration_map.empty()) @@ -1453,7 +1440,6 @@ void GSApp::BuildConfigurationMap(const char* lpFileName) m_configuration_map[key] = value; } } -#endif void GSApp::SetConfigDir() { @@ -1492,40 +1478,18 @@ int GSApp::GetConfigI(const char* entry) if (def != m_default_configuration.end()) { -#ifndef PCSX2_CORE return GetIniInt(m_section.c_str(), entry, std::stoi(def->second), m_ini.c_str()); -#else - return Host::GetIntSettingValue("EmuCore/GS", entry, std::stoi(def->second)); -#endif } else { fprintf(stderr, "Option %s doesn't have a default value\n", entry); -#ifndef PCSX2_CORE return GetIniInt(m_section.c_str(), entry, 0, m_ini.c_str()); -#else - return Host::GetIntSettingValue("EmuCore/GS", entry, 0); -#endif } } bool GSApp::GetConfigB(const char* entry) { -#ifndef PCSX2_CORE return !!GetConfigI(entry); -#else - auto def = m_default_configuration.find(entry); - - if (def != m_default_configuration.end()) - { - return Host::GetBoolSettingValue("EmuCore/GS", entry, StringUtil::FromChars(def->second).value_or(false)); - } - else - { - fprintf(stderr, "Option %s doesn't have a default value\n", entry); - return Host::GetBoolSettingValue("EmuCore/GS", entry, false); - } -#endif } void GSApp::SetConfig(const char* entry, int value) @@ -1537,6 +1501,8 @@ void GSApp::SetConfig(const char* entry, int value) SetConfig(entry, buff); } +#endif // PCSX2_CORE + #ifdef PCSX2_CORE static void HotkeyAdjustUpscaleMultiplier(s32 delta) diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index 3f499637d4..2c2e0b8b43 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -16,7 +16,6 @@ #pragma once #include "common/WindowInfo.h" -#include "Window/GSSetting.h" #include "SaveState.h" #include "pcsx2/Config.h" #include "pcsx2/GS/config.h" @@ -24,6 +23,10 @@ #include +#ifndef PCSX2_CORE +#include "Window/GSSetting.h" +#endif + #ifdef None // X11 seems to like to define this, not fun #undef None @@ -101,6 +104,8 @@ bool GSSaveSnapshotToMemory(u32 window_width, u32 window_height, bool apply_aspe u32* width, u32* height, std::vector* pixels); void GSJoinSnapshotThreads(); +#ifndef PCSX2_CORE + class GSApp { std::string m_section; @@ -157,14 +162,13 @@ public: std::vector m_gs_dump_compression; }; +extern GSApp theApp; + +#endif + struct GSError { }; struct GSRecoverableError : GSError { }; -struct GSErrorGlVertexArrayTooSmall : GSError -{ -}; - -extern GSApp theApp; diff --git a/pcsx2/GS/GSCrc.cpp b/pcsx2/GS/GSCrc.cpp index 89b2f05d75..bb3187fe27 100644 --- a/pcsx2/GS/GSCrc.cpp +++ b/pcsx2/GS/GSCrc.cpp @@ -19,6 +19,10 @@ #include "GS.h" #include "common/StringUtil.h" +#ifdef PCSX2_CORE +#include "HostSettings.h" +#endif + const CRC::Game CRC::m_games[] = { // Note: IDs 0x7ACF7E03, 0x7D4EA48F, 0x37C53760 - shouldn't be added as it's from the multiloaders when packing games. @@ -337,7 +341,11 @@ const CRC::Game& CRC::Lookup(u32 crc) printf("GS Lookup CRC:%08X\n", crc); if (m_map.empty()) { +#ifndef PCSX2_CORE std::string exclusions = theApp.GetConfigS("CrcHacksExclusions"); +#else + std::string exclusions = Host::GetStringSettingValue("EmuCore/GS", "CrcHacksExclusions"); +#endif if (exclusions.length() != 0) printf("GS: CrcHacksExclusions: %s\n", exclusions.c_str()); int crcDups = 0; diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index 88d15ca396..43907f2461 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -25,6 +25,7 @@ #include // Dump Verticles int GSState::s_n = 0; +std::string GSState::s_dump_root; static __fi bool IsAutoFlushEnabled() { @@ -55,16 +56,9 @@ GSState::GSState() m_mipmap = GSConfig.Mipmap; s_n = 0; - s_dump = theApp.GetConfigB("dump"); - s_save = theApp.GetConfigB("save"); - s_savet = theApp.GetConfigB("savet"); - s_savez = theApp.GetConfigB("savez"); - s_savef = theApp.GetConfigB("savef"); - s_saven = theApp.GetConfigI("saven"); - s_savel = theApp.GetConfigI("savel"); - m_dump_root = ""; + s_dump_root = ""; #if defined(__unix__) - if (s_dump) + if (GSConfig.DumpGSData) { GSmkdir(root_hw.c_str()); GSmkdir(root_sw.c_str()); @@ -2085,9 +2079,9 @@ void GSState::Read(u8* mem, int len) m_mem.ReadImageX(m_tr.x, m_tr.y, mem, len, m_env.BITBLTBUF, m_env.TRXPOS, m_env.TRXREG); - if (s_dump && s_save && s_n >= s_saven) + if (GSConfig.DumpGSData && GSConfig.SaveRT && s_n >= GSConfig.SaveN) { - std::string s = m_dump_root + StringUtil::StdStringFromFormat( + std::string s = s_dump_root + StringUtil::StdStringFromFormat( "%05d_read_%05x_%d_%d_%d_%d_%d_%d.bmp", s_n, (int)m_env.BITBLTBUF.SBP, (int)m_env.BITBLTBUF.SBW, (int)m_env.BITBLTBUF.SPSM, r.left, r.top, r.right, r.bottom); diff --git a/pcsx2/GS/GSState.h b/pcsx2/GS/GSState.h index 7fee8ac119..fb65874625 100644 --- a/pcsx2/GS/GSState.h +++ b/pcsx2/GS/GSState.h @@ -241,14 +241,7 @@ public: int m_backed_up_ctx; static int s_n; - bool s_dump; - bool s_save; - bool s_savet; - bool s_savez; - bool s_savef; - int s_saven; - int s_savel; - std::string m_dump_root; + static std::string s_dump_root; static constexpr u32 STATE_VERSION = 8; diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.cpp b/pcsx2/GS/Renderers/Common/GSRenderer.cpp index be6d8675ee..1c49a968ac 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.cpp +++ b/pcsx2/GS/Renderers/Common/GSRenderer.cpp @@ -629,7 +629,7 @@ void GSRenderer::VSync(u32 field, bool registers_written) { Flush(GSFlushReason::VSYNC); - if (s_dump && s_n >= s_saven) + if (GSConfig.DumpGSData && s_n >= GSConfig.SaveN) { m_regs->Dump(root_sw + StringUtil::StdStringFromFormat("%05d_f%lld_gs_reg.txt", s_n, g_perfmon.GetFrame())); } diff --git a/pcsx2/GS/Renderers/Common/GSTexture.cpp b/pcsx2/GS/Renderers/Common/GSTexture.cpp index 41e0075c54..b6d1acc4d4 100644 --- a/pcsx2/GS/Renderers/Common/GSTexture.cpp +++ b/pcsx2/GS/Renderers/Common/GSTexture.cpp @@ -58,7 +58,7 @@ bool GSTexture::Save(const std::string& fn) return false; } - const int compression = theApp.GetConfigI("png_compression_level"); + const int compression = GSConfig.PNGCompressionLevel; bool success = GSPng::Save(format, fn, map.bits, m_size.x, m_size.y, map.pitch, compression); g_gs_device->DownloadTextureComplete(); diff --git a/pcsx2/GS/Renderers/DX11/GSTexture11.cpp b/pcsx2/GS/Renderers/DX11/GSTexture11.cpp index 99ba516f38..98b564128b 100644 --- a/pcsx2/GS/Renderers/DX11/GSTexture11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTexture11.cpp @@ -179,8 +179,7 @@ bool GSTexture11::Save(const std::string& fn) return false; } - int compression = theApp.GetConfigI("png_compression_level"); - bool success = GSPng::Save(format, fn, static_cast(sm.pData), desc.Width, desc.Height, sm.RowPitch, compression); + bool success = GSPng::Save(format, fn, static_cast(sm.pData), desc.Width, desc.Height, sm.RowPitch, GSConfig.PNGCompressionLevel); GSDevice11::GetInstance()->GetD3DContext()->Unmap(res.get(), 0); diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index de5e2543da..e9fddb14c6 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -37,7 +37,7 @@ GSRendererHW::GSRendererHW() m_mipmap = (GSConfig.HWMipmap >= HWMipmapLevel::Basic); SetTCOffset(); - m_dump_root = root_hw; + s_dump_root = root_hw; GSTextureReplacements::Initialize(m_tc); // Hope nothing requires too many draw calls. @@ -267,11 +267,11 @@ GSTexture* GSRendererHW::GetOutput(int i, int& y_offset) } #ifdef ENABLE_OGL_DEBUG - if (s_dump) + if (GSConfig.DumpGSData) { - if (s_savef && s_n >= s_saven) + if (GSConfig.SaveFrame && s_n >= GSConfig.SaveN) { - t->Save(m_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, (int)TEX0.TBP0, psm_str(TEX0.PSM))); + t->Save(s_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, (int)TEX0.TBP0, psm_str(TEX0.PSM))); } } #endif @@ -299,8 +299,8 @@ GSTexture* GSRendererHW::GetFeedbackOutput() GSTexture* t = rt->m_texture; #ifdef ENABLE_OGL_DEBUG - if (s_dump && s_savef && s_n >= s_saven) - t->Save(m_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), 3, (int)TEX0.TBP0, psm_str(TEX0.PSM))); + if (GSConfig.DumpGSData && GSConfig.SaveFrame && s_n >= GSConfig.SaveN) + t->Save(s_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), 3, (int)TEX0.TBP0, psm_str(TEX0.PSM))); #endif return t; @@ -1278,19 +1278,19 @@ void GSRendererHW::RoundSpriteOffset() void GSRendererHW::Draw() { - if (s_dump && (s_n >= s_saven)) + if (GSConfig.DumpGSData && (s_n >= GSConfig.SaveN)) { std::string s; // Dump Register state s = StringUtil::StdStringFromFormat("%05d_context.txt", s_n); - m_env.Dump(m_dump_root + s); - m_context->Dump(m_dump_root + s); + m_env.Dump(s_dump_root + s); + m_context->Dump(s_dump_root + s); // Dump vertices s = StringUtil::StdStringFromFormat("%05d_vertex.txt", s_n); - DumpVertices(m_dump_root + s); + DumpVertices(s_dump_root + s); } if (IsBadFrame()) @@ -1778,13 +1778,13 @@ void GSRendererHW::Draw() m_src->m_texture = *m_src->m_from_target; } - if (s_dump) + if (GSConfig.DumpGSData) { const u64 frame = g_perfmon.GetFrame(); std::string s; - if (s_savet && s_n >= s_saven && m_src) + if (GSConfig.SaveTexture && s_n >= GSConfig.SaveN && m_src) { s = StringUtil::StdStringFromFormat("%05d_f%lld_itex_%05x_%s_%d%d_%02x_%02x_%02x_%02x.dds", s_n, frame, (int)context->TEX0.TBP0, psm_str(context->TEX0.PSM), @@ -1792,30 +1792,30 @@ void GSRendererHW::Draw() (int)context->CLAMP.MINU, (int)context->CLAMP.MAXU, (int)context->CLAMP.MINV, (int)context->CLAMP.MAXV); - m_src->m_texture->Save(m_dump_root + s); + m_src->m_texture->Save(s_dump_root + s); if (m_src->m_palette) { s = StringUtil::StdStringFromFormat("%05d_f%lld_itpx_%05x_%s.dds", s_n, frame, context->TEX0.CBP, psm_str(context->TEX0.CPSM)); - m_src->m_palette->Save(m_dump_root + s); + m_src->m_palette->Save(s_dump_root + s); } } - if (rt && s_save && s_n >= s_saven) + if (rt && GSConfig.SaveRT && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rt0_%05x_%s.bmp", s_n, frame, context->FRAME.Block(), psm_str(context->FRAME.PSM)); if (rt->m_texture) - rt->m_texture->Save(m_dump_root + s); + rt->m_texture->Save(s_dump_root + s); } - if (ds && s_savez && s_n >= s_saven) + if (ds && GSConfig.SaveDepth && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rz0_%05x_%s.bmp", s_n, frame, context->ZBUF.Block(), psm_str(context->ZBUF.PSM)); if (ds->m_texture) - ds->m_texture->Save(m_dump_root + s); + ds->m_texture->Save(s_dump_root + s); } } @@ -1939,31 +1939,31 @@ void GSRendererHW::Draw() (this->*m_hacks.m_oo)(); } - if (s_dump) + if (GSConfig.DumpGSData) { const u64 frame = g_perfmon.GetFrame(); std::string s; - if (s_save && s_n >= s_saven) + if (GSConfig.SaveRT && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rt1_%05x_%s.bmp", s_n, frame, context->FRAME.Block(), psm_str(context->FRAME.PSM)); if (rt) - rt->m_texture->Save(m_dump_root + s); + rt->m_texture->Save(s_dump_root + s); } - if (s_savez && s_n >= s_saven) + if (GSConfig.SaveDepth && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rz1_%05x_%s.bmp", s_n, frame, context->ZBUF.Block(), psm_str(context->ZBUF.PSM)); if (ds) - rt->m_texture->Save(m_dump_root + s); + rt->m_texture->Save(s_dump_root + s); } - if (s_savel > 0 && (s_n - s_saven) > s_savel) + if (GSConfig.SaveL > 0 && (s_n - GSConfig.SaveN) > GSConfig.SaveL) { - s_dump = 0; + GSConfig.DumpGSData = 0; } } diff --git a/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp b/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp index e321f7798b..b7f2a6caca 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureReplacementLoaders.cpp @@ -235,7 +235,7 @@ bool PNGLoader(const std::string& filename, GSTextureReplacements::ReplacementTe bool GSTextureReplacements::SavePNGImage(const std::string& filename, u32 width, u32 height, const u8* buffer, u32 pitch) { - const int compression = theApp.GetConfigI("png_compression_level"); + const int compression = GSConfig.PNGCompressionLevel; png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!png_ptr) diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.h b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.h index e04521373c..434ebd19ac 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.h +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.h @@ -212,9 +212,6 @@ public: using PSSelector = GSHWDrawConfig::PSSelector; - // MARK: Configuration - int m_mipmap; - // MARK: Permanent resources std::shared_ptr> m_backref; GSMTLDevice m_dev; diff --git a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm index 71ba2e7dde..d3db177756 100644 --- a/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSDeviceMTL.mm @@ -89,7 +89,6 @@ GSDeviceMTL::GSDeviceMTL() , m_dev(nil) { m_backref->second = this; - m_mipmap = theApp.GetConfigI("mipmap"); } GSDeviceMTL::~GSDeviceMTL() @@ -783,7 +782,6 @@ bool GSDeviceMTL::Create() // Init samplers MTLSamplerDescriptor* sdesc = [[MTLSamplerDescriptor new] autorelease]; - const int anisotropy = theApp.GetConfigI("MaxAnisotropy"); for (size_t i = 0; i < std::size(m_sampler_hw); i++) { GSHWDrawConfig::SamplerSelector sel; @@ -826,7 +824,7 @@ bool GSDeviceMTL::Create() sdesc.tAddressMode = sel.tav ? MTLSamplerAddressModeRepeat : MTLSamplerAddressModeClampToEdge; sdesc.rAddressMode = MTLSamplerAddressModeClampToEdge; - sdesc.maxAnisotropy = anisotropy && sel.aniso ? anisotropy : 1; + sdesc.maxAnisotropy = GSConfig.MaxAnisotropy && sel.aniso ? GSConfig.MaxAnisotropy : 1; sdesc.lodMaxClamp = sel.lodclamp ? 0.25f : FLT_MAX; [sdesc setLabel:[NSString stringWithFormat:@"%s%s %s%s", taudesc, tavdesc, magname, minname]]; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index ce7722bf3f..a94782df5b 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -97,7 +97,7 @@ bool GSDeviceOGL::Create() if (!GLLoader::check_gl_requirements()) return false; - if (!theApp.GetConfigB("disable_shader_cache")) + if (!GSConfig.DisableShaderCache) { if (!m_shader_cache.Open(false, EmuFolders::Cache, SHADER_CACHE_VERSION)) Console.Warning("Shader cache failed to open."); diff --git a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp index 5235335682..ac40e077ea 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp @@ -410,8 +410,7 @@ bool GSTextureOGL::Save(const std::string& fn) glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); } - int compression = theApp.GetConfigI("png_compression_level"); - return GSPng::Save(fmt, fn, image.get(), m_size.x, m_size.y, pitch, compression); + return GSPng::Save(fmt, fn, image.get(), m_size.x, m_size.y, pitch, GSConfig.PNGCompressionLevel); } void GSTextureOGL::Swap(GSTexture* tex) diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp index 162cb21c40..0b9e88cf5e 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp @@ -38,7 +38,7 @@ static int compute_best_thread_height(int threads) // - but not too small to keep the threading overhead low // - ideal value between 3 and 5, or log2(64 / number of threads) - int th = theApp.GetConfigI("extrathreads_height"); + int th = GSConfig.SWExtraThreadsHeight; if (th > 0 && th < 9) return th; diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index 6577ce9637..1506a9362b 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -44,7 +44,7 @@ GSRendererSW::GSRendererSW(int threads) std::fill(std::begin(m_fzb_pages), std::end(m_fzb_pages), 0); std::fill(std::begin(m_tex_pages), std::end(m_tex_pages), 0); - m_dump_root = root_sw; + s_dump_root = root_sw; } GSRendererSW::~GSRendererSW() @@ -201,11 +201,11 @@ GSTexture* GSRendererSW::GetOutput(int i, int& y_offset) m_texture[i]->Update(out_r, m_output, pitch); - if (s_dump) + if (GSConfig.DumpGSData) { - if (s_savef && s_n >= s_saven) + if (GSConfig.SaveFrame && s_n >= GSConfig.SaveN) { - m_texture[i]->Save(m_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, (int)DISPFB.Block(), psm_str(DISPFB.PSM))); + m_texture[i]->Save(s_dump_root + StringUtil::StdStringFromFormat("%05d_f%lld_fr%d_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), i, (int)DISPFB.Block(), psm_str(DISPFB.PSM))); } } } @@ -333,21 +333,21 @@ void GSRendererSW::Draw() { const GSDrawingContext* context = m_context; - if (s_dump) + if (GSConfig.DumpGSData) { std::string s; - if (s_n >= s_saven) + if (s_n >= GSConfig.SaveN) { // Dump Register state s = StringUtil::StdStringFromFormat("%05d_context.txt", s_n); - m_env.Dump(m_dump_root + s); - m_context->Dump(m_dump_root + s); + m_env.Dump(s_dump_root + s); + m_context->Dump(s_dump_root + s); // Dump vertices s = StringUtil::StdStringFromFormat("%05d_vertex.txt", s_n); - DumpVertices(m_dump_root + s); + DumpVertices(s_dump_root + s); } } @@ -454,7 +454,7 @@ void GSRendererSW::Draw() // - if (s_dump) + if (GSConfig.DumpGSData) { Sync(2); @@ -465,67 +465,67 @@ void GSRendererSW::Draw() // It will breaks the few games that really uses 16 bits RT bool texture_shuffle = ((context->FRAME.PSM & 0x2) && ((context->TEX0.PSM & 3) == 2) && (m_vt.m_primclass == GS_SPRITE_CLASS)); - if (s_savet && s_n >= s_saven && PRIM->TME) + if (GSConfig.SaveTexture && s_n >= GSConfig.SaveN && PRIM->TME) { if (texture_shuffle) { // Dump the RT in 32 bits format. It helps to debug texture shuffle effect s = StringUtil::StdStringFromFormat("%05d_f%lld_itexraw_%05x_32bits.bmp", s_n, frame, (int)m_context->TEX0.TBP0); - m_mem.SaveBMP(m_dump_root + s, m_context->TEX0.TBP0, m_context->TEX0.TBW, 0, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH); + m_mem.SaveBMP(s_dump_root + s, m_context->TEX0.TBP0, m_context->TEX0.TBW, 0, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH); } s = StringUtil::StdStringFromFormat("%05d_f%lld_itexraw_%05x_%s.bmp", s_n, frame, (int)m_context->TEX0.TBP0, psm_str(m_context->TEX0.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH); + m_mem.SaveBMP(s_dump_root + s, m_context->TEX0.TBP0, m_context->TEX0.TBW, m_context->TEX0.PSM, 1 << m_context->TEX0.TW, 1 << m_context->TEX0.TH); } - if (s_save && s_n >= s_saven) + if (GSConfig.SaveRT && s_n >= GSConfig.SaveN) { if (texture_shuffle) { // Dump the RT in 32 bits format. It helps to debug texture shuffle effect s = StringUtil::StdStringFromFormat("%05d_f%lld_rt0_%05x_32bits.bmp", s_n, frame, m_context->FRAME.Block()); - m_mem.SaveBMP(m_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, 0, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, 0, GetFrameRect().width(), 512); } s = StringUtil::StdStringFromFormat("%05d_f%lld_rt0_%05x_%s.bmp", s_n, frame, m_context->FRAME.Block(), psm_str(m_context->FRAME.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); } - if (s_savez && s_n >= s_saven) + if (GSConfig.SaveDepth && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rz0_%05x_%s.bmp", s_n, frame, m_context->ZBUF.Block(), psm_str(m_context->ZBUF.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); } Queue(data); Sync(3); - if (s_save && s_n >= s_saven) + if (GSConfig.SaveRT && s_n >= GSConfig.SaveN) { if (texture_shuffle) { // Dump the RT in 32 bits format. It helps to debug texture shuffle effect s = StringUtil::StdStringFromFormat("%05d_f%lld_rt1_%05x_32bits.bmp", s_n, frame, m_context->FRAME.Block()); - m_mem.SaveBMP(m_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, 0, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, 0, GetFrameRect().width(), 512); } s = StringUtil::StdStringFromFormat("%05d_f%lld_rt1_%05x_%s.bmp", s_n, frame, m_context->FRAME.Block(), psm_str(m_context->FRAME.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); } - if (s_savez && s_n >= s_saven) + if (GSConfig.SaveDepth && s_n >= GSConfig.SaveN) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rz1_%05x_%s.bmp", s_n, frame, m_context->ZBUF.Block(), psm_str(m_context->ZBUF.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); } - if (s_savel > 0 && (s_n - s_saven) > s_savel) + if (GSConfig.SaveL > 0 && (s_n - GSConfig.SaveN) > GSConfig.SaveL) { - s_dump = 0; + GSConfig.DumpGSData = 0; } } else @@ -604,18 +604,18 @@ void GSRendererSW::Sync(int reason) { std::string s; - if (s_save) + if (GSConfig.SaveRT) { s = StringUtil::StdStringFromFormat("%05d_f%lld_rt1_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), m_context->FRAME.Block(), psm_str(m_context->FRAME.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512); } - if (s_savez) + if (GSConfig.SaveDepth) { s = StringUtil::StdStringFromFormat("%05d_f%lld_zb1_%05x_%s.bmp", s_n, g_perfmon.GetFrame(), m_context->ZBUF.Block(), psm_str(m_context->ZBUF.PSM)); - m_mem.SaveBMP(m_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); + m_mem.SaveBMP(s_dump_root + s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512); } } @@ -1571,13 +1571,13 @@ void GSRendererSW::SharedData::UpdateSource() // TODO - if (g_gs_renderer->s_dump) + if (GSConfig.DumpGSData) { u64 frame = g_perfmon.GetFrame(); std::string s; - if (g_gs_renderer->s_savet && g_gs_renderer->s_n >= g_gs_renderer->s_saven) + if (GSConfig.SaveTexture && g_gs_renderer->s_n >= GSConfig.SaveN) { for (size_t i = 0; m_tex[i].t != NULL; i++) { diff --git a/pcsx2/GS/Renderers/SW/GSTextureSW.cpp b/pcsx2/GS/Renderers/SW/GSTextureSW.cpp index 9abf94c11b..3190e86a09 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSTextureSW.cpp @@ -91,7 +91,7 @@ bool GSTextureSW::Save(const std::string& fn) #else GSPng::Format fmt = GSPng::RGB_PNG; #endif - int compression = theApp.GetConfigI("png_compression_level"); + int compression = GSConfig.PNGCompressionLevel; return GSPng::Save(fmt, fn, static_cast(m_data), m_size.x, m_size.y, m_pitch, compression); } diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 2033cff599..760c00e41b 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -489,6 +489,7 @@ bool Pcsx2Config::GSOptions::OptionsAreEqual(const GSOptions& right) const OpEqu(ShadeBoost_Brightness) && OpEqu(ShadeBoost_Contrast) && OpEqu(ShadeBoost_Saturation) && + OpEqu(PNGCompressionLevel) && OpEqu(SaveN) && OpEqu(SaveL) && @@ -693,6 +694,7 @@ void Pcsx2Config::GSOptions::ReloadIniSettings() GSSettingInt(ShadeBoost_Brightness); GSSettingInt(ShadeBoost_Contrast); GSSettingInt(ShadeBoost_Saturation); + GSSettingIntEx(PNGCompressionLevel, "png_compression_level"); GSSettingIntEx(SaveN, "saven"); GSSettingIntEx(SaveL, "savel"); diff --git a/pcsx2/pcsx2core.vcxproj b/pcsx2/pcsx2core.vcxproj index e3aaf9d8aa..a95ae80f0f 100644 --- a/pcsx2/pcsx2core.vcxproj +++ b/pcsx2/pcsx2core.vcxproj @@ -310,7 +310,6 @@ - @@ -653,7 +652,6 @@ - @@ -893,4 +891,4 @@ - + \ No newline at end of file diff --git a/pcsx2/pcsx2core.vcxproj.filters b/pcsx2/pcsx2core.vcxproj.filters index d167a79ddc..7389fd0cbf 100644 --- a/pcsx2/pcsx2core.vcxproj.filters +++ b/pcsx2/pcsx2core.vcxproj.filters @@ -1175,9 +1175,6 @@ System\Ps2\GS\Window - - System\Ps2\GS\Window - System\Ps2\GS\Renderers\Direct3D11 @@ -2123,9 +2120,6 @@ System\Ps2\GS\Window - - System\Ps2\GS\Window - System\Ps2\GS