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

Author: Lucas Stach <[email protected]>
Date:   Fri Oct 14 16:16:49 2022 +0200

etnaviv: canonicalize modifier on import

Unknown modifiers are currently squashed down to linear when transforming
the modifier into our interal layout representation. However, the only real
modifier that we expect to see, which isn't Vivante specific or LINEAR, is
the INVALID modifier. Treat this modifier as linear and reject any other
unexpected modifiers.

Signed-off-by: Lucas Stach <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9780>

---

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

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 5ae018c882a..b807e587aa7 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -51,8 +51,9 @@ static enum etna_surface_layout modifier_to_layout(uint64_t 
modifier)
    case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED:
       return ETNA_LAYOUT_MULTI_SUPERTILED;
    case DRM_FORMAT_MOD_LINEAR:
-   default:
       return ETNA_LAYOUT_LINEAR;
+   default:
+      unreachable("unhandled modifier");
    }
 }
 
@@ -523,6 +524,7 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
    struct etna_resource *rsc;
    struct etna_resource_level *level;
    struct pipe_resource *prsc;
+   uint64_t modifier = handle->modifier;
 
    DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
        "nr_samples=%u, usage=%u, bind=%x, flags=%x",
@@ -547,8 +549,11 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
    if (!rsc->bo)
       goto fail;
 
+   if (modifier == DRM_FORMAT_MOD_INVALID)
+      modifier = DRM_FORMAT_MOD_LINEAR;
+
    rsc->seqno = 1;
-   rsc->layout = modifier_to_layout(handle->modifier);
+   rsc->layout = modifier_to_layout(modifier);
 
    if (usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH)
       rsc->explicit_flush = true;

Reply via email to