From 2290eac84ef0c80a6e60cafac8ed0fb8f8a4ca93 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Fri, 30 Sep 2016 20:48:22 +0200 Subject: [PATCH] gallium/util: Really allow aliasing of dst for u_box_union_* MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Gallium nine relies on aliasing to work with this function. Without this patch, dirty region tracking was incorrect, which could lead to incorrect textures or vertex buffers. Fixes several game bugs with nine. Fixes https://github.com/iXit/Mesa-3D/issues/234 Signed-off-by: Axel Davy Reviewed-by: Patrick Rudolph Reviewed-by: Nicolai Hähnle Reviewed-by: Roland Scheidegger Reviewed-by: Edward O'Callaghan Cc: "12.0" --- src/gallium/auxiliary/util/u_box.h | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/util/u_box.h b/src/gallium/auxiliary/util/u_box.h index eb41f8aca36..b3f478e7bfc 100644 --- a/src/gallium/auxiliary/util/u_box.h +++ b/src/gallium/auxiliary/util/u_box.h @@ -124,11 +124,15 @@ static inline void u_box_union_2d(struct pipe_box *dst, const struct pipe_box *a, const struct pipe_box *b) { - dst->x = MIN2(a->x, b->x); - dst->y = MIN2(a->y, b->y); + int x, y; - dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x; - dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y; + x = MIN2(a->x, b->x); + y = MIN2(a->y, b->y); + + dst->width = MAX2(a->x + a->width, b->x + b->width) - x; + dst->height = MAX2(a->y + a->height, b->y + b->height) - y; + dst->x = x; + dst->y = y; } /* Aliasing of @dst permitted. */ @@ -136,13 +140,18 @@ static inline void u_box_union_3d(struct pipe_box *dst, const struct pipe_box *a, const struct pipe_box *b) { - dst->x = MIN2(a->x, b->x); - dst->y = MIN2(a->y, b->y); - dst->z = MIN2(a->z, b->z); - - dst->width = MAX2(a->x + a->width, b->x + b->width) - dst->x; - dst->height = MAX2(a->y + a->height, b->y + b->height) - dst->y; - dst->depth = MAX2(a->z + a->depth, b->z + b->depth) - dst->z; + int x, y, z; + + x = MIN2(a->x, b->x); + y = MIN2(a->y, b->y); + z = MIN2(a->z, b->z); + + dst->width = MAX2(a->x + a->width, b->x + b->width) - x; + dst->height = MAX2(a->y + a->height, b->y + b->height) - y; + dst->depth = MAX2(a->z + a->depth, b->z + b->depth) - z; + dst->x = x; + dst->y = y; + dst->z = z; } static inline boolean -- 2.30.2