1 /*============================================================================== 2 Copyright(c) 2017 Intel Corporation 3 4 Permission is hereby granted, free of charge, to any person obtaining a 5 copy of this software and associated documentation files(the "Software"), 6 to deal in the Software without restriction, including without limitation 7 the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 and / or sell copies of the Software, and to permit persons to whom the 9 Software is furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included 12 in all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 OTHER DEALINGS IN THE SOFTWARE. 21 ============================================================================*/ 22 23 #pragma once 24 #ifdef __cplusplus 25 #include "GmmMemAllocator.hpp" 26 #include "GmmLibInc.h" 27 ///////////////////////////////////////////////////////////////////////////////////// 28 /// @file GmmTextureCalc.h 29 /// @brief This file contains the common functions and members for texture calculations 30 /// on all GENs/Platforms 31 ///////////////////////////////////////////////////////////////////////////////////// 32 namespace GmmLib 33 { 34 ///////////////////////////////////////////////////////////////////////// 35 /// Contains texture calc functions and members that are common across all platform 36 /// implementation. This class is inherited by gen specific class so 37 /// so clients shouldn't have to ever interact with this class directly. 38 ///////////////////////////////////////////////////////////////////////// 39 class NON_PAGED_SECTION GmmTextureCalc : 40 public GmmMemAllocator 41 { 42 // GMMLIB2_TODO: 43 // 1) Change it to protected when all functions are part of the class 44 // 2) Mode Gen specific implementation in derived class later. 45 private: 46 47 protected: 48 /* Function prototypes */ 49 50 public: 51 /* Constructors */ 52 53 // "Creates GmmTextureCalc object based on platform ID" Create(PLATFORM Platform)54 static GmmTextureCalc* Create(PLATFORM Platform) 55 { 56 return new GmmTextureCalc(); 57 } 58 GmmTextureCalc()59 GmmTextureCalc() 60 { 61 62 } 63 ~GmmTextureCalc()64 ~GmmTextureCalc() 65 { 66 67 } 68 69 /* Function prototypes */ 70 71 //GmmTextureAlloc.cpp 72 GMM_STATUS AllocateTexture(GMM_TEXTURE_INFO *pTexInfo); 73 74 GMM_STATUS __GmmTexFillBlockMem( 75 GMM_TEXTURE_INFO *pTexInfo, 76 __GMM_BUFFER_TYPE *pRestrictions); 77 78 GMM_STATUS GmmTexFillPitchAndSize(GMM_TEXTURE_INFO *pTexInfo, 79 GMM_GFX_SIZE_T WidthBytesPhysical, 80 uint32_t Height, 81 __GMM_BUFFER_TYPE *pBufferType); 82 83 void GmmTexGetRestrictions( 84 GMM_TEXTURE_INFO* pTexInfo, 85 __GMM_BUFFER_TYPE* pBuff); 86 87 GMM_STATUS GMM_STDCALL __GmmTexFillPlanar( 88 GMM_TEXTURE_INFO *pTexInfo, 89 __GMM_BUFFER_TYPE *pRestrictions); 90 91 void __GmmTexFillPlanar_SetTilingBasedOnRequiredAlignment( 92 GMM_TEXTURE_INFO *pTexInfo, 93 uint32_t YHeight, bool YHeightAlignmentNeeded, 94 uint32_t VHeight, bool VHeightAlignmentNeeded); 95 96 bool __GmmTexValidateTexInfo( 97 GMM_TEXTURE_INFO *pTexInfo, 98 __GMM_BUFFER_TYPE *pRestrictions); 99 100 void __GmmSetTileMode( 101 GMM_TEXTURE_INFO* pTexInfo); 102 103 GMM_STATUS __GmmTexSpecialCasePreProcessing( 104 GMM_TEXTURE_INFO* pTexInfo); 105 106 //GmmTexture.cpp 107 108 uint32_t __GmmExpandHeight( 109 uint32_t Height, 110 uint32_t UnitAlignment, 111 uint32_t NumSamples); 112 113 uint32_t __GmmExpandWidth( 114 uint32_t Width, 115 uint32_t UnitAlignment, 116 uint32_t NumSamples); 117 118 void __GmmGetElementDimensions( 119 GMM_RESOURCE_FORMAT Format, 120 uint32_t *pWidth, 121 uint32_t *pHeight, 122 uint32_t *pDepth); 123 124 void __GmmFillPlanarOffsetAddress( 125 GMM_TEXTURE_INFO *pTexInfo); 126 127 void __GmmFindMipTailStartLod( 128 GMM_TEXTURE_INFO *pTexInfo); 129 130 131 // Virtual functions 132 // TODO GmmLib2.0 Create derived class of TextureCalc and add virtual functions. 133 /*virtual GMM_STATUS GMM_STDCALL __GmmTexFill1D( 134 GMM_TEXTURE_INFO *pTexInfo, 135 __GMM_BUFFER_TYPE *pRestrictions) = 0; 136 virtual GMM_STATUS GMM_STDCALL __GmmTexFill2D( 137 GMM_TEXTURE_INFO *pTexInfo, 138 __GMM_BUFFER_TYPE *pRestrictions) = 0; 139 virtual GMM_STATUS GMM_STDCALL __GmmTexFill3D( 140 GMM_TEXTURE_INFO *pTexInfo, 141 __GMM_BUFFER_TYPE *pRestrictions) = 0; 142 virtual GMM_STATUS GMM_STDCALL __GmmTexFillCube( 143 GMM_TEXTURE_INFO *pTexInfo, 144 __GMM_BUFFER_TYPE *pRestrictions) = 0;*/ 145 146 /* inline functions */ 147 }; 148 149 } 150 #endif // #ifdef __cplusplus