xref: /aosp_15_r20/external/mesa3d/src/mesa/main/menums.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Mesa 3-D graphics library
3  *
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.
7  *
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:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
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.
25  */
26 
27 /**
28  * \file menums.h
29  * Often used definitions and enums.
30  */
31 
32 #ifndef MENUMS_H
33 #define MENUMS_H
34 
35 #include <stdbool.h>
36 #include "util/macros.h"
37 
38 /**
39  * Enum for the OpenGL APIs we know about and may support.
40  *
41  * NOTE: This must match the api_enum table in
42  * src/mesa/main/get_hash_generator.py
43  */
44 typedef enum
45 {
46    API_OPENGL_COMPAT,      /* legacy / compatibility contexts */
47    API_OPENGLES,
48    API_OPENGLES2,
49    API_OPENGL_CORE,
50    API_OPENGL_LAST = API_OPENGL_CORE
51 } gl_api;
52 
53 /**
54  * Checks if the api is for GLES 2.0 or later
55  */
56 static inline bool
_mesa_is_api_gles2(gl_api api)57 _mesa_is_api_gles2(gl_api api)
58 {
59 #if HAVE_OPENGL_ES_2
60    return api == API_OPENGLES2;
61 #else
62    return false;
63 #endif
64 }
65 
66 /**
67  * An index for each type of texture object.  These correspond to the GL
68  * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
69  * Note: the order is from highest priority to lowest priority.
70  */
71 typedef enum
72 {
73    TEXTURE_2D_MULTISAMPLE_INDEX,
74    TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX,
75    TEXTURE_CUBE_ARRAY_INDEX,
76    TEXTURE_BUFFER_INDEX,
77    TEXTURE_2D_ARRAY_INDEX,
78    TEXTURE_1D_ARRAY_INDEX,
79    TEXTURE_EXTERNAL_INDEX,
80    TEXTURE_CUBE_INDEX,
81    TEXTURE_3D_INDEX,
82    TEXTURE_RECT_INDEX,
83    TEXTURE_2D_INDEX,
84    TEXTURE_1D_INDEX,
85    NUM_TEXTURE_TARGETS
86 } gl_texture_index;
87 
88 /**
89  * Remapped color logical operations
90  *
91  * With the exception of NVIDIA hardware, which consumes the OpenGL enumerants
92  * directly, everything wants this mapping of color logical operations.
93  *
94  * Fun fact: These values are just the bit-reverse of the low-nibble of the GL
95  * enumerant values (i.e., `GL_NOOP & 0x0f` is `b0101' while
96  * \c COLOR_LOGICOP_NOOP is `b1010`).
97  *
98  * Fun fact #2: These values are just an encoding of the operation as a table
99  * of bit values. The result of the logic op is:
100  *
101  *    result_bit = (logic_op >> (2 * src_bit + dst_bit)) & 1
102  *
103  * For the GL enums, the result is:
104  *
105  *    result_bit = logic_op & (1 << (2 * src_bit + dst_bit))
106  */
107 enum ENUM_PACKED gl_logicop_mode {
108    COLOR_LOGICOP_CLEAR = 0,
109    COLOR_LOGICOP_NOR = 1,
110    COLOR_LOGICOP_AND_INVERTED = 2,
111    COLOR_LOGICOP_COPY_INVERTED = 3,
112    COLOR_LOGICOP_AND_REVERSE = 4,
113    COLOR_LOGICOP_INVERT = 5,
114    COLOR_LOGICOP_XOR = 6,
115    COLOR_LOGICOP_NAND = 7,
116    COLOR_LOGICOP_AND = 8,
117    COLOR_LOGICOP_EQUIV = 9,
118    COLOR_LOGICOP_NOOP = 10,
119    COLOR_LOGICOP_OR_INVERTED = 11,
120    COLOR_LOGICOP_COPY = 12,
121    COLOR_LOGICOP_OR_REVERSE = 13,
122    COLOR_LOGICOP_OR = 14,
123    COLOR_LOGICOP_SET = 15
124 };
125 
126 /**
127  * Indexes for all renderbuffers
128  */
129 typedef enum
130 {
131    /* the four standard color buffers */
132    BUFFER_FRONT_LEFT,
133    BUFFER_BACK_LEFT,
134    BUFFER_FRONT_RIGHT,
135    BUFFER_BACK_RIGHT,
136    BUFFER_DEPTH,
137    BUFFER_STENCIL,
138    BUFFER_ACCUM,
139    /* generic renderbuffers */
140    BUFFER_COLOR0,
141    BUFFER_COLOR1,
142    BUFFER_COLOR2,
143    BUFFER_COLOR3,
144    BUFFER_COLOR4,
145    BUFFER_COLOR5,
146    BUFFER_COLOR6,
147    BUFFER_COLOR7,
148    BUFFER_COUNT,
149    BUFFER_NONE = -1,
150 } gl_buffer_index;
151 
152 typedef enum
153 {
154    MAP_USER,
155    MAP_INTERNAL,
156    MAP_GLTHREAD,
157    MAP_COUNT
158 } gl_map_buffer_index;
159 
160 /** @{
161  *
162  * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
163  * to small enums suitable for use as an array index.
164  */
165 
166 enum mesa_debug_source
167 {
168    MESA_DEBUG_SOURCE_API,
169    MESA_DEBUG_SOURCE_WINDOW_SYSTEM,
170    MESA_DEBUG_SOURCE_SHADER_COMPILER,
171    MESA_DEBUG_SOURCE_THIRD_PARTY,
172    MESA_DEBUG_SOURCE_APPLICATION,
173    MESA_DEBUG_SOURCE_OTHER,
174    MESA_DEBUG_SOURCE_COUNT
175 };
176 
177 enum mesa_debug_type
178 {
179    MESA_DEBUG_TYPE_ERROR,
180    MESA_DEBUG_TYPE_DEPRECATED,
181    MESA_DEBUG_TYPE_UNDEFINED,
182    MESA_DEBUG_TYPE_PORTABILITY,
183    MESA_DEBUG_TYPE_PERFORMANCE,
184    MESA_DEBUG_TYPE_OTHER,
185    MESA_DEBUG_TYPE_MARKER,
186    MESA_DEBUG_TYPE_PUSH_GROUP,
187    MESA_DEBUG_TYPE_POP_GROUP,
188    MESA_DEBUG_TYPE_COUNT
189 };
190 
191 enum mesa_debug_severity
192 {
193    MESA_DEBUG_SEVERITY_LOW,
194    MESA_DEBUG_SEVERITY_MEDIUM,
195    MESA_DEBUG_SEVERITY_HIGH,
196    MESA_DEBUG_SEVERITY_NOTIFICATION,
197    MESA_DEBUG_SEVERITY_COUNT
198 };
199 
200 /** @} */
201 
202 #endif
203