Performance is poor when Loop a uniform

Hello!


clip_polygonCount is a uniform, I found the performance of this shader is very poor,.
if I change this to a constant, such as 10, the performance is quite good.
I know the use of constants will be optimized, but this clip_polygon is possible to modify. The constant doesn’t satisfy the condition, so what do I do
Thanks!

How about:

for (int i = 0; i < 65536; i++) {
  if (i >= clip_polygonCount) {
    break;
  }

  // NOTE Rest of the code...
}
1 Like