summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-06-25 13:29:42 -0700
committerEric Anholt <[email protected]>2018-06-27 09:35:51 -0700
commitad1a4cb563f483a5767431adcc6a1a8f973326fd (patch)
treea32bbd4e110748798148ff4613fbb4abccf14caf
parent9f80bcc2bc2d9221a67b39715b1b5443b263a091 (diff)
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
-rw-r--r--src/gallium/drivers/v3d/v3dx_emit.c10
1 files 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) {