template <typename T, int NUM_ELEMENTS>
struct UncheckedFixedVector
{
- UncheckedFixedVector() : mSize(0)
- {
- }
-
- UncheckedFixedVector(std::size_t size, T const& exemplar)
- {
- this->mSize = 0;
- for (std::size_t i = 0; i < size; ++i)
- this->push_back(exemplar);
- }
-
- template <typename Iter>
- UncheckedFixedVector(Iter fst, Iter lst)
- {
- this->mSize = 0;
- for ( ; fst != lst; ++fst)
- this->push_back(*fst);
- }
-
- UncheckedFixedVector(UncheckedFixedVector const& UFV)
- {
- this->mSize = 0;
- for (std::size_t i = 0, N = UFV.size(); i < N; ++i)
- (*this)[i] = UFV[i];
- this->mSize = UFV.size();
- }
-
- UncheckedFixedVector& operator=(UncheckedFixedVector const& UFV)
- {
- for (std::size_t i = 0, N = UFV.size(); i < N; ++i)
- (*this)[i] = UFV[i];
- this->mSize = UFV.size();
- return *this;
- }
-
- T* begin() { return &this->mElements[0]; }
- T* end() { return &this->mElements[0] + this->mSize; }
- T const* begin() const { return &this->mElements[0]; }
- T const* end() const { return &this->mElements[0] + this->mSize; }
-
- friend bool operator==(UncheckedFixedVector const& L, UncheckedFixedVector const& R)
- {
- if (L.size() != R.size()) return false;
- for (std::size_t i = 0, N = L.size(); i < N; ++i)
- {
- if (L[i] != R[i]) return false;
- }
- return true;
- }
-
- friend bool operator!=(UncheckedFixedVector const& L, UncheckedFixedVector const& R)
- {
- if (L.size() != R.size()) return true;
- for (std::size_t i = 0, N = L.size(); i < N; ++i)
- {
- if (L[i] != R[i]) return true;
- }
- return false;
- }
-
- T& operator[](std::size_t idx)
- {
- return this->mElements[idx];
- }
- T const& operator[](std::size_t idx) const
- {
- return this->mElements[idx];
- }
- void push_back(T const& t)
- {
- this->mElements[this->mSize] = t;
- ++this->mSize;
- }
- void pop_back()
- {
- SWR_ASSERT(this->mSize > 0);
- --this->mSize;
- }
- T& back()
- {
- return this->mElements[this->mSize-1];
- }
- T const& back() const
- {
- return this->mElements[this->mSize-1];
- }
- bool empty() const
- {
- return this->mSize == 0;
- }
- std::size_t size() const
- {
- return this->mSize;
- }
- void resize(std::size_t sz)
- {
- this->mSize = sz;
- }
- void clear()
- {
- this->resize(0);
- }
+ UncheckedFixedVector() : mSize(0)
+ {
+ }
+
+ UncheckedFixedVector(std::size_t size, T const& exemplar)
+ {
+ this->mSize = 0;
+ for (std::size_t i = 0; i < size; ++i)
+ this->push_back(exemplar);
+ }
+
+ template <typename Iter>
+ UncheckedFixedVector(Iter fst, Iter lst)
+ {
+ this->mSize = 0;
+ for ( ; fst != lst; ++fst)
+ this->push_back(*fst);
+ }
+
+ UncheckedFixedVector(UncheckedFixedVector const& UFV)
+ {
+ this->mSize = 0;
+ for (std::size_t i = 0, N = UFV.size(); i < N; ++i)
+ (*this)[i] = UFV[i];
+ this->mSize = UFV.size();
+ }
+
+ UncheckedFixedVector& operator=(UncheckedFixedVector const& UFV)
+ {
+ for (std::size_t i = 0, N = UFV.size(); i < N; ++i)
+ (*this)[i] = UFV[i];
+ this->mSize = UFV.size();
+ return *this;
+ }
+
+ T* begin() { return &this->mElements[0]; }
+ T* end() { return &this->mElements[0] + this->mSize; }
+ T const* begin() const { return &this->mElements[0]; }
+ T const* end() const { return &this->mElements[0] + this->mSize; }
+
+ friend bool operator==(UncheckedFixedVector const& L, UncheckedFixedVector const& R)
+ {
+ if (L.size() != R.size()) return false;
+ for (std::size_t i = 0, N = L.size(); i < N; ++i)
+ {
+ if (L[i] != R[i]) return false;
+ }
+ return true;
+ }
+
+ friend bool operator!=(UncheckedFixedVector const& L, UncheckedFixedVector const& R)
+ {
+ if (L.size() != R.size()) return true;
+ for (std::size_t i = 0, N = L.size(); i < N; ++i)
+ {
+ if (L[i] != R[i]) return true;
+ }
+ return false;
+ }
+
+ T& operator[](std::size_t idx)
+ {
+ return this->mElements[idx];
+ }
+ T const& operator[](std::size_t idx) const
+ {
+ return this->mElements[idx];
+ }
+ void push_back(T const& t)
+ {
+ this->mElements[this->mSize] = t;
+ ++this->mSize;
+ }
+ void pop_back()
+ {
+ SWR_ASSERT(this->mSize > 0);
+ --this->mSize;
+ }
+ T& back()
+ {
+ return this->mElements[this->mSize-1];
+ }
+ T const& back() const
+ {
+ return this->mElements[this->mSize-1];
+ }
+ bool empty() const
+ {
+ return this->mSize == 0;
+ }
+ std::size_t size() const
+ {
+ return this->mSize;
+ }
+ void resize(std::size_t sz)
+ {
+ this->mSize = sz;
+ }
+ void clear()
+ {
+ this->resize(0);
+ }
private:
- std::size_t mSize;
- T mElements[NUM_ELEMENTS];
+ std::size_t mSize{ 0 };
+ T mElements[NUM_ELEMENTS];
};
template <typename T, int NUM_ELEMENTS>
struct FixedStack : UncheckedFixedVector<T, NUM_ELEMENTS>
{
- FixedStack() {}
-
- void push(T const& t)
- {
- this->push_back(t);
- }
-
- void pop()
- {
- this->pop_back();
- }
-
- T& top()
- {
- return this->back();
- }
-
- T const& top() const
- {
- return this->back();
- }
+ FixedStack() {}
+
+ void push(T const& t)
+ {
+ this->push_back(t);
+ }
+
+ void pop()
+ {
+ this->pop_back();
+ }
+
+ T& top()
+ {
+ return this->back();
+ }
+
+ T const& top() const
+ {
+ return this->back();
+ }
};
template <typename T>
template <typename T, int N>
struct hash<SWRL::UncheckedFixedVector<T, N>>
{
- size_t operator() (SWRL::UncheckedFixedVector<T, N> const& v) const
- {
- if (v.size() == 0) return 0;
- std::hash<T> H;
- size_t x = H(v[0]);
- if (v.size() == 1) return x;
- for (size_t i = 1; i < v.size(); ++i)
- x ^= H(v[i]) + 0x9e3779b9 + (x<<6) + (x>>2);
- return x;
- }
+ size_t operator() (SWRL::UncheckedFixedVector<T, N> const& v) const
+ {
+ if (v.size() == 0) return 0;
+ std::hash<T> H;
+ size_t x = H(v[0]);
+ if (v.size() == 1) return x;
+ for (size_t i = 1; i < v.size(); ++i)
+ x ^= H(v[i]) + 0x9e3779b9 + (x<<6) + (x>>2);
+ return x;
+ }
};
std::string name;
// id for this thread, assigned by the thread manager
- uint32_t id;
+ uint32_t id{ 0 };
// root of the bucket hierarchy for this thread
BUCKET root;
// currently executing bucket somewhere in the hierarchy
- BUCKET* pCurrent;
+ BUCKET* pCurrent{ nullptr };
// currently executing hierarchy level
uint32_t level{ 0 };
psContext.vY.center = _simd_add_ps(vCenterOffsetsY, _simd_set1_ps((float)yy));
for(uint32_t xx = x; xx < x + KNOB_TILE_X_DIM; xx += SIMD_TILE_X_DIM)
{
- simdscalar vZ[MultisampleTraits<sampleCount>::numSamples];
+ simdscalar vZ[MultisampleTraits<sampleCount>::numSamples]{ 0 };
psContext.vX.UL = _simd_add_ps(vULOffsetsX, _simd_set1_ps((float)xx));
// set pixel center positions
psContext.vX.center = _simd_add_ps(vCenterOffsetsX, _simd_set1_ps((float)xx));
return vNumOutPts;
}
- const uint32_t workerId;
- const DRIVER_TYPE driverType;
- DRAW_CONTEXT* pDC;
+ const uint32_t workerId{ 0 };
+ const DRIVER_TYPE driverType{ DX };
+ DRAW_CONTEXT* pDC{ nullptr };
const API_STATE& state;
simdscalar clipCodes[NumVertsPerPrim];
};
struct PA_STATE
{
- DRAW_CONTEXT *pDC; // draw context
- uint8_t* pStreamBase; // vertex stream
- uint32_t streamSizeInVerts; // total size of the input stream in verts
+ DRAW_CONTEXT *pDC{ nullptr }; // draw context
+ uint8_t* pStreamBase{ nullptr }; // vertex stream
+ uint32_t streamSizeInVerts{ 0 }; // total size of the input stream in verts
// The topology the binner will use. In some cases the FE changes the topology from the api state.
- PRIMITIVE_TOPOLOGY binTopology;
+ PRIMITIVE_TOPOLOGY binTopology{ TOP_UNKNOWN };
PA_STATE() {}
PA_STATE(DRAW_CONTEXT *in_pDC, uint8_t* in_pStreamBase, uint32_t in_streamSizeInVerts) :
// cuts
struct PA_STATE_OPT : public PA_STATE
{
- simdvertex leadingVertex; // For tri-fan
- uint32_t numPrims; // Total number of primitives for draw.
- uint32_t numPrimsComplete; // Total number of complete primitives.
+ simdvertex leadingVertex; // For tri-fan
+ uint32_t numPrims{ 0 }; // Total number of primitives for draw.
+ uint32_t numPrimsComplete{ 0 }; // Total number of complete primitives.
- uint32_t numSimdPrims; // Number of prims in current simd.
+ uint32_t numSimdPrims{ 0 }; // Number of prims in current simd.
- uint32_t cur; // index to current VS output.
- uint32_t prev; // index to prev VS output. Not really needed in the state.
- uint32_t first; // index to first VS output. Used for trifan.
+ uint32_t cur{ 0 }; // index to current VS output.
+ uint32_t prev{ 0 }; // index to prev VS output. Not really needed in the state.
+ uint32_t first{ 0 }; // index to first VS output. Used for trifan.
- uint32_t counter; // state counter
- bool reset; // reset state
+ uint32_t counter{ 0 }; // state counter
+ bool reset{ false }; // reset state
- uint32_t primIDIncr; // how much to increment for each vector (typically vector / {1, 2})
+ uint32_t primIDIncr{ 0 }; // how much to increment for each vector (typically vector / {1, 2})
simdscalari primID;
typedef bool(*PFN_PA_FUNC)(PA_STATE_OPT& state, uint32_t slot, simdvector verts[]);
typedef void(*PFN_PA_SINGLE_FUNC)(PA_STATE_OPT& pa, uint32_t slot, uint32_t primIndex, __m128 verts[]);
- PFN_PA_FUNC pfnPaFunc; // PA state machine function for assembling 4 triangles.
- PFN_PA_SINGLE_FUNC pfnPaSingleFunc; // PA state machine function for assembling single triangle.
- PFN_PA_FUNC pfnPaFuncReset; // initial state to set on reset
+ PFN_PA_FUNC pfnPaFunc{ nullptr }; // PA state machine function for assembling 4 triangles.
+ PFN_PA_SINGLE_FUNC pfnPaSingleFunc{ nullptr }; // PA state machine function for assembling single triangle.
+ PFN_PA_FUNC pfnPaFuncReset{ nullptr }; // initial state to set on reset
// state used to advance the PA when Next is called
- PFN_PA_FUNC pfnPaNextFunc;
- uint32_t nextNumSimdPrims;
- uint32_t nextNumPrimsIncrement;
- bool nextReset;
- bool isStreaming;
+ PFN_PA_FUNC pfnPaNextFunc{ nullptr };
+ uint32_t nextNumSimdPrims{ 0 };
+ uint32_t nextNumPrimsIncrement{ 0 };
+ bool nextReset{ false };
+ bool isStreaming{ false };
- simdmask tmpIndices; // temporary index store for unused virtual function
+ simdmask tmpIndices{ 0 }; // temporary index store for unused virtual function
PA_STATE_OPT() {}
PA_STATE_OPT(DRAW_CONTEXT* pDC, uint32_t numPrims, uint8_t* pStream, uint32_t streamSizeInVerts,
// Cut-aware primitive assembler.
struct PA_STATE_CUT : public PA_STATE
{
- simdmask* pCutIndices; // cut indices buffer, 1 bit per vertex
- uint32_t numVerts; // number of vertices available in buffer store
- uint32_t numAttribs; // number of attributes
- int32_t numRemainingVerts; // number of verts remaining to be assembled
- uint32_t numVertsToAssemble; // total number of verts to assemble for the draw
+ simdmask* pCutIndices{ nullptr }; // cut indices buffer, 1 bit per vertex
+ uint32_t numVerts{ 0 }; // number of vertices available in buffer store
+ uint32_t numAttribs{ 0 }; // number of attributes
+ int32_t numRemainingVerts{ 0 }; // number of verts remaining to be assembled
+ uint32_t numVertsToAssemble{ 0 }; // total number of verts to assemble for the draw
OSALIGNSIMD(uint32_t) indices[MAX_NUM_VERTS_PER_PRIM][KNOB_SIMD_WIDTH]; // current index buffer for gather
simdscalari vOffsets[MAX_NUM_VERTS_PER_PRIM]; // byte offsets for currently assembling simd
- uint32_t numPrimsAssembled; // number of primitives that are fully assembled
- uint32_t headVertex; // current unused vertex slot in vertex buffer store
- uint32_t tailVertex; // beginning vertex currently assembling
- uint32_t curVertex; // current unprocessed vertex
- uint32_t startPrimId; // starting prim id
- simdscalari vPrimId; // vector of prim ID
- bool needOffsets; // need to compute gather offsets for current SIMD
- uint32_t vertsPerPrim;
- simdvertex tmpVertex; // temporary simdvertex for unimplemented API
- bool processCutVerts; // vertex indices with cuts should be processed as normal, otherwise they
- // are ignored. Fetch shader sends invalid verts on cuts that should be ignored
- // while the GS sends valid verts for every index
+ uint32_t numPrimsAssembled{ 0 }; // number of primitives that are fully assembled
+ uint32_t headVertex{ 0 }; // current unused vertex slot in vertex buffer store
+ uint32_t tailVertex{ 0 }; // beginning vertex currently assembling
+ uint32_t curVertex{ 0 }; // current unprocessed vertex
+ uint32_t startPrimId{ 0 }; // starting prim id
+ simdscalari vPrimId; // vector of prim ID
+ bool needOffsets{ false }; // need to compute gather offsets for current SIMD
+ uint32_t vertsPerPrim{ 0 };
+ simdvertex tmpVertex; // temporary simdvertex for unimplemented API
+ bool processCutVerts{ false }; // vertex indices with cuts should be processed as normal, otherwise they
+ // are ignored. Fetch shader sends invalid verts on cuts that should be ignored
+ // while the GS sends valid verts for every index
// Topology state tracking
uint32_t vert[MAX_NUM_VERTS_PER_PRIM];
- uint32_t curIndex;
- bool reverseWinding; // indicates reverse winding for strips
- int32_t adjExtraVert; // extra vert uses for tristrip w/ adj
+ uint32_t curIndex{ 0 };
+ bool reverseWinding{ false }; // indicates reverse winding for strips
+ int32_t adjExtraVert{ 0 }; // extra vert uses for tristrip w/ adj
typedef void(PA_STATE_CUT::* PFN_PA_FUNC)(uint32_t vert, bool finish);
- PFN_PA_FUNC pfnPa; // per-topology function that processes a single vert
+ PFN_PA_FUNC pfnPa{ nullptr }; // per-topology function that processes a single vert
PA_STATE_CUT() {}
PA_STATE_CUT(DRAW_CONTEXT* pDC, uint8_t* in_pStream, uint32_t in_streamSizeInVerts, simdmask* in_pIndices, uint32_t in_numVerts,
PA_STATE_OPT paOpt;
PA_STATE_CUT paCut;
- bool cutPA;
+ bool cutPA{ false };
- PRIMITIVE_TOPOLOGY topo;
+ PRIMITIVE_TOPOLOGY topo{ TOP_UNKNOWN };
simdvertex vertexStore[MAX_NUM_VERTS_PER_PRIM];
simdmask indexStore[MAX_NUM_VERTS_PER_PRIM];
private:
Arena& mArena;
- SWR_FORMAT mFormat;
std::unordered_map<uint32_t, MacroTileQueue> mTiles;
// Any tile that has work queued to it is a dirty tile.
std::vector<uint32_t> mDirtyTiles;
- OSALIGNLINE(LONG) mWorkItemsProduced;
- OSALIGNLINE(volatile LONG) mWorkItemsConsumed;
+ OSALIGNLINE(LONG) mWorkItemsProduced { 0 };
+ OSALIGNLINE(volatile LONG) mWorkItemsConsumed { 0 };
};
//////////////////////////////////////////////////////////////////////////
void *operator new(size_t size);
void operator delete (void *p);
- void* mpTaskData; // The API thread will set this up and the callback task function will interpet this.
+ void* mpTaskData{ nullptr }; // The API thread will set this up and the callback task function will interpet this.
OSALIGNLINE(volatile LONG) mTasksAvailable{ 0 };
OSALIGNLINE(volatile LONG) mTasksOutstanding{ 0 };
OSALIGNLINE(struct) BBOX
{
- int top, bottom, left, right;
+ int top{ 0 };
+ int bottom{ 0 };
+ int left{ 0 };
+ int right{ 0 };
BBOX() {}
BBOX(int t, int b, int l, int r) : top(t), bottom(b), left(l), right(r) {}
struct simdBBox
{
- simdscalari top, bottom, left, right;
+ simdscalari top;
+ simdscalari bottom;
+ simdscalari left;
+ simdscalari right;
};
INLINE
FunctionType* mTrinaryFPTy;
FunctionType* mUnaryIntTy;
FunctionType* mBinaryIntTy;
- FunctionType* mTrinaryIntTy;
Type* mSimtFP32Ty;
Type* mSimtInt32Ty;
vsnprintf_s(strBuf, _TRUNCATE, fmt, args);
OutputDebugString(strBuf);
#endif
+
+ va_end(args);
}
Value *Builder::VEXTRACTI128(Value* a, Constant* imm8)
BYTE* pDstPixel,
const float srcPixel[4])
{
- UINT outColor[4]; // typeless bits
+ uint32_t outColor[4] = { 0 }; // typeless bits
// Store component
for (UINT comp = 0; comp < FormatTraits<DstFormat>::numComps; ++comp)
float dstPixel[4],
const BYTE* pSrc)
{
- UINT srcColor[4]; // typeless bits
+ uint32_t srcColor[4]; // typeless bits
// unpack src pixel
typename FormatTraits<SrcFormat>::FormatT* pPixel = (typename FormatTraits<SrcFormat>::FormatT*)pSrc;
}
// Convert components
- for (UINT comp = 0; comp < FormatTraits<SrcFormat>::numComps; ++comp)
+ for (uint32_t comp = 0; comp < FormatTraits<SrcFormat>::numComps; ++comp)
{
SWR_TYPE type = FormatTraits<SrcFormat>::GetType(comp);
- UINT src = srcColor[comp];
+ uint32_t src = srcColor[comp];
switch (type)
{
}
case SWR_TYPE_UINT:
{
- UINT dst = (UINT)src;
+ uint32_t dst = (uint32_t)src;
dstPixel[FormatTraits<SrcFormat>::swizzle(comp)] = *(float*)&dst;
break;
}