diff options
Diffstat (limited to 'src/amd/addrlib/r800/egbaddrlib.cpp')
-rw-r--r-- | src/amd/addrlib/r800/egbaddrlib.cpp | 656 |
1 files changed, 7 insertions, 649 deletions
diff --git a/src/amd/addrlib/r800/egbaddrlib.cpp b/src/amd/addrlib/r800/egbaddrlib.cpp index 7affdecbf02..99aa6cf4cdb 100644 --- a/src/amd/addrlib/r800/egbaddrlib.cpp +++ b/src/amd/addrlib/r800/egbaddrlib.cpp @@ -739,13 +739,12 @@ BOOL_32 EgBasedLib::ComputeSurfaceAlignmentsMicroTiled( AdjustPitchAlignment(flags, pPitchAlign); - // ECR#393489 - // Workaround 2 for 1D tiling - There is HW bug for Carrizo + // Workaround 2 for 1D tiling - There is HW bug for Carrizo, // where it requires the following alignments for 1D tiling. if (flags.czDispCompatible && (mipLevel == 0)) { *pBaseAlign = PowTwoAlign(*pBaseAlign, 4096); //Base address MOD 4096 = 0 - *pPitchAlign = PowTwoAlign(*pPitchAlign, 512 / (BITS_TO_BYTES(bpp))); //(8 lines * pitch * bytes per pixel) MOD 4096 = 0 + *pPitchAlign = PowTwoAlign(*pPitchAlign, 512 / (BITS_TO_BYTES(bpp))); //(8 lines * pitch * bytes per pixel) MOD 4096 = 0 } // end Carrizo workaround for 1D tilling @@ -1091,6 +1090,8 @@ AddrTileMode EgBasedLib::ComputeSurfaceMipLevelTileMode( ADDR_TILEINFO* pTileInfo ///< [in] ptr to bank structure ) const { + UINT_64 bytesPerSlice; + (void)bytesPerSlice; UINT_32 bytesPerTile; AddrTileMode expTileMode = baseTileMode; @@ -1100,6 +1101,7 @@ AddrTileMode EgBasedLib::ComputeSurfaceMipLevelTileMode( // // Compute the size of a slice. // + bytesPerSlice = BITS_TO_BYTES(static_cast<UINT_64>(pitch) * height * bpp * numSamples); bytesPerTile = BITS_TO_BYTES(MicroTilePixels * microTileThickness * NextPow2(bpp) * numSamples); // @@ -1329,12 +1331,6 @@ UINT_64 EgBasedLib::DispatchComputeSurfaceAddrFromCoord( UINT_32* pBitPosition = &pOut->bitPosition; UINT_64 addr; -#if ADDR_AM_BUILD - UINT_32 addr5Bit = 0; - UINT_32 addr5Swizzle = pIn->addr5Swizzle; - BOOL_32 is32ByteTile = pIn->is32ByteTile; -#endif - // ADDR_DEPTH_SAMPLE_ORDER = non-disp + depth-sample-order if (microTileType == ADDR_DEPTH_SAMPLE_ORDER) { @@ -1439,23 +1435,6 @@ UINT_64 EgBasedLib::DispatchComputeSurfaceAddrFromCoord( break; } -#if ADDR_AM_BUILD - if (m_chipFamily >= ADDR_CHIP_FAMILY_NI) - { - if (addr5Swizzle && isDepthSampleOrder && is32ByteTile) - { - UINT_32 tx = x >> 3; - UINT_32 ty = y >> 3; - UINT_32 tileBits = ((ty&0x3) << 2) | (tx&0x3); - - tileBits = tileBits & addr5Swizzle; - addr5Bit = XorReduce(tileBits, 4); - - addr = addr | static_cast<UINT_64>(addr5Bit << 5); - } - } -#endif - return addr; } @@ -2751,6 +2730,8 @@ ADDR_E_RETURNCODE EgBasedLib::HwlComputeBaseSwizzle( { 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 }, // ADDR_SURF_16_BANK }; + UINT_32 pipes = HwlGetPipes(pTileInfo); + (void)pipes; UINT_32 banks = pTileInfo ? pTileInfo->banks : 2; UINT_32 hwNumBanks; @@ -3379,20 +3360,6 @@ ADDR_E_RETURNCODE EgBasedLib::HwlComputeFmaskAddrFromCoord( { ADDR_E_RETURNCODE retCode = ADDR_OK; -#if ADDR_AM_BUILD - if ((pIn->x > pIn->pitch) || - (pIn->y > pIn->height) || - (pIn->numSamples > m_maxSamples) || - (pIn->sample >= m_maxSamples)) - { - retCode = ADDR_INVALIDPARAMS; - } - else - { - pOut->addr = DispatchComputeFmaskAddrFromCoord(pIn, pOut); - } -#endif - return retCode; } @@ -3412,618 +3379,9 @@ ADDR_E_RETURNCODE EgBasedLib::HwlComputeFmaskCoordFromAddr( { ADDR_E_RETURNCODE retCode = ADDR_OK; -#if ADDR_AM_BUILD - if ((pIn->bitPosition >= 8) || - (pIn->numSamples > m_maxSamples)) - { - retCode = ADDR_INVALIDPARAMS; - } - else - { - DispatchComputeFmaskCoordFromAddr(pIn, pOut); - } -#endif - return retCode; } -#if ADDR_AM_BUILD -/** -**************************************************************************************************** -* EgBasedLib::DispatchComputeFmaskAddrFromCoord -* -* @brief -* Computes the FMASK address and bit position from a coordinate. -* @return -* The byte address -**************************************************************************************************** -*/ -UINT_64 EgBasedLib::DispatchComputeFmaskAddrFromCoord( - const ADDR_COMPUTE_FMASK_ADDRFROMCOORD_INPUT* pIn, ///< [in] input structure - ADDR_COMPUTE_FMASK_ADDRFROMCOORD_OUTPUT* pOut ///< [out] output structure - ) const -{ - UINT_32 x = pIn->x; - UINT_32 y = pIn->y; - UINT_32 slice = pIn->slice; - UINT_32 sample = pIn->sample; - UINT_32 plane = pIn->plane; - UINT_32 pitch = pIn->pitch; - UINT_32 height = pIn->height; - UINT_32 numSamples = pIn->numSamples; - AddrTileMode tileMode = pIn->tileMode; - BOOL_32 ignoreSE = pIn->ignoreSE; - ADDR_TILEINFO* pTileInfo = pIn->pTileInfo; - BOOL_32 resolved = pIn->resolved; - - UINT_32* pBitPosition = &pOut->bitPosition; - UINT_64 addr = 0; - - ADDR_ASSERT(numSamples > 1); - ADDR_ASSERT(Thickness(tileMode) == 1); - - switch (tileMode) - { - case ADDR_TM_1D_TILED_THIN1: - addr = ComputeFmaskAddrFromCoordMicroTiled(x, - y, - slice, - sample, - plane, - pitch, - height, - numSamples, - tileMode, - resolved, - pBitPosition); - break; - case ADDR_TM_2D_TILED_THIN1: //fall through - case ADDR_TM_3D_TILED_THIN1: - UINT_32 pipeSwizzle; - UINT_32 bankSwizzle; - - if (m_configFlags.useCombinedSwizzle) - { - ExtractBankPipeSwizzle(pIn->tileSwizzle, pIn->pTileInfo, - &bankSwizzle, &pipeSwizzle); - } - else - { - pipeSwizzle = pIn->pipeSwizzle; - bankSwizzle = pIn->bankSwizzle; - } - - addr = ComputeFmaskAddrFromCoordMacroTiled(x, - y, - slice, - sample, - plane, - pitch, - height, - numSamples, - tileMode, - pipeSwizzle, - bankSwizzle, - ignoreSE, - pTileInfo, - resolved, - pBitPosition); - break; - default: - *pBitPosition = 0; - break; - } - - return addr; -} - -/** -**************************************************************************************************** -* EgBasedLib::ComputeFmaskAddrFromCoordMicroTiled -* -* @brief -* Computes the FMASK address and bit position from a coordinate for 1D tilied (micro -* tiled) -* @return -* The byte address -**************************************************************************************************** -*/ -UINT_64 EgBasedLib::ComputeFmaskAddrFromCoordMicroTiled( - UINT_32 x, ///< [in] x coordinate - UINT_32 y, ///< [in] y coordinate - UINT_32 slice, ///< [in] slice index - UINT_32 sample, ///< [in] sample number - UINT_32 plane, ///< [in] plane number - UINT_32 pitch, ///< [in] surface pitch in pixels - UINT_32 height, ///< [in] surface height in pixels - UINT_32 numSamples, ///< [in] number of samples - AddrTileMode tileMode, ///< [in] tile mode - BOOL_32 resolved, ///< [in] TRUE if this is for resolved fmask - UINT_32* pBitPosition ///< [out] pointer to returned bit position - ) const -{ - UINT_64 addr = 0; - UINT_32 effectiveBpp; - UINT_32 effectiveSamples; - - // - // 2xAA use the same layout as 4xAA - // - if (numSamples == 2) - { - numSamples = 4; - } - - // - // Compute the number of planes. - // - if (resolved == FALSE) - { - effectiveSamples = ComputeFmaskNumPlanesFromNumSamples(numSamples); - effectiveBpp = numSamples; - - // - // Compute the address just like a color surface with numSamples bits per element and - // numPlanes samples. - // - addr = ComputeSurfaceAddrFromCoordMicroTiled(x, - y, - slice, - plane, // sample - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - ADDR_NON_DISPLAYABLE, - FALSE, - pBitPosition); - - // - // Compute the real bit position. Each (sample, plane) is stored with one bit per sample. - // - - // - // Compute the pixel index with in the micro tile - // - UINT_32 pixelIndex = ComputePixelIndexWithinMicroTile(x % 8, - y % 8, - slice, - 1, - tileMode, - ADDR_NON_DISPLAYABLE); - - *pBitPosition = ((pixelIndex * numSamples) + sample) & (BITS_PER_BYTE-1); - - UINT_64 bitAddr = BYTES_TO_BITS(addr) + *pBitPosition; - - addr = bitAddr / 8; - } - else - { - effectiveBpp = ComputeFmaskResolvedBppFromNumSamples(numSamples); - effectiveSamples = 1; - - // - // Compute the address just like a color surface with numSamples bits per element and - // numPlanes samples. - // - addr = ComputeSurfaceAddrFromCoordMicroTiled(x, - y, - slice, - sample, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - ADDR_NON_DISPLAYABLE, - TRUE, - pBitPosition); - } - - return addr; -} - -/** -**************************************************************************************************** -* EgBasedLib::ComputeFmaskAddrFromCoordMacroTiled -* -* @brief -* Computes the FMASK address and bit position from a coordinate for 2D tilied (macro -* tiled) -* @return -* The byte address -**************************************************************************************************** -*/ -UINT_64 EgBasedLib::ComputeFmaskAddrFromCoordMacroTiled( - UINT_32 x, ///< [in] x coordinate - UINT_32 y, ///< [in] y coordinate - UINT_32 slice, ///< [in] slice index - UINT_32 sample, ///< [in] sample number - UINT_32 plane, ///< [in] plane number - UINT_32 pitch, ///< [in] surface pitch in pixels - UINT_32 height, ///< [in] surface height in pixels - UINT_32 numSamples, ///< [in] number of samples - AddrTileMode tileMode, ///< [in] tile mode - UINT_32 pipeSwizzle, ///< [in] pipe swizzle - UINT_32 bankSwizzle, ///< [in] bank swizzle - BOOL_32 ignoreSE, ///< [in] TRUE if ignore shader engine - ADDR_TILEINFO* pTileInfo, ///< [in] bank structure.**All fields to be valid on entry** - BOOL_32 resolved, ///< [in] TRUE if this is for resolved fmask - UINT_32* pBitPosition ///< [out] pointer to returned bit position - ) const -{ - UINT_64 addr = 0; - UINT_32 effectiveBpp; - UINT_32 effectiveSamples; - - // - // 2xAA use the same layout as 4xAA - // - if (numSamples == 2) - { - numSamples = 4; - } - - // - // Compute the number of planes. - // - if (resolved == FALSE) - { - effectiveSamples = ComputeFmaskNumPlanesFromNumSamples(numSamples); - effectiveBpp = numSamples; - - // - // Compute the address just like a color surface with numSamples bits per element and - // numPlanes samples. - // - addr = ComputeSurfaceAddrFromCoordMacroTiled(x, - y, - slice, - plane, // sample - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - ADDR_NON_DISPLAYABLE,// isdisp - ignoreSE,// ignore_shader - FALSE,// depth_sample_order - pipeSwizzle, - bankSwizzle, - pTileInfo, - pBitPosition); - - // - // Compute the real bit position. Each (sample, plane) is stored with one bit per sample. - // - - - // - // Compute the pixel index with in the micro tile - // - UINT_32 pixelIndex = ComputePixelIndexWithinMicroTile(x , - y , - slice, - effectiveBpp, - tileMode, - ADDR_NON_DISPLAYABLE); - - *pBitPosition = ((pixelIndex * numSamples) + sample) & (BITS_PER_BYTE-1); - - UINT_64 bitAddr = BYTES_TO_BITS(addr) + *pBitPosition; - - addr = bitAddr / 8; - - } - else - { - effectiveBpp = ComputeFmaskResolvedBppFromNumSamples(numSamples); - effectiveSamples = 1; - - // - // Compute the address just like a color surface with numSamples bits per element and - // numPlanes samples. - // - addr = ComputeSurfaceAddrFromCoordMacroTiled(x, - y, - slice, - sample, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - ADDR_NON_DISPLAYABLE, - ignoreSE, - TRUE, - pipeSwizzle, - bankSwizzle, - pTileInfo, - pBitPosition); - } - - return addr; -} - -/** -**************************************************************************************************** -* EgBasedLib::ComputeFmaskCoordFromAddrMicroTiled -* -* @brief -* Compute (x,y,slice,sample,plane) coordinates from fmask address -* @return -* N/A -* -**************************************************************************************************** -*/ -VOID EgBasedLib::ComputeFmaskCoordFromAddrMicroTiled( - UINT_64 addr, ///< [in] byte address - UINT_32 bitPosition,///< [in] bit position - UINT_32 pitch, ///< [in] pitch in pixels - UINT_32 height, ///< [in] height in pixels - UINT_32 numSamples, ///< [in] number of samples (of color buffer) - AddrTileMode tileMode, ///< [in] tile mode - BOOL_32 resolved, ///< [in] TRUE if it is resolved fmask - UINT_32* pX, ///< [out] X coord - UINT_32* pY, ///< [out] Y coord - UINT_32* pSlice, ///< [out] slice index - UINT_32* pSample, ///< [out] sample index - UINT_32* pPlane ///< [out] plane index - ) const -{ - UINT_32 effectiveBpp; - UINT_32 effectiveSamples; - - // 2xAA use the same layout as 4xAA - if (numSamples == 2) - { - numSamples = 4; - } - - if (resolved == FALSE) - { - effectiveSamples = ComputeFmaskNumPlanesFromNumSamples(numSamples); - effectiveBpp = numSamples; - - ComputeSurfaceCoordFromAddrMicroTiled(addr, - bitPosition, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - 0, // tileBase - 0, // compBits - pX, - pY, - pSlice, - pPlane, - ADDR_NON_DISPLAYABLE, // microTileType - FALSE // isDepthSampleOrder - ); - - - if ( pSample ) - { - *pSample = bitPosition % numSamples; - } - } - else - { - effectiveBpp = ComputeFmaskResolvedBppFromNumSamples(numSamples); - effectiveSamples = 1; - - ComputeSurfaceCoordFromAddrMicroTiled(addr, - bitPosition, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - 0, // tileBase - 0, // compBits - pX, - pY, - pSlice, - pSample, - ADDR_NON_DISPLAYABLE, // microTileType - TRUE // isDepthSampleOrder - ); - } -} - -/** -**************************************************************************************************** -* EgBasedLib::ComputeFmaskCoordFromAddrMacroTiled -* -* @brief -* Compute (x,y,slice,sample,plane) coordinates from -* fmask address -* @return -* N/A -* -**************************************************************************************************** -*/ -VOID EgBasedLib::ComputeFmaskCoordFromAddrMacroTiled( - UINT_64 addr, ///< [in] byte address - UINT_32 bitPosition,///< [in] bit position - UINT_32 pitch, ///< [in] pitch in pixels - UINT_32 height, ///< [in] height in pixels - UINT_32 numSamples, ///< [in] number of samples (of color buffer) - AddrTileMode tileMode, ///< [in] tile mode - UINT_32 pipeSwizzle,///< [in] pipe swizzle - UINT_32 bankSwizzle,///< [in] bank swizzle - BOOL_32 ignoreSE, ///< [in] TRUE if ignore shader engine - ADDR_TILEINFO* pTileInfo, ///< [in] bank structure. **All fields to be valid on entry** - BOOL_32 resolved, ///< [in] TRUE if it is resolved fmask - UINT_32* pX, ///< [out] X coord - UINT_32* pY, ///< [out] Y coord - UINT_32* pSlice, ///< [out] slice index - UINT_32* pSample, ///< [out] sample index - UINT_32* pPlane ///< [out] plane index - ) const -{ - UINT_32 effectiveBpp; - UINT_32 effectiveSamples; - - // 2xAA use the same layout as 4xAA - if (numSamples == 2) - { - numSamples = 4; - } - - // - // Compute the number of planes. - // - if (resolved == FALSE) - { - effectiveSamples = ComputeFmaskNumPlanesFromNumSamples(numSamples); - effectiveBpp = numSamples; - - ComputeSurfaceCoordFromAddrMacroTiled(addr, - bitPosition, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - 0, // No tileBase - 0, // No compBits - ADDR_NON_DISPLAYABLE, - ignoreSE, - FALSE, - pipeSwizzle, - bankSwizzle, - pTileInfo, - pX, - pY, - pSlice, - pPlane); - - if (pSample) - { - *pSample = bitPosition % numSamples; - } - } - else - { - effectiveBpp = ComputeFmaskResolvedBppFromNumSamples(numSamples); - effectiveSamples = 1; - - ComputeSurfaceCoordFromAddrMacroTiled(addr, - bitPosition, - effectiveBpp, - pitch, - height, - effectiveSamples, - tileMode, - 0, // No tileBase - 0, // No compBits - ADDR_NON_DISPLAYABLE, - ignoreSE, - TRUE, - pipeSwizzle, - bankSwizzle, - pTileInfo, - pX, - pY, - pSlice, - pSample); - } -} - -/** -**************************************************************************************************** -* EgBasedLib::DispatchComputeFmaskCoordFromAddr -* -* @brief -* Compute (x,y,slice,sample,plane) coordinates from -* fmask address -* @return -* N/A -* -**************************************************************************************************** -*/ -VOID EgBasedLib::DispatchComputeFmaskCoordFromAddr( - const ADDR_COMPUTE_FMASK_COORDFROMADDR_INPUT* pIn, ///< [in] input structure - ADDR_COMPUTE_FMASK_COORDFROMADDR_OUTPUT* pOut ///< [out] output structure - ) const -{ - UINT_64 addr = pIn->addr; - UINT_32 bitPosition = pIn->bitPosition; - UINT_32 pitch = pIn->pitch; - UINT_32 height = pIn->height; - UINT_32 numSamples = pIn->numSamples; - AddrTileMode tileMode = pIn->tileMode; - BOOL_32 ignoreSE = pIn->ignoreSE; - ADDR_TILEINFO* pTileInfo = pIn->pTileInfo; - BOOL_32 resolved = pIn->resolved; - - UINT_32* pX = &pOut->x; - UINT_32* pY = &pOut->y; - UINT_32* pSlice = &pOut->slice; - UINT_32* pSample = &pOut->sample; - UINT_32* pPlane = &pOut->plane; - - switch (tileMode) - { - case ADDR_TM_1D_TILED_THIN1: - ComputeFmaskCoordFromAddrMicroTiled(addr, - bitPosition, - pitch, - height, - numSamples, - tileMode, - resolved, - pX, - pY, - pSlice, - pSample, - pPlane); - break; - case ADDR_TM_2D_TILED_THIN1://fall through - case ADDR_TM_3D_TILED_THIN1: - UINT_32 pipeSwizzle; - UINT_32 bankSwizzle; - - if (m_configFlags.useCombinedSwizzle) - { - ExtractBankPipeSwizzle(pIn->tileSwizzle, pIn->pTileInfo, - &bankSwizzle, &pipeSwizzle); - } - else - { - pipeSwizzle = pIn->pipeSwizzle; - bankSwizzle = pIn->bankSwizzle; - } - - ComputeFmaskCoordFromAddrMacroTiled(addr, - bitPosition, - pitch, - height, - numSamples, - tileMode, - pipeSwizzle, - bankSwizzle, - ignoreSE, - pTileInfo, - resolved, - pX, - pY, - pSlice, - pSample, - pPlane); - break; - default: - ADDR_ASSERT_ALWAYS(); - break; - - } -} -#endif - /** **************************************************************************************************** * EgBasedLib::ComputeFmaskNumPlanesFromNumSamples |