From f977c52b8408a702443924cf8ea052f04c11f2c1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 13 Aug 2024 11:40:36 -0400 Subject: [PATCH] ail: swallow up formats ail is a more sensible place for the format tables to live. this does create a bit of dependency soup but hey. nfc Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 4 +- src/asahi/compiler/agx_internal_formats.h | 45 ---- src/asahi/layout/formats.c | 265 +++++++++++++++++++++ src/asahi/layout/layout.h | 51 +++++ src/asahi/layout/meson.build | 3 +- src/asahi/lib/agx_border.c | 2 +- src/asahi/lib/agx_device.h | 2 +- src/asahi/lib/agx_formats.c | 266 ---------------------- src/asahi/lib/agx_formats.h | 29 --- src/asahi/lib/agx_helpers.h | 5 + src/asahi/lib/agx_nir_lower_texture.c | 1 - src/asahi/lib/agx_nir_lower_tilebuffer.c | 2 +- src/asahi/lib/agx_nir_lower_vbo.c | 5 +- src/asahi/lib/agx_tilebuffer.c | 7 +- src/asahi/lib/meson.build | 3 +- src/asahi/meson.build | 2 +- src/asahi/vulkan/hk_buffer_view.c | 12 +- src/asahi/vulkan/hk_cmd_clear.c | 4 +- src/asahi/vulkan/hk_image.c | 5 +- src/asahi/vulkan/hk_image_view.c | 8 +- src/compiler/nir/nir_intrinsics.py | 8 +- src/gallium/drivers/asahi/agx_blit.c | 4 +- src/gallium/drivers/asahi/agx_pipe.c | 7 +- src/gallium/drivers/asahi/agx_state.c | 13 +- 24 files changed, 363 insertions(+), 390 deletions(-) delete mode 100644 src/asahi/compiler/agx_internal_formats.h create mode 100644 src/asahi/layout/formats.c delete mode 100644 src/asahi/lib/agx_formats.c delete mode 100644 src/asahi/lib/agx_formats.h diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index c79c9a44d2c..f8994e5f921 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -6,6 +6,7 @@ */ #include "agx_compile.h" +#include "asahi/layout/layout.h" #include "compiler/nir/nir_builder.h" #include "util/bitset.h" #include "util/glheader.h" @@ -16,7 +17,6 @@ #include "agx_builder.h" #include "agx_compiler.h" #include "agx_debug.h" -#include "agx_internal_formats.h" #include "agx_nir.h" #include "glsl_types.h" #include "nir.h" @@ -493,7 +493,7 @@ static enum agx_format agx_format_for_pipe(enum pipe_format format) { #define CASE(x) \ - if (format == (enum pipe_format)AGX_INTERNAL_FORMAT_##x) \ + if (format == (enum pipe_format)AIL_ISA_FORMAT_##x) \ return AGX_FORMAT_##x; CASE(I8); diff --git a/src/asahi/compiler/agx_internal_formats.h b/src/asahi/compiler/agx_internal_formats.h deleted file mode 100644 index b4692856c2b..00000000000 --- a/src/asahi/compiler/agx_internal_formats.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 Alyssa Rosenzweig - * SPDX-License-Identifier: MIT - */ - -#pragma once - -#include -#include "util/format/u_formats.h" - -/* Define aliases for the subset formats that are accessible in the ISA. These - * subsets disregard component mapping and number of components. This - * constitutes ABI with the compiler. - */ -enum agx_internal_formats { - AGX_INTERNAL_FORMAT_I8 = PIPE_FORMAT_R8_UINT, - AGX_INTERNAL_FORMAT_I16 = PIPE_FORMAT_R16_UINT, - AGX_INTERNAL_FORMAT_I32 = PIPE_FORMAT_R32_UINT, - AGX_INTERNAL_FORMAT_F16 = PIPE_FORMAT_R16_FLOAT, - AGX_INTERNAL_FORMAT_U8NORM = PIPE_FORMAT_R8_UNORM, - AGX_INTERNAL_FORMAT_S8NORM = PIPE_FORMAT_R8_SNORM, - AGX_INTERNAL_FORMAT_U16NORM = PIPE_FORMAT_R16_UNORM, - AGX_INTERNAL_FORMAT_S16NORM = PIPE_FORMAT_R16_SNORM, - AGX_INTERNAL_FORMAT_RGB10A2 = PIPE_FORMAT_R10G10B10A2_UNORM, - AGX_INTERNAL_FORMAT_SRGBA8 = PIPE_FORMAT_R8G8B8A8_SRGB, - AGX_INTERNAL_FORMAT_RG11B10F = PIPE_FORMAT_R11G11B10_FLOAT, - AGX_INTERNAL_FORMAT_RGB9E5 = PIPE_FORMAT_R9G9B9E5_FLOAT -}; - -/* - * The architecture load/store instructions support masking, but packed formats - * are not compatible with masking. Check if a format is packed. - */ -static inline bool -agx_internal_format_supports_mask(enum agx_internal_formats format) -{ - switch (format) { - case AGX_INTERNAL_FORMAT_RGB10A2: - case AGX_INTERNAL_FORMAT_RG11B10F: - case AGX_INTERNAL_FORMAT_RGB9E5: - return false; - default: - return true; - } -} diff --git a/src/asahi/layout/formats.c b/src/asahi/layout/formats.c new file mode 100644 index 00000000000..fffa95adeb2 --- /dev/null +++ b/src/asahi/layout/formats.c @@ -0,0 +1,265 @@ +/* + * Copyright 2021 Alyssa Rosenzweig + * SPDX-License-Identifier: MIT + */ + +#include "agx_pack.h" +#include "layout.h" + +#define AIL_ISA_FORMAT__ PIPE_FORMAT_NONE + +#define AIL_FMT(pipe, channels_, type_, renderable_) \ + [PIPE_FORMAT_##pipe] = { \ + .channels = AGX_CHANNELS_##channels_, \ + .type = AGX_TEXTURE_TYPE_##type_, \ + .texturable = true, \ + .renderable = (enum pipe_format)AIL_ISA_FORMAT_##renderable_, \ + } + +/* clang-format off */ +const struct ail_pixel_format_entry ail_pixel_format[PIPE_FORMAT_COUNT] = { + AIL_FMT(R5G6B5_UNORM, R5G6B5, UNORM, F16), + AIL_FMT(B5G6R5_UNORM, R5G6B5, UNORM, F16), + + AIL_FMT(R5G5B5A1_UNORM, R5G5B5A1, UNORM, F16), + AIL_FMT(B5G5R5A1_UNORM, R5G5B5A1, UNORM, F16), + AIL_FMT(R5G5B5X1_UNORM, R5G5B5A1, UNORM, F16), + AIL_FMT(B5G5R5X1_UNORM, R5G5B5A1, UNORM, F16), + + AIL_FMT(R4G4B4A4_UNORM, R4G4B4A4, UNORM, F16), + AIL_FMT(B4G4R4A4_UNORM, R4G4B4A4, UNORM, F16), + AIL_FMT(A4B4G4R4_UNORM, R4G4B4A4, UNORM, F16), + AIL_FMT(A4R4G4B4_UNORM, R4G4B4A4, UNORM, F16), + + AIL_FMT(R8_UNORM, R8, UNORM, U8NORM), + AIL_FMT(R8G8_UNORM, R8G8, UNORM, U8NORM), + AIL_FMT(R8G8B8A8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(A8R8G8B8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(A8B8G8R8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(B8G8R8A8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(R8G8B8X8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(X8R8G8B8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(X8B8G8R8_UNORM, R8G8B8A8, UNORM, U8NORM), + AIL_FMT(B8G8R8X8_UNORM, R8G8B8A8, UNORM, U8NORM), + + AIL_FMT(R16_UNORM, R16, UNORM, U16NORM), + AIL_FMT(R16G16_UNORM, R16G16, UNORM, U16NORM), + AIL_FMT(R16G16B16A16_UNORM, R16G16B16A16, UNORM, U16NORM), + AIL_FMT(R16_SNORM, R16, SNORM, S16NORM), + AIL_FMT(R16G16_SNORM, R16G16, SNORM, S16NORM), + AIL_FMT(R16G16B16A16_SNORM, R16G16B16A16, SNORM, S16NORM), + + AIL_FMT(R8_SRGB, R8, UNORM, SRGBA8), + AIL_FMT(R8G8_SRGB, R8G8, UNORM, SRGBA8), + AIL_FMT(R8G8B8A8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(A8R8G8B8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(A8B8G8R8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(B8G8R8A8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(R8G8B8X8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(X8R8G8B8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(X8B8G8R8_SRGB, R8G8B8A8, UNORM, SRGBA8), + AIL_FMT(B8G8R8X8_SRGB, R8G8B8A8, UNORM, SRGBA8), + + AIL_FMT(R8_SNORM, R8, SNORM, S8NORM), + AIL_FMT(R8G8_SNORM, R8G8, SNORM, S8NORM), + AIL_FMT(R8G8B8A8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(A8R8G8B8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(A8B8G8R8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(B8G8R8A8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(R8G8B8X8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(X8R8G8B8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(X8B8G8R8_SNORM, R8G8B8A8, SNORM, S8NORM), + AIL_FMT(B8G8R8X8_SNORM, R8G8B8A8, SNORM, S8NORM), + + AIL_FMT(R16_FLOAT, R16, FLOAT, F16), + AIL_FMT(R16G16_FLOAT, R16G16, FLOAT, F16), + AIL_FMT(R16G16B16X16_FLOAT, R16G16B16A16, FLOAT, F16), + AIL_FMT(R16G16B16A16_FLOAT, R16G16B16A16, FLOAT, F16), + + AIL_FMT(R32_FLOAT, R32, FLOAT, I32), + AIL_FMT(R32G32_FLOAT, R32G32, FLOAT, I32), + AIL_FMT(R32G32B32X32_FLOAT, R32G32B32A32, FLOAT, I32), + AIL_FMT(R32G32B32A32_FLOAT, R32G32B32A32, FLOAT, I32), + + AIL_FMT(R8_UINT, R8, UINT, I8), + AIL_FMT(R8G8_UINT, R8G8, UINT, I8), + AIL_FMT(R8G8B8X8_UINT, R8G8B8A8, UINT, I8), + AIL_FMT(R8G8B8A8_UINT, R8G8B8A8, UINT, I8), + AIL_FMT(B8G8R8X8_UINT, R8G8B8A8, UINT, I8), + AIL_FMT(B8G8R8A8_UINT, R8G8B8A8, UINT, I8), + + AIL_FMT(R16_UINT, R16, UINT, I16), + AIL_FMT(R16G16_UINT, R16G16, UINT, I16), + AIL_FMT(R16G16B16X16_UINT, R16G16B16A16, UINT, I16), + AIL_FMT(R16G16B16A16_UINT, R16G16B16A16, UINT, I16), + + AIL_FMT(R32_UINT, R32, UINT, I32), + AIL_FMT(R32G32_UINT, R32G32, UINT, I32), + AIL_FMT(R32G32B32X32_UINT, R32G32B32A32, UINT, I32), + AIL_FMT(R32G32B32A32_UINT, R32G32B32A32, UINT, I32), + + AIL_FMT(R8_SINT, R8, SINT, I8), + AIL_FMT(R8G8_SINT, R8G8, SINT, I8), + AIL_FMT(R8G8B8X8_SINT, R8G8B8A8, SINT, I8), + AIL_FMT(R8G8B8A8_SINT, R8G8B8A8, SINT, I8), + AIL_FMT(B8G8R8X8_SINT, R8G8B8A8, SINT, I8), + AIL_FMT(B8G8R8A8_SINT, R8G8B8A8, SINT, I8), + + AIL_FMT(R16_SINT, R16, SINT, I16), + AIL_FMT(R16G16_SINT, R16G16, SINT, I16), + AIL_FMT(R16G16B16X16_SINT, R16G16B16A16, SINT, I16), + AIL_FMT(R16G16B16A16_SINT, R16G16B16A16, SINT, I16), + + AIL_FMT(R32_SINT, R32, SINT, I32), + AIL_FMT(R32G32_SINT, R32G32, SINT, I32), + AIL_FMT(R32G32B32X32_SINT, R32G32B32A32, SINT, I32), + AIL_FMT(R32G32B32A32_SINT, R32G32B32A32, SINT, I32), + + AIL_FMT(Z16_UNORM, R16, UNORM, _), + AIL_FMT(Z32_FLOAT, R32, FLOAT, _), + AIL_FMT(Z32_FLOAT_S8X24_UINT, R32, FLOAT, _), + AIL_FMT(S8_UINT, R8, UINT, _), + + /* The stencil part of Z32F + S8 is just S8 */ + AIL_FMT(X32_S8X24_UINT, R8, UINT, _), + + /* These must be lowered by u_transfer_helper to Z32F + S8 */ + AIL_FMT(Z24X8_UNORM, R32, FLOAT, _), + AIL_FMT(Z24_UNORM_S8_UINT, R32, FLOAT, _), + + AIL_FMT(R10G10B10A2_UNORM, R10G10B10A2, UNORM, RGB10A2), + AIL_FMT(R10G10B10X2_UNORM, R10G10B10A2, UNORM, RGB10A2), + AIL_FMT(B10G10R10A2_UNORM, R10G10B10A2, UNORM, RGB10A2), + AIL_FMT(B10G10R10X2_UNORM, R10G10B10A2, UNORM, RGB10A2), + + AIL_FMT(R10G10B10A2_UINT, R10G10B10A2, UINT, I16), + AIL_FMT(B10G10R10A2_UINT, R10G10B10A2, UINT, I16), + + /* I don't see why this wouldn't be renderable, but it doesn't seem to work + * properly and it's not in Metal. + */ + AIL_FMT(R10G10B10A2_SINT, R10G10B10A2, SINT, _), + AIL_FMT(B10G10R10A2_SINT, R10G10B10A2, SINT, _), + + AIL_FMT(R11G11B10_FLOAT, R11G11B10, FLOAT, RG11B10F), + + /* TODO: This should be renderable but there are copyimage issues */ + AIL_FMT(R9G9B9E5_FLOAT, R9G9B9E5, FLOAT, _), + + /* These formats are emulated for texture buffers only */ + AIL_FMT(R32G32B32_FLOAT, R32G32B32_EMULATED, FLOAT, _), + AIL_FMT(R32G32B32_UINT, R32G32B32_EMULATED, UINT, _), + AIL_FMT(R32G32B32_SINT, R32G32B32_EMULATED, SINT, _), + + /* Likewise, luminance/alpha/intensity formats are supported for texturing, + * because they are required for texture buffers in the compat profile and + * mesa/st is unable to emulate them for texture buffers. Our Gallium driver + * handles the swizzles appropriately, so we just need to plumb through the + * enums. + * + * If mesa/st grows emulation for these formats later, we can drop this. + */ + AIL_FMT(A8_UNORM, R8, UNORM, _), + AIL_FMT(A16_UNORM, R16, UNORM, _), + AIL_FMT(A8_SINT, R8, SINT, _), + AIL_FMT(A16_SINT, R16, SINT, _), + AIL_FMT(A32_SINT, R32, SINT, _), + AIL_FMT(A8_UINT, R8, UINT, _), + AIL_FMT(A16_UINT, R16, UINT, _), + AIL_FMT(A32_UINT, R32, UINT, _), + AIL_FMT(A16_FLOAT, R16, FLOAT, _), + AIL_FMT(A32_FLOAT, R32, FLOAT, _), + + AIL_FMT(L8_UNORM, R8, UNORM, _), + AIL_FMT(L16_UNORM, R16, UNORM, _), + AIL_FMT(L8_SINT, R8, SINT, _), + AIL_FMT(L16_SINT, R16, SINT, _), + AIL_FMT(L32_SINT, R32, SINT, _), + AIL_FMT(L8_UINT, R8, UINT, _), + AIL_FMT(L16_UINT, R16, UINT, _), + AIL_FMT(L32_UINT, R32, UINT, _), + AIL_FMT(L16_FLOAT, R16, FLOAT, _), + AIL_FMT(L32_FLOAT, R32, FLOAT, _), + + AIL_FMT(L8A8_UNORM, R8G8, UNORM, _), + AIL_FMT(L16A16_UNORM, R16G16, UNORM, _), + AIL_FMT(L8A8_SINT, R8G8, SINT, _), + AIL_FMT(L16A16_SINT, R16G16, SINT, _), + AIL_FMT(L32A32_SINT, R32G32, SINT, _), + AIL_FMT(L8A8_UINT, R8G8, UINT, _), + AIL_FMT(L16A16_UINT, R16G16, UINT, _), + AIL_FMT(L32A32_UINT, R32G32, UINT, _), + AIL_FMT(L16A16_FLOAT, R16G16, FLOAT, _), + AIL_FMT(L32A32_FLOAT, R32G32, FLOAT, _), + + AIL_FMT(I8_UNORM, R8, UNORM, _), + AIL_FMT(I16_UNORM, R16, UNORM, _), + AIL_FMT(I8_SINT, R8, SINT, _), + AIL_FMT(I16_SINT, R16, SINT, _), + AIL_FMT(I32_SINT, R32, SINT, _), + AIL_FMT(I8_UINT, R8, UINT, _), + AIL_FMT(I16_UINT, R16, UINT, _), + AIL_FMT(I32_UINT, R32, UINT, _), + AIL_FMT(I16_FLOAT, R16, FLOAT, _), + AIL_FMT(I32_FLOAT, R32, FLOAT, _), + + AIL_FMT(ETC1_RGB8, ETC2_RGB8, UNORM, _), + AIL_FMT(ETC2_RGB8, ETC2_RGB8, UNORM, _), + AIL_FMT(ETC2_SRGB8, ETC2_RGB8, UNORM, _), + AIL_FMT(ETC2_RGB8A1, ETC2_RGB8A1, UNORM, _), + AIL_FMT(ETC2_SRGB8A1, ETC2_RGB8A1, UNORM, _), + AIL_FMT(ETC2_RGBA8, ETC2_RGBA8, UNORM, _), + AIL_FMT(ETC2_SRGBA8, ETC2_RGBA8, UNORM, _), + AIL_FMT(ETC2_R11_UNORM, EAC_R11, UNORM, _), + AIL_FMT(ETC2_R11_SNORM, EAC_R11, SNORM, _), + AIL_FMT(ETC2_RG11_UNORM, EAC_RG11, UNORM, _), + AIL_FMT(ETC2_RG11_SNORM, EAC_RG11, SNORM, _), + + AIL_FMT(ASTC_4x4, ASTC_4X4, UNORM, _), + AIL_FMT(ASTC_5x4, ASTC_5X4, UNORM, _), + AIL_FMT(ASTC_5x5, ASTC_5X5, UNORM, _), + AIL_FMT(ASTC_6x5, ASTC_6X5, UNORM, _), + AIL_FMT(ASTC_6x6, ASTC_6X6, UNORM, _), + AIL_FMT(ASTC_8x5, ASTC_8X5, UNORM, _), + AIL_FMT(ASTC_8x6, ASTC_8X6, UNORM, _), + AIL_FMT(ASTC_8x8, ASTC_8X8, UNORM, _), + AIL_FMT(ASTC_10x5, ASTC_10X5, UNORM, _), + AIL_FMT(ASTC_10x6, ASTC_10X6, UNORM, _), + AIL_FMT(ASTC_10x8, ASTC_10X8, UNORM, _), + AIL_FMT(ASTC_10x10, ASTC_10X10, UNORM, _), + AIL_FMT(ASTC_12x10, ASTC_12X10, UNORM, _), + AIL_FMT(ASTC_12x12, ASTC_12X12, UNORM, _), + + AIL_FMT(ASTC_4x4_SRGB, ASTC_4X4, UNORM, _), + AIL_FMT(ASTC_5x4_SRGB, ASTC_5X4, UNORM, _), + AIL_FMT(ASTC_5x5_SRGB, ASTC_5X5, UNORM, _), + AIL_FMT(ASTC_6x5_SRGB, ASTC_6X5, UNORM, _), + AIL_FMT(ASTC_6x6_SRGB, ASTC_6X6, UNORM, _), + AIL_FMT(ASTC_8x5_SRGB, ASTC_8X5, UNORM, _), + AIL_FMT(ASTC_8x6_SRGB, ASTC_8X6, UNORM, _), + AIL_FMT(ASTC_8x8_SRGB, ASTC_8X8, UNORM, _), + AIL_FMT(ASTC_10x5_SRGB, ASTC_10X5, UNORM, _), + AIL_FMT(ASTC_10x6_SRGB, ASTC_10X6, UNORM, _), + AIL_FMT(ASTC_10x8_SRGB, ASTC_10X8, UNORM, _), + AIL_FMT(ASTC_10x10_SRGB, ASTC_10X10, UNORM, _), + AIL_FMT(ASTC_12x10_SRGB, ASTC_12X10, UNORM, _), + AIL_FMT(ASTC_12x12_SRGB, ASTC_12X12, UNORM, _), + + AIL_FMT(DXT1_RGB, BC1, UNORM, _), + AIL_FMT(DXT1_RGBA, BC1, UNORM, _), + AIL_FMT(DXT1_SRGB, BC1, UNORM, _), + AIL_FMT(DXT1_SRGBA, BC1, UNORM, _), + AIL_FMT(DXT3_RGBA, BC2, UNORM, _), + AIL_FMT(DXT3_SRGBA, BC2, UNORM, _), + AIL_FMT(DXT5_RGBA, BC3, UNORM, _), + AIL_FMT(DXT5_SRGBA, BC3, UNORM, _), + AIL_FMT(RGTC1_UNORM, BC4, UNORM, _), + AIL_FMT(RGTC1_SNORM, BC4, SNORM, _), + AIL_FMT(RGTC2_UNORM, BC5, UNORM, _), + AIL_FMT(RGTC2_SNORM, BC5, SNORM, _), + AIL_FMT(BPTC_RGB_FLOAT, BC6H, FLOAT, _), + AIL_FMT(BPTC_RGB_UFLOAT, BC6H_UFLOAT, FLOAT, _), + AIL_FMT(BPTC_RGBA_UNORM, BC7, UNORM, _), + AIL_FMT(BPTC_SRGBA, BC7, UNORM, _), +}; +/* clang-format on */ diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index bf468a32179..3f37f6a9f62 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -287,6 +287,57 @@ void ail_tile(void *_tiled, void *_linear, unsigned linear_pitch_B, unsigned sx_px, unsigned sy_px, unsigned width_px, unsigned height_px); +/* Define aliases for the subset formats that are accessible in the ISA. These + * subsets disregard component mapping and number of components. This + * constitutes ABI with the compiler. + */ +enum ail_isa_format { + AIL_ISA_FORMAT_I8 = PIPE_FORMAT_R8_UINT, + AIL_ISA_FORMAT_I16 = PIPE_FORMAT_R16_UINT, + AIL_ISA_FORMAT_I32 = PIPE_FORMAT_R32_UINT, + AIL_ISA_FORMAT_F16 = PIPE_FORMAT_R16_FLOAT, + AIL_ISA_FORMAT_U8NORM = PIPE_FORMAT_R8_UNORM, + AIL_ISA_FORMAT_S8NORM = PIPE_FORMAT_R8_SNORM, + AIL_ISA_FORMAT_U16NORM = PIPE_FORMAT_R16_UNORM, + AIL_ISA_FORMAT_S16NORM = PIPE_FORMAT_R16_SNORM, + AIL_ISA_FORMAT_RGB10A2 = PIPE_FORMAT_R10G10B10A2_UNORM, + AIL_ISA_FORMAT_SRGBA8 = PIPE_FORMAT_R8G8B8A8_SRGB, + AIL_ISA_FORMAT_RG11B10F = PIPE_FORMAT_R11G11B10_FLOAT, + AIL_ISA_FORMAT_RGB9E5 = PIPE_FORMAT_R9G9B9E5_FLOAT +}; + +/* + * The architecture load/store instructions support masking, but packed formats + * are not compatible with masking. Check if a format is packed. + */ +static inline bool +ail_isa_format_supports_mask(enum ail_isa_format format) +{ + switch (format) { + case AIL_ISA_FORMAT_RGB10A2: + case AIL_ISA_FORMAT_RG11B10F: + case AIL_ISA_FORMAT_RGB9E5: + return false; + default: + return true; + } +} + +struct ail_pixel_format_entry { + uint8_t channels; + uint8_t type; + bool texturable : 1; + enum pipe_format renderable; +}; + +extern const struct ail_pixel_format_entry ail_pixel_format[PIPE_FORMAT_COUNT]; + +static inline bool +ail_is_valid_pixel_format(enum pipe_format format) +{ + return ail_pixel_format[format].texturable; +} + #ifdef __cplusplus } /* extern C */ #endif diff --git a/src/asahi/layout/meson.build b/src/asahi/layout/meson.build index 7d399a6ec3c..de5599c4ce3 100644 --- a/src/asahi/layout/meson.build +++ b/src/asahi/layout/meson.build @@ -2,6 +2,7 @@ # SPDX-License-Identifier: MIT libasahi_layout_files = files( + 'formats.c', 'layout.c', 'tiling.cc', ) @@ -10,7 +11,7 @@ libasahi_layout = static_library( 'asahi_layout', [libasahi_layout_files], include_directories : [inc_include, inc_src], - dependencies: idep_mesautil, + dependencies: [idep_mesautil, idep_agx_pack], c_args : [no_override_init_args], gnu_symbol_visibility : 'hidden', build_by_default : false, diff --git a/src/asahi/lib/agx_border.c b/src/asahi/lib/agx_border.c index 0cbf474d2ca..fc139b1179c 100644 --- a/src/asahi/lib/agx_border.c +++ b/src/asahi/lib/agx_border.c @@ -6,7 +6,7 @@ #include "util/format/format_utils.h" #include "util/format/u_format.h" #include "util/half_float.h" -#include "agx_formats.h" +#include "agx_helpers.h" #include "agx_pack.h" /* diff --git a/src/asahi/lib/agx_device.h b/src/asahi/lib/agx_device.h index db166c6124a..37232147d22 100644 --- a/src/asahi/lib/agx_device.h +++ b/src/asahi/lib/agx_device.h @@ -13,8 +13,8 @@ #include "util/timespec.h" #include "util/vma.h" #include "agx_bo.h" -#include "agx_formats.h" #include "decode.h" +#include "layout.h" #include "unstable_asahi_drm.h" // TODO: this is a lie right now diff --git a/src/asahi/lib/agx_formats.c b/src/asahi/lib/agx_formats.c deleted file mode 100644 index f6293ee5759..00000000000 --- a/src/asahi/lib/agx_formats.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright 2021 Alyssa Rosenzweig - * SPDX-License-Identifier: MIT - */ - -#include "agx_formats.h" -#include "agx_internal_formats.h" -#include "agx_pack.h" - -#define AGX_INTERNAL_FORMAT__ PIPE_FORMAT_NONE - -#define AGX_FMT(pipe, channels_, type_, renderable_) \ - [PIPE_FORMAT_##pipe] = { \ - .channels = AGX_CHANNELS_##channels_, \ - .type = AGX_TEXTURE_TYPE_##type_, \ - .texturable = true, \ - .renderable = (enum pipe_format)AGX_INTERNAL_FORMAT_##renderable_, \ - } - -/* clang-format off */ -const struct agx_pixel_format_entry agx_pixel_format[PIPE_FORMAT_COUNT] = { - AGX_FMT(R5G6B5_UNORM, R5G6B5, UNORM, F16), - AGX_FMT(B5G6R5_UNORM, R5G6B5, UNORM, F16), - - AGX_FMT(R5G5B5A1_UNORM, R5G5B5A1, UNORM, F16), - AGX_FMT(B5G5R5A1_UNORM, R5G5B5A1, UNORM, F16), - AGX_FMT(R5G5B5X1_UNORM, R5G5B5A1, UNORM, F16), - AGX_FMT(B5G5R5X1_UNORM, R5G5B5A1, UNORM, F16), - - AGX_FMT(R4G4B4A4_UNORM, R4G4B4A4, UNORM, F16), - AGX_FMT(B4G4R4A4_UNORM, R4G4B4A4, UNORM, F16), - AGX_FMT(A4B4G4R4_UNORM, R4G4B4A4, UNORM, F16), - AGX_FMT(A4R4G4B4_UNORM, R4G4B4A4, UNORM, F16), - - AGX_FMT(R8_UNORM, R8, UNORM, U8NORM), - AGX_FMT(R8G8_UNORM, R8G8, UNORM, U8NORM), - AGX_FMT(R8G8B8A8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(A8R8G8B8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(A8B8G8R8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(B8G8R8A8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(R8G8B8X8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(X8R8G8B8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(X8B8G8R8_UNORM, R8G8B8A8, UNORM, U8NORM), - AGX_FMT(B8G8R8X8_UNORM, R8G8B8A8, UNORM, U8NORM), - - AGX_FMT(R16_UNORM, R16, UNORM, U16NORM), - AGX_FMT(R16G16_UNORM, R16G16, UNORM, U16NORM), - AGX_FMT(R16G16B16A16_UNORM, R16G16B16A16, UNORM, U16NORM), - AGX_FMT(R16_SNORM, R16, SNORM, S16NORM), - AGX_FMT(R16G16_SNORM, R16G16, SNORM, S16NORM), - AGX_FMT(R16G16B16A16_SNORM, R16G16B16A16, SNORM, S16NORM), - - AGX_FMT(R8_SRGB, R8, UNORM, SRGBA8), - AGX_FMT(R8G8_SRGB, R8G8, UNORM, SRGBA8), - AGX_FMT(R8G8B8A8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(A8R8G8B8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(A8B8G8R8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(B8G8R8A8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(R8G8B8X8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(X8R8G8B8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(X8B8G8R8_SRGB, R8G8B8A8, UNORM, SRGBA8), - AGX_FMT(B8G8R8X8_SRGB, R8G8B8A8, UNORM, SRGBA8), - - AGX_FMT(R8_SNORM, R8, SNORM, S8NORM), - AGX_FMT(R8G8_SNORM, R8G8, SNORM, S8NORM), - AGX_FMT(R8G8B8A8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(A8R8G8B8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(A8B8G8R8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(B8G8R8A8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(R8G8B8X8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(X8R8G8B8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(X8B8G8R8_SNORM, R8G8B8A8, SNORM, S8NORM), - AGX_FMT(B8G8R8X8_SNORM, R8G8B8A8, SNORM, S8NORM), - - AGX_FMT(R16_FLOAT, R16, FLOAT, F16), - AGX_FMT(R16G16_FLOAT, R16G16, FLOAT, F16), - AGX_FMT(R16G16B16X16_FLOAT, R16G16B16A16, FLOAT, F16), - AGX_FMT(R16G16B16A16_FLOAT, R16G16B16A16, FLOAT, F16), - - AGX_FMT(R32_FLOAT, R32, FLOAT, I32), - AGX_FMT(R32G32_FLOAT, R32G32, FLOAT, I32), - AGX_FMT(R32G32B32X32_FLOAT, R32G32B32A32, FLOAT, I32), - AGX_FMT(R32G32B32A32_FLOAT, R32G32B32A32, FLOAT, I32), - - AGX_FMT(R8_UINT, R8, UINT, I8), - AGX_FMT(R8G8_UINT, R8G8, UINT, I8), - AGX_FMT(R8G8B8X8_UINT, R8G8B8A8, UINT, I8), - AGX_FMT(R8G8B8A8_UINT, R8G8B8A8, UINT, I8), - AGX_FMT(B8G8R8X8_UINT, R8G8B8A8, UINT, I8), - AGX_FMT(B8G8R8A8_UINT, R8G8B8A8, UINT, I8), - - AGX_FMT(R16_UINT, R16, UINT, I16), - AGX_FMT(R16G16_UINT, R16G16, UINT, I16), - AGX_FMT(R16G16B16X16_UINT, R16G16B16A16, UINT, I16), - AGX_FMT(R16G16B16A16_UINT, R16G16B16A16, UINT, I16), - - AGX_FMT(R32_UINT, R32, UINT, I32), - AGX_FMT(R32G32_UINT, R32G32, UINT, I32), - AGX_FMT(R32G32B32X32_UINT, R32G32B32A32, UINT, I32), - AGX_FMT(R32G32B32A32_UINT, R32G32B32A32, UINT, I32), - - AGX_FMT(R8_SINT, R8, SINT, I8), - AGX_FMT(R8G8_SINT, R8G8, SINT, I8), - AGX_FMT(R8G8B8X8_SINT, R8G8B8A8, SINT, I8), - AGX_FMT(R8G8B8A8_SINT, R8G8B8A8, SINT, I8), - AGX_FMT(B8G8R8X8_SINT, R8G8B8A8, SINT, I8), - AGX_FMT(B8G8R8A8_SINT, R8G8B8A8, SINT, I8), - - AGX_FMT(R16_SINT, R16, SINT, I16), - AGX_FMT(R16G16_SINT, R16G16, SINT, I16), - AGX_FMT(R16G16B16X16_SINT, R16G16B16A16, SINT, I16), - AGX_FMT(R16G16B16A16_SINT, R16G16B16A16, SINT, I16), - - AGX_FMT(R32_SINT, R32, SINT, I32), - AGX_FMT(R32G32_SINT, R32G32, SINT, I32), - AGX_FMT(R32G32B32X32_SINT, R32G32B32A32, SINT, I32), - AGX_FMT(R32G32B32A32_SINT, R32G32B32A32, SINT, I32), - - AGX_FMT(Z16_UNORM, R16, UNORM, _), - AGX_FMT(Z32_FLOAT, R32, FLOAT, _), - AGX_FMT(Z32_FLOAT_S8X24_UINT, R32, FLOAT, _), - AGX_FMT(S8_UINT, R8, UINT, _), - - /* The stencil part of Z32F + S8 is just S8 */ - AGX_FMT(X32_S8X24_UINT, R8, UINT, _), - - /* These must be lowered by u_transfer_helper to Z32F + S8 */ - AGX_FMT(Z24X8_UNORM, R32, FLOAT, _), - AGX_FMT(Z24_UNORM_S8_UINT, R32, FLOAT, _), - - AGX_FMT(R10G10B10A2_UNORM, R10G10B10A2, UNORM, RGB10A2), - AGX_FMT(R10G10B10X2_UNORM, R10G10B10A2, UNORM, RGB10A2), - AGX_FMT(B10G10R10A2_UNORM, R10G10B10A2, UNORM, RGB10A2), - AGX_FMT(B10G10R10X2_UNORM, R10G10B10A2, UNORM, RGB10A2), - - AGX_FMT(R10G10B10A2_UINT, R10G10B10A2, UINT, I16), - AGX_FMT(B10G10R10A2_UINT, R10G10B10A2, UINT, I16), - - /* I don't see why this wouldn't be renderable, but it doesn't seem to work - * properly and it's not in Metal. - */ - AGX_FMT(R10G10B10A2_SINT, R10G10B10A2, SINT, _), - AGX_FMT(B10G10R10A2_SINT, R10G10B10A2, SINT, _), - - AGX_FMT(R11G11B10_FLOAT, R11G11B10, FLOAT, RG11B10F), - - /* TODO: This should be renderable but there are copyimage issues */ - AGX_FMT(R9G9B9E5_FLOAT, R9G9B9E5, FLOAT, _), - - /* These formats are emulated for texture buffers only */ - AGX_FMT(R32G32B32_FLOAT, R32G32B32_EMULATED, FLOAT, _), - AGX_FMT(R32G32B32_UINT, R32G32B32_EMULATED, UINT, _), - AGX_FMT(R32G32B32_SINT, R32G32B32_EMULATED, SINT, _), - - /* Likewise, luminance/alpha/intensity formats are supported for texturing, - * because they are required for texture buffers in the compat profile and - * mesa/st is unable to emulate them for texture buffers. Our Gallium driver - * handles the swizzles appropriately, so we just need to plumb through the - * enums. - * - * If mesa/st grows emulation for these formats later, we can drop this. - */ - AGX_FMT(A8_UNORM, R8, UNORM, _), - AGX_FMT(A16_UNORM, R16, UNORM, _), - AGX_FMT(A8_SINT, R8, SINT, _), - AGX_FMT(A16_SINT, R16, SINT, _), - AGX_FMT(A32_SINT, R32, SINT, _), - AGX_FMT(A8_UINT, R8, UINT, _), - AGX_FMT(A16_UINT, R16, UINT, _), - AGX_FMT(A32_UINT, R32, UINT, _), - AGX_FMT(A16_FLOAT, R16, FLOAT, _), - AGX_FMT(A32_FLOAT, R32, FLOAT, _), - - AGX_FMT(L8_UNORM, R8, UNORM, _), - AGX_FMT(L16_UNORM, R16, UNORM, _), - AGX_FMT(L8_SINT, R8, SINT, _), - AGX_FMT(L16_SINT, R16, SINT, _), - AGX_FMT(L32_SINT, R32, SINT, _), - AGX_FMT(L8_UINT, R8, UINT, _), - AGX_FMT(L16_UINT, R16, UINT, _), - AGX_FMT(L32_UINT, R32, UINT, _), - AGX_FMT(L16_FLOAT, R16, FLOAT, _), - AGX_FMT(L32_FLOAT, R32, FLOAT, _), - - AGX_FMT(L8A8_UNORM, R8G8, UNORM, _), - AGX_FMT(L16A16_UNORM, R16G16, UNORM, _), - AGX_FMT(L8A8_SINT, R8G8, SINT, _), - AGX_FMT(L16A16_SINT, R16G16, SINT, _), - AGX_FMT(L32A32_SINT, R32G32, SINT, _), - AGX_FMT(L8A8_UINT, R8G8, UINT, _), - AGX_FMT(L16A16_UINT, R16G16, UINT, _), - AGX_FMT(L32A32_UINT, R32G32, UINT, _), - AGX_FMT(L16A16_FLOAT, R16G16, FLOAT, _), - AGX_FMT(L32A32_FLOAT, R32G32, FLOAT, _), - - AGX_FMT(I8_UNORM, R8, UNORM, _), - AGX_FMT(I16_UNORM, R16, UNORM, _), - AGX_FMT(I8_SINT, R8, SINT, _), - AGX_FMT(I16_SINT, R16, SINT, _), - AGX_FMT(I32_SINT, R32, SINT, _), - AGX_FMT(I8_UINT, R8, UINT, _), - AGX_FMT(I16_UINT, R16, UINT, _), - AGX_FMT(I32_UINT, R32, UINT, _), - AGX_FMT(I16_FLOAT, R16, FLOAT, _), - AGX_FMT(I32_FLOAT, R32, FLOAT, _), - - AGX_FMT(ETC1_RGB8, ETC2_RGB8, UNORM, _), - AGX_FMT(ETC2_RGB8, ETC2_RGB8, UNORM, _), - AGX_FMT(ETC2_SRGB8, ETC2_RGB8, UNORM, _), - AGX_FMT(ETC2_RGB8A1, ETC2_RGB8A1, UNORM, _), - AGX_FMT(ETC2_SRGB8A1, ETC2_RGB8A1, UNORM, _), - AGX_FMT(ETC2_RGBA8, ETC2_RGBA8, UNORM, _), - AGX_FMT(ETC2_SRGBA8, ETC2_RGBA8, UNORM, _), - AGX_FMT(ETC2_R11_UNORM, EAC_R11, UNORM, _), - AGX_FMT(ETC2_R11_SNORM, EAC_R11, SNORM, _), - AGX_FMT(ETC2_RG11_UNORM, EAC_RG11, UNORM, _), - AGX_FMT(ETC2_RG11_SNORM, EAC_RG11, SNORM, _), - - AGX_FMT(ASTC_4x4, ASTC_4X4, UNORM, _), - AGX_FMT(ASTC_5x4, ASTC_5X4, UNORM, _), - AGX_FMT(ASTC_5x5, ASTC_5X5, UNORM, _), - AGX_FMT(ASTC_6x5, ASTC_6X5, UNORM, _), - AGX_FMT(ASTC_6x6, ASTC_6X6, UNORM, _), - AGX_FMT(ASTC_8x5, ASTC_8X5, UNORM, _), - AGX_FMT(ASTC_8x6, ASTC_8X6, UNORM, _), - AGX_FMT(ASTC_8x8, ASTC_8X8, UNORM, _), - AGX_FMT(ASTC_10x5, ASTC_10X5, UNORM, _), - AGX_FMT(ASTC_10x6, ASTC_10X6, UNORM, _), - AGX_FMT(ASTC_10x8, ASTC_10X8, UNORM, _), - AGX_FMT(ASTC_10x10, ASTC_10X10, UNORM, _), - AGX_FMT(ASTC_12x10, ASTC_12X10, UNORM, _), - AGX_FMT(ASTC_12x12, ASTC_12X12, UNORM, _), - - AGX_FMT(ASTC_4x4_SRGB, ASTC_4X4, UNORM, _), - AGX_FMT(ASTC_5x4_SRGB, ASTC_5X4, UNORM, _), - AGX_FMT(ASTC_5x5_SRGB, ASTC_5X5, UNORM, _), - AGX_FMT(ASTC_6x5_SRGB, ASTC_6X5, UNORM, _), - AGX_FMT(ASTC_6x6_SRGB, ASTC_6X6, UNORM, _), - AGX_FMT(ASTC_8x5_SRGB, ASTC_8X5, UNORM, _), - AGX_FMT(ASTC_8x6_SRGB, ASTC_8X6, UNORM, _), - AGX_FMT(ASTC_8x8_SRGB, ASTC_8X8, UNORM, _), - AGX_FMT(ASTC_10x5_SRGB, ASTC_10X5, UNORM, _), - AGX_FMT(ASTC_10x6_SRGB, ASTC_10X6, UNORM, _), - AGX_FMT(ASTC_10x8_SRGB, ASTC_10X8, UNORM, _), - AGX_FMT(ASTC_10x10_SRGB, ASTC_10X10, UNORM, _), - AGX_FMT(ASTC_12x10_SRGB, ASTC_12X10, UNORM, _), - AGX_FMT(ASTC_12x12_SRGB, ASTC_12X12, UNORM, _), - - AGX_FMT(DXT1_RGB, BC1, UNORM, _), - AGX_FMT(DXT1_RGBA, BC1, UNORM, _), - AGX_FMT(DXT1_SRGB, BC1, UNORM, _), - AGX_FMT(DXT1_SRGBA, BC1, UNORM, _), - AGX_FMT(DXT3_RGBA, BC2, UNORM, _), - AGX_FMT(DXT3_SRGBA, BC2, UNORM, _), - AGX_FMT(DXT5_RGBA, BC3, UNORM, _), - AGX_FMT(DXT5_SRGBA, BC3, UNORM, _), - AGX_FMT(RGTC1_UNORM, BC4, UNORM, _), - AGX_FMT(RGTC1_SNORM, BC4, SNORM, _), - AGX_FMT(RGTC2_UNORM, BC5, UNORM, _), - AGX_FMT(RGTC2_SNORM, BC5, SNORM, _), - AGX_FMT(BPTC_RGB_FLOAT, BC6H, FLOAT, _), - AGX_FMT(BPTC_RGB_UFLOAT, BC6H_UFLOAT, FLOAT, _), - AGX_FMT(BPTC_RGBA_UNORM, BC7, UNORM, _), - AGX_FMT(BPTC_SRGBA, BC7, UNORM, _), -}; -/* clang-format on */ diff --git a/src/asahi/lib/agx_formats.h b/src/asahi/lib/agx_formats.h deleted file mode 100644 index c189092de5d..00000000000 --- a/src/asahi/lib/agx_formats.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2021 Alyssa Rosenzweig - * SPDX-License-Identifier: MIT - * - */ - -#pragma once - -#include "util/format/u_format.h" - -struct agx_pixel_format_entry { - uint8_t channels; - uint8_t type; - bool texturable : 1; - enum pipe_format renderable; -}; - -extern const struct agx_pixel_format_entry agx_pixel_format[PIPE_FORMAT_COUNT]; - -static inline bool -agx_is_valid_pixel_format(enum pipe_format format) -{ - return agx_pixel_format[format].texturable; -} - -struct agx_border_packed; - -void agx_pack_border(struct agx_border_packed *out, const uint32_t in[4], - enum pipe_format format); diff --git a/src/asahi/lib/agx_helpers.h b/src/asahi/lib/agx_helpers.h index af5cedbf1f4..7dd8ddaabda 100644 --- a/src/asahi/lib/agx_helpers.h +++ b/src/asahi/lib/agx_helpers.h @@ -247,3 +247,8 @@ agx_gather_device_key(struct agx_device *dev) .soft_fault = agx_has_soft_fault(dev), }; } + +struct agx_border_packed; + +void agx_pack_border(struct agx_border_packed *out, const uint32_t in[4], + enum pipe_format format); diff --git a/src/asahi/lib/agx_nir_lower_texture.c b/src/asahi/lib/agx_nir_lower_texture.c index 99db4abb953..ea071b682d4 100644 --- a/src/asahi/lib/agx_nir_lower_texture.c +++ b/src/asahi/lib/agx_nir_lower_texture.c @@ -8,7 +8,6 @@ #include "compiler/nir/nir.h" #include "compiler/nir/nir_builder.h" -#include "agx_internal_formats.h" #include "agx_nir_passes.h" #include "glsl_types.h" #include "libagx_shaders.h" diff --git a/src/asahi/lib/agx_nir_lower_tilebuffer.c b/src/asahi/lib/agx_nir_lower_tilebuffer.c index fd9c1dd2108..6ed7249bffa 100644 --- a/src/asahi/lib/agx_nir_lower_tilebuffer.c +++ b/src/asahi/lib/agx_nir_lower_tilebuffer.c @@ -4,13 +4,13 @@ */ #include -#include "compiler/agx_internal_formats.h" #include "compiler/glsl_types.h" #include "util/format/u_format.h" #include "util/macros.h" #include "agx_nir_format_helpers.h" #include "agx_pack.h" #include "agx_tilebuffer.h" +#include "layout.h" #include "nir.h" #include "nir_builder.h" #include "nir_builder_opcodes.h" diff --git a/src/asahi/lib/agx_nir_lower_vbo.c b/src/asahi/lib/agx_nir_lower_vbo.c index a46c194fdd9..79466cd6778 100644 --- a/src/asahi/lib/agx_nir_lower_vbo.c +++ b/src/asahi/lib/agx_nir_lower_vbo.c @@ -4,7 +4,7 @@ */ #include "agx_nir_lower_vbo.h" -#include "asahi/compiler/agx_internal_formats.h" +#include "asahi/layout/layout.h" #include "compiler/nir/nir_builder.h" #include "compiler/nir/nir_format_convert.h" #include "util/bitset.h" @@ -223,8 +223,7 @@ pass(struct nir_builder *b, nir_intrinsic_instr *intr, void *data) * i.e. the set of formats that support masking. */ if (offset_el == 0 && (stride_el == 2 || stride_el == 4) && - agx_internal_format_supports_mask( - (enum agx_internal_formats)interchange_format)) { + ail_isa_format_supports_mask((enum ail_isa_format)interchange_format)) { shift = util_logbase2(stride_el); stride_el = 1; diff --git a/src/asahi/lib/agx_tilebuffer.c b/src/asahi/lib/agx_tilebuffer.c index 72adb2dcde7..2c7c385e7c8 100644 --- a/src/asahi/lib/agx_tilebuffer.c +++ b/src/asahi/lib/agx_tilebuffer.c @@ -5,11 +5,10 @@ #include "agx_tilebuffer.h" #include -#include "compiler/agx_internal_formats.h" #include "util/bitscan.h" #include "util/format/u_format.h" -#include "agx_formats.h" #include "agx_usc.h" +#include "layout.h" /* Maximum number of bytes per tile on G13G. This may change in future versions * of the architecture. @@ -141,7 +140,7 @@ agx_build_tilebuffer_layout(const enum pipe_format *formats, uint8_t nr_cbufs, enum pipe_format agx_tilebuffer_physical_format(struct agx_tilebuffer_layout *tib, unsigned rt) { - return agx_pixel_format[tib->logical_format[rt]].renderable; + return ail_pixel_format[tib->logical_format[rt]].renderable; } bool @@ -154,7 +153,7 @@ agx_tilebuffer_supports_mask(struct agx_tilebuffer_layout *tib, unsigned rt) return false; enum pipe_format fmt = agx_tilebuffer_physical_format(tib, rt); - return agx_internal_format_supports_mask((enum agx_internal_formats)fmt); + return ail_isa_format_supports_mask((enum ail_isa_format)fmt); } uint32_t diff --git a/src/asahi/lib/meson.build b/src/asahi/lib/meson.build index 8ad0fbbed00..04e8d577f95 100644 --- a/src/asahi/lib/meson.build +++ b/src/asahi/lib/meson.build @@ -10,7 +10,6 @@ libasahi_lib_files = files( 'agx_border.c', 'agx_device.c', 'agx_device_virtio.c', - 'agx_formats.c', 'agx_linker.c', 'agx_bg_eot.c', 'agx_tilebuffer.c', @@ -111,7 +110,7 @@ if with_tests c_args : [c_msvc_compat_args, no_override_init_args], gnu_symbol_visibility : 'hidden', dependencies: [idep_gtest, idep_agx_pack, idep_mesautil], - link_with : [libasahi_lib], + link_with : [libasahi_lib, libasahi_layout], ), suite : ['asahi'], protocol : 'gtest', diff --git a/src/asahi/meson.build b/src/asahi/meson.build index c5f08ead519..1494a6b3038 100644 --- a/src/asahi/meson.build +++ b/src/asahi/meson.build @@ -7,10 +7,10 @@ inc_asahi = include_directories([ ]) if with_gallium_asahi or with_asahi_vk + subdir('genxml') subdir('layout') subdir('compiler') subdir('clc') - subdir('genxml') subdir('lib') endif diff --git a/src/asahi/vulkan/hk_buffer_view.c b/src/asahi/vulkan/hk_buffer_view.c index 73d32d945ae..a5fe25983de 100644 --- a/src/asahi/vulkan/hk_buffer_view.c +++ b/src/asahi/vulkan/hk_buffer_view.c @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT */ #include "hk_buffer_view.h" -#include "asahi/lib/agx_formats.h" +#include "asahi/layout/layout.h" #include "asahi/lib/agx_nir_lower_vbo.h" #include "util/bitscan.h" #include "util/format/u_format.h" @@ -34,7 +34,7 @@ hk_get_buffer_format_features(struct hk_physical_device *pdev, if (agx_vbo_supports_format(p_format)) features |= VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT; - if (agx_pixel_format[p_format].texturable && + if (ail_pixel_format[p_format].texturable && !util_format_is_depth_or_stencil(p_format)) { features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT; @@ -104,8 +104,8 @@ hk_CreateBufferView(VkDevice _device, const VkBufferViewCreateInfo *pCreateInfo, agx_pack(&tex, TEXTURE, cfg) { cfg.dimension = AGX_TEXTURE_DIMENSION_2D; cfg.layout = AGX_LAYOUT_LINEAR; - cfg.channels = agx_pixel_format[format].channels; - cfg.type = agx_pixel_format[format].type; + cfg.channels = ail_pixel_format[format].channels; + cfg.type = ail_pixel_format[format].type; cfg.swizzle_r = agx_channel_from_pipe(format_swizzle[0]); cfg.swizzle_g = agx_channel_from_pipe(format_swizzle[1]); cfg.swizzle_b = agx_channel_from_pipe(format_swizzle[2]); @@ -130,8 +130,8 @@ hk_CreateBufferView(VkDevice _device, const VkBufferViewCreateInfo *pCreateInfo, agx_pack(&pbe, PBE, cfg) { cfg.dimension = AGX_TEXTURE_DIMENSION_2D; cfg.layout = AGX_LAYOUT_LINEAR; - cfg.channels = agx_pixel_format[format].channels; - cfg.type = agx_pixel_format[format].type; + cfg.channels = ail_pixel_format[format].channels; + cfg.type = ail_pixel_format[format].type; cfg.srgb = util_format_is_srgb(format); assert(desc->nr_channels >= 1 && desc->nr_channels <= 4); diff --git a/src/asahi/vulkan/hk_cmd_clear.c b/src/asahi/vulkan/hk_cmd_clear.c index 427c5fed2a1..50a5fae752d 100644 --- a/src/asahi/vulkan/hk_cmd_clear.c +++ b/src/asahi/vulkan/hk_cmd_clear.c @@ -4,8 +4,8 @@ * Copyright 2022-2023 Collabora Ltd. and Red Hat Inc. * SPDX-License-Identifier: MIT */ -#include "agx_formats.h" #include "hk_cmd_buffer.h" +#include "layout.h" #include "hk_device.h" #include "hk_entrypoints.h" @@ -164,7 +164,7 @@ hk_CmdClearColorImage(VkCommandBuffer commandBuffer, VkImage _image, enum pipe_format p_format = vk_format_to_pipe_format(vk_format); assert(p_format != PIPE_FORMAT_NONE); - if (!agx_pixel_format[p_format].renderable) { + if (!ail_pixel_format[p_format].renderable) { memset(&clear_value, 0, sizeof(clear_value)); util_format_pack_rgba(p_format, clear_value.color.uint32, pColor->uint32, 1); diff --git a/src/asahi/vulkan/hk_image.c b/src/asahi/vulkan/hk_image.c index 1f203996faf..bb2c9f892ca 100644 --- a/src/asahi/vulkan/hk_image.c +++ b/src/asahi/vulkan/hk_image.c @@ -6,7 +6,6 @@ */ #include "hk_image.h" #include "asahi/layout/layout.h" -#include "asahi/lib/agx_formats.h" #include "drm-uapi/drm_fourcc.h" #include "util/bitscan.h" #include "util/format/u_format.h" @@ -74,7 +73,7 @@ hk_get_image_plane_format_features(struct hk_physical_device *pdev, } } - if (agx_pixel_format[p_format].texturable) { + if (ail_pixel_format[p_format].texturable) { features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; features |= VK_FORMAT_FEATURE_2_BLIT_SRC_BIT; @@ -90,7 +89,7 @@ hk_get_image_plane_format_features(struct hk_physical_device *pdev, } } - if (agx_pixel_format[p_format].renderable) { + if (ail_pixel_format[p_format].renderable) { /* For now, disable snorm rendering due to nir_lower_blend bugs. * * TODO: revisit. diff --git a/src/asahi/vulkan/hk_image_view.c b/src/asahi/vulkan/hk_image_view.c index 5a78224a4fd..285e2dd84e6 100644 --- a/src/asahi/vulkan/hk_image_view.c +++ b/src/asahi/vulkan/hk_image_view.c @@ -255,8 +255,8 @@ pack_texture(struct hk_image_view *view, unsigned view_plane, cfg.dimension = translate_image_view_type( view->vk.view_type, view->vk.image->samples > 1, layers > 1, usage); cfg.layout = agx_translate_layout(layout->tiling); - cfg.channels = agx_pixel_format[p_format].channels; - cfg.type = agx_pixel_format[p_format].type; + cfg.channels = ail_pixel_format[p_format].channels; + cfg.type = ail_pixel_format[p_format].type; cfg.srgb = util_format_is_srgb(p_format); cfg.swizzle_r = agx_channel_from_pipe(out_swizzle[0]); @@ -357,8 +357,8 @@ pack_pbe(struct hk_device *dev, struct hk_image_view *view, unsigned view_plane, cfg.dimension = translate_image_view_type(view->vk.view_type, msaa, layers > 1, usage); cfg.layout = agx_translate_layout(layout->tiling); - cfg.channels = agx_pixel_format[p_format].channels; - cfg.type = agx_pixel_format[p_format].type; + cfg.channels = ail_pixel_format[p_format].channels; + cfg.type = ail_pixel_format[p_format].type; cfg.srgb = util_format_is_srgb(p_format); assert(desc->nr_channels >= 1 && desc->nr_channels <= 4); diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index b0e4748b076..4b7c08aa271 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -1923,7 +1923,7 @@ intrinsic("load_uvs_index_agx", dest_comp = 1, bit_sizes=[16], # converting between floating-point registers and normalized memory formats. # # The format is the pipe_format of the local memory (the source), see -# agx_internal_formats.h for the supported list. +# ail for the supported list. # # Logically, this loads/stores a single sample. The sample to load is # specified by the bitfield sample mask source. However, for stores multiple @@ -1955,7 +1955,7 @@ intrinsic("store_zs_agx", [1, 1, 1], indices=[BASE], flags=[]) # kernels. # # The format is the pipe_format of the local memory (the source), see -# agx_internal_formats.h for the supported list. The image format is +# ail for the supported list. The image format is # specified in the PBE descriptor. # # The image dimension is used to distinguish multisampled images from @@ -1964,8 +1964,8 @@ intrinsic("store_zs_agx", [1, 1, 1], indices=[BASE], flags=[]) # extra src[] = { logical offset within shared memory, coordinates/layer } image("store_block_agx", [1, -1], extra_indices=[EXPLICIT_COORD]) -# Formatted load/store. The format is the pipe_format in memory (see -# agx_internal_formats.h for the supported list). This accesses: +# Formatted load/store. The format is the pipe_format in memory (see ail for the +# supported list). This accesses: # # address + extend(index) << (format shift + shift) # diff --git a/src/gallium/drivers/asahi/agx_blit.c b/src/gallium/drivers/asahi/agx_blit.c index 8cdbe4ee1d1..a490983e9da 100644 --- a/src/gallium/drivers/asahi/agx_blit.c +++ b/src/gallium/drivers/asahi/agx_blit.c @@ -25,8 +25,6 @@ #include "util/ralloc.h" #include "util/u_sampler.h" #include "util/u_surface.h" -#include "agx_formats.h" -#include "agx_internal_formats.h" #include "agx_state.h" #include "glsl_types.h" #include "nir.h" @@ -203,7 +201,7 @@ asahi_blit_compute_shader(struct pipe_context *ctx, struct asahi_blit_key *key) * flow of fragment and end-of-tile shaders. */ enum pipe_format tib_format = - agx_pixel_format[effective_format(key->dst_format)].renderable; + ail_pixel_format[effective_format(key->dst_format)].renderable; nir_store_local_pixel_agx(b, color, nir_imm_int(b, 1), lid, .base = 0, .write_mask = 0xf, .format = tib_format, diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 0713ecf2db0..732bd867e32 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -10,7 +10,6 @@ #include #include "asahi/compiler/agx_compile.h" #include "asahi/layout/layout.h" -#include "asahi/lib/agx_formats.h" #include "asahi/lib/decode.h" #include "asahi/lib/unstable_asahi_drm.h" #include "drm-uapi/drm_fourcc.h" @@ -428,7 +427,7 @@ agx_compression_allowed(const struct agx_resource *pres) * renderable formats. As framebuffer compression, other formats don't make a * ton of sense to compress anyway. */ - if (agx_pixel_format[pres->base.format].renderable == PIPE_FORMAT_NONE && + if (ail_pixel_format[pres->base.format].renderable == PIPE_FORMAT_NONE && !util_format_is_depth_or_stencil(pres->base.format)) { rsrc_debug(pres, "No compression: format not renderable\n"); return false; @@ -2497,9 +2496,9 @@ agx_is_format_supported(struct pipe_screen *pscreen, enum pipe_format format, if (tex_format == PIPE_FORMAT_X24S8_UINT) tex_format = PIPE_FORMAT_S8_UINT; - struct agx_pixel_format_entry ent = agx_pixel_format[tex_format]; + struct ail_pixel_format_entry ent = ail_pixel_format[tex_format]; - if (!agx_is_valid_pixel_format(tex_format)) + if (!ail_is_valid_pixel_format(tex_format)) return false; /* RGB32, luminance/alpha/intensity emulated for texture buffers only */ diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index b9799ac4a4f..11d15009df1 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -11,7 +11,6 @@ #include "asahi/compiler/agx_compile.h" #include "asahi/genxml/agx_pack.h" #include "asahi/layout/layout.h" -#include "asahi/lib/agx_formats.h" #include "asahi/lib/agx_helpers.h" #include "asahi/lib/agx_nir_passes.h" #include "asahi/lib/agx_ppp.h" @@ -91,7 +90,7 @@ agx_legalize_compression(struct agx_context *ctx, struct agx_resource *rsrc, * This has not been exhaustively tested and might be missing some corner * cases around XR formats, but is well-motivated and seems to work. */ - if (agx_pixel_format[storage].channels == agx_pixel_format[format].channels) + if (ail_pixel_format[storage].channels == ail_pixel_format[format].channels) return; /* Otherwise, decompress. */ @@ -671,7 +670,7 @@ agx_pack_texture(void *out, struct agx_resource *rsrc, { const struct util_format_description *desc = util_format_description(format); - assert(agx_is_valid_pixel_format(format)); + assert(ail_is_valid_pixel_format(format)); uint8_t format_swizzle[4] = { desc->swizzle[0], @@ -707,8 +706,8 @@ agx_pack_texture(void *out, struct agx_resource *rsrc, cfg.dimension = agx_translate_tex_dim(state->target, util_res_sample_count(&rsrc->base)); cfg.layout = agx_translate_layout(rsrc->layout.tiling); - cfg.channels = agx_pixel_format[format].channels; - cfg.type = agx_pixel_format[format].type; + cfg.channels = ail_pixel_format[format].channels; + cfg.type = ail_pixel_format[format].type; cfg.swizzle_r = agx_channel_from_pipe(out_swizzle[0]); cfg.swizzle_g = agx_channel_from_pipe(out_swizzle[1]); cfg.swizzle_b = agx_channel_from_pipe(out_swizzle[2]); @@ -1228,8 +1227,8 @@ agx_batch_upload_pbe(struct agx_batch *batch, struct agx_pbe_packed *out, cfg.dimension = agx_translate_tex_dim(target, util_res_sample_count(&tex->base)); cfg.layout = agx_translate_layout(tex->layout.tiling); - cfg.channels = agx_pixel_format[view->format].channels; - cfg.type = agx_pixel_format[view->format].type; + cfg.channels = ail_pixel_format[view->format].channels; + cfg.type = ail_pixel_format[view->format].type; cfg.srgb = util_format_is_srgb(view->format); assert(desc->nr_channels >= 1 && desc->nr_channels <= 4);