summaryrefslogtreecommitdiff
path: root/retrace/daemon/gldispatch/glframe_glhelper.cpp
blob: 32cabac82685ee7cd3262e54efb84c1b3e7714f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
// Copyright (C) Intel Corp.  2015.  All Rights Reserved.

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:

// The above copyright notice and this permission notice (including the
// next paragraph) shall be included in all copies or substantial
// portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

//  **********************************************************************/
//  * Authors:
//  *   Mark Janes <mark.a.janes@intel.com>
//  **********************************************************************/

#include "glframe_glhelper.hpp"

#include <assert.h>
#ifdef WIN32
#include "retrace.hpp"
#include "glretrace.hpp"
#include "glws.hpp"
#else
#include <dlfcn.h>
#endif

using glretrace::GlFunctions;

bool GlFunctions::m_is_initialized = false;

namespace {
static void *pCreateProgram = NULL;
static void *pCreateShader = NULL;
static void *pShaderSource = NULL;
static void *pCompileShader = NULL;
static void *pAttachShader = NULL;
static void *pLinkProgram = NULL;
static void *pUseProgram = NULL;
static void *pGetError = NULL;
static void *pGetShaderiv = NULL;
static void *pGetShaderInfoLog = NULL;
static void *pGenBuffers = NULL;
static void *pBindBuffer = NULL;
static void *pGetAttribLocation = NULL;
static void *pGetUniformLocation = NULL;
static void *pClearColor = NULL;
static void *pClear = NULL;
static void *pUniform1f = NULL;
static void *pUniform4f = NULL;
static void *pBufferData = NULL;
static void *pEnableVertexAttribArray = NULL;
static void *pVertexAttribPointer = NULL;
static void *pDrawArrays = NULL;
static void *pDisableVertexAttribArray = NULL;
static void *pEnable = NULL;
static void *pReadPixels = NULL;
static void *pDrawElements = NULL;
static void *pBlendFunc = NULL;
static void *pGetFirstPerfQueryIdINTEL = NULL;
static void *pGetNextPerfQueryIdINTEL = NULL;
static void *pGetIntegerv = NULL;
static void *pGetStringi = NULL;
static void *pGetPerfQueryInfoINTEL = NULL;
static void *pGetPerfCounterInfoINTEL = NULL;
static void *pCreatePerfQueryINTEL = NULL;
static void *pDeletePerfQueryINTEL = NULL;
static void *pBeginPerfQueryINTEL = NULL;
static void *pEndPerfQueryINTEL = NULL;
static void *pGetPerfQueryDataINTEL = NULL;
static void *pGetProgramiv = NULL;
static void *pGetProgramInfoLog = NULL;
static void *pGetBooleanv = NULL;
static void *pGetFloatv = NULL;
static void *pBlendColor = NULL;
static void *pBlendFuncSeparate = NULL;
static void *pDisable = NULL;
static void *pBlendEquation = NULL;
static void *pBlendEquationSeparate = NULL;
static void *pBindAttribLocation = NULL;
static void *pValidateProgram = NULL;
static void *pIsEnabled = NULL;
static void *pGetUniformBlockIndex = NULL;
static void *pUniformBlockBinding = NULL;

}  // namespace

static void * _GetProcAddress(const char *name) {
  typedef void* (* GETPROCADDRESS) (const char *procName);
  static GETPROCADDRESS lookup_fn = NULL;
#ifdef WIN32
  static HMODULE lib_handle = NULL;
  if (!lib_handle) {
    char szDll[MAX_PATH] = {0};
    if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
      return NULL;
    }
    strncat(szDll, "\\opengl32.dll", MAX_PATH - 1);
    lib_handle = LoadLibraryA(szDll);
  }
  if (!lookup_fn) {
    lookup_fn = (GETPROCADDRESS) GetProcAddress(lib_handle,
                                                "wglGetProcAddress");
  }
