st/mesa: add a notify_before_flush callback param to flush

The new callback is called right before the flush is done to allow
users of st->flush to do some work after all the previous work has
been flushed.

This will be used by dri_flush in the next commit.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2019-11-27 11:22:11 +01:00
parent f5c1cb2383
commit cc0d0afe3b
11 changed files with 28 additions and 20 deletions

View File

@ -389,7 +389,9 @@ struct st_context_iface
* Flush all drawing from context to the pipe also flushes the pipe.
*/
void (*flush)(struct st_context_iface *stctxi, unsigned flags,
struct pipe_fence_handle **fence);
struct pipe_fence_handle **fence,
void (*notify_before_flush_cb) (void*),
void* notify_before_flush_cb_args);
/**
* Replace the texture image of a texture object at the specified level.

View File

@ -1517,11 +1517,11 @@ dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
if (flush_flag == __BLIT_FLAG_FLUSH) {
pipe->flush_resource(pipe, dst->texture);
ctx->st->flush(ctx->st, 0, NULL);
ctx->st->flush(ctx->st, 0, NULL, NULL, NULL);
} else if (flush_flag == __BLIT_FLAG_FINISH) {
screen = dri_screen(ctx->sPriv)->base.screen;
pipe->flush_resource(pipe, dst->texture);
ctx->st->flush(ctx->st, 0, &fence);
ctx->st->flush(ctx->st, 0, &fence, NULL, NULL);
(void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE);
screen->fence_reference(screen, &fence, NULL);
}

View File

@ -241,7 +241,7 @@ dri_destroy_context(__DRIcontext * cPriv)
* to avoid having to add code elsewhere to cope with flushing a
* partially destroyed context.
*/
ctx->st->flush(ctx->st, 0, NULL);
ctx->st->flush(ctx->st, 0, NULL, NULL, NULL);
ctx->st->destroy(ctx->st);
free(ctx);
}

View File

