[PATCH 2/8] glamor/xv: add vbo support

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_xv.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 85e6528..d9db574 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
 PixmapPtr pixmap = port_priv->pPixmap;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_pixmap_private *src_pixmap_priv[3];
-float vertices[32], texcoords[8];
 BoxPtr box = REGION_RECTS(_priv->clip);
 int nBox = REGION_NUM_RECTS(_priv->clip);
 int dst_x_off, dst_y_off;
@@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float bright, cont, gamma;
 int ref = port_priv->transform_index;
 GLint uloc, sampler_loc;
+GLfloat *v;
+char *vbo_offset;
 
 if (!glamor_priv->xv_prog)
 glamor_init_xv_shader(screen);
@@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
 sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
 glUniform1i(sampler_loc, 2);
 
-glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-  GL_FLOAT, GL_FALSE,
-  2 * sizeof(float), texcoords);
+glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 2 * sizeof(float), vertices);
-
-glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnable(GL_SCISSOR_TEST);
+
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, _offset);
+
 for (i = 0; i < nBox; i++) {
 float off_x = box[i].x1 - port_priv->drw_x;
 float off_y = box[i].y1 - port_priv->drw_y;
@@ -352,6 +350,7 @@ glamor_xv_render(glamor_port_private *port_priv)
 float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
 float srcx, srcy, srcw, srch;
 int dstx, dsty, dstw, dsth;
+GLfloat *ptr = v + (i * 16);
 
 dstx = box[i].x1 + dst_x_off;
 dsty = box[i].y1 + dst_y_off;
@@ -369,7 +368,7 @@ glamor_xv_render(glamor_port_private *port_priv)
  dsty,
  dstx + dstw,
  dsty + dsth * 2,
- vertices);
+ ptr);
 
 glamor_set_normalize_tcoords(src_pixmap_priv[0],
  src_xscale[0],
@@ -378,16 +377,28 @@ glamor_xv_render(glamor_port_private *port_priv)
  srcy,
  srcx + srcw,
  srcy + srch * 2,
- texcoords);
+ ptr + 8);
+
+
+glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset);
+
+glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset + 8 * 
sizeof(GLfloat));
 
 glScissor(dstx, dsty, dstw, dsth);
 glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
+vbo_offset += 16 * sizeof(GLfloat);
 }
 glDisable(GL_SCISSOR_TEST);
 
 glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
 glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
+glamor_put_vbo_space(screen);
+
 DamageDamageRegion(port_priv->pDraw, _priv->clip);
 
 glamor_xv_free_port_data(port_priv);
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 6/8] ephyr: Create 3.3 core profile context if possible (v2)

2016-01-18 Thread Dave Airlie
From: Keith Packard 

On desktop GL, Ask for a 3.3 core profile context if that's available,
otherwise create a generic context.

v2: tell glamor the profile is a core one.

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 19 +--
 hw/kdrive/ephyr/ephyr_glamor_glx.h |  2 +-
 hw/kdrive/ephyr/hostx.c|  7 +--
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 30c5245..674e7f5 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -277,7 +277,7 @@ ephyr_glamor_process_event(xcb_generic_event_t *xev)
 }
 
 struct ephyr_glamor *
-ephyr_glamor_glx_screen_init(xcb_window_t win)
+ephyr_glamor_glx_screen_init(xcb_window_t win, Bool *profile_is_core)
 {
 static const float position[] = {
 -1, -1,
@@ -295,6 +295,7 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
 struct ephyr_glamor *glamor;
 GLXWindow glx_win;
 
+*profile_is_core = FALSE;
 glamor = calloc(1, sizeof(struct ephyr_glamor));
 if (!glamor) {
 FatalError("malloc");
@@ -319,7 +320,21 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
"GLX_EXT_create_context_es2_profile\n");
 }
 } else {
-ctx = glXCreateContext(dpy, visual_info, NULL, True);
+static const int context_attribs[] = {
+GLX_CONTEXT_PROFILE_MASK_ARB,
+GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+GLX_CONTEXT_MAJOR_VERSION_ARB,
+3,
+GLX_CONTEXT_MINOR_VERSION_ARB,
+3,
+0,
+};
+ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
+ context_attribs);
+if (!ctx)
+ctx = glXCreateContext(dpy, visual_info, NULL, True);
+else
+*profile_is_core = TRUE;
 }
 if (ctx == NULL)
 FatalError("glXCreateContext failed\n");
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.h 
b/hw/kdrive/ephyr/ephyr_glamor_glx.h
index 0c238cf..c479b73 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.h
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.h
@@ -44,7 +44,7 @@ xcb_visualtype_t *
 ephyr_glamor_get_visual(void);
 
 struct ephyr_glamor *
-ephyr_glamor_glx_screen_init(xcb_window_t win);
+ephyr_glamor_glx_screen_init(xcb_window_t win, Bool *profile_is_core);
 
 void
 ephyr_glamor_glx_screen_fini(struct ephyr_glamor *glamor);
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 49516bb..e7fa089 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1426,12 +1426,15 @@ ephyr_glamor_init(ScreenPtr screen)
 KdScreenPriv(screen);
 KdScreenInfo *kd_screen = pScreenPriv->screen;
 EphyrScrPriv *scrpriv = kd_screen->driver;
+Bool profile_is_core;
+int flags;
+scrpriv->glamor = ephyr_glamor_glx_screen_init(scrpriv->win, 
_is_core);
 
-scrpriv->glamor = ephyr_glamor_glx_screen_init(scrpriv->win);
+flags = profile_is_core ? GLAMOR_USE_CORE_PROFILE : 0;
 ephyr_glamor_set_window_size(scrpriv->glamor,
  scrpriv->win_width, scrpriv->win_height);
 
-if (!glamor_init(screen, 0)) {
+if (!glamor_init(screen, flags)) {
 FatalError("Failed to initialize glamor\n");
 return FALSE;
 }
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 5/8] glamor: add core profile support.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This adds a new flag to glamor_init to denote the context is
core profile.

This flag is used to disable quads for rendering.

Signed-off-by: Dave Airlie 
---
 glamor/glamor.c | 3 ++-
 glamor/glamor.h | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 7fa3a46..a2bd687 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -578,7 +578,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 
 glamor_setup_debug_output(screen);
 
-glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
+glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) && 
!(glamor_priv->flags & GLAMOR_USE_CORE_PROFILE);
+
 /* Driver-specific hack: Avoid using GL_QUADS on VC4, where
  * they'll be emulated more expensively than we can with our
  * cached IB.
diff --git a/glamor/glamor.h b/glamor/glamor.h
index a4e0655..8f34409 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -63,8 +63,9 @@ typedef enum glamor_pixmap_type {
 #define GLAMOR_EGL_EXTERNAL_BUFFER 3
 #define GLAMOR_USE_EGL_SCREEN  (1 << 0)
 #define GLAMOR_NO_DRI3 (1 << 1)
+#define GLAMOR_USE_CORE_PROFILE (1 << 2)
 #define GLAMOR_VALID_FLAGS  (GLAMOR_USE_EGL_SCREEN\
- | GLAMOR_NO_DRI3)
+ | GLAMOR_NO_DRI3 | GLAMOR_USE_CORE_PROFILE)
 
 /* @glamor_init: Initialize glamor internal data structure.
  *
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 8/8] xwayland: add support for use core profile for glamor.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This adds support to Xwayland to try and use OpenGL core
profile for glamor first.

Signed-off-by: Dave Airlie 
---
 hw/xwayland/xwayland-glamor.c | 22 +-
 hw/xwayland/xwayland.h|  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index c357217..9655079 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -270,6 +270,15 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
 {
 EGLint major, minor;
 const char *version;
+static const EGLint config_attribs_core[] = {
+EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+EGL_CONTEXT_MAJOR_VERSION_KHR,
+3,
+EGL_CONTEXT_MINOR_VERSION_KHR,
+3,
+EGL_NONE
+};
 
 if (xwl_screen->egl_display)
 return;
@@ -297,8 +306,15 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
 version = eglQueryString(xwl_screen->egl_display, EGL_VERSION);
 ErrorF("glamor: EGL version %s:\n", version);
 
+xwl_screen->glamor_uses_core_profile = FALSE;
 xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
-   NULL, EGL_NO_CONTEXT, NULL);
+   NULL, EGL_NO_CONTEXT, 
config_attribs_core);
+if (!xwl_screen->egl_context)
+xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
+   NULL, EGL_NO_CONTEXT, NULL);
+else
+xwl_screen->glamor_uses_core_profile = TRUE;
+
 if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
 ErrorF("Failed to create EGL context\n");
 return;
@@ -534,12 +550,16 @@ Bool
 xwl_glamor_init(struct xwl_screen *xwl_screen)
 {
 ScreenPtr screen = xwl_screen->screen;
+int flags = GLAMOR_USE_EGL_SCREEN;
 
 if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
 ErrorF("Disabling glamor and dri3, EGL setup failed\n");
 return FALSE;
 }
 
+if (xwl_screen->glamor_uses_core_profile)
+flags |= GLAMOR_USE_CORE_PROFILE;
+
 if (!glamor_init(xwl_screen->screen, GLAMOR_USE_EGL_SCREEN)) {
 ErrorF("Failed to initialize glamor\n");
 return FALSE;
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index a7d7119..52228a9 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -92,6 +92,7 @@ struct xwl_screen {
 void *egl_display, *egl_context;
 struct gbm_device *gbm;
 struct glamor_context *glamor_ctx;
+Bool glamor_uses_core_profile;
 };
 
 struct xwl_window {
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 1/8] glamor: use vbos in gradient/picture code.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts two client arrays users to using vbos,
this is necessary to move to using core profile later.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_gradient.c | 33 -
 glamor/glamor_picture.c  | 27 +++
 2 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 30c29f6..c50542a 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -647,12 +647,12 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
 PicturePtr dst_picture,
 GLfloat *xscale, GLfloat *yscale,
 int x_source, int y_source,
-float vertices[8],
-float tex_vertices[8],
 int tex_normalize)
 {
 glamor_pixmap_private *pixmap_priv;
 PixmapPtr pixmap = NULL;
+GLfloat *v;
+char *vbo_offset;
 
 pixmap = glamor_get_drawable_pixmap(dst_picture->pDrawable);
 pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -670,13 +670,15 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
*xscale, *yscale, x_source, y_source,
dst_picture->pDrawable->width, dst_picture->pDrawable->height);
 
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat), _offset);
+
 glamor_set_normalize_vcoords_tri_strip(*xscale, *yscale,
0, 0,
(INT16) (dst_picture->pDrawable->
 width),
(INT16) (dst_picture->pDrawable->
 height),
-   vertices);
+   v);
 
 if (tex_normalize) {
 glamor_set_normalize_tcoords_tri_stripe(*xscale, *yscale,
@@ -687,7 +689,7 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
 (INT16) (dst_picture->
  pDrawable->height +
  y_source),
-tex_vertices);
+[8]);
 }
 else {
 glamor_set_tcoords_tri_strip(x_source, y_source,
@@ -695,28 +697,29 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
  x_source,
  (INT16) (dst_picture->pDrawable->height) +
  y_source,
- tex_vertices);
+ [8]);
 }
 
 DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
"rightbottom: %f X %f, leftbottom : %f X %f\n",
-   vertices[0], vertices[1], vertices[2], vertices[3],
-   vertices[4], vertices[5], vertices[6], vertices[7]);
+   v[0], v[1], v[2], v[3],
+   v[4], v[5], v[6], v[7]);
 DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
"rightbottom: %f X %f, leftbottom : %f X %f\n",
-   tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
-   tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
+   v[8], v[9], v[10], v[11],
+   v[12], v[13], v[14], v[15]);
 
 glamor_make_current(glamor_priv);
 
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 0, vertices);
+  GL_FALSE, 0, vbo_offset);
 glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-  GL_FALSE, 0, tex_vertices);
+  GL_FALSE, 0, vbo_offset + 8 * sizeof(GLfloat));
 
 glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
+glamor_put_vbo_space(screen);
 return 1;
 }
 
@@ -812,13 +815,11 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
 PixmapPtr pixmap = NULL;
 GLint gradient_prog = 0;
 int error;
-float tex_vertices[8];
 int stops_count = 0;
 int count = 0;
 GLfloat *stop_colors = NULL;
 GLfloat *n_stops = NULL;
 GLfloat xscale, yscale;
-float vertices[8];
 float transform_mat[3][3];
 static const float identity_mat[3][3] = { {1.0, 0.0, 0.0},
 {0.0, 1.0, 0.0},
@@ -969,7 +970,7 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
 
 if (!_glamor_gradient_set_pixmap_destination
 (screen, glamor_priv, dst_picture, , , x_source, 
y_source,
- vertices, tex_vertices, 0))
+ 0))
 goto GRADIENT_FAIL;
 
 glamor_set_alu(screen, 

[PATCH 7/8] glamor: add core profile support to EGL glamor.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This breaks ABI unfortunately as we have to pass the core profile
info from the egl part of glamor to the glamor part of glamor.

Signed-off-by: Dave Airlie 
---
 glamor/glamor.h |  2 +-
 glamor/glamor_egl.c | 32 ++--
 hw/xfree86/drivers/modesetting/driver.c |  8 ++--
 hw/xfree86/drivers/modesetting/driver.h |  2 ++
 4 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 8f34409..0c64a1c 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -260,7 +260,7 @@ extern _X_EXPORT Bool glamor_back_pixmap_from_fd(PixmapPtr 
pixmap,
  * Should be called from DDX's preInit function.
  * Return TRUE if success, otherwise return FALSE.
  * */
-extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
+extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd, Bool 
*context_is_core);
 
 extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index ea0443d..1b2e65a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -727,7 +727,7 @@ glamor_egl_free_screen(ScrnInfoPtr scrn)
 }
 
 Bool
-glamor_egl_init(ScrnInfoPtr scrn, int fd)
+glamor_egl_init(ScrnInfoPtr scrn, int fd, Bool *context_is_core_profile)
 {
 struct glamor_egl_screen_private *glamor_egl;
 const char *version;
@@ -738,6 +738,15 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 #endif
 EGL_NONE
 };
+static const EGLint config_attribs_core[] = {
+EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+EGL_CONTEXT_MAJOR_VERSION_KHR,
+3,
+EGL_CONTEXT_MINOR_VERSION_KHR,
+3,
+EGL_NONE
+};
 
 glamor_identify(0);
 glamor_egl = calloc(sizeof(*glamor_egl), 1);
@@ -798,13 +807,24 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 KHR_surfaceless_opengl);
 #endif
 
