From 640d256a2dff0d02dc731edb3c02a3059055dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 2 Jan 2025 13:46:44 +0100 Subject: [PATCH] Rename a couple of member variables to follow our convention --- GPU/Common/DrawEngineCommon.cpp | 50 ++++++++++++++++++++------------- GPU/Common/DrawEngineCommon.h | 14 +++++---- GPU/Common/SplineCommon.cpp | 2 +- GPU/D3D11/DrawEngineD3D11.cpp | 4 +-- GPU/Directx9/DrawEngineDX9.cpp | 2 +- GPU/GLES/DrawEngineGLES.cpp | 4 +-- GPU/Vulkan/DrawEngineVulkan.cpp | 6 ++-- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index b7bc4eb811..c20dcafd00 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -54,7 +54,7 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(32) { transformedExpanded_ = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); decoded_ = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); decIndex_ = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); - indexGen.Setup(decIndex_); + indexGen_.Setup(decIndex_); switch ((DepthRasterMode)g_Config.iDepthRasterMode) { case DepthRasterMode::DEFAULT: @@ -677,7 +677,7 @@ int DrawEngineCommon::ExtendNonIndexedPrim(const uint32_t *cmd, const uint32_t * } void DrawEngineCommon::SkipPrim(GEPrimitiveType prim, int vertexCount, VertexDecoder *dec, u32 vertTypeID, int *bytesRead) { - if (!indexGen.PrimCompatible(prevPrim_, prim)) { + if (!indexGen_.PrimCompatible(prevPrim_, prim)) { Flush(); } @@ -697,7 +697,7 @@ void DrawEngineCommon::SkipPrim(GEPrimitiveType prim, int vertexCount, VertexDec // vertTypeID is the vertex type but with the UVGen mode smashed into the top bits. bool DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, VertexDecoder *dec, u32 vertTypeID, bool clockwise, int *bytesRead) { - if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawVerts_ >= MAX_DEFERRED_DRAW_VERTS || numDrawInds_ >= MAX_DEFERRED_DRAW_INDS || vertexCountInDrawCalls_ + vertexCount > VERTEX_BUFFER_MAX) { + if (!indexGen_.PrimCompatible(prevPrim_, prim) || numDrawVerts_ >= MAX_DEFERRED_DRAW_VERTS || numDrawInds_ >= MAX_DEFERRED_DRAW_INDS || vertexCountInDrawCalls_ + vertexCount > VERTEX_BUFFER_MAX) { Flush(); } _dbg_assert_(numDrawVerts_ < MAX_DEFERRED_DRAW_VERTS); @@ -838,22 +838,22 @@ int DrawEngineCommon::DecodeInds() { // 2. Loop through the drawcalls, translating indices as we go. switch (di.indexType) { case GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT: - indexGen.AddPrim(di.prim, di.vertexCount, indexOffset, clockwise); + indexGen_.AddPrim(di.prim, di.vertexCount, indexOffset, clockwise); break; case GE_VTYPE_IDX_8BIT >> GE_VTYPE_IDX_SHIFT: - indexGen.TranslatePrim(di.prim, di.vertexCount, (const u8 *)di.inds, indexOffset, clockwise); + indexGen_.TranslatePrim(di.prim, di.vertexCount, (const u8 *)di.inds, indexOffset, clockwise); break; case GE_VTYPE_IDX_16BIT >> GE_VTYPE_IDX_SHIFT: - indexGen.TranslatePrim(di.prim, di.vertexCount, (const u16_le *)di.inds, indexOffset, clockwise); + indexGen_.TranslatePrim(di.prim, di.vertexCount, (const u16_le *)di.inds, indexOffset, clockwise); break; case GE_VTYPE_IDX_32BIT >> GE_VTYPE_IDX_SHIFT: - indexGen.TranslatePrim(di.prim, di.vertexCount, (const u32_le *)di.inds, indexOffset, clockwise); + indexGen_.TranslatePrim(di.prim, di.vertexCount, (const u32_le *)di.inds, indexOffset, clockwise); break; } } decodeIndsCounter_ = i; - return indexGen.VertexCount(); + return indexGen_.VertexCount(); } bool DrawEngineCommon::CanUseHardwareTransform(int prim) const { @@ -1001,14 +1001,6 @@ bool DrawEngineCommon::CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim, return true; } -void DrawEngineCommon::EnqueueDepthDraw(const DepthDraw &draw) { - if (depthDraws_.empty()) { - rasterTimeStart_ = time_now_d(); - } - - depthDraws_.push_back(draw); -} - // TODO: Possibly split this in stages, to avoid switching back and forth between clipping and drawing. void DrawEngineCommon::ProcessDepthDraw(const DepthDraw &draw) { int *tx = depthScreenVerts_; @@ -1045,12 +1037,29 @@ void DrawEngineCommon::ProcessDepthDraw(const DepthDraw &draw) { } } -void DrawEngineCommon::FlushQueuedDepth() { - if (rasterTimeStart_ != 0.0) { - gpuStats.msRasterTimeAvailable += time_now_d() - rasterTimeStart_; - rasterTimeStart_ = 0.0; +void DrawEngineCommon::EnqueueDepthDraw(const DepthDraw &draw) { + if (depthDraws_.empty()) { + _dbg_assert_(!inDepthDrawPass_); + + depthRasterPassStart_ = time_now_d(); + inDepthDrawPass_ = true; } + depthDraws_.push_back(draw); +} + +void DrawEngineCommon::FlushQueuedDepth() { + if (!inDepthDrawPass_) { + _dbg_assert_(depthIndexCount_ == 0 && depthVertexCount_ == 0 && depthDraws_.empty()); + return; + } + + _dbg_assert_(depthRasterPassStart_ != 0.0); + gpuStats.msRasterTimeAvailable += time_now_d() - depthRasterPassStart_; + depthRasterPassStart_ = 0.0; + + // TODO: here we should wait for the thread to finish. + for (const auto &draw : depthDraws_) { ProcessDepthDraw(draw); } @@ -1059,6 +1068,7 @@ void DrawEngineCommon::FlushQueuedDepth() { depthIndexCount_ = 0; depthVertexCount_ = 0; depthDraws_.clear(); + inDepthDrawPass_ = false; } void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder *dec, uint32_t vertTypeID, int vertexCount) { diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 9dc7bf42ad..ab1e29d7b3 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -80,7 +80,7 @@ public: virtual void BeginFrame(); void SetGPUCommon(GPUCommon *gpuCommon) { - gpuCommon = gpuCommon; + gpuCommon_ = gpuCommon; } virtual void DeviceLost() = 0; @@ -210,7 +210,7 @@ protected: gpuStats.numVertsSubmitted += vertexCountInDrawCalls_; gpuStats.numVertsDecoded += numDecodedVerts_; - indexGen.Reset(); + indexGen_.Reset(); numDecodedVerts_ = 0; numDrawVerts_ = 0; numDrawInds_ = 0; @@ -327,7 +327,7 @@ protected: bool applySkinInDecode_ = false; // Vertex collector state - IndexGenerator indexGen; + IndexGenerator indexGen_; int numDecodedVerts_ = 0; GEPrimitiveType prevPrim_ = GE_PRIM_INVALID; @@ -340,9 +340,9 @@ protected: ComputedPipelineState pipelineState_; // Hardware tessellation - TessellationDataTransfer *tessDataTransfer = nullptr; + TessellationDataTransfer *tessDataTransfer_ = nullptr; - GPUCommon *gpuCommon_; + GPUCommon *gpuCommon_ = nullptr; // Culling private: @@ -379,5 +379,7 @@ private: int depthIndexCount_ = 0; std::vector depthDraws_; - double rasterTimeStart_ = 0.0; + double depthRasterPassStart_ = 0.0; + + bool inDepthDrawPass_ = false; }; diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index 11a7a25439..496d574aec 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -552,7 +552,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic surface.Init(maxVerts); if (CanUseHardwareTessellation(surface.primType)) { - HardwareTessellation(output, surface, origVertType, points, tessDataTransfer); + HardwareTessellation(output, surface, origVertType, points, tessDataTransfer_); } else { ControlPoints cpoints(points, num_points, managedBuf); if (cpoints.IsValid()) diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index a1238172bd..2fe34cf038 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -82,7 +82,7 @@ void DrawEngineD3D11::InitDeviceObjects() { pushInds_ = new PushBufferD3D11(device_, INDEX_PUSH_SIZE, D3D11_BIND_INDEX_BUFFER); tessDataTransferD3D11 = new TessellationDataTransferD3D11(context_, device_); - tessDataTransfer = tessDataTransferD3D11; + tessDataTransfer_ = tessDataTransferD3D11; draw_->SetInvalidationCallback(std::bind(&DrawEngineD3D11::Invalidate, this, std::placeholders::_1)); } @@ -108,7 +108,7 @@ void DrawEngineD3D11::DestroyDeviceObjects() { ClearInputLayoutMap(); delete tessDataTransferD3D11; tessDataTransferD3D11 = nullptr; - tessDataTransfer = nullptr; + tessDataTransfer_ = nullptr; delete pushVerts_; delete pushInds_; depthStencilCache_.Iterate([&](const uint64_t &key, ID3D11DepthStencilState *ds) { diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index e6d7d3ab51..cb6debe717 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -84,7 +84,7 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : draw_(draw), vertexDeclM InitDeviceObjects(); tessDataTransferDX9 = new TessellationDataTransferDX9(); - tessDataTransfer = tessDataTransferDX9; + tessDataTransfer_ = tessDataTransferDX9; device_->CreateVertexDeclaration(TransformedVertexElements, &transformedVertexDecl_); } diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 42fed50d2e..5ff5d3596e 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -59,7 +59,7 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d InitDeviceObjects(); tessDataTransferGLES = new TessellationDataTransferGLES(render_); - tessDataTransfer = tessDataTransferGLES; + tessDataTransfer_ = tessDataTransferGLES; } DrawEngineGLES::~DrawEngineGLES() { @@ -231,7 +231,7 @@ void DrawEngineGLES::Flush() { // Something went badly wrong. Try to survive by simply skipping the draw, though. _dbg_assert_msg_(false, "Trying to DoFlush while not in a render pass. This is bad."); // can't goto bail here, skips too many variable initializations. So let's wipe the most important stuff. - indexGen.Reset(); + indexGen_.Reset(); numDecodedVerts_ = 0; numDrawVerts_ = 0; numDrawInds_ = 0; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index a456b5d72c..80f1410c7e 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -94,7 +94,7 @@ void DrawEngineVulkan::InitDeviceObjects() { _dbg_assert_(VK_SUCCESS == res); tessDataTransferVulkan = new TessellationDataTransferVulkan(vulkan); - tessDataTransfer = tessDataTransferVulkan; + tessDataTransfer_ = tessDataTransferVulkan; draw_->SetInvalidationCallback(std::bind(&DrawEngineVulkan::Invalidate, this, std::placeholders::_1)); } @@ -115,7 +115,7 @@ void DrawEngineVulkan::DestroyDeviceObjects() { draw_->SetInvalidationCallback(InvalidationCallback()); delete tessDataTransferVulkan; - tessDataTransfer = nullptr; + tessDataTransfer_ = nullptr; tessDataTransferVulkan = nullptr; pushUBO_ = nullptr; @@ -577,7 +577,7 @@ void DrawEngineVulkan::Flush() { } void DrawEngineVulkan::ResetAfterDraw() { - indexGen.Reset(); + indexGen_.Reset(); numDecodedVerts_ = 0; numDrawVerts_ = 0; numDrawInds_ = 0;