@ -499,7 +499,7 @@ dri_flush(__DRIcontext *cPriv,
struct pipe_screen *screen = drawable->screen->base.screen;
struct pipe_fence_handle *new_fence = NULL;
st->flush(st, flush_flags, &new_fence);
st->flush(st, flush_flags, &new_fence, args.ctx ? notify_before_flush_cb : NULL, &args);
/* throttle on the previous fence */
if (drawable->throttle_fence) {
@ -509,7 +509,7 @@ dri_flush(__DRIcontext *cPriv,
drawable->throttle_fence = new_fence;
}
else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) {
st->flush(st, flush_flags, NULL);
st->flush(st, flush_flags, NULL, NULL, NULL);
}
if (drawable) {

View File

@ -97,7 +97,7 @@ dri2_create_fence(__DRIcontext *_ctx)
if (!fence)
return NULL;
stapi->flush(stapi, 0, &fence->pipe_fence);
stapi->flush(stapi, 0, &fence->pipe_fence, NULL, NULL);
if (!fence->pipe_fence) {
FREE(fence);
@ -117,7 +117,7 @@ dri2_create_fence_fd(__DRIcontext *_ctx, int fd)
if (fd == -1) {
/* exporting driver created fence, flush: */
stapi->flush(stapi, ST_FLUSH_FENCE_FD, &fence->pipe_fence);
stapi->flush(stapi, ST_FLUSH_FENCE_FD, &fence->pipe_fence, NULL, NULL);
} else {
/* importing a foreign fence fd: */
ctx->create_fence_fd(ctx, &fence->pipe_fence, fd, PIPE_FD_TYPE_NATIVE_SYNC);

View File

@ -249,7 +249,7 @@ drisw_swap_buffers(__DRIdrawable *dPriv)
if (ctx->hud)
hud_run(ctx->hud, ctx->st->cso_context, ptex);
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
drisw_copy_to_front(dPriv, ptex);
}
@ -272,7 +272,7 @@ drisw_copy_sub_buffer(__DRIdrawable *dPriv, int x, int y,
if (ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
u_box_2d(x, dPriv->h - y - h, w, h, &box);
drisw_present_texture(dPriv, ptex, &box);

View File

@ -1358,7 +1358,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
}
if (xmctx && xmctx->xm_buffer == b) {
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL);
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
}
xmesa_swap_st_framebuffer(b->stfb);
@ -1373,7 +1373,7 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
{
XMesaContext xmctx = XMesaGetCurrentContext();
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL);
xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
xmesa_copy_st_framebuffer(b->stfb,
ST_ATTACHMENT_BACK_LEFT, ST_ATTACHMENT_FRONT_LEFT,
@ -1388,7 +1388,7 @@ void XMesaFlush( XMesaContext c )
XMesaDisplay xmdpy = xmesa_init_display(c->xm_visual->display);
struct pipe_fence_handle *fence = NULL;
c->st->flush(c->st, ST_FLUSH_FRONT, &fence);
c->st->flush(c->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
if (fence) {
xmdpy->screen->fence_finish(xmdpy->screen, NULL, fence,
PIPE_TIMEOUT_INFINITE);

View File

@ -448,10 +448,11 @@ stw_make_current(HDC hDrawDC, HDC hReadDC, DHGLRC dhglrc)
if (old_ctx->shared) {
struct pipe_fence_handle *fence = NULL;
old_ctx->st->flush(old_ctx->st,
ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence);
ST_FLUSH_FRONT | ST_FLUSH_WAIT, &fence,
NULL, NULL);
}
else {
old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL);
old_ctx->st->flush(old_ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
}
}
}

View File

@ -647,7 +647,7 @@ DrvSwapBuffers(HDC hdc)
if (ctx->current_framebuffer == fb) {
/* flush current context */
ctx->st->flush(ctx->st, ST_FLUSH_END_OF_FRAME, NULL);
ctx->st->flush(ctx->st, ST_FLUSH_END_OF_FRAME, NULL, NULL, NULL);
}
}

View File

@ -243,7 +243,7 @@ GalliumContext::DestroyContext(context_id contextID)
return;
if (fContext[contextID]->st) {
fContext[contextID]->st->flush(fContext[contextID]->st, 0, NULL);
fContext[contextID]->st->flush(fContext[contextID]->st, 0, NULL, NULL, NULL);
fContext[contextID]->st->destroy(fContext[contextID]->st);
}
@ -297,7 +297,7 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID)
if (oldContextID > 0 && oldContextID != contextID) {
fContext[oldContextID]->st->flush(fContext[oldContextID]->st,
ST_FLUSH_FRONT, NULL);
ST_FLUSH_FRONT, NULL, NULL, NULL);
}
// We need to lock and unlock framebuffers before accessing them
@ -333,7 +333,7 @@ GalliumContext::SwapBuffers(context_id contextID)
ERROR("%s: context not found\n", __func__);
return B_ERROR;
}
context->st->flush(context->st, ST_FLUSH_FRONT, NULL);
context->st->flush(context->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
struct hgl_buffer* buffer = hgl_st_framebuffer(context->draw->stfbi);
pipe_surface* surface = buffer->surface;

View File

@ -649,7 +649,9 @@ st_framebuffers_purge(struct st_context *st)
static void
st_context_flush(struct st_context_iface *stctxi, unsigned flags,
struct pipe_fence_handle **fence)
struct pipe_fence_handle **fence,
void (*before_flush_cb) (void*),
void* args)
{
struct st_context *st = (struct st_context *) stctxi;
unsigned pipe_flags = 0;
@ -661,6 +663,9 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
FLUSH_VERTICES(st->ctx, 0);
FLUSH_CURRENT(st->ctx, 0);
/* Notify the caller that we're ready to flush */
if (before_flush_cb)
before_flush_cb(args);
st_flush(st, fence, pipe_flags);
if ((flags & ST_FLUSH_WAIT) && fence && *fence) {