Using <Program> Reflection

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

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.

Start The Module Application

  1. Start the Module app. (Start > Programs > Scenomics > Module) or (Windows® key and then type 'Module' 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 Reference Document

  1. Examine the main menu and select File > Open From GLSL Reference Library....

    The software presents a dialog that allows you to choose the GLSL version, pixel format, and topology of the GLSL reference shader you wish to locate. The third option allows you to open the reference document in the application or to open an Explorer® window to the location of the GLSL reference shader.

    This is a picture of the reference shader selector dialog.
  2. Set Select GLSL Version to 430.
  3. Set Select Sampler Type to sampler2D.
  4. Click OK or hit ENTER when you are finished.

    The software presents an Explorer® in the directory containing the desired GLSL reference shader.

    This is a picture of the file open dialog.
  5. Select sampler2D.box and click Open or hit ENTER when you are finished.

    The software opens the GLSL reference document.

    This is a picture of the GLSL reference document.

Dump <Program> Objects

  1. Examine the hierarchy.
  2. Right click over the <Program> named Visual and select Dump Variables from the listed options.

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

    --- <Executing Command 'ProgramNodeDumpVariables'> ---
    
    //////////////////////////////////////////////////
    Program Object Name: 83
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................83
    a_oInfo.TypeCode........................GL_INT32
    a_oInfo.TypeName........................int
    a_oInfo.Index...........................0
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.BufferSize......................-1
    a_oInfo.Location........................0
    a_oInfo.Offset..........................-1
    a_oInfo.Count...........................1
    a_oInfo.Type............................0x1404
    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.TopLevelArrayCount..............-1
    a_oInfo.TopLevelArrayStride.............-1
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: 83
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................83
    a_oInfo.TypeCode........................GL_FLOAT_VEC4
    a_oInfo.TypeName........................vec4
    a_oInfo.Index...........................1
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.BufferSize......................-1
    a_oInfo.Location........................1
    a_oInfo.Offset..........................-1
    a_oInfo.Count...........................1
    a_oInfo.Type............................0x8b52
    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.TopLevelArrayCount..............-1
    a_oInfo.TopLevelArrayStride.............-1
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................16
    
    //////////////////////////////////////////////////
    Program Object Name: SPA_UsePerObjectID
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................SPA_UsePerObjectID
    a_oInfo.TypeCode........................GL_BOOL
    a_oInfo.TypeName........................bool
    a_oInfo.Index...........................2
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.BufferSize......................-1
    a_oInfo.Location........................2
    a_oInfo.Offset..........................-1
    a_oInfo.Count...........................1
    a_oInfo.Type............................0x8b56
    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.TopLevelArrayCount..............-1
    a_oInfo.TopLevelArrayStride.............-1
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    //////////////////////////////////////////////////
    Program Object Name: modelViewProjectionMatrix
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................modelViewProjectionMatrix
    a_oInfo.TypeCode........................GL_FLOAT_MAT4
    a_oInfo.TypeName........................mat4
    a_oInfo.Index...........................3
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.BufferSize......................-1
    a_oInfo.Location........................3
    a_oInfo.Offset..........................-1
    a_oInfo.Count...........................1
    a_oInfo.Type............................0x8b5c
    a_oInfo.TypeSize........................64
    a_oInfo.ArrayStride.....................-1
    a_oInfo.MatrixStride....................-1
    a_oInfo.Rows............................4
    a_oInfo.Cols............................4
    a_oInfo.RowMajor........................0
    a_oInfo.TopLevelArrayCount..............-1
    a_oInfo.TopLevelArrayStride.............-1
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................64
    
    //////////////////////////////////////////////////
    Program Object Name: pixel_data
    //////////////////////////////////////////////////
    
    a_oInfo.Name............................pixel_data
    a_oInfo.TypeCode........................GL_SAMPLER_2D
    a_oInfo.TypeName........................sampler2D
    a_oInfo.Index...........................4
    a_oInfo.BufferIndex.....................-1
    a_oInfo.BufferBinding...................-1
    a_oInfo.BufferType......................3
    a_oInfo.BufferSize......................-1
    a_oInfo.Location........................4
    a_oInfo.Offset..........................-1
    a_oInfo.Count...........................1
    a_oInfo.Type............................0x8b5e
    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.TopLevelArrayCount..............-1
    a_oInfo.TopLevelArrayStride.............-1
    a_oInfo.IsMemberOfTopLevelArray.........0
    a_oInfo.IsMemberOfTopLevelUnsizedArray..0
    a_oInfo.GetTotalSize....................4
    
    Printed information for (5) 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.

  3. Close all Simdify applications started during this exercise.