OpenGL: enhance debug output
[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 const char* source_name(GLenum source)
163 {
164         switch (source) {
165                 case GL_DEBUG_SOURCE_API: return "API";
166                 case GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "window system";
167                 case GL_DEBUG_SOURCE_SHADER_COMPILER: return "shader compiler";
168                 case GL_DEBUG_SOURCE_THIRD_PARTY: return "3rd party";
169                 case GL_DEBUG_SOURCE_APPLICATION: return "application";
170                 case GL_DEBUG_SOURCE_OTHER: return "other";
171                 default: return "???";
172         }
173 }
174
175 static const char* message_type_name(GLenum message)
176 {
177         switch (message) {
178                 case GL_DEBUG_TYPE_ERROR: return "error";
179                 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "deprecated behavior";
180                 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "undefined behavior";
181                 case GL_DEBUG_TYPE_PORTABILITY: return "portability";
182                 case GL_DEBUG_TYPE_PERFORMANCE: return "performance";
183                 case GL_DEBUG_TYPE_OTHER: return "other";
184                 case GL_DEBUG_TYPE_MARKER: return "marker"; /* KHR has this, ARB does not */
185                 default: return "???";
186         }
187 }
188
189 static const char* category_name_amd(GLenum category)
190 {
191         switch (category) {
192                 case GL_DEBUG_CATEGORY_API_ERROR_AMD: return "API error";
193                 case GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: return "window system";
194                 case GL_DEBUG_CATEGORY_DEPRECATION_AMD: return "deprecated behavior";
195                 case GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: return "undefined behavior";
196                 case GL_DEBUG_CATEGORY_PERFORMANCE_AMD: return "performance";
197                 case GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: return "shader compiler";
198                 case GL_DEBUG_CATEGORY_APPLICATION_AMD: return "application";
199                 case GL_DEBUG_CATEGORY_OTHER_AMD: return "other";
200                 default: return "???";
201         }
202 }
203
204
205 static void APIENTRY gpu_debug_proc(
206         GLenum source, GLenum type, GLuint UNUSED(id),
207         GLenum severity, GLsizei UNUSED(length),
208         const GLchar *message, const GLvoid *UNUSED(userParm))
209 {
210         switch (severity) {
211                 case GL_DEBUG_SEVERITY_HIGH:
212                 case GL_DEBUG_SEVERITY_MEDIUM:
213                 case GL_DEBUG_SEVERITY_LOW:
214                 case GL_DEBUG_SEVERITY_NOTIFICATION: /* KHR has this, ARB does not */
215                         fprintf(stderr, "GL %s %s: %s\n", source_name(source), message_type_name(type), message);
216                         fflush(stderr);
217         }
218 }
219
220
221 #ifndef GLEW_ES_ONLY
222 static void APIENTRY gpu_debug_proc_amd(
223         GLuint UNUSED(id), GLenum category,
224         GLenum severity, GLsizei UNUSED(length),
225         const GLchar *message,  GLvoid *UNUSED(userParm))
226 {
227         switch (severity) {
228                 case GL_DEBUG_SEVERITY_HIGH:
229                 case GL_DEBUG_SEVERITY_MEDIUM:
230                 case GL_DEBUG_SEVERITY_LOW:
231                         fprintf(stderr, "GL %s: %s\n", category_name_amd(category), message);
232                         fflush(stderr);
233         }
234 }
235 #endif
236
237
238 #undef APIENTRY
239
240 void gpu_debug_init(void)
241 {
242         const char success[] = "Successfully hooked OpenGL debug callback.";
243
244 #if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY)
245         if (GLEW_VERSION_4_3) {
246                 fprintf(stderr, "Using OpenGL 4.3 debug facilities\n");
247                 glEnable(GL_DEBUG_OUTPUT);
248                 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
249                 glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
250                 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
251                 GPU_string_marker(success);
252                 return;
253         }
254 #endif
255
256         if (GLEW_KHR_debug) {
257 #ifndef GLEW_ES_ONLY
258                 fprintf(stderr, "Using KHR_debug extension\n");
259                 glEnable(GL_DEBUG_OUTPUT);
260                 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
261                 glDebugMessageCallback((GLDEBUGPROC)gpu_debug_proc, mxGetCurrentContext());
262                 glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
263                 GPU_string_marker(success);
264 #endif
265                 return;
266         }
267
268 #ifndef GLEW_ES_ONLY
269         if (GLEW_ARB_debug_output) {
270                 fprintf(stderr, "Using ARB_debug_output extension\n");
271                 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
272                 glDebugMessageCallbackARB((GLDEBUGPROCARB)gpu_debug_proc, mxGetCurrentContext());
273                 glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
274                 GPU_string_marker(success);
275
276                 return;
277         }
278
279         if (GLEW_AMD_debug_output) {
280                 fprintf(stderr, "Using AMD_debug_output extension\n");
281                 glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext());
282                 glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
283                 GPU_string_marker(success);
284
285                 return;
286         }
287 #endif
288
289         fprintf(stderr, "Failed to hook OpenGL debug callback.\n");
290
291         return;
292 }
293
294
295 void gpu_debug_exit(void)
296 {
297 #ifndef WITH_GLEW_ES
298 #ifndef GLEW_ES_ONLY
299         if (GLEW_VERSION_4_3) {
300                 glDebugMessageCallback(NULL, NULL);
301
302                 return;
303         }
304 #endif
305 #endif
306
307         if (GLEW_KHR_debug) {
308 #ifndef GLEW_ES_ONLY
309                 glDebugMessageCallback(NULL, NULL);
310 #endif
311                 return;
312         }
313
314 #ifndef GLEW_ES_ONLY
315         if (GLEW_ARB_debug_output) {
316                 glDebugMessageCallbackARB(NULL, NULL);
317
318                 return;
319         }
320
321         if (GLEW_AMD_debug_output) {
322                 glDebugMessageCallbackAMD(NULL, NULL);
323
324                 return;
325         }
326 #endif
327
328         return;
329 }
330
331 void GPU_string_marker(const char *buf)
332 {
333 #ifndef WITH_GLEW_ES
334 #ifndef GLEW_ES_ONLY
335         if (GLEW_VERSION_4_3) {
336                 glDebugMessageInsert(
337                         GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
338                         GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf);
339
340                 return;
341         }
342 #endif
343 #endif
344
345         if (GLEW_KHR_debug) {
346 #ifndef GLEW_ES_ONLY
347                 glDebugMessageInsert(
348                         GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
349                         GL_DEBUG_SEVERITY_NOTIFICATION, -1, buf);
350 #endif
351                 return;
352         }
353
354 #ifndef GLEW_ES_ONLY
355         if (GLEW_ARB_debug_output) {
356                 glDebugMessageInsertARB(
357                         GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0,
358                         GL_DEBUG_SEVERITY_LOW_ARB, -1, buf);
359
360                 return;
361         }
362
363         if (GLEW_AMD_debug_output) {
364                 glDebugMessageInsertAMD(
365                         GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0,
366                         0, buf);
367
368                 return;
369         }
370
371         if (GLEW_GREMEDY_string_marker) {
372                 glStringMarkerGREMEDY(0, buf);
373
374                 return;
375         }
376 #endif
377 }
378
379 void GPU_print_error_debug(const char *str)
380 {
381         if (G.debug & G_DEBUG)
382                 fprintf(stderr, "GPU: %s\n", str);
383 }
384
385
386 void GPU_assert_no_gl_errors(const char *file, int line, const char *str)
387 {
388         if (G.debug) {
389                 GLboolean gl_ok = gpu_report_gl_errors(file, line, str);
390
391                 BLI_assert(gl_ok);
392                 (void) gl_ok;
393         }
394 }
395
396
397 static void gpu_state_print_fl_ex(const char *name, GLenum type)
398 {
399         const unsigned char err_mark[4] = {0xff, 0xff, 0xff, 0xff};
400
401         float value[32];
402         int a;
403
404         memset(value, 0xff, sizeof(value));
405         glGetFloatv(type, value);
406
407         if (glGetError() == GL_NO_ERROR) {
408                 printf("%s: ", name);
409                 for (a = 0; a < 32; a++) {
410                         if (memcmp(&value[a], err_mark, sizeof(value[a])) == 0) {
411                                 break;
412                         }
413                         printf("%.2f ", value[a]);
414                 }
415                 printf("\n");
416         }
417 }
418
419 #define gpu_state_print_fl(val) gpu_state_print_fl_ex(#val, val)
420
421 void GPU_state_print(void)
422 {
423         GPU_ASSERT_NO_GL_ERRORS("GPU_state_print"); /* clear any errors */
424
425         gpu_state_print_fl(GL_ACCUM_ALPHA_BITS);
426         gpu_state_print_fl(GL_ACCUM_BLUE_BITS);
427         gpu_state_print_fl(GL_ACCUM_CLEAR_VALUE);
428         gpu_state_print_fl(GL_ACCUM_GREEN_BITS);
429         gpu_state_print_fl(GL_ACCUM_RED_BITS);
430         gpu_state_print_fl(GL_ACTIVE_TEXTURE);
431         gpu_state_print_fl(GL_ALIASED_LINE_WIDTH_RANGE);
432         gpu_state_print_fl(GL_ALIASED_POINT_SIZE_RANGE);
433         gpu_state_print_fl(GL_ALPHA_BIAS);
434         gpu_state_print_fl(GL_ALPHA_BITS);
435         gpu_state_print_fl(GL_ALPHA_SCALE);
436         gpu_state_print_fl(GL_ALPHA_TEST);
437         gpu_state_print_fl(GL_ALPHA_TEST_FUNC);
438         gpu_state_print_fl(GL_ALPHA_TEST_REF);
439         gpu_state_print_fl(GL_ARRAY_BUFFER_BINDING);
440         gpu_state_print_fl(GL_ATTRIB_STACK_DEPTH);
441         gpu_state_print_fl(GL_AUTO_NORMAL);
442         gpu_state_print_fl(GL_AUX_BUFFERS);
443         gpu_state_print_fl(GL_BLEND);
444         gpu_state_print_fl(GL_BLEND_COLOR);
445         gpu_state_print_fl(GL_BLEND_DST_ALPHA);
446         gpu_state_print_fl(GL_BLEND_DST_RGB);
447         gpu_state_print_fl(GL_BLEND_EQUATION_ALPHA);
448         gpu_state_print_fl(GL_BLEND_EQUATION_RGB);
449         gpu_state_print_fl(GL_BLEND_SRC_ALPHA);
450         gpu_state_print_fl(GL_BLEND_SRC_RGB);
451         gpu_state_print_fl(GL_BLUE_BIAS);
452         gpu_state_print_fl(GL_BLUE_BITS);
453         gpu_state_print_fl(GL_BLUE_SCALE);
454         gpu_state_print_fl(GL_CLIENT_ACTIVE_TEXTURE);
455         gpu_state_print_fl(GL_CLIENT_ATTRIB_STACK_DEPTH);
456         gpu_state_print_fl(GL_CLIP_PLANE0);
457         gpu_state_print_fl(GL_COLOR_ARRAY);
458         gpu_state_print_fl(GL_COLOR_ARRAY_BUFFER_BINDING);
459         gpu_state_print_fl(GL_COLOR_ARRAY_SIZE);
460         gpu_state_print_fl(GL_COLOR_ARRAY_STRIDE);
461         gpu_state_print_fl(GL_COLOR_ARRAY_TYPE);
462         gpu_state_print_fl(GL_COLOR_CLEAR_VALUE);
463         gpu_state_print_fl(GL_COLOR_LOGIC_OP);
464         gpu_state_print_fl(GL_COLOR_MATERIAL);
465         gpu_state_print_fl(GL_COLOR_MATERIAL_FACE);
466         gpu_state_print_fl(GL_COLOR_MATERIAL_PARAMETER);
467         gpu_state_print_fl(GL_COLOR_MATRIX);
468         gpu_state_print_fl(GL_COLOR_MATRIX_STACK_DEPTH);
469         gpu_state_print_fl(GL_COLOR_SUM);
470         gpu_state_print_fl(GL_COLOR_TABLE);
471         gpu_state_print_fl(GL_COLOR_WRITEMASK);
472         gpu_state_print_fl(GL_COMPRESSED_TEXTURE_FORMATS);
473         gpu_state_print_fl(GL_CONVOLUTION_1D);
474         gpu_state_print_fl(GL_CONVOLUTION_2D);
475         gpu_state_print_fl(GL_CULL_FACE);
476         gpu_state_print_fl(GL_CULL_FACE_MODE);
477         gpu_state_print_fl(GL_CURRENT_COLOR);
478         gpu_state_print_fl(GL_CURRENT_FOG_COORD);
479         gpu_state_print_fl(GL_CURRENT_INDEX);
480         gpu_state_print_fl(GL_CURRENT_NORMAL);
481         gpu_state_print_fl(GL_CURRENT_PROGRAM);
482         gpu_state_print_fl(GL_CURRENT_RASTER_COLOR);
483         gpu_state_print_fl(GL_CURRENT_RASTER_DISTANCE);
484         gpu_state_print_fl(GL_CURRENT_RASTER_INDEX);
485         gpu_state_print_fl(GL_CURRENT_RASTER_POSITION);
486         gpu_state_print_fl(GL_CURRENT_RASTER_POSITION_VALID);
487         gpu_state_print_fl(GL_CURRENT_RASTER_SECONDARY_COLOR);
488         gpu_state_print_fl(GL_CURRENT_RASTER_TEXTURE_COORDS);
489         gpu_state_print_fl(GL_CURRENT_SECONDARY_COLOR);
490         gpu_state_print_fl(GL_CURRENT_TEXTURE_COORDS);
491         gpu_state_print_fl(GL_DEPTH_BIAS);
492         gpu_state_print_fl(GL_DEPTH_BITS);
493         gpu_state_print_fl(GL_DEPTH_CLEAR_VALUE);
494         gpu_state_print_fl(GL_DEPTH_FUNC);
495         gpu_state_print_fl(GL_DEPTH_RANGE);
496         gpu_state_print_fl(GL_DEPTH_SCALE);
497         gpu_state_print_fl(GL_DEPTH_TEST);
498         gpu_state_print_fl(GL_DEPTH_WRITEMASK);
499         gpu_state_print_fl(GL_DITHER);
500         gpu_state_print_fl(GL_DOUBLEBUFFER);
501         gpu_state_print_fl(GL_DRAW_BUFFER);
502         gpu_state_print_fl(GL_DRAW_BUFFER0);
503         gpu_state_print_fl(GL_EDGE_FLAG);
504         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY);
505         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_BUFFER_BINDING);
506         gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_STRIDE);
507         gpu_state_print_fl(GL_ELEMENT_ARRAY_BUFFER_BINDING);
508         gpu_state_print_fl(GL_FEEDBACK_BUFFER_SIZE);
509         gpu_state_print_fl(GL_FEEDBACK_BUFFER_TYPE);
510         gpu_state_print_fl(GL_FOG);
511         gpu_state_print_fl(GL_FOG_COLOR);
512         gpu_state_print_fl(GL_FOG_COORD_ARRAY);
513         gpu_state_print_fl(GL_FOG_COORD_ARRAY_BUFFER_BINDING);
514         gpu_state_print_fl(GL_FOG_COORD_ARRAY_STRIDE);
515         gpu_state_print_fl(GL_FOG_COORD_ARRAY_TYPE);
516         gpu_state_print_fl(GL_FOG_COORD_SRC);
517         gpu_state_print_fl(GL_FOG_DENSITY);
518         gpu_state_print_fl(GL_FOG_END);
519         gpu_state_print_fl(GL_FOG_HINT);
520         gpu_state_print_fl(GL_FOG_INDEX);
521         gpu_state_print_fl(GL_FOG_MODE);
522         gpu_state_print_fl(GL_FOG_START);
523         gpu_state_print_fl(GL_FRAGMENT_PROGRAM_ARB); /* TODO: remove ARB program support */
524         gpu_state_print_fl(GL_FRAGMENT_SHADER_DERIVATIVE_HINT);
525         gpu_state_print_fl(GL_FRONT_FACE);
526         gpu_state_print_fl(GL_GENERATE_MIPMAP_HINT);
527         gpu_state_print_fl(GL_GREEN_BIAS);
528         gpu_state_print_fl(GL_GREEN_BITS);
529         gpu_state_print_fl(GL_GREEN_SCALE);
530         gpu_state_print_fl(GL_HISTOGRAM);
531         gpu_state_print_fl(GL_INDEX_ARRAY);
532         gpu_state_print_fl(GL_INDEX_ARRAY_BUFFER_BINDING);
533         gpu_state_print_fl(GL_INDEX_ARRAY_STRIDE);
534         gpu_state_print_fl(GL_INDEX_ARRAY_TYPE);
535         gpu_state_print_fl(GL_INDEX_BITS);
536         gpu_state_print_fl(GL_INDEX_CLEAR_VALUE);
537         gpu_state_print_fl(GL_INDEX_LOGIC_OP);
538         gpu_state_print_fl(GL_INDEX_MODE);
539         gpu_state_print_fl(GL_INDEX_OFFSET);
540         gpu_state_print_fl(GL_INDEX_SHIFT);
541         gpu_state_print_fl(GL_INDEX_WRITEMASK);
542         gpu_state_print_fl(GL_LIGHT0);
543         gpu_state_print_fl(GL_LIGHT1);
544         gpu_state_print_fl(GL_LIGHT2);
545         gpu_state_print_fl(GL_LIGHT3);
546         gpu_state_print_fl(GL_LIGHT4);
547         gpu_state_print_fl(GL_LIGHT5);
548         gpu_state_print_fl(GL_LIGHT6);
549         gpu_state_print_fl(GL_LIGHT7);
550         gpu_state_print_fl(GL_LIGHTING);
551         gpu_state_print_fl(GL_LIGHT_MODEL_AMBIENT);
552         gpu_state_print_fl(GL_LIGHT_MODEL_COLOR_CONTROL);
553         gpu_state_print_fl(GL_LIGHT_MODEL_LOCAL_VIEWER);
554         gpu_state_print_fl(GL_LIGHT_MODEL_TWO_SIDE);
555         gpu_state_print_fl(GL_LINE_SMOOTH);
556         gpu_state_print_fl(GL_LINE_SMOOTH_HINT);
557         gpu_state_print_fl(GL_LINE_STIPPLE);
558         gpu_state_print_fl(GL_LINE_STIPPLE_PATTERN);
559         gpu_state_print_fl(GL_LINE_STIPPLE_REPEAT);
560         gpu_state_print_fl(GL_LINE_WIDTH);
561         gpu_state_print_fl(GL_LINE_WIDTH_GRANULARITY);
562         gpu_state_print_fl(GL_LINE_WIDTH_RANGE);
563         gpu_state_print_fl(GL_LIST_BASE);
564         gpu_state_print_fl(GL_LIST_INDEX);
565         gpu_state_print_fl(GL_LIST_MODE);
566         gpu_state_print_fl(GL_LOGIC_OP);
567         gpu_state_print_fl(GL_LOGIC_OP_MODE);
568         gpu_state_print_fl(GL_MAP1_COLOR_4);
569         gpu_state_print_fl(GL_MAP1_GRID_DOMAIN);
570         gpu_state_print_fl(GL_MAP1_GRID_SEGMENTS);
571         gpu_state_print_fl(GL_MAP1_INDEX);
572         gpu_state_print_fl(GL_MAP1_NORMAL);
573         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_1);
574         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_2);
575         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_3);
576         gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_4);
577         gpu_state_print_fl(GL_MAP1_VERTEX_3);
578         gpu_state_print_fl(GL_MAP1_VERTEX_4);
579         gpu_state_print_fl(GL_MAP2_COLOR_4);
580         gpu_state_print_fl(GL_MAP2_GRID_DOMAIN);
581         gpu_state_print_fl(GL_MAP2_GRID_SEGMENTS);
582         gpu_state_print_fl(GL_MAP2_INDEX);
583         gpu_state_print_fl(GL_MAP2_NORMAL);
584         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_1);
585         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_2);
586         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_3);
587         gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_4);
588         gpu_state_print_fl(GL_MAP2_VERTEX_3);
589         gpu_state_print_fl(GL_MAP2_VERTEX_4);
590         gpu_state_print_fl(GL_MAP_COLOR);
591         gpu_state_print_fl(GL_MAP_STENCIL);
592         gpu_state_print_fl(GL_MATRIX_MODE);
593         gpu_state_print_fl(GL_MAX_3D_TEXTURE_SIZE);
594         gpu_state_print_fl(GL_MAX_ATTRIB_STACK_DEPTH);
595         gpu_state_print_fl(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH);
596         gpu_state_print_fl(GL_MAX_CLIP_PLANES);
597         gpu_state_print_fl(GL_MAX_COLOR_MATRIX_STACK_DEPTH);
598         gpu_state_print_fl(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
599         gpu_state_print_fl(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
600         gpu_state_print_fl(GL_MAX_DRAW_BUFFERS);
601         gpu_state_print_fl(GL_MAX_ELEMENTS_INDICES);
602         gpu_state_print_fl(GL_MAX_ELEMENTS_VERTICES);
603         gpu_state_print_fl(GL_MAX_EVAL_ORDER);
604         gpu_state_print_fl(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
605         gpu_state_print_fl(GL_MAX_LIGHTS);
606         gpu_state_print_fl(GL_MAX_LIST_NESTING);
607         gpu_state_print_fl(GL_MAX_MODELVIEW_STACK_DEPTH);
608         gpu_state_print_fl(GL_MAX_NAME_STACK_DEPTH);
609         gpu_state_print_fl(GL_MAX_PIXEL_MAP_TABLE);
610         gpu_state_print_fl(GL_MAX_PROJECTION_STACK_DEPTH);
611         gpu_state_print_fl(GL_MAX_TEXTURE_COORDS);
612         gpu_state_print_fl(GL_MAX_TEXTURE_IMAGE_UNITS);
613         gpu_state_print_fl(GL_MAX_TEXTURE_LOD_BIAS);
614         gpu_state_print_fl(GL_MAX_TEXTURE_SIZE);
615         gpu_state_print_fl(GL_MAX_TEXTURE_STACK_DEPTH);
616         gpu_state_print_fl(GL_MAX_TEXTURE_UNITS);
617         gpu_state_print_fl(GL_MAX_VARYING_FLOATS);
618         gpu_state_print_fl(GL_MAX_VERTEX_ATTRIBS);
619         gpu_state_print_fl(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
620         gpu_state_print_fl(GL_MAX_VERTEX_UNIFORM_COMPONENTS);
621         gpu_state_print_fl(GL_MAX_VIEWPORT_DIMS);
622         gpu_state_print_fl(GL_MINMAX);
623         gpu_state_print_fl(GL_MODELVIEW_MATRIX);
624         gpu_state_print_fl(GL_MODELVIEW_STACK_DEPTH);
625         gpu_state_print_fl(GL_MULTISAMPLE);
626         gpu_state_print_fl(GL_NAME_STACK_DEPTH);
627         gpu_state_print_fl(GL_NORMALIZE);
628         gpu_state_print_fl(GL_NORMAL_ARRAY);
629         gpu_state_print_fl(GL_NORMAL_ARRAY_BUFFER_BINDING);
630         gpu_state_print_fl(GL_NORMAL_ARRAY_STRIDE);
631         gpu_state_print_fl(GL_NORMAL_ARRAY_TYPE);
632         gpu_state_print_fl(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
633         gpu_state_print_fl(GL_PACK_ALIGNMENT);
634         gpu_state_print_fl(GL_PACK_IMAGE_HEIGHT);
635         gpu_state_print_fl(GL_PACK_LSB_FIRST);
636         gpu_state_print_fl(GL_PACK_ROW_LENGTH);
637         gpu_state_print_fl(GL_PACK_SKIP_IMAGES);
638         gpu_state_print_fl(GL_PACK_SKIP_PIXELS);
639         gpu_state_print_fl(GL_PACK_SKIP_ROWS);
640         gpu_state_print_fl(GL_PACK_SWAP_BYTES);
641         gpu_state_print_fl(GL_PERSPECTIVE_CORRECTION_HINT);
642         gpu_state_print_fl(GL_PIXEL_MAP_A_TO_A_SIZE);
643         gpu_state_print_fl(GL_PIXEL_MAP_B_TO_B_SIZE);
644         gpu_state_print_fl(GL_PIXEL_MAP_G_TO_G_SIZE);
645         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_A_SIZE);
646         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_B_SIZE);
647         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_G_SIZE);
648         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_I_SIZE);
649         gpu_state_print_fl(GL_PIXEL_MAP_I_TO_R_SIZE);
650         gpu_state_print_fl(GL_PIXEL_MAP_R_TO_R_SIZE);
651         gpu_state_print_fl(GL_PIXEL_MAP_S_TO_S_SIZE);
652         gpu_state_print_fl(GL_PIXEL_PACK_BUFFER_BINDING);
653         gpu_state_print_fl(GL_PIXEL_UNPACK_BUFFER_BINDING);
654         gpu_state_print_fl(GL_POINT_DISTANCE_ATTENUATION);
655         gpu_state_print_fl(GL_POINT_FADE_THRESHOLD_SIZE);
656         gpu_state_print_fl(GL_POINT_SIZE);
657         gpu_state_print_fl(GL_POINT_SIZE_GRANULARITY);
658         gpu_state_print_fl(GL_POINT_SIZE_MAX);
659         gpu_state_print_fl(GL_POINT_SIZE_MIN);
660         gpu_state_print_fl(GL_POINT_SIZE_RANGE);
661         gpu_state_print_fl(GL_POINT_SMOOTH);
662         gpu_state_print_fl(GL_POINT_SMOOTH_HINT);
663         gpu_state_print_fl(GL_POINT_SPRITE);
664         gpu_state_print_fl(GL_POLYGON_MODE);
665         gpu_state_print_fl(GL_POLYGON_OFFSET_FACTOR);
666         gpu_state_print_fl(GL_POLYGON_OFFSET_FILL);
667         gpu_state_print_fl(GL_POLYGON_OFFSET_LINE);
668         gpu_state_print_fl(GL_POLYGON_OFFSET_POINT);
669         gpu_state_print_fl(GL_POLYGON_OFFSET_UNITS);
670         gpu_state_print_fl(GL_POLYGON_SMOOTH);
671         gpu_state_print_fl(GL_POLYGON_SMOOTH_HINT);
672         gpu_state_print_fl(GL_POLYGON_STIPPLE);
673         gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_BIAS);
674         gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_SCALE);
675         gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_BIAS);
676         gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_SCALE);
677         gpu_state_print_fl(GL_POST_COLOR_MATRIX_COLOR_TABLE);
678         gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_BIAS);
679         gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_SCALE);
680         gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_BIAS);
681         gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_SCALE);
682         gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_BIAS);
683         gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_SCALE);
684         gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_BIAS);
685         gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_SCALE);
686         gpu_state_print_fl(GL_POST_CONVOLUTION_COLOR_TABLE);
687         gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_BIAS);
688         gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_SCALE);
689         gpu_state_print_fl(GL_POST_CONVOLUTION_RED_BIAS);
690         gpu_state_print_fl(GL_POST_CONVOLUTION_RED_SCALE);
691         gpu_state_print_fl(GL_PROJECTION_MATRIX);
692         gpu_state_print_fl(GL_PROJECTION_STACK_DEPTH);
693         gpu_state_print_fl(GL_READ_BUFFER);
694         gpu_state_print_fl(GL_RED_BIAS);
695         gpu_state_print_fl(GL_RED_BITS);
696         gpu_state_print_fl(GL_RED_SCALE);
697         gpu_state_print_fl(GL_RENDER_MODE);
698         gpu_state_print_fl(GL_RESCALE_NORMAL);
699         gpu_state_print_fl(GL_RGBA_MODE);
700         gpu_state_print_fl(GL_SAMPLES);
701         gpu_state_print_fl(GL_SAMPLE_BUFFERS);
702         gpu_state_print_fl(GL_SAMPLE_COVERAGE_INVERT);
703         gpu_state_print_fl(GL_SAMPLE_COVERAGE_VALUE);
704         gpu_state_print_fl(GL_SCISSOR_BOX);
705         gpu_state_print_fl(GL_SCISSOR_TEST);
706         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY);
707         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING);
708         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_SIZE);
709         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_STRIDE);
710         gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_TYPE);
711         gpu_state_print_fl(GL_SELECTION_BUFFER_SIZE);
712         gpu_state_print_fl(GL_SEPARABLE_2D);
713         gpu_state_print_fl(GL_SHADE_MODEL);
714         gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_GRANULARITY);
715         gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_RANGE);
716         gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_GRANULARITY);
717         gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_RANGE);
718         gpu_state_print_fl(GL_STENCIL_BACK_FAIL);
719         gpu_state_print_fl(GL_STENCIL_BACK_FUNC);
720         gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
721         gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_PASS);
722         gpu_state_print_fl(GL_STENCIL_BACK_REF);
723         gpu_state_print_fl(GL_STENCIL_BACK_VALUE_MASK);
724         gpu_state_print_fl(GL_STENCIL_BACK_WRITEMASK);
725         gpu_state_print_fl(GL_STENCIL_BITS);
726         gpu_state_print_fl(GL_STENCIL_CLEAR_VALUE);
727         gpu_state_print_fl(GL_STENCIL_FAIL);
728         gpu_state_print_fl(GL_STENCIL_FUNC);
729         gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_FAIL);
730         gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_PASS);
731         gpu_state_print_fl(GL_STENCIL_REF);
732         gpu_state_print_fl(GL_STENCIL_TEST);
733         gpu_state_print_fl(GL_STENCIL_VALUE_MASK);
734         gpu_state_print_fl(GL_STENCIL_WRITEMASK);
735         gpu_state_print_fl(GL_STEREO);
736         gpu_state_print_fl(GL_SUBPIXEL_BITS);
737         gpu_state_print_fl(GL_TEXTURE_1D);
738         gpu_state_print_fl(GL_TEXTURE_2D);
739         gpu_state_print_fl(GL_TEXTURE_3D);
740         gpu_state_print_fl(GL_TEXTURE_BINDING_1D);
741         gpu_state_print_fl(GL_TEXTURE_BINDING_2D);
742         gpu_state_print_fl(GL_TEXTURE_BINDING_3D);
743         gpu_state_print_fl(GL_TEXTURE_BINDING_CUBE_MAP);
744         gpu_state_print_fl(GL_TEXTURE_COMPRESSION_HINT);
745         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY);
746         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING);
747         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_SIZE);
748         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_STRIDE);
749         gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_TYPE);
750         gpu_state_print_fl(GL_TEXTURE_CUBE_MAP);
751         gpu_state_print_fl(GL_TEXTURE_GEN_Q);
752         gpu_state_print_fl(GL_TEXTURE_GEN_R);
753         gpu_state_print_fl(GL_TEXTURE_GEN_S);
754         gpu_state_print_fl(GL_TEXTURE_GEN_T);
755         gpu_state_print_fl(GL_TEXTURE_MATRIX);
756         gpu_state_print_fl(GL_TEXTURE_STACK_DEPTH);
757         gpu_state_print_fl(GL_TRANSPOSE_COLOR_MATRIX);
758         gpu_state_print_fl(GL_TRANSPOSE_MODELVIEW_MATRIX);
759         gpu_state_print_fl(GL_TRANSPOSE_PROJECTION_MATRIX);
760         gpu_state_print_fl(GL_TRANSPOSE_TEXTURE_MATRIX);
761         gpu_state_print_fl(GL_UNPACK_ALIGNMENT);
762         gpu_state_print_fl(GL_UNPACK_IMAGE_HEIGHT);
763         gpu_state_print_fl(GL_UNPACK_LSB_FIRST);
764         gpu_state_print_fl(GL_UNPACK_ROW_LENGTH);
765         gpu_state_print_fl(GL_UNPACK_SKIP_IMAGES);
766         gpu_state_print_fl(GL_UNPACK_SKIP_PIXELS);
767         gpu_state_print_fl(GL_UNPACK_SKIP_ROWS);
768         gpu_state_print_fl(GL_UNPACK_SWAP_BYTES);
769         gpu_state_print_fl(GL_VERTEX_ARRAY);
770         gpu_state_print_fl(GL_VERTEX_ARRAY_BUFFER_BINDING);
771         gpu_state_print_fl(GL_VERTEX_ARRAY_SIZE);
772         gpu_state_print_fl(GL_VERTEX_ARRAY_STRIDE);
773         gpu_state_print_fl(GL_VERTEX_ARRAY_TYPE);
774         gpu_state_print_fl(GL_VERTEX_PROGRAM_POINT_SIZE);
775         gpu_state_print_fl(GL_VERTEX_PROGRAM_TWO_SIDE);
776         gpu_state_print_fl(GL_VIEWPORT);
777         gpu_state_print_fl(GL_ZOOM_X);
778         gpu_state_print_fl(GL_ZOOM_Y);
779 }
780
781 #undef gpu_state_print_fl