ac/surface: don't oversize surf_size
Yet another iteration on the same YUV surfaces. The change from87ecfdfbf0
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:87ecfdfbf0
("ac/surface: adapt surf_size when modifying surf_pitch") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6131 Acked-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26693>
This commit is contained in:
@@ -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++) {
|
||||
|
Reference in New Issue
Block a user