mesa_glinterop: make GL interop version field bidirectional
This allows clear and easy communication between the two. Caller: Requesting information (struct vN) Callee: I know how to deal with older version (vN-1) only. Here is your data and the version I support. Caller: Older version ? Sure I'll cap all access to the fields provided by the older version (vN-1) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:

committed by
Emil Velikov

parent
0e983276b9
commit
e384d75b12
@@ -414,7 +414,7 @@ struct __DRI2interopExtensionRec {
|
|||||||
|
|
||||||
/** Same as MesaGLInterop*ExportObject. */
|
/** Same as MesaGLInterop*ExportObject. */
|
||||||
int (*export_object)(__DRIcontext *ctx,
|
int (*export_object)(__DRIcontext *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -94,6 +94,11 @@ enum {
|
|||||||
*/
|
*/
|
||||||
typedef struct _mesa_glinterop_device_info {
|
typedef struct _mesa_glinterop_device_info {
|
||||||
/* The caller should set this to the version of the struct they support */
|
/* 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 the callee.
|
||||||
|
*/
|
||||||
/* NOTE: Do not use the MESA_GLINTEROP_DEVICE_INFO_VERSION macro */
|
/* NOTE: Do not use the MESA_GLINTEROP_DEVICE_INFO_VERSION macro */
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
@@ -117,6 +122,11 @@ typedef struct _mesa_glinterop_device_info {
|
|||||||
*/
|
*/
|
||||||
typedef struct _mesa_glinterop_export_in {
|
typedef struct _mesa_glinterop_export_in {
|
||||||
/* The caller should set this to the version of the struct they support */
|
/* 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 the callee.
|
||||||
|
*/
|
||||||
/* NOTE: Do not use the MESA_GLINTEROP_EXPORT_IN_VERSION macro */
|
/* NOTE: Do not use the MESA_GLINTEROP_EXPORT_IN_VERSION macro */
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
@@ -177,6 +187,11 @@ typedef struct _mesa_glinterop_export_in {
|
|||||||
*/
|
*/
|
||||||
typedef struct _mesa_glinterop_export_out {
|
typedef struct _mesa_glinterop_export_out {
|
||||||
/* The caller should set this to the version of the struct they support */
|
/* 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 the callee.
|
||||||
|
*/
|
||||||
/* NOTE: Do not use the MESA_GLINTEROP_EXPORT_OUT_VERSION macro */
|
/* NOTE: Do not use the MESA_GLINTEROP_EXPORT_OUT_VERSION macro */
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
@@ -257,7 +272,7 @@ MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
|
MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
|
|
||||||
|
|
||||||
@@ -267,7 +282,7 @@ MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
|
MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
|
|
||||||
|
|
||||||
@@ -276,10 +291,10 @@ typedef int (PFNMESAGLINTEROPGLXQUERYDEVICEINFOPROC)(Display *dpy, GLXContext co
|
|||||||
typedef int (PFNMESAGLINTEROPEGLQUERYDEVICEINFOPROC)(EGLDisplay dpy, EGLContext context,
|
typedef int (PFNMESAGLINTEROPEGLQUERYDEVICEINFOPROC)(EGLDisplay dpy, EGLContext context,
|
||||||
mesa_glinterop_device_info *out);
|
mesa_glinterop_device_info *out);
|
||||||
typedef int (PFNMESAGLINTEROPGLXEXPORTOBJECTPROC)(Display *dpy, GLXContext context,
|
typedef int (PFNMESAGLINTEROPGLXEXPORTOBJECTPROC)(Display *dpy, GLXContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
typedef int (PFNMESAGLINTEROPEGLEXPORTOBJECTPROC)(EGLDisplay dpy, EGLContext context,
|
typedef int (PFNMESAGLINTEROPEGLEXPORTOBJECTPROC)(EGLDisplay dpy, EGLContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -2703,7 +2703,7 @@ dri2_interop_query_device_info(_EGLDisplay *dpy, _EGLContext *ctx,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
dri2_interop_export_object(_EGLDisplay *dpy, _EGLContext *ctx,
|
dri2_interop_export_object(_EGLDisplay *dpy, _EGLContext *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
|
||||||
|
@@ -1961,7 +1961,7 @@ MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context,
|
|||||||
|
|
||||||
int
|
int
|
||||||
MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
|
MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
_EGLDisplay *disp;
|
_EGLDisplay *disp;
|
||||||
|
@@ -195,7 +195,7 @@ struct _egl_api
|
|||||||
int (*GLInteropQueryDeviceInfo)(_EGLDisplay *dpy, _EGLContext *ctx,
|
int (*GLInteropQueryDeviceInfo)(_EGLDisplay *dpy, _EGLContext *ctx,
|
||||||
mesa_glinterop_device_info *out);
|
mesa_glinterop_device_info *out);
|
||||||
int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
|
int (*GLInteropExportObject)(_EGLDisplay *dpy, _EGLContext *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1480,12 +1480,15 @@ dri2_interop_query_device_info(__DRIcontext *_ctx,
|
|||||||
out->vendor_id = screen->get_param(screen, PIPE_CAP_VENDOR_ID);
|
out->vendor_id = screen->get_param(screen, PIPE_CAP_VENDOR_ID);
|
||||||
out->device_id = screen->get_param(screen, PIPE_CAP_DEVICE_ID);
|
out->device_id = screen->get_param(screen, PIPE_CAP_DEVICE_ID);
|
||||||
|
|
||||||
|
/* Instruct the caller that we support up-to version one of the interface */
|
||||||
|
out->version = 1;
|
||||||
|
|
||||||
return MESA_GLINTEROP_SUCCESS;
|
return MESA_GLINTEROP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dri2_interop_export_object(__DRIcontext *_ctx,
|
dri2_interop_export_object(__DRIcontext *_ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct st_context_iface *st = dri_context(_ctx)->st;
|
struct st_context_iface *st = dri_context(_ctx)->st;
|
||||||
@@ -1704,6 +1707,10 @@ dri2_interop_export_object(__DRIcontext *_ctx,
|
|||||||
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 */
|
||||||
|
in->version = 1;
|
||||||
|
out->version = 1;
|
||||||
|
|
||||||
return MESA_GLINTEROP_SUCCESS;
|
return MESA_GLINTEROP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ dri2_interop_query_device_info(struct glx_context *ctx,
|
|||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri2_interop_export_object(struct glx_context *ctx,
|
dri2_interop_export_object(struct glx_context *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -139,5 +139,5 @@ dri3_interop_query_device_info(struct glx_context *ctx,
|
|||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri3_interop_export_object(struct glx_context *ctx,
|
dri3_interop_export_object(struct glx_context *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
|
@@ -47,7 +47,7 @@ dri2_interop_query_device_info(struct glx_context *ctx,
|
|||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri2_interop_export_object(struct glx_context *ctx,
|
dri2_interop_export_object(struct glx_context *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
|
||||||
@@ -76,7 +76,7 @@ dri3_interop_query_device_info(struct glx_context *ctx,
|
|||||||
|
|
||||||
_X_HIDDEN int
|
_X_HIDDEN int
|
||||||
dri3_interop_export_object(struct glx_context *ctx,
|
dri3_interop_export_object(struct glx_context *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
|
||||||
|
@@ -234,7 +234,7 @@ struct glx_context_vtable {
|
|||||||
int (*interop_query_device_info)(struct glx_context *ctx,
|
int (*interop_query_device_info)(struct glx_context *ctx,
|
||||||
mesa_glinterop_device_info *out);
|
mesa_glinterop_device_info *out);
|
||||||
int (*interop_export_object)(struct glx_context *ctx,
|
int (*interop_export_object)(struct glx_context *ctx,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out);
|
mesa_glinterop_export_out *out);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2721,7 +2721,7 @@ MesaGLInteropGLXQueryDeviceInfo(Display *dpy, GLXContext context,
|
|||||||
|
|
||||||
int
|
int
|
||||||
MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
|
MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
|
||||||
const mesa_glinterop_export_in *in,
|
mesa_glinterop_export_in *in,
|
||||||
mesa_glinterop_export_out *out)
|
mesa_glinterop_export_out *out)
|
||||||
{
|
{
|
||||||
struct glx_context *gc = (struct glx_context*)context;
|
struct glx_context *gc = (struct glx_context*)context;
|
||||||
|
Reference in New Issue
Block a user