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