[Mesa-stable] [PATCH] egl: support EGL_LARGEST_PBUFFER in eglCreatePbufferSurface(...)

Tapani Pälli tapani.palli at intel.com
Mon Feb 15 10:54:06 UTC 2016


From: Daniel Czarnowski <daniel.czarnowski at intel.com>

Patch provides a 'sane default' for a set pbuffer surface size when
EGL_LARGEST_PBUFFER is used by the client. MIN2 macro is moved to
egldefines so that it can be shared.

Fixes following Piglit test:
   egl-create-largest-pbuffer-surface

Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
Cc: "11.0 11.1" <mesa-stable at lists.freedesktop.org
---
 src/egl/main/eglconfig.c  | 1 -
 src/egl/main/egldefines.h | 5 +++++
 src/egl/main/eglsurface.c | 6 ++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index c445d9b..d79c0e1 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -44,7 +44,6 @@
 #include "egllog.h"
 
 
-#define MIN2(A, B)  (((A) < (B)) ? (A) : (B))
 
 
 /**
diff --git a/src/egl/main/egldefines.h b/src/egl/main/egldefines.h
index a32cab2..e6ff07e 100644
--- a/src/egl/main/egldefines.h
+++ b/src/egl/main/egldefines.h
@@ -40,9 +40,14 @@ extern "C" {
 
 #define _EGL_MAX_EXTENSIONS_LEN 1000
 
+/* Hardcoded default for EGL_LARGEST_PBUFFER */
+#define _EGL_MAX_PBUFFER_WIDTH 4096
+#define _EGL_MAX_PBUFFER_HEIGHT 4096
+
 #define _EGL_VENDOR_STRING "Mesa Project"
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#define MIN2(A, B)  (((A) < (B)) ? (A) : (B))
 
 #ifdef __cplusplus
 }
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 4fa43f3..2971bb0 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -307,6 +307,12 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
    if (err != EGL_SUCCESS)
       return _eglError(err, func);
 
+   /* if EGL_LARGEST_PBUFFER in use, clamp width and height */
+   if (surf->LargestPbuffer) {
+      surf->Width = MIN2(surf->Width, _EGL_MAX_PBUFFER_WIDTH);
+      surf->Height = MIN2(surf->Height, _EGL_MAX_PBUFFER_HEIGHT);
+   }
+
    return EGL_TRUE;
 }
 
-- 
2.5.0



More information about the mesa-stable mailing list