From: Tim Rowley Date: Thu, 20 Jul 2017 18:48:28 +0000 (-0500) Subject: swr/rast: stop using MSFT types in platform independent code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f253798205a3ce7f577867a96ce487bf20e10909;p=mesa.git swr/rast: stop using MSFT types in platform independent code Reviewed-by: Bruce Cherniak --- diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h index dc90fca7501..4ed6b88e454 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 855d133920a..8dc9ac24a74 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 236e0fcd666..a39420552b5 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 de6691b4cf8..c1f0f07804f 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 1b98e442fd8..c89c47646a3 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 -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 bf16792a0a6..ca6596eafbf 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 49ba71f6435..3be72f37cd6 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 1721aa46e75..c04ea5f8ee7 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 +template 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 4bb3236a638..cb3470ff6b8 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 36710bf0da5..70bde027ee0 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 8f1cd21543d..8ef74a7f4b9 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 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 a8c58d9d4ef..392ee4ba94a 100644 --- a/src/gallium/drivers/swr/rasterizer/core/utils.h +++ b/src/gallium/drivers/swr/rasterizer/core/utils.h @@ -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 +INLINE +static bool CheckBit(T word, uint32_t bit) +{ + return 0 != (word & (T(1) << bit)); +} + ////////////////////////////////////////////////////////////////////////// /// Add byte offset to any-type pointer ////////////////////////////////////////////////////////////////////////// diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp index 427884004f5..f2e6e532bbf 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 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 fbb49486892..402fd2652f2 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;