Search code examples
macosdebuggingglslshader

Debugging shaders, specifically .glsl on macOS


It is my second day working with shaders and it is a lot of fun so far. I started googleing how to debug your code and found out, that (obviously) you cant communicate with the GPU like you can with the CPU - therefore debugging isn't as straight forward. I found a lot of debugging-tools for shader debugging but nothing thats running on macOS. So now my question: Is there a tool or way to debug shader code on macOS? Sorry if thats a noobie question...

I searched for tools but couldnt find any running on macOS unfortunatly. Also you can debug like within the shader itself and draw a line or something whenever a condition is met - but there has to be a more elegant way, right?


Solution

  • You could try GLSL-Debugger. The project is attempting to move toward supporting OSX (says it currently does not). However, the source and build system are available, so if you're willing to dive into that level of work you might be able to get it to compile on OSX.

    RenderDoc is another that supports Linux at least, so it may be transferable over to OSX with a bit of work.

    Otherwise, the best recommendation is create debug textures with a second output path or texture. Render whatever values you are interested in checking as some kind of interpreted color output, so you can look for strange behavior.

    You can also create input keys as number flags that will change the output based on what you want to look at. An example is this shader I wrote over on Shadertoy where each of the letter keys changes the rendering output so you can look at how different values are calculating and check for weird numerical errors.