[Mesa-dev] [PATCH] i965: Fix crash from calling brw_depthbuffer_format with no Z buffer.

Kenneth Graunke kenneth at whitecape.org
Tue Dec 6 16:12:56 PST 2011


Fixes a regression on Ivybridge (didn't track it down).  +3992 piglits.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/gen7_sf_state.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_sf_state.c b/src/mesa/drivers/dri/i965/gen7_sf_state.c
index 8876722..c4ec20c 100644
--- a/src/mesa/drivers/dri/i965/gen7_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sf_state.c
@@ -27,6 +27,7 @@
 #include "brw_util.h"
 #include "main/macros.h"
 #include "intel_batchbuffer.h"
+#include "intel_fbo.h"
 
 static void
 upload_sbe_state(struct brw_context *brw)
@@ -149,12 +150,15 @@ upload_sf_state(struct brw_context *brw)
    uint32_t dw1, dw2, dw3;
    float point_size;
    /* _NEW_BUFFERS */
-   bool render_to_fbo = brw->intel.ctx.DrawBuffer->Name != 0;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   struct intel_renderbuffer *drb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   bool render_to_fbo = fb->Name != 0;
 
    dw1 = GEN6_SF_STATISTICS_ENABLE | GEN6_SF_VIEWPORT_TRANSFORM_ENABLE;
 
    /* _NEW_BUFFERS */
-   dw1 |= (brw_depthbuffer_format(brw) << GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT);
+   dw1 |= (drb ? brw_depthbuffer_format(brw) : BRW_DEPTHFORMAT_D32_FLOAT)
+	   << GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT;
 
    /* _NEW_POLYGON */
    if ((ctx->Polygon.FrontFace == GL_CCW) ^ render_to_fbo)
-- 
1.7.7.3



More information about the mesa-dev mailing list