diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-04-15 14:46:31 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-04-15 21:37:44 +0200 |
commit | 62c9caac7028a9c5094b6a7c35d2bae9e9994ac5 (patch) | |
tree | bce3fb8e72388babd1ee02bb181cb3e26ae9d6bd | |
parent | d2afae33f896ece1af0c8953ac9ce141c39f6dd2 (diff) |
egl/wayland: Implement WL_EGL_USE_SCANOUTuse_flags
-rw-r--r-- | include/GL/internal/dri_interface.h | 8 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 22 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/wayland-egl-priv.h | 3 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/wayland-egl.c | 14 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/drm/dri2.c | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_wayland.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_screen.c | 2 |
8 files changed, 63 insertions, 15 deletions
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 2fb729afcd..70be105af1 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -761,6 +761,9 @@ struct __DRIdri2LoaderExtensionRec { #define __DRI_API_GLES 1 #define __DRI_API_GLES2 2 +#define __DRI_BUFFER_USE_SHARE 0x0001 +#define __DRI_BUFFER_USE_SCANOUT 0x0002 + struct __DRIdri2ExtensionRec { __DRIextension base; @@ -790,8 +793,9 @@ struct __DRIdri2ExtensionRec { __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen, unsigned int attachment, unsigned int format, - int width, - int height); + int width, int height, + unsigned int use); + void (*releaseBuffer)(__DRIscreen *screen, __DRIbuffer *buffer); }; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index cb1de2681f..5ebe9d9281 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -140,6 +140,7 @@ struct dri2_egl_surface __DRIbuffer *dri_buffers[__DRI_BUFFER_COUNT]; __DRIbuffer *pending_buffer; EGLBoolean block_swap_buffers; + unsigned int buffer_use; #endif }; diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 0cc20bbc0b..d0b7dac050 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -91,6 +91,7 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, dri2_surf->pending_buffer = NULL; dri2_surf->block_swap_buffers = EGL_FALSE; + dri2_surf->buffer_use = __DRI_BUFFER_USE_SHARE; switch (type) { case EGL_WINDOW_BIT: @@ -99,6 +100,10 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, dri2_surf->base.Width = -1; dri2_surf->base.Height = -1; + + if (dri2_surf->wl_win->flags & WL_EGL_USE_SCANOUT); + dri2_surf->buffer_use |= __DRI_BUFFER_USE_SCANOUT; + break; case EGL_PIXMAP_BIT: dri2_surf->wl_pix = (struct wl_egl_pixmap *) window; @@ -107,6 +112,9 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type, dri2_surf->base.Width = dri2_surf->wl_pix->width; dri2_surf->base.Height = dri2_surf->wl_pix->height; + if (dri2_surf->wl_pix->flags & WL_EGL_USE_SCANOUT); + dri2_surf->buffer_use |= __DRI_BUFFER_USE_SCANOUT; + if (dri2_surf->wl_pix->name > 0) { dri2_buf = dri2_surf->wl_pix->driver_private; dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] = dri2_buf->dri_buffer; @@ -221,7 +229,8 @@ dri2_process_back_buffer(struct dri2_egl_surface *dri2_surf, unsigned format) dri2_surf->dri_buffers[__DRI_BUFFER_FRONT_LEFT] = dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, __DRI_BUFFER_FRONT_LEFT, format, - dri2_surf->base.Width, dri2_surf->base.Height); + dri2_surf->base.Width, dri2_surf->base.Height, + dri2_surf->buffer_use); break; default: break; @@ -332,11 +341,11 @@ dri2_get_buffers_with_format(__DRIdrawable * driDrawable, assert(dri2_surf->buffer_count < 5); if (dri2_surf->dri_buffers[attachments[i]] == NULL) { - dri2_surf->dri_buffers[attachments[i]] = dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, attachments[i], attachments[i+1], - dri2_surf->base.Width, dri2_surf->base.Height); + dri2_surf->base.Width, dri2_surf->base.Height, + dri2_surf->buffer_use); if (!dri2_surf->dri_buffers[attachments[i]]) continue; @@ -524,17 +533,22 @@ dri2_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA, EGL_NONE }; + unsigned use = __DRI_BUFFER_USE_SHARE; dri2_buf = malloc(sizeof *dri2_buf); if (!dri2_buf) return NULL; + if (wl_egl_pixmap->flags & WL_EGL_USE_SCANOUT) + use |= __DRI_BUFFER_USE_SCANOUT; + dri2_buf->dri2_dpy = dri2_dpy; dri2_buf->dri_buffer = dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, __DRI_BUFFER_FRONT_LEFT, 32, wl_egl_pixmap->width, - wl_egl_pixmap->height); + wl_egl_pixmap->height, + use); wl_egl_pixmap->name = dri2_buf->dri_buffer->name; wl_egl_pixmap->stride = dri2_buf->dri_buffer->pitch; diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h b/src/egl/wayland/wayland-egl/wayland-egl-priv.h index 38b21c25be..b1d880af98 100644 --- a/src/egl/wayland/wayland-egl/wayland-egl-priv.h +++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h @@ -14,6 +14,7 @@ extern "C" { #include <stdbool.h> #include <wayland-client.h> +#include <wayland-egl.h> struct wl_egl_display { struct wl_display *display; @@ -34,6 +35,7 @@ struct wl_egl_window { int height; int dx; int dy; + uint32_t flags; int attached_width; int attached_height; @@ -47,6 +49,7 @@ struct wl_egl_pixmap { int width; int height; int stride; + uint32_t flags; void (*destroy) (struct wl_egl_pixmap *egl_pixmap); diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c b/src/egl/wayland/wayland-egl/wayland-egl.c index 2c84bec64a..46f0457a75 100644 --- a/src/egl/wayland/wayland-egl/wayland-egl.c +++ b/src/egl/wayland/wayland-egl/wayland-egl.c @@ -141,10 +141,15 @@ WL_EGL_EXPORT struct wl_egl_window * wl_egl_window_create(struct wl_egl_display *egl_display, struct wl_surface *surface, int width, int height, - struct wl_visual *visual) + struct wl_visual *visual, uint32_t flags) { struct wl_egl_window *egl_window; + if ((flags & WL_EGL_USE_SCANOUT) != 0) { + fprintf(stderr, "wayland-egl: %s: invalid flags\n", __func__); + return NULL; + } + egl_window = malloc(sizeof *egl_window); if (!egl_window) return NULL; @@ -154,6 +159,7 @@ wl_egl_window_create(struct wl_egl_display *egl_display, wl_egl_window_resize(egl_window, width, height, 0, 0); egl_window->attached_width = 0; egl_window->attached_height = 0; + egl_window->flags = flags; return egl_window; } @@ -181,6 +187,11 @@ wl_egl_pixmap_create(struct wl_egl_display *egl_display, { struct wl_egl_pixmap *egl_pixmap; + if ((flags & WL_EGL_USE_SCANOUT) != 0) { + fprintf(stderr, "wayland-egl: %s: invalid flags\n", __func__); + return NULL; + } + egl_pixmap = malloc(sizeof *egl_pixmap); if (egl_pixmap == NULL) return NULL; @@ -191,6 +202,7 @@ wl_egl_pixmap_create(struct wl_egl_display *egl_display, egl_pixmap->visual = visual; egl_pixmap->name = 0; egl_pixmap->stride = 0; + egl_pixmap->flags = flags; egl_pixmap->destroy = NULL; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 30326a23d6..fdffad7e43 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -263,7 +263,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable, static __DRIbuffer * dri2_allocate_buffer(__DRIscreen *sPriv, unsigned attachment, unsigned format, - int width, int height) + int width, int height, unsigned use) { struct dri_screen *screen = dri_screen(sPriv); struct dri2_buffer *buffer; @@ -305,6 +305,11 @@ dri2_allocate_buffer(__DRIscreen *sPriv, return NULL; } + if (use & __DRI_BUFFER_USE_SCANOUT) + bind |= PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET; + if (use & __DRI_BUFFER_USE_SHARE) + bind |= PIPE_BIND_SHARED; + buffer = CALLOC_STRUCT(dri2_buffer); if (!buffer) return NULL; diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c index fd35b45373..9dca1c2f37 100644 --- a/src/gallium/state_trackers/egl/wayland/native_wayland.c +++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c @@ -401,6 +401,7 @@ wayland_create_pixmap_surface(struct native_display *ndpy, struct wayland_surface *surface; struct wl_egl_pixmap *egl_pixmap = (struct wl_egl_pixmap *) pix; enum native_attachment natt = NATIVE_ATTACHMENT_FRONT_LEFT; + uint bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; surface = CALLOC_STRUCT(wayland_surface); if (!surface) @@ -419,10 +420,13 @@ wayland_create_pixmap_surface(struct native_display *ndpy, surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT); + if (surface->pix->flags & WL_EGL_USE_SCANOUT) + bind |= PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET; + + bind |= PIPE_BIND_SHARED; + surface->rsurf = resource_surface_create(display->base.screen, - surface->color_format, - PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | - PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT); + surface->color_format, bind); if (!surface->rsurf) { FREE(surface); @@ -453,6 +457,7 @@ wayland_create_window_surface(struct native_display *ndpy, struct wayland_display *display = wayland_display(ndpy); struct wayland_config *config = wayland_config(nconf); struct wayland_surface *surface; + uint bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; surface = CALLOC_STRUCT(wayland_surface); if (!surface) @@ -472,10 +477,14 @@ wayland_create_window_surface(struct native_display *ndpy, surface->attachment_mask = (1 << NATIVE_ATTACHMENT_FRONT_LEFT) | (1 << NATIVE_ATTACHMENT_BACK_LEFT); + + if (surface->win->flags & WL_EGL_USE_SCANOUT) + bind |= PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET; + + bind |= PIPE_BIND_SHARED; + surface->rsurf = resource_surface_create(display->base.screen, - surface->color_format, - PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | - PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT); + surface->color_format, bind); if (!surface->rsurf) { FREE(surface); diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 64a21a147f..cf631f9fa9 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -656,7 +656,7 @@ struct intel_buffer { static __DRIbuffer * intelAllocateBuffer(__DRIscreen *screen, unsigned attachment, unsigned format, - int width, int height) + int width, int height, unsigned use) { struct intel_buffer *intelBuffer; struct intel_screen *intelScreen = screen->private; |