[Mesa-dev] [PATCH v2 06/17] swr/rast: stop using MSFT types in platform independent code

Tim Rowley timothy.o.rowley at intel.com
Tue Aug 1 19:44:36 UTC 2017


---
 src/gallium/drivers/swr/rasterizer/common/os.h             |  6 ------
 src/gallium/drivers/swr/rasterizer/core/api.cpp            |  2 +-
 src/gallium/drivers/swr/rasterizer/core/api.h              |  4 ++--
 src/gallium/drivers/swr/rasterizer/core/binner.cpp         |  4 ++--
 src/gallium/drivers/swr/rasterizer/core/blend.h            |  2 +-
 src/gallium/drivers/swr/rasterizer/core/clip.h             |  8 ++++----
 src/gallium/drivers/swr/rasterizer/core/fifo.hpp           |  2 +-
 src/gallium/drivers/swr/rasterizer/core/format_traits.h    |  4 ++--
 src/gallium/drivers/swr/rasterizer/core/pa.h               |  2 +-
 src/gallium/drivers/swr/rasterizer/core/threads.cpp        |  4 ++--
 src/gallium/drivers/swr/rasterizer/core/tilemgr.h          | 12 ++++++------
 src/gallium/drivers/swr/rasterizer/core/utils.h            | 10 ++++++++++
 src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp    |  2 +-
 src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp |  4 ++--
 14 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h
index dc90fca..4ed6b88 100644
--- a/src/gallium/drivers/swr/rasterizer/common/os.h
+++ b/src/gallium/drivers/swr/rasterizer/common/os.h
@@ -220,12 +220,6 @@ void *AlignedMalloc(unsigned int size, unsigned int alignment)
     return ret;
 }
 
