mesa: add helper func for checking combined depthstencil buffers from st/mesa
authorMarek Olšák <maraeo@gmail.com>
Thu, 14 Mar 2013 13:22:56 +0000 (14:22 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 23 Mar 2013 12:17:05 +0000 (13:17 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com>
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/state_tracker/st_cb_blit.c
src/mesa/state_tracker/st_cb_fbo.c
src/mesa/state_tracker/st_cb_fbo.h

index 0126e2930517c78d36f6dbd7417283e630259c55..d7e15e1ce6cf1a34fb146b1fff9f4c4d66be3efb 100644 (file)
@@ -473,6 +473,32 @@ _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
 }
 
 
+/**
+ * Return true if the framebuffer has a combined depth/stencil
+ * renderbuffer attached.
+ */
+GLboolean
+_mesa_has_depthstencil_combined(const struct gl_framebuffer *fb)
+{
+   const struct gl_renderbuffer_attachment *depth =
+         &fb->Attachment[BUFFER_DEPTH];
+   const struct gl_renderbuffer_attachment *stencil =
+         &fb->Attachment[BUFFER_STENCIL];
+
+   if (depth->Type == stencil->Type) {
+      if (depth->Type == GL_RENDERBUFFER_EXT &&
+          depth->Renderbuffer == stencil->Renderbuffer)
+         return GL_TRUE;
+
+      if (depth->Type == GL_TEXTURE &&
+          depth->Texture == stencil->Texture)
+         return GL_TRUE;
+   }
+
+   return GL_FALSE;
+}
+
+
 /**
  * For debug only.
  */
index ec8b0afe410751b9d69df505336fbb3891d57e1a..0358864d7982beb1a23ffe28f0bf8cf97e376d71 100644 (file)
@@ -113,6 +113,9 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
 extern void
 _mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
 
+extern GLboolean
+_mesa_has_depthstencil_combined(const struct gl_framebuffer *fb);
+
 extern void
 _mesa_test_framebuffer_completeness(struct gl_context *ctx,
                                     struct gl_framebuffer *fb);
index c463e3b047ab323740afb5a3b3f9164b16aba1f8..50cab4294da31ae658521353a560bf53162b0a49 100644 (file)
@@ -239,31 +239,22 @@ st_BlitFramebuffer(struct gl_context *ctx,
       /* depth and/or stencil blit */
 
       /* get src/dst depth surfaces */
-      struct gl_renderbuffer_attachment *srcDepth =
-         &readFB->Attachment[BUFFER_DEPTH];
-      struct gl_renderbuffer_attachment *dstDepth =
-         &drawFB->Attachment[BUFFER_DEPTH];
-      struct gl_renderbuffer_attachment *srcStencil =
-         &readFB->Attachment[BUFFER_STENCIL];
-      struct gl_renderbuffer_attachment *dstStencil =
-         &drawFB->Attachment[BUFFER_STENCIL];
-
       struct st_renderbuffer *srcDepthRb =
-         st_renderbuffer(srcDepth->Renderbuffer);
+         st_renderbuffer(readFB->Attachment[BUFFER_DEPTH].Renderbuffer);
       struct st_renderbuffer *dstDepthRb = 
-         st_renderbuffer(dstDepth->Renderbuffer);
+         st_renderbuffer(drawFB->Attachment[BUFFER_DEPTH].Renderbuffer);
       struct pipe_surface *dstDepthSurf =
          dstDepthRb ? dstDepthRb->surface : NULL;
 
       struct st_renderbuffer *srcStencilRb =
-         st_renderbuffer(srcStencil->Renderbuffer);
+         st_renderbuffer(readFB->Attachment[BUFFER_STENCIL].Renderbuffer);
       struct st_renderbuffer *dstStencilRb =
-         st_renderbuffer(dstStencil->Renderbuffer);
+         st_renderbuffer(drawFB->Attachment[BUFFER_STENCIL].Renderbuffer);
       struct pipe_surface *dstStencilSurf =
          dstStencilRb ? dstStencilRb->surface : NULL;
 
-      if (st_is_depth_stencil_combined(srcDepth, srcStencil) &&
-          st_is_depth_stencil_combined(dstDepth, dstStencil)) {
+      if (_mesa_has_depthstencil_combined(readFB) &&
+          _mesa_has_depthstencil_combined(drawFB)) {
          blit.mask = 0;
          if (mask & GL_DEPTH_BUFFER_BIT)
             blit.mask |= PIPE_MASK_Z;
index 87c5b048c564fbecc16fad97b8adad74a3bc3d90..4452e523b68ea8036d158176320c90a95700d50e 100644 (file)
@@ -547,30 +547,6 @@ st_validate_attachment(struct gl_context *ctx,
 
    return valid;
 }
-
-
-/**
- * Check if two renderbuffer attachments name a combined depth/stencil
- * renderbuffer.
- */
-GLboolean
-st_is_depth_stencil_combined(const struct gl_renderbuffer_attachment *depth,
-                             const struct gl_renderbuffer_attachment *stencil)
-{
-   assert(depth && stencil);
-
-   if (depth->Type == stencil->Type) {
-      if (depth->Type == GL_RENDERBUFFER_EXT &&
-          depth->Renderbuffer == stencil->Renderbuffer)
-         return GL_TRUE;
-
-      if (depth->Type == GL_TEXTURE &&
-          depth->Texture == stencil->Texture)
-         return GL_TRUE;
-   }
-
-   return GL_FALSE;
-}
  
 
 /**
index 506fd06d68087797acebb786d7dd12355c05e233..461dbe985970cab343825c91f26cd13839a5e860 100644 (file)
@@ -76,9 +76,4 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw);
 extern void
 st_init_fbo_functions(struct dd_function_table *functions);
 
-extern GLboolean
-st_is_depth_stencil_combined(const struct gl_renderbuffer_attachment *depth,
-                             const struct gl_renderbuffer_attachment *stencil);
-
-
 #endif /* ST_CB_FBO_H */