• entries
    316
  • comments
    485
  • views
    322237

Getting Shader Details in D3D11

Sign in to follow this  

289 views


Getting Shader Details in D3D11


While attempting to get my D3D11 renderer to automatically update constant buffers based on the information from the shader itself (to determine what to load into it), and I decided to write some code to convert all of the shader reflection information into text and build a shader method to print the text to my game log. The process of building the functions was educational, since it required digging into the D3D10 and D3D11 header files.

The result is a fairly compact representation of all of the input/output signatures along with the resources that are used. For example, from my recent NSE simulation shader, it produced the following output:

----------------------------------------------------------------------
Shader details printout for: Data/Shaders/NSE_Solver_CS_Optimized_Grid_Downlevel.hlsl
----------------------------------------------------------------------
Number of Input Signature Elements: 0

Number of Output Signature Elements: 0

Number of Constant Buffer Descriptions: 2
Buffer Name: Input, Buffer Type: RESOURCE_BIND_INFO, Variables: 1, Size: 20, Flags: 0
Variable Name: $Element, Start Offset: 0, Size: 20, Flags: 2, Start Texture: -1, Texture Size: 0, Start Sampler: -1, Sampler Size: 0
Variable Type Name: , Class: STRUCT, Type: VOID, Rows: 1, Columns: 5, Elements: 0, Members: 2, Offset: 0
Buffer Name: Output, Buffer Type: RESOURCE_BIND_INFO, Variables: 1, Size: 20, Flags: 0
Variable Name: $Element, Start Offset: 0, Size: 20, Flags: 2, Start Texture: -1, Texture Size: 0, Start Sampler: -1, Sampler Size: 0
Variable Type Name: , Class: STRUCT, Type: VOID, Rows: 1, Columns: 5, Elements: 0, Members: 2, Offset: 0

Number of Resource Binding Descriptions: 2
Name: Input, Type: STRUCTURED, Bind Point: 0, Bind Count: 1, Flags: 1, Resource Return Type: MIXED, Dimension: 1, Number of Samples: 20
Name: Output, Type: UAV_RW_STRUCTURED, Bind Point: 0, Bind Count: 1, Flags: 1, Resource Return Type: MIXED, Dimension: 1, Number of Samples: 20
----------------------------------------------------------------------



The latter portion delivers the most useful information for automatic updating, as well as general resource binding information. The input and output signatures are both empty since this is a compute shader that uses the read write attributes from a unordered access view.

Hopefully I'll get this thing wrapped up in the next couple days or so...
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now