/*============================================================================== Copyright(c) 2017 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================================================================*/ #include "Internal/Common/GmmLibInc.h" #ifdef _WIN32 #include #endif //64KB Undefined Swizzle Descriptors ######################################### // !! TODO (critical): Provide mapping helper function to UMD to map in non-TR // Undefined64KBSwizzle resources. Also check if support // for it is needed in GmmResCpuBlt. // // Note: These 64KB swizzles are not really hardware tile swizzles, so leave // them out of the CpuSwizzleBlt.c /* On systems that do not support Std Swizzle (IGFX_GEN7_5_CORE / IGFX_GEN8_CORE), we still have to support 64KB tiles. These 64KB tiles will be made of 16 4KB tiles -- we'll be using TileY to create these 64KB tiles. The table below shows how the 64KB tile shape changes depending on the bpp and how we need to arrange (in columns X rows) the 4KB tiles to fit that shape. bpp Tile Size (in pixels) Tile Size (in bytes) 4K tile config --- -------------------- -------------------- -------------- 8bpp 256x256 256x256 2x8 16bpp 256x128 512x128 4x4 32bpp 128x128 512x128 4x4 64bpp 128x64 1024x64 8x2 128bpp 64x64 1024x64 8x2 We need 3 different swizzle pattern to support all configs above. The swizzle patterns are: |-Rows-| |-Column-| |-TileY Swizzle-| 8bpp: YYY X XXXYYYYYXXXX 16/32bpp: YY XX XXXYYYYYXXXX 64/128bpp: Y XXX XXXYYYYYXXXX The translation of these Xs and Ys to bitmap is shown below */ extern const SWIZZLE_DESCRIPTOR INTEL_64KB_UNDEFINED_8bpp = {0x1E0F, 0xE1F0, 0}; extern const SWIZZLE_DESCRIPTOR INTEL_64KB_UNDEFINED_16_32bpp = {0x3E0F, 0xC1F0, 0}; extern const SWIZZLE_DESCRIPTOR INTEL_64KB_UNDEFINED_64_128bpp = {0x7E0F, 0x81F0, 0}; //############################################################################# //============================================================================= // Function: // GmmIsRedecribedPlanes // // Description: // Checks if the resource has redescribed planes // // Arguments: GetResFlags().Info.RedecribedPlanes; } //============================================================================= // Function: // GmmGetLosslessCompressionType // // Description: // Returns the format's E2E compression format. // // Arguments: GMM_FORMAT_INVALID) && (Format < GMM_RESOURCE_FORMATS)); return pGmmLibContext->GetPlatformInfo().FormatTable[Format].CompressionFormat.AuxL1eFormat; } //============================================================================= // Function: // GmmIsUVPacked // // Description: // Checks if format has packed UV plane // // Arguments: GMM_FORMAT_INVALID) && (Format < GMM_RESOURCE_FORMATS) && pGmmLibContext->GetPlatformInfo().FormatTable[Format].Compressed; } //============================================================================= // Function: // GmmGetCacheSizes // // Description: // This function returns the L3, LLC and EDRAM cache sizes. // // Arguments: // pCacheSizes ==> ptr to GMM_CACHE_SIZES struct // // Return: // void // //----------------------------------------------------------------------------- void GMM_STDCALL GmmGetCacheSizes(GMM_LIB_CONTEXT *pGmmLibContext, GMM_CACHE_SIZES *pCacheSizes) { const GT_SYSTEM_INFO *pGtSysInfo; __GMM_ASSERT(pCacheSizes != NULL); __GMM_ASSERT(pGmmLibContext != NULL); GMM_DPF_ENTER; pGtSysInfo = pGmmLibContext->GetGtSysInfoPtr(); pCacheSizes->TotalEDRAM = GMM_KBYTE(pGtSysInfo->EdramSizeInKb); pCacheSizes->TotalLLCCache = GMM_KBYTE(pGtSysInfo->LLCCacheSizeInKb); pCacheSizes->TotalL3Cache = GMM_KBYTE(pGtSysInfo->L3CacheSizeInKb); GMM_DPF_EXIT; } namespace GmmLib { namespace Utility { //============================================================================= // Function: // GmmGetNumPlanes // // Description: // Returns number of planes for given format // // Arguments: Must be power of 2 // // Returns: // See desc. // Example Value = 8 => Log2(Value) = 3 // Example Value = 32 => Log2(Value) = 5 //----------------------------------------------------------------------------- uint32_t __GmmLog2(uint32_t Value) { uint32_t FirstSetBit = 0; // bit # of first set bit in Bpp. #if _MSC_VER // Check that Value is pow2 __GMM_ASSERT(__popcnt(Value) <= 1); _BitScanReverse((DWORD *)&FirstSetBit, (DWORD)Value); #else // Check that Value is pow2 __GMM_ASSERT(__builtin_popcount(Value) <= 1); FirstSetBit = __builtin_ctz(Value); #endif // Log2(Value) = FirstSetBit. return FirstSetBit; }; // Table for converting the tile layout of DirectX tiled resources // to TileY. const uint32_t __GmmTileYConversionTable[5][2] = { //WxH 256x256, of 64KB tile in texels, BPP = 8 {2, 8}, // = (W * (BPP >> 3)) / 128, H / 32 //WxH 256x128, BPP = 16 {4, 4}, //WxH 128x128, BPP = 32 {4, 4}, //WxH 128x64, BPP = 64 {8, 2}, //WxH 64x64, BPP = 128 {8, 2}}; // With MSAA, modify DirectX tile dimensions // MSAA Divide Tile Dimensions (WxH) by // 1 1x1 // 2 2x1 // 4 2x2 // 8 4x2 //16 4x4 const uint32_t __GmmMSAAConversion[5][2] = { // MSAA 1x {1, 1}, // MSAA 2x {2, 1}, // MSAA 4x {2, 2}, // MSAA 8x {4, 2}, // MSAA 16x {4, 4}};