+*context_is_core_profile = FALSE;
+#ifndef GLAMOR_GLES2
 glamor_egl->context = eglCreateContext(glamor_egl->display,
NULL, EGL_NO_CONTEXT,
-   config_attribs);
-if (glamor_egl->context == EGL_NO_CONTEXT) {
-xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
-goto error;
-}
+   config_attribs_core);
+#else
+glamor_egl->context = NULL;
+#endif
+if (!glamor_egl->context) {
+glamor_egl->context = eglCreateContext(glamor_egl->display,
+   NULL, EGL_NO_CONTEXT,
+   config_attribs);
+if (glamor_egl->context == EGL_NO_CONTEXT) {
+xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL 
context\n");
+goto error;
+}
+} else
+*context_is_core_profile = TRUE;
 
 if (!eglMakeCurrent(glamor_egl->display,
 EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
diff --git a/hw/xfree86/drivers/modesetting/driver.c 
b/hw/xfree86/drivers/modesetting/driver.c
index 8f60eae..c5d4d02 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -668,7 +668,7 @@ try_enable_glamor(ScrnInfoPtr pScrn)
 }
 
 if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
-if (glamor_egl_init(pScrn, ms->fd)) {
+if (glamor_egl_init(pScrn, ms->fd, >glamor_uses_core_profile)) {
 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
 ms->drmmode.glamor = TRUE;
 } else {
@@ -1173,7 +1173,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
 #ifdef GLAMOR
 if (ms->drmmode.glamor) {
-if (!glamor_init(pScreen, GLAMOR_USE_EGL_SCREEN)) {
+int flags = GLAMOR_USE_EGL_SCREEN;
+if (ms->glamor_uses_core_profile)
+flags |= GLAMOR_USE_CORE_PROFILE;
+
+if (!glamor_init(pScreen, flags)) {
 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to initialize glamor at ScreenInit() time.\n");
 return FALSE;
diff --git a/hw/xfree86/drivers/modesetting/driver.h 
b/hw/xfree86/drivers/modesetting/driver.h
index 5e1c5d9..047a765 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -118,6 +118,8 @@ typedef struct _modesettingRec {
 Bool dirty_enabled;
 
 uint32_t cursor_width, cursor_height;
+
+Bool glamor_uses_core_profile;
 } modesettingRec, *modesettingPtr;
 
 #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 4/8] glamor: Use GL_RED instead of GL_ALPHA if we have texture_swizzle

2016-01-18 Thread Dave Airlie
From: Keith Packard 

GL_RED is supported by core profiles while GL_ALPHA is not; use GL_RED
for one channel objects (depth 1 to 8), and then swizzle them into the
alpha channel when used as a mask.

[airlied: updated to master, add swizzle to composited glyphs and xv paths]

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 glamor/glamor.c  |  4 
 glamor/glamor_composite_glyphs.c |  5 +
 glamor/glamor_fbo.c  |  2 ++
 glamor/glamor_picture.c  | 22 ++
 glamor/glamor_priv.h |  2 ++
 glamor/glamor_render.c   |  9 +
 glamor/glamor_transfer.c |  2 +-
 glamor/glamor_utils.h|  4 +++-
 glamor/glamor_xv.c   | 12 
 9 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 8828ad3..7fa3a46 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -596,6 +596,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
 
+glamor_priv->one_channel_format = GL_ALPHA;
+if (epoxy_has_gl_extension("GL_ARB_texture_rg") && 
epoxy_has_gl_extension("GL_ARB_texture_swizzle"))
+glamor_priv->one_channel_format = GL_RED;
+
 glamor_set_debug_level(_debug_level);
 
 glamor_priv->saved_procs.create_screen_resources =
diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index fb31340..5f0fda5 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -247,6 +247,11 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr 
dst,
 glActiveTexture(GL_TEXTURE1);
 glBindTexture(GL_TEXTURE_2D, atlas_fbo->tex);
 
+if (glamor_priv->one_channel_format == GL_RED &&
+atlas->atlas->drawable.depth <= 8)
+{
+glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
+}
 for (;;) {
 if (!glamor_use_program_render(prog, op, src, dst))
 break;
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index b1b584d..3b16f82 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -75,6 +75,8 @@ cache_format(GLenum format)
 {
 switch (format) {
 case GL_ALPHA:
+case GL_LUMINANCE:
+case GL_RED:
 return 2;
 case GL_RGB:
 return 1;
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 352858f..b069ce5 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -41,19 +41,21 @@
  * Return 0 if find a matched texture type. Otherwise return -1.
  **/
 static int
-glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
+glamor_get_tex_format_type_from_pictformat_gl(ScreenPtr pScreen,
+  PictFormatShort format,
   GLenum *tex_format,
   GLenum *tex_type,
   int *no_alpha,
   int *revert,
   int *swap_rb, int is_upload)
 {
+glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
 *no_alpha = 0;
 *revert = REVERT_NONE;
 *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
 switch (format) {
 case PICT_a1:
-*tex_format = GL_ALPHA;
+*tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
 *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
 break;
@@ -111,7 +113,7 @@ 
glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
 *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 break;
 case PICT_a8:
-*tex_format = GL_ALPHA;
+*tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
 break;
 case PICT_x4r4g4b4:
@@ -137,13 +139,15 @@ 
glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
 #define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
 
 static int
-glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
+glamor_get_tex_format_type_from_pictformat_gles2(ScreenPtr pScreen,
+ PictFormatShort format,
  GLenum *tex_format,
  GLenum *tex_type,
  int *no_alpha,
  int *revert,
  int *swap_rb, int is_upload)
 {
+glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
 int need_swap_rb = 0;
 
 *no_alpha = 0;
@@ -264,13 +268,13 @@ 
glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
 break;
 
 case PICT_a1:
-   

Re: [PATCH 2/8] glamor/xv: add vbo support

2016-01-18 Thread Eric Anholt
Dave Airlie  writes:

> From: Dave Airlie 
>
> This converts the Xv code to using VBOs instead of
> client ptrs. This is necessary to move towards using
> the core profile later.
>
> Signed-off-by: Dave Airlie 
> ---
>  glamor/glamor_xv.c | 31 +--
>  1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
> index 85e6528..d9db574 100644
> --- a/glamor/glamor_xv.c
> +++ b/glamor/glamor_xv.c
> @@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
>  PixmapPtr pixmap = port_priv->pPixmap;
>  glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
>  glamor_pixmap_private *src_pixmap_priv[3];
> -float vertices[32], texcoords[8];
>  BoxPtr box = REGION_RECTS(_priv->clip);
>  int nBox = REGION_NUM_RECTS(_priv->clip);
>  int dst_x_off, dst_y_off;
> @@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
>  float bright, cont, gamma;
>  int ref = port_priv->transform_index;
>  GLint uloc, sampler_loc;
> +GLfloat *v;
> +char *vbo_offset;
>  
>  if (!glamor_priv->xv_prog)
>  glamor_init_xv_shader(screen);
> @@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
>  sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
>  glUniform1i(sampler_loc, 2);
>  
> -glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
> -  GL_FLOAT, GL_FALSE,
> -  2 * sizeof(float), texcoords);
> +glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
>  glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
>  
> -glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
> -  GL_FALSE, 2 * sizeof(float), vertices);
> -
> -glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
>  glEnable(GL_SCISSOR_TEST);
> +
> +v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, 
> _offset);
> +
>  for (i = 0; i < nBox; i++) {
>  float off_x = box[i].x1 - port_priv->drw_x;
>  float off_y = box[i].y1 - port_priv->drw_y;
> @@ -352,6 +350,7 @@ glamor_xv_render(glamor_port_private *port_priv)
>  float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
>  float srcx, srcy, srcw, srch;
>  int dstx, dsty, dstw, dsth;
> +GLfloat *ptr = v + (i * 16);
>  
>  dstx = box[i].x1 + dst_x_off;
>  dsty = box[i].y1 + dst_y_off;
> @@ -369,7 +368,7 @@ glamor_xv_render(glamor_port_private *port_priv)
>   dsty,
>   dstx + dstw,
>   dsty + dsth * 2,
> - vertices);
> + ptr);
>  
>  glamor_set_normalize_tcoords(src_pixmap_priv[0],
>   src_xscale[0],
> @@ -378,16 +377,28 @@ glamor_xv_render(glamor_port_private *port_priv)
>   srcy,
>   srcx + srcw,
>   srcy + srch * 2,
> - texcoords);
> + ptr + 8);
> +
> +
> +glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
> +  GL_FLOAT, GL_FALSE,
> +  2 * sizeof(float), vbo_offset);
> +
> +glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
> +  GL_FLOAT, GL_FALSE,
> +  2 * sizeof(float), vbo_offset + 8 * 
> sizeof(GLfloat));
>  
>  glScissor(dstx, dsty, dstw, dsth);
>  glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
> +vbo_offset += 16 * sizeof(GLfloat);

You could move the pointer setup out of the loop, s/0/i * 4/ in
glDrawArrays(), and then drop the vbo_offset math, I think.  With that
changed, the first two are:

Reviewed-by: Eric Anholt 


signature.asc
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

glamor core profile support

2016-01-18 Thread Dave Airlie
This series implements support for glamor in ephyr/EGL/Xwayland
to use GL core profile when it can.

This required 4 main changes:
a) stop using client ptrs everywhere, I found 3 places left,
gradient, picture and xv where we use these.
b) start using VAOs
c) use GL_RED instead of GL_ALPHA
d) stop using GL_QUADS.

These patches are also in my glamor-core-profile branch.

Dave.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 3/8] glamor: Use vertex arrays

2016-01-18 Thread Dave Airlie
From: Keith Packard 

Core contexts require the use of vertex arrays, so switch both glamor
and ephyr/glamor over.

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 glamor/glamor.c|  2 +
 glamor/glamor_priv.h   |  2 +
 glamor/glamor_vbo.c|  9 
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 86 +++---
 4 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 523f0cb..8828ad3 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -573,6 +573,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 epoxy_has_gl_extension("GL_NV_pack_subimage");
 glamor_priv->has_dual_blend =
 epoxy_has_gl_extension("GL_ARB_blend_func_extended");
+glamor_priv->has_vertex_array_object =
+epoxy_has_gl_extension("GL_ARB_vertex_array_object");
 
 glamor_setup_debug_output(screen);
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 6a84548..d26593d 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -209,6 +209,7 @@ typedef struct glamor_screen_private {
 Bool has_rw_pbo;
 Bool use_quads;
 Bool has_dual_blend;
+Bool has_vertex_array_object;
 int max_fbo_size;
 
 struct xorg_list
@@ -255,6 +256,7 @@ typedef struct glamor_screen_private {
 char*glyph_defines;
 
 /** Vertex buffer for all GPU rendering. */
+GLuint vao;
 GLuint vbo;
 /** Next offset within the VBO that glamor_get_vbo_space() will use. */
 int vbo_offset;
diff --git a/glamor/glamor_vbo.c b/glamor/glamor_vbo.c
index ba60ce6..b8db009 100644
--- a/glamor/glamor_vbo.c
+++ b/glamor/glamor_vbo.c
@@ -174,6 +174,11 @@ glamor_init_vbo(ScreenPtr screen)
 glamor_make_current(glamor_priv);
 
 glGenBuffers(1, _priv->vbo);
+if (glamor_priv->has_vertex_array_object) {
+glGenVertexArrays(1, _priv->vao);
+glBindVertexArray(glamor_priv->vao);
+} else
+glamor_priv->vao = 0;
 }
 
 void
@@ -183,6 +188,10 @@ glamor_fini_vbo(ScreenPtr screen)
 
 glamor_make_current(glamor_priv);
 
+if (glamor_priv->vao != 0) {
+glDeleteVertexArrays(1, _priv->vao);
+glamor_priv->vao = 0;
+}
 if (!glamor_priv->has_map_buffer_range)
 free(glamor_priv->vb);
 }
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 582e3af..30c5245 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -71,6 +71,8 @@ struct ephyr_glamor {
 
 /* Size of the window that we're rendering to. */
 unsigned width, height;
+
+GLuint vao, vbo;
 };
 
 static GLint
