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
|
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
// File: d3dx12.h
// Content: D3DX12 utility library
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3DX12_H__
#define __D3DX12_H__
#include "d3d12.h"
#if defined( __cplusplus )
struct CD3DX12_DEFAULT {};
extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT;
//------------------------------------------------------------------------------------------------
inline bool operator==( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r )
{
return l.TopLeftX == r.TopLeftX && l.TopLeftY == r.TopLeftY && l.Width == r.Width &&
l.Height == r.Height && l.MinDepth == r.MinDepth && l.MaxDepth == r.MaxDepth;
}
//------------------------------------------------------------------------------------------------
inline bool operator!=( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r )
{ return !( l == r ); }
//------------------------------------------------------------------------------------------------
struct CD3DX12_RECT : public D3D12_RECT
{
CD3DX12_RECT()
{}
explicit CD3DX12_RECT( const D3D12_RECT& o ) :
D3D12_RECT( o )
{}
explicit CD3DX12_RECT(
LONG Left,
LONG Top,
LONG Right,
LONG Bottom )
{
left = Left;
top = Top;
right = Right;
bottom = Bottom;
}
~CD3DX12_RECT() {}
operator const D3D12_RECT&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_BOX : public D3D12_BOX
{
CD3DX12_BOX()
{}
explicit CD3DX12_BOX( const D3D12_BOX& o ) :
D3D12_BOX( o )
{}
explicit CD3DX12_BOX(
LONG Left,
LONG Right )
{
left = Left;
top = 0;
front = 0;
right = Right;
bottom = 1;
back = 1;
}
explicit CD3DX12_BOX(
LONG Left,
LONG Top,
LONG Right,
LONG Bottom )
{
left = Left;
top = Top;
front = 0;
right = Right;
bottom = Bottom;
back = 1;
}
explicit CD3DX12_BOX(
LONG Left,
LONG Top,
LONG Front,
LONG Right,
LONG Bottom,
LONG Back )
{
left = Left;
top = Top;
front = Front;
right = Right;
bottom = Bottom;
back = Back;
}
~CD3DX12_BOX() {}
operator const D3D12_BOX&() const { return *this; }
};
inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r )
{
return l.left == r.left && l.top == r.top && l.front == r.front &&
l.right == r.right && l.bottom == r.bottom && l.back == r.back;
}
inline bool operator!=( const D3D12_BOX& l, const D3D12_BOX& r )
{ return !( l == r ); }
//------------------------------------------------------------------------------------------------
struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
{
CD3DX12_DEPTH_STENCIL_DESC()
{}
explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) :
D3D12_DEPTH_STENCIL_DESC( o )
{}
explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT )
{
DepthEnable = TRUE;
DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
DepthFunc = D3D12_COMPARISON_FUNC_LESS;
StencilEnable = FALSE;
StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK;
StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK;
const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp =
{ D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS };
FrontFace = defaultStencilOp;
BackFace = defaultStencilOp;
}
explicit CD3DX12_DEPTH_STENCIL_DESC(
BOOL depthEnable,
D3D12_DEPTH_WRITE_MASK depthWriteMask,
D3D12_COMPARISON_FUNC depthFunc,
BOOL stencilEnable,
UINT8 stencilReadMask,
UINT8 stencilWriteMask,
D3D12_STENCIL_OP frontStencilFailOp,
D3D12_STENCIL_OP frontStencilDepthFailOp,
D3D12_STENCIL_OP frontStencilPassOp,
D3D12_COMPARISON_FUNC frontStencilFunc,
D3D12_STENCIL_OP backStencilFailOp,
D3D12_STENCIL_OP backStencilDepthFailOp,
D3D12_STENCIL_OP backStencilPassOp,
D3D12_COMPARISON_FUNC backStencilFunc )
{
DepthEnable = depthEnable;
DepthWriteMask = depthWriteMask;
DepthFunc = depthFunc;
StencilEnable = stencilEnable;
StencilReadMask = stencilReadMask;
StencilWriteMask = stencilWriteMask;
FrontFace.StencilFailOp = frontStencilFailOp;
FrontFace.StencilDepthFailOp = frontStencilDepthFailOp;
FrontFace.StencilPassOp = frontStencilPassOp;
FrontFace.StencilFunc = frontStencilFunc;
BackFace.StencilFailOp = backStencilFailOp;
BackFace.StencilDepthFailOp = backStencilDepthFailOp;
BackFace.StencilPassOp = backStencilPassOp;
BackFace.StencilFunc = backStencilFunc;
}
~CD3DX12_DEPTH_STENCIL_DESC() {}
operator const D3D12_DEPTH_STENCIL_DESC&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
{
CD3DX12_BLEND_DESC()
{}
explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) :
D3D12_BLEND_DESC( o )
{}
explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT )
{
AlphaToCoverageEnable = FALSE;
IndependentBlendEnable = FALSE;
const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc =
{
FALSE,FALSE,
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
RenderTarget[ i ] = defaultRenderTargetBlendDesc;
}
~CD3DX12_BLEND_DESC() {}
operator const D3D12_BLEND_DESC&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
{
CD3DX12_RASTERIZER_DESC()
{}
explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) :
D3D12_RASTERIZER_DESC( o )
{}
explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT )
{
FillMode = D3D12_FILL_MODE_SOLID;
CullMode = D3D12_CULL_MODE_BACK;
FrontCounterClockwise = FALSE;
DepthBias = D3D12_DEFAULT_DEPTH_BIAS;
DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP;
SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS;
DepthClipEnable = TRUE;
MultisampleEnable = FALSE;
AntialiasedLineEnable = FALSE;
ForcedSampleCount = 0;
ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
}
explicit CD3DX12_RASTERIZER_DESC(
D3D12_FILL_MODE fillMode,
D3D12_CULL_MODE cullMode,
BOOL frontCounterClockwise,
INT depthBias,
FLOAT depthBiasClamp,
FLOAT slopeScaledDepthBias,
BOOL depthClipEnable,
BOOL multisampleEnable,
BOOL antialiasedLineEnable,
UINT forcedSampleCount,
D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster)
{
FillMode = fillMode;
CullMode = cullMode;
FrontCounterClockwise = frontCounterClockwise;
DepthBias = depthBias;
DepthBiasClamp = depthBiasClamp;
SlopeScaledDepthBias = slopeScaledDepthBias;
DepthClipEnable = depthClipEnable;
MultisampleEnable = multisampleEnable;
AntialiasedLineEnable = antialiasedLineEnable;
ForcedSampleCount = forcedSampleCount;
ConservativeRaster = conservativeRaster;
}
~CD3DX12_RASTERIZER_DESC() {}
operator const D3D12_RASTERIZER_DESC&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO
{
CD3DX12_RESOURCE_ALLOCATION_INFO()
{}
explicit CD3DX12_RESOURCE_ALLOCATION_INFO( const D3D12_RESOURCE_ALLOCATION_INFO& o ) :
D3D12_RESOURCE_ALLOCATION_INFO( o )
{}
CD3DX12_RESOURCE_ALLOCATION_INFO(
UINT64 size,
UINT64 alignment )
{
SizeInBytes = size;
Alignment = alignment;
}
operator const D3D12_RESOURCE_ALLOCATION_INFO&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES
{
CD3DX12_HEAP_PROPERTIES()
{}
explicit CD3DX12_HEAP_PROPERTIES(const D3D12_HEAP_PROPERTIES &o) :
D3D12_HEAP_PROPERTIES(o)
{}
CD3DX12_HEAP_PROPERTIES(
D3D12_CPU_PAGE_PROPERTY cpuPageProperty,
D3D12_MEMORY_POOL memoryPoolPreference,
UINT creationNodeMask = 1,
UINT nodeMask = 1 )
{
Type = D3D12_HEAP_TYPE_CUSTOM;
CPUPageProperty = cpuPageProperty;
MemoryPoolPreference = memoryPoolPreference;
CreationNodeMask = creationNodeMask;
VisibleNodeMask = nodeMask;
}
explicit CD3DX12_HEAP_PROPERTIES(
D3D12_HEAP_TYPE type,
UINT creationNodeMask = 1,
UINT nodeMask = 1 )
{
Type = type;
CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
CreationNodeMask = creationNodeMask;
VisibleNodeMask = nodeMask;
}
operator const D3D12_HEAP_PROPERTIES&() const { return *this; }
bool IsCPUAccessible() const
{
return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM &&
(CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE || CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK));
}
};
inline bool operator==( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r )
{
return l.Type == r.Type && l.CPUPageProperty == r.CPUPageProperty &&
l.MemoryPoolPreference == r.MemoryPoolPreference &&
l.CreationNodeMask == r.CreationNodeMask &&
l.VisibleNodeMask == r.VisibleNodeMask;
}
inline bool operator!=( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r )
{ return !( l == r ); }
//------------------------------------------------------------------------------------------------
struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC
{
CD3DX12_HEAP_DESC()
{}
explicit CD3DX12_HEAP_DESC(const D3D12_HEAP_DESC &o) :
D3D12_HEAP_DESC(o)
{}
CD3DX12_HEAP_DESC(
UINT64 size,
D3D12_HEAP_PROPERTIES properties,
UINT64 alignment = 0,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = size;
Properties = properties;
Alignment = alignment;
Flags = flags;
}
CD3DX12_HEAP_DESC(
UINT64 size,
D3D12_HEAP_TYPE type,
UINT64 alignment = 0,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = size;
Properties = CD3DX12_HEAP_PROPERTIES( type );
Alignment = alignment;
Flags = flags;
}
CD3DX12_HEAP_DESC(
UINT64 size,
D3D12_CPU_PAGE_PROPERTY cpuPageProperty,
D3D12_MEMORY_POOL memoryPoolPreference,
UINT64 alignment = 0,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = size;
Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference );
Alignment = alignment;
Flags = flags;
}
CD3DX12_HEAP_DESC(
const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo,
D3D12_HEAP_PROPERTIES properties,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = resAllocInfo.SizeInBytes;
Properties = properties;
Alignment = resAllocInfo.Alignment;
Flags = flags;
}
CD3DX12_HEAP_DESC(
const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo,
D3D12_HEAP_TYPE type,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = resAllocInfo.SizeInBytes;
Properties = CD3DX12_HEAP_PROPERTIES( type );
Alignment = resAllocInfo.Alignment;
Flags = flags;
}
CD3DX12_HEAP_DESC(
const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo,
D3D12_CPU_PAGE_PROPERTY cpuPageProperty,
D3D12_MEMORY_POOL memoryPoolPreference,
D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE )
{
SizeInBytes = resAllocInfo.SizeInBytes;
Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference );
Alignment = resAllocInfo.Alignment;
Flags = flags;
}
operator const D3D12_HEAP_DESC&() const { return *this; }
bool IsCPUAccessible() const
{ return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); }
};
inline bool operator==( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r )
{
return l.SizeInBytes == r.SizeInBytes &&
l.Properties == r.Properties &&
l.Alignment == r.Alignment &&
l.Flags == r.Flags;
}
inline bool operator!=( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r )
{ return !( l == r ); }
//------------------------------------------------------------------------------------------------
struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE
{
CD3DX12_CLEAR_VALUE()
{}
explicit CD3DX12_CLEAR_VALUE(const D3D12_CLEAR_VALUE &o) :
D3D12_CLEAR_VALUE(o)
{}
CD3DX12_CLEAR_VALUE(
DXGI_FORMAT format,
const FLOAT color[4] )
{
Format = format;
memcpy( Color, color, sizeof( Color ) );
}
CD3DX12_CLEAR_VALUE(
DXGI_FORMAT format,
FLOAT depth,
UINT8 stencil )
{
Format = format;
/* Use memcpy to preserve NAN values */
memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) );
DepthStencil.Stencil = stencil;
}
operator const D3D12_CLEAR_VALUE&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_RANGE : public D3D12_RANGE
{
CD3DX12_RANGE()
{}
explicit CD3DX12_RANGE(const D3D12_RANGE &o) :
D3D12_RANGE(o)
{}
CD3DX12_RANGE(
SIZE_T begin,
SIZE_T end )
{
Begin = begin;
End = end;
}
operator const D3D12_RANGE&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE
{
CD3DX12_TILED_RESOURCE_COORDINATE()
{}
explicit CD3DX12_TILED_RESOURCE_COORDINATE(const D3D12_TILED_RESOURCE_COORDINATE &o) :
D3D12_TILED_RESOURCE_COORDINATE(o)
{}
CD3DX12_TILED_RESOURCE_COORDINATE(
UINT x,
UINT y,
UINT z,
UINT subresource )
{
X = x;
Y = y;
Z = z;
Subresource = subresource;
}
operator const D3D12_TILED_RESOURCE_COORDINATE&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE
{
CD3DX12_TILE_REGION_SIZE()
{}
explicit CD3DX12_TILE_REGION_SIZE(const D3D12_TILE_REGION_SIZE &o) :
D3D12_TILE_REGION_SIZE(o)
{}
CD3DX12_TILE_REGION_SIZE(
UINT numTiles,
BOOL useBox,
UINT width,
UINT16 height,
UINT16 depth )
{
NumTiles = numTiles;
UseBox = useBox;
Width = width;
Height = height;
Depth = depth;
}
operator const D3D12_TILE_REGION_SIZE&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING
{
CD3DX12_SUBRESOURCE_TILING()
{}
explicit CD3DX12_SUBRESOURCE_TILING(const D3D12_SUBRESOURCE_TILING &o) :
D3D12_SUBRESOURCE_TILING(o)
{}
CD3DX12_SUBRESOURCE_TILING(
UINT widthInTiles,
UINT16 heightInTiles,
UINT16 depthInTiles,
UINT startTileIndexInOverallResource )
{
WidthInTiles = widthInTiles;
HeightInTiles = heightInTiles;
DepthInTiles = depthInTiles;
StartTileIndexInOverallResource = startTileIndexInOverallResource;
}
operator const D3D12_SUBRESOURCE_TILING&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE
{
CD3DX12_TILE_SHAPE()
{}
explicit CD3DX12_TILE_SHAPE(const D3D12_TILE_SHAPE &o) :
D3D12_TILE_SHAPE(o)
{}
CD3DX12_TILE_SHAPE(
UINT widthInTexels,
UINT heightInTexels,
UINT depthInTexels )
{
WidthInTexels = widthInTexels;
HeightInTexels = heightInTexels;
DepthInTexels = depthInTexels;
}
operator const D3D12_TILE_SHAPE&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER
{
CD3DX12_RESOURCE_BARRIER()
{}
explicit CD3DX12_RESOURCE_BARRIER(const D3D12_RESOURCE_BARRIER &o) :
D3D12_RESOURCE_BARRIER(o)
{}
static inline CD3DX12_RESOURCE_BARRIER Transition(
_In_ ID3D12Resource* pResource,
D3D12_RESOURCE_STATES stateBefore,
D3D12_RESOURCE_STATES stateAfter,
UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE)
{
CD3DX12_RESOURCE_BARRIER result;
ZeroMemory(&result, sizeof(result));
D3D12_RESOURCE_BARRIER &barrier = result;
result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
result.Flags = flags;
barrier.Transition.pResource = pResource;
barrier.Transition.StateBefore = stateBefore;
barrier.Transition.StateAfter = stateAfter;
barrier.Transition.Subresource = subresource;
return result;
}
static inline CD3DX12_RESOURCE_BARRIER Aliasing(
_In_ ID3D12Resource* pResourceBefore,
_In_ ID3D12Resource* pResourceAfter)
{
CD3DX12_RESOURCE_BARRIER result;
ZeroMemory(&result, sizeof(result));
D3D12_RESOURCE_BARRIER &barrier = result;
result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING;
barrier.Aliasing.pResourceBefore = pResourceBefore;
barrier.Aliasing.pResourceAfter = pResourceAfter;
return result;
}
static inline CD3DX12_RESOURCE_BARRIER UAV(
_In_ ID3D12Resource* pResource)
{
CD3DX12_RESOURCE_BARRIER result;
ZeroMemory(&result, sizeof(result));
D3D12_RESOURCE_BARRIER &barrier = result;
result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
barrier.UAV.pResource = pResource;
return result;
}
operator const D3D12_RESOURCE_BARRIER&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO
{
CD3DX12_PACKED_MIP_INFO()
{}
explicit CD3DX12_PACKED_MIP_INFO(const D3D12_PACKED_MIP_INFO &o) :
D3D12_PACKED_MIP_INFO(o)
{}
CD3DX12_PACKED_MIP_INFO(
UINT8 numStandardMips,
UINT8 numPackedMips,
UINT numTilesForPackedMips,
UINT startTileIndexInOverallResource )
{
NumStandardMips = numStandardMips;
NumPackedMips = numPackedMips;
NumTilesForPackedMips = numTilesForPackedMips;
StartTileIndexInOverallResource = startTileIndexInOverallResource;
}
operator const D3D12_PACKED_MIP_INFO&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT
{
CD3DX12_SUBRESOURCE_FOOTPRINT()
{}
explicit CD3DX12_SUBRESOURCE_FOOTPRINT(const D3D12_SUBRESOURCE_FOOTPRINT &o) :
D3D12_SUBRESOURCE_FOOTPRINT(o)
{}
CD3DX12_SUBRESOURCE_FOOTPRINT(
DXGI_FORMAT format,
UINT width,
UINT height,
UINT depth,
UINT rowPitch )
{
Format = format;
Width = width;
Height = height;
Depth = depth;
RowPitch = rowPitch;
}
explicit CD3DX12_SUBRESOURCE_FOOTPRINT(
const D3D12_RESOURCE_DESC& resDesc,
UINT rowPitch )
{
Format = resDesc.Format;
Width = UINT( resDesc.Width );
Height = resDesc.Height;
Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1);
RowPitch = rowPitch;
}
operator const D3D12_SUBRESOURCE_FOOTPRINT&() const { return *this; }
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION
{
CD3DX12_TEXTURE_COPY_LOCATION()
{}
explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) :
D3D12_TEXTURE_COPY_LOCATION(o)
{}
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes) { pResource = pRes; }
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint)
{
pResource = pRes;
Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
PlacedFootprint = Footprint;
}
CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, UINT Sub)
{
pResource = pRes;
Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
SubresourceIndex = Sub;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE
{
CD3DX12_DESCRIPTOR_RANGE() { }
explicit CD3DX12_DESCRIPTOR_RANGE(const D3D12_DESCRIPTOR_RANGE &o) :
D3D12_DESCRIPTOR_RANGE(o)
{}
CD3DX12_DESCRIPTOR_RANGE(
D3D12_DESCRIPTOR_RANGE_TYPE rangeType,
UINT numDescriptors,
UINT baseShaderRegister,
UINT registerSpace = 0,
UINT offsetInDescriptorsFromTableStart =
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
{
Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart);
}
inline void Init(
D3D12_DESCRIPTOR_RANGE_TYPE rangeType,
UINT numDescriptors,
UINT baseShaderRegister,
UINT registerSpace = 0,
UINT offsetInDescriptorsFromTableStart =
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
{
Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart);
}
static inline void Init(
_Out_ D3D12_DESCRIPTOR_RANGE &range,
D3D12_DESCRIPTOR_RANGE_TYPE rangeType,
UINT numDescriptors,
UINT baseShaderRegister,
UINT registerSpace = 0,
UINT offsetInDescriptorsFromTableStart =
D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
{
range.RangeType = rangeType;
range.NumDescriptors = numDescriptors;
range.BaseShaderRegister = baseShaderRegister;
range.RegisterSpace = registerSpace;
range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE
{
CD3DX12_ROOT_DESCRIPTOR_TABLE() {}
explicit CD3DX12_ROOT_DESCRIPTOR_TABLE(const D3D12_ROOT_DESCRIPTOR_TABLE &o) :
D3D12_ROOT_DESCRIPTOR_TABLE(o)
{}
CD3DX12_ROOT_DESCRIPTOR_TABLE(
UINT numDescriptorRanges,
_In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges)
{
Init(numDescriptorRanges, _pDescriptorRanges);
}
inline void Init(
UINT numDescriptorRanges,
_In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges)
{
Init(*this, numDescriptorRanges, _pDescriptorRanges);
}
static inline void Init(
_Out_ D3D12_ROOT_DESCRIPTOR_TABLE &rootDescriptorTable,
UINT numDescriptorRanges,
_In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges)
{
rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges;
rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS
{
CD3DX12_ROOT_CONSTANTS() {}
explicit CD3DX12_ROOT_CONSTANTS(const D3D12_ROOT_CONSTANTS &o) :
D3D12_ROOT_CONSTANTS(o)
{}
CD3DX12_ROOT_CONSTANTS(
UINT num32BitValues,
UINT shaderRegister,
UINT registerSpace = 0)
{
Init(num32BitValues, shaderRegister, registerSpace);
}
inline void Init(
UINT num32BitValues,
UINT shaderRegister,
UINT registerSpace = 0)
{
Init(*this, num32BitValues, shaderRegister, registerSpace);
}
static inline void Init(
_Out_ D3D12_ROOT_CONSTANTS &rootConstants,
UINT num32BitValues,
UINT shaderRegister,
UINT registerSpace = 0)
{
rootConstants.Num32BitValues = num32BitValues;
rootConstants.ShaderRegister = shaderRegister;
rootConstants.RegisterSpace = registerSpace;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR
{
CD3DX12_ROOT_DESCRIPTOR() {}
explicit CD3DX12_ROOT_DESCRIPTOR(const D3D12_ROOT_DESCRIPTOR &o) :
D3D12_ROOT_DESCRIPTOR(o)
{}
CD3DX12_ROOT_DESCRIPTOR(
UINT shaderRegister,
UINT registerSpace = 0)
{
Init(shaderRegister, registerSpace);
}
inline void Init(
UINT shaderRegister,
UINT registerSpace = 0)
{
Init(*this, shaderRegister, registerSpace);
}
static inline void Init(_Out_ D3D12_ROOT_DESCRIPTOR &table, UINT shaderRegister, UINT registerSpace = 0)
{
table.ShaderRegister = shaderRegister;
table.RegisterSpace = registerSpace;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER
{
CD3DX12_ROOT_PARAMETER() {}
explicit CD3DX12_ROOT_PARAMETER(const D3D12_ROOT_PARAMETER &o) :
D3D12_ROOT_PARAMETER(o)
{}
static inline void InitAsDescriptorTable(
_Out_ D3D12_ROOT_PARAMETER &rootParam,
UINT numDescriptorRanges,
_In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
rootParam.ShaderVisibility = visibility;
CD3DX12_ROOT_DESCRIPTOR_TABLE::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges);
}
static inline void InitAsConstants(
_Out_ D3D12_ROOT_PARAMETER &rootParam,
UINT num32BitValues,
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
rootParam.ShaderVisibility = visibility;
CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace);
}
static inline void InitAsConstantBufferView(
_Out_ D3D12_ROOT_PARAMETER &rootParam,
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
rootParam.ShaderVisibility = visibility;
CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace);
}
static inline void InitAsShaderResourceView(
_Out_ D3D12_ROOT_PARAMETER &rootParam,
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
rootParam.ShaderVisibility = visibility;
CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace);
}
static inline void InitAsUnorderedAccessView(
_Out_ D3D12_ROOT_PARAMETER &rootParam,
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV;
rootParam.ShaderVisibility = visibility;
CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace);
}
inline void InitAsDescriptorTable(
UINT numDescriptorRanges,
_In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility);
}
inline void InitAsConstants(
UINT num32BitValues,
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility);
}
inline void InitAsConstantBufferView(
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
InitAsConstantBufferView(*this, shaderRegister, registerSpace, visibility);
}
inline void InitAsShaderResourceView(
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
InitAsShaderResourceView(*this, shaderRegister, registerSpace, visibility);
}
inline void InitAsUnorderedAccessView(
UINT shaderRegister,
UINT registerSpace = 0,
D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, visibility);
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC
{
CD3DX12_STATIC_SAMPLER_DESC() {}
explicit CD3DX12_STATIC_SAMPLER_DESC(const D3D12_STATIC_SAMPLER_DESC &o) :
D3D12_STATIC_SAMPLER_DESC(o)
{}
CD3DX12_STATIC_SAMPLER_DESC(
UINT shaderRegister,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
FLOAT mipLODBias = 0,
UINT maxAnisotropy = 16,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE,
FLOAT minLOD = 0.f,
FLOAT maxLOD = D3D12_FLOAT32_MAX,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL,
UINT registerSpace = 0)
{
Init(
shaderRegister,
filter,
addressU,
addressV,
addressW,
mipLODBias,
maxAnisotropy,
comparisonFunc,
borderColor,
minLOD,
maxLOD,
shaderVisibility,
registerSpace);
}
static inline void Init(
_Out_ D3D12_STATIC_SAMPLER_DESC &samplerDesc,
UINT shaderRegister,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
FLOAT mipLODBias = 0,
UINT maxAnisotropy = 16,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE,
FLOAT minLOD = 0.f,
FLOAT maxLOD = D3D12_FLOAT32_MAX,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL,
UINT registerSpace = 0)
{
samplerDesc.ShaderRegister = shaderRegister;
samplerDesc.Filter = filter;
samplerDesc.AddressU = addressU;
samplerDesc.AddressV = addressV;
samplerDesc.AddressW = addressW;
samplerDesc.MipLODBias = mipLODBias;
samplerDesc.MaxAnisotropy = maxAnisotropy;
samplerDesc.ComparisonFunc = comparisonFunc;
samplerDesc.BorderColor = borderColor;
samplerDesc.MinLOD = minLOD;
samplerDesc.MaxLOD = maxLOD;
samplerDesc.ShaderVisibility = shaderVisibility;
samplerDesc.RegisterSpace = registerSpace;
}
inline void Init(
UINT shaderRegister,
D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC,
D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP,
FLOAT mipLODBias = 0,
UINT maxAnisotropy = 16,
D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL,
D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE,
FLOAT minLOD = 0.f,
FLOAT maxLOD = D3D12_FLOAT32_MAX,
D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL,
UINT registerSpace = 0)
{
Init(
*this,
shaderRegister,
filter,
addressU,
addressV,
addressW,
mipLODBias,
maxAnisotropy,
comparisonFunc,
borderColor,
minLOD,
maxLOD,
shaderVisibility,
registerSpace);
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC
{
CD3DX12_ROOT_SIGNATURE_DESC() {}
explicit CD3DX12_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) :
D3D12_ROOT_SIGNATURE_DESC(o)
{}
CD3DX12_ROOT_SIGNATURE_DESC(
UINT numParameters,
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
UINT numStaticSamplers = 0,
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
{
Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
}
CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT)
{
Init(0, NULL, 0, NULL, D3D12_ROOT_SIGNATURE_FLAG_NONE);
}
inline void Init(
UINT numParameters,
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
UINT numStaticSamplers = 0,
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
{
Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags);
}
static inline void Init(
_Out_ D3D12_ROOT_SIGNATURE_DESC &desc,
UINT numParameters,
_In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters,
UINT numStaticSamplers = 0,
_In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = NULL,
D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE)
{
desc.NumParameters = numParameters;
desc.pParameters = _pParameters;
desc.NumStaticSamplers = numStaticSamplers;
desc.pStaticSamplers = _pStaticSamplers;
desc.Flags = flags;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE
{
CD3DX12_CPU_DESCRIPTOR_HANDLE() {}
explicit CD3DX12_CPU_DESCRIPTOR_HANDLE(const D3D12_CPU_DESCRIPTOR_HANDLE &o) :
D3D12_CPU_DESCRIPTOR_HANDLE(o)
{}
CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) { ptr = 0; }
CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize)
{
InitOffsetted(other, offsetScaledByIncrementSize);
}
CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize);
}
CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize)
{
ptr += offsetInDescriptors * descriptorIncrementSize;
return *this;
}
CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize)
{
ptr += offsetScaledByIncrementSize;
return *this;
}
bool operator==(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other)
{
return (ptr == other.ptr);
}
bool operator!=(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other)
{
return (ptr != other.ptr);
}
CD3DX12_CPU_DESCRIPTOR_HANDLE &operator=(const D3D12_CPU_DESCRIPTOR_HANDLE &other)
{
ptr = other.ptr;
return *this;
}
inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize)
{
InitOffsetted(*this, base, offsetScaledByIncrementSize);
}
inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize);
}
static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize)
{
handle.ptr = base.ptr + offsetScaledByIncrementSize;
}
static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
handle.ptr = base.ptr + offsetInDescriptors * descriptorIncrementSize;
}
};
//------------------------------------------------------------------------------------------------
struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE
{
CD3DX12_GPU_DESCRIPTOR_HANDLE() {}
explicit CD3DX12_GPU_DESCRIPTOR_HANDLE(const D3D12_GPU_DESCRIPTOR_HANDLE &o) :
D3D12_GPU_DESCRIPTOR_HANDLE(o)
{}
CD3DX12_GPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) { ptr = 0; }
CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize)
{
InitOffsetted(other, offsetScaledByIncrementSize);
}
CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize);
}
CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize)
{
ptr += offsetInDescriptors * descriptorIncrementSize;
return *this;
}
CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize)
{
ptr += offsetScaledByIncrementSize;
return *this;
}
inline bool operator==(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other)
{
return (ptr == other.ptr);
}
inline bool operator!=(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other)
{
return (ptr != other.ptr);
}
CD3DX12_GPU_DESCRIPTOR_HANDLE &operator=(const D3D12_GPU_DESCRIPTOR_HANDLE &other)
{
ptr = other.ptr;
return *this;
}
inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize)
{
InitOffsetted(*this, base, offsetScaledByIncrementSize);
}
inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize);
}
static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize)
{
handle.ptr = base.ptr + offsetScaledByIncrementSize;
}
static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize)
{
handle.ptr = base.ptr + offsetInDescriptors * descriptorIncrementSize;
}
};
//------------------------------------------------------------------------------------------------
inline UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize )
{
return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize;
}
//------------------------------------------------------------------------------------------------
template <typename T, typename U, typename V>
inline void D3D12DecomposeSubresource( UINT Subresource, UINT MipLevels, UINT ArraySize, _Out_ T& MipSlice, _Out_ U& ArraySlice, _Out_ V& PlaneSlice )
{
MipSlice = static_cast<T>(Subresource % MipLevels);
ArraySlice = static_cast<U>((Subresource / MipLevels) % ArraySize);
PlaneSlice = static_cast<V>(Subresource / (MipLevels * ArraySize));
}
//------------------------------------------------------------------------------------------------
inline UINT8 D3D12GetFormatPlaneCount(
_In_ ID3D12Device* pDevice,
DXGI_FORMAT Format
)
{
D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = {Format};
if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo))))
{
return 0;
}
return formatInfo.PlaneCount;
}
//------------------------------------------------------------------------------------------------
struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC
{
CD3DX12_RESOURCE_DESC()
{}
explicit CD3DX12_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o ) :
D3D12_RESOURCE_DESC( o )
{}
CD3DX12_RESOURCE_DESC(
D3D12_RESOURCE_DIMENSION dimension,
UINT64 alignment,
UINT64 width,
UINT height,
UINT16 depthOrArraySize,
UINT16 mipLevels,
DXGI_FORMAT format,
UINT sampleCount,
UINT sampleQuality,
D3D12_TEXTURE_LAYOUT layout,
D3D12_RESOURCE_FLAGS flags )
{
Dimension = dimension;
Alignment = alignment;
Width = width;
Height = height;
DepthOrArraySize = depthOrArraySize;
MipLevels = mipLevels;
Format = format;
SampleDesc.Count = sampleCount;
SampleDesc.Quality = sampleQuality;
Layout = layout;
Flags = flags;
}
static inline CD3DX12_RESOURCE_DESC Buffer(
const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE )
{
return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes,
1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags );
}
static inline CD3DX12_RESOURCE_DESC Buffer(
UINT64 width,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
UINT64 alignment = 0 )
{
return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1,
DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags );
}
static inline CD3DX12_RESOURCE_DESC Tex1D(
DXGI_FORMAT format,
UINT64 width,
UINT16 arraySize = 1,
UINT16 mipLevels = 0,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN,
UINT64 alignment = 0 )
{
return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize,
mipLevels, format, 1, 0, layout, flags );
}
static inline CD3DX12_RESOURCE_DESC Tex2D(
DXGI_FORMAT format,
UINT64 width,
UINT height,
UINT16 arraySize = 1,
UINT16 mipLevels = 0,
UINT sampleCount = 1,
UINT sampleQuality = 0,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN,
UINT64 alignment = 0 )
{
return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize,
mipLevels, format, sampleCount, sampleQuality, layout, flags );
}
static inline CD3DX12_RESOURCE_DESC Tex3D(
DXGI_FORMAT format,
UINT64 width,
UINT height,
UINT16 depth,
UINT16 mipLevels = 0,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE,
D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN,
UINT64 alignment = 0 )
{
return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth,
mipLevels, format, 1, 0, layout, flags );
}
inline UINT16 Depth() const
{ return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); }
inline UINT16 ArraySize() const
{ return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); }
inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const
{ return D3D12GetFormatPlaneCount(pDevice, Format); }
inline UINT Subresources(_In_ ID3D12Device* pDevice) const
{ return MipLevels * ArraySize() * PlaneCount(pDevice); }
inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice)
{ return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); }
operator const D3D12_RESOURCE_DESC&() const { return *this; }
};
inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r )
{
return l.Dimension == r.Dimension &&
l.Alignment == r.Alignment &&
l.Width == r.Width &&
l.Height == r.Height &&
l.DepthOrArraySize == r.DepthOrArraySize &&
l.MipLevels == r.MipLevels &&
l.Format == r.Format &&
l.SampleDesc.Count == r.SampleDesc.Count &&
l.SampleDesc.Quality == r.SampleDesc.Quality &&
l.Layout == r.Layout &&
l.Flags == r.Flags;
}
inline bool operator!=( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r )
{ return !( l == r ); }
//------------------------------------------------------------------------------------------------
// Row-by-row memcpy
inline void MemcpySubresource(
_In_ const D3D12_MEMCPY_DEST* pDest,
_In_ const D3D12_SUBRESOURCE_DATA* pSrc,
SIZE_T RowSizeInBytes,
UINT NumRows,
UINT NumSlices)
{
for (UINT z = 0; z < NumSlices; ++z)
{
BYTE* pDestSlice = reinterpret_cast<BYTE*>(pDest->pData) + pDest->SlicePitch * z;
const BYTE* pSrcSlice = reinterpret_cast<const BYTE*>(pSrc->pData) + pSrc->SlicePitch * z;
for (UINT y = 0; y < NumRows; ++y)
{
memcpy(pDestSlice + pDest->RowPitch * y,
pSrcSlice + pSrc->RowPitch * y,
RowSizeInBytes);
}
}
}
//------------------------------------------------------------------------------------------------
// Returns required size of a buffer to be used for data upload
inline UINT64 GetRequiredIntermediateSize(
_In_ ID3D12Resource* pDestinationResource,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources)
{
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
UINT64 RequiredSize = 0;
ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
pDevice->Release();
return RequiredSize;
}
//------------------------------------------------------------------------------------------------
// All arrays must be populated (e.g. by calling GetCopyableFootprints)
inline UINT64 UpdateSubresources(
_In_ ID3D12GraphicsCommandList* pCmdList,
_In_ ID3D12Resource* pDestinationResource,
_In_ ID3D12Resource* pIntermediate,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources,
UINT64 RequiredSize,
_In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts,
_In_reads_(NumSubresources) const UINT* pNumRows,
_In_reads_(NumSubresources) const UINT64* pRowSizesInBytes,
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData)
{
// Minor validation
D3D12_RESOURCE_DESC IntermediateDesc = pIntermediate->GetDesc();
D3D12_RESOURCE_DESC DestinationDesc = pDestinationResource->GetDesc();
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
RequiredSize > (SIZE_T)-1 ||
(DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER &&
(FirstSubresource != 0 || NumSubresources != 1)))
{
return 0;
}
BYTE* pData;
HRESULT hr = pIntermediate->Map(0, NULL, reinterpret_cast<void**>(&pData));
if (FAILED(hr))
{
return 0;
}
for (UINT i = 0; i < NumSubresources; ++i)
{
if (pRowSizesInBytes[i] > (SIZE_T)-1) return 0;
D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, pLayouts[i].Footprint.RowPitch * pNumRows[i] };
MemcpySubresource(&DestData, &pSrcData[i], (SIZE_T)pRowSizesInBytes[i], pNumRows[i], pLayouts[i].Footprint.Depth);
}
pIntermediate->Unmap(0, NULL);
if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
{
CD3DX12_BOX SrcBox( UINT( pLayouts[0].Offset ), UINT( pLayouts[0].Offset + pLayouts[0].Footprint.Width ) );
pCmdList->CopyBufferRegion(
pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width);
}
else
{
for (UINT i = 0; i < NumSubresources; ++i)
{
CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource);
CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]);
pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr);
}
}
return RequiredSize;
}
//------------------------------------------------------------------------------------------------
// Heap-allocating UpdateSubresources implementation
inline UINT64 UpdateSubresources(
_In_ ID3D12GraphicsCommandList* pCmdList,
_In_ ID3D12Resource* pDestinationResource,
_In_ ID3D12Resource* pIntermediate,
UINT64 IntermediateOffset,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources,
_In_reads_(NumSubresources) D3D12_SUBRESOURCE_DATA* pSrcData)
{
UINT64 RequiredSize = 0;
UINT64 MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources;
if (MemToAlloc > SIZE_MAX)
{
return 0;
}
void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast<SIZE_T>(MemToAlloc));
if (pMem == NULL)
{
return 0;
}
D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts = reinterpret_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem);
UINT64* pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
UINT* pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
pDevice->Release();
UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData);
HeapFree(GetProcessHeap(), 0, pMem);
return Result;
}
//------------------------------------------------------------------------------------------------
// Stack-allocating UpdateSubresources implementation
template <UINT MaxSubresources>
inline UINT64 UpdateSubresources(
_In_ ID3D12GraphicsCommandList* pCmdList,
_In_ ID3D12Resource* pDestinationResource,
_In_ ID3D12Resource* pIntermediate,
UINT64 IntermediateOffset,
_In_range_(0, MaxSubresources) UINT FirstSubresource,
_In_range_(1, MaxSubresources - FirstSubresource) UINT NumSubresources,
_In_reads_(NumSubresources) D3D12_SUBRESOURCE_DATA* pSrcData)
{
UINT64 RequiredSize = 0;
D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources];
UINT NumRows[MaxSubresources];
UINT64 RowSizesInBytes[MaxSubresources];
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize);
pDevice->Release();
return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData);
}
//------------------------------------------------------------------------------------------------
inline bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout )
{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; }
//------------------------------------------------------------------------------------------------
inline ID3D12CommandList * const * CommandListCast(ID3D12GraphicsCommandList * const * pp)
{
// This cast is useful for passing strongly typed command list pointers into
// ExecuteCommandLists.
// This cast is valid as long as the const-ness is respected. D3D12 APIs do
// respect the const-ness of their arguments.
return reinterpret_cast<ID3D12CommandList * const *>(pp);
}
#endif // defined( __cplusplus )
#endif //__D3DX12_H__
|