Re: [igt-dev] [PATCH i-g-t v2 07/13] igt: fb: Account for all planes bpp

Maxime Ripard
2019-01-21T13:10:39Z

[-- Attachment #1.1: Type: text/plain, Size: 1119 bytes --]

On Thu, Jan 10, 2019 at 11:21:24AM +0100, Paul Kocialkowski wrote:
> On Tue, 2019-01-08 at 16:19 +0100, Maxime Ripard wrote:
> > When allocating a dumb buffer for a format with multiple plane, we need to
> > account for all plane's bpp in order to allocate the proper size.
> >
> > Let's add all the planes bpp and use the result to allocate our buffer.
>
> As discussed off-list, this approach doesn't work well when multiple
> planes and sub-sampling are involved, causing over-allocation.
>
> For instance, NV12 requires at least width * height * 1.5.
> The bpp for the second plane is 16 but with four times less pixels due
> to sub-sampling. Here, this would amount to width * height * 3 at
> least, so over-allocating.
>
> I think dividing each plane's bpp by the sub-sampling before adding it
> should work (with a round-up division to be on the safe side for cases
> where bpp cannot be exactly dividided by hsub * vsub in the future).
>
> What do you think?

It sounds great, thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]