swr/rast: stop using MSFT types in platform independent code

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
Tim Rowley 2017-07-20 13:48:28 -05:00
parent 030cfa8eed
commit f253798205
14 changed files with 35 additions and 31 deletions

View 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)
{

View File

@ -189,7 +189,7 @@ void QueueWork(SWR_CONTEXT *pContext)
if (IsDraw)
{
InterlockedIncrement((volatile LONG*)&pContext->drawsOutstandingFE);
InterlockedIncrement((volatile long*)&pContext->drawsOutstandingFE);
}
_ReadWriteBarrier();

View 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);

View 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;

View 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;

View 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)
{

View 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);
}

View File

@ -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];

View 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

View 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)

View 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 };
};

View 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
//////////////////////////////////////////////////////////////////////////

View 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*

View 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;