Coordinate::Coordinate()
{
- dim = 'x';
+ dim = DIM_X;
ord = 0;
}
-Coordinate::Coordinate(INT_8 c, INT_32 n)
+Coordinate::Coordinate(enum Dim dim, INT_32 n)
{
- set(c, n);
+ set(dim, n);
}
-VOID Coordinate::set(INT_8 c, INT_32 n)
+VOID Coordinate::set(enum Dim d, INT_32 n)
{
- dim = c;
+ dim = d;
ord = static_cast<INT_8>(n);
}
-UINT_32 Coordinate::ison(UINT_32 x, UINT_32 y, UINT_32 z, UINT_32 s, UINT_32 m) const
+UINT_32 Coordinate::ison(const UINT_32 *coords) const
{
UINT_32 bit = static_cast<UINT_32>(1ull << static_cast<UINT_32>(ord));
- UINT_32 out = 0;
- switch (dim)
- {
- case 'm': out = m & bit; break;
- case 's': out = s & bit; break;
- case 'x': out = x & bit; break;
- case 'y': out = y & bit; break;
- case 'z': out = z & bit; break;
- }
- return (out != 0) ? 1 : 0;
+ return (coords[dim] & bit) ? 1 : 0;
}
-INT_8 Coordinate::getdim()
+enum Dim Coordinate::getdim()
{
return dim;
}
return num_coords;
}
-UINT_32 CoordTerm::getxor(UINT_32 x, UINT_32 y, UINT_32 z, UINT_32 s, UINT_32 m) const
+UINT_32 CoordTerm::getxor(const UINT_32 *coords) const
{
UINT_32 out = 0;
for (UINT_32 i = 0; i < num_coords; i++)
{
- out = out ^ m_coord[i].ison(x, y, z, s, m);
+ out = out ^ m_coord[i].ison(coords);
}
return out;
}
co = m_coord[0];
}
-UINT_32 CoordTerm::Filter(INT_8 f, Coordinate& co, UINT_32 start, INT_8 axis)
+UINT_32 CoordTerm::Filter(INT_8 f, Coordinate& co, UINT_32 start, enum Dim axis)
{
for (UINT_32 i = start; i < num_coords;)
{
if (((f == '<' && m_coord[i] < co) ||
(f == '>' && m_coord[i] > co) ||
(f == '=' && m_coord[i] == co)) &&
- (axis == '\0' || axis == m_coord[i].getdim()))
+ (axis == NUM_DIMS || axis == m_coord[i].getdim()))
{
for (UINT_32 j = i; j < num_coords - 1; j++)
{
return !(*this == b);
}
-BOOL_32 CoordTerm::exceedRange(UINT_32 xRange, UINT_32 yRange, UINT_32 zRange, UINT_32 sRange)
+BOOL_32 CoordTerm::exceedRange(const UINT_32 *ranges)
{
BOOL_32 exceed = FALSE;
for (UINT_32 i = 0; (i < num_coords) && (exceed == FALSE); i++)
{
- UINT_32 subject;
- switch (m_coord[i].getdim())
- {
- case 'x':
- subject = xRange;
- break;
- case 'y':
- subject = yRange;
- break;
- case 'z':
- subject = zRange;
- break;
- case 's':
- subject = sRange;
- break;
- case 'm':
- subject = 0;
- break;
- default:
- // Invalid input!
- ADDR_ASSERT_ALWAYS();
- subject = 0;
- break;
- }
-
- exceed = ((1u << m_coord[i].getord()) <= subject);
+ exceed = ((1u << m_coord[i].getord()) <= ranges[m_coord[i].getdim()]);
}
return exceed;
return m_numBits;
}
-UINT_64 CoordEq::solve(UINT_32 x, UINT_32 y, UINT_32 z, UINT_32 s, UINT_32 m) const
+UINT_64 CoordEq::solve(const UINT_32 *coords) const
{
UINT_64 out = 0;
for (UINT_32 i = 0; i < m_numBits; i++)
{
- if (m_eq[i].getxor(x, y, z, s, m) != 0)
- {
- out |= (1ULL << i);
- }
+ out |= static_cast<UINT_64>(m_eq[i].getxor(coords)) << i;
}
return out;
}
VOID CoordEq::solveAddr(
UINT_64 addr, UINT_32 sliceInM,
- UINT_32& x, UINT_32& y, UINT_32& z, UINT_32& s, UINT_32& m) const
+ UINT_32 *coords) const
{
- UINT_32 xBitsValid = 0;
- UINT_32 yBitsValid = 0;
- UINT_32 zBitsValid = 0;
- UINT_32 sBitsValid = 0;
- UINT_32 mBitsValid = 0;
+ UINT_32 BitsValid[NUM_DIMS] = {0};
CoordEq temp = *this;
- x = y = z = s = m = 0;
+ memset(coords, 0, NUM_DIMS * sizeof(coords[0]));
UINT_32 bitsLeft = 0;
if (termSize == 1)
{
INT_8 bit = (addr >> i) & 1;
- INT_8 dim = temp.m_eq[i][0].getdim();
+ enum Dim dim = temp.m_eq[i][0].getdim();
INT_8 ord = temp.m_eq[i][0].getord();
ADDR_ASSERT((ord < 32) || (bit == 0));
- switch (dim)
- {
- case 'x':
- xBitsValid |= (1 << ord);
- x |= (bit << ord);
- break;
- case 'y':
- yBitsValid |= (1 << ord);
- y |= (bit << ord);
- break;
- case 'z':
- zBitsValid |= (1 << ord);
- z |= (bit << ord);
- break;
- case 's':
- sBitsValid |= (1 << ord);
- s |= (bit << ord);
- break;
- case 'm':
- mBitsValid |= (1 << ord);
- m |= (bit << ord);
- break;
- default:
- break;
- }
+ BitsValid[dim] |= 1u << ord;
+ coords[dim] |= bit << ord;
temp.m_eq[i].Clear();
}
{
if (sliceInM != 0)
{
- z = m / sliceInM;
- zBitsValid = 0xffffffff;
+ coords[DIM_Z] = coords[DIM_M] / sliceInM;
+ BitsValid[DIM_Z] = 0xffffffff;
}
do
if (termSize == 1)
{
INT_8 bit = (addr >> i) & 1;
- INT_8 dim = temp.m_eq[i][0].getdim();
+ enum Dim dim = temp.m_eq[i][0].getdim();
INT_8 ord = temp.m_eq[i][0].getord();
ADDR_ASSERT((ord < 32) || (bit == 0));
+ ADDR_ASSERT(dim < DIM_S);
- switch (dim)
- {
- case 'x':
- xBitsValid |= (1 << ord);
- x |= (bit << ord);
- break;
- case 'y':
- yBitsValid |= (1 << ord);
- y |= (bit << ord);
- break;
- case 'z':
- zBitsValid |= (1 << ord);
- z |= (bit << ord);
- break;
- case 's':
- ADDR_ASSERT_ALWAYS();
- break;
- case 'm':
- ADDR_ASSERT_ALWAYS();
- break;
- default:
- break;
- }
+ BitsValid[dim] |= 1u << ord;
+ coords[dim] |= bit << ord;
temp.m_eq[i].Clear();
}
for (UINT_32 j = 0; j < termSize; j++)
{
- INT_8 dim = temp.m_eq[i][j].getdim();
+ enum Dim dim = temp.m_eq[i][j].getdim();
INT_8 ord = temp.m_eq[i][j].getord();
- switch (dim)
+ ADDR_ASSERT(dim < DIM_S);
+
+ if (BitsValid[dim] & (1u << ord))
{
- case 'x':
- if (xBitsValid & (1 << ord))
- {
- UINT_32 v = (((x >> ord) & 1) << i);
- addr ^= static_cast<UINT_64>(v);
- tmpTerm.remove(temp.m_eq[i][j]);
- }
- break;
- case 'y':
- if (yBitsValid & (1 << ord))
- {
- UINT_32 v = (((y >> ord) & 1) << i);
- addr ^= static_cast<UINT_64>(v);
- tmpTerm.remove(temp.m_eq[i][j]);
- }
- break;
- case 'z':
- if (zBitsValid & (1 << ord))
- {
- UINT_32 v = (((z >> ord) & 1) << i);
- addr ^= static_cast<UINT_64>(v);
- tmpTerm.remove(temp.m_eq[i][j]);
- }
- break;
- case 's':
- ADDR_ASSERT_ALWAYS();
- break;
- case 'm':
- ADDR_ASSERT_ALWAYS();
- break;
- default:
- break;
+ UINT_32 v = (((coords[dim] >> ord) & 1) << i);
+ addr ^= static_cast<UINT_64>(v);
+ tmpTerm.remove(temp.m_eq[i][j]);
}
}
}
}
-UINT_32 CoordEq::Filter(INT_8 f, Coordinate& co, UINT_32 start, INT_8 axis)
+UINT_32 CoordEq::Filter(INT_8 f, Coordinate& co, UINT_32 start, enum Dim axis)
{
for (UINT_32 i = start; i < m_numBits;)
{
namespace V2
{
+enum Dim
+{
+ DIM_X,
+ DIM_Y,
+ DIM_Z,
+ DIM_S,
+ DIM_M,
+ NUM_DIMS
+};
+
class Coordinate
{
public:
Coordinate();
- Coordinate(INT_8 c, INT_32 n);
+ Coordinate(enum Dim dim, INT_32 n);
- VOID set(INT_8 c, INT_32 n);
- UINT_32 ison(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const;
- INT_8 getdim();
+ VOID set(enum Dim dim, INT_32 n);
+ UINT_32 ison(const UINT_32 *coords) const;
+ enum Dim getdim();
INT_8 getord();
BOOL_32 operator==(const Coordinate& b);
Coordinate& operator++(INT_32);
private:
- INT_8 dim;
+ enum Dim dim;
INT_8 ord;
};
BOOL_32 Exists(Coordinate& co);
VOID copyto(CoordTerm& cl);
UINT_32 getsize();
- UINT_32 getxor(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const;
+ UINT_32 getxor(const UINT_32 *coords) const;
VOID getsmallest(Coordinate& co);
- UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, INT_8 axis = '\0');
+ UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
Coordinate& operator[](UINT_32 i);
BOOL_32 operator==(const CoordTerm& b);
BOOL_32 operator!=(const CoordTerm& b);
- BOOL_32 exceedRange(UINT_32 xRange, UINT_32 yRange = 0, UINT_32 zRange = 0, UINT_32 sRange = 0);
+ BOOL_32 exceedRange(const UINT_32 *ranges);
private:
static const UINT_32 MaxCoords = 8;
BOOL_32 Exists(Coordinate& co);
VOID resize(UINT_32 n);
UINT_32 getsize();
- virtual UINT_64 solve(UINT_32 x, UINT_32 y, UINT_32 z = 0, UINT_32 s = 0, UINT_32 m = 0) const;
+ virtual UINT_64 solve(const UINT_32 *coords) const;
virtual VOID solveAddr(UINT_64 addr, UINT_32 sliceInM,
- UINT_32& x, UINT_32& y, UINT_32& z, UINT_32& s, UINT_32& m) const;
+ UINT_32 *coords) const;
VOID copy(CoordEq& o, UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
VOID reverse(UINT_32 start = 0, UINT_32 num = 0xFFFFFFFF);
VOID xorin(CoordEq& x, UINT_32 start = 0);
- UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, INT_8 axis = '\0');
+ UINT_32 Filter(INT_8 f, Coordinate& co, UINT_32 start = 0, enum Dim axis = NUM_DIMS);
VOID shift(INT_32 amount, INT_32 start = 0);
virtual CoordTerm& operator[](UINT_32 i);
VOID mort2d(Coordinate& c0, Coordinate& c1, UINT_32 start = 0, UINT_32 end = 0);
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
- UINT_64 address = pMetaEq->solve(pIn->x, pIn->y, pIn->slice, 0, blockIndex);
+ UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, 0, blockIndex };
+ UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
pOut->bitPosition = static_cast<UINT_32>((address & 1) << 2);
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
- UINT_64 address = pMetaEq->solve(pIn->x, pIn->y, pIn->slice, 0, blockIndex);
+ UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, 0, blockIndex };
+ UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
UINT_32 pitchInBlock = output.pitch / output.metaBlkWidth;
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
- UINT_32 x, y, z, s, m;
- pMetaEq->solveAddr(nibbleAddress, sliceSizeInBlock, x, y, z, s, m);
+ UINT_32 coords[NUM_DIMS];
+ pMetaEq->solveAddr(nibbleAddress, sliceSizeInBlock, coords);
- pOut->slice = m / sliceSizeInBlock;
- pOut->y = ((m % sliceSizeInBlock) / pitchInBlock) * output.metaBlkHeight + y;
- pOut->x = (m % pitchInBlock) * output.metaBlkWidth + x;
+ pOut->slice = coords[DIM_M] / sliceSizeInBlock;
+ pOut->y = ((coords[DIM_M] % sliceSizeInBlock) / pitchInBlock) * output.metaBlkHeight + coords[DIM_Y];
+ pOut->x = (coords[DIM_M] % pitchInBlock) * output.metaBlkWidth + coords[DIM_X];
}
}
UINT_32 sliceSizeInBlock = (output.height / output.metaBlkHeight) * pitchInBlock;
UINT_32 blockIndex = zb * sliceSizeInBlock + yb * pitchInBlock + xb;
- UINT_64 address = pMetaEq->solve(pIn->x, pIn->y, pIn->slice, pIn->sample, blockIndex);
+ UINT_32 coords[] = { pIn->x, pIn->y, pIn->slice, pIn->sample, blockIndex };
+ UINT_64 address = pMetaEq->solve(coords);
pOut->addr = address >> 1;
{
// RB's are distributed on 16x16, except when we have 1 rb per se, in which case its 32x32
UINT_32 rbRegion = (numRbPerSeLog2 == 0) ? 5 : 4;
- Coordinate cx('x', rbRegion);
- Coordinate cy('y', rbRegion);
+ Coordinate cx(DIM_X, rbRegion);
+ Coordinate cy(DIM_Y, rbRegion);
UINT_32 start = 0;
UINT_32 numRbTotalLog2 = numRbPerSeLog2 + numSeLog2;
UINT_32 numSamplesLog2) ///< [in] data surface sample count
const
{
- Coordinate cx('x', 0);
- Coordinate cy('y', 0);
- Coordinate cz('z', 0);
- Coordinate cs('s', 0);
+ Coordinate cx(DIM_X, 0);
+ Coordinate cy(DIM_Y, 0);
+ Coordinate cz(DIM_Z, 0);
+ Coordinate cs(DIM_S, 0);
// Clear the equation
pDataEq->resize(0);
{
if (IsLinear(swizzleMode))
{
- Coordinate cm('m', 0);
+ Coordinate cm(DIM_M, 0);
pDataEq->resize(49);
// Fill in sample bits
for (i = 0; i < numSamplesLog2; i++)
{
- cs.set('s', i);
+ cs.set(DIM_S, i);
(*pDataEq)[tileSplitStart + i].add(cs);
}
// Fill in x/y bits above sample split
for (UINT_32 s = 0; s < numSamplesLog2; s++)
{
- cs.set('s', s);
+ cs.set(DIM_S, s);
(*pDataEq)[sampleStart + s].add(cs);
}
if (dataSurfaceType != Gfx9DataColor)
{
- Coordinate tileMin('x', 3);
+ Coordinate tileMin(DIM_X, 3);
while (dataEq[pipeInterleaveLog2 + pipeStart][0] < tileMin)
{
xorMask2.resize(numPipeLog2);
for (UINT_32 pipeIdx = 0; pipeIdx < numPipeLog2; pipeIdx++)
{
- co.set('z', numPipeLog2 - 1 - pipeIdx);
+ co.set(DIM_Z, numPipeLog2 - 1 - pipeIdx);
xorMask2[pipeIdx].add(co);
}
if (IsThick(resourceType, swizzleMode))
{
- Coordinate cx('x', 0);
- Coordinate cy('y', 0);
- Coordinate cz('z', 0);
+ Coordinate cx(DIM_X, 0);
+ Coordinate cy(DIM_Y, 0);
+ Coordinate cz(DIM_Z, 0);
if (maxMip > 0)
{
}
else
{
- Coordinate cx('x', 0);
- Coordinate cy('y', 0);
+ Coordinate cx(DIM_X, 0);
+ Coordinate cy(DIM_Y, 0);
Coordinate cs;
if (maxMip > 0)
//------------------------------------------------------------------------------------------------------------------------
for (UINT_32 s = 0; s < compFragLog2; s++)
{
- cs.set('s', s);
+ cs.set(DIM_S, s);
(*pMetaEq)[s].add(cs);
}
}
Coordinate co;
// filter out everything under the compressed block size
- co.set('x', compBlkWidthLog2);
- pMetaEq->Filter('<', co, 0, 'x');
- co.set('y', compBlkHeightLog2);
- pMetaEq->Filter('<', co, 0, 'y');
- co.set('z', compBlkDepthLog2);
- pMetaEq->Filter('<', co, 0, 'z');
+ co.set(DIM_X, compBlkWidthLog2);
+ pMetaEq->Filter('<', co, 0, DIM_X);
+ co.set(DIM_Y, compBlkHeightLog2);
+ pMetaEq->Filter('<', co, 0, DIM_Y);
+ co.set(DIM_Z, compBlkDepthLog2);
+ pMetaEq->Filter('<', co, 0, DIM_Z);
// For non-color, filter out sample bits
if (dataSurfaceType != Gfx9DataColor)
{
- co.set('x', 0);
- pMetaEq->Filter('<', co, 0, 's');
+ co.set(DIM_X, 0);
+ pMetaEq->Filter('<', co, 0, DIM_S);
}
// filter out everything above the metablock size
- co.set('x', metaBlkWidthLog2 - 1);
- pMetaEq->Filter('>', co, 0, 'x');
- co.set('y', metaBlkHeightLog2 - 1);
- pMetaEq->Filter('>', co, 0, 'y');
- co.set('z', metaBlkDepthLog2 - 1);
- pMetaEq->Filter('>', co, 0, 'z');
+ co.set(DIM_X, metaBlkWidthLog2 - 1);
+ pMetaEq->Filter('>', co, 0, DIM_X);
+ co.set(DIM_Y, metaBlkHeightLog2 - 1);
+ pMetaEq->Filter('>', co, 0, DIM_Y);
+ co.set(DIM_Z, metaBlkDepthLog2 - 1);
+ pMetaEq->Filter('>', co, 0, DIM_Z);
// filter out everything above the metablock size for the channel bits
- co.set('x', metaBlkWidthLog2 - 1);
- pipeEquation.Filter('>', co, 0, 'x');
- co.set('y', metaBlkHeightLog2 - 1);
- pipeEquation.Filter('>', co, 0, 'y');
- co.set('z', metaBlkDepthLog2 - 1);
- pipeEquation.Filter('>', co, 0, 'z');
+ co.set(DIM_X, metaBlkWidthLog2 - 1);
+ pipeEquation.Filter('>', co, 0, DIM_X);
+ co.set(DIM_Y, metaBlkHeightLog2 - 1);
+ pipeEquation.Filter('>', co, 0, DIM_Y);
+ co.set(DIM_Z, metaBlkDepthLog2 - 1);
+ pipeEquation.Filter('>', co, 0, DIM_Z);
// Make sure we still have the same number of channel bits
if (pipeEquation.getsize() != numPipeTotalLog2)
if (m_settings.applyAliasFix)
{
- co.set('z', -1);
+ co.set(DIM_Z, -1);
}
// Loop through each rb id bit; if it is equal to any of the filtered channel bits, clear it
CoordTerm filteredPipeEq;
filteredPipeEq = pipeEquation[j];
- filteredPipeEq.Filter('>', co, 0, 'z');
+ filteredPipeEq.Filter('>', co, 0, DIM_Z);
isRbEquationInPipeEquation = (rbEquation[i] == filteredPipeEq);
}
// Concatenate the macro address above the current address
for (UINT_32 i = metaSize, j = 0; i < 49; i++, j++)
{
- co.set('m', j);
+ co.set(DIM_M, j);
(*pMetaEq)[i].add(co);
}
//------------------------------------------------------------------------------------------
for (UINT_32 i = 0; i < uncompFragLog2; i++)
{
- co.set('s', compFragLog2 + i);
+ co.set(DIM_S, compFragLog2 + i);
(*pMetaEq)[pipeInterleaveLog2 + 1 + numPipeTotalLog2 + rbBitsLeft + i].add(co);
}
}