Debug fragment Shader code (other than code inspection?)

At the end of Ch 14 (Deferred Rendering) I had a small problem. My final image (image-1) was not right. I took a GPU workload check (image-2) and the “Present” image looked right, but what came out wasn’t right. First, why the difference?
I finally figured out the issue (forgot to send the number of lights in the params.LightCount in drawSunLight(), and got it to look right (image-4), but the GPU workload checkpoint (image-3) looked the same.
So, secondly, is there a “better” way to debug such issues other than code examination of fragment shaders?

I mostly use the GPU workload option to examine buffers to ensure they contain what I think they contain.

I also do debugging using the debug feature inside the GPU workload option and check actual values. For example, if params.lightcount is zero in this code, the loop wouldn’t have values in them.

To get to this, highlight the draw call you want to debug and click the bug icon.

Then click the fragment you want to debug, and click the bug at the bottom right.

You’ll then see the code with the calculated value in the side bar next to the code. (Just like in a playground.)

To exit this debug click the bug icon, which has now turned blue, again.

But usually I rely on checking the contents of buffers.

1 Like

AHA! Thank you SO much.
I just knew there had to be a secret handshake of icons hits to get to this information. I just didn’t know which itty-bitty little things to hit in what order. Finally.
This is precisely what I was looking for. YAY!
And, thanks for your patience in answering me.

1 Like

I’m not sure why we didn’t talk about the bug icon. It might have been lack of space. Apparently we were at the longest book that Amazon would print in one volume :grin:.

But as I said, I generally just check buffers by double clicking them in the GPU workload for a frame. If there’s a zero or a nan in any buffer, it’s a pretty good indication that something’s off.