Module: Mesa
Branch: staging/23.3
Commit: 3dcea0be227eacc3e279442e78cb5ae6aff9ab84
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3dcea0be227eacc3e279442e78cb5ae6aff9ab84

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>
(cherry picked from commit 115b61e51f619df0b8d920b8ee572b56e7be575f)

---

 .pick_status.json           |  2 +-
 src/amd/common/ac_surface.c | 10 ++--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 981e0902c60..0ef1979e2b1 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5604,7 +5604,7 @@
         "description": "ac/surface: don't oversize surf_size",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "87ecfdfbf0a8448d1475e6da15175e68bdeb933b",
         "notes": null
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index 6285e76ad9f..337bb85d383 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -1875,14 +1875,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++) {

Reply via email to