#else
  static void *lib_handle = NULL;
  lib_handle = dlopen("libGL.so", RTLD_LAZY | RTLD_GLOBAL);
  lookup_fn = reinterpret_cast<GETPROCADDRESS>(dlsym(lib_handle,
                                                     "glXGetProcAddress"));
#endif
  assert(lookup_fn);
  void* ret = lookup_fn(name);
#ifdef WIN32
  if (ret == NULL)
    ret = GetProcAddress(lib_handle, name);
  if (ret == NULL)
    ret = wglGetProcAddress(name);
#endif
  assert(ret);
  return ret;
}
void
GlFunctions::Init(void *lookup_fn) {
  if (m_is_initialized)
    return;

#ifdef WIN32
  // GetProcAddress will return null on windows unless there is an
  // active GL context.
  retrace::setUp();
  glws::Drawable *d = glretrace::createDrawable();
  glretrace::Context *c = glretrace::createContext();
  glws::makeCurrent(d, c->wsContext);
#endif

  pCreateProgram = _GetProcAddress("glCreateProgram");
  assert(pCreateProgram);

  pCreateShader = _GetProcAddress("glCreateShader");
  assert(pCreateShader);
  pShaderSource = _GetProcAddress("glShaderSource");
  assert(pShaderSource);
  pCompileShader = _GetProcAddress("glCompileShader");
  assert(pCompileShader);
  pAttachShader = _GetProcAddress("glAttachShader");
  assert(pAttachShader);
  pLinkProgram = _GetProcAddress("glLinkProgram");
  assert(pLinkProgram);
  pUseProgram = _GetProcAddress("glUseProgram");
  assert(pUseProgram);
  pGetError = _GetProcAddress("glGetError");
  assert(pGetError);
  pGetShaderiv = _GetProcAddress("glGetShaderiv");
  assert(pGetShaderiv);
  pGetShaderInfoLog = _GetProcAddress("glGetShaderInfoLog");
  assert(pGetShaderInfoLog);
  pGenBuffers = _GetProcAddress("glGenBuffers");
  assert(pGenBuffers);
  pBindBuffer = _GetProcAddress("glBindBuffer");
  assert(pBindBuffer);
  pGetAttribLocation = _GetProcAddress("glGetAttribLocation");
  assert(pGetAttribLocation);
  pGetUniformLocation = _GetProcAddress("glGetUniformLocation");
  assert(pGetUniformLocation);
  pClearColor = _GetProcAddress("glClearColor");
  assert(pClearColor);
  pClear = _GetProcAddress("glClear");
  assert(pClear);
  pUniform1f = _GetProcAddress("glUniform1f");
  assert(pUniform1f);
  pUniform4f = _GetProcAddress("glUniform4f");
  assert(pUniform4f);
  pBufferData = _GetProcAddress("glBufferData");
  assert(pBufferData);
  pEnableVertexAttribArray = _GetProcAddress("glEnableVertexAttribArray");
  assert(pEnableVertexAttribArray);
  pVertexAttribPointer = _GetProcAddress("glVertexAttribPointer");
  assert(pVertexAttribPointer);
  pDrawArrays = _GetProcAddress("glDrawArrays");
  assert(pDrawArrays);
  pDisableVertexAttribArray = _GetProcAddress("glDisableVertexAttribArray");
  assert(pDisableVertexAttribArray);
  pEnable = _GetProcAddress("glEnable");
  assert(pEnable);
  pReadPixels = _GetProcAddress("glReadPixels");
  assert(pReadPixels);
  pDrawElements = _GetProcAddress("glDrawElements");
  assert(pDrawElements);
  pBlendFunc = _GetProcAddress("glBlendFunc");
  assert(pBlendFunc);
  pGetFirstPerfQueryIdINTEL = _GetProcAddress("glGetFirstPerfQueryIdINTEL");
  assert(pGetFirstPerfQueryIdINTEL);
  pGetNextPerfQueryIdINTEL = _GetProcAddress("glGetNextPerfQueryIdINTEL");
  assert(pGetNextPerfQueryIdINTEL);
  pGetIntegerv = _GetProcAddress("glGetIntegerv");
  assert(pGetIntegerv);
  pGetStringi = _GetProcAddress("glGetStringi");
  assert(pGetStringi);
  pGetPerfQueryInfoINTEL = _GetProcAddress("glGetPerfQueryInfoINTEL");
  assert(pGetPerfQueryInfoINTEL);
  pGetPerfCounterInfoINTEL = _GetProcAddress("glGetPerfCounterInfoINTEL");
  assert(pGetPerfCounterInfoINTEL);
  pCreatePerfQueryINTEL = _GetProcAddress("glCreatePerfQueryINTEL");
  assert(pCreatePerfQueryINTEL);
  pDeletePerfQueryINTEL = _GetProcAddress("glDeletePerfQueryINTEL");
  assert(pDeletePerfQueryINTEL);
  pBeginPerfQueryINTEL = _GetProcAddress("glBeginPerfQueryINTEL");
  assert(pBeginPerfQueryINTEL);
  pEndPerfQueryINTEL = _GetProcAddress("glEndPerfQueryINTEL");
  assert(pEndPerfQueryINTEL);
  pGetPerfQueryDataINTEL = _GetProcAddress("glGetPerfQueryDataINTEL");
  assert(pGetPerfQueryDataINTEL);
  pGetProgramiv = _GetProcAddress("glGetProgramiv");
  assert(pGetProgramiv);
  pGetProgramInfoLog = _GetProcAddress("glGetProgramInfoLog");
  assert(pGetProgramInfoLog);
  pGetBooleanv = _GetProcAddress("glGetBooleanv");
  assert(pGetBooleanv);
  pGetFloatv = _GetProcAddress("glGetFloatv");
  assert(pGetFloatv);
  pBlendColor = _GetProcAddress("glBlendColor");
  assert(pBlendColor);
  pBlendFuncSeparate = _GetProcAddress("glBlendFuncSeparate");
  assert(pBlendFuncSeparate);
  pDisable = _GetProcAddress("glDisable");
  assert(pDisable);
  pBlendEquation = _GetProcAddress("glBlendEquation");
  assert(pBlendEquation);
  pBlendEquationSeparate = _GetProcAddress("glBlendEquationSeparate");
  assert(pBlendEquationSeparate);
  pBindAttribLocation = _GetProcAddress("glBindAttribLocation");
  assert(pBindAttribLocation);
  pValidateProgram = _GetProcAddress("glValidateProgram");
  assert(pValidateProgram);
  pIsEnabled = _GetProcAddress("glIsEnabled");
  assert(pIsEnabled);
  pGetUniformBlockIndex = _GetProcAddress("glGetUniformBlockIndex");
  assert(pGetUniformBlockIndex);
  pUniformBlockBinding = _GetProcAddress("glUniformBlockBinding");
  assert(pUniformBlockBinding);
}

