Extracting Data from a Query

[This documentation is preliminary and is subject to change.]

The way to extract data from a query is to use the ResolveQueryData method. ResolveQueryData works with all heap types (default, upload, and readback). 


ResolveQueryData performs a batched operation which writes query data into a destination buffer. Query data is written contiguously to the destination buffer, and the parameter AlignedDestinationBufferOffset must be a multiple of 8 bytes. The destination buffer must be in the D3D12_RESOURCE_USAGE_COPY_DEST state.

Binary occlusion queries write 64-bits per query. The least significant bit is either 0 or 1. The rest of the bits are 0.

The core runtime will validate the following:

  • StartElement and ElementCount are within range
  • AlignedDestinationBufferOffset is a multiple of 8 bytes
  • DestinationBuffer is a buffer
  • The written data will not overflow the output buffer
  • The query type must be supported by the command list type
  • The query type must be supported by the query heap

The debug layer will issue a warning if the destination buffer is not in the D3D12_RESOURCE_USAGE_COPY_DEST state.

Related topics

Counters and Queries