[PATCH xserver 5/5] glamor: Fix segfault in fallback picture uploading.

2015-11-06 Thread Eric Anholt
If the source/mask pixmap is a pixmap that doesn't have an FBO
attached, and it doesn't match the Render operation's size, then we'll
composite it to a CPU temporary (not sure why).  We would take the
PictFormatShort from the source Picture, make a pixmap of that depth,
and try to look up the PictFormat description from the depth and the
PictFormatShort.  However, the screen's PictFormats are only attached
to the screen's visuals' depths.  So, with an x2r10g10b10 short format
(depth 30), we wouldn't find the screen's PictFormat for it
(associated with depth 32).

Instead of trying to look up from the screen, just use the pFormat
that came from our source picture.  The only time we need to look up a
PictFormat when we're doing non-shader gradients, which we put in
a8r8g8b8.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index c3a8f17..d8574ec 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1279,12 +1279,17 @@ glamor_convert_gradient_picture(ScreenPtr screen,
 PixmapPtr pixmap;
 PicturePtr dst = NULL;
 int error;
+PictFormatPtr pFormat;
 PictFormatShort format;
 
-if (!source->pDrawable)
+if (source->pDrawable) {
+pFormat = source->pFormat;
+format = pFormat->format;
+} else {
 format = PICT_a8r8g8b8;
-else
-format = source->format;
+pFormat = PictureMatchFormat(screen, 32, format);
+}
+
 #ifdef GLAMOR_GRADIENT_SHADER
 if (!source->pDrawable) {
 if (source->pSourcePict->type == SourcePictTypeLinear) {
@@ -1320,10 +1325,7 @@ glamor_convert_gradient_picture(ScreenPtr screen,
 return NULL;
 
 dst = CreatePicture(0,
->drawable,
-PictureMatchFormat(screen,
-   PIXMAN_FORMAT_DEPTH(format),
-   format), 0, 0, serverClient, 
);
+>drawable, pFormat, 0, 0, serverClient, 
);
 glamor_destroy_pixmap(pixmap);
 if (!dst)
 return NULL;
-- 
2.6.2

___
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 xserver 3/5] glamor: Fix rendering when core font texture allocation fails.

2015-11-06 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_font.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c
index 6b3a16a..6753d50 100644
--- a/glamor/glamor_font.c
+++ b/glamor/glamor_font.c
@@ -127,8 +127,13 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
 }
 
 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, overall_width, overall_height,
  0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, bits);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
+if (glGetError() == GL_OUT_OF_MEMORY)
+return NULL;
 
 free(bits);
 
-- 
2.6.2

___
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 xserver 4/5] glamor: Fix assert failures when fallback picture upload alloc fails.

2015-11-06 Thread Eric Anholt
If the glTexImage (or glTexSubImage) out-of-memories, error out
cleanly so that we can fall back to software.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 37 ++---
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 9b09454..d6f37cf 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -534,7 +534,7 @@ glamor_color_convert_to_bits(void *src_bits, void 
*dst_bits, int w, int h,
  * Upload pixmap to a specified texture.
  * This texture may not be the one attached to it.
  **/
-static void
+static Bool
 __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
   GLenum format,
   GLenum type,
@@ -567,13 +567,24 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
 glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
 }
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 if (non_sub)
 glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0, format, type, bits);
 else
 glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, format, type, bits);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
+if (glGetError() == GL_OUT_OF_MEMORY) {
+if (non_sub) {
+glDeleteTextures(1, tex);
+*tex = 0;
+}
+return FALSE;
+}
 
 if (bits == NULL)
 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+
+return TRUE;
 }
 
 static Bool
@@ -645,10 +656,15 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 assert(x + fbo_x_off >= 0 && y + fbo_y_off >= 0);
 assert(x + fbo_x_off + w <= pixmap_priv->fbo->width);
 assert(y + fbo_y_off + h <= pixmap_priv->fbo->height);
-__glamor_upload_pixmap_to_texture(pixmap, _priv->fbo->tex,
-  format, type,
-  x + fbo_x_off, y + fbo_y_off, w, h,
-  bits, pbo);
+if (!__glamor_upload_pixmap_to_texture(pixmap, _priv->fbo->tex,
+   format, type,
+   x + fbo_x_off, y + fbo_y_off,
+   w, h,
+   bits, pbo)) {
+if (need_free_bits)
+free(bits);
+return FALSE;
+}
 } else {
 ptexcoords = texcoords_inv;
 
@@ -660,6 +676,15 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
  vertices);
 /* Slow path, we need to flip y or wire alpha to 1. */
 glamor_make_current(glamor_priv);
+
+if (!__glamor_upload_pixmap_to_texture(pixmap, ,
+   format, type, 0, 0, w, h, bits,
+   pbo)) {
+if (need_free_bits)
+free(bits);
+return FALSE;
+}
+
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
   GL_FALSE, 2 * sizeof(float), vertices);
 glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
@@ -669,8 +694,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 
 glamor_set_destination_pixmap_priv_nc(glamor_priv, pixmap, 
pixmap_priv);
 glamor_set_alu(screen, GXcopy);
-__glamor_upload_pixmap_to_texture(pixmap, ,
-  format, type, 0, 0, w, h, bits, pbo);
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, tex);
 
-- 
2.6.2

___
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 xserver 1/5] glamor: Handle GL_OUT_OF_MEMORY when allocating texture images.

2015-11-06 Thread Eric Anholt
The spec allows general undefined behavior when GL_OOM is thrown.  But
if the driver happens to throw the error at this point, it probably
means the pixmap was just too big, so we should delete that texture
and have this pixmap fall back to software.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.c  |  7 +++
 glamor/glamor_fbo.c  | 18 ++
 glamor/glamor_priv.h |  3 +++
 3 files changed, 28 insertions(+)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..e69f83d 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -379,6 +379,13 @@ glamor_debug_output_callback(GLenum source,
  const void *userParam)
 {
 ScreenPtr screen = (void *)userParam;
+glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+if (glamor_priv->suppress_gl_out_of_memory_logging &&
+source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) {
+return;
+}
+
 LogMessageVerb(X_ERROR, 0, "glamor%d: GL error: %*s\n",
screen->myNum, length, message);
 }
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 262033f..545f89f 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -347,9 +347,25 @@ _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);
+
+glamor_priv->suppress_gl_out_of_memory_logging = true;
 glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
  format, GL_UNSIGNED_BYTE, NULL);
+glamor_priv->suppress_gl_out_of_memory_logging = false;
 }
+
+if (glGetError() == GL_OUT_OF_MEMORY) {
+if (!glamor_priv->logged_any_fbo_allocation_failure) {
+LogMessageVerb(X_WARNING, 0, "glamor: Failed to allocate %dx%d "
+   "FBO due to GL_OUT_OF_MEMORY.\n", w, h);
+LogMessageVerb(X_WARNING, 0,
+   "glamor: Expect reduced performance.\n");
+glamor_priv->logged_any_fbo_allocation_failure = true;
+}
+glDeleteTextures(1, );
+return 0;
+}
+
 return tex;
 }
 
@@ -368,6 +384,8 @@ glamor_create_fbo(glamor_screen_private *glamor_priv,
 return fbo;
  new_fbo:
 tex = _glamor_create_tex(glamor_priv, w, h, format, flag == 
CREATE_PIXMAP_USAGE_SHARED);
+if (!tex)
+return NULL;
 fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
 
 return fbo;
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index f3950f1..058edae 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -292,6 +292,9 @@ typedef struct glamor_screen_private {
 ScreenPtr screen;
 int dri3_enabled;
 
+Bool suppress_gl_out_of_memory_logging;
+Bool logged_any_fbo_allocation_failure;
+
 /* xv */
 GLint xv_prog;
 
-- 
2.6.2

___
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 xserver 2/5] glamor: Fix crashes when the glyph atlas allocation fails.

2015-11-06 Thread Eric Anholt
We already have a fallback path, so we just need to jump to it when we
hit the failure.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_composite_glyphs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index 389c8f4..8692904 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -127,6 +127,10 @@ glamor_glyph_atlas_init(ScreenPtr screen, struct 
glamor_glyph_atlas *atlas)
 atlas->atlas = glamor_create_pixmap(screen, glamor_priv->glyph_atlas_dim,
 glamor_priv->glyph_atlas_dim, 
format->depth,
 GLAMOR_CREATE_FBO_NO_FBO);
+if (!glamor_pixmap_has_fbo(atlas->atlas)) {
+glamor_destroy_pixmap(atlas->atlas);
+atlas->atlas = NULL;
+}
 atlas->x = 0;
 atlas->y = 0;
 atlas->row_height = 0;
@@ -420,8 +424,11 @@ glamor_composite_glyphs(CARD8 op,
 glyph_atlas->atlas = NULL;
 }
 }
-if (!glyph_atlas->atlas)
+if (!glyph_atlas->atlas) {
 glamor_glyph_atlas_init(screen, glyph_atlas);
+if (!glyph_atlas->atlas)
+goto bail_one;
+}
 glamor_glyph_add(glyph_atlas, glyph_draw);
 }
 
-- 
2.6.2

___
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 xserver] glamor: Remove the FBO cache.

2015-11-06 Thread Eric Anholt
It is a modest performance improvemnt (2.7% on Intel), with the
significant downside that it keeps extra pixmap contents laying around
for 1000 BlockHandlers without the ability for the system to purge
them when under memory pressure, and tiled renderers don't know that
we could avoid reading their current contents when beginning to render
again.  We could use the FB invalidate functions, but they aren't
always available, aren't hooked up well in Mesa, and would eat into
the performance gains of having the cache.
---
 glamor/glamor.c  |   5 --
 glamor/glamor_fbo.c  | 234 ++-
 glamor/glamor_priv.h |  27 --
 3 files changed, 7 insertions(+), 259 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..47686af 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -110,7 +110,6 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int 
tex)
 ErrorF("XXX fail to create fbo.\n");
 return;
 }
-fbo->external = TRUE;
 
 glamor_pixmap_attach_fbo(pixmap, fbo);
 }
@@ -226,9 +225,7 @@ glamor_block_handler(ScreenPtr screen)
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 
 glamor_make_current(glamor_priv);
-glamor_priv->tick++;
 glFlush();
-glamor_fbo_expire(glamor_priv);
 }
 
 static void
@@ -651,7 +648,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 ps->Glyphs = glamor_composite_glyphs;
 
 glamor_init_vbo(screen);
-glamor_init_pixmap_fbo(screen);
 glamor_init_finish_access_shaders(screen);
 
 #ifdef GLAMOR_GRADIENT_SHADER
@@ -677,7 +673,6 @@ glamor_release_screen_priv(ScreenPtr screen)
 
 glamor_priv = glamor_get_screen_private(screen);
 glamor_fini_vbo(screen);
-glamor_fini_pixmap_fbo(screen);
 glamor_pixmap_fini(screen);
 free(glamor_priv);
 
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 262033f..0524c16 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -30,105 +30,9 @@
 
 #include "glamor_priv.h"
 
-#define GLAMOR_CACHE_EXPIRE_MAX 100
-
-#define GLAMOR_CACHE_DEFAULT0
-#define GLAMOR_CACHE_EXACT_SIZE 1
-
-//#define NO_FBO_CACHE 1
-#define FBO_CACHE_THRESHOLD  (256*1024*1024)
-
-/* Loop from the tail to the head. */
-#define xorg_list_for_each_entry_reverse(pos, head, member) \
-for (pos = __container_of((head)->prev, pos, member);   \
- >member != (head);\
- pos = __container_of(pos->member.prev, pos, member))
-
-#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member)   \
-for (pos = __container_of((head)->prev, pos, member),   \
- tmp = __container_of(pos->member.prev, pos, member);   \
- >member != (head);\
- pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
-
-inline static int
-cache_wbucket(int size)
-{
-int order = __fls(size / 32);
-
-if (order >= CACHE_BUCKET_WCOUNT)
-order = CACHE_BUCKET_WCOUNT - 1;
-return order;
-}
-
-inline static int
-cache_hbucket(int size)
-{
-int order = __fls(size / 32);
-
-if (order >= CACHE_BUCKET_HCOUNT)
-order = CACHE_BUCKET_HCOUNT - 1;
-return order;
-}
-
-static int
-cache_format(GLenum format)
-{
-switch (format) {
-case GL_ALPHA:
-return 2;
-case GL_RGB:
-return 1;
-case GL_RGBA:
-return 0;
-default:
-return -1;
-}
-}
-
-static glamor_pixmap_fbo *
-glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
-int w, int h, GLenum format)
-{
-struct xorg_list *cache;
-glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
-int n_format;
-
-#ifdef NO_FBO_CACHE
-return NULL;
-#else
-n_format = cache_format(format);
-if (n_format == -1)
-return NULL;
-cache = _priv->fbo_cache[n_format]
-[cache_wbucket(w)]
-[cache_hbucket(h)];
-
-xorg_list_for_each_entry(fbo_entry, cache, list) {
-if (fbo_entry->width == w && fbo_entry->height == h) {
-
-DEBUGF("Request w %d h %d format %x \n", w, h, format);
-DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
-   fbo_entry, fbo_entry->width, fbo_entry->height,
-   fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
-assert(format == fbo_entry->format);
-xorg_list_del(_entry->list);
-ret_fbo = fbo_entry;
-break;
-}
-}
-
-if (ret_fbo)
-glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
-
-assert(glamor_priv->fbo_cache_watermark >= 0);
-
-return ret_fbo;
-#endif
-}
-
-static void
-glamor_purge_fbo(glamor_screen_private *glamor_priv,
- glamor_pixmap_fbo *fbo)
+void
+glamor_destroy_fbo(glamor_screen_private *glamor_priv,
+   glamor_pixmap_fbo *fbo)
 {
 

[PATCH xserver 08/11] glamor: Simplify DRI3 pixmap-from-fd, using GBM.

2015-11-06 Thread Eric Anholt
This GBM import path was introduced in 10.2, which we already require.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_egl.c | 37 +++--
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index f3650b7..fde7688 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -506,18 +506,8 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_egl_screen_private *glamor_egl;
 struct gbm_bo *bo;
-EGLImageKHR image;
 Bool ret = FALSE;
-
-EGLint attribs[] = {
-EGL_WIDTH, 0,
-EGL_HEIGHT, 0,
-EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB,
-EGL_DMA_BUF_PLANE0_FD_EXT, 0,
-EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
-EGL_DMA_BUF_PLANE0_PITCH_EXT, 0,
-EGL_NONE
-};
+struct gbm_import_fd_data import_data = { 0 };
 
 glamor_egl = glamor_egl_get_screen_private(scrn);
 
@@ -527,23 +517,12 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
 if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 
0)
 return FALSE;
 
-attribs[1] = width;
-attribs[3] = height;
-attribs[7] = fd;
-attribs[11] = stride;
-image = eglCreateImageKHR(glamor_egl->display,
-  EGL_NO_CONTEXT,
-  EGL_LINUX_DMA_BUF_EXT,
-  NULL, attribs);
-
-if (image == EGL_NO_IMAGE_KHR)
-return FALSE;
-
-/* EGL_EXT_image_dma_buf_import can impose restrictions on the
- * usage of the image. Use gbm_bo to bypass the limitations. */
-bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
-eglDestroyImageKHR(glamor_egl->display, image);
-
+import_data.fd = fd;
+import_data.width = width;
+import_data.height = height;
+import_data.stride = stride;
+import_data.format = GBM_FORMAT_ARGB;
+bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, _data, 0);
 if (!bo)
 return FALSE;
 
@@ -871,8 +850,6 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 #ifdef GLAMOR_HAS_GBM
 if (epoxy_has_egl_extension(glamor_egl->display,
 "EGL_KHR_gl_texture_2D_image") &&
-epoxy_has_egl_extension(glamor_egl->display,
-"EGL_EXT_image_dma_buf_import") &&
 epoxy_has_gl_extension("GL_OES_EGL_image"))
 glamor_egl->dri3_capable = TRUE;
 #endif
-- 
2.6.2

___
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 xserver 07/11] glamor: Use real types for glamor_egl's public gbm functions.

2015-11-06 Thread Eric Anholt
I think void * was just used to avoid needing to #include gbm.h, but
we can just forward-declare the structs and be fine.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.h | 11 +++
 glamor/glamor_egl.c |  7 ---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 4459fa4..12dff8e 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -40,6 +40,8 @@
 #endif
 
 struct glamor_context;
+struct gbm_bo;
+struct gbm_device;
 
 /*
  * glamor_pixmap_type : glamor pixmap's type.
@@ -147,7 +149,7 @@ extern _X_EXPORT int 
glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
 
-extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
+extern _X_EXPORT struct gbm_device *glamor_egl_get_gbm_device(ScreenPtr 
screen);
 
 /* @glamor_supports_pixmap_import_export: Returns whether
  * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
@@ -207,8 +209,8 @@ extern _X_EXPORT int glamor_name_from_pixmap(PixmapPtr 
pixmap,
  *
  * Returns the gbm_bo on success, NULL on error.
  * */
-extern _X_EXPORT void *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
- PixmapPtr pixmap);
+extern _X_EXPORT struct gbm_bo *glamor_gbm_bo_from_pixmap(ScreenPtr screen,
+  PixmapPtr pixmap);
 
 /* @glamor_pixmap_from_fd: Creates a pixmap to wrap a dma-buf fd.
  *
@@ -315,7 +317,8 @@ extern _X_EXPORT Bool 
glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
  * This function is similar to glamor_egl_create_textured_pixmap.
  */
 extern _X_EXPORT Bool
- glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
+ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+   struct gbm_bo *bo);
 
 #endif
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 6580141..f3650b7 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -175,7 +175,7 @@ glamor_create_texture_from_image(ScreenPtr screen,
 return TRUE;
 }
 
-void *
+struct gbm_device *
 glamor_egl_get_gbm_device(ScreenPtr screen)
 {
 #ifdef GLAMOR_HAS_GBM
@@ -335,7 +335,8 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 }
 
 Bool
-glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
+glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+  struct gbm_bo *bo)
 {
 ScreenPtr screen = pixmap->drawable.pScreen;
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -428,7 +429,7 @@ _get_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, 
unsigned int tex)
 }
 #endif
 
-void *
+struct gbm_bo *
 glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr pixmap)
 {
 #ifdef GLAMOR_HAS_GBM
-- 
2.6.2

___
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 xserver 10/11] glamor: Delay making pixmaps shareable until we need to.

2015-11-06 Thread Eric Anholt
If a pixmap isn't getting exported as a dmabuf, then we don't need to
go the GBM route for it.  This should reduce normal pixmap allocation
overhead, and also lets the driver choose non-scanout formats which
may be much higher performance.

On Raspberry Pi, where scanout isn't usable as a texture source, this
improves x11perf -copypixwin100 from about 4300/sec to 5780/sec under
xcompmgr -a, because we no longer need to upload our x11perf window to
a tiled temporary in order to render it to the screen.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.c   |   2 +
 glamor/glamor.h   |   5 -
 glamor/glamor_egl.c   | 211 ++
 glamor/glamor_egl_stubs.c |   6 --
 glamor/glamor_fbo.c   |  35 +++
 glamor/glamor_priv.h  |   2 +
 hw/xwayland/xwayland-glamor.c |   6 --
 7 files changed, 109 insertions(+), 158 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index ec5f81b..663399c 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -168,6 +168,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 
 pixmap_priv = glamor_get_pixmap_private(pixmap);
 
+pixmap_priv->usage_shared = (usage == CREATE_PIXMAP_USAGE_SHARED);
+
 format = gl_iformat_for_pixmap(pixmap);
 
 pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 12dff8e..a4e0655 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -140,11 +140,6 @@ extern _X_EXPORT void 
glamor_pixmap_exchange_fbos(PixmapPtr front,
 
 /* The DDX is not supposed to call these three functions */
 extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
-extern _X_EXPORT unsigned int 
glamor_egl_create_argb_based_texture(ScreenPtr
-   screen,
-   int w,
-   int h,
-   Bool 
linear);
 extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e68af18..8638063 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -187,49 +187,6 @@ glamor_egl_get_gbm_device(ScreenPtr screen)
 #endif
 }
 
-unsigned int
-glamor_egl_create_argb_based_texture(ScreenPtr screen, int w, int h, Bool 
linear)
-{
-ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-struct glamor_egl_screen_private *glamor_egl;
-EGLImageKHR image;
-GLuint texture;
-
-#ifdef GLAMOR_HAS_GBM
-struct gbm_bo *bo;
-EGLNativePixmapType native_pixmap;
-
-glamor_egl = glamor_egl_get_screen_private(scrn);
-bo = gbm_bo_create(glamor_egl->gbm, w, h, GBM_FORMAT_ARGB,
-#ifdef GLAMOR_HAS_GBM_LINEAR
-   (linear ? GBM_BO_USE_LINEAR : 0) |
-#endif
-   GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
-if (!bo)
-return 0;
-
-/* If the following assignment raises an error or a warning
- * then that means EGLNativePixmapType is not struct gbm_bo *
- * on your platform: This code won't work and you should not
- * compile with dri3 support enabled */
-native_pixmap = bo;
-
-image = eglCreateImageKHR(glamor_egl->display,
-  EGL_NO_CONTEXT,
-  EGL_NATIVE_PIXMAP_KHR,
-  native_pixmap, NULL);
-gbm_bo_destroy(bo);
-if (image == EGL_NO_IMAGE_KHR)
-return 0;
-glamor_create_texture_from_image(screen, image, );
-eglDestroyImageKHR(glamor_egl->display, image);
-
-return texture;
-#else
-return 0;   /* this path should never happen */
-#endif
-}
-
 Bool
 glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
 {
@@ -334,6 +291,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 return ret;
 }
 
+#ifdef GLAMOR_HAS_GBM
 Bool
 glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
   struct gbm_bo *bo)
@@ -342,6 +300,8 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 struct glamor_screen_private *glamor_priv =
 glamor_get_screen_private(screen);
+struct glamor_pixmap_private *pixmap_priv =
+glamor_get_pixmap_private(pixmap);
 struct glamor_egl_screen_private *glamor_egl;
 EGLImageKHR image;
 GLuint texture;
@@ -362,13 +322,15 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixma

[PATCH xserver 03/11] glamor: Remove glamor_egl_destroy_textured_pixmap().

2015-11-06 Thread Eric Anholt
The DestroyPixmap chain and CloseScreen chain all do pixmap teardown
already, and calling it manually would be redundant.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.h | 1 -
 glamor/glamor_egl.c | 6 --
 2 files changed, 7 deletions(-)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 4be8800..54fec1d 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -324,7 +324,6 @@ extern _X_EXPORT Bool
 
 extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
  struct glamor_context 
*glamor_ctx);
-extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
 
 extern _X_EXPORT int glamor_create_gc(GCPtr gc);
 
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index cc16b0a..24d5586 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -633,12 +633,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr 
back)
 glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
 }
 
-void
-glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
-{
-glamor_destroy_textured_pixmap(pixmap);
-}
-
 static Bool
 glamor_egl_close_screen(ScreenPtr screen)
 {
-- 
2.6.2

___
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 xserver 06/11] glamor: Use the GBM function for getting an FD from a GBM BO.

2015-11-06 Thread Eric Anholt
We were rolling ioctl calls ourselves, when there's a nice interface
for it.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_egl.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 761874f..6580141 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -368,22 +368,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap, void *bo)
 }
 
 #ifdef GLAMOR_HAS_GBM
-int glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd);
 void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
-int
-glamor_get_fd_from_bo(int gbm_fd, struct gbm_bo *bo, int *fd)
-{
-union gbm_bo_handle handle;
-struct drm_prime_handle args;
-
-handle = gbm_bo_get_handle(bo);
-args.handle = handle.u32;
-args.flags = DRM_CLOEXEC;
-if (ioctl(gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, ))
-return FALSE;
-*fd = args.fd;
-return TRUE;
-}
 
 void
 glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
@@ -495,8 +480,7 @@ glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
 glamor_get_name_from_bo(glamor_egl->fd, bo, );
 }
 else {
-if (glamor_get_fd_from_bo(glamor_egl->fd, bo, )) {
-}
+fd = gbm_bo_get_fd(bo);
 }
 *stride = pixmap->devKind;
 *size = pixmap->devKind * gbm_bo_get_height(bo);
-- 
2.6.2

___
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 xserver 11/11] glamor: Stop holding on to the EGLImage for textures.

2015-11-06 Thread Eric Anholt
We used to cache the EGLImage to be able to return an fd again faster,
but now we keep the gbm bo on hand to do so.

One concern might be if the early destruction of the EGLImage meant
orphaning. However, the EGL_KHR_image_base spec text says:

Once destroyed,  may not be used to create any additional
EGLImage target resources within any client API contexts, although
existing EGLImage siblings may continue to be used.

and, even more clearly in the issues section:

Note that the EGLImage source and any EGLImage target resources
will still be EGLImage siblings, even if the EGLImage object is
destroyed by a call to DestroyImageKHR.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_egl.c  | 37 ++---
 glamor/glamor_priv.h |  5 -
 2 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 8638063..6eeb7f2 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -225,24 +225,6 @@ glamor_egl_check_has_gem(int fd)
 return FALSE;
 }
 
-static void
-glamor_egl_set_pixmap_image(PixmapPtr pixmap, EGLImageKHR image)
-{
-struct glamor_pixmap_private *pixmap_priv =
-glamor_get_pixmap_private(pixmap);
-EGLImageKHR old;
-
-old = pixmap_priv->image;
-if (old) {
-ScreenPtr   screen = 
pixmap->drawable.pScreen;
-ScrnInfoPtr scrn = 
xf86ScreenToScrn(screen);
-struct glamor_egl_screen_private*glamor_egl = 
glamor_egl_get_screen_private(scrn);
-
-eglDestroyImageKHR(glamor_egl->display, old);
-}
-pixmap_priv->image = image;
-}
-
 Bool
 glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
 {
@@ -284,7 +266,7 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int 
handle, int stride)
 glamor_create_texture_from_image(screen, image, );
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixmap_texture(pixmap, texture);
-glamor_egl_set_pixmap_image(pixmap, image);
+eglDestroyImageKHR(glamor_egl->display, image);
 ret = TRUE;
 
  done:
@@ -321,7 +303,6 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 glamor_create_texture_from_image(screen, image, );
 glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
 glamor_set_pixmap_texture(pixmap, texture);
-glamor_egl_set_pixmap_image(pixmap, image);
 if (pixmap_priv->gbm)
 gbm_bo_destroy(pixmap_priv->gbm);
 pixmap_priv->gbm = bo;
