<div dir="ltr"><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Dec 16, 2024 at 5:46 AM Lucas Stach <<a href="mailto:l.stach@pengutronix.de">l.stach@pengutronix.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Montag, dem 16.12.2024 um 10:27 +0100 schrieb Michel Dänzer:<br>
> On 2024-12-15 21:53, Marek Olšák wrote:<br>
> > The comment explains the problem with DRM_FORMAT_MOD_LINEAR.<br>
> > <br>
> > Signed-off-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a> <mailto:<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>>><br>
> > <br>
> > diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h<br>
> > index 78abd819fd62e..8ec4163429014 100644<br>
> > --- a/include/uapi/drm/drm_fourcc.h<br>
> > +++ b/include/uapi/drm/drm_fourcc.h<br>
> > @@ -484,9 +484,27 @@ extern "C" {<br>
> > * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl),<br>
> > * which tells the driver to also take driver-internal information into account<br>
> > * and so might actually result in a tiled framebuffer.<br>
> > + *<br>
> > + * WARNING:<br>
> > + * There are drivers out there that expose DRM_FORMAT_MOD_LINEAR, but only<br>
> > + * support a certain pitch alignment and can't import images with this modifier<br>
> > + * if the pitch alignment isn't exactly the one supported. They can however<br>
> > + * allocate images with this modifier and other drivers can import them only<br>
> > + * if they support the same pitch alignment. Thus, DRM_FORMAT_MOD_LINEAR is<br>
> > + * fundamentically incompatible across devices and is the only modifier that<br>
> > + * has a chance of not working. The PITCH_ALIGN modifiers should be used<br>
> > + * instead.<br>
> > */<br>
> > #define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)<br>
> > <br>
> > +/* Linear layout modifiers with an explicit pitch alignment in bytes.<br>
> > + * Exposing this modifier requires that the pitch alignment is exactly<br>
> > + * the number in the definition.<br>
> > + */<br>
> > +#define DRM_FORMAT_MOD_LINEAR_PITCH_ALIGN_64B fourcc_mod_code(NONE, 1)<br>
> <br>
> It's not clear what you mean by "requires that the pitch alignment is exactly<br>
> the number in the definition", since a pitch which is aligned to 256 bytes is<br>
> also aligned to 128 & 64 bytes. Do you mean the pitch must be exactly the width<br>
> rounded up to the next / smallest possible multiple of the specified number of bytes?<br>
<br>
I guess that's the intention here, as some AMD GPUs apparently have<br>
this limitation that they need an exact aligned pitch.<br>
<br>
If we open the can of worms to overhaul the linear modifier, I think it<br>
would make sense to also add modifiers for the more common restriction,<br>
where the pitch needs to be aligned to a specific granule, but the<br>
engine doesn't care if things get overaligned to a multiple of the<br>
granule. Having both sets would probably make it easier for the reader<br>
to see the difference to the exact pitch modifiers proposed in this<br>
patch.<br></blockquote><div><br></div>That's a good point.</div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container">It could be:</div><div class="gmail_quote gmail_quote_container">- LINEAR_PITCH_ALIGN_EXACT_#B</div><div class="gmail_quote gmail_quote_container">- LINEAR_PITCH_ALIGN_MULTIPLE_#B</div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container">Drivers that expose the MULTIPLE ones should also expose the EXACT ones that are equivalent. Other drivers will only expose the EXACT ones but not the MULTIPLE ones.<br></div><div class="gmail_quote gmail_quote_container"><br></div><div class="gmail_quote gmail_quote_container">Marek<br></div></div>