From dc5c0c0d2da5d3368fd55a4765be13a29e1a76c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 21 Dec 2016 19:58:10 +0100 Subject: [PATCH] Centralize ProcessEvent --- GPU/Directx9/GPU_DX9.cpp | 35 ----------------------------------- GPU/Directx9/GPU_DX9.h | 8 ++++---- GPU/GLES/GPU_GLES.cpp | 39 --------------------------------------- GPU/GLES/GPU_GLES.h | 11 ++++++----- GPU/GPUCommon.cpp | 29 +++++++++++++++++++++++++++++ GPU/GPUCommon.h | 5 +++++ GPU/Vulkan/GPU_Vulkan.cpp | 39 --------------------------------------- GPU/Vulkan/GPU_Vulkan.h | 10 ++++------ 8 files changed, 48 insertions(+), 128 deletions(-) diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index cec624d44e..cbec9370e3 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -670,41 +670,6 @@ void GPU_DX9::FinishDeferred() { drawEngine_.FinishDeferred(); } -void GPU_DX9::ProcessEvent(GPUEvent ev) { - switch (ev.type) { - case GPU_EVENT_INIT_CLEAR: - InitClearInternal(); - break; - - case GPU_EVENT_BEGIN_FRAME: - BeginFrameInternal(); - break; - - case GPU_EVENT_COPY_DISPLAY_TO_OUTPUT: - CopyDisplayToOutputInternal(); - break; - - case GPU_EVENT_INVALIDATE_CACHE: - InvalidateCacheInternal(ev.invalidate_cache.addr, ev.invalidate_cache.size, ev.invalidate_cache.type); - break; - - case GPU_EVENT_FB_MEMCPY: - PerformMemoryCopyInternal(ev.fb_memcpy.dst, ev.fb_memcpy.src, ev.fb_memcpy.size); - break; - - case GPU_EVENT_FB_MEMSET: - PerformMemorySetInternal(ev.fb_memset.dst, ev.fb_memset.v, ev.fb_memset.size); - break; - - case GPU_EVENT_FB_STENCIL_UPLOAD: - PerformStencilUploadInternal(ev.fb_stencil_upload.dst, ev.fb_stencil_upload.size); - break; - - default: - GPUCommon::ProcessEvent(ev); - } -} - inline void GPU_DX9::CheckFlushOp(int cmd, u32 diff) { const u8 cmdFlags = cmdInfo_[cmd].flags; if ((cmdFlags & FLAG_FLUSHBEFORE) || (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE))) { diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 8b8e4f7c15..a1bf7ac22a 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -143,7 +143,6 @@ public: protected: void FastRunLoop(DisplayList &list) override; - void ProcessEvent(GPUEvent ev) override; void FastLoadBoneMatrix(u32 target) override; void FinishDeferred() override; @@ -156,9 +155,10 @@ private: // void ApplyDrawState(int prim); void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo(); - void InitClearInternal(); - void BeginFrameInternal(); - void CopyDisplayToOutputInternal(); + + void InitClearInternal() override; + void BeginFrameInternal() override; + void CopyDisplayToOutputInternal() override; FramebufferManagerDX9 *framebufferManagerDX9_; TextureCacheDX9 *textureCacheDX9_; diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index bcc594d5b4..5a1215a7bc 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -863,45 +863,6 @@ void GPU_GLES::FinishDeferred() { drawEngine_.FinishDeferred(); } -void GPU_GLES::ProcessEvent(GPUEvent ev) { - switch (ev.type) { - case GPU_EVENT_INIT_CLEAR: - InitClearInternal(); - break; - - case GPU_EVENT_BEGIN_FRAME: - BeginFrameInternal(); - break; - - case GPU_EVENT_COPY_DISPLAY_TO_OUTPUT: - CopyDisplayToOutputInternal(); - break; - - case GPU_EVENT_INVALIDATE_CACHE: - InvalidateCacheInternal(ev.invalidate_cache.addr, ev.invalidate_cache.size, ev.invalidate_cache.type); - break; - - case GPU_EVENT_FB_MEMCPY: - PerformMemoryCopyInternal(ev.fb_memcpy.dst, ev.fb_memcpy.src, ev.fb_memcpy.size); - break; - - case GPU_EVENT_FB_MEMSET: - PerformMemorySetInternal(ev.fb_memset.dst, ev.fb_memset.v, ev.fb_memset.size); - break; - - case GPU_EVENT_FB_STENCIL_UPLOAD: - PerformStencilUploadInternal(ev.fb_stencil_upload.dst, ev.fb_stencil_upload.size); - break; - - case GPU_EVENT_REINITIALIZE: - ReinitializeInternal(); - break; - - default: - GPUCommon::ProcessEvent(ev); - } -} - inline void GPU_GLES::CheckFlushOp(int cmd, u32 diff) { const u8 cmdFlags = cmdInfo_[cmd].flags; if ((cmdFlags & FLAG_FLUSHBEFORE) || (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE))) { diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index 9abedb937e..774f6ba208 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -149,7 +149,6 @@ public: protected: void FastRunLoop(DisplayList &list) override; - void ProcessEvent(GPUEvent ev) override; void FastLoadBoneMatrix(u32 target) override; void FinishDeferred() override; @@ -159,10 +158,12 @@ private: } void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo(); - void InitClearInternal(); - void BeginFrameInternal(); - void CopyDisplayToOutputInternal(); - void ReinitializeInternal(); + + void InitClearInternal() override; + void BeginFrameInternal() override; + void CopyDisplayToOutputInternal() override; + void ReinitializeInternal() override; + inline void UpdateVsyncInterval(bool force); void UpdateCmdInfo(); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index e7368add32..7e8bb73202 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -698,8 +698,37 @@ void GPUCommon::ProcessEvent(GPUEvent ev) { ReapplyGfxStateInternal(); break; + case GPU_EVENT_INIT_CLEAR: + InitClearInternal(); + break; + + case GPU_EVENT_BEGIN_FRAME: + BeginFrameInternal(); + break; + + case GPU_EVENT_COPY_DISPLAY_TO_OUTPUT: + CopyDisplayToOutputInternal(); + break; + + case GPU_EVENT_INVALIDATE_CACHE: + InvalidateCacheInternal(ev.invalidate_cache.addr, ev.invalidate_cache.size, ev.invalidate_cache.type); + break; + + case GPU_EVENT_FB_MEMCPY: + PerformMemoryCopyInternal(ev.fb_memcpy.dst, ev.fb_memcpy.src, ev.fb_memcpy.size); + break; + + case GPU_EVENT_FB_MEMSET: + PerformMemorySetInternal(ev.fb_memset.dst, ev.fb_memset.v, ev.fb_memset.size); + break; + + case GPU_EVENT_FB_STENCIL_UPLOAD: + PerformStencilUploadInternal(ev.fb_stencil_upload.dst, ev.fb_stencil_upload.size); + break; + default: ERROR_LOG_REPORT(G3D, "Unexpected GPU event type: %d", (int)ev); + break; } } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index bb9871031b..271373f5a9 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -151,6 +151,11 @@ public: } protected: + virtual void InitClearInternal() {} + virtual void BeginFrameInternal() {} + virtual void CopyDisplayToOutputInternal() {} + virtual void ReinitializeInternal() {} + // To avoid virtual calls to PreExecuteOp(). virtual void FastRunLoop(DisplayList &list) = 0; void SlowRunLoop(DisplayList &list); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 691e32f254..f26cacb090 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -722,45 +722,6 @@ void GPU_Vulkan::FastRunLoop(DisplayList &list) { void GPU_Vulkan::FinishDeferred() { } -void GPU_Vulkan::ProcessEvent(GPUEvent ev) { - switch (ev.type) { - case GPU_EVENT_INIT_CLEAR: - InitClearInternal(); - break; - - case GPU_EVENT_BEGIN_FRAME: - BeginFrameInternal(); - break; - - case GPU_EVENT_COPY_DISPLAY_TO_OUTPUT: - CopyDisplayToOutputInternal(); - break; - - case GPU_EVENT_INVALIDATE_CACHE: - InvalidateCacheInternal(ev.invalidate_cache.addr, ev.invalidate_cache.size, ev.invalidate_cache.type); - break; - - case GPU_EVENT_FB_MEMCPY: - PerformMemoryCopyInternal(ev.fb_memcpy.dst, ev.fb_memcpy.src, ev.fb_memcpy.size); - break; - - case GPU_EVENT_FB_MEMSET: - PerformMemorySetInternal(ev.fb_memset.dst, ev.fb_memset.v, ev.fb_memset.size); - break; - - case GPU_EVENT_FB_STENCIL_UPLOAD: - PerformStencilUploadInternal(ev.fb_stencil_upload.dst, ev.fb_stencil_upload.size); - break; - - case GPU_EVENT_REINITIALIZE: - ReinitializeInternal(); - break; - - default: - GPUCommon::ProcessEvent(ev); - } -} - inline void GPU_Vulkan::CheckFlushOp(int cmd, u32 diff) { const u8 cmdFlags = cmdInfo_[cmd].flags; if ((cmdFlags & FLAG_FLUSHBEFORE) || (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE))) { diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index e7842dd1cf..837b066f90 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -137,10 +137,8 @@ public: bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) override; bool DescribeCodePtr(const u8 *ptr, std::string &name) override; - protected: void FastRunLoop(DisplayList &list) override; - void ProcessEvent(GPUEvent ev) override; void FastLoadBoneMatrix(u32 target) override; void FinishDeferred() override; @@ -150,10 +148,10 @@ private: } void CheckFlushOp(int cmd, u32 diff); void BuildReportingInfo(); - void InitClearInternal(); - void BeginFrameInternal(); - void CopyDisplayToOutputInternal(); - void ReinitializeInternal(); + void InitClearInternal() override; + void BeginFrameInternal() override; + void CopyDisplayToOutputInternal() override; + void ReinitializeInternal() override; inline void UpdateVsyncInterval(bool force); void UpdateCmdInfo(); static CommandInfo cmdInfo_[256];