From 598cc1f74d7ae924e84dee801b456ab7b0b22f84 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 21 Dec 2012 17:03:22 +0100 Subject: gallium: extend pipe_context::flush for it to accept an END_OF_FRAME flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Usage with pipe_context: pipe->flush(pipe, NULL, PIPE_FLUSH_END_OF_FRAME); Usage with st_context_iface: st->flush(st, ST_FLUSH_END_OF_FRAME, NULL); The flag is only a hint for drivers. Radeon will use it for buffer eviction heuristics in the kernel (e.g. for queries like how many frames have passed since a buffer was used). The flag is currently only generated by st/dri on SwapBuffers. Reviewed-by: Brian Paul Reviewed-by: Stéphane Marchesin --- src/gallium/state_trackers/clover/core/queue.cpp | 2 +- src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp | 2 +- src/gallium/state_trackers/dri/common/dri_drawable.c | 2 ++ src/gallium/state_trackers/dri/drm/dri2.c | 2 +- src/gallium/state_trackers/egl/android/native_android.cpp | 2 +- src/gallium/state_trackers/egl/common/native_helper.c | 4 ++-- src/gallium/state_trackers/vdpau/presentation.c | 2 +- src/gallium/state_trackers/vdpau/surface.c | 2 +- src/gallium/state_trackers/vega/api_context.c | 4 ++-- src/gallium/state_trackers/vega/vg_manager.c | 8 +++++++- src/gallium/state_trackers/xa/xa_composite.c | 2 +- src/gallium/state_trackers/xa/xa_context.c | 8 ++++---- src/gallium/state_trackers/xa/xa_tracker.c | 2 +- src/gallium/state_trackers/xa/xa_yuv.c | 2 +- src/gallium/state_trackers/xorg/xorg_crtc.c | 2 +- src/gallium/state_trackers/xorg/xorg_dri2.c | 4 ++-- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- src/gallium/state_trackers/xorg/xorg_exa.c | 2 +- src/gallium/state_trackers/xvmc/surface.c | 2 +- 19 files changed, 32 insertions(+), 24 deletions(-) (limited to 'src/gallium/state_trackers') diff --git a/src/gallium/state_trackers/clover/core/queue.cpp b/src/gallium/state_trackers/clover/core/queue.cpp index 7e476c715e0..cd961efbf2f 100644 --- a/src/gallium/state_trackers/clover/core/queue.cpp +++ b/src/gallium/state_trackers/clover/core/queue.cpp @@ -53,7 +53,7 @@ _cl_command_queue::flush() { [](event_ptr &ev) { return !ev->signalled(); }); // Flush and fence them. - pipe->flush(pipe, &fence); + pipe->flush(pipe, &fence, 0); std::for_each(first, last, [&](event_ptr &ev) { ev->fence(fence); }); screen->fence_reference(screen, &fence, NULL); queued_events.erase(first, last); diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp index dc63fb90704..2b03dfe5a93 100644 --- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp @@ -1234,7 +1234,7 @@ struct GalliumDXGISwapChain : public GalliumDXGIObjectsurface_destroy(pipe, dst_surface); - pipe->flush(pipe, 0); + pipe->flush(pipe, NULL, 0); memset(&ctrl, 0, sizeof(ctrl)); ctrl.natt = (db) ? NATIVE_ATTACHMENT_BACK_LEFT : NATIVE_ATTACHMENT_FRONT_LEFT; diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index ee4d11d1495..2ea54781d17 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -441,6 +441,8 @@ dri_flush(__DRIcontext *cPriv, flush_flags = 0; if (flags & __DRI2_FLUSH_CONTEXT) flush_flags |= ST_FLUSH_FRONT; + if (reason == __DRI2_THROTTLE_SWAPBUFFER) + flush_flags |= ST_FLUSH_END_OF_FRAME; /* Flush the context and throttle if needed. */ if (dri_screen(ctx->sPriv)->throttling_enabled && diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 7f4f2f00c77..f8d311ca8fa 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -420,7 +420,7 @@ dri2_flush_frontbuffer(struct dri_context *ctx, struct pipe_context *pipe = ctx->st->pipe; dri_msaa_resolve(ctx, drawable, ST_ATTACHMENT_FRONT_LEFT); - pipe->flush(pipe, NULL); + pipe->flush(pipe, NULL, 0); } if (loader->flushFrontBuffer) { diff --git a/src/gallium/state_trackers/egl/android/native_android.cpp b/src/gallium/state_trackers/egl/android/native_android.cpp index 01d3a02d364..267727d5d99 100644 --- a/src/gallium/state_trackers/egl/android/native_android.cpp +++ b/src/gallium/state_trackers/egl/android/native_android.cpp @@ -387,7 +387,7 @@ copy_resources(struct native_display *ndpy, u_box_origin_2d(src->width0, src->height0, &box); pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &box); - pipe->flush(pipe, NULL); + pipe->flush(pipe, NULL, 0); } static boolean diff --git a/src/gallium/state_trackers/egl/common/native_helper.c b/src/gallium/state_trackers/egl/common/native_helper.c index ebe5144b367..99259b816c0 100644 --- a/src/gallium/state_trackers/egl/common/native_helper.c +++ b/src/gallium/state_trackers/egl/common/native_helper.c @@ -352,7 +352,7 @@ resource_surface_flush(struct resource_surface *rsurf, if (!pipe) return FALSE; - pipe->flush(pipe, &fence); + pipe->flush(pipe, &fence, 0); if (fence == NULL) return FALSE; @@ -398,7 +398,7 @@ native_display_copy_to_pixmap(struct native_display *ndpy, u_box_origin_2d(src->width0, src->height0, &src_box); pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &src_box); - pipe->flush(pipe, NULL); + pipe->flush(pipe, NULL, 0); memset(&ctrl, 0, sizeof(ctrl)); ctrl.natt = natt; diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c index 349654d0625..3dd7f05375e 100644 --- a/src/gallium/state_trackers/vdpau/presentation.c +++ b/src/gallium/state_trackers/vdpau/presentation.c @@ -275,7 +275,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, ); pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL); - pipe->flush(pipe, &surf->fence); + pipe->flush(pipe, &surf->fence, 0); if (dump_window == -1) { dump_window = debug_get_num_option("VDPAU_DUMP", 0); diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index c987979f1f4..5c06f8511aa 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -359,5 +359,5 @@ vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf) pipe->clear_render_target(pipe, surfaces[i], &c, 0, 0, surfaces[i]->width, surfaces[i]->height); } - pipe->flush(pipe, NULL); + pipe->flush(pipe, NULL, 0); } diff --git a/src/gallium/state_trackers/vega/api_context.c b/src/gallium/state_trackers/vega/api_context.c index 19e42dd1562..055277cd76e 100644 --- a/src/gallium/state_trackers/vega/api_context.c +++ b/src/gallium/state_trackers/vega/api_context.c @@ -56,7 +56,7 @@ void vegaFlush(void) return; pipe = ctx->pipe; - pipe->flush(pipe, NULL); + pipe->flush(pipe, NULL, 0); vg_manager_flush_frontbuffer(ctx); } @@ -72,7 +72,7 @@ void vegaFinish(void) pipe = ctx->pipe; - pipe->flush(pipe, &fence); + pipe->flush(pipe, &fence, 0); if (fence) { pipe->screen->fence_finish(pipe->screen, fence, PIPE_TIMEOUT_INFINITE); diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c index c8531f8b53a..7b35f3afeeb 100644 --- a/src/gallium/state_trackers/vega/vg_manager.c +++ b/src/gallium/state_trackers/vega/vg_manager.c @@ -143,7 +143,13 @@ vg_context_flush(struct st_context_iface *stctxi, unsigned flags, struct pipe_fence_handle **fence) { struct vg_context *ctx = (struct vg_context *) stctxi; - ctx->pipe->flush(ctx->pipe, fence); + enum pipe_flush_flags pipe_flags = 0; + + if (flags & ST_FLUSH_END_OF_FRAME) { + pipe_flags |= PIPE_FLUSH_END_OF_FRAME; + } + + ctx->pipe->flush(ctx->pipe, fence, pipe_flags); if (flags & ST_FLUSH_FRONT) vg_manager_flush_frontbuffer(ctx); } diff --git a/src/gallium/state_trackers/xa/xa_composite.c b/src/gallium/state_trackers/xa/xa_composite.c index 17d2d7f727d..eb949b93cd1 100644 --- a/src/gallium/state_trackers/xa/xa_composite.c +++ b/src/gallium/state_trackers/xa/xa_composite.c @@ -527,7 +527,7 @@ XA_EXPORT void xa_composite_done(struct xa_context *ctx) { renderer_draw_flush(ctx); - ctx->pipe->flush(ctx->pipe, &ctx->last_fence); + ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0); ctx->comp = NULL; ctx->has_solid_color = FALSE; diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c index 7b7a90343df..b31d555c50a 100644 --- a/src/gallium/state_trackers/xa/xa_context.c +++ b/src/gallium/state_trackers/xa/xa_context.c @@ -119,7 +119,7 @@ xa_surface_dma(struct xa_context *ctx, } pipe->transfer_unmap(pipe, transfer); if (to_surface) - pipe->flush(pipe, &ctx->last_fence); + pipe->flush(pipe, &ctx->last_fence, 0); } return XA_ERR_NONE; } @@ -244,9 +244,9 @@ xa_copy_done(struct xa_context *ctx) { if (!ctx->simple_copy) { renderer_draw_flush(ctx); - ctx->pipe->flush(ctx->pipe, &ctx->last_fence); + ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0); } else - ctx->pipe->flush(ctx->pipe, &ctx->last_fence); + ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0); } static void @@ -325,7 +325,7 @@ XA_EXPORT void xa_solid_done(struct xa_context *ctx) { renderer_draw_flush(ctx); - ctx->pipe->flush(ctx->pipe, &ctx->last_fence); + ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0); ctx->comp = NULL; ctx->has_solid_color = FALSE; diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c index 8bd40ddc7d2..3410144141d 100644 --- a/src/gallium/state_trackers/xa/xa_tracker.c +++ b/src/gallium/state_trackers/xa/xa_tracker.c @@ -407,7 +407,7 @@ xa_surface_redefine(struct xa_surface *srf, xa_min(save_height, template->height0), &src_box); pipe->resource_copy_region(pipe, texture, 0, 0, 0, 0, srf->tex, 0, &src_box); - pipe->flush(pipe, &xa->default_ctx->last_fence); + pipe->flush(pipe, &xa->default_ctx->last_fence, 0); } pipe_resource_reference(&srf->tex, texture); diff --git a/src/gallium/state_trackers/xa/xa_yuv.c b/src/gallium/state_trackers/xa/xa_yuv.c index 912ea77c753..9c7c4d68781 100644 --- a/src/gallium/state_trackers/xa/xa_yuv.c +++ b/src/gallium/state_trackers/xa/xa_yuv.c @@ -153,7 +153,7 @@ xa_yuv_planar_blit(struct xa_context *r, box++; } - r->pipe->flush(r->pipe, &r->last_fence); + r->pipe->flush(r->pipe, &r->last_fence, 0); xa_ctx_sampler_views_destroy(r); xa_ctx_srf_destroy(r); diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 11888096e66..3cbffb59802 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -248,7 +248,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) transfer->stride, 0, 0, 64, 64, (void*)image, 64 * 4, 0, 0); ctx->transfer_unmap(ctx, transfer); - ctx->flush(ctx, &fence); + ctx->flush(ctx, &fence, 0); if (fence) { screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 04e6a211def..fb50ef8ca11 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -336,7 +336,7 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, /* pixmap glXWaitX */ if (pSrcBuffer->attachment == DRI2BufferFrontLeft && pDestBuffer->attachment == DRI2BufferFakeFrontLeft) { - ms->ctx->flush(ms->ctx, NULL); + ms->ctx->flush(ms->ctx, NULL, 0); return; } /* pixmap glXWaitGL */ @@ -394,7 +394,7 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, ms->ctx->flush(ms->ctx, (pDestBuffer->attachment == DRI2BufferFrontLeft && ms->swapThrottling) ? - &dst_priv->fence : NULL); + &dst_priv->fence : NULL, 0); if (cust && cust->winsys_context_throttle) cust->winsys_context_throttle(cust, ms->ctx, THROTTLE_RENDER); diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 69038d9ef47..9d7713c8f5d 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -551,7 +551,7 @@ void xorg_flush(ScreenPtr pScreen) ms->ctx->flush(ms->ctx, ms->dirtyThrottling ? &ms->fence[XORG_NR_FENCES-1] : - NULL); + NULL, 0); if (ms->dirtyThrottling) { if (ms->fence[0]) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index d78ab74aeef..f010be65227 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -1071,7 +1071,7 @@ xorg_gpu_surface(struct pipe_context *pipe, struct exa_pixmap_priv *priv) void xorg_exa_flush(struct exa_context *exa, struct pipe_fence_handle **fence) { - exa->pipe->flush(exa->pipe, fence); + exa->pipe->flush(exa->pipe, fence, 0); } void xorg_exa_finish(struct exa_context *exa) diff --git a/src/gallium/state_trackers/xvmc/surface.c b/src/gallium/state_trackers/xvmc/surface.c index fd3f26c5070..99d2d7072a1 100644 --- a/src/gallium/state_trackers/xvmc/surface.c +++ b/src/gallium/state_trackers/xvmc/surface.c @@ -434,7 +434,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable, vl_compositor_set_layer_dst_area(cstate, 1, &dst_rect); vl_compositor_render(cstate, compositor, surf, dirty_area); - pipe->flush(pipe, &surface_priv->fence); + pipe->flush(pipe, &surface_priv->fence, 0); XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for display. Pushing to front buffer.\n", surface); -- cgit v1.2.3