Home > Back-end >  does opengl es draw on the screen exactly on draw call?
does opengl es draw on the screen exactly on draw call?

Time:07-16

I'm making an android game and I noticed that if I account only for the time spent in GLSurfaceView.Renderer (where I put all the graphics-related compuation), I have 300 fps, but if I account for the total amount of time per frame, I have 10 fps. So I was wondering, when I call GLES30.glDrawElements(); in android, does it stall the program and starts drawing or does it add a draw call to a list and goes throught it, drawing each draw call, in the background, between each update to the Activity or the SurfaceView?

Is it 1:

Android call update
||
Draw call
||
Drawing
||
Continue program
||
Loops

Or 2:

Android call update
||
Draw call
||
Add to list
||
Continue program and exit GLSurfaceView
||
Android goes through all draw calls and draws to the screen.
||
Loops

CodePudding user response:

GPU rendering is completely asynchronous - calling glDraw...() just adds the draw command to a queue of commands that the GPU will process when it can.

It's basically "2" in your question, except:

Android goes through all draw calls and draws to the screen.

is really:

  • GPU hardware goes through all queued draw calls and draws to a back buffer.
  • Display compositor swaps the front and back buffer when the back buffer is complete, and it is safe to do so (i.e. waiting for display vsync).

If the application is limited by rendering performance at least one of your graphics API calls will stall waiting for a buffer to render in to. This is normally eglSwapBuffers(), but doesn't have to be.

  • Related