From 8cef1f0f8dab4cb3f8f629c271a1cb27ff8a0fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 26 Feb 2018 11:44:02 +0100 Subject: [PATCH] GPU: Unify command table (cmdInfo_) --- GPU/D3D11/GPU_D3D11.cpp | 27 --------------------------- GPU/D3D11/GPU_D3D11.h | 8 -------- GPU/Directx9/GPU_DX9.cpp | 27 --------------------------- GPU/Directx9/GPU_DX9.h | 8 -------- GPU/GLES/GPU_GLES.cpp | 27 --------------------------- GPU/GLES/GPU_GLES.h | 8 -------- GPU/GPUCommon.cpp | 27 +++++++++++++++++++++++++++ GPU/GPUCommon.h | 8 ++++++++ GPU/Vulkan/GPU_Vulkan.cpp | 26 -------------------------- GPU/Vulkan/GPU_Vulkan.h | 8 -------- 10 files changed, 35 insertions(+), 139 deletions(-) diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 4c8a3d591e..eabd5d3507 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -66,8 +66,6 @@ #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceGe.h" -GPU_D3D11::CommandInfo GPU_D3D11::cmdInfo_[256]{}; - GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), drawEngine_(draw, (ID3D11Device *)draw->GetNativeObject(Draw::NativeObject::DEVICE), @@ -103,31 +101,6 @@ GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw) ERROR_LOG(G3D, "gstate has drifted out of sync!"); } - memset(cmdInfo_, 0, sizeof(cmdInfo_)); - - // Import both the global and local command tables, and check for dupes - std::set dupeCheck; - for (size_t i = 0; i < commonCommandTableSize; i++) { - const u8 cmd = commonCommandTable[i].cmd; - if (dupeCheck.find(cmd) != dupeCheck.end()) { - ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd); - } else { - dupeCheck.insert(cmd); - } - cmdInfo_[cmd].flags |= (uint64_t)commonCommandTable[i].flags | (commonCommandTable[i].dirty << 8); - cmdInfo_[cmd].func = commonCommandTable[i].func; - if ((cmdInfo_[cmd].flags & (FLAG_EXECUTE | FLAG_EXECUTEONCHANGE)) && !cmdInfo_[cmd].func) { - Crash(); - } - } - - // Find commands missing from the table. - for (int i = 0; i < 0xEF; i++) { - if (dupeCheck.find((u8)i) == dupeCheck.end()) { - ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i); - } - } - // No need to flush before the tex scale/offset commands if we are baking // the tex scale/offset into the vertices anyway. UpdateCmdInfo(); diff --git a/GPU/D3D11/GPU_D3D11.h b/GPU/D3D11/GPU_D3D11.h index 28eeccb522..c9cb6bad2f 100644 --- a/GPU/D3D11/GPU_D3D11.h +++ b/GPU/D3D11/GPU_D3D11.h @@ -58,12 +58,6 @@ public: fullInfo = reportingFullInfo_; } - typedef void (GPU_D3D11::*CmdFunc)(u32 op, u32 diff); - struct CommandInfo { - uint64_t flags; - GPU_D3D11::CmdFunc func; - }; - // Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend. std::vector DebugGetShaderIDs(DebugShaderType shader) override; std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override; @@ -98,8 +92,6 @@ private: DrawEngineD3D11 drawEngine_; ShaderManagerD3D11 *shaderManagerD3D11_; - static CommandInfo cmdInfo_[256]; - int lastVsync_; int vertexCost_ = 0; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 3704269b25..504ab226c1 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -50,8 +50,6 @@ namespace DX9 { -GPU_DX9::CommandInfo GPU_DX9::cmdInfo_[256]; - GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), depalShaderCache_(draw), @@ -85,31 +83,6 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw) ERROR_LOG(G3D, "gstate has drifted out of sync!"); } - memset(cmdInfo_, 0, sizeof(cmdInfo_)); - - // Import both the global and local command tables, and check for dupes - std::set dupeCheck; - for (size_t i = 0; i < commonCommandTableSize; i++) { - const u8 cmd = commonCommandTable[i].cmd; - if (dupeCheck.find(cmd) != dupeCheck.end()) { - ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd); - } else { - dupeCheck.insert(cmd); - } - cmdInfo_[cmd].flags |= (uint64_t)commonCommandTable[i].flags | (commonCommandTable[i].dirty << 8); - cmdInfo_[cmd].func = commonCommandTable[i].func; - if ((cmdInfo_[cmd].flags & (FLAG_EXECUTE | FLAG_EXECUTEONCHANGE)) && !cmdInfo_[cmd].func) { - Crash(); - } - } - - // Find commands missing from the table. - for (int i = 0; i < 0xEF; i++) { - if (dupeCheck.find((u8)i) == dupeCheck.end()) { - ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i); - } - } - // No need to flush before the tex scale/offset commands if we are baking // the tex scale/offset into the vertices anyway. UpdateCmdInfo(); diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 9ea2f95c1e..9a168628f3 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -59,12 +59,6 @@ public: fullInfo = reportingFullInfo_; } - typedef void (GPU_DX9::*CmdFunc)(u32 op, u32 diff); - struct CommandInfo { - uint64_t flags; - GPU_DX9::CmdFunc func; - }; - // Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend. std::vector DebugGetShaderIDs(DebugShaderType shader) override; std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override; @@ -98,8 +92,6 @@ private: DrawEngineDX9 drawEngine_; ShaderManagerDX9 *shaderManagerDX9_; - static CommandInfo cmdInfo_[256]; - int lastVsync_; int vertexCost_ = 0; diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index ea6c6a17ec..b73caca731 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -51,8 +51,6 @@ #include "Windows/GPU/WindowsGLContext.h" #endif -GPU_GLES::CommandInfo GPU_GLES::cmdInfo_[256]; - GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), drawEngine_(draw), fragmentTestCache_(draw), depalShaderCache_(draw) { UpdateVsyncInterval(true); @@ -88,31 +86,6 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) ERROR_LOG(G3D, "gstate has drifted out of sync!"); } - memset(cmdInfo_, 0, sizeof(cmdInfo_)); - - // Import both the global and local command tables, and check for dupes - std::set dupeCheck; - for (size_t i = 0; i < commonCommandTableSize; i++) { - const u8 cmd = commonCommandTable[i].cmd; - if (dupeCheck.find(cmd) != dupeCheck.end()) { - ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd); - } else { - dupeCheck.insert(cmd); - } - cmdInfo_[cmd].flags |= (uint64_t)commonCommandTable[i].flags | (commonCommandTable[i].dirty << 8); - cmdInfo_[cmd].func = commonCommandTable[i].func; - if ((cmdInfo_[cmd].flags & (FLAG_EXECUTE | FLAG_EXECUTEONCHANGE)) && !cmdInfo_[cmd].func) { - Crash(); - } - } - - // Find commands missing from the table. - for (int i = 0; i < 0xEF; i++) { - if (dupeCheck.find((u8)i) == dupeCheck.end()) { - ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i); - } - } - // No need to flush before the tex scale/offset commands if we are baking // the tex scale/offset into the vertices anyway. diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index d6ed19083d..0184ab604d 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -63,12 +63,6 @@ public: fullInfo = reportingFullInfo_; } - typedef void (GPU_GLES::*CmdFunc)(u32 op, u32 diff); - struct CommandInfo { - uint64_t flags; - GPU_GLES::CmdFunc func; - }; - // Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend. std::vector DebugGetShaderIDs(DebugShaderType shader) override; std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override; @@ -95,8 +89,6 @@ private: inline void UpdateVsyncInterval(bool force); void UpdateCmdInfo(); - static CommandInfo cmdInfo_[256]; - FramebufferManagerGLES *framebufferManagerGL_; TextureCacheGLES *textureCacheGL_; DepalShaderCacheGLES depalShaderCache_; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index f92920ffd3..e63411c5b0 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -352,6 +352,9 @@ const CommonCommandTableEntry commonCommandTable[] = { }; size_t commonCommandTableSize = ARRAY_SIZE(commonCommandTable); +// TODO: Make class member? +GPUCommon::CommandInfo GPUCommon::cmdInfo_[256]; + void GPUCommon::Flush() { drawEngineCommon_->DispatchFlush(); } @@ -375,6 +378,30 @@ GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : gstate.Reset(); gstate_c.Reset(); gpuStats.Reset(); + + memset(cmdInfo_, 0, sizeof(cmdInfo_)); + + // Import both the global and local command tables, and check for dupes + std::set dupeCheck; + for (size_t i = 0; i < commonCommandTableSize; i++) { + const u8 cmd = commonCommandTable[i].cmd; + if (dupeCheck.find(cmd) != dupeCheck.end()) { + ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd); + } else { + dupeCheck.insert(cmd); + } + cmdInfo_[cmd].flags |= (uint64_t)commonCommandTable[i].flags | (commonCommandTable[i].dirty << 8); + cmdInfo_[cmd].func = commonCommandTable[i].func; + if ((cmdInfo_[cmd].flags & (FLAG_EXECUTE | FLAG_EXECUTEONCHANGE)) && !cmdInfo_[cmd].func) { + Crash(); + } + } + // Find commands missing from the table. + for (int i = 0; i < 0xEF; i++) { + if (dupeCheck.find((u8)i) == dupeCheck.end()) { + ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i); + } + } } GPUCommon::~GPUCommon() { diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index b19077e3c0..f203660216 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -295,6 +295,14 @@ protected: GraphicsContext *gfxCtx_; Draw::DrawContext *draw_; + typedef void (GPUCommon::*CmdFunc)(u32 op, u32 diff); + struct CommandInfo { + uint64_t flags; + GPUCommon::CmdFunc func; + }; + + static CommandInfo cmdInfo_[256]; + typedef std::list DisplayListQueue; int nextListID; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 4e05af6bc6..8f7dd68c1c 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -46,8 +46,6 @@ #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceGe.h" -GPU_Vulkan::CommandInfo GPU_Vulkan::cmdInfo_[256]; - GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), vulkan_((VulkanContext *)gfxCtx->GetAPIContext()), @@ -88,30 +86,6 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) ERROR_LOG(G3D, "gstate has drifted out of sync!"); } - memset(cmdInfo_, 0, sizeof(cmdInfo_)); - - // Import both the global and local command tables, and check for dupes - std::set dupeCheck; - for (size_t i = 0; i < commonCommandTableSize; i++) { - const u8 cmd = commonCommandTable[i].cmd; - if (dupeCheck.find(cmd) != dupeCheck.end()) { - ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd); - } else { - dupeCheck.insert(cmd); - } - cmdInfo_[cmd].flags |= (uint64_t)commonCommandTable[i].flags | (commonCommandTable[i].dirty << 8); - cmdInfo_[cmd].func = commonCommandTable[i].func; - if ((cmdInfo_[cmd].flags & (FLAG_EXECUTE | FLAG_EXECUTEONCHANGE)) && !cmdInfo_[cmd].func) { - Crash(); - } - } - // Find commands missing from the table. - for (int i = 0; i < 0xEF; i++) { - if (dupeCheck.find((u8)i) == dupeCheck.end()) { - ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i); - } - } - UpdateCmdInfo(); BuildReportingInfo(); diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index 81f213bb18..162e9a0992 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -62,12 +62,6 @@ public: fullInfo = reportingFullInfo_; } - typedef void (GPU_Vulkan::*CmdFunc)(u32 op, u32 diff); - struct CommandInfo { - uint64_t flags; - GPU_Vulkan::CmdFunc func; - }; - // Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend. std::vector DebugGetShaderIDs(DebugShaderType shader) override; std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override; @@ -95,8 +89,6 @@ private: void InitDeviceObjects(); void DestroyDeviceObjects(); - static CommandInfo cmdInfo_[256]; - VulkanContext *vulkan_; FramebufferManagerVulkan *framebufferManagerVulkan_; TextureCacheVulkan *textureCacheVulkan_;