1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
|
/*==============================================================================
Copyright(c) 2017 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files(the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and / or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "Internal/Common/GmmLibInc.h"
//===========================================================================
// Global Variable:
// pGmmGlobalContext
//
// Description:
// Handle to global GMM structure containing GMM context and platform info.
//
//----------------------------------------------------------------------------
GMM_GLOBAL_CONTEXT *pGmmGlobalContext = NULL;
int32_t GmmLib::Context::RefCount = 0;
#ifdef GMM_LIB_DLL
// Create Mutex Object used for syncronization of ProcessSingleton Context
#ifdef _WIN32
GMM_MUTEX_HANDLE GmmLib::Context::SingletonContextSyncMutex = ::CreateMutex(NULL, FALSE, NULL);
#else
GMM_MUTEX_HANDLE GmmLib::Context::SingletonContextSyncMutex = PTHREAD_MUTEX_INITIALIZER;
#endif // _WIN32
/////////////////////////////////////////////////////////////////////////////////////
/// GMM lib DLL exported functions for creating Singleton Context (GmmLib::Context)
/// object which shall be process singleton across all UMD clients within a process.
/// @see Class GmmLib::Context
///
/// @param[in] Platform: platform variable. Includes product family (Haswell, Cherryview,
/// Broxton) with related render and display core revision (GEN3,
// ..., GEN10)
/// @param[in] pSkuTable: Pointer to the sku feature table. Set of capabilities to
/// allow code paths to be feature based and GEN agnostic.
/// @param[in] pWaTable: Pointer to the work around table. A set of anti-features,
/// often in early/prototype silicon that require work-arounds
/// until they are resolved to allow code paths to be GEN agnostic.
/// @param[in] pGtSysInfo: Pointer to the GT system info. Contains various GT System
/// Information such as EU counts, Thread Counts, Cache Sizes etc.
/// @return GMM_SUCCESS if Context is created, GMM_ERROR otherwise
/////////////////////////////////////////////////////////////////////////////////////
#ifdef _WIN32
extern "C" GMM_STATUS GMM_STDCALL GmmCreateSingletonContext(const PLATFORM Platform,
const SKU_FEATURE_TABLE *pSkuTable,
const WA_TABLE * pWaTable,
const GT_SYSTEM_INFO * pGtSysInfo)
#else
extern "C" GMM_STATUS GMM_STDCALL GmmCreateSingletonContext(const PLATFORM Platform,
const void * pSkuTable,
const void * pWaTable,
const void * pGtSysInfo)
#endif
{
__GMM_ASSERTPTR(pSkuTable, GMM_ERROR);
__GMM_ASSERTPTR(pWaTable, GMM_ERROR);
__GMM_ASSERTPTR(pGtSysInfo, GMM_ERROR);
GMM_STATUS Status = GMM_SUCCESS;
SKU_FEATURE_TABLE *skuTable;
WA_TABLE * waTable;
GT_SYSTEM_INFO * sysInfo;
skuTable = (SKU_FEATURE_TABLE *)pSkuTable;
waTable = (WA_TABLE *)pWaTable;
sysInfo = (GT_SYSTEM_INFO *)pGtSysInfo;
GMM_STATUS SyncLockStatus = GmmLib::Context::LockSingletonContextSyncMutex();
if(SyncLockStatus == GMM_SUCCESS)
{
int32_t ContextRefCount = GmmLib::Context::IncrementRefCount();
if(ContextRefCount)
{
GmmLib::Context::UnlockSingletonContextSyncMutex();
return GMM_SUCCESS;
}
pGmmGlobalContext = new GMM_GLOBAL_CONTEXT();
if(!pGmmGlobalContext)
{
GmmLib::Context::DecrementRefCount();
GmmLib::Context::UnlockSingletonContextSyncMutex();
return GMM_ERROR;
}
Status = (pGmmGlobalContext->InitContext(Platform, skuTable, waTable, sysInfo, GMM_KMD_VISTA));
#ifdef _WIN32
// Intialize SingletonContext Data.
// TBD: ProcessHeap creation requires size and GfxAddress parameters. These parameters are contants
// and are given by GMM lib internally by PageTableMgr. Hence pHeapObj should be created here at the
// time of SingletonContext creation. But untill all UMD clients have moved to GMM DLL, then we will
// create this here.
pGmmGlobalContext->pHeapObj = NULL;
pGmmGlobalContext->ProcessHeapCounter = 0;
// TBD: ProcessVA Gfx partition should be created here using VirtualAlloc at the time of SingletonContext
// creation. But untill all UMD clients have moved to GMM DLL, then we will
// create this here.
pGmmGlobalContext->ProcessVA = {0};
pGmmGlobalContext->ProcessVACounter = 0;
#endif
GmmLib::Context::UnlockSingletonContextSyncMutex();
return Status;
}
else ///< Error in Acquiring SyncLock, return Error
{
return GMM_ERROR;
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// GMM lib DLL exported functions for deleting the Singleton Context.
/// Reference Count will be decremented and once the reference count reaches 0,
/// Singleton Context will be freeed in memory
/////////////////////////////////////////////////////////////////////////////////////
extern "C" void GMM_STDCALL GmmDestroySingletonContext(void)
{
GMM_STATUS SyncLockStatus = GmmLib::Context::LockSingletonContextSyncMutex();
if(SyncLockStatus == GMM_SUCCESS)
{
int32_t ContextRefCount = GmmLib::Context::DecrementRefCount();
if(!ContextRefCount && pGmmGlobalContext)
{
pGmmGlobalContext->DestroyContext();
delete pGmmGlobalContext;
pGmmGlobalContext = NULL;
}
GmmLib::Context::UnlockSingletonContextSyncMutex();
}
}
#ifdef _WIN32
/////////////////////////////////////////////////////////////////////////
/// Get ProcessHeapVA Singleton HeapObj
/////////////////////////////////////////////////////////////////////////
GMM_HEAP *GmmLib::Context::GetSharedHeapObject()
{
GMM_HEAP *pHeapObjOut = NULL;
// Obtain ProcessSingleton Lock
GmmLib::Context::LockSingletonContextSyncMutex();
//Check if the ProcessHeapCounter is 0 or not, if not 0 increment the counter and return the heapObj
// that is stored in the DLL Singleton context
if(ProcessHeapCounter)
{
ProcessHeapCounter++;
pHeapObjOut = pHeapObj;
}
// Unlock ProcessSingleton Lock
GmmLib::Context::UnlockSingletonContextSyncMutex();
return pHeapObjOut;
}
/////////////////////////////////////////////////////////////////////////
/// Set ProcessHeapVA Singleton HeapObj
/////////////////////////////////////////////////////////////////////////
uint32_t GmmLib::Context::SetSharedHeapObject(GMM_HEAP **pProcessHeapObj)
{
uint32_t DllClientsCount = 0;
// Obtain ProcessSingleton Lock
GmmLib::Context::LockSingletonContextSyncMutex();
if(pProcessHeapObj)
{
if(!ProcessHeapCounter)
{
// Setting it for the first time
ProcessHeapCounter++;
pHeapObj = *pProcessHeapObj;
}
else
{
ProcessHeapCounter++;
*pProcessHeapObj = pHeapObj;
}
}
else // Destroy the HeapObj Handle Case
{
ProcessHeapCounter--;
if(!ProcessHeapCounter)
{
// When all UMDs clients have called destroy
pHeapObj = NULL;
}
}
DllClientsCount = ProcessHeapCounter;
// Unlock ProcessSingleton Lock
GmmLib::Context::UnlockSingletonContextSyncMutex();
return DllClientsCount;
}
/////////////////////////////////////////////////////////////////////////
/// Get ProcessGfxPartition
/////////////////////////////////////////////////////////////////////////
void GmmLib::Context::GetProcessGfxPartition(GMM_GFX_PARTITIONING *pProcessVA)
{
// Obtain ProcessSingleton Lock
GmmLib::Context::LockSingletonContextSyncMutex();
//Check if the ProcessVACounter is 0 or not, if not 0 increment the counter and return the ProcessVA
// that is stored in the DLL Singleton context
if(ProcessVACounter)
{
ProcessVACounter++;
if(pProcessVA)
{
*pProcessVA = ProcessVA;
}
}
// Unlock ProcessSingleton Lock
GmmLib::Context::UnlockSingletonContextSyncMutex();
}
/////////////////////////////////////////////////////////////////////////
/// Set ProcessGfxPartition
/////////////////////////////////////////////////////////////////////////
void GmmLib::Context::SetProcessGfxPartition(GMM_GFX_PARTITIONING *pProcessVA)
{
// Obtain ProcessSingleton Lock
GmmLib::Context::LockSingletonContextSyncMutex();
if(pProcessVA)
{
if(!ProcessVACounter)
{
// Setting it for the first time
ProcessVACounter++;
ProcessVA = *pProcessVA;
}
else
{
ProcessVACounter++;
// TBD: Add code to return the stored value of ProcessVA when Escapes are removed
}
}
else // Reset the ProcessVA Case
{
ProcessVACounter--;
if(!ProcessVACounter)
{
// When all UMDs clients have called destroy
ProcessVA = {0};
}
}
// Unlock ProcessSingleton Lock
GmmLib::Context::UnlockSingletonContextSyncMutex();
}
#endif // _WIN32
#endif // GMM_LIB_DLL
/////////////////////////////////////////////////////////////////////////////////////
/// C wrapper for creating GmmLib::Context object
/// @see Class GmmLib::Context
///
/// @param[in] Platform: platform variable. Includes product family (Haswell, Cherryview,
/// Broxton) with related render and display core revision (GEN3,
// ..., GEN10)
/// @param[in] pSkuTable: Pointer to the sku feature table. Set of capabilities to
/// allow code paths to be feature based and GEN agnostic.
/// @param[in] pWaTable: Pointer to the work around table. A set of anti-features,
/// often in early/prototype silicon that require work-arounds
/// until they are resolved to allow code paths to be GEN agnostic.
/// @param[in] pGtSysInfo: Pointer to the GT system info. Contains various GT System
/// Information such as EU counts, Thread Counts, Cache Sizes etc.
/// @param[in] ClientType : describles the UMD clients such as OCL, DX, OGL, Vulkan etc
/// @return GMM_SUCCESS if Context is created, GMM_ERROR otherwise
/////////////////////////////////////////////////////////////////////////////////////
#if defined(LINUX)
GMM_STATUS GMM_STDCALL GmmInitGlobalContext(const PLATFORM Platform,
const void * pSkuTable,
const void * pWaTable,
const void * pGtSysInfo,
GMM_CLIENT ClientType)
#else
GMM_STATUS GMM_STDCALL GmmInitGlobalContext(const PLATFORM Platform,
const SKU_FEATURE_TABLE *pSkuTable,
const WA_TABLE * pWaTable,
const GT_SYSTEM_INFO * pGtSysInfo,
GMM_CLIENT ClientType)
#endif
{
GMM_STATUS Status = GMM_ERROR;
__GMM_ASSERTPTR(pSkuTable, GMM_ERROR);
__GMM_ASSERTPTR(pWaTable, GMM_ERROR);
__GMM_ASSERTPTR(pGtSysInfo, GMM_ERROR);
SKU_FEATURE_TABLE *skuTable;
WA_TABLE * waTable;
GT_SYSTEM_INFO * sysInfo;
skuTable = (SKU_FEATURE_TABLE *)pSkuTable;
waTable = (WA_TABLE *)pWaTable;
sysInfo = (GT_SYSTEM_INFO *)pGtSysInfo;
int32_t ContextRefCount = GmmLib::Context::IncrementRefCount();
if(ContextRefCount)
{
return GMM_SUCCESS;
}
pGmmGlobalContext = new GMM_GLOBAL_CONTEXT();
if(!pGmmGlobalContext)
{
GmmLib::Context::DecrementRefCount();
return GMM_ERROR;
}
Status = (pGmmGlobalContext->InitContext(Platform, skuTable, waTable, sysInfo, ClientType));
#if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
Status = GmmCreateGlobalClientContext(ClientType);
#endif
return Status;
}
/////////////////////////////////////////////////////////////////////////////////////
/// This function frees the GMM context memory.
/////////////////////////////////////////////////////////////////////////////////////
void GMM_STDCALL GmmDestroyGlobalContext(void)
{
__GMM_ASSERTPTR(pGmmGlobalContext, VOIDRETURN);
int32_t ContextRefCount = GmmLib::Context::DecrementRefCount();
if(!ContextRefCount && pGmmGlobalContext)
{
#if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
GmmDestroyGlobalClientContext();
#endif
pGmmGlobalContext->DestroyContext();
delete pGmmGlobalContext;
pGmmGlobalContext = NULL;
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Constructor to zero initialize the GmmLib::Context object
/////////////////////////////////////////////////////////////////////////////////////
GmmLib::Context::Context()
: ClientType(),
pPlatformInfo(),
pTextureCalc(),
SkuTable(),
WaTable(),
GtSysInfo(),
#if(defined(__GMM_KMD__))
GttContext(),
#endif
pGmmKmdContext(),
pGmmUmdContext(),
pKmdHwDev(),
pUmdAdapter(),
pGmmCachePolicy()
#if(defined(__GMM_KMD__))
,
IA32ePATTable()
#endif
{
memset(CachePolicy, 0, sizeof(CachePolicy));
memset(CachePolicyTbl, 0, sizeof(CachePolicyTbl));
#if(defined(__GMM_KMD__))
memset(PrivatePATTable, 0, sizeof(PrivatePATTable));
memset(PrivatePATTableMemoryType, 0, sizeof(PrivatePATTableMemoryType));
#endif
//Default initialize 64KB Page padding percentage.
AllowedPaddingFor64KbPagesPercentage = 10;
InternalGpuVaMax = 0;
#if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
pGmmGlobalClientContext = NULL;
#endif
}
/////////////////////////////////////////////////////////////////////////////////////
/// Destructor to release GmmLib::Context object memory
/////////////////////////////////////////////////////////////////////////////////////
GmmLib::Context::~Context()
{
}
/////////////////////////////////////////////////////////////////////////////////////
/// Member function to initialize the GmmLib::Context object with cache policy,
/// platform info, Texture calculator etc.
/// @param[in] Platform: ref to platform
/// @param[in] pSkuTable: ptr to sku table
/// @param[in] pWaTable: ptr to workaround table
/// @param[in] pGtSysInfo: ptr to gt system info
/// @param[in] ClientType: client type such as dx, ogl, ocl etc
/// @return GMM_SUCCESS if init is success, GMM_ERROR otherwise
/////////////////////////////////////////////////////////////////////////////////////
GMM_STATUS GMM_STDCALL GmmLib::Context::InitContext(
const PLATFORM & Platform,
const SKU_FEATURE_TABLE *pSkuTable,
const WA_TABLE * pWaTable,
const GT_SYSTEM_INFO * pGtSysInfo,
GMM_CLIENT ClientType)
{
this->ClientType = ClientType;
// Save the SKU and WA
this->SkuTable = *pSkuTable;
this->WaTable = *pWaTable;
this->GtSysInfo = *pGtSysInfo;
OverrideSkuWa();
pGmmGlobalContext->pPlatformInfo = GmmLib::PlatformInfo::Create(Platform, false);
this->pGmmCachePolicy = GmmLib::GmmCachePolicyCommon::Create();
if(this->pGmmCachePolicy == NULL)
{
return GMM_ERROR;
}
this->pGmmCachePolicy->InitCachePolicy();
this->pTextureCalc = GmmLib::GmmTextureCalc::Create(Platform, false);
if(this->pTextureCalc == NULL)
{
return GMM_ERROR;
}
return GMM_SUCCESS;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Member function to deallcoate the GmmLib::Context's cache policy, platform info,
/// Texture calculator etc.
/////////////////////////////////////////////////////////////////////////////////////
void GMM_STDCALL GmmLib::Context::DestroyContext()
{
if(this->pGmmCachePolicy)
{
int32_t CachePolicyObjRefCount = GmmLib::GmmCachePolicyCommon::DecrementRefCount();
if(!CachePolicyObjRefCount)
{
delete this->pGmmCachePolicy;
this->pGmmCachePolicy = NULL;
}
}
if(this->pTextureCalc)
{
int32_t TextureCalcObjRefCount = GmmLib::GmmTextureCalc::DecrementRefCount();
if(!TextureCalcObjRefCount)
{
delete this->pTextureCalc;
this->pTextureCalc = NULL;
}
}
if(pGmmGlobalContext->pPlatformInfo)
{
int32_t PlatformInfoRefCount = GmmLib::PlatformInfo::DecrementRefCount();
if(!PlatformInfoRefCount)
{
delete pGmmGlobalContext->pPlatformInfo;
pGmmGlobalContext->pPlatformInfo = NULL;
}
}
}
void GMM_STDCALL GmmLib::Context::OverrideSkuWa()
{
SkuTable.FtrTileY = true;
}
#ifdef __GMM_KMD__ /*LINK CONTEXT TO GLOBAL*/
//=============================================================================
// Function:
// GmmLinkKmdContextToGlobalInfo
//
// Description:
// Links KMD GMM_CONTEXT to GMM Global struct
//-----------------------------------------------------------------------------
void GMM_STDCALL GmmLinkKmdContextToGlobalInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext, GMM_CONTEXT *pGmmKmdContext)
{
__GMM_ASSERTPTR(pGmmKmdContext, VOIDRETURN);
pGmmLibContext->SetGmmKmdContext(pGmmKmdContext);
}
#endif /*__GMM_KMD__ LINK CONTEXT TO GLOBAL*/
//C - Wrappers
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the PlatformInfo ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return const PlatformInfo ptr
/////////////////////////////////////////////////////////////////////////
const GMM_PLATFORM_INFO *GMM_STDCALL GmmGetPlatformInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (&pGmmLibContext->GetPlatformInfo());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the cache policy element array ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return const cache policy elment ptr
/////////////////////////////////////////////////////////////////////////
const GMM_CACHE_POLICY_ELEMENT *GmmGetCachePolicyUsage(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetCachePolicyUsage());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the texture calculation object ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return TextureCalc ptr
/////////////////////////////////////////////////////////////////////////
GMM_TEXTURE_CALC *GmmGetTextureCalc(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetTextureCalc());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the sku table ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return const SkuTable ptr
/////////////////////////////////////////////////////////////////////////
const SKU_FEATURE_TABLE *GmmGetSkuTable(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (&pGmmLibContext->GetSkuTable());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the Wa table ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return const WaTable ptr
/////////////////////////////////////////////////////////////////////////
const WA_TABLE *GmmGetWaTable(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (&pGmmLibContext->GetWaTable());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the GT system info ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return const GtSysInfo ptr
/////////////////////////////////////////////////////////////////////////
const GT_SYSTEM_INFO *GmmGetGtSysInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetGtSysInfoPtr());
}
#ifdef __GMM_KMD__
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the private PAT table memory type for a given PAT type
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] PatIndex: PAT index
/// @return PAT Memory type
/////////////////////////////////////////////////////////////////////////
int32_t GmmGetPrivatePATTableMemoryType(GMM_GLOBAL_CONTEXT *pGmmLibContext, GMM_GFX_PAT_TYPE PatType)
{
return (pGmmLibContext->GetPrivatePATTableMemoryType(PatType));
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the private PAT table entry for a given PAT index
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] PatIndex: PAT index
/// @return PAT entry
/////////////////////////////////////////////////////////////////////////
GMM_PRIVATE_PAT GmmGetPrivatePATEntry(GMM_GLOBAL_CONTEXT *pGmmLibContext, uint32_t PatIndex)
{
GMM_PRIVATE_PAT NullPAT = {0};
if(PatIndex >= GMM_NUM_PAT_ENTRIES)
{
GMM_ASSERTDPF(false, "CRITICAL ERROR: INVALID PAT IDX");
return NullPAT;
}
return pGmmLibContext->GetPrivatePATEntry(PatIndex);
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the gmm kmd context ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return GmmKmdContext ptr
/////////////////////////////////////////////////////////////////////////
GMM_CONTEXT *GmmGetGmmKmdContext(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetGmmKmdContext());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get gtt context ptr
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return GttContext ptr
/////////////////////////////////////////////////////////////////////////
GMM_GTT_CONTEXT *GmmGetGttContext(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetGttContext());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the Cache policy tbl element for a given usage type
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] Usage: cache policy resource usage type
/// @return cache policy tbl element
////////////////////////////////////////////////////////////////////////
GMM_CACHE_POLICY_TBL_ELEMENT GmmGetCachePolicyTblElement(GMM_GLOBAL_CONTEXT *pGmmLibContext, GMM_RESOURCE_USAGE_TYPE Usage)
{
return (pGmmLibContext->GetCachePolicyTblElement(Usage));
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the Cache policy element for a given usage type
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] Usage: cache policy resource usage type
/// @return cache policy element
////////////////////////////////////////////////////////////////////////
GMM_CACHE_POLICY_ELEMENT GmmGetCachePolicyElement(GMM_GLOBAL_CONTEXT *pGmmLibContext, GMM_RESOURCE_USAGE_TYPE Usage)
{
return (pGmmLibContext->GetCachePolicyElement(Usage));
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to reset the sku Table after GmmInitContext() could have
/// changed them since original latching
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] SkuTable: platform based sku feature table
////////////////////////////////////////////////////////////////////////
void GmmSetSkuTable(GMM_GLOBAL_CONTEXT *pGmmLibContext, SKU_FEATURE_TABLE SkuTable)
{
pGmmLibContext->SetSkuTable(SkuTable);
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to reset the Wa Table after GmmInitContext() could have
/// changed them since original latching
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @param[in] WaTable: platform based workaround table
////////////////////////////////////////////////////////////////////////
void GmmSetWaTable(GMM_GLOBAL_CONTEXT *pGmmLibContext, WA_TABLE WaTable)
{
pGmmLibContext->SetWaTable(WaTable);
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the Platform info ptr to kmd
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return PlatformInfo ptr
////////////////////////////////////////////////////////////////////////
GMM_PLATFORM_INFO *GmmKmdGetPlatformInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (&pGmmLibContext->GetPlatformInfo());
}
#if(_DEBUG || _RELEASE_INTERNAL)
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the override Platform info ptr to kmd
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return override PlatformInfo ptr
////////////////////////////////////////////////////////////////////////
const GMM_PLATFORM_INFO *GmmGetOverridePlatformInfo(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (&pGmmLibContext->GetOverridePlatformInfo());
}
/////////////////////////////////////////////////////////////////////////
/// C-wrapper to get the override Texture calc ptr to kmd
/// @param[in] pGmmLibContext: ptr to GMM_GLOBAL_CONTEXT
/// @return override Texture calc ptr
////////////////////////////////////////////////////////////////////////
GMM_TEXTURE_CALC *GmmGetOverrideTextureCalc(GMM_GLOBAL_CONTEXT *pGmmLibContext)
{
return (pGmmLibContext->GetOverrideTextureCalc());
}
#endif
#endif
|