swr/rast: stop using MSFT types in platform independent code
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 20 Jul 2017 18:48:28 +0000 (13:48 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 2 Aug 2017 16:39:33 +0000 (11:39 -0500)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
14 files changed:
src/gallium/drivers/swr/rasterizer/common/os.h
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/api.h
src/gallium/drivers/swr/rasterizer/core/binner.cpp
src/gallium/drivers/swr/rasterizer/core/blend.h
src/gallium/drivers/swr/rasterizer/core/clip.h
src/gallium/drivers/swr/rasterizer/core/fifo.hpp
src/gallium/drivers/swr/rasterizer/core/format_traits.h
src/gallium/drivers/swr/rasterizer/core/pa.h
src/gallium/drivers/swr/rasterizer/core/threads.cpp
src/gallium/drivers/swr/rasterizer/core/tilemgr.h
src/gallium/drivers/swr/rasterizer/core/utils.h
src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp

index dc90fca7501c5db2440a8ea8b60454002f304a54..4ed6b88e45419758b1412f2fbb6e969e1790520b 100644 (file)
@@ -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)
 {
index 855d133920a5d19ed7f4fc4cb5e17c03fcadadd1..8dc9ac24a745cd4a4e11352c5fd35174a2ff191d 100644 (file)
@@ -189,7 +189,7 @@ void QueueWork(SWR_CONTEXT *pContext)
 
     if (IsDraw)
     {
-        InterlockedIncrement((volatile LONG*)&pContext->drawsOutstandingFE);
+        InterlockedIncrement((volatile long*)&pContext->drawsOutstandingFE);
     }
 
     _ReadWriteBarrier();
index 236e0fcd666e0a04234a8a221cb2fd2ee216e2e5..a39420552b55932c122d2229aadf1949bae01484 100644 (file)
@@ -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);
 
index de6691b4cf8b181de92b652e9e6a3277980bea92..c1f0f07804fbc8dc0c7e234d2db4b1d87eadb733 100644 (file)
@@ -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;
index 1b98e442fd8aba46f328f3746122f8af6e782545..c89c47646a3cd9e72dc973852f7a9830c357606e 100644 (file)
@@ -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;
index bf16792a0a608e0136ef63aba9eb2a8d657d4194..ca6596eafbfcfa1847cc48dd8da99e65c0fd7382 100644 (file)
@@ -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)
                 {
index 49ba71f6435827e2b20837a633394c5e60998459..3be72f37cd6b865e48f7347ba5963fb8c54405ef 100644 (file)
@@ -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);
     }
         
index 1721aa46e75d6740e7c32b95875d5abae1b6e6a3..c04ea5f8ee72383f6912f09b1fc8326de7b68ddf 100644 (file)
 //////////////////////////////////////////////////////////////////////////
 /// 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];
index 4bb3236a638550a771a2ba9d33b5d1cf17d3c866..cb3470ff6b8df2a18128ae070faafb660cab9b08 100644 (file)
@@ -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 
index 36710bf0da56248a3ad4ce96d002fdcfde261ddf..70bde027ee0e1c6091392953502ef20882b94269 100644 (file)
@@ -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)
index 8f1cd21543d708000c3e36b1fc55aa21ccbfec95..8ef74a7f4b9880a0956a1257b4d9a89e36e92645 100644 (file)
@@ -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 };
 };
 
 
index a8c58d9d4efa011cee0e8bb2ba6a9996ab34f786..392ee4ba94a73831eab46c53bd01f2e02715e327 100644 (file)
@@ -122,6 +122,16 @@ uint32_t ComputeCRC(uint32_t crc, const void *pData, uint32_t size)
     return crc;
 }
 
+//////////////////////////////////////////////////////////////////////////
+/// 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
 //////////////////////////////////////////////////////////////////////////
index 427884004f5f90e6227fe7b4fd9ec3fd4e887788..f2e6e532bbf82fcf8ad4d367dfac4fdcdb264b3e 100644 (file)
@@ -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*
index fbb49486892801adcd5685b6cb48c2d70ee12d3c..402fd2652f22073355bfcbdb72be94dd589e692e 100644 (file)
@@ -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;