diff options
author | Chad Versace <[email protected]> | 2011-06-17 12:12:35 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2011-06-21 11:22:05 -0700 |
commit | 3db27d4a4aee9f311a447778ce94007415f2637f (patch) | |
tree | cf8546ce60c173a613df1f9918375d03ec1f6dac /src/mesa | |
parent | 36e05c6870fc466053b4f54edd890e19d5ac9dcf (diff) |
intel: Allocate s8_z24 non-texture renderbuffers when using separate stencil
Now all infrastructure is in place to support s8_z24 non-texture
renderbuffers for gen7.
Reviewed-by: Eric Anholt <[email protected]>
Signed-off-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_fbo.c | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index ff09b5dc7e7..f48703e155c 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -107,6 +107,12 @@ intel_get_pointer(struct gl_context * ctx, struct gl_renderbuffer *rb, } +static struct gl_renderbuffer* +intel_create_wrapped_renderbuffer(struct gl_context * ctx, + struct gl_renderbuffer *wrapper, + gl_format format); + + /** * Called via glRenderbufferStorageEXT() to set the format and allocate * storage for a user-created renderbuffer. @@ -147,6 +153,8 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer break; } + rb->Width = width; + rb->Height = height; rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); rb->DataType = intel_mesa_format_to_rb_datatype(rb->Format); cpp = _mesa_get_format_bytes(rb->Format); @@ -199,6 +207,38 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer if (!irb->region) return false; + } else if (irb->Base.Format == MESA_FORMAT_S8_Z24 + && intel->must_use_separate_stencil) { + + bool ok = true; + struct gl_renderbuffer *depth_rb; + struct gl_renderbuffer *stencil_rb; + + depth_rb = intel_create_wrapped_renderbuffer(ctx, rb, + MESA_FORMAT_X8_Z24); + stencil_rb = intel_create_wrapped_renderbuffer(ctx, rb, + MESA_FORMAT_S8); + 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->wrapped_depth, depth_rb); + _mesa_reference_renderbuffer(&irb->wrapped_stencil, stencil_rb); + } else { irb->region = intel_region_alloc(intel->intelScreen, tiling, cpp, width, height, GL_TRUE); @@ -219,9 +259,6 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer } } - rb->Width = width; - rb->Height = height; - return GL_TRUE; } @@ -372,6 +409,47 @@ intel_create_renderbuffer(gl_format format) } +static struct gl_renderbuffer * +intel_create_wrapped_renderbuffer(struct gl_context * ctx, + struct gl_renderbuffer *wrapper, + gl_format format) +{ + /* + * 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 = wrapper->Width; + rb->Height = wrapper->Height; + + rb->AllocStorage = intel_nop_alloc_storage; + rb->Delete = intel_delete_renderbuffer; + rb->GetPointer = intel_get_pointer; + + /* + * A refcount here would cause a cyclic reference. The wrapper references + * the unwrapper. + */ + rb->Wrapped = wrapper; + + return rb; +} + + /** * Create a new renderbuffer object. * Typically called via glBindRenderbufferEXT(). |