Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
  • Groups
    • Research Collaboration and Enablement
    • DesignStart
    • Education Hub
    • Innovation
    • Open Source Software and Platforms
  • Forums
    • AI and ML forum
    • Architectures and Processors forum
    • Arm Development Platforms forum
    • Arm Development Studio forum
    • Arm Virtual Hardware forum
    • Automotive forum
    • Compilers and Libraries forum
    • Graphics, Gaming, and VR forum
    • High Performance Computing (HPC) forum
    • Infrastructure Solutions forum
    • Internet of Things (IoT) forum
    • Keil forum
    • Morello Forum
    • Operating Systems forum
    • SoC Design and Simulation forum
    • 中文社区论区
  • Blogs
    • AI and ML blog
    • Announcements
    • Architectures and Processors blog
    • Automotive blog
    • Graphics, Gaming, and VR blog
    • High Performance Computing (HPC) blog
    • Infrastructure Solutions blog
    • Innovation blog
    • Internet of Things (IoT) blog
    • Operating Systems blog
    • Research Articles
    • SoC Design and Simulation blog
    • Tools, Software and IDEs blog
    • 中文社区博客
  • Support
    • Arm Support Services
    • Documentation
    • Downloads
    • Training
    • Arm Approved program
    • Arm Design Reviews
  • Community Help
  • More
  • Cancel
Arm Community blogs
Arm Community blogs
Graphics, Gaming, and VR blog Using RenderDoc to Find Shader Issues in OpenGL ES
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI and ML blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded blog

  • Graphics, Gaming, and VR blog

  • High Performance Computing (HPC) blog

  • Infrastructure Solutions blog

  • Internet of Things (IoT) blog

  • Operating Systems blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tell us what you think
Tags
  • OpenGL ES
  • Compute Shaders
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

Using RenderDoc to Find Shader Issues in OpenGL ES

xiang chen
xiang chen
March 1, 2023
3 minute read time.

You might encounter some defects when you run 3D applications that use OpenGL ES to render images. This blog helps you find the cause of the defects. These examples show defective images and golden images.


 Cone image with defects  Screen image with defects Figure 1: Defective images
 Cone golden image  Screen golden image Figure 2: Golden images

The defective images are caused by:

  • Compiler shader handling
  • OpenGL ES driver bugs

Use a visualizing tool

When you see defective images, you can investigate the problem with visualizing tools. These tools capture and analyze the trace. We recommend that you use RenderDoc (https://renderdoc.org). Renderdoc can capture frame buffer output and API sequence. This tool captures shader source. You can then modify, recompile, and rerun the shader source instead of investigating the driver.

This screenshot shows captured APIs and the shader by some draw calls.

  1. On the Pipeline State tab, click View. You see the shader source.
  2. To edit the shader source, on the Pipeline State tab, click Edit.
  3. After editing, click Refresh, then click the same draw call.
  4. Check the result to see if it is changed. No matter where the change occurs, the result gives information about where the issue is.

Investigate the shader issue

RenderDoc captures the trace, so that you can run draw calls, one by one, to find which draw call has the defective image.

  1. Click the tab Pipeline State to see which shader the current draw call is using.
  2. Modify the shader and compare the results.

If your modification fixes the issue, you have found the shader that encountered a compiler bug.

Investigate the issue in the following ways.

Find the executed shader source

The shader source you look at might be very long. It contains a lot of options and branches. For the current draw call, the GPU only executes some of the options and branches. Take care to identify the draw call that uses the options and branches. To help you quickly read and modify the shader source, you can skip the options, and branches that the GPU does not execute. For example:

Pseudo shader source:
#version 300 es
…
void main()
{
   u_xlat12 = dot(in_POSITION0, u_xlat1);
   if (branch1)
   {

   } else {
       if (branch2)
       {
           if (branch3)
           {

           } else {
           	if (branch3)
           	{
                   if (branch4)
                   {
                       if(bran)h5)
                       {
			  if (branch5)
                          {
                             ....
                          }
                       }
                   }
           	}
	   }
       }

       if (branch1)00)
       {
       }
       u_xlat2 = vec4(u_xlat12) * hlslcc_mtx4x4unity_ObjectToWorld[1]
   }
}

In the following example, only the 2 sentences shown in red are executed. This is the code you are looking for. You can ignore the rest.

 Shader fragment

To find which codes are not executed, disable the branches one by one and then refresh:

  • If the branch is executed, the result changes.
  • If the branch is not executed, the result does not change. 

You can then find which codes are not executed.

Find the final output and do a bottom-up investigation

For Vertex Shader (VS), find gl_position and the attributes to Fragment shader (FS). For FS, find gl_FragColor or a string, like “layout(location = 0) out vec4 SV_Target0;”.

Then, take a bottom-up traversal of calculation or variants related to the final output.

For example, find gl_FragColor first and then find the related variants a4, a3, and a1.

 Example

Assuming a1 or a3 is wrong, you can assign a1 or a3 to gl_FragColor, then you can visualize a1 or a3 to check the result. These steps help you identify which variant is wrong by matching the result against the golden result.

Change mediump or lowp into highp

Change mediump or lowp into highp, one by one, to check the result. If one of these changes eliminates the issue, then the problem is with precision.

Replace built-in functions with your own implementation

There are some built-in functions, like max, clamp, and dot. In some circumstances, the compiler might handle them wrongly. You can replace a build-in function with your own implementation to check the result. If your implementation works, then the build-in function does not work.

Anonymous
Graphics, Gaming, and VR blog
  • Arm Immortalis-G715 Developer Overview

    Peter Harris
    Peter Harris
    The new Arm®︎ Immortalis™︎ -G715 GPU is now available in consumer devices. This blog explores what is new, and how developers can get the best performance out of it.
    • March 20, 2023
  • Success in mobile games with ray tracing

    arm-phodges
    arm-phodges
    Blog provides details on how to use ray tracing techniques successfully across all mobile games on Arm-powered smartphones.
    • March 6, 2023
  • Arm at Vulkanised 2023

    Peter Harris
    Peter Harris
    A summary of the Arm talks at Khronos' Vulkanised 2023 event.
    • March 1, 2023