如何从 ID3D11ShaderReflection 获取着色器类型(vertex/pixel 等)?
How could I get shader kind (vertex/pixel, etc.) from ID3D11ShaderReflection?
我想从着色器字节码中提取着色器程序类型信息。我先试了D3D11Reflect
,发现了_D3D11_SHADER_DESC
结构。但是我无法确定哪个字段存储程序类型信息...
如果您查看 d3d11shader.h
header,您会看到它被编码到 16 位高位字的版本字段中:
typedef enum D3D11_SHADER_VERSION_TYPE
{
D3D11_SHVER_PIXEL_SHADER = 0,
D3D11_SHVER_VERTEX_SHADER = 1,
D3D11_SHVER_GEOMETRY_SHADER = 2,
// D3D11 Shaders
D3D11_SHVER_HULL_SHADER = 3,
D3D11_SHVER_DOMAIN_SHADER = 4,
D3D11_SHVER_COMPUTE_SHADER = 5,
D3D11_SHVER_RESERVED0 = 0xFFF0,
} D3D11_SHADER_VERSION_TYPE;
#define D3D11_SHVER_GET_TYPE(_Version) \
(((_Version) >> 16) & 0xffff)
#define D3D11_SHVER_GET_MAJOR(_Version) \
(((_Version) >> 4) & 0xf)
#define D3D11_SHVER_GET_MINOR(_Version) \
(((_Version) >> 0) & 0xf)
typedef struct _D3D11_SHADER_DESC
{
UINT Version; // Shader version
...
} D3D11_SIGNATURE_PARAMETER_DESC;
我想从着色器字节码中提取着色器程序类型信息。我先试了D3D11Reflect
,发现了_D3D11_SHADER_DESC
结构。但是我无法确定哪个字段存储程序类型信息...
如果您查看 d3d11shader.h
header,您会看到它被编码到 16 位高位字的版本字段中:
typedef enum D3D11_SHADER_VERSION_TYPE
{
D3D11_SHVER_PIXEL_SHADER = 0,
D3D11_SHVER_VERTEX_SHADER = 1,
D3D11_SHVER_GEOMETRY_SHADER = 2,
// D3D11 Shaders
D3D11_SHVER_HULL_SHADER = 3,
D3D11_SHVER_DOMAIN_SHADER = 4,
D3D11_SHVER_COMPUTE_SHADER = 5,
D3D11_SHVER_RESERVED0 = 0xFFF0,
} D3D11_SHADER_VERSION_TYPE;
#define D3D11_SHVER_GET_TYPE(_Version) \
(((_Version) >> 16) & 0xffff)
#define D3D11_SHVER_GET_MAJOR(_Version) \
(((_Version) >> 4) & 0xf)
#define D3D11_SHVER_GET_MINOR(_Version) \
(((_Version) >> 0) & 0xf)
typedef struct _D3D11_SHADER_DESC
{
UINT Version; // Shader version
...
} D3D11_SIGNATURE_PARAMETER_DESC;