Shader Debuging requirements and issues

Hello!

My existing project uses GLFX which is a shader creation library. You create single shader files using a slightly modified shader structure, and GLFX translates them and splits them into individual shaders (vertex, fragment, geometry, etc) at runtime.

I had been curious if this would pose a problem with Shader Debugging in NSight. If I pause frame, I can see a list of shaders. I can double click on them and see their source code (the names are sort of random, possibly generated by GLFX),
however, if I add breakpoints, they appear as empty circles and on mouse hover I see the disclaimer:

“The breakpoint will not be hit. No source correspondance for breakpoint ID …”

Is this because NSight doesn’t know where to find the shader source code in my project? (Since it exists in GLFX format)

Well I assumed it was GLFX problem so I tried downloading an example OpenGL project http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/

I compiled it with CMAKE for Visual Studio 2010 and gave it a test run. Running from my visual studio debugger the window loads fine and draws the triangle. Then I tried Running with NSight, and the application fails to run because the shader files fail to be opened (no doubt NSight is somehow preventing the application from accessing these files). NSight really doesn’t want to cooperate with me! :\

So to summarize my questions:

  1. Can NSight work if the shader source files are generated at runtime?

  2. What does “The breakpoint will not be hit. No source correspondance for breakpoint ID …” mean and how do I address this?

  3. Why, when I try to run a project with static shader source files, is NSight preventing opening of the shader files?

Suggestions or advice will be much appreciated!

Hi thegeneralsolution,

  1. Can NSight work if the shader source files are generated at runtime?
    <<< I never tried GLFX, but I used glsw sometime ago, which is also a tiny open source project for handle shaders at runtime. I think Nsight can handle it correctly.

  2. What does “The breakpoint will not be hit. No source correspondance for breakpoint ID …” mean and how do I address this?
    <<< That means Nsight’s shader debug can’t find shader’s source file in current context. There maybe many reason for this, it’s better to discuss one-by-one. Maybe you can try this, just click on your shader’s link in API Inspector, and set bp on the init position when shader file open.
    It’s better to have a small sample to repro and investigate your issue locally, that will make discuss and fix more effect.

  3. Why, when I try to run a project with static shader source files, is NSight preventing opening of the shader files?
    <<< No, Nsight never prevent open the shader files. please make sure you have configured your project with prop ‘Working directory’ in Nsight’s User Settings, by default, it will read your project’s (TargetDir) setting. In face, I notice opengl-tutorial.org's tutorial 1 needs you set 'Working Directory' in Visual Studio's Debugging, that will only make Visual Studio's Debug work, but Nsight still read (TargetDir) which is not suit for the sample. Please try to set Nsight’s ‘Working directory’ to the same folder as your Visual Studio Debugging’s. This should make it run smoothly.

Thanks
An

Hi AYan,

Once again, thank you for your prompt and helpful response. I just have one more question.

I set NSight’s working directory and I was able to set breakpoints on my shaders - very exciting! :)

When using GLFX the results are catastrophic though… NSight behaves erratically. I am doing away with GLFX anyway for a variety of reasons, so its no longer an issue for me. It seems to me the syntax of GLFX is too far from pure GLSL for NSight to understand. Perhaps a GLFX user would have to maintain static versions of the shaders it assembles internally.

Well I am converting my GLFX shaders back into vanilla GLSL shaders, and I’m setting up a folder structure to keep my shaders organized.

My question is, do the shaders have to be inside the working directory, or a descendant folder of the working directory? It will take me a little time to re-write and re-organize my shader files before I can test N-Sight here so I’d like to know what NSight needs to know to be able to find my shaders. More importantly I guess I’m wondering, what is the meaning of NSights “working directory”?

Hi thegeneralsolution,

Actually, place your shaders in the working directory or not depends on your own program, and how you read your shader file’s contents into your memory. If your program find the shader files depend on the program’s working directory, then run your program by visual studio’s debugger or nsight will also need to know that.

There is no magic here, nsight’s working directory is the same meaning as your program’s working directory which can make your app run smoothly.

Thanks
An

Thank you for your help, AYan! I have removed GLFX from my project and NSight seems to be working beautifully now. :)