@@ -532,13 +513,10 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 Bool ret;
 
 if (pixmap->refcnt == 1) {
+#ifdef GLAMOR_HAS_GBM
 struct glamor_pixmap_private *pixmap_priv =
 glamor_get_pixmap_private(pixmap);
 
-if (pixmap_priv->image)
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-
-#ifdef GLAMOR_HAS_GBM
 if (pixmap_priv->gbm) {
 gbm_bo_destroy(pixmap_priv->gbm);
 pixmap_priv->gbm = NULL;
@@ -557,7 +535,6 @@ glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 _X_EXPORT void
 glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
 {
-EGLImageKHR temp_image;
 struct gbm_bo *temp_bo;
 struct glamor_pixmap_private *front_priv =
 glamor_get_pixmap_private(front);
@@ -566,10 +543,6 @@ glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr 
back)
 
 glamor_pixmap_exchange_fbos(front, back);
 
-temp_image = back_priv->image;
-back_priv->image = front_priv->image;
-front_priv->image = temp_image;
-
 temp_bo = back_priv->gbm;
 back_priv->gbm = front_priv->gbm;
 front_priv->gbm = temp_bo;
@@ -591,8 +564,10 @@ glamor_egl_close_screen(ScreenPtr screen)
 screen_pixmap = screen->GetScreenPixmap(screen);
 pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
 
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-pixmap_priv->image = NULL;
+if (pixmap_priv->gbm) {
+gbm_bo_destroy(pixmap_priv->gbm);
+pixmap_priv->gbm = NULL;
+}
 
 screen->CloseScreen = glamor_egl->saved_close_screen;
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index df6a02a..dd01aeb 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -38,10 +38,6 @@
 #endif
 
 #include 
-#if GLAMOR_HAS_GBM
-#define MESA_EGL_NO_X11_HEADERS
-#include 
-#endif
 
 #define GLAMOR_DEFAULT_PRECISION  \
 "#ifdef GL_ES\n"  \
@@ -355,7 +351,6 @@ typedef struct glamor_pixmap_private {
 Bool prepared;
 Bool usage_shared;
 #if GLAMOR_HAS_GBM
-EGLImageKHR image;
 struct gbm_bo *gbm;
 #endif
 /** block width of this large pixmap. */
-- 
2.6.2

___
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 xserver 01/11] glamor: No need to glFlush before destroying a pixmap.

2015-11-06 Thread Eric Anholt
I assume this was a workaround for an old, broken, closed driver.  The
driver doesn't get to throw away rendering just because the rendering
context's shared-across-processes render target is getting freed from
the local address space.  If the rendering isn't to a shared render
target, then we *do* want to throw away the rendering to it.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_egl.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 2e6c7bd..cc16b0a 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -609,10 +609,6 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 struct glamor_egl_screen_private *glamor_egl =
 glamor_egl_get_screen_private(scrn);
 
-/* Before destroy an image which was attached to
- * a texture. we must call glFlush to make sure the
- * operation on that texture has been done.*/
-glamor_block_handler(pixmap->drawable.pScreen);
 eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
 pixmap_priv->image = NULL;
 }
-- 
2.6.2

___
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: Delay making pixmaps shared until needed.

2015-11-06 Thread Eric Anholt
This is a branch I've been working on for a while for glamor,
targeting 1.19.  The observation is that X allocates many pixmaps,
only a few of which will be shared between clients, and sharing a new
pixmap between clients is infrequent.  Given this, we can allocate
higher-performance non-shared pixmaps, and just use a quick CopyArea
to a shared pixmap when we need to produce an fd for one (aka when
texture_from_pixmap is used on a new window).

This is particularly important for VC4 (Raspberry Pi), since the 3D
engine can't read from the raster format, but you really want raster
format for anything you might pageflip to (the scanout engine is slow
at tiled texture formats).  Window dragging in LXDE or XFCE4 goes from
rendering at a few fps to mostly smooth.

This is available in the glamor-delay-shareable branch of my tree.

___
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 xserver 02/11] modesetting: No need to free the EGLImage just before freeing the pixmap.

2015-11-06 Thread Eric Anholt
DestroyPixmap handles that just fine.  This also lets us drop our use
of the manual image destruction function (Note that the ATI driver
still uses it in a similar fashion, though).

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c 
b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 4421578..0d34ca1 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -780,7 +780,6 @@ drmmode_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr 
rotate_pixmap, void *data)
 drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
 if (rotate_pixmap) {
-drmmode_set_pixmap_bo(drmmode, rotate_pixmap, NULL);
 rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
 }
 
@@ -1588,11 +1587,6 @@ drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr 
pixmap, drmmode_bo *bo)
 if (!drmmode->glamor)
 return TRUE;
 
-if (bo == NULL) {
-glamor_egl_destroy_textured_pixmap(pixmap);
-return TRUE;
-}
-
 #ifdef GLAMOR_HAS_GBM
 if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm)) {
 xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
-- 
2.6.2

___
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 xserver 09/11] glamor: Make glamor_get_name_from_bo static.

2015-11-06 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_egl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index fde7688..e68af18 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -369,9 +369,7 @@ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr 
pixmap,
 }
 
 #ifdef GLAMOR_HAS_GBM
-void glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name);
-
-void
+static void
 glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name)
 {
 union gbm_bo_handle handle;
-- 
2.6.2

___
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 xserver 04/11] glamor: Unexport glamor_destroy_textured_pixmap().

2015-11-06 Thread Eric Anholt
This is just a bit of the DestroyPixmap chain.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.c | 9 ++---
 glamor/glamor.h | 1 -
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index d4a0236..dbaee46 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -202,8 +202,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 return pixmap;
 }
 
-void
-glamor_destroy_textured_pixmap(PixmapPtr pixmap)
+Bool
+glamor_destroy_pixmap(PixmapPtr pixmap)
 {
 if (pixmap->refcnt == 1) {
 #if GLAMOR_HAS_GBM
@@ -211,12 +211,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap)
 #endif
 glamor_pixmap_destroy_fbo(pixmap);
 }
-}
 
-Bool
-glamor_destroy_pixmap(PixmapPtr pixmap)
-{
-glamor_destroy_textured_pixmap(pixmap);
 return fbDestroyPixmap(pixmap);
 }
 
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 54fec1d..6d135df 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -110,7 +110,6 @@ extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr 
pixmap,
 
 extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
  glamor_pixmap_type_t type);
-extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
 extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
 
 extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
-- 
2.6.2

___
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 xserver 05/11] glamor: Hook up EGL DestroyPixmap through the normal wrap chain.

2015-11-06 Thread Eric Anholt
One less layering violation (EGL should call glamor, if anything, not
the other way around).

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.c   |  3 ---
 glamor/glamor.h   |  2 --
 glamor/glamor_egl.c   | 33 +++--
 glamor/glamor_egl_stubs.c |  5 -
 hw/xwayland/xwayland-glamor.c |  5 -
 5 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index dbaee46..ec5f81b 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -206,9 +206,6 @@ Bool
 glamor_destroy_pixmap(PixmapPtr pixmap)
 {
 if (pixmap->refcnt == 1) {
-#if GLAMOR_HAS_GBM
-glamor_egl_destroy_pixmap_image(pixmap);
-#endif
 glamor_pixmap_destroy_fbo(pixmap);
 }
 
diff --git a/glamor/glamor.h b/glamor/glamor.h
index 6d135df..4459fa4 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -147,8 +147,6 @@ extern _X_EXPORT int 
glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
   unsigned int, Bool,
   CARD16 *, CARD32 *);
 
-extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
-
 extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
 
 /* @glamor_supports_pixmap_import_export: Returns whether
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 24d5586..761874f 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -78,6 +78,7 @@ struct glamor_egl_screen_private {
 int dri3_capable;
 
 CloseScreenProcPtr saved_close_screen;
+DestroyPixmapProcPtr saved_destroy_pixmap;
 xf86FreeScreenProc *saved_free_screen;
 };
 
@@ -598,20 +599,29 @@ glamor_pixmap_from_fd(ScreenPtr screen,
 #endif
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
+static Bool
+glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 {
-struct glamor_pixmap_private *pixmap_priv =
-glamor_get_pixmap_private(pixmap);
+ScreenPtr screen = pixmap->drawable.pScreen;
+ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+struct glamor_egl_screen_private *glamor_egl =
+glamor_egl_get_screen_private(scrn);
+Bool ret;
 
-if (pixmap_priv->image) {
-ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-struct glamor_egl_screen_private *glamor_egl =
-glamor_egl_get_screen_private(scrn);
+if (pixmap->refcnt == 1) {
+struct glamor_pixmap_private *pixmap_priv =
+glamor_get_pixmap_private(pixmap);
 
-eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
-pixmap_priv->image = NULL;
+if (pixmap_priv->image)
+eglDestroyImageKHR(glamor_egl->display, pixmap_priv->image);
 }
+
+screen->DestroyPixmap = glamor_egl->saved_destroy_pixmap;
+ret = screen->DestroyPixmap(pixmap);
+glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
+screen->DestroyPixmap = glamor_egl_destroy_pixmap;
+
+return ret;
 }
 
 _X_EXPORT void
@@ -723,6 +733,9 @@ glamor_egl_screen_init(ScreenPtr screen, struct 
glamor_context *glamor_ctx)
 glamor_egl->saved_close_screen = screen->CloseScreen;
 screen->CloseScreen = glamor_egl_close_screen;
 
+glamor_egl->saved_destroy_pixmap = screen->DestroyPixmap;
+screen->DestroyPixmap = glamor_egl_destroy_pixmap;
+
 glamor_ctx->ctx = glamor_egl->context;
 glamor_ctx->display = glamor_egl->display;
 
diff --git a/glamor/glamor_egl_stubs.c b/glamor/glamor_egl_stubs.c
index c11e6d5..35944c8 100644
--- a/glamor/glamor_egl_stubs.c
+++ b/glamor/glamor_egl_stubs.c
@@ -35,11 +35,6 @@ glamor_egl_screen_init(ScreenPtr screen, struct 
glamor_context *glamor_ctx)
 {
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
-{
-}
-
 int
 glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
  PixmapPtr pixmap,
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index ece7dbe..dedefdc 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -400,11 +400,6 @@ xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
 return TRUE;
 }
 
-void
-glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
-{
-}
-
 int
 glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
  PixmapPtr pixmap,
-- 
2.6.2

___
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] glamor: fix crash when drawing nothing

2015-10-14 Thread Eric Anholt
Rob Clark  writes:

> For example, in the PolyFillRect() path w/ nrect==0, we end up in
> glamor_get_vbo_space(size=0):

I wonder instead if we shouldn't just have glamor_get_vbo_space() return
NULL on size == 0?


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

Re: [PATCH 4/4] glamor: Drop a bunch of glamor_priv == NULL checks.

2015-07-08 Thread Eric Anholt
Keith Packard kei...@keithp.com writes:

 Eric Anholt e...@anholt.net writes:

 Now that it's always non-null when the pixmap is non-null, we don't
 need so much of this.  glamor_get_pixmap_private() itself still
 accepts a NULL pixmap and returns NULL, because of glamor_render.c

 Might want to change glamor_pixmap_type to explicitly make GLAMOR_MEMORY
 be zero just to make it clear that fbCreatePixmap returns a valid glamor
 pixmap?

Sounds good!


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

Re: [PATCH 4/4] glamor: Drop a bunch of glamor_priv == NULL checks.

2015-07-08 Thread Eric Anholt
Michel Dänzer mic...@daenzer.net writes:

 On 08.07.2015 09:26, Eric Anholt wrote:
 
 diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
 index 0a7de82..a923b7a 100644
 --- a/glamor/glamor_utils.h
 +++ b/glamor/glamor_utils.h
 @@ -756,8 +756,8 @@ glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, 
 int dy)
  || _depth_ == 30\
  || _depth_ == 32)
  
 -#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv  
 pixmap_priv-is_picture == 1)
 -#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)(pixmap_priv  
 pixmap_priv-gl_fbo == GLAMOR_FBO_NORMAL)
 +#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv-is_picture 
 == 1)
 +#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)(pixmap_priv-gl_fbo == 
 GLAMOR_FBO_NORMAL)

 I guess these macros could be removed now, but that's for later.

 The series is

 Reviewed-by: Michel Dänzer michel.daen...@amd.com

Thanks!

The get_pixmap_priv_from_fd() function isn't attribute-const, so we want
to be using these macros instead of glamor_pixmap_has_fbo() generally,
since pixmap private lookups can't be CSEed.

We could expand the macros in the code, but before that I'm hoping to
get rid of the gl_fbo enum, too.  It feels like I'm close.
GLAMOR_PIXMAP_PRIV_IS_PICTURE is dead in another series that will arrive
soon.


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

Re: [PATCH] glamor_egl: Properly free resources on init-error and exit

2015-07-08 Thread Eric Anholt
Hans de Goede hdego...@redhat.com writes:

 glamor_egl_init() was not undoing any of the init steps on init error,
 add an glamor_egl_cleanup() function and use this both on error and on exit
 to cleanup the various resources.

 Even on a clean exit eglTerminate() was not being called, causing the fd
 dup()-ed by eglInitialize() to stay open, call eglTerminate() from the new
 glamor_egl_cleanup() to fix this.

 Signed-off-by: Hans de Goede hdego...@redhat.com

Reviewed-by: Eric Anholt e...@anholt.net

I'll stick it in my next pull request, unless keithp grabs it first.


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

[PATCH 05/12] glamor: Move glamor_render.c pict handling to glamor_picture.c

2015-07-08 Thread Eric Anholt
These functions aren't used by anything else, and are specific to the
temporary-upload-as-a-weird-format path of glamor_render.c, called
through glamor_upload_picture_to_texture().

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_picture.c | 870 
 glamor/glamor_pixmap.c  | 870 
 glamor/glamor_priv.h|   7 -
 3 files changed, 870 insertions(+), 877 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 20b9de2..3b0b7c9 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -31,6 +31,876 @@
 #include glamor_priv.h
 #include mipict.h
 
+/*
+ * Map picture's format to the correct gl texture format and type.
+ * no_alpha is used to indicate whehter we need to wire alpha to 1.
+ *
+ * Although opengl support A1/GL_BITMAP, we still don't use it
+ * here, it seems that mesa has bugs when uploading a A1 bitmap.
+ *
+ * Return 0 if find a matched texture type. Otherwise return -1.
+ **/
+static int
+glamor_get_tex_format_type_from_pictformat_gl(PictFormatShort format,
+  GLenum *tex_format,
+  GLenum *tex_type,
+  int *no_alpha,
+  int *revert,
+  int *swap_rb, int is_upload)
+{
+*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_type = GL_UNSIGNED_BYTE;
+*revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
+break;
+case PICT_b8g8r8x8:
+*no_alpha = 1;
+case PICT_b8g8r8a8:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8;
+break;
+
+case PICT_x8r8g8b8:
+*no_alpha = 1;
+case PICT_a8r8g8b8:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+break;
+case PICT_x8b8g8r8:
+*no_alpha = 1;
+case PICT_a8b8g8r8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+break;
+case PICT_x2r10g10b10:
+*no_alpha = 1;
+case PICT_a2r10g10b10:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+break;
+case PICT_x2b10g10r10:
+*no_alpha = 1;
+case PICT_a2b10g10r10:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+break;
+
+case PICT_r5g6b5:
+*tex_format = GL_RGB;
+*tex_type = GL_UNSIGNED_SHORT_5_6_5;
+break;
+case PICT_b5g6r5:
+*tex_format = GL_RGB;
+*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
+break;
+case PICT_x1b5g5r5:
+*no_alpha = 1;
+case PICT_a1b5g5r5:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+break;
+
+case PICT_x1r5g5b5:
+*no_alpha = 1;
+case PICT_a1r5g5b5:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+break;
+case PICT_a8:
+*tex_format = GL_ALPHA;
+*tex_type = GL_UNSIGNED_BYTE;
+break;
+case PICT_x4r4g4b4:
+*no_alpha = 1;
+case PICT_a4r4g4b4:
+*tex_format = GL_BGRA;
+*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+break;
+
+case PICT_x4b4g4r4:
+*no_alpha = 1;
+case PICT_a4b4g4r4:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+break;
+
+default:
+return -1;
+}
+return 0;
+}
+
+#define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
+
+static int
+glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
+ GLenum *tex_format,
+ GLenum *tex_type,
+ int *no_alpha,
+ int *revert,
+ int *swap_rb, int is_upload)
+{
+int need_swap_rb = 0;
+
+*no_alpha = 0;
+*revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;
+
+switch (format) {
+case PICT_b8g8r8x8:
+*no_alpha = 1;
+case PICT_b8g8r8a8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE;
+need_swap_rb = 1;
+*revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+break;
+
+case PICT_x8r8g8b8:
+*no_alpha = 1;
+case PICT_a8r8g8b8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE;
+need_swap_rb = 1;
+break;
+
+case PICT_x8b8g8r8:
+*no_alpha = 1;
+case PICT_a8b8g8r8:
+*tex_format = GL_RGBA;
+*tex_type = GL_UNSIGNED_BYTE

[PATCH 08/12] glamor: Drop dead drm_stride field.

2015-07-08 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 5989dc4..f3950f1 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -350,7 +350,6 @@ typedef struct glamor_pixmap_private {
 glamor_pixmap_fbo *fbo;
 /** current fbo's coords in the whole pixmap. */
 BoxRec box;
-int drm_stride;
 GLuint pbo;
 RegionRec prepare_region;
 Bool prepared;
-- 
2.1.4

___
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 07/12] glamor: Drop tracking of the last picture attached to pixmaps.

2015-07-08 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c | 11 ---
 glamor/glamor_picture.c | 48 
 glamor/glamor_priv.h| 15 ---
 glamor/glamor_render.c  |  3 ---
 glamor/glamor_utils.h   | 10 +-
 glamor/glamor_window.c  | 32 
 6 files changed, 5 insertions(+), 114 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 04c548d..6dcc259 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -649,15 +649,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 glamor_priv-saved_procs.glyphs = ps-Glyphs;
 ps-Glyphs = glamor_composite_glyphs;
 
-glamor_priv-saved_procs.create_picture = ps-CreatePicture;
-ps-CreatePicture = glamor_create_picture;
-
-glamor_priv-saved_procs.destroy_picture = ps-DestroyPicture;
-ps-DestroyPicture = glamor_destroy_picture;
-
-glamor_priv-saved_procs.set_window_pixmap = screen-SetWindowPixmap;
-screen-SetWindowPixmap = glamor_set_window_pixmap;
-
 glamor_init_vbo(screen);
 glamor_init_pixmap_fbo(screen);
 glamor_init_finish_access_shaders(screen);
@@ -719,10 +710,8 @@ glamor_close_screen(ScreenPtr screen)
 ps-Composite = glamor_priv-saved_procs.composite;
 ps-Trapezoids = glamor_priv-saved_procs.trapezoids;
 ps-Triangles = glamor_priv-saved_procs.triangles;
-ps-CreatePicture = glamor_priv-saved_procs.create_picture;
 ps-CompositeRects = glamor_priv-saved_procs.composite_rects;
 ps-Glyphs = glamor_priv-saved_procs.glyphs;
-screen-SetWindowPixmap = glamor_priv-saved_procs.set_window_pixmap;
 
 screen_pixmap = screen-GetScreenPixmap(screen);
 glamor_pixmap_destroy_fbo(screen_pixmap);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index c36d9d6..691f179 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -900,51 +900,3 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 else
 return GLAMOR_UPLOAD_FAILED;
 }
-
-/*
- * We should already have drawable attached to it, if it has one.
- * Then set the attached pixmap to is_picture format, and set
- * the pict format.
- * */
-int
-glamor_create_picture(PicturePtr picture)
-{
-PixmapPtr pixmap;
-glamor_pixmap_private *pixmap_priv;
-
-if (!picture || !picture-pDrawable)
-return 0;
-
-pixmap = glamor_get_drawable_pixmap(picture-pDrawable);
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-pixmap_priv-is_picture = 1;
-pixmap_priv-picture = picture;
-
-return miCreatePicture(picture);
-}
-
-void
-glamor_destroy_picture(PicturePtr picture)
-{
-PixmapPtr pixmap;
-glamor_pixmap_private *pixmap_priv;
-
-if (!picture || !picture-pDrawable)
-return;
-
-pixmap = glamor_get_drawable_pixmap(picture-pDrawable);
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-
-if (pixmap_priv) {
-pixmap_priv-is_picture = 0;
-pixmap_priv-picture = NULL;
-}
-miDestroyPicture(picture);
-}
-
-void
-glamor_picture_format_fixup(PicturePtr picture,
-glamor_pixmap_private *pixmap_priv)
-{
-pixmap_priv-picture = picture;
-}
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 2792afa..5989dc4 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -173,9 +173,6 @@ struct glamor_saved_procs {
 BitmapToRegionProcPtr bitmap_to_region;
 TrianglesProcPtr triangles;
 AddTrapsProcPtr addtraps;
-CreatePictureProcPtr create_picture;
-DestroyPictureProcPtr destroy_picture;
-SetWindowPixmapProcPtr set_window_pixmap;
 #if XSYNC
 SyncScreenFuncsRec sync_screen_funcs;
 #endif
@@ -350,13 +347,10 @@ typedef struct glamor_pixmap_private {
  * that data on glamor_finish_access().
  */
 glamor_access_t map_access;
-/** Set if the pixmap is currenty attached to a Picture. */
-unsigned char is_picture:1;
 glamor_pixmap_fbo *fbo;
 /** current fbo's coords in the whole pixmap. */
 BoxRec box;
 int drm_stride;
-PicturePtr picture;
 GLuint pbo;
 RegionRec prepare_region;
 Bool prepared;
@@ -734,15 +728,6 @@ Bool glamor_composite_largepixmap_region(CARD8 op,
  **/
 enum glamor_pixmap_status glamor_upload_picture_to_texture(PicturePtr picture);
 
-int glamor_create_picture(PicturePtr picture);
-
-void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
-
-void glamor_destroy_picture(PicturePtr picture);
-
-void glamor_picture_format_fixup(PicturePtr picture,
- glamor_pixmap_private *pixmap_priv);
-
 void glamor_add_traps(PicturePtr pPicture,
   INT16 x_off, INT16 y_off, int ntrap, xTrap *traps);
 
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 3048cd8..c3a8f17 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -936,9 +936,6 @@ glamor_composite_choose_shader(CARD8 op,
 goto fail

[PATCH 09/12] glamor: Take transforms into account when preparing for a fallback.

2015-07-08 Thread Eric Anholt
This function takes the start x/y and the destination's width/height,
so it only works if there's no transform.  We could potentially
transform this box and take its bounds with some rounding, but this at
least gets us to read out enough data.

Note that this does the same overshoot on destination pictures with a
transform attached, but that seems unlikely to be used anyway.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_prepare.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 9bfc557..f63cd6e 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -220,8 +220,15 @@ glamor_prepare_access_picture_box(PicturePtr picture, 
glamor_access_t access,
 {
 if (!picture || !picture-pDrawable)
 return TRUE;
-return glamor_prepare_access_box(picture-pDrawable, access,
-x, y, w, h);
+if (picture-transform) {
+return glamor_prepare_access_box(picture-pDrawable, access,
+ 0, 0,
+ picture-pDrawable-width,
+ picture-pDrawable-height);
+} else {
+return glamor_prepare_access_box(picture-pDrawable, access,
+ x, y, w, h);
+}
 }
 
 void
-- 
2.1.4

___
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 01/12] glamor: Don't try to do rendering with unsupported formats.

2015-07-08 Thread Eric Anholt
I'm amazed we've made it as far as we have without these checks: if
you made an unusual format picture that wasn't the normal a8r8g8b8 or
x8r8g8b8 or a8, we'd go ahead and try to render with it, ignoring that
the sampler would fetch totally wrong bits.

Fixes 260 tests in rendercheck -t blend -o src -f a8r8g8b8,x2r10g10b10

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_render.c | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 488d1a7..3048cd8 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -753,6 +753,29 @@ glamor_set_normalize_tcoords_generic(PixmapPtr pixmap,
 texcoords, stride);
 }
 
+/**
+ * Returns whether the general composite path supports this picture
+ * format for a pixmap that is permanently stored in an FBO (as
+ * opposed to the GLAMOR_PIXMAP_DYNAMIC_UPLOAD path).
+ *
+ * We could support many more formats by using GL_ARB_texture_view to
+ * parse the same bits as different formats.  For now, we only support
+ * tweaking whether we sample the alpha bits of an a8r8g8b8, or just
+ * force them to 1.
+ */
+static Bool
+glamor_render_format_is_supported(PictFormatShort format)
+{
+switch (format) {
+case PICT_a8r8g8b8:
+case PICT_x8r8g8b8:
+case PICT_a8:
+return TRUE;
+default:
+return FALSE;
+}
+}
+
 static Bool
 glamor_composite_choose_shader(CARD8 op,
PicturePtr source,
@@ -783,6 +806,11 @@ glamor_composite_choose_shader(CARD8 op,
 goto fail;
 }
 
+if (!glamor_render_format_is_supported(dest-format)) {
+glamor_fallback(Unsupported dest picture format.\n);
+goto fail;
+}
+
 memset(key, 0, sizeof(key));
 if (!source) {
 key.source = SHADER_SOURCE_SOLID;
@@ -951,6 +979,11 @@ glamor_composite_choose_shader(CARD8 op,
 glamor_fallback(Failed to upload source texture.\n);
 goto fail;
 }
+} else {
+if (!glamor_render_format_is_supported(source-format)) {
+glamor_fallback(Unsupported source picture format.\n);
+goto fail;
+}
 }
 
 if (mask_status == GLAMOR_UPLOAD_PENDING) {
@@ -959,6 +992,11 @@ glamor_composite_choose_shader(CARD8 op,
 glamor_fallback(Failed to upload mask texture.\n);
 goto fail;
 }
+} else if (mask) {
+if (!glamor_render_format_is_supported(mask-format)) {
+glamor_fallback(Unsupported mask picture format.\n);
+goto fail;
+}
 }
 }
 #endif
-- 
2.1.4

___
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 11/12] glamor: Move cache_format to glamor_fbo.c, where it's used.

2015-07-08 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_fbo.c   | 15 +++
 glamor/glamor_utils.h | 15 ---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 1eee304..262033f 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -70,6 +70,21 @@ cache_hbucket(int size)
 return order;
 }
 
+static int
+cache_format(GLenum format)
+{
+switch (format) {
+case GL_ALPHA:
+return 2;
+case GL_RGB:
+return 1;
+case GL_RGBA:
+return 0;
+default:
+return -1;
+}
+}
+
 static glamor_pixmap_fbo *
 glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
 int w, int h, GLenum format)
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index e22bbc1..8a96c61 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -824,21 +824,6 @@ format_for_pixmap(PixmapPtr pixmap)
 #define SWAP_UPLOADING 2
 #define SWAP_NONE_UPLOADING3
 
-inline static int
-cache_format(GLenum format)
-{
-switch (format) {
-case GL_ALPHA:
-return 2;
-case GL_RGB:
-return 1;
-case GL_RGBA:
-return 0;
-default:
-return -1;
-}
-}
-
 /* borrowed from uxa */
 static inline Bool
 glamor_get_rgba_from_pixel(CARD32 pixel,
-- 
2.1.4

___
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 06/12] glamor: Use the actual picture's format when uploading memory pixmaps.

2015-07-08 Thread Eric Anholt
The pixmap-picture is just the *last* picture attached to the pixmap,
so you'd potentially be looking at the wrong one when trying to
temporarily upload to avoid a composite fallback.

There's some trickiness in glamor_render.c when we're dealing with the
upload of a GLAMOR_MEMORY pixmap as both the source and mask using
different formats, where we smash the source's format to a new value
so that the mask can use the same uploaded bits.  Dropping most of
that should be safe, since it will be uploaded as the source first, so
the smashed format will still be used.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_picture.c | 40 +---
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 3b0b7c9..c36d9d6 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -307,22 +307,15 @@ 
glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
 
 static int
 glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
+   PictFormatShort pict_format,
GLenum *format,
GLenum *type,
int *no_alpha,
int *revert, int *swap_rb, int 
is_upload)
 {
-glamor_pixmap_private *pixmap_priv;
-PictFormatShort pict_format;
 glamor_screen_private *glamor_priv =
 glamor_get_screen_private(pixmap-drawable.pScreen);
 
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
-pict_format = pixmap_priv-picture-format;
-else
-pict_format = format_for_depth(pixmap-drawable.depth);
-
 if (glamor_priv-gl_flavor == GLAMOR_GL_DESKTOP) {
 return glamor_get_tex_format_type_from_pictformat_gl(pict_format,
  format, type,
@@ -774,7 +767,8 @@ glamor_put_bits(char *dst_bits, int dst_stride, char 
*src_bits,
 
 static Bool
 glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
-int h, int stride, void *bits, int pbo)
+int h, int stride, void *bits, int pbo,
+PictFormatShort pict_format)
 {
 ScreenPtr screen = pixmap-drawable.pScreen;
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -784,6 +778,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 Bool force_clip;
 
 if (glamor_get_tex_format_type_from_pixmap(pixmap,
+   pict_format,
format,
type,
no_alpha,
@@ -884,23 +879,6 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
  pbo);
 }
 
-static enum glamor_pixmap_status
-glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
-{
-int ret;
-
-if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
-pixmap-drawable.width,
-pixmap-drawable.height,
-pixmap-devKind,
-pixmap-devPrivate.ptr, 0))
-ret = GLAMOR_UPLOAD_DONE;
-else
-ret = GLAMOR_UPLOAD_FAILED;
-
-return ret;
-}
-
 /* Upload picture to texture.  We may need to flip the y axis or
  * wire alpha to 1. So we may conditional create fbo for the picture.
  * */
@@ -912,7 +890,15 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 assert(picture-pDrawable);
 pixmap = glamor_get_drawable_pixmap(picture-pDrawable);
 
-return glamor_upload_pixmap_to_texture(pixmap);
+if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
+pixmap-drawable.width,
+pixmap-drawable.height,
+pixmap-devKind,
+pixmap-devPrivate.ptr, 0,
+picture-format))
+return GLAMOR_UPLOAD_DONE;
+else
+return GLAMOR_UPLOAD_FAILED;
 }
 
 /*
-- 
2.1.4

___
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 10/12] glamor: Drop another dead function.

2015-07-08 Thread Eric Anholt
This hasn't been used since the format swap/revert stuff for pictures
was added back in 2012.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_utils.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 59e6b64..e22bbc1 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -936,13 +936,6 @@ glamor_is_large_pixmap(PixmapPtr pixmap)
 return (glamor_pixmap_priv_is_large(priv));
 }
 
-inline static Bool
-glamor_tex_format_is_readable(GLenum format)
-{
-return ((format == GL_RGBA || format == GL_RGB || format == GL_ALPHA));
-
-}
-
 static inline void
 _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
 {
-- 
2.1.4

___
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 04/12] glamor: Drop dead glamor_upload_bits_to_pixmap_texture() proto.

2015-07-08 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_priv.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 1614b6f..508433a 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -741,15 +741,6 @@ Bool glamor_composite_largepixmap_region(CARD8 op,
  **/
 enum glamor_pixmap_status glamor_upload_picture_to_texture(PicturePtr picture);
 
