[virglrenderer-devel] [PATCH] vrend: Adjust the GL blit source bounds based on the blit read direction

Alexandros Frantzis alexandros.frantzis at collabora.com
Fri May 11 15:48:54 UTC 2018


When bounding a blit within the source resource extents, whether a
coordinate bound is inclusive or exclusive depends on the direction of
the read. Take this direction into account and bound the coordinates
accordingly.

Fixes: piglit fbo-blit-stretch

Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
---
 src/vrend_blitter.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/vrend_blitter.c b/src/vrend_blitter.c
index b727436..042a115 100644
--- a/src/vrend_blitter.c
+++ b/src/vrend_blitter.c
@@ -564,15 +564,20 @@ static void calc_src_deltas_for_bounds(struct vrend_resource *src_res,
    int max_x = u_minify(src_res->base.width0, info->src.level) - 1;
    int max_y = u_minify(src_res->base.height0, info->src.level) - 1;
 
-   /* point 0 uses inclusive bounds */
-   src0_delta->dx = calc_delta_for_bound(info->src.box.x, max_x);
-   src0_delta->dy = calc_delta_for_bound(info->src.box.y, max_y);
+   /* Whether the bounds for the coordinates of a point are inclusive or
+    * exclusive depends on the direction of the blit read. Adjust the max
+    * bounds accordingly, with an adjustment of 0 for inclusive, and 1 for
+    * exclusive. */
+   int src0_x_excl = info->src.box.width < 0;
+   int src0_y_excl = info->src.box.height < 0;
+
+   src0_delta->dx = calc_delta_for_bound(info->src.box.x, max_x + src0_x_excl);
+   src0_delta->dy = calc_delta_for_bound(info->src.box.y, max_y + src0_y_excl);
 
-   /* point 1 uses exclusive bounds */
    src1_delta->dx = calc_delta_for_bound(info->src.box.x + info->src.box.width,
-                                         max_x + 1);
+                                         max_x + !src0_x_excl);
    src1_delta->dy = calc_delta_for_bound(info->src.box.y + info->src.box.height,
-                                         max_y + 1);
+                                         max_y + !src0_y_excl);
 }
 
 /* Calculate dst delta values to adjust the dst points for any changes in the
-- 
2.17.0



More information about the virglrenderer-devel mailing list