Minor GPU interface cleanup

This commit is contained in:
Henrik Rydgard 2016-01-06 23:49:02 +01:00
parent 2b5d38d2d0
commit e11d0a7e1c
11 changed files with 41 additions and 45 deletions

View file

@ -292,7 +292,7 @@ void __DisplayDoState(PointerWrap &p) {
}
gpu->DoState(p);
ReapplyGfxState();
gpu->ReapplyGfxState();
if (p.mode == p.MODE_READ) {
if (hasSetMode) {

View file

@ -533,7 +533,7 @@ u32 sceGeRestoreContext(u32 ctxAddr) {
gstate.Restore((u32_le *)Memory::GetPointer(ctxAddr));
}
ReapplyGfxState();
gpu->ReapplyGfxState();
return 0;
}

View file

@ -55,6 +55,8 @@
#include "Core/HLE/KernelWaitHelpers.h"
#include "Core/ELF/ParamSFO.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"
#ifdef BLACKBERRY
@ -1518,7 +1520,7 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
HLEShutdown();
Replacement_Init();
HLEInit();
GPU_Reinitialize();
gpu->Reinitialize();
}
__KernelModuleInit();

View file

@ -484,6 +484,14 @@ void PSP_Shutdown() {
g_Config.unloadGameConfig();
}
void PSP_BeginHostFrame() {
// Reapply the graphics state of the PSP
gpu->ReapplyGfxState();
}
void PSP_EndHostFrame() {
}
void PSP_RunLoopUntil(u64 globalticks) {
SaveState::Process();
if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {

View file

@ -62,6 +62,9 @@ bool PSP_InitUpdate(std::string *error_string);
bool PSP_IsIniting();
bool PSP_IsInited();
void PSP_Shutdown();
void PSP_BeginHostFrame();
void PSP_EndHostFrame();
void PSP_RunLoopUntil(u64 globalticks);
void PSP_RunLoopFor(int cycles);

View file

@ -64,35 +64,3 @@ void GPU_Shutdown() {
gpu = 0;
gpuDebug = 0;
}
void GPU_Reinitialize() {
if (gpu) {
gpu->Reinitialize();
}
}
void InitGfxState() {
memset(&gstate, 0, sizeof(gstate));
memset(&gstate_c, 0, sizeof(gstate_c));
for (int i = 0; i < 256; i++) {
gstate.cmdmem[i] = i << 24;
}
// Lighting is not enabled by default, matrices are zero initialized.
memset(gstate.worldMatrix, 0, sizeof(gstate.worldMatrix));
memset(gstate.viewMatrix, 0, sizeof(gstate.viewMatrix));
memset(gstate.projMatrix, 0, sizeof(gstate.projMatrix));
memset(gstate.tgenMatrix, 0, sizeof(gstate.tgenMatrix));
memset(gstate.boneMatrix, 0, sizeof(gstate.boneMatrix));
}
void ShutdownGfxState() {
}
// When you have changed state outside the psp gfx core,
// or saved the context and has reloaded it, call this function.
void ReapplyGfxState() {
if (!gpu)
return;
gpu->ReapplyGfxState();
}

View file

@ -106,4 +106,3 @@ extern GPUDebugInterface *gpuDebug;
bool GPU_Init(GraphicsContext *ctx);
void GPU_Shutdown();
void GPU_Reinitialize();

View file

@ -33,11 +33,11 @@ GPUCommon::GPUCommon() :
Reinitialize();
SetupColorConv();
SetThreadEnabled(g_Config.bSeparateCPUThread);
InitGfxState();
gstate.Reset();
gstate_c.Reset();
}
GPUCommon::~GPUCommon() {
ShutdownGfxState();
}
void GPUCommon::Reinitialize() {

View file

@ -74,6 +74,20 @@ static const CmdRange contextCmdRanges[] = {
// Skip: {0xFA, 0xFF},
};
void GPUgstate::Reset() {
memset(gstate.cmdmem, 0, sizeof(gstate.cmdmem));
for (int i = 0; i < 256; i++) {
gstate.cmdmem[i] = i << 24;
}
// Lighting is not enabled by default, matrices are zero initialized.
memset(gstate.worldMatrix, 0, sizeof(gstate.worldMatrix));
memset(gstate.viewMatrix, 0, sizeof(gstate.viewMatrix));
memset(gstate.projMatrix, 0, sizeof(gstate.projMatrix));
memset(gstate.tgenMatrix, 0, sizeof(gstate.tgenMatrix));
memset(gstate.boneMatrix, 0, sizeof(gstate.boneMatrix));
}
void GPUgstate::Save(u32_le *ptr) {
// Not sure what the first 10 values are, exactly, but these seem right.
ptr[5] = gstate_c.vertexAddr;
@ -189,6 +203,10 @@ struct GPUStateCache_v0
bool flipTexture;
};
void GPUStateCache::Reset() {
memset(&gstate_c, 0, sizeof(gstate_c));
}
void GPUStateCache::DoState(PointerWrap &p) {
auto s = p.Section("GPUStateCache", 0, 4);
if (!s) {

View file

@ -415,6 +415,7 @@ struct GPUgstate {
// Real data in the context ends here
void Reset();
void Save(u32_le *ptr);
void Restore(u32_le *ptr);
};
@ -528,13 +529,10 @@ struct GPUStateCache {
u32 curRTOffsetX;
u32 getRelativeAddress(u32 data) const;
void Reset();
void DoState(PointerWrap &p);
};
void InitGfxState();
void ShutdownGfxState();
void ReapplyGfxState();
class GPUInterface;
class GPUDebugInterface;

View file

@ -879,9 +879,7 @@ void EmuScreen::render() {
thin3d->SetTargetSize(pixel_xres, pixel_yres);
}
// Reapply the graphics state of the PSP
ReapplyGfxState();
PSP_BeginHostFrame();
// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.
// The actual number of cycles doesn't matter so much here as we will break due to CORE_NEXTFRAME, most of the time hopefully...
@ -898,6 +896,8 @@ void EmuScreen::render() {
}
checkPowerDown();
PSP_EndHostFrame();
if (invalid_)
return;