1 /*==============================================================================
2 Copyright(c) 2019 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 #pragma once
23 #include "GmmGen11Platform.h"
24 
25 typedef struct __CCS_UNIT
26 {
27     ALIGNMENT Align;
28     struct
29     {
30         //represents downscale factor if msb = 0,
31         //             upscale factor if msb = 1,
32         //factor value is absolute (+ve)
33         int32_t Width;
34         int32_t Height;
35         uint32_t Depth;  //Depth slices or Samples sharing CCS$line
36     } Downscale;
37 } CCS_UNIT;
38 
39 //Gen12 CCS supported on Yf/Ys 2D/MSAA/3D tiling
40 #define CCS_MODES          (GMM_TILE_MODES - TILE_YF_2D_8bpe)
41 #define CCS_MODE(x)        (x >= TILE_YF_2D_8bpe) ? (x - TILE_YF_2D_8bpe) : CCS_MODES
42 
43 typedef enum _FC_TileType
44 {
45     FC_TILE_Y,
46     FC_TILE_YF,
47     FC_TILE_YS,
48     FC_TILE_4,
49     FC_TILE_64,
50     //max equals last supported plus one
51     FC_TILE_MAX
52 } FC_TILE_TYPE;
53 
54 #define FCTilingType(x)    (((x) == LEGACY_TILE_Y) ? (FC_TILE_Y) : \
55                            (((x) == TILE4) ? (FC_TILE_4) : \
56                            (((x) >= TILE_YF_2D_8bpe && (x) <= TILE_YF_2D_128bpe) ? (FC_TILE_YF) : \
57                            (((x) >= TILE_YS_2D_8bpe && (x) <= TILE_YS_2D_128bpe) ? (FC_TILE_YS) : \
58                            (((x) >= TILE__64_2D_8bpe && (x) <= TILE__64_2D_128bpe) ? (FC_TILE_64) : \
59                            (FC_TILE_MAX))))))
60 #define FCMaxBppModes      5
61 #define FCMaxModes         FC_TILE_MAX * FCMaxBppModes
62 #define FCBppMode(bpp)     __GmmLog2(bpp) - 3
63 #define FCMode(TileMode, bpp)  (FCTilingType(TileMode) < FC_TILE_MAX) ? (FCTilingType(TileMode) * FCMaxBppModes + FCBppMode(bpp)) : FCMaxModes
64 
65 //===========================================================================
66 // typedef:
67 //        GMM_TEXTURE_ALIGN_EX
68 //
69 // Description:
70 //      The following struct extends the texture mip map unit alignment
71 //      required for each map format. The alignment values are platform
72 //      dependent.
73 //
74 //---------------------------------------------------------------------------
75 typedef struct GMM_TEXTURE_ALIGN_EX_REC
76 {
77     CCS_UNIT CCSEx[CCS_MODES];
78 }GMM_TEXTURE_ALIGN_EX;
79 
80 #ifdef __cplusplus
81 
82 namespace GmmLib
83 {
84     class NON_PAGED_SECTION PlatformInfoGen12 : public PlatformInfoGen11
85     {
86     protected:
87         GMM_TEXTURE_ALIGN_EX    TexAlignEx;
88         CCS_UNIT                FCTileMode[FCMaxModes];
89     public:
90         PlatformInfoGen12(PLATFORM &Platform, Context *pGmmLibContext);
~PlatformInfoGen12()91 	~PlatformInfoGen12(){};
GetExTextureAlign()92         virtual GMM_TEXTURE_ALIGN_EX GetExTextureAlign() { return TexAlignEx; }
93         virtual void ApplyExtendedTexAlign(uint32_t CCSMode, ALIGNMENT& UnitAlign);
GetFCRectAlign()94         virtual CCS_UNIT* GetFCRectAlign() { return FCTileMode; }
95         virtual void                 SetCCSFlag(GMM_RESOURCE_FLAG &Flags);
96         virtual uint8_t              ValidateMMC(GMM_TEXTURE_INFO &Surf);
97         virtual uint8_t              ValidateCCS(GMM_TEXTURE_INFO &Surf);
98         virtual uint8_t              ValidateUnifiedAuxSurface(GMM_TEXTURE_INFO &Surf);
99         virtual uint8_t              CheckFmtDisplayDecompressible(GMM_TEXTURE_INFO &Surf,
100                                                                    bool IsSupportedRGB64_16_16_16_16,
101                                                                    bool IsSupportedRGB32_8_8_8_8,
102                                                                    bool IsSupportedRGB32_2_10_10_10,
103                                                                    bool IsSupportedMediaFormats);
104         virtual uint8_t OverrideCompressionFormat(GMM_RESOURCE_FORMAT Format, uint8_t IsMC);
105     };
106 }
107 
108 #endif
109