Skip to content

Commit

Permalink
Merge pull request #4667 from unknownbrackets/gpu-thread
Browse files Browse the repository at this point in the history
Reinitialize the GE on sceKernelLoadExec()
  • Loading branch information
hrydgard committed Nov 28, 2013
2 parents a29f1a9 + 4351154 commit 74ecdc6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Core/HLE/sceKernelModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "Core/HLE/sceIo.h"
#include "Core/HLE/KernelWaitHelpers.h"

#include "GPU/GPUState.h"

enum {
PSP_THREAD_ATTR_USER = 0x80000000
};
Expand Down Expand Up @@ -1223,6 +1225,7 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
//HLE needs to be reset here
HLEShutdown();
HLEInit();
GPU_Reinitialize();
}

__KernelModuleInit();
Expand Down
24 changes: 15 additions & 9 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,28 @@
#include "Core/HLE/sceGe.h"

GPUCommon::GPUCommon() :
nextListID(0),
currentList(NULL),
isbreak(false),
drawCompleteTicks(0),
busyTicks(0),
dumpNextFrame_(false),
dumpThisFrame_(false),
interruptsEnabled_(true),
curTickEst_(0)
dumpThisFrame_(false)
{
Reinitialize();
SetThreadEnabled(g_Config.bSeparateCPUThread);
}

void GPUCommon::Reinitialize() {
easy_guard guard(listLock);
memset(dls, 0, sizeof(dls));
for (int i = 0; i < DisplayListMaxCount; ++i) {
dls[i].state = PSP_GE_DL_STATE_NONE;
dls[i].waitTicks = 0;
}
SetThreadEnabled(g_Config.bSeparateCPUThread);

nextListID = 0;
currentList = NULL;
isbreak = false;
drawCompleteTicks = 0;
busyTicks = 0;
interruptsEnabled_ = true;
UpdateTickEstimate(0);
}

void GPUCommon::PopDLQueue() {
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface
public:
GPUCommon();
virtual ~GPUCommon() {}
virtual void Reinitialize();

virtual void InterruptStart(int listid);
virtual void InterruptEnd(int listid);
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class GPUInterface {

// Initialization
virtual void InitClear() = 0;
virtual void Reinitialize() = 0;

virtual void RunEventsUntil(u64 globalticks) = 0;
virtual void FinishEventLoop() = 0;
Expand Down
6 changes: 6 additions & 0 deletions GPU/GPUState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ void GPU_Shutdown() {
gpuDebug = 0;
}

void GPU_Reinitialize() {
if (gpu) {
gpu->Reinitialize();
}
}

void InitGfxState() {
memset(&gstate, 0, sizeof(gstate));
memset(&gstate_c, 0, sizeof(gstate_c));
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUState.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ struct GPUStatistics {

bool GPU_Init();
void GPU_Shutdown();
void GPU_Reinitialize();

void InitGfxState();
void ShutdownGfxState();
Expand Down

0 comments on commit 74ecdc6

Please sign in to comment.