1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
From dbaa4390bc23b1620fe2c2bbf947d1693083650d Mon Sep 17 00:00:00 2001
From: Brendan King <Brendan.King@imgtec.com>
Date: Tue, 11 Mar 2014 11:50:53 +0000
Subject: [PATCH] Add EGL_IMG_cl_image extension
Add support for the experimental EGL_IMG_cl_image extension to EGL, and
the DRI2 EGL driver.
---
include/EGL/eglmesaext.h | 5 +++
include/GL/internal/dri_interface.h | 13 +++++++
src/egl/drivers/dri2/egl_dri2.c | 60 +++++++++++++++++++++++++----
src/egl/main/eglapi.c | 1 +
src/egl/main/egldisplay.h | 2 +
5 files changed, 73 insertions(+), 8 deletions(-)
diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h
index f0395a8..5d11f3e 100644
--- a/include/EGL/eglmesaext.h
+++ b/include/EGL/eglmesaext.h
@@ -49,6 +49,11 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
#define EGL_DRM_BUFFER_FORMAT_RGB565_MESA 0x3292
#endif /* EGL_MESA_drm_image_formats */
+#ifndef EGL_IMG_cl_image
+#define EGL_IMG_cl_image 1
+#define EGL_CL_IMAGE_IMG 0x6010
+#endif /* Experimental eglCreateImageKHR target */
+
#ifdef __cplusplus
}
#endif
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 7f8872f..ef2f44f 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1704,6 +1704,19 @@ struct __DRIimageExtensionRec {
* \since 21
*/
void (*setInFenceFd)(__DRIimage *image, int fd);
+
+ /**
+ * Support for experimental EGL_CL_IMAGE_IMG.
+ * Like createImageFromTexture, but from a buffer, the contents
+ * of which depend on the target.
+ *
+ * \since 8
+ */
+ __DRIimage *(*createImageFromBuffer)(__DRIcontext *context,
+ int target,
+ void *buffer,
+ unsigned *error,
+ void *loaderPrivate);
};
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index a583b91..d3a8fbe 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1007,6 +1007,10 @@ dri2_setup_screen(_EGLDisplay *disp)
disp->Extensions.EXT_image_dma_buf_import_modifiers = EGL_TRUE;
}
#endif
+ if (dri2_dpy->image->base.version >= 8 &&
+ dri2_dpy->image->createImageFromBuffer) {
+ disp->Extensions.IMG_cl_image = EGL_TRUE;
+ }
}
if (dri2_dpy->flush_control)
@@ -2386,17 +2390,13 @@ dri2_get_sync_values_chromium(_EGLDisplay *disp, _EGLSurface *surf,
return dri2_dpy->vtbl->get_sync_values(disp, surf, ust, msc, sbc);
}
-/**
- * Set the error code after a call to
- * dri2_egl_image::dri_image::createImageFromTexture.
- */
static void
-dri2_create_image_khr_texture_error(int dri_error)
+dri2_create_image_khr_error(int dri_error)
{
EGLint egl_error = egl_error_from_dri_image_error(dri_error);
if (egl_error != EGL_SUCCESS)
- _eglError(egl_error, "dri2_create_image_khr_texture");
+ _eglError(egl_error, "dri2_create_image_khr");
}
static _EGLImage *
@@ -2475,7 +2475,49 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx,
attrs.GLTextureLevel,
&error,
NULL);
- dri2_create_image_khr_texture_error(error);
+ dri2_create_image_khr_error(error);
+
+ if (!dri2_img->dri_image) {
+ free(dri2_img);
+ return EGL_NO_IMAGE_KHR;
+ }
+ return &dri2_img->base;
+}
+
+static _EGLImage *
+dri2_create_image_img_buffer(_EGLDisplay *disp, _EGLContext *ctx,
+ EGLenum target,
+ EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+ struct dri2_egl_image *dri2_img;
+ unsigned error;
+
+ switch (target) {
+ case EGL_CL_IMAGE_IMG:
+ break;
+ default:
+ _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ dri2_img = malloc(sizeof *dri2_img);
+ if (!dri2_img) {
+ _eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
+ return EGL_NO_IMAGE_KHR;
+ }
+
+ _eglInitImage(&dri2_img->base, disp);
+
+ dri2_img->dri_image =
+ dri2_dpy->image->createImageFromBuffer(dri2_ctx->dri_context,
+ target,
+ buffer,
+ &error,
+ NULL);
+ dri2_create_image_khr_error(error);
if (!dri2_img->dri_image) {
free(dri2_img);
@@ -2942,7 +2984,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
&error,
NULL);
}
- dri2_create_image_khr_texture_error(error);
+ dri2_create_image_khr_error(error);
if (!dri_image)
return EGL_NO_IMAGE_KHR;
@@ -3178,6 +3220,8 @@ dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target,
case EGL_WAYLAND_BUFFER_WL:
return dri2_create_image_wayland_wl_buffer(disp, ctx, buffer, attr_list);
#endif
+ case EGL_CL_IMAGE_IMG:
+ return dri2_create_image_img_buffer(disp, ctx, target, buffer, attr_list);
default:
_eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr");
return EGL_NO_IMAGE_KHR;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index d0238fe..ddad85d 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -550,6 +550,7 @@ _eglCreateExtensionsString(_EGLDisplay *disp)
_EGL_CHECK_EXTENSION(WL_bind_wayland_display);
_EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image);
+ _EGL_CHECK_EXTENSION(IMG_cl_image);
#undef _EGL_CHECK_EXTENSION
}
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 25b4ea7..d95c7b9 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -152,6 +152,8 @@ struct _egl_extensions
EGLBoolean WL_bind_wayland_display;
EGLBoolean WL_create_wayland_buffer_from_image;
+
+ EGLBoolean IMG_cl_image;
};
struct _egl_display
|