From ad1a4cb563f483a5767431adcc6a1a8f973326fd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Jun 2018 13:29:42 -0700 Subject: [PATCH] v3d: Fix Z clipping when viewport.scale[2] is negative. Fixes: dEQP-GLES3.functional.shaders.builtin_variable.depth_range_fragment dEQP-GLES3.functional.shaders.builtin_variable.depth_range_vertex --- src/gallium/drivers/v3d/v3dx_emit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/v3d/v3dx_emit.c b/src/gallium/drivers/v3d/v3dx_emit.c index e0bb95efb21..d5549bb945c 100644 --- a/src/gallium/drivers/v3d/v3dx_emit.c +++ b/src/gallium/drivers/v3d/v3dx_emit.c @@ -465,10 +465,12 @@ v3dX(emit_state)(struct pipe_context *pctx) v3d->viewport.scale[2]; } cl_emit(&job->bcl, CLIPPER_Z_MIN_MAX_CLIPPING_PLANES, clip) { - clip.minimum_zw = (v3d->viewport.translate[2] - - v3d->viewport.scale[2]); - clip.maximum_zw = (v3d->viewport.translate[2] + - v3d->viewport.scale[2]); + float z1 = (v3d->viewport.translate[2] - + v3d->viewport.scale[2]); + float z2 = (v3d->viewport.translate[2] + + v3d->viewport.scale[2]); + clip.minimum_zw = MIN2(z1, z2); + clip.maximum_zw = MAX2(z1, z2); } cl_emit(&job->bcl, VIEWPORT_OFFSET, vp) { -- 2.30.2