Udostępnij za pośrednictwem


Figuring out the shader type from a blob

If you work with tools that manipulate shaders, you might find yourself at some point wondering what kind of shader you're dealing with if all you have is a blob of bytes.

Using the shader reflection APIs, you can check whether the shader is a pixel shader, vertex shader, etc, by looking at the Version field of the D3D11_SHADER_DESC type. The field is defined as a UINT that's really a bitmask of values, but there are helpers to get at each piece of information.

d3d11shader.h defines the following three macros: D3D11_SHVER_GET_TYPE, D3D11_SHVER_GET_MAJOR and D3D11_SHVER_GET_MINOR. The type macro will yield a value in the D3D11_SHADER_VERSION_TYPE enumeration, with values such as D3D11_SHVER_PIXEL_SHADER, D3D11_SHVER_VERTEX_SHADER, etc. - this will tell you the shader type for the blob itself.

Enjoy!

Comments

  • Anonymous
    November 09, 2015
    Thanks for sharing.