mesa/st, dri2, wgl, glx: Restore flush_objects interop backward compat
In commit1396dc1c
a new output field was added as a parameter, but this is a problem since the signature of the function are not versionned. The flush function didn't have a versionned output struct. So what I'm proposing here is that if the version of the input argument is new enough (bumped to 2 here), then we re-use the existing argument, which until now was directly a pointer to GLsync, and instead use it as a pointer to a versioned struct. We're just changing one pointer type to another, so in C, this should be fine AFAIK. Fixes:1396dc1c
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26315>
This commit is contained in:
parent
76b751c3b1
commit
0fa85b983f
|
@ -441,6 +441,7 @@ struct __DRI2fenceExtensionRec {
|
|||
struct mesa_glinterop_device_info;
|
||||
struct mesa_glinterop_export_in;
|
||||
struct mesa_glinterop_export_out;
|
||||
struct mesa_glinterop_flush_out;
|
||||
typedef struct __GLsync *GLsync;
|
||||
|
||||
struct __DRI2interopExtensionRec {
|
||||
|
@ -462,7 +463,7 @@ struct __DRI2interopExtensionRec {
|
|||
*/
|
||||
int (*flush_objects)(__DRIcontext *ctx,
|
||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||
GLsync *sync, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ struct mesa_glinterop_device_info {
|
|||
/* Structure version 3 ends here. */
|
||||
};
|
||||
|
||||
#define MESA_GLINTEROP_EXPORT_IN_VERSION 1
|
||||
#define MESA_GLINTEROP_EXPORT_IN_VERSION 2
|
||||
|
||||
/**
|
||||
* Input parameters to Mesa interop export functions.
|
||||
|
@ -210,6 +210,12 @@ struct mesa_glinterop_export_in {
|
|||
*/
|
||||
void *out_driver_data;
|
||||
/* Structure version 1 ends here. */
|
||||
|
||||
/* Structure version 2 starts here. */
|
||||
/* NOTE: Version 2 doesn't add any fields to input but redefines the
|
||||
* argument to flush call to `struct mesa_glinterop_flush_out *`
|
||||
* instead of `GLsync *` */
|
||||
/* Structure version 2 ends here. */
|
||||
};
|
||||
|
||||
#define MESA_GLINTEROP_EXPORT_OUT_VERSION 2
|
||||
|
@ -286,6 +292,28 @@ struct mesa_glinterop_export_out {
|
|||
/* Structure version 2 ends here. */
|
||||
};
|
||||
|
||||
#define MESA_GLINTEROP_FLUSH_OUT_VERSION 1
|
||||
|
||||
/**
|
||||
* Outputs of Mesa interop flush functions.
|
||||
*/
|
||||
struct mesa_glinterop_flush_out {
|
||||
/* The caller should set this to the version of the struct they support */
|
||||
/* The callee will overwrite it if it supports a lower version.
|
||||
*
|
||||
* The caller should check the value and access up-to the version supported
|
||||
* by the callee.
|
||||
*/
|
||||
/* NOTE: Do not use the MESA_GLINTEROP_EXPORT_OUT_VERSION macro */
|
||||
uint32_t version;
|
||||
|
||||
/* GLsync to map to CL event, caller set it non-NULL to be filled */
|
||||
GLsync *sync;
|
||||
|
||||
/* fence_fd to use in CL, caller set it to non-NULL to be filled */
|
||||
int *fence_fd;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Query device information.
|
||||
|
@ -362,15 +390,14 @@ wglMesaGLInteropExportObject(HDC dpy, HGLRC context,
|
|||
* \param context GLX 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
|
||||
* \param out return values
|
||||
*
|
||||
* \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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
/**
|
||||
* Same as MesaGLInteropGLXFlushObjects except that it accepts
|
||||
|
@ -379,16 +406,16 @@ MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *cont
|
|||
int
|
||||
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context,
|
||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
/**
|
||||
* Same as MesaGLInteropGLXFlushObjects except that it accepts
|
||||
* HDC and HGLRC, and not a fence_fd.
|
||||
* HDC and HGLRC.
|
||||
*/
|
||||
int
|
||||
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
|
||||
typedef int (*PFNMESAGLINTEROPGLXQUERYDEVICEINFOPROC)(struct _XDisplay *dpy, struct __GLXcontextRec *context,
|
||||
|
@ -408,13 +435,13 @@ 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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
typedef int (*PFNMESAGLINTEROPEGLFLUSHOBJECTSPROC)(EGLDisplay dpy, EGLContext context,
|
||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
typedef int (*PFNWGLMESAGLINTEROPFLUSHOBJECTSPROC)(HDC dpy, HGLRC context,
|
||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -3701,7 +3701,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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
|
||||
|
@ -3710,7 +3710,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, fence_fd);
|
||||
objects, out);
|
||||
}
|
||||
|
||||
const _EGLDriver _eglDriver = {
|
||||
|
|
|
@ -1164,10 +1164,10 @@ 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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
struct wgl_egl_context *wgl_ctx = wgl_egl_context(ctx);
|
||||
return stw_interop_flush_objects(wgl_ctx->ctx, count, objects, sync);
|
||||
return stw_interop_flush_objects(wgl_ctx->ctx, count, objects, out);
|
||||
}
|
||||
|
||||
struct _egl_driver _eglDriver = {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<type>struct <name>mesa_glinterop_device_info</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_export_in</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_export_out</name>;</type>
|
||||
<type>struct <name>mesa_glinterop_flush_out</name>;</type>
|
||||
</types>
|
||||
<commands namespace="EGL">
|
||||
<!-- EGL_WL_bind_wayland_display -->
|
||||
|
@ -103,7 +104,7 @@
|
|||
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
||||
<param>unsigned <name>count</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_export_in</ptype> *<name>objects</name></param>
|
||||
<param>GLsync *<name>sync</name></param>
|
||||
<param>struct <ptype>mesa_glinterop_flush_out</ptype> *<name>out</name></param>
|
||||
</command>
|
||||
</commands>
|
||||
</registry>
|
||||
|
|
|
@ -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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
_EGLDisplay *disp;
|
||||
_EGLContext *ctx;
|
||||
|
@ -2910,8 +2910,7 @@ MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
|
|||
return ret;
|
||||
|
||||
if (disp->Driver->GLInteropFlushObjects)
|
||||
ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, sync,
|
||||
fence_fd);
|
||||
ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, out);
|
||||
else
|
||||
ret = MESA_GLINTEROP_UNSUPPORTED;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ struct wl_display;
|
|||
struct mesa_glinterop_device_info;
|
||||
struct mesa_glinterop_export_in;
|
||||
struct mesa_glinterop_export_out;
|
||||
struct mesa_glinterop_flush_out;
|
||||
typedef struct __GLsync *GLsync;
|
||||
|
||||
/**
|
||||
|
@ -208,7 +209,7 @@ struct _egl_driver {
|
|||
int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx,
|
||||
unsigned count,
|
||||
struct mesa_glinterop_export_in *in,
|
||||
GLsync *sync, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
/* for EGL_EXT_image_dma_buf_import_modifiers */
|
||||
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats,
|
||||
|
|
|
@ -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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
return st_interop_flush_objects(dri_context(_ctx)->st, count, objects, sync, fence_fd);
|
||||
return st_interop_flush_objects(dri_context(_ctx)->st, count, objects, out);
|
||||
}
|
||||
|
||||
static const __DRI2interopExtension dri2InteropExtension = {
|
||||
|
|
|
@ -193,7 +193,7 @@ impl GLCtxManager {
|
|||
) -> CLResult<GLExportManager> {
|
||||
let xplat_manager = &self.xplat_manager;
|
||||
let mut export_in = mesa_glinterop_export_in {
|
||||
version: 1,
|
||||
version: 2,
|
||||
target: target,
|
||||
obj: texture,
|
||||
miplevel: miplevel as u32,
|
||||
|
@ -206,6 +206,14 @@ impl GLCtxManager {
|
|||
..Default::default()
|
||||
};
|
||||
|
||||
let mut fd = -1;
|
||||
|
||||
let mut flush_out = mesa_glinterop_flush_out {
|
||||
version: 1,
|
||||
fence_fd: &mut fd,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let err = unsafe {
|
||||
match &self.gl_ctx {
|
||||
GLCtx::EGL(disp, ctx) => {
|
||||
|
@ -217,14 +225,12 @@ impl GLCtxManager {
|
|||
.MesaGLInteropEGLFlushObjects()?
|
||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
||||
|
||||
let mut fd = -1;
|
||||
let err_flush = egl_flush_objects_func(
|
||||
disp.cast(),
|
||||
ctx.cast(),
|
||||
1,
|
||||
&mut export_in,
|
||||
ptr::null_mut(),
|
||||
&mut fd,
|
||||
&mut flush_out,
|
||||
);
|
||||
// TODO: use fence_server_sync in ctx inside the queue thread
|
||||
let fence_fd = FenceFd { fd };
|
||||
|
@ -253,14 +259,12 @@ impl GLCtxManager {
|
|||
.MesaGLInteropGLXFlushObjects()?
|
||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
||||
|
||||
let mut fd = -1;
|
||||
let err_flush = glx_flush_objects_func(
|
||||
disp.cast(),
|
||||
ctx.cast(),
|
||||
1,
|
||||
&mut export_in,
|
||||
ptr::null_mut(),
|
||||
&mut fd,
|
||||
&mut flush_out,
|
||||
);
|
||||
// TODO: use fence_server_sync in ctx inside the queue thread
|
||||
let fence_fd = FenceFd { fd };
|
||||
|
|
|
@ -88,7 +88,7 @@ stw_interop_export_object(struct stw_context *ctx,
|
|||
int
|
||||
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
DHGLRC dhglrc = 0;
|
||||
|
||||
|
@ -104,14 +104,14 @@ wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
|||
if (!ctx)
|
||||
return MESA_GLINTEROP_INVALID_CONTEXT;
|
||||
|
||||
return stw_interop_flush_objects(ctx, count, resources, sync);
|
||||
return stw_interop_flush_objects(ctx, count, resources, out);
|
||||
}
|
||||
|
||||
int
|
||||
stw_interop_flush_objects(struct stw_context *ctx,
|
||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||
GLsync *sync)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
return st_interop_flush_objects(ctx->st, count, objects, sync, NULL);
|
||||
return st_interop_flush_objects(ctx->st, count, objects, out);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@ stw_interop_export_object(struct stw_context *ctx,
|
|||
int
|
||||
stw_interop_flush_objects(struct stw_context *ctx,
|
||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||
GLsync *sync);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
#endif /* STW_EXT_INTEROP_H */
|
||||
|
|
|
@ -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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
|
|
@ -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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
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, fence_fd);
|
||||
return psc->interop->flush_objects(ctx->driContext, count, objects, out);
|
||||
}
|
||||
|
||||
#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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
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, fence_fd);
|
||||
return psc->interop->flush_objects(ctx->driContext, count, objects, out);
|
||||
}
|
||||
|
||||
#endif /* HAVE_DRI3 */
|
||||
|
|
|
@ -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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
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, fence_fd);
|
||||
return pGLInteropFlushObjectsMESA(dpy, ctx, count, resources, out);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ typedef struct __GLXattributeMachineRec
|
|||
struct mesa_glinterop_device_info;
|
||||
struct mesa_glinterop_export_in;
|
||||
struct mesa_glinterop_export_out;
|
||||
struct mesa_glinterop_flush_out;
|
||||
|
||||
struct glx_context_vtable {
|
||||
void (*destroy)(struct glx_context *ctx);
|
||||
|
@ -222,7 +223,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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -2458,7 +2458,7 @@ PUBLIC int
|
|||
MesaGLInteropGLXFlushObjects(Display *dpy, GLXContext context,
|
||||
unsigned count,
|
||||
struct mesa_glinterop_export_in *resources,
|
||||
GLsync *sync, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
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, fence_fd);
|
||||
ret = gc->vtable->interop_flush_objects(gc, count, resources, out);
|
||||
__glXUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -341,8 +341,8 @@ st_interop_export_object(struct st_context *st,
|
|||
if (res->target == PIPE_BUFFER)
|
||||
out->buf_offset += whandle.offset;
|
||||
|
||||
/* Instruct the caller that we support up-to version one of the interface */
|
||||
in->version = MIN2(in->version, 1);
|
||||
/* Instruct the caller of the version of the interface we support */
|
||||
in->version = MIN2(in->version, 2);
|
||||
out->version = MIN2(out->version, 2);
|
||||
|
||||
return MESA_GLINTEROP_SUCCESS;
|
||||
|
@ -363,8 +363,8 @@ flush_object(struct gl_context *ctx,
|
|||
|
||||
ctx->pipe->flush_resource(ctx->pipe, res);
|
||||
|
||||
/* Instruct the caller that we support up-to version one of the interface */
|
||||
in->version = 1;
|
||||
/* Instruct the caller of the version of the interface we support */
|
||||
in->version = MIN2(in->version, 2);
|
||||
|
||||
return MESA_GLINTEROP_SUCCESS;
|
||||
}
|
||||
|
@ -372,9 +372,10 @@ 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, int *fence_fd)
|
||||
struct mesa_glinterop_flush_out *out)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
bool flush_out_struct = false;
|
||||
|
||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||
_mesa_glthread_finish(st->ctx);
|
||||
|
@ -384,6 +385,9 @@ st_interop_flush_objects(struct st_context *st,
|
|||
for (unsigned i = 0; i < count; ++i) {
|
||||
int ret = flush_object(ctx, &objects[i]);
|
||||
|
||||
if (objects[i].version >= 2)
|
||||
flush_out_struct = true;
|
||||
|
||||
if (ret != MESA_GLINTEROP_SUCCESS) {
|
||||
simple_mtx_unlock(&ctx->Shared->Mutex);
|
||||
return ret;
|
||||
|
@ -392,12 +396,21 @@ st_interop_flush_objects(struct st_context *st,
|
|||
|
||||
simple_mtx_unlock(&ctx->Shared->Mutex);
|
||||
|
||||
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);
|
||||
if (count > 0 && out) {
|
||||
if (flush_out_struct) {
|
||||
if (out->sync) {
|
||||
*out->sync = _mesa_fence_sync(ctx, GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
if (out->fence_fd) {
|
||||
struct pipe_fence_handle *fence = NULL;
|
||||
ctx->pipe->flush(ctx->pipe, &fence, PIPE_FLUSH_FENCE_FD | PIPE_FLUSH_ASYNC);
|
||||
*out->fence_fd = ctx->screen->fence_get_fd(ctx->screen, fence);
|
||||
}
|
||||
out->version = MIN2(out->version, 1);
|
||||
} else {
|
||||
GLsync *sync = (GLsync *)out;
|
||||
*sync = _mesa_fence_sync(ctx, GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return MESA_GLINTEROP_SUCCESS;
|
||||
|
|
|
@ -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, int *fence_fd);
|
||||
struct mesa_glinterop_flush_out *out);
|
||||
|
||||
#endif /* ST_INTEROP_H */
|
||||
|
|
Loading…
Reference in New Issue