Skip to content

Commit

Permalink
GS: Purge GSinit() and GSshutdown()
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Mar 28, 2024
1 parent 0384d9c commit 5be4326
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 47 deletions.
17 changes: 2 additions & 15 deletions pcsx2/GS/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<GSRendererNull>();
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/GS/GS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const Pcsx2Config::GSOptions*> old_config);
void GSreset(bool hardware_reset);
Expand Down
36 changes: 13 additions & 23 deletions pcsx2/GS/GSUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@
#include <wil/com.h>
#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];

// Defer init to avoid AVX2 illegal instructions
void Init()
u8 PrimClassField[8] = {};
u8 VertexCountField[8] = {};
u8 ClassVertexCountField[4] = {};
u32 CompatibleBitsField[64][2] = {};
u32 SharedBitsField[64][2] = {};
u32 SwizzleField[64][2] = {};

constexpr GSUtilMaps()
{
PrimClassField[GS_POINTLIST] = GS_POINT_CLASS;
PrimClassField[GS_LINELIST] = GS_LINE_CLASS;
Expand All @@ -58,8 +57,6 @@ static class GSUtilMaps
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);
Expand All @@ -74,8 +71,6 @@ static class GSUtilMaps
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);
Expand All @@ -92,8 +87,6 @@ static class GSUtilMaps
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);
Expand All @@ -109,14 +102,11 @@ static class GSUtilMaps
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[] = {
Expand Down
4 changes: 1 addition & 3 deletions pcsx2/GS/GSUtil.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,8 +9,6 @@
class GSUtil
{
public:
static void Init();

static const char* GetATSTName(u32 atst);
static const char* GetAFAILName(u32 afail);

Expand Down
2 changes: 0 additions & 2 deletions pcsx2/MTGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions pcsx2/VMManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -425,9 +424,9 @@ void VMManager::Internal::CPUThreadShutdown()
PerformanceMetrics::SetCPUThread(Threading::ThreadHandle());

USBshutdown();
GSshutdown();

MTGS::ShutdownThread();
GSJoinSnapshotThreads();

ShutdownCPUProviders();

Expand Down

0 comments on commit 5be4326

Please sign in to comment.