[Mesa-dev] [PATCH] st/xorg: flush after loading the cursor
Marcin Slusarz
marcin.slusarz at gmail.com
Tue May 3 02:45:01 PDT 2011
On Tue, May 03, 2011 at 09:40:55AM +0200, Michel Dänzer wrote:
> On Mon, 2011-05-02 at 21:26 +0200, Marcin Slusarz wrote:
> > On Mon, May 02, 2011 at 08:57:25AM +0200, Michel Dänzer wrote:
> > > On Mon, 2011-05-02 at 00:01 +0200, Marcin Slusarz wrote:
> > > > We need cursor data to land in destination buffer before drmModeSetCursor.
> > > > It fixes "cursor lag" at least on nv50.
> > > > ---
> > > > src/gallium/state_trackers/xorg/xorg_crtc.c | 1 +
> > > > 1 files changed, 1 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
> > > > index b8d9474..e8ca631 100644
> > > > --- a/src/gallium/state_trackers/xorg/xorg_crtc.c
> > > > +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
> > > > @@ -247,6 +247,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
> > > > 64, 64, (void*)image, 64 * 4, 0, 0);
> > > > ms->ctx->transfer_unmap(ms->ctx, transfer);
> > > > ms->ctx->transfer_destroy(ms->ctx, transfer);
> > > > + ms->ctx->flush(ms->ctx, NULL);
> > > >
> > > > if (crtc->cursor_shown)
> > > > drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
> > >
> > > To guarantee that the data lands before drmModeSetCursor, you'd have to
> > > take a fence from the flush and finish that as well.
> > >
> >
> > Thanks!
> >
> > Updated patch below.
>
> Actually, it looks like an incremental patch against the previous
> version. A real updated patch would be better.
Yes. I forgot to join them. Sorry.
>
> > + ctx->transfer_unmap(ctx, transfer);
> > + ctx->transfer_destroy(ctx, transfer);
> > + ctx->flush(ctx, &fence);
> > +
> > + if (fence) {
> > + screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
> > + screen->fence_reference(screen, &fence, NULL);
> > + }
>
> This looks good.
Thanks.
New patch below.
---
From: Marcin Slusarz <marcin.slusarz at gmail.com>
Subject: [PATCH v3] st/xorg: flush after loading the cursor
We need cursor data to land in destination buffer before drmModeSetCursor.
It fixes "cursor lag" on nv50.
---
src/gallium/state_trackers/xorg/xorg_crtc.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 8eaf414..0499ed1 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -210,6 +210,9 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
modesettingPtr ms = modesettingPTR(crtc->scrn);
struct crtc_private *crtcp = crtc->driver_private;
struct pipe_transfer *transfer;
+ struct pipe_fence_handle *fence = NULL;
+ struct pipe_context *ctx = ms->ctx;
+ struct pipe_screen *screen = ms->screen;
if (!crtcp->cursor_tex) {
struct pipe_resource templat;
@@ -230,23 +233,28 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- crtcp->cursor_tex = ms->screen->resource_create(ms->screen,
- &templat);
- ms->screen->resource_get_handle(ms->screen, crtcp->cursor_tex, &whandle);
+ crtcp->cursor_tex = screen->resource_create(screen, &templat);
+ screen->resource_get_handle(screen, crtcp->cursor_tex, &whandle);
crtcp->cursor_handle = whandle.handle;
}
- transfer = pipe_get_transfer(ms->ctx, crtcp->cursor_tex,
+ transfer = pipe_get_transfer(ctx, crtcp->cursor_tex,
0, 0,
PIPE_TRANSFER_WRITE,
0, 0, 64, 64);
- ptr = ms->ctx->transfer_map(ms->ctx, transfer);
+ ptr = ctx->transfer_map(ctx, transfer);
util_copy_rect(ptr, crtcp->cursor_tex->format,
transfer->stride, 0, 0,
64, 64, (void*)image, 64 * 4, 0, 0);
- ms->ctx->transfer_unmap(ms->ctx, transfer);
- ms->ctx->transfer_destroy(ms->ctx, transfer);
+ ctx->transfer_unmap(ctx, transfer);
+ ctx->transfer_destroy(ctx, transfer);
+ ctx->flush(ctx, &fence);
+
+ if (fence) {
+ screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
+ screen->fence_reference(screen, &fence, NULL);
+ }
if (crtc->cursor_shown)
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
--
1.7.4.1
More information about the mesa-dev
mailing list