Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97231 Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> Cc: "11.2 12.0" <mesa-sta...@lists.freedesktop.org> --- src/gallium/drivers/nouveau/nv50/nv50_state_validate.c | 18 ++++++++++++++---- src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c index 19181a9..1dd3647 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c @@ -265,13 +265,23 @@ nv50_validate_viewport(struct nv50_context *nv50) PUSH_DATAf(push, vpt->scale[1]); PUSH_DATAf(push, vpt->scale[2]); - zmin = vpt->translate[2] - fabsf(vpt->scale[2]); - zmax = vpt->translate[2] + fabsf(vpt->scale[2]); + /* If the halfz setting ever changes, the viewports will also get + * updated. The rast will get updated before the validate function has a + * chance to hit, so we can just use it directly without an atom + * dependency. + */ + if (nv50->rast->pipe.clip_halfz) { + zmin = vpt->translate[2]; + zmax = vpt->translate[2] + vpt->scale[2]; + } else { + zmin = vpt->translate[2] - vpt->scale[2]; + zmax = vpt->translate[2] + vpt->scale[2]; + } #ifdef NV50_SCISSORS_CLIPPING BEGIN_NV04(push, NV50_3D(DEPTH_RANGE_NEAR(i)), 2); - PUSH_DATAf(push, zmin); - PUSH_DATAf(push, zmax); + PUSH_DATAf(push, zmin < zmax ? zmin : zmax); + PUSH_DATAf(push, zmin < zmax ? zmax : zmin); #endif } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index 160abae..3791c27 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -329,12 +329,22 @@ nvc0_validate_viewport(struct nvc0_context *nvc0) PUSH_DATA (push, (w << 16) | x); PUSH_DATA (push, (h << 16) | y); - zmin = vp->translate[2] - fabsf(vp->scale[2]); - zmax = vp->translate[2] + fabsf(vp->scale[2]); + /* If the halfz setting ever changes, the viewports will also get + * updated. The rast will get updated before the validate function has a + * chance to hit, so we can just use it directly without an atom + * dependency. + */ + if (nvc0->rast->pipe.clip_halfz) { + zmin = vp->translate[2]; + zmax = vp->translate[2] + vp->scale[2]; + } else { + zmin = vp->translate[2] - vp->scale[2]; + zmax = vp->translate[2] + vp->scale[2]; + } BEGIN_NVC0(push, NVC0_3D(DEPTH_RANGE_NEAR(i)), 2); - PUSH_DATAf(push, zmin); - PUSH_DATAf(push, zmax); + PUSH_DATAf(push, zmin < zmax ? zmin : zmax); + PUSH_DATAf(push, zmin < zmax ? zmax : zmin); } nvc0->viewports_dirty = 0; } -- 2.7.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev