1 /*
2 * Copyright © 2013 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
25
26 #include "glxclient.h"
27 #include "glx_error.h"
28 #include "GL/internal/dri_interface.h"
29 #include "dri2_priv.h"
30 #if defined(HAVE_DRI3)
31 #include "dri3_priv.h"
32 #endif
33 #include "GL/mesa_glinterop.h"
34
35 _X_HIDDEN int
dri2_interop_query_device_info(struct glx_context * ctx,struct mesa_glinterop_device_info * out)36 dri2_interop_query_device_info(struct glx_context *ctx,
37 struct mesa_glinterop_device_info *out)
38 {
39 struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
40
41 if (!psc->interop)
42 return MESA_GLINTEROP_UNSUPPORTED;
43
44 return psc->interop->query_device_info(ctx->driContext, out);
45 }
46
47 _X_HIDDEN int
dri2_interop_export_object(struct glx_context * ctx,struct mesa_glinterop_export_in * in,struct mesa_glinterop_export_out * out)48 dri2_interop_export_object(struct glx_context *ctx,
49 struct mesa_glinterop_export_in *in,
50 struct mesa_glinterop_export_out *out)
51 {
52 struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
53
54 if (!psc->interop)
55 return MESA_GLINTEROP_UNSUPPORTED;
56
57 return psc->interop->export_object(ctx->driContext, in, out);
58 }
59
60 _X_HIDDEN int
dri2_interop_flush_objects(struct glx_context * ctx,unsigned count,struct mesa_glinterop_export_in * objects,struct mesa_glinterop_flush_out * out)61 dri2_interop_flush_objects(struct glx_context *ctx,
62 unsigned count, struct mesa_glinterop_export_in *objects,
63 struct mesa_glinterop_flush_out *out)
64 {
65 struct dri2_screen *psc = (struct dri2_screen*)ctx->psc;
66
67 if (!psc->interop || psc->interop->base.version < 2)
68 return MESA_GLINTEROP_UNSUPPORTED;
69
70 return psc->interop->flush_objects(ctx->driContext, count, objects, out);
71 }
72
73 #if defined(HAVE_DRI3)
74
75 _X_HIDDEN int
dri3_interop_query_device_info(struct glx_context * ctx,struct mesa_glinterop_device_info * out)76 dri3_interop_query_device_info(struct glx_context *ctx,
77 struct mesa_glinterop_device_info *out)
78 {
79 struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
80
81 if (!psc->interop)
82 return MESA_GLINTEROP_UNSUPPORTED;
83
84 return psc->interop->query_device_info(ctx->driContext, out);
85 }
86
87 _X_HIDDEN int
dri3_interop_export_object(struct glx_context * ctx,struct mesa_glinterop_export_in * in,struct mesa_glinterop_export_out * out)88 dri3_interop_export_object(struct glx_context *ctx,
89 struct mesa_glinterop_export_in *in,
90 struct mesa_glinterop_export_out *out)
91 {
92 struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
93
94 if (!psc->interop)
95 return MESA_GLINTEROP_UNSUPPORTED;
96
97 return psc->interop->export_object(ctx->driContext, in, out);
98 }
99
100 _X_HIDDEN int
dri3_interop_flush_objects(struct glx_context * ctx,unsigned count,struct mesa_glinterop_export_in * objects,struct mesa_glinterop_flush_out * out)101 dri3_interop_flush_objects(struct glx_context *ctx,
102 unsigned count, struct mesa_glinterop_export_in *objects,
103 struct mesa_glinterop_flush_out *out)
104 {
105 struct dri3_screen *psc = (struct dri3_screen*)ctx->psc;
106
107 if (!psc->interop || psc->interop->base.version < 2)
108 return MESA_GLINTEROP_UNSUPPORTED;
109
110 return psc->interop->flush_objects(ctx->driContext, count, objects, out);
111 }
112
113 #endif /* HAVE_DRI3 */
114 #endif /* defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) */
115