summaryrefslogtreecommitdiff
path: root/src/mesa/main/formats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/formats.c')
-rw-r--r--src/mesa/main/formats.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 654ea038a5..88a04e888e 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -945,6 +945,7 @@ _mesa_get_format_bits(gl_format format, GLenum pname)
* GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
* GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
* GL_UNSIGNED_INT = an ordinary unsigned integer
+ * GL_INT = an ordinary signed integer
* GL_FLOAT = an ordinary float
*/
GLenum
@@ -1007,6 +1008,20 @@ _mesa_is_format_packed_depth_stencil(gl_format format)
/**
+ * Is the given format a signed/unsigned integer color format?
+ */
+GLboolean
+_mesa_is_format_integer_color(gl_format format)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return (info->DataType == GL_INT || info->DataType == GL_UNSIGNED_INT) &&
+ info->BaseFormat != GL_DEPTH_COMPONENT &&
+ info->BaseFormat != GL_DEPTH_STENCIL &&
+ info->BaseFormat != GL_STENCIL_INDEX;
+}
+
+
+/**
* Return color encoding for given format.
* \return GL_LINEAR or GL_SRGB
*/
@@ -1179,6 +1194,7 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_ARGB8888:
case MESA_FORMAT_ARGB8888_REV:
case MESA_FORMAT_XRGB8888:
+ case MESA_FORMAT_XRGB8888_REV:
*datatype = GL_UNSIGNED_BYTE;
*comps = 4;
return;
@@ -1205,6 +1221,11 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 4;
return;
+ case MESA_FORMAT_RGBA5551:
+ *datatype = GL_UNSIGNED_SHORT_5_5_5_1;
+ *comps = 4;
+ return;
+
case MESA_FORMAT_AL88:
case MESA_FORMAT_AL88_REV:
case MESA_FORMAT_RG88:
@@ -1236,6 +1257,7 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_I8:
case MESA_FORMAT_CI8:
case MESA_FORMAT_R8:
+ case MESA_FORMAT_S8:
*datatype = GL_UNSIGNED_BYTE;
*comps = 1;
return;
@@ -1281,12 +1303,26 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 2;
return;
+ case MESA_FORMAT_SIGNED_R8:
+ *datatype = GL_BYTE;
+ *comps = 1;
+ return;
+ case MESA_FORMAT_SIGNED_RG88:
+ *datatype = GL_BYTE;
+ *comps = 2;
+ return;
case MESA_FORMAT_SIGNED_RGBA8888:
case MESA_FORMAT_SIGNED_RGBA8888_REV:
+ case MESA_FORMAT_SIGNED_RGBX8888:
*datatype = GL_BYTE;
*comps = 4;
return;
+ case MESA_FORMAT_RGBA_16:
+ *datatype = GL_UNSIGNED_SHORT;
+ *comps = 4;
+ return;
+
case MESA_FORMAT_SIGNED_R_16:
*datatype = GL_SHORT;
*comps = 1;
@@ -1411,9 +1447,14 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 4;
return;
-
+ case MESA_FORMAT_NONE:
+ case MESA_FORMAT_COUNT:
+ /* For debug builds, warn if any formats are not handled */
+#ifndef DEBUG
default:
- _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
+#endif
+ _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps",
+ _mesa_get_format_name(format));
*datatype = 0;
*comps = 1;
}