Expand Minimize

CreateComputeShader routine

The CreateComputeShader function creates a compute shader.



VOID APIENTRY CreateComputeShader(
  _In_       D3D10DDI_HDEVICE   hDevice,
  _In_ const UINT               *pCode,
  _In_       D3D10DDI_HSHADER   hShader,
  _In_       D3D10DDI_HRTSHADER hRTShader
{ ... }


hDevice [in]

A handle to the display device (graphics context).

pCode [in]

An array of CONST UINT tokens that form the shader code. The first token in the shader code stream is always the version token. The next token in the stream is the length token that determines the end of the shader code stream. For more information about the format of Direct3D version 11 shader code, see the comments inside the D3d11tokenizedprogramformat.hpp header file that is included with the WDK.

hShader [in]

A handle to the driver's private data for the compute shader. The driver returns the size, in bytes, of the memory region that the Microsoft Direct3D runtime must allocate for the private data from a call to the driver's CalcPrivateShaderSize function. The handle is just a pointer to a region of memory, the size of which the driver requested. The driver uses this region of memory to store internal data structures that are related to its shader object.

hRTShader [in]

A handle to the compute shader that the driver should use when it calls back into the Direct3D runtime.

Return value


The driver can use the pfnSetErrorCb callback function to set an error code. For more information about setting error codes, see the following Remarks section.


The driver can pass E_OUTOFMEMORY (if the driver runs out of memory) or D3DDDIERR_DEVICEREMOVED (if the device is removed) in a call to the pfnSetErrorCb function. The Direct3D runtime determines that any other errors are critical. If the driver passes any errors, which includes D3DDDIERR_DEVICEREMOVED, the Direct3D runtime determines that the handle is invalid; therefore, the runtime does not call the DestroyShader function to destroy the handle that the hShader parameter specifies.


Target platform



CreateComputeShader is supported beginning with the Windows 7 operating system.


D3d10umddi.h (include D3d10umddi.h)

See also




Send comments about this topic to Microsoft

© 2015 Microsoft