gallium/swr: fix rdtsc debug statistics mechanism
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Thu, 13 Feb 2020 13:41:41 +0000 (14:41 +0100)
committerKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Thu, 13 Feb 2020 14:33:27 +0000 (15:33 +0100)
Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3812>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3812>

src/gallium/drivers/swr/rasterizer/core/api.h
src/gallium/drivers/swr/rasterizer/core/backend.cpp
src/gallium/drivers/swr/rasterizer/core/tilemgr.cpp
src/gallium/drivers/swr/rasterizer/memory/InitMemory.h
src/gallium/drivers/swr/rasterizer/memory/LoadTile.cpp
src/gallium/drivers/swr/rasterizer/memory/LoadTile.h
src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp
src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
src/gallium/drivers/swr/swr_memory.h

index 29651c9beedaf9a5a53d8e26e994fee35e54251c..77f20e5834be0878992d10d1f8c9952c907dc711 100644 (file)
@@ -97,13 +97,13 @@ struct SWR_RECT
 
 //////////////////////////////////////////////////////////////////////////
 /// @brief Function signature for load hot tiles
-/// @param hPrivateContext - handle to private data
+/// @param hDC - handle to DRAW_CONTEXT
 /// @param dstFormat - format of the hot tile
 /// @param renderTargetIndex - render target to store, can be color, depth or stencil
 /// @param x - destination x coordinate
 /// @param y - destination y coordinate
 /// @param pDstHotTile - pointer to the hot tile surface
