aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/egl/common')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c11
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_image.c24
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_st.c7
-rw-r--r--src/gallium/state_trackers/egl/common/native.h3
-rw-r--r--src/gallium/state_trackers/egl/common/native_buffer.h4
5 files changed, 46 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 6649f02b244..b5e3d99b811 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -132,6 +132,12 @@ egl_g3d_get_platform(_EGLDriver *drv, _EGLPlatformType plat)
nplat = native_get_fbdev_platform(&egl_g3d_native_event_handler);
#endif
break;
+ case _EGL_PLATFORM_ANDROID:
+ plat_name = "Android";
+#ifdef HAVE_ANDROID_BACKEND
+ nplat = native_get_android_platform(&egl_g3d_native_event_handler);
+#endif
+ break;
default:
break;
}
@@ -572,6 +578,11 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
if (dpy->Platform == _EGL_PLATFORM_WAYLAND && gdpy->native->buffer)
dpy->Extensions.MESA_drm_image = EGL_TRUE;
+#ifdef EGL_ANDROID_image_native_buffer
+ if (dpy->Platform == _EGL_PLATFORM_ANDROID && gdpy->native->buffer)
+ dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
+#endif
+
#ifdef EGL_WL_bind_wayland_display
if (gdpy->native->wayland_bufmgr)
dpy->Extensions.WL_bind_wayland_display = EGL_TRUE;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
index 7e9a29b0284..4d90c400319 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
@@ -202,6 +202,24 @@ egl_g3d_reference_wl_buffer(_EGLDisplay *dpy, struct wl_buffer *buffer,
#endif /* EGL_WL_bind_wayland_display */
+#ifdef EGL_ANDROID_image_native_buffer
+
+static struct pipe_resource *
+egl_g3d_reference_android_native_buffer(_EGLDisplay *dpy,
+ struct android_native_buffer_t *buf)
+{
+ struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
+ struct native_buffer nbuf;
+
+ memset(&nbuf, 0, sizeof(nbuf));
+ nbuf.type = NATIVE_BUFFER_ANDROID;
+ nbuf.u.android = buf;
+
+ return gdpy->native->buffer->import_buffer(gdpy->native, &nbuf);
+}
+
+#endif /* EGL_ANDROID_image_native_buffer */
+
_EGLImage *
egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
EGLenum target, EGLClientBuffer buffer,
@@ -239,6 +257,12 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
(struct wl_buffer *) buffer, &gimg->base, attribs);
break;
#endif
+#ifdef EGL_ANDROID_image_native_buffer
+ case EGL_NATIVE_BUFFER_ANDROID:
+ ptex = egl_g3d_reference_android_native_buffer(dpy,
+ (struct android_native_buffer_t *) buffer);
+ break;
+#endif
default:
ptex = NULL;
break;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index 60c3e332ac9..b839f848d7b 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -126,7 +126,7 @@ pbuffer_reference_openvg_image(struct egl_g3d_surface *gsurf)
}
static void
-pbuffer_allocate_render_texture(struct egl_g3d_surface *gsurf)
+pbuffer_allocate_pbuffer_texture(struct egl_g3d_surface *gsurf)
{
struct egl_g3d_display *gdpy =
egl_g3d_display(gsurf->base.Resource.Display);
@@ -141,7 +141,8 @@ pbuffer_allocate_render_texture(struct egl_g3d_surface *gsurf)
templ.depth0 = 1;
templ.array_size = 1;
templ.format = gsurf->stvis.color_format;
- templ.bind = PIPE_BIND_RENDER_TARGET;
+ /* for rendering and binding to texture */
+ templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
ptex = screen->resource_create(screen, &templ);
gsurf->render_texture = ptex;
@@ -166,7 +167,7 @@ egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi,
if (!gsurf->render_texture) {
switch (gsurf->client_buffer_type) {
case EGL_NONE:
- pbuffer_allocate_render_texture(gsurf);
+ pbuffer_allocate_pbuffer_texture(gsurf);
break;
case EGL_OPENVG_IMAGE:
pbuffer_reference_openvg_image(gsurf);
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index fc50ee485fe..58593a489cd 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -293,6 +293,9 @@ native_get_drm_platform(const struct native_event_handler *event_handler);
const struct native_platform *
native_get_fbdev_platform(const struct native_event_handler *event_handler);
+const struct native_platform *
+native_get_android_platform(const struct native_event_handler *event_handler);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/state_trackers/egl/common/native_buffer.h b/src/gallium/state_trackers/egl/common/native_buffer.h
index b8a66d17e12..503ed580b05 100644
--- a/src/gallium/state_trackers/egl/common/native_buffer.h
+++ b/src/gallium/state_trackers/egl/common/native_buffer.h
@@ -33,9 +33,11 @@
#include "pipe/p_state.h"
struct native_display;
+struct android_native_buffer_t;
enum native_buffer_type {
NATIVE_BUFFER_DRM,
+ NATIVE_BUFFER_ANDROID,
NUM_NATIVE_BUFFERS
};
@@ -50,6 +52,8 @@ struct native_buffer {
unsigned handle; /**< the handle of the GEM object */
unsigned stride;
} drm;
+
+ struct android_native_buffer_t *android; /**< opaque native buffer */
} u;
};