summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/intel/intel_buffers.c
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-06-16 14:12:54 -0700
committerChad Versace <[email protected]>2011-06-21 11:21:57 -0700
commit39d0e3632a4ccb10f2ce6578151e854ba52d3c0e (patch)
tree61656ec849d067bd7452d29e4369e61c85d7eaf7 /src/mesa/drivers/dri/intel/intel_buffers.c
parent23ed3b90c7f9056182307f9a69a56f748da331a3 (diff)
intel: Add fields to intel_renderbuffer for unwrapping packed depth/stencil buffers
Add the following fields: intel_renderbuffer.wrapped_depth; intel_renderbuffer.wrapped_stencil If the intel_context is using separate stencil and the renderbuffer has a packed depth/stencil format, then wrapped_depth and wrapped_stencil are the real renderbuffers. Alter the following functions to accomodate the wrapped buffers: intel_delete_renderbuffer intel_draw_buffer intel_get_renderbuffer intel_renderbuffer_map intel_renderbuffer_unmap Subsequent commits allocate renderbuffer storage for wrapped_depth and wrapped_stencil. Reviewed-by: Eric Anholt <[email protected]> Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/intel/intel_buffers.c')
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c82
1 files changed, 45 insertions, 37 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index 7eb50edc6b4..33f691bf5f3 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -28,7 +28,9 @@
#include "intel_context.h"
#include "intel_buffers.h"
#include "intel_fbo.h"
+
#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
/**
* Return pointer to current color drawing region, or NULL.
@@ -100,6 +102,26 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
return;
}
+ /*
+ * If intel_context is using separate stencil, but the depth attachment
+ * (gl_framebuffer.Attachment[BUFFER_DEPTH]) has a packed depth/stencil
+ * format, then we must install the real depth buffer at
+ * gl_framebuffer._DepthBuffer before calling _mesa_update_framebuffer.
+ * Otherwise, _mesa_update_framebuffer will create and install a swrast
+ * depth wrapper instead.
+ *
+ * Ditto for stencil.
+ */
+ irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+ if (irbDepth && irbDepth->Base.Format == MESA_FORMAT_X8_Z24) {
+ _mesa_reference_renderbuffer(&fb->_DepthBuffer, &irbDepth->Base);
+ }
+
+ irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+ if (irbStencil && irbStencil->Base.Format == MESA_FORMAT_S8) {
+ _mesa_reference_renderbuffer(&fb->_StencilBuffer, &irbStencil->Base);
+ }
+
/* Do this here, not core Mesa, since this function is called from
* many places within the driver.
*/
@@ -165,47 +187,33 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
}
- /***
- *** Get depth buffer region and check if we need a software fallback.
- ***/
- if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
- irbDepth = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
- if (irbDepth && irbDepth->region) {
- assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
- FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
- depthRegion = irbDepth->region;
- }
- else {
- FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
- depthRegion = NULL;
- }
- }
- else {
- /* not using depth buffer */
+ /* Check for depth fallback. */
+ if (irbDepth && irbDepth->region) {
+ assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
+ FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+ depthRegion = irbDepth->region;
+ } else if (irbDepth && !irbDepth->region) {
+ FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+ depthRegion = NULL;
+ } else { /* !irbDepth */
+ /* No fallback is needed because there is no depth buffer. */
FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
depthRegion = NULL;
}
- /***
- *** Stencil buffer
- ***/
- if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
- irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
- if (irbStencil && irbStencil->region) {
- if (!intel->has_separate_stencil)
- assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
- if (fb_has_hiz || intel->must_use_separate_stencil)
- assert(irbStencil->Base.Format == MESA_FORMAT_S8);
- if (irbStencil->Base.Format == MESA_FORMAT_S8)
- assert(intel->has_separate_stencil);
- FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
- }
- else {
- FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
- }
- }
- else {
- /* XXX FBO: instead of FALSE, pass ctx->Stencil._Enabled ??? */
+ /* Check for stencil fallback. */
+ if (irbStencil && irbStencil->region) {
+ if (!intel->has_separate_stencil)
+ assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+ if (fb_has_hiz || intel->must_use_separate_stencil)
+ assert(irbStencil->Base.Format == MESA_FORMAT_S8);
+ if (irbStencil->Base.Format == MESA_FORMAT_S8)
+ assert(intel->has_separate_stencil);
+ FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+ } else if (irbStencil && !irbStencil->region) {
+ FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+ } else { /* !irbStencil */
+ /* No fallback is needed because there is no stencil buffer. */
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
}