GLSL conditional fines

I wrote the first pair of GLSL programs for Processing (a visual language similar to Java that can load shaders) lately, which fractals do. In the loop that processes the fractal code, I have an exception condition that breaks if the point tends to infinity.

It works great and is similar to the way I generally write code for non-GLSL. However, someone told me that two paths are computed each time the condition is met. It was hard for me to find exactly how much fines caused by conventions in GLSL.

Change . As far as I understand, in the absence of GLSL, when it occurs if, the path is assumed. Assuming that the "right" path has been adopted, everything is fine. If the "wrong" path was adopted, then the "bad" work is discarded and the instructions continue along the "correct" path. A fine may be 3 (or as many as you like) instructions. I want to know if there are any number (3 or something else) of instructions that are fine, or if both paths are calculated to the end.

Here is the code if the explanation is not clear enough:

// Mandelbrot Set code
int i = 0;
float zr = x;
float zi = y;
for (; i < maxIterations; i++) {
    float sqZr = zr*zr;
    float sqZi = zi*zi;
    float twoZri = 2.0*zr*zi;
    zr = sqZr-sqZi+x;
    zi = twoZri+y;
    if (sqZr+sqZi > 16.0) break;
}
+4
source share
1 answer

if() . , , , . if() : , : "if() 14 ", .

? , ( , ). SIMD - SIMD - .

, , NVIDIA , ( !) .

(BTW Java: Java)

+4

All Articles