mesa/st, dri2, wgl, glx: Modify flush_objects interop func to export a fence_fd

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305>
This commit is contained in:
Antonio Gomes 2023-10-24 17:31:15 -03:00 committed by Marge Bot
parent 663cef26d0
commit 1396dc1c38
16 changed files with 45 additions and 39 deletions

View file

@ -462,7 +462,7 @@ struct __DRI2interopExtensionRec {
*/
int (*flush_objects)(__DRIcontext *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
GLsync *sync, int *fence_fd);
};

View file

@ -363,13 +363,14 @@ wglMesaGLInteropExportObject(HDC dpy, HGLRC context,
* \param count number of resources
* \param resources resources to flush
* \param sync optional GLsync to map to CL event
* \param fence_fd optional fence_fd to use in CL
*
* \return MESA_GLINTEROP_SUCCESS or MESA_GLINTEROP_* != 0 on error
*/
int
MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *context,
unsigned count, struct mesa_glinterop_export_in *resources,
GLsync *sync);
GLsync *sync, int *fence_fd);
/**
* Same as MesaGLInteropGLXFlushObjects except that it accepts
@ -378,11 +379,11 @@ MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *cont
int
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context,
unsigned count, struct mesa_glinterop_export_in *resources,
GLsync *sync);
GLsync *sync, int *fence_fd);
/**
* Same as MesaGLInteropGLXFlushObjects except that it accepts
* HDC and HGLRC.
* HDC and HGLRC, and not a fence_fd.
*/
int
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
@ -407,10 +408,10 @@ typedef int (*PFNWGLMESAGLINTEROPEXPORTOBJECTPROC)(HDC dpy, HGLRC context,
struct mesa_glinterop_export_out *out);
typedef int (*PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC)(struct _XDisplay *dpy, struct __GLXcontextRec *context,
unsigned count, struct mesa_glinterop_export_in *resources,
GLsync *sync);
GLsync *sync, int *fence_fd);
typedef int (*PFNMESAGLINTEROPEGLFLUSHOBJECTSPROC)(EGLDisplay dpy, EGLContext context,
unsigned count, struct mesa_glinterop_export_in *resources,
GLsync *sync);
GLsync *sync, int *fence_fd);
typedef int (*PFNWGLMESAGLINTEROPFLUSHOBJECTSPROC)(HDC dpy, HGLRC context,
unsigned count, struct mesa_glinterop_export_in *resources,
GLsync *sync);

View file

@ -3664,7 +3664,7 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
static int
dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
@ -3673,7 +3673,7 @@ dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
return MESA_GLINTEROP_UNSUPPORTED;
return dri2_dpy->interop->flush_objects(dri2_ctx->dri_context, count,
objects, sync);
objects, sync, fence_fd);
}
const _EGLDriver _eglDriver = {

View file

@ -1164,7 +1164,7 @@ wgl_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
static int
wgl_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct wgl_egl_context *wgl_ctx = wgl_egl_context(ctx);
return stw_interop_flush_objects(wgl_ctx->ctx, count, objects, sync);

View file

@ -2899,7 +2899,7 @@ MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
PUBLIC int
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
_EGLDisplay *disp;
_EGLContext *ctx;
@ -2910,8 +2910,8 @@ MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
return ret;
if (disp->Driver->GLInteropFlushObjects)
ret =
disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, sync);
ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, sync,
fence_fd);
else
ret = MESA_GLINTEROP_UNSUPPORTED;

View file

@ -208,7 +208,7 @@ struct _egl_driver {
int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx,
unsigned count,
struct mesa_glinterop_export_in *in,
GLsync *sync);
GLsync *sync, int *fence_fd);
/* for EGL_EXT_image_dma_buf_import_modifiers */
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats,

View file

