swr: [rasterizer core] SwrStoreTiles api change
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 6 Oct 2016 18:22:35 +0000 (13:22 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Tue, 11 Oct 2016 16:22:04 +0000 (11:22 -0500)
SwrStoreTiles now takes a mask of surfaces to store.  Reduces
overhead when storing multiple render targets.

Signed-off-by: Tim Rowley <timothy.o.rowley@intel.com>
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/api.h
src/gallium/drivers/swr/rasterizer/core/backend.cpp
src/gallium/drivers/swr/rasterizer/core/backend.h
src/gallium/drivers/swr/rasterizer/core/context.h
src/gallium/drivers/swr/rasterizer/core/frontend.cpp
src/gallium/drivers/swr/swr_draw.cpp

index 2c2810eb26a4e1e7af2b03e149d6b5083eb5114e..a90d9933735742a1677ec0f703c68e9518ee0586 100644 (file)
@@ -1445,7 +1445,7 @@ void SwrDispatch(
 // described by pState
 void SWR_API SwrStoreTiles(
     HANDLE hContext,
-    SWR_RENDERTARGET_ATTACHMENT attachment,
+    uint32_t attachmentMask,
     SWR_TILE_STATE postStoreTileState,
     const SWR_RECT& storeRect)
 {
@@ -1461,7 +1461,7 @@ void SWR_API SwrStoreTiles(
 
     pDC->FeWork.type = STORETILES;
     pDC->FeWork.pfnWork = ProcessStoreTiles;
-    pDC->FeWork.desc.storeTiles.attachment = attachment;
+    pDC->FeWork.desc.storeTiles.attachmentMask = attachmentMask;
     pDC->FeWork.desc.storeTiles.postStoreTileState = postStoreTileState;
     pDC->FeWork.desc.storeTiles.rect = storeRect;
     pDC->FeWork.desc.storeTiles.rect &= g_MaxScissorRect;
index 9ca235d821e0f2bdd98e3aaf32d8984a69cbe9d9..93337e662ba2d8d2c5c211798649b34776d75dd8 100644 (file)
@@ -543,7 +543,7 @@ enum SWR_TILE_STATE
 /// @todo Add a good description for what attachments are and when and why you would use the different SWR_TILE_STATEs.
 void SWR_API SwrStoreTiles(
     HANDLE hContext,
-    SWR_RENDERTARGET_ATTACHMENT attachment,
+    uint32_t attachmentMask,
     SWR_TILE_STATE postStoreTileState,
     const SWR_RECT& storeRect);
 
index 8b7ce6a75a36d175493c81ae76a609d2217b54e2..888af794e95d3c29e4e4d8741a60521256fe61d3 100644 (file)
@@ -280,19 +280,15 @@ void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, vo
     }
 }
 
-
-void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData)
+void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, STORE_TILES_DESC* pDesc, 
+    SWR_RENDERTARGET_ATTACHMENT attachment)
 {
-    STORE_TILES_DESC *pDesc = (STORE_TILES_DESC*)pData;
     SWR_CONTEXT *pContext = pDC->pContext;
 
     AR_BEGIN(BEStoreTiles, pDC->drawId);
 
-#if defined(KNOB_ENABLE_RDTSC) || defined(KNOB_ENABLE_AR)
-    uint32_t numTiles = 0;
-#endif
     SWR_FORMAT srcFormat;
-    switch (pDesc->attachment)
+    switch (attachment)
     {
     case SWR_ATTACHMENT_COLOR0:
     case SWR_ATTACHMENT_COLOR1:
@@ -304,14 +300,14 @@ void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile
     case SWR_ATTACHMENT_COLOR7: srcFormat = KNOB_COLOR_HOT_TILE_FORMAT; break;
     case SWR_ATTACHMENT_DEPTH: srcFormat = KNOB_DEPTH_HOT_TILE_FORMAT; break;
     case SWR_ATTACHMENT_STENCIL: srcFormat = KNOB_STENCIL_HOT_TILE_FORMAT; break;
-    default: SWR_ASSERT(false, "Unknown attachment: %d", pDesc->attachment); srcFormat = KNOB_COLOR_HOT_TILE_FORMAT; break;
+    default: SWR_ASSERT(false, "Unknown attachment: %d", attachment); srcFormat = KNOB_COLOR_HOT_TILE_FORMAT; break;
     }
 
     uint32_t x, y;
     MacroTileMgr::getTileIndices(macroTile, x, y);
 
     // Only need to store the hottile if it's been rendered to...
-    HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, pDesc->attachment, false);
+    HOTTILE *pHotTile = pContext->pHotTileMgr->GetHotTile(pContext, pDC, macroTile, attachment, false);
     if (pHotTile)
     {
         // clear if clear is pending (i.e., not rendered to), then mark as dirty for store.
@@ -320,7 +316,7 @@ void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile
             PFN_CLEAR_TILES pfnClearTiles = sClearTilesTable[srcFormat];
             SWR_ASSERT(pfnClearTiles != nullptr);
 
-            pfnClearTiles(pDC, pDesc->attachment, macroTile, pHotTile->clearData, pDesc->rect);
+            pfnClearTiles(pDC, attachment, macroTile, pHotTile->clearData, pDesc->rect);
         }
 
         if (pHotTile->state == HOTTILE_DIRTY || pDesc->postStoreTileState == (SWR_TILE_STATE)HOTTILE_DIRTY)