-inline
-unsigned char _bittest(const LONG *a, LONG b)
-{
-    return ((*(unsigned *)(a) & (1 << b)) != 0);
-}
-
 static inline
 void AlignedFree(void* p)
 {
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 855d133..8dc9ac2 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -189,7 +189,7 @@ void QueueWork(SWR_CONTEXT *pContext)
 
     if (IsDraw)
     {
-        InterlockedIncrement((volatile LONG*)&pContext->drawsOutstandingFE);
+        InterlockedIncrement((volatile long*)&pContext->drawsOutstandingFE);
     }
 
     _ReadWriteBarrier();
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.h b/src/gallium/drivers/swr/rasterizer/core/api.h
index 236e0fc..a394205 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.h
+++ b/src/gallium/drivers/swr/rasterizer/core/api.h
@@ -697,8 +697,8 @@ SWR_FUNC(void, SwrStoreHotTileToSurface,
 SWR_FUNC(void, SwrStoreHotTileClear,
          SWR_SURFACE_STATE *pDstSurface,
          SWR_RENDERTARGET_ATTACHMENT renderTargetIndex,
-         UINT x,
-         UINT y,
+         uint32_t x,
+         uint32_t y,
          uint32_t renderTargetArrayIndex,
          const float* pClearColor);
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
index de6691b..c1f0f07 100644
--- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
@@ -64,7 +64,7 @@ INLINE void ProcessAttributes(
     static_assert(NumVertsT::value > 0 && NumVertsT::value <= 3, "Invalid value for NumVertsT");
     const SWR_BACKEND_STATE& backendState = pDC->pState->state.backendState;
     // Conservative Rasterization requires degenerate tris to have constant attribute interpolation
-    LONG constantInterpMask = IsDegenerate::value ? 0xFFFFFFFF : backendState.constantInterpolationMask;
+    uint32_t constantInterpMask = IsDegenerate::value ? 0xFFFFFFFF : backendState.constantInterpolationMask;
     const uint32_t provokingVertex = pDC->pState->state.frontendState.topologyProvokingVertex;
     const PRIMITIVE_TOPOLOGY topo = pDC->pState->state.topology;
 
@@ -93,7 +93,7 @@ INLINE void ProcessAttributes(
 
         if (HasConstantInterpT::value || IsDegenerate::value)
         {
-            if (_bittest(&constantInterpMask, i))
+            if (CheckBit(constantInterpMask, i))
             {
                 uint32_t vid;
                 uint32_t adjustedTriIndex;
diff --git a/src/gallium/drivers/swr/rasterizer/core/blend.h b/src/gallium/drivers/swr/rasterizer/core/blend.h
index 1b98e44..c89c476 100644
--- a/src/gallium/drivers/swr/rasterizer/core/blend.h
+++ b/src/gallium/drivers/swr/rasterizer/core/blend.h
@@ -278,7 +278,7 @@ INLINE void Clamp(simdvector &src)
 }
 
 template<SWR_TYPE type>
-void Blend(const SWR_BLEND_STATE *pBlendState, const SWR_RENDER_TARGET_BLEND_STATE *pState, simdvector &src, simdvector& src1, BYTE *pDst, simdvector &result)
+void Blend(const SWR_BLEND_STATE *pBlendState, const SWR_RENDER_TARGET_BLEND_STATE *pState, simdvector &src, simdvector& src1, uint8_t *pDst, simdvector &result)
 {
     // load render target
     simdvector dst;
diff --git a/src/gallium/drivers/swr/rasterizer/core/clip.h b/src/gallium/drivers/swr/rasterizer/core/clip.h
index bf16792..ca6596e 100644
--- a/src/gallium/drivers/swr/rasterizer/core/clip.h
+++ b/src/gallium/drivers/swr/rasterizer/core/clip.h
@@ -464,7 +464,7 @@ public:
         // input/output vertex store for clipper
         simdvertex vertices[7]; // maximum 7 verts generated per triangle
 
-        LONG constantInterpMask = this->state.backendState.constantInterpolationMask;
+        uint32_t constantInterpMask = this->state.backendState.constantInterpolationMask;
         uint32_t provokingVertex = 0;
         if(pa.binTopology == TOP_TRIANGLE_FAN)
         {
@@ -495,7 +495,7 @@ public:
 
             // if constant interpolation enabled for this attribute, assign the provoking
             // vertex values to all edges
-            if (_bittest(&constantInterpMask, slot))
+            if (CheckBit(constantInterpMask, slot))
             {
                 for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
                 {
@@ -721,7 +721,7 @@ public:
         // input/output vertex store for clipper
         simd16vertex vertices[7]; // maximum 7 verts generated per triangle
 
-        LONG constantInterpMask = this->state.backendState.constantInterpolationMask;
+        uint32_t constantInterpMask = this->state.backendState.constantInterpolationMask;
         uint32_t provokingVertex = 0;
         if (pa.binTopology == TOP_TRIANGLE_FAN)
         {
@@ -752,7 +752,7 @@ public:
 
             // if constant interpolation enabled for this attribute, assign the provoking
             // vertex values to all edges
-            if (_bittest(&constantInterpMask, slot))
+            if (CheckBit(constantInterpMask, slot))
             {
                 for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
                 {
diff --git a/src/gallium/drivers/swr/rasterizer/core/fifo.hpp b/src/gallium/drivers/swr/rasterizer/core/fifo.hpp
index 49ba71f..3be72f3 100644
--- a/src/gallium/drivers/swr/rasterizer/core/fifo.hpp
+++ b/src/gallium/drivers/swr/rasterizer/core/fifo.hpp
@@ -76,7 +76,7 @@ struct QUEUE
         }
 
         // try to lock the FIFO
-        LONG initial = InterlockedCompareExchange(&mLock, 1, 0);
+        long initial = InterlockedCompareExchange(&mLock, 1, 0);
         return (initial == 0);
     }
         
diff --git a/src/gallium/drivers/swr/rasterizer/core/format_traits.h b/src/gallium/drivers/swr/rasterizer/core/format_traits.h
index 1721aa4..c04ea5f 100644
--- a/src/gallium/drivers/swr/rasterizer/core/format_traits.h
+++ b/src/gallium/drivers/swr/rasterizer/core/format_traits.h
@@ -35,11 +35,11 @@
 //////////////////////////////////////////////////////////////////////////
 /// FormatSwizzle - Component swizzle selects
 //////////////////////////////////////////////////////////////////////////
-template<UINT comp0 = 0, uint32_t comp1 = 0, uint32_t comp2 = 0, uint32_t comp3 = 0>
+template<uint32_t comp0 = 0, uint32_t comp1 = 0, uint32_t comp2 = 0, uint32_t comp3 = 0>
 struct FormatSwizzle
 {
     // Return swizzle select for component.
-    INLINE static uint32_t swizzle(UINT c)
+    INLINE static uint32_t swizzle(uint32_t c)
     {
         static const uint32_t s[4] = { comp0, comp1, comp2, comp3 };
         return s[c];
diff --git a/src/gallium/drivers/swr/rasterizer/core/pa.h b/src/gallium/drivers/swr/rasterizer/core/pa.h
index 4bb3236..cb3470f 100644
--- a/src/gallium/drivers/swr/rasterizer/core/pa.h
+++ b/src/gallium/drivers/swr/rasterizer/core/pa.h
@@ -572,7 +572,7 @@ struct PA_STATE_CUT : public PA_STATE
     {
         uint32_t vertexIndex = vertex / SIMD_WIDTH;
         uint32_t vertexOffset = vertex & (SIMD_WIDTH - 1);
-        return _bittest((const LONG*)&this->pCutIndices[vertexIndex], vertexOffset) == 1;
+        return CheckBit(this->pCutIndices[vertexIndex], vertexOffset);
     }
 
     // iterates across the unprocessed verts until we hit the end or we 
diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
index 36710bf..70bde02 100644
--- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
@@ -393,7 +393,7 @@ INLINE void ExecuteCallbacks(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONT
 // inlined-only version
 INLINE int32_t CompleteDrawContextInl(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC)
 {
-    int32_t result = InterlockedDecrement((volatile LONG*)&pDC->threadsDone);
+    int32_t result = InterlockedDecrement((volatile long*)&pDC->threadsDone);
     SWR_ASSERT(result >= 0);
 
     AR_FLUSH(pDC->drawId);
@@ -639,7 +639,7 @@ INLINE void CompleteDrawFE(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEX
     _mm_mfence();
     pDC->doneFE = true;
 
-    InterlockedDecrement((volatile LONG*)&pContext->drawsOutstandingFE);
+    InterlockedDecrement((volatile long*)&pContext->drawsOutstandingFE);
 }
 
 void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t &curDrawFE)
diff --git a/src/gallium/drivers/swr/rasterizer/core/tilemgr.h b/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
index 8f1cd21..8ef74a7 100644
--- a/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
+++ b/src/gallium/drivers/swr/rasterizer/core/tilemgr.h
@@ -147,8 +147,8 @@ private:
     // Any tile that has work queued to it is a dirty tile.
     std::vector<MacroTileQueue*> mDirtyTiles;
 
-    OSALIGNLINE(LONG) mWorkItemsProduced { 0 };
-    OSALIGNLINE(volatile LONG) mWorkItemsConsumed { 0 };
+    OSALIGNLINE(long) mWorkItemsProduced { 0 };
+    OSALIGNLINE(volatile long) mWorkItemsConsumed { 0 };
 };
 
 typedef void(*PFN_DISPATCH)(DRAW_CONTEXT* pDC, uint32_t workerId, uint32_t threadGroupId, void*& pSpillFillBuffer, void*& pScratchSpace);
@@ -191,7 +191,7 @@ public:
     //         Otherwise, there is no more work to do.
     bool getWork(uint32_t& groupId)
     {
-        LONG result = InterlockedDecrement(&mTasksAvailable);
+        long result = InterlockedDecrement(&mTasksAvailable);
 
         if (result >= 0)
         {
@@ -208,7 +208,7 @@ public:
     ///        the last worker to complete this dispatch.
     bool finishedWork()
     {
-        LONG result = InterlockedDecrement(&mTasksOutstanding);
+        long result = InterlockedDecrement(&mTasksOutstanding);
         SWR_ASSERT(result >= 0, "Should never oversubscribe work");
 
         return (result == 0) ? true : false;
@@ -240,8 +240,8 @@ public:
     void* mpTaskData{ nullptr };        // The API thread will set this up and the callback task function will interpet this.
     PFN_DISPATCH mPfnDispatch{ nullptr };      // Function to call per dispatch
 
-    OSALIGNLINE(volatile LONG) mTasksAvailable{ 0 };
-    OSALIGNLINE(volatile LONG) mTasksOutstanding{ 0 };
+    OSALIGNLINE(volatile long) mTasksAvailable{ 0 };
+    OSALIGNLINE(volatile long) mTasksOutstanding{ 0 };
 };
 
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
index a8c58d9..392ee4b 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.h
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
@@ -123,6 +123,16 @@ uint32_t ComputeCRC(uint32_t crc, const void *pData, uint32_t size)
 }
 
 //////////////////////////////////////////////////////////////////////////
+/// Check specified bit within a data word
+//////////////////////////////////////////////////////////////////////////
+template <typename T>
+INLINE
+static bool CheckBit(T word, uint32_t bit)
+{
+    return 0 != (word & (T(1) << bit));
+}
+
+//////////////////////////////////////////////////////////////////////////
 /// Add byte offset to any-type pointer
 //////////////////////////////////////////////////////////////////////////
 template <typename T>
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
index 4278840..f2e6e53 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
@@ -518,7 +518,7 @@ struct BlendJit : public Builder
         fnName << ComputeCRC(0, &state, sizeof(state));
 
         // blend function signature
-        //typedef void(*PFN_BLEND_JIT_FUNC)(const SWR_BLEND_STATE*, simdvector&, simdvector&, uint32_t, BYTE*, simdvector&, simdscalari*, simdscalari*);
+        //typedef void(*PFN_BLEND_JIT_FUNC)(const SWR_BLEND_STATE*, simdvector&, simdvector&, uint32_t, uint8_t*, simdvector&, simdscalari*, simdscalari*);
 
         std::vector<Type*> args{
             PointerType::get(Gen_SWR_BLEND_STATE(JM()), 0), // SWR_BLEND_STATE*
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
index fbb4948..402fd26 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
@@ -112,9 +112,9 @@ namespace SwrJit
     ///        float
     /// @param val - 16-bit float
     /// @todo Maybe move this outside of this file into a header?
-    static float ConvertSmallFloatTo32(UINT val)
+    static float ConvertSmallFloatTo32(uint32_t val)
     {
-        UINT result;
+        uint32_t result;
         if ((val & 0x7fff) == 0)
         {
             result = ((uint32_t)(val & 0x8000)) << 16;
-- 
2.7.4



More information about the mesa-dev mailing list