[Mesa-dev] [PATCH kmscube 3/4] atomic: Duplicate fence before SwapBuffers
Rob Clark
robdclark at gmail.com
Tue May 2 13:49:00 UTC 2017
On Tue, May 2, 2017 at 6:52 AM, Daniel Stone <daniels at collabora.com> wrote:
> Duplicating the fence before we flush means that the implementation can
> know that the fence needs to be CPU-visible. After flush it may be too
> late.
I think this is papering over an i965 bug.. in fact doing the
DupNativeFenceFD could trigger a flush which you don't actually want
on a tiler.
The corresponding wording in the spec:
After associating the fence command with an EGL native fence sync object,
the next Flush() operation performed by the current client API causes a
new native fence object to be created, and the
EGL_SYNC_NATIVE_FENCE_ANDROID attribute of the EGL native fence object is
set to a file descriptor that refers to the new native fence object. This
new native fence object is signaled when the EGL native fence sync object
is signaled.
Plus, errors for eglDupNativeFenceFDANDROID():
* If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute of <sync> is
EGL_NO_NATIVE_FENCE_FD_ANDROID, EGL_NO_NATIVE_FENCE_FD_ANDROID is
returned and an EGL_BAD_PARAMETER error is generated.
It could be worded more explicitly, but taking those two together, I
think the correct behavior is to call eglDupNativeFenceFDANDROID()
after the flush/swap.
And I guess we need a better piglit test ;-)
BR,
-R
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
> drm-atomic.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drm-atomic.c b/drm-atomic.c
> index 65caacd..25e04b1 100644
> --- a/drm-atomic.c
> +++ b/drm-atomic.c
> @@ -230,16 +230,12 @@ static int atomic_run(const struct gbm *gbm, const struct egl *egl)
> */
> gpu_fence = create_fence(egl, EGL_NO_NATIVE_FENCE_FD_ANDROID);
> assert(gpu_fence);
> -
> - eglSwapBuffers(egl->display, egl->surface);
> -
> - /* after swapbuffers, gpu_fence should be flushed, so safe
> - * to get fd:
> - */
> drm.kms_in_fence_fd = egl->eglDupNativeFenceFDANDROID(egl->display, gpu_fence);
> egl->eglDestroySyncKHR(egl->display, gpu_fence);
> assert(drm.kms_in_fence_fd != -1);
>
> + eglSwapBuffers(egl->display, egl->surface);
> +
> next_bo = gbm_surface_lock_front_buffer(gbm->surface);
> fb = drm_fb_get_from_bo(next_bo);
> if (!fb) {
> --
> 2.12.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list