summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-10-29 20:56:07 -0700
committerKenneth Graunke <[email protected]>2014-11-06 16:30:47 -0800
commita16ca4ac6a356e02c6aa03c1e305f613a4e23202 (patch)
treedd15611d27b6f632ccf62ab5bf094dde4d52e0b1 /src/mapi
parent4f22db5fbbe59eacb762aa410f18c3078e85c2b7 (diff)
glsl: Skip loop-too-large heuristic if indexing arrays of a certain size
A pattern in certain shaders is: uniform vec4 colors[NUM_LIGHTS]; for (int i = 0; i < NUM_LIGHTS; i++) { ...use colors[i]... } In this case, the application author expects the shader compiler to unroll the loop. By doing so, it replaces variable indexing of the array with constant indexing, which is more efficient. This patch extends the heuristic to see if arrays accessed within the loop are indexed by an induction variable, and if the array size exactly matches the number of loop iterations. If so, the application author probably intended us to unroll it. If not, we rely on the existing loop-too-large heuristic. Improves performance in a phong shading microbenchmark by 2.88x, and a shadow mapping microbenchmark by 1.63x. Without variable indexing, we can upload the small uniform arrays as push constants instead of pull constants, avoiding shader memory access. Affects several games, but doesn't appear to impact their performance. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/mapi')
0 files changed, 0 insertions, 0 deletions