我想从着色器字节码中提取着色器程序类型信息。我首先尝试了D3D11Reflect
,然后发现了_D3D11_SHADER_DESC
结构。但是我无法确定哪个字段存储了程序类型信息...
答案 0 :(得分:2)
如果您查看d3d11shader.h
标头,则会看到它被编码为16位高位字的Version字段:
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;