Using <Program> Reflection

You need one of the following products to complete this exercise: Simdify® Free Edition, Simdify® Compute+ Module

During shader development, it can be very useful to print out a list of all shader objects associated with a particular <Program> node. For example, you can learn whether or not a constant has been declared or not, and therefore should be visible through reflection, and you can also learn things like whether or not a particular uniform has been optimized out.

This exercise requires the Simdify® Compute+ Module, but you can do the same thing with any <Program> node.

Start The Layout application

  1. Start the Layout app. (Start » Programs » Scenomics » Layout) or (Windows® key and then type 'Layout' to find the app icon.)

    The application displays a splash screen and then the application desktop appears. The main menu is composed of three items that contain commands relevant to the current context (which is an empty document). The interface changes when you create a new file or load a file from disk.

    This is a picture of the desktop.

Open Gaussian Blur Sample

  1. Select File » Open from the main menu.

    The software displays the file dialog in the \Shader folder.

    This is a picture of the new project dialog.
  2. Enter the directory named Gaussian Blur and open the file named Gaussian Blur.box.

    The application loads the document.

    This is a picture of the Gaussian blur shader.

Dump <Program> Objects

  1. Examine the hierarchy.
  2. Right click over the <Program> named Compute and select Dump Variables from the listed options. This is a picture of the Gaussian blur shader.

    The application dumps OpenGL reflection information for the associated shader program.

    --- <Executing Command 'ProgramNodeDumpVariables'> ---
    
    //////////////////////////////////////////////////
    Program Object Name: delta
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................delta
    a_oInfo.Index...........................0
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.Location........................0
    a_oInfo.Offset..........................-1
    a_oInfo.Size............................1
    a_oInfo.Type............................35669
    a_oInfo.TypeSize........................16
    a_oInfo.ArrayStride.....................-1
    a_oInfo.MatrixStride....................-1
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............0
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................16
    
    //////////////////////////////////////////////////
    Program Object Name: dst_image
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................dst_image
    a_oInfo.Index...........................1
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.Location........................1
    a_oInfo.Offset..........................-1
    a_oInfo.Size............................1
    a_oInfo.Type............................36941
    a_oInfo.TypeSize........................4
    a_oInfo.ArrayStride.....................-1
    a_oInfo.MatrixStride....................-1
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............0
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: kernel_dimension
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................kernel_dimension
    a_oInfo.Index...........................2
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.Location........................2
    a_oInfo.Offset..........................-1
    a_oInfo.Size............................1
    a_oInfo.Type............................5124
    a_oInfo.TypeSize........................4
    a_oInfo.ArrayStride.....................-1
    a_oInfo.MatrixStride....................-1
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............0
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: src_image
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................src_image
    a_oInfo.Index...........................3
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.Location........................3
    a_oInfo.Offset..........................-1
    a_oInfo.Size............................1
    a_oInfo.Type............................36941
    a_oInfo.TypeSize........................4
    a_oInfo.ArrayStride.....................-1
    a_oInfo.MatrixStride....................-1
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............0
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: gaussian_filter
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................gaussian_filter
    a_oInfo.Index...........................-1
    a_oInfo.BufferIndex.....................0
    a_oInfo.BufferBinding...................0
    a_oInfo.BufferType......................4
    a_oInfo.Location........................-1
    a_oInfo.Offset..........................-1
    a_oInfo.Size............................4
    a_oInfo.Type............................0
    a_oInfo.TypeSize........................1
    a_oInfo.ArrayStride.....................0
    a_oInfo.MatrixStride....................0
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............0
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: values[0]
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................values[0]
    a_oInfo.Index...........................0
    a_oInfo.BufferIndex.....................0
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................4
    a_oInfo.Location........................-1
    a_oInfo.Offset..........................0
    a_oInfo.Size............................1
    a_oInfo.Type............................5126
    a_oInfo.TypeSize........................4
    a_oInfo.ArrayStride.....................4
    a_oInfo.MatrixStride....................0
    a_oInfo.Rows............................0
    a_oInfo.Cols............................0
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArraySize...............1
    a_oInfo.TopLevelArrayStride.............0
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    Printed information for (6) variables.
             

    This shows all the objects OpenGL finds that are associated with this shader program. You can even see the buffer object named gaussian_blur.