Reputation: 2176
I have written an openGLES code that is having one vertex shader and one fragment shader. Pseudo code is like this
main()
{ .
.
.
for(int i=0; i<100;i++)
{
//t1 = clock();
//Setting two textures as input
//Setting 10 glUniform 4f variables
//Setting Viewport
//Launch : glDrawArray
//glFinish();
//t2 = clock();
//printf("Execution time : %f\n",t2-t1);
}
}
I am getting the expected output. But while executing it 100 times, for first execution I am getting 80 ms and for subsequent execution it is 25 ms. I just want to confirm that whether it is expected in openGLES( due to some fectors ) or I am making some mistake.
Thank you
Upvotes: 1
Views: 250
Reputation: 12084
In addition to the driver setup times mentioned by @Colombo, it's also worth noting that if you are running on mobile device it will take some time (> 100ms) for the device performance to settle into a steady state when workloads change. The GPU performance (operating frequency) will adapt on the fly to the required workload, so the first frames are probably at a lower frequency than ideally needed.
Upvotes: 2
Reputation: 6766
Most OpenGLES drivers don't completely compile your shaders when you first create them, they defer much of the work until the first time you draw something with them.
They do this because they know empirically that loads of programs create shaders that they'll never use. The downside is that it creates frame-glitches/inconsistent draw calls times for users who are more careful.
Sometimes people 'pre-warm' shaders by doing an off-screen render with them to avoid frame glitches during gameplay.
Upvotes: 2