Imagination PowerVR SDK Blog

Branching vs Multiple texture fetch and step/mix


#1

On PowerVR SGX 544 MP with OpenGL ES2 I need to selectively tap into 4 different 2D texture samplers.
Am I better off branching using if statements or fetch all 4 texels and select them using steps and/or mixes?


#2

IIRC, Series5 will prefetch all independent taps within branches (both paths) if the conditional cannot be evaluated before fragment shader calculation. This may also apply to conditionals where a uniform value dictates the path, e.g. a uniform bool.

Depending on where your application’s bottlenecks are, dependant texture fetches in the branches should be faster than independent as there will be fewer texel fetches and sampling operations. If you have access to our NDA deliverables, you should be able to confirm this with our Series5XT disassembly compiler (only Series6 onwards disassemblers are public).