Module: Mesa Branch: main Commit: 115b61e51f619df0b8d920b8ee572b56e7be575f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=115b61e51f619df0b8d920b8ee572b56e7be575f
Author: Pierre-Eric Pelloux-Prayer <[email protected]> Date: Thu Dec 14 16:32:30 2023 +0100 ac/surface: don't oversize surf_size Yet another iteration on the same YUV surfaces. The change from 87ecfdfbf0a has 2 odd things: * it's using MAX2(original value, new value) but the point of updating surf_slice_size / surf_size is to make it correct relative to the new value of surf_pitch * it's multiplying surf_pitch (= number of elements per row) by height (ok) by surf->bpe (= number of bytes per element) by surf->blk_w (= number of "horizontal" pixels in an element) so the end unit doesn't make sense. Fix this by computing a reasonnable value based on unit: the surf_slice_size is the number of elements per row (surf_pitch) x number of bytes per element (bpe) x number of rows. This makes the expected size correct and thus fixes users of eglCreateImageKHR, like the issue #6131. I tested a bunch of gst pipelines and ffmpeg scripts on various files I have and didn't notice any issues (on gfx10.3 and gfx9). Fixes: 87ecfdfbf0a ("ac/surface: adapt surf_size when modifying surf_pitch") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6131 Acked-by: Marek Olšák <[email protected]> Tested-by: Nicolas Dufresne <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26693> --- src/amd/common/ac_surface.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index 25832d8f966..330ef3da903 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -1889,14 +1889,8 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_ linear_alignment); surf->u.gfx9.epitch = MAX2(surf->u.gfx9.epitch, surf->u.gfx9.surf_pitch * surf->blk_w - 1); - /* The surface is really a surf->bpe bytes per pixel surface even if we - * use it as a surf->bpe bytes per element one. - * Adjust surf_slice_size and surf_size to reflect the change - * made to surf_pitch. - */ - surf->u.gfx9.surf_slice_size = - MAX2(surf->u.gfx9.surf_slice_size, - (uint64_t)surf->u.gfx9.surf_pitch * out.height * surf->bpe * surf->blk_w); + /* Adjust surf_slice_size and surf_size to reflect the change made to surf_pitch. */ + surf->u.gfx9.surf_slice_size = (uint64_t)surf->u.gfx9.surf_pitch * out.height * surf->bpe; surf->surf_size = surf->u.gfx9.surf_slice_size * in->numSlices; for (unsigned i = 0; i < in->numMipLevels; i++) {
