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 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644
|
/*==============================================================================
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.
============================================================================*/
#pragma once
#ifdef __cplusplus
#include "GmmMemAllocator.hpp"
#include "GmmCachePolicy.h"
#include "GmmUtil.h"
#include "GmmInfoExt.h"
#include "GmmInfo.h"
#include "../../../Platform/GmmPlatforms.h"
#include "../../../../inc/common/gfxmacro.h"
#include "GmmClientContext.h"
// Macro definitions
#ifndef __GMM_ASSERT
// Needs to be defined before including this file. If not defined, then
// we'll nop these macros.
#define __GMM_ASSERT(expr)
#define GMM_ASSERTDPF(expr, ret)
#define __GMM_ASSERTPTR(expr, ret)
#endif
/////////////////////////////////////////////////////////////////////////////////////
/// @file GmmResourceInfoCommon.h
/// @brief This file contains the functions and members of GmmResourceInfo that is
/// common for both Linux and Windows.
///
/////////////////////////////////////////////////////////////////////////////////////
namespace GmmLib
{
/////////////////////////////////////////////////////////////////////////
/// Contains functions and members that are common between Linux and
/// Windows implementation. This class is inherited by the Linux and
/// Windows specific class, so clients shouldn't have to ever interact
/// with this class directly.
/////////////////////////////////////////////////////////////////////////
class GMM_LIB_API NON_PAGED_SECTION GmmResourceInfoCommon:
public GmmMemAllocator
{
protected:
/// Type of Client type using the library. Can be used by GmmLib to
/// implement client specific functionality.
GMM_CLIENT ClientType;
GMM_TEXTURE_INFO Surf; ///< Contains info about the surface being created
GMM_TEXTURE_INFO AuxSurf; ///< Contains info about the auxiliary surface if using Unified Auxiliary surfaces.
GMM_TEXTURE_INFO AuxSecSurf; ///< For multi-Aux surfaces, contains info about the secondary auxiliary surface
GMM_TEXTURE_INFO PlaneSurf[GMM_MAX_PLANE]; ///< Contains info for each plane for tiled Ys/Yf planar resources
uint32_t RotateInfo;
GMM_EXISTING_SYS_MEM ExistingSysMem; ///< Info about resources initialized with existing system memory
GMM_GFX_ADDRESS SvmAddress; ///< Driver managed SVM address
uint64_t pGmmLibContext; ///< Pointer to GmmLib context passed in during Create()
uint64_t pPrivateData; ///< Allows clients to attach any private data to GmmResourceInfo
#ifdef __GMM_KMD__
void *pClientContext; ///< void * in oreder to of same size for the ResInfo Object across KMD and UMD
#else
GmmClientContext *pClientContext; ///< ClientContext of the client creating this Resource
#endif
private:
GMM_STATUS ApplyExistingSysMemRestrictions();
protected:
/* Function prototypes */
GMM_VIRTUAL bool IsPresentableformat();
// Move GMM Restrictions to it's own class?
virtual bool CopyClientParams(GMM_RESCREATE_PARAMS &CreateParams);
GMM_VIRTUAL bool RedescribePlanes();
GMM_VIRTUAL bool ReAdjustPlaneProperties(bool IsAuxSurf);
GMM_VIRTUAL const GMM_PLATFORM_INFO& GetPlatformInfo();
/////////////////////////////////////////////////////////////////////////////////////
/// Returns tile mode for SURFACE_STATE programming.
/// @return Tiled Mode
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE uint32_t GetTileModeSurfaceState(const GMM_TEXTURE_INFO *pTextureInfo) const
{
uint32_t TiledMode = 0;
if(GMM_IS_TILEY)
{
TiledMode =
pTextureInfo->Flags.Info.Linear ? 0 :
pTextureInfo->Flags.Info.TiledW ? 1 :
pTextureInfo->Flags.Info.TiledX ? 2 :
/* Y/YF/YS */ 3;
__GMM_ASSERT((TiledMode != 3) || (pTextureInfo->Flags.Info.TiledY || pTextureInfo->Flags.Info.TiledYf || pTextureInfo->Flags.Info.TiledYs));
}
return TiledMode;
}
public:
/* Constructors */
GmmResourceInfoCommon():
ClientType(),
Surf(),
AuxSurf(),
AuxSecSurf(),
PlaneSurf{},
RotateInfo(),
ExistingSysMem(),
SvmAddress(),
pGmmLibContext(),
pPrivateData(),
pClientContext()
{
#if (!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
// For clients, who derive classes from GMM class and call their derived class constructors
if (pGmmGlobalContext) // Client ULT does new on ResInfo without calling GmmInitGlobalContext.
{
pClientContext = pGmmGlobalContext->pGmmGlobalClientContext;
GET_GMM_CLIENT_TYPE(pClientContext, ClientType);
}
#endif
}
#ifndef __GMM_KMD__
GmmResourceInfoCommon(GmmClientContext *pClientContextIn) :
ClientType(),
Surf(),
AuxSurf(),
AuxSecSurf(),
PlaneSurf{},
RotateInfo(),
ExistingSysMem(),
SvmAddress(),
pGmmLibContext(),
pPrivateData(),
pClientContext()
{
pClientContext = pClientContextIn;
}
#endif
GmmResourceInfoCommon& operator=(const GmmResourceInfoCommon& rhs)
{
ClientType = rhs.ClientType;
Surf = rhs.Surf;
AuxSurf = rhs.AuxSurf;
AuxSecSurf = rhs.AuxSecSurf;
RotateInfo = rhs.RotateInfo;
ExistingSysMem = rhs.ExistingSysMem;
SvmAddress = rhs.SvmAddress;
pPrivateData = rhs.pPrivateData;
pGmmLibContext = rhs.pGmmLibContext;
return *this;
}
virtual ~GmmResourceInfoCommon()
{
if (ExistingSysMem.pVirtAddress && ExistingSysMem.IsGmmAllocated)
{
GMM_FREE((void *)ExistingSysMem.pVirtAddress);
}
}
/* Function prototypes */
// Overloaded Create function to keep backward compatible. This shall be deprecated soon
GMM_VIRTUAL GMM_STATUS GMM_STDCALL Create(Context &GmmLibContext, GMM_RESCREATE_PARAMS &CreateParams);
GMM_VIRTUAL uint8_t GMM_STDCALL ValidateParams();
GMM_VIRTUAL GMM_STATUS GMM_STDCALL Create(GMM_RESCREATE_PARAMS &CreateParams);
GMM_VIRTUAL void GMM_STDCALL GetRestrictions(__GMM_BUFFER_TYPE& Restrictions);
GMM_VIRTUAL uint32_t GMM_STDCALL GetPaddedWidth(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetPaddedHeight(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetPaddedPitch(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetQPitch();
GMM_VIRTUAL GMM_STATUS GMM_STDCALL GetOffset(GMM_REQ_OFFSET_INFO &ReqInfo);
GMM_VIRTUAL uint8_t GMM_STDCALL CpuBlt(GMM_RES_COPY_BLT *pBlt);
GMM_VIRTUAL uint8_t GMM_STDCALL GetMappingSpanDesc(GMM_GET_MAPPING *pMapping);
GMM_VIRTUAL uint8_t GMM_STDCALL Is64KBPageSuitable();
GMM_VIRTUAL void GMM_STDCALL GetTiledResourceMipPacking(uint32_t *pNumPackedMips,
uint32_t *pNumTilesForPackedMips);
GMM_VIRTUAL uint32_t GMM_STDCALL GetPackedMipTailStartLod();
GMM_VIRTUAL bool GMM_STDCALL IsMipRCCAligned(uint8_t &MisAlignedLod);
GMM_VIRTUAL uint8_t GMM_STDCALL GetDisplayFastClearSupport();
GMM_VIRTUAL uint8_t GMM_STDCALL GetDisplayCompressionSupport();
GMM_VIRTUAL uint32_t GMM_STDCALL GetCompressionBlockWidth();
GMM_VIRTUAL uint32_t GMM_STDCALL GetCompressionBlockHeight();
GMM_VIRTUAL uint32_t GMM_STDCALL GetCompressionBlockDepth();
GMM_VIRTUAL uint8_t GMM_STDCALL IsArraySpacingSingleLod();
GMM_VIRTUAL uint8_t GMM_STDCALL IsASTC();
GMM_VIRTUAL MEMORY_OBJECT_CONTROL_STATE GMM_STDCALL GetMOCS();
GMM_VIRTUAL uint32_t GMM_STDCALL GetStdTilingModeExtSurfaceState();
GMM_VIRTUAL GMM_SURFACESTATE_FORMAT GMM_STDCALL GetResourceFormatSurfaceState();
GMM_VIRTUAL GMM_GFX_SIZE_T GMM_STDCALL GetMipWidth(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetMipHeight(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetMipDepth(uint32_t MipLevel);
GMM_VIRTUAL uint64_t GMM_STDCALL GetFastClearWidth(uint32_t MipLevel);
GMM_VIRTUAL uint32_t GMM_STDCALL GetFastClearHeight(uint32_t MipLevel);
/* inline functions */
#ifndef __GMM_KMD__
/////////////////////////////////////////////////////////////////////////////////////
/// Returns GmmClientContext associated with this resource
/// @return ::GmmClientContext
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GmmClientContext* GetGmmClientContext()
{
return pClientContext;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Sets GmmClientContext to be associated with this resource
/// @return ::void
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void SetGmmClientContext(GmmClientContext* pGmmClientContext)
{
pClientContext = pGmmClientContext;
GET_GMM_CLIENT_TYPE(pGmmClientContext, ClientType);
}
#endif
/////////////////////////////////////////////////////////////////////////////////////
/// Returns GMM_CLIENT Type that has created this resource
/// @return ::GMM_CLIENT
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_CLIENT GetClientType()
{
return ClientType;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the system memory pointer. It selectively returns either the natural
/// pointer or a value appriopriately page aligned for D3DDI_ALLOCATIONINFO,
/// depending on what the caller request.
/// @param[in] IsD3DDdiAllocation: Specifies where allocation was made by a D3D client
/// @return Pointer to system memory. NULL if not available.
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void* GMM_STDCALL GetSystemMemPointer(uint8_t IsD3DDdiAllocation)
{
if (IsD3DDdiAllocation)
{
return (void *)GMM_GFX_ADDRESS_CANONIZE(ExistingSysMem.pGfxAlignedVirtAddress);
}
else
{
return (void *)GMM_GFX_ADDRESS_CANONIZE(ExistingSysMem.pVirtAddress);
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the system memory size.
/// @return Size of memory.
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSystemMemSize()
{
return ExistingSysMem.Size;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns a reference to the surface flags.
/// @return Reference to ::GMM_RESOURCE_FLAGS
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_FLAG& GMM_STDCALL GetResFlags()
{
return Surf.Flags;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource type
/// @return ::GMM_RESOURCE_TYPE
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_TYPE GMM_STDCALL GetResourceType()
{
return Surf.Type;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource format
/// @return ::GMM_RESOURCE_FORMAT
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_FORMAT GMM_STDCALL GetResourceFormat()
{
return Surf.Format;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource width
/// @return width
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetBaseWidth()
{
return Surf.BaseWidth;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource height
/// @return height
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetBaseHeight()
{
return Surf.BaseHeight;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource depth
/// @return depth
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetBaseDepth()
{
return Surf.Depth;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource's base alignment
/// @return Base Alignment
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetBaseAlignment()
{
return Surf.Alignment.BaseAlignment;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource's max lod
/// @return Max Lod
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetMaxLod()
{
return Surf.MaxLod;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource's max array size
/// @return Max Array Size
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetArraySize()
{
return Surf.ArraySize;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource's rotation info
/// @return rotation info
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetRotateInfo()
{
return RotateInfo;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource's maximum remaining list length
/// @return maximum remaining list length
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL uint32_t GMM_STDCALL GetMaximumRenamingListLength()
{
return Surf.MaximumRenamingListLength;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the auxiliary resource's QPitch
/// @return Aux QPitch
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetAuxQPitch()
{
const GMM_PLATFORM_INFO *pPlatform;
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
if (GMM_IS_PLANAR(Surf.Format))
{
return static_cast<uint32_t>(AuxSurf.OffsetInfo.Plane.ArrayQPitch);
}
else if (AuxSurf.Flags.Gpu.HiZ)
{
// HiZ ==> HZ_PxPerByte * HZ_QPitch
return AuxSurf.Alignment.QPitch * pPlatform->HiZPixelsPerByte;
}
else
{
return AuxSurf.Alignment.QPitch;
}
}
else
{
return GetQPitch();
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the planar resource's QPitch
/// @return planar QPitch in rows
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetQPitchPlanar(GMM_YUV_PLANE Plane)
{
uint32_t QPitch;
const GMM_PLATFORM_INFO *pPlatform;
__GMM_ASSERT(GMM_IS_PLANAR(Surf.Format));
GMM_UNREFERENCED_LOCAL_VARIABLE(Plane);
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
__GMM_ASSERT(GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN8_CORE);
QPitch = static_cast<uint32_t>(Surf.OffsetInfo.Plane.ArrayQPitch / Surf.Pitch);
return QPitch;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns distance in bytes between array elements (or pseudo-array-elements--e.g.
/// cube faces, MSFMT_MSS sample planes).
/// @return QPitch
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetQPitchInBytes()
{
return Surf.OffsetInfo.Texture2DOffsetInfo.ArrayQPitchRender;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns resource's pitch
/// @return Pitch
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetRenderPitch()
{
return Surf.Pitch;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns resource's pitch in tiles
/// @return Pitch in tiles
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetRenderPitchTiles()
{
uint32_t PitchInTiles;
const GMM_PLATFORM_INFO *pPlatform;
GMM_TILE_MODE TileMode;
__GMM_ASSERT(!Surf.Flags.Info.Linear);
TileMode = Surf.TileMode;
__GMM_ASSERT(TileMode < GMM_TILE_MODES);
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if (pPlatform->TileInfo[TileMode].LogicalTileWidth != 0)
{
// In case of Depth/Stencil buffer MSAA TileYs surface, the LogicalTileWidth/Height is smaller than non-MSAA ones
// Thus introducting the below variable to get the right PitchInTiles
uint32_t MSAASpecialFactorForDepthAndStencil = 1;
if ((Surf.Flags.Gpu.Depth || Surf.Flags.Gpu.SeparateStencil) &&
(Surf.MSAA.NumSamples > 1 && (GMM_IS_64KB_TILE(Surf.Flags) || Surf.Flags.Info.TiledYf)))
{
switch (Surf.MSAA.NumSamples)
{
case 2:
case 4:
MSAASpecialFactorForDepthAndStencil = 2;
break;
case 8:
case 16:
MSAASpecialFactorForDepthAndStencil = 4;
break;
default:
break;
}
}
PitchInTiles = static_cast<uint32_t>(Surf.Pitch / pPlatform->TileInfo[TileMode].LogicalTileWidth);
PitchInTiles /= MSAASpecialFactorForDepthAndStencil;
}
else
{
// Surf.TileMode not set correctly
__GMM_ASSERT(false);
PitchInTiles = 0;
}
return PitchInTiles;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns unified auxiliary resource's pitch in tiles
/// @return Aux Pitch in bytes
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetUnifiedAuxPitch()
{
return AuxSurf.Pitch;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns auxiliary resource's pitch in tiles
/// @return Aux Pitch in tiles
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetRenderAuxPitchTiles()
{
uint32_t PitchInTiles = 0;
const GMM_PLATFORM_INFO *pPlatform;
__GMM_ASSERT(!AuxSurf.Flags.Info.Linear);
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&AuxSurf);
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
const GMM_TILE_MODE TileMode = AuxSurf.TileMode;
__GMM_ASSERT(TileMode < GMM_TILE_MODES);
if (pPlatform->TileInfo[TileMode].LogicalTileWidth)
{
PitchInTiles = static_cast<uint32_t>(AuxSurf.Pitch / pPlatform->TileInfo[TileMode].LogicalTileWidth);
}
}
else
{
PitchInTiles = GetRenderPitchTiles();
}
return PitchInTiles;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns resource's bits per pixel
/// @return bpp
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetBitsPerPixel()
{
return Surf.BitsPerPixel;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns unified aux resource's bits per pixel
/// @return aux bpp
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetUnifiedAuxBitsPerPixel()
{
__GMM_ASSERT(Surf.Flags.Gpu.UnifiedAuxSurface);
return AuxSurf.BitsPerPixel;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns layout of the mips: right or below.
/// @return ::GMM_TEXTURE_LAYOUT
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_TEXTURE_LAYOUT GMM_STDCALL GetTextureLayout()
{
return Surf.Flags.Info.LayoutRight? GMM_2D_LAYOUT_RIGHT : GMM_2D_LAYOUT_BELOW;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns resource's tile type
/// @return ::GMM_TILE_TYPE
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_TILE_TYPE GMM_STDCALL GetTileType()
{
if (Surf.Flags.Info.TiledW)
{
return GMM_TILED_W;
}
else if (Surf.Flags.Info.TiledX)
{
return GMM_TILED_X;
}
// Surf.Flags.Info.TiledYs/Yf tiling are only in
// conjunction with Surf.Flags.Info.TiledY/Linear depending on resource type (1D).
else if (Surf.Flags.Info.TiledY)
{
return GMM_TILED_Y;
}
return GMM_NOT_TILED;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns resource's tile mode
/// @return ::GMM_TILE_MODE
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_TILE_MODE GMM_STDCALL GmmGetTileMode()
{
return Surf.TileMode;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns CPU cacheability information
/// @return ::GMM_CPU_CACHE_TYPE
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_CPU_CACHE_TYPE GMM_STDCALL GetCpuCacheType()
{
if (Surf.Flags.Info.Cacheable)
{
return GMM_CACHEABLE;
}
return GMM_NOTCACHEABLE;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns Media Memory Compression mode.
/// @param[in] ArrayIndex ArrayIndex for which this info is needed
/// @return Media Memory Compression Mode (Disabled, Horizontal, Vertical)
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_MMC_INFO GMM_STDCALL GetMmcMode(uint32_t ArrayIndex)
{
__GMM_ASSERT(ArrayIndex < GMM_MAX_MMC_INDEX);
return
(ArrayIndex < GMM_MAX_MMC_INDEX) ?
(GMM_RESOURCE_MMC_INFO)Surf.MmcMode[ArrayIndex] :
GMM_MMC_DISABLED;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Sets Media Memory Compression mode.
/// @param[in] Mode Media Memory Compression Mode (Disabled, Horizontal, Vertical)
/// @param[in] ArrayIndex ArrayIndex for which this info needs to be set
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL SetMmcMode(GMM_RESOURCE_MMC_INFO Mode, uint32_t ArrayIndex)
{
__GMM_ASSERT((Mode == GMM_MMC_DISABLED) || (Mode == GMM_MMC_HORIZONTAL) || (Mode == GMM_MMC_VERTICAL));
__GMM_ASSERT(ArrayIndex < GMM_MAX_MMC_INDEX);
if (ArrayIndex < GMM_MAX_MMC_INDEX)
{
Surf.MmcMode[ArrayIndex] = static_cast<uint8_t>(Mode);
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns whether Media Memory Compression enabled or not.
/// @param[in] ArrayIndex ArrayIndex for which this info is needed
/// @return 1 (enabled), 0 (disabled)
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint8_t GMM_STDCALL IsMediaMemoryCompressed(uint32_t ArrayIndex)
{
__GMM_ASSERT(ArrayIndex < GMM_MAX_MMC_INDEX);
return
(ArrayIndex < GMM_MAX_MMC_INDEX) ?
Surf.MmcMode[ArrayIndex] != GMM_MMC_DISABLED :
0;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns mmc hints.
/// @param[in] ArrayIndex ArrayIndex for which this info is needed
/// @return 1/0
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_MMC_HINT GMM_STDCALL GetMmcHint(uint32_t ArrayIndex)
{
__GMM_ASSERT(ArrayIndex < GMM_MAX_MMC_INDEX);
return Surf.MmcHint[ArrayIndex] ? GMM_MMC_HINT_OFF : GMM_MMC_HINT_ON;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Sets mmc hints.
/// @param[in] Hint Mmc hint to store
/// @param[in] ArrayIndex ArrayIndex for which this info is needed
/// @return
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL SetMmcHint(GMM_RESOURCE_MMC_HINT Hint, uint32_t ArrayIndex)
{
__GMM_ASSERT(ArrayIndex < GMM_MAX_MMC_INDEX);
__GMM_ASSERT(GMM_MMC_HINT_ON == 0);
__GMM_ASSERT(GMM_MMC_HINT_OFF == 1);
Surf.MmcHint[ArrayIndex] = static_cast<uint8_t>(Hint);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the MSAA Sample Counter
/// @return Sample count
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetNumSamples()
{
return Surf.MSAA.NumSamples;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the MSAA Sample Pattern
/// @return Sample pattern
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_MSAA_SAMPLE_PATTERN GMM_STDCALL GetSamplePattern()
{
return Surf.MSAA.SamplePattern;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the X offset of planar surface
/// @param[in] Plane: Plane for which the offset is needed
/// @return X offset
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetPlanarXOffset(GMM_YUV_PLANE Plane)
{
__GMM_ASSERT(Plane < GMM_MAX_PLANE);
return Surf.OffsetInfo.Plane.X[Plane];
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the Y offset of planar surface
/// @param[in] Plane: Plane for which the offset is needed
/// @return Y offset
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetPlanarYOffset(GMM_YUV_PLANE Plane)
{
__GMM_ASSERT(Plane < GMM_MAX_PLANE);
return Surf.OffsetInfo.Plane.Y[Plane];
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the Aux offset of planar surface
/// @param[in] ArrayIndex: Surf index for which aux offset is required
/// @param[in] GmmAuxType: Aux Plane for which the offset is needed
/// @return Y_CCS offset/ UV_CCS offset/ Media compression state
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetPlanarAuxOffset(uint32_t ArrayIndex, GMM_UNIFIED_AUX_TYPE GmmAuxType)
{
GMM_GFX_SIZE_T Offset = 0;
__GMM_ASSERT(ArrayIndex < Surf.ArraySize);
__GMM_ASSERT(GMM_IS_PLANAR(Surf.Format));
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
if (GmmAuxType == GMM_AUX_Y_CCS)
{
Offset = Surf.Size;
}
else if (GmmAuxType == GMM_AUX_UV_CCS)
{
Offset = Surf.Size + (AuxSurf.Pitch * AuxSurf.OffsetInfo.Plane.Y[GMM_PLANE_U]); //Aux Offset in HwLayout
if (Surf.Flags.Gpu.CCS && AuxSurf.Flags.Gpu.__NonMsaaLinearCCS)
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_U];
}
else if (Surf.Flags.Gpu.MMC && AuxSurf.Flags.Gpu.__NonMsaaLinearCCS )
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_Y];
}
}
else if (GmmAuxType == GMM_AUX_COMP_STATE)
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_Y] + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_U];
}
Offset += AuxSurf.OffsetInfo.Plane.ArrayQPitch * ArrayIndex;
}
else
{
Offset = 0;
}
return Offset;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource Horizontal alignment
/// @return HAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetHAlign()
{
const __GMM_PLATFORM_RESOURCE *pPlatformResource;
uint32_t HAlign;
pPlatformResource = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if ((GFX_GET_CURRENT_RENDERCORE(pPlatformResource->Platform) >= IGFX_GEN9_CORE) &&
!(Surf.Flags.Info.TiledYf || GMM_IS_64KB_TILE(Surf.Flags)))
{
HAlign = Surf.Alignment.HAlign / GetCompressionBlockWidth();
}
else
{
HAlign = Surf.Alignment.HAlign;
}
return HAlign;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource Vertical alignment
/// @return VAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetVAlign()
{
const __GMM_PLATFORM_RESOURCE *pPlatformResource;
uint32_t VAlign;
pPlatformResource = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if ((GFX_GET_CURRENT_RENDERCORE(pPlatformResource->Platform) >= IGFX_GEN9_CORE) &&
!(GetResFlags().Info.TiledYf || GMM_IS_64KB_TILE(GetResFlags())))
{
VAlign = Surf.Alignment.VAlign / GetCompressionBlockHeight();
}
else
{
VAlign = Surf.Alignment.VAlign;
}
return VAlign;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the auxiliary resource Horizontal alignment
/// @return HAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetAuxHAlign()
{
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
return AuxSurf.Alignment.HAlign;
}
else
{
return GetHAlign();
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the auxiliary resource Vertical alignment
/// @return HAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetAuxVAlign()
{
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
return AuxSurf.Alignment.VAlign;
}
else
{
return GetVAlign();
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns indication of whether resource uses the MSFMT_DEPTH_STENCIL Multisampled
/// Surface Storage Format.
/// @return 1/0
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint8_t GMM_STDCALL IsMsaaFormatDepthStencil()
{
// Gen7 MSAA (non-Depth/Stencil) render targets use (MSFMT_DEPTH_MSS) array
// expansion instead of (MSFMT_DEPTH_STENCIL) Width/Height expansion.
return (Surf.MSAA.NumSamples > 1) &&
(Surf.Flags.Gpu.Depth ||
Surf.Flags.Gpu.SeparateStencil);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns indication of whether resource is SVM or not
/// @return 1/0
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint8_t GMM_STDCALL IsSvm()
{
return static_cast<uint8_t>(Surf.Flags.Info.SVM);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Allows clients to attach a private data to the resource
/// @param[in] pNewPrivateData: pointer to opaque private data from clients
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL SetPrivateData(void *pNewPrivateData)
{
this->pPrivateData = reinterpret_cast<uint64_t>(pNewPrivateData);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns private data attached to the resource
/// @return Pointer to opaque private data
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void* GMM_STDCALL GetPrivateData()
{
return reinterpret_cast<void*>(pPrivateData);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the resource GFX address
/// @return Gfx Address
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_ADDRESS GMM_STDCALL GetGfxAddress()
{
// Support for Sparse/Tiled resources will be unified in later
if (SvmAddress)
{
return GMM_GFX_ADDRESS_CANONIZE(SvmAddress);
}
else
{
return 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// This function returns the total height of an S3D tall buffer. For non-S3D
/// resources, it returns base height.
/// @return Surface height
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetTallBufferHeight()
{
if (Surf.Flags.Gpu.S3d)
{
return Surf.S3d.TallBufferHeight;
}
else
{
GMM_ASSERTDPF(0, "Unsupported S3D Resource Type!");
return Surf.BaseHeight;
}
};
/////////////////////////////////////////////////////////////////////////////////////
/// Returns size of the surface depending on the surface parameters.
/// @return Size of surface
///
/// Below legacy API to query surface size are deprecated and will be removed in
/// later gmm releases. Client must move to unified GetSize() api.
/// - GmmResGetSizeSurface()/ pResInfo->GetSizeSurface()
/// - GmmResGetSizeMainSurface()/ pResInfo->GetSizeAllocation()
/// - GmmResGetSizeAllocation()/ pResInfo->GetSizeMainSurface()
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSize(GMM_SIZE_PARAM GmmSizeParam)
{
GMM_GFX_SIZE_T Size = 0;
switch (GmmSizeParam)
{
case GMM_MAIN_SURF:
Size = Surf.Size;
break;
case GMM_MAIN_PLUS_AUX_SURF:
Size = Surf.Size + AuxSurf.Size + AuxSecSurf.Size;
break;
case GMM_TOTAL_SURF:
Size = Surf.Size + AuxSurf.Size + AuxSecSurf.Size;
if (Is64KBPageSuitable())
{
Size = GFX_ALIGN(Surf.Size + AuxSurf.Size + AuxSecSurf.Size, GMM_KBYTE(64));
}
break;
default:
__GMM_ASSERT(0);
}
return Size;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns size of the main surface only. Aux surface size not included.
/// @return Size of main surface
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSizeMainSurface() const
{
return Surf.Size;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the number of bytes that are required to back this padded and aligned
/// resource. The calculation takes into consideration more than simply width
/// height and bits per pixel. Width padding (stride), pixel formats, inter-plane
/// padding depts/array-size and so on also for part of the list of factors.
/// @return Surface Size
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSizeSurface()
{
return (Surf.Size + AuxSurf.Size + AuxSecSurf.Size);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns surface size(GetSizeSurface) plus additional padding due to 64kb pages
/// @return Allocation Size
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSizeAllocation()
{
if (Is64KBPageSuitable())
{
return(GFX_ALIGN(Surf.Size + AuxSurf.Size + AuxSecSurf.Size, GMM_KBYTE(64)));
}
else
{
return (Surf.Size + AuxSurf.Size + AuxSecSurf.Size);
}
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns max no of GpuVa bits supported per resource on a given platform
/// @return Max # of GpuVA bits per resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetMaxGpuVirtualAddressBits()
{
const GMM_PLATFORM_INFO *pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
__GMM_ASSERTPTR(pPlatform, 0);
return pPlatform->MaxGpuVirtualAddressBitsPerResource;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the surface offset for unified allocations
/// @param[in] GmmAuxType: the type of aux the offset is needed for
/// @return Surface Offset in bytes
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE GmmAuxType)
{
GMM_GFX_SIZE_T Offset = 0;
const GMM_PLATFORM_INFO *pPlatform;
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if (Surf.Flags.Gpu.UnifiedAuxSurface)
{
if ((GmmAuxType == GMM_AUX_CCS) || (GmmAuxType == GMM_AUX_SURF) || (GmmAuxType == GMM_AUX_Y_CCS)
|| (GmmAuxType == GMM_AUX_HIZ) || (GmmAuxType == GMM_AUX_MCS))
{
Offset = Surf.Size;
if (GmmAuxType == GMM_AUX_CCS && AuxSecSurf.Type != RESOURCE_INVALID
&& (Surf.Flags.Gpu.CCS && (Surf.MSAA.NumSamples > 1 ||
Surf.Flags.Gpu.Depth)))
{
Offset += AuxSurf.Size;
}
}
else if (GmmAuxType == GMM_AUX_UV_CCS)
{
Offset = Surf.Size + (AuxSurf.Pitch * AuxSurf.OffsetInfo.Plane.Y[GMM_PLANE_U]); //Aux Offset in HwLayout
if (Surf.Flags.Gpu.CCS && AuxSurf.Flags.Gpu.__NonMsaaLinearCCS)
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_U];
}
else if (Surf.Flags.Gpu.MMC && AuxSurf.Flags.Gpu.__NonMsaaLinearCCS )
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_Y];
}
}
else if ((GmmAuxType == GMM_AUX_CC) && (Surf.Flags.Gpu.IndirectClearColor || Surf.Flags.Gpu.ColorDiscard))
{
Offset = Surf.Size + AuxSurf.UnpaddedSize;
}
else if (GmmAuxType == GMM_AUX_COMP_STATE)
{
Offset = Surf.Size + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_Y] + AuxSurf.OffsetInfo.Plane.X[GMM_PLANE_U];
}
else if ((GmmAuxType == GMM_AUX_ZCS) && Surf.Flags.Gpu.Depth && Surf.Flags.Gpu.CCS)
{
if (AuxSecSurf.Type != RESOURCE_INVALID)
{
Offset = Surf.Size + AuxSurf.Size;
}
}
}
else if(GmmAuxType == GMM_AUX_CC &&
Surf.Flags.Gpu.IndirectClearColor &&
Surf.Flags.Gpu.HiZ)
{
Offset = Surf.Size - GMM_HIZ_CLEAR_COLOR_SIZE;
}
else if (GmmAuxType == GMM_AUX_CC &&
Surf.Flags.Gpu.ColorDiscard &&
!Surf.Flags.Gpu.CCS)
{
Offset = Surf.Size;
}
else
{
Offset = 0;
}
return Offset;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the surface size for unified allocations
/// @param[in] GmmAuxType: the type of aux the size is needed for
/// @return Surface Size in bytes
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetSizeAuxSurface(GMM_UNIFIED_AUX_TYPE GmmAuxType)
{
if (GmmAuxType == GMM_AUX_SURF)
{
return (AuxSurf.Size + AuxSecSurf.Size);
}
else if (GmmAuxType == GMM_AUX_CCS || GmmAuxType == GMM_AUX_HIZ || GmmAuxType == GMM_AUX_MCS)
{
if (GmmAuxType == GMM_AUX_CCS && AuxSecSurf.Type != RESOURCE_INVALID &&
(Surf.Flags.Gpu.CCS && (Surf.MSAA.NumSamples > 1 ||
Surf.Flags.Gpu.Depth)))
{
return AuxSecSurf.Size;
}
else
{
return (AuxSurf.UnpaddedSize);
}
}
else if (GmmAuxType == GMM_AUX_COMP_STATE)
{
return GMM_MEDIA_COMPRESSION_STATE_SIZE;
}
else if (GmmAuxType == GMM_AUX_CC)
{
if (!Surf.Flags.Gpu.UnifiedAuxSurface && Surf.Flags.Gpu.HiZ)
{
return GMM_HIZ_CLEAR_COLOR_SIZE;
}
else
{
return (AuxSurf.CCSize);
}
}
else if (GmmAuxType == GMM_AUX_ZCS)
{
if (Surf.Flags.Gpu.UnifiedAuxSurface && AuxSecSurf.Type != RESOURCE_INVALID)
{
return AuxSecSurf.Size;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
/////////////////////////////////////////////////////////////////////////
/// This function returns or sets the value of the hardware protected flag
/// associated with the given GMM resource within same process.
/// @param[in] GetIsEncrypted: Read encryption status
/// @param[in] SetIsEncrypted: Write encryption status
/// @return Whether surface is encrypted or not
/////////////////////////////////////////////////////////////////////////
virtual GMM_INLINE_EXPORTED uint8_t GMM_STDCALL GetSetHardwareProtection(uint8_t GetIsEncrypted, uint8_t SetIsEncrypted)
{
uint8_t IsEncrypted = 0;
if (GetIsEncrypted)
{
IsEncrypted = Surf.Flags.Info.HardwareProtected;
}
else
{
Surf.Flags.Info.HardwareProtected = IsEncrypted = SetIsEncrypted;
}
return IsEncrypted;
}
/////////////////////////////////////////////////////////////////////////
/// This function returns or sets the value of the Cp surface tag
/// associated with the given GMM resource within same process.
/// @param[in] IsSet: true for updating tag in gmm
/// @param[in] CpTag: Cp surface tag value
/// @return current cp surface tag in gmm
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE uint32_t GMM_STDCALL GetSetCpSurfTag(uint8_t IsSet, uint32_t CpTag)
{
if (IsSet)
{
Surf.CpTag = CpTag;
}
return Surf.CpTag;
}
/////////////////////////////////////////////////////////////////////////
/// Returns the size of the surface in StdLayout format
/// @return Size in bytes of Standard Layout version of surface.
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_GFX_SIZE_T GMM_STDCALL GetStdLayoutSize()
{
GMM_REQ_OFFSET_INFO GetOffset = {};
GetOffset.ReqStdLayout = 1;
GetOffset.StdLayout.Offset = static_cast<GMM_GFX_SIZE_T>(-1); // Special Req for StdLayout Size
this->GetOffset(GetOffset);
return GetOffset.StdLayout.Offset;
}
/////////////////////////////////////////////////////////////////////////
/// Returns whether resource is color separated target
/// @return 1 if the resource is color separated target, 0 otherwise
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint8_t GMM_STDCALL IsColorSeparation()
{
return Surf.Flags.Gpu.ColorSeparation || Surf.Flags.Gpu.ColorSeparationRGBX;
}
/////////////////////////////////////////////////////////////////////////
/// Translate packed source x coordinate to color separation target x coordinate
/// @param[in] x: X coordinate
/// @return Translated color separation target x coordinate
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL TranslateColorSeparationX(uint32_t x)
{
uint32_t ret = x;
if (Surf.Flags.Gpu.ColorSeparation)
{
ret /= GMM_COLOR_SEPARATION_WIDTH_DIVISION;
}
else if (Surf.Flags.Gpu.ColorSeparationRGBX)
{
ret /= GMM_COLOR_SEPARATION_RGBX_WIDTH_DIVISION;
}
return ret;
}
/////////////////////////////////////////////////////////////////////////
/// Returns the array size of a color separated target resource.
/// @return Array size of a color separated target resource
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetColorSeparationArraySize()
{
if (Surf.Flags.Gpu.ColorSeparation ||
Surf.Flags.Gpu.ColorSeparationRGBX)
{
return GMM_COLOR_SEPARATION_ARRAY_SIZE;
}
else
{
return Surf.ArraySize;
}
}
/////////////////////////////////////////////////////////////////////////
/// Returns the physical width of a color separated target resource
/// @return physical width of a color separated target resource
/////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetColorSeparationPhysicalWidth()
{
if (Surf.Flags.Gpu.ColorSeparation)
{
return ((uint32_t)Surf.BaseWidth * Surf.ArraySize) / GMM_COLOR_SEPARATION_WIDTH_DIVISION;
}
else if (Surf.Flags.Gpu.ColorSeparationRGBX)
{
return ((uint32_t)Surf.BaseWidth * Surf.ArraySize) / GMM_COLOR_SEPARATION_RGBX_WIDTH_DIVISION;
}
else
{
return (uint32_t)Surf.BaseWidth;
}
}
/////////////////////////////////////////////////////////////////////////
/// Returns whether surface can be faulted on
/// @return 1 is surface can be faulted on
/////////////////////////////////////////////////////////////////////////
virtual GMM_INLINE_EXPORTED uint8_t GMM_STDCALL IsSurfaceFaultable()
{
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the cache policy usage associated with this surface.
/// @return Cache Policy Usage
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED GMM_RESOURCE_USAGE_TYPE GMM_STDCALL GetCachePolicyUsage()
{
return Surf.CachePolicy.Usage;
}
//##################################################################################
// Functions that can help clients program the SURFACE_STATE with appropriate values.
//##################################################################################
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the surface state value for Mip Tail Start LOD
/// @return Mip Tail Start
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetMipTailStartLodSurfaceState()
{
return Surf.Alignment.MipTailStartLod;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the Tile Address Mapping Mode, for SURFACE_STATE programming and is
/// applicable only for 3D surface
/// @return Tile Address Mapping Mode
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetTileAddressMappingModeSurfaceState()
{
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the horizontal alignment for SURFACE_STATE programming.
/// @return HAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetHAlignSurfaceState()
{
uint32_t HAlign = 0;
const GMM_PLATFORM_INFO *pPlatform;
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if (GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN8_CORE)
{
if (GetResFlags().Info.TiledYf || GMM_IS_64KB_TILE(GetResFlags()))
{
HAlign = 1; //Ignored, but we'll retrun valid encoding nonetheless.
}
else
{
if(GMM_IS_TILEY)
{
switch (GetHAlign())
{
case 4: HAlign = 1; break;
case 8: HAlign = 2; break;
case 16: HAlign = 3; break;
default: HAlign = 1; // TODO(Benign): Change back to 0 + assert after packed YUV handling corrected.
}
}
}
}
else
{
switch (Surf.Alignment.HAlign)
{
case 4: HAlign = 0; break;
case 8: HAlign = 1; break;
default: HAlign = 0; __GMM_ASSERT(0);
}
}
return HAlign;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns the vertical alignment for SURFACE_STATE programming.
/// @return HAlign
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetVAlignSurfaceState()
{
uint32_t VAlign;
const GMM_PLATFORM_INFO *pPlatform;
pPlatform = (GMM_PLATFORM_INFO *)GMM_OVERRIDE_EXPORTED_PLATFORM_INFO(&Surf);
if (GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN8_CORE)
{
if (GetResFlags().Info.TiledYf || GMM_IS_64KB_TILE(GetResFlags()))
{
VAlign = 1; // Ignored , but we'll return valid encoding nonetheless.
}
else
{
switch (GetVAlign())
{
case 4: VAlign = 1; break;
case 8: VAlign = 2; break;
case 16: VAlign = 3; break;
default: VAlign = 1;
}
}
}
else
{
switch (Surf.Alignment.VAlign)
{
case 2: VAlign = 0; break;
case 4: VAlign = 1; break;
default: VAlign = 0; __GMM_ASSERT(0);
}
}
return VAlign;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns tile mode for SURFACE_STATE programming.
/// @return Tiled Mode
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetTileModeSurfaceState()
{
return GetTileModeSurfaceState(&Surf);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns tile mode for AUX SURFACE_STATE programming.
/// @return Tiled Mode
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetAuxTileModeSurfaceState()
{
return GetTileModeSurfaceState(&AuxSurf);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Returns tiled resource mode for SURFACE_STATE programming.
/// @return Tiled Resource Mode
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED uint32_t GMM_STDCALL GetTiledResourceModeSurfaceState()
{
uint32_t TiledResourceMode = 0;
if(GMM_IS_TILEY)
{
if (Surf.Flags.Info.TiledYf)
{
TiledResourceMode = 1;
}
else if (Surf.Flags.Info.TiledYs)
{
TiledResourceMode = 2;
}
else
{
TiledResourceMode = 0;
}
}
else
{
__GMM_ASSERT(0);
}
return TiledResourceMode;
}
//###################################################################################
// Functions that allows clients to override certain members
// of ResourceInfo. Client assumes the risk of using these functions.
// May cause unintended side-affects.
//##################################################################################
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the main surface size
/// @param[in] Size: new size of the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideSize(GMM_GFX_SIZE_T Size)
{
Surf.Size = Size;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the surface pitch
/// @param[in] Pitch: new pitch of the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverridePitch(GMM_GFX_SIZE_T Pitch)
{
Surf.Pitch = Pitch;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the aux surface pitch
/// @param[in] Pitch: new pitch of the aux surface
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideUnifiedAuxPitch(GMM_GFX_SIZE_T Pitch)
{
__GMM_ASSERT(Surf.Flags.Gpu.UnifiedAuxSurface);
AuxSurf.Pitch = Pitch;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the allocation flags
/// @param[in] Flags: new set of flags for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideAllocationFlags(GMM_RESOURCE_FLAG& Flags)
{
Surf.Flags = Flags;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource HAlign
/// @param[in] HAlign: new HAlign for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideHAlign(uint32_t HAlign)
{
Surf.Alignment.HAlign = HAlign;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource BaseAlignment
/// @param[in] Alignment: new BaseAlignment for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideBaseAlignment(uint32_t Alignment)
{
Surf.Alignment.BaseAlignment = Alignment;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource BaseWidth
/// @param[in] BaseWidth: new BaseWidth for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideBaseWidth(GMM_GFX_SIZE_T BaseWidth)
{
Surf.BaseWidth = BaseWidth;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource BaseHeight
/// @param[in] BaseHeight: new BaseHeight for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideBaseHeight(uint32_t BaseHeight)
{
Surf.BaseHeight = BaseHeight;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource Depth
/// @param[in] Depth: new Depth for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideDepth(uint32_t Depth)
{
Surf.Depth = Depth;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource tile mode
/// @param[in] TileMode: new tile mode for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideTileMode(GMM_TILE_MODE TileMode)
{
Surf.TileMode = TileMode;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource tile mode
/// @param[in] TileMode: new tile mode for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideUnifiedAuxTileMode(GMM_TILE_MODE TileMode)
{
__GMM_ASSERT(Surf.Flags.Gpu.UnifiedAuxSurface);
AuxSurf.TileMode = TileMode;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the surface format
/// @param[in] Format: new format for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideSurfaceFormat(GMM_RESOURCE_FORMAT Format)
{
Surf.Format = Format;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the surface type
/// @param[in] Type: new surface type for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideSurfaceType(GMM_RESOURCE_TYPE Type)
{
Surf.Type = Type;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the svm gfx address
/// @param[in] SvmGfxAddress: new svm gfx address for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideSvmGfxAddress(GMM_GFX_ADDRESS SvmGfxAddress)
{
this->SvmAddress = SvmGfxAddress;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource array size
/// @param[in] ArraySize: new array size for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideArraySize(uint32_t ArraySize)
{
Surf.ArraySize = ArraySize;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource max LOD
/// @param[in] MaxLod: new max LOD for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideMaxLod(uint32_t MaxLod)
{
Surf.MaxLod = MaxLod;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the resource cache policy usage
/// @param[in] Usage: new usage for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideCachePolicyUsage(GMM_RESOURCE_USAGE_TYPE Usage)
{
Surf.CachePolicy.Usage = Usage;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the platform associated with this resource
/// @param[in] Platform: new platform for the resource
/// @note Function only available for Debug/Release-Internal builds.
/////////////////////////////////////////////////////////////////////////////////////
#if(_DEBUG || _RELEASE_INTERNAL)
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverridePlatform(PLATFORM Platform)
{
Surf.Platform = Platform;
}
#endif
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the GmmLibContext associated with this resource
/// @param[in] pNewGmmLibContext: new GmmLibContext for the resource
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverrideGmmLibContext(Context *pNewGmmLibContext)
{
this->pGmmLibContext = reinterpret_cast<uint64_t>(pNewGmmLibContext);
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the X offset of planar surface
/// @param[in] Plane: Plane for which the offset needs to be overriden
/// @param[in] XOffset: X offset
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverridePlanarXOffset(GMM_YUV_PLANE Plane, GMM_GFX_SIZE_T XOffset)
{
__GMM_ASSERT(Plane < GMM_MAX_PLANE);
Surf.OffsetInfo.Plane.X[Plane] = XOffset;
}
/////////////////////////////////////////////////////////////////////////////////////
/// Overrides the Y offset of planar surface
/// @param[in] Plane: Plane for which the offset needs to be overriden
/// @param[in] YOffset: Y offset
/////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE_EXPORTED void GMM_STDCALL OverridePlanarYOffset(GMM_YUV_PLANE Plane, GMM_GFX_SIZE_T YOffset)
{
__GMM_ASSERT(Plane < GMM_MAX_PLANE);
Surf.OffsetInfo.Plane.Y[Plane] = YOffset;
}
GMM_VIRTUAL GMM_STATUS GMM_STDCALL CreateCustomRes(Context& GmmLibContext, GMM_RESCREATE_CUSTOM_PARAMS& CreateParams);
protected:
GMM_VIRTUAL void UpdateUnAlignedParams();
};
} // namespace GmmLib
#endif // #ifdef __cplusplus
|