Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Is it possible to debug shaders in Android OpenGL ES 2?

Writer Andrew Henderson

Is there a possibility to debug the shaders (fragment and vertex) in an Android Application with OpenGL-ES 2?

Since we only pass a String with code and a bunch of variables to replace with handles, it is very tedious to find the proper changes that need to be done.

  • Is it possible to write to the Android Log, as in Log.d()

  • Is it possible to use break points and to inspect the current values in the shader calculations?

I am simply not used to write code with a pen anymore and that's what it feels like to code within the shader text code.

2 Answers

This is an old question but since it appears first in searches and the old answer can be expanded upon, I'm leaving an alternative answer:

While printing or debugging like we do on Java or Kotlin is not possible, this doesn't mean that it cannot be debugged. There used to be a tool on the now deprecated Android Monitor for letting you see a trace of your GPU execution frame by frame, which included inspecting calls and geometry.

Right now the official GPU debugger is the Android GPU Inspector, which has some useful performance metrics and will include debugging frame by frame in a future update.

Screen recording of the frame debug tool

If the Android GPU Inspector doesn't have what you need, you can go with vendor-specific debuggers depending on your device (Mali Graphics Debugger, Snapdragon Debugger, etc.)

No. Remember that the GPU is going to execute every program millions of times (once per vertex, and once per fragment), often with hundreds of threads running concurrently, so any concept of "connect a debugger" is pretty much impossible.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy