try to fix renderbuffer breakage, primarily in calculate_buffer_parameters()
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 7 Sep 2005 18:32:29 +0000 (18:32 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 7 Sep 2005 18:32:29 +0000 (18:32 +0000)
src/mesa/drivers/dri/unichrome/via_context.c

index 0f504ee..64f4e28 100644 (file)
@@ -211,25 +211,45 @@ calculate_buffer_parameters( struct via_context *vmesa,
     * state!
     * That should be fixed someday.
     */
-   _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base);
-   _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base);
-   _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base);
-   _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base);
 
    if (!vmesa->front.Base.InternalFormat) {
       /* do one-time init for the renderbuffers */
       viaInitRenderbuffer(&vmesa->front.Base, GL_RGBA);
-      viaInitRenderbuffer(&vmesa->back.Base, GL_RGBA);
+      viaSetSpanFunctions(&vmesa->front, &fb->Visual);
+      _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &vmesa->front.Base);
+
+      if (fb->Visual.doubleBufferMode) {
+         viaInitRenderbuffer(&vmesa->back.Base, GL_RGBA);
+         viaSetSpanFunctions(&vmesa->back, &fb->Visual);
+         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &vmesa->back.Base);
+      }
+
       if (vmesa->glCtx->Visual.depthBits > 0) {
          viaInitRenderbuffer(&vmesa->depth.Base, 
                              (vmesa->glCtx->Visual.depthBits == 16
                               ? GL_DEPTH_COMPONENT16 : GL_DEPTH_COMPONENT24));
+         viaSetSpanFunctions(&vmesa->depth, &fb->Visual);
+         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &vmesa->depth.Base);
       }
+
       if (vmesa->glCtx->Visual.stencilBits > 0) {
          viaInitRenderbuffer(&vmesa->stencil.Base, GL_STENCIL_INDEX8_EXT);
+         viaSetSpanFunctions(&vmesa->stencil, &fb->Visual);
+         _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &vmesa->stencil.Base);
       }
    }
 
+   assert(vmesa->front.Base.InternalFormat);
+   assert(vmesa->front.Base.AllocStorage);
+   if (fb->Visual.doubleBufferMode) {
+      assert(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+      assert(vmesa->front.Base.AllocStorage);
+   }
+   if (fb->Visual.depthBits) {
+      assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
+      assert(vmesa->depth.Base.AllocStorage);
+   }
+
 
    /* Allocate front-buffer */
    if (vmesa->drawType == GLX_PBUFFER_BIT) {
@@ -329,13 +349,9 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
 {
     struct via_context *vmesa = VIA_CONTEXT(ctx);
 
-#if 0
-    _swrast_alloc_buffers( drawbuffer );
-#else
-    _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
-#endif
-
     calculate_buffer_parameters( vmesa, drawbuffer );
+
+    _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
 }
 
 static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)