以下是 ID3D12ShaderReflection 接口的定义:
DECLARE_INTERFACE(ID3D12ShaderReflection)
{
STDMETHOD(GetDesc)(
THIS_
_Out_ D3D12_SHADER_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(
THIS_
_In_ UINT Index) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(
THIS_
_In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(
THIS_
_In_ UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetInputParameterDesc)(
THIS_
_In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetOutputParameterDesc)(
THIS_
_In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetPatchConstantParameterDesc)(
THIS_
_In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetVariableTypeByIndex)(
THIS_
_In_ UINT Index) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetVariableTypeByName)(
THIS_
_In_ LPCSTR Name) PURE;
STDMETHOD(GetVariableNameByIndex)(
THIS_
_In_ UINT Index,
_Out_ LPCSTR *ppName) PURE;
STDMETHOD(GetResourceBindingDescByName)(
THIS_
_In_ LPCSTR Name,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD_(UINT, GetMovcInstructionCount)(
THIS) PURE;
STDMETHOD_(UINT, GetMovcInstruction(
THIS_
_In_ UINT Index,
_Out_ LPCSTR *ppInstruction)) PURE;
STDMETHOD_(UINT, GetMovcInstructionAtInputRegisterIndex)(
THIS_
_In_ UINT Index,
_Out_ UINT *pInputRegisterIndex) PURE;
STDMETHOD_(LPCSTR, GetMovcInstructionInputRegisterName)(
THIS_
_In_ UINT Index) PURE;
STDMETHOD(GetMovcInstructionRegisterType)(
THIS_
_In_ UINT Index,
_Out_ D3D12_SHADER_REGISTER_TYPE *pRegisterType) PURE;
STDMETHOD(GetMovcInstructionOperandType)(
THIS_
_In_ UINT Index,
_Out_ D3D12_SHADER_OPERAND_TYPE *pOperandType) PURE;
STDMETHOD(GetMovcInstructionTextureDimension)(
THIS_
_In_ UINT Index,
_Out_ D3D12_SHADER_TEXTURE_DIMENSION *pTextureDimension) PURE;
STDMETHOD(GetMovcInstructionReturnType)(
THIS_
_In_ UINT Index,
_Out_ D3D12_SHADER_VARIABLE_TYPE *pReturnType) PURE;
STDMETHOD_(UINT, GetTextureSRVDimension)(
THIS_
_In_ UINT Index) PURE;
STDMETHOD(GetTextureSRVReturnType)(
THIS_
_In_ UINT Index,
_Out_ D3D12_SHADER_VARIABLE_TYPE *pReturnType) PURE;
};
这个接口提供了一系列用于获取 HLSL 着色器信息的方法,包括获取着色器描述、常量缓冲区信息、资源绑定描述、输入参数描述、输出参数描述、Patch 常量参数描述、变量类型、变量名称等等。
要使用这个接口,你通常需要通过调用其他 API 获取到着色器反射器(reflection)对象,然后通过该对象获取到 ID3D12ShaderReflection 接口。具体的使用方法可以参考 Direct3D 12 的相关文档和示例代码。
转载请注明出处:http://www.zyzy.cn/article/detail/26169/Win32 API/D3d12shader.h/ID3D12ShaderReflection