@@ -189,47 +191,53 @@ ephyr_glamor_set_texture(struct ephyr_glamor *glamor, 
uint32_t tex)
 glamor->tex = tex;
 }
 
+static void
+ephyr_glamor_set_vertices(struct ephyr_glamor *glamor)
+{
+glVertexAttribPointer(glamor->texture_shader_position_loc,
+  2, GL_FLOAT, FALSE, 0, (void *) 0);
+glVertexAttribPointer(glamor->texture_shader_texcoord_loc,
+  2, GL_FLOAT, FALSE, 0, (void *) (sizeof (float) * 
8));
+
+glEnableVertexAttribArray(glamor->texture_shader_position_loc);
+glEnableVertexAttribArray(glamor->texture_shader_texcoord_loc);
+}
+
+static void
+ephyr_glamor_clear_vertices(struct ephyr_glamor *glamor)
+{
+glDisableVertexAttribArray(glamor->texture_shader_position_loc);
+glDisableVertexAttribArray(glamor->texture_shader_texcoord_loc);
+}
+
 void
 ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
   struct pixman_region16 *damage)
 {
-/* Redraw the whole screen, since glXSwapBuffers leaves the back
- * buffer undefined.
- */
-static const float position[] = {
--1, -1,
- 1, -1,
- 1,  1,
--1,  1,
-};
-static const float texcoords[] = {
-0, 1,
-1, 1,
-1, 0,
-0, 0,
-};
+GLint old_vao;
 
 glXMakeCurrent(dpy, glamor->glx_win, glamor->ctx);
 
+if (glamor->vao) {
+glGetIntegerv(GL_VERTEX_ARRAY_BINDING, _vao);
+glBindVertexArray(glamor->vao);
+} else
+ephyr_glamor_set_vertices(glamor);
+
 glBindFramebuffer(GL_FRAMEBUFFER, 0);
 glUseProgram(glamor->texture_shader);
 glViewport(0, 0, glamor->width, glamor->height);
 if (!ephyr_glamor_gles2)
 glDisable(GL_COLOR_LOGIC_OP);
 
-glVertexAttribPointer(glamor->texture_shader_position_loc,
-  2, GL_FLOAT, FALSE, 0, position);
-glVertexAttribPointer(glamor->texture_shader_texcoord_loc,
-  2, GL_FLOAT, FALSE, 0, texcoords);
-glEnableVertexAttribArray(glamor->texture_shader_position_loc);
-glEnableVertexAttribArray(glamor->texture_shader_texcoord_loc);
-
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, glamor->tex);

Re: [PATCH 7/8] glamor: add core profile support to EGL glamor.

2016-01-18 Thread Michel Dänzer
On 19.01.2016 09:56, Dave Airlie wrote:
> From: Dave Airlie 
> 
> This breaks ABI unfortunately as we have to pass the core profile
> info from the egl part of glamor to the glamor part of glamor.

That's indeed a bit ugly. Can't the glamor code determine itself whether
or not it's a core profile context?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glamor: don't do copy if we have 0 boxes to copy.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This happens if you run twm + mplayer + xclock and drag
the clock over the mplayer. If we don't catch it, we cause
an illegal draw elements command to be passed to GL.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_copy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 028acf2..1adfba0 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -640,6 +640,9 @@ glamor_copy(DrawablePtr src,
 Pixel bitplane,
 void *closure)
 {
+if (nbox == 0)
+   return;
+
 if (glamor_copy_gl(src, dst, gc, box, nbox, dx, dy, reverse, upsidedown, 
bitplane, closure))
 return;
 glamor_copy_bail(src, dst, gc, box, nbox, dx, dy, reverse, upsidedown, 
bitplane, closure);
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

New composers for local languages in Togo

2016-01-18 Thread Mats Blakstad
I've opened this ticket:
https://bugs.freedesktop.org/show_bug.cgi?id=93660

I need some feedback to be able to upload a final verion!

How should the composer be formatted. Now each composer is added like this:

* : "Ɛ̃́"   LATIN CAPITAL
LETTER EPSILON WITH TILDE AND ACUTE*

But it looks like the other composer keys have a hash tag and the unicode
after the quotation mark, like this:

* : "Ɛ̃́"   U+0190 # LATIN
CAPITAL LETTER EPSILON WITH TILDE AND ACUTE*

However, I need several unicodes to represent the symbols, like:

*U+0190U+0303U+0301*

How should I add this? Can I do like this:

* : "Ɛ̃́"   U+0190U+0303U+0301
# LATIN CAPITAL LETTER EPSILON WITH TILDE AND ACUTE*

Thanks in advance.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 2/8] glamor/xv: add vbo support

2016-01-18 Thread Dave Airlie
On 19 January 2016 at 11:15, Eric Anholt  wrote:
> Dave Airlie  writes:
>
>> From: Dave Airlie 
>>
>> This converts the Xv code to using VBOs instead of
>> client ptrs. This is necessary to move towards using
>> the core profile later.
>>
>> Signed-off-by: Dave Airlie 
>> ---
>>  glamor/glamor_xv.c | 31 +--
>>  1 file changed, 21 insertions(+), 10 deletions(-)
>>
>> diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
>> index 85e6528..d9db574 100644
>> --- a/glamor/glamor_xv.c
>> +++ b/glamor/glamor_xv.c
>> @@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
>>  PixmapPtr pixmap = port_priv->pPixmap;
>>  glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
>>  glamor_pixmap_private *src_pixmap_priv[3];
>> -float vertices[32], texcoords[8];
>>  BoxPtr box = REGION_RECTS(_priv->clip);
>>  int nBox = REGION_NUM_RECTS(_priv->clip);
>>  int dst_x_off, dst_y_off;
>> @@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
>>  float bright, cont, gamma;
>>  int ref = port_priv->transform_index;
>>  GLint uloc, sampler_loc;
>> +GLfloat *v;
>> +char *vbo_offset;
>>
>>  if (!glamor_priv->xv_prog)
>>  glamor_init_xv_shader(screen);
>> @@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
>>  sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
>>  glUniform1i(sampler_loc, 2);
>>
>> -glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
>> -  GL_FLOAT, GL_FALSE,
>> -  2 * sizeof(float), texcoords);
>> +glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
>>  glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
>>
>> -glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
>> -  GL_FALSE, 2 * sizeof(float), vertices);
>> -
>> -glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
>>  glEnable(GL_SCISSOR_TEST);
>> +
>> +v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, 
>> _offset);
>> +
>>  for (i = 0; i < nBox; i++) {
>>  float off_x = box[i].x1 - port_priv->drw_x;
>>  float off_y = box[i].y1 - port_priv->drw_y;
>> @@ -352,6 +350,7 @@ glamor_xv_render(glamor_port_private *port_priv)
>>  float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
>>  float srcx, srcy, srcw, srch;
>>  int dstx, dsty, dstw, dsth;
>> +GLfloat *ptr = v + (i * 16);
>>
>>  dstx = box[i].x1 + dst_x_off;
>>  dsty = box[i].y1 + dst_y_off;
>> @@ -369,7 +368,7 @@ glamor_xv_render(glamor_port_private *port_priv)
>>   dsty,
>>   dstx + dstw,
>>   dsty + dsth * 2,
>> - vertices);
>> + ptr);
>>
>>  glamor_set_normalize_tcoords(src_pixmap_priv[0],
>>   src_xscale[0],
>> @@ -378,16 +377,28 @@ glamor_xv_render(glamor_port_private *port_priv)
>>   srcy,
>>   srcx + srcw,
>>   srcy + srch * 2,
>> - texcoords);
>> + ptr + 8);
>> +
>> +
>> +glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
>> +  GL_FLOAT, GL_FALSE,
>> +  2 * sizeof(float), vbo_offset);
>> +
>> +glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
>> +  GL_FLOAT, GL_FALSE,
>> +  2 * sizeof(float), vbo_offset + 8 * 
>> sizeof(GLfloat));
>>
>>  glScissor(dstx, dsty, dstw, dsth);
>>  glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
>> +vbo_offset += 16 * sizeof(GLfloat);
>
> You could move the pointer setup out of the loop, s/0/i * 4/ in
> glDrawArrays(), and then drop the vbo_offset math, I think.  With that
> changed, the first two are:

unfortunately that doesn't work all that easily, as we aren't
interleaving things properly.

