nouveau: nv10: also check ctx->DrawBuffer in nv10ViewportScale
authorPatrice Mandin <pmandin@caramail.com>
Tue, 20 Feb 2007 22:13:48 +0000 (23:13 +0100)
committerPatrice Mandin <pmandin@caramail.com>
Tue, 20 Feb 2007 22:13:48 +0000 (23:13 +0100)
src/mesa/drivers/dri/nouveau/nv10_state.c

index 09fc07556d92cbd2c8181863fead08e1da00ada2..e204eba6ba2a02f8fc1f5731ea97778ec43dba36 100644 (file)
@@ -41,13 +41,18 @@ static void nv10ViewportScale(nouveauContextPtr nmesa)
        GLuint h = ctx->Viewport.Height;
 
        GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5;
-       switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
-               case 16:
-                       max_depth *= 32767.0;
-                       break;
-               case 24:
-                       max_depth *= 16777215.0;
-                       break;
+       if (ctx->DrawBuffer) {
+               switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
+                       case 16:
+                               max_depth *= 32767.0;
+                               break;
+                       case 24:
+                               max_depth *= 16777215.0;
+                               break;
+               }
+       } else {
+               /* Default to 24 bits range */  
+               max_depth *= 16777215.0;
        }
 
        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4);