@@ -329,7 +325,7 @@ void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile
             int32_t destY = KNOB_MACROTILE_Y_DIM * y;
 
             pContext->pfnStoreTile(GetPrivateState(pDC), srcFormat,
-                pDesc->attachment, destX, destY, pHotTile->renderTargetArrayIndex, pHotTile->pBuffer);
+                attachment, destX, destY, pHotTile->renderTargetArrayIndex, pHotTile->pBuffer);
         }
         
 
@@ -338,9 +334,21 @@ void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile
             pHotTile->state = (HOTTILE_STATE)pDesc->postStoreTileState;
         }
     }
-    AR_END(BEStoreTiles, numTiles);
+    AR_END(BEStoreTiles, 1);
 }
 
+void ProcessStoreTilesBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData)
+{
+    STORE_TILES_DESC *pDesc = (STORE_TILES_DESC*)pData;
+
+    unsigned long rt = 0;
+    uint32_t mask = pDesc->attachmentMask;
+    while (_BitScanForward(&rt, mask))
+    {
+        mask &= ~(1 << rt);
+        ProcessStoreTileBE(pDC, workerId, macroTile, pDesc, (SWR_RENDERTARGET_ATTACHMENT)rt);
+    }
+}
 
 void ProcessDiscardInvalidateTilesBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData)
 {
index e19a53d6b04ea8720665bf65f1fbb8602aeea0fe..da4f46e7fd26b168ae3b0910181f9bcffc4adb65 100644 (file)
@@ -36,7 +36,7 @@
 void ProcessComputeBE(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroupId, void*& pSpillFillBuffer);
 void ProcessSyncBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pUserData);
 void ProcessClearBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pUserData);
-void ProcessStoreTileBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData);
+void ProcessStoreTilesBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData);
 void ProcessDiscardInvalidateTilesBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pData);
 void ProcessShutdownBE(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, void *pUserData);
 void BackendNullPS(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t y, SWR_TRIANGLE_DESC &work, RenderOutputBuffers &renderBuffers);
index 7a817ef0dd8ef899b194b091e4d1a43791aefce5..1f56dfc76d4b04c7690e6ff37c92b0442b262384 100644 (file)
@@ -137,7 +137,7 @@ struct SYNC_DESC
 
 struct STORE_TILES_DESC
 {
-    SWR_RENDERTARGET_ATTACHMENT attachment;
+    uint32_t attachmentMask;
     SWR_TILE_STATE postStoreTileState;
     SWR_RECT rect;
 };
index 2bc11c8095ffca88d6a01a0c5ebc77f0ecdc8064..2bcb4e3fbf5edd8b3185ff4c75b5142a1a247931 100644 (file)
@@ -174,7 +174,7 @@ void ProcessStoreTiles(
     // store tiles
     BE_WORK work;
     work.type = STORETILES;
-    work.pfnWork = ProcessStoreTileBE;
+    work.pfnWork = ProcessStoreTilesBE;
     work.desc.storeTiles = *pDesc;
 
     for (uint32_t y = macroTileYMin; y <= macroTileYMax; ++y)
index a46aef924ab33dc23781872e87c97f4d56cb4fd0..39378e61bb293cab9b400947f1807d0321b02c89 100644 (file)
@@ -262,7 +262,7 @@ swr_store_render_target(struct pipe_context *pipe,
       SWR_RECT full_rect =
          {0, 0, (int32_t)renderTarget->width, (int32_t)renderTarget->height};
       SwrStoreTiles(ctx->swrContext,
-                    (enum SWR_RENDERTARGET_ATTACHMENT)attachment,
+                    1 << attachment,
                     post_tile_state,
                     full_rect);
    }