GLuint
GlFunctions::CreateProgram(void) {
  typedef GLuint(*CREATEPROGRAM)();
  return ((CREATEPROGRAM)pCreateProgram)();
}

GLuint
GlFunctions::CreateShader(GLenum type) {
  typedef GLuint (*CREATESHADER)(GLenum type);
  return ((CREATESHADER)pCreateShader)(type);
}

void
GlFunctions::ShaderSource(GLuint shader, GLsizei count,
                          const GLchar *const*str,
                          const GLint *length) {
  typedef void (*SHADERSOURCE)(GLuint shader, GLsizei count,
                               const GLchar *const*str,
                               const GLint *length);
  ((SHADERSOURCE)pShaderSource)(shader, count, str, length);
}

void
GlFunctions::CompileShader(GLuint shader) {
  typedef void (*COMPILESHADER)(GLuint shader);
  ((COMPILESHADER)pCompileShader)(shader);
}

void
GlFunctions::AttachShader(GLuint program, GLuint shader) {
  typedef void (*ATTACHSHADER)(GLuint program, GLuint shader);
  ((ATTACHSHADER)pAttachShader)(program, shader);
}

void
GlFunctions::LinkProgram(GLuint program) {
  typedef void (*LINKPROGRAM)(GLuint program);
  ((LINKPROGRAM)pLinkProgram)(program);
}

