return ret;
}
-inline
-unsigned char _bittest(const LONG *a, LONG b)
-{
- return ((*(unsigned *)(a) & (1 << b)) != 0);
-}
-
static inline
void AlignedFree(void* p)
{
if (IsDraw)
{
- InterlockedIncrement((volatile LONG*)&pContext->drawsOutstandingFE);
+ InterlockedIncrement((volatile long*)&pContext->drawsOutstandingFE);
}
_ReadWriteBarrier();
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);
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;
if (HasConstantInterpT::value || IsDegenerate::value)
{
- if (_bittest(&constantInterpMask, i))
+ if (CheckBit(constantInterpMask, i))
{
uint32_t vid;
uint32_t adjustedTriIndex;
}
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;
// 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)
{
// 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)
{
// 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)
{
// 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)
{
}
// try to lock the FIFO
- LONG initial = InterlockedCompareExchange(&mLock, 1, 0);
+ long initial = InterlockedCompareExchange(&mLock, 1, 0);
return (initial == 0);
}
//////////////////////////////////////////////////////////////////////////
/// 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];
{
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
// 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);
_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)
// 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);
// Otherwise, there is no more work to do.
bool getWork(uint32_t& groupId)
{
- LONG result = InterlockedDecrement(&mTasksAvailable);
+ long result = InterlockedDecrement(&mTasksAvailable);
if (result >= 0)
{
/// 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;
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 };
};
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
//////////////////////////////////////////////////////////////////////////
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*
/// 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;