-/**
- * Upload bits to a pixmap's texture. This function will
- * convert the bits to the specified format/type format
- * if the conversion is unavoidable.
- **/
-Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
-  GLenum type, int no_alpha, int 
revert,
-  int swap_rb, void *bits);
-
 int glamor_create_picture(PicturePtr picture);
 
 void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
-- 
2.1.4

___
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 03/12] glamor: Use the new upload/download interface for XV uploads.

2015-07-08 Thread Eric Anholt
We don't need any of its weird handling of picture formats, since our
XV pixmaps don't have any pictures attached.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_pixmap.c |  2 +-
 glamor/glamor_priv.h   |  4 
 glamor/glamor_xv.c | 38 --
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 9a14527..5a09d32 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -931,7 +931,7 @@ glamor_put_bits(char *dst_bits, int dst_stride, char 
*src_bits,
 }
 }
 
-Bool
+static Bool
 glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
 int h, int stride, void *bits, int pbo)
 {
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index d085ff2..1614b6f 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -708,10 +708,6 @@ Bool glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum 
format, int flag);
  */
 enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
 
-Bool glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
- int h, int stride, void *bits,
- int pbo);
-
 glamor_pixmap_clipped_regions *
 glamor_compute_clipped_regions(PixmapPtr pixmap,
RegionPtr region, int *clipped_nbox,
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 364104d..85e6528 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -37,6 +37,7 @@
 #endif
 
 #include glamor_priv.h
+#include glamor_transfer.h
 
 #include X11/extensions/Xv.h
 #include ../hw/xfree86/common/fourcc.h
@@ -410,6 +411,7 @@ glamor_xv_put_image(glamor_port_private *port_priv,
 int srcPitch, srcPitch2;
 int top, nlines;
 int s2offset, s3offset, tmp;
+BoxRec full_box, half_box;
 
 s2offset = s3offset = srcPitch2 = 0;
 
@@ -452,20 +454,28 @@ glamor_xv_put_image(glamor_port_private *port_priv,
 s2offset = s3offset;
 s3offset = tmp;
 }
-glamor_upload_sub_pixmap_to_texture(port_priv-src_pix[0],
-0, 0, width, nlines,
-srcPitch,
-buf + (top * srcPitch), 0);
-
-glamor_upload_sub_pixmap_to_texture(port_priv-src_pix[1],
-0, 0, width  1, (nlines + 1)  
1,
-srcPitch2,
-buf + s2offset, 0);
-
-glamor_upload_sub_pixmap_to_texture(port_priv-src_pix[2],
-0, 0, width  1, (nlines + 1)  
1,
-srcPitch2,
-buf + s3offset, 0);
+
+full_box.x1 = 0;
+full_box.y1 = 0;
+full_box.x2 = width;
+full_box.y2 = nlines;
+
+half_box.x1 = 0;
+half_box.y1 = 0;
+half_box.x2 = width  1;
+half_box.y2 = (nlines + 1)  1;
+
+glamor_upload_boxes(port_priv-src_pix[0], full_box, 1,
+0, 0, 0, 0,
+buf + (top * srcPitch), srcPitch);
+
+glamor_upload_boxes(port_priv-src_pix[1], half_box, 1,
+0, 0, 0, 0,
+buf + s2offset, srcPitch2);
+
+glamor_upload_boxes(port_priv-src_pix[2], half_box, 1,
+0, 0, 0, 0,
+buf + s3offset, srcPitch2);
 break;
 default:
 return BadMatch;
-- 
2.1.4

___
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: rendercheck fixes and picture handling simplification

2015-07-08 Thread Eric Anholt
This series came out of the process of trying to figure out if I could
safely store a8 pixmaps in an a8r8g8b8 FBO, to improve glamor
performance on VC4 (which doesn't support 8-bit FBOs).  It turns out
the answer is not quite, but the Render code had a lot of bugs
obscuring that fact.

___
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 02/12] glamor: Ignore picture formats when choosing color for core rendering.

2015-07-08 Thread Eric Anholt
Attaching a picture to a pixmap doesn't change its GL format, so it
doesn't change how core rendering should be assigning colors to it.

(Imagine XCreatePixmap(), optional XCreatePicture(pixmap) with various
formats, XFillRectangle, XGetImage().  If the XGetImage results
changed, this would be wrong).

Fixes all failures in rendercheck -t fill and, as a result, the
remaining failures in rendercheck -t blend -o src -f
a8r8g8b8,x2r10g10b10

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_utils.h | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index a923b7a..8182006 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -805,16 +805,7 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
 static inline CARD32
 format_for_pixmap(PixmapPtr pixmap)
 {
-glamor_pixmap_private *pixmap_priv;
-PictFormatShort pict_format;
-
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
-pict_format = pixmap_priv-picture-format;
-else
-pict_format = format_for_depth((pixmap)-drawable.depth);
-
-return pict_format;
+return format_for_depth((pixmap)-drawable.depth);
 }
 
 #define REVERT_NONE0
-- 
2.1.4

___
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 12/12] glamor: Drop unused box translation/bounds code.

2015-07-08 Thread Eric Anholt
These are dead since the glamor_copy.c replacement.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_utils.h | 39 ---
 1 file changed, 39 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 8a96c61..e648af2 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -697,45 +697,6 @@
 (c)[1] = (float)y; \
 } while(0)
 
-inline static void
-glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
-{
-int x_min, y_min;
-int x_max, y_max;
-int i;
-
-x_min = y_min = MAXSHORT;
-x_max = y_max = MINSHORT;
-for (i = 0; i  nbox; i++) {
-if (x_min  boxes[i].x1)
-x_min = boxes[i].x1;
-if (y_min  boxes[i].y1)
-y_min = boxes[i].y1;
-
-if (x_max  boxes[i].x2)
-x_max = boxes[i].x2;
-if (y_max  boxes[i].y2)
-y_max = boxes[i].y2;
-}
-bound-x1 = x_min;
-bound-y1 = y_min;
-bound-x2 = x_max;
-bound-y2 = y_max;
-}
-
-inline static void
-glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
-{
-int i;
-
-for (i = 0; i  nbox; i++) {
-boxes[i].x1 += dx;
-boxes[i].y1 += dy;
-boxes[i].x2 += dx;
-boxes[i].y2 += dy;
-}
-}
-
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 #endif
-- 
2.1.4

___
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] glamor: Use glamor_prepare_access_box() for PutImage/GetImage fallback

2015-07-10 Thread Eric Anholt
Michel Dänzer mic...@daenzer.net writes:

 From: Michel Dänzer michel.daen...@amd.com

 Fixes slow text display in xdvi.

 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91260
 Signed-off-by: Michel Dänzer michel.daen...@amd.com

Reviewed-by: Eric Anholt e...@anholt.net

I'll grab it in the next pull request.



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

[PATCH 4/4] glamor: Drop a bunch of glamor_priv == NULL checks.

2015-07-07 Thread Eric Anholt
Now that it's always non-null when the pixmap is non-null, we don't
need so much of this.  glamor_get_pixmap_private() itself still
accepts a NULL pixmap and returns NULL, because of glamor_render.c

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c | 17 ++---
 glamor/glamor_core.c|  3 +--
 glamor/glamor_egl.c |  4 ++--
 glamor/glamor_picture.c |  9 -
 glamor/glamor_priv.h| 12 ++--
 glamor/glamor_utils.h   |  4 ++--
 6 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 2470a8d..04c548d 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -207,13 +207,10 @@ void
 glamor_destroy_textured_pixmap(PixmapPtr pixmap)
 {
 if (pixmap-refcnt == 1) {
-glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (pixmap_priv != NULL) {
 #if GLAMOR_HAS_GBM
-glamor_egl_destroy_pixmap_image(pixmap);
+glamor_egl_destroy_pixmap_image(pixmap);
 #endif
-glamor_pixmap_destroy_fbo(pixmap);
-}
+glamor_pixmap_destroy_fbo(pixmap);
 }
 }
 
