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:

committed by
Marge Bot

parent
76b751c3b1
commit
0fa85b983f
@@ -441,6 +441,7 @@ struct __DRI2fenceExtensionRec {
|
|||||||
struct mesa_glinterop_device_info;
|
struct mesa_glinterop_device_info;
|
||||||
struct mesa_glinterop_export_in;
|
struct mesa_glinterop_export_in;
|
||||||
struct mesa_glinterop_export_out;
|
struct mesa_glinterop_export_out;
|
||||||
|
struct mesa_glinterop_flush_out;
|
||||||
typedef struct __GLsync *GLsync;
|
typedef struct __GLsync *GLsync;
|
||||||
|
|
||||||
struct __DRI2interopExtensionRec {
|
struct __DRI2interopExtensionRec {
|
||||||
@@ -462,7 +463,7 @@ struct __DRI2interopExtensionRec {
|
|||||||
*/
|
*/
|
||||||
int (*flush_objects)(__DRIcontext *ctx,
|
int (*flush_objects)(__DRIcontext *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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. */
|
/* 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.
|
* Input parameters to Mesa interop export functions.
|
||||||
@@ -210,6 +210,12 @@ struct mesa_glinterop_export_in {
|
|||||||
*/
|
*/
|
||||||
void *out_driver_data;
|
void *out_driver_data;
|
||||||
/* Structure version 1 ends here. */
|
/* 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
|
#define MESA_GLINTEROP_EXPORT_OUT_VERSION 2
|
||||||
@@ -286,6 +292,28 @@ struct mesa_glinterop_export_out {
|
|||||||
/* Structure version 2 ends here. */
|
/* 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.
|
* Query device information.
|
||||||
@@ -362,15 +390,14 @@ wglMesaGLInteropExportObject(HDC dpy, HGLRC context,
|
|||||||
* \param context GLX context
|
* \param context GLX context
|
||||||
* \param count number of resources
|
* \param count number of resources
|
||||||
* \param resources resources to flush
|
* \param resources resources to flush
|
||||||
* \param sync optional GLsync to map to CL event
|
* \param out return values
|
||||||
* \param fence_fd optional fence_fd to use in CL
|
|
||||||
*
|
*
|
||||||
* \return MESA_GLINTEROP_SUCCESS or MESA_GLINTEROP_* != 0 on error
|
* \return MESA_GLINTEROP_SUCCESS or MESA_GLINTEROP_* != 0 on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *context,
|
MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
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
|
* Same as MesaGLInteropGLXFlushObjects except that it accepts
|
||||||
@@ -379,16 +406,16 @@ MesaGLInteropGLXFlushObjects(struct _XDisplay *dpy, struct __GLXcontextRec *cont
|
|||||||
int
|
int
|
||||||
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context,
|
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
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
|
* Same as MesaGLInteropGLXFlushObjects except that it accepts
|
||||||
* HDC and HGLRC, and not a fence_fd.
|
* HDC and HGLRC.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
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,
|
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);
|
struct mesa_glinterop_export_out *out);
|
||||||
typedef int (*PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC)(struct _XDisplay *dpy, struct __GLXcontextRec *context,
|
typedef int (*PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC)(struct _XDisplay *dpy, struct __GLXcontextRec *context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
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,
|
typedef int (*PFNMESAGLINTEROPEGLFLUSHOBJECTSPROC)(EGLDisplay dpy, EGLContext context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
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,
|
typedef int (*PFNWGLMESAGLINTEROPFLUSHOBJECTSPROC)(HDC dpy, HGLRC context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||||
GLsync *sync);
|
struct mesa_glinterop_flush_out *out);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -3701,7 +3701,7 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
|
|||||||
static int
|
static int
|
||||||
dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
|
dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
|
||||||
struct mesa_glinterop_export_in *objects,
|
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_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
|
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 MESA_GLINTEROP_UNSUPPORTED;
|
||||||
|
|
||||||
return dri2_dpy->interop->flush_objects(dri2_ctx->dri_context, count,
|
return dri2_dpy->interop->flush_objects(dri2_ctx->dri_context, count,
|
||||||
objects, sync, fence_fd);
|
objects, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
const _EGLDriver _eglDriver = {
|
const _EGLDriver _eglDriver = {
|
||||||
|
@@ -1164,10 +1164,10 @@ wgl_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx,
|
|||||||
static int
|
static int
|
||||||
wgl_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
|
wgl_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, unsigned count,
|
||||||
struct mesa_glinterop_export_in *objects,
|
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);
|
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 = {
|
struct _egl_driver _eglDriver = {
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
<type>struct <name>mesa_glinterop_device_info</name>;</type>
|
<type>struct <name>mesa_glinterop_device_info</name>;</type>
|
||||||
<type>struct <name>mesa_glinterop_export_in</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_export_out</name>;</type>
|
||||||
|
<type>struct <name>mesa_glinterop_flush_out</name>;</type>
|
||||||
</types>
|
</types>
|
||||||
<commands namespace="EGL">
|
<commands namespace="EGL">
|
||||||
<!-- EGL_WL_bind_wayland_display -->
|
<!-- EGL_WL_bind_wayland_display -->
|
||||||
@@ -103,7 +104,7 @@
|
|||||||
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
<param><ptype>EGLContext</ptype> <name>ctx</name></param>
|
||||||
<param>unsigned <name>count</name></param>
|
<param>unsigned <name>count</name></param>
|
||||||
<param>struct <ptype>mesa_glinterop_export_in</ptype> *<name>objects</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>
|
</command>
|
||||||
</commands>
|
</commands>
|
||||||
</registry>
|
</registry>
|
||||||
|
@@ -2899,7 +2899,7 @@ MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
|
|||||||
PUBLIC int
|
PUBLIC int
|
||||||
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
|
MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
|
||||||
struct mesa_glinterop_export_in *objects,
|
struct mesa_glinterop_export_in *objects,
|
||||||
GLsync *sync, int *fence_fd)
|
struct mesa_glinterop_flush_out *out)
|
||||||
{
|
{
|
||||||
_EGLDisplay *disp;
|
_EGLDisplay *disp;
|
||||||
_EGLContext *ctx;
|
_EGLContext *ctx;
|
||||||
@@ -2910,8 +2910,7 @@ MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, unsigned count,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (disp->Driver->GLInteropFlushObjects)
|
if (disp->Driver->GLInteropFlushObjects)
|
||||||
ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, sync,
|
ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, out);
|
||||||
fence_fd);
|
|
||||||
else
|
else
|
||||||
ret = MESA_GLINTEROP_UNSUPPORTED;
|
ret = MESA_GLINTEROP_UNSUPPORTED;
|
||||||
|
|
||||||
|
@@ -73,6 +73,7 @@ struct wl_display;
|
|||||||
struct mesa_glinterop_device_info;
|
struct mesa_glinterop_device_info;
|
||||||
struct mesa_glinterop_export_in;
|
struct mesa_glinterop_export_in;
|
||||||
struct mesa_glinterop_export_out;
|
struct mesa_glinterop_export_out;
|
||||||
|
struct mesa_glinterop_flush_out;
|
||||||
typedef struct __GLsync *GLsync;
|
typedef struct __GLsync *GLsync;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,7 +209,7 @@ struct _egl_driver {
|
|||||||
int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx,
|
int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
unsigned count,
|
unsigned count,
|
||||||
struct mesa_glinterop_export_in *in,
|
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 */
|
/* for EGL_EXT_image_dma_buf_import_modifiers */
|
||||||
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats,
|
EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, EGLint max_formats,
|
||||||
|
@@ -2098,9 +2098,9 @@ dri2_interop_export_object(__DRIcontext *_ctx,
|
|||||||
static int
|
static int
|
||||||
dri2_interop_flush_objects(__DRIcontext *_ctx,
|
dri2_interop_flush_objects(__DRIcontext *_ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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 = {
|
static const __DRI2interopExtension dri2InteropExtension = {
|
||||||
|
@@ -193,7 +193,7 @@ impl GLCtxManager {
|
|||||||
) -> CLResult<GLExportManager> {
|
) -> CLResult<GLExportManager> {
|
||||||
let xplat_manager = &self.xplat_manager;
|
let xplat_manager = &self.xplat_manager;
|
||||||
let mut export_in = mesa_glinterop_export_in {
|
let mut export_in = mesa_glinterop_export_in {
|
||||||
version: 1,
|
version: 2,
|
||||||
target: target,
|
target: target,
|
||||||
obj: texture,
|
obj: texture,
|
||||||
miplevel: miplevel as u32,
|
miplevel: miplevel as u32,
|
||||||
@@ -206,6 +206,14 @@ impl GLCtxManager {
|
|||||||
..Default::default()
|
..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 {
|
let err = unsafe {
|
||||||
match &self.gl_ctx {
|
match &self.gl_ctx {
|
||||||
GLCtx::EGL(disp, ctx) => {
|
GLCtx::EGL(disp, ctx) => {
|
||||||
@@ -217,14 +225,12 @@ impl GLCtxManager {
|
|||||||
.MesaGLInteropEGLFlushObjects()?
|
.MesaGLInteropEGLFlushObjects()?
|
||||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
||||||
|
|
||||||
let mut fd = -1;
|
|
||||||
let err_flush = egl_flush_objects_func(
|
let err_flush = egl_flush_objects_func(
|
||||||
disp.cast(),
|
disp.cast(),
|
||||||
ctx.cast(),
|
ctx.cast(),
|
||||||
1,
|
1,
|
||||||
&mut export_in,
|
&mut export_in,
|
||||||
ptr::null_mut(),
|
&mut flush_out,
|
||||||
&mut fd,
|
|
||||||
);
|
);
|
||||||
// TODO: use fence_server_sync in ctx inside the queue thread
|
// TODO: use fence_server_sync in ctx inside the queue thread
|
||||||
let fence_fd = FenceFd { fd };
|
let fence_fd = FenceFd { fd };
|
||||||
@@ -253,14 +259,12 @@ impl GLCtxManager {
|
|||||||
.MesaGLInteropGLXFlushObjects()?
|
.MesaGLInteropGLXFlushObjects()?
|
||||||
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
.ok_or(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR)?;
|
||||||
|
|
||||||
let mut fd = -1;
|
|
||||||
let err_flush = glx_flush_objects_func(
|
let err_flush = glx_flush_objects_func(
|
||||||
disp.cast(),
|
disp.cast(),
|
||||||
ctx.cast(),
|
ctx.cast(),
|
||||||
1,
|
1,
|
||||||
&mut export_in,
|
&mut export_in,
|
||||||
ptr::null_mut(),
|
&mut flush_out,
|
||||||
&mut fd,
|
|
||||||
);
|
);
|
||||||
// TODO: use fence_server_sync in ctx inside the queue thread
|
// TODO: use fence_server_sync in ctx inside the queue thread
|
||||||
let fence_fd = FenceFd { fd };
|
let fence_fd = FenceFd { fd };
|
||||||
|
@@ -88,7 +88,7 @@ stw_interop_export_object(struct stw_context *ctx,
|
|||||||
int
|
int
|
||||||
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
||||||
unsigned count, struct mesa_glinterop_export_in *resources,
|
unsigned count, struct mesa_glinterop_export_in *resources,
|
||||||
GLsync *sync)
|
struct mesa_glinterop_flush_out *out)
|
||||||
{
|
{
|
||||||
DHGLRC dhglrc = 0;
|
DHGLRC dhglrc = 0;
|
||||||
|
|
||||||
@@ -104,14 +104,14 @@ wglMesaGLInteropFlushObjects(HDC dpy, HGLRC context,
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
return MESA_GLINTEROP_INVALID_CONTEXT;
|
return MESA_GLINTEROP_INVALID_CONTEXT;
|
||||||
|
|
||||||
return stw_interop_flush_objects(ctx, count, resources, sync);
|
return stw_interop_flush_objects(ctx, count, resources, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
stw_interop_flush_objects(struct stw_context *ctx,
|
stw_interop_flush_objects(struct stw_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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
|
int
|
||||||
stw_interop_flush_objects(struct stw_context *ctx,
|
stw_interop_flush_objects(struct stw_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||||
GLsync *sync);
|
struct mesa_glinterop_flush_out *out);
|
||||||
|
|
||||||
#endif /* STW_EXT_INTEROP_H */
|
#endif /* STW_EXT_INTEROP_H */
|
||||||
|
@@ -83,7 +83,7 @@ dri2_interop_export_object(struct glx_context *ctx,
|
|||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri2_interop_flush_objects(struct glx_context *ctx,
|
dri2_interop_flush_objects(struct glx_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||||
GLsync *sync, int *fence_fd);
|
struct mesa_glinterop_flush_out *out);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -143,4 +143,4 @@ dri3_interop_export_object(struct glx_context *ctx,
|
|||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri3_interop_flush_objects(struct glx_context *ctx,
|
dri3_interop_flush_objects(struct glx_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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
|
_X_HIDDEN int
|
||||||
dri2_interop_flush_objects(struct glx_context *ctx,
|
dri2_interop_flush_objects(struct glx_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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;
|
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
||||||
|
|
||||||
if (!psc->interop || psc->interop->base.version < 2)
|
if (!psc->interop || psc->interop->base.version < 2)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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)
|
#if defined(HAVE_DRI3)
|
||||||
@@ -100,14 +100,14 @@ dri3_interop_export_object(struct glx_context *ctx,
|
|||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri3_interop_flush_objects(struct glx_context *ctx,
|
dri3_interop_flush_objects(struct glx_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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;
|
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
||||||
|
|
||||||
if (!psc->interop || psc->interop->base.version < 2)
|
if (!psc->interop || psc->interop->base.version < 2)
|
||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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 */
|
#endif /* HAVE_DRI3 */
|
||||||
|
@@ -333,7 +333,7 @@ static int dispatch_GLInteropExportObjectMESA(Display *dpy, GLXContext ctx,
|
|||||||
static int dispatch_GLInteropFlushObjectsMESA(Display *dpy, GLXContext ctx,
|
static int dispatch_GLInteropFlushObjectsMESA(Display *dpy, GLXContext ctx,
|
||||||
unsigned count,
|
unsigned count,
|
||||||
struct mesa_glinterop_export_in *resources,
|
struct mesa_glinterop_export_in *resources,
|
||||||
GLsync *sync, int *fence_fd)
|
struct mesa_glinterop_flush_out *out)
|
||||||
{
|
{
|
||||||
PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC pGLInteropFlushObjectsMESA;
|
PFNMESAGLINTEROPGLXFLUSHOBJECTSPROC pGLInteropFlushObjectsMESA;
|
||||||
__GLXvendorInfo *dd;
|
__GLXvendorInfo *dd;
|
||||||
@@ -346,7 +346,7 @@ static int dispatch_GLInteropFlushObjectsMESA(Display *dpy, GLXContext ctx,
|
|||||||
if (pGLInteropFlushObjectsMESA == NULL)
|
if (pGLInteropFlushObjectsMESA == NULL)
|
||||||
return 0;
|
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_device_info;
|
||||||
struct mesa_glinterop_export_in;
|
struct mesa_glinterop_export_in;
|
||||||
struct mesa_glinterop_export_out;
|
struct mesa_glinterop_export_out;
|
||||||
|
struct mesa_glinterop_flush_out;
|
||||||
|
|
||||||
struct glx_context_vtable {
|
struct glx_context_vtable {
|
||||||
void (*destroy)(struct glx_context *ctx);
|
void (*destroy)(struct glx_context *ctx);
|
||||||
@@ -222,7 +223,7 @@ struct glx_context_vtable {
|
|||||||
struct mesa_glinterop_export_out *out);
|
struct mesa_glinterop_export_out *out);
|
||||||
int (*interop_flush_objects)(struct glx_context *ctx,
|
int (*interop_flush_objects)(struct glx_context *ctx,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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,
|
MesaGLInteropGLXFlushObjects(Display *dpy, GLXContext context,
|
||||||
unsigned count,
|
unsigned count,
|
||||||
struct mesa_glinterop_export_in *resources,
|
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;
|
struct glx_context *gc = (struct glx_context*)context;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -2475,7 +2475,7 @@ MesaGLInteropGLXFlushObjects(Display *dpy, GLXContext context,
|
|||||||
return MESA_GLINTEROP_UNSUPPORTED;
|
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();
|
__glXUnlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -341,8 +341,8 @@ st_interop_export_object(struct st_context *st,
|
|||||||
if (res->target == PIPE_BUFFER)
|
if (res->target == PIPE_BUFFER)
|
||||||
out->buf_offset += whandle.offset;
|
out->buf_offset += whandle.offset;
|
||||||
|
|
||||||
/* Instruct the caller that we support up-to version one of the interface */
|
/* Instruct the caller of the version of the interface we support */
|
||||||
in->version = MIN2(in->version, 1);
|
in->version = MIN2(in->version, 2);
|
||||||
out->version = MIN2(out->version, 2);
|
out->version = MIN2(out->version, 2);
|
||||||
|
|
||||||
return MESA_GLINTEROP_SUCCESS;
|
return MESA_GLINTEROP_SUCCESS;
|
||||||
@@ -363,8 +363,8 @@ flush_object(struct gl_context *ctx,
|
|||||||
|
|
||||||
ctx->pipe->flush_resource(ctx->pipe, res);
|
ctx->pipe->flush_resource(ctx->pipe, res);
|
||||||
|
|
||||||
/* Instruct the caller that we support up-to version one of the interface */
|
/* Instruct the caller of the version of the interface we support */
|
||||||
in->version = 1;
|
in->version = MIN2(in->version, 2);
|
||||||
|
|
||||||
return MESA_GLINTEROP_SUCCESS;
|
return MESA_GLINTEROP_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -372,9 +372,10 @@ flush_object(struct gl_context *ctx,
|
|||||||
int
|
int
|
||||||
st_interop_flush_objects(struct st_context *st,
|
st_interop_flush_objects(struct st_context *st,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
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;
|
struct gl_context *ctx = st->ctx;
|
||||||
|
bool flush_out_struct = false;
|
||||||
|
|
||||||
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
/* Wait for glthread to finish to get up-to-date GL object lookups. */
|
||||||
_mesa_glthread_finish(st->ctx);
|
_mesa_glthread_finish(st->ctx);
|
||||||
@@ -384,6 +385,9 @@ st_interop_flush_objects(struct st_context *st,
|
|||||||
for (unsigned i = 0; i < count; ++i) {
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
int ret = flush_object(ctx, &objects[i]);
|
int ret = flush_object(ctx, &objects[i]);
|
||||||
|
|
||||||
|
if (objects[i].version >= 2)
|
||||||
|
flush_out_struct = true;
|
||||||
|
|
||||||
if (ret != MESA_GLINTEROP_SUCCESS) {
|
if (ret != MESA_GLINTEROP_SUCCESS) {
|
||||||
simple_mtx_unlock(&ctx->Shared->Mutex);
|
simple_mtx_unlock(&ctx->Shared->Mutex);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -392,12 +396,21 @@ st_interop_flush_objects(struct st_context *st,
|
|||||||
|
|
||||||
simple_mtx_unlock(&ctx->Shared->Mutex);
|
simple_mtx_unlock(&ctx->Shared->Mutex);
|
||||||
|
|
||||||
if (count > 0 && sync) {
|
if (count > 0 && out) {
|
||||||
*sync = _mesa_fence_sync(ctx, GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
if (flush_out_struct) {
|
||||||
} else if (count > 0 && fence_fd) {
|
if (out->sync) {
|
||||||
struct pipe_fence_handle *fence = NULL;
|
*out->sync = _mesa_fence_sync(ctx, GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
ctx->pipe->flush(ctx->pipe, &fence, PIPE_FLUSH_FENCE_FD | PIPE_FLUSH_ASYNC);
|
}
|
||||||
*fence_fd = ctx->screen->fence_get_fd(ctx->screen, fence);
|
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;
|
return MESA_GLINTEROP_SUCCESS;
|
||||||
|
@@ -41,6 +41,6 @@ st_interop_export_object(struct st_context *st,
|
|||||||
int
|
int
|
||||||
st_interop_flush_objects(struct st_context *st,
|
st_interop_flush_objects(struct st_context *st,
|
||||||
unsigned count, struct mesa_glinterop_export_in *objects,
|
unsigned count, struct mesa_glinterop_export_in *objects,
|
||||||
GLsync *sync, int *fence_fd);
|
struct mesa_glinterop_flush_out *out);
|
||||||
|
|
||||||
#endif /* ST_INTEROP_H */
|
#endif /* ST_INTEROP_H */
|
||||||
|
Reference in New Issue
Block a user