2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (c) 2008-2009 VMware, Inc.
6 * Copyright (c) 2012 Intel Corporation
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "glformats.h"
32 * Test if the given format is an integer (non-normalized) format.
35 _mesa_is_enum_format_integer(GLenum format
)
38 /* generic integer formats */
39 case GL_RED_INTEGER_EXT
:
40 case GL_GREEN_INTEGER_EXT
:
41 case GL_BLUE_INTEGER_EXT
:
42 case GL_ALPHA_INTEGER_EXT
:
43 case GL_RGB_INTEGER_EXT
:
44 case GL_RGBA_INTEGER_EXT
:
45 case GL_BGR_INTEGER_EXT
:
46 case GL_BGRA_INTEGER_EXT
:
47 case GL_LUMINANCE_INTEGER_EXT
:
48 case GL_LUMINANCE_ALPHA_INTEGER_EXT
:
50 /* specific integer formats */
55 case GL_ALPHA32UI_EXT
:
56 case GL_INTENSITY32UI_EXT
:
57 case GL_LUMINANCE32UI_EXT
:
58 case GL_LUMINANCE_ALPHA32UI_EXT
:
63 case GL_ALPHA16UI_EXT
:
64 case GL_INTENSITY16UI_EXT
:
65 case GL_LUMINANCE16UI_EXT
:
66 case GL_LUMINANCE_ALPHA16UI_EXT
:
72 case GL_INTENSITY8UI_EXT
:
73 case GL_LUMINANCE8UI_EXT
:
74 case GL_LUMINANCE_ALPHA8UI_EXT
:
80 case GL_INTENSITY32I_EXT
:
81 case GL_LUMINANCE32I_EXT
:
82 case GL_LUMINANCE_ALPHA32I_EXT
:
88 case GL_INTENSITY16I_EXT
:
89 case GL_LUMINANCE16I_EXT
:
90 case GL_LUMINANCE_ALPHA16I_EXT
:
96 case GL_INTENSITY8I_EXT
:
97 case GL_LUMINANCE8I_EXT
:
98 case GL_LUMINANCE_ALPHA8I_EXT
:
108 * Test if the given type is an integer (non-normalized) format.
111 _mesa_is_type_integer(GLenum type
)
115 case GL_UNSIGNED_INT
:
117 case GL_UNSIGNED_SHORT
:
119 case GL_UNSIGNED_BYTE
:
128 * Test if the given format or type is an integer (non-normalized) format.
131 _mesa_is_enum_format_or_type_integer(GLenum format
, GLenum type
)
133 return _mesa_is_enum_format_integer(format
) || _mesa_is_type_integer(type
);
138 _mesa_is_type_unsigned(GLenum type
)
141 case GL_UNSIGNED_INT
:
142 case GL_UNSIGNED_INT_8_8_8_8
:
143 case GL_UNSIGNED_INT_8_8_8_8_REV
:
144 case GL_UNSIGNED_INT_10_10_10_2
:
145 case GL_UNSIGNED_INT_2_10_10_10_REV
:
147 case GL_UNSIGNED_SHORT
:
148 case GL_UNSIGNED_SHORT_4_4_4_4
:
149 case GL_UNSIGNED_SHORT_5_5_5_1
:
150 case GL_UNSIGNED_SHORT_5_6_5
:
151 case GL_UNSIGNED_SHORT_5_6_5_REV
:
152 case GL_UNSIGNED_SHORT_4_4_4_4_REV
:
153 case GL_UNSIGNED_SHORT_1_5_5_5_REV
:
154 case GL_UNSIGNED_SHORT_8_8_MESA
:
155 case GL_UNSIGNED_SHORT_8_8_REV_MESA
:
157 case GL_UNSIGNED_BYTE
:
158 case GL_UNSIGNED_BYTE_3_3_2
:
159 case GL_UNSIGNED_BYTE_2_3_3_REV
:
169 * Convert various base formats to the cooresponding integer format.
172 _mesa_base_format_to_integer_format(GLenum format
)
176 return GL_RED_INTEGER
;
178 return GL_GREEN_INTEGER
;
180 return GL_BLUE_INTEGER
;
182 return GL_RG_INTEGER
;
184 return GL_RGB_INTEGER
;
186 return GL_RGBA_INTEGER
;
188 return GL_BGR_INTEGER
;
190 return GL_BGRA_INTEGER
;
192 return GL_ALPHA_INTEGER
;
194 return GL_LUMINANCE_INTEGER_EXT
;
195 case GL_LUMINANCE_ALPHA
:
196 return GL_LUMINANCE_ALPHA_INTEGER_EXT
;