From 6b26e1a591aaa00c6765700cb3aa822618acaf09 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 14 Mar 2015 18:11:00 -0700 Subject: [PATCH] Read pending vertex data before exiting gpu loop. Fixes save pictures in Crimson Gem Saga. --- GPU/Directx9/GPU_DX9.cpp | 5 +++++ GPU/Directx9/GPU_DX9.h | 7 ++++--- GPU/Directx9/TransformPipelineDX9.h | 6 ++++++ GPU/GLES/GLES_GPU.cpp | 4 ++++ GPU/GLES/GLES_GPU.h | 7 ++++--- GPU/GLES/TransformPipeline.h | 6 ++++++ GPU/GPUCommon.cpp | 2 ++ GPU/GPUCommon.h | 2 ++ 8 files changed, 33 insertions(+), 6 deletions(-) diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 04e1391d4a..f4acb85add 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -621,6 +621,11 @@ void DIRECTX9_GPU::FastRunLoop(DisplayList &list) { } } +void DIRECTX9_GPU::FinishDeferred() { + // This finishes reading any vertex data that is pending. + transformDraw_.FinishDeferred(); +} + void DIRECTX9_GPU::ProcessEvent(GPUEvent ev) { switch (ev.type) { case GPU_EVENT_INIT_CLEAR: diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 8b093d310a..290ad14300 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -144,9 +144,10 @@ public: void Execute_BoneMtxData(u32 op, u32 diff); protected: - virtual void FastRunLoop(DisplayList &list); - virtual void ProcessEvent(GPUEvent ev); - virtual void FastLoadBoneMatrix(u32 target); + void FastRunLoop(DisplayList &list) override; + void ProcessEvent(GPUEvent ev) override; + void FastLoadBoneMatrix(u32 target) override; + void FinishDeferred() override; private: void UpdateCmdInfo(); diff --git a/GPU/Directx9/TransformPipelineDX9.h b/GPU/Directx9/TransformPipelineDX9.h index 47f1133de5..37dbdfcd3d 100644 --- a/GPU/Directx9/TransformPipelineDX9.h +++ b/GPU/Directx9/TransformPipelineDX9.h @@ -171,6 +171,12 @@ public: DoFlush(); } + void FinishDeferred() { + if (!numDrawCalls) + return; + DecodeVerts(); + } + bool IsCodePtrVertexDecoder(const u8 *ptr) const; protected: diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index d8caced3e9..6b93fe6537 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -705,6 +705,10 @@ void GLES_GPU::FastRunLoop(DisplayList &list) { downcount = 0; } +void GLES_GPU::FinishDeferred() { + // This finishes reading any vertex data that is pending. + transformDraw_.FinishDeferred(); +} void GLES_GPU::ProcessEvent(GPUEvent ev) { switch (ev.type) { diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index c9937951b1..814f08065c 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -146,9 +146,10 @@ public: void Execute_BlockTransferStart(u32 op, u32 diff); protected: - virtual void FastRunLoop(DisplayList &list); - virtual void ProcessEvent(GPUEvent ev); - virtual void FastLoadBoneMatrix(u32 target); + void FastRunLoop(DisplayList &list) override; + void ProcessEvent(GPUEvent ev) override; + void FastLoadBoneMatrix(u32 target) override; + void FinishDeferred() override; private: void Flush() { diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index a91d2f264e..34fcb6bcc6 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -174,6 +174,12 @@ public: DoFlush(); } + void FinishDeferred() { + if (!numDrawCalls) + return; + DecodeVerts(); + } + bool IsCodePtrVertexDecoder(const u8 *ptr) const; protected: diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 51a0453032..a8e3c5bbfa 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -533,6 +533,8 @@ bool GPUCommon::InterpretList(DisplayList &list) { } } + FinishDeferred(); + // We haven't run the op at list.pc, so it shouldn't count. if (cycleLastPC != list.pc) { UpdatePC(list.pc - 4, list.pc); diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index ab0967b5be..fe09c08edd 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -139,6 +139,8 @@ protected: virtual bool ShouldExitEventLoop() { return coreState != CORE_RUNNING; } + virtual void FinishDeferred() { + } // Allows early unlocking with a guard. Do not double unlock. class easy_guard {