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 #pragma once
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /*__cplusplus*/
28 
29 // Set packing alignment
30 #pragma pack(push, 8)
31 
32 extern const uint32_t __GmmMSAAConversion[5][2];
33 extern const uint32_t __GmmTileYConversionTable[5][2];
34 
35 //
36 // Normally, GMM_RESOURCE_INFO should not contain any user mode pointers because
37 // if the resource is shared, then the pointer will be invalid in the other process.
38 // However, the pointers below are OK because pMappedTiles and pTiledPoolArray are
39 // associated with a TR surface, which is not shareable. AuxInfo.pTilePoolInfo is associated
40 // with tile pools; Tile Pools are shareable, but Aux tile pool aren't.
41 //
42 typedef struct TILE_POOL_INFO_REC
43 {
44     uint64_t                          UsedTiles[4];       // Tiles being used in 1 tile pool
45     GMM_GFX_ADDRESS                   StartingGfxAddress; // GfxAddress associated with the TilePool
46 } TILE_POOL_INFO;
47 
48 typedef struct GMM_TILED_RESOURCE_INFO_REC
49 {
50     GMM_GFX_ADDRESS                     TiledResourceGfxAddress; // used for tiled resources
51     uint64_t                            pMappedTiles;            // tracks which tiles have been mapped
52     uint64_t                            pTilePoolArray;          // list of tile pool allocation
53                                                                  // handles (D3DKMT_HANDLE),
54                                                                  // only used for tiled resources
55     uint64_t                            pAuxTilePoolResArray;    // list of aux tile pool allocation resource, and handles
56 
57     uint32_t                            TilePoolArraySize;
58     uint32_t                            AuxTilePoolArraySize;
59 
60     struct
61     {
62         uint64_t                        pTilePoolInfo;
63         uint64_t                        PagingFenceValue;
64         uint32_t                        TilePoolInfoTotalNumElements; // Number of elements in pTilePoolInfo array
65         uint32_t                        TilePoolInfoFreeNumElements;  // Number of free tile pools
66     } AuxInfo;
67 } GMM_TILED_RESOURCE_INFO;
68 
69 typedef struct GMM_EXISTING_SYS_MEM_REC
70 {
71     // 64bit kernel mode drivers must validate sizeof structs passed from
72     // 32bit & 64bit user mode drivers. Store as 64bit to keep uniform size.
73     uint64_t                        pExistingSysMem; //Original buffer address.
74     uint64_t                        pVirtAddress;
75     uint64_t                        pGfxAlignedVirtAddress;
76 #if(LHDM)
77     D3DKMT_HANDLE                   hParentAllocation;
78 #endif
79     GMM_GFX_SIZE_T                  Size;
80     uint8_t                         IsGmmAllocated;
81 } GMM_EXISTING_SYS_MEM;
82 //===========================================================================
83 // typedef:
84 //      GMM_RESOURCE_INFO
85 //
86 // Description:
87 //     Struct describing the attributes and properties of a user mode resource
88 //
89 //----------------------------------------------------------------------------
90 #ifndef _WIN32
91     #include "../Linux/GmmResourceInfoLin.h"
92 #endif
93 
94 // Reset packing alignment to project default
95 #pragma pack(pop)
96 
97 uint8_t     GMM_STDCALL GmmResValidateParams(GMM_RESOURCE_INFO *pResourceInfo);
98 void        GMM_STDCALL GmmResGetRestrictions(GMM_RESOURCE_INFO* pResourceInfo, __GMM_BUFFER_TYPE* pRestrictions);
99 uint8_t     __CanSupportStdTiling(GMM_TEXTURE_INFO Surface, GMM_LIB_CONTEXT *pGmmLibContext);
100 
101 #ifdef __cplusplus
102 }
103 #endif /*__cplusplus*/
104 
105