jFort
jFort

Reputation: 327

Android Open GL fragment shader speed

I have a fragment shader that's calculating RGB float values running on a Nexus 7.

If I run this shader with gl_FragColor = vec4(c1,c2,c3,1.0); - where c1, c2, and c3 are the three colours calculated - I get around 26 fps.

If I keep everything else the same - so all the calculations remain in place - and simply change to gl_FragColor = vec4(c1,1.0,1.0,1.0); I get 60 fps.

Should I expect that assigning these float values should take so long? Or am I missing something?

Upvotes: 0

Views: 149

Answers (2)

weston
weston

Reputation: 54781

If you don't use c2,c3 anywhere else, then when you remove them from the gl_FragColor the compiler will decide that it's not worth calculating them at all, and so it will optimize the calculations away.

We'd need to see how those c2,c3 variables are calculated to identify the problem.

Upvotes: 2

mrVoid
mrVoid

Reputation: 995

Vertical synchronization could be your problem

Most probable cause of this is that v-sync is on in your graphics card settings (in this case mobile/tablet).

Turn it off and see it skyrocket. But I guess this is not possible. You can also measure the time it takes to render the frame and see that it is in fact much shorter than 1/60th of a second. So loads of time for logic code.

Upvotes: 0

Related Questions