2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 * Copyright (C) 2018 Advanced Micro Devices, Inc. All Rights Reserved.
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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
29 * Often used definitions and enums.
35 #include "util/macros.h"
38 * Enum for the OpenGL APIs we know about and may support.
40 * NOTE: This must match the api_enum table in
41 * src/mesa/main/get_hash_generator.py
45 API_OPENGL_COMPAT
, /* legacy / compatibility contexts */
49 API_OPENGL_LAST
= API_OPENGL_CORE
53 * An index for each type of texture object. These correspond to the GL
54 * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
55 * Note: the order is from highest priority to lowest priority.
59 TEXTURE_2D_MULTISAMPLE_INDEX
,
60 TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX
,
61 TEXTURE_CUBE_ARRAY_INDEX
,
63 TEXTURE_2D_ARRAY_INDEX
,
64 TEXTURE_1D_ARRAY_INDEX
,
65 TEXTURE_EXTERNAL_INDEX
,
75 * Remapped color logical operations
77 * With the exception of NVIDIA hardware, which consumes the OpenGL enumerants
78 * directly, everything wants this mapping of color logical operations.
80 * Fun fact: These values are just the bit-reverse of the low-nibble of the GL
81 * enumerant values (i.e., `GL_NOOP & 0x0f` is `b0101' while
82 * \c COLOR_LOGICOP_NOOP is `b1010`).
84 * Fun fact #2: These values are just an encoding of the operation as a table
85 * of bit values. The result of the logic op is:
87 * result_bit = (logic_op >> (2 * src_bit + dst_bit)) & 1
89 * For the GL enums, the result is:
91 * result_bit = logic_op & (1 << (2 * src_bit + dst_bit))
93 enum PACKED gl_logicop_mode
{
94 COLOR_LOGICOP_CLEAR
= 0,
95 COLOR_LOGICOP_NOR
= 1,
96 COLOR_LOGICOP_AND_INVERTED
= 2,
97 COLOR_LOGICOP_COPY_INVERTED
= 3,
98 COLOR_LOGICOP_AND_REVERSE
= 4,
99 COLOR_LOGICOP_INVERT
= 5,
100 COLOR_LOGICOP_XOR
= 6,
101 COLOR_LOGICOP_NAND
= 7,
102 COLOR_LOGICOP_AND
= 8,
103 COLOR_LOGICOP_EQUIV
= 9,
104 COLOR_LOGICOP_NOOP
= 10,
105 COLOR_LOGICOP_OR_INVERTED
= 11,
106 COLOR_LOGICOP_COPY
= 12,
107 COLOR_LOGICOP_OR_REVERSE
= 13,
108 COLOR_LOGICOP_OR
= 14,
109 COLOR_LOGICOP_SET
= 15
113 * Indexes for all renderbuffers
117 /* the four standard color buffers */
125 /* optional aux buffer */
127 /* generic renderbuffers */
145 } gl_map_buffer_index
;
149 * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
150 * to small enums suitable for use as an array index.
153 enum mesa_debug_source
155 MESA_DEBUG_SOURCE_API
,
156 MESA_DEBUG_SOURCE_WINDOW_SYSTEM
,
157 MESA_DEBUG_SOURCE_SHADER_COMPILER
,
158 MESA_DEBUG_SOURCE_THIRD_PARTY
,
159 MESA_DEBUG_SOURCE_APPLICATION
,
160 MESA_DEBUG_SOURCE_OTHER
,
161 MESA_DEBUG_SOURCE_COUNT
166 MESA_DEBUG_TYPE_ERROR
,
167 MESA_DEBUG_TYPE_DEPRECATED
,
168 MESA_DEBUG_TYPE_UNDEFINED
,
169 MESA_DEBUG_TYPE_PORTABILITY
,
170 MESA_DEBUG_TYPE_PERFORMANCE
,
171 MESA_DEBUG_TYPE_OTHER
,
172 MESA_DEBUG_TYPE_MARKER
,
173 MESA_DEBUG_TYPE_PUSH_GROUP
,
174 MESA_DEBUG_TYPE_POP_GROUP
,
175 MESA_DEBUG_TYPE_COUNT
178 enum mesa_debug_severity
180 MESA_DEBUG_SEVERITY_LOW
,
181 MESA_DEBUG_SEVERITY_MEDIUM
,
182 MESA_DEBUG_SEVERITY_HIGH
,
183 MESA_DEBUG_SEVERITY_NOTIFICATION
,
184 MESA_DEBUG_SEVERITY_COUNT
189 /** Set a single bit */
190 #define BITFIELD_BIT(b) (1u << (b))
191 /** Set all bits up to excluding bit b */
192 #define BITFIELD_MASK(b) \
193 ((b) == 32 ? (~0u) : BITFIELD_BIT((b) % 32) - 1)
194 /** Set count bits starting from bit b */
195 #define BITFIELD_RANGE(b, count) \
196 (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))
200 * \name 64-bit extension of GLbitfield.
204 /** Set a single bit */
205 #define BITFIELD64_BIT(b) (1ull << (b))
206 /** Set all bits up to excluding bit b */
207 #define BITFIELD64_MASK(b) \
208 ((b) == 64 ? (~0ull) : BITFIELD64_BIT(b) - 1)
209 /** Set count bits starting from bit b */
210 #define BITFIELD64_RANGE(b, count) \
211 (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))