On Fri, May 04, 2018 at 09:42:34AM -0700, Nanley Chery wrote:
> On Thu, May 03, 2018 at 12:03:50PM -0700, Nanley Chery wrote:
> > Add infrastructure for initializing the clear color BO.
> > ---
> >  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 68 
> > ++++++++++++---------------
> >  1 file changed, 31 insertions(+), 37 deletions(-)
> > 
> > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
> > b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > index 182a896e23a..5d3ee569bd8 100644
> > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> > @@ -1658,41 +1658,13 @@ intel_miptree_copy_teximage(struct brw_context *brw,
> >     intel_obj->needs_validate = true;
> >  }
> >  
> > -static bool
> > -intel_miptree_init_mcs(struct brw_context *brw,
> > -                       struct intel_mipmap_tree *mt,
> > -                       int init_value)
> > -{
> > -   assert(mt->aux_buf != NULL);
> > -
> > -   /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
> > -    *
> > -    *     When MCS buffer is enabled and bound to MSRT, it is required 
> > that it
> > -    *     is cleared prior to any rendering.
> > -    *
> > -    * Since we don't use the MCS buffer for any purpose other than 
> > rendering,
> > -    * it makes sense to just clear it immediately upon allocation.
> > -    *
> > -    * Note: the clear value for MCS buffers is all 1's, so we memset to 
> > 0xff.
> > -    */
> > -   void *map = brw_bo_map(brw, mt->aux_buf->bo, MAP_WRITE | MAP_RAW);
> > -   if (unlikely(map == NULL)) {
> > -      fprintf(stderr, "Failed to map mcs buffer into GTT\n");
> > -      intel_miptree_aux_buffer_free(mt->aux_buf);
> > -      mt->aux_buf = NULL;
> > -      return false;
> > -   }
> > -   void *data = map;
> > -   memset(data, init_value, mt->aux_buf->size);
> > -   brw_bo_unmap(mt->aux_buf->bo);
> > -   return true;
> > -}
> > -
> >  static struct intel_miptree_aux_buffer *
> >  intel_alloc_aux_buffer(struct brw_context *brw,
> >                         const char *name,
> >                         const struct isl_surf *aux_surf,
> >                         uint32_t alloc_flags,
> > +                       bool wants_memset,
> > +                       uint8_t memset_value,
> >                         struct intel_mipmap_tree *mt)
> >  {
> >     struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);
> > @@ -1725,6 +1697,19 @@ intel_alloc_aux_buffer(struct brw_context *brw,
> >        return NULL;
> >     }
> >  
> > +   /* Initialize the bo to the desired value */
> > +   if (wants_memset) {
> > +      assert(!(alloc_flags & BO_ALLOC_BUSY));
> > +
> > +      void *map = brw_bo_map(brw, buf->bo, MAP_WRITE | MAP_RAW);
> > +      if (map == NULL) {
> > +         intel_miptree_aux_buffer_free(buf);
> > +         return NULL;
> > +      }
> > +      memset(map, memset_value, mt->aux_buf->size);
> 
> Found a bug here. The last argument should be buf->size because
> mt->aux_buf hasn't been assigned yet. Will fix locally.
> 
> -Nanley
> 

False alarm. Sorry for the noise.

-Nanley

> > +      brw_bo_unmap(buf->bo);
> > +   }
> > +
> >     if (devinfo->gen >= 10) {
> >        buf->clear_color_bo = buf->bo;
> >        brw_bo_reference(buf->clear_color_bo);
> > @@ -1763,10 +1748,19 @@ intel_miptree_alloc_mcs(struct brw_context *brw,
> >      * to be just used by the GPU.
> >      */
> >     const uint32_t alloc_flags = 0;
> > -   mt->aux_buf = intel_alloc_aux_buffer(brw, "mcs-miptree",
> > -                                        &temp_mcs_surf, alloc_flags, mt);
> > -   if (!mt->aux_buf ||
> > -       !intel_miptree_init_mcs(brw, mt, 0xFF)) {
> > +   /* From the Ivy Bridge PRM, Vol 2 Part 1 p326:
> > +    *
> > +    *     When MCS buffer is enabled and bound to MSRT, it is required 
> > that it
> > +    *     is cleared prior to any rendering.
> > +    *
> > +    * Since we don't use the MCS buffer for any purpose other than 
> > rendering,
> > +    * it makes sense to just clear it immediately upon allocation.
> > +    *
> > +    * Note: the clear value for MCS buffers is all 1's, so we memset to 
> > 0xff.
> > +    */
> > +   mt->aux_buf = intel_alloc_aux_buffer(brw, "mcs-miptree", &temp_mcs_surf,
> > +                                        alloc_flags, true, 0xFF, mt);
> > +   if (!mt->aux_buf) {
> >        free(aux_state);
> >        return false;
> >     }
> > @@ -1810,7 +1804,7 @@ intel_miptree_alloc_ccs(struct brw_context *brw,
> >      * bits in the aux buffer.
> >      */
> >     mt->aux_buf = intel_alloc_aux_buffer(brw, "ccs-miptree", &temp_ccs_surf,
> > -                                        BO_ALLOC_ZEROED, mt);
> > +                                        BO_ALLOC_ZEROED, false, 0, mt);
> >     if (!mt->aux_buf) {
> >        free(aux_state);
> >        return false;
> > @@ -1876,8 +1870,8 @@ intel_miptree_alloc_hiz(struct brw_context *brw,
> >     assert(ok);
> >  
> >     const uint32_t alloc_flags = BO_ALLOC_BUSY;
> > -   mt->aux_buf = intel_alloc_aux_buffer(brw, "hiz-miptree",
> > -                                        &temp_hiz_surf, alloc_flags, mt);
> > +   mt->aux_buf = intel_alloc_aux_buffer(brw, "hiz-miptree", &temp_hiz_surf,
> > +                                        alloc_flags, false, 0, mt);
> >  
> >     if (!mt->aux_buf) {
> >        free(aux_state);
> > -- 
> > 2.16.2
> > 
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to