ID3D11Device::CreateGeometryShader method (d3d11.h)
Create a geometry shader.
Syntax
HRESULT CreateGeometryShader(
[in] const void *pShaderBytecode,
[in] SIZE_T BytecodeLength,
[in, optional] ID3D11ClassLinkage *pClassLinkage,
[out, optional] ID3D11GeometryShader **ppGeometryShader
);
Parameters
[in] pShaderBytecode
Type: const void*
A pointer to the compiled shader.
[in] BytecodeLength
Type: SIZE_T
Size of the compiled geometry shader.
[in, optional] pClassLinkage
Type: ID3D11ClassLinkage*
A pointer to a class linkage interface (see ID3D11ClassLinkage); the value can be NULL.
[out, optional] ppGeometryShader
Type: ID3D11GeometryShader**
Address of a pointer to a ID3D11GeometryShader interface. If this is NULL, all other parameters will be validated, and if all parameters pass validation this API will return S_FALSE instead of S_OK.
Return value
Type: HRESULT
This method returns one of the following Direct3D 11 Return Codes.
Remarks
After it is created, the shader can be set to the device by calling ID3D11DeviceContext::GSSetShader.
The Direct3D 11.1 runtime, which is available starting with Windows 8, provides the following new functionality for CreateGeometryShader.
The following shader model 5.0 instructions are available to just pixel shaders and compute shaders in the Direct3D 11.0 runtime. For the Direct3D 11.1 runtime, because unordered access views (UAV) are available at all shader stages, you can use these instructions in all shader stages.
Therefore, if you use the following shader model 5.0 instructions in a geometry shader, you can successfully pass the compiled geometry shader to pShaderBytecode. That is, the call to CreateGeometryShader succeeds.
If you pass a compiled shader to pShaderBytecode that uses any of the following instructions on a device that doesn’t support UAVs at every shader stage (including existing drivers that are not implemented to support UAVs at every shader stage), CreateGeometryShader fails. CreateGeometryShader also fails if the shader tries to use a UAV slot beyond the set of UAV slots that the hardware supports.
- dcl_uav_typed
- dcl_uav_raw
- dcl_uav_structured
- ld_raw
- ld_structured
- ld_uav_typed
- store_raw
- store_structured
- store_uav_typed
- sync_uglobal
- All atomics and immediate atomics (for example, atomic_and and imm_atomic_and)
Examples
Usage Example
ID3D11GeometryShader* g_pGeometryShader11 = NULL;
ID3DBlob* pGeometryShaderBuffer = NULL;
ID3DBlob * errorbuffer = NULL;
D3DX11CompileFromFile( str, NULL, NULL, "GS", "gs_4_0", dwShaderFlags, 0, NULL,
&pGeometryShaderBuffer, &errorbuffer, NULL );
pd3dDevice->CreateGeometryShader( pGeometryShaderBuffer->GetBufferPointer(),
pGeometryShaderBuffer->GetBufferSize(), NULL, &g_pGeometryShader11 );
Requirements
Requirement | Value |
---|---|
Target Platform | Windows |
Header | d3d11.h |
Library | D3D11.lib |