[Mesa-dev] [PATCH 2/5] swr: [rasterizer core] make all api functions call GetContext

Tim Rowley timothy.o.rowley at intel.com
Wed Jul 6 21:51:44 UTC 2016


Small api cleanup.  Make all api functions call GetContext instead
of locally casting handle.  Makes debugging easier by providing a
single point to track context changes.
---
 src/gallium/drivers/swr/rasterizer/core/api.cpp | 28 ++++++++++++-------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index edde918..6f9c402 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -48,6 +48,11 @@
 
 void SetupDefaultState(SWR_CONTEXT *pContext);
 
+static INLINE SWR_CONTEXT* GetContext(HANDLE hContext)
+{
+    return (SWR_CONTEXT*)hContext;
+}
+
 //////////////////////////////////////////////////////////////////////////
 /// @brief Create SWR Context.
 /// @param pCreateInfo - pointer to creation info.
@@ -140,7 +145,7 @@ HANDLE SwrCreateContext(
 
 void SwrDestroyContext(HANDLE hContext)
 {
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     DestroyThreadPool(pContext, &pContext->threadPool);
 
     // free the fifos
@@ -168,7 +173,7 @@ void SwrDestroyContext(HANDLE hContext)
     delete(pContext->pHotTileMgr);
 
     pContext->~SWR_CONTEXT();
-    AlignedFree((SWR_CONTEXT*)hContext);
+    AlignedFree(GetContext(hContext));
 }
 
 void CopyState(DRAW_STATE& dst, const DRAW_STATE& src)
@@ -357,7 +362,7 @@ void SWR_API SwrSaveState(
     void* pOutputStateBlock,
     size_t memSize)
 {
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     auto pSrc = GetDrawState(pContext);
     SWR_ASSERT(pOutputStateBlock && memSize >= sizeof(*pSrc));
 
@@ -369,7 +374,7 @@ void SWR_API SwrRestoreState(
     const void* pStateBlock,
     size_t memSize)
 {
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     auto pDst = GetDrawState(pContext);
     SWR_ASSERT(pStateBlock && memSize >= sizeof(*pDst));
 
@@ -384,11 +389,6 @@ void SetupDefaultState(SWR_CONTEXT *pContext)
     pState->rastState.frontWinding = SWR_FRONTWINDING_CCW;
 }
 
-static INLINE SWR_CONTEXT* GetContext(HANDLE hContext)
-{
-    return (SWR_CONTEXT*)hContext;
-}
-
 void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, uint64_t userData, uint64_t userData2, uint64_t userData3)
 {
     RDTSC_START(APISync);
@@ -1286,7 +1286,7 @@ void SwrInvalidateTiles(
         return;
     }
 
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
     pDC->FeWork.type = DISCARDINVALIDATETILES;
@@ -1316,7 +1316,7 @@ void SwrDiscardRect(
         return;
     }
 
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
     // Queue a load to the hottile
@@ -1350,7 +1350,7 @@ void SwrDispatch(
     }
 
     RDTSC_START(APIDispatch);
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
     pDC->isCompute = true;      // This is a compute context.
@@ -1384,7 +1384,7 @@ void SwrStoreTiles(
 
     RDTSC_START(APIStoreTiles);
 
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
     SetupMacroTileScissors(pDC);
@@ -1414,7 +1414,7 @@ void SwrClearRenderTarget(
 
     RDTSC_START(APIClearRenderTarget);
 
-    SWR_CONTEXT *pContext = (SWR_CONTEXT*)hContext;
+    SWR_CONTEXT *pContext = GetContext(hContext);
 
     DRAW_CONTEXT* pDC = GetDrawContext(pContext);
 
-- 
1.9.1



More information about the mesa-dev mailing list