swr: [rasterizer core] Cleanup state ring arena after last draw that references it...
authorTim Rowley <timothy.o.rowley@intel.com>
Tue, 22 Mar 2016 21:13:29 +0000 (15:13 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 25 Mar 2016 19:45:40 +0000 (14:45 -0500)
Rather than waiting for the API thread to re-use it.

src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/context.h
src/gallium/drivers/swr/rasterizer/core/threads.cpp

index 6ebb3f87f7a280eae34153fd5ed2aaabd4b36274..591342239d30bbf175a530ba86db66dcff02c534 100644 (file)
@@ -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);
 
index b8f15cae4a325ca2c0b71ae689ab7966dfbf77de..39f23372a18e04e52795913d83370ff4f42a304b 100644 (file)
@@ -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)
index ce8646fb28d0eb87c5746213efee4b4cbaf1dba7..521a306b96e0995f7e0dfc64c74313320eb44ae6 100644 (file)
@@ -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
     }