asahi: Localize the modifier #define hack for macOS
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 8 Nov 2022 22:13:10 +0000 (17:13 -0500)
committerMarge Bot <emma+marge@anholt.net>
Thu, 17 Nov 2022 02:47:10 +0000 (02:47 +0000)
This reduces the burden of synchronizing the values between Linux and macOS and
provides fewer ways to shoot ourselves in the foot.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19606>

src/gallium/drivers/asahi/agx_pipe.c
src/gallium/drivers/asahi/agx_state.h

index f2b59fa..2f9c1eb 100644 (file)
 #include "asahi/compiler/agx_compile.h"
 #include "asahi/lib/decode.h"
 #include "asahi/lib/agx_formats.h"
+#include "util/u_drm.h"
+
+/* drm_fourcc cannot be built on macOS */
+#ifndef __APPLE__
+#include "drm-uapi/drm_fourcc.h"
+#endif
+
+/* In case of macOS, pick some fake modifier values so we still build */
+#ifndef DRM_FORMAT_MOD_LINEAR
+#define DRM_FORMAT_MOD_LINEAR 1
+#endif
+
+#ifndef DRM_FORMAT_MOD_APPLE_TWIDDLED
+#define DRM_FORMAT_MOD_APPLE_TWIDDLED (2)
+#endif
 
 static const struct debug_named_value agx_debug_options[] = {
    {"trace",     AGX_DBG_TRACE,    "Trace the command stream"},
index d647985..62b95b3 100644 (file)
@@ -272,12 +272,6 @@ agx_device(struct pipe_screen *p)
    return &(agx_screen(p)->dev);
 }
 
-/* TODO: UABI, fake for macOS */
-#ifndef DRM_FORMAT_MOD_LINEAR
-#define DRM_FORMAT_MOD_LINEAR 1
-#endif
-#define DRM_FORMAT_MOD_APPLE_TWIDDLED (2)
-
 struct agx_resource {
    struct pipe_resource        base;
    uint64_t modifier;