summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Rowley <[email protected]>2016-03-22 15:13:29 -0600
committerTim Rowley <[email protected]>2016-03-25 14:45:40 -0500
commit813e89c0cc0ea6a6ed4b69303073995b4c4c7666 (patch)
treee45063939b2ef7f82fbbdfeeebae77a59371569f /src
parent83822d7ed580e764b3e0a6cb773310af2473f062 (diff)
swr: [rasterizer core] Cleanup state ring arena after last draw that references it completes
Rather than waiting for the API thread to re-use it.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/api.cpp6
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/context.h2
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/threads.cpp8
3 files changed, 14 insertions, 2 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 6ebb3f87f7a..591342239d3 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -297,6 +297,8 @@ DRAW_CONTEXT* GetDrawContext(SWR_CONTEXT *pContext, bool isSplitDraw = false)
// Assign unique drawId for this DC
pCurDrawContext->drawId = pContext->dcRing.GetHead();
+
+ pCurDrawContext->cleanupState = true;
}
else
{
@@ -1076,6 +1078,8 @@ void DrawInstanced(
pDC->FeWork.desc.draw.startPrimID = draw * primsPerDraw;
pDC->FeWork.desc.draw.startVertexID = draw * maxVertsPerDraw;
+ pDC->cleanupState = (remainingVerts == numVertsForDraw);
+
//enqueue DC
QueueDraw(pContext);
@@ -1210,6 +1214,8 @@ void DrawIndexedInstance(
pDC->FeWork.desc.draw.baseVertex = baseVertex;
pDC->FeWork.desc.draw.startPrimID = draw * primsPerDraw;
+ pDC->cleanupState = (remainingIndices == numIndicesForDraw);
+
//enqueue DC
QueueDraw(pContext);
diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h
index b8f15cae4a3..39f23372a18 100644
--- a/src/gallium/drivers/swr/rasterizer/core/context.h
+++ b/src/gallium/drivers/swr/rasterizer/core/context.h
@@ -402,6 +402,8 @@ struct DRAW_CONTEXT
CachingArena* pArena;
uint8_t* pSpillFill[KNOB_MAX_NUM_THREADS]; // Scratch space used for spill fills.
+
+ bool cleanupState; // True if this is the last draw using an entry in the state ring.
};
INLINE const API_STATE& GetApiState(const DRAW_CONTEXT* pDC)
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index ce8646fb28d..521a306b96e 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -287,11 +287,15 @@ INLINE void CompleteDrawContext(SWR_CONTEXT* pContext, DRAW_CONTEXT* pDC)
if (result == 0)
{
- _ReadWriteBarrier();
-
// Cleanup memory allocations
pDC->pArena->Reset(true);
pDC->pTileMgr->initialize();
+ if (pDC->cleanupState)
+ {
+ pDC->pState->pArena->Reset(true);
+ }
+
+ _ReadWriteBarrier();
pContext->dcRing.Dequeue(); // Remove from tail
}