Merge branch 'master' into blender2.8
[blender.git] / source / blender / gpu / intern / gpu_debug.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2005 Blender Foundation.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): Brecht Van Lommel, Jason Wilkins.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file source/blender/gpu/intern/gpu_debug.c
29  *  \ingroup gpu
30  */
31
32 #include "BLI_sys_types.h"
33
34 #include "BKE_global.h"
35
36 #include "GPU_glew.h"
37 #include "GPU_debug.h"
38 #include "intern/gpu_private.h"
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43
44 #define CASE_CODE_RETURN_STR(code) case code: return #code;
45
46 static const char *gpu_gl_error_symbol(GLenum err)
47 {
48         switch (err) {
49                 CASE_CODE_RETURN_STR(GL_NO_ERROR)
50                 CASE_CODE_RETURN_STR(GL_INVALID_ENUM)
51                 CASE_CODE_RETURN_STR(GL_INVALID_VALUE)
52                 CASE_CODE_RETURN_STR(GL_INVALID_OPERATION)
53                 CASE_CODE_RETURN_STR(GL_STACK_OVERFLOW)
54                 CASE_CODE_RETURN_STR(GL_STACK_UNDERFLOW)
55                 CASE_CODE_RETURN_STR(GL_OUT_OF_MEMORY)
56
57 #if GL_ARB_imaging
58                 CASE_CODE_RETURN_STR(GL_TABLE_TOO_LARGE)
59 #endif
60
61 #if defined(WITH_GLU)
62                 CASE_CODE_RETURN_STR(GLU_INVALID_ENUM)
63                 CASE_CODE_RETURN_STR(GLU_INVALID_VALUE)
64                 CASE_CODE_RETURN_STR(GLU_OUT_OF_MEMORY)
65 #endif
66
67                 default:
68                         return "<unknown error>";
69         }
70 }
71
72 #undef CASE_CODE_RETURN_STR
73
74
75 static bool gpu_report_gl_errors(const char *file, int line, const char *str)
76 {
77         GLenum gl_error = glGetError();
78
79         if (gl_error == GL_NO_ERROR) {
80                 return true;
81         }
82         else {
83                 /* glGetError should have cleared the error flag, so if we get the
84                  * same flag twice that means glGetError itself probably triggered
85                  * the error. This happens on Windows if the GL context is invalid.
86                  */
87                 {
88                         GLenum new_error = glGetError();
89                         if (gl_error == new_error) {
90                                 fprintf(stderr, "GL: Possible context invalidation issue\n");
91                                 return false;
92                         }
93                 }
94
95                 fprintf(stderr,
96                         "%s:%d: ``%s'' -> GL Error (0x%04X - %s): %s\n",
97                         file, line, str, gl_error,
98                         gpu_gl_error_symbol(gl_error),
99                         gpuErrorString(gl_error));
100
101                 return false;
102         }
103 }
104
105
106 const char *gpuErrorString(GLenum err)
107 {
108         switch (err) {
109                 case GL_NO_ERROR:
110                         return "No Error";
111
112                 case GL_INVALID_ENUM:
113                         return "Invalid Enumeration";
114
115                 case GL_INVALID_VALUE:
116                         return "Invalid Value";
117
118                 case GL_INVALID_OPERATION:
119                         return "Invalid Operation";
120
121                 case GL_STACK_OVERFLOW:
122                         return "Stack Overflow";
123
124                 case GL_STACK_UNDERFLOW:
125                         return "Stack Underflow";
126
127                 case GL_OUT_OF_MEMORY:
128                         return "Out of Memory";
129
130 #if GL_ARB_imaging
131                 case GL_TABLE_TOO_LARGE:
132                         return "Table Too Large";
133 #endif
134
135 #if defined(WITH_GLU)
136                 case GLU_INVALID_ENUM:
137                         return "Invalid Enum (GLU)";
138
139                 case GLU_INVALID_VALUE:
140                         return "Invalid Value (GLU)";
141
142                 case GLU_OUT_OF_MEMORY:
143                         return "Out of Memory (GLU)";
144 #endif
145
146                 default:
147                         return "<unknown error>";
148         }
149 }
150
151
152 /* Debug callbacks need the same calling convention as OpenGL functions.
153  */
154 #if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
155     /* Win32 but not WinCE */
156 #   define APIENTRY __stdcall
157 #else
158 #   define APIENTRY
159 #endif
160
161
162 static void APIENTRY gpu_debug_proc(
163         GLenum source, GLenum type, GLuint UNUSED(id),
164         GLenum UNUSED(severity), GLsizei UNUSED(length),
165         const GLchar *message, const GLvoid *UNUSED(userParm))
166 {
167         if (source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) {
168                 fprintf(stderr, "GL: %s\n", message);
169                 fflush(stderr);
170         }
171         else if (G.debug_value == 20) {
172                 fprintf(stderr, "GL: %s\n", message);
173                 fflush(stderr);
174         }
175 }
176
177
178 #ifndef GLEW_ES_ONLY
179 static void APIENTRY gpu_debug_proc_amd(
180         GLuint UNUSED(id), GLenum UNUSED(category),
181         GLenum UNUSED(severity), GLsizei UNUSED(length),
182         const GLchar *message,  GLvoid *UNUSED(userParm))
183 {
184         fprintf(stderr, "GL: %s\n", message);
185 }
186 #endif
187
188
189 #undef APIENTRY
190
191 void gpu_debug_init(void)
192 {
193         const char success[] = "Successfully hooked OpenGL debug callback.";
194
195 #if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY)
196         if (GLEW_VERSION_4_3) {
197                 glEnable(GL_DEBUG_OUTPUT);
198                 glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
199                 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
200                 GPU_string_marker(sizeof(success), success);
201                 return;
202         }
203 #endif
204
205         if (GLEW_KHR_debug) {
206 #ifndef GLEW_ES_ONLY
207                 glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
208                 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
209                 GPU_string_marker(sizeof(success), success);
210 #endif
211                 return;
212         }
213
214 #ifndef GLEW_ES_ONLY
215         if (GLEW_ARB_debug_output) {
216                 glDebugMessageCallbackARB((GLDEBUGPROCARB)gpu_debug_proc, mxGetCurrentContext());
217                 glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
218                 GPU_string_marker(sizeof(success), success);
219
220                 return;
221         }
222
223         if (GLEW_AMD_debug_output) {
224                 glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext());
225                 glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
226                 GPU_string_marker(sizeof(success), success);
227
228                 return;
229         }
230 #endif
231
232         fprintf(stderr, "Failed to hook OpenGL debug callback.\n");
233
234         return;
235 }
236
237
238 void gpu_debug_exit(void)
239 {
240 #ifndef WITH_GLEW_ES
241 #ifndef GLEW_ES_ONLY
242         if (GLEW_VERSION_4_3) {
243                 glDebugMessageCallback(NULL, NULL);
244
245                 return;
246         }
247 #endif
248 #endif
249
250         if (GLEW_KHR_debug) {
251 #ifndef GLEW_ES_ONLY
252                 glDebugMessageCallback(NULL, NULL);
253 #endif
254                 return;
255         }
256
257 #ifndef GLEW_ES_ONLY
258         if (GLEW_ARB_debug_output) {
259                 glDebugMessageCallbackARB(NULL, NULL);
260
261                 return;
262         }
263
264         if (GLEW_AMD_debug_output) {
265                 glDebugMessageCallbackAMD(NULL, NULL);
266
267                 return;
268         }
269 #endif
270
271         return;
272 }
273
274 void GPU_string_marker(size_t length, const char *buf)
275 {
276 #ifndef WITH_GLEW_ES
277 #ifndef GLEW_ES_ONLY
278         if (GLEW_VERSION_4_3) {
279                 glDebugMessageInsert(
280                         GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
281                         GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
282
283                 return;
284         }
285 #endif
286 #endif
287
288         if (GLEW_KHR_debug) {
289 #ifndef GLEW_ES_ONLY
290                 glDebugMessageInsert(
291                         GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
292                         GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
293 #endif
294                 return;
295         }
296
297 #ifndef GLEW_ES_ONLY
298         if (GLEW_ARB_debug_output) {
299                 glDebugMessageInsertARB(
300                         GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0,
301                         GL_DEBUG_SEVERITY_LOW_ARB, length, buf);
302
303                 return;
304         }
305
306         if (GLEW_AMD_debug_output) {
307                 glDebugMessageInsertAMD(
308                         GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0,
309                         length, buf);
310
311                 return;
312         }
313
314         if (GLEW_GREMEDY_string_marker) {
315                 glStringMarkerGREMEDY(length, buf);
316
317                 return;
318         }
319 #endif
320
321         return;
322 }
323
324 void GPU_print_error_debug(const char *str)
325 {
326         if (G.debug & G_DEBUG)
327                 fprintf(stderr, "GPU: %s\n", str);
328 }
329
330
331 void GPU_assert_no_gl_errors(const char *file, int line, const char *str)
332 {
333         if (G.debug) {
334                 GLboolean gl_ok = gpu_report_gl_errors(file, line, str);
335
336                 BLI_assert(gl_ok);
337                 (void) gl_ok;
338         }
339 }
340
341
342 static void gpu_state_print_fl_ex(const char *name, GLenum type)
343 {
344         const unsigned char err_mark[4] = {0xff, 0xff, 0xff, 0xff};
345
346         float value[32];
347         int a;
348
349         memset(value, 0xff, sizeof(value));
350         glGetFloatv(type, value);
351
352         if (glGetError() == GL_NO_ERROR) {
353                 printf("%s: ", name);
354                 for (a = 0; a < 32; a++) {
355                         if (memcmp(&value[a], err_mark, sizeof(value[a])) == 0) {
356                                 break;
357                         }
358                         printf("%.2f ", value[a]);
359                 }
360                 printf("\n");
361         }
362 }
363
364 #define gpu_state_print_fl(val) gpu_state_print_fl_ex(#val, val)
365
366 void GPU_state_print(void)
367 {
368         GPU_ASSERT_NO_GL_ERRORS("GPU_state_print"); /* clear any errors */
369
370         gpu_state_print_fl(GL_ACCUM_ALPHA_BITS);
371         gpu_state_print_fl(GL_ACCUM_BLUE_BITS);
372         gpu_state_print_fl(GL_ACCUM_CLEAR_VALUE);
373         gpu_state_print_fl(GL_ACCUM_GREEN_BITS);
374         gpu_state_print_fl(GL_ACCUM_RED_BITS);
375         gpu_state_print_fl(GL_ACTIVE_TEXTURE);
376         gpu_state_print_fl(GL_ALIASED_LINE_WIDTH_RANGE);
377         gpu_state_print_fl(GL_ALIASED_POINT_SIZE_RANGE);
378         gpu_state_print_fl(GL_ALPHA_BIAS);
379         gpu_state_print_fl(GL_ALPHA_BITS);
380         gpu_state_print_fl(GL_ALPHA_SCALE);
381         gpu_state_print_fl(GL_ALPHA_TEST);
382         gpu_state_print_fl(GL_ALPHA_TEST_FUNC);
383         gpu_state_print_fl(GL_ALPHA_TEST_REF);
384         gpu_state_print_fl(GL_ARRAY_BUFFER_BINDING);
385         gpu_state_print_fl(GL_ATTRIB_STACK_DEPTH);
386         gpu_state_print_fl(GL_AUTO_NORMAL);
387         gpu_state_print_fl(GL_AUX_BUFFERS);
388         gpu_state_print_fl(GL_BLEND);
389         gpu_state_print_fl(GL_BLEND_COLOR);
390         gpu_state_print_fl(GL_BLEND_DST_ALPHA);
391         gpu_state_print_fl(GL_BLEND_DST_RGB);
392         gpu_state_print_fl(GL_BLEND_EQUATION_ALPHA);
393         gpu_state_print_fl(GL_BLEND_EQUATION_RGB);
394         gpu_state_print_fl(GL_BLEND_SRC_ALPHA);
395         gpu_state_print_fl(GL_BLEND_SRC_RGB);
396         gpu_state_print_fl(GL_BLUE_BIAS);
397         gpu_state_print_fl(GL_BLUE_BITS);
398         gpu_state_print_fl(GL_BLUE_SCALE);
399         gpu_state_print_fl(GL_CLIENT_ACTIVE_TEXTURE);
400         gpu_state_print_fl(GL_CLIENT_ATTRIB_STACK_DEPTH);
401         gpu_state_print_fl(GL_CLIP_PLANE0);
402         gpu_state_print_fl(GL_COLOR_ARRAY);
403         gpu_state_print_fl(GL_COLOR_ARRAY_BUFFER_BINDING);
404         gpu_state_print_fl(GL_COLOR_ARRAY_SIZE);
405         gpu_state_print_fl(GL_COLOR_ARRAY_STRIDE);
406         gpu_state_print_fl(GL_COLOR_ARRAY_TYPE);
407         gpu_state_print_fl(GL_COLOR_CLEAR_VALUE);
408         gpu_state_print_fl(GL_COLOR_LOGIC_OP);
409         gpu_state_print_fl(GL_COLOR_MATERIAL);
410         gpu_state_print_fl(GL_COLOR_MATERIAL_FACE);
411         gpu_state_print_fl(GL_COLOR_MATERIAL_PARAMETER);
412         gpu_state_print_fl(GL_COLOR_MATRIX);
413         gpu_state_print_fl(GL_COLOR_MATRIX_STACK_DEPTH);
414         gpu_state_print_fl(GL_COLOR_SUM);
415         gpu_state_print_fl(GL_COLOR_TABLE);
416         gpu_state_print_fl(GL_COLOR_WRITEMASK);
417         gpu_state_print_fl(GL_COMPRESSED_TEXTURE_FORMATS);
418         gpu_state_print_fl(GL_CONVOLUTION_1D);
419         gpu_state_print_fl(GL_CONVOLUTION_2D);
420         gpu_state_print_fl(GL_CULL_FACE);
421         gpu_state_print_fl(GL_CULL_FACE_MODE);
422         gpu_state_print_fl(GL_CURRENT_COLOR);
423         gpu_state_print_fl(GL_CURRENT_FOG_COORD);
424         gpu_state_print_fl(GL_CURRENT_INDEX);
425         gpu_state_print_fl(GL_CURRENT_NORMAL);
426         gpu_state_print_fl(GL_CURRENT_PROGRAM);
427         gpu_state_print_fl(GL_CURRENT_RASTER_COLOR);
428         gpu_state_print_fl(GL_CURRENT_RASTER_DISTANCE);
429         gpu_state_print_fl(GL_CURRENT_RASTER_INDEX);
430         gpu_state_print_fl(GL_CURRENT_RASTER_POSITION);
431         gpu_state_print_fl(GL_CURRENT_RASTER_POSITION_VALID);
432         gpu_state_print_fl(GL_CURRENT_RASTER_SECONDARY_COLOR);
433         gpu_state_print_fl(GL_CURRENT_RASTER_TEXTURE_COORDS);
434         gpu_state_print_fl(GL_CURRENT_SECONDARY_COLOR);
435         gpu_state_print_fl(GL_CURRENT_TEXTURE_COORDS);
436         gpu_state_print_fl(GL_DEPTH_BIAS);
437         gpu_state_print_fl(GL_DEPTH_BITS);
438         gpu_state_print_fl(GL_DEPTH_CLEAR_VALUE);
439         gpu_state_print_fl(GL_DEPTH_FUNC);
440         gpu_state_print_fl(GL_DEPTH_RANGE);
441         gpu_state_print_fl(GL_DEPTH_SCALE);
442         gpu_state_print_fl(GL_DEPTH_TEST);
443         gpu_state_print_fl(GL_DEPTH_WRITEMASK);
444         gpu_state_print_fl(GL_DITHER);
445         gpu_state_print_fl(GL_DOUBLEBUFFER);
446         gpu_state_print_fl(GL_DRAW_BUFFER);
447         gpu_state_print_fl(GL_DRAW_BUFFER0);
448         gpu_state_print_fl(GL_EDGE_FLAG);
449         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY);
450         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_BUFFER_BINDING);
451         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_STRIDE);
452         gpu_state_print_fl(GL_ELEMENT_ARRAY_BUFFER_BINDING);
453         gpu_state_print_fl(GL_FEEDBACK_BUFFER_SIZE);
454         gpu_state_print_fl(GL_FEEDBACK_BUFFER_TYPE);
455         gpu_state_print_fl(GL_FOG);
456         gpu_state_print_fl(GL_FOG_COLOR);
457         gpu_state_print_fl(GL_FOG_COORD_ARRAY);
458         gpu_state_print_fl(GL_FOG_COORD_ARRAY_BUFFER_BINDING);
459         gpu_state_print_fl(GL_FOG_COORD_ARRAY_STRIDE);
460         gpu_state_print_fl(GL_FOG_COORD_ARRAY_TYPE);
461         gpu_state_print_fl(GL_FOG_COORD_SRC);
462         gpu_state_print_fl(GL_FOG_DENSITY);
463         gpu_state_print_fl(GL_FOG_END);
464         gpu_state_print_fl(GL_FOG_HINT);
465         gpu_state_print_fl(GL_FOG_INDEX);
466         gpu_state_print_fl(GL_FOG_MODE);
467         gpu_state_print_fl(GL_FOG_START);
468         gpu_state_print_fl(GL_FRAGMENT_PROGRAM_ARB); /* TODO: remove ARB program support */
469         gpu_state_print_fl(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
470         gpu_state_print_fl(GL_FRONT_FACE);
471         gpu_state_print_fl(GL_GENERATE_MIPMAP_HINT);
472         gpu_state_print_fl(GL_GREEN_BIAS);
473         gpu_state_print_fl(GL_GREEN_BITS);
474         gpu_state_print_fl(GL_GREEN_SCALE);
475         gpu_state_print_fl(GL_HISTOGRAM);
476         gpu_state_print_fl(GL_INDEX_ARRAY);
477         gpu_state_print_fl(GL_INDEX_ARRAY_BUFFER_BINDING);
478         gpu_state_print_fl(GL_INDEX_ARRAY_STRIDE);
479         gpu_state_print_fl(GL_INDEX_ARRAY_TYPE);
480         gpu_state_print_fl(GL_INDEX_BITS);
481         gpu_state_print_fl(GL_INDEX_CLEAR_VALUE);
482         gpu_state_print_fl(GL_INDEX_LOGIC_OP);
483         gpu_state_print_fl(GL_INDEX_MODE);
484         gpu_state_print_fl(GL_INDEX_OFFSET);
485         gpu_state_print_fl(GL_INDEX_SHIFT);
486         gpu_state_print_fl(GL_INDEX_WRITEMASK);
487         gpu_state_print_fl(GL_LIGHT0);
488         gpu_state_print_fl(GL_LIGHT1);
489         gpu_state_print_fl(GL_LIGHT2);
490         gpu_state_print_fl(GL_LIGHT3);
491         gpu_state_print_fl(GL_LIGHT4);
492         gpu_state_print_fl(GL_LIGHT5);
493         gpu_state_print_fl(GL_LIGHT6);
494         gpu_state_print_fl(GL_LIGHT7);
495         gpu_state_print_fl(GL_LIGHTING);
496         gpu_state_print_fl(GL_LIGHT_MODEL_AMBIENT);
497         gpu_state_print_fl(GL_LIGHT_MODEL_COLOR_CONTROL);
498         gpu_state_print_fl(GL_LIGHT_MODEL_LOCAL_VIEWER);
499         gpu_state_print_fl(GL_LIGHT_MODEL_TWO_SIDE);
500         gpu_state_print_fl(GL_LINE_SMOOTH);
501         gpu_state_print_fl(GL_LINE_SMOOTH_HINT);
502         gpu_state_print_fl(GL_LINE_STIPPLE);
503         gpu_state_print_fl(GL_LINE_STIPPLE_PATTERN);
504         gpu_state_print_fl(GL_LINE_STIPPLE_REPEAT);
505         gpu_state_print_fl(GL_LINE_WIDTH);
506         gpu_state_print_fl(GL_LINE_WIDTH_GRANULARITY);
507         gpu_state_print_fl(GL_LINE_WIDTH_RANGE);
508         gpu_state_print_fl(GL_LIST_BASE);
509         gpu_state_print_fl(GL_LIST_INDEX);
510         gpu_state_print_fl(GL_LIST_MODE);
511         gpu_state_print_fl(GL_LOGIC_OP);
512         gpu_state_print_fl(GL_LOGIC_OP_MODE);
513         gpu_state_print_fl(GL_MAP1_COLOR_4);
514         gpu_state_print_fl(GL_MAP1_GRID_DOMAIN);
515         gpu_state_print_fl(GL_MAP1_GRID_SEGMENTS);
516         gpu_state_print_fl(GL_MAP1_INDEX);
517         gpu_state_print_fl(GL_MAP1_NORMAL);
518         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_1);
519         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_2);
520         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_3);
521         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_4);
522         gpu_state_print_fl(GL_MAP1_VERTEX_3);
523         gpu_state_print_fl(GL_MAP1_VERTEX_4);
524         gpu_state_print_fl(GL_MAP2_COLOR_4);
525         gpu_state_print_fl(GL_MAP2_GRID_DOMAIN);
526         gpu_state_print_fl(GL_MAP2_GRID_SEGMENTS);
527         gpu_state_print_fl(GL_MAP2_INDEX);
528         gpu_state_print_fl(GL_MAP2_NORMAL);
529         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_1);
530         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_2);
531         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_3);
532         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_4);
533         gpu_state_print_fl(GL_MAP2_VERTEX_3);
534         gpu_state_print_fl(GL_MAP2_VERTEX_4);
535         gpu_state_print_fl(GL_MAP_COLOR);
536         gpu_state_print_fl(GL_MAP_STENCIL);
537         gpu_state_print_fl(GL_MATRIX_MODE);
538         gpu_state_print_fl(GL_MAX_3D_TEXTURE_SIZE);
539         gpu_state_print_fl(GL_MAX_ATTRIB_STACK_DEPTH);
540         gpu_state_print_fl(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH);
541         gpu_state_print_fl(GL_MAX_CLIP_PLANES);
542         gpu_state_print_fl(GL_MAX_COLOR_MATRIX_STACK_DEPTH);
543         gpu_state_print_fl(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
544         gpu_state_print_fl(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
545         gpu_state_print_fl(GL_MAX_DRAW_BUFFERS);
546         gpu_state_print_fl(GL_MAX_ELEMENTS_INDICES);
547         gpu_state_print_fl(GL_MAX_ELEMENTS_VERTICES);
548         gpu_state_print_fl(GL_MAX_EVAL_ORDER);
549         gpu_state_print_fl(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
550         gpu_state_print_fl(GL_MAX_LIGHTS);
551         gpu_state_print_fl(GL_MAX_LIST_NESTING);
552         gpu_state_print_fl(GL_MAX_MODELVIEW_STACK_DEPTH);
553         gpu_state_print_fl(GL_MAX_NAME_STACK_DEPTH);
554         gpu_state_print_fl(GL_MAX_PIXEL_MAP_TABLE);
555         gpu_state_print_fl(GL_MAX_PROJECTION_STACK_DEPTH);
556         gpu_state_print_fl(GL_MAX_TEXTURE_COORDS);
557         gpu_state_print_fl(GL_MAX_TEXTURE_IMAGE_UNITS);
558         gpu_state_print_fl(GL_MAX_TEXTURE_LOD_BIAS);
559         gpu_state_print_fl(GL_MAX_TEXTURE_SIZE);
560         gpu_state_print_fl(GL_MAX_TEXTURE_STACK_DEPTH);
561         gpu_state_print_fl(GL_MAX_TEXTURE_UNITS);
562         gpu_state_print_fl(GL_MAX_VARYING_FLOATS);
563         gpu_state_print_fl(GL_MAX_VERTEX_ATTRIBS);
564         gpu_state_print_fl(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
565         gpu_state_print_fl(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
566         gpu_state_print_fl(GL_MAX_VIEWPORT_DIMS);
567         gpu_state_print_fl(GL_MINMAX);
568         gpu_state_print_fl(GL_MODELVIEW_MATRIX);
569         gpu_state_print_fl(GL_MODELVIEW_STACK_DEPTH);
570         gpu_state_print_fl(GL_MULTISAMPLE);
571         gpu_state_print_fl(GL_NAME_STACK_DEPTH);
572         gpu_state_print_fl(GL_NORMALIZE);
573         gpu_state_print_fl(GL_NORMAL_ARRAY);
574         gpu_state_print_fl(GL_NORMAL_ARRAY_BUFFER_BINDING);
575         gpu_state_print_fl(GL_NORMAL_ARRAY_STRIDE);
576         gpu_state_print_fl(GL_NORMAL_ARRAY_TYPE);
577         gpu_state_print_fl(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
578         gpu_state_print_fl(GL_PACK_ALIGNMENT);
579         gpu_state_print_fl(GL_PACK_IMAGE_HEIGHT);
580         gpu_state_print_fl(GL_PACK_LSB_FIRST);
581         gpu_state_print_fl(GL_PACK_ROW_LENGTH);
582         gpu_state_print_fl(GL_PACK_SKIP_IMAGES);
583         gpu_state_print_fl(GL_PACK_SKIP_PIXELS);
584         gpu_state_print_fl(GL_PACK_SKIP_ROWS);
585         gpu_state_print_fl(GL_PACK_SWAP_BYTES);
586         gpu_state_print_fl(GL_PERSPECTIVE_CORRECTION_HINT);
587         gpu_state_print_fl(GL_PIXEL_MAP_A_TO_A_SIZE);
588         gpu_state_print_fl(GL_PIXEL_MAP_B_TO_B_SIZE);
589         gpu_state_print_fl(GL_PIXEL_MAP_G_TO_G_SIZE);
590         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_A_SIZE);
591         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_B_SIZE);
592         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_G_SIZE);
593         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_I_SIZE);
594         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_R_SIZE);
595         gpu_state_print_fl(GL_PIXEL_MAP_R_TO_R_SIZE);
596         gpu_state_print_fl(GL_PIXEL_MAP_S_TO_S_SIZE);
597         gpu_state_print_fl(GL_PIXEL_PACK_BUFFER_BINDING);
598         gpu_state_print_fl(GL_PIXEL_UNPACK_BUFFER_BINDING);
599         gpu_state_print_fl(GL_POINT_DISTANCE_ATTENUATION);
600         gpu_state_print_fl(GL_POINT_FADE_THRESHOLD_SIZE);
601         gpu_state_print_fl(GL_POINT_SIZE);
602         gpu_state_print_fl(GL_POINT_SIZE_GRANULARITY);
603         gpu_state_print_fl(GL_POINT_SIZE_MAX);
604         gpu_state_print_fl(GL_POINT_SIZE_MIN);
605         gpu_state_print_fl(GL_POINT_SIZE_RANGE);
606         gpu_state_print_fl(GL_POINT_SMOOTH);
607         gpu_state_print_fl(GL_POINT_SMOOTH_HINT);
608         gpu_state_print_fl(GL_POINT_SPRITE);
609         gpu_state_print_fl(GL_POLYGON_MODE);
610         gpu_state_print_fl(GL_POLYGON_OFFSET_FACTOR);
611         gpu_state_print_fl(GL_POLYGON_OFFSET_FILL);
612         gpu_state_print_fl(GL_POLYGON_OFFSET_LINE);
613         gpu_state_print_fl(GL_POLYGON_OFFSET_POINT);
614         gpu_state_print_fl(GL_POLYGON_OFFSET_UNITS);
615         gpu_state_print_fl(GL_POLYGON_SMOOTH);
616         gpu_state_print_fl(GL_POLYGON_SMOOTH_HINT);
617         gpu_state_print_fl(GL_POLYGON_STIPPLE);
618         gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_BIAS);
619         gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_SCALE);
620         gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_BIAS);
621         gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_SCALE);
622         gpu_state_print_fl(GL_POST_COLOR_MATRIX_COLOR_TABLE);
623         gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_BIAS);
624         gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_SCALE);
625         gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_BIAS);
626         gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_SCALE);
627         gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_BIAS);
628         gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_SCALE);
629         gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_BIAS);
630         gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_SCALE);
631         gpu_state_print_fl(GL_POST_CONVOLUTION_COLOR_TABLE);
632         gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_BIAS);
633         gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_SCALE);
634         gpu_state_print_fl(GL_POST_CONVOLUTION_RED_BIAS);
635         gpu_state_print_fl(GL_POST_CONVOLUTION_RED_SCALE);
636         gpu_state_print_fl(GL_PROJECTION_MATRIX);
637         gpu_state_print_fl(GL_PROJECTION_STACK_DEPTH);
638         gpu_state_print_fl(GL_READ_BUFFER);
639         gpu_state_print_fl(GL_RED_BIAS);
640         gpu_state_print_fl(GL_RED_BITS);
641         gpu_state_print_fl(GL_RED_SCALE);
642         gpu_state_print_fl(GL_RENDER_MODE);
643         gpu_state_print_fl(GL_RESCALE_NORMAL);
644         gpu_state_print_fl(GL_RGBA_MODE);
645         gpu_state_print_fl(GL_SAMPLES);
646         gpu_state_print_fl(GL_SAMPLE_BUFFERS);
647         gpu_state_print_fl(GL_SAMPLE_COVERAGE_INVERT);
648         gpu_state_print_fl(GL_SAMPLE_COVERAGE_VALUE);
649         gpu_state_print_fl(GL_SCISSOR_BOX);
650         gpu_state_print_fl(GL_SCISSOR_TEST);
651         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY);
652         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING);
653         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_SIZE);
654         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_STRIDE);
655         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_TYPE);
656         gpu_state_print_fl(GL_SELECTION_BUFFER_SIZE);
657         gpu_state_print_fl(GL_SEPARABLE_2D);
658         gpu_state_print_fl(GL_SHADE_MODEL);
659         gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
660         gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_RANGE);
661         gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_GRANULARITY);
662         gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_RANGE);
663         gpu_state_print_fl(GL_STENCIL_BACK_FAIL);
664         gpu_state_print_fl(GL_STENCIL_BACK_FUNC);
665         gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
666         gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_PASS);
667         gpu_state_print_fl(GL_STENCIL_BACK_REF);
668         gpu_state_print_fl(GL_STENCIL_BACK_VALUE_MASK);
669         gpu_state_print_fl(GL_STENCIL_BACK_WRITEMASK);
670         gpu_state_print_fl(GL_STENCIL_BITS);
671         gpu_state_print_fl(GL_STENCIL_CLEAR_VALUE);
672         gpu_state_print_fl(GL_STENCIL_FAIL);
673         gpu_state_print_fl(GL_STENCIL_FUNC);
674         gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_FAIL);
675         gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_PASS);
676         gpu_state_print_fl(GL_STENCIL_REF);
677         gpu_state_print_fl(GL_STENCIL_TEST);
678         gpu_state_print_fl(GL_STENCIL_VALUE_MASK);
679         gpu_state_print_fl(GL_STENCIL_WRITEMASK);
680         gpu_state_print_fl(GL_STEREO);
681         gpu_state_print_fl(GL_SUBPIXEL_BITS);
682         gpu_state_print_fl(GL_TEXTURE_1D);
683         gpu_state_print_fl(GL_TEXTURE_2D);
684         gpu_state_print_fl(GL_TEXTURE_3D);
685         gpu_state_print_fl(GL_TEXTURE_BINDING_1D);
686         gpu_state_print_fl(GL_TEXTURE_BINDING_2D);
687         gpu_state_print_fl(GL_TEXTURE_BINDING_3D);
688         gpu_state_print_fl(GL_TEXTURE_BINDING_CUBE_MAP);
689         gpu_state_print_fl(GL_TEXTURE_COMPRESSION_HINT);
690         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY);
691         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING);
692         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_SIZE);
693         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_STRIDE);
694         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_TYPE);
695         gpu_state_print_fl(GL_TEXTURE_CUBE_MAP);
696         gpu_state_print_fl(GL_TEXTURE_GEN_Q);
697         gpu_state_print_fl(GL_TEXTURE_GEN_R);
698         gpu_state_print_fl(GL_TEXTURE_GEN_S);
699         gpu_state_print_fl(GL_TEXTURE_GEN_T);
700         gpu_state_print_fl(GL_TEXTURE_MATRIX);
701         gpu_state_print_fl(GL_TEXTURE_STACK_DEPTH);
702         gpu_state_print_fl(GL_TRANSPOSE_COLOR_MATRIX);
703         gpu_state_print_fl(GL_TRANSPOSE_MODELVIEW_MATRIX);
704         gpu_state_print_fl(GL_TRANSPOSE_PROJECTION_MATRIX);
705         gpu_state_print_fl(GL_TRANSPOSE_TEXTURE_MATRIX);
706         gpu_state_print_fl(GL_UNPACK_ALIGNMENT);
707         gpu_state_print_fl(GL_UNPACK_IMAGE_HEIGHT);
708         gpu_state_print_fl(GL_UNPACK_LSB_FIRST);
709         gpu_state_print_fl(GL_UNPACK_ROW_LENGTH);
710         gpu_state_print_fl(GL_UNPACK_SKIP_IMAGES);
711         gpu_state_print_fl(GL_UNPACK_SKIP_PIXELS);
712         gpu_state_print_fl(GL_UNPACK_SKIP_ROWS);
713         gpu_state_print_fl(GL_UNPACK_SWAP_BYTES);
714         gpu_state_print_fl(GL_VERTEX_ARRAY);
715         gpu_state_print_fl(GL_VERTEX_ARRAY_BUFFER_BINDING);
716         gpu_state_print_fl(GL_VERTEX_ARRAY_SIZE);
717         gpu_state_print_fl(GL_VERTEX_ARRAY_STRIDE);
718         gpu_state_print_fl(GL_VERTEX_ARRAY_TYPE);
719         gpu_state_print_fl(GL_VERTEX_PROGRAM_POINT_SIZE);
720         gpu_state_print_fl(GL_VERTEX_PROGRAM_TWO_SIDE);
721         gpu_state_print_fl(GL_VIEWPORT);
722         gpu_state_print_fl(GL_ZOOM_X);
723         gpu_state_print_fl(GL_ZOOM_Y);
724 }
725
726 #undef gpu_state_print_fl