summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuelian <xuelian.bai@samsung.com>2020-02-17 20:39:44 +0800
committerXuelian <xuelian.bai@samsung.com>2020-02-22 00:05:46 +0800
commit9f96373b703664c94903c7057c2092f3babfdb31 (patch)
treec98a131cb4d258b522228816fed18ac1e005772f
parent27573473cad2e63d274e2ec45e4109fc8183a50b (diff)
downloadmesa-9f96373b703664c94903c7057c2092f3babfdb31.tar.gz
mesa-9f96373b703664c94903c7057c2092f3babfdb31.tar.bz2
mesa-9f96373b703664c94903c7057c2092f3babfdb31.zip
Add Pbuffer support on Tizen platform
Merged old commit: Change-Id: I8cb2b7776a334f96cf67408b81c8325bd9b46bf9 Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com> 1. Add EGL_PBUFFER_BIT to surface_type if maskes match 2. Alloc local buffer when render buffer type is "FRONT_LEFT" which will be used by Pbuffer Change-Id: I55c7f4d06392198ae41ffd0a9d5dd23fb15bd532 Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com> Fix crash when query a pbuffer surface Pbuffer is not created via TPL, so when query a pbuffer surface, we can only call _eglQuerySurface instead of TPL APIs. Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rwxr-xr-xsrc/egl/drivers/dri2/platform_tizen.c96
1 files changed, 68 insertions, 28 deletions
diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c
index a9f52caf607..71ffe3c15f3 100755
--- a/src/egl/drivers/dri2/platform_tizen.c
+++ b/src/egl/drivers/dri2/platform_tizen.c
@@ -50,6 +50,8 @@
#include <wayland-client.h>
#include <drm-uapi/drm_fourcc.h>
+#include <drm_fourcc.h>
+
int tbm_bufmgr_fd = -1;
static void tizen_free_local_buffers(struct dri2_egl_surface *dri2_surf);
@@ -364,6 +366,7 @@ tizen_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
_eglError(EGL_BAD_NATIVE_PIXMAP, "tizen_create_surface needs valid native pixmap");
goto cleanup_surface;
}
+
ret = tpl_display_get_native_pixmap_info(dri2_dpy->tpl_display,
(tpl_handle_t)native_window,
&dri2_surf->base.Width,
@@ -376,17 +379,16 @@ tizen_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
}
tpl_surf_type = TPL_SURFACE_TYPE_PIXMAP;
- } else {
- _eglError(EGL_BAD_NATIVE_WINDOW, "tizen_create_surface does not support PBuffer");
- goto cleanup_surface;
}
- dri2_surf->tpl_surface = tpl_surface_create(dri2_dpy->tpl_display,
+ if(type == EGL_WINDOW_BIT || type == EGL_PIXMAP_BIT) {
+ dri2_surf->tpl_surface = tpl_surface_create(dri2_dpy->tpl_display,
(tpl_handle_t)native_window,
tpl_surf_type,
dri2_surf->tbm_format);
- if (!dri2_surf->tpl_surface)
- goto cleanup_surface;
+ if (!dri2_surf->tpl_surface)
+ goto cleanup_surface;
+ }
if (!dri2_create_drawable(dri2_dpy, config, dri2_surf, dri2_surf)) {
_eglError(EGL_BAD_ALLOC, "createNewDrawable");
@@ -456,7 +458,8 @@ tizen_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
dri2_dpy->core->destroyDrawable(dri2_surf->dri_drawable);
- tpl_object_unreference((tpl_object_t *)dri2_surf->tpl_surface);
+ if (dri2_surf->tpl_surface)
+ tpl_object_unreference((tpl_object_t *)dri2_surf->tpl_surface);
free(dri2_surf);
@@ -925,26 +928,28 @@ tizen_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
int width = 0, height = 0;
- if (tpl_display_get_native_window_info(dri2_dpy->tpl_display,
- dri2_surf->native_win,
- &width, &height, NULL, 0, 0) != TPL_ERROR_NONE)
- return EGL_FALSE;
-
- switch (attribute) {
- case EGL_WIDTH:
- if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->native_win) {
- *value = width;
- return EGL_TRUE;
- }
- break;
- case EGL_HEIGHT:
- if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->native_win) {
- *value = height;
- return EGL_TRUE;
- }
- break;
- default:
- break;
+ if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+ if (tpl_display_get_native_window_info(dri2_dpy->tpl_display,
+ dri2_surf->native_win,
+ &width, &height, NULL, 0, 0) != TPL_ERROR_NONE)
+ return EGL_FALSE;
+
+ switch (attribute) {
+ case EGL_WIDTH:
+ if (dri2_surf->native_win) {
+ *value = width;
+ return EGL_TRUE;
+ }
+ break;
+ case EGL_HEIGHT:
+ if (dri2_surf->native_win) {
+ *value = height;
+ return EGL_TRUE;
+ }
+ break;
+ default:
+ break;
+ }
}
return _eglQuerySurface(drv, dpy, surf, attribute, value);
}
@@ -1033,6 +1038,9 @@ tizen_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
break;
}
/* fall through for pbuffers */
+ case __DRI_BUFFER_FRONT_LEFT:
+ if (dri2_surf->base.Type != EGL_PBUFFER_BIT)
+ break;
case __DRI_BUFFER_DEPTH:
case __DRI_BUFFER_STENCIL:
case __DRI_BUFFER_ACCUM:
@@ -1045,7 +1053,6 @@ tizen_get_buffers_parse_attachments(struct dri2_egl_surface *dri2_surf,
num_buffers++;
}
break;
- case __DRI_BUFFER_FRONT_LEFT:
case __DRI_BUFFER_FRONT_RIGHT:
case __DRI_BUFFER_FAKE_FRONT_LEFT:
case __DRI_BUFFER_FAKE_FRONT_RIGHT:
@@ -1216,6 +1223,16 @@ tizen_add_configs(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
int count, i;
+ struct rgba_masks {
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ unsigned int alpha;
+ } pbuffer_masks[] = {
+ { 0xff0000, 0xff00, 0xff, 0xff000000 }, /* ARGB8888 */
+ { 0xff0000, 0xff00, 0xff, 0x0 }, /* RGB888 */
+ { 0x00f800, 0x07e0, 0x1f, 0x0 }, /* RGB565 */
+ };
for (i = 0, count = 0; dri2_dpy->driver_configs[i]; i++) {
struct dri2_egl_config *dri2_cfg;
@@ -1227,6 +1244,8 @@ tizen_add_configs(_EGLDriver *drv, _EGLDisplay *dpy)
EGL_NONE,
};
tpl_result_t res;
+ struct rgba_masks masks;
+ int j;
dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
__DRI_ATTRIB_RED_SIZE, &red);
@@ -1251,6 +1270,27 @@ tizen_add_configs(_EGLDriver *drv, _EGLDisplay *dpy)
if (res == TPL_ERROR_NONE)
surface_type |= EGL_PIXMAP_BIT;
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_RED_MASK, &masks.red);
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_GREEN_MASK, &masks.green);
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_BLUE_MASK, &masks.blue);
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_ALPHA_MASK, &masks.alpha);
+
+ for (j = 0; j < ARRAY_SIZE(pbuffer_masks); j++) {
+ const struct rgba_masks *pbuffer_mask = &pbuffer_masks[j];
+
+ if (pbuffer_mask->red == masks.red &&
+ pbuffer_mask->green == masks.green &&
+ pbuffer_mask->blue == masks.blue &&
+ pbuffer_mask->alpha == masks.alpha) {
+ surface_type |= EGL_PBUFFER_BIT;
+ break;
+ }
+ }
+
if (!surface_type)
continue;