xserver: Branch 'master' - 4 commits

Eric Anholt anholt at kemper.freedesktop.org
Mon Aug 14 20:48:51 UTC 2017


 glamor/glamor_copy.c   |   25 +++++++++++++++++++++----
 glamor/glamor_rects.c  |   26 ++++++++++++++++++++++----
 glamor/glamor_render.c |   25 +++++++++++++++++++++++++
 glamor/glamor_utils.h  |   44 ++++++++++++++++++++++++++++++++++++++++++++
 include/meson.build    |    2 +-
 os/ospoll.c            |    2 +-
 6 files changed, 114 insertions(+), 10 deletions(-)

New commits:
commit c52f77e4ca2cda878da341a6228e6411eec7b1a0
Author: Peter Harris <pharris at opentext.com>
Date:   Mon Aug 14 15:54:36 2017 -0400

    meson: Fix epoll detection
    
    The epoll code depends on epoll_create1, not epoll_create.
    
    Signed-off-by: Peter Harris <pharris at opentext.com>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/include/meson.build b/include/meson.build
index 78ec521ac..05ef76930 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -110,7 +110,7 @@ conf_data.set('HAVE_UNISTD_H', cc.has_header('unistd.h'))
 conf_data.set('HAVE_ARC4RANDOM_BUF', cc.has_function('arc4random_buf', dependencies: libbsd_dep))
 conf_data.set('HAVE_BACKTRACE', cc.has_function('backtrace'))
 conf_data.set('HAVE_CBRT', cc.has_function('cbrt'))
-conf_data.set('HAVE_EPOLL_CREATE', cc.has_function('epoll_create'))
+conf_data.set('HAVE_EPOLL_CREATE1', cc.has_function('epoll_create1'))
 conf_data.set('HAVE_FFS', cc.has_function('ffs'))
 conf_data.set('HAVE_GETUID', cc.has_function('getuid'))
 conf_data.set('HAVE_GETEUID', cc.has_function('geteuid'))
diff --git a/os/ospoll.c b/os/ospoll.c
index 51bd02dc7..ca14a0c8c 100644
--- a/os/ospoll.c
+++ b/os/ospoll.c
@@ -32,7 +32,7 @@
 #include "ospoll.h"
 #include "list.h"
 
-#if !HAVE_OSPOLL && HAVE_EPOLL_CREATE1
+#if !HAVE_OSPOLL && defined(HAVE_EPOLL_CREATE1)
 #include <sys/epoll.h>
 #define EPOLL           1
 #define HAVE_OSPOLL     1
