[Mesa-dev] [PATCH] egl_dri2: drm: make sure back buffer is validated before making current
Guarantee that the back buffer is validated by calling flush before assigning the back buffer to current. Signed-off-by: Mandeep Singh Baines m...@chromium.org Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com Cc: Benjamin Franzke benjaminfran...@googlemail.com Cc: Kristian Hogsberg k...@bitplanet.net Cc: David Reveman reve...@chromium.org Cc: Stephane Marchesin marc...@chromium.org --- src/egl/drivers/dri2/platform_drm.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 18ecd17..7b4529d 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -325,6 +325,8 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); + (*dri2_dpy-flush-flush)(dri2_surf-dri_drawable); + if (dri2_surf-base.Type == EGL_WINDOW_BIT) { if (dri2_surf-current) _eglError(EGL_BAD_SURFACE, dri2_swap_buffers); @@ -332,7 +334,6 @@ dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) dri2_surf-back = NULL; } - (*dri2_dpy-flush-flush)(dri2_surf-dri_drawable); (*dri2_dpy-flush-invalidate)(dri2_surf-dri_drawable); return EGL_TRUE; -- 1.7.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform
Keep a reference to any newly allocated aux buffers to avoid re-allocating for every st_framebuffer_validate() (i.e. leaking). Signed-off-by: Mandeep Singh Baines m...@chromium.org Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com Cc: Benjamin Franzke benjaminfran...@googlemail.com Cc: Kristian Hogsberg k...@bitplanet.net Cc: David Reveman reve...@chromium.org Cc: Stephane Marchesin marc...@chromium.org --- src/egl/drivers/dri2/platform_drm.c |9 - 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 18ecd17..54067ff 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf, { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf-base.Resource.Display); - __DRIbuffer *b; + __DRIbuffer *b = dri2_surf-dri_buffers[attachment]; - b = NULL; - if (dri2_surf-dri_buffers[attachment]) - b = dri2_surf-dri_buffers[attachment]; - if (b == NULL) + if (b == NULL) { b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen, attachment, format, dri2_surf-base.Width, dri2_surf-base.Height); + dri2_surf-dri_buffers[attachment] = b; + } if (b == NULL) return -1; -- 1.7.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform
On Tue, Apr 10, 2012 at 4:02 PM, Kristian Høgsberg k...@bitplanet.net wrote: On Tue, Apr 10, 2012 at 6:30 PM, Mandeep Baines mandeep.bai...@gmail.com wrote: Attached is the test case I've been using. Nice, I've been meaning to update eglkms.c to also demonstrate pageflipping. Do you mind if I commit your version? Sure. Signed-off-by: Mandeep Singh Bainesm...@chromium.org Kristian On Tue, Apr 10, 2012 at 3:26 PM, mandeep.bai...@gmail.com wrote: From: Mandeep Singh Baines m...@chromium.org Keep a reference to any newly allocated aux buffers to avoid re-allocating for every st_framebuffer_validate() (i.e. leaking). Signed-off-by: Mandeep Singh Baines m...@chromium.org Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com Cc: Benjamin Franzke benjaminfran...@googlemail.com Cc: Kristian Hogsberg k...@bitplanet.net Cc: David Reveman reve...@chromium.org Cc: Stephane Marchesin marc...@chromium.org --- src/egl/drivers/dri2/platform_drm.c | 9 - 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 18ecd17..54067ff 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf, { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf-base.Resource.Display); - __DRIbuffer *b; + __DRIbuffer *b = dri2_surf-dri_buffers[attachment]; - b = NULL; - if (dri2_surf-dri_buffers[attachment]) - b = dri2_surf-dri_buffers[attachment]; - if (b == NULL) + if (b == NULL) { b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen, attachment, format, dri2_surf-base.Width, dri2_surf-base.Height); + dri2_surf-dri_buffers[attachment] = b; + } if (b == NULL) return -1; -- 1.7.3.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl_dri2: fix aux buffer leak in drm platform
On Tue, Apr 10, 2012 at 4:02 PM, Kristian Høgsberg k...@bitplanet.net wrote: On Tue, Apr 10, 2012 at 6:30 PM, Mandeep Baines mandeep.bai...@gmail.com wrote: Attached is the test case I've been using. Nice, I've been meaning to update eglkms.c to also demonstrate pageflipping. Do you mind if I commit your version? Attached is a cleaned up version with proper error handling. Kristian On Tue, Apr 10, 2012 at 3:26 PM, mandeep.bai...@gmail.com wrote: From: Mandeep Singh Baines m...@chromium.org Keep a reference to any newly allocated aux buffers to avoid re-allocating for every st_framebuffer_validate() (i.e. leaking). Signed-off-by: Mandeep Singh Baines m...@chromium.org Cc: Ander Conselvan de Oliveira ander.conselvan.de.olive...@intel.com Cc: Benjamin Franzke benjaminfran...@googlemail.com Cc: Kristian Hogsberg k...@bitplanet.net Cc: David Reveman reve...@chromium.org Cc: Stephane Marchesin marc...@chromium.org --- src/egl/drivers/dri2/platform_drm.c | 9 - 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 18ecd17..54067ff 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf, { struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf-base.Resource.Display); - __DRIbuffer *b; + __DRIbuffer *b = dri2_surf-dri_buffers[attachment]; - b = NULL; - if (dri2_surf-dri_buffers[attachment]) - b = dri2_surf-dri_buffers[attachment]; - if (b == NULL) + if (b == NULL) { b = dri2_dpy-dri2-allocateBuffer(dri2_dpy-dri_screen, attachment, format, dri2_surf-base.Width, dri2_surf-base.Height); + dri2_surf-dri_buffers[attachment] = b; + } if (b == NULL) return -1; -- 1.7.3.4 /* * Copyright © 2011 Kristian Høgsberg * Copyright © 2011 Benjamin Franzke * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of the copyright holders not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no representations * about the suitability of this software for any purpose. It is provided as * is without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include stdio.h #include stdlib.h #define EGL_EGLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES #include gbm.h #include GL/gl.h #include EGL/egl.h #include EGL/eglext.h #include drm.h #include xf86drm.h #include xf86drmMode.h #include fcntl.h #include signal.h #include unistd.h #include string.h #include time.h #ifdef GL_OES_EGL_image static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_func; #endif struct kms { drmModeConnector *connector; drmModeEncoder *encoder; drmModeModeInfo mode; }; GLfloat x = 1.0; GLfloat y = 1.0; GLfloat xstep = 1.0f; GLfloat ystep = 1.0f; GLfloat rsize = 50; int quit = 0; static EGLBoolean setup_kms(int fd, struct kms *kms) { drmModeRes *resources; drmModeConnector *connector; drmModeEncoder *encoder; int i; resources = drmModeGetResources(fd); if (!resources) { fprintf(stderr, drmModeGetResources failed\n); return EGL_FALSE; } for (i = 0; i resources-count_connectors; i++) { connector = drmModeGetConnector(fd, resources-connectors[i]); if (connector == NULL) continue; if (connector-connection == DRM_MODE_CONNECTED connector-count_modes 0) break; drmModeFreeConnector(connector); } if (i == resources-count_connectors) { fprintf(stderr, No currently active connector found.\n); return EGL_FALSE; } for (i = 0; i resources-count_encoders; i++) { encoder = drmModeGetEncoder(fd, resources-encoders[i]); if (encoder == NULL) continue; if (encoder-encoder_id == connector-encoder_id) break; drmModeFreeEncoder(encoder); } kms-connector = connector; kms-encoder = encoder; kms-mode = connector-modes[0