mesa: move depth/stencil buffer validation to swrast
authorBrian Paul <brianp@vmware.com>
Sat, 10 Dec 2011 18:44:43 +0000 (11:44 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 13 Dec 2011 13:45:37 +0000 (06:45 -0700)
Since gl_framebuffer::_DepthBuffer and _StencilBuffer are only used
by swrast, do the validation of those fields in swrast too.
The main/depthstencil.[ch] code is no longer used and will be removed
next.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/framebuffer.c
src/mesa/swrast/s_context.c

index 0185622009a402177fd6668759755a8365fe35a4..4a4ade0961e41dca6df23e0f9d43b2963ecb05a4 100644 (file)
@@ -34,7 +34,6 @@
 #include "imports.h"
 #include "buffers.h"
 #include "context.h"
-#include "depthstencil.h"
 #include "enums.h"
 #include "formats.h"
 #include "macros.h"
@@ -738,8 +737,6 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
     */
    update_color_draw_buffers(ctx, fb);
    update_color_read_buffer(ctx, fb);
-   _mesa_update_depth_buffer(ctx, fb);
-   _mesa_update_stencil_buffer(ctx, fb);
 
    compute_depth_max(fb);
 }
index 924612578e29f473e10432dd0619479cf9f6d9c8..6850a09f364eb7554c001de546f95ddb5bd368b0 100644 (file)
@@ -36,6 +36,7 @@
 #include "swrast.h"
 #include "s_blend.h"
 #include "s_context.h"
+#include "s_depthstencil.h"
 #include "s_lines.h"
 #include "s_points.h"
 #include "s_span.h"
@@ -545,6 +546,25 @@ _swrast_update_active_attribs(struct gl_context *ctx)
 }
 
 
+/**
+ * Update the depth/stencil renderbuffers, if needed.
+ */
+static void
+_swrast_update_depth_stencil(struct gl_context *ctx)
+{
+   struct gl_framebuffer *drawFb = ctx->DrawBuffer;
+   struct gl_framebuffer *readFb = ctx->ReadBuffer;
+
+   _swrast_update_depth_buffer(ctx, drawFb);
+   _swrast_update_stencil_buffer(ctx, drawFb);
+
+   if (readFb != drawFb) {
+      _swrast_update_depth_buffer(ctx, readFb);
+      _swrast_update_stencil_buffer(ctx, readFb);
+   }
+}
+
+
 void
 _swrast_validate_derived( struct gl_context *ctx )
 {
@@ -589,6 +609,9 @@ _swrast_validate_derived( struct gl_context *ctx )
                               _NEW_TEXTURE))
          _swrast_update_specular_vertex_add(ctx);
 
+      if (swrast->NewState & _NEW_BUFFERS)
+         _swrast_update_depth_stencil(ctx);
+
       swrast->NewState = 0;
       swrast->StateChanges = 0;
       swrast->InvalidateState = _swrast_invalidate_state;