xref: /aosp_15_r20/external/gmmlib/Source/GmmLib/Platform/GmmPlatforms.h (revision 35ffd701415c9e32e53136d61a677a8d0a8fc4a5)
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 
25 #ifdef __cplusplus
26 #include "../inc/External/Common/GmmMemAllocator.hpp"
27 #include "../inc/External/Common/GmmTextureExt.h"
28 
29 namespace GmmLib {
30 
31     class Context;
32     class NON_PAGED_SECTION PlatformInfo : public GmmMemAllocator
33     {
34     public:
35         static int32_t RefCount;
36         static int32_t OverrideRefCount;
37 
38     protected:
39         GMM_PLATFORM_INFO Data;
40         Context *         pGmmLibContext;
41 
42     public:
43         PlatformInfo(PLATFORM &Platform, Context* pGmmLibContext);
~PlatformInfo()44         virtual ~PlatformInfo()
45         {
46         }
47 
GetData()48         const GMM_PLATFORM_INFO& GetData()
49         {
50             return Data;
51         }
52 
ApplyExtendedTexAlign(uint32_t CCSMode,ALIGNMENT & UnitAlign)53         virtual void ApplyExtendedTexAlign(uint32_t CCSMode, ALIGNMENT& UnitAlign)
54         {
55             GMM_UNREFERENCED_PARAMETER(CCSMode);
56             GMM_UNREFERENCED_PARAMETER(UnitAlign);
57         }
58 
OverrideCompressionFormat(GMM_RESOURCE_FORMAT Format,uint8_t IsMC)59         virtual uint8_t OverrideCompressionFormat(GMM_RESOURCE_FORMAT Format, uint8_t IsMC)
60         {
61             GMM_UNREFERENCED_PARAMETER(Format);
62             GMM_UNREFERENCED_PARAMETER(IsMC);
63             return 0;
64         }
65 
SetDataSurfaceMaxSize(uint64_t Size)66         void SetDataSurfaceMaxSize(uint64_t Size)
67         {
68             Data.SurfaceMaxSize = Size;
69         }
SetDataFBCRequiredStolenMemorySize(uint32_t Size)70         void SetDataFBCRequiredStolenMemorySize(uint32_t Size)
71         {
72             Data.FBCRequiredStolenMemorySize = Size;
73         }
SetDataNumberFenceRegisters(uint32_t Number)74         void SetDataNumberFenceRegisters(uint32_t Number)
75         {
76             Data.NumberFenceRegisters = Number;
77         }
78         virtual void SetCCSFlag(GMM_RESOURCE_FLAG &Flags);
79         virtual uint8_t ValidateMMC(GMM_TEXTURE_INFO &Surf);
80         virtual uint8_t ValidateCCS(GMM_TEXTURE_INFO &Surf);
81         virtual uint8_t ValidateUnifiedAuxSurface(GMM_TEXTURE_INFO &Surf);
82         virtual uint8_t CheckFmtDisplayDecompressible(GMM_TEXTURE_INFO &Surf,
83                                                       bool IsSupportedRGB64_16_16_16_16,
84                                                       bool IsSupportedRGB32_8_8_8_8,
85                                                       bool IsSupportedRGB32_2_10_10_10,
86                                                       bool IsSupportedMediaFormats);
87 
88     };
89 }
90 #define GMM_PLATFORM_INFO_CLASS GmmLib::PlatformInfo
91 #else
92 typedef struct PlatformInfo PlatformInfo;
93 #define GMM_PLATFORM_INFO_CLASS PlatformInfo
94 #endif
95 
96 //***************************************************************************
97 //
98 //                      GMM_PLATFORM_INFO Internl API
99 //
100 //***************************************************************************
101 #define SET_TILE_MODE_INFO(Mode, _Width, _Height, _Depth, _MtsWidth, _MtsHeight, _MtsDepth) \
102 {                                                                                           \
103     Data.TileInfo[Mode].LogicalTileWidth      = GMM_BYTES(_Width);                          \
104     Data.TileInfo[Mode].LogicalTileHeight     = GMM_SCANLINES(_Height);                     \
105     Data.TileInfo[Mode].LogicalTileDepth      = (_Depth);                                   \
106     Data.TileInfo[Mode].LogicalSize           = (_Width) * (_Height) * (_Depth);            \
107     Data.TileInfo[Mode].MaxPitch              = GMM_KBYTE(256);                             \
108     Data.TileInfo[Mode].MaxMipTailStartWidth  = (_MtsWidth);                                \
109     Data.TileInfo[Mode].MaxMipTailStartHeight = (_MtsHeight);                               \
110     Data.TileInfo[Mode].MaxMipTailStartDepth  = (_MtsDepth);                                \
111 }
112 
113 #if __cplusplus
114 extern "C" {
115 #endif
116 
117     const GMM_PLATFORM_INFO *GMM_STDCALL __GmmGetPlatformInfo(void *pLibContext);
118     void GMM_STDCALL __SetNumberFenceRegisters(void *pLibContext, uint32_t Number);
119 
120 #if __cplusplus
121 }
122 #endif
123