diff options
Diffstat (limited to 'src/mesa/state_tracker/st_format.c')
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 366 |
1 files changed, 108 insertions, 258 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 851c16f83c..9ae0c9f9ba 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1,7 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright (c) 2008 VMware, Inc. + * Copyright (c) 2008-2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -28,7 +28,7 @@ /** - * Texture Image-related functions. + * Mesa / Gallium format conversion and format selection code. * \author Brian Paul */ @@ -59,151 +59,69 @@ format_max_bits(enum pipe_format format) return size; } -static GLuint -format_size(enum pipe_format format) -{ - return - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1); -} -/* - * XXX temporary here +/** + * Return basic GL datatype for the given gallium format. */ -GLboolean -st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo) +GLenum +st_format_datatype(enum pipe_format format) { const struct util_format_description *desc; desc = util_format_description(format); assert(desc); - if (desc->layout == UTIL_FORMAT_LAYOUT_ARITH || - desc->layout == UTIL_FORMAT_LAYOUT_ARRAY) { -#if 0 - printf("%s\n", util_format_name( format ) ); -#endif - - /* Data type */ - if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) { - pinfo->datatype = GL_UNSIGNED_SHORT; + if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) { + if (format == PIPE_FORMAT_B5G5R5A1_UNORM || + format == PIPE_FORMAT_B5G6R5_UNORM) { + return GL_UNSIGNED_SHORT; } - else if (format == PIPE_FORMAT_S8Z24_UNORM || - format == PIPE_FORMAT_Z24S8_UNORM) { - pinfo->datatype = GL_UNSIGNED_INT_24_8; + else if (format == PIPE_FORMAT_Z24S8_UNORM || + format == PIPE_FORMAT_S8Z24_UNORM) { + return GL_UNSIGNED_INT_24_8; } else { const GLuint size = format_max_bits(format); if (size == 8) { if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_BYTE; + return GL_UNSIGNED_BYTE; else - pinfo->datatype = GL_BYTE; + return GL_BYTE; } else if (size == 16) { if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_SHORT; + return GL_UNSIGNED_SHORT; else - pinfo->datatype = GL_SHORT; + return GL_SHORT; } else { assert( size <= 32 ); if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_INT; + return GL_UNSIGNED_INT; else - pinfo->datatype = GL_INT; + return GL_INT; } } - - /* Component bits */ - pinfo->red_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0); - pinfo->green_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1); - pinfo->blue_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2); - pinfo->alpha_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3); - pinfo->depth_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0); - pinfo->stencil_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1); - pinfo->luminance_bits = 0; - pinfo->intensity_bits = 0; - - /* Format size */ - pinfo->size = format_size(format) / 8; - - /* Luminance & Intensity bits */ - if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X && - desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X && - desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X) { - if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) { - pinfo->intensity_bits = pinfo->red_bits; - } - else { - pinfo->luminance_bits = pinfo->red_bits; - } - pinfo->red_bits = 0; - } - - pinfo->mesa_format = st_pipe_format_to_mesa_format(format); } - else if (desc->layout == UTIL_FORMAT_LAYOUT_YUV) { - pinfo->mesa_format = MESA_FORMAT_YCBCR; - pinfo->datatype = GL_UNSIGNED_SHORT; - pinfo->size = 2; /* two bytes per "texel" */ + else if (format == PIPE_FORMAT_UYVY) { + return GL_UNSIGNED_SHORT; + } + else if (format == PIPE_FORMAT_YUYV) { + return GL_UNSIGNED_SHORT; } else { /* compressed format? */ assert(0); } -#if 0 - printf( - "ST_FORMAT: R(%u), G(%u), B(%u), A(%u), Z(%u), S(%u)\n", - pinfo->red_bits, - pinfo->green_bits, - pinfo->blue_bits, - pinfo->alpha_bits, - pinfo->depth_bits, - pinfo->stencil_bits ); -#endif - - pinfo->format = format; - - return GL_TRUE; -} - - -/** - * Return bytes per pixel for the given format. - */ -GLuint -st_sizeof_format(enum pipe_format format) -{ - struct pipe_format_info info; - if (!st_get_format_info( format, &info )) { - assert( 0 ); - return 0; - } - return info.size; + assert(0); + return GL_NONE; } /** - * Return bytes per pixel for the given format. + * Translate Mesa format to Gallium format. */ -GLenum -st_format_datatype(enum pipe_format format) -{ - struct pipe_format_info info; - if (!st_get_format_info( format, &info )) { - assert( 0 ); - return 0; - } - return info.datatype; -} - - enum pipe_format st_mesa_format_to_pipe_format(gl_format mesaFormat) { @@ -211,17 +129,17 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) /* fix this */ case MESA_FORMAT_ARGB8888_REV: case MESA_FORMAT_ARGB8888: - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; case MESA_FORMAT_XRGB8888: - return PIPE_FORMAT_X8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8X8_UNORM; case MESA_FORMAT_ARGB1555: - return PIPE_FORMAT_A1R5G5B5_UNORM; + return PIPE_FORMAT_B5G5R5A1_UNORM; case MESA_FORMAT_ARGB4444: - return PIPE_FORMAT_A4R4G4B4_UNORM; + return PIPE_FORMAT_B4G4R4A4_UNORM; case MESA_FORMAT_RGB565: - return PIPE_FORMAT_R5G6B5_UNORM; + return PIPE_FORMAT_B5G6R5_UNORM; case MESA_FORMAT_AL88: - return PIPE_FORMAT_A8L8_UNORM; + return PIPE_FORMAT_L8A8_UNORM; case MESA_FORMAT_A8: return PIPE_FORMAT_A8_UNORM; case MESA_FORMAT_L8: @@ -233,11 +151,11 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_Z32: return PIPE_FORMAT_Z32_UNORM; case MESA_FORMAT_Z24_S8: - return PIPE_FORMAT_Z24S8_UNORM; - case MESA_FORMAT_S8_Z24: return PIPE_FORMAT_S8Z24_UNORM; + case MESA_FORMAT_S8_Z24: + return PIPE_FORMAT_Z24S8_UNORM; case MESA_FORMAT_YCBCR: - return PIPE_FORMAT_YCBCR; + return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc case MESA_FORMAT_RGB_DXT1: return PIPE_FORMAT_DXT1_RGB; @@ -260,15 +178,15 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) #endif #if FEATURE_EXT_texture_sRGB case MESA_FORMAT_SLA8: - return PIPE_FORMAT_A8L8_SRGB; + return PIPE_FORMAT_L8A8_SRGB; case MESA_FORMAT_SL8: return PIPE_FORMAT_L8_SRGB; case MESA_FORMAT_SRGB8: return PIPE_FORMAT_R8G8B8_SRGB; case MESA_FORMAT_SRGBA8: - return PIPE_FORMAT_R8G8B8A8_SRGB; + return PIPE_FORMAT_A8B8G8R8_SRGB; case MESA_FORMAT_SARGB8: - return PIPE_FORMAT_A8R8G8B8_SRGB; + return PIPE_FORMAT_B8G8R8A8_SRGB; #endif default: assert(0); @@ -277,25 +195,28 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) } +/** + * Translate Gallium format to Mesa format. + */ gl_format -st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) +st_pipe_format_to_mesa_format(enum pipe_format format) { - switch (pipeFormat) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + switch (format) { + case PIPE_FORMAT_B8G8R8A8_UNORM: return MESA_FORMAT_ARGB8888; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return MESA_FORMAT_XRGB8888; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return MESA_FORMAT_ARGB8888_REV; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: return MESA_FORMAT_XRGB8888_REV; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return MESA_FORMAT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return MESA_FORMAT_ARGB4444; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return MESA_FORMAT_RGB565; - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return MESA_FORMAT_AL88; case PIPE_FORMAT_A8_UNORM: return MESA_FORMAT_A8; @@ -303,25 +224,29 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) return MESA_FORMAT_L8; case PIPE_FORMAT_I8_UNORM: return MESA_FORMAT_I8; + case PIPE_FORMAT_S8_UNORM: + return MESA_FORMAT_S8; + + case PIPE_FORMAT_R16G16B16A16_SNORM: + return MESA_FORMAT_SIGNED_RGBA_16; + case PIPE_FORMAT_Z16_UNORM: return MESA_FORMAT_Z16; case PIPE_FORMAT_Z32_UNORM: return MESA_FORMAT_Z32; - case PIPE_FORMAT_Z24X8_UNORM: - return MESA_FORMAT_Z24_X8; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return MESA_FORMAT_Z24_S8; case PIPE_FORMAT_X8Z24_UNORM: + return MESA_FORMAT_Z24_X8; + case PIPE_FORMAT_Z24X8_UNORM: return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return MESA_FORMAT_S8_Z24; - case PIPE_FORMAT_S8_UNORM: - return MESA_FORMAT_S8; - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return MESA_FORMAT_YCBCR; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; + case PIPE_FORMAT_YUYV: + return MESA_FORMAT_YCBCR_REV; #if FEATURE_texture_s3tc case PIPE_FORMAT_DXT1_RGB: @@ -343,21 +268,22 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) return MESA_FORMAT_SRGBA_DXT5; #endif #endif + #if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_SRGB: return MESA_FORMAT_SLA8; case PIPE_FORMAT_L8_SRGB: return MESA_FORMAT_SL8; case PIPE_FORMAT_R8G8B8_SRGB: return MESA_FORMAT_SRGB8; - case PIPE_FORMAT_R8G8B8A8_SRGB: + case PIPE_FORMAT_A8B8G8R8_SRGB: return MESA_FORMAT_SRGBA8; - case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_B8G8R8A8_SRGB: return MESA_FORMAT_SARGB8; #endif default: assert(0); - return 0; + return MESA_FORMAT_NONE; } } @@ -372,10 +298,10 @@ default_rgba_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -396,13 +322,13 @@ default_rgb_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_X8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_FORMAT_R8G8B8X8_UNORM, - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_X8B8G8R8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -423,9 +349,9 @@ default_srgba_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_A8R8G8B8_SRGB, PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_R8G8B8A8_SRGB, + PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_A8B8G8R8_SRGB, }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -467,8 +393,8 @@ default_depth_format(struct pipe_screen *screen, static const enum pipe_format zFormats[] = { PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_Z24S8_UNORM + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_S8Z24_UNORM }; uint i; for (i = 0; i < Elements(zFormats); i++) { @@ -513,13 +439,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGBA4: case GL_RGBA2: - if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A4R4G4B4_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B4G4R4A4_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_RGB5_A1: - if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A1R5G5B5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_RGB8: @@ -531,10 +457,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: - if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_R5G6B5_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A1R5G5B5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G6R5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_ALPHA: @@ -567,8 +493,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: - if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A8L8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_L8A8_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_INTENSITY: @@ -582,13 +508,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_YCBCR_MESA: - if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target, tex_usage, geom_flags)) { - return PIPE_FORMAT_YCBCR; + return PIPE_FORMAT_UYVY; } - if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, + if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target, tex_usage, geom_flags)) { - return PIPE_FORMAT_YCBCR_REV; + return PIPE_FORMAT_YUYV; } return PIPE_FORMAT_NONE; @@ -620,10 +546,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) @@ -639,18 +565,18 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_STENCIL_INDEX16_EXT: if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; return PIPE_FORMAT_NONE; case GL_SRGB_EXT: @@ -673,8 +599,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_SLUMINANCE8_ALPHA8_EXT: case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_SRGB, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A8L8_SRGB; + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_SRGB, target, tex_usage, geom_flags )) + return PIPE_FORMAT_L8A8_SRGB; return default_srgba_format( screen, target, tex_usage, geom_flags ); case GL_SLUMINANCE_EXT: @@ -726,82 +652,6 @@ st_choose_renderbuffer_format(struct pipe_screen *screen, } -static gl_format -translate_gallium_format_to_mesa_format(enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - return MESA_FORMAT_ARGB8888; - case PIPE_FORMAT_X8R8G8B8_UNORM: - return MESA_FORMAT_XRGB8888; - case PIPE_FORMAT_A1R5G5B5_UNORM: - return MESA_FORMAT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: - return MESA_FORMAT_ARGB4444; - case PIPE_FORMAT_R5G6B5_UNORM: - return MESA_FORMAT_RGB565; - case PIPE_FORMAT_A8L8_UNORM: - return MESA_FORMAT_AL88; - case PIPE_FORMAT_A8_UNORM: - return MESA_FORMAT_A8; - case PIPE_FORMAT_L8_UNORM: - return MESA_FORMAT_L8; - case PIPE_FORMAT_I8_UNORM: - return MESA_FORMAT_I8; - case PIPE_FORMAT_Z16_UNORM: - return MESA_FORMAT_Z16; - case PIPE_FORMAT_Z32_UNORM: - return MESA_FORMAT_Z32; - case PIPE_FORMAT_Z24S8_UNORM: - return MESA_FORMAT_Z24_S8; - case PIPE_FORMAT_X8Z24_UNORM: - return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_S8Z24_UNORM: - return MESA_FORMAT_S8_Z24; - case PIPE_FORMAT_YCBCR: - return MESA_FORMAT_YCBCR; - case PIPE_FORMAT_YCBCR_REV: - return MESA_FORMAT_YCBCR_REV; -#if FEATURE_texture_s3tc - case PIPE_FORMAT_DXT1_RGB: - return MESA_FORMAT_RGB_DXT1; - case PIPE_FORMAT_DXT1_RGBA: - return MESA_FORMAT_RGBA_DXT1; - case PIPE_FORMAT_DXT3_RGBA: - return MESA_FORMAT_RGBA_DXT3; - case PIPE_FORMAT_DXT5_RGBA: - return MESA_FORMAT_RGBA_DXT5; -#if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_DXT1_SRGB: - return MESA_FORMAT_SRGB_DXT1; - case PIPE_FORMAT_DXT1_SRGBA: - return MESA_FORMAT_SRGBA_DXT1; - case PIPE_FORMAT_DXT3_SRGBA: - return MESA_FORMAT_SRGBA_DXT3; - case PIPE_FORMAT_DXT5_SRGBA: - return MESA_FORMAT_SRGBA_DXT5; -#endif -#endif -#if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_A8L8_SRGB: - return MESA_FORMAT_SLA8; - case PIPE_FORMAT_L8_SRGB: - return MESA_FORMAT_SL8; - case PIPE_FORMAT_R8G8B8_SRGB: - return MESA_FORMAT_SRGB8; - case PIPE_FORMAT_R8G8B8A8_SRGB: - return MESA_FORMAT_SRGBA8; - case PIPE_FORMAT_A8R8G8B8_SRGB: - return MESA_FORMAT_SARGB8; -#endif - /* XXX add additional cases */ - default: - assert(0); - return MESA_FORMAT_NONE; - } -} - - /** * Called via ctx->Driver.chooseTextureFormat(). */ @@ -819,7 +669,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, if (pFormat == PIPE_FORMAT_NONE) return MESA_FORMAT_NONE; - return translate_gallium_format_to_mesa_format(pFormat); + return st_pipe_format_to_mesa_format(pFormat); } @@ -830,11 +680,11 @@ GLboolean st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type) { switch (pFormat) { - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_A8B8G8R8_UNORM: return format == GL_RGBA && type == GL_UNSIGNED_BYTE; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return format == GL_BGRA && type == GL_UNSIGNED_BYTE; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; /* XXX more combos... */ default: |