As much as memset clears amuse me, I have to nak this patch as is. The memset you are using doesn't properly account for the Y-tiled format of the MCs buffer for certain surface sizes. I can explain more later but the short version is that the total_height parameter we have in intel_mipmap_tree may not be the full height of the tiled buffer. The total_height is only 4-aligned while the buffer is going to be 32-aligned (I think). The result is a partially-cleared surface. Incidentally, I think the memset we use when we create the MCs is wrong too. --Jason On Sep 25, 2014 11:28 AM, "Kenneth Graunke" <kenn...@whitecape.org> wrote:
> Fast color clears simply fill the MCS buffer with 0xff. If the MCS BO > is not busy, we can map it without stalling and simply use memset to do > that, without having to reprogram the entire GPU, draw rectangles, and > invoke pixel shaders. This is presumably cheaper. > > This code was swiped from intel_miptree_alloc_mcs, which clears the > buffer using memset when allocating the MCS. > > Improves performance in GpuTest Triangle by 5.09439% +/- 1.27536%. > Xonotic, EgyptHD, and many others also hit this path, but I was not > able to measure any performance increase in other applications. > > Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> > > Concerns I have which hopefully reviewers can address: > - Do we need to worry about clipping/scissoring/etc? I think our > fast color clear implementation only handles full surface clears, so we > should be OK. > - Do we need to check if the miptree BO is referenced/busy? Or is > checking the MCS really sufficient? > --- > src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c > b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c > index b4e75a7..43df2d0 100644 > --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c > +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c > @@ -503,6 +503,19 @@ brw_meta_fast_clear(struct brw_context *brw, struct > gl_framebuffer *fb, > if (irb->mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_CLEAR) > continue; > > + /* If the MCS isn't busy, just do a CPU-side memset rather than > + * reprogramming the whole GPU. > + */ > + if (!drm_intel_bo_references(brw->batch.bo, > irb->mt->mcs_mt->bo) && > + !drm_intel_bo_busy(irb->mt->mcs_mt->bo)) { > + void *data = intel_miptree_map_raw(brw, irb->mt->mcs_mt); > + memset(data, 0xff, > + irb->mt->mcs_mt->total_height * > irb->mt->mcs_mt->pitch); > + intel_miptree_unmap_raw(brw, irb->mt->mcs_mt); > + irb->mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_CLEAR; > + continue; > + } > + > /* Set fast_clear_state to RESOLVED so we don't try resolve them > when > * we draw, in case the mt is also bound as a texture. > */ > -- > 2.1.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev