From 4ddfc1cfdd169ba047c236a817ffc3f0a42dd0ce Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 2 Sep 2024 21:02:44 -0400 Subject: [PATCH] ail: pull in DRM modifier helper Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.h | 28 ++++++++++++++++++++++++++++ src/gallium/drivers/asahi/agx_pipe.c | 17 +---------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index c0b148f8afc..6c045c44fae 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -6,6 +6,7 @@ #pragma once +#include "drm-uapi/drm_fourcc.h" #include "util/format/u_format.h" #include "util/macros.h" #include "util/u_math.h" @@ -434,6 +435,33 @@ ail_is_view_compatible(struct ail_layout *layout, enum pipe_format view) ail_formats_compatible(layout->format, view); } +/* Fake values, pending UAPI upstreaming */ +#ifndef DRM_FORMAT_MOD_APPLE_TWIDDLED +#define DRM_FORMAT_MOD_APPLE_TWIDDLED (2) +#endif +#ifndef DRM_FORMAT_MOD_APPLE_TWIDDLED_COMPRESSED +#define DRM_FORMAT_MOD_APPLE_TWIDDLED_COMPRESSED (3) +#endif + +/* + * We generally use ail enums instead of DRM format modifiers. This helper + * bridges the gap. + */ +static inline enum ail_tiling +ail_drm_modifier_to_tiling(uint64_t modifier) +{ + switch (modifier) { + case DRM_FORMAT_MOD_LINEAR: + return AIL_TILING_LINEAR; + case DRM_FORMAT_MOD_APPLE_TWIDDLED: + return AIL_TILING_TWIDDLED; + case DRM_FORMAT_MOD_APPLE_TWIDDLED_COMPRESSED: + return AIL_TILING_TWIDDLED_COMPRESSED; + default: + unreachable("Unsupported modifier"); + } +} + #ifdef __cplusplus } /* extern C */ #endif diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 018beacea83..8fae84eb4ec 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -87,21 +87,6 @@ void agx_init_state_functions(struct pipe_context *ctx); * resource */ -static enum ail_tiling -ail_modifier_to_tiling(uint64_t modifier) -{ - switch (modifier) { - case DRM_FORMAT_MOD_LINEAR: - return AIL_TILING_LINEAR; - case DRM_FORMAT_MOD_APPLE_TWIDDLED: - return AIL_TILING_TWIDDLED; - case DRM_FORMAT_MOD_APPLE_TWIDDLED_COMPRESSED: - return AIL_TILING_TWIDDLED_COMPRESSED; - default: - unreachable("Unsupported modifier"); - } -} - const static char *s_tiling[] = { [AIL_TILING_LINEAR] = "LINR", [AIL_TILING_TWIDDLED] = "TWID", @@ -159,7 +144,7 @@ agx_resource_setup(struct agx_device *dev, struct agx_resource *nresource) struct pipe_resource *templ = &nresource->base; nresource->layout = (struct ail_layout){ - .tiling = ail_modifier_to_tiling(nresource->modifier), + .tiling = ail_drm_modifier_to_tiling(nresource->modifier), .mipmapped_z = templ->target == PIPE_TEXTURE_3D, .format = templ->format, .width_px = templ->width0,