Call glFlush after eglCreateSync, not before#15
Call glFlush after eglCreateSync, not before#15kbrenneman wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
In SyncRendering, when we need to create a new syncfd, call glFlush after eglCreateSync, not before. According to the EGL_ANDROID_native_fence_sync spec, when you create a new EGLSync, it's not until the next flush that it'll assign the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute.
| goto done; | ||
| } | ||
|
|
||
| pwin->inst->platform->priv->egl.Flush(); |
There was a problem hiding this comment.
Despite what the spec claims, this isn't actually how our implementation behaves. It flushes internally during CreateSync() and attaches the fence created by that flush operation. I think this was and is still just perturbing some timing/race if it affects anything at all.
There was a problem hiding this comment.
That's possible -- I'm still trying to make sense of that myself.
But at the very least, this is the one sequence that the spec requires to work, so even if there's a driver bug lurking, this should continue to work once it's fixed, right?
There was a problem hiding this comment.
In that it won't make things worse, yes. I just worry there's a worse bug somewhere that this continues to paper over. This might actually break the papering over, in that the after-create flush will probably get reduced to a no-op by the driver logic.
There was a problem hiding this comment.
Thus far, I haven't managed to get an incorrect result, short of trying to draw a frame that takes long enough to cause timeouts (in which case the result is identical to the current code).
The fact that eglQuerySync without a glFlush gets signaled at the wrong point does suggest a driver bug, but matching the spec seems like the best hedge against whatever changes in driver behavior might happen in the future.
Strictly speaking, with the current code in egl-x11, the EGLSync isn't even required to be signaled at all.
By the EGL_ANDROID_native_fence_sync spec, when you create a fence with eglCreateSync, the file descriptor isn't valid until the next glFlush, so we should be calling glFlush after eglCreateSync, not before.