Skip to content

Commit

Permalink
Unify the clearing of variables after a draw call
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Oct 6, 2023
1 parent 64ee567 commit 10ccbfd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 83 deletions.
22 changes: 22 additions & 0 deletions GPU/Common/DrawEngineCommon.h
Expand Up @@ -195,6 +195,28 @@ class DrawEngineCommon {
}
}

inline void ResetAfterDrawInline() {
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawInds_;
gpuStats.numVertexDecodes += numDrawVerts_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;

indexGen.Reset();
decodedVerts_ = 0;
numDrawVerts_ = 0;
numDrawInds_ = 0;
vertexCountInDrawCalls_ = 0;
decodeIndsCounter_ = 0;
decodeVertsCounter_ = 0;
gstate_c.vertexFullAlpha = true;

// Now seems as good a time as any to reset the min/max coords, which we may examine later.
gstate_c.vertBounds.minU = 512;
gstate_c.vertBounds.minV = 512;
gstate_c.vertBounds.maxU = 0;
gstate_c.vertBounds.maxV = 0;
}

uint32_t ComputeDrawcallsHash() const;

bool useHWTransform_ = false;
Expand Down
21 changes: 1 addition & 20 deletions GPU/D3D11/DrawEngineD3D11.cpp
Expand Up @@ -725,27 +725,8 @@ void DrawEngineD3D11::DoFlush() {
decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning;
}

gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawInds_;
gpuStats.numVertexDecodes += numDrawVerts_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;

indexGen.Reset();
decodedVerts_ = 0;
numDrawVerts_ = 0;
numDrawInds_ = 0;
vertexCountInDrawCalls_ = 0;
decodeVertsCounter_ = 0;
decodeIndsCounter_ = 0;
gstate_c.vertexFullAlpha = true;
ResetAfterDrawInline();
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);

// Now seems as good a time as any to reset the min/max coords, which we may examine later.
gstate_c.vertBounds.minU = 512;
gstate_c.vertBounds.minV = 512;
gstate_c.vertBounds.maxU = 0;
gstate_c.vertBounds.maxV = 0;

GPUDebug::NotifyDraw();
}

Expand Down
23 changes: 1 addition & 22 deletions GPU/Directx9/DrawEngineDX9.cpp
Expand Up @@ -666,29 +666,8 @@ void DrawEngineDX9::DoFlush() {
decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning;
}

gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawInds_;
gpuStats.numVertexDecodes += numDrawVerts_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;

// TODO: The below should be shared.

indexGen.Reset();
decodedVerts_ = 0;
numDrawVerts_ = 0;
numDrawInds_ = 0;
vertexCountInDrawCalls_ = 0;
decodeVertsCounter_ = 0;
decodeIndsCounter_ = 0;
gstate_c.vertexFullAlpha = true;
ResetAfterDrawInline();
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);

// Now seems as good a time as any to reset the min/max coords, which we may examine later.
gstate_c.vertBounds.minU = 512;
gstate_c.vertBounds.minV = 512;
gstate_c.vertBounds.maxU = 0;
gstate_c.vertBounds.maxV = 0;

GPUDebug::NotifyDraw();
}

Expand Down
24 changes: 1 addition & 23 deletions GPU/GLES/DrawEngineGLES.cpp
Expand Up @@ -473,30 +473,8 @@ void DrawEngineGLES::DoFlush() {
}

bail:
gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawInds_;
gpuStats.numVertexDecodes += numDrawVerts_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;

// TODO: When the next flush has the same vertex format, we can continue with the same offset in the vertex buffer,
// and start indexing from a higher value. This is very friendly to OpenGL (where we can't rely on baseindex if we
// wanted to avoid rebinding the vertex input every time).
indexGen.Reset();
decodedVerts_ = 0;
numDrawVerts_ = 0;
numDrawInds_ = 0;
vertexCountInDrawCalls_ = 0;
decodeVertsCounter_ = 0;
decodeIndsCounter_ = 0;
gstate_c.vertexFullAlpha = true;
ResetAfterDrawInline();
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);

// Now seems as good a time as any to reset the min/max coords, which we may examine later.
gstate_c.vertBounds.minU = 512;
gstate_c.vertBounds.minV = 512;
gstate_c.vertBounds.maxU = 0;
gstate_c.vertBounds.maxV = 0;

GPUDebug::NotifyDraw();
}

Expand Down
19 changes: 1 addition & 18 deletions GPU/Vulkan/DrawEngineVulkan.cpp
Expand Up @@ -1014,27 +1014,10 @@ void DrawEngineVulkan::DoFlush() {
decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning;
}

gpuStats.numFlushes++;
gpuStats.numDrawCalls += numDrawInds_;
gpuStats.numVertexDecodes += numDrawVerts_;
gpuStats.numVertsSubmitted += vertexCountInDrawCalls_;
ResetAfterDrawInline();

indexGen.Reset();
decodedVerts_ = 0;
numDrawVerts_ = 0;
numDrawInds_ = 0;
vertexCountInDrawCalls_ = 0;
decodeIndsCounter_ = 0;
decodeVertsCounter_ = 0;
gstate_c.vertexFullAlpha = true;
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);

// Now seems as good a time as any to reset the min/max coords, which we may examine later.
gstate_c.vertBounds.minU = 512;
gstate_c.vertBounds.minV = 512;
gstate_c.vertBounds.maxU = 0;
gstate_c.vertBounds.maxV = 0;

GPUDebug::NotifyDraw();
}

Expand Down

0 comments on commit 10ccbfd

Please sign in to comment.