-typedef void(SWR_API* PFN_LOAD_TILE)(HANDLE                      hPrivateContext,
+typedef void(SWR_API* PFN_LOAD_TILE)(HANDLE                      hDC,
                                      HANDLE                      hWorkerPrivateData,
                                      SWR_FORMAT                  dstFormat,
                                      SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
@@ -114,13 +114,13 @@ typedef void(SWR_API* PFN_LOAD_TILE)(HANDLE                      hPrivateContext
 
 //////////////////////////////////////////////////////////////////////////
 /// @brief Function signature for store hot tiles
-/// @param hPrivateContext - handle to private data
+/// @param hDC - handle to DRAW_CONTEXT
 /// @param srcFormat - format of the hot tile
 /// @param renderTargetIndex - render target to store, can be color, depth or stencil
 /// @param x - destination x coordinate
 /// @param y - destination y coordinate
 /// @param pSrcHotTile - pointer to the hot tile surface
-typedef void(SWR_API* PFN_STORE_TILE)(HANDLE                      hPrivateContext,
+typedef void(SWR_API* PFN_STORE_TILE)(HANDLE                      hDC,
                                       HANDLE                      hWorkerPrivateData,
                                       SWR_FORMAT                  srcFormat,
                                       SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
index 49b163ee6aed8a0190ce0b1878780189db4216de..bb9d6f7dc527947e6d52afe4bf3161cb45a973a1 100644 (file)
@@ -175,7 +175,7 @@ void ProcessStoreTileBE(DRAW_CONTEXT*               pDC,
             int32_t destX = KNOB_MACROTILE_X_DIM * x;
             int32_t destY = KNOB_MACROTILE_Y_DIM * y;
 
-            pContext->pfnStoreTile(GetPrivateState(pDC),
+            pContext->pfnStoreTile(pDC,
                                    hWorkerPrivateData,
                                    srcFormat,
                                    attachment,
index a23de56a0a5d9878bc27017bb5218318da4a8d1d..a02fa336277607bab98f39116dd1f219fedb48ce 100644 (file)
@@ -184,7 +184,7 @@ HOTTILE* HotTileMgr::GetHotTile(SWR_CONTEXT*                pContext,
 
             if (hotTile.state == HOTTILE_DIRTY)
             {
-                pContext->pfnStoreTile(GetPrivateState(pDC),
+                pContext->pfnStoreTile(pDC,
                                        hWorkerPrivateData,
                                        format,
                                        attachment,
@@ -194,7 +194,7 @@ HOTTILE* HotTileMgr::GetHotTile(SWR_CONTEXT*                pContext,
                                        hotTile.pBuffer);
             }
 
-            pContext->pfnLoadTile(GetPrivateState(pDC),
+            pContext->pfnLoadTile(pDC,
                                   hWorkerPrivateData,
                                   format,
                                   attachment,
@@ -370,7 +370,7 @@ void HotTileMgr::InitializeHotTiles(SWR_CONTEXT*  pContext,
         {
             RDTSC_BEGIN(pContext->pBucketMgr, BELoadTiles, pDC->drawId);
             // invalid hottile before draw requires a load from surface before we can draw to it
-            pContext->pfnLoadTile(GetPrivateState(pDC),
+            pContext->pfnLoadTile(pDC,
                                   hWorkerPrivateData,
                                   KNOB_COLOR_HOT_TILE_FORMAT,
                                   (SWR_RENDERTARGET_ATTACHMENT)(SWR_ATTACHMENT_COLOR0 + rtSlot),
@@ -401,7 +401,7 @@ void HotTileMgr::InitializeHotTiles(SWR_CONTEXT*  pContext,
         {
             RDTSC_BEGIN(pContext->pBucketMgr, BELoadTiles, pDC->drawId);
             // invalid hottile before draw requires a load from surface before we can draw to it
-            pContext->pfnLoadTile(GetPrivateState(pDC),
+            pContext->pfnLoadTile(pDC,
                                   hWorkerPrivateData,
                                   KNOB_DEPTH_HOT_TILE_FORMAT,
                                   SWR_ATTACHMENT_DEPTH,
@@ -431,7 +431,7 @@ void HotTileMgr::InitializeHotTiles(SWR_CONTEXT*  pContext,
         {
             RDTSC_BEGIN(pContext->pBucketMgr, BELoadTiles, pDC->drawId);
             // invalid hottile before draw requires a load from surface before we can draw to it
-            pContext->pfnLoadTile(GetPrivateState(pDC),
+            pContext->pfnLoadTile(pDC,
                                   hWorkerPrivateData,
                                   KNOB_STENCIL_HOT_TILE_FORMAT,
                                   SWR_ATTACHMENT_STENCIL,
index 6838ddc701d13504c934025dad3e230b05d09581..a3ed7b3cbdbf742ce116add1424eb82bc780ff28 100644 (file)
@@ -42,6 +42,7 @@ SWR_FUNC(void,
          SwrLoadHotTile,
          HANDLE                      hWorkerPrivateData,
          const SWR_SURFACE_STATE*    pSrcSurface,
+         BucketManager*              pBucketManager,
          SWR_FORMAT                  dstFormat,
          SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
          uint32_t                    x,
@@ -60,6 +61,7 @@ SWR_FUNC(void,
          SwrStoreHotTileToSurface,
          HANDLE                      hWorkerPrivateData,
          SWR_SURFACE_STATE*          pDstSurface,
+         BucketManager*              pBucketManager,
          SWR_FORMAT                  srcFormat,
          SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
          uint32_t                    x,
index 8033304d20c6ea4d7288606ef0f8029842e84f97..a26d45d130f49711d0e2c9931a29818fd565cd25 100644 (file)
 ******************************************************************************/
 #include "LoadTile.h"
 
-
-static void BUCKETS_START(UINT id)
-{
-#ifdef KNOB_ENABLE_RDTSC
-    gBucketMgr.StartBucket(id);
-#endif
-}
-
-static void BUCKETS_STOP(UINT id)
-{
-#ifdef KNOB_ENABLE_RDTSC
-    gBucketMgr.StopBucket(id);
-#endif
-}
-
 // on demand buckets for load tiles
 static std::vector<int> sBuckets(NUM_SWR_FORMATS, -1);
 static std::mutex sBucketMutex;
@@ -56,6 +41,7 @@ static std::mutex sBucketMutex;
 void SwrLoadHotTile(
     HANDLE hWorkerPrivateData,
     const SWR_SURFACE_STATE *pSrcSurface,
+    BucketManager* pBucketMgr,
     SWR_FORMAT dstFormat,
     SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
     uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
@@ -147,15 +133,19 @@ void SwrLoadHotTile(
         {
             const SWR_FORMAT_INFO& info = GetFormatInfo(pSrcSurface->format);
             BUCKET_DESC desc{ info.name, "", false, 0xffffffff };
-            sBuckets[pSrcSurface->format] = gBucketMgr.RegisterBucket(desc);
+            sBuckets[pSrcSurface->format] = pBucketMgr->RegisterBucket(desc);
         }
         sBucketMutex.unlock();
     }
 #endif
 
-    BUCKETS_START(sBuckets[pSrcSurface->format]);
+#ifdef KNOB_ENABLE_RDTSC
+    pBucketMgr->StartBucket(sBuckets[pSrcSurface->format]);
+#endif
     pfnLoadTiles(pSrcSurface, pDstHotTile, x, y, renderTargetArrayIndex);
-    BUCKETS_STOP(sBuckets[pSrcSurface->format]);
+#ifdef KNOB_ENABLE_RDTSC
+    pBucketMgr->StopBucket(sBuckets[pSrcSurface->format]);
+#endif
 }
 
 
index 37be28c5ec7700c3e6cd6b2247f9f6e2c683bb0c..f74c3fdf4b00ee5ad47fb7a5c9eae2c22ee8e9c2 100644 (file)
@@ -347,7 +347,8 @@ static INLINE void InitLoadTileDepthTable(PFN_LOAD_TILES(&table)[NUM_SWR_FORMATS
 void SwrLoadHotTile(
         HANDLE hWorkerPrivateData,
         const SWR_SURFACE_STATE *pSrcSurface,
+        BucketManager* pBucketMgr,
         SWR_FORMAT dstFormat,
         SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
         uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
-        uint8_t *pDstHotTile);
\ No newline at end of file
+        uint8_t *pDstHotTile);
index 53b82c4c12c145990e1f7d0b14dbd409018b1034..9fee13a045adb9996ac8c06f526c2173d659e75c 100644 (file)
@@ -33,20 +33,6 @@ PFN_STORE_TILES sStoreTilesTableColor[SWR_TILE_MODE_COUNT][NUM_SWR_FORMATS] = {}
 PFN_STORE_TILES sStoreTilesTableDepth[SWR_TILE_MODE_COUNT][NUM_SWR_FORMATS] = {};
 PFN_STORE_TILES sStoreTilesTableStencil[SWR_TILE_MODE_COUNT][NUM_SWR_FORMATS] = {};
 
-static void BUCKETS_START(UINT id)
-{
-#ifdef KNOB_ENABLE_RDTSC
-    gBucketMgr.StartBucket(id);
-#endif
-}
-
-static void BUCKETS_STOP(UINT id)
-{
-#ifdef KNOB_ENABLE_RDTSC
-    gBucketMgr.StopBucket(id);
-#endif
-}
-
 // on demand buckets for store tiles
 static std::mutex sBucketMutex;
 static std::vector<int32_t> sBuckets(NUM_SWR_FORMATS, -1);
@@ -61,6 +47,7 @@ static std::vector<int32_t> sBuckets(NUM_SWR_FORMATS, -1);
 void SwrStoreHotTileToSurface(
     HANDLE hWorkerPrivateData,
     SWR_SURFACE_STATE *pDstSurface,
+    BucketManager* pBucketMgr,
     SWR_FORMAT srcFormat,
     SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
     uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
@@ -108,15 +95,20 @@ void SwrStoreHotTileToSurface(
         {
             const SWR_FORMAT_INFO& info = GetFormatInfo(pDstSurface->format);
             BUCKET_DESC desc{info.name, "", false, 0xffffffff};
-            sBuckets[pDstSurface->format] = gBucketMgr.RegisterBucket(desc);
+            sBuckets[pDstSurface->format] = pBucketMgr->RegisterBucket(desc);
         }
         sBucketMutex.unlock();
     }
 #endif
 
-    BUCKETS_START(sBuckets[pDstSurface->format]);
+#ifdef KNOB_ENABLE_RDTSC
+    pBucketMgr->StartBucket(sBuckets[pDstSurface->format]);
+#endif
     pfnStoreTiles(pSrcHotTile, pDstSurface, x, y, renderTargetArrayIndex);
-    BUCKETS_STOP(sBuckets[pDstSurface->format]);
+#ifdef KNOB_ENABLE_RDTSC
+    pBucketMgr->StopBucket(sBuckets[pDstSurface->format]);
+#endif
+
 }
 
 
index 9b7f5aa3efc1f2d1b46a9e2650d153ec010f5638..2d32e90330e75eeeacd9c6594106e239c4481395 100644 (file)
@@ -2044,7 +2044,8 @@ void InitStoreTilesTableStencil(
 void SwrStoreHotTileToSurface(
         HANDLE hWorkerPrivateData,
         SWR_SURFACE_STATE *pDstSurface,
+        BucketManager* pBucketMgr,
         SWR_FORMAT srcFormat,
         SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
         uint32_t x, uint32_t y, uint32_t renderTargetArrayIndex,
-        uint8_t *pSrcHotTile);
\ No newline at end of file
+        uint8_t *pSrcHotTile);
index c7c05fb7c65ae8f3da8cf617575932bdb4b36812..bf6eaa347582cebd5aabaa2b4d4bc4174be506e0 100644 (file)
  ***************************************************************************/
 
 #pragma once
-
+#include "rasterizer/core/context.h"
 INLINE void
-swr_LoadHotTile(HANDLE hPrivateContext,
+swr_LoadHotTile(HANDLE hDC,
                 HANDLE hWorkerPrivateData,
                 SWR_FORMAT dstFormat,
                 SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
                 UINT x, UINT y,
                 uint32_t renderTargetArrayIndex, uint8_t* pDstHotTile)
 {
-   // Grab source surface state from private context
-   swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
-   SWR_SURFACE_STATE *pSrcSurface = &pDC->renderTargets[renderTargetIndex];
+   DRAW_CONTEXT *pDC = (DRAW_CONTEXT*)hDC;
+   swr_draw_context *pSDC = (swr_draw_context*)GetPrivateState(pDC);
+   SWR_SURFACE_STATE *pSrcSurface = &pSDC->renderTargets[renderTargetIndex];
 
-   pDC->pTileAPI->pfnSwrLoadHotTile(hWorkerPrivateData, pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile);
+   pSDC->pTileAPI->pfnSwrLoadHotTile(hWorkerPrivateData, pSrcSurface, pDC->pContext->pBucketMgr, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile);
 }
 
 INLINE void
-swr_StoreHotTile(HANDLE hPrivateContext,
+swr_StoreHotTile(HANDLE hDC,
                  HANDLE hWorkerPrivateData,
                  SWR_FORMAT srcFormat,
                  SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
                  UINT x, UINT y,
                  uint32_t renderTargetArrayIndex, uint8_t* pSrcHotTile)
 {
-   // Grab destination surface state from private context
-   swr_draw_context *pDC = (swr_draw_context*)hPrivateContext;
-   SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex];
+   DRAW_CONTEXT *pDC = (DRAW_CONTEXT*)hDC;
+   swr_draw_context *pSDC = (swr_draw_context*)GetPrivateState(pDC);
+   SWR_SURFACE_STATE *pDstSurface = &pSDC->renderTargets[renderTargetIndex];
 
-   pDC->pTileAPI->pfnSwrStoreHotTileToSurface(hWorkerPrivateData, pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile);
+   pSDC->pTileAPI->pfnSwrStoreHotTileToSurface(hWorkerPrivateData, pDstSurface, pDC->pContext->pBucketMgr, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile);
 }
 
 INLINE gfxptr_t