diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 384d9199cf..a0b7ce362e 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -58,21 +58,6 @@ static GSRendererType GSCurrentRenderer; static u64 s_next_manual_present_time; -void GSinit() -{ - GSVertexSW::InitStatic(); - - GSUtil::Init(); -} - -void GSshutdown() -{ - GSclose(); - - // ensure all screenshots have been saved - GSJoinSnapshotThreads(); -} - GSRendererType GSGetCurrentRenderer() { return GSCurrentRenderer; @@ -192,6 +177,8 @@ static bool OpenGSRenderer(GSRendererType renderer, u8* basemem) // Must be done first, initialization routines in GSState use GSIsHardwareRenderer(). GSCurrentRenderer = renderer; + GSVertexSW::InitStatic(); + if (renderer == GSRendererType::Null) { g_gs_renderer = std::make_unique(); diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index f96ffd336d..69b7dfb063 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -56,8 +56,6 @@ s16 GSLookupGetSkipCountFunctionId(const std::string_view& name); s16 GSLookupBeforeDrawFunctionId(const std::string_view& name); s16 GSLookupMoveHandlerFunctionId(const std::string_view& name); -void GSinit(); -void GSshutdown(); bool GSopen(const Pcsx2Config::GSOptions& config, GSRendererType renderer, u8* basemem); bool GSreopen(bool recreate_device, GSRendererType new_renderer, std::optional old_config); void GSreset(bool hardware_reset); diff --git a/pcsx2/GS/GSUtil.cpp b/pcsx2/GS/GSUtil.cpp index bac0dd8a2c..a6ae155564 100644 --- a/pcsx2/GS/GSUtil.cpp +++ b/pcsx2/GS/GSUtil.cpp @@ -22,18 +22,17 @@ #include #endif -static class GSUtilMaps +namespace { +struct GSUtilMaps { -public: - u8 PrimClassField[8]; - u8 VertexCountField[8]; - u8 ClassVertexCountField[4]; - u32 CompatibleBitsField[64][2]; - u32 SharedBitsField[64][2]; - u32 SwizzleField[64][2]; + u8 PrimClassField[8] = {}; + u8 VertexCountField[8] = {}; + u8 ClassVertexCountField[4] = {}; + u32 CompatibleBitsField[64][2] = {}; + u32 SharedBitsField[64][2] = {}; + u32 SwizzleField[64][2] = {}; - // Defer init to avoid AVX2 illegal instructions - void Init() + constexpr GSUtilMaps() { PrimClassField[GS_POINTLIST] = GS_POINT_CLASS; PrimClassField[GS_LINELIST] = GS_LINE_CLASS; @@ -58,8 +57,6 @@ public: ClassVertexCountField[GS_TRIANGLE_CLASS] = 3; ClassVertexCountField[GS_SPRITE_CLASS] = 2; - memset(CompatibleBitsField, 0, sizeof(CompatibleBitsField)); - for (int i = 0; i < 64; i++) { CompatibleBitsField[i][i >> 5] |= 1U << (i & 0x1f); @@ -74,8 +71,6 @@ public: CompatibleBitsField[PSMZ16][PSMZ16S >> 5] |= 1 << (PSMZ16S & 0x1f); CompatibleBitsField[PSMZ16S][PSMZ16 >> 5] |= 1 << (PSMZ16 & 0x1f); - memset(SwizzleField, 0, sizeof(SwizzleField)); - for (int i = 0; i < 64; i++) { SwizzleField[i][i >> 5] |= 1U << (i & 0x1f); @@ -92,8 +87,6 @@ public: SwizzleField[PSMZ32][PSMZ24 >> 5] |= 1 << (PSMZ24 & 0x1f); SwizzleField[PSMZ24][PSMZ32 >> 5] |= 1 << (PSMZ32 & 0x1f); - memset(SharedBitsField, 0, sizeof(SharedBitsField)); - SharedBitsField[PSMCT24][PSMT8H >> 5] |= 1 << (PSMT8H & 0x1f); SharedBitsField[PSMCT24][PSMT4HL >> 5] |= 1 << (PSMT4HL & 0x1f); SharedBitsField[PSMCT24][PSMT4HH >> 5] |= 1 << (PSMT4HH & 0x1f); @@ -109,14 +102,11 @@ public: SharedBitsField[PSMT4HH][PSMZ24 >> 5] |= 1 << (PSMZ24 & 0x1f); SharedBitsField[PSMT4HH][PSMT4HL >> 5] |= 1 << (PSMT4HL & 0x1f); } - -} s_maps; - -void GSUtil::Init() -{ - s_maps.Init(); +}; } +static constexpr const GSUtilMaps s_maps; + const char* GSUtil::GetATSTName(u32 atst) { static constexpr const char* names[] = { diff --git a/pcsx2/GS/GSUtil.h b/pcsx2/GS/GSUtil.h index cc10452acf..773cb08cca 100644 --- a/pcsx2/GS/GSUtil.h +++ b/pcsx2/GS/GSUtil.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team +// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: LGPL-3.0+ #pragma once @@ -9,8 +9,6 @@ class GSUtil { public: - static void Init(); - static const char* GetATSTName(u32 atst); static const char* GetAFAILName(u32 afail); diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index b182c4cb83..31e8784784 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -190,8 +190,6 @@ void MTGS::ThreadEntryPoint() // we need to reset sem_event here, because MainLoop() kills it. s_sem_event.Reset(); } - - GSshutdown(); } void MTGS::ResetGS(bool hardware_reset) diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index a4479eb67b..b83ea3276b 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -393,7 +393,6 @@ bool VMManager::Internal::CPUThreadInitialize() InitializeCPUProviders(); - GSinit(); USBinit(); // We want settings loaded so we choose the correct renderer for big picture mode. @@ -425,9 +424,9 @@ void VMManager::Internal::CPUThreadShutdown() PerformanceMetrics::SetCPUThread(Threading::ThreadHandle()); USBshutdown(); - GSshutdown(); MTGS::ShutdownThread(); + GSJoinSnapshotThreads(); ShutdownCPUProviders();