void
GlFunctions::UseProgram(GLuint program) {
  typedef void (*USEPROGRAM)(GLuint program);
  ((USEPROGRAM)pUseProgram)(program);
}

GLenum
GlFunctions::GetError() {
  typedef GLenum (*GETERROR)();
  return ((GETERROR)pGetError)();
}

void
GlFunctions::GetShaderiv(GLuint shader, GLenum pname, GLint *params) {
  typedef void (*GETSHADERIV)(GLuint shader, GLenum pname, GLint *params);
  ((GETSHADERIV)pGetShaderiv)(shader, pname, params);
}

void
GlFunctions::GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length,
                              GLchar *infoLog) {
  typedef void (*GETSHADERINFOLOG)(GLuint shader, GLsizei bufSize,
                                   GLsizei *length, GLchar *infoLog);
  ((GETSHADERINFOLOG)pGetShaderInfoLog)(shader, bufSize,
                                        length, infoLog);
}

void
GlFunctions::GenBuffers(GLsizei n, GLuint *buffers) {
  typedef void (*GENBUFFERS)(GLsizei n, GLuint *buffers);
  ((GENBUFFERS) pGenBuffers)(n, buffers);
}

void
GlFunctions::BindBuffer(GLenum target, GLuint buffer) {
  typedef void (*BINDBUFFER)(GLenum target, GLuint buffer);
  ((BINDBUFFER)pBindBuffer)(target, buffer);
}

GLint
GlFunctions::GetAttribLocation(GLuint program, const GLchar *name) {
  typedef GLint (*GETATTRIBLOCATION)(GLuint program, const GLchar *name);
  return ((GETATTRIBLOCATION)pGetAttribLocation)(program, name);
}

GLint
GlFunctions::GetUniformLocation(GLuint program, const GLchar *name) {
  typedef GLint (*GETUNIFORMLOCATION)(GLuint program, const GLchar *name);
  return ((GETUNIFORMLOCATION)pGetUniformLocation)(program, name);
}

void
GlFunctions::ClearColor(GLclampf red, GLclampf green, GLclampf blue,
                        GLclampf alpha) {
  typedef void (*CLEARCOLOR)(GLclampf red, GLclampf green, GLclampf blue,
                             GLclampf alpha);
  ((CLEARCOLOR)pClearColor)(red, green, blue, alpha);
}

void
GlFunctions::Clear(GLbitfield mask) {
  typedef void(*CLEAR)(GLbitfield mask);
  ((CLEAR)pClear)(mask);
}


void
GlFunctions::Uniform1f(GLint location, GLfloat v0) {
  typedef void (*UNIFORM1F)(GLint location, GLfloat v0);
  ((UNIFORM1F)pUniform1f)(location, v0);
}

void
GlFunctions::Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
                       GLfloat v3) {
  typedef void (*UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
                            GLfloat v3);
  ((UNIFORM4F)pUniform4f)(location, v0, v1, v2, v3);
}

void
GlFunctions::BufferData(GLenum target, GLsizeiptr size, const void *data,
                        GLenum usage) {
  typedef void (*BUFFERDATA) (GLenum target, GLsizeiptr size, const void *data,
                              GLenum usage);
  ((BUFFERDATA)pBufferData) (target, size, data, usage);
}

void
GlFunctions::EnableVertexAttribArray(GLuint index) {
  typedef void (*ENABLEVERTEXATTRIBARRAY)(GLuint index);
  ((ENABLEVERTEXATTRIBARRAY)pEnableVertexAttribArray)(index);
}

