PFND3DDDI_CREATEQUERY callback function

The CreateQuery function creates driver-side resources for a query that the Microsoft Direct3D runtime subsequently issues for processing.



__checkReturn HRESULT APIENTRY CreateQuery(
  _In_    HANDLE                hDevice,
{ ... }


hDevice [in]

A handle to the display device (graphics context).

pData [in, out]

A pointer to a D3DDDIARG_CREATEQUERY structure that identifies the query.

Return value

CreateQuery returns one of the following values:

Return codeDescription

The query is successfully created.


CreateQuery could not allocate the required memory for it to complete.



The Direct3D runtime calls the user-mode display driver's CreateQuery function with a query type to create resources for a query. The user-mode display driver creates the following resources for query types:

  • BOOL for D3DDDIQUERYTYPE_EVENT. Before responding about an event, the driver must ensure that the graphics processing unit (GPU) is finished processing all of the operations that are related to the event. That is, the driver responds about an event after the issue end state occurs. The driver must always set the event's BOOL value to TRUE when responding.

  • UINT for D3DDDIQUERYTYPE_OCCLUSION. The driver sets this UINT variable to the number of pixels for which the z-test passed for all of the primitives between the beginning and end states of the issue query. If the depth buffer is multisampled, the driver determines the number of pixels from the number of samples. However, if the display device is capable of z-test accuracy for each multisample, the conversion to number of pixels should generally be rounded up. An application can then check the occlusion result against 0, to effectively mean "fully occluded." Drivers that convert multisampled quantities to pixel quantities should detect render target multisampling changes and continue to compute the query results appropriately.

  • A D3DDDIDEVINFO_VCACHE structure for D3DDDIQUERYTYPE_VCACHE. The driver responds after the issue end state occurs.

For more information about issue query states, see D3DDDI_ISSUEQUERYFLAGS.


Target platform


Available in Windows Vista and later versions of the Windows operating systems.


D3dumddi.h (include D3dumddi.h)

See also




Send comments about this topic to Microsoft