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 #if _WIN32 30 #ifndef __GMM_KMD__ 31 typedef LONG NTSTATUS; 32 #include <windows.h> 33 #include <d3d9types.h> 34 #include <d3dkmthk.h> 35 #endif 36 #endif 37 38 // Set packing alignment 39 #pragma pack(push, 8) 40 41 // Rotation bitmap fields 42 #define GMM_KMD_ROTATE 0x00000001 // this is to inform KMD to enable 43 // rotation in Full screen case 44 45 // Color separation textures width division factors and array size 46 #define GMM_COLOR_SEPARATION_WIDTH_DIVISION 4 47 #define GMM_COLOR_SEPARATION_RGBX_WIDTH_DIVISION 3 48 #define GMM_COLOR_SEPARATION_ARRAY_SIZE 4 // XXX: Change that to 3 once 2nd green scanout using sprites is validated 49 50 //=========================================================================== 51 // typedef: 52 // GMM_RESOURCE_MMC_INFO 53 // 54 // Description: 55 // This struct is used to describe Media Memory Compression information. 56 //--------------------------------------------------------------------------- 57 typedef enum GMM_RESOURCE_MMC_INFO_REC 58 { 59 GMM_MMC_DISABLED = 0, 60 GMM_MMC_HORIZONTAL, 61 GMM_MMC_VERTICAL, 62 }GMM_RESOURCE_MMC_INFO; 63 64 //=========================================================================== 65 // typedef: 66 // GMM_RESOURCE_MMC_HINT 67 // 68 // Description: 69 // This struct is used to indicate if Media Memory Compression is needed. 70 //--------------------------------------------------------------------------- 71 typedef enum GMM_RESOURCE_MMC_HINT_REC 72 { 73 GMM_MMC_HINT_ON = 0, 74 GMM_MMC_HINT_OFF, 75 }GMM_RESOURCE_MMC_HINT; 76 77 //=========================================================================== 78 // typedef: 79 // GMM_MSAA_SAMPLE_PATTERN 80 // 81 // Description: 82 // This enum details the sample pattern of a MSAA texture 83 //--------------------------------------------------------------------------- 84 typedef enum GMM_MSAA_SAMPLE_PATTERN_REC 85 { 86 GMM_MSAA_DISABLED = 0, 87 GMM_MSAA_STANDARD, 88 GMM_MSAA_CENTEROID, 89 GMM_MSAA_REGULAR 90 91 }GMM_MSAA_SAMPLE_PATTERN; 92 93 typedef enum GMM_TILE_RANGE_FLAG_ENUM 94 { 95 GMM_TILE_RANGE_NULL = 0x00000001, 96 GMM_TILE_RANGE_SKIP = 0x00000002, 97 GMM_TILE_RANGE_REUSE_SINGLE_TILE = 0x00000004, 98 } GMM_TILE_RANGE_FLAG; 99 100 //=========================================================================== 101 // typedef: 102 // GMM_RESOURCE_MSAA_INFO 103 // 104 // Description: 105 // This struct is used to describe MSAA information. 106 //--------------------------------------------------------------------------- 107 typedef struct GMM_RESOURCE_MSAA_INFO_REC 108 { 109 GMM_MSAA_SAMPLE_PATTERN SamplePattern; 110 uint32_t NumSamples; 111 }GMM_RESOURCE_MSAA_INFO; 112 113 //=========================================================================== 114 // typedef: 115 // GMM_RESOURCE_ALIGNMENT_UNITS 116 // 117 // Description: 118 // Various alignment units of an allocation. 119 // NOTE: H/VAlign and QPitch stored *UNCOMPRESSED* here, despite Gen9+ 120 // SURFACE_STATE using compressed!!! 121 //--------------------------------------------------------------------------- 122 typedef struct GMM_RESOURCE_ALIGNMENT_REC 123 { 124 uint8_t ArraySpacingSingleLod; // Single-LOD/Full Array Spacing 125 uint32_t BaseAlignment; // Base Alignment 126 uint32_t HAlign, VAlign, DAlign; // Alignment Unit Width/Height 127 uint32_t MipTailStartLod; // Mip Tail (SKL+) 128 uint32_t PackedMipStartLod; // Packed Mip (Pre-Gen9 / Undefined64KBSwizzle) 129 uint32_t PackedMipWidth; // Packed Mip Width in # of 64KB Tiles (Pre-Gen9 / Undefined64KBSwizzle) 130 uint32_t PackedMipHeight; // Packed Mip Height in # of 64KB Tiles (Pre-Gen9 / Undefined64KBSwizzle) 131 uint32_t QPitch; // Programmable QPitch (BDW+) 132 }GMM_RESOURCE_ALIGNMENT; 133 //=========================================================================== 134 // typedef: 135 // GMM_PAGETABLE_MGR 136 // 137 // Description: 138 // This struct is used to describe page table manager. 139 // Forward Declaration: Defined in GmmPageTableMgr.h 140 //--------------------------------------------------------------------------- 141 #ifdef __cplusplus 142 namespace GmmLib 143 { 144 class GmmPageTableMgr; 145 } 146 typedef GmmLib::GmmPageTableMgr GMM_PAGETABLE_MGR; 147 #else 148 typedef struct GmmPageTableMgr GMM_PAGETABLE_MGR; 149 #endif 150 151 #ifdef __cplusplus 152 namespace GmmLib 153 { 154 class Context; 155 } // namespace GmmLib 156 typedef GmmLib::Context GMM_LIB_CONTEXT; 157 #else 158 typedef struct GmmLibContext GMM_LIB_CONTEXT; 159 #endif 160 //=========================================================================== 161 // typedef: 162 // GMM_RESOURCE_INFO 163 // 164 // Description: 165 // This struct is used to describe resource allocations. 166 // Forward Declaration: Defined in GmmResourceInfo*.h 167 //--------------------------------------------------------------------------- 168 #ifdef __cplusplus 169 namespace GmmLib 170 { 171 #ifdef _WIN32 172 class GmmResourceInfoWin; 173 typedef GmmResourceInfoWin GmmResourceInfo; 174 #else 175 class GmmResourceInfoLin; 176 typedef GmmResourceInfoLin GmmResourceInfo; 177 #endif 178 } 179 typedef GmmLib::GmmResourceInfo GMM_RESOURCE_INFO; 180 typedef GmmLib::GmmResourceInfo GMM_RESOURCE_INFO_REC; 181 typedef GmmLib::GmmResourceInfo* PGMM_RESOURCE_INFO; 182 183 #else 184 typedef struct GmmResourceInfo GMM_RESOURCE_INFO; 185 typedef struct GmmResourceInfo* PGMM_RESOURCE_INFO; 186 #endif 187 188 //=========================================================================== 189 // Place holder for GMM_RESOURCE_FLAG definition. 190 //--------------------------------------------------------------------------- 191 #include "GmmResourceFlags.h" 192 #if defined __linux__ 193 #include "External/Linux/GmmResourceInfoLinExt.h" 194 #endif 195 196 //========================================================================== 197 // typedef: 198 // GMM_S3D_OFFSET_INFO 199 // 200 // Description: 201 // Contains offset info for S3D resources. 202 // 203 //-------------------------------------------------------------------------- 204 typedef struct GMM_S3D_OFFSET_INFO_REC 205 { 206 uint32_t AddressOffset; 207 uint32_t OffsetX; 208 uint32_t OffsetY; 209 uint32_t LineOffsetY; 210 } GMM_S3D_OFFSET_INFO; 211 212 //========================================================================== 213 // typedef: 214 // GMM_S3D_INFO 215 // 216 // Description: 217 // Describes properties of S3D feature. 218 // 219 //-------------------------------------------------------------------------- 220 typedef struct GMM_S3D_INFO_REC 221 { 222 uint32_t DisplayModeHeight; // Current display mode resolution 223 uint32_t NumBlankActiveLines; // Number of blank lines 224 uint32_t RFrameOffset; // R frame offset 225 uint32_t BlankAreaOffset; // Blank area offset 226 uint32_t TallBufferHeight; // Tall buffer height 227 uint32_t TallBufferSize; // Tall buffer size 228 uint8_t IsRFrame; // Flag indicating this is the R frame 229 } GMM_S3D_INFO; 230 231 //=========================================================================== 232 // typedef: 233 // GMM_MULTI_TILE_ARCH 234 // 235 // Description: 236 // This structure is provides an advanced allocation interface for 4xXeHP 237 // multi tile Gpu support 238 //--------------------------------------------------------------------------- 239 typedef struct GMM_MULTI_TILE_ARCH_REC // FtrMultiTileArch Advanced Parameters... 240 { 241 242 uint8_t Enable : 1; // When FALSE, this struct is ignored 243 // and GMM will make such decisions 244 // based on the process's default 245 // tile assignment from KMD. 246 247 uint8_t TileInstanced : 1; // When TRUE allocation is Tile 248 // instanced resource 249 250 uint8_t GpuVaMappingSet; // Bitmask indicating which tiles 251 // should receive page table updates 252 // when this allocation is mapped. 253 // For all tiles set ADAPTER_INFO.MultiTileArch.TileMask 254 255 uint8_t LocalMemEligibilitySet; // Bitmask indicating which tile's 256 // Local Memory this allocation 257 // can reside in--i.e. in addition to 258 // its preferred set, which others 259 // can it be migrated to under memory 260 // pressure. Entirely zeroed mask 261 // would be used for NonLocalOnly 262 // allocations. 263 264 uint8_t LocalMemPreferredSet; // Bitmask indicating subset of above 265 // eligibility set that is preferred 266 // above the others. Entirely zeroed 267 // mask is equivalent to mask of all 268 // ones--i.e. "no preference within 269 // eligibility set". 270 271 uint32_t Reserved; 272 273 } GMM_MULTI_TILE_ARCH; 274 //=========================================================================== 275 // typedef: 276 // GMM_RESCREATE_PARAMS 277 // 278 // Description: 279 // This structure is used to describe an resource allocation request. 280 // Please note that AllocationReuse makes use of member order. 281 // more info: oskl.h: AllocationReusePredicate and Functor 282 //--------------------------------------------------------------------------- 283 typedef struct GMM_RESCREATE_PARAMS_REC 284 { 285 GMM_RESOURCE_TYPE Type; // 1D/2D/.../SCRATCH/... 286 GMM_RESOURCE_FORMAT Format; // Pixel format e.g. NV12, GENERIC_8BIT 287 GMM_RESOURCE_FLAG Flags; // See substructure type. 288 GMM_RESOURCE_MSAA_INFO MSAA; // How to sample this resource for anti-alisaing. 289 290 GMM_RESOURCE_USAGE_TYPE Usage; // Intended use for this resource. See enumerated type. 291 uint32_t CpTag; 292 293 union 294 { 295 uint32_t BaseWidth; // Aligned width of buffer (aligned according to .Format) 296 GMM_GFX_SIZE_T BaseWidth64; 297 298 // The HW buffer types, BUFFER and STRBUF, are arrays of user-defined 299 // struct's. Their natural sizing parameters are (1) the struct size 300 // and (2) the numer of array elements (i.e. the number of structs). 301 // However, the GMM allows these to be allocated in either of two ways: 302 // (1) Client computes total allocation size and passes via BaseWidth 303 // (leaving ArraySize 0), or (2) Client passes natural sizing parameters 304 // via BaseWidth and ArraySize. To make the latter more readable, 305 // clients can use the BaseWidth union alias, BufferStructSize (as well 306 // as the GmmResGetBaseWidth alias, GmmResGetBufferStructSize). 307 uint32_t BufferStructSize; // Note: If ever de-union'ing, mind the GmmResGetBufferStructSize #define. 308 }; 309 310 uint32_t BaseHeight; // Aligned height of buffer (aligned according to .Format) 311 uint32_t Depth; // For 3D resources Depth>1, for 1D/2D, a default of 0 is uplifted to 1. 312 313 uint32_t MaxLod; 314 uint32_t ArraySize; // A number of n-dimensional buffers can be allocated together. 315 316 uint32_t BaseAlignment; 317 uint32_t OverridePitch; 318 #if(LHDM) 319 D3DDDI_RATIONAL DdiRefreshRate; 320 D3DDDI_RESOURCEFLAGS DdiD3d9Flags; 321 D3DDDIFORMAT DdiD3d9Format; 322 D3DDDI_VIDEO_PRESENT_SOURCE_ID DdiVidPnSrcId; 323 #endif 324 uint32_t RotateInfo; 325 uint64_t pExistingSysMem; 326 GMM_GFX_SIZE_T ExistingSysMemSize; 327 #ifdef _WIN32 328 D3DKMT_HANDLE hParentAllocation; //For ExistingSysMem Virtual Padding 329 #endif 330 331 #if __GMM_KMD__ 332 uint32_t CpuAccessible; // Kernel mode clients set if CPU pointer to resource is required. 333 GMM_S3D_INFO S3d; 334 void *pDeviceContext; 335 #endif 336 uint32_t MaximumRenamingListLength; 337 uint8_t NoGfxMemory; 338 GMM_RESOURCE_INFO *pPreallocatedResInfo; 339 GMM_MULTI_TILE_ARCH MultiTileArch; 340 341 } GMM_RESCREATE_PARAMS; 342 343 typedef struct GMM_RESCREATE_CUSTOM_PARAMS__REC 344 { 345 GMM_RESOURCE_TYPE Type; // 1D/2D/.../SCRATCH/... 346 GMM_RESOURCE_FORMAT Format; // Pixel format e.g. NV12, GENERIC_8BIT 347 GMM_RESOURCE_FLAG Flags; // See substructure type. 348 GMM_RESOURCE_USAGE_TYPE Usage; // Intended use for this resource. See enumerated type. 349 GMM_GFX_SIZE_T BaseWidth64; 350 uint32_t BaseHeight; // Aligned height of buffer (aligned according to .Format) 351 352 uint32_t Pitch; 353 GMM_GFX_SIZE_T Size; 354 uint32_t BaseAlignment; 355 356 struct 357 { 358 uint32_t X[GMM_MAX_PLANE]; 359 uint32_t Y[GMM_MAX_PLANE]; 360 }PlaneOffset; 361 362 uint32_t NoOfPlanes; 363 uint32_t CpTag; 364 }GMM_RESCREATE_CUSTOM_PARAMS; 365 366 typedef union GMM_DRIVERPROTECTION_BITS 367 { 368 struct 369 { 370 uint64_t PATIndex : 5; // PATIndex 371 uint64_t Reserved : 25; 372 uint64_t CacheableNoSnoop: 1; // disregard OS's coherent request in UpdatePageTable 373 uint64_t CompressionEnReq: 1; // C/NC request from UMD 374 uint64_t Reserved1 : 32; //DO NOT SET !! Reserved for OS Refer: D3DGPU_UNIQUE_DRIVER_PROTECTION 375 }; 376 uint64_t Value; 377 } GMM_DRIVERPROTECTION; 378 379 #ifndef __GMM_KMD__ 380 typedef struct GMM_RESCREATE_CUSTOM_PARAMS_2_REC : public GMM_RESCREATE_CUSTOM_PARAMS 381 { 382 struct 383 { 384 uint32_t Pitch; 385 GMM_GFX_SIZE_T Size; 386 uint32_t BaseAlignment; 387 struct 388 { 389 uint32_t X[GMM_MAX_PLANE]; 390 uint32_t Y[GMM_MAX_PLANE]; 391 } PlaneOffset; 392 } AuxSurf; 393 394 uint64_t Reserved; 395 uint64_t Reserved1; 396 }GMM_RESCREATE_CUSTOM_PARAMS_2; 397 #endif 398 399 typedef struct GMM_OVERRIDE_VALUES_REC 400 { 401 uint32_t Usage; // GMM_RESOURCE_USAGE_TYPE 402 uint8_t CompressionDis; 403 } GMM_OVERRIDE_VALUES; 404 405 //=========================================================================== 406 // enum : 407 // GMM_UNIFIED_AUX_TYPE 408 // 409 // Description: 410 // This enumarates various aux surface types in a unified 411 // auxiliary surface 412 //--------------------------------------------------------------------------- 413 // Usage : 414 // UMD client use this enum to request the aux offset and size. 415 // using via GmmResGetAuxSurfaceOffset, GmmResGetSizeAuxSurface 416 // 417 // RT buffer with Clear Color 418 // ________________________________________________ 419 // | | 420 // | | 421 // | | 422 // | Pixel Data | 423 // | | 424 // | | 425 // | | 426 // | | 427 // | | 428 // | | 429 // A | | 430 // -->|________________________________________________| 431 // | | | 432 // | | | 433 // | Tag plane | | 434 // | (a.k.a mcs, aux-plane,ccs) | ------------|->GmmResGetSizeAuxSurface(pRes, GMM_AUX_CCS) 435 // | | | 436 // -->|__________________________________| | 437 // B | CC FV | CC NV | ------------------------------|--->GmmResGetSizeAuxSurface(pRes, GMM_AUX_CC) 438 // |_______|________| | 439 // | | 440 // | | 441 // | Padded to Main Surf's(TileHeight & SurfPitch)| --> Padding needed for Global GTT aliasing 442 // -->|________________________________________________| 443 // C | | 444 // | Tag plane | 445 // | for MSAA/Depth compr | 446 // | (a.k.a ccs, zcs) ------------|->GmmResGetSizeAuxSurface(pRes, GMM_AUX_CCS or GMM_AUX_ZCS) 447 // |________________________________________________| 448 // 449 // Where 450 // FV. Clear color Float Value 451 // NV. Clear color Native Value 452 // A. GmmResGetAuxSurfaceOffset(pRes, GMM_AUX_CCS) 453 // B. GmmResGetAuxSurfaceOffset(pRes, GMM_AUX_CC) 454 // C. GmmResGetAuxSurfaceOffset(pRes, GMM_AUX_CCS or GMM_AUX_ZCS) 455 typedef enum 456 { 457 GMM_AUX_INVALID, // Main resource 458 GMM_AUX_CCS, // RT buffer's color control surface (Unpadded) 459 GMM_AUX_Y_CCS, // color control surface for Y-plane 460 GMM_AUX_UV_CCS, // color control surface for UV-plane 461 GMM_AUX_CC, // clear color value (4kb granularity) 462 GMM_AUX_COMP_STATE, // Media compression state (cacheline aligned 64B) 463 GMM_AUX_HIZ, // HiZ surface for unified Depth buffer 464 GMM_AUX_MCS, // multi-sample control surface for unified MSAA 465 GMM_AUX_ZCS, // CCS for Depth Z compression 466 GMM_AUX_SURF // Total Aux Surface (CCS + CC + Padding) 467 } GMM_UNIFIED_AUX_TYPE; 468 469 //=========================================================================== 470 // enum : 471 // GMM_SIZE_PARAM 472 // 473 // Description: 474 // This enumarates various surface size parameters available for GetSize query. 475 // Refer GmmResourceInfoCommon.h GetSize() api 476 // 477 // Note: 478 // Below legacy API to query surface size are deprecated and will be removed in 479 // later gmm releases. 480 // - GmmResGetSizeSurface()/ pResInfo->GetSizeSurface() 481 // - GmmResGetSizeMainSurface()/ pResInfo->GetSizeAllocation() 482 // - GmmResGetSizeAllocation()/ pResInfo->GetSizeMainSurface() 483 //--------------------------------------------------------------------------- 484 // Usage : 485 // UMD client use this enum to request the surface size. 486 //=========================================================================== 487 typedef enum 488 { 489 GMM_INVALID_PARAM, // Leave 0 as invalid to force client to explictly set 490 GMM_MAIN_SURF, // Main surface size(w/o aux data) 491 GMM_MAIN_PLUS_AUX_SURF, // Main surface plus auxilary data, includes ccs, cc, zcs, mcs metadata. Renderable portion of the surface. 492 GMM_TOTAL_SURF, // Main+Aux with additional padding based on hardware PageSize. 493 GMM_MAPGPUVA_SIZE = GMM_TOTAL_SURF,// To be used for mapping gpu virtual address space. 494 GMM_TOTAL_SURF_PHYSICAL, 495 GMM_MAIN_SURF_PHYSICAL, 496 } GMM_SIZE_PARAM; 497 498 //=========================================================================== 499 // typedef: 500 // GMM_RES_COPY_BLT 501 // 502 // Description: 503 // Describes a GmmResCpuBlt operation. 504 //--------------------------------------------------------------------------- 505 typedef struct GMM_RES_COPY_BLT_REC 506 { 507 struct // GPU Surface Description... 508 { 509 void *pData; // Pointer to base of the mapped resource data (e.g. D3DDDICB_LOCK.pData). 510 uint32_t Slice; // Array/Volume Slice or Cube Face; zero if N/A. 511 uint32_t MipLevel; // Index of applicable MIP, or zero if N/A. 512 //uint32_t MsaaSample; // Index of applicable MSAA sample, or zero if N/A. 513 uint32_t OffsetX; // Pixel offset from left-edge of specified (Slice/MipLevel) subresource. 514 uint32_t OffsetY; // Pixel row offset from top of specified subresource. 515 uint32_t OffsetSubpixel; // Byte offset into the surface pixel of the applicable subpixel. 516 } Gpu; // Surface description of GPU resource involved in BLT. 517 518 struct // System Surface Description... 519 { 520 void *pData; // Pointer to system memory surface. 521 uint32_t RowPitch; // Row pitch in bytes of pData surface. 522 uint32_t SlicePitch; // Slice pitch in bytes of pData surface; ignored if Blt.Slices <= 1. 523 uint32_t PixelPitch; // Number of bytes from one pData pixel to its horizontal neighbor; 0 = "Same as GPU Resource". 524 //uint32_t MsaaSamplePitch;// Number of bytes from one pData MSAA sample to the next; ignored if Blt.MsaaSamples <= 1. 525 uint32_t BufferSize; // Number of bytes at pData. (Value used only in asserts to catch overuns.) 526 } Sys; // Description of system memory surface being BLT'ed to/from the GPU surface. 527 528 struct // BLT Description... 529 { 530 uint32_t Width; // Copy width in pixels; 0 = "Full Width" of specified subresource. 531 uint32_t Height; // Copy height in pixel rows; 0 = "Full Height" of specified subresource. 532 uint32_t Slices; // Number of slices being copied; 0 = 1 = "N/A or single slice". 533 uint32_t BytesPerPixel; // Number of bytes to copy, per pixel; 0 = "Same as Sys.PixelPitch". 534 //uint32_t MsaaSamples; // Number of samples to copy per pixel; 0 = 1 = "N/A or single sample". 535 uint8_t Upload; // true = Sys-->Gpu; false = Gpu-->Sys. 536 } Blt; // Description of the BLT being performed. 537 } GMM_RES_COPY_BLT; 538 539 //=========================================================================== 540 // typedef: 541 // GMM_GET_MAPPING 542 // 543 // Description: 544 // GmmResGetMappingSpanDesc interface and inter-call state. 545 //--------------------------------------------------------------------------- 546 typedef enum 547 { 548 GMM_MAPPING_NULL = 0, 549 GMM_MAPPING_LEGACY_Y_TO_STDSWIZZLE_SHAPE, 550 GMM_MAPPING_GEN9_YS_TO_STDSWIZZLE, 551 GMM_MAPPING_YUVPLANAR, 552 GMM_MAPPING_YUVPLANAR_AUX, 553 } GMM_GET_MAPPING_TYPE; 554 555 typedef struct GMM_GET_MAPPING_REC 556 { 557 GMM_GET_MAPPING_TYPE Type; 558 559 struct 560 { 561 GMM_GFX_SIZE_T VirtualOffset; 562 GMM_GFX_SIZE_T PhysicalOffset; 563 GMM_GFX_SIZE_T Size; 564 } Span, __NextSpan; 565 566 struct 567 { 568 struct 569 { 570 uint32_t Width, Height, Depth; // in Uncompressed Pixels 571 } Element, Tile; 572 struct 573 { 574 GMM_GFX_SIZE_T Physical, Virtual; 575 } Slice0MipOffset, SlicePitch; 576 uint32_t EffectiveLodMax, Lod, Row, RowPitchVirtual, Rows, Slice, Slices; 577 GMM_YUV_PLANE Plane, LastPlane; 578 } Scratch; // Zero on initial call to GmmResGetMappingSpanDesc and then let persist. 579 } GMM_GET_MAPPING; 580 //*************************************************************************** 581 // 582 // GMM_RESOURCE_INFO API 583 // 584 //*************************************************************************** 585 uint8_t GMM_STDCALL GmmIsPlanar(GMM_RESOURCE_FORMAT Format); 586 uint8_t GMM_STDCALL GmmIsP0xx(GMM_RESOURCE_FORMAT Format); 587 uint8_t GMM_STDCALL GmmIsUVPacked(GMM_RESOURCE_FORMAT Format); 588 bool GMM_STDCALL GmmIsYUVFormatLCUAligned(GMM_RESOURCE_FORMAT Format); 589 #define GmmIsYUVPlanar GmmIsPlanar // TODO(Benign): Support old name until we have a chance to correct in UMD(s) using this. No longer YUV since there are now RGB planar formats. 590 uint8_t GMM_STDCALL GmmIsReconstructableSurface(GMM_RESOURCE_FORMAT Format); 591 uint8_t GMM_STDCALL GmmIsCompressed(void *pLibContext, GMM_RESOURCE_FORMAT Format); 592 uint8_t GMM_STDCALL GmmIsYUVPacked(GMM_RESOURCE_FORMAT Format); 593 uint8_t GMM_STDCALL GmmIsRedecribedPlanes(GMM_RESOURCE_INFO *pGmmResource); 594 uint8_t GMM_STDCALL GmmResApplyExistingSysMem(GMM_RESOURCE_INFO *pGmmResource, void *pExistingSysMem, GMM_GFX_SIZE_T ExistingSysMemSize); 595 uint8_t GMM_STDCALL GmmGetLosslessCompressionType(void *pLibContext, GMM_RESOURCE_FORMAT Format); 596 GMM_RESOURCE_INFO* GMM_STDCALL GmmResCopy(GMM_RESOURCE_INFO *pGmmResource); 597 void GMM_STDCALL GmmResMemcpy(void *pDst, void *pSrc); 598 uint8_t GMM_STDCALL GmmResCpuBlt(GMM_RESOURCE_INFO *pGmmResource, GMM_RES_COPY_BLT *pBlt); 599 GMM_RESOURCE_INFO *GMM_STDCALL GmmResCreate(GMM_RESCREATE_PARAMS *pCreateParams, GMM_LIB_CONTEXT *pLibContext); 600 void GMM_STDCALL GmmResFree(GMM_RESOURCE_INFO *pGmmResource); 601 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeMainSurface(const GMM_RESOURCE_INFO *pResourceInfo); 602 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeSurface(GMM_RESOURCE_INFO *pResourceInfo); 603 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeAllocation(GMM_RESOURCE_INFO *pResourceInfo); 604 605 uint32_t GMM_STDCALL GmmResGetArraySize(GMM_RESOURCE_INFO *pGmmResource); 606 uint32_t GMM_STDCALL GmmResGetAuxBitsPerPixel(GMM_RESOURCE_INFO *pGmmResource); 607 uint32_t GMM_STDCALL GmmResGetAuxPitch(GMM_RESOURCE_INFO *pGmmResource); 608 uint32_t GMM_STDCALL GmmResGetAuxQPitch(GMM_RESOURCE_INFO *pGmmResource); 609 uint8_t GMM_STDCALL GmmResIs64KBPageSuitable(GMM_RESOURCE_INFO *pGmmResource); 610 uint32_t GMM_STDCALL GmmResGetAuxSurfaceOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType); 611 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetAuxSurfaceOffset64(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType); 612 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSizeAuxSurface(GMM_RESOURCE_INFO *pGmmResource, GMM_UNIFIED_AUX_TYPE GmmAuxType); 613 uint32_t GMM_STDCALL GmmResGetAuxHAlign(GMM_RESOURCE_INFO *pGmmResource); 614 uint32_t GMM_STDCALL GmmResGetAuxVAlign(GMM_RESOURCE_INFO *pGmmResource); 615 uint32_t GMM_STDCALL GmmResGetBaseAlignment(GMM_RESOURCE_INFO *pGmmResource); 616 uint32_t GMM_STDCALL GmmResGetBaseHeight(GMM_RESOURCE_INFO *pGmmResource); 617 uint32_t GMM_STDCALL GmmResGetBaseWidth(GMM_RESOURCE_INFO *pGmmResource); 618 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetBaseWidth64(GMM_RESOURCE_INFO *pGmmResource); 619 uint32_t GMM_STDCALL GmmResGetBitsPerPixel(GMM_RESOURCE_INFO *pGmmResource); 620 #define GmmResGetBufferStructSize GmmResGetBaseWidth // See GMM_RESCREATE_PARAMS.BufferStructSize comment. 621 uint32_t GMM_STDCALL GmmResGetCompressionBlockDepth(GMM_RESOURCE_INFO *pGmmResource); 622 uint32_t GMM_STDCALL GmmResGetCompressionBlockHeight(GMM_RESOURCE_INFO *pGmmResource); 623 uint32_t GMM_STDCALL GmmResGetCompressionBlockWidth(GMM_RESOURCE_INFO *pGmmResource); 624 GMM_CPU_CACHE_TYPE GMM_STDCALL GmmResGetCpuCacheType(GMM_RESOURCE_INFO *pGmmResource); 625 uint32_t GMM_STDCALL GmmResGetDepth(GMM_RESOURCE_INFO *pGmmResource); 626 void GMM_STDCALL GmmResGetFlags(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FLAG *pFlags /*output*/); //TODO: Remove after changing all UMDs 627 GMM_RESOURCE_FLAG GMM_STDCALL GmmResGetResourceFlags(const GMM_RESOURCE_INFO *pGmmResource); 628 GMM_GFX_ADDRESS GMM_STDCALL GmmResGetGfxAddress(GMM_RESOURCE_INFO *pGmmResource); 629 uint32_t GMM_STDCALL GmmResGetHAlign(GMM_RESOURCE_INFO *pGmmResource); 630 #define GmmResGetLockPitch GmmResGetRenderPitch // Support old name until UMDs drop use. 631 uint8_t GMM_STDCALL GmmResGetMappingSpanDesc(GMM_RESOURCE_INFO *pGmmResource, GMM_GET_MAPPING *pMapping); 632 uint32_t GMM_STDCALL GmmResGetMaxLod(GMM_RESOURCE_INFO *pGmmResource); 633 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetStdLayoutSize(GMM_RESOURCE_INFO *pGmmResource); 634 uint32_t GMM_STDCALL GmmResGetSurfaceStateMipTailStartLod(GMM_RESOURCE_INFO *pGmmResource); 635 uint32_t GMM_STDCALL GmmResGetSurfaceStateTileAddressMappingMode(GMM_RESOURCE_INFO *pGmmResource); 636 uint32_t GMM_STDCALL GmmResGetSurfaceStateStdTilingModeExt(GMM_RESOURCE_INFO *pGmmResource); 637 GMM_RESOURCE_MMC_INFO GMM_STDCALL GmmResGetMmcMode(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex); 638 uint32_t GMM_STDCALL GmmResGetNumSamples(GMM_RESOURCE_INFO *pGmmResource); 639 GMM_STATUS GMM_STDCALL GmmResGetOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_REQ_OFFSET_INFO *pReqInfo); 640 GMM_STATUS GMM_STDCALL GmmResGetOffsetFor64KBTiles(GMM_RESOURCE_INFO *pGmmResource, GMM_REQ_OFFSET_INFO *pReqInfo); 641 uint32_t GMM_STDCALL GmmResGetPaddedHeight(GMM_RESOURCE_INFO *pGmmResource, uint32_t MipLevel); 642 uint32_t GMM_STDCALL GmmResGetPaddedWidth(GMM_RESOURCE_INFO *pGmmResource, uint32_t MipLevel); 643 uint32_t GMM_STDCALL GmmResGetPaddedPitch(GMM_RESOURCE_INFO *pGmmResource, uint32_t MipLevel); 644 void* GMM_STDCALL GmmResGetPrivateData(GMM_RESOURCE_INFO *pGmmResource); 645 uint32_t GMM_STDCALL GmmResGetQPitch(GMM_RESOURCE_INFO *pGmmResource); 646 uint32_t GMM_STDCALL GmmResGetQPitchPlanar(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane); 647 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetQPitchInBytes(GMM_RESOURCE_INFO *pGmmResource); 648 uint32_t GMM_STDCALL GmmResGetRenderAuxPitchTiles(GMM_RESOURCE_INFO *pGmmResource); 649 uint32_t GMM_STDCALL GmmResGetRenderPitch(GMM_RESOURCE_INFO *pGmmResource); 650 uint32_t GMM_STDCALL GmmResGetRenderPitchIn64KBTiles(GMM_RESOURCE_INFO *pGmmResource); 651 uint32_t GMM_STDCALL GmmResGetRenderPitchTiles(GMM_RESOURCE_INFO *pGmmResource); 652 GMM_RESOURCE_FORMAT GMM_STDCALL GmmResGetResourceFormat(GMM_RESOURCE_INFO *pGmmResource); 653 GMM_RESOURCE_TYPE GMM_STDCALL GmmResGetResourceType(GMM_RESOURCE_INFO *pGmmResource); 654 uint32_t GMM_STDCALL GmmResGetRotateInfo(GMM_RESOURCE_INFO *pGmmResource); 655 GMM_MSAA_SAMPLE_PATTERN GMM_STDCALL GmmResGetSamplePattern(GMM_RESOURCE_INFO *pGmmResource); 656 uint32_t GMM_STDCALL GmmResGetSizeOfStruct(void); 657 GMM_SURFACESTATE_FORMAT GMM_STDCALL GmmResGetSurfaceStateFormat(GMM_RESOURCE_INFO *pGmmResource); 658 GMM_SURFACESTATE_FORMAT GMM_STDCALL GmmGetSurfaceStateFormat(GMM_RESOURCE_FORMAT Format,GMM_LIB_CONTEXT* pGmmLibContext); 659 uint32_t GMM_STDCALL GmmResGetSurfaceStateHAlign(GMM_RESOURCE_INFO *pGmmResource); 660 uint32_t GMM_STDCALL GmmResGetSurfaceStateVAlign(GMM_RESOURCE_INFO *pGmmResource); 661 uint32_t GMM_STDCALL GmmResGetSurfaceStateTiledResourceMode(GMM_RESOURCE_INFO *pGmmResource); 662 void* GMM_STDCALL GmmResGetSystemMemPointer(GMM_RESOURCE_INFO *pGmmResource, uint8_t IsD3DDdiAllocation); 663 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetSystemMemSize( GMM_RESOURCE_INFO* pRes ); 664 uint32_t GMM_STDCALL GmmResGetTallBufferHeight(GMM_RESOURCE_INFO *pResourceInfo); 665 uint32_t GMM_STDCALL GmmResGetMipHeight(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel); 666 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetMipWidth(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel); 667 uint32_t GMM_STDCALL GmmResGetMipDepth(GMM_RESOURCE_INFO *pResourceInfo, uint32_t MipLevel); 668 uint8_t GMM_STDCALL GmmResGetCornerTexelMode(GMM_RESOURCE_INFO *pGmmResource); 669 GMM_TEXTURE_LAYOUT GMM_STDCALL GmmResGetTextureLayout(GMM_RESOURCE_INFO *pGmmResource); 670 GMM_TILE_TYPE GMM_STDCALL GmmResGetTileType(GMM_RESOURCE_INFO *pGmmResource); 671 uint32_t GMM_STDCALL GmmResGetVAlign(GMM_RESOURCE_INFO *pGmmResource); 672 uint8_t GMM_STDCALL GmmResIsArraySpacingSingleLod(GMM_RESOURCE_INFO *pGmmResource); 673 uint8_t GMM_STDCALL GmmResIsASTC(GMM_RESOURCE_INFO *pGmmResource); 674 uint8_t GMM_STDCALL GmmResIsLockDiscardCompatible(GMM_RESOURCE_INFO *pGmmResource); 675 uint8_t GMM_STDCALL GmmResIsMediaMemoryCompressed(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex); 676 uint8_t GMM_STDCALL GmmResIsMsaaFormatDepthStencil(GMM_RESOURCE_INFO *pGmmResource); 677 uint8_t GMM_STDCALL GmmResIsSvm(GMM_RESOURCE_INFO *pGmmResource); 678 void GMM_STDCALL GmmResSetMmcMode(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_MMC_INFO Mode, uint32_t ArrayIndex); 679 void GMM_STDCALL GmmResSetMmcHint(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_MMC_HINT Hint, uint32_t ArrayIndex); 680 GMM_RESOURCE_MMC_HINT GMM_STDCALL GmmResGetMmcHint(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex); 681 uint8_t GMM_STDCALL GmmResIsColorSeparation(GMM_RESOURCE_INFO *pGmmResource); 682 uint32_t GMM_STDCALL GmmResTranslateColorSeparationX(GMM_RESOURCE_INFO *pGmmResource, uint32_t x); 683 uint32_t GMM_STDCALL GmmResGetColorSeparationArraySize(GMM_RESOURCE_INFO *pGmmResource); 684 uint32_t GMM_STDCALL GmmResGetColorSeparationPhysicalWidth(GMM_RESOURCE_INFO *pGmmResource); 685 uint8_t GMM_STDCALL GmmResGetSetHardwareProtection(GMM_RESOURCE_INFO *pGmmResource, uint8_t GetIsEncrypted, uint8_t SetIsEncrypted); 686 uint32_t GMM_STDCALL GmmResGetMaxGpuVirtualAddressBits(GMM_RESOURCE_INFO *pGmmResource, GMM_LIB_CONTEXT* pGmmLibContext); 687 uint8_t GMM_STDCALL GmmIsSurfaceFaultable(GMM_RESOURCE_INFO *pGmmResource); 688 uint32_t GMM_STDCALL GmmResGetMaximumRenamingListLength(GMM_RESOURCE_INFO* pGmmResource); 689 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetXOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane); 690 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarGetYOffset(GMM_RESOURCE_INFO *pGmmResource, GMM_YUV_PLANE Plane); 691 GMM_GFX_SIZE_T GMM_STDCALL GmmResGetPlanarAuxOffset(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArrayIndex, GMM_UNIFIED_AUX_TYPE Plane); 692 void GMM_STDCALL GmmResSetLibContext(GMM_RESOURCE_INFO *pGmmResource, void *pLibContext); 693 uint32_t GMM_STDCALL GmmResIsMappedCompressible(GMM_RESOURCE_INFO *pGmmResource); 694 // Remove when client moves to new interface 695 uint32_t GMM_STDCALL GmmResGetRenderSize(GMM_RESOURCE_INFO *pResourceInfo); 696 uint8_t GMM_STDCALL GmmGetCompressionFormat(GMM_RESOURCE_FORMAT Format, GMM_LIB_CONTEXT *pGmmLibContext); 697 698 //===================================================================================================== 699 //forward declarations 700 struct GMM_TEXTURE_INFO_REC; 701 702 // Hack to define and undefine typedef name to avoid redefinition of the 703 // typedef. Part 1. 704 705 // typedef struct GMM_TEXTURE_INFO_REC GMM_TEXTURE_INFO; 706 #define GMM_TEXTURE_INFO struct GMM_TEXTURE_INFO_REC 707 708 709 // TODO: Allows UMD to override some parameters. Remove these functions once GMM comprehends UMD usage model and 710 // can support them properly. 711 void GMM_STDCALL GmmResOverrideAllocationSize(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Size); 712 void GMM_STDCALL GmmResOverrideAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch); 713 void GMM_STDCALL GmmResOverrideAuxAllocationPitch(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T Pitch); 714 void GMM_STDCALL GmmResOverrideAllocationFlags(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FLAG *pFlags); 715 void GMM_STDCALL GmmResOverrideAllocationHAlign(GMM_RESOURCE_INFO *pGmmResource, uint32_t HAlign); 716 void GMM_STDCALL GmmResOverrideAllocationBaseAlignment(GMM_RESOURCE_INFO *pGmmResource, uint32_t Alignment); 717 void GMM_STDCALL GmmResOverrideAllocationBaseWidth(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_SIZE_T BaseWidth); 718 void GMM_STDCALL GmmResOverrideAllocationBaseHeight(GMM_RESOURCE_INFO *pGmmResource, uint32_t BaseHeight); 719 void GMM_STDCALL GmmResOverrideAllocationDepth(GMM_RESOURCE_INFO *pGmmResource, uint32_t Depth); 720 void GMM_STDCALL GmmResOverrideResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode); 721 void GMM_STDCALL GmmResOverrideAuxResourceTiling(GMM_RESOURCE_INFO *pGmmResource, uint32_t TileMode); 722 void GMM_STDCALL GmmResOverrideAllocationTextureInfo(GMM_RESOURCE_INFO *pGmmResource, GMM_CLIENT Client, const GMM_TEXTURE_INFO *pTexInfo); 723 void GMM_STDCALL GmmResOverrideAllocationFormat(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_FORMAT Format); 724 void GMM_STDCALL GmmResOverrideSurfaceType(GMM_RESOURCE_INFO *pGmmResource, GMM_RESOURCE_TYPE ResourceType); 725 void GMM_STDCALL GmmResOverrideSvmGfxAddress(GMM_RESOURCE_INFO *pGmmResource, GMM_GFX_ADDRESS SvmGfxAddress); 726 void GMM_STDCALL GmmResOverrideAllocationArraySize(GMM_RESOURCE_INFO *pGmmResource, uint32_t ArraySize); 727 void GMM_STDCALL GmmResOverrideAllocationMaxLod(GMM_RESOURCE_INFO *pGmmResource, uint32_t MaxLod); 728 729 ////////////////////////////////////////////////////////////////////////////////////// 730 // GmmCachePolicy.c 731 ////////////////////////////////////////////////////////////////////////////////////// 732 MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmCachePolicyGetMemoryObject(void *pLibContext, 733 GMM_RESOURCE_INFO *pResInfo, 734 GMM_RESOURCE_USAGE_TYPE Usage); 735 GMM_PTE_CACHE_CONTROL_BITS GMM_STDCALL GmmCachePolicyGetPteType(void *pLibContext, GMM_RESOURCE_USAGE_TYPE Usage); 736 GMM_RESOURCE_USAGE_TYPE GMM_STDCALL GmmCachePolicyGetResourceUsage(GMM_RESOURCE_INFO *pResInfo ); 737 MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GmmCachePolicyGetOriginalMemoryObject(void *pLibContext, GMM_RESOURCE_INFO *pResInfo); 738 uint8_t GMM_STDCALL GmmCachePolicyIsUsagePTECached(void *pLibContext, GMM_RESOURCE_USAGE_TYPE Usage); 739 uint8_t GMM_STDCALL GmmGetSurfaceStateL1CachePolicy(void *pLibContext, GMM_RESOURCE_USAGE_TYPE Usage); 740 void GMM_STDCALL GmmCachePolicyOverrideResourceUsage(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage); 741 uint32_t GMM_STDCALL GmmCachePolicyGetMaxMocsIndex(void *pLibContext); 742 uint32_t GMM_STDCALL GmmCachePolicyGetMaxL1HdcMocsIndex(void *pLibContext); 743 uint32_t GMM_STDCALL GmmCachePolicyGetMaxSpecialMocsIndex(void *pLibContext); 744 745 746 void GMM_STDCALL GmmResSetPrivateData(GMM_RESOURCE_INFO *pGmmResource, void *pPrivateData); 747 uint32_t GMM_STDCALL GmmCachePolicyGetPATIndex(void *pLibContext, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable); 748 uint8_t GMM_STDCALL GmmGetSurfaceStateL2CachePolicy(void *pLibContext, GMM_RESOURCE_USAGE_TYPE Usage); 749 #if (!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB)) 750 ///////////////////////////////////////////////////////////////////////////////////// 751 /// C wrapper functions for UMD clients Translation layer from OLD GMM APIs to New 752 /// unified GMM Lib APIs 753 ///////////////////////////////////////////////////////////////////////////////////// 754 GMM_STATUS GmmCreateGlobalClientContext(GMM_CLIENT ClientType); 755 void GmmDestroyGlobalClientContext(); 756 GMM_RESOURCE_INFO* GmmResCreateThroughClientCtxt(GMM_RESCREATE_PARAMS *pCreateParams); 757 void GmmResFreeThroughClientCtxt(GMM_RESOURCE_INFO *pRes); 758 GMM_RESOURCE_INFO* GmmResCopyThroughClientCtxt(GMM_RESOURCE_INFO* pSrcRes); 759 void GmmResMemcpyThroughClientCtxt(void *pDst, void *pSrc); 760 #endif 761 762 // Hack to define and undefine typedef name to avoid redefinition of the 763 // typedef. Part 2. 764 #undef GMM_TEXTURE_INFO 765 766 // Reset packing alignment to project default 767 #pragma pack(pop) 768 769 #ifdef __cplusplus 770 } 771 #endif /*__cplusplus*/ 772