mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-29 08:30:42 +02:00
mesa: refactor: move _mesa_is_color/depth/stencil_format() helpers to image.c
This commit is contained in:
parent
ba2a55ccd6
commit
73b150c816
5 changed files with 225 additions and 224 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include "main/bufferobj.h"
|
||||
#include "main/depth.h"
|
||||
#include "main/enable.h"
|
||||
#include "main/image.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/matrix.h"
|
||||
#include "main/polygon.h"
|
||||
|
|
|
|||
|
|
@ -530,6 +530,210 @@ _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a color/RGBA format (i.e., not color
|
||||
* index, depth, stencil, etc).
|
||||
* \param format the image format value (may by an internal texture format)
|
||||
* \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_color_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_RED:
|
||||
case GL_GREEN:
|
||||
case GL_BLUE:
|
||||
case GL_ALPHA:
|
||||
case GL_ALPHA4:
|
||||
case GL_ALPHA8:
|
||||
case GL_ALPHA12:
|
||||
case GL_ALPHA16:
|
||||
case 1:
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE4:
|
||||
case GL_LUMINANCE8:
|
||||
case GL_LUMINANCE12:
|
||||
case GL_LUMINANCE16:
|
||||
case 2:
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
case GL_LUMINANCE4_ALPHA4:
|
||||
case GL_LUMINANCE6_ALPHA2:
|
||||
case GL_LUMINANCE8_ALPHA8:
|
||||
case GL_LUMINANCE12_ALPHA4:
|
||||
case GL_LUMINANCE12_ALPHA12:
|
||||
case GL_LUMINANCE16_ALPHA16:
|
||||
case GL_INTENSITY:
|
||||
case GL_INTENSITY4:
|
||||
case GL_INTENSITY8:
|
||||
case GL_INTENSITY12:
|
||||
case GL_INTENSITY16:
|
||||
case 3:
|
||||
case GL_RGB:
|
||||
case GL_BGR:
|
||||
case GL_R3_G3_B2:
|
||||
case GL_RGB4:
|
||||
case GL_RGB5:
|
||||
case GL_RGB8:
|
||||
case GL_RGB10:
|
||||
case GL_RGB12:
|
||||
case GL_RGB16:
|
||||
case 4:
|
||||
case GL_ABGR_EXT:
|
||||
case GL_RGBA:
|
||||
case GL_BGRA:
|
||||
case GL_RGBA2:
|
||||
case GL_RGBA4:
|
||||
case GL_RGB5_A1:
|
||||
case GL_RGBA8:
|
||||
case GL_RGB10_A2:
|
||||
case GL_RGBA12:
|
||||
case GL_RGBA16:
|
||||
/* float texture formats */
|
||||
case GL_ALPHA16F_ARB:
|
||||
case GL_ALPHA32F_ARB:
|
||||
case GL_LUMINANCE16F_ARB:
|
||||
case GL_LUMINANCE32F_ARB:
|
||||
case GL_LUMINANCE_ALPHA16F_ARB:
|
||||
case GL_LUMINANCE_ALPHA32F_ARB:
|
||||
case GL_INTENSITY16F_ARB:
|
||||
case GL_INTENSITY32F_ARB:
|
||||
case GL_RGB16F_ARB:
|
||||
case GL_RGB32F_ARB:
|
||||
case GL_RGBA16F_ARB:
|
||||
case GL_RGBA32F_ARB:
|
||||
/* compressed formats */
|
||||
case GL_COMPRESSED_ALPHA:
|
||||
case GL_COMPRESSED_LUMINANCE:
|
||||
case GL_COMPRESSED_LUMINANCE_ALPHA:
|
||||
case GL_COMPRESSED_INTENSITY:
|
||||
case GL_COMPRESSED_RGB:
|
||||
case GL_COMPRESSED_RGBA:
|
||||
case GL_RGB_S3TC:
|
||||
case GL_RGB4_S3TC:
|
||||
case GL_RGBA_S3TC:
|
||||
case GL_RGBA4_S3TC:
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_RGB_FXT1_3DFX:
|
||||
case GL_COMPRESSED_RGBA_FXT1_3DFX:
|
||||
#if FEATURE_EXT_texture_sRGB
|
||||
case GL_SRGB_EXT:
|
||||
case GL_SRGB8_EXT:
|
||||
case GL_SRGB_ALPHA_EXT:
|
||||
case GL_SRGB8_ALPHA8_EXT:
|
||||
case GL_SLUMINANCE_ALPHA_EXT:
|
||||
case GL_SLUMINANCE8_ALPHA8_EXT:
|
||||
case GL_SLUMINANCE_EXT:
|
||||
case GL_SLUMINANCE8_EXT:
|
||||
case GL_COMPRESSED_SRGB_EXT:
|
||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_SLUMINANCE_EXT:
|
||||
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
|
||||
#endif /* FEATURE_EXT_texture_sRGB */
|
||||
return GL_TRUE;
|
||||
/* signed texture formats */
|
||||
case GL_RGBA_SNORM:
|
||||
case GL_RGBA8_SNORM:
|
||||
return GL_TRUE;
|
||||
case GL_YCBCR_MESA: /* not considered to be RGB */
|
||||
/* fall-through */
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a color index format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_index_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_COLOR_INDEX:
|
||||
case GL_COLOR_INDEX1_EXT:
|
||||
case GL_COLOR_INDEX2_EXT:
|
||||
case GL_COLOR_INDEX4_EXT:
|
||||
case GL_COLOR_INDEX8_EXT:
|
||||
case GL_COLOR_INDEX12_EXT:
|
||||
case GL_COLOR_INDEX16_EXT:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a depth component format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_depth_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a YCbCr format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_ycbcr_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_YCBCR_MESA:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a depth+stencil format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_depthstencil_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given image format is a dudv format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_dudv_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DUDV_ATI:
|
||||
case GL_DU8DV8_ATI:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the address of a specific pixel in an image (1D, 2D or 3D).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -54,6 +54,24 @@ _mesa_bytes_per_pixel( GLenum format, GLenum type );
|
|||
extern GLboolean
|
||||
_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_color_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_index_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_depth_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_ycbcr_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_depthstencil_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_dudv_format(GLenum format);
|
||||
|
||||
|
||||
extern GLvoid *
|
||||
_mesa_image_address( GLuint dimensions,
|
||||
|
|
|
|||
|
|
@ -182,6 +182,8 @@ logbase2( int n )
|
|||
*
|
||||
* This is the format which is used during texture application (i.e. the
|
||||
* texture format and env mode determine the arithmetic used.
|
||||
*
|
||||
* XXX this could be static
|
||||
*/
|
||||
GLint
|
||||
_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
|
||||
|
|
@ -414,211 +416,6 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a color/RGBA format (i.e., not color
|
||||
* index, depth, stencil, etc).
|
||||
* \param format the image format value (may by an internal texture format)
|
||||
* \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
|
||||
* XXX maybe move this func to image.c
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_color_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_RED:
|
||||
case GL_GREEN:
|
||||
case GL_BLUE:
|
||||
case GL_ALPHA:
|
||||
case GL_ALPHA4:
|
||||
case GL_ALPHA8:
|
||||
case GL_ALPHA12:
|
||||
case GL_ALPHA16:
|
||||
case 1:
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE4:
|
||||
case GL_LUMINANCE8:
|
||||
case GL_LUMINANCE12:
|
||||
case GL_LUMINANCE16:
|
||||
case 2:
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
case GL_LUMINANCE4_ALPHA4:
|
||||
case GL_LUMINANCE6_ALPHA2:
|
||||
case GL_LUMINANCE8_ALPHA8:
|
||||
case GL_LUMINANCE12_ALPHA4:
|
||||
case GL_LUMINANCE12_ALPHA12:
|
||||
case GL_LUMINANCE16_ALPHA16:
|
||||
case GL_INTENSITY:
|
||||
case GL_INTENSITY4:
|
||||
case GL_INTENSITY8:
|
||||
case GL_INTENSITY12:
|
||||
case GL_INTENSITY16:
|
||||
case 3:
|
||||
case GL_RGB:
|
||||
case GL_BGR:
|
||||
case GL_R3_G3_B2:
|
||||
case GL_RGB4:
|
||||
case GL_RGB5:
|
||||
case GL_RGB8:
|
||||
case GL_RGB10:
|
||||
case GL_RGB12:
|
||||
case GL_RGB16:
|
||||
case 4:
|
||||
case GL_ABGR_EXT:
|
||||
case GL_RGBA:
|
||||
case GL_BGRA:
|
||||
case GL_RGBA2:
|
||||
case GL_RGBA4:
|
||||
case GL_RGB5_A1:
|
||||
case GL_RGBA8:
|
||||
case GL_RGB10_A2:
|
||||
case GL_RGBA12:
|
||||
case GL_RGBA16:
|
||||
/* float texture formats */
|
||||
case GL_ALPHA16F_ARB:
|
||||
case GL_ALPHA32F_ARB:
|
||||
case GL_LUMINANCE16F_ARB:
|
||||
case GL_LUMINANCE32F_ARB:
|
||||
case GL_LUMINANCE_ALPHA16F_ARB:
|
||||
case GL_LUMINANCE_ALPHA32F_ARB:
|
||||
case GL_INTENSITY16F_ARB:
|
||||
case GL_INTENSITY32F_ARB:
|
||||
case GL_RGB16F_ARB:
|
||||
case GL_RGB32F_ARB:
|
||||
case GL_RGBA16F_ARB:
|
||||
case GL_RGBA32F_ARB:
|
||||
/* compressed formats */
|
||||
case GL_COMPRESSED_ALPHA:
|
||||
case GL_COMPRESSED_LUMINANCE:
|
||||
case GL_COMPRESSED_LUMINANCE_ALPHA:
|
||||
case GL_COMPRESSED_INTENSITY:
|
||||
case GL_COMPRESSED_RGB:
|
||||
case GL_COMPRESSED_RGBA:
|
||||
case GL_RGB_S3TC:
|
||||
case GL_RGB4_S3TC:
|
||||
case GL_RGBA_S3TC:
|
||||
case GL_RGBA4_S3TC:
|
||||
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_RGB_FXT1_3DFX:
|
||||
case GL_COMPRESSED_RGBA_FXT1_3DFX:
|
||||
#if FEATURE_EXT_texture_sRGB
|
||||
case GL_SRGB_EXT:
|
||||
case GL_SRGB8_EXT:
|
||||
case GL_SRGB_ALPHA_EXT:
|
||||
case GL_SRGB8_ALPHA8_EXT:
|
||||
case GL_SLUMINANCE_ALPHA_EXT:
|
||||
case GL_SLUMINANCE8_ALPHA8_EXT:
|
||||
case GL_SLUMINANCE_EXT:
|
||||
case GL_SLUMINANCE8_EXT:
|
||||
case GL_COMPRESSED_SRGB_EXT:
|
||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_SLUMINANCE_EXT:
|
||||
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
|
||||
#endif /* FEATURE_EXT_texture_sRGB */
|
||||
return GL_TRUE;
|
||||
/* signed texture formats */
|
||||
case GL_RGBA_SNORM:
|
||||
case GL_RGBA8_SNORM:
|
||||
return GL_TRUE;
|
||||
case GL_YCBCR_MESA: /* not considered to be RGB */
|
||||
/* fall-through */
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a color index format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_index_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_COLOR_INDEX:
|
||||
case GL_COLOR_INDEX1_EXT:
|
||||
case GL_COLOR_INDEX2_EXT:
|
||||
case GL_COLOR_INDEX4_EXT:
|
||||
case GL_COLOR_INDEX8_EXT:
|
||||
case GL_COLOR_INDEX12_EXT:
|
||||
case GL_COLOR_INDEX16_EXT:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a depth component format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_depth_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DEPTH_COMPONENT16:
|
||||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
case GL_DEPTH_COMPONENT:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a YCbCr format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_ycbcr_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_YCBCR_MESA:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given image format is a Depth/Stencil format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_depthstencil_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given image format is a dudv format.
|
||||
*/
|
||||
GLboolean
|
||||
_mesa_is_dudv_format(GLenum format)
|
||||
{
|
||||
switch (format) {
|
||||
case GL_DUDV_ATI:
|
||||
case GL_DU8DV8_ATI:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if it is a supported compressed format.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -115,25 +115,6 @@ extern GLuint
|
|||
_mesa_tex_target_to_face(GLenum target);
|
||||
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_color_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_index_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_depth_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_ycbcr_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_depthstencil_format(GLenum format);
|
||||
|
||||
extern GLboolean
|
||||
_mesa_is_dudv_format(GLenum format);
|
||||
|
||||
|
||||
/**
|
||||
* Lock a texture for updating. See also _mesa_lock_context_textures().
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue