From: Eric Anholt Date: Fri, 6 Sep 2019 21:29:10 +0000 (-0700) Subject: mesa/st: Gut most of st_mesa_format_to_pipe_format(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75921a0912225903e40881f2d89e2f4a22c2f6ae;p=mesa.git mesa/st: Gut most of st_mesa_format_to_pipe_format(). Now that MESA_FORMAT_x is just a PIPE_FORMAT_x define, we can strip this function down to just the compression fallbacks. v2: Restore the SRGB format for ASTC SRGB fallback case. Reviewed-by: Marek Olšák --- diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index a65e4952755..84bee15d44b 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -63,646 +63,57 @@ st_mesa_format_to_pipe_format(const struct st_context *st, mesa_format mesaFormat) { struct pipe_screen *screen = st->pipe->screen; - bool has_bgra_srgb = screen->is_format_supported(screen, - PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_TEXTURE_2D, 0, 0, - PIPE_BIND_SAMPLER_VIEW); - - switch (mesaFormat) { - case MESA_FORMAT_A8B8G8R8_UNORM: - return PIPE_FORMAT_ABGR8888_UNORM; - case MESA_FORMAT_RGB_UNORM8: - return PIPE_FORMAT_R8G8B8_UNORM; - case MESA_FORMAT_R8G8B8A8_UNORM: - return PIPE_FORMAT_RGBA8888_UNORM; - case MESA_FORMAT_B8G8R8A8_UNORM: - return PIPE_FORMAT_BGRA8888_UNORM; - case MESA_FORMAT_A8R8G8B8_UNORM: - return PIPE_FORMAT_ARGB8888_UNORM; - case MESA_FORMAT_X8B8G8R8_UNORM: - return PIPE_FORMAT_XBGR8888_UNORM; - case MESA_FORMAT_R8G8B8X8_UNORM: - return PIPE_FORMAT_RGBX8888_UNORM; - case MESA_FORMAT_B8G8R8X8_UNORM: - return PIPE_FORMAT_BGRX8888_UNORM; - case MESA_FORMAT_X8R8G8B8_UNORM: - return PIPE_FORMAT_XRGB8888_UNORM; - case MESA_FORMAT_B5G5R5A1_UNORM: - return PIPE_FORMAT_B5G5R5A1_UNORM; - case MESA_FORMAT_A1B5G5R5_UNORM: - return PIPE_FORMAT_A1B5G5R5_UNORM; - case MESA_FORMAT_A1R5G5B5_UNORM: - return PIPE_FORMAT_A1R5G5B5_UNORM; - case MESA_FORMAT_R5G5B5A1_UNORM: - return PIPE_FORMAT_R5G5B5A1_UNORM; - case MESA_FORMAT_R4G4B4A4_UNORM: - return PIPE_FORMAT_R4G4B4A4_UNORM; - case MESA_FORMAT_B4G4R4A4_UNORM: - return PIPE_FORMAT_B4G4R4A4_UNORM; - case MESA_FORMAT_A4B4G4R4_UNORM: - return PIPE_FORMAT_A4B4G4R4_UNORM; - case MESA_FORMAT_A4R4G4B4_UNORM: - return PIPE_FORMAT_A4R4G4B4_UNORM; - case MESA_FORMAT_R5G6B5_UNORM: - return PIPE_FORMAT_R5G6B5_UNORM; - case MESA_FORMAT_B5G6R5_UNORM: - return PIPE_FORMAT_B5G6R5_UNORM; - case MESA_FORMAT_R3G3B2_UNORM: - return PIPE_FORMAT_R3G3B2_UNORM; - case MESA_FORMAT_B2G3R3_UNORM: - return PIPE_FORMAT_B2G3R3_UNORM; - case MESA_FORMAT_B10G10R10A2_UNORM: - return PIPE_FORMAT_B10G10R10A2_UNORM; - case MESA_FORMAT_R10G10B10A2_UNORM: - return PIPE_FORMAT_R10G10B10A2_UNORM; - case MESA_FORMAT_R10G10B10X2_UNORM: - return PIPE_FORMAT_R10G10B10X2_UNORM; - case MESA_FORMAT_A2B10G10R10_UNORM: - return PIPE_FORMAT_A2B10G10R10_UNORM; - case MESA_FORMAT_A2R10G10B10_UNORM: - return PIPE_FORMAT_A2R10G10B10_UNORM; - case MESA_FORMAT_L4A4_UNORM: - return PIPE_FORMAT_L4A4_UNORM; - case MESA_FORMAT_A_UNORM8: - return PIPE_FORMAT_A8_UNORM; - case MESA_FORMAT_A_UNORM16: - return PIPE_FORMAT_A16_UNORM; - case MESA_FORMAT_L_UNORM8: - return PIPE_FORMAT_L8_UNORM; - case MESA_FORMAT_L_UNORM16: - return PIPE_FORMAT_L16_UNORM; - case MESA_FORMAT_LA_UNORM8: - return PIPE_FORMAT_L8A8_UNORM; - case MESA_FORMAT_LA_UNORM16: - return PIPE_FORMAT_L16A16_UNORM; - case MESA_FORMAT_I_UNORM8: - return PIPE_FORMAT_I8_UNORM; - case MESA_FORMAT_I_UNORM16: - return PIPE_FORMAT_I16_UNORM; - case MESA_FORMAT_Z_UNORM16: - return PIPE_FORMAT_Z16_UNORM; - case MESA_FORMAT_Z_UNORM32: - return PIPE_FORMAT_Z32_UNORM; - case MESA_FORMAT_S8_UINT_Z24_UNORM: - return PIPE_FORMAT_S8_UINT_Z24_UNORM; - case MESA_FORMAT_Z24_UNORM_S8_UINT: - return PIPE_FORMAT_Z24_UNORM_S8_UINT; - case MESA_FORMAT_X8_UINT_Z24_UNORM: - return PIPE_FORMAT_X8Z24_UNORM; - case MESA_FORMAT_Z24_UNORM_X8_UINT: - return PIPE_FORMAT_Z24X8_UNORM; - case MESA_FORMAT_S_UINT8: - return PIPE_FORMAT_S8_UINT; - case MESA_FORMAT_Z_FLOAT32: - return PIPE_FORMAT_Z32_FLOAT; - case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: - return PIPE_FORMAT_Z32_FLOAT_S8X24_UINT; - case MESA_FORMAT_YCBCR: - return PIPE_FORMAT_UYVY; - case MESA_FORMAT_YCBCR_REV: - return PIPE_FORMAT_YUYV; - case MESA_FORMAT_RGB_DXT1: - return PIPE_FORMAT_DXT1_RGB; - case MESA_FORMAT_RGBA_DXT1: - return PIPE_FORMAT_DXT1_RGBA; - case MESA_FORMAT_RGBA_DXT3: - return PIPE_FORMAT_DXT3_RGBA; - case MESA_FORMAT_RGBA_DXT5: - return PIPE_FORMAT_DXT5_RGBA; - case MESA_FORMAT_SRGB_DXT1: - return PIPE_FORMAT_DXT1_SRGB; - case MESA_FORMAT_SRGBA_DXT1: - return PIPE_FORMAT_DXT1_SRGBA; - case MESA_FORMAT_SRGBA_DXT3: - return PIPE_FORMAT_DXT3_SRGBA; - case MESA_FORMAT_SRGBA_DXT5: - return PIPE_FORMAT_DXT5_SRGBA; - case MESA_FORMAT_L_SRGB8: - return PIPE_FORMAT_L8_SRGB; - case MESA_FORMAT_LA_SRGB8: - return PIPE_FORMAT_L8A8_SRGB; - case MESA_FORMAT_R_SRGB8: - return PIPE_FORMAT_R8_SRGB; - case MESA_FORMAT_BGR_SRGB8: - return PIPE_FORMAT_R8G8B8_SRGB; - case MESA_FORMAT_A8B8G8R8_SRGB: - return PIPE_FORMAT_ABGR8888_SRGB; - case MESA_FORMAT_R8G8B8A8_SRGB: - return PIPE_FORMAT_RGBA8888_SRGB; - case MESA_FORMAT_B8G8R8A8_SRGB: - return PIPE_FORMAT_BGRA8888_SRGB; - case MESA_FORMAT_A8R8G8B8_SRGB: - return PIPE_FORMAT_ARGB8888_SRGB; - case MESA_FORMAT_RGBA_FLOAT32: - return PIPE_FORMAT_R32G32B32A32_FLOAT; - case MESA_FORMAT_RGBA_FLOAT16: - return PIPE_FORMAT_R16G16B16A16_FLOAT; - case MESA_FORMAT_RGB_FLOAT32: - return PIPE_FORMAT_R32G32B32_FLOAT; - case MESA_FORMAT_RGB_FLOAT16: - return PIPE_FORMAT_R16G16B16_FLOAT; - case MESA_FORMAT_LA_FLOAT32: - return PIPE_FORMAT_L32A32_FLOAT; - case MESA_FORMAT_LA_FLOAT16: - return PIPE_FORMAT_L16A16_FLOAT; - case MESA_FORMAT_L_FLOAT32: - return PIPE_FORMAT_L32_FLOAT; - case MESA_FORMAT_L_FLOAT16: - return PIPE_FORMAT_L16_FLOAT; - case MESA_FORMAT_A_FLOAT32: - return PIPE_FORMAT_A32_FLOAT; - case MESA_FORMAT_A_FLOAT16: - return PIPE_FORMAT_A16_FLOAT; - case MESA_FORMAT_I_FLOAT32: - return PIPE_FORMAT_I32_FLOAT; - case MESA_FORMAT_I_FLOAT16: - return PIPE_FORMAT_I16_FLOAT; - case MESA_FORMAT_R_FLOAT32: - return PIPE_FORMAT_R32_FLOAT; - case MESA_FORMAT_R_FLOAT16: - return PIPE_FORMAT_R16_FLOAT; - case MESA_FORMAT_RG_FLOAT32: - return PIPE_FORMAT_R32G32_FLOAT; - case MESA_FORMAT_RG_FLOAT16: - return PIPE_FORMAT_R16G16_FLOAT; - - case MESA_FORMAT_R_UNORM8: - return PIPE_FORMAT_R8_UNORM; - case MESA_FORMAT_R_UNORM16: - return PIPE_FORMAT_R16_UNORM; - case MESA_FORMAT_RG_UNORM8: - return PIPE_FORMAT_R8G8_UNORM; - case MESA_FORMAT_RG_UNORM16: - return PIPE_FORMAT_R16G16_UNORM; - case MESA_FORMAT_BGR_UNORM8: - return PIPE_FORMAT_B8G8R8_UNORM; - case MESA_FORMAT_RGBA_UNORM16: - return PIPE_FORMAT_R16G16B16A16_UNORM; - - /* signed int formats */ - case MESA_FORMAT_A_UINT8: - return PIPE_FORMAT_A8_UINT; - case MESA_FORMAT_A_UINT16: - return PIPE_FORMAT_A16_UINT; - case MESA_FORMAT_A_UINT32: - return PIPE_FORMAT_A32_UINT; - - case MESA_FORMAT_A_SINT8: - return PIPE_FORMAT_A8_SINT; - case MESA_FORMAT_A_SINT16: - return PIPE_FORMAT_A16_SINT; - case MESA_FORMAT_A_SINT32: - return PIPE_FORMAT_A32_SINT; - - case MESA_FORMAT_I_UINT8: - return PIPE_FORMAT_I8_UINT; - case MESA_FORMAT_I_UINT16: - return PIPE_FORMAT_I16_UINT; - case MESA_FORMAT_I_UINT32: - return PIPE_FORMAT_I32_UINT; - - case MESA_FORMAT_I_SINT8: - return PIPE_FORMAT_I8_SINT; - case MESA_FORMAT_I_SINT16: - return PIPE_FORMAT_I16_SINT; - case MESA_FORMAT_I_SINT32: - return PIPE_FORMAT_I32_SINT; - - case MESA_FORMAT_L_UINT8: - return PIPE_FORMAT_L8_UINT; - case MESA_FORMAT_L_UINT16: - return PIPE_FORMAT_L16_UINT; - case MESA_FORMAT_L_UINT32: - return PIPE_FORMAT_L32_UINT; - - case MESA_FORMAT_L_SINT8: - return PIPE_FORMAT_L8_SINT; - case MESA_FORMAT_L_SINT16: - return PIPE_FORMAT_L16_SINT; - case MESA_FORMAT_L_SINT32: - return PIPE_FORMAT_L32_SINT; - - case MESA_FORMAT_LA_UINT8: - return PIPE_FORMAT_L8A8_UINT; - case MESA_FORMAT_LA_UINT16: - return PIPE_FORMAT_L16A16_UINT; - case MESA_FORMAT_LA_UINT32: - return PIPE_FORMAT_L32A32_UINT; - - case MESA_FORMAT_LA_SINT8: - return PIPE_FORMAT_L8A8_SINT; - case MESA_FORMAT_LA_SINT16: - return PIPE_FORMAT_L16A16_SINT; - case MESA_FORMAT_LA_SINT32: - return PIPE_FORMAT_L32A32_SINT; - - case MESA_FORMAT_R_SINT8: - return PIPE_FORMAT_R8_SINT; - case MESA_FORMAT_RG_SINT8: - return PIPE_FORMAT_R8G8_SINT; - case MESA_FORMAT_RGB_SINT8: - return PIPE_FORMAT_R8G8B8_SINT; - case MESA_FORMAT_RGBA_SINT8: - return PIPE_FORMAT_R8G8B8A8_SINT; - case MESA_FORMAT_R_SINT16: - return PIPE_FORMAT_R16_SINT; - case MESA_FORMAT_RG_SINT16: - return PIPE_FORMAT_R16G16_SINT; - case MESA_FORMAT_RGB_SINT16: - return PIPE_FORMAT_R16G16B16_SINT; - case MESA_FORMAT_RGBA_SINT16: - return PIPE_FORMAT_R16G16B16A16_SINT; - case MESA_FORMAT_R_SINT32: - return PIPE_FORMAT_R32_SINT; - case MESA_FORMAT_RG_SINT32: - return PIPE_FORMAT_R32G32_SINT; - case MESA_FORMAT_RGB_SINT32: - return PIPE_FORMAT_R32G32B32_SINT; - case MESA_FORMAT_RGBA_SINT32: - return PIPE_FORMAT_R32G32B32A32_SINT; - - /* unsigned int formats */ - case MESA_FORMAT_R_UINT8: - return PIPE_FORMAT_R8_UINT; - case MESA_FORMAT_RG_UINT8: - return PIPE_FORMAT_R8G8_UINT; - case MESA_FORMAT_RGB_UINT8: - return PIPE_FORMAT_R8G8B8_UINT; - case MESA_FORMAT_R_UINT16: - return PIPE_FORMAT_R16_UINT; - case MESA_FORMAT_RG_UINT16: - return PIPE_FORMAT_R16G16_UINT; - case MESA_FORMAT_RGB_UINT16: - return PIPE_FORMAT_R16G16B16_UINT; - case MESA_FORMAT_RGBA_UINT16: - return PIPE_FORMAT_R16G16B16A16_UINT; - case MESA_FORMAT_R_UINT32: - return PIPE_FORMAT_R32_UINT; - case MESA_FORMAT_RG_UINT32: - return PIPE_FORMAT_R32G32_UINT; - case MESA_FORMAT_RGB_UINT32: - return PIPE_FORMAT_R32G32B32_UINT; - case MESA_FORMAT_RGBA_UINT32: - return PIPE_FORMAT_R32G32B32A32_UINT; - - case MESA_FORMAT_R_RGTC1_UNORM: - return PIPE_FORMAT_RGTC1_UNORM; - case MESA_FORMAT_R_RGTC1_SNORM: - return PIPE_FORMAT_RGTC1_SNORM; - case MESA_FORMAT_RG_RGTC2_UNORM: - return PIPE_FORMAT_RGTC2_UNORM; - case MESA_FORMAT_RG_RGTC2_SNORM: - return PIPE_FORMAT_RGTC2_SNORM; - - case MESA_FORMAT_L_LATC1_UNORM: - return PIPE_FORMAT_LATC1_UNORM; - case MESA_FORMAT_L_LATC1_SNORM: - return PIPE_FORMAT_LATC1_SNORM; - case MESA_FORMAT_LA_LATC2_UNORM: - return PIPE_FORMAT_LATC2_UNORM; - case MESA_FORMAT_LA_LATC2_SNORM: - return PIPE_FORMAT_LATC2_SNORM; /* The destination RGBA format mustn't be changed, because it's also - * a destination format of the unpack/decompression function. */ - case MESA_FORMAT_ETC1_RGB8: - return st->has_etc1 ? PIPE_FORMAT_ETC1_RGB8 : PIPE_FORMAT_R8G8B8A8_UNORM; - - case MESA_FORMAT_BPTC_RGBA_UNORM: - return PIPE_FORMAT_BPTC_RGBA_UNORM; - case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: - return PIPE_FORMAT_BPTC_SRGBA; - case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: - return PIPE_FORMAT_BPTC_RGB_FLOAT; - case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: - return PIPE_FORMAT_BPTC_RGB_UFLOAT; - - /* signed normalized formats */ - case MESA_FORMAT_R_SNORM8: - return PIPE_FORMAT_R8_SNORM; - case MESA_FORMAT_RG_SNORM8: - return PIPE_FORMAT_R8G8_SNORM; - case MESA_FORMAT_R8G8B8A8_SNORM: - return PIPE_FORMAT_RGBA8888_SNORM; - case MESA_FORMAT_A8B8G8R8_SNORM: - return PIPE_FORMAT_ABGR8888_SNORM; - - case MESA_FORMAT_A_SNORM8: - return PIPE_FORMAT_A8_SNORM; - case MESA_FORMAT_L_SNORM8: - return PIPE_FORMAT_L8_SNORM; - case MESA_FORMAT_LA_SNORM8: - return PIPE_FORMAT_L8A8_SNORM; - case MESA_FORMAT_I_SNORM8: - return PIPE_FORMAT_I8_SNORM; - - case MESA_FORMAT_R_SNORM16: - return PIPE_FORMAT_R16_SNORM; - case MESA_FORMAT_RG_SNORM16: - return PIPE_FORMAT_R16G16_SNORM; - case MESA_FORMAT_RGB_SNORM16: - return PIPE_FORMAT_R16G16B16_SNORM; - case MESA_FORMAT_RGBA_SNORM16: - return PIPE_FORMAT_R16G16B16A16_SNORM; - - case MESA_FORMAT_A_SNORM16: - return PIPE_FORMAT_A16_SNORM; - case MESA_FORMAT_L_SNORM16: - return PIPE_FORMAT_L16_SNORM; - case MESA_FORMAT_LA_SNORM16: - return PIPE_FORMAT_L16A16_SNORM; - case MESA_FORMAT_I_SNORM16: - return PIPE_FORMAT_I16_SNORM; - - case MESA_FORMAT_R9G9B9E5_FLOAT: - return PIPE_FORMAT_R9G9B9E5_FLOAT; - case MESA_FORMAT_R11G11B10_FLOAT: - return PIPE_FORMAT_R11G11B10_FLOAT; - - case MESA_FORMAT_R8G8B8A8_UINT: - return PIPE_FORMAT_RGBA8888_UINT; - case MESA_FORMAT_B8G8R8A8_UINT: - return PIPE_FORMAT_BGRA8888_UINT; - case MESA_FORMAT_A8R8G8B8_UINT: - return PIPE_FORMAT_ARGB8888_UINT; - case MESA_FORMAT_A8B8G8R8_UINT: - return PIPE_FORMAT_ABGR8888_UINT; - case MESA_FORMAT_B10G10R10A2_UINT: - return PIPE_FORMAT_B10G10R10A2_UINT; - case MESA_FORMAT_R10G10B10A2_UINT: - return PIPE_FORMAT_R10G10B10A2_UINT; - case MESA_FORMAT_A2B10G10R10_UINT: - return PIPE_FORMAT_A2B10G10R10_UINT; - case MESA_FORMAT_A2R10G10B10_UINT: - return PIPE_FORMAT_A2R10G10B10_UINT; - case MESA_FORMAT_R4G4B4A4_UINT: - return PIPE_FORMAT_R4G4B4A4_UINT; - case MESA_FORMAT_B4G4R4A4_UINT: - return PIPE_FORMAT_B4G4R4A4_UINT; - case MESA_FORMAT_A4B4G4R4_UINT: - return PIPE_FORMAT_A4B4G4R4_UINT; - case MESA_FORMAT_A4R4G4B4_UINT: - return PIPE_FORMAT_A4R4G4B4_UINT; - case MESA_FORMAT_R5G6B5_UINT: - return PIPE_FORMAT_R5G6B5_UINT; - case MESA_FORMAT_B5G6R5_UINT: - return PIPE_FORMAT_B5G6R5_UINT; - case MESA_FORMAT_B5G5R5A1_UINT: - return PIPE_FORMAT_B5G5R5A1_UINT; - case MESA_FORMAT_R5G5B5A1_UINT: - return PIPE_FORMAT_R5G5B5A1_UINT; - case MESA_FORMAT_A1B5G5R5_UINT: - return PIPE_FORMAT_A1B5G5R5_UINT; - case MESA_FORMAT_A1R5G5B5_UINT: - return PIPE_FORMAT_A1R5G5B5_UINT; - case MESA_FORMAT_R3G3B2_UINT: - return PIPE_FORMAT_R3G3B2_UINT; - case MESA_FORMAT_B2G3R3_UINT: - return PIPE_FORMAT_B2G3R3_UINT; - - case MESA_FORMAT_B4G4R4X4_UNORM: - return PIPE_FORMAT_B4G4R4X4_UNORM; - case MESA_FORMAT_B5G5R5X1_UNORM: - return PIPE_FORMAT_B5G5R5X1_UNORM; - case MESA_FORMAT_X1B5G5R5_UNORM: - return PIPE_FORMAT_X1B5G5R5_UNORM; - case MESA_FORMAT_R8G8B8X8_SNORM: - return PIPE_FORMAT_RGBX8888_SNORM; - case MESA_FORMAT_X8B8G8R8_SNORM: - return PIPE_FORMAT_XBGR8888_SNORM; - case MESA_FORMAT_R8G8B8X8_SRGB: - return PIPE_FORMAT_RGBX8888_SRGB; - case MESA_FORMAT_X8B8G8R8_SRGB: - return PIPE_FORMAT_XBGR8888_SRGB; - case MESA_FORMAT_RGBX_UINT8: - return PIPE_FORMAT_R8G8B8X8_UINT; - case MESA_FORMAT_RGBX_SINT8: - return PIPE_FORMAT_R8G8B8X8_SINT; - case MESA_FORMAT_B10G10R10X2_UNORM: - return PIPE_FORMAT_B10G10R10X2_UNORM; - case MESA_FORMAT_RGBX_UNORM16: - return PIPE_FORMAT_R16G16B16X16_UNORM; - case MESA_FORMAT_RGBX_SNORM16: - return PIPE_FORMAT_R16G16B16X16_SNORM; - case MESA_FORMAT_RGBX_FLOAT16: - return PIPE_FORMAT_R16G16B16X16_FLOAT; - case MESA_FORMAT_RGBX_UINT16: - return PIPE_FORMAT_R16G16B16X16_UINT; - case MESA_FORMAT_RGBX_SINT16: - return PIPE_FORMAT_R16G16B16X16_SINT; - case MESA_FORMAT_RGBX_FLOAT32: - return PIPE_FORMAT_R32G32B32X32_FLOAT; - case MESA_FORMAT_RGBX_UINT32: - return PIPE_FORMAT_R32G32B32X32_UINT; - case MESA_FORMAT_RGBX_SINT32: - return PIPE_FORMAT_R32G32B32X32_SINT; - - case MESA_FORMAT_B8G8R8X8_SRGB: - return PIPE_FORMAT_BGRX8888_SRGB; - case MESA_FORMAT_X8R8G8B8_SRGB: - return PIPE_FORMAT_XRGB8888_SRGB; + * a destination format of the unpack/decompression function. + */ + if (mesaFormat == MESA_FORMAT_ETC1_RGB8 && !st->has_etc1) + return PIPE_FORMAT_R8G8B8A8_UNORM; /* ETC2 formats are emulated as uncompressed ones. * The destination formats mustn't be changed, because they are also - * destination formats of the unpack/decompression function. */ - case MESA_FORMAT_ETC2_RGB8: - return st->has_etc2 ? PIPE_FORMAT_ETC2_RGB8 : PIPE_FORMAT_R8G8B8A8_UNORM; - case MESA_FORMAT_ETC2_SRGB8: - return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8 : - has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; - case MESA_FORMAT_ETC2_RGBA8_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_RGBA8 : PIPE_FORMAT_R8G8B8A8_UNORM; - case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGBA8 : - has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; - case MESA_FORMAT_ETC2_R11_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_R11_UNORM : PIPE_FORMAT_R16_UNORM; - case MESA_FORMAT_ETC2_RG11_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_RG11_UNORM : PIPE_FORMAT_R16G16_UNORM; - case MESA_FORMAT_ETC2_SIGNED_R11_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_R11_SNORM : PIPE_FORMAT_R16_SNORM; - case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: - return st->has_etc2 ? PIPE_FORMAT_ETC2_RG11_SNORM : PIPE_FORMAT_R16G16_SNORM; - case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1: - return st->has_etc2 ? PIPE_FORMAT_ETC2_RGB8A1 : PIPE_FORMAT_R8G8B8A8_UNORM; - case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: - return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8A1 : - has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; - - case MESA_FORMAT_RGBA_ASTC_4x4: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_4x4; - case MESA_FORMAT_RGBA_ASTC_5x4: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_5x4; - case MESA_FORMAT_RGBA_ASTC_5x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_5x5; - case MESA_FORMAT_RGBA_ASTC_6x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_6x5; - case MESA_FORMAT_RGBA_ASTC_6x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_6x6; - case MESA_FORMAT_RGBA_ASTC_8x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_8x5; - case MESA_FORMAT_RGBA_ASTC_8x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_8x6; - case MESA_FORMAT_RGBA_ASTC_8x8: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_8x8; - case MESA_FORMAT_RGBA_ASTC_10x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_10x5; - case MESA_FORMAT_RGBA_ASTC_10x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_10x6; - case MESA_FORMAT_RGBA_ASTC_10x8: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_10x8; - case MESA_FORMAT_RGBA_ASTC_10x10: - if (!st->has_astc_2d_ldr) + * destination formats of the unpack/decompression function. + */ + if (_mesa_is_format_etc2(mesaFormat) && !st->has_etc2) { + bool has_bgra_srgb = screen->is_format_supported(screen, + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_TEXTURE_2D, 0, 0, + PIPE_BIND_SAMPLER_VIEW); + + switch (mesaFormat) { + case MESA_FORMAT_ETC2_RGB8: return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_10x10; - case MESA_FORMAT_RGBA_ASTC_12x10: - if (!st->has_astc_2d_ldr) + case MESA_FORMAT_ETC2_SRGB8: + return has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; + case MESA_FORMAT_ETC2_RGBA8_EAC: return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_12x10; - case MESA_FORMAT_RGBA_ASTC_12x12: - if (!st->has_astc_2d_ldr) + case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: + return has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; + case MESA_FORMAT_ETC2_R11_EAC: + return PIPE_FORMAT_R16_UNORM; + case MESA_FORMAT_ETC2_RG11_EAC: + return PIPE_FORMAT_R16G16_UNORM; + case MESA_FORMAT_ETC2_SIGNED_R11_EAC: + return PIPE_FORMAT_R16_SNORM; + case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: + return PIPE_FORMAT_R16G16_SNORM; + case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1: return PIPE_FORMAT_R8G8B8A8_UNORM; - return PIPE_FORMAT_ASTC_12x12; + case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: + return has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB; + default: + unreachable("Unknown ETC2 format"); + } + } - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4: - if (!st->has_astc_2d_ldr) + if (_mesa_is_format_astc_2d(mesaFormat) && !st->has_astc_2d_ldr) { + if (_mesa_is_format_srgb(mesaFormat)) return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_4x4_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_5x4_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_5x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_6x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_6x6_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_8x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_8x6_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_8x8_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_10x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_10x6_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_10x8_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_10x10_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_12x10_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12: - if (!st->has_astc_2d_ldr) - return PIPE_FORMAT_R8G8B8A8_SRGB; - return PIPE_FORMAT_ASTC_12x12_SRGB; - - case MESA_FORMAT_RGBA_ASTC_3x3x3: - return PIPE_FORMAT_ASTC_3x3x3; - case MESA_FORMAT_RGBA_ASTC_4x3x3: - return PIPE_FORMAT_ASTC_4x3x3; - case MESA_FORMAT_RGBA_ASTC_4x4x3: - return PIPE_FORMAT_ASTC_4x4x3; - case MESA_FORMAT_RGBA_ASTC_4x4x4: - return PIPE_FORMAT_ASTC_4x4x4; - case MESA_FORMAT_RGBA_ASTC_5x4x4: - return PIPE_FORMAT_ASTC_5x4x4; - case MESA_FORMAT_RGBA_ASTC_5x5x4: - return PIPE_FORMAT_ASTC_5x5x4; - case MESA_FORMAT_RGBA_ASTC_5x5x5: - return PIPE_FORMAT_ASTC_5x5x5; - case MESA_FORMAT_RGBA_ASTC_6x5x5: - return PIPE_FORMAT_ASTC_6x5x5; - case MESA_FORMAT_RGBA_ASTC_6x6x5: - return PIPE_FORMAT_ASTC_6x6x5; - case MESA_FORMAT_RGBA_ASTC_6x6x6: - return PIPE_FORMAT_ASTC_6x6x6; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_3x3x3: - return PIPE_FORMAT_ASTC_3x3x3_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x3x3: - return PIPE_FORMAT_ASTC_4x3x3_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x3: - return PIPE_FORMAT_ASTC_4x4x3_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x4: - return PIPE_FORMAT_ASTC_4x4x4_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4x4: - return PIPE_FORMAT_ASTC_5x4x4_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x4: - return PIPE_FORMAT_ASTC_5x5x4_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x5: - return PIPE_FORMAT_ASTC_5x5x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5: - return PIPE_FORMAT_ASTC_6x5x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5: - return PIPE_FORMAT_ASTC_6x6x5_SRGB; - case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6: - return PIPE_FORMAT_ASTC_6x6x6_SRGB; - - case MESA_FORMAT_ATC_RGB: - return PIPE_FORMAT_ATC_RGB; - case MESA_FORMAT_ATC_RGBA_EXPLICIT: - return PIPE_FORMAT_ATC_RGBA_EXPLICIT; - case MESA_FORMAT_ATC_RGBA_INTERPOLATED: - return PIPE_FORMAT_ATC_RGBA_INTERPOLATED; - - case MESA_FORMAT_RGB_FXT1: - return PIPE_FORMAT_FXT1_RGB; - case MESA_FORMAT_RGBA_FXT1: - return PIPE_FORMAT_FXT1_RGBA; - - default: - if (0) { - debug_printf("%s(mesa_format=%s) -> NONE\n", - __func__, _mesa_get_format_name(mesaFormat)); - } - return PIPE_FORMAT_NONE; + else + return PIPE_FORMAT_R8G8B8A8_UNORM; } + + return mesaFormat; }