From 2d159e6b365f039d9322b59e1538f3d42e8d8d8d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 15 Nov 2011 16:16:43 -0800 Subject: [PATCH] i965: Reorganize MESA_FORMAT -> BRW_SURFACEFORMAT table. This should be a no-op change. The initializers are reordered to match the ordering of the enum, since there isn't a clearly sensible ordering, but "the order they were added to the driver, sort of" is definitely not one. Also, the unsupported formats are explicitly initialized to 0, so it's more obvious what we aren't claiming to support. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 194 +++++++++++++++++------ 1 file changed, 146 insertions(+), 48 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 4308432..7f32d54 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -278,83 +278,181 @@ const struct surface_format_info surface_formats[] = { uint32_t brw_format_for_mesa_format(gl_format mesa_format) { + /* This table is ordered according to the enum ordering in formats.h. We do + * expect that enum to be extended without our explicit initialization + * staying in sync, so we initialize to 0 even though + * BRW_SURFACEFORMAT_R32G32B32A32_FLOAT happens to also be 0. + */ static const uint32_t table[MESA_FORMAT_COUNT] = { - [MESA_FORMAT_L8] = BRW_SURFACEFORMAT_L8_UNORM, - [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM, - [MESA_FORMAT_A8] = BRW_SURFACEFORMAT_A8_UNORM, - [MESA_FORMAT_AL88] = BRW_SURFACEFORMAT_L8A8_UNORM, - [MESA_FORMAT_L16] = BRW_SURFACEFORMAT_L16_UNORM, - [MESA_FORMAT_A16] = BRW_SURFACEFORMAT_A16_UNORM, - [MESA_FORMAT_I16] = BRW_SURFACEFORMAT_I16_UNORM, - [MESA_FORMAT_AL1616] = BRW_SURFACEFORMAT_L16A16_UNORM, - [MESA_FORMAT_R8] = BRW_SURFACEFORMAT_R8_UNORM, - [MESA_FORMAT_R16] = BRW_SURFACEFORMAT_R16_UNORM, - [MESA_FORMAT_RG88] = BRW_SURFACEFORMAT_R8G8_UNORM, - [MESA_FORMAT_RG1616] = BRW_SURFACEFORMAT_R16G16_UNORM, + [MESA_FORMAT_RGBA8888] = 0, + [MESA_FORMAT_RGBA8888_REV] = 0, [MESA_FORMAT_ARGB8888] = BRW_SURFACEFORMAT_B8G8R8A8_UNORM, + [MESA_FORMAT_ARGB8888_REV] = 0, [MESA_FORMAT_XRGB8888] = BRW_SURFACEFORMAT_B8G8R8X8_UNORM, + [MESA_FORMAT_XRGB8888_REV] = 0, + [MESA_FORMAT_RGB888] = 0, + [MESA_FORMAT_BGR888] = 0, [MESA_FORMAT_RGB565] = BRW_SURFACEFORMAT_B5G6R5_UNORM, - [MESA_FORMAT_ARGB1555] = BRW_SURFACEFORMAT_B5G5R5A1_UNORM, + [MESA_FORMAT_RGB565_REV] = 0, [MESA_FORMAT_ARGB4444] = BRW_SURFACEFORMAT_B4G4R4A4_UNORM, + [MESA_FORMAT_ARGB4444_REV] = 0, + [MESA_FORMAT_RGBA5551] = 0, + [MESA_FORMAT_ARGB1555] = BRW_SURFACEFORMAT_B5G5R5A1_UNORM, + [MESA_FORMAT_ARGB1555_REV] = 0, + [MESA_FORMAT_AL44] = 0, + [MESA_FORMAT_AL88] = BRW_SURFACEFORMAT_L8A8_UNORM, + [MESA_FORMAT_AL88_REV] = 0, + [MESA_FORMAT_AL1616] = BRW_SURFACEFORMAT_L16A16_UNORM, + [MESA_FORMAT_AL1616_REV] = 0, + [MESA_FORMAT_RGB332] = 0, + [MESA_FORMAT_A8] = BRW_SURFACEFORMAT_A8_UNORM, + [MESA_FORMAT_A16] = BRW_SURFACEFORMAT_A16_UNORM, + [MESA_FORMAT_L8] = BRW_SURFACEFORMAT_L8_UNORM, + [MESA_FORMAT_L16] = BRW_SURFACEFORMAT_L16_UNORM, + [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM, + [MESA_FORMAT_I16] = BRW_SURFACEFORMAT_I16_UNORM, [MESA_FORMAT_YCBCR_REV] = BRW_SURFACEFORMAT_YCRCB_NORMAL, [MESA_FORMAT_YCBCR] = BRW_SURFACEFORMAT_YCRCB_SWAPUVY, + [MESA_FORMAT_R8] = BRW_SURFACEFORMAT_R8_UNORM, + [MESA_FORMAT_RG88] = BRW_SURFACEFORMAT_R8G8_UNORM, + [MESA_FORMAT_RG88_REV] = 0, + [MESA_FORMAT_R16] = BRW_SURFACEFORMAT_R16_UNORM, + [MESA_FORMAT_RG1616] = BRW_SURFACEFORMAT_R16G16_UNORM, + [MESA_FORMAT_RG1616_REV] = 0, + [MESA_FORMAT_ARGB2101010] = 0, + [MESA_FORMAT_Z24_S8] = 0, + [MESA_FORMAT_S8_Z24] = 0, + [MESA_FORMAT_Z16] = 0, + [MESA_FORMAT_X8_Z24] = 0, + [MESA_FORMAT_Z24_S8] = 0, + [MESA_FORMAT_Z32] = 0, + [MESA_FORMAT_S8] = 0, + + [MESA_FORMAT_SRGB8] = 0, + [MESA_FORMAT_SRGBA8] = 0, + [MESA_FORMAT_SARGB8] = BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB, + [MESA_FORMAT_SL8] = BRW_SURFACEFORMAT_L8_UNORM_SRGB, + [MESA_FORMAT_SLA8] = BRW_SURFACEFORMAT_L8A8_UNORM_SRGB, + [MESA_FORMAT_SRGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB_SRGB, + [MESA_FORMAT_SRGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM_SRGB, + [MESA_FORMAT_SRGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM_SRGB, + [MESA_FORMAT_SRGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM_SRGB, + [MESA_FORMAT_RGB_FXT1] = BRW_SURFACEFORMAT_FXT1, [MESA_FORMAT_RGBA_FXT1] = BRW_SURFACEFORMAT_FXT1, [MESA_FORMAT_RGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB, [MESA_FORMAT_RGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM, [MESA_FORMAT_RGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM, [MESA_FORMAT_RGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM, - [MESA_FORMAT_SRGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB_SRGB, - [MESA_FORMAT_SRGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM_SRGB, - [MESA_FORMAT_SRGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM_SRGB, - [MESA_FORMAT_SRGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM_SRGB, - [MESA_FORMAT_SARGB8] = BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB, - [MESA_FORMAT_SLA8] = BRW_SURFACEFORMAT_L8A8_UNORM_SRGB, - [MESA_FORMAT_SL8] = BRW_SURFACEFORMAT_L8_UNORM_SRGB, - [MESA_FORMAT_DUDV8] = BRW_SURFACEFORMAT_R8G8_SNORM, - [MESA_FORMAT_SIGNED_R8] = BRW_SURFACEFORMAT_R8_SNORM, - [MESA_FORMAT_SIGNED_RG88_REV] = BRW_SURFACEFORMAT_R8G8_SNORM, - [MESA_FORMAT_SIGNED_RGBA8888_REV] = BRW_SURFACEFORMAT_R8G8B8A8_SNORM, - [MESA_FORMAT_SIGNED_R16] = BRW_SURFACEFORMAT_R16_SNORM, - [MESA_FORMAT_SIGNED_GR1616] = BRW_SURFACEFORMAT_R16G16_SNORM, + [MESA_FORMAT_RGBA_FLOAT32] = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT, - [MESA_FORMAT_RG_FLOAT32] = BRW_SURFACEFORMAT_R32G32_FLOAT, - [MESA_FORMAT_R_FLOAT32] = BRW_SURFACEFORMAT_R32_FLOAT, - [MESA_FORMAT_INTENSITY_FLOAT32] = BRW_SURFACEFORMAT_I32_FLOAT, - [MESA_FORMAT_LUMINANCE_FLOAT32] = BRW_SURFACEFORMAT_L32_FLOAT, + [MESA_FORMAT_RGBA_FLOAT16] = 0, + [MESA_FORMAT_RGB_FLOAT32] = 0, + [MESA_FORMAT_RGB_FLOAT16] = 0, [MESA_FORMAT_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_A32_FLOAT, + [MESA_FORMAT_ALPHA_FLOAT16] = 0, + [MESA_FORMAT_LUMINANCE_FLOAT32] = BRW_SURFACEFORMAT_L32_FLOAT, + [MESA_FORMAT_LUMINANCE_FLOAT16] = 0, [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_L32A32_FLOAT, - [MESA_FORMAT_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_UNORM, - [MESA_FORMAT_SIGNED_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_SNORM, - [MESA_FORMAT_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_UNORM, - [MESA_FORMAT_SIGNED_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_SNORM, - [MESA_FORMAT_RGB9_E5_FLOAT] = BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP, - [MESA_FORMAT_R11_G11_B10_FLOAT] = BRW_SURFACEFORMAT_R11G11B10_FLOAT, + [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = 0, + [MESA_FORMAT_INTENSITY_FLOAT32] = BRW_SURFACEFORMAT_I32_FLOAT, + [MESA_FORMAT_INTENSITY_FLOAT16] = 0, + [MESA_FORMAT_R_FLOAT32] = BRW_SURFACEFORMAT_R32_FLOAT, + [MESA_FORMAT_R_FLOAT16] = 0, + [MESA_FORMAT_RG_FLOAT32] = BRW_SURFACEFORMAT_R32G32_FLOAT, + [MESA_FORMAT_RG_FLOAT16] = 0, + + [MESA_FORMAT_ALPHA_UINT8] = 0, + [MESA_FORMAT_ALPHA_UINT16] = 0, + [MESA_FORMAT_ALPHA_UINT32] = 0, + [MESA_FORMAT_ALPHA_INT8] = 0, + [MESA_FORMAT_ALPHA_INT16] = 0, + [MESA_FORMAT_ALPHA_INT32] = 0, + + [MESA_FORMAT_INTENSITY_UINT8] = 0, + [MESA_FORMAT_INTENSITY_UINT16] = 0, + [MESA_FORMAT_INTENSITY_UINT32] = 0, + [MESA_FORMAT_INTENSITY_INT8] = 0, + [MESA_FORMAT_INTENSITY_INT16] = 0, + [MESA_FORMAT_INTENSITY_INT32] = 0, + + [MESA_FORMAT_LUMINANCE_UINT8] = 0, + [MESA_FORMAT_LUMINANCE_UINT16] = 0, + [MESA_FORMAT_LUMINANCE_UINT32] = 0, + [MESA_FORMAT_LUMINANCE_INT8] = 0, + [MESA_FORMAT_LUMINANCE_INT16] = 0, + [MESA_FORMAT_LUMINANCE_INT32] = 0, + + [MESA_FORMAT_LUMINANCE_ALPHA_UINT8] = 0, + [MESA_FORMAT_LUMINANCE_ALPHA_UINT16] = 0, + [MESA_FORMAT_LUMINANCE_ALPHA_UINT32] = 0, + [MESA_FORMAT_LUMINANCE_ALPHA_INT8] = 0, + [MESA_FORMAT_LUMINANCE_ALPHA_INT16] = 0, + [MESA_FORMAT_LUMINANCE_ALPHA_INT32] = 0, + [MESA_FORMAT_R_INT8] = BRW_SURFACEFORMAT_R8_SINT, + [MESA_FORMAT_RG_INT8] = BRW_SURFACEFORMAT_R8G8_SINT, + [MESA_FORMAT_RGB_INT8] = 0, + [MESA_FORMAT_RGBA_INT8] = BRW_SURFACEFORMAT_R8G8B8A8_SINT, + [MESA_FORMAT_R_INT16] = BRW_SURFACEFORMAT_R16_SINT, + [MESA_FORMAT_RG_INT16] = BRW_SURFACEFORMAT_R16G16_SINT, + [MESA_FORMAT_RGB_INT16] = 0, + [MESA_FORMAT_RGBA_INT16] = BRW_SURFACEFORMAT_R16G16B16A16_SINT, [MESA_FORMAT_R_INT32] = BRW_SURFACEFORMAT_R32_SINT, [MESA_FORMAT_RG_INT32] = BRW_SURFACEFORMAT_R32G32_SINT, [MESA_FORMAT_RGB_INT32] = BRW_SURFACEFORMAT_R32G32B32_SINT, [MESA_FORMAT_RGBA_INT32] = BRW_SURFACEFORMAT_R32G32B32A32_SINT, + [MESA_FORMAT_R_UINT8] = BRW_SURFACEFORMAT_R8_UINT, + [MESA_FORMAT_RG_UINT8] = BRW_SURFACEFORMAT_R8G8_UINT, + [MESA_FORMAT_RGB_UINT8] = 0, + [MESA_FORMAT_RGBA_UINT8] = BRW_SURFACEFORMAT_R8G8B8A8_UINT, + [MESA_FORMAT_R_UINT16] = BRW_SURFACEFORMAT_R16_UINT, + [MESA_FORMAT_RG_UINT16] = BRW_SURFACEFORMAT_R16G16_UINT, + [MESA_FORMAT_RGB_UINT16] = 0, + [MESA_FORMAT_RGBA_UINT16] = BRW_SURFACEFORMAT_R16G16B16A16_UINT, [MESA_FORMAT_R_UINT32] = BRW_SURFACEFORMAT_R32_UINT, [MESA_FORMAT_RG_UINT32] = BRW_SURFACEFORMAT_R32G32_UINT, [MESA_FORMAT_RGB_UINT32] = BRW_SURFACEFORMAT_R32G32B32_UINT, [MESA_FORMAT_RGBA_UINT32] = BRW_SURFACEFORMAT_R32G32B32A32_UINT, - [MESA_FORMAT_RGBA_UINT16] = BRW_SURFACEFORMAT_R16G16B16A16_UINT, - [MESA_FORMAT_RGBA_INT16] = BRW_SURFACEFORMAT_R16G16B16A16_SINT, - [MESA_FORMAT_RG_UINT16] = BRW_SURFACEFORMAT_R16G16_UINT, - [MESA_FORMAT_RG_INT16] = BRW_SURFACEFORMAT_R16G16_SINT, - [MESA_FORMAT_R_UINT16] = BRW_SURFACEFORMAT_R16_UINT, - [MESA_FORMAT_R_INT16] = BRW_SURFACEFORMAT_R16_SINT, + [MESA_FORMAT_DUDV8] = BRW_SURFACEFORMAT_R8G8_SNORM, + [MESA_FORMAT_SIGNED_R8] = BRW_SURFACEFORMAT_R8_SNORM, + [MESA_FORMAT_SIGNED_RG88_REV] = BRW_SURFACEFORMAT_R8G8_SNORM, + [MESA_FORMAT_SIGNED_RGBX8888] = 0, + [MESA_FORMAT_SIGNED_RGBA8888] = 0, + [MESA_FORMAT_SIGNED_RGBA8888_REV] = BRW_SURFACEFORMAT_R8G8B8A8_SNORM, + [MESA_FORMAT_SIGNED_R16] = BRW_SURFACEFORMAT_R16_SNORM, + [MESA_FORMAT_SIGNED_GR1616] = BRW_SURFACEFORMAT_R16G16_SNORM, + [MESA_FORMAT_SIGNED_RGB_16] = 0, + [MESA_FORMAT_SIGNED_RGBA_16] = 0, + [MESA_FORMAT_RGBA_16] = 0, - [MESA_FORMAT_RGBA_UINT8] = BRW_SURFACEFORMAT_R8G8B8A8_UINT, - [MESA_FORMAT_RGBA_INT8] = BRW_SURFACEFORMAT_R8G8B8A8_SINT, - [MESA_FORMAT_RG_UINT8] = BRW_SURFACEFORMAT_R8G8_UINT, - [MESA_FORMAT_RG_INT8] = BRW_SURFACEFORMAT_R8G8_SINT, - [MESA_FORMAT_R_UINT8] = BRW_SURFACEFORMAT_R8_UINT, - [MESA_FORMAT_R_INT8] = BRW_SURFACEFORMAT_R8_SINT, + [MESA_FORMAT_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_UNORM, + [MESA_FORMAT_SIGNED_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_SNORM, + [MESA_FORMAT_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_UNORM, + [MESA_FORMAT_SIGNED_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_SNORM, + + [MESA_FORMAT_L_LATC1] = 0, + [MESA_FORMAT_SIGNED_L_LATC1] = 0, + [MESA_FORMAT_LA_LATC2] = 0, + [MESA_FORMAT_SIGNED_LA_LATC2] = 0, + + [MESA_FORMAT_SIGNED_A8] = 0, + [MESA_FORMAT_SIGNED_L8] = 0, + [MESA_FORMAT_SIGNED_AL88] = 0, + [MESA_FORMAT_SIGNED_I8] = 0, + [MESA_FORMAT_SIGNED_A16] = 0, + [MESA_FORMAT_SIGNED_L16] = 0, + [MESA_FORMAT_SIGNED_AL1616] = 0, + [MESA_FORMAT_SIGNED_I16] = 0, + + [MESA_FORMAT_RGB9_E5_FLOAT] = BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP, + [MESA_FORMAT_R11_G11_B10_FLOAT] = BRW_SURFACEFORMAT_R11G11B10_FLOAT, + + [MESA_FORMAT_Z32_FLOAT] = 0, + [MESA_FORMAT_Z32_FLOAT_X24S8] = 0, }; assert(mesa_format < MESA_FORMAT_COUNT); return table[mesa_format]; -- 2.7.4