From 18999c3687d458ae5e691a7149e3e8c2073b6e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 25 Feb 2023 14:24:59 +0100 Subject: [PATCH] Create the GPUCommonHW class. --- CMakeLists.txt | 2 ++ GPU/D3D11/GPU_D3D11.cpp | 2 +- GPU/D3D11/GPU_D3D11.h | 6 ++---- GPU/Directx9/GPU_DX9.cpp | 2 +- GPU/Directx9/GPU_DX9.h | 4 ++-- GPU/GLES/GPU_GLES.cpp | 2 +- GPU/GLES/GPU_GLES.h | 4 ++-- GPU/GPU.vcxproj | 2 ++ GPU/GPU.vcxproj.filters | 6 ++++++ GPU/GPUCommon.cpp | 4 ---- GPU/GPUCommon.h | 2 +- GPU/GPUCommonHW.cpp | 13 +++++++++++++ GPU/GPUCommonHW.h | 16 ++++++++++++++++ GPU/Software/SoftGpu.h | 1 - GPU/Vulkan/GPU_Vulkan.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.h | 4 ++-- UWP/GPU_UWP/GPU_UWP.vcxproj | 2 ++ UWP/GPU_UWP/GPU_UWP.vcxproj.filters | 2 ++ android/jni/Android.mk | 1 + libretro/Makefile.common | 1 + 20 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 GPU/GPUCommonHW.cpp create mode 100644 GPU/GPUCommonHW.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fadd2853c7..20cd4d0e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1659,6 +1659,8 @@ set(GPU_SOURCES GPU/GPU.h GPU/GPUCommon.cpp GPU/GPUCommon.h + GPU/GPUCommonHW.cpp + GPU/GPUCommonHW.h GPU/GPUState.cpp GPU/GPUState.h GPU/Math3D.cpp diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index a9c6632a88..dd87755570 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -42,7 +42,7 @@ #include "GPU/D3D11/D3D11Util.h" GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw) - : GPUCommon(gfxCtx, draw), drawEngine_(draw, + : GPUCommonHW(gfxCtx, draw), drawEngine_(draw, (ID3D11Device *)draw->GetNativeObject(Draw::NativeObject::DEVICE), (ID3D11DeviceContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT)) { device_ = (ID3D11Device *)draw->GetNativeObject(Draw::NativeObject::DEVICE); diff --git a/GPU/D3D11/GPU_D3D11.h b/GPU/D3D11/GPU_D3D11.h index cdb3ddbfb7..7a6418bb34 100644 --- a/GPU/D3D11/GPU_D3D11.h +++ b/GPU/D3D11/GPU_D3D11.h @@ -21,17 +21,15 @@ #include #include -#include "GPU/GPUCommon.h" +#include "GPU/GPUCommonHW.h" #include "GPU/D3D11/DrawEngineD3D11.h" -#include "GPU/Common/TextureShaderCommon.h" #include "GPU/Common/VertexDecoderCommon.h" class FramebufferManagerD3D11; class ShaderManagerD3D11; -class LinkedShaderD3D11; class TextureCacheD3D11; -class GPU_D3D11 : public GPUCommon { +class GPU_D3D11 : public GPUCommonHW { public: GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw); ~GPU_D3D11(); diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 90f7e1a0dd..d0ad42dfc5 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -44,7 +44,7 @@ #include "GPU/Directx9/TextureCacheDX9.h" GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw) - : GPUCommon(gfxCtx, draw), + : GPUCommonHW(gfxCtx, draw), drawEngine_(draw) { device_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE); deviceEx_ = (LPDIRECT3DDEVICE9EX)draw->GetNativeObject(Draw::NativeObject::DEVICE_EX); diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index 218145ab15..a1e5c1102c 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -20,7 +20,7 @@ #include #include -#include "GPU/GPUCommon.h" +#include "GPU/GPUCommonHW.h" #include "GPU/Directx9/FramebufferManagerDX9.h" #include "GPU/Directx9/DrawEngineDX9.h" #include "GPU/Common/TextureShaderCommon.h" @@ -30,7 +30,7 @@ class ShaderManagerDX9; class LinkedShaderDX9; class TextureCacheDX9; -class GPU_DX9 : public GPUCommon { +class GPU_DX9 : public GPUCommonHW { public: GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw); ~GPU_DX9(); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index f63c61dd59..6cffceb53d 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -48,7 +48,7 @@ #endif GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) - : GPUCommon(gfxCtx, draw), drawEngine_(draw), fragmentTestCache_(draw) { + : GPUCommonHW(gfxCtx, draw), drawEngine_(draw), fragmentTestCache_(draw) { UpdateVsyncInterval(true); gstate_c.SetUseFlags(CheckGPUFeatures()); diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index ff9bc1373b..8cb6be8fc7 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -22,7 +22,7 @@ #include "Common/File/Path.h" -#include "GPU/GPUCommon.h" +#include "GPU/GPUCommonHW.h" #include "GPU/Common/TextureShaderCommon.h" #include "GPU/GLES/FramebufferManagerGLES.h" #include "GPU/GLES/DrawEngineGLES.h" @@ -32,7 +32,7 @@ class ShaderManagerGLES; class TextureCacheGLES; class LinkedShader; -class GPU_GLES : public GPUCommon { +class GPU_GLES : public GPUCommonHW { public: GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw); ~GPU_GLES(); diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 625bfb112c..606e169859 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -427,6 +427,7 @@ + @@ -572,6 +573,7 @@ + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index e30366acb3..b34942e06c 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -264,6 +264,9 @@ Common + + Common + @@ -524,6 +527,9 @@ Common + + Common + diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 0725563bc0..8f8c410fa1 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1410,10 +1410,6 @@ void GPUCommon::ProcessDLQueue() { // Since the event is in CoreTiming, we're in sync. Just set 0 now. } -void GPUCommon::PreExecuteOp(u32 op, u32 diff) { - CheckFlushOp(op >> 24, diff); -} - void GPUCommon::Execute_OffsetAddr(u32 op, u32 diff) { gstate_c.offsetAddr = op << 8; } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 92c8d0d0ae..ddc955a237 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -109,7 +109,7 @@ public: void DumpNextFrame() override; void ExecuteOp(u32 op, u32 diff) override; - virtual void PreExecuteOp(u32 op, u32 diff); + virtual void PreExecuteOp(u32 op, u32 diff) {} bool InterpretList(DisplayList &list); void ProcessDLQueue(); diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp new file mode 100644 index 0000000000..e1438db9db --- /dev/null +++ b/GPU/GPUCommonHW.cpp @@ -0,0 +1,13 @@ +#include "Common/GPU/thin3d.h" +#include "GPU/GPUCommonHW.h" + + +GPUCommonHW::GPUCommonHW(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw) { + +} + +GPUCommonHW::~GPUCommonHW() {} + +void GPUCommonHW::PreExecuteOp(u32 op, u32 diff) { + CheckFlushOp(op >> 24, diff); +} diff --git a/GPU/GPUCommonHW.h b/GPU/GPUCommonHW.h new file mode 100644 index 0000000000..9efe41d80b --- /dev/null +++ b/GPU/GPUCommonHW.h @@ -0,0 +1,16 @@ +#pragma once + +#include "GPUCommon.h" + +// Shared GPUCommon implementation for the HW backends. +// Things that are irrelevant for SoftGPU should live here. +class GPUCommonHW : public GPUCommon { +public: + GPUCommonHW(GraphicsContext *gfxCtx, Draw::DrawContext *draw); + ~GPUCommonHW(); + +protected: + void PreExecuteOp(u32 op, u32 diff); + +}; + diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index f60f26a9b1..2496c7b474 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -210,7 +210,6 @@ protected: void ConvertTextureDescFrom16(Draw::TextureDesc &desc, int srcwidth, int srcheight, const uint16_t *overrideData = nullptr); void BuildReportingInfo() override {} - void PreExecuteOp(u32 op, u32 diff) override {} private: void MarkDirty(uint32_t addr, uint32_t stride, uint32_t height, GEBufferFormat fmt, SoftGPUVRAMDirty value); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 54953c879b..513a2906d6 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -46,7 +46,7 @@ #include "Common/GPU/Vulkan/VulkanQueueRunner.h" GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) - : GPUCommon(gfxCtx, draw), drawEngine_(draw) { + : GPUCommonHW(gfxCtx, draw), drawEngine_(draw) { gstate_c.SetUseFlags(CheckGPUFeatures()); drawEngine_.InitDeviceObjects(); diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index 58e1726f20..c2bb6bf73b 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -22,7 +22,7 @@ #include "Common/File/Path.h" -#include "GPU/GPUCommon.h" +#include "GPU/GPUCommonHW.h" #include "GPU/Vulkan/DrawEngineVulkan.h" #include "GPU/Vulkan/PipelineManagerVulkan.h" #include "GPU/Common/TextureShaderCommon.h" @@ -32,7 +32,7 @@ class ShaderManagerVulkan; class LinkedShader; class TextureCacheVulkan; -class GPU_Vulkan : public GPUCommon { +class GPU_Vulkan : public GPUCommonHW { public: GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw); ~GPU_Vulkan(); diff --git a/UWP/GPU_UWP/GPU_UWP.vcxproj b/UWP/GPU_UWP/GPU_UWP.vcxproj index 0b8ed0070f..03ce6c90bb 100644 --- a/UWP/GPU_UWP/GPU_UWP.vcxproj +++ b/UWP/GPU_UWP/GPU_UWP.vcxproj @@ -423,6 +423,7 @@ + @@ -487,6 +488,7 @@ + diff --git a/UWP/GPU_UWP/GPU_UWP.vcxproj.filters b/UWP/GPU_UWP/GPU_UWP.vcxproj.filters index 2481c765c9..dc746a6f6d 100644 --- a/UWP/GPU_UWP/GPU_UWP.vcxproj.filters +++ b/UWP/GPU_UWP/GPU_UWP.vcxproj.filters @@ -61,6 +61,7 @@ + @@ -123,5 +124,6 @@ + \ No newline at end of file diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 9c7912881b..9af8d57b17 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -358,6 +358,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/Math3D.cpp \ $(SRC)/GPU/GPU.cpp \ $(SRC)/GPU/GPUCommon.cpp \ + $(SRC)/GPU/GPUCommonHW.cpp \ $(SRC)/GPU/GPUState.cpp \ $(SRC)/GPU/GeConstants.cpp \ $(SRC)/GPU/GeDisasm.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index e734a43415..7e602464b4 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -406,6 +406,7 @@ SOURCES_CXX += \ $(GPUDIR)/GeConstants.cpp \ $(GPUDIR)/GeDisasm.cpp \ $(GPUDIR)/GPUCommon.cpp \ + $(GPUDIR)/GPUCommonHW.cpp \ $(GPUDIR)/GPU.cpp \ $(GPUDIR)/GPUState.cpp \ $(GPUDIR)/Math3D.cpp \