November 2019
Intermediate to advanced
404 pages
12h 9m
English
The compiler will try its best to optimize our shader code into the more GPU-friendly low-level language so that it is not waiting on data to be fetched when it could be processing some other task. For example, the following poorly optimized code could be written in our shader:
float sum = input.color1.r;sum = sum + input.color2.g;sum = sum + input.color3.b;sum = sum + input.color4.a;float result = calculateSomething(sum);
This code has a data dependency such that each calculation cannot begin until the last finishes due to the dependency on the sum variable. However, such situations are often detected by the shader compiler and optimized into a version that uses instruction-level parallelism. The following code ...
Read now
Unlock full access