[Mesa-dev] [PATCH 7/7] intel: Support s8z24 pure renderbuffers when using separate stencil
Chad Versace
chad at chad-versace.us
Wed Jun 15 17:34:44 PDT 2011
This adds support only for *pure* renderbuffers. Support for texture
renderbuffers is added in a subsequent patch.
Fixes the following Piglit tests from abort to pass on gen5 when
intel_screen.hw_must_use_separate_stencil and .hw_has_hiz are manually
enabled.
hiz-depth-read-fbo-d24s8
hiz-depth-stencil-test-fbo-d24s8
hiz-depth-test-fbo-d24s8
hiz-stencil-read-fbo-d24s8
Signed-off-by: Chad Versace <chad at chad-versace.us>
---
src/mesa/drivers/dri/intel/intel_fbo.c | 80 +++++++++++++++++++++++++++++++-
1 files changed, 79 insertions(+), 1 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 50ca131..db6b179 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -101,6 +101,11 @@ intel_get_pointer(struct gl_context * ctx, struct gl_renderbuffer *rb,
}
+static struct gl_renderbuffer *
+intel_create_renderbuffer_unwrapper(struct gl_context * ctx, gl_format format,
+ int width, int height);
+
+
/**
* Called via glRenderbufferStorageEXT() to set the format and allocate
* storage for a user-created renderbuffer.
@@ -195,6 +200,40 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
}
intel_region_reference(&irb->region, region);
+ } else if (irb->Base.Format == MESA_FORMAT_S8_Z24
+ && intel->has_separate_stencil) {
+
+ bool ok = true;
+ struct gl_renderbuffer *depth_rb;
+ struct gl_renderbuffer *stencil_rb;
+
+ depth_rb = intel_create_renderbuffer_unwrapper(ctx, MESA_FORMAT_X8_Z24,
+ width, height);
+ stencil_rb = intel_create_renderbuffer_unwrapper(ctx, MESA_FORMAT_S8,
+ width, height);
+ ok = depth_rb && stencil_rb;
+ ok = ok && intel_alloc_renderbuffer_storage(ctx, depth_rb,
+ depth_rb->InternalFormat,
+ width, height);
+ ok = ok && intel_alloc_renderbuffer_storage(ctx, stencil_rb,
+ stencil_rb->InternalFormat,
+ width, height);
+
+ if (!ok) {
+ if (depth_rb) {
+ intel_delete_renderbuffer(depth_rb);
+ }
+ if (stencil_rb) {
+ intel_delete_renderbuffer(stencil_rb);
+ }
+ return false;
+ }
+
+ _mesa_reference_renderbuffer(&irb->Base.Unwrapped[BUFFER_DEPTH],
+ depth_rb);
+ _mesa_reference_renderbuffer(&irb->Base.Unwrapped[BUFFER_STENCIL],
+ stencil_rb);
+
} else {
struct intel_region *region =
intel_region_alloc(intel->intelScreen, tiling, cpp,
@@ -402,6 +441,40 @@ intel_new_renderbuffer(struct gl_context * ctx, GLuint name)
}
+static struct gl_renderbuffer *
+intel_create_renderbuffer_unwrapper(struct gl_context * ctx, gl_format format,
+ int width, int height)
+{
+ /*
+ * The name here is irrelevant, as long as its nonzero, because the
+ * renderbuffer never gets entered into Mesa's renderbuffer hash table.
+ */
+ GLuint name = ~0;
+
+ struct intel_renderbuffer *irb = CALLOC_STRUCT(intel_renderbuffer);
+ if (!irb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+ return NULL;
+ }
+
+ struct gl_renderbuffer *rb = &irb->Base;
+ _mesa_init_renderbuffer(rb, name);
+ rb->ClassID = INTEL_RB_CLASS;
+ rb->_BaseFormat = _mesa_get_format_base_format(format);
+ rb->Format = format;
+ rb->InternalFormat = rb->_BaseFormat;
+ rb->DataType = intel_mesa_format_to_rb_datatype(format);
+ rb->Width = width;
+ rb->Height = height;
+
+ rb->AllocStorage = intel_nop_alloc_storage;
+ rb->Delete = intel_delete_renderbuffer;
+ rb->GetPointer = intel_get_pointer;
+
+ return rb;
+}
+
+
/**
* Called via glBindFramebufferEXT().
*/
@@ -730,10 +803,15 @@ intel_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
(depthRb && depthRb->Base.Format == MESA_FORMAT_S8_Z24) ||
(stencilRb && stencilRb->Base.Format == MESA_FORMAT_S8_Z24);
+ bool depth_stencil_are_unwrapped =
+ (depthRb && (&depthRb->Base == fb->Attachment[BUFFER_DEPTH].Renderbuffer->Unwrapped[BUFFER_DEPTH])) &&
+ (stencilRb && (&stencilRb->Base == fb->Attachment[BUFFER_STENCIL].Renderbuffer->Unwrapped[BUFFER_STENCIL]));
+
bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
if ((intel->must_use_separate_stencil || fb_has_hiz)
- && (depth_stencil_are_same || fb_has_combined_depth_stencil_format)) {
+ && (fb_has_combined_depth_stencil_format
+ || (depth_stencil_are_same && !depth_stencil_are_unwrapped))) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
} else if (!intel->has_separate_stencil && depthRb && stencilRb && !depth_stencil_are_same) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
--
1.7.5.2
More information about the mesa-dev
mailing list