Sets up an occlusion or StreamOut (SO) overflow predication on an arbitrary buffer.
public:
void SetPredicationFromQuery(
D3D11_QUERY QueryType,
ID3D11Buffer *pBuffer,
UINT OffsetInBytes,
UINT Flags
)
QueryType
Type: D3D11_QUERY
[in] The query type, as a D3D11_QUERY enumeration constant.
pBuffer
Type: ID3D11Buffer *
[in] The buffer, as a pointer to ID3D11Buffer.
OffsetInBytes
Type: UINT
[in] The offset within the buffer, in bytes.
Flags
Type: UINT
[in] Options to control this method, as a bitwise-OR’d combination of D3D11X_SET_PREDICATION_FROM_QUERY_FLAG enumeration constants.
Use SetPredicationFromQuery in conjunction with ID3D11DeviceContextX::WriteQuery. SetPredicationFromQuery directly supports the output format of the WriteQuery method.
WriteQuery makes each Depth Block (DB) to write the number of passed pixels into memory. Each written result is 64 bits long, with the top bit representing a valid query. If the top bit is set, then the query is valid; if the top bit is not set, then the query is invalid. When the stride is set to 256 bytes, each DB’s result is offset by 8 bytes from the previous results; for example:
That is, the two calls of WriteQuery write interleaved results. The Xbox One X writes an additional four UINT64 values representing its additional Depth Block values.
For occlusion queries, SetPredicationFromQuery takes the results of the two WriteQuery DB writes, and makes the GPU set predication based on whether the results for all DBs are the same.
Example:
// Prepare
D3D11X_QUERY_CONFIG_OCCLUSION occ;
occ.Samples = 0;
occ.DisableOptimizationsForCountAccuracy = FALSE;
occ.Counter[ 0 ].EnableEvenTargets = 1;
occ.Counter[ 0 ].EnableOddTargets = 1;
occ.Counter[ 0 ].Flags = D3D11X_QUERY_CONFIG_OCCLUSION_COUNT_DEPTH_PASS;
occ.Counter[ 1 ].EnableEvenTargets = 1;
occ.Counter[ 1 ].EnableOddTargets = 1;
occ.Counter[ 1 ].Flags = D3D11X_QUERY_CONFIG_OCCLUSION_COUNT_DEPTH_PASS;
pCtx->ConfigureQuery( D3D11_QUERY_OCCLUSION, &occ, sizeof( occ ) );
pCtx->ResetQuery( D3D11_QUERY_OCCLUSION, 0, 0 );
// Write queries
pCtx->WriteQuery( D3D11_QUERY_OCCLUSION, 0, 0, pBuf, 0, 256 );
Draw...
pCtx->WriteQuery( D3D11_QUERY_OCCLUSION, 0, 0, pBuf, 8, 256 );
// Predicate based on queries
pCtx->SetPredicationFromQuery( D3D11_QUERY_OCCLUSION, pBuf, 0, D3D11X_SET_PREDICATION_FROM_QUERY_SKIP_IF_VISIBLE | D3D11X_SET_PREDICATION_FROM_QUERY_HINT_WAIT_IF_PENDING );
Draw...
pCtx->SetPredicationFromQuery( D3D11_QUERY_OCCLUSION, nullptr, 0, 0 );
Header: Declared in d3d11_x.h.
Library: Use d3d11_x.lib.