Go to the source code of this file.
Functions | |
static GLuint | format_bits (pipe_format_rgbazs_t info, GLuint comp) |
Texture Image-related functions. | |
static GLuint | format_max_bits (pipe_format_rgbazs_t info) |
static GLuint | format_size (pipe_format_rgbazs_t info) |
GLboolean | st_get_format_info (enum pipe_format format, struct pipe_format_info *pinfo) |
GLuint | st_sizeof_format (enum pipe_format format) |
Return bytes per pixel for the given format. | |
GLenum | st_format_datatype (enum pipe_format format) |
Return bytes per pixel for the given format. | |
enum pipe_format | st_mesa_format_to_pipe_format (GLuint mesaFormat) |
static enum pipe_format | default_rgba_format (struct pipe_screen *screen, enum pipe_texture_target target, unsigned tex_usage, unsigned geom_flags) |
Find an RGBA format supported by the context/winsys. | |
static enum pipe_format | default_deep_rgba_format (struct pipe_screen *screen, enum pipe_texture_target target, unsigned tex_usage, unsigned geom_flags) |
Search list of formats for first RGBA format with >8 bits/channel. | |
static enum pipe_format | default_depth_format (struct pipe_screen *screen, enum pipe_texture_target target, unsigned tex_usage, unsigned geom_flags) |
Find an Z format supported by the context/winsys. | |
enum pipe_format | st_choose_format (struct pipe_context *pipe, GLint internalFormat, enum pipe_texture_target target, unsigned tex_usage) |
Given an OpenGL internalFormat value for a texture or surface, return the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. | |
static GLboolean | is_stencil_format (GLenum format) |
enum pipe_format | st_choose_renderbuffer_format (struct pipe_context *pipe, GLint internalFormat) |
Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces. | |
static struct gl_texture_format * | translate_gallium_format_to_mesa_format (enum pipe_format format) |
struct gl_texture_format * | st_ChooseTextureFormat (GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type) |
Called via ctx->Driver.chooseTextureFormat(). |
static enum pipe_format default_deep_rgba_format | ( | struct pipe_screen * | screen, | |
enum pipe_texture_target | target, | |||
unsigned | tex_usage, | |||
unsigned | geom_flags | |||
) | [static] |
Search list of formats for first RGBA format with >8 bits/channel.
Definition at line 302 of file st_format.c.
References default_rgba_format(), pipe_screen::is_format_supported, PIPE_FORMAT_NONE, PIPE_FORMAT_R16G16B16A16_SNORM, and PIPE_TEXTURE_USAGE_RENDER_TARGET.
00306 { 00307 if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) { 00308 return PIPE_FORMAT_R16G16B16A16_SNORM; 00309 } 00310 if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) 00311 return default_rgba_format(screen, target, tex_usage, geom_flags); 00312 else 00313 return PIPE_FORMAT_NONE; 00314 }
static enum pipe_format default_depth_format | ( | struct pipe_screen * | screen, | |
enum pipe_texture_target | target, | |||
unsigned | tex_usage, | |||
unsigned | geom_flags | |||
) | [static] |
Find an Z format supported by the context/winsys.
Definition at line 321 of file st_format.c.
References Elements, pipe_screen::is_format_supported, PIPE_FORMAT_NONE, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, and PIPE_FORMAT_Z32_UNORM.
00325 { 00326 static const enum pipe_format zFormats[] = { 00327 PIPE_FORMAT_Z16_UNORM, 00328 PIPE_FORMAT_Z32_UNORM, 00329 PIPE_FORMAT_S8Z24_UNORM, 00330 PIPE_FORMAT_Z24S8_UNORM 00331 }; 00332 uint i; 00333 for (i = 0; i < Elements(zFormats); i++) { 00334 if (screen->is_format_supported( screen, zFormats[i], target, tex_usage, geom_flags )) { 00335 return zFormats[i]; 00336 } 00337 } 00338 return PIPE_FORMAT_NONE; 00339 }
static enum pipe_format default_rgba_format | ( | struct pipe_screen * | screen, | |
enum pipe_texture_target | target, | |||
unsigned | tex_usage, | |||
unsigned | geom_flags | |||
) | [static] |
Find an RGBA format supported by the context/winsys.
Definition at line 277 of file st_format.c.
References Elements, pipe_screen::is_format_supported, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_NONE, PIPE_FORMAT_R5G6B5_UNORM, and PIPE_FORMAT_R8G8B8A8_UNORM.
00281 { 00282 static const enum pipe_format colorFormats[] = { 00283 PIPE_FORMAT_A8R8G8B8_UNORM, 00284 PIPE_FORMAT_B8G8R8A8_UNORM, 00285 PIPE_FORMAT_R8G8B8A8_UNORM, 00286 PIPE_FORMAT_R5G6B5_UNORM 00287 }; 00288 uint i; 00289 for (i = 0; i < Elements(colorFormats); i++) { 00290 if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) { 00291 return colorFormats[i]; 00292 } 00293 } 00294 return PIPE_FORMAT_NONE; 00295 }
static GLuint format_bits | ( | pipe_format_rgbazs_t | info, | |
GLuint | comp | |||
) | [static] |
Texture Image-related functions.
Definition at line 48 of file st_format.c.
References pf_get_component_bits().
00051 { 00052 return pf_get_component_bits( (enum pipe_format) info, comp ); 00053 }
static GLuint format_max_bits | ( | pipe_format_rgbazs_t | info | ) | [static] |
Definition at line 56 of file st_format.c.
References format_bits(), MAX2, PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_S, and PIPE_FORMAT_COMP_Z.
00058 { 00059 GLuint size = format_bits( info, PIPE_FORMAT_COMP_R ); 00060 00061 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_G ) ); 00062 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_B ) ); 00063 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_A ) ); 00064 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_Z ) ); 00065 size = MAX2( size, format_bits( info, PIPE_FORMAT_COMP_S ) ); 00066 return size; 00067 }
static GLuint format_size | ( | pipe_format_rgbazs_t | info | ) | [static] |
Definition at line 70 of file st_format.c.
References format_bits(), PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_S, and PIPE_FORMAT_COMP_Z.
00072 { 00073 return 00074 format_bits( info, PIPE_FORMAT_COMP_R ) + 00075 format_bits( info, PIPE_FORMAT_COMP_G ) + 00076 format_bits( info, PIPE_FORMAT_COMP_B ) + 00077 format_bits( info, PIPE_FORMAT_COMP_A ) + 00078 format_bits( info, PIPE_FORMAT_COMP_Z ) + 00079 format_bits( info, PIPE_FORMAT_COMP_S ); 00080 }
static GLboolean is_stencil_format | ( | GLenum | format | ) | [static] |
Definition at line 522 of file st_format.c.
00523 { 00524 switch (format) { 00525 case GL_STENCIL_INDEX: 00526 case GL_STENCIL_INDEX1_EXT: 00527 case GL_STENCIL_INDEX4_EXT: 00528 case GL_STENCIL_INDEX8_EXT: 00529 case GL_STENCIL_INDEX16_EXT: 00530 case GL_DEPTH_STENCIL_EXT: 00531 case GL_DEPTH24_STENCIL8_EXT: 00532 return GL_TRUE; 00533 default: 00534 return GL_FALSE; 00535 } 00536 }
enum pipe_format st_choose_format | ( | struct pipe_context * | pipe, | |
GLint | internalFormat, | |||
enum pipe_texture_target | target, | |||
unsigned | tex_usage | |||
) |
Given an OpenGL internalFormat value for a texture or surface, return the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
target | one of PIPE_TEXTURE_x | |
tex_usage | either PIPE_TEXTURE_USAGE_RENDER_TARGET or PIPE_TEXTURE_USAGE_SAMPLER |
Definition at line 350 of file st_format.c.
References default_deep_rgba_format(), default_depth_format(), default_rgba_format(), pipe_screen::is_format_supported, PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_DXT1_RGB, PIPE_FORMAT_DXT1_RGBA, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT5_RGBA, PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_NONE, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_S8_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_YCBCR, PIPE_FORMAT_YCBCR_REV, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z32_UNORM, PIPE_TEXTURE_USAGE_RENDER_TARGET, and pipe_context::screen.
00352 { 00353 struct pipe_screen *screen = pipe->screen; 00354 unsigned geom_flags = 0; 00355 00356 switch (internalFormat) { 00357 case 4: 00358 case GL_RGBA: 00359 case GL_COMPRESSED_RGBA: 00360 case 3: 00361 case GL_RGB: 00362 case GL_COMPRESSED_RGB: 00363 case GL_RGBA8: 00364 case GL_RGB10_A2: 00365 case GL_RGBA12: 00366 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00367 case GL_RGBA16: 00368 if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) 00369 return default_deep_rgba_format( screen, target, tex_usage, geom_flags ); 00370 else 00371 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00372 00373 case GL_RGBA4: 00374 case GL_RGBA2: 00375 if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, target, tex_usage, geom_flags )) 00376 return PIPE_FORMAT_A4R4G4B4_UNORM; 00377 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00378 00379 case GL_RGB5_A1: 00380 if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) 00381 return PIPE_FORMAT_A1R5G5B5_UNORM; 00382 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00383 00384 case GL_RGB8: 00385 case GL_RGB10: 00386 case GL_RGB12: 00387 case GL_RGB16: 00388 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00389 00390 case GL_RGB5: 00391 case GL_RGB4: 00392 case GL_R3_G3_B2: 00393 if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) 00394 return PIPE_FORMAT_A1R5G5B5_UNORM; 00395 if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, target, tex_usage, geom_flags )) 00396 return PIPE_FORMAT_R5G6B5_UNORM; 00397 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00398 00399 case GL_ALPHA: 00400 case GL_ALPHA4: 00401 case GL_ALPHA8: 00402 case GL_ALPHA12: 00403 case GL_ALPHA16: 00404 case GL_COMPRESSED_ALPHA: 00405 if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, tex_usage, geom_flags )) 00406 return PIPE_FORMAT_A8_UNORM; 00407 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00408 00409 case 1: 00410 case GL_LUMINANCE: 00411 case GL_LUMINANCE4: 00412 case GL_LUMINANCE8: 00413 case GL_LUMINANCE12: 00414 case GL_LUMINANCE16: 00415 case GL_COMPRESSED_LUMINANCE: 00416 if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags )) 00417 return PIPE_FORMAT_L8_UNORM; 00418 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00419 00420 case 2: 00421 case GL_LUMINANCE_ALPHA: 00422 case GL_LUMINANCE4_ALPHA4: 00423 case GL_LUMINANCE6_ALPHA2: 00424 case GL_LUMINANCE8_ALPHA8: 00425 case GL_LUMINANCE12_ALPHA4: 00426 case GL_LUMINANCE12_ALPHA12: 00427 case GL_LUMINANCE16_ALPHA16: 00428 case GL_COMPRESSED_LUMINANCE_ALPHA: 00429 if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags )) 00430 return PIPE_FORMAT_A8L8_UNORM; 00431 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00432 00433 case GL_INTENSITY: 00434 case GL_INTENSITY4: 00435 case GL_INTENSITY8: 00436 case GL_INTENSITY12: 00437 case GL_INTENSITY16: 00438 case GL_COMPRESSED_INTENSITY: 00439 if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, tex_usage, geom_flags )) 00440 return PIPE_FORMAT_I8_UNORM; 00441 return default_rgba_format( screen, target, tex_usage, geom_flags ); 00442 00443 case GL_YCBCR_MESA: 00444 if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, 00445 target, tex_usage, geom_flags)) { 00446 return PIPE_FORMAT_YCBCR; 00447 } 00448 if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, 00449 target, tex_usage, geom_flags)) { 00450 return PIPE_FORMAT_YCBCR_REV; 00451 } 00452 return PIPE_FORMAT_NONE; 00453 00454 case GL_RGB_S3TC: 00455 case GL_RGB4_S3TC: 00456 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 00457 return PIPE_FORMAT_DXT1_RGB; 00458 00459 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 00460 return PIPE_FORMAT_DXT1_RGBA; 00461 00462 case GL_RGBA_S3TC: 00463 case GL_RGBA4_S3TC: 00464 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 00465 return PIPE_FORMAT_DXT3_RGBA; 00466 00467 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 00468 return PIPE_FORMAT_DXT5_RGBA; 00469 00470 #if 0 00471 case GL_COMPRESSED_RGB_FXT1_3DFX: 00472 return PIPE_FORMAT_RGB_FXT1; 00473 case GL_COMPRESSED_RGBA_FXT1_3DFX: 00474 return PIPE_FORMAT_RGB_FXT1; 00475 #endif 00476 00477 case GL_DEPTH_COMPONENT16: 00478 if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, target, tex_usage, geom_flags )) 00479 return PIPE_FORMAT_Z16_UNORM; 00480 /* fall-through */ 00481 case GL_DEPTH_COMPONENT24: 00482 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) 00483 return PIPE_FORMAT_S8Z24_UNORM; 00484 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) 00485 return PIPE_FORMAT_Z24S8_UNORM; 00486 /* fall-through */ 00487 case GL_DEPTH_COMPONENT32: 00488 if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) 00489 return PIPE_FORMAT_Z32_UNORM; 00490 /* fall-through */ 00491 case GL_DEPTH_COMPONENT: 00492 return default_depth_format( screen, target, tex_usage, geom_flags ); 00493 00494 case GL_STENCIL_INDEX: 00495 case GL_STENCIL_INDEX1_EXT: 00496 case GL_STENCIL_INDEX4_EXT: 00497 case GL_STENCIL_INDEX8_EXT: 00498 case GL_STENCIL_INDEX16_EXT: 00499 if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags )) 00500 return PIPE_FORMAT_S8_UNORM; 00501 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) 00502 return PIPE_FORMAT_S8Z24_UNORM; 00503 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) 00504 return PIPE_FORMAT_Z24S8_UNORM; 00505 return PIPE_FORMAT_NONE; 00506 00507 case GL_DEPTH_STENCIL_EXT: 00508 case GL_DEPTH24_STENCIL8_EXT: 00509 if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) 00510 return PIPE_FORMAT_S8Z24_UNORM; 00511 if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) 00512 return PIPE_FORMAT_Z24S8_UNORM; 00513 return PIPE_FORMAT_NONE; 00514 00515 default: 00516 return PIPE_FORMAT_NONE; 00517 } 00518 }
enum pipe_format st_choose_renderbuffer_format | ( | struct pipe_context * | pipe, | |
GLint | internalFormat | |||
) |
Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
Definition at line 542 of file st_format.c.
References is_stencil_format(), PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, PIPE_TEXTURE_USAGE_RENDER_TARGET, and st_choose_format().
00543 { 00544 uint usage; 00545 if (is_stencil_format(internalFormat)) 00546 usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; 00547 else 00548 usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; 00549 return st_choose_format(pipe, internalFormat, PIPE_TEXTURE_2D, usage); 00550 }
struct gl_texture_format* st_ChooseTextureFormat | ( | GLcontext * | ctx, | |
GLint | internalFormat, | |||
GLenum | format, | |||
GLenum | type | |||
) | [read] |
Called via ctx->Driver.chooseTextureFormat().
Definition at line 607 of file st_format.c.
References PIPE_FORMAT_NONE, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, st_choose_format(), and translate_gallium_format_to_mesa_format().
00609 { 00610 enum pipe_format pFormat; 00611 00612 (void) format; 00613 (void) type; 00614 00615 pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE_2D, 00616 PIPE_TEXTURE_USAGE_SAMPLER); 00617 if (pFormat == PIPE_FORMAT_NONE) 00618 return NULL; 00619 00620 return translate_gallium_format_to_mesa_format(pFormat); 00621 }
GLenum st_format_datatype | ( | enum pipe_format | format | ) |
Return bytes per pixel for the given format.
Definition at line 214 of file st_format.c.
References assert, pipe_format_info::datatype, and st_get_format_info().
00215 { 00216 struct pipe_format_info info; 00217 if (!st_get_format_info( format, &info )) { 00218 assert( 0 ); 00219 return 0; 00220 } 00221 return info.datatype; 00222 }
GLboolean st_get_format_info | ( | enum pipe_format | format, | |
struct pipe_format_info * | pinfo | |||
) |
Definition at line 86 of file st_format.c.
References pipe_format_info::alpha_bits, assert, pipe_format_info::base_format, pipe_format_info::blue_bits, pipe_format_info::datatype, pipe_format_info::depth_bits, pipe_format_info::format, format_bits(), format_max_bits(), format_size(), pipe_format_info::green_bits, pipe_format_info::intensity_bits, pipe_format_info::luminance_bits, pf_layout(), pf_name(), pf_swizzle_w, pf_swizzle_x, pf_swizzle_y, pf_swizzle_z, pf_type, PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_LAYOUT_RGBAZS, PIPE_FORMAT_LAYOUT_YCBCR, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_TYPE_UNORM, pipe_format_info::red_bits, pipe_format_info::size, and pipe_format_info::stencil_bits.
00087 { 00088 if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) { 00089 pipe_format_rgbazs_t info; 00090 00091 info = format; 00092 00093 #if 0 00094 printf("%s\n", pf_name( format ) ); 00095 #endif 00096 00097 /* Data type */ 00098 if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) { 00099 pinfo->datatype = GL_UNSIGNED_SHORT; 00100 } 00101 else { 00102 GLuint size; 00103 00104 size = format_max_bits( info ); 00105 if (size == 8) { 00106 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM) 00107 pinfo->datatype = GL_UNSIGNED_BYTE; 00108 else 00109 pinfo->datatype = GL_BYTE; 00110 } 00111 else if (size == 16) { 00112 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM) 00113 pinfo->datatype = GL_UNSIGNED_SHORT; 00114 else 00115 pinfo->datatype = GL_SHORT; 00116 } 00117 else { 00118 assert( size <= 32 ); 00119 if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM) 00120 pinfo->datatype = GL_UNSIGNED_INT; 00121 else 00122 pinfo->datatype = GL_INT; 00123 } 00124 } 00125 00126 /* Component bits */ 00127 pinfo->red_bits = format_bits( info, PIPE_FORMAT_COMP_R ); 00128 pinfo->green_bits = format_bits( info, PIPE_FORMAT_COMP_G ); 00129 pinfo->blue_bits = format_bits( info, PIPE_FORMAT_COMP_B ); 00130 pinfo->alpha_bits = format_bits( info, PIPE_FORMAT_COMP_A ); 00131 pinfo->depth_bits = format_bits( info, PIPE_FORMAT_COMP_Z ); 00132 pinfo->stencil_bits = format_bits( info, PIPE_FORMAT_COMP_S ); 00133 pinfo->luminance_bits = 0; 00134 pinfo->intensity_bits = 0; 00135 00136 /* Format size */ 00137 pinfo->size = format_size( info ) / 8; 00138 00139 /* Luminance & Intensity bits */ 00140 if( pf_swizzle_x(info) == PIPE_FORMAT_COMP_R && 00141 pf_swizzle_y(info) == PIPE_FORMAT_COMP_R && 00142 pf_swizzle_z(info) == PIPE_FORMAT_COMP_R ) { 00143 if( pf_swizzle_w(info) == PIPE_FORMAT_COMP_R ) { 00144 pinfo->intensity_bits = pinfo->red_bits; 00145 } 00146 else { 00147 pinfo->luminance_bits = pinfo->red_bits; 00148 } 00149 pinfo->red_bits = 0; 00150 } 00151 00152 /* Base format */ 00153 if (pinfo->depth_bits) { 00154 if (pinfo->stencil_bits) { 00155 pinfo->base_format = GL_DEPTH_STENCIL_EXT; 00156 } 00157 else { 00158 pinfo->base_format = GL_DEPTH_COMPONENT; 00159 } 00160 } 00161 else if (pinfo->stencil_bits) { 00162 pinfo->base_format = GL_STENCIL_INDEX; 00163 } 00164 else { 00165 pinfo->base_format = GL_RGBA; 00166 } 00167 } 00168 else if (pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR) { 00169 pinfo->base_format = GL_YCBCR_MESA; 00170 pinfo->datatype = GL_UNSIGNED_SHORT; 00171 pinfo->size = 2; /* two bytes per "texel" */ 00172 } 00173 else { 00174 /* compressed format? */ 00175 assert(0); 00176 } 00177 00178 #if 0 00179 printf( 00180 "ST_FORMAT: R(%u), G(%u), B(%u), A(%u), Z(%u), S(%u)\n", 00181 pinfo->red_bits, 00182 pinfo->green_bits, 00183 pinfo->blue_bits, 00184 pinfo->alpha_bits, 00185 pinfo->depth_bits, 00186 pinfo->stencil_bits ); 00187 #endif 00188 00189 pinfo->format = format; 00190 00191 return GL_TRUE; 00192 }
enum pipe_format st_mesa_format_to_pipe_format | ( | GLuint | mesaFormat | ) |
Definition at line 226 of file st_format.c.
References assert, PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_DXT1_RGB, PIPE_FORMAT_DXT1_RGBA, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT5_RGBA, PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_YCBCR, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, and PIPE_FORMAT_Z32_UNORM.
00227 { 00228 switch (mesaFormat) { 00229 /* fix this */ 00230 case MESA_FORMAT_ARGB8888_REV: 00231 case MESA_FORMAT_ARGB8888: 00232 return PIPE_FORMAT_A8R8G8B8_UNORM; 00233 case MESA_FORMAT_ARGB1555: 00234 return PIPE_FORMAT_A1R5G5B5_UNORM; 00235 case MESA_FORMAT_ARGB4444: 00236 return PIPE_FORMAT_A4R4G4B4_UNORM; 00237 case MESA_FORMAT_RGB565: 00238 return PIPE_FORMAT_R5G6B5_UNORM; 00239 case MESA_FORMAT_AL88: 00240 return PIPE_FORMAT_A8L8_UNORM; 00241 case MESA_FORMAT_A8: 00242 return PIPE_FORMAT_A8_UNORM; 00243 case MESA_FORMAT_L8: 00244 return PIPE_FORMAT_L8_UNORM; 00245 case MESA_FORMAT_I8: 00246 return PIPE_FORMAT_I8_UNORM; 00247 case MESA_FORMAT_Z16: 00248 return PIPE_FORMAT_Z16_UNORM; 00249 case MESA_FORMAT_Z32: 00250 return PIPE_FORMAT_Z32_UNORM; 00251 case MESA_FORMAT_Z24_S8: 00252 return PIPE_FORMAT_Z24S8_UNORM; 00253 case MESA_FORMAT_S8_Z24: 00254 return PIPE_FORMAT_S8Z24_UNORM; 00255 case MESA_FORMAT_YCBCR: 00256 return PIPE_FORMAT_YCBCR; 00257 #if FEATURE_texture_s3tc 00258 case MESA_FORMAT_RGB_DXT1: 00259 return PIPE_FORMAT_DXT1_RGB; 00260 case MESA_FORMAT_RGBA_DXT1: 00261 return PIPE_FORMAT_DXT1_RGBA; 00262 case MESA_FORMAT_RGBA_DXT3: 00263 return PIPE_FORMAT_DXT3_RGBA; 00264 case MESA_FORMAT_RGBA_DXT5: 00265 return PIPE_FORMAT_DXT5_RGBA; 00266 #endif 00267 default: 00268 assert(0); 00269 return 0; 00270 } 00271 }
GLuint st_sizeof_format | ( | enum pipe_format | format | ) |
Return bytes per pixel for the given format.
Definition at line 199 of file st_format.c.
References assert, pipe_format_info::size, and st_get_format_info().
00200 { 00201 struct pipe_format_info info; 00202 if (!st_get_format_info( format, &info )) { 00203 assert( 0 ); 00204 return 0; 00205 } 00206 return info.size; 00207 }
static struct gl_texture_format* translate_gallium_format_to_mesa_format | ( | enum pipe_format | format | ) | [static, read] |
Definition at line 554 of file st_format.c.
References assert, PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_DXT1_RGB, PIPE_FORMAT_DXT1_RGBA, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT5_RGBA, PIPE_FORMAT_I8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_YCBCR, PIPE_FORMAT_YCBCR_REV, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, and PIPE_FORMAT_Z32_UNORM.
00555 { 00556 switch (format) { 00557 case PIPE_FORMAT_A8R8G8B8_UNORM: 00558 return &_mesa_texformat_argb8888; 00559 case PIPE_FORMAT_A1R5G5B5_UNORM: 00560 return &_mesa_texformat_argb1555; 00561 case PIPE_FORMAT_A4R4G4B4_UNORM: 00562 return &_mesa_texformat_argb4444; 00563 case PIPE_FORMAT_R5G6B5_UNORM: 00564 return &_mesa_texformat_rgb565; 00565 case PIPE_FORMAT_A8L8_UNORM: 00566 return &_mesa_texformat_al88; 00567 case PIPE_FORMAT_A8_UNORM: 00568 return &_mesa_texformat_a8; 00569 case PIPE_FORMAT_L8_UNORM: 00570 return &_mesa_texformat_l8; 00571 case PIPE_FORMAT_I8_UNORM: 00572 return &_mesa_texformat_i8; 00573 case PIPE_FORMAT_Z16_UNORM: 00574 return &_mesa_texformat_z16; 00575 case PIPE_FORMAT_Z32_UNORM: 00576 return &_mesa_texformat_z32; 00577 case PIPE_FORMAT_Z24S8_UNORM: 00578 return &_mesa_texformat_z24_s8; 00579 case PIPE_FORMAT_S8Z24_UNORM: 00580 return &_mesa_texformat_s8_z24; 00581 case PIPE_FORMAT_YCBCR: 00582 return &_mesa_texformat_ycbcr; 00583 case PIPE_FORMAT_YCBCR_REV: 00584 return &_mesa_texformat_ycbcr_rev; 00585 #if FEATURE_texture_s3tc 00586 case PIPE_FORMAT_DXT1_RGB: 00587 return &_mesa_texformat_rgb_dxt1; 00588 case PIPE_FORMAT_DXT1_RGBA: 00589 return &_mesa_texformat_rgba_dxt1; 00590 case PIPE_FORMAT_DXT3_RGBA: 00591 return &_mesa_texformat_rgba_dxt3; 00592 case PIPE_FORMAT_DXT5_RGBA: 00593 return &_mesa_texformat_rgba_dxt5; 00594 #endif 00595 /* XXX add additional cases */ 00596 default: 00597 assert(0); 00598 return NULL; 00599 } 00600 }