Skip to content

panfrost: Require 64-byte alignment on imports

Alyssa Rosenzweig requested to merge alyssa/mesa:panfrost/imports into main
While Panfrost allocates linear images with strides that are a multiple of 64
bytes, other dma-buf producers on the system may not satisfy this requirement.
However, at least on v7 and newer, any image with a regular format must have a
stride that is a multiple of 64 bytes.

This fixes a real bug in an application that created a linear R8_UNORM image
with stride 480 bytes, imported it as an EGL_image, and then tried to texture
from it with the GPU. Previously, the driver allowed this siutation but it
resulted in an imprecise fault from the GPU. This patch corrects the driver to
reject the import as invalid due to the unaligned stride, ensuring we never
attempt to texture from such a resource.

To implement, we add some new layout queries to centralize knowledge about the
stride alignment requirements, and we sprinkle in asserts to show how the
invariant is upheld throughout the lifecycle of image creation to texturing.

Cc @bbrezillon for the implementation and @cphealy for testing.

(just the last patch -- the first 3 patches are from !19576 (merged) and only here to avoid a merge conflict, since that is landing first)

Merge request reports