I've sent a v2 patch. Also since in some paths we probably can't leave the VBO
mapped across draws, I've fixed things up to do it in two passes, one
to set the VBO
up and the other to do the draws.

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glamor/xv: add vbo support (v2)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

v2: put all boxes into single vbo, use draw arrays
to offset things. (Eric)
Signed-off-by: Dave Airlie 
---
 glamor/glamor_xv.c | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 85e6528..3103992 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
 PixmapPtr pixmap = port_priv->pPixmap;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_pixmap_private *src_pixmap_priv[3];
-float vertices[32], texcoords[8];
 BoxPtr box = REGION_RECTS(_priv->clip);
 int nBox = REGION_NUM_RECTS(_priv->clip);
 int dst_x_off, dst_y_off;
@@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float bright, cont, gamma;
 int ref = port_priv->transform_index;
 GLint uloc, sampler_loc;
+GLfloat *v;
+char *vbo_offset;
 
 if (!glamor_priv->xv_prog)
 glamor_init_xv_shader(screen);
@@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
 sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
 glUniform1i(sampler_loc, 2);
 
-glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-  GL_FLOAT, GL_FALSE,
-  2 * sizeof(float), texcoords);
+glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 2 * sizeof(float), vertices);
-
-glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnable(GL_SCISSOR_TEST);
+
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, _offset);
+
 for (i = 0; i < nBox; i++) {
 float off_x = box[i].x1 - port_priv->drw_x;
 float off_y = box[i].y1 - port_priv->drw_y;
@@ -352,6 +350,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
 float srcx, srcy, srcw, srch;
 int dstx, dsty, dstw, dsth;
+GLfloat *vptr = v + (i * 8);
+GLfloat *tptr = vptr + (8 * nBox);
 
 dstx = box[i].x1 + dst_x_off;
 dsty = box[i].y1 + dst_y_off;
@@ -369,7 +369,7 @@ glamor_xv_render(glamor_port_private *port_priv)
  dsty,
  dstx + dstw,
  dsty + dsth * 2,
- vertices);
+ vptr);
 
 glamor_set_normalize_tcoords(src_pixmap_priv[0],
  src_xscale[0],
@@ -378,10 +378,29 @@ glamor_xv_render(glamor_port_private *port_priv)
  srcy,
  srcx + srcw,
  srcy + srch * 2,
- texcoords);
+ tptr);
+}
+glamor_put_vbo_space(screen);
+
+glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset);
+
+glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset + (nBox * 8 * 
sizeof(GLfloat)));
+
+
+for (i = 0; i < nBox; i++) {
+int dstx, dsty, dstw, dsth;
+
+dstx = box[i].x1 + dst_x_off;
+dsty = box[i].y1 + dst_y_off;
+dstw = box[i].x2 - box[i].x1;
+dsth = box[i].y2 - box[i].y1;
 
 glScissor(dstx, dsty, dstw, dsth);
-glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
+glDrawArrays(GL_TRIANGLE_FAN, i * 4, 3);
 }
 glDisable(GL_SCISSOR_TEST);
 
-- 
2.5.0

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 5/8] glamor: add core profile support.

2016-01-18 Thread Michel Dänzer
On 19.01.2016 09:56, Dave Airlie wrote:
> From: Dave Airlie 
> 
> This adds a new flag to glamor_init to denote the context is
> core profile.
> 
> This flag is used to disable quads for rendering.
> 
> Signed-off-by: Dave Airlie 
> ---
>  glamor/glamor.c | 3 ++-
>  glamor/glamor.h | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/glamor/glamor.c b/glamor/glamor.c
> index 7fa3a46..a2bd687 100644
> --- a/glamor/glamor.c
> +++ b/glamor/glamor.c
> @@ -578,7 +578,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
>  
>  glamor_setup_debug_output(screen);
>  
> -glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
> +glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) 
> && !(glamor_priv->flags & GLAMOR_USE_CORE_PROFILE);

This line is getting a bit long.


> diff --git a/glamor/glamor.h b/glamor/glamor.h
> index a4e0655..8f34409 100644
> --- a/glamor/glamor.h
> +++ b/glamor/glamor.h
> @@ -63,8 +63,9 @@ typedef enum glamor_pixmap_type {
>  #define GLAMOR_EGL_EXTERNAL_BUFFER 3
>  #define GLAMOR_USE_EGL_SCREEN(1 << 0)
>  #define GLAMOR_NO_DRI3   (1 << 1)
> +#define GLAMOR_USE_CORE_PROFILE (1 << 2)

Indentation (using spaces) doesn't match the previous lines (using tabs).


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] glamor/xv: add vbo support (v2.1)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

v2: put all boxes into single vbo, use draw arrays
to offset things. (Eric)
v2.1: brown paper bag with releasing vbo.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_xv.c | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 85e6528..6e1a588 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
 PixmapPtr pixmap = port_priv->pPixmap;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_pixmap_private *src_pixmap_priv[3];
-float vertices[32], texcoords[8];
 BoxPtr box = REGION_RECTS(_priv->clip);
 int nBox = REGION_NUM_RECTS(_priv->clip);
 int dst_x_off, dst_y_off;
@@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float bright, cont, gamma;
 int ref = port_priv->transform_index;
 GLint uloc, sampler_loc;
+GLfloat *v;
+char *vbo_offset;
 
 if (!glamor_priv->xv_prog)
 glamor_init_xv_shader(screen);
@@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
 sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
 glUniform1i(sampler_loc, 2);
 
-glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-  GL_FLOAT, GL_FALSE,
-  2 * sizeof(float), texcoords);
+glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 2 * sizeof(float), vertices);
-
-glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnable(GL_SCISSOR_TEST);
+
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, _offset);
+
 for (i = 0; i < nBox; i++) {
 float off_x = box[i].x1 - port_priv->drw_x;
 float off_y = box[i].y1 - port_priv->drw_y;
@@ -352,6 +350,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
 float srcx, srcy, srcw, srch;
 int dstx, dsty, dstw, dsth;
+GLfloat *vptr = v + (i * 8);
+GLfloat *tptr = vptr + (8 * nBox);
 
 dstx = box[i].x1 + dst_x_off;
 dsty = box[i].y1 + dst_y_off;
@@ -369,7 +369,7 @@ glamor_xv_render(glamor_port_private *port_priv)
  dsty,
  dstx + dstw,
  dsty + dsth * 2,
- vertices);
+ vptr);
 
 glamor_set_normalize_tcoords(src_pixmap_priv[0],
  src_xscale[0],
@@ -378,10 +378,29 @@ glamor_xv_render(glamor_port_private *port_priv)
  srcy,
  srcx + srcw,
  srcy + srch * 2,
- texcoords);
+ tptr);
+}
+
+glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset);
+
+glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset + (nBox * 8 * 
sizeof(GLfloat)));
+
+glamor_put_vbo_space(screen);
+
+for (i = 0; i < nBox; i++) {
+int dstx, dsty, dstw, dsth;
+
+dstx = box[i].x1 + dst_x_off;
+dsty = box[i].y1 + dst_y_off;
+dstw = box[i].x2 - box[i].x1;
+dsth = box[i].y2 - box[i].y1;
 
 glScissor(dstx, dsty, dstw, dsth);
-glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
+glDrawArrays(GL_TRIANGLE_FAN, i * 4, 3);
 }
 glDisable(GL_SCISSOR_TEST);
 
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 7/8] glamor: add core profile support to EGL glamor.

2016-01-18 Thread Dave Airlie
On 19 January 2016 at 12:09, Michel Dänzer  wrote:
> On 19.01.2016 09:56, Dave Airlie wrote:
>> From: Dave Airlie 
>>
>> This breaks ABI unfortunately as we have to pass the core profile
>> info from the egl part of glamor to the glamor part of glamor.
>
> That's indeed a bit ugly. Can't the glamor code determine itself whether
> or not it's a core profile context?

I couldn't find a query in GL for that, and if I have to resort to GLX/EGL
(which I can't find a obvious query in either) than I still need to
change the ABI.

suggestions welcome.

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 7/8] glamor: add core profile support to EGL glamor.

