GLSL: Which is more optimal? Ping-ponging with loops on the processor or loops in the fragment shader?

I have a fragmented shader that executes a for loop with the number of passes passed as a single int variable.

uniform int numPasses;
void main(void) {
   for (int i=0; i<numPasses; i=i+1) {
      //do something
   }
}

I see that performance drops sharply as the number of cycles increases. So is this the right way to do loops in a fragment shader, or should I just loop through the processor using ping-ponging between two framebuffer attachments?

I'm trying to try ping-ponging, but I just wanted to know the opinions of people who may have come across this before.

+3
source share
1 answer

, , , , .

, , , - GPU, .

. , , , . , .

0

All Articles