Graphics Reference
In-Depth Information
D3D11_SHADER_DESC shaderDesc;
shaderReflection->GetDesc( &shaderDesc );
const UINT numCBuffers = shaderDesc.ConstantBuffers;
for ( UINT i = 0; i < numCBuffers; i++ )
{
ID3DllShaderReflectionConstantBuffer* cbReflection = NULL;
cbReflection = shaderReflection->GetConstantBufferByIndex( i );
// Query constant buffer interface for information
}
Listing 6.25. Retrieving constant buffer reflection interfaces.
Like the ID3D11ShaderReflection interface, the ID3D11ShaderReflectionConstant
Buffer interface provides a GetDesc method that returns a structure containing general
information. In this case, GetDesc returns a D3D11_SHADER_BUFFER_DESC structure, whose
declaration is shown in Listing 6.26.
struct D3D11_SHADER_BUFFER_DESC {
LPCSTR Name;
D3D11_CBUFFER_TYPE Type;
UINT
Variables;
UINT
Size;
UINT
uFlags;
}
Listing 6.26. The D3D11_SHADER_BUFFER_DESC structure.
The main members of interest in the D3D11_SHADER_BUFFER_DESC structure are Size
and Variables. The Size member indicates the total size of all constants in the constant
buffer, and can be used to initialize an ID3D11Buffer containing the actual constant data
bound to the pipeline at runtime. The Variables member indicates the number of constants
within the constant buffer, and can be used in conjunction with GetVariableBylndex to
enumerate all individual constants within the constant buffer.
6.8.3 Variable Information
Information for individual constants in a constant buffer is available through the ID3D11
ShaderReflectionVariable interface, which can be obtained by calling the Get
VariableBylndex or GetVariableByName methods on an ID3DllShaderReflection
ConstantBuffer interface. It can also be obtained for any global variable in a shader
Search WWH ::




Custom Search