ID3D11DeviceContextX::SetPredicationBuffer Method

Sets the predication buffer.

Syntax

public:
void SetPredicationBuffer(
         ID3D11Buffer *pBuffer,
         UINT Offset,
         UINT Flags
)  

Parameters

pBuffer
Type: ID3D11Buffer *

[in, optional] A buffer of any kind. Pass NULL to disable predication.

Offset
Type: UINT 

[in] The offset, in bytes, from the start of the buffer that should be read to determine predication.

Flags
Type: UINT 

[in] Flags to control this method, defined in the D3D11X_SET_PREDICATION_BUFFER_FLAG enumeration. Can be zero or D3D11X_SET_PREDICATION_BUFFER_NO_HAZARD_TRACKING. The use of D3D11X_SET_PREDICATION_BUFFER_NO_HAZARD_TRACKING disables the automatic pipeline synchronization and GPU cache flush that Direct3D does the first time this API is called after the buffer is modified by the GPU. The recommended value is zero, because the hazard check is very lightweight for both CPU and GPU on calls subsequent to any modification and ensures proper coherency and synchronization between the GPU Command Processor and the Compute Shader that updates the buffer for the first call after modification.

Return value

None.

Remarks

This method works with Command Lists, but doing so forces ExecuteCommandList to do the INDIRECT_BUFFER calls at the Primary Ring Buffer level instead of the usual Indirect Buffer 1 level – there is some CPU and GPU performance penalty associated with this.

This method will cause the GPU Command Processor to read the 32-bit value at the specified offset in the buffer and set its Predication state appropriately. If the 32-bit value is zero, then subsequent Draw calls will not draw. If the 32-bit value is non-zero, then subsequent Draw calls will draw.

An example use of this method is to have a Compute Shader that calculates visibility on a per-Draw basis and write the results to this predication buffer. This can then save GPU overhead by not doing vertex processing on Draw calls that are non-visible.

Unlike other Set methods, SetPredicationBuffer does not hold a reference to the specified buffer once the call has completed. Consequently, there is no GetPredicationBuffer API.

Calling the regular SetPredication method will overwrite this predication value.

Requirements

Header: Declared in d3d11_x.h.

Library: Use d3d11_x.lib.

See also

Reference

ID3D11DeviceContextX Interface

ID3D11DeviceContextX Members