From 24da7335b22432ef4c2d57cab86e4b8fbe8733d5 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 15 Nov 2011 10:05:21 -0800 Subject: [PATCH] intel: Track the miptree layer wrapped by a renderbuffer [v2] TODO: Make v2 for kwg. Add two fields to intel_renderbuffer: mt_level mt_layer Multiple renderbuffers may simultaneously wrap a single texture and each provide a different view into that texture. [Consider glFramebufferTextureLayer()]. The new fields indicate which slice of the miptree is wrapped by the renderbuffer. The buffer resolve operations, to be introduced in the future, require these fields in order to resolve the correct slice in the miptree. To add the fields, it was necessary to replace the type of some function parameters from gl_texture_image to gl_renderbuffer_attachment. v2: [kwg] Replace confusing condition `CubeMapFace > 0` with the more sensible `Target == GL_TEXTURE_CUBE_MAP`. Reviewed-by: Eric Anholt Reviewed-by: Kenneth Graunke Signed-off-by: Chad Versace --- src/mesa/drivers/dri/intel/intel_fbo.c | 37 ++++++++++++++++++++++---- src/mesa/drivers/dri/intel/intel_fbo.h | 17 ++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index e5328df2ff5..252f2425f2a 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -948,8 +948,9 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx, static bool intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, - struct gl_texture_image *texImage) + struct gl_renderbuffer_attachment *att) { + struct gl_texture_image *texImage = _mesa_get_attachment_teximage(att); struct intel_texture_image *intel_image = intel_texture_image(texImage); int width, height, depth; @@ -973,15 +974,40 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, irb->Base.Delete = intel_delete_renderbuffer; irb->Base.AllocStorage = intel_nop_alloc_storage; + irb->mt_level = att->TextureLevel; + if (texImage->TexObject->Target == GL_TEXTURE_CUBE_MAP) { + assert(att->Zoffset == 0); + irb->mt_layer = att->CubeMapFace; + } else { + assert(att->CubeMapFace == 0); + irb->mt_layer= att->Zoffset; + } + if (intel_image->stencil_rb) { /* The tex image has packed depth/stencil format, but is using separate * stencil. It shares its embedded depth and stencil renderbuffers with * the renderbuffer wrapper. + * + * FIXME: glFramebufferTexture*() is broken for depthstencil textures + * FIXME: with separate stencil. To fix this, we must create a separate + * FIXME: pair of depth/stencil renderbuffers for each attached slice + * FIXME: of the miptree. */ + struct intel_renderbuffer *depth_irb; + struct intel_renderbuffer *stencil_irb; + _mesa_reference_renderbuffer(&irb->wrapped_depth, intel_image->depth_rb); _mesa_reference_renderbuffer(&irb->wrapped_stencil, intel_image->stencil_rb); + + depth_irb = intel_renderbuffer(intel_image->depth_rb); + depth_irb->mt_level = irb->mt_level; + depth_irb->mt_layer = irb->mt_layer; + + stencil_irb = intel_renderbuffer(intel_image->stencil_rb); + stencil_irb->mt_level = irb->mt_level; + stencil_irb->mt_layer = irb->mt_layer; } else { intel_miptree_reference(&irb->mt, intel_image->mt); } @@ -994,7 +1020,8 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, * This will have the region info needed for hardware rendering. */ static struct intel_renderbuffer * -intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage) +intel_wrap_texture(struct gl_context * ctx, + struct gl_renderbuffer_attachment *att) { const GLuint name = ~0; /* not significant, but distinct for debugging */ struct intel_renderbuffer *irb; @@ -1009,7 +1036,7 @@ intel_wrap_texture(struct gl_context * ctx, struct gl_texture_image *texImage) _mesa_init_renderbuffer(&irb->Base, name); irb->Base.ClassID = INTEL_RB_CLASS; - if (!intel_update_wrapper(ctx, irb, texImage)) { + if (!intel_update_wrapper(ctx, irb, att)) { free(irb); return NULL; } @@ -1114,7 +1141,7 @@ intel_render_texture(struct gl_context * ctx, return; } else if (!irb) { - irb = intel_wrap_texture(ctx, image); + irb = intel_wrap_texture(ctx, att); if (irb) { /* bind the wrapper to the attachment point */ _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base); @@ -1126,7 +1153,7 @@ intel_render_texture(struct gl_context * ctx, } } - if (!intel_update_wrapper(ctx, irb, image)) { + if (!intel_update_wrapper(ctx, irb, att)) { _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); _swrast_render_texture(ctx, fb, att); return; diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h index 34d2f9a61cf..3a213745e38 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.h +++ b/src/mesa/drivers/dri/intel/intel_fbo.h @@ -51,6 +51,23 @@ struct intel_renderbuffer GLuint map_x, map_y, map_w, map_h; GLbitfield map_mode; + /** + * \name Miptree view + * \{ + * + * Multiple renderbuffers may simultaneously wrap a single texture and each + * provide a different view into that texture. The fields below indicate + * which miptree slice is wrapped by this renderbuffer. The fields' values + * are consistent with the 'level' and 'layer' parameters of + * glFramebufferTextureLayer(). + * + * For renderbuffers not created with glFramebufferTexture*(), mt_level and + * mt_layer are 0. + */ + unsigned int mt_level; + unsigned int mt_layer; + /** \} */ + /** * \name Packed depth/stencil unwrappers * -- 2.30.2