I’m currently doing a large shader where I need functions to create layers of abstraction. I have some loops (I know, bad) in some of my functions and I implement a loopbreaker to prevent infinite loops. I don’t know if this is good or bad practise, but I’d like to check if my loopbreakers are being hit and for what fragments this happens. Is there an easier way to do this than propagating some kind of
out bool loopbreaking parameter up until my main() catches it and outputs an ultragreen color for those fragments? (that’s how I debug my shader code most of the times) Maybe altering the output register and jumping to program exit? (can I actually go into assembly and do this? safely?)
You could just have that function write to a global out variable. You can write multiple colors, after all; outputs don’t have to be written from
But if you’re going to conditionally write to this variable, you need to make sure that you unconditionally write to it first. That can happen in
Or you could use Image Load/Store, which isn’t all that different.
No. That’s not how fragment shader’s work.
Nice to see you at the forums again! Thanks for the answer, very helpful. I forgot I could just output to the global out variable! However, if in my main I have something that does alter that same global out variable, I could make it check the global out variable first to see if it has not been changed before, right? That or I could use something like an atomic counter to flag any fragments that need a different color.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.