Mesa (7.11): i915: Fix incorrect depth scaling when enabling/ disabling depth buffers.
Eric Anholt
anholt at kemper.freedesktop.org
Wed Jul 20 19:53:27 UTC 2011
Module: Mesa
Branch: 7.11
Commit: 891073fea30c3f9fc6f4cc216e23a6bc486e454d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=891073fea30c3f9fc6f4cc216e23a6bc486e454d
Author: Eric Anholt <eric at anholt.net>
Date: Tue Jul 12 13:47:21 2011 -0700
i915: Fix incorrect depth scaling when enabling/disabling depth buffers.
We were updating our new viewport using the old buffers' _WindowMap.m.
We can do less math and avoid using that deprecated matrix by just
folding the viewport calculation right in to the driver.
Fixes piglit fbo-depthtex.
(cherry picked from commit debf751aeaf0f02b9a7fc0e242ae3b97dde8416f)
---
src/mesa/drivers/dri/i915/i915_state.c | 43 ++++++++++++++-----------------
1 files changed, 19 insertions(+), 24 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index b876717..2b35ed7 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -401,31 +401,26 @@ void
intelCalcViewport(struct gl_context * ctx)
{
struct intel_context *intel = intel_context(ctx);
- const GLfloat *v = ctx->Viewport._WindowMap.m;
- const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
- GLfloat *m = intel->ViewportMatrix.m;
- GLfloat yScale, yBias;
-
- if (ctx->DrawBuffer->Name) {
- /* User created FBO */
- /* y=0=bottom */
- yScale = 1.0;
- yBias = 0.0;
- }
- else {
- /* window buffer, y=0=top */
- yScale = -1.0;
- yBias = ctx->DrawBuffer->Height;
- }
-
- m[MAT_SX] = v[MAT_SX];
- m[MAT_TX] = v[MAT_TX];
- m[MAT_SY] = v[MAT_SY] * yScale;
- m[MAT_TY] = v[MAT_TY] * yScale + yBias;
-
- m[MAT_SZ] = v[MAT_SZ] * depthScale;
- m[MAT_TZ] = v[MAT_TZ] * depthScale;
+ if (ctx->DrawBuffer->Name == 0) {
+ _math_matrix_viewport(&intel->ViewportMatrix,
+ ctx->Viewport.X,
+ ctx->DrawBuffer->Height - ctx->Viewport.Y,
+ ctx->Viewport.Width,
+ -ctx->Viewport.Height,
+ ctx->Viewport.Near,
+ ctx->Viewport.Far,
+ 1.0);
+ } else {
+ _math_matrix_viewport(&intel->ViewportMatrix,
+ ctx->Viewport.X,
+ ctx->Viewport.Y,
+ ctx->Viewport.Width,
+ ctx->Viewport.Height,
+ ctx->Viewport.Near,
+ ctx->Viewport.Far,
+ 1.0);
+ }
}
More information about the mesa-commit
mailing list