I ran the OpenGL ES analysis tool from the tools in my application, and it stated that after compiling the shader I should make a glDrawArrays call in a prewarm pass. Therefore, I checked the time of some shaders that I wrote, and indeed, the first time the program starts, it is much slower.
In my code, I have a common shader loader that does not know the shader form / attributes, it just compiles it. And it seems like the best place to pre-heat the shader is (so I don't need to add glDrawArrays everywhere). I tried adding this to my shader loader:
glUseProgram(prog);
glDrawArrays(GL_TRIANGLES, 0, 0);
He fixed the delay, but since I am not setting any uniforms / attributes, I am not sure if it is safe. Also, it kind of looks like a workaround. What is the best way to pre-program a program?
source
share