2016-01-18 Thread Michel Dänzer
On 19.01.2016 11:20, Dave Airlie wrote:
> On 19 January 2016 at 12:09, Michel Dänzer  wrote:
>> On 19.01.2016 09:56, Dave Airlie wrote:
>>> From: Dave Airlie 
>>>
>>> This breaks ABI unfortunately as we have to pass the core profile
>>> info from the egl part of glamor to the glamor part of glamor.
>>
>> That's indeed a bit ugly. Can't the glamor code determine itself whether
>> or not it's a core profile context?
> 
> I couldn't find a query in GL for that, and if I have to resort to GLX/EGL
> (which I can't find a obvious query in either) than I still need to
> change the ABI.
> 
> suggestions welcome.

glGetIntegerv(GL_CONTEXT_PROFILE_MASK, );

and check mask for GL_CONTEXT_CORE_PROFILE_BIT?


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: glamor core profile support

2016-01-18 Thread Dave Airlie
On 19 January 2016 at 12:39, Dave Airlie  wrote:
> On 19 January 2016 at 10:56, Dave Airlie  wrote:
>> This series implements support for glamor in ephyr/EGL/Xwayland
>> to use GL core profile when it can.
>>
>> This required 4 main changes:
>> a) stop using client ptrs everywhere, I found 3 places left,
>> gradient, picture and xv where we use these.
>> b) start using VAOs
>> c) use GL_RED instead of GL_ALPHA
>> d) stop using GL_QUADS.
>>
>> These patches are also in my glamor-core-profile branch.
>
> I've updated the branch with some fixes for things people pointed out so far.
>
> I've also made it use GL 3.1 instead of 3.3 at Ilia's request. I don't
> think this
> should be an issue until we need geom shaders :-)

Updated branch again to avoid the ABI break, we test for GL3.1 and
no ARB_compatibility extension to detect if the context is core now.

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH 7/8] glamor: add core profile support to EGL glamor.

2016-01-18 Thread Dave Airlie
On 19 January 2016 at 12:38, Michel Dänzer  wrote:
> On 19.01.2016 11:20, Dave Airlie wrote:
>> On 19 January 2016 at 12:09, Michel Dänzer  wrote:
>>> On 19.01.2016 09:56, Dave Airlie wrote:
 From: Dave Airlie 

 This breaks ABI unfortunately as we have to pass the core profile
 info from the egl part of glamor to the glamor part of glamor.
>>>
>>> That's indeed a bit ugly. Can't the glamor code determine itself whether
>>> or not it's a core profile context?
>>
>> I couldn't find a query in GL for that, and if I have to resort to GLX/EGL
>> (which I can't find a obvious query in either) than I still need to
>> change the ABI.
>>
>> suggestions welcome.
>
> glGetIntegerv(GL_CONTEXT_PROFILE_MASK, );
>
> and check mask for GL_CONTEXT_CORE_PROFILE_BIT?
>

That is only available in OpenGL 3.2.

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: glamor core profile support

2016-01-18 Thread Dave Airlie
On 19 January 2016 at 10:56, Dave Airlie  wrote:
> This series implements support for glamor in ephyr/EGL/Xwayland
> to use GL core profile when it can.
>
> This required 4 main changes:
> a) stop using client ptrs everywhere, I found 3 places left,
> gradient, picture and xv where we use these.
> b) start using VAOs
> c) use GL_RED instead of GL_ALPHA
> d) stop using GL_QUADS.
>
> These patches are also in my glamor-core-profile branch.

I've updated the branch with some fixes for things people pointed out so far.

I've also made it use GL 3.1 instead of 3.3 at Ilia's request. I don't
think this
should be an issue until we need geom shaders :-)

Dave.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 4/8] glamor: Use GL_RED instead of GL_ALPHA if we have texture_swizzle (v2)

2016-01-18 Thread Dave Airlie
From: Keith Packard 

GL_RED is supported by core profiles while GL_ALPHA is not; use GL_RED
for one channel objects (depth 1 to 8), and then swizzle them into the
alpha channel when used as a mask.

[airlied: updated to master, add swizzle to composited glyphs and xv paths]

v2: consolidate setting swizzle into the texture creation code, it should
work fine there. Handle swizzle when setting color as well.

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 glamor/glamor.c   |  4 
 glamor/glamor_fbo.c   |  4 
 glamor/glamor_picture.c   | 22 ++
 glamor/glamor_priv.h  |  2 ++
 glamor/glamor_transfer.c  |  2 +-
 glamor/glamor_transform.c |  6 ++
 glamor/glamor_utils.h |  4 +++-
 7 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 8828ad3..7fa3a46 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -596,6 +596,10 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
 
+glamor_priv->one_channel_format = GL_ALPHA;
+if (epoxy_has_gl_extension("GL_ARB_texture_rg") && 
epoxy_has_gl_extension("GL_ARB_texture_swizzle"))
+glamor_priv->one_channel_format = GL_RED;
+
 glamor_set_debug_level(_debug_level);
 
 glamor_priv->saved_procs.create_screen_resources =
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index b1b584d..1093ba9 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -75,6 +75,8 @@ cache_format(GLenum format)
 {
 switch (format) {
 case GL_ALPHA:
+case GL_LUMINANCE:
+case GL_RED:
 return 2;
 case GL_RGB:
 return 1;
@@ -338,6 +340,8 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
 glBindTexture(GL_TEXTURE_2D, tex);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+if (format == glamor_priv->one_channel_format && format == GL_RED)
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
 glamor_priv->suppress_gl_out_of_memory_logging = true;
 glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
  format, GL_UNSIGNED_BYTE, NULL);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 352858f..b069ce5 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -41,19 +41,21 @@
  * Return 0 if find a matched texture type. Otherwise return -1.
  **/
 static int
-glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
+glamor_get_tex_format_type_from_pictformat_gl(ScreenPtr pScreen,
+  PictFormatShort format,
   GLenum *tex_format,
   GLenum *tex_type,
   int *no_alpha,
   int *revert,
   int *swap_rb, int is_upload)
 {
+glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
 *no_alpha = 0;
 *revert = REVERT_NONE;
 *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
 switch (format) {
 case PICT_a1:
-*tex_format = GL_ALPHA;
+*tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
 *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
 break;
@@ -111,7 +113,7 @@ 
glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
 *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 break;
 case PICT_a8:
-*tex_format = GL_ALPHA;
+*tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
 break;
 case PICT_x4r4g4b4:
@@ -137,13 +139,15 @@ 
glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
 #define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
 
 static int
-glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
+glamor_get_tex_format_type_from_pictformat_gles2(ScreenPtr pScreen,
+ PictFormatShort format,
  GLenum *tex_format,
  GLenum *tex_type,
  int *no_alpha,
  int *revert,
  int *swap_rb, int is_upload)
 {
+glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
 int need_swap_rb = 0;
 
 *no_alpha = 0;
@@ -264,13 +268,13 @@ 
glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
 break;
 
 case PICT_a1:
-*tex_format = GL_ALPHA;
+*tex_format = glamor_priv->one_channel_format;

[PATCH 5/8] glamor: add core profile support. (v2)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

Glamor works out from the profile if it is
core.

This flag is used to disable quads for rendering.

v1.1: split long line + make whitespace conform (Michel)
v1.2: add GL 3.1 version defines
v2: move to having glamor work out the profile.

Signed-off-by: Dave Airlie 
---
 glamor/glamor.c  | 8 +++-
 glamor/glamor.h  | 4 
 glamor/glamor_priv.h | 1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 7fa3a46..e751a09 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -576,9 +576,15 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 glamor_priv->has_vertex_array_object =
 epoxy_has_gl_extension("GL_ARB_vertex_array_object");
 
+/* assume a core profile if we are GL 3.1 and don't have ARB_compatibility 
*/
+glamor_priv->is_core_profile =
+gl_version >= 31 && !epoxy_has_gl_extension("GL_ARB_compatibility");
+
 glamor_setup_debug_output(screen);
 
-glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
+glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) &&
+ !glamor_priv->is_core_profile;
+
 /* Driver-specific hack: Avoid using GL_QUADS on VC4, where
  * they'll be emulated more expensively than we can with our
  * cached IB.
diff --git a/glamor/glamor.h b/glamor/glamor.h
index a4e0655..a73e9ef 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -66,6 +66,10 @@ typedef enum glamor_pixmap_type {
 #define GLAMOR_VALID_FLAGS  (GLAMOR_USE_EGL_SCREEN\
  | GLAMOR_NO_DRI3)
 
+/* until we need geometry shaders GL3.1 should suffice. */
+#define GLAMOR_GL_CORE_VER_MAJOR 3
+#define GLAMOR_GL_CORE_VER_MINOR 1
+
 /* @glamor_init: Initialize glamor internal data structure.
  *
  * @screen: Current screen pointer.
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index d58c40f..a90c3ac 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -210,6 +210,7 @@ typedef struct glamor_screen_private {
 Bool use_quads;
 Bool has_dual_blend;
 Bool has_vertex_array_object;
+Bool is_core_profile;
 int max_fbo_size;
 
 GLuint one_channel_format;
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 3/8] glamor: Use vertex arrays

2016-01-18 Thread Dave Airlie
From: Keith Packard 

Core contexts require the use of vertex arrays, so switch both glamor
and ephyr/glamor over.

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 glamor/glamor.c|  2 +
 glamor/glamor_priv.h   |  2 +
 glamor/glamor_vbo.c|  9 
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 86 +++---
 4 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 523f0cb..8828ad3 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -573,6 +573,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 epoxy_has_gl_extension("GL_NV_pack_subimage");
 glamor_priv->has_dual_blend =
 epoxy_has_gl_extension("GL_ARB_blend_func_extended");
+glamor_priv->has_vertex_array_object =
+epoxy_has_gl_extension("GL_ARB_vertex_array_object");
 
 glamor_setup_debug_output(screen);
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 6a84548..d26593d 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -209,6 +209,7 @@ typedef struct glamor_screen_private {
 Bool has_rw_pbo;
 Bool use_quads;
 Bool has_dual_blend;
+Bool has_vertex_array_object;
 int max_fbo_size;
 
 struct xorg_list
@@ -255,6 +256,7 @@ typedef struct glamor_screen_private {
 char*glyph_defines;
 
 /** Vertex buffer for all GPU rendering. */
+GLuint vao;
 GLuint vbo;
 /** Next offset within the VBO that glamor_get_vbo_space() will use. */
 int vbo_offset;
diff --git a/glamor/glamor_vbo.c b/glamor/glamor_vbo.c
index ba60ce6..b8db009 100644
--- a/glamor/glamor_vbo.c
+++ b/glamor/glamor_vbo.c
@@ -174,6 +174,11 @@ glamor_init_vbo(ScreenPtr screen)
 glamor_make_current(glamor_priv);
 
 glGenBuffers(1, _priv->vbo);
+if (glamor_priv->has_vertex_array_object) {
+glGenVertexArrays(1, _priv->vao);
+glBindVertexArray(glamor_priv->vao);
+} else
+glamor_priv->vao = 0;
 }
 
 void
@@ -183,6 +188,10 @@ glamor_fini_vbo(ScreenPtr screen)
 
 glamor_make_current(glamor_priv);
 
+if (glamor_priv->vao != 0) {
+glDeleteVertexArrays(1, _priv->vao);
+glamor_priv->vao = 0;
+}
 if (!glamor_priv->has_map_buffer_range)
 free(glamor_priv->vb);
 }
diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 582e3af..30c5245 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -71,6 +71,8 @@ struct ephyr_glamor {
 
 /* Size of the window that we're rendering to. */
 unsigned width, height;
+
+GLuint vao, vbo;
 };
 
 static GLint
@@ -189,47 +191,53 @@ ephyr_glamor_set_texture(struct ephyr_glamor *glamor, 
uint32_t tex)
 glamor->tex = tex;
 }
 
