[Mesa-dev] [PATCH] isl: round format alignment to nearest power of 2

Jason Ekstrand jason at jlekstrand.net
Wed Aug 24 00:58:17 UTC 2016


On Tue, Aug 23, 2016 at 5:41 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:

> On Fri, Aug 19, 2016 at 7:44 PM, Lionel Landwerlin
> <llandwerlin at gmail.com> wrote:
> > A few inline asserts in anv assume alignments are power of 2, but with
> > formats like R8G8B8 we have odd alignments.
> >
> > Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> > ---
> >  src/intel/isl/isl.c      | 1 +
> >  src/intel/isl/isl_priv.h | 6 ++++++
> >  2 files changed, 7 insertions(+)
> >
> > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
> > index 18e95e2..dfe0fc1 100644
> > --- a/src/intel/isl/isl.c
> > +++ b/src/intel/isl/isl.c
> > @@ -1182,6 +1182,7 @@ isl_surf_init_s(const struct isl_device *dev,
> >              base_alignment = MAX(base_alignment, fmtl->bpb / 8);
> >           }
> >        }
> > +      base_alignment = isl_round_to_power_of_two(base_alignment);
> >     } else {
> >        assert(phys_slice0_sa.w % fmtl->bw == 0);
> >        const uint32_t total_w_el = phys_slice0_sa.width / fmtl->bw;
> > diff --git a/src/intel/isl/isl_priv.h b/src/intel/isl/isl_priv.h
> > index 3a7af1a..cc9991c 100644
> > --- a/src/intel/isl/isl_priv.h
> > +++ b/src/intel/isl/isl_priv.h
> > @@ -99,6 +99,12 @@ isl_log2u(uint32_t n)
> >  }
> >
> >  static inline uint32_t
> > +isl_round_to_power_of_two(uint32_t value)
> > +{
> > +   return 1 << isl_log2u(value);
>
> This will round down. Is that desired? (Don't know, just asking... I
> kind of assumed you'd want to round up to the nearest power of two,
> but perhaps not.)
>

You're right!  R-B recinded.  If you rounded up to a power of two, that
would work fine.


> > +}
> > +
> > +static inline uint32_t
> >  isl_minify(uint32_t n, uint32_t levels)
> >  {
> >     if (unlikely(n == 0))
> > --
> > 2.9.3
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160823/5f53b1ee/attachment.html>


More information about the mesa-dev mailing list