commit 27500ee82e97ef8a6b3199c2d7b623523c1ee2c1
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jul 10 12:08:29 2017 -0700

    glamor: Scissor Render composite operations to the bounds of the drawing.
    
    Unlike the previous two fixes, this one introduces new GL calls and
    statechanges of the scissor.  However, given that our Render drawing
    already does CPU side transformation and inefficient box upload, this
    shouldn't be a limiting factor for Render acceleration.
    
    Surprisingly, it improves x11perf -comppixwin10 -repeat 1 -reps 10000
    on i965 by 3.21191% +/- 1.79977% (n=50).
    
    v2: Make the jump to the exit land after scissor disable.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 52f073d05..3f982a2d2 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1198,6 +1198,29 @@ glamor_composite_with_shader(CARD8 op,
 
     nrect_max = MIN(nrect, GLAMOR_COMPOSITE_VBO_VERT_CNT / 4);
 
+    if (nrect < 100) {
+        BoxRec bounds = glamor_start_rendering_bounds();
+
+        for (int i = 0; i < nrect; i++) {
+            BoxRec box = {
+                .x1 = rects[i].x_dst,
+                .y1 = rects[i].y_dst,
+                .x2 = rects[i].x_dst + rects[i].width,
+                .y2 = rects[i].y_dst + rects[i].height,
+            };
+            glamor_bounds_union_box(&bounds, &box);
+        }
+
+        if (bounds.x1 >= bounds.x2 || bounds.y1 >= bounds.y2)
+            goto disable_va;
+
+        glEnable(GL_SCISSOR_TEST);
+        glScissor(bounds.x1 + dest_x_off,
+                  bounds.y1 + dest_y_off,
+                  bounds.x2 - bounds.x1,
+                  bounds.y2 - bounds.y1);
+    }
+
     while (nrect) {
         int mrect, rect_processed;
         int vb_stride;
@@ -1279,6 +1302,8 @@ glamor_composite_with_shader(CARD8 op,
         }
     }
 
+    glDisable(GL_SCISSOR_TEST);
+disable_va:
     glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
     glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
     glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
commit e6ab3b1109e72a1512c6b7b92dd84525ad8c8052
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jul 6 16:15:17 2017 -0700

    glamor: Scissor CopyArea to the bounds of the drawing.
    
    Like the previous fix to rectangles, this reduces the area drawn on
    tiled renderers by letting the CPU-side tile setup know what tiles
    might be drawn at all.
    
    Surprisingly, it improves x11perf -copypixwin1 -repeat 1 -reps 10000
    on i965 by 2.93185% +/- 1.5561% (n=90).
    
    v2: Drop extra glamor_bounds_union_box() from previous debugging
        (caught by Mark Marshall).
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com> (v1)

diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index f7d6eb163..cbaf06ddd 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -351,6 +351,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
     const glamor_facet *copy_facet;
     int n;
     Bool ret = FALSE;
+    BoxRec bounds = glamor_no_rendering_bounds();
 
     glamor_make_current(glamor_priv);
 
@@ -391,11 +392,18 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
     glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
                           2 * sizeof (GLshort), vbo_offset);
 
+    if (nbox < 100) {
+        bounds = glamor_start_rendering_bounds();
+        for (int i = 0; i < nbox; i++)
+            glamor_bounds_union_box(&bounds, &box[i]);
+    }
+
     for (n = 0; n < nbox; n++) {
         v[0] = box->x1; v[1] = box->y1;
         v[2] = box->x1; v[3] = box->y2;
         v[4] = box->x2; v[5] = box->y2;
         v[6] = box->x2; v[7] = box->y1;
+
         v += 8;
         box++;
     }
@@ -417,15 +425,24 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
             goto bail_ctx;
 
         glamor_pixmap_loop(dst_priv, dst_box_index) {
+            BoxRec scissor = {
+                .x1 = max(-args.dx, bounds.x1),
+                .y1 = max(-args.dy, bounds.y1),
+                .x2 = min(-args.dx + src_box->x2 - src_box->x1, bounds.x2),
+                .y2 = min(-args.dy + src_box->y2 - src_box->y1, bounds.y2),
+            };
+            if (scissor.x1 >= scissor.x2 || scissor.y1 >= scissor.y2)
+                continue;
+
             if (!glamor_set_destination_drawable(dst, dst_box_index, FALSE, FALSE,
                                                  prog->matrix_uniform,
                                                  &dst_off_x, &dst_off_y))
                 goto bail_ctx;
 
-            glScissor(dst_off_x - args.dx,
-                      dst_off_y - args.dy,
-                      src_box->x2 - src_box->x1,
-                      src_box->y2 - src_box->y1);
+            glScissor(scissor.x1 + dst_off_x,
+                      scissor.y1 + dst_off_y,
+                      scissor.x2 - scissor.x1,
+                      scissor.y2 - scissor.y1);
 
             glamor_glDrawArrays_GL_QUADS(glamor_priv, nbox);
         }
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index f1f8f5633..6e9d88674 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -764,6 +764,15 @@ glamor_bounds_union_rect(BoxPtr bounds, xRectangle *rect)
     bounds->y2 = min(SHRT_MAX, max(bounds->y2, rect->y + rect->height));
 }
 
