aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/glformats.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/glformats.c')
-rw-r--r--mesalib/src/mesa/main/glformats.c83
1 files changed, 68 insertions, 15 deletions
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index f33a0503d..ff56ffad0 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -271,7 +271,8 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
- format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+ format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT ||
+ format == GL_RGB)
return sizeof(GLuint);
else
return -1;
@@ -353,21 +354,9 @@ _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type)
* Test if the given format is an integer (non-normalized) format.
*/
GLboolean
-_mesa_is_enum_format_integer(GLenum format)
+_mesa_is_enum_format_unsigned_int(GLenum format)
{
switch (format) {
- /* generic integer formats */
- case GL_RED_INTEGER_EXT:
- case GL_GREEN_INTEGER_EXT:
- case GL_BLUE_INTEGER_EXT:
- case GL_ALPHA_INTEGER_EXT:
- case GL_RGB_INTEGER_EXT:
- case GL_RGBA_INTEGER_EXT:
- case GL_BGR_INTEGER_EXT:
- case GL_BGRA_INTEGER_EXT:
- case GL_LUMINANCE_INTEGER_EXT:
- case GL_LUMINANCE_ALPHA_INTEGER_EXT:
- case GL_RG_INTEGER:
/* specific integer formats */
case GL_RGBA32UI_EXT:
case GL_RGB32UI_EXT:
@@ -393,6 +382,34 @@ _mesa_is_enum_format_integer(GLenum format)
case GL_INTENSITY8UI_EXT:
case GL_LUMINANCE8UI_EXT:
case GL_LUMINANCE_ALPHA8UI_EXT:
+ case GL_RGB10_A2UI:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_signed_int(GLenum format)
+{
+ switch (format) {
+ /* generic integer formats */
+ case GL_RED_INTEGER_EXT:
+ case GL_GREEN_INTEGER_EXT:
+ case GL_BLUE_INTEGER_EXT:
+ case GL_ALPHA_INTEGER_EXT:
+ case GL_RGB_INTEGER_EXT:
+ case GL_RGBA_INTEGER_EXT:
+ case GL_BGR_INTEGER_EXT:
+ case GL_BGRA_INTEGER_EXT:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ case GL_RG_INTEGER:
+ /* specific integer formats */
case GL_RGBA32I_EXT:
case GL_RGB32I_EXT:
case GL_RG32I:
@@ -417,7 +434,6 @@ _mesa_is_enum_format_integer(GLenum format)
case GL_INTENSITY8I_EXT:
case GL_LUMINANCE8I_EXT:
case GL_LUMINANCE_ALPHA8I_EXT:
- case GL_RGB10_A2UI:
return GL_TRUE;
default:
return GL_FALSE;
@@ -426,6 +442,17 @@ _mesa_is_enum_format_integer(GLenum format)
/**
+ * Test if the given format is an integer (non-normalized) format.
+ */
+GLboolean
+_mesa_is_enum_format_integer(GLenum format)
+{
+ return _mesa_is_enum_format_unsigned_int(format) ||
+ _mesa_is_enum_format_signed_int(format);
+}
+
+
+/**
* Test if the given type is an integer (non-normalized) format.
*/
GLboolean
@@ -1032,6 +1059,32 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname)
/**
+ * Returns the number of channels/components for a base format.
+ */
+GLint
+_mesa_base_format_component_count(GLenum base_format)
+{
+ switch (base_format) {
+ case GL_RED:
+ case GL_ALPHA:
+ case GL_INTENSITY:
+ case GL_DEPTH_COMPONENT:
+ return 1;
+ case GL_RG:
+ case GL_LUMINANCE_ALPHA:
+ case GL_DEPTH_STENCIL:
+ return 2;
+ case GL_RGB:
+ return 3;
+ case GL_RGBA:
+ return 4;
+ default:
+ return -1;
+ }
+}
+
+
+/**
* If format is a generic compressed format, return the corresponding
* non-compressed format. For other formats, return the format as-is.
*/