Module: Mesa
Branch: main
Commit: 175732bb51c81513ae05f9313d6df7c0631ef159
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=175732bb51c81513ae05f9313d6df7c0631ef159

Author: Lucas Stach <[email protected]>
Date:   Mon Jan 30 18:58:30 2023 +0100

etnaviv: fix double scanout import of multiplanar resources

etna_resource_from_handle() is called for each plane of a multiplanar
resource, so there is no point in looping over all planes to do the
renderonly scanout import. In fact that will cause us to lose track
of the scanout imports from later planes when the earlier planes are
redoing the import, overwriting the pointer to the allocated
renderonly_scanout struct.

Drop the loop and just do the import for the current plane.

Fixes: 826f95778a4e ("etnaviv: always try to create KMS side handles for 
imported resources")
Signed-off-by: Lucas Stach <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20993>

---

 src/gallium/drivers/etnaviv/etnaviv_resource.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index cffa43aa52b..92cb5ce7fa3 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -696,15 +696,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
                                                                   
level->padded_height);
    level->size = level->layer_stride;
 
-   if (screen->ro) {
-      struct pipe_resource *imp_prsc = prsc;
-      do {
-         etna_resource(imp_prsc)->scanout =
-               renderonly_create_gpu_import_for_resource(imp_prsc, screen->ro,
-                                                         NULL);
-         /* failure is expected for scanout incompatible buffers */
-      } while ((imp_prsc = imp_prsc->next));
-   }
+   if (screen->ro)
+      rsc->scanout = renderonly_create_gpu_import_for_resource(prsc, 
screen->ro,
+                                                               NULL);
 
    /* If the buffer is for a TS plane, skip the RS compatible checks */
    if (handle->plane >= util_format_get_num_planes(prsc->format))

Reply via email to