+static inline void
+glamor_bounds_union_box(BoxPtr bounds, BoxPtr box)
+{
+    bounds->x1 = min(bounds->x1, box->x1);
+    bounds->y1 = min(bounds->y1, box->y1);
+    bounds->x2 = max(bounds->x2, box->x2);
+    bounds->y2 = max(bounds->y2, box->y2);
+}
+
 /**
  * Helper function for implementing draws with GL_QUADS on GLES2,
  * where we don't have them.
commit 60cc7e367a2a5e6014f193105dafd47a4d598fd9
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jul 6 15:43:14 2017 -0700

    glamor: Scissor rectangle drawing to the bounds of the rects.
    
    Scissors provide a critical hint to tiled renderers as to what tiles
    need to be load/stored because they could be modified by the
    rendering.
    
    The bounds calculation here is limited to when we have a small number
    of rects (large enough to cover rounded window corners, but probably
    not xeyes) to avoid overhead on desktop GL.
    
    No performance difference on i965 with x11perf -rect1 -repeat 1 -reps
    10000 (n=50)
    
    v2: Clamp rectangle bounds addition.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_rects.c b/glamor/glamor_rects.c
index cc029c8c0..6cbb040c1 100644
--- a/glamor/glamor_rects.c
+++ b/glamor/glamor_rects.c
@@ -53,6 +53,7 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
     char *vbo_offset;
     int box_index;
     Bool ret = FALSE;
+    BoxRec bounds = glamor_no_rendering_bounds();
 
     pixmap_priv = glamor_get_pixmap_private(pixmap);
     if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
@@ -60,6 +61,12 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
 
     glamor_make_current(glamor_priv);
 
+    if (nrect < 100) {
+        bounds = glamor_start_rendering_bounds();
+        for (int i = 0; i < nrect; i++)
+            glamor_bounds_union_rect(&bounds, &prect[i]);
+    }
+
     if (glamor_priv->glsl_version >= 130) {
         prog = glamor_use_program_fill(pixmap, gc,
                                        &glamor_priv->poly_fill_rect_program,
@@ -121,11 +128,22 @@ glamor_poly_fill_rect_gl(DrawablePtr drawable,
             goto bail;
 
         while (nbox--) {
-            glScissor(box->x1 + off_x,
-                      box->y1 + off_y,
-                      box->x2 - box->x1,
-                      box->y2 - box->y1);
+            BoxRec scissor = {
+                .x1 = max(box->x1, bounds.x1 + drawable->x),
+                .y1 = max(box->y1, bounds.y1 + drawable->y),
+                .x2 = min(box->x2, bounds.x2 + drawable->x),
+                .y2 = min(box->y2, bounds.y2 + drawable->y),
+            };
+
             box++;
+
+            if (scissor.x1 >= scissor.x2 || scissor.y1 >= scissor.y2)
+                continue;
+
+            glScissor(scissor.x1 + off_x,
+                      scissor.y1 + off_y,
+                      scissor.x2 - scissor.x1,
+                      scissor.y2 - scissor.y1);
             if (glamor_priv->glsl_version >= 130)
                 glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nrect);
             else {
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index a35917c37..f1f8f5633 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -729,6 +729,41 @@ glamor_make_current(glamor_screen_private *glamor_priv)
     }
 }
 
+static inline BoxRec
+glamor_no_rendering_bounds(void)
+{
+    BoxRec bounds = {
+        .x1 = 0,
+        .y1 = 0,
+        .x2 = MAXSHORT,
+        .y2 = MAXSHORT,
+    };
+
+    return bounds;
+}
+
+static inline BoxRec
+glamor_start_rendering_bounds(void)
+{
+    BoxRec bounds = {
+        .x1 = MAXSHORT,
+        .y1 = MAXSHORT,
+        .x2 = 0,
+        .y2 = 0,
+    };
+
+    return bounds;
+}
+
+static inline void
+glamor_bounds_union_rect(BoxPtr bounds, xRectangle *rect)
+{
+    bounds->x1 = min(bounds->x1, rect->x);
+    bounds->y1 = min(bounds->y1, rect->y);
+    bounds->x2 = min(SHRT_MAX, max(bounds->x2, rect->x + rect->width));
+    bounds->y2 = min(SHRT_MAX, max(bounds->y2, rect->y + rect->height));
+}
+
 /**
  * Helper function for implementing draws with GL_QUADS on GLES2,
  * where we don't have them.


More information about the xorg-commit mailing list