File size: 49,774 Bytes
2f705f7 | 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 | /*-------------------------------------------------------------------------------------
*
* Copyright (c) Microsoft Corporation
* Licensed under the MIT license
*
*-------------------------------------------------------------------------------------*/
#if !defined(__cplusplus)
#error C++11 required
#endif
#pragma once
#include <unknwn.h>
#include <d3d12.h>
#include <dstorageerr.h>
#define DSTORAGE_SDK_VERSION 202
interface ID3D12Resource;
interface ID3D12Fence;
interface IDStorageStatusArray;
/// <summary>
/// The priority of a DirectStorage queue.
/// </summary>
enum DSTORAGE_PRIORITY : INT8 {
DSTORAGE_PRIORITY_LOW = -1,
DSTORAGE_PRIORITY_NORMAL = 0,
DSTORAGE_PRIORITY_HIGH = 1,
DSTORAGE_PRIORITY_REALTIME = 2,
/// <summary>
/// The following values can be used for iterating over all priority levels.
/// </summary>
DSTORAGE_PRIORITY_FIRST = DSTORAGE_PRIORITY_LOW,
DSTORAGE_PRIORITY_LAST = DSTORAGE_PRIORITY_REALTIME,
DSTORAGE_PRIORITY_COUNT = 4
};
/// <summary>
/// The minimum valid queue capacity.
/// </summary>
#define DSTORAGE_MIN_QUEUE_CAPACITY 0x80
/// <summary>
/// The maximum valid queue capacity.
/// </summary>
#define DSTORAGE_MAX_QUEUE_CAPACITY 0x2000
/// <summary>
/// The source type of a DirectStorage request.
/// </summary>
enum DSTORAGE_REQUEST_SOURCE_TYPE : UINT64 {
/// <summary>
/// The source of the DirectStorage request is a file.
/// </summary>
DSTORAGE_REQUEST_SOURCE_FILE = 0,
/// <summary>
/// The source of the DirectStorage request is a block of memory.
/// </summary>
DSTORAGE_REQUEST_SOURCE_MEMORY = 1,
};
/// <summary>
/// The destination type of a DirectStorage request.
/// </summary>
enum DSTORAGE_REQUEST_DESTINATION_TYPE : UINT64 {
/// <summary>
/// The destination of the DirectStorage request is a block of memory.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_MEMORY = 0,
/// <summary>
/// The destination of the DirectStorage request is an ID3D12Resource
/// that is a buffer.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_BUFFER = 1,
/// <summary>
/// The destination of the DirectStorage request is an ID3D12Resource
/// that is a texture.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_TEXTURE_REGION = 2,
/// <summary>
/// The destination of the DirectStorage request is an ID3D12Resource
/// that is a texture that will receive all subresources in a
/// single request.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_MULTIPLE_SUBRESOURCES = 3,
/// <summary>
/// The destination of the DirectStorage request is an ID3D12Resource
/// that is tiled.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_TILES = 4
};
/// <summary>
/// The DSTORAGE_QUEUE_DESC structure contains the properties of a DirectStorage
/// queue for the queue's creation.
/// </summary>
struct DSTORAGE_QUEUE_DESC {
/// <summary>
/// The source type of requests that this DirectStorage queue can accept.
/// </summary>
DSTORAGE_REQUEST_SOURCE_TYPE SourceType;
/// <summary>
/// The maximum number of requests that the queue can hold.
/// </summary>
UINT16 Capacity;
/// <summary>
/// The priority of the requests in this queue.
/// </summary>
DSTORAGE_PRIORITY Priority;
/// <summary>
/// Optional name of the queue. Used for debugging.
/// </summary>
_In_opt_z_ const CHAR *Name;
/// <summary>
/// Optional device to use for writing to destination resources and
/// performing GPU decompression. The destination resource's device
/// must match this device.
///
/// This member may be null. If you specify a null device, then the
/// destination type must be DSTORAGE_REQUEST_DESTINATION_MEMORY.
/// </summary>
ID3D12Device* Device;
};
/// <summary>
/// The DSTORAGE_QUEUE_INFO structure contains the properties and current state
/// of a DirectStorage queue.
/// </summary>
struct DSTORAGE_QUEUE_INFO {
/// <summary>
/// The DSTORAGE_QUEUE_DESC structure used for the queue's creation.
/// </summary>
DSTORAGE_QUEUE_DESC Desc;
/// <summary>
/// The number of available empty slots. If a queue is empty, then the number
/// of empty slots equals capacity - 1. The reserved slot is used to
/// distinguish between empty and full cases.
/// </summary>
UINT16 EmptySlotCount;
/// <summary>
/// The number of entries that would need to be enqueued in order to trigger
/// automatic submission.
/// </summary>
UINT16 RequestCountUntilAutoSubmit;
};
/// <summary>
/// The type of compression format used at the decompression stage.
/// Your application can implement custom decompressors, starting from
/// DSTORAGE_CUSTOM_COMPRESSION_0.
/// </summary>
enum DSTORAGE_COMPRESSION_FORMAT : UINT8 {
/// <summary>
/// The data is uncompressed.
/// </summary>
DSTORAGE_COMPRESSION_FORMAT_NONE = 0,
/// <summary>
/// The data is compressed using the built-in GDEFLATE format.
/// </summary>
DSTORAGE_COMPRESSION_FORMAT_GDEFLATE = 1,
/// <summary>
/// The data is stored in an application-defined custom format. The
/// application must use IDStorageCustomDecompressionQueue to implement
/// custom decompression. Additional custom compression formats can be
/// used, for example `(DSTORAGE_CUSTOM_COMPRESSION_0 + 1)`.
DSTORAGE_CUSTOM_COMPRESSION_0 = 0x80,
};
/// <summary>
/// Options for a DirectStorage request.
/// </summary>
struct DSTORAGE_REQUEST_OPTIONS {
/// <summary>
/// DSTORAGE_COMPRESSION_FORMAT indicating how the data is compressed.
/// </summary>
DSTORAGE_COMPRESSION_FORMAT CompressionFormat : 8;
/// <summary>
/// Reserved fields. Must be 0.
/// </summary>
UINT8 Reserved1[7];
/// <summary>
/// DSTORAGE_REQUEST_SOURCE_TYPE enum value indicating whether the
/// source of the request is a file or a block of memory.
/// </summary>
DSTORAGE_REQUEST_SOURCE_TYPE SourceType : 1;
/// <summary>
/// DSTORAGE_REQUEST_DESTINATION_TYPE enum value indicating the
/// destination of the request. Block of memory, resource.
/// </summary>
DSTORAGE_REQUEST_DESTINATION_TYPE DestinationType : 7;
/// <summary>
/// Reserved fields. Must be 0.
/// </summary>
UINT64 Reserved : 48;
};
/// <summary>
/// Flags controlling DirectStorage debug layer.
/// </summary>
enum DSTORAGE_DEBUG {
/// <summary>
/// DirectStorage debug layer is disabled.
/// </summary>
DSTORAGE_DEBUG_NONE = 0x00,
/// <summary>
/// Print error information to a debugger.
/// </summary>
DSTORAGE_DEBUG_SHOW_ERRORS = 0x01,
/// <summary>
/// Trigger a debug break each time an error is detected.
/// </summary>
DSTORAGE_DEBUG_BREAK_ON_ERROR = 0x02,
/// <summary>
/// Include object names in ETW events.
/// </summary>
DSTORAGE_DEBUG_RECORD_OBJECT_NAMES = 0x04
};
DEFINE_ENUM_FLAG_OPERATORS(DSTORAGE_DEBUG);
/// <summary>
/// Represents a file to be accessed by DirectStorage.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageFile, IUnknown, "5de95e7b-955a-4868-a73c-243b29f4b8da")
{
/// <summary>
/// Closes the file, regardless of the reference count on this object.
///
/// After an IDStorageFile object is closed, it can no longer be used in
/// DirectStorage requests. This does not modify the reference count on this
/// object; Release() must be called as usual.
/// </summary>
virtual void STDMETHODCALLTYPE Close() = 0;
/// <summary>
/// Retrieves file information for an opened file.
/// </summary>
/// <param name="info">Receives the file information.</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE GetFileInformation(_Out_ BY_HANDLE_FILE_INFORMATION* info) = 0;
};
/// <summary>
/// Describes a source for a request with SourceType
/// DSTORAGE_REQUEST_SOURCE_FILE.
/// </summary>
struct DSTORAGE_SOURCE_FILE {
/// <summary>
/// The file to perform this read request from.
/// </summary>
IDStorageFile* Source;
/// <summary>
/// The offset, in bytes, in the file to start the read request at.
/// </summary>
UINT64 Offset;
/// <summary>
/// Number of bytes to read from the file.
/// </summary>
UINT32 Size;
};
/// <summary>
/// Describes the source for a request with SourceType
/// DSTORAGE_REQUEST_SOURCE_MEMORY.
/// </summary>
struct DSTORAGE_SOURCE_MEMORY {
/// <summary>
/// Address of the source buffer to be read from.
/// </summary>
void const* Source;
/// <summary>
/// Number of bytes to read from the source buffer.
/// </summary>
UINT32 Size;
};
/// <summary>
/// Describes the destination for a request with DestinationType
/// DSTORAGE_REQUEST_DESTINATION_MEMORY.
/// </summary>
struct DSTORAGE_DESTINATION_MEMORY {
/// <summary>
/// Address of the buffer to receive the final result of this request.
/// </summary>
void* Buffer;
/// <summary>
/// Number of bytes to write to the destination buffer.
/// </summary>
UINT32 Size;
};
/// <summary>
/// Describes the destination for a request with DestinationType
/// DSTORAGE_REQUEST_DESTINATION_BUFFER.
/// </summary>
struct DSTORAGE_DESTINATION_BUFFER {
/// <summary>
/// Address of the resource to receive the final result of this request.
/// </summary>
ID3D12Resource* Resource;
/// <summary>
/// The offset, in bytes, in the buffer resource to write into.
/// </summary>
UINT64 Offset;
/// <summary>
/// Number of bytes to write to the destination buffer.
/// </summary>
UINT32 Size;
};
/// <summary>
/// Describes the destination for a request with DestinationType
/// DSTORAGE_REQUEST_DESTINATION_TEXTURE_REGION.
/// </summary>
struct DSTORAGE_DESTINATION_TEXTURE_REGION {
/// <summary>
/// Address of the resource to receive the final result of this request.
/// </summary>
ID3D12Resource* Resource;
/// <summary>
/// Describes the destination texture copy location. The subresource
/// referred to must be in the D3D12_RESOURCE_STATE_COMMON state.
/// </summary>
UINT SubresourceIndex;
/// <summary>
/// Coordinates and size of the destination region to copy, in pixels.
/// </summary>
D3D12_BOX Region;
};
/// <summary>
/// Describes the destination for a request with DestinationType
/// DSTORAGE_REQUEST_DESTINATION_MULTIPLE_SUBRESOURCES.
/// </summary>
struct DSTORAGE_DESTINATION_MULTIPLE_SUBRESOURCES {
/// <summary>
/// Address of the resource to receive the final result of this request. The
/// source is expected to contain full data for all subresources, starting
/// from FirstSubresource.
/// </summary>
ID3D12Resource* Resource;
/// <summary>
/// Describes the first subresource of the destination texture copy
/// location. The subresource referred to must be in the
/// D3D12_RESOURCE_STATE_COMMON state.
/// </summary>
UINT FirstSubresource;
};
/// <summary>
/// Describes the destination for a request with DestinationType
/// DSTORAGE_REQUEST_DESTINATION_TILES.
/// </summary>
struct DSTORAGE_DESTINATION_TILES {
/// <summary>
/// Address of the resource to receive the final result of this request. The
/// source buffer is expected to contain data arranged as if it were the
/// source to a CopyTiles call with these parameters.
/// </summary>
ID3D12Resource* Resource;
/// <summary>
/// The starting coordinates of the tiled region.
/// </summary>
D3D12_TILED_RESOURCE_COORDINATE TiledRegionStartCoordinate;
/// <summary>
/// The size of the tiled region.
/// </summary>
D3D12_TILE_REGION_SIZE TileRegionSize;
};
/// <summary>
/// Describes the source specified for a DirectStorage request. For a request,
/// the value of `request.Options.SourceType` determines which of these union
/// fields is active.
/// </summary>
union DSTORAGE_SOURCE {
DSTORAGE_SOURCE_MEMORY Memory;
DSTORAGE_SOURCE_FILE File;
};
/// <summary>
/// Describes the destination for a DirectStorage request. For a request, the
/// value of `request.Options.DestinationType` determines which of these union
/// fields is active.
/// </summary>
union DSTORAGE_DESTINATION {
DSTORAGE_DESTINATION_MEMORY Memory;
DSTORAGE_DESTINATION_BUFFER Buffer;
DSTORAGE_DESTINATION_TEXTURE_REGION Texture;
DSTORAGE_DESTINATION_MULTIPLE_SUBRESOURCES MultipleSubresources;
DSTORAGE_DESTINATION_TILES Tiles;
};
/// <summary>
/// Represents a DirectStorage request.
/// </summary>
struct DSTORAGE_REQUEST {
/// <summary>
/// Combination of decompression and other options for this request.
/// </summary>
DSTORAGE_REQUEST_OPTIONS Options;
/// <summary>
/// The source for this request.
/// </summary>
DSTORAGE_SOURCE Source;
/// <summary>
/// The destination for this request.
/// </summary>
DSTORAGE_DESTINATION Destination;
/// <summary>
/// The uncompressed size in bytes for the destination for this request.
/// If the request is not compressed, then this can be left as 0.
///
/// For compressed data, if the destination is memory, then the uncompressed size must
/// exactly equal the destination size. For other destination types, the uncompressed
/// size may be greater than the destination size.
///
/// If the destination is to memory or buffer, then the destination size should
/// be specified in the corresponding struct (for example, DSTORAGE_DESTINATION_MEMORY).
/// For textures, it's the value of pTotalBytes returned by GetCopyableFootprints.
/// For tiles, it's 64k * number of tiles.
/// </summary>
UINT32 UncompressedSize;
/// <summary>
/// An arbitrary UINT64 number used for cancellation matching.
/// </summary>
UINT64 CancellationTag;
/// <summary>
/// Optional name of the request. Used for debugging. If specified, the
/// string should be accessible until the request completes.
/// </summary>
_In_opt_z_ const CHAR *Name;
};
/// <summary>
/// The maximum number of characters that will be stored for a request's name.
/// </summary>
#define DSTORAGE_REQUEST_MAX_NAME 64
/// <summary>
/// The type of command that failed, as reported by
/// DSTORAGE_ERROR_FIRST_FAILURE.
/// </summary>
enum DSTORAGE_COMMAND_TYPE {
DSTORAGE_COMMAND_TYPE_NONE = -1,
DSTORAGE_COMMAND_TYPE_REQUEST = 0,
DSTORAGE_COMMAND_TYPE_STATUS = 1,
DSTORAGE_COMMAND_TYPE_SIGNAL = 2,
DSTORAGE_COMMAND_TYPE_EVENT = 3,
};
/// <summary>
/// The parameters passed to the EnqueueRequest call, and optional
/// filename if the request is for a file source.
/// </summary>
struct DSTORAGE_ERROR_PARAMETERS_REQUEST {
/// <summary>
/// For a file source request, the name of the file the request was
/// targeted to.
/// </summary>
WCHAR Filename[MAX_PATH];
/// <summary>
/// The name of the request if one was specified.
/// </summary>
CHAR RequestName[DSTORAGE_REQUEST_MAX_NAME];
/// <summary>
/// The parameters passed to the EnqueueRequest call.
/// </summary>
DSTORAGE_REQUEST Request;
};
/// <summary>
/// The parameters passed to the EnqueueStatus call.
/// </summary>
struct DSTORAGE_ERROR_PARAMETERS_STATUS {
IDStorageStatusArray* StatusArray;
UINT32 Index;
};
/// <summary>
/// The parameters passed to the EnqueueSignal call.
/// </summary>
struct DSTORAGE_ERROR_PARAMETERS_SIGNAL {
ID3D12Fence* Fence;
UINT64 Value;
};
/// <summary>
/// The parameters passed to the EnqueueSetEvent call.
/// </summary>
struct DSTORAGE_ERROR_PARAMETERS_EVENT
{
HANDLE Handle;
};
/// <summary>
/// Structure to receive the detailed record of the first failed DirectStorage
/// request.
/// </summary>
struct DSTORAGE_ERROR_FIRST_FAILURE {
/// <summary>
/// The HRESULT code of the failure.
/// </summary>
HRESULT HResult;
/// <summary>
/// Type of the Enqueue command that caused the failure.
/// </summary>
DSTORAGE_COMMAND_TYPE CommandType;
/// <summary>
/// The parameters passed to the Enqueue call.
/// </summary>
union
{
DSTORAGE_ERROR_PARAMETERS_REQUEST Request;
DSTORAGE_ERROR_PARAMETERS_STATUS Status;
DSTORAGE_ERROR_PARAMETERS_SIGNAL Signal;
DSTORAGE_ERROR_PARAMETERS_EVENT Event;
};
};
/// <summary>
/// Structure to receive the detailed record of a failed DirectStorage request.
/// </summary>
struct DSTORAGE_ERROR_RECORD {
/// <summary>
/// The number of failed requests in the queue since the last
/// RetrieveErrorRecord call.
/// </summary>
UINT32 FailureCount;
/// <summary>
/// Detailed record about the first failed command in the enqueue order.
/// </summary>
DSTORAGE_ERROR_FIRST_FAILURE FirstFailure;
};
/// <summary>
/// Defines common staging buffer sizes.
/// </summary>
enum DSTORAGE_STAGING_BUFFER_SIZE : UINT32 {
/// <summary>
/// There is no staging buffer. Use this value to force DirectStorage to
/// deallocate any memory it has allocated for staging buffers.
/// <summary>
DSTORAGE_STAGING_BUFFER_SIZE_0 = 0,
/// <summary>
/// The default staging buffer size of 32MB.
/// </summary>
DSTORAGE_STAGING_BUFFER_SIZE_32MB = 32 * 1048576,
};
/// <summary>
/// Flags used with GetRequests1 when requesting
/// items from the custom decompression queue.
/// </summary>
enum DSTORAGE_GET_REQUEST_FLAGS : UINT32
{
/// <summary>
/// Request entries that use custom decompression formats
/// >= DSTORAGE_CUSTOM_COMPRESSION_0.
/// </summary>
DSTORAGE_GET_REQUEST_FLAG_SELECT_CUSTOM = 0x01,
/// <summary>
/// Request entries that use built in compression formats
/// that DirectStorage understands.
/// </summary>
DSTORAGE_GET_REQUEST_FLAG_SELECT_BUILTIN = 0x02,
/// <summary>
/// Request all entries. This includes custom decompression and
/// built-in compressed formats.
/// </summary>
DSTORAGE_GET_REQUEST_FLAG_SELECT_ALL = (DSTORAGE_GET_REQUEST_FLAG_SELECT_CUSTOM | DSTORAGE_GET_REQUEST_FLAG_SELECT_BUILTIN)
};
DEFINE_ENUM_FLAG_OPERATORS(DSTORAGE_GET_REQUEST_FLAGS);
/// <summary>
/// Specifies information about a custom decompression request.
/// </summary>
enum DSTORAGE_CUSTOM_DECOMPRESSION_FLAGS : UINT32
{
/// <summary>
/// No additional information.
/// </summary>
DSTORAGE_CUSTOM_DECOMPRESSION_FLAG_NONE = 0x00,
/// <summary>
/// The uncompressed destination buffer is located in an
/// upload heap, and is marked as WRITE_COMBINED.
/// </summary>
DSTORAGE_CUSTOM_DECOMPRESSION_FLAG_DEST_IN_UPLOAD_HEAP = 0x01,
};
DEFINE_ENUM_FLAG_OPERATORS(DSTORAGE_CUSTOM_DECOMPRESSION_FLAGS);
/// <summary>
/// A custom decompression request. Use IDStorageCustomDecompressionQueue to
/// retrieve these requests.
/// </summary>
struct DSTORAGE_CUSTOM_DECOMPRESSION_REQUEST {
/// <summary>
/// An identifier provided by DirectStorage. This should be used to
/// identify the request in DSTORAGE_CUSTOM_DECOMPRESSION_RESULT. This
/// identifier is unique among uncompleted requests, but may be reused after
/// a request has completed.
/// </summary>
UINT64 Id;
/// <summary>
/// The compression format. This will be >= DSTORAGE_CUSTOM_COMPRESSION_0
/// if DSTORAGE_CUSTOM_DECOMPRESSION_CUSTOMONLY is used to retrieve requests.
/// </summary>
DSTORAGE_COMPRESSION_FORMAT CompressionFormat;
/// <summary>
/// Reserved for future use.
/// </summary>
UINT8 Reserved[3];
/// <summary>
/// Flags containing additional details about the decompression request.
/// </summary>
DSTORAGE_CUSTOM_DECOMPRESSION_FLAGS Flags;
/// <summary>
/// The size of SrcBuffer in bytes.
/// </summary>
UINT64 SrcSize;
/// <summary>
/// The compressed source buffer.
/// </summary>
void const* SrcBuffer;
/// <summary>
/// The size of DstBuffer in bytes.
/// </summary>
UINT64 DstSize;
/// <summary>
/// The uncompressed destination buffer. SrcBuffer should be decompressed to
/// DstBuffer.
/// </summary>
void* DstBuffer;
};
/// <summary>
/// The result of a custom decompression operation. If the request failed, then
/// the Result code is passed back through the standard DirectStorage
/// status/error reporting mechanism.
/// </summary>
struct DSTORAGE_CUSTOM_DECOMPRESSION_RESULT {
/// <summary>
/// The identifier for the request, from DSTORAGE_CUSTOM_DECOMPRESSION_REQUEST.
/// </summary>
UINT64 Id;
/// <summary>
/// The result of this decompression. S_OK indicates success.
/// </summary>
HRESULT Result;
};
/// <summary>
/// A queue of decompression requests. This can be obtained using QueryInterface
/// against the factory. Your application must take requests from this queue,
/// decompress them, and report that decompression is complete. That allows an
/// application to provide its own custom decompression.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageCustomDecompressionQueue, IUnknown, "97179b2f-2c21-49ca-8291-4e1bf4a160df")
{
/// <summary>
/// Obtains an event to wait on. This event is set when there are pending
/// decompression requests.
/// </summary>
virtual HANDLE STDMETHODCALLTYPE GetEvent() = 0;
/// <summary>
/// Populates the given array of request structs with new pending requests.
/// Your application must arrange to fulfill all these requests, and then
/// call SetRequestResults to indicate completion.
/// <summary>
virtual HRESULT STDMETHODCALLTYPE GetRequests(
_In_ UINT32 maxRequests,
_Out_writes_to_(maxRequests, *numRequests) DSTORAGE_CUSTOM_DECOMPRESSION_REQUEST* requests,
_Out_ UINT32* numRequests) = 0;
/// <summary>
/// Your application calls this to indicate that requests have been
/// completed.
/// </summary>
/// <param name="numResults">The number of results in `results`.</param>
/// <param name="results">An array of results, the size is specified by
/// `numResults.`</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE SetRequestResults(
_In_ UINT32 numResults,
_In_reads_(numResults) DSTORAGE_CUSTOM_DECOMPRESSION_RESULT* results) = 0;
};
/// <summary>
/// An extension of IDStorageCustomDecompressionQueue that allows an
/// application to retrieve specific types of custom decompression
/// requests from the decompression queue.
/// </summary>
DECLARE_INTERFACE_IID_(
IDStorageCustomDecompressionQueue1,
IDStorageCustomDecompressionQueue,
"0D47C6C9-E61A-4706-93B4-68BFE3F4AA4A")
{
/// <summary>
/// Populates the given array of request structs with new pending requests
/// based on the specified custom decompression request type.
/// The application must arrange to fulfill all these requests, and then
/// call SetRequestResults to indicate completion.
/// <summary>
virtual HRESULT STDMETHODCALLTYPE GetRequests1(
_In_ DSTORAGE_GET_REQUEST_FLAGS flags,
_In_ UINT32 maxRequests,
_Out_writes_to_(maxRequests, *numRequests) DSTORAGE_CUSTOM_DECOMPRESSION_REQUEST* requests,
_Out_ UINT32 * numRequests) = 0;
};
/// <summary>
/// Represents the static DirectStorage object used to create DirectStorage
/// queues, open files for DirectStorage access, and other global operations.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageFactory, IUnknown, "6924ea0c-c3cd-4826-b10a-f64f4ed927c1")
{
/// <summary>
/// Creates a DirectStorage queue object.
/// </summary>
/// <param name="desc">Descriptor to specify the properties of the queue.</param>
/// <param name="riid">Specifies the DirectStorage queue interface, such as
/// __uuidof(IDStorageQueue).</param>
/// <param name="ppv">Receives the new queue created.</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE CreateQueue(const DSTORAGE_QUEUE_DESC *desc, REFIID riid, _COM_Outptr_ void **ppv) = 0;
/// <summary>
/// Opens a file for DirectStorage access.
/// </summary>
/// <param name="path">Path of the file to be opened.</param>
/// <param name="riid">Specifies the DirectStorage file interface, such as
/// __uuidof(IDStorageFile).</param>
/// <param name="ppv">Receives the new file opened.</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE OpenFile(_In_z_ const WCHAR *path, REFIID riid, _COM_Outptr_ void **ppv) = 0;
/// <summary>
/// Creates a DirectStorage status array object.
/// </summary>
/// <param name="capacity">Specifies the number of statuses that the array can
/// hold.</param>
/// <param name="name">Specifies object's name that will appear in
// the ETW events if enabled through the debug layer. This is an optional
// parameter.</param>
/// <param name="riid">Specifies the DirectStorage status interface, such as
/// __uuidof(IDStorageStatusArray).</param>
/// <param name="ppv">Receives the new status array object created.</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE CreateStatusArray(UINT32 capacity, _In_opt_ PCSTR name, REFIID riid, _COM_Outptr_ void **ppv) = 0;
/// <summary>
/// Sets flags used to control the debug layer.
/// </summary>
/// <param name="flags">A set of flags controlling the debug layer.</param>
virtual void STDMETHODCALLTYPE SetDebugFlags(UINT32 flags) = 0;
/// <summary>
/// Sets the size of staging buffer(s) used to temporarily store content loaded
/// from the storage device before they are decompressed. If only uncompressed
/// memory sourced queues writing to cpu memory destinations are used, then the
/// staging buffer may be 0-sized.
/// </summary>
/// <param name="size">Size, in bytes, of each staging buffer used
/// to complete a request.</param>
///
/// <remarks>
/// The default staging buffer is DSTORAGE_STAGING_BUFFER_SIZE_32MB.
/// If multiple staging buffers are necessary to complete a request, then each
/// separate staging buffer is allocated to this staging buffer size.
///
/// If the destination is a GPU resource, then some but not all of the staging
/// buffers will be allocated from VRAM.
///
/// Requests that exceed the specified size to SetStagingBufferSize will fail.
/// </remarks>
virtual HRESULT STDMETHODCALLTYPE SetStagingBufferSize(UINT32 size) = 0;
};
/// <summary>
/// Represents an array of status entries to receive completion results for the
/// read requests before them.
/// </summary>
/// <remarks>
/// A status entry receives completion status for all the requests in the
/// DStorageQueue between where it is enqueued and the previously enqueued
/// status entry. Only when all requests enqueued before the status entry
/// complete (that is, IsComplete for the entry returns true), the status entry
/// can be enqueued again.
/// </remarks>
DECLARE_INTERFACE_IID_(IDStorageStatusArray, IUnknown, "82397587-7cd5-453b-a02e-31379bd64656")
{
/// <summary>
/// Returns a Boolean value indicating that all requests enqueued prior to the
/// specified status entry have completed.
/// </summary>
/// <param name="index">Specifies the index of the status entry to retrieve.</param>
/// <returns>Boolean value indicating completion.</returns>
/// <remarks>This is equivalent to `GetHResult(index) != E_PENDING`.</remarks>
virtual bool STDMETHODCALLTYPE IsComplete(UINT32 index) = 0;
/// <summary>
/// Returns the HRESULT code of all requests between the specified status
/// entry and the status entry enqueued before it.
/// </summary>
/// <param name="index">Specifies the index of the status entry to retrieve.</param>
/// <returns>HRESULT code of the requests.</returns>
/// <remarks>
/// <list type="bullet">
/// <item><description>
/// If any requests have not completed yet, the return value is E_PENDING.
/// </description></item>
/// <item><description>
/// If all requests have completed, and there were failure(s), then the return
/// value stores the failure code of the first failed request in the enqueue
/// order.
/// </description></item>
/// <item><description>
/// If all requests have completed successfully, then the return value is S_OK.
/// </description></item>
/// </list>
/// </remarks>
virtual HRESULT STDMETHODCALLTYPE GetHResult(UINT32 index) = 0;
};
/// <summary>
/// Represents a DirectStorage queue to perform read operations.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageQueue, IUnknown, "cfdbd83f-9e06-4fda-8ea5-69042137f49b")
{
/// <summary>
/// Enqueues a read request to the queue. The request remains in the queue
/// until Submit is called, or until the queue is half full.
/// If there are no free entries in the queue, then the enqueue operation
/// blocks until one becomes available.
/// </summary>
/// <param name="request">The read request to be queued.</param>
virtual void STDMETHODCALLTYPE EnqueueRequest(const DSTORAGE_REQUEST *request) = 0;
/// <summary>
/// Enqueues a status write. The status write happens when all requests
/// before the status write entry complete. If there were failure(s)
/// since the previous status write entry, then the HResult of the enqueued
/// status entry stores the failure code of the first failed request in the
/// enqueue order.
/// If there are no free entries in the queue, then the enqueue operation
/// blocks until one becomes available.
/// </summary>
/// <param name="statusArray">IDStorageStatusArray object.</param>
/// <param name="index">Index of the status entry in the
/// IDStorageStatusArray object to receive the status.</param>
virtual void STDMETHODCALLTYPE EnqueueStatus(IDStorageStatusArray *statusArray, UINT32 index) = 0;
/// <summary>
/// Enqueues fence write. The fence write happens when all requests before
/// the fence entry complete.
/// If there are no free entries in the queue, then the enqueue operation will
/// block until one becomes available.
/// </summary>
/// <param name="fence">An ID3D12Fence to be written.</param>
/// <param name="value">The value to write to the fence.</param>
virtual void STDMETHODCALLTYPE EnqueueSignal(ID3D12Fence *fence, UINT64 value) = 0;
/// <summary>
/// Submits all requests enqueued so far to DirectStorage to be executed.
/// </summary>
virtual void STDMETHODCALLTYPE Submit() = 0;
/// <summary>
/// Attempts to cancel a group of previously enqueued read requests. All
/// previously enqueued requests whose CancellationTag matches the formula
/// (CancellationTag & mask) == value will be cancelled.
/// A cancelled request might or might not complete its original read request.
/// A cancelled request is not counted as a failure in either
/// IDStorageStatus or DSTORAGE_ERROR_RECORD.
/// </summary>
/// <param name="mask">The mask for the cancellation formula.</param>
/// <param name="value">The value for the cancellation formula.</param>
virtual void STDMETHODCALLTYPE CancelRequestsWithTag(UINT64 mask, UINT64 value) = 0;
/// <summary>
/// Closes the DirectStorage queue, regardless of the reference count on this
/// object.
///
/// After the Close function returns, the queue will no longer complete any
/// more requests, even if some are submitted. This does not modify the
/// reference count on this object; Release() must be called as usual.
/// </summary>
virtual void STDMETHODCALLTYPE Close() = 0;
/// <summary>
/// Obtains an event to wait on. When there is any error happening for read
/// requests in this queue, the event will be signaled, and you may call
/// RetrieveErrorRecord to retrieve diagnostic information.
/// </summary>
/// <returns>HANDLE to an event.</returns>
virtual HANDLE STDMETHODCALLTYPE GetErrorEvent() = 0;
/// <summary>
/// When the error event is signaled, this function can be called to
/// retrieve a DSTORAGE_ERROR_RECORD. Once the error record is retrieved,
/// this function should not be called until the next time the error event
/// is signaled.
/// </summary>
/// <param name="record">Receives the error record.</param>
virtual void STDMETHODCALLTYPE RetrieveErrorRecord(_Out_ DSTORAGE_ERROR_RECORD *record) = 0;
/// <summary>
/// Obtains information about the queue. It includes the DSTORAGE_QUEUE_DESC
/// structure used for the queue's creation as well as the number of empty slots
/// and number of entries that need to be enqueued to trigger automatic
/// submission.
/// </summary>
/// <param name="info">Receives the queue information.</param>
virtual void STDMETHODCALLTYPE Query(_Out_ DSTORAGE_QUEUE_INFO *info) = 0;
};
/// <summary>
/// Represents a DirectStorage queue to perform read operations.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageQueue1, IDStorageQueue, "dd2f482c-5eff-41e8-9c9e-d2374b278128")
{
/// <summary>
/// Enqueues an operation to set the specified event object to a signaled state.
/// The event object is set when all requests before it complete.
/// If there are no free entries in the queue the enqueue operation will
/// block until one becomes available.
/// </summary>
/// <param name="handle">A handle to an event object.</param>
virtual void STDMETHODCALLTYPE EnqueueSetEvent(HANDLE handle) = 0;
};
/// <summary>
/// Flags returned with GetCompressionSupport that describe the features
/// used by the runtime to decompress content.
/// </summary>
enum DSTORAGE_COMPRESSION_SUPPORT : UINT32
{
/// <summary>
/// None
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_NONE = 0x0,
/// <summary>
/// Optimized driver support for GPU decompression will be used.
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_GPU_OPTIMIZED = 0x01,
/// <summary>
/// Built-in GPU decompression fallback shader will be used. This can occur if
/// optimized driver support is not available and the D3D12 device used for this
/// DirectStorage queue supports the required capabilities.
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_GPU_FALLBACK = 0x02,
/// <summary>
/// CPU fallback implementation will be used.
/// This can occur if:
/// * Optimized driver support and built-in GPU decompression is not available.
/// * GPU decompression support has been explicitly disabled using
/// DSTORAGE_CONFIGURATION.
/// * DirectStorage runtime encounters a failure during initialization of its
/// GPU decompression system.
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_CPU_FALLBACK = 0x04,
/// <summary>
/// Executes work on a compute queue.
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_USES_COMPUTE_QUEUE = 0x08,
/// <summary>
/// Executes work on a copy queue.
/// </summary>
DSTORAGE_COMPRESSION_SUPPORT_USES_COPY_QUEUE = 0x010,
};
DEFINE_ENUM_FLAG_OPERATORS(DSTORAGE_COMPRESSION_SUPPORT);
/// <summary>
/// Represents a DirectStorage queue to perform read operations.
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageQueue2, IDStorageQueue1, "b1c9d643-3a49-44a2-b46f-653649470d18")
{
/// <summary>
/// Obtains support information about the queue for a specified compression format.
/// It includes the chosen path that the DirectStorage runtime will use for decompression.
/// </summary>
/// <param name="format">Specifies the compression format to retrieve information
/// about.</param>
virtual DSTORAGE_COMPRESSION_SUPPORT STDMETHODCALLTYPE GetCompressionSupport(DSTORAGE_COMPRESSION_FORMAT format) = 0;
};
/// <summary>
/// Disables built-in decompression.
///
/// Set NumBuiltInCpuDecompressionThreads in DSTORAGE_CONFIGURATION to
/// this value to disable built-in decompression. No decompression threads
/// will be created and the title is fully responsible for checking
/// the custom decompression queue and pulling off ALL entries to decompress.
/// </summary>
#define DSTORAGE_DISABLE_BUILTIN_CPU_DECOMPRESSION -1
/// <summary>
/// DirectStorage Configuration. Zero initializing this will result in the default values.
/// </summary>
struct DSTORAGE_CONFIGURATION {
/// <summary>
/// Sets the number of threads to use for submitting IO operations.
/// Specifying 0 means use the system's best guess at a good value.
/// Default == 0.
/// </summary>
UINT32 NumSubmitThreads;
/// <summary>
/// Sets the number of threads to be used by the DirectStorage runtime to
/// decompress data using the CPU for built-in compressed formats
/// that cannot be decompressed using the GPU.
///
/// Specifying 0 means to use the system's best guess at a good value.
///
/// Specifying DSTORAGE_DISABLE_BUILTIN_CPU_DECOMPRESSION means no decompression
/// threads will be created and the title is fully responsible for checking
/// the custom decompression queue and pulling off ALL entries to decompress.
///
/// Default == 0.
/// </summary>
INT32 NumBuiltInCpuDecompressionThreads;
/// <summary>
/// Forces the use of the IO mapping layer, even when running on an
/// operation system that doesn't require it. This may be useful during
/// development, but should be set to the FALSE for release. Default=FALSE.
/// </summary>
BOOL ForceMappingLayer;
/// <summary>
/// Disables the use of the bypass IO optimization, even if it is available.
/// This might be useful during development, but should be set to FALSE
/// for release unless ForceFileBuffering is set to TRUE.
/// Default == FALSE.
/// </summary>
BOOL DisableBypassIO;
/// <summary>
/// Disables the reporting of telemetry data when set to TRUE.
/// Telemetry data is enabled by default in the DirectStorage runtime.
/// Default == FALSE.
/// </summary>
BOOL DisableTelemetry;
/// <summary>
/// Disables the use of a decompression metacommand, even if one
/// is available. This will force the runtime to use the built-in GPU decompression
/// fallback shader.
/// This may be useful during development, but should be set to the FALSE
/// for release. Default == FALSE.
/// </summary>
BOOL DisableGpuDecompressionMetacommand;
/// <summary>
/// Disables the use of GPU based decompression, even if it is available.
/// This will force the runtime to use the CPU. Default=FALSE.
/// </summary>
BOOL DisableGpuDecompression;
};
/// <summary>
/// DirectStorage Configuration. Zero initializing this will result in the default values.
/// </summary>
struct DSTORAGE_CONFIGURATION1
{
/// <summary>
/// Sets the number of threads to use for submitting IO operations.
/// Specifying 0 means use the system's best guess at a good value.
/// Default == 0.
/// </summary>
UINT32 NumSubmitThreads;
/// <summary>
/// Sets the number of threads to be used by the DirectStorage runtime to
/// decompress data using the CPU for built-in compressed formats
/// that cannot be decompressed using the GPU.
///
/// Specifying 0 means to use the system's best guess at a good value.
///
/// Specifying DSTORAGE_DISABLE_BUILTIN_CPU_DECOMPRESSION means no decompression
/// threads will be created and the title is fully responsible for checking
/// the custom decompression queue and pulling off ALL entries to decompress.
///
/// Default == 0.
/// </summary>
INT32 NumBuiltInCpuDecompressionThreads;
/// <summary>
/// Forces the use of the IO mapping layer, even when running on an
/// operation system that doesn't require it. This may be useful during
/// development, but should be set to the FALSE for release. Default=FALSE.
/// </summary>
BOOL ForceMappingLayer;
/// <summary>
/// Disables the use of the bypass IO optimization, even if it is available.
/// This might be useful during development, but should be set to FALSE
/// for release unless ForceFileBuffering is set to TRUE.
/// Default == FALSE.
/// </summary>
BOOL DisableBypassIO;
/// <summary>
/// Disables the reporting of telemetry data when set to TRUE.
/// Telemetry data is enabled by default in the DirectStorage runtime.
/// Default == FALSE.
/// </summary>
BOOL DisableTelemetry;
/// <summary>
/// Disables the use of a decompression metacommand, even if one
/// is available. This will force the runtime to use the built-in GPU decompression
/// fallback shader.
/// This may be useful during development, but should be set to the FALSE
/// for release. Default == FALSE.
/// </summary>
BOOL DisableGpuDecompressionMetacommand;
/// <summary>
/// Disables the use of GPU based decompression, even if it is available.
/// This will force the runtime to use the CPU. Default=FALSE.
/// </summary>
BOOL DisableGpuDecompression;
/// <summary>
/// Forces the use of the built-in file caching behaviors supported
/// within the Windows operating system by not setting
/// FILE_FLAG_NO_BUFFERING when opening files.
///
/// DisableBypassIO must be set to TRUE when using this option or
/// E_DSTORAGE_FILEBUFFERING_REQUIRES_DISABLED_BYPASSIO will be returned.
///
/// It is the title's responsibility to know when to use this setting.
/// This feature should ONLY be enabled for slower HDD drives that will
/// benefit from the OS file buffering features.
///
/// WARNING: Enabling file buffering on high speed drives may reduce
/// overall performance when reading from that drive because BypassIO
/// is also disabled. Default=FALSE.
/// </summary>
BOOL ForceFileBuffering;
};
/// <summary>
/// Settings controlling DirectStorage compression codec behavior.
/// </summary>
enum DSTORAGE_COMPRESSION : INT32 {
/// <summary>
/// Compress data at a fast rate which may not yield the best
/// compression ratio.
/// </summary>
DSTORAGE_COMPRESSION_FASTEST = -1,
/// <summary>
/// Compress data at an average rate with a good compression ratio.
/// </summary>
DSTORAGE_COMPRESSION_DEFAULT = 0,
/// <summary>
/// Compress data at slow rate with the best compression ratio.
/// </summary>
DSTORAGE_COMPRESSION_BEST_RATIO = 1
};
/// <summary>
/// Represents the DirectStorage object for compressing and decompressing the buffers.
///
/// Use DStorageCreateCompressionCodec to get an instance of this.
///
/// </summary>
DECLARE_INTERFACE_IID_(IDStorageCompressionCodec, IUnknown, "84ef5121-9b43-4d03-b5c1-cc34606b262d")
{
/// <summary>
/// Compresses a buffer of data using a known compression format at the specifed
/// compression level.
/// </summary>
/// <param name="uncompressedData">Points to a buffer containing uncompressed data.</param>
/// <param name="uncompressedDataSize">Size, in bytes, of the uncompressed data buffer.</param>
/// <param name="compressionSetting">Specifies the compression settings to use.</param>
/// <param name="compressedBuffer">Points to a buffer where compressed data will be
/// written.</param>
/// <param name="compressedBufferSize">Size, in bytes, of the buffer which will receive
/// the compressed data</param>
/// <param name="compressedDataSize">Size, in bytes, of the actual size written to compressedBuffer</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE CompressBuffer(
const void* uncompressedData,
size_t uncompressedDataSize,
DSTORAGE_COMPRESSION compressionSetting,
void* compressedBuffer,
size_t compressedBufferSize,
size_t* compressedDataSize) = 0;
/// <summary>
/// Decompresses data previously compressed using CompressBuffer.
/// </summary>
/// <param name="compressedData">Points to a buffer containing compressed data.</param>
/// <param name="compressedDataSize">Size, in bytes, of the compressed data buffer.</param>
/// <param name="uncompressedBuffer">Points to a buffer where uncompressed data will be
/// written.</param>
/// <param name="uncompressedBufferSize">Size, in bytes, of the buffer which will receive
/// the uncompressed data</param>
/// <param name="uncompressedDataSize">Size, in bytes, of the actual size written to uncompressedBuffer</param>
/// <returns>Standard HRESULT error code.</returns>
virtual HRESULT STDMETHODCALLTYPE DecompressBuffer(
const void* compressedData,
size_t compressedDataSize,
void* uncompressedBuffer,
size_t uncompressedBufferSize,
size_t* uncompressedDataSize) = 0;
/// <summary>
/// Returns an upper bound estimated size in bytes required to compress the specified data size.
/// </summary>
/// <param name="uncompressedDataSize">Size, in bytes, of the data to be compressed</param>
virtual size_t STDMETHODCALLTYPE CompressBufferBound(size_t uncompressedDataSize) = 0;
};
extern "C" {
/// <summary>
/// Configures DirectStorage. This must be called before the first call to
/// DStorageGetFactory. If this is not called, then default values are used.
/// </summary>
/// <param name="configuration">Specifies the configuration.</param>
/// <returns>Standard HRESULT error code. The configuration can only be changed
/// when no queue is created and no files are open,
/// E_DSTORAGE_STAGING_BUFFER_LOCKED is returned if this is not the case.</returns>
HRESULT WINAPI DStorageSetConfiguration(DSTORAGE_CONFIGURATION const* configuration);
/// <summary>
/// Configures DirectStorage. This must be called before the first call to
/// DStorageGetFactory. If this is not called, then default values are used.
/// </summary>
/// <param name="configuration">Specifies the configuration.</param>
/// <returns>Standard HRESULT error code. The configuration can only be changed
/// when no queue is created and no files are open,
/// E_DSTORAGE_STAGING_BUFFER_LOCKED is returned if this is not the case.</returns>
HRESULT WINAPI DStorageSetConfiguration1(DSTORAGE_CONFIGURATION1 const* configuration);
/// <summary>
/// Returns the static DirectStorage factory object used to create DirectStorage queues,
/// open files for DirectStorage access, and other global operations.
/// </summary>
/// <param name="riid">Specifies the DirectStorage factory interface, such as
/// __uuidof(IDStorageFactory)</param>
/// <param name="ppv">Receives the DirectStorage factory object.</param>
/// <returns>Standard HRESULT error code.</returns>
HRESULT WINAPI DStorageGetFactory(REFIID riid, _COM_Outptr_ void** ppv);
/// <summary>
/// Returns an object used to compress/decompress content.
/// Compression codecs are not thread safe so multiple
/// instances are required if the codecs need to be used
/// by multiple threads.
/// </summary>
/// <param name="format">Specifies how the data is compressed.</param>
/// <param name="numThreads">Specifies maximum number of threads this codec
/// will use. Specifying 0 means to use the system's best guess at a good value.</param>
/// <param name="riid">Specifies the DirectStorage compressor/decompressor interface, such as
/// __uuidof(IDStorageCompressionCodec)</param>
/// <param name="ppv">Receives the DirectStorage object.</param>
/// <returns>Standard HRESULT error code.</returns>
HRESULT WINAPI DStorageCreateCompressionCodec(DSTORAGE_COMPRESSION_FORMAT format, UINT32 numThreads, REFIID riid, _COM_Outptr_ void** ppv);
}
|