+static void
+ephyr_glamor_set_vertices(struct ephyr_glamor *glamor)
+{
+glVertexAttribPointer(glamor->texture_shader_position_loc,
+  2, GL_FLOAT, FALSE, 0, (void *) 0);
+glVertexAttribPointer(glamor->texture_shader_texcoord_loc,
+  2, GL_FLOAT, FALSE, 0, (void *) (sizeof (float) * 
8));
+
+glEnableVertexAttribArray(glamor->texture_shader_position_loc);
+glEnableVertexAttribArray(glamor->texture_shader_texcoord_loc);
+}
+
+static void
+ephyr_glamor_clear_vertices(struct ephyr_glamor *glamor)
+{
+glDisableVertexAttribArray(glamor->texture_shader_position_loc);
+glDisableVertexAttribArray(glamor->texture_shader_texcoord_loc);
+}
+
 void
 ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
   struct pixman_region16 *damage)
 {
-/* Redraw the whole screen, since glXSwapBuffers leaves the back
- * buffer undefined.
- */
-static const float position[] = {
--1, -1,
- 1, -1,
- 1,  1,
--1,  1,
-};
-static const float texcoords[] = {
-0, 1,
-1, 1,
-1, 0,
-0, 0,
-};
+GLint old_vao;
 
 glXMakeCurrent(dpy, glamor->glx_win, glamor->ctx);
 
+if (glamor->vao) {
+glGetIntegerv(GL_VERTEX_ARRAY_BINDING, _vao);
+glBindVertexArray(glamor->vao);
+} else
+ephyr_glamor_set_vertices(glamor);
+
 glBindFramebuffer(GL_FRAMEBUFFER, 0);
 glUseProgram(glamor->texture_shader);
 glViewport(0, 0, glamor->width, glamor->height);
 if (!ephyr_glamor_gles2)
 glDisable(GL_COLOR_LOGIC_OP);
 
-glVertexAttribPointer(glamor->texture_shader_position_loc,
-  2, GL_FLOAT, FALSE, 0, position);
-glVertexAttribPointer(glamor->texture_shader_texcoord_loc,
-  2, GL_FLOAT, FALSE, 0, texcoords);
-glEnableVertexAttribArray(glamor->texture_shader_position_loc);
-glEnableVertexAttribArray(glamor->texture_shader_texcoord_loc);
-
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, glamor->tex);

[PATCH 8/8] xwayland: add support for use core profile for glamor. (v2)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This adds support to Xwayland to try and use OpenGL core
profile for glamor first.

v1.1: use version defines.
v2: let glamor work out core profile itself.

Signed-off-by: Dave Airlie 
---
 hw/xwayland/xwayland-glamor.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index c357217..7f6fb9a 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -270,6 +270,15 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
 {
 EGLint major, minor;
 const char *version;
+static const EGLint config_attribs_core[] = {
+EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+EGL_CONTEXT_MAJOR_VERSION_KHR,
+GLAMOR_GL_CORE_VER_MAJOR,
+EGL_CONTEXT_MINOR_VERSION_KHR,
+GLAMOR_GL_CORE_VER_MINOR,
+EGL_NONE
+};
 
 if (xwl_screen->egl_display)
 return;
@@ -298,7 +307,11 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
 ErrorF("glamor: EGL version %s:\n", version);
 
 xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
-   NULL, EGL_NO_CONTEXT, NULL);
+   NULL, EGL_NO_CONTEXT, 
config_attribs_core);
+if (!xwl_screen->egl_context)
+xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
+   NULL, EGL_NO_CONTEXT, NULL);
+
 if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
 ErrorF("Failed to create EGL context\n");
 return;
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 2/8] glamor/xv: add vbo support (v2.1)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts the Xv code to using VBOs instead of
client ptrs. This is necessary to move towards using
the core profile later.

v2: put all boxes into single vbo, use draw arrays
to offset things. (Eric)
v2.1: brown paper bag with releasing vbo.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_xv.c | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 85e6528..6e1a588 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -245,7 +245,6 @@ glamor_xv_render(glamor_port_private *port_priv)
 PixmapPtr pixmap = port_priv->pPixmap;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_pixmap_private *src_pixmap_priv[3];
-float vertices[32], texcoords[8];
 BoxPtr box = REGION_RECTS(_priv->clip);
 int nBox = REGION_NUM_RECTS(_priv->clip);
 int dst_x_off, dst_y_off;
@@ -260,6 +259,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float bright, cont, gamma;
 int ref = port_priv->transform_index;
 GLint uloc, sampler_loc;
+GLfloat *v;
+char *vbo_offset;
 
 if (!glamor_priv->xv_prog)
 glamor_init_xv_shader(screen);
@@ -335,16 +336,13 @@ glamor_xv_render(glamor_port_private *port_priv)
 sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
 glUniform1i(sampler_loc, 2);
 
-glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
-  GL_FLOAT, GL_FALSE,
-  2 * sizeof(float), texcoords);
+glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 2 * sizeof(float), vertices);
-
-glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnable(GL_SCISSOR_TEST);
+
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, _offset);
+
 for (i = 0; i < nBox; i++) {
 float off_x = box[i].x1 - port_priv->drw_x;
 float off_y = box[i].y1 - port_priv->drw_y;
@@ -352,6 +350,8 @@ glamor_xv_render(glamor_port_private *port_priv)
 float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h;
 float srcx, srcy, srcw, srch;
 int dstx, dsty, dstw, dsth;
+GLfloat *vptr = v + (i * 8);
+GLfloat *tptr = vptr + (8 * nBox);
 
 dstx = box[i].x1 + dst_x_off;
 dsty = box[i].y1 + dst_y_off;
@@ -369,7 +369,7 @@ glamor_xv_render(glamor_port_private *port_priv)
  dsty,
  dstx + dstw,
  dsty + dsth * 2,
- vertices);
+ vptr);
 
 glamor_set_normalize_tcoords(src_pixmap_priv[0],
  src_xscale[0],
@@ -378,10 +378,29 @@ glamor_xv_render(glamor_port_private *port_priv)
  srcy,
  srcx + srcw,
  srcy + srch * 2,
- texcoords);
+ tptr);
+}
+
+glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset);
+
+glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+  GL_FLOAT, GL_FALSE,
+  2 * sizeof(float), vbo_offset + (nBox * 8 * 
sizeof(GLfloat)));
+
+glamor_put_vbo_space(screen);
+
+for (i = 0; i < nBox; i++) {
+int dstx, dsty, dstw, dsth;
+
+dstx = box[i].x1 + dst_x_off;
+dsty = box[i].y1 + dst_y_off;
+dstw = box[i].x2 - box[i].x1;
+dsth = box[i].y2 - box[i].y1;
 
 glScissor(dstx, dsty, dstw, dsth);
-glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
+glDrawArrays(GL_TRIANGLE_FAN, i * 4, 3);
 }
 glDisable(GL_SCISSOR_TEST);
 
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 1/8] glamor: use vbos in gradient/picture code.

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This converts two client arrays users to using vbos,
this is necessary to move to using core profile later.

