st: st_equal_formats() function to compare gallium/GL pixel formats

This commit is contained in:
Brian Paul
2009-04-15 09:51:38 -06:00
parent 51b339af2e
commit 66cdbf945a
2 changed files with 24 additions and 0 deletions
+20
View File
@@ -716,3 +716,23 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
return translate_gallium_format_to_mesa_format(pFormat);
}
/**
* Test if a gallium format is equivalent to a GL format/type.
*/
GLboolean
st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type)
{
switch (pFormat) {
case PIPE_FORMAT_R8G8B8A8_UNORM:
return format == GL_RGBA && type == GL_UNSIGNED_BYTE;
case PIPE_FORMAT_B8G8R8A8_UNORM:
return format == GL_BGRA && type == GL_UNSIGNED_BYTE;
case PIPE_FORMAT_R5G6B5_UNORM:
return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5;
/* XXX more combos... */
default:
return GL_FALSE;
}
}
+4
View File
@@ -76,4 +76,8 @@ st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
GLenum format, GLenum type);
extern GLboolean
st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type);
#endif /* ST_CB_TEXIMAGE_H */