Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tracinghelper.cc
Go to the documentation of this file.
1 
18 #include "ion/gfx/tracinghelper.h"
19 
20 #include <string.h> // For strcmp().
21 
22 #include <sstream>
23 
24 #include "ion/base/stringutils.h"
25 #include "ion/portgfx/glheaders.h"
26 
27 namespace ion {
28 namespace gfx {
29 
30 #if ION_PRODUCTION
31 
33 template <typename T>
34 const std::string TracingHelper::ToString(const char*, T) {
35  return std::string();
36 }
37 
39 template ION_API const std::string TracingHelper::ToString(
40  const char*, char*);
41 template ION_API const std::string TracingHelper::ToString(
42  const char*, char**);
43 template ION_API const std::string TracingHelper::ToString(
44  const char*, const char*);
45 template ION_API const std::string TracingHelper::ToString(
46  const char*, const char**);
47 template ION_API const std::string TracingHelper::ToString(
48  const char*, unsigned char);
49 template ION_API const std::string TracingHelper::ToString(
50  const char*, unsigned int);
51 template ION_API const std::string TracingHelper::ToString(
52  const char*, const float*);
53 template ION_API const std::string TracingHelper::ToString(
54  const char*, const int*);
55 template ION_API const std::string TracingHelper::ToString(
56  const char*, const unsigned char*);
57 template ION_API const std::string TracingHelper::ToString(
58  const char*, const unsigned int*);
59 template ION_API const std::string TracingHelper::ToString(
60  const char*, const void*);
61 template ION_API const std::string TracingHelper::ToString(
62  const char*, float);
63 template ION_API const std::string TracingHelper::ToString(
64  const char*, float*);
65 template ION_API const std::string TracingHelper::ToString(
66  const char*, int*);
67 template ION_API const std::string TracingHelper::ToString(
68  const char*, long); // NOLINT
69 template ION_API const std::string TracingHelper::ToString(
70  const char*, long*); // NOLINT
71 template ION_API const std::string TracingHelper::ToString(
72  const char*, long long); // NOLINT
73 template ION_API const std::string TracingHelper::ToString(
74  const char*, long long*); // NOLINT
75 template ION_API const std::string TracingHelper::ToString(
76  const char*, unsigned char*);
77 template ION_API const std::string TracingHelper::ToString(
78  const char*, unsigned int*);
79 template ION_API const std::string TracingHelper::ToString(
80  const char*, unsigned long); // NOLINT
81 template ION_API const std::string TracingHelper::ToString(
82  const char*, unsigned long*); // NOLINT
83 template ION_API const std::string TracingHelper::ToString(
84  const char*, unsigned long long); // NOLINT
85 template ION_API const std::string TracingHelper::ToString(
86  const char*, unsigned long long*); // NOLINT
87 template ION_API const std::string TracingHelper::ToString(
88  const char*, void*);
89 template ION_API const std::string TracingHelper::ToString(
90  const char*, void**);
91 template ION_API const std::string TracingHelper::ToString(
92  const char*, GLsync);
93 template ION_API const std::string TracingHelper::ToString(const char*,
94  GLDEBUGPROC);
95 
96 #else
97 
98 namespace {
99 
101 template <typename T>
102 static const std::string AnyToString(const T& val) {
103  std::ostringstream out;
104  out << val;
105  return out.str();
106 }
107 
109 template <> const std::string AnyToString(const unsigned int& val) { // NOLINT
110  std::ostringstream out;
111  out << "0x" << std::hex << val;
112  return out.str();
113 }
114 
118 static const std::string GetClearBitsString(GLbitfield mask) {
119  std::string s;
120  if (mask & GL_COLOR_BUFFER_BIT) {
121  s += "GL_COLOR_BUFFER_BIT";
122  mask &= ~GL_COLOR_BUFFER_BIT;
123  }
124  if (mask & GL_DEPTH_BUFFER_BIT) {
125  if (!s.empty())
126  s += " | ";
127  s += "GL_DEPTH_BUFFER_BIT";
128  mask &= ~GL_DEPTH_BUFFER_BIT;
129  }
130  if (mask & GL_STENCIL_BUFFER_BIT) {
131  if (!s.empty())
132  s += " | ";
133  s += "GL_STENCIL_BUFFER_BIT";
134  mask &= ~GL_STENCIL_BUFFER_BIT;
135  }
137  if (mask)
138  s.clear();
139  return s;
140 }
141 
145 static const std::string GetMapBitsString(GLbitfield mode) {
146  std::string s;
147  if (mode & GL_MAP_READ_BIT) {
148  s += "GL_MAP_READ_BIT";
149  mode &= ~GL_MAP_READ_BIT;
150  }
151  if (mode & GL_MAP_WRITE_BIT) {
152  if (!s.empty())
153  s += " | ";
154  s += "GL_MAP_WRITE_BIT";
155  mode &= ~GL_MAP_WRITE_BIT;
156  }
158  if (mode)
159  s.clear();
160  return s;
161 }
162 
165 template <typename T>
166 static std::string ArrayToString(const std::string& type, T arg) {
167  return std::string();
168 }
169 
171 template <typename T>
172 static std::string TypedArrayToString(const std::string& type, T arg) {
173  std::ostringstream out;
174 
176  if (int count = base::StringToInt32(type.substr(type.length() - 2, 1))) {
177  int rows = 1;
179  if (type.find("matrix") != std::string::npos)
180  rows = count;
181  out << " -> [";
182  for (int j = 0; j < rows; ++j) {
183  for (int i = 0; i < count; ++i) {
184  out << arg[j * count + i];
185  if (i < count - 1)
186  out << "; ";
187  }
188  if (j < rows - 1)
189  out << " | ";
190  }
191  out << "]";
192  }
193  return out.str();
194 }
195 
198 template <>
199 std::string ArrayToString<const int*>(const std::string& type, const int* arg) {
200  return TypedArrayToString(type, arg);
201 }
202 template <>
203 std::string ArrayToString<const float*>(const std::string& type,
204  const float* arg) {
205  return TypedArrayToString(type, arg);
206 }
207 
210 
211 #define ION_ADD_CONSTANT(name) (*constants)[name] = #name
212 static void IonAddConstantsAToF(
213  std::unordered_map<int, std::string>* constants) {
214  ION_ADD_CONSTANT(GL_ACTIVE_ATTRIBUTES);
215  ION_ADD_CONSTANT(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
216  ION_ADD_CONSTANT(GL_ACTIVE_TEXTURE);
217  ION_ADD_CONSTANT(GL_ACTIVE_UNIFORMS);
218  ION_ADD_CONSTANT(GL_ACTIVE_UNIFORM_MAX_LENGTH);
219  ION_ADD_CONSTANT(GL_ALIASED_LINE_WIDTH_RANGE);
221  ION_ADD_CONSTANT(GL_ALPHA);
223  ION_ADD_CONSTANT(GL_ALREADY_SIGNALED);
224  ION_ADD_CONSTANT(GL_ALWAYS);
225  ION_ADD_CONSTANT(GL_ARRAY_BUFFER);
226  ION_ADD_CONSTANT(GL_ARRAY_BUFFER_BINDING);
227  ION_ADD_CONSTANT(GL_ATTACHED_SHADERS);
228  ION_ADD_CONSTANT(GL_BACK);
229  ION_ADD_CONSTANT(GL_BACK_LEFT);
230  ION_ADD_CONSTANT(GL_BACK_RIGHT);
231  ION_ADD_CONSTANT(GL_BLEND);
232  ION_ADD_CONSTANT(GL_BLEND_COLOR);
233  ION_ADD_CONSTANT(GL_BLEND_DST_ALPHA);
234  ION_ADD_CONSTANT(GL_BLEND_DST_RGB);
235  ION_ADD_CONSTANT(GL_BLEND_EQUATION);
236  ION_ADD_CONSTANT(GL_BLEND_EQUATION_ALPHA);
237  ION_ADD_CONSTANT(GL_BLEND_EQUATION_RGB);
238  ION_ADD_CONSTANT(GL_BLEND_SRC_ALPHA);
239  ION_ADD_CONSTANT(GL_BLEND_SRC_RGB);
240  ION_ADD_CONSTANT(GL_BLUE);
242  ION_ADD_CONSTANT(GL_BOOL);
243  ION_ADD_CONSTANT(GL_BOOL_VEC2);
244  ION_ADD_CONSTANT(GL_BOOL_VEC3);
245  ION_ADD_CONSTANT(GL_BOOL_VEC4);
247  ION_ADD_CONSTANT(GL_BUFFER_SIZE);
248  ION_ADD_CONSTANT(GL_BUFFER_USAGE);
249  ION_ADD_CONSTANT(GL_BYTE);
250  ION_ADD_CONSTANT(GL_CCW);
251  ION_ADD_CONSTANT(GL_CLAMP_TO_EDGE);
252  ION_ADD_CONSTANT(GL_COLOR_ATTACHMENT0);
253  ION_ADD_CONSTANT(GL_COLOR_CLEAR_VALUE);
254  ION_ADD_CONSTANT(GL_COLOR_WRITEMASK);
255  ION_ADD_CONSTANT(GL_COMPARE_REF_TO_TEXTURE);
256  ION_ADD_CONSTANT(GL_COMPILE_STATUS);
257  ION_ADD_CONSTANT(GL_COMPRESSED_R11_EAC);
258  ION_ADD_CONSTANT(GL_COMPRESSED_RG11_EAC);
259  ION_ADD_CONSTANT(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
260  ION_ADD_CONSTANT(GL_COMPRESSED_RGB8_ETC2);
261  ION_ADD_CONSTANT(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
266  ION_ADD_CONSTANT(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
267  ION_ADD_CONSTANT(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
268  ION_ADD_CONSTANT(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
269  ION_ADD_CONSTANT(GL_COMPRESSED_RGBA8_ETC2_EAC);
270  ION_ADD_CONSTANT(GL_COMPRESSED_SIGNED_R11_EAC);
271  ION_ADD_CONSTANT(GL_COMPRESSED_SIGNED_RG11_EAC);
272  ION_ADD_CONSTANT(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
273  ION_ADD_CONSTANT(GL_COMPRESSED_SRGB8_ETC2);
274  ION_ADD_CONSTANT(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
275  ION_ADD_CONSTANT(GL_COMPRESSED_TEXTURE_FORMATS);
277  ION_ADD_CONSTANT(GL_CONSTANT_ALPHA);
278  ION_ADD_CONSTANT(GL_CONSTANT_COLOR);
279  ION_ADD_CONSTANT(GL_COPY_READ_BUFFER);
280  ION_ADD_CONSTANT(GL_COPY_WRITE_BUFFER);
281  ION_ADD_CONSTANT(GL_CULL_FACE);
282  ION_ADD_CONSTANT(GL_CULL_FACE_MODE);
283  ION_ADD_CONSTANT(GL_CURRENT_PROGRAM);
284  ION_ADD_CONSTANT(GL_CURRENT_VERTEX_ATTRIB);
285  ION_ADD_CONSTANT(GL_CW);
286  ION_ADD_CONSTANT(GL_DEBUG_OUTPUT_SYNCHRONOUS);
287  ION_ADD_CONSTANT(GL_DECR);
288  ION_ADD_CONSTANT(GL_DECR_WRAP);
289  ION_ADD_CONSTANT(GL_DELETE_STATUS);
290  ION_ADD_CONSTANT(GL_DEPTH_ATTACHMENT);
292  ION_ADD_CONSTANT(GL_DEPTH_CLEAR_VALUE);
293  ION_ADD_CONSTANT(GL_DEPTH_COMPONENT);
294  ION_ADD_CONSTANT(GL_DEPTH_COMPONENT16);
295  ION_ADD_CONSTANT(GL_DEPTH_COMPONENT24);
296  ION_ADD_CONSTANT(GL_DEPTH_COMPONENT32F);
297  ION_ADD_CONSTANT(GL_DEPTH_FUNC);
298  ION_ADD_CONSTANT(GL_DEPTH_RANGE);
299  ION_ADD_CONSTANT(GL_DEPTH_STENCIL);
300  ION_ADD_CONSTANT(GL_DEPTH_TEST);
301  ION_ADD_CONSTANT(GL_DEPTH_WRITEMASK);
302  ION_ADD_CONSTANT(GL_DEPTH24_STENCIL8);
303  ION_ADD_CONSTANT(GL_DEPTH32F_STENCIL8);
304  ION_ADD_CONSTANT(GL_DITHER);
305  ION_ADD_CONSTANT(GL_DONT_CARE);
306  ION_ADD_CONSTANT(GL_DRAW_BUFFER);
307  ION_ADD_CONSTANT(GL_DRAW_BUFFER0);
308  ION_ADD_CONSTANT(GL_DRAW_FRAMEBUFFER);
311  ION_ADD_CONSTANT(GL_DST_ALPHA);
312  ION_ADD_CONSTANT(GL_DST_COLOR);
313  ION_ADD_CONSTANT(GL_DYNAMIC_DRAW);
314  ION_ADD_CONSTANT(GL_ELEMENT_ARRAY_BUFFER);
315  ION_ADD_CONSTANT(GL_ELEMENT_ARRAY_BUFFER_BINDING);
316  ION_ADD_CONSTANT(GL_EQUAL);
318  ION_ADD_CONSTANT(GL_EXTENSIONS);
319  ION_ADD_CONSTANT(GL_FASTEST);
320  ION_ADD_CONSTANT(GL_FIXED);
321  ION_ADD_CONSTANT(GL_FLOAT);
322  ION_ADD_CONSTANT(GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
323  ION_ADD_CONSTANT(GL_FLOAT_MAT2);
324  ION_ADD_CONSTANT(GL_FLOAT_MAT3);
325  ION_ADD_CONSTANT(GL_FLOAT_MAT4);
326  ION_ADD_CONSTANT(GL_FLOAT_VEC2);
327  ION_ADD_CONSTANT(GL_FLOAT_VEC3);
328  ION_ADD_CONSTANT(GL_FLOAT_VEC4);
329  ION_ADD_CONSTANT(GL_FRAGMENT_SHADER);
330  ION_ADD_CONSTANT(GL_FRAMEBUFFER);
331  ION_ADD_CONSTANT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
332  ION_ADD_CONSTANT(GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE);
333  ION_ADD_CONSTANT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE);
334  ION_ADD_CONSTANT(GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL);
335  ION_ADD_CONSTANT(GL_FRAMEBUFFER_BINDING);
336  ION_ADD_CONSTANT(GL_FRAMEBUFFER_COMPLETE);
337  ION_ADD_CONSTANT(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
339  ION_ADD_CONSTANT(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
340  ION_ADD_CONSTANT(GL_FRAMEBUFFER_UNSUPPORTED);
341  ION_ADD_CONSTANT(GL_FRONT);
342  ION_ADD_CONSTANT(GL_FRONT_AND_BACK);
343  ION_ADD_CONSTANT(GL_FRONT_FACE);
344  ION_ADD_CONSTANT(GL_FRONT_LEFT);
345  ION_ADD_CONSTANT(GL_FRONT_RIGHT);
346  ION_ADD_CONSTANT(GL_FUNC_ADD);
347  ION_ADD_CONSTANT(GL_FUNC_REVERSE_SUBTRACT);
348  ION_ADD_CONSTANT(GL_FUNC_SUBTRACT);
349 }
350 
351 static void IonAddConstantsGToQ(
352  std::unordered_map<int, std::string>* constants) {
354  ION_ADD_CONSTANT(GL_GEQUAL);
355  ION_ADD_CONSTANT(GL_GREATER);
356  ION_ADD_CONSTANT(GL_GREEN);
358  ION_ADD_CONSTANT(GL_HALF_FLOAT);
359  ION_ADD_CONSTANT(GL_HIGH_FLOAT);
360  ION_ADD_CONSTANT(GL_HIGH_INT);
361  ION_ADD_CONSTANT(GL_IMPLEMENTATION_COLOR_READ_FORMAT);
362  ION_ADD_CONSTANT(GL_IMPLEMENTATION_COLOR_READ_TYPE);
363  ION_ADD_CONSTANT(GL_INCR);
364  ION_ADD_CONSTANT(GL_INCR_WRAP);
365  ION_ADD_CONSTANT(GL_INFO_LOG_LENGTH);
366  ION_ADD_CONSTANT(GL_INT);
367  ION_ADD_CONSTANT(GL_INTERLEAVED_ATTRIBS);
368  ION_ADD_CONSTANT(GL_INT_SAMPLER_1D);
369  ION_ADD_CONSTANT(GL_INT_SAMPLER_1D_ARRAY);
370  ION_ADD_CONSTANT(GL_INT_SAMPLER_2D);
371  ION_ADD_CONSTANT(GL_INT_SAMPLER_2D_ARRAY);
372  ION_ADD_CONSTANT(GL_INT_SAMPLER_3D);
373  ION_ADD_CONSTANT(GL_INT_SAMPLER_CUBE);
374  ION_ADD_CONSTANT(GL_INT_SAMPLER_CUBE_MAP_ARRAY);
375  ION_ADD_CONSTANT(GL_INT_VEC2);
376  ION_ADD_CONSTANT(GL_INT_VEC3);
377  ION_ADD_CONSTANT(GL_INT_VEC4);
378  ION_ADD_CONSTANT(GL_INVALID_ENUM);
379  ION_ADD_CONSTANT(GL_INVALID_FRAMEBUFFER_OPERATION);
380  ION_ADD_CONSTANT(GL_INVALID_OPERATION);
381  ION_ADD_CONSTANT(GL_INVALID_VALUE);
382  ION_ADD_CONSTANT(GL_INVERT);
383  ION_ADD_CONSTANT(GL_KEEP);
384  ION_ADD_CONSTANT(GL_LEFT);
385  ION_ADD_CONSTANT(GL_LEQUAL);
386  ION_ADD_CONSTANT(GL_LESS);
387  ION_ADD_CONSTANT(GL_LINEAR);
388  ION_ADD_CONSTANT(GL_LINEAR_MIPMAP_LINEAR);
389  ION_ADD_CONSTANT(GL_LINEAR_MIPMAP_NEAREST);
390  ION_ADD_CONSTANT(GL_LINES);
391  ION_ADD_CONSTANT(GL_LINE_LOOP);
392  ION_ADD_CONSTANT(GL_LINE_STRIP);
393  ION_ADD_CONSTANT(GL_LINE_WIDTH);
394  ION_ADD_CONSTANT(GL_LINK_STATUS);
395  ION_ADD_CONSTANT(GL_LOW_FLOAT);
396  ION_ADD_CONSTANT(GL_LOW_INT);
399  ION_ADD_CONSTANT(GL_MAX_COLOR_ATTACHMENTS);
400  ION_ADD_CONSTANT(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
401  ION_ADD_CONSTANT(GL_MAX_CUBE_MAP_TEXTURE_SIZE);
402  ION_ADD_CONSTANT(GL_MAX_DRAW_BUFFERS);
403  ION_ADD_CONSTANT(GL_MAX_FRAGMENT_UNIFORM_VECTORS);
404  ION_ADD_CONSTANT(GL_MAX_RENDERBUFFER_SIZE);
405  ION_ADD_CONSTANT(GL_MAX_SAMPLE_MASK_WORDS);
406  ION_ADD_CONSTANT(GL_MAX_SERVER_WAIT_TIMEOUT);
407  ION_ADD_CONSTANT(GL_MAX_TEXTURE_IMAGE_UNITS);
408  ION_ADD_CONSTANT(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
409  ION_ADD_CONSTANT(GL_MAX_TEXTURE_SIZE);
410  ION_ADD_CONSTANT(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS);
411  ION_ADD_CONSTANT(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
412  ION_ADD_CONSTANT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
413  ION_ADD_CONSTANT(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
414  ION_ADD_CONSTANT(GL_MAX_VARYING_VECTORS);
415  ION_ADD_CONSTANT(GL_MAX_VERTEX_ATTRIBS);
416  ION_ADD_CONSTANT(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
417  ION_ADD_CONSTANT(GL_MAX_VERTEX_UNIFORM_VECTORS);
418  ION_ADD_CONSTANT(GL_MAX_VIEWPORT_DIMS);
419  ION_ADD_CONSTANT(GL_MEDIUM_FLOAT);
420  ION_ADD_CONSTANT(GL_MEDIUM_INT);
421  ION_ADD_CONSTANT(GL_MIRRORED_REPEAT);
422  ION_ADD_CONSTANT(GL_MULTISAMPLE);
423  ION_ADD_CONSTANT(GL_NEAREST);
424  ION_ADD_CONSTANT(GL_NEAREST_MIPMAP_LINEAR);
425  ION_ADD_CONSTANT(GL_NEAREST_MIPMAP_NEAREST);
426  ION_ADD_CONSTANT(GL_NEVER);
427  ION_ADD_CONSTANT(GL_NICEST);
429  ION_ADD_CONSTANT(GL_NOTEQUAL);
430  ION_ADD_CONSTANT(GL_NO_ERROR);
431  ION_ADD_CONSTANT(GL_NUM_COMPRESSED_TEXTURE_FORMATS);
432  ION_ADD_CONSTANT(GL_NUM_EXTENSIONS);
433  ION_ADD_CONSTANT(GL_NUM_SHADER_BINARY_FORMATS);
434  ION_ADD_CONSTANT(GL_OBJECT_TYPE);
436  ION_ADD_CONSTANT(GL_ONE_MINUS_CONSTANT_ALPHA);
437  ION_ADD_CONSTANT(GL_ONE_MINUS_CONSTANT_COLOR);
438  ION_ADD_CONSTANT(GL_ONE_MINUS_DST_ALPHA);
439  ION_ADD_CONSTANT(GL_ONE_MINUS_DST_COLOR);
440  ION_ADD_CONSTANT(GL_ONE_MINUS_SRC_ALPHA);
441  ION_ADD_CONSTANT(GL_ONE_MINUS_SRC_COLOR);
442  ION_ADD_CONSTANT(GL_OUT_OF_MEMORY);
443  ION_ADD_CONSTANT(GL_PACK_ALIGNMENT);
444  ION_ADD_CONSTANT(GL_PALETTE4_R5_G6_B5_OES);
445  ION_ADD_CONSTANT(GL_PALETTE4_RGB5_A1_OES);
446  ION_ADD_CONSTANT(GL_PALETTE4_RGB8_OES);
447  ION_ADD_CONSTANT(GL_PALETTE4_RGBA4_OES);
448  ION_ADD_CONSTANT(GL_PALETTE4_RGBA8_OES);
449  ION_ADD_CONSTANT(GL_PALETTE8_R5_G6_B5_OES);
450  ION_ADD_CONSTANT(GL_PALETTE8_RGB5_A1_OES);
451  ION_ADD_CONSTANT(GL_PALETTE8_RGB8_OES);
452  ION_ADD_CONSTANT(GL_PALETTE8_RGBA4_OES);
453  ION_ADD_CONSTANT(GL_PALETTE8_RGBA8_OES);
454  ION_ADD_CONSTANT(GL_POINTS);
455  ION_ADD_CONSTANT(GL_POINT_SIZE_RANGE);
457  ION_ADD_CONSTANT(GL_POLYGON_OFFSET_FACTOR);
458  ION_ADD_CONSTANT(GL_POLYGON_OFFSET_FILL);
459  ION_ADD_CONSTANT(GL_POLYGON_OFFSET_UNITS);
460  ION_ADD_CONSTANT(GL_PRIMITIVES_GENERATED);
462  ION_ADD_CONSTANT(GL_PROGRAM_PIPELINE);
464  ION_ADD_CONSTANT(GL_PROGRAM_POINT_SIZE);
465  ION_ADD_CONSTANT(GL_QUERY);
467 }
468 
469 static void IonAddConstantsRToS(
470  std::unordered_map<int, std::string>* constants) {
471  ION_ADD_CONSTANT(GL_R11F_G11F_B10F);
472  ION_ADD_CONSTANT(GL_R16F);
473  ION_ADD_CONSTANT(GL_R16I);
474  ION_ADD_CONSTANT(GL_R16UI);
475  ION_ADD_CONSTANT(GL_R32F);
476  ION_ADD_CONSTANT(GL_R32I);
477  ION_ADD_CONSTANT(GL_R32UI);
478  ION_ADD_CONSTANT(GL_R8);
479  ION_ADD_CONSTANT(GL_R8I);
480  ION_ADD_CONSTANT(GL_R8UI);
481  ION_ADD_CONSTANT(GL_R8_SNORM);
482  ION_ADD_CONSTANT(GL_RASTERIZER_DISCARD);
483  ION_ADD_CONSTANT(GL_READ_BUFFER);
484  ION_ADD_CONSTANT(GL_READ_FRAMEBUFFER);
485  ION_ADD_CONSTANT(GL_READ_FRAMEBUFFER_BINDING);
486  ION_ADD_CONSTANT(GL_READ_ONLY);
487  ION_ADD_CONSTANT(GL_READ_WRITE);
488  ION_ADD_CONSTANT(GL_RED);
490  ION_ADD_CONSTANT(GL_RED_INTEGER);
491  ION_ADD_CONSTANT(GL_RENDERBUFFER);
492  ION_ADD_CONSTANT(GL_RENDERBUFFER_ALPHA_SIZE);
493  ION_ADD_CONSTANT(GL_RENDERBUFFER_BINDING);
494  ION_ADD_CONSTANT(GL_RENDERBUFFER_BLUE_SIZE);
495  ION_ADD_CONSTANT(GL_RENDERBUFFER_DEPTH_SIZE);
496  ION_ADD_CONSTANT(GL_RENDERBUFFER_GREEN_SIZE);
497  ION_ADD_CONSTANT(GL_RENDERBUFFER_HEIGHT);
498  ION_ADD_CONSTANT(GL_RENDERBUFFER_INTERNAL_FORMAT);
499  ION_ADD_CONSTANT(GL_RENDERBUFFER_RED_SIZE);
500  ION_ADD_CONSTANT(GL_RENDERBUFFER_STENCIL_SIZE);
501  ION_ADD_CONSTANT(GL_RENDERBUFFER_WIDTH);
502  ION_ADD_CONSTANT(GL_RENDERER);
503  ION_ADD_CONSTANT(GL_REPEAT);
504  ION_ADD_CONSTANT(GL_REPLACE);
505  ION_ADD_CONSTANT(GL_RG);
506  ION_ADD_CONSTANT(GL_RG16F);
507  ION_ADD_CONSTANT(GL_RG16I);
508  ION_ADD_CONSTANT(GL_RG16UI);
509  ION_ADD_CONSTANT(GL_RG32F);
510  ION_ADD_CONSTANT(GL_RG32I);
511  ION_ADD_CONSTANT(GL_RG32UI);
512  ION_ADD_CONSTANT(GL_RG8);
513  ION_ADD_CONSTANT(GL_RG8I);
514  ION_ADD_CONSTANT(GL_RG8UI);
515  ION_ADD_CONSTANT(GL_RG8_SNORM);
516  ION_ADD_CONSTANT(GL_RGB);
517  ION_ADD_CONSTANT(GL_RGB10_A2);
518  ION_ADD_CONSTANT(GL_RGB10_A2UI);
519  ION_ADD_CONSTANT(GL_RGB16F);
520  ION_ADD_CONSTANT(GL_RGB16I);
521  ION_ADD_CONSTANT(GL_RGB16UI);
522  ION_ADD_CONSTANT(GL_RGB32F);
523  ION_ADD_CONSTANT(GL_RGB32I);
524  ION_ADD_CONSTANT(GL_RGB32UI);
525  ION_ADD_CONSTANT(GL_RGB565);
526  ION_ADD_CONSTANT(GL_RGB5_A1);
527  ION_ADD_CONSTANT(GL_RGB8);
528  ION_ADD_CONSTANT(GL_RGB8I);
529  ION_ADD_CONSTANT(GL_RGB8UI);
530  ION_ADD_CONSTANT(GL_RGB9_E5);
531  ION_ADD_CONSTANT(GL_RGBA);
532  ION_ADD_CONSTANT(GL_RGBA16F);
533  ION_ADD_CONSTANT(GL_RGBA16I);
534  ION_ADD_CONSTANT(GL_RGBA16UI);
535  ION_ADD_CONSTANT(GL_RGBA32F);
536  ION_ADD_CONSTANT(GL_RGBA32I);
537  ION_ADD_CONSTANT(GL_RGBA32UI);
538  ION_ADD_CONSTANT(GL_RGBA4);
539  ION_ADD_CONSTANT(GL_RGBA8);
540  ION_ADD_CONSTANT(GL_RGBA8I);
541  ION_ADD_CONSTANT(GL_RGBA8UI);
542  ION_ADD_CONSTANT(GL_RGBA8_SNORM);
543  ION_ADD_CONSTANT(GL_RGBA_INTEGER);
544  ION_ADD_CONSTANT(GL_RGB_INTEGER);
545  ION_ADD_CONSTANT(GL_RG_INTEGER);
546  ION_ADD_CONSTANT(GL_RIGHT);
547  ION_ADD_CONSTANT(GL_SAMPLER);
548  ION_ADD_CONSTANT(GL_SAMPLER_1D);
549  ION_ADD_CONSTANT(GL_SAMPLER_1D_ARRAY);
550  ION_ADD_CONSTANT(GL_SAMPLER_1D_ARRAY_SHADOW);
551  ION_ADD_CONSTANT(GL_SAMPLER_1D_SHADOW);
552  ION_ADD_CONSTANT(GL_SAMPLER_2D);
553  ION_ADD_CONSTANT(GL_SAMPLER_2D);
554  ION_ADD_CONSTANT(GL_SAMPLER_2D_ARRAY);
555  ION_ADD_CONSTANT(GL_SAMPLER_2D_ARRAY_SHADOW);
556  ION_ADD_CONSTANT(GL_SAMPLER_2D_MULTISAMPLE);
557  ION_ADD_CONSTANT(GL_SAMPLER_2D_MULTISAMPLE_ARRAY);
558  ION_ADD_CONSTANT(GL_SAMPLER_2D_SHADOW);
559  ION_ADD_CONSTANT(GL_SAMPLER_3D);
560  ION_ADD_CONSTANT(GL_SAMPLER_CUBE);
561  ION_ADD_CONSTANT(GL_SAMPLER_CUBE);
562  ION_ADD_CONSTANT(GL_SAMPLER_CUBE_MAP_ARRAY);
563  ION_ADD_CONSTANT(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW);
564  ION_ADD_CONSTANT(GL_SAMPLER_CUBE_SHADOW);
566  ION_ADD_CONSTANT(GL_SAMPLES);
567  ION_ADD_CONSTANT(GL_SAMPLE_ALPHA_TO_COVERAGE);
568  ION_ADD_CONSTANT(GL_SAMPLE_BUFFERS);
569  ION_ADD_CONSTANT(GL_SAMPLE_COVERAGE);
570  ION_ADD_CONSTANT(GL_SAMPLE_COVERAGE_INVERT);
571  ION_ADD_CONSTANT(GL_SAMPLE_COVERAGE_VALUE);
572  ION_ADD_CONSTANT(GL_SAMPLE_POSITION);
573  ION_ADD_CONSTANT(GL_SEPARATE_ATTRIBS);
574  ION_ADD_CONSTANT(GL_SCISSOR_BOX);
575  ION_ADD_CONSTANT(GL_SCISSOR_TEST);
576  ION_ADD_CONSTANT(GL_SHADER_BINARY_FORMATS);
577  ION_ADD_CONSTANT(GL_SHADER_COMPILER);
579  ION_ADD_CONSTANT(GL_SHADER_SOURCE_LENGTH);
580  ION_ADD_CONSTANT(GL_SHADER_TYPE);
581  ION_ADD_CONSTANT(GL_SHADING_LANGUAGE_VERSION);
582  ION_ADD_CONSTANT(GL_SHORT);
583  ION_ADD_CONSTANT(GL_SIGNALED);
584  ION_ADD_CONSTANT(GL_SRC_ALPHA);
585  ION_ADD_CONSTANT(GL_SRC_ALPHA_SATURATE);
586  ION_ADD_CONSTANT(GL_SRC_COLOR);
587  ION_ADD_CONSTANT(GL_SRGB8);
588  ION_ADD_CONSTANT(GL_SRGB8_ALPHA8);
589  ION_ADD_CONSTANT(GL_STATIC_DRAW);
590  ION_ADD_CONSTANT(GL_STENCIL);
591  ION_ADD_CONSTANT(GL_STENCIL_ATTACHMENT);
592  ION_ADD_CONSTANT(GL_STENCIL_BACK_FAIL);
593  ION_ADD_CONSTANT(GL_STENCIL_BACK_FUNC);
594  ION_ADD_CONSTANT(GL_STENCIL_BACK_PASS_DEPTH_FAIL);
595  ION_ADD_CONSTANT(GL_STENCIL_BACK_PASS_DEPTH_PASS);
596  ION_ADD_CONSTANT(GL_STENCIL_BACK_REF);
597  ION_ADD_CONSTANT(GL_STENCIL_BACK_VALUE_MASK);
598  ION_ADD_CONSTANT(GL_STENCIL_BACK_WRITEMASK);
600  ION_ADD_CONSTANT(GL_STENCIL_CLEAR_VALUE);
601  ION_ADD_CONSTANT(GL_STENCIL_FAIL);
602  ION_ADD_CONSTANT(GL_STENCIL_FUNC);
603  ION_ADD_CONSTANT(GL_STENCIL_INDEX8);
604  ION_ADD_CONSTANT(GL_STENCIL_PASS_DEPTH_FAIL);
605  ION_ADD_CONSTANT(GL_STENCIL_PASS_DEPTH_PASS);
606  ION_ADD_CONSTANT(GL_STENCIL_REF);
607  ION_ADD_CONSTANT(GL_STENCIL_TEST);
608  ION_ADD_CONSTANT(GL_STENCIL_VALUE_MASK);
609  ION_ADD_CONSTANT(GL_STENCIL_WRITEMASK);
610  ION_ADD_CONSTANT(GL_STREAM_DRAW);
611  ION_ADD_CONSTANT(GL_SUBPIXEL_BITS);
612  ION_ADD_CONSTANT(GL_SYNC_CONDITION);
613  ION_ADD_CONSTANT(GL_SYNC_FENCE);
614  ION_ADD_CONSTANT(GL_SYNC_FLAGS);
615  ION_ADD_CONSTANT(GL_SYNC_GPU_COMMANDS_COMPLETE);
616  ION_ADD_CONSTANT(GL_SYNC_STATUS);
617 }
618 
619 static void IonAddConstantsTToZ(
620  std::unordered_map<int, std::string>* constants) {
621  ION_ADD_CONSTANT(GL_TEXTURE);
622  ION_ADD_CONSTANT(GL_TEXTURE0);
623  ION_ADD_CONSTANT(GL_TEXTURE1);
624  ION_ADD_CONSTANT(GL_TEXTURE10);
625  ION_ADD_CONSTANT(GL_TEXTURE11);
626  ION_ADD_CONSTANT(GL_TEXTURE12);
627  ION_ADD_CONSTANT(GL_TEXTURE13);
628  ION_ADD_CONSTANT(GL_TEXTURE14);
629  ION_ADD_CONSTANT(GL_TEXTURE15);
630  ION_ADD_CONSTANT(GL_TEXTURE16);
631  ION_ADD_CONSTANT(GL_TEXTURE17);
632  ION_ADD_CONSTANT(GL_TEXTURE18);
633  ION_ADD_CONSTANT(GL_TEXTURE19);
634  ION_ADD_CONSTANT(GL_TEXTURE2);
635  ION_ADD_CONSTANT(GL_TEXTURE20);
636  ION_ADD_CONSTANT(GL_TEXTURE21);
637  ION_ADD_CONSTANT(GL_TEXTURE22);
638  ION_ADD_CONSTANT(GL_TEXTURE23);
639  ION_ADD_CONSTANT(GL_TEXTURE24);
640  ION_ADD_CONSTANT(GL_TEXTURE25);
641  ION_ADD_CONSTANT(GL_TEXTURE26);
642  ION_ADD_CONSTANT(GL_TEXTURE27);
643  ION_ADD_CONSTANT(GL_TEXTURE28);
644  ION_ADD_CONSTANT(GL_TEXTURE29);
645  ION_ADD_CONSTANT(GL_TEXTURE3);
646  ION_ADD_CONSTANT(GL_TEXTURE30);
647  ION_ADD_CONSTANT(GL_TEXTURE31);
648  ION_ADD_CONSTANT(GL_TEXTURE4);
649  ION_ADD_CONSTANT(GL_TEXTURE5);
650  ION_ADD_CONSTANT(GL_TEXTURE6);
651  ION_ADD_CONSTANT(GL_TEXTURE7);
652  ION_ADD_CONSTANT(GL_TEXTURE8);
653  ION_ADD_CONSTANT(GL_TEXTURE9);
654  ION_ADD_CONSTANT(GL_TEXTURE_1D_ARRAY);
655  ION_ADD_CONSTANT(GL_TEXTURE_2D);
656  ION_ADD_CONSTANT(GL_TEXTURE_2D_ARRAY);
657  ION_ADD_CONSTANT(GL_TEXTURE_2D_MULTISAMPLE);
658  ION_ADD_CONSTANT(GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
659  ION_ADD_CONSTANT(GL_TEXTURE_3D);
660  ION_ADD_CONSTANT(GL_TEXTURE_BASE_LEVEL);
661  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_1D_ARRAY);
662  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_2D);
663  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_2D_ARRAY);
664  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_2D_MULTISAMPLE);
665  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY);
666  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_3D);
667  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_BUFFER);
668  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_CUBE_MAP);
669  ION_ADD_CONSTANT(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY);
671  ION_ADD_CONSTANT(GL_TEXTURE_COMPARE_FUNC);
672  ION_ADD_CONSTANT(GL_TEXTURE_COMPARE_MODE);
673  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP);
674  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_ARRAY);
675  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X);
676  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
677  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
678  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_POSITIVE_X);
679  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y);
680  ION_ADD_CONSTANT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z);
682  ION_ADD_CONSTANT(GL_TEXTURE_IMMUTABLE_FORMAT);
683  ION_ADD_CONSTANT(GL_TEXTURE_MAG_FILTER);
684  ION_ADD_CONSTANT(GL_TEXTURE_MAX_ANISOTROPY_EXT);
685  ION_ADD_CONSTANT(GL_TEXTURE_MAX_LEVEL);
686  ION_ADD_CONSTANT(GL_TEXTURE_MAX_LOD);
687  ION_ADD_CONSTANT(GL_TEXTURE_MIN_FILTER);
688  ION_ADD_CONSTANT(GL_TEXTURE_MIN_LOD);
689  ION_ADD_CONSTANT(GL_TEXTURE_SWIZZLE_A);
690  ION_ADD_CONSTANT(GL_TEXTURE_SWIZZLE_B);
691  ION_ADD_CONSTANT(GL_TEXTURE_SWIZZLE_G);
692  ION_ADD_CONSTANT(GL_TEXTURE_SWIZZLE_R);
693  ION_ADD_CONSTANT(GL_TEXTURE_WRAP_R);
694  ION_ADD_CONSTANT(GL_TEXTURE_WRAP_S);
695  ION_ADD_CONSTANT(GL_TEXTURE_WRAP_T);
696  ION_ADD_CONSTANT(GL_TIMEOUT_EXPIRED);
697  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK);
698  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_ACTIVE);
699  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BINDING);
700  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER);
701  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE);
702  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING);
703  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_MODE);
704  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED);
705  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE);
706  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_BUFFER_START);
707  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_PAUSED);
708  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
709  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_VARYINGS);
710  ION_ADD_CONSTANT(GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH);
711  ION_ADD_CONSTANT(GL_TRIANGLES);
712  ION_ADD_CONSTANT(GL_TRIANGLE_FAN);
713  ION_ADD_CONSTANT(GL_TRIANGLE_STRIP);
714  ION_ADD_CONSTANT(GL_UNPACK_ALIGNMENT);
715  ION_ADD_CONSTANT(GL_UNSIGNALED);
716  ION_ADD_CONSTANT(GL_UNSIGNED_BYTE);
717  ION_ADD_CONSTANT(GL_UNSIGNED_INT);
718  ION_ADD_CONSTANT(GL_UNSIGNED_INT_10F_11F_11F_REV);
719  ION_ADD_CONSTANT(GL_UNSIGNED_INT_24_8);
720  ION_ADD_CONSTANT(GL_UNSIGNED_INT_2_10_10_10_REV);
721  ION_ADD_CONSTANT(GL_UNSIGNED_INT_5_9_9_9_REV);
722  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_1D);
723  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY);
724  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_2D);
725  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY);
726  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_3D);
727  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_CUBE);
728  ION_ADD_CONSTANT(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY);
729  ION_ADD_CONSTANT(GL_UNSIGNED_INT_VEC2);
730  ION_ADD_CONSTANT(GL_UNSIGNED_INT_VEC3);
731  ION_ADD_CONSTANT(GL_UNSIGNED_INT_VEC4);
732  ION_ADD_CONSTANT(GL_UNSIGNED_SHORT);
733  ION_ADD_CONSTANT(GL_UNSIGNED_SHORT_4_4_4_4);
734  ION_ADD_CONSTANT(GL_UNSIGNED_SHORT_5_5_5_1);
735  ION_ADD_CONSTANT(GL_UNSIGNED_SHORT_5_6_5);
736  ION_ADD_CONSTANT(GL_VALIDATE_STATUS);
737  ION_ADD_CONSTANT(GL_VENDOR);
738  ION_ADD_CONSTANT(GL_VERSION);
739  ION_ADD_CONSTANT(GL_VERTEX_ARRAY_BINDING);
741  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
742  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_DIVISOR);
743  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_ENABLED);
744  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_NORMALIZED);
745  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_POINTER);
746  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_SIZE);
747  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_STRIDE);
748  ION_ADD_CONSTANT(GL_VERTEX_ATTRIB_ARRAY_TYPE);
749  ION_ADD_CONSTANT(GL_VERTEX_SHADER);
750  ION_ADD_CONSTANT(GL_VIEWPORT);
751  ION_ADD_CONSTANT(GL_WAIT_FAILED);
752  ION_ADD_CONSTANT(GL_WRITE_ONLY);
754 }
755 #undef ION_ADD_CONSTANT
756 
757 } // anonymous namespace
758 
760  IonAddConstantsAToF(&constants_);
761  IonAddConstantsGToQ(&constants_);
762  IonAddConstantsRToS(&constants_);
763  IonAddConstantsTToZ(&constants_);
764 }
765 
767 template <typename T>
768 const std::string TracingHelper::ToString(const char* arg_type, T arg) {
770  const std::string arg_type_str(arg_type);
771  if (arg_type_str.find('*') != std::string::npos ||
772  arg_type_str.find("PROC") != std::string::npos) {
773  if (arg != static_cast<T>(0)) {
774  std::ostringstream out;
775  out << "0x" << std::hex << *reinterpret_cast<size_t*>(&arg);
776 
778  out << ArrayToString(arg_type, arg);
779  return out.str();
780  } else {
781  return "NULL";
782  }
783  }
784 
785  return AnyToString(arg);
786 }
787 
789 template <> ION_API
790 const std::string TracingHelper::ToString(const char* arg_type,
791  const char* arg) {
792  return std::string("\"") + arg + '"';
793 }
794 
796 template <> ION_API
797 const std::string TracingHelper::ToString(const char* arg_type, char* arg) {
798  return std::string("\"") + arg + '"';
799 }
800 
802 template <> ION_API const std::string TracingHelper::ToString(
803  const char* arg_type, const char** arg) {
804  return arg ? "[" + ToString(arg_type, arg[0]) + ", ...]" : "NULL";
805 }
806 
808 template <> ION_API
809 const std::string TracingHelper::ToString(
810  const char* arg_type, unsigned char arg) {
812  switch (arg) {
813  case 0:
814  return "GL_FALSE";
815  case 1:
816  return "GL_TRUE";
817  default: {
818  return AnyToString(static_cast<int>(arg));
819  }
820  }
821 }
822 
824 template <> ION_API
825 const std::string TracingHelper::ToString(const char* arg_type, int arg) {
827  if (!strcmp(arg_type, "GLtextureenum")) {
830  if (arg >= 0 && !constants_[arg].empty()) {
831  switch (arg) {
832  case 0:
833  return "GL_NONE";
834  case GL_ALPHA:
835  case GL_ALWAYS:
836  case GL_BLUE:
837  case GL_CLAMP_TO_EDGE:
838  case GL_COMPARE_REF_TO_TEXTURE:
839  case GL_EQUAL:
840  case GL_GEQUAL:
841  case GL_GREATER:
842  case GL_GREEN:
843  case GL_LESS:
844  case GL_LINEAR:
845  case GL_LINEAR_MIPMAP_LINEAR:
846  case GL_LINEAR_MIPMAP_NEAREST:
847  case GL_LEQUAL:
848  case GL_MIRRORED_REPEAT:
849  case GL_NEAREST:
850  case GL_NEAREST_MIPMAP_NEAREST:
851  case GL_NEAREST_MIPMAP_LINEAR:
852  case GL_NEVER:
853  case GL_NOTEQUAL:
854  case GL_RED:
855  case GL_REPEAT:
856  return constants_[arg];
857  default:
858  break;
859  }
860  const std::string& name = constants_[arg];
861  if (base::StartsWith(name, "GL_TEXTURE"))
862  return constants_[arg];
863  }
864  } else if (!strcmp(arg_type, "GLintenum")) {
865  if (arg >= 0 && !constants_[arg].empty()) {
866  return constants_[arg];
867  }
868  }
869 
870  return AnyToString(arg);
871 }
872 
874 template <> ION_API
875 const std::string TracingHelper::ToString(const char* arg_type,
876  unsigned int arg) {
879  if (!strcmp(arg_type, "GLblendenum")) {
880  if (arg == GL_ZERO)
881  return "GL_ZERO";
882  else if (arg == GL_ONE)
883  return "GL_ONE";
884  else if (!constants_[arg].empty())
885  return constants_[arg];
886  } else if (!strcmp(arg_type, "GLstencilenum")) {
887  if (arg == GL_ZERO)
888  return "GL_ZERO";
889  else if (!constants_[arg].empty())
890  return constants_[arg];
891  } else if (!strcmp(arg_type, "GLenum")) {
892  if (!constants_[arg].empty())
893  return constants_[arg];
894  } else if (!strcmp(arg_type, "GLbitfield")) {
896  const std::string s = GetClearBitsString(arg);
897  if (!s.empty())
898  return s;
899  } else if (!strcmp(arg_type, "GLmapaccess")) {
901  const std::string s = GetMapBitsString(arg);
902  if (!s.empty())
903  return s;
904  } else if (!strcmp(arg_type, "GLtextureenum")) {
905  if (arg == GL_NONE)
906  return "GL_NONE";
907  else if (!constants_[arg].empty())
908  return constants_[arg];
909  }
910  return AnyToString(arg);
911 }
912 
914 template ION_API const std::string TracingHelper::ToString(
915  const char*, const float*);
916 template ION_API const std::string TracingHelper::ToString(
917  const char*, const int*);
918 template ION_API const std::string TracingHelper::ToString(
919  const char*, const unsigned char*);
920 template ION_API const std::string TracingHelper::ToString(
921  const char*, const unsigned int*);
922 template ION_API const std::string TracingHelper::ToString(
923  const char*, const void*);
924 template ION_API const std::string TracingHelper::ToString(
925  const char*, float);
926 template ION_API const std::string TracingHelper::ToString(
927  const char*, float*);
928 template ION_API const std::string TracingHelper::ToString(
929  const char*, int*);
930 template ION_API const std::string TracingHelper::ToString(
931  const char*, long); // NOLINT
932 template ION_API const std::string TracingHelper::ToString(
933  const char*, long*); // NOLINT
934 template ION_API const std::string TracingHelper::ToString(
935  const char*, long long); // NOLINT
936 template ION_API const std::string TracingHelper::ToString(
937  const char*, long long*); // NOLINT
938 template ION_API const std::string TracingHelper::ToString(
939  const char*, unsigned char*);
940 template ION_API const std::string TracingHelper::ToString(
941  const char*, unsigned int*);
942 template ION_API const std::string TracingHelper::ToString(
943  const char*, unsigned long); // NOLINT
944 template ION_API const std::string TracingHelper::ToString(
945  const char*, unsigned long*); // NOLINT
946 template ION_API const std::string TracingHelper::ToString(
947  const char*, unsigned long long); // NOLINT
948 template ION_API const std::string TracingHelper::ToString(
949  const char*, unsigned long long*); // NOLINT
950 template ION_API const std::string TracingHelper::ToString(
951  const char*, void*);
952 template ION_API const std::string TracingHelper::ToString(
953  const char*, void**);
954 template ION_API const std::string TracingHelper::ToString(
955  const char*, GLsync);
956 template ION_API const std::string TracingHelper::ToString(const char*,
957  GLDEBUGPROC);
958 
959 #endif // ION_PRODUCTION
960 
961 } // namespace gfx
962 } // namespace ion
#define GL_TEXTURE_BINDING_EXTERNAL_OES
Definition: glheaders.h:1008
#define GL_PROGRAM_OBJECT
Definition: glheaders.h:624
#define GL_BLUE_BITS
Definition: glheaders.h:159
bool StartsWith(const std::string &target, const std::string &start)
Returns whether target begins with start.
Definition: stringutils.h:76
#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
Definition: glheaders.h:195
std::string type
Definition: printer.cc:353
#define GL_GREEN_BITS
Definition: glheaders.h:411
#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
Definition: glheaders.h:192
#define GL_LUMINANCE_ALPHA
Definition: glheaders.h:468
#define GL_DEPTH_BITS
Definition: glheaders.h:321
#define GL_PROGRAM_PIPELINE_OBJECT
Definition: glheaders.h:630
struct __GLsync * GLsync
Definition: glheaders.h:132
#define GL_ALPHA_BITS
Definition: glheaders.h:141
const std::string ToString(const char *arg_type, T arg)
This templated function is used to print each OpenGL function argument in a more readable way...
#define GL_CONDITION_SATISFIED
Definition: glheaders.h:228
#define GL_SAMPLER_EXTERNAL_OES
Definition: glheaders.h:912
#define GL_RED_BITS
Definition: glheaders.h:705
#define GL_BUFFER_OBJECT
Definition: glheaders.h:165
#define GL_GENERATE_MIPMAP_HINT
Definition: glheaders.h:402
#define GL_POINT_SPRITE
Definition: glheaders.h:618
#define GL_ALIASED_POINT_SIZE_RANGE
These constants are not always defined in OpenGL header files.
Definition: glheaders.h:138
TracingHelper()
The constructor sets up the data necessary to map OpenGL constant values to mnemonic names...
#define ION_ADD_CONSTANT(name)
std::string name
Definition: printer.cc:324
int32 ION_API StringToInt32(const std::string &str)
Extracts and returns an integral value from str.
Definition: stringutils.cc:328
#define GL_SHADER_OBJECT
Definition: glheaders.h:924
#define GL_QUERY_OBJECT
Definition: glheaders.h:642
#define GL_STENCIL_BITS
Definition: glheaders.h:942
#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
Definition: glheaders.h:198
#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
Definition: glheaders.h:189
#define GL_TEXTURE_EXTERNAL_OES
Definition: glheaders.h:1029
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS
Definition: glheaders.h:381
#define GL_LUMINANCE
Definition: glheaders.h:465
#define GL_ETC1_RGB8_OES
Definition: glheaders.h:345
#define GL_VERTEX_ARRAY_OBJECT
Definition: glheaders.h:1170