void
GlFunctions::VertexAttribPointer(GLuint index, GLint size, GLenum type,
                                 GLboolean normalized, GLsizei stride,
                                 const void *pointer) {
  typedef void (*VERTEXATTRIBPOINTER)(GLuint index, GLint size, GLenum type,
                                      GLboolean normalized, GLsizei stride,
                                      const void *pointer);
  ((VERTEXATTRIBPOINTER)pVertexAttribPointer)(index, size,
                                              type, normalized,
                                              stride, pointer);
}

void
GlFunctions::DrawArrays(GLenum mode, GLint first, GLsizei count) {
  typedef void (*DRAWARRAYS)(GLenum mode, GLint first, GLsizei count);
  ((DRAWARRAYS)pDrawArrays)(mode, first, count);
}

void
GlFunctions::DisableVertexAttribArray(GLuint index) {
  typedef void (*DISABLEVERTEXATTRIBARRAY)(GLuint index);
  ((DISABLEVERTEXATTRIBARRAY)pDisableVertexAttribArray)(index);
}

void
GlFunctions::Enable(GLenum cap) {
  typedef void (*ENABLE)(GLenum cap);
  ((ENABLE)pEnable)(cap);
}


void
GlFunctions::ReadPixels(GLint x, GLint y,
                        GLsizei width, GLsizei height,
                        GLenum format, GLenum type,
                        GLvoid *pixels) {
  typedef void (*READPIXELS)(GLint x, GLint y,
                             GLsizei width, GLsizei height,
                             GLenum format, GLenum type,
                             GLvoid *pixels);
  ((READPIXELS)pReadPixels)(x, y, width, height, format, type, pixels);
}

void
GlFunctions::DrawElements(GLenum mode, GLsizei count,
                          GLenum type, const GLvoid *indices) {
  typedef void (*DRAWELEMENTS)(GLenum mode, GLsizei count,
                               GLenum type, const GLvoid *indices);
  ((DRAWELEMENTS) pDrawElements)(mode, count, type, indices);
}

void
GlFunctions::BlendFunc(GLenum sfactor, GLenum dfactor) {
  typedef void (*BLENDFUNC)(GLenum sfactor, GLenum dfactor);
  ((BLENDFUNC) pBlendFunc)(sfactor, dfactor);
}

void
GlFunctions::GetFirstPerfQueryIdINTEL(GLuint *queryId) {
  if (!pGetFirstPerfQueryIdINTEL) {
    *queryId = -1;
    return;
  }
  typedef void (*GETFIRSTPERFQUERYIDINTEL)(GLuint *queryId);
  ((GETFIRSTPERFQUERYIDINTEL) pGetFirstPerfQueryIdINTEL)(queryId);
}

void
GlFunctions::GetNextPerfQueryIdINTEL(GLuint queryId, GLuint *nextQueryId) {
  typedef void (*GETNEXTPERFQUERYIDINTEL)(GLuint queryId, GLuint *nextQueryId);
  ((GETNEXTPERFQUERYIDINTEL) pGetNextPerfQueryIdINTEL)(queryId, nextQueryId);
}

void
GlFunctions::GetIntegerv(GLenum pname, GLint *params) {
  typedef void (*GETINTEGERV)(GLenum pname, GLint *params);
  ((GETINTEGERV)pGetIntegerv)(pname, params);
}

const GLubyte *
GlFunctions::GetStringi(GLenum pname, GLuint index) {
  typedef const GLubyte * (*GETSTRINGI)(GLenum pname, GLuint index);
  return ((GETSTRINGI)pGetStringi)(pname, index);
}

