1

I want to debug a GLSL Shader. What i need is to send Strings information. I have tried FBO but this is not a clean way

Is there a way to send log to the main program?

Bob5421
  • 7,757
  • 14
  • 81
  • 175
  • see my [GLSL debug prints](https://stackoverflow.com/a/44797902/2521214) You just have to make sure that you print the same thing for each fragment of the region containing the text output. That can be tricky and even impossible in some cases. Here example: [GLSL Ray tracer](https://stackoverflow.com/a/45140313/2521214) – Spektre Oct 11 '17 at 07:59
  • 1
    https://github.com/msqrt/shader-printf – genpfault Oct 11 '17 at 15:27
  • Possible duplicate of [How to debug a GLSL shader?](https://stackoverflow.com/questions/2508818/how-to-debug-a-glsl-shader) – LJᛃ Oct 11 '17 at 18:37

2 Answers2

1

No, there is no way to send strings from a shader to a main program.

What you usually do is to output specific colors for specific cases. Depending on your hardware CodeXL or Nvidia NSight might also help.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
BDL
  • 21,052
  • 22
  • 49
  • 55
  • There is no official way to debug shaders ? – Bob5421 Oct 11 '17 at 06:59
  • Yes there is: Use NSight or RenderDoc or whatever GPU debugger fits your hardware. The only thing you can't do is writing strings to some output. Btw.: GLSL doesn't have a construct for strings at all. – BDL Oct 11 '17 at 07:21
1

You can do following if you want to have some kind of your own error codes.

You can use transform feedback. Transform feedback cant store strings . It is generally used to store per vertex or per primitive attribute.You may define some error codes. for example

In Application

#define VERTICES_TRANSFORMED_WRONGLY 1

in VS shader

#define VERTICES_TRANSFORMED_WRONGLY 1 

void main(void)
{
  if(condition for error met)
    write error code(VERTICES_TRANSFORMED_WRONGLY) to Transform feedback.
}

In Application

Read this transform feedback if it has any error code you know what went wrong.

You can attach transform feedback after every shader stage. [Edit suggested by BDL] : You cant attach Transform Feedback after fragment shader but you can do something similar with FBO for fragments shader stage.

Note : I would still suggest you to use tools you have already been referred like Renderdoc ,glDebugger,Nsight .