2
votes

I recently attempted to write some GLSL shader code and did not have much luck when the shader didn't draw what I expected (basically, everything is black on screen). Here are the tools I tried:

  1. Nvidia NSight VS integration - It crashes right away when I start the application, try couples other application even with the simple triangle drawing and still have no luck. Search through the internet and Nvidia forum and seem it is a common issue, and didn't seems to find any solution.

  2. glslDevil - It can start the application but then the program keeps exiting before any rendering happens, the GL Trace is

    wglMakeCurrent(0, 0)
    wglDeleteContext(00010000)
    ChildProcess exited
    

    Get another crash when running another application when after calling glDeleteTexture(1, 0314EF74) Child process exited

    I have no clue what is going on.

  3. AMD PerfStudio 2 - It seems it is the most promising tools, successfully run my application and display the required information. However, it didn't seems support debugging GLSL, I cannot step through the shader and watching the local variables etc? It seems only support DirextX shader

  4. gDebugger - It works pretty well tool, similar to AMD PerfStudio, but again it is not a debugger, cannot step through the shader code and watching any local variables.

  5. Printf - ?? Someone on stack overflow saying using printf, how can I do printf() in the shader?

  6. Convert DirectX shader to GLSL - Since DirectX shader have better debugging tool, and there are tools like http://sourceforge.net/projects/hlsl2glsl/ to automatically convert the hlsl to glsl, it seems it can be an alternative. I personally didn't like this solution, and really wish I have another choice.

Can anyone suggest how you debug your GLSL? What tool you are using successfully?

I am running on:

  • NVidia GFX 460v2
  • Visual Studio 2008 and 2010
  • GLEW
  • OpenGL 2.0
2
Implicitly you mean under Windows? - Tommy
it's easier to just write them correctly from the beginning... and use some obvious visual tests to check if the calculations work the way they should - Display Name
fix your NSight installation would be my suggestion. Make sure that you don't have anything else listening at the port NSight listens (I had something called freemake studio installed that blocked NSight). Better yet, look at the log-file of Nsight to figure out why it crashed - PeterT
"everything is black on screen"...did you check your shader compilation/link statuses/logs? ARB_debug_output? - genpfault
glslDevil's been broken for years unfortunately. If you are lucky enough to have a codebase / driver that is old enough it might work for you, but since it has not been maintained that perfect combination is hard to come by. Many GL tools are in a similar situation, including some vendor-specific ones. NSight is reasonably well-maintained as long as you are not using the absolute latest version of Visual Studio (it still does not support VS 2013). - Andon M. Coleman

2 Answers

1
votes

You can specify extra outputs using the glDrawBuffers and then inspect that (your printf).

However that doesn't fixes anything when the primitive is outside the drawing area.

Otherwise it's old school programming by pure reasoning and mental debugging.

1
votes

After many hours struggle, I finally make my NSight working on my machine, and I write up the process in here and hope it will help someone with similar problem,

  1. Download NSight from https://developer.nvidia.com/nsight-visual-studio-edition-downloads, and it involves couple download steps, just follow the instruction. I have Nsight Tegra install before and get a NSight menu in my Visual Studio, however, when I start the graphics debugger, the application crash right away. I think the NSight integration come with the NSight Terga is broken, and reinstall the NSight follow the above link seems fix the problem

  2. When running the NSight graphics debugger, I am not able to debug my shader code due to the fact that my app is using some incompatible function, such as

    glTexImage2D() glTexEnvf()
    and much more. The graphics debugger told me I can call a tool named Nav.Launcher.exe to find out a list of incompatible functions in my application. However, I cannot find the tool in my hard drive.

  3. Then I decide to use the gDEBugger to run my application again and turn on Breakpoints->Break On Deprecated Function. This allow my to know all deprecated functions I called in my code. After removed all deprecated functions, the NSight graphics debugger's frame debugger feature can be enabled and I can finally step through my shader code line by line in Visual Studio

Hope this help.