void GlFunctions::GetPerfQueryInfoINTEL(GLuint queryId, GLuint queryNameLength,
                                        GLchar *queryName, GLuint *dataSize,
                                        GLuint *noCounters, GLuint *noInstances,
                                        GLuint *capsMask) {
  typedef void (*GETPERFQUERYINFOINTEL)(GLuint queryId, GLuint queryNameLength,
                                        GLchar *queryName, GLuint *dataSize,
                                        GLuint *noCounters, GLuint *noInstances,
                                        GLuint *capsMask);
  ((GETPERFQUERYINFOINTEL)pGetPerfQueryInfoINTEL)(queryId, queryNameLength,
                                                  queryName, dataSize,
                                                  noCounters, noInstances,
                                                  capsMask);
}

void
GlFunctions::GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId,
                                     GLuint counterNameLength,
                                     GLchar *counterName,
                                     GLuint counterDescLength,
                                     GLchar *counterDesc,
                                     GLuint *counterOffset,
                                     GLuint *counterDataSize,
                                     GLuint *counterTypeEnum,
                                     GLuint *counterDataTypeEnum,
                                     GLuint64 *rawCounterMaxValue) {
  typedef void (*GETPERFCOUNTERINFOINTEL)(GLuint queryId, GLuint counterId,
                                          GLuint counterNameLength,
                                          GLchar *counterName,
                                          GLuint counterDescLength,
                                          GLchar *counterDesc,
                                          GLuint *counterOffset,
                                          GLuint *counterDataSize,
                                          GLuint *counterTypeEnum,
                                          GLuint *counterDataTypeEnum,
                                          GLuint64 *rawCounterMaxValue);
  ((GETPERFCOUNTERINFOINTEL)pGetPerfCounterInfoINTEL)(queryId,
                                                      counterId,
                                                      counterNameLength,
                                                      counterName,
                                                      counterDescLength,
                                                      counterDesc,
                                                      counterOffset,
                                                      counterDataSize,
                                                      counterTypeEnum,
                                                      counterDataTypeEnum,
                                                      rawCounterMaxValue);
}

void GlFunctions::CreatePerfQueryINTEL(GLuint queryId, GLuint *queryHandle) {
  typedef void (*CREATEPERFQUERYINTEL)(GLuint queryId, GLuint *queryHandle);
  ((CREATEPERFQUERYINTEL)pCreatePerfQueryINTEL)(queryId, queryHandle);
}

void GlFunctions::DeletePerfQueryINTEL(GLuint queryHandle) {
  typedef void (*DELETEPERFQUERYINTEL)(GLuint queryHandle);
  ((DELETEPERFQUERYINTEL)pDeletePerfQueryINTEL)(queryHandle);
}

void
GlFunctions::BeginPerfQueryINTEL(GLuint queryHandle) {
  typedef void (*BEGINPERFQUERYINTEL)(GLuint queryHandle);
  ((BEGINPERFQUERYINTEL) pBeginPerfQueryINTEL)(queryHandle);
}

void
GlFunctions::EndPerfQueryINTEL(GLuint queryHandle) {
  typedef void (*ENDPERFQUERYINTEL)(GLuint queryHandle);
  ((ENDPERFQUERYINTEL) pEndPerfQueryINTEL)(queryHandle);
}

void
GlFunctions::GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags,
                                   GLsizei dataSize, GLvoid *data,
                                   GLuint *bytesWritten) {
  typedef void (*GETPERFQUERYDATAINTEL)(GLuint queryHandle, GLuint flags,
                                        GLsizei dataSize, GLvoid *data,
                                        GLuint *bytesWritten);
  ((GETPERFQUERYDATAINTEL) pGetPerfQueryDataINTEL)(queryHandle, flags,
                                                   dataSize, data,
                                                   bytesWritten);
}

void
GlFunctions::GetProgramiv(GLuint program, GLenum pname, GLint *params) {
  typedef void (*GETPROGRAMIV)(GLuint program, GLenum pname, GLint *params);
  ((GETPROGRAMIV) pGetProgramiv)(program, pname, params);
}

