glx/kopper: Wire up a way for SwapBuffers to fail

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16038>
This commit is contained in:
Adam Jackson
2022-04-26 16:01:20 -04:00
committed by Marge Bot
parent 0394f35424
commit c865416f44
4 changed files with 24 additions and 6 deletions

View File

@@ -73,6 +73,7 @@ struct __DRIkopperExtensionRec {
const __DRIconfig *config, const __DRIconfig *config,
void *loaderPrivate, void *loaderPrivate,
int pixmap); int pixmap);
int64_t (*swapBuffers)(__DRIdrawable *draw);
}; };
/** /**

View File

@@ -812,29 +812,41 @@ kopper_create_buffer(__DRIscreen * sPriv,
return TRUE; return TRUE;
} }
static void static int64_t
kopper_swap_buffers(__DRIdrawable *dPriv) kopperSwapBuffers(__DRIdrawable *dPriv)
{ {
struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv); struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
struct dri_drawable *drawable = dri_drawable(dPriv); struct dri_drawable *drawable = dri_drawable(dPriv);
struct kopper_drawable *kdraw = (struct kopper_drawable *)drawable;
struct pipe_resource *ptex; struct pipe_resource *ptex;
if (!ctx) if (!ctx)
return; return 0;
ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT]; ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
if (!ptex) if (!ptex)
return; return 0;
drawable->texture_stamp = dPriv->lastStamp - 1; drawable->texture_stamp = dPriv->lastStamp - 1;
dri_flush(dPriv->driContextPriv, dPriv, __DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT, __DRI2_THROTTLE_SWAPBUFFER); dri_flush(dPriv->driContextPriv, dPriv, __DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT, __DRI2_THROTTLE_SWAPBUFFER);
kopper_copy_to_front(ctx->st->pipe, dPriv, ptex); kopper_copy_to_front(ctx->st->pipe, dPriv, ptex);
if (!kdraw->is_pixmap && !zink_kopper_check(ptex))
return -1;
if (!drawable->textures[ST_ATTACHMENT_FRONT_LEFT]) { if (!drawable->textures[ST_ATTACHMENT_FRONT_LEFT]) {
return; return 0;
} }
/* have to manually swap the pointers here to make frontbuffer readback work */ /* have to manually swap the pointers here to make frontbuffer readback work */
drawable->textures[ST_ATTACHMENT_BACK_LEFT] = drawable->textures[ST_ATTACHMENT_FRONT_LEFT]; drawable->textures[ST_ATTACHMENT_BACK_LEFT] = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
drawable->textures[ST_ATTACHMENT_FRONT_LEFT] = ptex; drawable->textures[ST_ATTACHMENT_FRONT_LEFT] = ptex;
return 0;
}
static void
kopper_swap_buffers(__DRIdrawable *dPriv)
{
kopperSwapBuffers(dPriv);
} }
static __DRIdrawable * static __DRIdrawable *
@@ -878,6 +890,7 @@ kopperCreateNewDrawable(__DRIscreen *screen,
const __DRIkopperExtension driKopperExtension = { const __DRIkopperExtension driKopperExtension = {
.base = { __DRI_KOPPER, 1 }, .base = { __DRI_KOPPER, 1 },
.createNewDrawable = kopperCreateNewDrawable, .createNewDrawable = kopperCreateNewDrawable,
.swapBuffers = kopperSwapBuffers,
}; };
const struct __DriverAPIRec galliumvk_driver_api = { const struct __DriverAPIRec galliumvk_driver_api = {

View File

@@ -731,6 +731,9 @@ driswSwapBuffers(__GLXDRIdrawable * pdraw,
glFlush(); glFlush();
} }
if (psc->kopper)
return psc->kopper->swapBuffers (pdp->driDrawable);
(*psc->core->swapBuffers) (pdp->driDrawable); (*psc->core->swapBuffers) (pdp->driDrawable);
return 0; return 0;

View File

@@ -860,7 +860,8 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
if (pdraw != NULL) { if (pdraw != NULL) {
Bool flush = gc != &dummyContext && drawable == gc->currentDrawable; Bool flush = gc != &dummyContext && drawable == gc->currentDrawable;
pdraw->psc->driScreen->swapBuffers(pdraw, 0, 0, 0, flush); if (pdraw->psc->driScreen->swapBuffers(pdraw, 0, 0, 0, flush) == -1)
__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
return; return;
} }
} }