This patch fixes three interrelated bugs. Fixes many depthstencil Piglit tests on gen7, too many to list.
1. Don't map the depthstencil buffer twice ------------------------------------------ Place a guard in intel_renderbuffer_map() to prevent a renderbuffer from being mapped twice. This happened if a single buffer was attached to the framebuffer's depth and stencil attachment points. (Interestingly, because intel_map_renderbuffer_gtt() is idempotent, the double mapping did not cause bugs for depthstencil buffers *without* separate stencil). 2. Stop using the special stencil span accessors ------------------------------------------------ The special stencil span accessors, as set by intel_span_init_funcs. perform software W detiling. Since intel_renderbuffer_map() now uses MapRenderbuffer, rb->Data points to an *untiled* stencil buffer. 3. Stop overriding gl_framebuffer::_DepthBuffer,_StencilBuffer -------------------------------------------------------------- Normally, if a depthstencil buffer is attached to the framebuffer's depth attachment point, then _mesa_update_framebuffer() installs a wrapper depth renderbuffer at gl_framebuffer::_DepthBuffer. Ditto for the stencil attachment point and gl_framebuffer::_StencilBuffer A depthstencil intel_renderbuffer with separate stencil contains hidden depth and stencil renderbuffers, which are the *real* renderbuffers. In order to force swrast to work, we were installing, in brw_update_draw_buffer(), the hidden renderbuffers at gl_framebuffer::_DepthBuffer and _StencilBuffer, thus overriding the behavior of _mesa_update_framebuffer(). However, now that intel_renderbuffer_map() is implemented with MapRenderbuffer(), overriding _mesa_update_framebuffer's introduces bugs (You really don't want the horrid, detailed explanation, so I'll spare you...). This patch removes the override code. CC: Eric Anholt <[email protected]> Signed-off-by: Chad Versace <[email protected]> --- src/mesa/drivers/dri/i965/brw_vtbl.c | 19 --------- src/mesa/drivers/dri/intel/intel_span.c | 66 +++++++------------------------ 2 files changed, 15 insertions(+), 70 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 7c40f27..3e21641 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -103,27 +103,8 @@ brw_update_draw_buffer(struct intel_context *intel) 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 fb->_DepthBuffer - * and set fb->_DepthBuffer->Wrapped before calling _mesa_update_framebuffer. - * Otherwise, _mesa_update_framebuffer will create and install a swras - * 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); - irbDepth->Base.Wrapped = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - } - irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL); - if (irbStencil && irbStencil->Base.Format == MESA_FORMAT_S8) { - _mesa_reference_renderbuffer(&fb->_StencilBuffer, &irbStencil->Base); - irbStencil->Base.Wrapped = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - } /* Do this here, not core Mesa, since this function is called from * many places within the driver. diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 271d2e1..b103bbd 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -114,41 +114,6 @@ intel_set_span_functions(struct intel_context *intel, #define TAG2(x,y) intel_##x##y##_A8 #include "spantmp2.h" -/* ------------------------------------------------------------------------- */ -/* s8 stencil span and pixel functions */ -/* ------------------------------------------------------------------------- */ - -/* - * HAVE_HW_STENCIL_SPANS determines if stencil buffer read/writes are done with - * memcpy or for loops. Since the stencil buffer is interleaved, memcpy won't - * work. - */ -#define HAVE_HW_STENCIL_SPANS 0 - -#define LOCAL_STENCIL_VARS \ - (void) ctx; \ - int minx = 0; \ - int miny = 0; \ - int maxx = rb->Width; \ - int maxy = rb->Height; \ - \ - /* \ - * Here we ignore rb->Data and rb->RowStride as set by \ - * intelSpanRenderStart. Since intel_offset_S8 decodes the W tile \ - * manually, the region's *real* base address and stride is \ - * required. \ - */ \ - struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ - uint8_t *buf = irb->region->bo->virtual; \ - unsigned stride = irb->region->pitch; \ - unsigned height = irb->region->height; \ - bool flip = rb->Name == 0; \ - int y_scale = flip ? -1 : 1; \ - int y_bias = flip ? (height * 2 + height % 2 - 1) : 0; \ - -#undef Y_FLIP -#define Y_FLIP(y) (y_scale * (y) + y_bias) - /** * \brief Get pointer offset into stencil buffer. * @@ -211,13 +176,6 @@ intel_offset_S8(uint32_t stride, uint32_t x, uint32_t y) return u; } -#define WRITE_STENCIL(x, y, src) buf[intel_offset_S8(stride, x, y)] = src; -#define READ_STENCIL(dest, x, y) dest = buf[intel_offset_S8(stride, x, y)] -#define TAG(x) intel_##x##_S8 -#include "stenciltmp.h" - -/* ------------------------------------------------------------------------- */ - void intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb) { @@ -229,10 +187,13 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb) if (!irb) return; - if (irb->wrapped_depth) - intel_renderbuffer_map(intel, irb->wrapped_depth); - if (irb->wrapped_stencil) - intel_renderbuffer_map(intel, irb->wrapped_stencil); + if (rb->Data) { + /* Renderbuffer is already mapped. This usually happens when a single + * buffer is attached to the framebuffer's depth and stencil attachment + * points. + */ + return; + } ctx->Driver.MapRenderbuffer(ctx, rb, 0, 0, rb->Width, rb->Height, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, @@ -253,10 +214,13 @@ intel_renderbuffer_unmap(struct intel_context *intel, if (!irb) return; - if (irb->wrapped_depth) - intel_renderbuffer_unmap(intel, irb->wrapped_depth); - if (irb->wrapped_stencil) - intel_renderbuffer_unmap(intel, irb->wrapped_stencil); + if (!rb->Data) { + /* Renderbuffer is already unmapped. This usually happens when a single + * buffer is attached to the framebuffer's depth and stencil attachment + * points. + */ + return; + } ctx->Driver.UnmapRenderbuffer(ctx, rb); @@ -406,7 +370,7 @@ static span_init_func intel_span_init_funcs[MESA_FORMAT_COUNT] = [MESA_FORMAT_Z16] = _mesa_set_renderbuffer_accessors, [MESA_FORMAT_X8_Z24] = _mesa_set_renderbuffer_accessors, [MESA_FORMAT_S8_Z24] = _mesa_set_renderbuffer_accessors, - [MESA_FORMAT_S8] = intel_InitStencilPointers_S8, + [MESA_FORMAT_S8] = _mesa_set_renderbuffer_accessors, [MESA_FORMAT_R8] = _mesa_set_renderbuffer_accessors, [MESA_FORMAT_RG88] = _mesa_set_renderbuffer_accessors, [MESA_FORMAT_R16] = _mesa_set_renderbuffer_accessors, -- 1.7.7.1 _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