void
GlFunctions::GetProgramInfoLog(GLuint program, GLsizei bufSize,
                               GLsizei *length, GLchar *infoLog) {
  typedef void (*GETPROGRAMINFOLOG)(GLuint program, GLsizei bufSize,
                                    GLsizei *length, GLchar *infoLog);
  ((GETPROGRAMINFOLOG) pGetProgramInfoLog)(program, bufSize,
                                           length, infoLog);
}

void
GlFunctions::GetBooleanv(GLenum pname, GLboolean *params) {
  typedef void (*GETBOOLEANV)(GLenum pname, GLboolean *params);
  ((GETBOOLEANV) pGetBooleanv)(pname, params);
}

void
GlFunctions::GetFloatv(GLenum pname, GLfloat *params) {
  typedef void (*GETFLOATV)(GLenum pname, GLfloat *params);
  ((GETFLOATV) pGetFloatv)(pname, params);
}

void
GlFunctions::BlendColor(GLclampf red, GLclampf green,
                        GLclampf blue, GLclampf alpha) {
  typedef void (*BLENDCOLOR)(GLclampf red, GLclampf green,
                             GLclampf blue, GLclampf alpha);
  ((BLENDCOLOR) pBlendColor)(red, green, blue, alpha);
}

void
GlFunctions::BlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB,
                               GLenum sfactorAlpha, GLenum dfactorAlpha) {
  typedef void (*BLENDFUNCSEPARATE)(GLenum sfactorRGB, GLenum dfactorRGB,
                                    GLenum sfactorAlpha, GLenum dfactorAlpha);
  ((BLENDFUNCSEPARATE) pBlendFuncSeparate)(sfactorRGB, dfactorRGB,
                                           sfactorAlpha, dfactorAlpha);
}

void
GlFunctions::Disable(GLenum cap) {
  typedef void (*DISABLE)(GLenum cap);
  ((DISABLE) pDisable)(cap);
}

void
GlFunctions::BlendEquation(GLenum mode) {
  typedef void (*BLENDEQUATION)(GLenum mode);
  ((BLENDEQUATION) pBlendEquation)(mode);
}

void
GlFunctions::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
  typedef void (*BLENDEQUATIONSEPARATE)(GLenum modeRGB, GLenum modeAlpha);
  ((BLENDEQUATIONSEPARATE) pBlendEquationSeparate)(modeRGB, modeAlpha);
}

void
GlFunctions::BindAttribLocation(GLuint program, GLuint index,
                                const GLchar *name) {
  typedef void (*BINDATTRIBLOCATION)(GLuint program, GLuint index,
                                     const GLchar *name);
  ((BINDATTRIBLOCATION) pBindAttribLocation)(program, index, name);
}

void
GlFunctions::ValidateProgram(GLuint program) {
  typedef void (*VALIDATEPROGRAM)(GLuint program);
  ((VALIDATEPROGRAM) pValidateProgram)(program);
}

GLboolean
GlFunctions::IsEnabled(GLenum cap) {
  typedef GLboolean (*ISENABLED)(GLenum cap);
  return ((ISENABLED) pIsEnabled)(cap);
}

GLuint
GlFunctions::GetUniformBlockIndex(GLuint program,
                                  const GLchar *uniformBlockName) {
  typedef GLuint (*GETUNIFORMBLOCKINDEX)(GLuint program,
                                         const GLchar *uniformBlockName);
  return ((GETUNIFORMBLOCKINDEX) pGetUniformBlockIndex)(program,
                                                        uniformBlockName);
}

void
GlFunctions::UniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
                                 GLuint uniformBlockBinding) {
  typedef void (*UNIFORMBLOCKBINDING)(GLuint program, GLuint uniformBlockIndex,
                                      GLuint uniformBlockBinding);
  return ((UNIFORMBLOCKBINDING) pUniformBlockBinding)(program,
                                                      uniformBlockIndex,
                                                      uniformBlockBinding);
}