Graphics‎ > ‎Graphic API‎ > ‎Direct3D‎ > ‎HLSL‎ > ‎

Assembly

When debugging shaders it can be helpful to be able to read HLSL assembly. There are three steps of code for a HLSL shader.

  • HLSL: The code you write in HLSL form.
  • DXBC: The DirectX bytecode generated by the directx shader compiler from the HLSL. It can be shown as HLSL assembly.
  • ISA: The DXBC code compiled by the GPU to it's instruction set architecture. This is what runs on the GPU in the end. 
Version

Constants

Declarations

Shaders use registers to work on data. The register has names in the form of a tag (a single letter) and a number. The tag is the type of the register that limit what they can contain and how they can be used. The number start at 0 and go up to a shader model dependent required minimum number. Dimension is how many elements each register contain. Each register use need to be declared with a dcl statement before the instructions.

 Tag     I/O what     DimensionMin SM5
 Dcl
 r I 32-bit temp variable
 4 4096 
 x I 32-bit indexable temp array.
 4 4096 
 v I 32-bit input attribute
 4 32 dcl_input
 t I Input resource
 1 128 dcl_resource
 s I Sampler 1 16
 dcl_sampler
 cb I Constant buffer reference
 4 15
 dcl_constantBuffer
 oO
 32-bit output element
 4 8 
 dcl_output
 uO Unordered Access View
   
 oDepthO
 Output depth
 1 1 dcl_output oDepth
 oMaskO Output sample mask
 1 1 dcl_output oMask




Instructions



Comments