Bug 137897

Summary: Use glFinish instead of glFlush when drawing final GL output to screen
Product: WebKit Reporter: Roger Fong <roger_fong>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, dino, jonlee, kondapallykalyan, noam, roger_fong
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch bfulgham: review+

Description Roger Fong 2014-10-20 15:51:31 PDT
When we want to draw the final WebGL output to the screen we call drawInCGLContext which in turn calls GraphicsContext3D::prepareTexture.
We used to call glFinish here, which pushes all buffered gl operations and blocks until every operation has been completed and every last pixel has been drawn.

glFlush also pushes all buffered gl operations but returns immediately.

Using glFinish is a huge performance hit and based on my testing does not seem to offer any particular benefit over glFlush.
Thus we will switch to using glFlush.

This gives us a 20% performance boost on Unity 3d tests and a 33% boost on the frame rate on http://threejs.org/examples/#webgl_performance.
Comment 1 Roger Fong 2014-10-20 15:54:52 PDT
Created attachment 240154 [details]
patch
Comment 2 Roger Fong 2014-10-20 15:57:02 PDT
We should commit this, live on it, and keep an eye out for any unforeseen consequences.
Comment 3 Roger Fong 2014-10-20 15:58:09 PDT
rdar://problem/15846550
Comment 4 Brent Fulgham 2014-10-20 16:16:31 PDT
Comment on attachment 240154 [details]
patch

Looks good! r=me.
Comment 5 Roger Fong 2014-10-20 18:07:56 PDT
http://trac.webkit.org/changeset/174915