diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blending.c | 29 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.c | 56 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_format.c | 452 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_texture.c | 6 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_texture.h | 8 |
6 files changed, 288 insertions, 267 deletions
diff --git a/src/gallium/drivers/panfrost/pan_blending.c b/src/gallium/drivers/panfrost/pan_blending.c index 297bd0f3fd9..458ab51a4e9 100644 --- a/src/gallium/drivers/panfrost/pan_blending.c +++ b/src/gallium/drivers/panfrost/pan_blending.c @@ -107,26 +107,15 @@ panfrost_can_fixed_blend(enum pipe_format format) /* Fixed-function can handle sRGB */ format = util_format_linear(format); - /* Decompose the format */ - const struct util_format_description *desc = - util_format_description(format); - - /* Any 8-bit unorm is supported */ - if (util_format_is_unorm8(desc)) - return true; - - /* Certain special formats are, too */ - switch (format) { - case PIPE_FORMAT_B5G6R5_UNORM: - case PIPE_FORMAT_R10G10B10A2_UNORM: - case PIPE_FORMAT_B10G10R10A2_UNORM: - case PIPE_FORMAT_R10G10B10X2_UNORM: - case PIPE_FORMAT_B10G10R10X2_UNORM: - case PIPE_FORMAT_B4G4R4A4_UNORM: - case PIPE_FORMAT_B4G4R4X4_UNORM: - case PIPE_FORMAT_A4R4_UNORM: - case PIPE_FORMAT_R4A4_UNORM: - case PIPE_FORMAT_A4B4G4R4_UNORM: + switch (panfrost_pipe_format_table[format].hw) { + case MALI_RGB565: + case MALI_RGB5_A1_UNORM: + case MALI_RGB10_A2_UNORM: + case MALI_RGBA4_UNORM: + case MALI_R8_UNORM: + case MALI_RG8_UNORM: + case MALI_RGB8_UNORM: + case MALI_RGBA8_UNORM: return true; default: return false; diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index c8af10729c9..d20bd560b65 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -520,7 +520,9 @@ panfrost_create_vertex_elements_state( else so->hw[i].swizzle = panfrost_bifrost_swizzle(desc->nr_channels); - so->hw[i].format = panfrost_find_format(desc); + enum mali_format hw_format = panfrost_pipe_format_table[desc->format].hw; + so->hw[i].format = hw_format; + assert(hw_format); } /* Let's also prepare vertex builtins */ diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index c422625409e..9ec1c7f7330 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -462,19 +462,6 @@ panfrost_is_format_supported( struct pipe_screen *screen, if (MAX2(sample_count, 1) != MAX2(storage_sample_count, 1)) return false; - /* Format wishlist */ - if (format == PIPE_FORMAT_X8Z24_UNORM) - return false; - - if (format == PIPE_FORMAT_A1B5G5R5_UNORM || - format == PIPE_FORMAT_X1B5G5R5_UNORM || - format == PIPE_FORMAT_B2G3R3_UNORM) - return false; - - /* TODO */ - if (format == PIPE_FORMAT_B5G5R5A1_UNORM) - return FALSE; - /* Don't confuse poorly written apps (workaround dEQP bug) that expect * more alpha than they ask for */ @@ -484,45 +471,14 @@ panfrost_is_format_supported( struct pipe_screen *screen, if (scanout && renderable && !util_format_is_rgba8_variant(format_desc)) return false; - switch (format_desc->layout) { - case UTIL_FORMAT_LAYOUT_PLAIN: - case UTIL_FORMAT_LAYOUT_OTHER: - break; - case UTIL_FORMAT_LAYOUT_ETC: - case UTIL_FORMAT_LAYOUT_ASTC: - return true; - default: - return false; - } + /* Check we support the format with the given bind */ - if (format_desc->channel[0].size > 32) - return false; - - /* Internally, formats that are depth/stencil renderable are limited. - * - * In particular: Z16, Z24, Z24S8, S8 are all identical from the GPU - * rendering perspective. That is, we render to Z24S8 (which we can - * AFBC compress), ignore the different when texturing (who cares?), - * and then in the off-chance there's a CPU read we blit back to - * staging. - * - * ...alternatively, we can make the gallium frontend deal with that. */ - - if (bind & PIPE_BIND_DEPTH_STENCIL) { - switch (format) { - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z32_UNORM: - case PIPE_FORMAT_Z32_FLOAT: - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - return true; - - default: - return false; - } - } + unsigned relevant_bind = bind & + ( PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_RENDER_TARGET + | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_SAMPLER_VIEW); - return true; + struct panfrost_format fmt = panfrost_pipe_format_table[format]; + return fmt.hw && ((relevant_bind & ~fmt.bind) == 0); } static int diff --git a/src/panfrost/encoder/pan_format.c b/src/panfrost/encoder/pan_format.c index 66b3e68af00..c14c09758f2 100644 --- a/src/panfrost/encoder/pan_format.c +++ b/src/panfrost/encoder/pan_format.c @@ -28,197 +28,264 @@ #include "panfrost-job.h" #include "pan_texture.h" -static unsigned -panfrost_translate_channel_width(unsigned size) -{ - switch (size) { - case 4: - return MALI_CHANNEL_4; - case 8: - return MALI_CHANNEL_8; - case 16: - return MALI_CHANNEL_16; - case 32: - return MALI_CHANNEL_32; - default: - unreachable("Invalid format width\n"); - } -} - -static unsigned -panfrost_translate_channel_type(unsigned type, unsigned size, bool norm) -{ - switch (type) { - case UTIL_FORMAT_TYPE_UNSIGNED: - return norm ? MALI_FORMAT_UNORM : MALI_FORMAT_UINT; - - case UTIL_FORMAT_TYPE_SIGNED: - return norm ? MALI_FORMAT_SNORM : MALI_FORMAT_SINT; - - case UTIL_FORMAT_TYPE_FLOAT: - /* fp16 -- SINT, fp32 -- UNORM ... gotta use those bits */ - - if (size == 16) - return MALI_FORMAT_SINT; - else if (size == 32) - return MALI_FORMAT_UNORM; - else - unreachable("Invalid float size"); - - default: - unreachable("Invalid type"); - } -} - -/* Constructs a mali_format satisfying the specified Gallium format - * description */ - -enum mali_format -panfrost_find_format(const struct util_format_description *desc) -{ - /* Find first non-VOID channel */ - struct util_format_channel_description chan = desc->channel[0]; - - for (unsigned c = 0; c < 4; ++c) - { - if (desc->channel[c].type == UTIL_FORMAT_TYPE_VOID) - continue; - - chan = desc->channel[c]; - break; - } - - /* Check for special formats */ - switch (desc->format) - { - case PIPE_FORMAT_R10G10B10X2_UNORM: - case PIPE_FORMAT_B10G10R10X2_UNORM: - case PIPE_FORMAT_R10G10B10A2_UNORM: - case PIPE_FORMAT_B10G10R10A2_UNORM: - return MALI_RGB10_A2_UNORM; - - case PIPE_FORMAT_R10G10B10X2_SNORM: - case PIPE_FORMAT_R10G10B10A2_SNORM: - case PIPE_FORMAT_B10G10R10A2_SNORM: - return MALI_RGB10_A2_SNORM; - - case PIPE_FORMAT_R10G10B10A2_UINT: - case PIPE_FORMAT_B10G10R10A2_UINT: - case PIPE_FORMAT_R10G10B10A2_USCALED: - case PIPE_FORMAT_B10G10R10A2_USCALED: - return MALI_RGB10_A2UI; - - case PIPE_FORMAT_R10G10B10A2_SSCALED: - case PIPE_FORMAT_B10G10R10A2_SSCALED: - return MALI_RGB10_A2I; - - case PIPE_FORMAT_Z32_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - return MALI_Z32_UNORM; - - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - /* Z32F = R32F to the hardware */ - return MALI_R32F; - - case PIPE_FORMAT_R3G3B2_UNORM: - return MALI_RGB332_UNORM; - - case PIPE_FORMAT_B5G6R5_UNORM: - return MALI_RGB565; - - case PIPE_FORMAT_B5G5R5X1_UNORM: - return MALI_RGB5_X1_UNORM; - - case PIPE_FORMAT_B5G5R5A1_UNORM: - return MALI_RGB5_A1_UNORM; - - case PIPE_FORMAT_A1B5G5R5_UNORM: - case PIPE_FORMAT_X1B5G5R5_UNORM: - /* Not supported - this is backwards from OpenGL! */ - assert(0); - break; - - case PIPE_FORMAT_R32_FIXED: - return MALI_R32_FIXED; - case PIPE_FORMAT_R32G32_FIXED: - return MALI_RG32_FIXED; - case PIPE_FORMAT_R32G32B32_FIXED: - return MALI_RGB32_FIXED; - case PIPE_FORMAT_R32G32B32A32_FIXED: - return MALI_RGBA32_FIXED; - - case PIPE_FORMAT_R11G11B10_FLOAT: - return MALI_R11F_G11F_B10F; - case PIPE_FORMAT_R9G9B9E5_FLOAT: - return MALI_R9F_G9F_B9F_E5F; - - case PIPE_FORMAT_ETC1_RGB8: - case PIPE_FORMAT_ETC2_RGB8: - case PIPE_FORMAT_ETC2_SRGB8: - return MALI_ETC2_RGB8; - - case PIPE_FORMAT_ETC2_RGB8A1: - case PIPE_FORMAT_ETC2_SRGB8A1: - return MALI_ETC2_RGB8A1; - - case PIPE_FORMAT_ETC2_RGBA8: - case PIPE_FORMAT_ETC2_SRGBA8: - return MALI_ETC2_RGBA8; - - case PIPE_FORMAT_ETC2_R11_UNORM: - return MALI_ETC2_R11_UNORM; - case PIPE_FORMAT_ETC2_R11_SNORM: - return MALI_ETC2_R11_SNORM; - - case PIPE_FORMAT_ETC2_RG11_UNORM: - return MALI_ETC2_RG11_UNORM; - case PIPE_FORMAT_ETC2_RG11_SNORM: - return MALI_ETC2_RG11_SNORM; - - default: - /* Fallthrough to default */ - break; - } - - if (desc->layout == UTIL_FORMAT_LAYOUT_ASTC) { - if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) - return MALI_ASTC_SRGB_SUPP; - else - return MALI_ASTC_HDR_SUPP; - } - - /* Formats must match in channel count */ - assert(desc->nr_channels >= 1 && desc->nr_channels <= 4); - unsigned format = MALI_NR_CHANNELS(desc->nr_channels); - - switch (chan.type) - { - case UTIL_FORMAT_TYPE_UNSIGNED: - case UTIL_FORMAT_TYPE_SIGNED: - case UTIL_FORMAT_TYPE_FIXED: - /* Channel width */ - format |= panfrost_translate_channel_width(chan.size); - - /* Channel type */ - format |= panfrost_translate_channel_type(chan.type, chan.size, chan.normalized); - break; - - case UTIL_FORMAT_TYPE_FLOAT: - /* Float formats use a special width and encode width - * with type mixed */ - - format |= MALI_CHANNEL_FLOAT; - format |= panfrost_translate_channel_type(chan.type, chan.size, chan.normalized); - break; - - default: - fprintf(stderr, "%s\n", util_format_name(desc->format)); - unreachable("Invalid format type"); - } - - return (enum mali_format) format; -} +/* Convenience */ + +#define _V PIPE_BIND_VERTEX_BUFFER +#define _T PIPE_BIND_SAMPLER_VIEW +#define _R PIPE_BIND_RENDER_TARGET +#define _Z PIPE_BIND_DEPTH_STENCIL +#define _VT (_V | _T) +#define _VTR (_V | _T | _R) +#define _TZ (_T | _Z) + +struct panfrost_format panfrost_pipe_format_table[PIPE_FORMAT_COUNT] = { + [PIPE_FORMAT_ETC1_RGB8] = { MALI_ETC2_RGB8, _T }, + [PIPE_FORMAT_ETC2_RGB8] = { MALI_ETC2_RGB8, _T }, + [PIPE_FORMAT_ETC2_SRGB8] = { MALI_ETC2_RGB8, _T }, + [PIPE_FORMAT_ETC2_R11_UNORM] = { MALI_ETC2_R11_UNORM, _T }, + [PIPE_FORMAT_ETC2_RGBA8] = { MALI_ETC2_RGBA8, _T }, + [PIPE_FORMAT_ETC2_SRGBA8] = { MALI_ETC2_RGBA8, _T }, + [PIPE_FORMAT_ETC2_RG11_UNORM] = { MALI_ETC2_RG11_UNORM, _T }, + [PIPE_FORMAT_ETC2_R11_SNORM] = { MALI_ETC2_R11_SNORM, _T }, + [PIPE_FORMAT_ETC2_RG11_SNORM] = { MALI_ETC2_RG11_SNORM, _T }, + [PIPE_FORMAT_ETC2_RGB8A1] = { MALI_ETC2_RGB8A1, _T }, + [PIPE_FORMAT_ETC2_SRGB8A1] = { MALI_ETC2_RGB8A1, _T }, + + [PIPE_FORMAT_ASTC_4x4] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_5x4] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_5x5] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_6x5] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_6x6] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x5] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x6] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x8] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x5] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x6] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x8] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x10] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_12x10] = { MALI_ASTC_HDR_SUPP, _T }, + [PIPE_FORMAT_ASTC_12x12] = { MALI_ASTC_HDR_SUPP, _T }, + + [PIPE_FORMAT_ASTC_4x4_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_5x4_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_5x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_6x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_6x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_8x8_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x8_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_10x10_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_12x10_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_12x12_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_B5G6R5_UNORM] = { MALI_RGB565, _VTR }, + [PIPE_FORMAT_B5G5R5X1_UNORM] = { MALI_RGB5_X1_UNORM, _VT }, + [PIPE_FORMAT_R5G5B5A1_UNORM] = { MALI_RGB5_A1_UNORM, _VTR }, + + [PIPE_FORMAT_R10G10B10X2_UNORM] = { MALI_RGB10_A2_UNORM, _VTR }, + [PIPE_FORMAT_B10G10R10X2_UNORM] = { MALI_RGB10_A2_UNORM, _VTR }, + [PIPE_FORMAT_R10G10B10A2_UNORM] = { MALI_RGB10_A2_UNORM, _VTR }, + [PIPE_FORMAT_B10G10R10A2_UNORM] = { MALI_RGB10_A2_UNORM, _VTR }, + [PIPE_FORMAT_R10G10B10X2_SNORM] = { MALI_RGB10_A2_SNORM, _VT }, + [PIPE_FORMAT_R10G10B10A2_SNORM] = { MALI_RGB10_A2_SNORM, _VT }, + [PIPE_FORMAT_B10G10R10A2_SNORM] = { MALI_RGB10_A2_SNORM, _VT }, + [PIPE_FORMAT_R10G10B10A2_UINT] = { MALI_RGB10_A2UI, _VTR }, + [PIPE_FORMAT_B10G10R10A2_UINT] = { MALI_RGB10_A2UI, _VTR }, + [PIPE_FORMAT_R10G10B10A2_USCALED] = { MALI_RGB10_A2UI, _VTR }, + [PIPE_FORMAT_B10G10R10A2_USCALED] = { MALI_RGB10_A2UI, _VTR }, + [PIPE_FORMAT_R10G10B10A2_SINT] = { MALI_RGB10_A2I, _VTR}, + [PIPE_FORMAT_B10G10R10A2_SINT] = { MALI_RGB10_A2I, _VTR }, + [PIPE_FORMAT_R10G10B10A2_SSCALED] = { MALI_RGB10_A2I, _VTR }, + [PIPE_FORMAT_B10G10R10A2_SSCALED] = { MALI_RGB10_A2I, _VTR }, + + [PIPE_FORMAT_R8_SSCALED] = { MALI_R8I, _V }, + [PIPE_FORMAT_R8G8_SSCALED] = { MALI_RG8I, _V }, + [PIPE_FORMAT_R8G8B8_SSCALED] = { MALI_RGB8I, _V }, + [PIPE_FORMAT_B8G8R8_SSCALED] = { MALI_RGB8I, _V }, + [PIPE_FORMAT_R8G8B8A8_SSCALED] = { MALI_RGBA8I, _V }, + [PIPE_FORMAT_B8G8R8A8_SSCALED] = { MALI_RGBA8I, _V }, + [PIPE_FORMAT_A8B8G8R8_SSCALED] = { MALI_RGBA8I, _V }, + + [PIPE_FORMAT_R3G3B2_UNORM] = { MALI_RGB332_UNORM, _VT }, + + [PIPE_FORMAT_Z24_UNORM_S8_UINT] = { MALI_Z32_UNORM, _TZ }, + [PIPE_FORMAT_Z24X8_UNORM] = { MALI_Z32_UNORM, _TZ }, + [PIPE_FORMAT_Z32_UNORM] = { MALI_Z32_UNORM, _TZ }, + [PIPE_FORMAT_Z32_FLOAT] = { MALI_R32F, _TZ }, + [PIPE_FORMAT_Z32_FLOAT_S8X24_UINT] = { MALI_R32F, _TZ }, + + [PIPE_FORMAT_R32_FIXED] = { MALI_R32_FIXED, _V }, + [PIPE_FORMAT_R32G32_FIXED] = { MALI_RG32_FIXED, _V }, + [PIPE_FORMAT_R32G32B32_FIXED] = { MALI_RGB32_FIXED, _V }, + [PIPE_FORMAT_R32G32B32A32_FIXED] = { MALI_RGBA32_FIXED, _V }, + + [PIPE_FORMAT_R11G11B10_FLOAT] = { MALI_R11F_G11F_B10F, _VTR}, + [PIPE_FORMAT_R9G9B9E5_FLOAT] = { MALI_R9F_G9F_B9F_E5F, _VT }, + + [PIPE_FORMAT_R8_SNORM] = { MALI_R8_SNORM, _VT }, + [PIPE_FORMAT_R16_SNORM] = { MALI_R16_SNORM, _VT }, + [PIPE_FORMAT_R32_SNORM] = { MALI_R32_SNORM, _VT }, + [PIPE_FORMAT_R8G8_SNORM] = { MALI_RG8_SNORM, _VT }, + [PIPE_FORMAT_R16G16_SNORM] = { MALI_RG16_SNORM, _VT }, + [PIPE_FORMAT_R32G32_SNORM] = { MALI_RG32_SNORM, _VT }, + [PIPE_FORMAT_R8G8B8_SNORM] = { MALI_RGB8_SNORM, _VT }, + [PIPE_FORMAT_R16G16B16_SNORM] = { MALI_RGB16_SNORM, _VT }, + [PIPE_FORMAT_R32G32B32_SNORM] = { MALI_RGB32_SNORM, _VT }, + [PIPE_FORMAT_R8G8B8A8_SNORM] = { MALI_RGBA8_SNORM, _VT }, + [PIPE_FORMAT_R16G16B16A16_SNORM] = { MALI_RGBA16_SNORM, _VT }, + [PIPE_FORMAT_R32G32B32A32_SNORM] = { MALI_RGBA32_SNORM, _VT }, + + [PIPE_FORMAT_A8_SINT] = { MALI_R8I, _VTR }, + [PIPE_FORMAT_I8_SINT] = { MALI_R8I, _VTR }, + [PIPE_FORMAT_L8_SINT] = { MALI_R8I, _VTR }, + [PIPE_FORMAT_L8A8_SINT] = { MALI_RG8I, _VTR }, + [PIPE_FORMAT_A8_UINT] = { MALI_R8UI, _VTR }, + [PIPE_FORMAT_I8_UINT] = { MALI_R8UI, _VTR }, + [PIPE_FORMAT_L8_UINT] = { MALI_R8UI, _VTR }, + [PIPE_FORMAT_L8A8_UINT] = { MALI_RG8UI, _VTR }, + + [PIPE_FORMAT_A16_SINT] = { MALI_R16I, _VTR }, + [PIPE_FORMAT_I16_SINT] = { MALI_R16I, _VTR }, + [PIPE_FORMAT_L16_SINT] = { MALI_R16I, _VTR }, + [PIPE_FORMAT_L16A16_SINT] = { MALI_RG16I, _VTR }, + [PIPE_FORMAT_A16_UINT] = { MALI_R16UI, _VTR }, + [PIPE_FORMAT_I16_UINT] = { MALI_R16UI, _VTR }, + [PIPE_FORMAT_L16_UINT] = { MALI_R16UI, _VTR }, + [PIPE_FORMAT_L16A16_UINT] = { MALI_RG16UI, _VTR }, + + [PIPE_FORMAT_A32_SINT] = { MALI_R32I, _VTR }, + [PIPE_FORMAT_I32_SINT] = { MALI_R32I, _VTR }, + [PIPE_FORMAT_L32_SINT] = { MALI_R32I, _VTR }, + [PIPE_FORMAT_L32A32_SINT] = { MALI_RG32I, _VTR }, + [PIPE_FORMAT_A32_UINT] = { MALI_R32UI, _VTR }, + [PIPE_FORMAT_I32_UINT] = { MALI_R32UI, _VTR }, + [PIPE_FORMAT_L32_UINT] = { MALI_R32UI, _VTR }, + [PIPE_FORMAT_L32A32_UINT] = { MALI_RG32UI, _VTR }, + + [PIPE_FORMAT_B8G8R8_UINT] = { MALI_RGB8UI, _VTR }, + [PIPE_FORMAT_B8G8R8A8_UINT] = { MALI_RGBA8UI, _VTR }, + [PIPE_FORMAT_B8G8R8_SINT] = { MALI_RGB8I, _VTR }, + [PIPE_FORMAT_B8G8R8A8_SINT] = { MALI_RGBA8I, _VTR }, + [PIPE_FORMAT_A8R8G8B8_UINT] = { MALI_RGBA8UI, _VTR }, + [PIPE_FORMAT_A8B8G8R8_UINT] = { MALI_RGBA8UI, _VTR }, + + [PIPE_FORMAT_R8_UINT] = { MALI_R8UI, _VTR }, + [PIPE_FORMAT_R16_UINT] = { MALI_R16UI, _VTR }, + [PIPE_FORMAT_R32_UINT] = { MALI_R32UI, _VTR }, + [PIPE_FORMAT_R8G8_UINT] = { MALI_RG8UI, _VTR }, + [PIPE_FORMAT_R16G16_UINT] = { MALI_RG16UI, _VTR }, + [PIPE_FORMAT_R32G32_UINT] = { MALI_RG32UI, _VTR }, + [PIPE_FORMAT_R8G8B8_UINT] = { MALI_RGB8UI, _VTR }, + [PIPE_FORMAT_R16G16B16_UINT] = { MALI_RGB16UI, _VTR }, + [PIPE_FORMAT_R32G32B32_UINT] = { MALI_RGB32UI, _VTR }, + [PIPE_FORMAT_R8G8B8A8_UINT] = { MALI_RGBA8UI, _VTR }, + [PIPE_FORMAT_R16G16B16A16_UINT] = { MALI_RGBA16UI, _VTR }, + [PIPE_FORMAT_R32G32B32A32_UINT] = { MALI_RGBA32UI, _VTR }, + + [PIPE_FORMAT_R32_FLOAT] = { MALI_R32F, _VTR }, + [PIPE_FORMAT_R32G32_FLOAT] = { MALI_RG32F, _VTR }, + [PIPE_FORMAT_R32G32B32_FLOAT] = { MALI_RGB32F, _VTR }, + [PIPE_FORMAT_R32G32B32A32_FLOAT] = { MALI_RGBA32F, _VTR }, + + [PIPE_FORMAT_R8_UNORM] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_R16_UNORM] = { MALI_R16_UNORM, _VTR }, + [PIPE_FORMAT_R32_UNORM] = { MALI_R32_UNORM, _VTR }, + [PIPE_FORMAT_R8G8_UNORM] = { MALI_RG8_UNORM, _VTR }, + [PIPE_FORMAT_R16G16_UNORM] = { MALI_RG16_UNORM, _VTR }, + [PIPE_FORMAT_R32G32_UNORM] = { MALI_RG32_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8_UNORM] = { MALI_RGB8_UNORM, _VTR }, + [PIPE_FORMAT_R16G16B16_UNORM] = { MALI_RGB16_UNORM, _VTR }, + [PIPE_FORMAT_R32G32B32_UNORM] = { MALI_RGB32_UNORM, _VTR }, + [PIPE_FORMAT_R4G4B4A4_UNORM] = { MALI_RGBA4_UNORM, _VTR }, + [PIPE_FORMAT_R16G16B16A16_UNORM] = { MALI_RGBA16_UNORM, _VTR }, + [PIPE_FORMAT_R32G32B32A32_UNORM] = { MALI_RGBA32_UNORM, _VTR }, + + [PIPE_FORMAT_B8G8R8A8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_B8G8R8X8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_A8R8G8B8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_X8R8G8B8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_A8B8G8R8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_X8B8G8R8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8X8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8A8_UNORM] = { MALI_RGBA8_UNORM, _VTR }, + + [PIPE_FORMAT_R8G8B8X8_SNORM] = { MALI_RGBA8_SNORM, _VT }, + [PIPE_FORMAT_R8G8B8X8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8X8_UINT] = { MALI_RGBA8UI, _VTR }, + [PIPE_FORMAT_R8G8B8X8_SINT] = { MALI_RGBA8I, _VTR }, + + [PIPE_FORMAT_L8_UNORM] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_A8_UNORM] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_I8_UNORM] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_L8A8_UNORM] = { MALI_RG8_UNORM, _VTR }, + [PIPE_FORMAT_L16_UNORM] = { MALI_R16_UNORM, _VTR }, + [PIPE_FORMAT_A16_UNORM] = { MALI_R16_UNORM, _VTR }, + [PIPE_FORMAT_I16_UNORM] = { MALI_R16_UNORM, _VTR }, + [PIPE_FORMAT_L16A16_UNORM] = { MALI_RG16_UNORM, _VTR }, + + [PIPE_FORMAT_L8_SNORM] = { MALI_R8_SNORM, _VT }, + [PIPE_FORMAT_A8_SNORM] = { MALI_R8_SNORM, _VT }, + [PIPE_FORMAT_I8_SNORM] = { MALI_R8_SNORM, _VT }, + [PIPE_FORMAT_L8A8_SNORM] = { MALI_RG8_SNORM, _VT }, + [PIPE_FORMAT_L16_SNORM] = { MALI_R16_SNORM, _VT }, + [PIPE_FORMAT_A16_SNORM] = { MALI_R16_SNORM, _VT }, + [PIPE_FORMAT_I16_SNORM] = { MALI_R16_SNORM, _VT }, + [PIPE_FORMAT_L16A16_SNORM] = { MALI_RG16_SNORM, _VT }, + + [PIPE_FORMAT_L16_FLOAT] = { MALI_R16F, _VTR }, + [PIPE_FORMAT_A16_FLOAT] = { MALI_R16F, _VTR }, + [PIPE_FORMAT_I16_FLOAT] = { MALI_RG16F, _VTR }, + [PIPE_FORMAT_L16A16_FLOAT] = { MALI_RG16F, _VTR }, + + [PIPE_FORMAT_L8_SRGB] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_R8_SRGB] = { MALI_R8_UNORM, _VTR }, + [PIPE_FORMAT_L8A8_SRGB] = { MALI_RG8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8_SRGB] = { MALI_RG8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8_SRGB] = { MALI_RGB8_UNORM, _VTR }, + [PIPE_FORMAT_B8G8R8_SRGB] = { MALI_RGB8_UNORM, _VTR }, + [PIPE_FORMAT_R8G8B8A8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_A8B8G8R8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_X8B8G8R8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_B8G8R8A8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_B8G8R8X8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_A8R8G8B8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + [PIPE_FORMAT_X8R8G8B8_SRGB] = { MALI_RGBA8_UNORM, _VTR }, + + [PIPE_FORMAT_R8_SINT] = { MALI_R8I, _VTR }, + [PIPE_FORMAT_R16_SINT] = { MALI_R16I, _VTR }, + [PIPE_FORMAT_R32_SINT] = { MALI_R32I, _VTR }, + [PIPE_FORMAT_R16_FLOAT] = { MALI_R16F, _VTR }, + [PIPE_FORMAT_R8G8_SINT] = { MALI_RG8I, _VTR }, + [PIPE_FORMAT_R16G16_SINT] = { MALI_RG16I, _VTR }, + [PIPE_FORMAT_R32G32_SINT] = { MALI_RG32I, _VTR }, + [PIPE_FORMAT_R16G16_FLOAT] = { MALI_RG16F, _VTR }, + [PIPE_FORMAT_R8G8B8_SINT] = { MALI_RGB8I, _VTR }, + [PIPE_FORMAT_R16G16B16_SINT] = { MALI_RGB16I, _VTR }, + [PIPE_FORMAT_R32G32B32_SINT] = { MALI_RGB32I, _VTR }, + [PIPE_FORMAT_R16G16B16_FLOAT] = { MALI_RGB16F, _VTR }, + [PIPE_FORMAT_R8G8B8A8_SINT] = { MALI_RGBA8I, _VTR }, + [PIPE_FORMAT_R16G16B16A16_SINT] = { MALI_RGBA16I, _VTR }, + [PIPE_FORMAT_R32G32B32A32_SINT] = { MALI_RGBA32I, _VTR }, + [PIPE_FORMAT_R16G16B16A16_FLOAT] = { MALI_RGBA16F, _VTR }, + + [PIPE_FORMAT_R16G16B16X16_UNORM] = { MALI_RGBA16_UNORM, _VTR }, + [PIPE_FORMAT_R16G16B16X16_SNORM] = { MALI_RGBA16_SNORM, _VT }, + [PIPE_FORMAT_R16G16B16X16_FLOAT] = { MALI_RGBA16F, _VTR }, + [PIPE_FORMAT_R16G16B16X16_UINT] = { MALI_RGBA16UI, _VTR }, + [PIPE_FORMAT_R16G16B16X16_SINT] = { MALI_RGBA16I, _VTR }, + + [PIPE_FORMAT_R32G32B32X32_FLOAT] = { MALI_RGBA32F, _VTR }, + [PIPE_FORMAT_R32G32B32X32_UINT] = { MALI_RGBA32UI, _VTR }, + [PIPE_FORMAT_R32G32B32X32_SINT] = { MALI_RGBA32I, _VTR }, +}; + +#undef _VTR +#undef _VT +#undef _V +#undef _T +#undef _R /* Is a format encoded like Z24S8 and therefore compatible for render? */ @@ -279,7 +346,8 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out) enum mali_format panfrost_format_to_bifrost_blend(const struct util_format_description *desc) { - enum mali_format format = panfrost_find_format(desc); + enum mali_format format = panfrost_pipe_format_table[desc->format].hw; + assert(format); switch (format) { case MALI_RGBA4_UNORM: diff --git a/src/panfrost/encoder/pan_texture.c b/src/panfrost/encoder/pan_texture.c index 3f5d26680a7..9fb134e48ed 100644 --- a/src/panfrost/encoder/pan_texture.c +++ b/src/panfrost/encoder/pan_texture.c @@ -252,7 +252,8 @@ panfrost_new_texture( unsigned bytes_per_pixel = util_format_get_blocksize(format); - enum mali_format mali_format = panfrost_find_format(desc); + enum mali_format mali_format = panfrost_pipe_format_table[desc->format].hw; + assert(mali_format); bool manual_stride = (layout == MALI_TEXTURE_LINEAR) && panfrost_needs_explicit_stride(slices, width, @@ -313,7 +314,8 @@ panfrost_new_texture_bifrost( const struct util_format_description *desc = util_format_description(format); - enum mali_format mali_format = panfrost_find_format(desc); + enum mali_format mali_format = panfrost_pipe_format_table[desc->format].hw; + assert(mali_format); panfrost_emit_texture_payload( (mali_ptr *) payload->cpu, diff --git a/src/panfrost/encoder/pan_texture.h b/src/panfrost/encoder/pan_texture.h index b0238aeb888..f84e0a484a5 100644 --- a/src/panfrost/encoder/pan_texture.h +++ b/src/panfrost/encoder/pan_texture.h @@ -114,8 +114,12 @@ panfrost_texture_offset(struct panfrost_slice *slices, bool is_3d, unsigned cube /* Formats */ -enum mali_format -panfrost_find_format(const struct util_format_description *desc); +struct panfrost_format { + enum mali_format hw; + unsigned bind; +}; + +extern struct panfrost_format panfrost_pipe_format_table[PIPE_FORMAT_COUNT]; bool panfrost_is_z24s8_variant(enum pipe_format fmt); |