Graphics Reference
In-Depth Information
program by calling GetVariableByName on an ID3DllShaderReflectionInterface.
Global variables include not just constants, but also resource objects, samplers, and inter-
face instances. The GetDesc method of the ID3DllShaderReflectionVariable interface
returns a D3D11_SHADER_VARIABLE_DESC structure, which contains general information
about the variable. The declaration of this structure is listed in Listing 6.27.
Struct D3D11_SHADER_VARIABLE_DESC {
LPCSTR Name;
UINT StartOffset;
UINT Size;
UINT uFlags;
LPVOID DefaultValue;
}
Listing 6.27. The D3D11_SHADER_VARIABLE_DESC structure.
The Name member contains a string indicating the name of the variable in the HLSL
source code. This value is useful for creating a system of allowing constant values to be set
at runtime via by a string containing the name of the value. StartOffset and Size contain
the offset in bytes from the start of the constant buffer, and the size of the value in bytes.
These can be used to memcpy a value intended for specific constant into the correct portion
of a mapped buffer. The DefaultValue member contains the value that a constant was
initialized to in the shader source code, if one was provided. It is typically used to initialize
the contents of a constant buffer when it is first created.
If the ID3D11ShaderReflectionVariable represents an interface instance, the
GetInterfaceSlot method can be called to query the interface slot for that variable. This
value indicates the array index that should be used for this particular interface when pass-
ing the array of class instances to a *SSetShader method.
6.8.4 Type Information
Type information for a variable can be queried by obtaining an ID3D11ShaderReflection
Type interface, which is obtained by calling GetType on the ID3D11Shader
ReflectionVariable interface for a variable. Calling GetDesc on this interface returns
a D3D11_SHADER_TYPE_DESC structure, which contains general information regarding the
type of the variable. The declaration of this structure is available in Listing 6.28.
 
Search WWH ::




Custom Search