@@ -761,12 +758,11 @@ _X_EXPORT int
 glamor_fd_from_pixmap(ScreenPtr screen,
   PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
 {
-glamor_pixmap_private *pixmap_priv;
+glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_screen_private *glamor_priv =
 glamor_get_screen_private(pixmap-drawable.pScreen);
 
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (pixmap_priv == NULL || !glamor_priv-dri3_enabled)
+if (!glamor_priv-dri3_enabled)
 return -1;
 switch (pixmap_priv-type) {
 case GLAMOR_TEXTURE_DRM:
@@ -786,12 +782,11 @@ glamor_fd_from_pixmap(ScreenPtr screen,
 int
 glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
 {
-glamor_pixmap_private *pixmap_priv;
+glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_screen_private *glamor_priv =
 glamor_get_screen_private(pixmap-drawable.pScreen);
 
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (pixmap_priv == NULL || !glamor_priv-dri3_enabled)
+if (!glamor_priv-dri3_enabled)
 return -1;
 switch (pixmap_priv-type) {
 case GLAMOR_TEXTURE_DRM:
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 79f5981b..0104b88 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -42,8 +42,7 @@ glamor_get_drawable_location(const DrawablePtr drawable)
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 glamor_screen_private *glamor_priv =
 glamor_get_screen_private(drawable-pScreen);
-if (pixmap_priv == NULL ||
-pixmap_priv-gl_fbo == GLAMOR_FBO_UNATTACHED)
+if (pixmap_priv-gl_fbo == GLAMOR_FBO_UNATTACHED)
 return 'm';
 if (pixmap_priv-fbo-fb == glamor_priv-screen_fbo)
 return 's';
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index e01f723..753fb34 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -452,7 +452,7 @@ glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr 
pixmap)
 glamor_get_pixmap_private(pixmap);
 
 pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (pixmap_priv == NULL || !glamor_priv-dri3_enabled)
+if (!glamor_priv-dri3_enabled)
 return NULL;
 switch (pixmap_priv-type) {
 case GLAMOR_TEXTURE_DRM:
@@ -604,7 +604,7 @@ glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
 struct glamor_pixmap_private *pixmap_priv =
 glamor_get_pixmap_private(pixmap);
 
-if (pixmap_priv  pixmap_priv-image) {
+if (pixmap_priv-image) {
 ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap-drawable.pScreen);
 struct glamor_egl_screen_private *glamor_egl =
 glamor_egl_get_screen_private(scrn);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 53b032c..20b9de2 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -61,15 +61,6 @@ glamor_create_picture(PicturePtr picture)
 
 pixmap = glamor_get_drawable_pixmap(picture-pDrawable);
 pixmap_priv = glamor_get_pixmap_private(pixmap);
-if (!pixmap_priv) {
-/* We must create a pixmap priv to track the picture format even
- * if the pixmap is a pure in memory pixmap. The reason is that
- * we may need to upload this pixmap to a texture on the fly. During
- * the uploading, we need to know the picture format. */
-glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-}
-
 pixmap_priv-is_picture = 1;
 pixmap_priv-picture = picture;
 
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index fe65d9b..d085ff2 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -419,7 +419,7 @@ glamor_pixmap_drm_only(PixmapPtr pixmap)
 {
 glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap

[PATCH 2/4] glamor: Drop dead glamor_is_large_picture().

2015-07-07 Thread Eric Anholt
It died as of keithp's new glyphs code.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_utils.h | 12 
 1 file changed, 12 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index cef62c5..0a7de82 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -946,18 +946,6 @@ glamor_is_large_pixmap(PixmapPtr pixmap)
 }
 
 inline static Bool
-glamor_is_large_picture(PicturePtr picture)
-{
-PixmapPtr pixmap;
-
-if (picture-pDrawable) {
-pixmap = glamor_get_drawable_pixmap(picture-pDrawable);
-return glamor_is_large_pixmap(pixmap);
-}
-return FALSE;
-}
-
-inline static Bool
 glamor_tex_format_is_readable(GLenum format)
 {
 return ((format == GL_RGBA || format == GL_RGB || format == GL_ALPHA));
-- 
2.1.4

___
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/4] glamor: Ask the server to always allocate our private.

2015-07-07 Thread Eric Anholt
This avoids a lot of screwing around to attach our privates later.  It
means that non-glamor pixmaps now gain 120 bytes of glamor privates on
64-bit (which has quite a bit of fixable bloat), and glamor pixmaps
take one less pointer of storage (not counting malloc overhead).

Note that privates start out zero-filled, which matches the callocs we
were doing when making our own privates, and in the case of an fb
pixmap that has a priv where it didn't before, the type ends up being
GLAMOR_MEMORY as we would want.

Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor.c  | 43 ++-
 glamor/glamor_fbo.c  |  6 --
 glamor/glamor_priv.h | 15 ++-
 3 files changed, 12 insertions(+), 52 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 50d85ff..2470a8d 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -80,12 +80,7 @@ glamor_set_pixmap_type(PixmapPtr pixmap, 
glamor_pixmap_type_t type)
 {
 glamor_pixmap_private *pixmap_priv;
 
-pixmap_priv = dixLookupPrivate(pixmap-devPrivates,
-   glamor_pixmap_private_key);
-if (pixmap_priv == NULL) {
-pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
-glamor_set_pixmap_private(pixmap, pixmap_priv);
-}
+pixmap_priv = glamor_get_pixmap_private(pixmap);
 pixmap_priv-type = type;
 glamor_init_pixmap_private_small(pixmap, pixmap_priv);
 }
@@ -171,13 +166,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int 
depth,
 else
 pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
 
-pixmap_priv = calloc(1, sizeof(*pixmap_priv));
-
-if (!pixmap_priv) {
-fbDestroyPixmap(pixmap);
-return fbCreatePixmap(screen, w, h, depth, usage);
-}
-glamor_set_pixmap_private(pixmap, pixmap_priv);
+pixmap_priv = glamor_get_pixmap_private(pixmap);
 
 format = gl_iformat_for_pixmap(pixmap);
 
@@ -223,7 +212,7 @@ glamor_destroy_textured_pixmap(PixmapPtr pixmap)
 #if GLAMOR_HAS_GBM
 glamor_egl_destroy_pixmap_image(pixmap);
 #endif
-glamor_set_pixmap_private(pixmap, NULL);
+glamor_pixmap_destroy_fbo(pixmap);
 }
 }
 }
@@ -455,7 +444,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 
 glamor_set_screen_private(screen, glamor_priv);
 
-if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) 
{
+if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP,
+   sizeof(struct glamor_pixmap_private))) {
 LogMessage(X_WARNING,
glamor%d: Failed to allocate pixmap private\n,
screen-myNum);
@@ -705,27 +695,6 @@ glamor_release_screen_priv(ScreenPtr screen)
 glamor_set_screen_private(screen, NULL);
 }
 
-_X_EXPORT void
-glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
-{
-glamor_pixmap_private *old_priv;
-
-old_priv = dixGetPrivate(pixmap-devPrivates, glamor_pixmap_private_key);
-
-if (priv) {
-assert(old_priv == NULL);
-}
-else {
-if (old_priv == NULL)
-return;
-
glamor_pixmap_destroy_fbo(glamor_get_screen_private(pixmap-drawable.pScreen),
-  old_priv);
-free(old_priv);
-}
-
-dixSetPrivate(pixmap-devPrivates, glamor_pixmap_private_key, priv);
-}
-
 Bool
 glamor_close_screen(ScreenPtr screen)
 {
@@ -759,7 +728,7 @@ glamor_close_screen(ScreenPtr screen)
 screen-SetWindowPixmap = glamor_priv-saved_procs.set_window_pixmap;
 
 screen_pixmap = screen-GetScreenPixmap(screen);
-glamor_set_pixmap_private(screen_pixmap, NULL);
+glamor_pixmap_destroy_fbo(screen_pixmap);
 
 glamor_release_screen_priv(screen);
 
diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 84f3b22..1eee304 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -471,9 +471,11 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, 
glamor_pixmap_fbo *fbo)
 }
 
 void
-glamor_pixmap_destroy_fbo(glamor_screen_private *glamor_priv,
-  glamor_pixmap_private *priv)
+glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
 {
+ScreenPtr screen = pixmap-drawable.pScreen;
+glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+glamor_pixmap_private *priv = glamor_get_pixmap_private(pixmap);
 glamor_pixmap_fbo *fbo;
 
 if (glamor_pixmap_priv_is_large(priv)) {
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 66e5012..fe65d9b 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -405,22 +405,12 @@ extern DevPrivateKeyRec glamor_pixmap_private_key;
 static inline glamor_pixmap_private *
 glamor_get_pixmap_private(PixmapPtr pixmap)
 {
-glamor_pixmap_private *priv;
-
 if (pixmap == NULL)
 return NULL;
 
-priv = dixLookupPrivate(pixmap-devPrivates, glamor_pixmap_private_key);
-if (!priv) {
-glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY

[PATCH 1/4] glamor: Reuse the glamor_is_memory helper.

2015-07-07 Thread Eric Anholt
Signed-off-by: Eric Anholt e...@anholt.net
---
 glamor/glamor_composite_glyphs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index cd88524..389c8f4 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -376,14 +376,12 @@ glamor_composite_glyphs(CARD8 op,
 if (glyph-info.width  glyph-info.height) {
 PicturePtr glyph_pict = GlyphPicture(glyph)[screen_num];
 DrawablePtr glyph_draw = glyph_pict-pDrawable;
-glamor_pixmap_private *glyph_pix_priv =
-glamor_get_pixmap_private((PixmapPtr) glyph_draw);
 
 /* Need to draw with slow path?
  */
 if (_X_UNLIKELY(glyph_draw-width  glyph_max_dim ||
 glyph_draw-height  glyph_max_dim ||
-(glyph_pix_priv != 0  glyph_pix_priv-type 
!= GLAMOR_MEMORY)))
+
!glamor_pixmap_is_memory((PixmapPtr)glyph_draw)))
 {
 if (glyphs_queued) {
 glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, 
glyphs_queued);
-- 
2.1.4

___
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: Always allocate pixmap privates

2015-07-07 Thread Eric Anholt
The commit message in #3 has the meat of the series, but for further
explanation, note that this reduces the glamor library by 8588 bytes
(4.8%) on my x86-64 build, and I've only got 94 client-allocated
pixmaps on my desktop at the moment according to xrestop.

___
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

[git pull] glamor: always-privates and Render fixes.

2015-07-10 Thread Eric Anholt
I was hoping to get a bit more done this week, but kernel stuff
distracted me.  I'm planning on doing a bit of glamor_render.c rework
(using the new program compile infrastructure, making coordinate
transform look more familiar) soon.

The following changes since commit 90db5edf119187f8b1b9207c8c384d6cd7ef9edc:

  prime: add rotation support for offloaded outputs (v2) (2015-07-08 11:13:09 
-0700)

are available in the git repository at:

  git://people.freedesktop.org/~anholt/xserver glamor-next

for you to fetch changes up to fde13565c1b2462ee38f2a446ad3c9157261afa2:

  glamor: Drop unused box translation/bounds code. (2015-07-10 09:42:58 -0700)


Eric Anholt (16):
  glamor: Reuse the glamor_is_memory helper.
  glamor: Drop dead glamor_is_large_picture().
  glamor: Ask the server to always allocate our private.
  glamor: Drop a bunch of glamor_priv == NULL checks.
  glamor: Don't try to do rendering with unsupported formats.
  glamor: Ignore picture formats when choosing color for core rendering.
  glamor: Use the new upload/download interface for XV uploads.
  glamor: Drop dead glamor_upload_bits_to_pixmap_texture() proto.
  glamor: Move glamor_render.c pict handling to glamor_picture.c
  glamor: Use the actual picture's format when uploading memory pixmaps.
  glamor: Drop tracking of the last picture attached to pixmaps.
  glamor: Drop dead drm_stride field.
  glamor: Take transforms into account when preparing for a fallback.
  glamor: Drop another dead function.
  glamor: Move cache_format to glamor_fbo.c, where it's used.
  glamor: Drop unused box translation/bounds code.

Hans de Goede (1):
  glamor_egl: Properly free resources on init-error and exit

 glamor/glamor.c  |  69 +--
 glamor/glamor.h  |   2 +-
 glamor/glamor_composite_glyphs.c |   4 +-
 glamor/glamor_core.c |   3 +-
 glamor/glamor_egl.c  |  47 ++-
 glamor/glamor_fbo.c  |  21 +-
 glamor/glamor_picture.c  | 885 +--
 glamor/glamor_pixmap.c   | 870 --
 glamor/glamor_prepare.c  |  18 +-
 glamor/glamor_priv.h |  63 +--
 glamor/glamor_render.c   |  41 +-
 glamor/glamor_utils.h|  96 +
 glamor/glamor_window.c   |  32 --
 glamor/glamor_xv.c   |  38 +-
 14 files changed, 997 insertions(+), 1192 deletions(-)


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

Re: [PATCH xserver 1/5] glamor: Handle GL_OUT_OF_MEMORY when allocating texture images.

2015-11-18 Thread Eric Anholt
Keith Packard <kei...@keithp.com> writes:

> Eric Anholt <e...@anholt.net> writes:
>
>> I think it's a safe enough assumption that we're not generating non-OOM
>> errors.  And, now that we're logging errors, we should get reports of
>> them sooner than we used to.
>
> Would it be sensible to wrap the glGetError call like this?
>
> GLenum
> glamor_check_gl_oom() {
> GLenum last_oom = GL_NO_ERROR;
> GLenum error;
>
> while ((error = glGetError()) != GL_NO_ERROR) {
> if (error == GL_OUT_OF_MEMORY)
> last_oom = error;
> }
> return last_oom;
> }
>
> I admit I haven't looked at the Mesa glGetError() implementation, so I
> don't know if there's a queue of errors, or just a bitfield.

"When an error is detected, a flag is set and the code is
recorded. Further errors, if they occur, do not affect this recorded
code. When GetError is called, the code is returned and the flag is
cleared, so that a further error will again record its code."


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

Re: [PATCH v2] glamor: Make glamor_name_from_pixmap work without DRI3

2015-11-18 Thread Eric Anholt
Mark Kettenis  writes:

> This function is used by the modesetting driver to implement DRI2 and
> shouldn't fail on systems that don't support DRI3.  Remove the check
> for DRI3 and rename glamor_egl_dri3_fd_name_from_tex to
> glamor_egl_fd_name_from_tex.

At the time you sent the patch, if you didn't have the dri3_capable ->
glamor_enable_dri3() -> dri3_enable flag series set, then you wouldn't
have had glamor_egl_create_argb_based_texture() getting called, so
you'd make your EGL image to share out of whatever random format your GL
chose.  That probably explains your byte swapping bugs.

Also, if you didn't have dri3_capable set, then you hadn't succeeded at
the check for EGL_KHR_gl_texture_2D_image and
EGL_EXT_image_dma_buf_import and GL_OES_EGL_image.  I expect on your
platform you don't have EXT_image_dma_buf_import, but you still need to
check for the others before trying it.

Now, post glamor-delay-shareable, we shouldn't have the issue with byte
swapping since I always make the GBM bo-based EGLImage when exporting.
So, could you respin in a way that just makes sure that we've checked
for the appropriate extensions (see the calls in
glamor_egl_create_textured_pixmap_from_gbm_bo() and
glamor_create_texture_from_image())?

Oh, also, make sure you rename the other callers of
glamor_egl_dri3_fd_name_from_tex() in the tree.

> Signed-off-by: Mark Kettenis 
> ---
>  glamor/glamor.c | 2 --
>  glamor/glamor.h | 6 +++---
>  glamor/glamor_egl.c | 8 
>  3 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/glamor/glamor.c b/glamor/glamor.c
> index d4a0236..110bdb8 100644
> --- a/glamor/glamor.c
> +++ b/glamor/glamor.c
> @@ -776,8 +776,6 @@ glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, 
> CARD32 *size)
>  glamor_screen_private *glamor_priv =
>  glamor_get_screen_private(pixmap->drawable.pScreen);
>  
> -if (!glamor_priv->dri3_enabled)
> -return -1;
>  switch (pixmap_priv->type) {
>  case GLAMOR_TEXTURE_DRM:
>  case GLAMOR_TEXTURE_ONLY:
> diff --git a/glamor/glamor.h b/glamor/glamor.h
> index 4be8800..01b6e4c 100644
> --- a/glamor/glamor.h
> +++ b/glamor/glamor.h
> @@ -144,9 +144,9 @@ extern _X_EXPORT unsigned int 
> glamor_egl_create_argb_based_texture(ScreenPtr
> int w,
> int h,
> Bool 
> linear);
> -extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
> -  unsigned int, Bool,
> -  CARD16 *, CARD32 *);
> +extern _X_EXPORT int glamor_egl_fd_name_from_tex(ScreenPtr, PixmapPtr,
> +  unsigned int, Bool,
> +  CARD16 *, CARD32 *);
>  
>  extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
>  
> diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
> index 2e6c7bd..9b91147 100644
> --- a/glamor/glamor_egl.c
> +++ b/glamor/glamor_egl.c
> @@ -471,10 +471,10 @@ glamor_gbm_bo_from_pixmap(ScreenPtr screen, PixmapPtr 
> pixmap)
>  }
>  
>  int
> -glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
> - PixmapPtr pixmap,
> - unsigned int tex,
> - Bool want_name, CARD16 *stride, CARD32 
> *size)
> +glamor_egl_fd_name_from_tex(ScreenPtr screen,
> + PixmapPtr pixmap,
> + unsigned int tex,
> + Bool want_name, CARD16 *stride, CARD32 *size)
>  {
>  #ifdef GLAMOR_HAS_GBM
>  struct glamor_egl_screen_private *glamor_egl;
> -- 
> 2.6.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


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

Re: [PATCH] glamor: explicitly check for GL_OES_EGL_image

2015-09-17 Thread Eric Anholt
Emil Velikov  writes:

> Otherwise we'll fail miserably later on as we try to use
> glEGLImageTargetTexture2DOES.

I thought this had been implied by other extensions we check for, but I
don't see it.

I think this would go next to the EGL_EXT_image_dma_buf_import check --
we won't use it unless we're doing the other import/export paths, right?


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

Re: [PATCH:xserver] glamor: Get rid of an extraneous ; at the end of a C source line

2015-09-30 Thread Eric Anholt
Alan Coopersmith  writes:

> Signed-off-by: Alan Coopersmith 
> ---
>  glamor/glamor_picture.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
> index 691f179..9b09454 100644
> --- a/glamor/glamor_picture.c
> +++ b/glamor/glamor_picture.c
> @@ -231,7 +231,7 @@ 
> glamor_get_tex_format_type_from_pictformat_gles2(PictFormatShort format,
>  case PICT_b5g6r5:
>  *tex_format = GL_RGB;
>  *tex_type = GL_UNSIGNED_SHORT_5_6_5;
> -need_swap_rb = IS_LITTLE_ENDIAN ? 1 : 0;;
> +need_swap_rb = IS_LITTLE_ENDIAN ? 1 : 0;
>  break;
>  
>  case PICT_x1b5g5r5:
> -- 
> 1.7.9.2

Merged:

To git+ssh://git.freedesktop.org/git/xorg/xserver
   10e9116..c1f5f90  HEAD -> master


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

Re: [PATCH xserver 1/5] glamor: Handle GL_OUT_OF_MEMORY when allocating texture images.

2015-11-19 Thread Eric Anholt
Pekka Paalanen <ppaala...@gmail.com> writes:

> On Wed, 18 Nov 2015 09:57:02 -0800
> Eric Anholt <e...@anholt.net> wrote:
>
>> Keith Packard <kei...@keithp.com> writes:
>> 
>> > Eric Anholt <e...@anholt.net> writes:
>> >
>> >> I think it's a safe enough assumption that we're not generating non-OOM
>> >> errors.  And, now that we're logging errors, we should get reports of
>> >> them sooner than we used to.
>> >
>> > Would it be sensible to wrap the glGetError call like this?
>> >
>> > GLenum
>> > glamor_check_gl_oom() {
>> > GLenum last_oom = GL_NO_ERROR;
>> > GLenum error;
>> >
>> > while ((error = glGetError()) != GL_NO_ERROR) {
>> > if (error == GL_OUT_OF_MEMORY)
>> > last_oom = error;
>> > }
>> > return last_oom;
>> > }
>> >
>> > I admit I haven't looked at the Mesa glGetError() implementation, so I
>> > don't know if there's a queue of errors, or just a bitfield.
>> 
>> "When an error is detected, a flag is set and the code is
>> recorded. Further errors, if they occur, do not affect this recorded
>> code. When GetError is called, the code is returned and the flag is
>> cleared, so that a further error will again record its code."
>
> GL ES 2.0 spec explicitly recommends to call it in a loop:
> https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetError.xml
>
> and GL ES 3.2:
> https://www.khronos.org/opengles/sdk/docs/man32/html/glGetError.xhtml
>
> and OpenGL 4.5 also:
> https://www.opengl.org/sdk/docs/man/html/glGetError.xhtml
>
> My vague recollections are from OpenGL 2.1 era and already then you
> called it in a loop until it cleared to be sure.

I remember writing the loop in other code, but the Mesa implementation
only stores a single error.

I still stand by "If we've got other GL errors happening before this
point, we're already totally screwed, and you should go figure out where
they're coming from"


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

Re: [PATCH xserver] glamor: Limit outstanding drawing queue with glClientWaitSync

2016-06-07 Thread Eric Anholt
Keith Packard  writes:

> Michel Dänzer  writes:
>
>> Is this about x11perf by any chance? I was seeing long lag with that as
>> well, which turned out to be because we weren't correctly synchronizing
>> with the hardware for XGetImage.
>
> x11perf only does XGetImage once per run of the test; without some
> intra-test queue management, other applications are unusable while the
> test is running. This particular case isn't terribly interesting, but as
> we improve glamor to need fewer and fewer synchronizations between CPU
> and GPU, this should become relevant for interactions between regular
> applications.
>
>> In the amdgpu driver we now have a GPU scheduler managing the userspace
>> command submissions.
>
> That does seem like a fine place to manage this; right now, the intel
> driver appears to only do this in SwapBuffers.

vc4 just waits until you don't have too many (5, arbitrarily) execs
outstanding before submitting another one.  I think this is a problem of
the Intel driver, not glamor.  We ran into it with Intel on cairo-gl,
too, and I should have just fixed it in the driver back then.


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

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

2016-01-18 Thread Eric Anholt
Dave Airlie <airl...@gmail.com> writes:

> From: Dave Airlie <airl...@redhat.com>
>
> 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 <airl...@redhat.com>
> ---
>  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 <e...@anholt.net>


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

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

2016-01-18 Thread Eric Anholt
Adam Jackson <a...@redhat.com> 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 <a...@redhat.com>
> ---
>  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 <e...@anholt.net>



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

Re: Glamor bug in XVideo / XvPutImage when src_y != 0

2016-02-09 Thread Eric Anholt
Hans de Goede  writes:

> Hi Eric,
>
> While working on getting tvtime to work on cards using
> the modesetting driver + glamor, I have hit what I believe
> is a bug in glamor's XVideo implementation. I've tried
> with the current xserver master and it seems the bug is
> still present there.
>
> The problem is that src_y seems to get added to dest_y
> resulting in the bottom of the window where the tv
> is displaying via xv showing garbage when tvtime is
> using XvPutImage / XvShmPutImag to put only part of
> the tv image on the screen (to get rid of overscan or
> show a 16:9 show properly while it is transmitted as 4:3)
>
> Besides the bottom showing garbage the top of the
> actual desired content is missing, so src_x does seem
> to get correctly applied to the source image, as said
> it seems as if it is also getting added to dest_x
> (which is 0) shifting the desired image up in the window,
> and (correctly) clipping the top of the image of.
>
> Using tvtime requires an old analog tvcard + patches
> which I've in my personal git to get it work with
> planar yuv XVideo (until now it only supported
> packed yuv).
>
> I do not know of another way to reproduce this, but if
> you can spot the problem and send me a patch on top of
> current xserver master I will happily test it.

Maybe s/nlines/height/ in glamor_xv_put_image's boxes, and remove the
shifts by "top"?  I think we're uploading the rectangle from (0,srcy +
width,srch), but then we're texturing from the (src_x,srcy +
src_w,src_h) box within that uploaded content.

We could try to correct the other way and upload from (srcx,srcy +
srcw,srch) and then texture from (0,0+srcw,srch), but then you get bad
things when srch flips between even/odd iirc.  Handing us a chunk of
data over the wire and then asking to only use a subset of that is kind
of silly, and it's probably not something we should be optimizing for.

Since we can XV into pixmaps these days, maybe it's time to try to write
some tests.  I'm not sure where we'd want to put them, though.  I've
never tried to write an xts test, and it sounds terrifying.


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

Re: [PATCH RESEND] xfree86: prune duplicate monitor modes.

2016-01-27 Thread Eric Anholt
Michel Dänzer  writes:

> From: Leo Liu 
>
> same monitor modes added causing memory leak
> when looping `xrandr --prop'.
>
> Signed-off-by: Leo Liu 
> Signed-off-by: Michel Dänzer 
> ---
>
> More than two years later... Can somebody pick this up?
>
>  hw/xfree86/modes/xf86EdidModes.c |   22 ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/hw/xfree86/modes/xf86EdidModes.c
> b/hw/xfree86/modes/xf86EdidModes.c
> index 4ee862d..261780b 100644
> --- a/hw/xfree86/modes/xf86EdidModes.c
> +++ b/hw/xfree86/modes/xf86EdidModes.c
> @@ -1143,6 +1143,27 @@ handle_detailed_monset(struct
> detailed_monitor_section *det_mon, void *data)
>  }
>  }
>  +static void
> +xf86PruneDuplicateMonitorModes(MonPtr Monitor)
> +{
> +DisplayModePtr master, clone, next;
> +
> +for (master = Monitor->Modes;
> + master && master != Monitor->Last;
> + master = master->next) {
> +for (clone = master->next;
> + clone && clone != Monitor->Modes;
> + clone = next) {
> +next = clone->next;
> +if (xf86ModesEqual (master, clone)) {
> +if (Monitor->Last == clone)
> +Monitor->Last = clone->prev;
> +xf86DeleteMode (>Modes, clone);
> +}
> +}
> +}
> +}
> +
>  /*
>   * Fill out MonPtr with xf86MonPtr information.
>   */
> @@ -1204,5 +1225,6 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor,
> xf86MonPtr DDC)
>  Monitor->Modes = Modes;
>  Monitor->Last = Mode;
>  }
> +xf86PruneDuplicateMonitorModes(Monitor);
>  }
>  }

It looks like xf86EdidMonitorSet() is just appending the new DDC modes
to the monitor.  If you switch monitors, I think you get the DDC modes
From both.  Shouldn't we just be deleting the old M_T_DRIVER modes right
before appending?


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

Re: [PATCH 3/5] xephyr: Remove DRI1

2016-01-27 Thread Eric Anholt
Adam Jackson <a...@redhat.com> writes:

> This only worked if the backend server supported DRI1, which is
> stunningly unlikely these days.

Patches 1-3 are:

Reviewed-by: Eric Anholt <e...@anholt.net>

I have an old branch around for doing DRI3 under Xephyr, but I'm happy
to resurrect what I need when I get around to that.


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

[PATCH xserver 08/19] glamor: Set up XV sampler uniforms once at program build time.

2016-01-27 Thread Eric Anholt
No sense doing it on every draw.
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_xv.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 6e1a588..5d31fee 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -114,7 +114,7 @@ static void
 glamor_init_xv_shader(ScreenPtr screen)
 {
 glamor_screen_private *glamor_priv;
-GLint fs_prog, vs_prog;
+GLint fs_prog, vs_prog, sampler_loc;
 
 glamor_priv = glamor_get_screen_private(screen);
 glamor_make_current(glamor_priv);
@@ -130,6 +130,15 @@ glamor_init_xv_shader(ScreenPtr screen)
 glBindAttribLocation(glamor_priv->xv_prog,
  GLAMOR_VERTEX_SOURCE, "v_texcoord0");
 glamor_link_glsl_prog(screen, glamor_priv->xv_prog, "xv");
+
+glUseProgram(glamor_priv->xv_prog);
+sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
+glUniform1i(sampler_loc, 0);
+sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
+glUniform1i(sampler_loc, 1);
+sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
+glUniform1i(sampler_loc, 2);
+
 }
 
 #define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
@@ -258,7 +267,7 @@ glamor_xv_render(glamor_port_private *port_priv)
 float uco[3], vco[3], off[3];
 float bright, cont, gamma;
 int ref = port_priv->transform_index;
-GLint uloc, sampler_loc;
+GLint uloc;
 GLfloat *v;
 char *vbo_offset;
 
@@ -329,13 +338,6 @@ glamor_xv_render(glamor_port_private *port_priv)
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
-sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
-glUniform1i(sampler_loc, 0);
-sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
-glUniform1i(sampler_loc, 1);
-sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
-glUniform1i(sampler_loc, 2);
-
 glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
 glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
 
-- 
2.6.4

___
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 xserver 15/19] glamor: Clarify some logic in RepeatFix handling.

2016-01-27 Thread Eric Anholt
wh ratios are != 1.0 only when large, so with that we can simplify
down how we end up with RepeatFix being used.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index ec757b3..4fbf842 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -565,22 +565,15 @@ glamor_set_composite_texture(glamor_screen_private 
*glamor_priv, int unit,
  *  GLES2 doesn't support RepeatNone. We need to fix it anyway.
  *
  **/
-if (repeat_type != RepeatNone)
-repeat_type += RepeatFix;
-else if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
- || glamor_pixmap_priv_is_large(pixmap_priv)) {
-if (picture->transform)
-repeat_type += RepeatFix;
-}
-if (repeat_type >= RepeatFix) {
+if (glamor_pixmap_priv_is_large(pixmap_priv) ||
+(glamor_priv->gl_flavor == GLAMOR_GL_ES2 && repeat_type == RepeatNone 
&&
+ picture->transform)) {
 glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, pixmap_priv);
-if ((wh[0] != 1.0 || wh[1] != 1.0)
-|| (glamor_priv->gl_flavor == GLAMOR_GL_ES2
-&& repeat_type == RepeatFix))
-glUniform4fv(wh_location, 1, wh);
-else
-repeat_type -= RepeatFix;
+glUniform4fv(wh_location, 1, wh);
+
+repeat_type += RepeatFix;
 }
+
 glUniform1i(repeat_location, repeat_type);
 }
 
-- 
2.6.4

___
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 xserver 03/19] glamor: Clarify when Render fallbacks happen due to an unsupported op.

2016-01-27 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 5712cf8..51718d1 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1577,8 +1577,10 @@ glamor_composite(CARD8 op,
 if (!glamor_pixmap_has_fbo(dest_pixmap))
 goto fail;
 
-if (op >= ARRAY_SIZE(composite_op_info))
+if (op >= ARRAY_SIZE(composite_op_info)) {
+glamor_fallback("Unsupported composite op %x\n", op);
 goto fail;
+}
 
 if (mask && mask->componentAlpha && !glamor_priv->has_dual_blend) {
 if (op == PictOpAtop
-- 
2.6.4

___
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 xserver 09/19] glamor: Simplify XV vertex setup.

2016-01-27 Thread Eric Anholt
We were clipping the drawn rectangle to each clip box, then expanding
the box to a big triangle to avoid tearing, then drawing each triangle
to the destination through a scissor.  If we're using a scissor for
clipping, though, then we don't need to clip the drawn primitive on
the CPU in the first place.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_xv.c | 68 --
 1 file changed, 30 insertions(+), 38 deletions(-)

diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 5d31fee..2593d47 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -343,45 +343,36 @@ glamor_xv_render(glamor_port_private *port_priv)
 
 glEnable(GL_SCISSOR_TEST);
 
-v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, _offset);
+v = glamor_get_vbo_space(screen, 3 * 4 * sizeof(GLfloat), _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;
-float diff_x = (float) port_priv->src_w / (float) port_priv->dst_w;
-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);
+/* Set up a single primitive covering the area being drawn.  We'll
+ * clip it to port_priv->clip using GL scissors instead of just
+ * emitting a GL_QUAD per box, because this way we hopefully avoid
+ * diagonal tearing between the two trangles used to rasterize a
+ * GL_QUAD.
+ */
+i = 0;
+v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off);
+v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off);
 
-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;
+v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off +
+  port_priv->dst_w * 2);
+v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off);
 
-srcx = port_priv->src_x + off_x * diff_x;
-srcy = port_priv->src_y + off_y * diff_y;
-srcw = (port_priv->src_w * dstw) / (float) port_priv->dst_w;
-srch = (port_priv->src_h * dsth) / (float) port_priv->dst_h;
-
-glamor_set_normalize_vcoords(pixmap_priv,
- dst_xscale, dst_yscale,
- dstx - dstw,
- dsty,
- dstx + dstw,
- dsty + dsth * 2,
- vptr);
-
-glamor_set_normalize_tcoords(src_pixmap_priv[0],
- src_xscale[0],
- src_yscale[0],
- srcx - srcw,
- srcy,
- srcx + srcw,
- srcy + srch * 2,
- tptr);
-}
+v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off);
+v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off +
+  port_priv->dst_h * 2);
+
+v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x);
+v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y);
+
+v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x +
+  port_priv->src_w * 2);
+v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y);
+
+v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x);
+v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y +
+  port_priv->src_h * 2);
 
 glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
   GL_FLOAT, GL_FALSE,
@@ -389,10 +380,11 @@ glamor_xv_render(glamor_port_private *port_priv)
 
 glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
   GL_FLOAT, GL_FALSE,
-  2 * sizeof(float), vbo_offset + (nBox * 8 * 
sizeof(GLfloat)));
+  2 * sizeof(float), vbo_offset + 6 * sizeof(GLfloat));
 
 glamor_put_vbo_space(screen);
 
+/* Now draw our big triangle, clipped to each of the clip boxes. */
 for (i = 0; i < nBox; i++) {
 int dstx, dsty, dstw, dsth;
 
@@ -402,7 +394,7 @@ glamor_xv_render(glamor_port_private *port_priv)
 dsth = box[i].y2 - box[i].y1;
 
 glScissor(dstx, dsty, dstw, dsth);
-glDrawArrays(GL_TRIANGLE_FAN, i * 4, 3);
+glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
 }
 glDisable(GL_SCISSOR_TEST);
 
-- 
2.6.4

___
xorg-devel@lists.x.org: 

[PATCH xserver 02/19] glamor: Label programs before linking them.

2016-01-27 Thread Eric Anholt
i965 does most of its compiling at link time, so our debug output for
its shaders didn't have the name on.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_core.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index 0104b88..b9948b5 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -87,6 +87,17 @@ glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const 
char *format, ...)
 GLint ok;
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 
+if (glamor_priv->has_khr_debug) {
+char *label;
+va_list va;
+
+va_start(va, format);
+XNFvasprintf(, format, va);
+glObjectLabel(GL_PROGRAM, prog, -1, label);
+free(label);
+va_end(va);
+}
+
 glLinkProgram(prog);
 glGetProgramiv(prog, GL_LINK_STATUS, );
 if (!ok) {
@@ -100,17 +111,6 @@ glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const 
char *format, ...)
 ErrorF("Failed to link: %s\n", info);
 FatalError("GLSL link failure\n");
 }
-
-if (glamor_priv->has_khr_debug) {
-char *label;
-va_list va;
-
-va_start(va, format);
-XNFvasprintf(, format, va);
-glObjectLabel(GL_PROGRAM, prog, -1, label);
-free(label);
-va_end(va);
-}
 }
 
 /*
-- 
2.6.4

___
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 xserver 18/19] glamor: Cut down a bunch of conditional handling for RepeatFix.

2016-01-27 Thread Eric Anholt
For hardware that doesn't do actual jumps for conditionals (i915,
current vc4 driver), this reduces the number of texture fetches
performed (assuming the driver isn't really smart about noticing that
the same sampler is used on each side of an if).

No performance difference on i965 with x11perf -magpixwin100 (n=40).

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 50 +++---
 1 file changed, 19 insertions(+), 31 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index ed425f5..da45920 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -105,19 +105,18 @@ glamor_create_composite_fs(struct shader_key *key)
 /* The texture and the pixmap size is not match eaxctly, so can't sample 
it directly.
  * rel_sampler will recalculate the texture coords.*/
 const char *rel_sampler =
-" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, 
int set_alpha)\n"
+" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int 
repeat)\n"
 "{\n"
-"  tex = rel_tex_coord(tex, wh, repeat);\n"
-"  if (repeat == RepeatFix + RepeatNone) {\n"
-"  if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
-"  && tex.y >= 0.0 && tex.y < 1.0))\n"
-"  return vec4(0.0, 0.0, 0.0, set_alpha);\n"
-"  tex = (fract(tex) / wh.xy);\n"
+"  if (repeat >= RepeatFix) {\n"
+"  tex = rel_tex_coord(tex, wh, repeat);\n"
+"  if (repeat == RepeatFix + RepeatNone) {\n"
+"  if (!(tex.x >= 0.0 && tex.x < 1.0 && \n"
+"tex.y >= 0.0 && tex.y < 1.0))\n"
+"  return vec4(0.0, 0.0, 0.0, 0.0);\n"
+"  tex = (fract(tex) / wh.xy);\n"
+"  }\n"
 "  }\n"
-"  if (set_alpha != 1)\n"
-"  return texture2D(tex_image, tex);\n"
-"  else\n"
-"  return vec4(texture2D(tex_image, tex).rgb, 1.0);\n"
+"  return texture2D(tex_image, tex);\n"
 "}\n";
 
 const char *source_solid_fetch =
@@ -132,11 +131,8 @@ glamor_create_composite_fs(struct shader_key *key)
 "uniform vec4 source_wh;"
 "vec4 get_source()\n"
 "{\n"
-"  if (source_repeat_mode < RepeatFix)\n"
-"  return texture2D(source_sampler, source_texture);\n"
-"  else \n"
-"  return rel_sampler(source_sampler, source_texture,\n"
-" source_wh, source_repeat_mode, 0);\n"
+"  return rel_sampler(source_sampler, source_texture,\n"
+" source_wh, source_repeat_mode);\n"
 "}\n";
 const char *source_pixmap_fetch =
 "varying vec2 source_texture;\n"
@@ -144,11 +140,9 @@ glamor_create_composite_fs(struct shader_key *key)
 "uniform vec4 source_wh;\n"
 "vec4 get_source()\n"
 "{\n"
-"  if (source_repeat_mode < RepeatFix) \n"
-"  return vec4(texture2D(source_sampler, 
source_texture).rgb, 1);\n"
-"  else \n"
-"  return rel_sampler(source_sampler, source_texture,\n"
-" source_wh, source_repeat_mode, 1);\n"
+"  return vec4(rel_sampler(source_sampler, source_texture,\n"
+"  source_wh, source_repeat_mode).rgb,\n"
+"  1.0);\n"
 "}\n";
 const char *mask_none =
 "vec4 get_mask()\n"
@@ -167,11 +161,8 @@ glamor_create_composite_fs(struct shader_key *key)
 "uniform vec4 mask_wh;\n"
 "vec4 get_mask()\n"
 "{\n"
-"  if (mask_repeat_mode < RepeatFix) \n"
-"  return texture2D(mask_sampler, mask_texture);\n"
-"  else \n"
-"  return rel_sampler(mask_sampler, mask_texture,\n"
-" mask_wh, mask_repeat_mode, 0);\n"
+"  return rel_sampler(mask_sampler, mask_texture,\n"
+"   

[PATCH xserver 14/19] glamor: Drop extra conditionals for large pixmap handling.

2016-01-27 Thread Eric Anholt
For a small pixmap, it's got a box from 0,0 to width/height, so we can
always use that.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_utils.h | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 5128a33..f20d520 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -56,13 +56,8 @@
 
 #define PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap, priv, w, h)  \
   do { \
-   if (_X_UNLIKELY(glamor_pixmap_priv_is_large(priv))) {   \
-   w = priv->box.x2 - priv->box.x1;\
-   h = priv->box.y2 - priv->box.y1;\
-   } else {\
-   w = (pixmap)->drawable.width;   \
-   h = (pixmap)->drawable.height;  \
-   }   \
+  w = priv->box.x2 - priv->box.x1;  \
+  h = priv->box.y2 - priv->box.y1;  \
   } while(0)
 
 #define glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap, priv) \
@@ -77,13 +72,8 @@
 
 #define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_)\
do {\
-if (_X_UNLIKELY(_priv_ && glamor_pixmap_priv_is_large(_priv_))) { \
-   *(_xoff_) = - (_priv_)->box.x1; \
-   *(_yoff_) = - (_priv_)->box.y1; \
-   } else {\
-   *(_xoff_) = 0;  \
-   *(_yoff_) = 0;  \
-   }   \
+   *(_xoff_) = - (_priv_)->box.x1; \
+   *(_yoff_) = - (_priv_)->box.y1; \
} while(0)
 
 #define xFixedToFloat(_val_) ((float)xFixedToInt(_val_)
\
-- 
2.6.4

___
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 xserver 01/19] ephyr: Make sure we have GLX_ARB_create_context before calling it.

2016-01-27 Thread Eric Anholt
This should fix aborts()s from epoxy on old software stacks.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 34 --
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 0981144..636150d 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -330,20 +330,26 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
"GLX_EXT_create_context_es2_profile\n");
 }
 } else {
-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,
-};
-oldErrorHandler = XSetErrorHandler(ephyr_glx_error_handler);
-ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
- context_attribs);
-XSync(dpy, False);
-XSetErrorHandler(oldErrorHandler);
+if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
+"GLX_ARB_create_context")) {
+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,
+};
+oldErrorHandler = XSetErrorHandler(ephyr_glx_error_handler);
+ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
+ context_attribs);
+XSync(dpy, False);
+XSetErrorHandler(oldErrorHandler);
+} else {
+ctx = NULL;
+}
+
 if (!ctx)
 ctx = glXCreateContext(dpy, visual_info, NULL, True);
 }
-- 
2.6.4

___
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 xserver 19/19] glamor: Flip around conditionals in RepeatNone fixups.

2016-01-27 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index da45920..73ac831 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -110,8 +110,8 @@ glamor_create_composite_fs(struct shader_key *key)
 "  if (repeat >= RepeatFix) {\n"
 "  tex = rel_tex_coord(tex, wh, repeat);\n"
 "  if (repeat == RepeatFix + RepeatNone) {\n"
-"  if (!(tex.x >= 0.0 && tex.x < 1.0 && \n"
-"tex.y >= 0.0 && tex.y < 1.0))\n"
+"  if (tex.x < 0.0 || tex.x >= 1.0 || \n"
+"  tex.y < 0.0 || tex.y >= 1.0)\n"
 "  return vec4(0.0, 0.0, 0.0, 0.0);\n"
 "  tex = (fract(tex) / wh.xy);\n"
 "  }\n"
-- 
2.6.4

___
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 xserver 12/19] glamor: Reuse the glamor_program_alpha_* enums for Render.

2016-01-27 Thread Eric Anholt
This is a step toward using glamor_program.c for Render acceleration.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_priv.h   | 12 ++--
 glamor/glamor_render.c | 28 ++--
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index b70533a..60b0a66 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -107,14 +107,6 @@ enum shader_mask {
 SHADER_MASK_COUNT,
 };
 
-enum shader_in {
-SHADER_IN_NORMAL,
-SHADER_IN_CA_SOURCE,
-SHADER_IN_CA_ALPHA,
-SHADER_IN_CA_DUAL_BLEND,
-SHADER_IN_COUNT,
-};
-
 enum shader_dest_swizzle {
 SHADER_DEST_SWIZZLE_DEFAULT,
 SHADER_DEST_SWIZZLE_ALPHA_TO_RED,
@@ -124,7 +116,7 @@ enum shader_dest_swizzle {
 struct shader_key {
 enum shader_source source;
 enum shader_mask mask;
-enum shader_in in;
+glamor_program_alpha in;
 enum shader_dest_swizzle dest_swizzle;
 };
 
@@ -291,7 +283,7 @@ typedef struct glamor_screen_private {
 int render_nr_quads;
 glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
 [SHADER_MASK_COUNT]
-[SHADER_IN_COUNT]
+[glamor_program_alpha_count]
 [SHADER_DEST_SWIZZLE_COUNT];
 
 /* shaders to restore a texture to another texture. */
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index d1b7a15..ec757b3 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -278,16 +278,16 @@ glamor_create_composite_fs(struct shader_key *key)
 
 header = header_norm;
 switch (key->in) {
-case SHADER_IN_NORMAL:
+case glamor_program_alpha_normal:
 in = in_normal;
 break;
-case SHADER_IN_CA_SOURCE:
+case glamor_program_alpha_ca_first:
 in = in_ca_source;
 break;
-case SHADER_IN_CA_ALPHA:
+case glamor_program_alpha_ca_second:
 in = in_ca_alpha;
 break;
-case SHADER_IN_CA_DUAL_BLEND:
+case glamor_program_alpha_dual_blend:
 in = in_ca_dual_blend;
 header = header_ca_dual_blend;
 break;
@@ -368,7 +368,7 @@ glamor_create_composite_shader(ScreenPtr screen, struct 
shader_key *key,
 glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
 glBindAttribLocation(prog, GLAMOR_VERTEX_MASK, "v_texcoord1");
 
-if (key->in == SHADER_IN_CA_DUAL_BLEND) {
+if (key->in == glamor_program_alpha_dual_blend) {
 glBindFragDataLocationIndexed(prog, 0, 0, "color0");
 glBindFragDataLocationIndexed(prog, 0, 1, "color1");
 }
@@ -674,7 +674,7 @@ static const int pict_format_combine_tab[][3] = {
 
 static Bool
 combine_pict_format(PictFormatShort * des, const PictFormatShort src,
-const PictFormatShort mask, enum shader_in in_ca)
+const PictFormatShort mask, glamor_program_alpha in_ca)
 {
 PictFormatShort new_vis;
 int src_type, mask_type, src_bpp;
@@ -691,19 +691,19 @@ combine_pict_format(PictFormatShort * des, const 
PictFormatShort src,
 new_vis = PICT_FORMAT_VIS(src) | PICT_FORMAT_VIS(mask);
 
 switch (in_ca) {
-case SHADER_IN_NORMAL:
+case glamor_program_alpha_normal:
 src_type = PICT_FORMAT_TYPE(src);
 mask_type = PICT_TYPE_A;
 break;
-case SHADER_IN_CA_SOURCE:
+case glamor_program_alpha_ca_first:
 src_type = PICT_FORMAT_TYPE(src);
 mask_type = PICT_FORMAT_TYPE(mask);
 break;
-case SHADER_IN_CA_ALPHA:
+case glamor_program_alpha_ca_second:
 src_type = PICT_TYPE_A;
 mask_type = PICT_FORMAT_TYPE(mask);
 break;
-case SHADER_IN_CA_DUAL_BLEND:
+case glamor_program_alpha_dual_blend:
 src_type = PICT_FORMAT_TYPE(src);
 mask_type = PICT_FORMAT_TYPE(mask);
 break;
@@ -867,19 +867,19 @@ glamor_composite_choose_shader(CARD8 op,
 }
 
 if (!mask->componentAlpha) {
-key.in = SHADER_IN_NORMAL;
+key.in = glamor_program_alpha_normal;
 }
 else {
 if (op == PictOpClear)
 key.mask = SHADER_MASK_NONE;
 else if (glamor_priv->has_dual_blend)
-key.in = SHADER_IN_CA_DUAL_BLEND;
+key.in = glamor_program_alpha_dual_blend;
 else if (op == PictOpSrc || op == PictOpAdd
  || op == PictOpIn || op == PictOpOut
  || op == PictOpOverReverse)
-key.in = SHADER_IN_CA_SOURCE;
+key.in = glamor_program_alpha_ca_second;
 else if (op == PictOpOutReverse || op == PictOpInReverse) {
-key.in = SHADER_IN_CA_ALPHA;
+key.in = glamor_program_alpha_ca_first;
 }
 else {
 glamor_fallback("Unsupported component alpha op: %d\n", op);
-- 
2.6.4

___
xorg-devel@lists.x.org: X.Org 

[PATCH xserver 10/19] glamor: Convert XV to using glamor_program.c.

2016-01-27 Thread Eric Anholt
One less custom path!  By following the common glamor_program.c use
pattern, we get the ability to handle large pixmaps as the
destination.  It's also one less place where glamor_utils.h coordinate
transformation happens.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_priv.h |   2 +-
 glamor/glamor_xv.c   | 147 ---
 2 files changed, 71 insertions(+), 78 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index f1eed5b..d78db7f 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -318,7 +318,7 @@ typedef struct glamor_screen_private {
 Bool logged_any_fbo_allocation_failure;
 
 /* xv */
-GLint xv_prog;
+glamor_program xv_prog;
 
 struct glamor_context ctx;
 } glamor_screen_private;
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 2593d47..e8c849d 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -37,6 +37,7 @@
 #endif
 
 #include "glamor_priv.h"
+#include "glamor_transform.h"
 #include "glamor_transfer.h"
 
 #include 
@@ -58,36 +59,36 @@ typedef struct tagREF_TRANSFORM {
 #define RTFContrast(a)   (1.0 + ((a)*1.0)/1000.0)
 #define RTFHue(a)   (((a)*3.1416)/1000.0)
 
-static const char *xv_vs = "attribute vec4 v_position;\n"
-"attribute vec4 v_texcoord0;\n"
-"varying vec2 tcs;\n"
-"void main()\n"
-"{\n"
-" gl_Position = v_position;\n"
-"tcs = v_texcoord0.xy;\n"
-"}\n";
-
-static const char *xv_ps = GLAMOR_DEFAULT_PRECISION
-"uniform sampler2D y_sampler;\n"
-"uniform sampler2D u_sampler;\n"
-"uniform sampler2D v_sampler;\n"
-"uniform vec4 offsetyco;\n"
-"uniform vec4 ucogamma;\n"
-"uniform vec4 vco;\n"
-"varying vec2 tcs;\n"
-"float sample;\n"
-"vec4 temp1;\n"
-"void main()\n"
-"{\n"
-"sample = texture2D(y_sampler, tcs).w;\n"
-"temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
-"sample = texture2D(u_sampler, tcs).w;\n"
-"temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n"
-"sample = texture2D(v_sampler, tcs).w;\n"
-"temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 0.0, 1.0);\n"
-"temp1.w = 1.0;\n"
-"gl_FragColor = temp1;\n"
-"}\n";
+static const glamor_facet glamor_facet_xv_planar = {
+.name = "xv_planar",
+
+.source_name = "v_texcoord0",
+.vs_vars = ("attribute vec2 position;\n"
+"attribute vec2 v_texcoord0;\n"
+"varying vec2 tcs;\n"),
+.vs_exec = (GLAMOR_POS(gl_Position, position)
+"tcs = v_texcoord0;\n"),
+
+.fs_vars = ("uniform sampler2D y_sampler;\n"
+"uniform sampler2D u_sampler;\n"
+"uniform sampler2D v_sampler;\n"
+"uniform vec4 offsetyco;\n"
+"uniform vec4 ucogamma;\n"
+"uniform vec4 vco;\n"
+"varying vec2 tcs;\n"),
+.fs_exec = (
+"float sample;\n"
+"vec4 temp1;\n"
+"sample = texture2D(y_sampler, tcs).w;\n"
+"temp1.xyz = offsetyco.www * vec3(sample) + 
offsetyco.xyz;\n"
+"sample = texture2D(u_sampler, tcs).w;\n"
+"temp1.xyz = ucogamma.xyz * vec3(sample) + 
temp1.xyz;\n"
+"sample = texture2D(v_sampler, tcs).w;\n"
+"temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 
0.0, 1.0);\n"
+"temp1.w = 1.0;\n"
+"gl_FragColor = temp1;\n"
+),
+};
 
 #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
 
@@ -113,30 +114,19 @@ int glamor_xv_num_images = ARRAY_SIZE(glamor_xv_images);
 static void
 glamor_init_xv_shader(ScreenPtr screen)
 {
-glamor_screen_private *glamor_priv;
-GLint fs_prog, vs_prog, sampler_loc;
-
-glamor_priv = glamor_get_screen_private(screen);
-glamor_make_current(glamor_priv);
-glamor_priv->xv_prog = glCreateProgram();
-
-vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xv_vs);
-fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xv_ps);
-glAttachShader(glamor_priv->xv_prog, vs_prog);
-glAttachShader(glamor_priv->xv_prog, fs_prog);
+glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+GLint sampler_loc;
 
-glBindAttribLocation(glamor_priv->xv_prog,
- GLAMOR_

[PATCH xserver 11/19] glamor: Drop extra SHADER_IN type for no mask present.

2016-01-27 Thread Eric Anholt
We can just hand in a constant mask and the driver will optimize away
the multiplication for us.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_priv.h   |  1 -
 glamor/glamor_render.c | 17 ++---
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index d78db7f..b70533a 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -108,7 +108,6 @@ enum shader_mask {
 };
 
 enum shader_in {
-SHADER_IN_SOURCE_ONLY,
 SHADER_IN_NORMAL,
 SHADER_IN_CA_SOURCE,
 SHADER_IN_CA_ALPHA,
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 51718d1..d1b7a15 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -147,6 +147,11 @@ glamor_create_composite_fs(struct shader_key *key)
 "  return rel_sampler(source_sampler, source_texture,\n"
 " source_wh, source_repeat_mode, 1);\n"
 "}\n";
+const char *mask_none =
+"vec4 get_mask()\n"
+"{\n"
+"  return vec4(0.0, 0.0, 0.0, 1.0);\n"
+"}\n";
 const char *mask_solid_fetch =
 "uniform vec4 mask;\n"
 "vec4 get_mask()\n"
@@ -190,11 +195,6 @@ glamor_create_composite_fs(struct shader_key *key)
 "  return vec4(color.a, undef, undef, undef);"
 "}";
 
-const char *in_source_only =
-"void main()\n"
-"{\n"
-"  gl_FragColor = dest_swizzle(get_source());\n"
-"}\n";
 const char *in_normal =
 "void main()\n"
 "{\n"
@@ -246,6 +246,7 @@ glamor_create_composite_fs(struct shader_key *key)
 
 switch (key->mask) {
 case SHADER_MASK_NONE:
+mask_fetch = mask_none;
 break;
 case SHADER_MASK_SOLID:
 mask_fetch = mask_solid_fetch;
@@ -277,9 +278,6 @@ glamor_create_composite_fs(struct shader_key *key)
 
 header = header_norm;
 switch (key->in) {
-case SHADER_IN_SOURCE_ONLY:
-in = in_source_only;
-break;
 case SHADER_IN_NORMAL:
 in = in_normal;
 break;
@@ -693,8 +691,6 @@ combine_pict_format(PictFormatShort * des, const 
PictFormatShort src,
 new_vis = PICT_FORMAT_VIS(src) | PICT_FORMAT_VIS(mask);
 
 switch (in_ca) {
-case SHADER_IN_SOURCE_ONLY:
-return TRUE;
 case SHADER_IN_NORMAL:
 src_type = PICT_FORMAT_TYPE(src);
 mask_type = PICT_TYPE_A;
@@ -893,7 +889,6 @@ glamor_composite_choose_shader(CARD8 op,
 }
 else {
 key.mask = SHADER_MASK_NONE;
-key.in = SHADER_IN_SOURCE_ONLY;
 }
 
 if (dest_pixmap->drawable.bitsPerPixel <= 8 &&
-- 
2.6.4

___
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 xserver 00/19] glamor: Cleanups all over

2016-01-27 Thread Eric Anholt
I've been working on vc4 X performance again, particularly looking at
dragging windows with xcompmgr -c running.  I'll be sending a separate
patch to accelerate a8 rendering on GLES2-class renderers, but even
with that things are crazy slow.  I think at this point the major
problem is the crazy mass of code from rel_sampler().

This series was some cleanups as I worked toward that, and finally one
patch that should reduce the cost of rel_sampler on non-control-flow
hardware (I see fewer texture sampler requests on vc4).  No
performance change on i965, but I hope that vc4 is in better shape
after it.  (I'm away from the hardware at the moment, but should test
later today).

Eric Anholt (19):
  ephyr: Make sure we have GLX_ARB_create_context before calling it.
  glamor: Label programs before linking them.
  glamor: Clarify when Render fallbacks happen due to an unsupported op.
  glamor: Drop dead *_from_x_coord_y() functions.
  glamor: Rename the *y_inverted helpers to not say "inverted".
  glamor: Drop comment about dead yInverted flag.
  glamor: Drop dead glamor_pict_format_is_compatible().
  glamor: Set up XV sampler uniforms once at program build time.
  glamor: Simplify XV vertex setup.
  glamor: Convert XV to using glamor_program.c.
  glamor: Drop extra SHADER_IN type for no mask present.
  glamor: Reuse the glamor_program_alpha_* enums for Render.
  glamor: Simplify the pixmap box looping.
  glamor: Drop extra conditionals for large pixmap handling.
  glamor: Clarify some logic in RepeatFix handling.
  glamor: Clean up formatting of RepeatFix shader code.
  glamor: Clarify how the repeat values being passed around work.
  glamor: Cut down a bunch of conditional handling for RepeatFix.
  glamor: Flip around conditionals in RepeatNone fixups.

 glamor/glamor_composite_glyphs.c   |  10 +-
 glamor/glamor_copy.c   |  15 +--
 glamor/glamor_core.c   |  22 ++--
 glamor/glamor_dash.c   |   6 +-
 glamor/glamor_glyphblt.c   |  12 +--
 glamor/glamor_lines.c  |   6 +-
 glamor/glamor_points.c |   7 +-
 glamor/glamor_priv.h   |  35 +++---
 glamor/glamor_rects.c  |   7 +-
 glamor/glamor_render.c | 161 +---
 glamor/glamor_segs.c   |   6 +-
 glamor/glamor_spans.c  |  23 ++--
 glamor/glamor_text.c   |   8 +-
 glamor/glamor_transfer.c   |  16 +--
 glamor/glamor_transform.c  |   9 +-
 glamor/glamor_transform.h  |   3 +-
 glamor/glamor_utils.h  |  70 
 glamor/glamor_xv.c | 213 +
 hw/kdrive/ephyr/ephyr_glamor_glx.c |  34 +++---
 19 files changed, 298 insertions(+), 365 deletions(-)

-- 
2.6.4

___
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 xserver 04/19] glamor: Drop dead *_from_x_coord_y() functions.

2016-01-27 Thread Eric Anholt
They've been dead since the yInverted removal
(e310387f443b6333edf02c8980daa303505382b4).

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_utils.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index d4366c1..875c935 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -36,10 +36,8 @@
 #include "mipict.h"
 
 #define v_from_x_coord_x(_xscale_, _x_)  ( 2 * (_x_) * (_xscale_) - 
1.0)
-#define v_from_x_coord_y(_yscale_, _y_)  (-2 * (_y_) * (_yscale_) + 
1.0)
 #define v_from_x_coord_y_inverted(_yscale_, _y_) (2 * (_y_) * (_yscale_) - 1.0)
 #define t_from_x_coord_x(_xscale_, _x_)  ((_x_) * (_xscale_))
-#define t_from_x_coord_y(_yscale_, _y_)  (1.0 - (_y_) * (_yscale_))
 #define t_from_x_coord_y_inverted(_yscale_, _y_) ((_y_) * (_yscale_))
 
 #define pixmap_priv_get_dest_scale(pixmap, _pixmap_priv_, _pxscale_, 
_pyscale_) \
-- 
2.6.4

___
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 xserver 16/19] glamor: Clean up formatting of RepeatFix shader code.

2016-01-27 Thread Eric Anholt
All sorts of weird indentation, and some cuddled conditional
statements deep in the if tree.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 57 ++
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 4fbf842..a2a7f4a 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -74,30 +74,33 @@ glamor_create_composite_fs(struct shader_key *key)
 const char *relocate_texture =
 "vec2 rel_tex_coord(vec2 texture, vec4 wh, int repeat) \n"
 "{\n"
-"   vec2 rel_tex; \n"
-"   rel_tex = texture * wh.xy; \n"
+"  vec2 rel_tex; \n"
+"  rel_tex = texture * wh.xy; \n"
 "  if (repeat == RepeatNone)\n"
 "  return rel_tex; \n"
-"   else if (repeat == RepeatNormal) \n"
-"  rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy);\n"
-"   else if(repeat == RepeatPad) { \n"
-"   if (rel_tex.x >= 1.0) rel_tex.x = 1.0 - wh.z * wh.x / 2.;  
\n"
-"  else if(rel_tex.x < 0.0) rel_tex.x = 0.0;   
\n"
-"   if (rel_tex.y >= 1.0) rel_tex.y = 1.0 - wh.w * wh.y / 2.;  
\n"
-"  else if(rel_tex.y < 0.0) rel_tex.y = 0.0;   \n"
-"  rel_tex = rel_tex / wh.xy; \n"
-"} \n"
-"   else if(repeat == RepeatReflect) {\n"
+"  else if (repeat == RepeatNormal) \n"
+"  rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
+"  else if (repeat == RepeatPad) { \n"
+"  if (rel_tex.x >= 1.0) \n"
+"  rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
+"  else if (rel_tex.x < 0.0) \n"
+"  rel_tex.x = 0.0; \n"
+"  if (rel_tex.y >= 1.0) \n"
+"  rel_tex.y = 1.0 - wh.w * wh.y / 2.; \n"
+"  else if (rel_tex.y < 0.0) \n"
+"  rel_tex.y = 0.0; \n"
+"  rel_tex = rel_tex / wh.xy; \n"
+"  } else if (repeat == RepeatReflect) {\n"
 "  if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
-"  rel_tex.x = 2.0 - (1.0 - 
fract(rel_tex.x))/wh.x;\n"
+"  rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x)) / 
wh.x;\n"
 "  else \n"
-"  rel_tex.x = fract(rel_tex.x)/wh.x;\n"
+"  rel_tex.x = fract(rel_tex.x) / wh.x;\n"
 "  if ((1.0 - mod(abs(floor(rel_tex.y)), 2.0)) < 0.001)\n"
-"  rel_tex.y = 2.0 - (1.0 - 
fract(rel_tex.y))/wh.y;\n"
+"  rel_tex.y = 2.0 - (1.0 - fract(rel_tex.y)) / 
wh.y;\n"
 "  else \n"
-"  rel_tex.y = fract(rel_tex.y)/wh.y;\n"
-"} \n"
-"   return rel_tex; \n"
+"  rel_tex.y = fract(rel_tex.y) / wh.y;\n"
+"  } \n"
+"  return rel_tex; \n"
 "}\n";
 /* The texture and the pixmap size is not match eaxctly, so can't sample 
it directly.
  * rel_sampler will recalculate the texture coords.*/
@@ -105,7 +108,7 @@ glamor_create_composite_fs(struct shader_key *key)
 " vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, 
int set_alpha)\n"
 "{\n"
 "  tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
-"   if (repeat == RepeatFix) {\n"
+"  if (repeat == RepeatFix) {\n"
 "  if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
 "  && tex.y >= 0.0 && tex.y < 1.0))\n"
 "  return vec4(0.0, 0.0, 0.0, set_alpha);\n"
@@ -129,9 +132,9 @@ glamor_create_composite_fs(struct shader_key *key)
 "uniform vec4 source_wh;"
 "vec4 get_source()\n"
 "{\n"
-"   if (source_repeat_mode < RepeatFix)\n"
+"  if (source_repeat_mode < RepeatFix)\n"
 "  return texture2D(source_sampler, source_texture);\n"
-"   else \n"
+ 

[PATCH xserver 13/19] glamor: Simplify the pixmap box looping.

2016-01-27 Thread Eric Anholt
We had a double loop across h and w, and passed the current x and y
out to callers who then used w to multiply/add to an index.  Instead,
just single loop across w * h.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_composite_glyphs.c | 10 ++
 glamor/glamor_copy.c | 15 ---
 glamor/glamor_dash.c |  6 +++---
 glamor/glamor_glyphblt.c | 12 ++--
 glamor/glamor_lines.c|  6 +++---
 glamor/glamor_points.c   |  7 ---
 glamor/glamor_priv.h | 20 +---
 glamor/glamor_rects.c|  7 ---
 glamor/glamor_segs.c |  6 +++---
 glamor/glamor_spans.c| 23 ---
 glamor/glamor_text.c |  8 +---
 glamor/glamor_transfer.c | 16 
 glamor/glamor_transform.c|  7 +++
 glamor/glamor_transform.h|  3 +--
 glamor/glamor_xv.c   |  6 +++---
 15 files changed, 78 insertions(+), 74 deletions(-)

diff --git a/glamor/glamor_composite_glyphs.c b/glamor/glamor_composite_glyphs.c
index 2e4dfe2..f51ff6d 100644
--- a/glamor/glamor_composite_glyphs.c
+++ b/glamor/glamor_composite_glyphs.c
@@ -237,10 +237,10 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr 
dst,
 glamor_screen_private *glamor_priv = 
glamor_get_screen_private(drawable->pScreen);
 PixmapPtr atlas_pixmap = atlas->atlas;
 glamor_pixmap_private *atlas_priv = 
glamor_get_pixmap_private(atlas_pixmap);
-glamor_pixmap_fbo *atlas_fbo = glamor_pixmap_fbo_at(atlas_priv, 0, 0);
+glamor_pixmap_fbo *atlas_fbo = glamor_pixmap_fbo_at(atlas_priv, 0);
 PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
-int box_x, box_y;
+int box_index;
 int off_x, off_y;
 
 glamor_put_vbo_space(drawable->pScreen);
@@ -255,11 +255,13 @@ glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr 
dst,
 
 glUniform1i(prog->atlas_uniform, 1);
 
-glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+glamor_pixmap_loop(pixmap_priv, box_index) {
 BoxPtr box = RegionRects(dst->pCompositeClip);
 int nbox = RegionNumRects(dst->pCompositeClip);
 
-glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, 
FALSE, prog->matrix_uniform, _x, _y);
+glamor_set_destination_drawable(drawable, box_index, TRUE, FALSE,
+prog->matrix_uniform,
+_x, _y);
 
 /* Run over the clip list, drawing the glyphs
  * in each box
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 1adfba0..5fed89f 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -307,7 +307,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
 PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
 glamor_pixmap_private *src_priv = glamor_get_pixmap_private(src_pixmap);
 glamor_pixmap_private *dst_priv = glamor_get_pixmap_private(dst_pixmap);
-int src_box_x, src_box_y, dst_box_x, dst_box_y;
+int src_box_index, dst_box_index;
 int dst_off_x, dst_off_y;
 int src_off_x, src_off_y;
 GLshort *v;
@@ -368,19 +368,20 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
 
 glEnable(GL_SCISSOR_TEST);
 
-glamor_pixmap_loop(src_priv, src_box_x, src_box_y) {
-BoxPtr src_box = glamor_pixmap_box_at(src_priv, src_box_x, src_box_y);
+glamor_pixmap_loop(src_priv, src_box_index) {
+BoxPtr src_box = glamor_pixmap_box_at(src_priv, src_box_index);
 
 args.dx = dx + src_off_x - src_box->x1;
 args.dy = dy + src_off_y - src_box->y1;
-args.src = glamor_pixmap_fbo_at(src_priv, src_box_x, src_box_y);
+args.src = glamor_pixmap_fbo_at(src_priv, src_box_index);
 
 if (!glamor_use_program(dst_pixmap, gc, prog, ))
 goto bail_ctx;
 
-glamor_pixmap_loop(dst_priv, dst_box_x, dst_box_y) {
-glamor_set_destination_drawable(dst, dst_box_x, dst_box_y, FALSE, 
FALSE,
-prog->matrix_uniform, _off_x, 
_off_y);
+glamor_pixmap_loop(dst_priv, dst_box_index) {
+glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
+prog->matrix_uniform,
+_off_x, _off_y);
 
 glScissor(dst_off_x - args.dx,
   dst_off_y - args.dy,
diff --git a/glamor/glamor_dash.c b/glamor/glamor_dash.c
index 101228e..a6a11c1 100644
--- a/glamor/glamor_dash.c
+++ b/glamor/glamor_dash.c
@@ -205,16 +205,16 @@ glamor_dash_loop(DrawablePtr drawable, GCPtr gc, 
glamor_program *prog,
 {
 PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
-int box_x,

[PATCH xserver 07/19] glamor: Drop dead glamor_pict_format_is_compatible().

2016-01-27 Thread Eric Anholt
This hasn't been used since 2f80c7791bb0b11f261cb1e3e0d89163dcdd0342
(GLAMOR_SEPARATE_TEXTURE removal).

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_utils.h | 20 
 1 file changed, 20 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 3adc687..5128a33 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -852,26 +852,6 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
 }
 
 inline static Bool
-glamor_pict_format_is_compatible(PicturePtr picture)
-{
-GLenum iformat;
-PixmapPtr pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
-
-iformat = gl_iformat_for_pixmap(pixmap);
-switch (iformat) {
-case GL_RGBA:
-return (picture->format == PICT_a8r8g8b8 ||
-picture->format == PICT_x8r8g8b8);
-case GL_ALPHA:
-case GL_RED:
-case GL_LUMINANCE:
-return (picture->format == PICT_a8);
-default:
-return FALSE;
-}
-}
-
-inline static Bool
 glamor_is_large_pixmap(PixmapPtr pixmap)
 {
 glamor_pixmap_private *priv;
-- 
2.6.4

___
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 xserver 17/19] glamor: Clarify how the repeat values being passed around work.

2016-01-27 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index a2a7f4a..ed425f5 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -76,11 +76,11 @@ glamor_create_composite_fs(struct shader_key *key)
 "{\n"
 "  vec2 rel_tex; \n"
 "  rel_tex = texture * wh.xy; \n"
-"  if (repeat == RepeatNone)\n"
+"  if (repeat == RepeatFix + RepeatNone)\n"
 "  return rel_tex; \n"
-"  else if (repeat == RepeatNormal) \n"
+"  else if (repeat == RepeatFix + RepeatNormal) \n"
 "  rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
-"  else if (repeat == RepeatPad) { \n"
+"  else if (repeat == RepeatFix + RepeatPad) { \n"
 "  if (rel_tex.x >= 1.0) \n"
 "  rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
 "  else if (rel_tex.x < 0.0) \n"
@@ -90,7 +90,7 @@ glamor_create_composite_fs(struct shader_key *key)
 "  else if (rel_tex.y < 0.0) \n"
 "  rel_tex.y = 0.0; \n"
 "  rel_tex = rel_tex / wh.xy; \n"
-"  } else if (repeat == RepeatReflect) {\n"
+"  } else if (repeat == RepeatFix + RepeatReflect) {\n"
 "  if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
 "  rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x)) / 
wh.x;\n"
 "  else \n"
@@ -107,8 +107,8 @@ glamor_create_composite_fs(struct shader_key *key)
 const char *rel_sampler =
 " vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, 
int set_alpha)\n"
 "{\n"
-"  tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
-"  if (repeat == RepeatFix) {\n"
+"  tex = rel_tex_coord(tex, wh, repeat);\n"
+"  if (repeat == RepeatFix + RepeatNone) {\n"
 "  if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
 "  && tex.y >= 0.0 && tex.y < 1.0))\n"
 "  return vec4(0.0, 0.0, 0.0, set_alpha);\n"
-- 
2.6.4

___
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 xserver 06/19] glamor: Drop comment about dead yInverted flag.

2016-01-27 Thread Eric Anholt
Wait long enough, and you don't need to think about it at all.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_transform.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/glamor/glamor_transform.c b/glamor/glamor_transform.c
index ad06943..564a52d 100644
--- a/glamor/glamor_transform.c
+++ b/glamor/glamor_transform.c
@@ -77,8 +77,6 @@ glamor_set_destination_drawable(DrawablePtr drawable,
  *  gl_x = (render_x + drawable->x + off_x) * 2 / width - 1
  *
  *  gl_x = (render_x) * 2 / width + (drawable->x + off_x) * 2 / width - 1
- *
- * I'll think about yInverted later, when I have some way to test
  */
 
 if (do_drawable_translate) {
-- 
2.6.4

___
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 xserver 05/19] glamor: Rename the *y_inverted helpers to not say "inverted".

2016-01-27 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_utils.h | 30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index 875c935..3adc687 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -36,9 +36,9 @@
 #include "mipict.h"
 
 #define v_from_x_coord_x(_xscale_, _x_)  ( 2 * (_x_) * (_xscale_) - 
1.0)
-#define v_from_x_coord_y_inverted(_yscale_, _y_) (2 * (_y_) * (_yscale_) - 1.0)
+#define v_from_x_coord_y(_yscale_, _y_)  (2 * (_y_) * (_yscale_) - 1.0)
 #define t_from_x_coord_x(_xscale_, _x_)  ((_x_) * (_xscale_))
-#define t_from_x_coord_y_inverted(_yscale_, _y_) ((_y_) * (_yscale_))
+#define t_from_x_coord_y(_yscale_, _y_)  ((_y_) * (_yscale_))
 
 #define pixmap_priv_get_dest_scale(pixmap, _pixmap_priv_, _pxscale_, 
_pyscale_) \
   do {   \
@@ -311,7 +311,7 @@
 texcoord)  \
   do { \
(texcoord)[0] = t_from_x_coord_x(xscale, _tx_); \
-(texcoord)[1] = t_from_x_coord_y_inverted(yscale, _ty_);\
+(texcoord)[1] = t_from_x_coord_y(yscale, _ty_); \
 DEBUGF("normalized point tx %f ty %f \n", (texcoord)[0],   \
(texcoord)[1]); \
   } while(0)
@@ -330,7 +330,7 @@
 tx += fbo_x_off;   \
 ty += fbo_y_off;   \
 (texcoord)[0] = t_from_x_coord_x(xscale, tx);  \
-(texcoord)[1] = t_from_x_coord_y_inverted(yscale, ty); \
+(texcoord)[1] = t_from_x_coord_y(yscale, ty);   \
 DEBUGF("normalized tx %f ty %f \n", (texcoord)[0], (texcoord)[1]); \
   } while(0)
 
@@ -482,8 +482,8 @@
 (vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2); \
 (vertices)[2 * stride] = _t2_; \
 (vertices)[3 * stride] = _t0_; \
-(vertices)[1] = _t1_ = t_from_x_coord_y_inverted(yscale, ty1); \
-(vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y_inverted(yscale, 
ty2); \
+(vertices)[1] = _t1_ = t_from_x_coord_y(yscale, ty1);   \
+(vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y(yscale, ty2);  \
 (vertices)[1 * stride + 1] = _t1_; \
 (vertices)[3 * stride + 1] = _t5_; \
   } while(0)
@@ -562,8 +562,8 @@
(vertices)[2] = t_from_x_coord_x(xscale, x2);   \
(vertices)[6] = (vertices)[2];  \
(vertices)[4] = (vertices)[0];  \
-(vertices)[1] = t_from_x_coord_y_inverted(yscale, y1);  \
-(vertices)[7] = t_from_x_coord_y_inverted(yscale, y2);  \
+(vertices)[1] = t_from_x_coord_y(yscale, y1);   \
+(vertices)[7] = t_from_x_coord_y(yscale, y2);   \
(vertices)[3] = (vertices)[1];  \
(vertices)[5] = (vertices)[7];  \
 } while(0)
@@ -596,7 +596,7 @@
vertices)   \
 do {   \
(vertices)[0] = v_from_x_coord_x(xscale, x);\
-(vertices)[1] = v_from_x_coord_y_inverted(yscale, y);   \
+(vertices)[1] = v_from_x_coord_y(yscale, y);\
 } while(0)
 
 #define glamor_set_normalize_tri_vcoords(xscale, yscale, vtx,  \
@@ -639,11 +639,9 @@
x2 + fbo_x_off);\
 (vertices)[2 * stride] = _t2_; \
 (vertices)[3 * stride] = _t0_; \
-(vertices)[1] = _t1_ = v_from_x_coord_y_inverted(yscale,   \
- y1 + fbo_y_off);   \
+(vertices)[1] = _t1_ = v_from_x_coord_y(yscale, y1 + fbo_y_off);\
 (vertices)[2 * stride + 1] = _t5_ = \
-v_from_x_coord_y_inverted(yscale,   \
-  y2 + fbo_y_off);  \
+v_from_x_coord_y(yscale, y2 + fbo_y_off);   \
 (vertices)[1 * stride + 1] = _t1_; \
 (vertices)[3 * stride + 1] = _t5_; \
   } while(0)
@@ -675,8 +673,8 @@
(vertices)[2] = v_from_x_coord_x(xscale, x2);   \

[PATCH xserver 02/12] glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.

2016-02-01 Thread Eric Anholt
glamor_composite_choose_shader() may upload our scratch pixmaps to get
a Render operation completed.  We don't want to hang onto GL memory
for our scratch pixmaps, since we'll just have to reallocate them at a
new w/h next time around, and the contents will be updated as well.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_fbo.c |  1 +
 glamor/glamor_picture.c | 13 -
 glamor/glamor_render.c  | 11 +--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 5bfffe5..0bfc1dd 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -510,6 +510,7 @@ glamor_pixmap_destroy_fbo(PixmapPtr pixmap)
 for (i = 0; i < priv->block_wcnt * priv->block_hcnt; i++)
 glamor_destroy_fbo(glamor_priv, priv->fbo_array[i]);
 free(priv->fbo_array);
+priv->fbo_array = NULL;
 }
 else {
 fbo = glamor_pixmap_detach_fbo(priv);
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index e91461c..9bb2c74 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -797,9 +797,10 @@ glamor_put_bits(char *dst_bits, int dst_stride, char 
*src_bits,
 }
 }
 
-/* Upload picture to texture.  We may need to flip the y axis or
- * wire alpha to 1. So we may conditional create fbo for the picture.
- * */
+/**
+ * Uploads a picture based on a GLAMOR_MEMORY pixmap to a texture in a
+ * temporary FBO.
+ */
 Bool
 glamor_upload_picture_to_texture(PicturePtr picture)
 {
@@ -810,9 +811,12 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 GLenum format, type;
 int no_alpha, revert, swap_rb;
-glamor_pixmap_private *pixmap_priv;
+glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
 Bool force_clip;
 
+assert(glamor_pixmap_is_memory(pixmap));
+assert(!pixmap_priv->fbo);
+
 if (glamor_get_tex_format_type_from_pixmap(pixmap,
picture->format,
,
@@ -825,7 +829,6 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, 
swap_rb))
 return FALSE;
 
-pixmap_priv = glamor_get_pixmap_private(pixmap);
 force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP;
 
 if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index d47e7d7..65f7059 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1125,7 +1125,7 @@ glamor_composite_with_shader(CARD8 op,
 , , _info,
 _source_format, ca_state)) {
 glamor_fallback("glamor_composite_choose_shader failed\n");
-return ret;
+goto fail;
 }
 if (ca_state == CA_TWO_PASS) {
 if (!glamor_composite_choose_shader(PictOpAdd, source, mask, dest,
@@ -1135,7 +1135,7 @@ glamor_composite_with_shader(CARD8 op,
 _ca, _ca, _info_ca,
 _source_format, ca_state)) {
 glamor_fallback("glamor_composite_choose_shader failed\n");
-return ret;
+goto fail;
 }
 }
 
@@ -1267,6 +1267,13 @@ glamor_composite_with_shader(CARD8 op,
 source->format = saved_source_format;
 
 ret = TRUE;
+
+fail:
+if (mask_pixmap && glamor_pixmap_is_memory(mask_pixmap))
+glamor_pixmap_destroy_fbo(mask_pixmap);
+if (source_pixmap && glamor_pixmap_is_memory(source_pixmap))
+glamor_pixmap_destroy_fbo(source_pixmap);
+
 return ret;
 }
 
-- 
2.7.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

[PATCH xserver 05/12] glamor: Merge the two GL-type-from-pictformat paths.

2016-02-01 Thread Eric Anholt
It clarifies what the difference is between the two paths, and would
potentially encourage us to handle GLES extensions that expose
additional types.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 322 ++--
 1 file changed, 121 insertions(+), 201 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 34cf4a3..e11280f 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -40,275 +40,195 @@
  *
  * Return 0 if find a matched texture type. Otherwise return -1.
  **/
-static int
-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)
+static Bool
+glamor_get_tex_format_type_from_pictformat(ScreenPtr pScreen,
+   PictFormatShort format,
+   GLenum *tex_format,
+   GLenum *tex_type,
+   int *no_alpha,
+   int *revert,
+   int *swap_rb)
 {
 glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
+Bool is_little_endian = IMAGE_BYTE_ORDER == LSBFirst;
+
 *no_alpha = 0;
 *revert = REVERT_NONE;
 *swap_rb = SWAP_NONE_UPLOADING;
+
 switch (format) {
 case PICT_a1:
 *tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
 *revert = REVERT_UPLOADING_A1;
 break;
-case PICT_b8g8r8x8:
-*no_alpha = 1;
-case PICT_b8g8r8a8:
-*tex_format = GL_BGRA;
-*tex_type = GL_UNSIGNED_INT_8_8_8_8;
-break;
-
-case PICT_x8r8g8b8:
-*no_alpha = 1;
-case PICT_a8r8g8b8:
-*tex_format = GL_BGRA;
-*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
-break;
-case PICT_x8b8g8r8:
-*no_alpha = 1;
-case PICT_a8b8g8r8:
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
-break;
-case PICT_x2r10g10b10:
-*no_alpha = 1;
-case PICT_a2r10g10b10:
-*tex_format = GL_BGRA;
-*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
-break;
-case PICT_x2b10g10r10:
-*no_alpha = 1;
-case PICT_a2b10g10r10:
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
-break;
-
-case PICT_r5g6b5:
-*tex_format = GL_RGB;
-*tex_type = GL_UNSIGNED_SHORT_5_6_5;
-break;
-case PICT_b5g6r5:
-*tex_format = GL_RGB;
-*tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
-break;
-case PICT_x1b5g5r5:
-*no_alpha = 1;
-case PICT_a1b5g5r5:
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-break;
-
-case PICT_x1r5g5b5:
-*no_alpha = 1;
-case PICT_a1r5g5b5:
-*tex_format = GL_BGRA;
-*tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-break;
-case PICT_a8:
-*tex_format = glamor_priv->one_channel_format;
-*tex_type = GL_UNSIGNED_BYTE;
-break;
-case PICT_x4r4g4b4:
-*no_alpha = 1;
-case PICT_a4r4g4b4:
-*tex_format = GL_BGRA;
-*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
-break;
-
-case PICT_x4b4g4r4:
-*no_alpha = 1;
-case PICT_a4b4g4r4:
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
-break;
-
-default:
-return -1;
-}
-return 0;
-}
-
-#define IS_LITTLE_ENDIAN  (IMAGE_BYTE_ORDER == LSBFirst)
-
-static int
-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)
-{
-glamor_screen_private *glamor_priv = glamor_get_screen_private(pScreen);
-int need_swap_rb = 0;
 
-*no_alpha = 0;
-*revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;
-
-switch (format) {
 case PICT_b8g8r8x8:
 *no_alpha = 1;
 case PICT_b8g8r8a8:
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_BYTE;
-need_swap_rb = 1;
-*revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+if (glamor_priv->gl_flavor == GL

[PATCH xserver 04/12] glamor: Propagate that is_upload is always true.

2016-02-01 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_core.c|  18 ++
 glamor/glamor_picture.c | 142 ++--
 glamor/glamor_utils.h   |   6 --
 3 files changed, 46 insertions(+), 120 deletions(-)

diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index b9948b5..a8768f4 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -164,8 +164,6 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 "uniform int swap_rb;\n"
 "#define REVERT_NONE   0\n"
 "#define REVERT_NORMAL 1\n"
-"#define SWAP_NONE_DOWNLOADING 0\n"
-"#define SWAP_DOWNLOADING  1\n"
 "#define SWAP_UPLOADING2\n"
 "#define SWAP_NONE_UPLOADING   3\n";
 
@@ -175,18 +173,14 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 "   vec4 color = texture2D(sampler, source_texture);\n"
 "   if (revert == REVERT_NONE) \n"
 "{ \n"
-" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != 
SWAP_NONE_UPLOADING))   \n"
+" if ((swap_rb != SWAP_NONE_UPLOADING))   \n"
 "  gl_FragColor = color.bgra;\n"
 " else \n"
 "  gl_FragColor = color.rgba;\n"
 "} \n"
 "   else \n"
 "{ \n"
-" if (swap_rb == SWAP_DOWNLOADING)   \n"
-"  gl_FragColor = color.argb;\n"
-" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
-"  gl_FragColor = color.abgr;\n"
-" else if (swap_rb == SWAP_UPLOADING)\n"
+" if (swap_rb == SWAP_UPLOADING)\n"
 "  gl_FragColor = color.gbar;\n"
 " else if (swap_rb == SWAP_NONE_UPLOADING)\n"
 "  gl_FragColor = color.abgr;\n"
@@ -199,18 +193,14 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
 "   vec4 color = texture2D(sampler, source_texture);\n"
 "   if (revert == REVERT_NONE) \n"
 "{ \n"
-" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != 
SWAP_NONE_UPLOADING))   \n"
+" if (swap_rb != SWAP_NONE_UPLOADING)   \n"
 "  gl_FragColor = vec4(color.bgr, 1);\n"
 " else \n"
 "  gl_FragColor = vec4(color.rgb, 1);\n"
 "} \n"
 "   else \n"
 "{ \n"
-" if (swap_rb == SWAP_DOWNLOADING)   \n"
-"  gl_FragColor = vec4(1, color.rgb);\n"
-" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
-"  gl_FragColor = vec4(1, color.bgr);\n"
-" else if (swap_rb == SWAP_UPLOADING)\n"
+" if (swap_rb == SWAP_UPLOADING)\n"
 "  gl_FragColor = vec4(color.gba, 1);\n"
 " else if (swap_rb == SWAP_NONE_UPLOADING)\n"
 "  gl_FragColor = vec4(color.abg, 1);\n"
diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index a032ed0..34cf4a3 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -47,17 +47,17 @@ glamor_get_tex_format_type_from_pictformat_gl(ScreenPtr 
pScreen,
   GLenum *tex_type,
   int *no_alpha,
   int *revert,
-  int *swap_rb, int is_upload)
+  int *swap_rb)
 {
 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;
+*swap_rb = SWAP_NONE_UPLOADING;
 switch (format) {
 case PICT_a1:
 *tex_format = glamor_priv->one_channel_format;
 *tex_type = GL_UNSIGNED_BYTE;
-*revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
+*revert = REVERT_UPLOADING_A1;
 break;
 case PICT_b8g8r8x8:
 *no_alpha = 1;
@@ -145,7 +145,7 @@ glamor_get_tex_format_type_from_pictformat_gles2(ScreenPtr 
pScreen,
  GLenum *tex_type,
  int *no_alpha,
  int *revert,
- int *swap_rb, int is_uplo

[PATCH xserver 06/12] glamor: Drop the GLES2 REVERT_UPLOADING_2_10_10_10 paths.

2016-02-01 Thread Eric Anholt
These just smash your 2_10_10_10 data into , despite what the
comments said.  That's not valid rendering, so just ditch this path
and fall back to software.  One might also note in the code being
removed here that the REVERT_UPLOADING_10_10_10_2 path wasn't even
connected.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 57 ++---
 glamor/glamor_utils.h   |  2 --
 2 files changed, 2 insertions(+), 57 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index e11280f..5c6a1a5 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -111,18 +111,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr 
pScreen,
 *tex_format = GL_BGRA;
 *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
 } else {
-/* glReadPixmap doesn't support
- * GL_UNSIGNED_INT_10_10_10_2.  We have to use
- * GL_UNSIGNED_BYTE and do the conversion in a shader
- * later.
- */
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_BYTE;
-if (!is_little_endian)
-*revert = REVERT_UPLOADING_10_10_10_2;
-else
-*revert = REVERT_UPLOADING_2_10_10_10;
-*swap_rb = SWAP_UPLOADING;
+return FALSE;
 }
 break;
 
@@ -133,13 +122,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr 
pScreen,
 *tex_format = GL_RGBA;
 *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
 } else {
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_BYTE;
-if (!is_little_endian)
-*revert = REVERT_UPLOADING_10_10_10_2;
-else
-*revert = REVERT_UPLOADING_2_10_10_10;
-break;
+return FALSE;
 }
 break;
 
@@ -300,37 +283,6 @@ _glamor_color_convert_a1_a8(void *src_bits, void 
*dst_bits, int w, int h,
(*dst) = ((a) << (a_shift)) | ((r) << (b_shift)) | ((g) 
<< (g_shift)) | ((b) << (r_shift)); \
} while (0)
 
-static void *
-_glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h,
- int stride, int no_alpha,
- int swap_rb)
-{
-int x, y;
-unsigned int *words, *saved_words, *source_words;
-int swap = swap_rb != SWAP_NONE_UPLOADING;
-
-source_words = src_bits;
-words = dst_bits;
-saved_words = words;
-
-for (y = 0; y < h; y++) {
-DEBUGF("Line %d :  ", y);
-for (x = 0; x < w; x++) {
-unsigned int pixel = source_words[x];
-
-GLAMOR_DO_CONVERT(pixel, [x], no_alpha, swap,
-  30, 2, 20, 10, 10, 10, 0, 10,
-  24, 8, 16, 8, 8, 8, 0, 8);
-DEBUGF("%x:%x ", pixel, words[x]);
-}
-DEBUGF("\n");
-words += stride / sizeof(*words);
-source_words += stride / sizeof(*words);
-}
-DEBUGF("\n");
-return saved_words;
-
-}
 
 static void *
 _glamor_color_revert_x1b5g5r5(void *src_bits, void *dst_bits, int w, int h,
@@ -371,7 +323,6 @@ _glamor_color_revert_x1b5g5r5(void *src_bits, void 
*dst_bits, int w, int h,
  * If it is set, then we need to wire the alpha value to 1.
  * @revert:
REVERT_UPLOADING_A1 : convert an A1 buffer to an Alpha8 
buffer
-   REVERT_UPLOADING_2_10_10_10 : convert X2B10G10R10 to R10G10B10X2
REVERT_UPLOADING_1_5_5_5: convert X1R5G5B5 to B5G5R5X1
@swap_rb: if we have the swap_rb set, then we need to swap the R and B's 
position.
  *
@@ -384,10 +335,6 @@ glamor_color_convert_to_bits(void *src_bits, void 
*dst_bits, int w, int h,
 if (revert == REVERT_UPLOADING_A1) {
 return _glamor_color_convert_a1_a8(src_bits, dst_bits, w, h, stride);
 }
-else if (revert == REVERT_UPLOADING_2_10_10_10) {
-return _glamor_color_revert_x2b10g10r10(src_bits, dst_bits, w, h,
-stride, no_alpha, swap_rb);
-}
 else if (revert == REVERT_UPLOADING_1_5_5_5) {
 return _glamor_color_revert_x1b5g5r5(src_bits, dst_bits, w, h, stride,
  no_alpha, swap_rb);
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index e23de86..fc33995 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -768,9 +768,7 @@ format_for_pixmap(PixmapPtr pixmap)
 #define REVERT_NONE0
 #define REVERT_NORMAL  1
 #define REVERT_UPLOADING_A13
-#define REVERT_UPLOADING_2_10_10_105
 #define REVERT_UPLOADING_1_5_5_5   8
-#define REVERT_UPLOADING_10_10_10_210
 
 #define SWAP_UPLOADING 2
 #define SWAP_NONE_UPLOADING3
-- 
2.7.0


[PATCH xserver 03/12] glamor: Drop dead fbo handling from GLAMORY_MEMORY pict uploads.

2016-02-01 Thread Eric Anholt
The previous commit asserts that we don't have one.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 25 ++---
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 9bb2c74..a032ed0 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -734,27 +734,10 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum 
format, int no_alpha,
  int revert, int swap_rb)
 {
 int flag = 0;
-glamor_pixmap_private *pixmap_priv;
-glamor_screen_private *glamor_priv;
-glamor_pixmap_fbo *fbo;
+glamor_screen_private *glamor_priv =
+glamor_get_screen_private(pixmap->drawable.pScreen);
 GLenum iformat;
 
-pixmap_priv = glamor_get_pixmap_private(pixmap);
-glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
-
-if (pixmap_priv->gl_fbo != GLAMOR_FBO_UNATTACHED)
-return 0;
-
-if (pixmap_priv->fbo
-&& (pixmap_priv->fbo->width < pixmap->drawable.width
-|| pixmap_priv->fbo->height < pixmap->drawable.height)) {
-fbo = glamor_pixmap_detach_fbo(pixmap_priv);
-glamor_destroy_fbo(glamor_priv, fbo);
-}
-
-if (pixmap_priv->fbo && pixmap_priv->fbo->fb)
-return 0;
-
 if (!(no_alpha || (revert == REVERT_NORMAL)
   || (swap_rb != SWAP_NONE_UPLOADING))) {
 /* We don't need a fbo, a simple texture uploading should work. */
@@ -762,10 +745,6 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum 
format, int no_alpha,
 flag = GLAMOR_CREATE_FBO_NO_FBO;
 }
 
-if ((flag == GLAMOR_CREATE_FBO_NO_FBO
- && pixmap_priv->fbo && pixmap_priv->fbo->tex))
-return 0;
-
 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
 iformat = gl_iformat_for_pixmap(pixmap);
 else
-- 
2.7.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

[PATCH xserver 00/12] glamor_picture.c total rewrite

2016-02-01 Thread Eric Anholt
I started incrementally cleaning up glamor_picture.c after being
surprised by its behavior during the last series, and ended up with a
total rewrite.  There will be some small losses in acceleration paths
for GLES2, but since GLES2 hasn't worked in several releases (and a
bunch of glamor_picture.c on GLES2 started out broken), I don't think
that's a big deal.  We could get back to acceleration for those paths
using the converted_format output, if someone cared.

I tested this with a full xts-render run, the new rendercheck/shmblend
test I wrote, and I also forced the upload paths to use the GLES2
cases for a rendercheck/shmblend to make sure I had their swizzles
right (I didn't).

Eric Anholt (12):
  glamor: Simplify temporary picture uploading call stack.
  glamor: Make sure that GLAMOR_MEMORY pixmaps don't retain an FBO.
  glamor: Drop dead fbo handling from GLAMORY_MEMORY pict uploads.
  glamor: Propagate that is_upload is always true.
  glamor: Merge the two GL-type-from-pictformat paths.
  glamor: Drop the GLES2 REVERT_UPLOADING_2_10_10_10 paths.
  glamor: Drop the REVERT_UPLOADING_1_5_5_5 path.
  glamor: Generalize the a1-to-a8 conversion path.
  glamor: Drop unused PBO code in temporary picture uploading.
  glamor: Drop dead large-pixmap handling code in temp picture uploads.
  glamor: Replace "finish access" shader with texture swizzling.
  ephyr: Fix redisplay with glamor on GLES.

 glamor/glamor.c|9 +-
 glamor/glamor_core.c   |  168 --
 glamor/glamor_fbo.c|   12 +
 glamor/glamor_picture.c| 1003 
 glamor/glamor_priv.h   |   27 +-
 glamor/glamor_render.c |   38 +-
 glamor/glamor_utils.h  |   11 +-
 hw/kdrive/ephyr/ephyr_glamor_glx.c |4 +-
 8 files changed, 267 insertions(+), 1005 deletions(-)

-- 
2.7.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

[PATCH xserver 10/12] glamor: Drop dead large-pixmap handling code in temp picture uploads.

2016-02-01 Thread Eric Anholt
The glamor_pixmap_ensure_fbo() in glamor_pixmap_upload_prepare() will
always fail on a large pixmap, so we can just be explicit about
bailing out here and then dump the rest of this garbage.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 127 ++--
 glamor/glamor_priv.h|   1 -
 2 files changed, 16 insertions(+), 112 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index e0458a6..42fee1b 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -315,11 +315,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 /* Try fast path firstly, upload the pixmap to the texture attached
  * to the fbo directly. */
 if (no_alpha == 0
-&& revert == REVERT_NONE && swap_rb == SWAP_NONE_UPLOADING
-#ifdef WALKAROUND_LARGE_TEXTURE_MAP
-&& glamor_pixmap_priv_is_small(pixmap_priv)
-#endif
-) {
+&& revert == REVERT_NONE && swap_rb == SWAP_NONE_UPLOADING) {
 int fbo_x_off, fbo_y_off;
 
 assert(pixmap_priv->fbo->tex);
@@ -429,26 +425,6 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum 
format, int no_alpha,
 return 0;
 }
 
-/*
- * upload sub region to a large region.
- * */
-static void
-glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
-int src_stride, int bpp, int x, int y, int w, int h)
-{
-int j;
-int byte_per_pixel;
-
-byte_per_pixel = bpp / 8;
-src_bits += y * src_stride + (x * byte_per_pixel);
-
-for (j = y; j < y + h; j++) {
-memcpy(dst_bits, src_bits, w * byte_per_pixel);
-src_bits += src_stride;
-dst_bits += dst_stride;
-}
-}
-
 /**
  * Uploads a picture based on a GLAMOR_MEMORY pixmap to a texture in a
  * temporary FBO.
@@ -464,11 +440,19 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 GLenum format, type;
 int no_alpha, revert, swap_rb;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
-Bool force_clip;
 
 assert(glamor_pixmap_is_memory(pixmap));
 assert(!pixmap_priv->fbo);
 
+/* No handling of large pixmap pictures here (would need to make
+ * an FBO array and split the uploads across it).
+ */
+if (!glamor_check_fbo_size(glamor_priv,
+   pixmap->drawable.width,
+   pixmap->drawable.height)) {
+return FALSE;
+}
+
 if (!glamor_get_tex_format_type_from_pictformat(screen,
 picture->format,
 ,
@@ -481,89 +465,10 @@ glamor_upload_picture_to_texture(PicturePtr picture)
 if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, 
swap_rb))
 return FALSE;
 
-force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP;
-
-if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {
-RegionRec region;
-BoxRec box;
-int n_region;
-glamor_pixmap_clipped_regions *clipped_regions;
-void *sub_bits;
-int i, j;
-
-sub_bits = xallocarray(pixmap->drawable.height, stride);
-if (sub_bits == NULL)
-return FALSE;
-box.x1 = 0;
-box.y1 = 0;
-box.x2 = pixmap->drawable.width;
-box.y2 = pixmap->drawable.height;
-RegionInitBoxes(, , 1);
-if (!force_clip)
-clipped_regions =
-glamor_compute_clipped_regions(pixmap, , _region,
-   0, 0, 0);
-else
-clipped_regions =
-glamor_compute_clipped_regions_ext(pixmap, ,
-   _region,
-   pixmap_priv->block_w,
-   pixmap_priv->block_h,
-   0,
-   0);
-DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap);
-for (i = 0; i < n_region; i++) {
-BoxPtr boxes;
-int nbox;
-int temp_stride;
-void *temp_bits;
-
-glamor_set_pixmap_fbo_current(pixmap_priv, 
clipped_regions[i].block_idx);
-
-boxes = RegionRects(clipped_regions[i].region);
-nbox = RegionNumRects(clipped_regions[i].region);
-DEBUGF("split to %d boxes\n", nbox);
-for (j = 0; j < nbox; j++) {
-temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
-pixmap->drawable.depth);
-
-if (boxes[j].x1 == 0 && temp_stride == stride) {
-temp_bits = (char *) bits + boxes[j].y1 * stride;
- 

[PATCH xserver 09/12] glamor: Drop unused PBO code in temporary picture uploading.

2016-02-01 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 30 +++---
 1 file changed, 7 insertions(+), 23 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index e0f5828..e0458a6 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -246,7 +246,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
   GLenum format,
   GLenum type,
   int x, int y, int w, int h,
-  void *bits, int pbo)
+  void *bits)
 {
 glamor_screen_private *glamor_priv =
 glamor_get_screen_private(pixmap->drawable.pScreen);
@@ -269,11 +269,6 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
 
-assert(pbo || bits != 0);
-if (bits == NULL) {
-glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
-glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
-}
 glamor_priv->suppress_gl_out_of_memory_logging = true;
 if (non_sub)
 glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0, format, type, bits);
@@ -288,9 +283,6 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, 
unsigned int *tex,
 return FALSE;
 }
 
-if (bits == NULL)
-glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
-
 return TRUE;
 }
 
@@ -298,7 +290,7 @@ static Bool
 _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
   GLenum type, int no_alpha, int revert,
   int swap_rb, int x, int y, int w, int h,
-  int stride, void *bits, int pbo)
+  int stride, void *bits)
 {
 ScreenPtr screen = pixmap->drawable.pScreen;
 glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
@@ -308,9 +300,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 GLuint tex = 0;
 pixman_image_t *converted_image = NULL;
 
-if (bits == NULL)
-goto ready_to_upload;
-
 if (revert == REVERT_UPLOADING_A1) {
 converted_image = glamor_get_converted_image(PICT_a8,
  PICT_a1,
@@ -323,8 +312,6 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 bits = pixman_image_get_data(converted_image);
 }
 
- ready_to_upload:
-
 /* Try fast path firstly, upload the pixmap to the texture attached
  * to the fbo directly. */
 if (no_alpha == 0
@@ -345,7 +332,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
format, type,
x + fbo_x_off, y + fbo_y_off,
w, h,
-   bits, pbo)) {
+   bits)) {
 if (converted_image)
 pixman_image_unref(bits);
 return FALSE;
@@ -371,8 +358,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, 
GLenum format,
 glamor_make_current(glamor_priv);
 
 if (!__glamor_upload_pixmap_to_texture(pixmap, ,
-   format, type, 0, 0, w, h, bits,
-   pbo)) {
+   format, type, 0, 0, w, h, 
bits)) {
 if (converted_image)
 pixman_image_unref(bits);
 return FALSE;
@@ -556,11 +542,10 @@ glamor_upload_picture_to_texture(PicturePtr picture)
boxes[j].x1, boxes[j].y1,
boxes[j].x2 - boxes[j].x1,
boxes[j].y2 - boxes[j].y1, temp_stride);
-if (_glamor_upload_bits_to_pixmap_texture
+if (!_glamor_upload_bits_to_pixmap_texture
 (pixmap, format, type, no_alpha, revert, swap_rb,
  boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1,
- boxes[j].y2 - boxes[j].y1, temp_stride, temp_bits,
- 0) == FALSE) {
+ boxes[j].y2 - boxes[j].y1, temp_stride, temp_bits)) {
 RegionUninit();
 free(sub_bits);
 assert(0);
@@ -580,6 +565,5 @@ glamor_upload_picture_to_texture(PicturePtr picture)
  0, 0,
  pixmap->drawable.width,
  pixmap->drawable.height,
- stride, bits,
- 

[PATCH xserver 07/12] glamor: Drop the REVERT_UPLOADING_1_5_5_5 path.

2016-02-01 Thread Eric Anholt
There was only a pretty special case that could have even worked --
you've got a GLES2 renderer, you've got a SHM pixmap, it's 1555 (not
the usual 565 for 16-bit), and you're little endian (BE was broken,
since GL's 5_5_5_1 picks the 1 bit from the lowest bit of the short,
and on BE we weren't doing the conversion path that swaps around the
channels).  This is just not worth the complexity.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 123 ++--
 glamor/glamor_utils.h   |   1 -
 2 files changed, 5 insertions(+), 119 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index 5c6a1a5..63d4365 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -151,11 +151,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr 
pScreen,
 if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
 *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 } else {
-*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
-if (is_little_endian)
-*revert = REVERT_UPLOADING_1_5_5_5;
-else
-*revert = REVERT_NONE;
+return FALSE;
 }
 break;
 
@@ -166,13 +162,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr 
pScreen,
 *tex_format = GL_BGRA;
 *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
 } else {
-*tex_format = GL_RGBA;
-*tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
-if (is_little_endian)
-*revert = REVERT_UPLOADING_1_5_5_5;
-else
-*revert = REVERT_NONE;
-*swap_rb = SWAP_UPLOADING;
+return FALSE;
 }
 break;
 
@@ -215,8 +205,7 @@ glamor_get_tex_format_type_from_pictformat(ScreenPtr 
pScreen,
 }
 
 static void *
-_glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h,
-int stride)
+glamor_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int stride)
 {
 PictFormatShort dst_format = PICT_a8, src_format = PICT_a1;
 pixman_image_t *dst_image;
@@ -244,107 +233,6 @@ _glamor_color_convert_a1_a8(void *src_bits, void 
*dst_bits, int w, int h,
 return dst_bits;
 }
 
-#define ADJUST_BITS(d, src_bits, dst_bits) (((dst_bits) == (src_bits)) ? 
(d) : \
-   (((dst_bits) > 
(src_bits)) ?\
- (((d) << ((dst_bits) 
- (src_bits)))   \
-  + (( 1 << 
((dst_bits) - (src_bits))) >> 1))  \
-   :  ((d) >> 
((src_bits) - (dst_bits)
-
-#define GLAMOR_DO_CONVERT(src, dst, no_alpha, swap,\
- a_shift_src, a_bits_src,  \
- b_shift_src, b_bits_src,  \
- g_shift_src, g_bits_src,  \
- r_shift_src, r_bits_src,  \
- a_shift, a_bits,  \
- b_shift, b_bits,  \
- g_shift, g_bits,  \
- r_shift, r_bits)  \
-   do {\
-   typeof(src) a,b,g,r;\
-   typeof(src) a_mask_src, b_mask_src, g_mask_src, r_mask_src;\
-   a_mask_src = (((1 << (a_bits_src)) - 1) << a_shift_src);\
-   b_mask_src = (((1 << (b_bits_src)) - 1) << b_shift_src);\
-   g_mask_src = (((1 << (g_bits_src)) - 1) << g_shift_src);\
-   r_mask_src = (((1 << (r_bits_src)) - 1) << r_shift_src);\
-   if (no_alpha)   \
-   a = (a_mask_src) >> (a_shift_src);  
\
-   else\
-   a = ((src) & (a_mask_src)) >> (a_shift_src);\
-   b = ((src) & (b_mask_src)) >> (b_shift_src);\
-   g = ((src) & (g_mask_src)) >> (g_shift_src);\
-   r = ((src) & (r_mask_src)) >> (r_shift_src);\
-   a = ADJUST_BITS(a, a_bits_src, a_bits); \
-   b = ADJUST_BITS(b, b_bits_src, b_bits); \
-   g = ADJUST_BITS(g, g_bits_src, g_bits); \
-   r = ADJUST_BITS(r, r_bits_src, r_bits); \
-   if (swap == 0)   

[PATCH xserver 12/12] ephyr: Fix redisplay with glamor on GLES.

2016-02-01 Thread Eric Anholt
glamor_transfer.c is still totally broken, though.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 hw/kdrive/ephyr/ephyr_glamor_glx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_glx.c 
b/hw/kdrive/ephyr/ephyr_glamor_glx.c
index 636150d..2f21914 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -225,8 +225,10 @@ ephyr_glamor_damage_redisplay(struct ephyr_glamor *glamor,
 if (glamor->vao) {
 glGetIntegerv(GL_VERTEX_ARRAY_BINDING, _vao);
 glBindVertexArray(glamor->vao);
-} else
+} else {
+glBindBuffer(GL_ARRAY_BUFFER, glamor->vbo);
 ephyr_glamor_set_vertices(glamor);
+}
 
 glBindFramebuffer(GL_FRAMEBUFFER, 0);
 glUseProgram(glamor->texture_shader);
-- 
2.7.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

[PATCH xserver 01/12] glamor: Simplify temporary picture uploading call stack.

2016-02-01 Thread Eric Anholt
glamor_upload_sub_pixmap_to_texture() only had the one caller, so we
can merge it in, fix its silly return value, and propagate a bunch of
constants.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_picture.c | 68 ++---
 glamor/glamor_priv.h| 18 +
 glamor/glamor_render.c  | 27 
 3 files changed, 37 insertions(+), 76 deletions(-)

diff --git a/glamor/glamor_picture.c b/glamor/glamor_picture.c
index b069ce5..e91461c 100644
--- a/glamor/glamor_picture.c
+++ b/glamor/glamor_picture.c
@@ -797,11 +797,15 @@ glamor_put_bits(char *dst_bits, int dst_stride, char 
*src_bits,
 }
 }
 
-static Bool
-glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
-int h, int stride, void *bits, int pbo,
-PictFormatShort pict_format)
+/* Upload picture to texture.  We may need to flip the y axis or
+ * wire alpha to 1. So we may conditional create fbo for the picture.
+ * */
+Bool
+glamor_upload_picture_to_texture(PicturePtr picture)
 {
+PixmapPtr pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+void *bits = pixmap->devPrivate.ptr;
+int stride = pixmap->devKind;
 ScreenPtr screen = pixmap->drawable.pScreen;
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 GLenum format, type;
@@ -810,7 +814,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 Bool force_clip;
 
 if (glamor_get_tex_format_type_from_pixmap(pixmap,
-   pict_format,
+   picture->format,
,
,
_alpha,
@@ -822,8 +826,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 return FALSE;
 
 pixmap_priv = glamor_get_pixmap_private(pixmap);
-force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP
-&& !glamor_check_fbo_size(glamor_priv, w, h);
+force_clip = glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP;
 
 if (glamor_pixmap_priv_is_large(pixmap_priv) || force_clip) {
 RegionRec region;
@@ -833,13 +836,13 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 void *sub_bits;
 int i, j;
 
-sub_bits = xallocarray(h, stride);
+sub_bits = xallocarray(pixmap->drawable.height, stride);
 if (sub_bits == NULL)
 return FALSE;
-box.x1 = x;
-box.y1 = y;
-box.x2 = x + w;
-box.y2 = y + h;
+box.x1 = 0;
+box.y1 = 0;
+box.x2 = pixmap->drawable.width;
+box.y2 = pixmap->drawable.height;
 RegionInitBoxes(, , 1);
 if (!force_clip)
 clipped_regions =
@@ -860,8 +863,6 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 int temp_stride;
 void *temp_bits;
 
-assert(pbo == 0);
-
 glamor_set_pixmap_fbo_current(pixmap_priv, 
clipped_regions[i].block_idx);
 
 boxes = RegionRects(clipped_regions[i].region);
@@ -871,26 +872,26 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int 
x, int y, int w,
 temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
 pixmap->drawable.depth);
 
-if (boxes[j].x1 == x && temp_stride == stride) {
-temp_bits = (char *) bits + (boxes[j].y1 - y) * stride;
+if (boxes[j].x1 == 0 && temp_stride == stride) {
+temp_bits = (char *) bits + boxes[j].y1 * stride;
 }
 else {
 temp_bits = sub_bits;
 glamor_put_bits(temp_bits, temp_stride, bits, stride,
 pixmap->drawable.bitsPerPixel,
-boxes[j].x1 - x, boxes[j].y1 - y,
+boxes[j].x1, boxes[j].y1,
 boxes[j].x2 - boxes[j].x1,
 boxes[j].y2 - boxes[j].y1);
 }
 DEBUGF("upload x %d y %d w %d h %d temp stride %d \n",
-   boxes[j].x1 - x, boxes[j].y1 - y,
+   boxes[j].x1, boxes[j].y1,
boxes[j].x2 - boxes[j].x1,
boxes[j].y2 - boxes[j].y1, temp_stride);
 if (_glamor_upload_bits_to_pixmap_texture
 (pixmap, format, type, no_alpha, revert, swap_rb,
  boxes[j].x1, boxes[j].y1, boxes[j].x2 - boxes[j].x1,
  boxes[j].y2 - boxes[j].y1, temp_stride, temp_bi

[PATCH xserver 11/12] glamor: Replace "finish access" shader with texture swizzling.

2016-02-01 Thread Eric Anholt
For pictures without alpha, and for most other formats for GLES2, we
would make a temporary FBO, make another temporary texture, upload our
GLAMORY_MEMORY pixmap to the texture, then run the "finish access"
shader across it to swizzle its values around into the temporary FBO
(which we would use for a single Render operation and then throw
away).

We can simplify everything by using GL_ARB_texture_swizzle (or its
GLES3 counterpart).  It's just not worth the complexity to try to
improve the performance of this already low-performance path (SHM
pixmaps + Render) on GLES2.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor.c |   9 +-
 glamor/glamor_core.c| 158 
 glamor/glamor_fbo.c |  11 ++
 glamor/glamor_picture.c | 381 ++--
 glamor/glamor_priv.h|   8 +-
 5 files changed, 160 insertions(+), 407 deletions(-)

diff --git a/glamor/glamor.c b/glamor/glamor.c
index e9c1d9e..efe5953 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -605,9 +605,15 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
 
+glamor_priv->has_texture_swizzle =
+(epoxy_has_gl_extension("GL_ARB_texture_swizzle") ||
+ (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP && gl_version >= 30));
+
 glamor_priv->one_channel_format = GL_ALPHA;
-if (epoxy_has_gl_extension("GL_ARB_texture_rg") && 
epoxy_has_gl_extension("GL_ARB_texture_swizzle"))
+if (epoxy_has_gl_extension("GL_ARB_texture_rg") &&
+glamor_priv->has_texture_swizzle) {
 glamor_priv->one_channel_format = GL_RED;
+}
 
 glamor_set_debug_level(_debug_level);
 
@@ -668,7 +674,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 
 glamor_init_vbo(screen);
 glamor_init_pixmap_fbo(screen);
-glamor_init_finish_access_shaders(screen);
 
 #ifdef GLAMOR_GRADIENT_SHADER
 glamor_init_gradient_shader(screen);
diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c
index a8768f4..7b2b396 100644
--- a/glamor/glamor_core.c
+++ b/glamor/glamor_core.c
@@ -113,164 +113,6 @@ glamor_link_glsl_prog(ScreenPtr screen, GLint prog, const 
char *format, ...)
 }
 }
 
-/*
- *  When downloading a unsupported color format to CPU memory,
-we need to shuffle the color elements and then use a supported
-color format to read it back to CPU memory.
-
-For an example, the picture's format is PICT_b8g8r8a8,
-Then the expecting color layout is as below (little endian):
-0  1   2   3   : address
-a  r   g   b
-
-Now the in GLES2 the supported color format is GL_RGBA, type is
-GL_UNSIGNED_TYPE, then we need to shuffle the fragment
-color as :
-   frag_color = sample(texture).argb;
-before we use glReadPixel to get it back.
-
-For the uploading process, the shuffle is a revert shuffle.
-We still use GL_RGBA, GL_UNSIGNED_BYTE to upload the color
-to a texture, then let's see
-0  1   2   3   : address
-a  r   g   b   : correct colors
-R  G   B   A   : GL_RGBA with GL_UNSIGNED_BYTE
-
-Now we need to shuffle again, the mapping rule is
-r = G, g = B, b = A, a = R. Then the uploading shuffle is as
-below:
-   frag_color = sample(texture).gbar;
-*/
-
-void
-glamor_init_finish_access_shaders(ScreenPtr screen)
-{
-glamor_screen_private *glamor_priv;
-const char *vs_source =
-"attribute vec4 v_position;\n"
-"attribute vec4 v_texcoord0;\n"
-"varying vec2 source_texture;\n"
-"void main()\n"
-"{\n"
-"  gl_Position = v_position;\n"
-"  source_texture = v_texcoord0.xy;\n"
-"}\n";
-
-const char *common_source =
-GLAMOR_DEFAULT_PRECISION
-"varying vec2 source_texture;\n"
-"uniform sampler2D sampler;\n"
-"uniform int revert;\n"
-"uniform int swap_rb;\n"
-"#define REVERT_NONE   0\n"
-"#define REVERT_NORMAL 1\n"
-"#define SWAP_UPLOADING2\n"
-"#define SWAP_NONE_UPLOADING   3\n";
-
-const char *fs_source =
-"void main()\n"
-"{\n"
-"   vec4 color = texture2D(sampler, source_texture);\n"
-"   if (revert == REVERT_NONE) \n"
-"{ \n"
-" if ((swap_rb != SWAP_NONE_UPLOADING))   \n"
-"  gl_FragColor = color.bgra;\n"
-" else \n"
-"  gl_FragColor = color.rgba;\n"
-"} \n"
-"   else \n"
- 

Re: [PATCH rendercheck 1/5] Start using stdbool.h instead of Xlib or custom bools.

2016-02-01 Thread Eric Anholt
Alex Deucher <alexdeuc...@gmail.com> writes:

> On Mon, Feb 1, 2016 at 4:48 PM, Eric Anholt <e...@anholt.net> wrote:
>> I have a hard time typing anything else at this point.
>>
>> Signed-off-by: Eric Anholt <e...@anholt.net>
>> ---
>>  main.c   | 21 ++
>>  ops.c|  2 +-
>>  rendercheck.h| 58 +++-
>>  t_blend.c|  8 +++
>>  t_bug7366.c  | 32 +--
>>  t_composite.c| 12 +-
>>  t_dstcoords.c|  6 ++---
>>  t_fill.c |  6 ++---
>>  t_gradient.c | 32 +--
>>  t_gtk_argb_xbgr.c|  8 +++
>>  t_libreoffice_xrgb.c | 10 -
>>  t_repeat.c   | 22 +--
>>  t_srccoords.c| 14 ++--
>>  t_triangles.c| 24 ++--
>>  t_tsrccoords.c   | 12 +-
>>  t_tsrccoords2.c  | 14 ++--
>>  tests.c  | 62 
>> ++--
>>  17 files changed, 171 insertions(+), 172 deletions(-)
>>
>> diff --git a/main.c b/main.c
>> index a7035b9..b5d67cc 100644
>> --- a/main.c
>> +++ b/main.c
>> @@ -27,7 +27,7 @@
>>  #include 
>>  #include 
>>
>> -Bool is_verbose = FALSE, minimalrendering = FALSE;
>> +bool is_verbose = false, minimalrendering = false;
>>  int enabled_tests = ~0;/* Enable all tests by default */
>>
>>  int format_whitelist_len = 0;
>> @@ -163,7 +163,8 @@ int main(int argc, char **argv)
>> Display *dpy;
>> XEvent ev;
>> int i, o, maj, min;
>> -   static Bool is_sync = FALSE, print_version = FALSE;
>> +   static int is_sync = false, print_version = false;
>
> Did you mean bool here rather than int?
>
> Alex

No, because it's an argument to getopt_long.


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

[PATCH rendercheck 2/5] Save the list of active formats in a global for use by tests.

2016-02-01 Thread Eric Anholt
I'd like to move driving of tests out of tests.c and into t_*.c, and
part of that will be allowing tests to use the formats list.  While I'm
at it, save the name of the format in the array so it doesn't need to be
recomputed.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 rendercheck.h |  8 
 tests.c   | 51 ++-
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/rendercheck.h b/rendercheck.h
index 55ffcff..2195cb4 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -80,6 +80,14 @@ struct op_info {
 #define TEST_GTK_ARGB_XBGR 0x2000
 #define TEST_LIBREOFFICE_XRGB  0x4000
 
+struct render_format {
+   XRenderPictFormat *format;
+   char *name;
+};
+
+extern struct render_format *formats;
+extern int nformats;
+
 extern int pixmap_move_iter;
 extern int win_width, win_height;
 extern struct op_info ops[];
diff --git a/tests.c b/tests.c
index 62fa34b..456e778 100644
--- a/tests.c
+++ b/tests.c
@@ -27,8 +27,8 @@
 
 #include "rendercheck.h"
 
-static XRenderPictFormat **format_list;
-static int nformats;
+struct render_format *formats;
+int nformats;
 static int argb32index;
 
 /* Note: changing the order of these colors may disrupt tests that depend on
@@ -240,36 +240,35 @@ create_formats_list(Display *dpy)
 {
 int i;
 int nformats_allocated = 5;
-XRenderPictFormat templ;
+XRenderPictFormat templ, *format;
 
 memset(, 0, sizeof(templ));
 templ.type = PictTypeDirect;
 
-format_list = malloc(sizeof(XRenderPictFormat *) * nformats_allocated);
-if (format_list == NULL)
+formats = malloc(sizeof(*formats) * nformats_allocated);
+if (formats == NULL)
errx(1, "malloc error");
 nformats = 0;
 
 argb32index = -1;
 for (i = 0; ; i++) {
-   char *name;
int alphabits, redbits;
 
if (nformats + 1 == nformats_allocated) {
nformats_allocated *= 2;
-   format_list = realloc(format_list, sizeof(XRenderPictFormat *) *
-   nformats_allocated);
-   if (format_list == NULL)
+   formats = realloc(formats, sizeof(*formats) * nformats_allocated);
+   if (formats == NULL)
errx(1, "realloc error");
}
 
-   format_list[nformats] = XRenderFindFormat(dpy, PictFormatType, ,
-   i);
-   if (format_list[nformats] == NULL)
-   break;
+   format = XRenderFindFormat(dpy, PictFormatType, , i);
+   if (!format)
+   break;
 
-   alphabits = bit_count(format_list[nformats]->direct.alphaMask);
-   redbits = bit_count(format_list[nformats]->direct.redMask);
+   formats[nformats].format = format;
+
+   alphabits = bit_count(format->direct.alphaMask);
+   redbits = bit_count(format->direct.redMask);
 
/* Our testing code isn't all that hot, so don't bother trying at
 * the low depths yet.
@@ -280,31 +279,33 @@ create_formats_list(Display *dpy)
continue;
}
 
-   describe_format(, NULL, format_list[nformats]);
+   describe_format([nformats].name, NULL, format);
 
if (format_whitelist_len != 0) {
bool ok = false;
int j;
 
for (j = 0; j < format_whitelist_len; j++) {
-   if (strcmp(format_whitelist[j], name) == 0) {
+   if (strcmp(format_whitelist[j], formats[nformats].name) == 0) {
ok = true;
break;
}
}
if (!ok) {
-   printf("Ignoring server-supported format: %s\n", name);
+   printf("Ignoring server-supported format: %s\n",
+  formats[nformats].name);
+   free(formats[nformats].name);
+   formats[nformats].name = NULL;
continue;
}
}
 
-   if (format_list[nformats] == XRenderFindStandardFormat(dpy,
-   PictStandardARGB32))
+   if (format == XRenderFindStandardFormat(dpy, PictStandardARGB32))
{
argb32index = nformats;
}
 
-   printf("Found server-supported format: %s\n", name);
+   printf("Found server-supported format: %s\n", formats[nformats].name);
 
nformats++;
 }
@@ -336,7 +337,7 @@ do_tests(Display *dpy, picture_info *win)
errx(1, "malloc error");
 
for (i = 0; i < num_dests; i++) {
-   dests[i].format = format_list[i];
+   dests[i].format = formats[i].format;
dests[i].d = XCreatePixmap(dpy, DefaultRootWindow(dpy),
win_width, win_height, dests[i].format->depth);
dests[i].pict = XRenderCreatePicture(dpy, dests[i].d,
@@ -355,7 +356,7 @@ do_tests(Display *dpy, picture_info *win)
color4d *c = [i / nformats];
 
/* The standard PictFormat numbers go from 0 to 4 */

[PATCH rendercheck 4/5] shmblend: New test for XRenderComposite() from a pixmap in SHM.

2016-02-01 Thread Eric Anholt
There's a giant pile of code in glamor for uploading SHM pixmaps to
temporary GL memory for accelerating a Composite operation, and most of
its code is about how you convert formats.  Add a test that runs through
all the formats, to give us some coverage.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 Makefile.am   |   1 +
 configure.ac  |   2 +-
 rendercheck.h |   3 +
 t_shmblend.c  | 245 ++
 tests.c   |   2 -
 5 files changed, 250 insertions(+), 3 deletions(-)
 create mode 100644 t_shmblend.c

diff --git a/Makefile.am b/Makefile.am
index 852d174..f77cb4f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ rendercheck_SOURCES = \
t_gtk_argb_xbgr.c \
t_libreoffice_xrgb.c \
t_repeat.c \
+   t_shmblend.c \
t_srccoords.c \
t_tsrccoords.c \
t_tsrccoords2.c \
diff --git a/configure.ac b/configure.ac
index 655a1b6..8ad0b3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ XORG_TESTSET_CFLAG(CWARNFLAGS, [-Wno-shadow])
 AC_CHECK_HEADERS([err.h])
 
 # Checks for pkg-config packages
-PKG_CHECK_MODULES(RC, [xrender x11 xproto >= 7.0.17])
+PKG_CHECK_MODULES(RC, [xrender xext x11 xproto >= 7.0.17])
 
 AC_CONFIG_FILES([Makefile
  man/Makefile])
diff --git a/rendercheck.h b/rendercheck.h
index f0fa7b7..1c392e8 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if HAVE_ERR_H
 # include 
@@ -44,6 +45,7 @@ static inline void errx(int eval, const char *fmt, ...) {
 
 #define min(a, b) (a < b ? a : b)
 #define max(a, b) (a > b ? a : b)
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 typedef struct _color4d
 {
@@ -92,6 +94,7 @@ record_result(struct rendercheck_test_result *result, bool 
success)
 #define TEST_BUG7366   0x1000
 #define TEST_gtk_argb_xbgr 0x2000
 #define TEST_libreoffice_xrgb  0x4000
+#define TEST_shmblend  0x8000
 
 struct rendercheck_test {
int bit;
diff --git a/t_shmblend.c b/t_shmblend.c
new file mode 100644
index 000..752e17a
--- /dev/null
+++ b/t_shmblend.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright © 2016 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include "rendercheck.h"
+#include 
+
+bool had_x_error;
+static int (*orig_x_error_handler)(Display *, XErrorEvent *);
+
+static int
+shmerrorhandler(Display *d, XErrorEvent *e)
+{
+   had_x_error = true;
+   if (e->error_code == BadAccess) {
+   fprintf(stderr,"failed to attach shared memory\n");
+   return 0;
+   } else {
+   return (*orig_x_error_handler)(d,e);
+   }
+}
+
+static XShmSegmentInfo *
+get_x_shm_info(Display *dpy, size_t size)
+{
+   XShmSegmentInfo *shm_info = calloc(1, sizeof(*shm_info));
+
+   if (!XShmQueryExtension(dpy))
+   return NULL;
+
+   shm_info->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
+   if (shm_info->shmid < 0) {
+   free(shm_info);
+   return NULL;
+   }
+
+   shm_info->shmaddr = shmat(shm_info->shmid, NULL, 0);
+   if (shm_info->shmaddr == (void *)-1) {
+   free(shm_info);
+   return NULL;
+   }
+
+   shm_info->readOnly = false;
+
+   XSync(dpy, true);
+   had_x_error = false;
+   orig_x_error_handler = XSetErrorHandler(shmerrorhandler);
+   XShmAttach(dpy, shm_info);
+   XSync(dpy, true);
+   XSetErrorHandler(orig_x_error_handler);
+
+   return shm_info;
+}
+
+static void
+fill_shm_with_formatted_color(Display *dpy, XShmSegmentInfo *shm_info,
+ XRenderPictFormat *format,
+ int w, int h, color4d *color)
+{
+   XImage *image;
+   XRenderDi

[PATCH rendercheck 1/5] Start using stdbool.h instead of Xlib or custom bools.

2016-02-01 Thread Eric Anholt
I have a hard time typing anything else at this point.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 main.c   | 21 ++
 ops.c|  2 +-
 rendercheck.h| 58 +++-
 t_blend.c|  8 +++
 t_bug7366.c  | 32 +--
 t_composite.c| 12 +-
 t_dstcoords.c|  6 ++---
 t_fill.c |  6 ++---
 t_gradient.c | 32 +--
 t_gtk_argb_xbgr.c|  8 +++
 t_libreoffice_xrgb.c | 10 -
 t_repeat.c   | 22 +--
 t_srccoords.c| 14 ++--
 t_triangles.c| 24 ++--
 t_tsrccoords.c   | 12 +-
 t_tsrccoords2.c  | 14 ++--
 tests.c  | 62 ++--
 17 files changed, 171 insertions(+), 172 deletions(-)

diff --git a/main.c b/main.c
index a7035b9..b5d67cc 100644
--- a/main.c
+++ b/main.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 
-Bool is_verbose = FALSE, minimalrendering = FALSE;
+bool is_verbose = false, minimalrendering = false;
 int enabled_tests = ~0;/* Enable all tests by default */
 
 int format_whitelist_len = 0;
@@ -163,7 +163,8 @@ int main(int argc, char **argv)
Display *dpy;
XEvent ev;
int i, o, maj, min;
-   static Bool is_sync = FALSE, print_version = FALSE;
+   static int is_sync = false, print_version = false;
+   static int longopt_minimalrendering = 0;
XWindowAttributes a;
XSetWindowAttributes as;
picture_info window;
@@ -177,10 +178,10 @@ int main(int argc, char **argv)
{ "tests",  required_argument,  NULL,   't' },
{ "ops",required_argument,  NULL,   'o' },
{ "verbose",no_argument,NULL,   'v' },
-   { "sync",   no_argument,_sync, TRUE},
-   { "minimalrendering", no_argument,  ,
-   TRUE},
-   { "version",no_argument,_version, TRUE },
+   { "sync",   no_argument,_sync, true},
+   { "minimalrendering", no_argument,
+ _minimalrendering, true},
+   { "version",no_argument,_version, true },
{ NULL, 0,  NULL,   0 }
};
 
@@ -194,7 +195,7 @@ int main(int argc, char **argv)
break;
case 'o':
for (i = 0; i < num_ops; i++)
-   ops[i].disabled = TRUE;
+   ops[i].disabled = true;
 
nextname = optarg;
while ((opname = strsep(, ",")) != NULL) {
@@ -202,7 +203,7 @@ int main(int argc, char **argv)
if (strcasecmp(ops[i].name, opname) !=
0)
continue;
-   ops[i].disabled = FALSE;
+   ops[i].disabled = false;
break;
}
if (i == num_ops)
@@ -252,7 +253,7 @@ int main(int argc, char **argv)
 
break;
case 'v':
-   is_verbose = TRUE;
+   is_verbose = true;
break;
case 0:
break;
@@ -262,6 +263,8 @@ int main(int argc, char **argv)
}
}
 
+   minimalrendering = longopt_minimalrendering;
+
/* Print the version string.  Bail out if --version was requested and
 * continue otherwise.
 */
diff --git a/ops.c b/ops.c
index 0e03550..b7803da 100644
--- a/ops.c
+++ b/ops.c
@@ -210,7 +210,7 @@ do_composite(int op,
 const color4d *mask,
 const color4d *dst,
 color4d *result,
-Bool componentAlpha)
+bool componentAlpha)
 {
color4d srcval, srcalpha;
 
diff --git a/rendercheck.h b/rendercheck.h
index 67efdbf..55ffcff 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -22,6 +22,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #if HAVE_ERR_H
@@ -44,11 +45,6 @@ static inline void errx(int eval, const char *fmt, ...) {
 #define min(a, b) (a < b ? a : b)
 #define max(a, b) (a > b ? a : b)
 
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
 typedef struct _color4d
 {
double r, g, b, a;
@@ -65,7 +61,7 @@ typedef struct _picture_info {
 struct op_info {
int op;
const char *name;
-   Bool disabled;
+   bool disabled;
 };
 
 #define TEST_FILL  0x0001
@@ -87,7 +8

[PATCH rendercheck 3/5] Use ELF sections to make test setup easier.

2016-02-01 Thread Eric Anholt
Managing the group logic was really error-prone (forget to edit
success_mask when copy and pasting?  Forget to printf a description of
the group?).  Most new tests being written can be described as a single
call that does a couple subtests.

This doesn't convert all of the tests.  Some of the remaining ones use
"win" for presenting results (which we may want to just put in a
global?), and the rest use the pre-created pictures, which would need
some much bigger refactoring if we want to move their test logic into
their test files.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 main.c   | 47 ++-
 rendercheck.h| 51 ---
 t_gtk_argb_xbgr.c| 17 -
 t_libreoffice_xrgb.c | 18 --
 tests.c  | 37 ++---
 5 files changed, 120 insertions(+), 50 deletions(-)

diff --git a/main.c b/main.c
index b5d67cc..4cec99b 100644
--- a/main.c
+++ b/main.c
@@ -121,27 +121,38 @@ struct {
 {TEST_REPEAT, "repeat"},
 {TEST_TRIANGLES, "triangles"},
 {TEST_BUG7366, "bug7366"},
-{TEST_GTK_ARGB_XBGR, "gtk_argb_xbgr"},
-{TEST_LIBREOFFICE_XRGB, "libreoffice_xrgb"},
 {0, NULL}
 };
 
+static void
+print_test_separator(int i)
+{
+if (i % 5 == 0) {
+if(i != 0)
+putc('\n', stderr);
+putc('\t', stderr);
+} else {
+fprintf(stderr, ", ");
+}
+}
+
 void print_tests(FILE *file, int tests) {
 int i, j;
 
 for (i=0, j=0; available_tests[i].name; i++) {
 if (!(available_tests[i].flag & tests))
 continue;
-if (j % 5 == 0) {
-if(j != 0)
-putc('\n', stderr);
-putc('\t', stderr);
-} else {
-fprintf(stderr, ", ");
-}
+   print_test_separator(j++);
 fprintf(stderr, "%s", available_tests[i].name);
 j++;
 }
+for_each_test(test) {
+   if (!(test->bit & tests))
+   continue;
+   print_test_separator(j++);
+fprintf(stderr, "%s", test->arg_name);
+j++;
+}
 if (j)
 fprintf(file, "\n");
 }
@@ -169,7 +180,7 @@ int main(int argc, char **argv)
XSetWindowAttributes as;
picture_info window;
char *display = NULL;
-   char *test, *format, *opname, *nextname;
+   char *test_name, *format, *opname, *nextname;
 
static struct option longopts[] = {
{ "display",required_argument,  NULL,   'd' },
@@ -239,15 +250,25 @@ int main(int argc, char **argv)
/* disable all tests */
enabled_tests = 0;
 
-   while ((test = strsep(, ",")) != NULL) {
+   while ((test_name = strsep(, ",")) != NULL) {
int i;
+   bool found = false;
for(i=0; available_tests[i].name; i++) {
-   if(strcmp(test, 
available_tests[i].name) == 0) {
+   if(strcmp(test_name, 
available_tests[i].name) == 0) {
enabled_tests |= 
available_tests[i].flag;
+   found = true;
+   break;
+   }
+   }
+   for_each_test(test) {
+   if (strcmp(test_name,
+  test->arg_name) == 0) {
+   enabled_tests |= test->bit;
+   found = true;
break;
}
}
-   if(available_tests[i].name == NULL)
+   if (!found)
usage(argv[0]);
}
 
diff --git a/rendercheck.h b/rendercheck.h
index 2195cb4..f0fa7b7 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -64,6 +64,19 @@ struct op_info {
bool disabled;
 };
 
+struct rendercheck_test_result {
+   int tests;
+   int passed;
+};
+
+static inline void
+record_result(struct rendercheck_test_result *result, bool success)
+{
+   result->tests++;
+   if (success)
+   result->passed++;
+}
+
 #define TEST_FILL  0x0001
 #define TEST_DSTCOORDS 0x0002
 #define TEST_SRCCOORDS 0x0004
@@ -77,8 +90,27 @@ struct op_info {
 #define TEST_REPEAT0x0400
 #define TEST_TRIANGLES

[PATCH rendercheck 5/5] autogen: Set a default prefix for patches if unset.

2016-02-01 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 autogen.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/autogen.sh b/autogen.sh
index 1b15e18..c262d6b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -11,3 +11,6 @@ autoreconf -v --install || exit 1
 cd $ORIGDIR || exit $?
 
 $srcdir/configure --enable-maintainer-mode "$@"
+
+git config --local --get format.subjectPrefix ||
+git config --local format.subjectPrefix "PATCH rendercheck"
-- 
2.7.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 xserver 14/19] glamor: Drop extra conditionals for large pixmap handling.

2016-01-29 Thread Eric Anholt
Eric Anholt <e...@anholt.net> writes:

> For a small pixmap, it's got a box from 0,0 to width/height, so we can
> always use that.

This seemed so sensible, but it turns out that for MEMORY pixmaps we'll
attach an FBO to it in the glamor_picture.c code, without setting its
box (which is still zeroed).  This may be lunacy, but it means this
patch is busted for now.

I'm going to revisit this after landing the rest of the series.


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

Re: [PATCH xserver 00/19] glamor: Cleanups all over

2016-01-29 Thread Eric Anholt
Dave Airlie <airl...@gmail.com> writes:

> On 28 January 2016 at 18:21, Dave Airlie <airl...@gmail.com> wrote:
>> On 28 January 2016 at 11:56, Eric Anholt <e...@anholt.net> wrote:
>>> I've been working on vc4 X performance again, particularly looking at
>>> dragging windows with xcompmgr -c running.  I'll be sending a separate
>>> patch to accelerate a8 rendering on GLES2-class renderers, but even
>>> with that things are crazy slow.  I think at this point the major
>>> problem is the crazy mass of code from rel_sampler().
>>>
>>> This series was some cleanups as I worked toward that, and finally one
>>> patch that should reduce the cost of rel_sampler on non-control-flow
>>> hardware (I see fewer texture sampler requests on vc4).  No
>>> performance change on i965, but I hope that vc4 is in better shape
>>> after it.  (I'm away from the hardware at the moment, but should test
>>> later today).
>>
>> 1-3 look good to me,
>>
>> Reviewed-by: Dave Airlie <airl...@redhat.com>
>
> Okay I've dug through the rest, assuming they don't break anything all
> look good.
>
> Reviewed-by: Dave Airlie <airl...@redhat.com>
>
> good to know if they have any effect on VC4.

Finally got my giant edifice of scripts working:

8.09199% +/- 0.416675% (n=5) on comppixwin100 on vc4.


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

Re: [PATCH v2 xserver] glamor: Disable debugging messages other than GL API errors

2016-01-19 Thread Eric Anholt
Michel Dänzer  writes:

> From: Michel Dänzer 
>
> According to Nicolai Hähnle, the relevant specification says "All
> messages are initially enabled unless their assigned severity is
> DEBUG_SEVERITY_LOW", so we need to explicitly disable the messages we
> don't want to get. Failing that, we were accidentally logging e.g.
> shader stats intended for shader-db.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93659
> Tested-by: Laurent Carlier 
> Reviewed-by: Emil Velikov 
> Signed-off-by: Michel Dänzer 
> ---
>
> v2: Added Bugzilla/Tested-by/Reviewed-by tags

Merged:

commit 1db6de7b6a6ee240eb50a13fe1fa1e135d7cb93b
Author: Michel Dänzer 
Date:   Tue Jan 12 15:42:47 2016 +0900

glamor: Disable debugging messages other than GL API errors


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

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

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

> 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.

What exactly is the error?  I was thinking it would be something about
count == 0, but that's not an error apparently.  If there is one about
count == 0, shouldn't we just have
glamor_gldrawarrays_quads_using_indices() do the short circuit so the
callers don't have to worry about it?


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

[PATCH xserver 1/2] glamor: Fix copy-like Render operations between 15 and 16 depth.

2016-01-21 Thread Eric Anholt
Please cherry-pick this to active stable branches.

Reading and writing to 16-depth pixmaps using PICT_x1r5g5b5 ends up
failing, unless you're doing a straight copy at the same bpp where the
misinterpretation matches on both sides.

Fixes rendercheck/blend/over and renderhceck/blend/src in piglit.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index d8574ec..92b6b0c 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -512,6 +512,14 @@ static int
 compatible_formats(CARD8 op, PicturePtr dst, PicturePtr src)
 {
 if (op == PictOpSrc) {
+/* We can't do direct copies between different depths at 16bpp
+ * because r,g,b are allocated to different bits.
+ */
+if (dst->pDrawable->bitsPerPixel == 16 &&
+dst->pDrawable->depth != src->pDrawable->depth) {
+return 0;
+}
+
 if (src->format == dst->format)
 return 1;
 
-- 
2.6.4

___
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 xserver 2/2] glamor: Drop the composite_with_copy path entirely.

2016-01-21 Thread Eric Anholt
I originally inherited this from the EXA code, without determining
whether it was really needed.  Regular composite should end up doing
the same thing, since it's all just shaders anyway.  To the extent
that it doesn't, we should fix composite.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 92 --
 1 file changed, 92 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 92b6b0c..1b226aa 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -508,41 +508,6 @@ glamor_set_composite_solid(float *color, GLint 
uniform_location)
 glUniform4fv(uniform_location, 1, color);
 }
 
-static int
-compatible_formats(CARD8 op, PicturePtr dst, PicturePtr src)
-{
-if (op == PictOpSrc) {
-/* We can't do direct copies between different depths at 16bpp
- * because r,g,b are allocated to different bits.
- */
-if (dst->pDrawable->bitsPerPixel == 16 &&
-dst->pDrawable->depth != src->pDrawable->depth) {
-return 0;
-}
-
-if (src->format == dst->format)
-return 1;
-
-if (src->format == PICT_a8r8g8b8 && dst->format == PICT_x8r8g8b8)
-return 1;
-
-if (src->format == PICT_a8b8g8r8 && dst->format == PICT_x8b8g8r8)
-return 1;
-}
-else if (op == PictOpOver) {
-if (src->alphaMap || dst->alphaMap)
-return 0;
-
-if (src->format != dst->format)
-return 0;
-
-if (src->format == PICT_x8r8g8b8 || src->format == PICT_x8b8g8r8)
-return 1;
-}
-
-return 0;
-}
-
 static char
 glamor_get_picture_location(PicturePtr picture)
 {
@@ -564,54 +529,6 @@ glamor_get_picture_location(PicturePtr picture)
 return glamor_get_drawable_location(picture->pDrawable);
 }
 
-static Bool
-glamor_composite_with_copy(CARD8 op,
-   PicturePtr source,
-   PicturePtr dest,
-   INT16 x_source,
-   INT16 y_source,
-   INT16 x_dest, INT16 y_dest, RegionPtr region)
-{
-int ret = FALSE;
-
-if (!source->pDrawable)
-return FALSE;
-
-if (!compatible_formats(op, dest, source))
-return FALSE;
-
-if (source->repeat || source->transform) {
-return FALSE;
-}
-
-x_dest += dest->pDrawable->x;
-y_dest += dest->pDrawable->y;
-x_source += source->pDrawable->x;
-y_source += source->pDrawable->y;
-if (PICT_FORMAT_A(source->format) == 0) {
-/* Fallback if we sample outside the source so that we
- * swizzle the correct clear color for out-of-bounds texels.
- */
-if (region->extents.x1 + x_source - x_dest < 0)
-goto cleanup_region;
-if (region->extents.x2 + x_source - x_dest > source->pDrawable->width)
-goto cleanup_region;
-
-if (region->extents.y1 + y_source - y_dest < 0)
-goto cleanup_region;
-if (region->extents.y2 + y_source - y_dest > source->pDrawable->height)
-goto cleanup_region;
-}
-glamor_copy(source->pDrawable,
-dest->pDrawable, NULL,
-RegionRects(region), RegionNumRects(region),
-x_source - x_dest, y_source - y_dest,
-FALSE, FALSE, 0, NULL);
-ret = TRUE;
- cleanup_region:
-return ret;
-}
-
 static void *
 glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
 {
@@ -1451,15 +1368,6 @@ glamor_composite_clipped_region(CARD8 op,
 }
 }
 
-if (!mask && temp_src) {
-if (glamor_composite_with_copy(op, temp_src, dest,
-   x_temp_src, y_temp_src,
-   x_dest, y_dest, region)) {
-ok = TRUE;
-goto out;
-}
-}
-
 if (temp_src_pixmap == dest_pixmap) {
 glamor_fallback("source and dest pixmaps are the same\n");
 goto out;
-- 
2.6.4

___
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 xserver 1/3] glamor: Drop duplicated GLAMOR_DEFAULT_PRECISIONs in render accel.

2016-01-21 Thread Eric Anholt
We only need it once at the top of the shader, so just put it
there.

Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_render.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index e4beafc..7a50fe9 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -72,7 +72,6 @@ glamor_create_composite_fs(struct shader_key *key)
 "uniform int   source_repeat_mode;\n"
 "uniform int   mask_repeat_mode;\n";
 const char *relocate_texture =
-GLAMOR_DEFAULT_PRECISION
 "vec2 rel_tex_coord(vec2 texture, vec4 wh, int repeat) \n"
 "{\n"
 "   vec2 rel_tex; \n"
@@ -119,14 +118,12 @@ glamor_create_composite_fs(struct shader_key *key)
 "}\n";
 
 const char *source_solid_fetch =
-GLAMOR_DEFAULT_PRECISION
 "uniform vec4 source;\n"
 "vec4 get_source()\n"
 "{\n"
 "  return source;\n"
 "}\n";
 const char *source_alpha_pixmap_fetch =
-GLAMOR_DEFAULT_PRECISION
 "varying vec2 source_texture;\n"
 "uniform sampler2D source_sampler;\n"
 "uniform vec4 source_wh;"
@@ -139,7 +136,6 @@ glamor_create_composite_fs(struct shader_key *key)
 " source_wh, source_repeat_mode, 0);\n"
 "}\n";
 const char *source_pixmap_fetch =
-GLAMOR_DEFAULT_PRECISION
 "varying vec2 source_texture;\n"
 "uniform sampler2D source_sampler;\n"
 "uniform vec4 source_wh;\n"
@@ -152,14 +148,12 @@ glamor_create_composite_fs(struct shader_key *key)
 " source_wh, source_repeat_mode, 1);\n"
 "}\n";
 const char *mask_solid_fetch =
-GLAMOR_DEFAULT_PRECISION
 "uniform vec4 mask;\n"
 "vec4 get_mask()\n"
 "{\n"
 "  return mask;\n"
 "}\n";
 const char *mask_alpha_pixmap_fetch =
-GLAMOR_DEFAULT_PRECISION
 "varying vec2 mask_texture;\n"
 "uniform sampler2D mask_sampler;\n"
 "uniform vec4 mask_wh;\n"
@@ -172,7 +166,6 @@ glamor_create_composite_fs(struct shader_key *key)
 " mask_wh, mask_repeat_mode, 0);\n"
 "}\n";
 const char *mask_pixmap_fetch =
-GLAMOR_DEFAULT_PRECISION
 "varying vec2 mask_texture;\n"
 "uniform sampler2D mask_sampler;\n"
 "uniform vec4 mask_wh;\n"
@@ -185,31 +178,26 @@ glamor_create_composite_fs(struct shader_key *key)
 " mask_wh, mask_repeat_mode, 1);\n"
 "}\n";
 const char *in_source_only =
-GLAMOR_DEFAULT_PRECISION
 "void main()\n"
 "{\n"
 "  gl_FragColor = get_source();\n"
 "}\n";
 const char *in_normal =
-GLAMOR_DEFAULT_PRECISION
 "void main()\n"
 "{\n"
 "  gl_FragColor = get_source() * get_mask().a;\n"
 "}\n";
 const char *in_ca_source =
-GLAMOR_DEFAULT_PRECISION
 "void main()\n"
 "{\n"
 "  gl_FragColor = get_source() * get_mask();\n"
 "}\n";
 const char *in_ca_alpha =
-GLAMOR_DEFAULT_PRECISION
 "void main()\n"
 "{\n"
 "  gl_FragColor = get_source().a * get_mask();\n"
 "}\n";
 const char *in_ca_dual_blend =
-GLAMOR_DEFAULT_PRECISION
 "out vec4 color0;\n"
 "out vec4 color1;\n"
 "void main()\n"
@@ -280,7 +268,10 @@ glamor_create_composite_fs(struct shader_key *key)
 FatalError("Bad composite IN type");
 }
 
-XNFasprintf(, "%s%s%s%s%s%s%s", header, repeat_define, 
relocate_texture,
+XNFasprintf(,
+"%s"
+GLAMOR_DEFAULT_PRECISION
+"%s%s%s%s%s%s", header, repeat_define, relocate_texture,
 rel_sampler, source_fetch, mask_fetch, in);
 
 prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
-- 
2.6.4

___
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 xserver 2/3] squash: glamor: Fix rendering to a8 textures in core profile.

2016-01-21 Thread Eric Anholt
Signed-off-by: Eric Anholt <e...@anholt.net>
---
 glamor/glamor_priv.h   | 10 +-
 glamor/glamor_render.c | 50 +++---
 2 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 558ed63..f1eed5b 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -116,10 +116,17 @@ enum shader_in {
 SHADER_IN_COUNT,
 };
 
+enum shader_dest_swizzle {
+SHADER_DEST_SWIZZLE_DEFAULT,
+SHADER_DEST_SWIZZLE_ALPHA_TO_RED,
+SHADER_DEST_SWIZZLE_COUNT,
+};
+
 struct shader_key {
 enum shader_source source;
 enum shader_mask mask;
 enum shader_in in;
+enum shader_dest_swizzle dest_swizzle;
 };
 
 struct blendinfo {
@@ -285,7 +292,8 @@ typedef struct glamor_screen_private {
 int render_nr_quads;
 glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
 [SHADER_MASK_COUNT]
-[SHADER_IN_COUNT];
+[SHADER_IN_COUNT]
+[SHADER_DEST_SWIZZLE_COUNT];
 
 /* shaders to restore a texture to another texture. */
 GLint finish_access_prog[2];
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 7a50fe9..c36b345 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -177,25 +177,38 @@ glamor_create_composite_fs(struct shader_key *key)
 "  return rel_sampler(mask_sampler, mask_texture,\n"
 " mask_wh, mask_repeat_mode, 1);\n"
 "}\n";
+
+const char *dest_swizzle_default =
+"vec4 dest_swizzle(vec4 color)\n"
+"{"
+"  return color;"
+"}";
+const char *dest_swizzle_alpha_to_red =
+"vec4 dest_swizzle(vec4 color)\n"
+"{"
+"  float undef;\n"
+"  return vec4(color.a, undef, undef, undef);"
+"}";
+
 const char *in_source_only =
 "void main()\n"
 "{\n"
-"  gl_FragColor = get_source();\n"
+"  gl_FragColor = dest_swizzle(get_source());\n"
 "}\n";
 const char *in_normal =
 "void main()\n"
 "{\n"
-"  gl_FragColor = get_source() * get_mask().a;\n"
+"  gl_FragColor = dest_swizzle(get_source() * get_mask().a);\n"
 "}\n";
 const char *in_ca_source =
 "void main()\n"
 "{\n"
-"  gl_FragColor = get_source() * get_mask();\n"
+"  gl_FragColor = dest_swizzle(get_source() * get_mask());\n"
 "}\n";
 const char *in_ca_alpha =
 "void main()\n"
 "{\n"
-"  gl_FragColor = get_source().a * get_mask();\n"
+"  gl_FragColor = dest_swizzle(get_source().a * get_mask());\n"
 "}\n";
 const char *in_ca_dual_blend =
 "out vec4 color0;\n"
@@ -214,6 +227,7 @@ glamor_create_composite_fs(struct shader_key *key)
 const char *in;
 const char *header;
 const char *header_norm = "";
+const char *dest_swizzle;
 GLuint prog;
 
 switch (key->source) {
@@ -246,6 +260,21 @@ glamor_create_composite_fs(struct shader_key *key)
 FatalError("Bad composite shader mask");
 }
 
+/* If we're storing to an a8 texture but our texture format is
+ * GL_RED because of a core context, then we need to make sure to
+ * put the alpha into the red channel.
+ */
+switch (key->dest_swizzle) {
+case SHADER_DEST_SWIZZLE_DEFAULT:
+dest_swizzle = dest_swizzle_default;
+break;
+case SHADER_DEST_SWIZZLE_ALPHA_TO_RED:
+dest_swizzle = dest_swizzle_alpha_to_red;
+break;
+default:
+FatalError("Bad composite shader dest swizzle");
+}
+
 header = header_norm;
 switch (key->in) {
 case SHADER_IN_SOURCE_ONLY:
@@ -271,8 +300,8 @@ glamor_create_composite_fs(struct shader_key *key)
 XNFasprintf(,
 "%s"
 GLAMOR_DEFAULT_PRECISION
-"%s%s%s%s%s%s", header, repeat_define, relocate_texture,
-rel_sampler, source_fetch, mask_fetch, in);
+"%s%s%s%s%s%s%s", header, repeat_define, relocate_texture,
+rel_sampler, source_fetch, mask_fetch, dest_swizzle, in);
 
 prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, source);
 free(source);
@@ -386,7 +415,7 @@ glamor_lookup_composite_shader(ScreenPtr screen, struct
 glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
 glamor_composite_shader *shader;
 
-shader = _priv->composite_shader[key->source][key->mask][key->in];
+shade

[PATCH xserver 0/3] Fixups for GL_RED patch.

2016-01-21 Thread Eric Anholt
Here are my fixes for the regressions in the glamor-core-profile
series.  The first commit would go just before the GL_RED change, then
I'd squash the other two into GL_RED.  The series is now in
glamor-core-profile of my fdo tree.

Eric Anholt (3):
  glamor: Drop duplicated GLAMOR_DEFAULT_PRECISIONs in render accel.
  squash: glamor: Fix rendering to a8 textures in core profile.
  squash: glamor: Fix Render blending for alpha-to-red.

 glamor/glamor_priv.h   |  10 -
 glamor/glamor_render.c | 101 ++---
 2 files changed, 87 insertions(+), 24 deletions(-)

-- 
2.6.4

___
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

<    2   3   4   5   6   7   8   9   10   11   >