@ -2098,9 +2098,9 @@ dri2_interop_export_object(__DRIcontext *_ctx,
static int
dri2_interop_flush_objects(__DRIcontext *_ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
return st_interop_flush_objects(dri_context(_ctx)->st, count, objects, sync);
return st_interop_flush_objects(dri_context(_ctx)->st, count, objects, sync, fence_fd);
}
static const __DRI2interopExtension dri2InteropExtension = {

View file

@ -112,6 +112,6 @@ stw_interop_flush_objects(struct stw_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
{
return st_interop_flush_objects(ctx->st, count, objects, sync);
return st_interop_flush_objects(ctx->st, count, objects, sync, NULL);
}

View file

@ -83,7 +83,7 @@ dri2_interop_export_object(struct glx_context *ctx,
_X_HIDDEN int
dri2_interop_flush_objects(struct glx_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
GLsync *sync, int *fence_fd);
#ifdef __cplusplus
}

View file

@ -143,4 +143,4 @@ dri3_interop_export_object(struct glx_context *ctx,
_X_HIDDEN int
dri3_interop_flush_objects(struct glx_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
GLsync *sync, int *fence_fd);

View file

@ -60,14 +60,14 @@ dri2_interop_export_object(struct glx_context *ctx,
_X_HIDDEN int
dri2_interop_flush_objects(struct glx_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
if (!psc->interop || psc->interop->base.version < 2)
return MESA_GLINTEROP_UNSUPPORTED;
return psc->interop->flush_objects(ctx->driContext, count, objects, sync);
return psc->interop->flush_objects(ctx->driContext, count, objects, sync, fence_fd);
}
#if defined(HAVE_DRI3)
@ -100,14 +100,14 @@ dri3_interop_export_object(struct glx_context *ctx,
_X_HIDDEN int
dri3_interop_flush_objects(struct glx_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
if (!psc->interop || psc->interop->base.version < 2)
return MESA_GLINTEROP_UNSUPPORTED;
return psc->interop->flush_objects(ctx->driContext, count, objects, sync);
return psc->interop->flush_objects(ctx->driContext, count, objects, sync, fence_fd);
}
#endif /* HAVE_DRI3 */

View file

@ -333,7 +333,7 @@ static int dispatch_GLInteropExportObjectMESA(Display *dpy, GLXContext ctx,
static int dispatch_GLInteropFlushObjectsMESA(Display *dpy, GLXContext ctx,
unsigned count,
struct mesa_glinterop_export_in *resources,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC pGLInteropFlushObjectsMESA;
__GLXvendorInfo *dd;
@ -346,7 +346,7 @@ static int dispatch_GLInteropFlushObjectsMESA(Display *dpy, GLXContext ctx,
if (pGLInteropFlushObjectsMESA == NULL)
return 0;
return pGLInteropFlushObjectsMESA(dpy, ctx, count, resources, sync);
return pGLInteropFlushObjectsMESA(dpy, ctx, count, resources, sync, fence_fd);
}

View file

@ -222,7 +222,7 @@ struct glx_context_vtable {
struct mesa_glinterop_export_out *out);
int (*interop_flush_objects)(struct glx_context *ctx,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
GLsync *sync, int *fence_fd);
};
/**

View file

@ -2458,7 +2458,7 @@ PUBLIC int
MesaGLInteropGLXFlushObjects(Display *dpy, GLXContext context,
unsigned count,
struct mesa_glinterop_export_in *resources,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct glx_context *gc = (struct glx_context*)context;
int ret;
@ -2475,7 +2475,7 @@ MesaGLInteropGLXFlushObjects(Display *dpy, GLXContext context,
return MESA_GLINTEROP_UNSUPPORTED;
}
ret = gc->vtable->interop_flush_objects(gc, count, resources, sync);
ret = gc->vtable->interop_flush_objects(gc, count, resources, sync, fence_fd);
__glXUnlock();
return ret;
}

View file

@ -25,6 +25,7 @@
#include "st_interop.h"
#include "st_cb_texture.h"
#include "st_cb_flush.h"
#include "st_texture.h"
#include "bufferobj.h"
@ -371,7 +372,7 @@ flush_object(struct gl_context *ctx,
int
st_interop_flush_objects(struct st_context *st,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync)
GLsync *sync, int *fence_fd)
{
struct gl_context *ctx = st->ctx;
@ -393,6 +394,10 @@ st_interop_flush_objects(struct st_context *st,
if (count > 0 && sync) {
*sync = _mesa_fence_sync(ctx, GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
} else if (count > 0 && fence_fd) {
struct pipe_fence_handle *fence = NULL;
ctx->pipe->flush(ctx->pipe, &fence, PIPE_FLUSH_FENCE_FD | PIPE_FLUSH_ASYNC);
*fence_fd = ctx->screen->fence_get_fd(ctx->screen, fence);
}
return MESA_GLINTEROP_SUCCESS;

View file

@ -41,6 +41,6 @@ st_interop_export_object(struct st_context *st,
int
st_interop_flush_objects(struct st_context *st,
unsigned count, struct mesa_glinterop_export_in *objects,
GLsync *sync);
GLsync *sync, int *fence_fd);
#endif /* ST_INTEROP_H */