Signed-off-by: Dave Airlie 
---
 glamor/glamor_gradient.c | 33 -
 glamor/glamor_picture.c  | 27 +++
 2 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c
index 30c29f6..c50542a 100644
--- a/glamor/glamor_gradient.c
+++ b/glamor/glamor_gradient.c
@@ -647,12 +647,12 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
 PicturePtr dst_picture,
 GLfloat *xscale, GLfloat *yscale,
 int x_source, int y_source,
-float vertices[8],
-float tex_vertices[8],
 int tex_normalize)
 {
 glamor_pixmap_private *pixmap_priv;
 PixmapPtr pixmap = NULL;
+GLfloat *v;
+char *vbo_offset;
 
 pixmap = glamor_get_drawable_pixmap(dst_picture->pDrawable);
 pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -670,13 +670,15 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
*xscale, *yscale, x_source, y_source,
dst_picture->pDrawable->width, dst_picture->pDrawable->height);
 
+v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat), _offset);
+
 glamor_set_normalize_vcoords_tri_strip(*xscale, *yscale,
0, 0,
(INT16) (dst_picture->pDrawable->
 width),
(INT16) (dst_picture->pDrawable->
 height),
-   vertices);
+   v);
 
 if (tex_normalize) {
 glamor_set_normalize_tcoords_tri_stripe(*xscale, *yscale,
@@ -687,7 +689,7 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
 (INT16) (dst_picture->
  pDrawable->height +
  y_source),
-tex_vertices);
+[8]);
 }
 else {
 glamor_set_tcoords_tri_strip(x_source, y_source,
@@ -695,28 +697,29 @@ _glamor_gradient_set_pixmap_destination(ScreenPtr screen,
  x_source,
  (INT16) (dst_picture->pDrawable->height) +
  y_source,
- tex_vertices);
+ [8]);
 }
 
 DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
"rightbottom: %f X %f, leftbottom : %f X %f\n",
-   vertices[0], vertices[1], vertices[2], vertices[3],
-   vertices[4], vertices[5], vertices[6], vertices[7]);
+   v[0], v[1], v[2], v[3],
+   v[4], v[5], v[6], v[7]);
 DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
"rightbottom: %f X %f, leftbottom : %f X %f\n",
-   tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
-   tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
+   v[8], v[9], v[10], v[11],
+   v[12], v[13], v[14], v[15]);
 
 glamor_make_current(glamor_priv);
 
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-  GL_FALSE, 0, vertices);
+  GL_FALSE, 0, vbo_offset);
 glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-  GL_FALSE, 0, tex_vertices);
+  GL_FALSE, 0, vbo_offset + 8 * sizeof(GLfloat));
 
 glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
+glamor_put_vbo_space(screen);
 return 1;
 }
 
@@ -812,13 +815,11 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
 PixmapPtr pixmap = NULL;
 GLint gradient_prog = 0;
 int error;
-float tex_vertices[8];
 int stops_count = 0;
 int count = 0;
 GLfloat *stop_colors = NULL;
 GLfloat *n_stops = NULL;
 GLfloat xscale, yscale;
-float vertices[8];
 float transform_mat[3][3];
 static const float identity_mat[3][3] = { {1.0, 0.0, 0.0},
 {0.0, 1.0, 0.0},
@@ -969,7 +970,7 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
 
 if (!_glamor_gradient_set_pixmap_destination
 (screen, glamor_priv, dst_picture, , , x_source, 
y_source,
- vertices, tex_vertices, 0))
+ 0))
 goto GRADIENT_FAIL;
 
 glamor_set_alu(screen, 

glamor core profile repost

2016-01-18 Thread Dave Airlie
I've reworked some bits of this patchset, the main changes since
earlier today,

a) drop the API changes, use GL3.1 !ARB_compatiblity to denote
core profile.
b) rework RED patch, to always set the texparam, and to
handle color swizzles, which broke some XTS tests.

Dave.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 7/8] glamor: add core profile support to EGL glamor. (v2)

2016-01-18 Thread Dave Airlie
From: Dave Airlie 

This breaks ABI unfortunately as we have to pass the core profile
info from the egl part of glamor to the glamor part of glamor.

v1.1: use version defines.
v2: let glamor work it out itself

Signed-off-by: Dave Airlie 
---
 glamor/glamor_egl.c | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index ea0443d..4bcd3ce 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -738,6 +738,15 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 #endif
 EGL_NONE
 };
+static const EGLint config_attribs_core[] = {
+EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
+EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
+EGL_CONTEXT_MAJOR_VERSION_KHR,
+GLAMOR_GL_CORE_VER_MAJOR,
+EGL_CONTEXT_MINOR_VERSION_KHR,
+GLAMOR_GL_CORE_VER_MINOR,
+EGL_NONE
+};
 
 glamor_identify(0);
 glamor_egl = calloc(sizeof(*glamor_egl), 1);
@@ -798,12 +807,21 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 KHR_surfaceless_opengl);
 #endif
 
+#ifndef GLAMOR_GLES2
 glamor_egl->context = eglCreateContext(glamor_egl->display,
NULL, EGL_NO_CONTEXT,
-   config_attribs);
-if (glamor_egl->context == EGL_NO_CONTEXT) {
-xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL context\n");
-goto error;
+   config_attribs_core);
+#else
+glamor_egl->context = NULL;
+#endif
+if (!glamor_egl->context) {
+glamor_egl->context = eglCreateContext(glamor_egl->display,
+   NULL, EGL_NO_CONTEXT,
+   config_attribs);
+if (glamor_egl->context == EGL_NO_CONTEXT) {
+xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create EGL 
context\n");
+goto error;
+}
 }
 
 if (!eglMakeCurrent(glamor_egl->display,
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH 6/8] ephyr: Create 3.3 core profile context if possible (v3)

2016-01-18 Thread Dave Airlie
From: Keith Packard 

On desktop GL, Ask for a 3.3 core profile context if that's available,
otherwise create a generic context.

v2: tell glamor the profile is a core one.
v2.1: add/use GL version defines
v3: let glamor work out core itself

Signed-off-by: Keith Packard 
Signed-off-by: Dave Airlie 
---
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 30c5245..b9fe8d1 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -41,6 +41,10 @@
 #include "os.h"
 #include 
 
+/* until we need geometry shaders GL3.1 should suffice. */
+/* Xephyr has it's own copy of this for build reasons */
+#define GLAMOR_GL_CORE_VER_MAJOR 3
+#define GLAMOR_GL_CORE_VER_MINOR 1
 /** @{
  *
  * global state for Xephyr with glamor.
@@ -319,7 +323,19 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
"GLX_EXT_create_context_es2_profile\n");
 }
 } else {
-ctx = glXCreateContext(dpy, visual_info, NULL, True);
+static const int context_attribs[] = {
+GLX_CONTEXT_PROFILE_MASK_ARB,
+GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+GLX_CONTEXT_MAJOR_VERSION_ARB,
+GLAMOR_GL_CORE_VER_MAJOR,
+GLX_CONTEXT_MINOR_VERSION_ARB,
+GLAMOR_GL_CORE_VER_MINOR,
+0,
+};
+ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
+ context_attribs);
+if (!ctx)
+ctx = glXCreateContext(dpy, visual_info, NULL, True);
 }
 if (ctx == NULL)
 FatalError("glXCreateContext failed\n");
-- 
2.4.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver] autogen: Set a default subject prefix for patches

2016-01-18 Thread Eric Anholt
Adam Jackson  writes:

> Per discussion at XDC2015, we want this so we can easily distinguish
> which module a patch is for. There's no way to set this in the
> server-side config, so setting a default at autogen time is about the
> best we can do.
>
> Signed-off-by: Adam Jackson 
> ---
>  autogen.sh | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/autogen.sh b/autogen.sh
> index aee4beb..4b1b523 100755
> --- a/autogen.sh
> +++ b/autogen.sh
> @@ -12,3 +12,6 @@ cd "$ORIGDIR" || exit $?
>  if test -z "$NOCONFIGURE"; then
>  exec "$srcdir"/configure "$@"
>  fi
> +
> +git config --local --get format.subjectPrefix ||
> +git config --local format.subjectPrefix "PATCH xserver"
> -- 

This doesn't work unless you have NOCONFIGURE set, because of "exec".
If you move it up above that block, it's:

Reviewed-by: Eric Anholt 



signature.asc
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel