diff options
author | Brian Paul <[email protected]> | 2009-04-15 09:51:38 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-04-15 09:51:38 -0600 |
commit | 66cdbf945a3ee75d7b8cba5135310a7ebec21289 (patch) | |
tree | 829221e03248173043453a30b6324fb3e88cbed8 | |
parent | 51b339af2e8b80575a24bb9146f031c9605180bb (diff) |
st: st_equal_formats() function to compare gallium/GL pixel formats
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 20 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 9e2d60c9269..d507e3e58dd 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -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; + } +} diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 3f5ac3201b1..7bbbe2d5704 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -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 */ |