summaryrefslogtreecommitdiffstats
path: root/host/libs/virglrenderer/GLESv3.cpp
blob: dd2707d17c213f6b674517c2eba7c7ee690ea832 (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
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <OpenGLESDispatch/GLESv3Dispatch.h>

#include "GLESv3.h"

#include <string>
#include <vector>

// Stubs (common)

static void glDeleteFencesNV(GLsizei, const GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glDisableDriverControlQCOM(GLuint) {
    printf("%s: not implemented\n", __func__);
}

static void glDiscardFramebufferEXT(GLenum, GLsizei, const GLenum*) {
    printf("%s: not implemented\n", __func__);
}

static void glEnableDriverControlQCOM(GLuint) {
    printf("%s: not implemented\n", __func__);
}

static void glEndTilingQCOM(GLbitfield) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetBufferPointervQCOM(GLenum, GLvoid**) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetBuffersQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetFramebuffersQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetProgramBinarySourceQCOM(GLuint, GLenum, GLchar*, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetProgramsQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetRenderbuffersQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetShadersQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetTexLevelParameterivQCOM(GLuint, GLenum, GLint, GLenum, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetTexSubImageQCOM(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei,
                                    GLenum, GLenum, GLvoid*) {
    printf("%s: not implemented\n", __func__);
}

static void glExtGetTexturesQCOM(GLuint*, GLint, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static GLboolean glExtIsProgramBinaryQCOM(GLuint) {
    printf("%s: not implemented\n", __func__);
    return GL_FALSE;
}

static void glExtTexObjectStateOverrideiQCOM(GLenum, GLenum, GLint) {
    printf("%s: not implemented\n", __func__);
}

static void glFinishFenceNV(GLuint) {
    printf("%s: not implemented\n", __func__);
}

static void glFramebufferTexture2DMultisampleIMG(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) {
    printf("%s: not implemented\n", __func__);
}

static void glGenFencesNV(GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetDriverControlsQCOM(GLint*, GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetDriverControlStringQCOM(GLuint, GLsizei, GLsizei*, GLchar*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetFenceivNV(GLuint, GLenum, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static GLboolean glIsFenceNV(GLuint) {
    printf("%s: not implemented\n", __func__);
    return GL_FALSE;
}

static void* glMapBufferOES(GLenum, GLenum) {
    printf("%s: not implemented\n", __func__);
    return nullptr;
}

static void glMultiDrawArraysEXT(GLenum, const GLint*, const GLsizei*, GLsizei) {
    printf("%s: not implemented\n", __func__);
}

static void glMultiDrawElementsEXT(GLenum, const GLsizei*, GLenum, const GLvoid* const*, GLsizei) {
    printf("%s: not implemented\n", __func__);
}

static void glRenderbufferStorageMultisampleIMG(GLenum, GLsizei, GLenum, GLsizei, GLsizei) {
    printf("%s: not implemented\n", __func__);
}

static void glSetFenceNV(GLuint, GLenum) {
    printf("%s: not implemented\n", __func__);
}

static void glStartTilingQCOM(GLuint, GLuint, GLuint, GLuint, GLbitfield) {
    printf("%s: not implemented\n", __func__);
}

static GLboolean glTestFenceNV(GLuint) {
    printf("%s: not implemented\n", __func__);
    return GL_FALSE;
}

// Stubs (ES 3.1)

static void glBeginPerfMonitorAMD(GLuint) {
    printf("%s: not implemented\n", __func__);
}

static void glCoverageMaskNV(GLboolean) {
    printf("%s: not implemented\n", __func__);
}

static void glCoverageOperationNV(GLenum) {
    printf("%s: not implemented\n", __func__);
}

static void glDeletePerfMonitorsAMD(GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glEndPerfMonitorAMD(GLuint) {
    printf("%s: not implemented\n", __func__);
}

static void glGenPerfMonitorsAMD(GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorCounterDataAMD(GLuint, GLenum, GLsizei, GLuint*, GLint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorCounterInfoAMD(GLuint, GLuint, GLenum, GLvoid*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorCountersAMD(GLuint, GLint*, GLint*, GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorCounterStringAMD(GLuint, GLuint, GLsizei, GLsizei*, GLchar*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorGroupsAMD(GLint*, GLsizei, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

static void glGetPerfMonitorGroupStringAMD(GLuint, GLsizei, GLsizei*, GLchar*) {
    printf("%s: not implemented\n", __func__);
}

static void glSelectPerfMonitorCountersAMD(GLuint, GLboolean, GLuint, GLint, GLuint*) {
    printf("%s: not implemented\n", __func__);
}

// Non-stubs (common)

static void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* indices, GLuint) {
    s_gles3.glDrawElements(mode, count, type, indices);
}

static void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset) {
    s_gles3.glDrawElements(mode, count, type, reinterpret_cast<const GLvoid*>(offset));
}

static GLint glFinishRoundTrip() {
    s_gles3.glFinish();
    return 0;
}

static void glGetCompressedTextureFormats(int count, GLint* formats) {
    int nFormats;
    s_gles3.glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats);
    if (nFormats <= count)
        s_gles3.glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
}

// Non-stubs (ES 3.1)

struct GlSync {
    GlSync(GLESv3* ctx_, GLsync sync_) : sync(sync_), id(ctx_->sync_nextId++), ctx(ctx_) {
        ctx->sync_map.emplace(id, this);
    }

    ~GlSync() {
        ctx->sync_map.erase(id);
    }

    GLsync sync;
    uint64_t id;

  private:
    GLESv3* ctx;
};

static GLenum glClientWaitSyncAEMU(void* ctx_, uint64_t wait_on, GLbitfield flags,
                                   GLuint64 timeout) {
    GLESv3* ctx = static_cast<GLESv3*>(ctx_);

    std::map<uint64_t, GlSync*>::iterator it;
    it = ctx->sync_map.find(wait_on);
    if (it == ctx->sync_map.end())
        return GL_INVALID_VALUE;

    GlSync* sync = it->second;
    return s_gles3.glClientWaitSync(sync->sync, flags, timeout);
}

static void glCompressedTexImage2DOffsetAEMU(GLenum target, GLint level, GLenum internalformat,
                                             GLsizei width, GLsizei height, GLint border,
                                             GLsizei imageSize, GLuint offset) {
    s_gles3.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize,
                                   reinterpret_cast<const GLvoid*>(offset));
}

static void glCompressedTexImage3DOffsetAEMU(GLenum target, GLint level, GLenum internalformat,
                                             GLsizei width, GLsizei height, GLsizei depth,
                                             GLint border, GLsizei imageSize, GLuint offset) {
    s_gles3.glCompressedTexImage3D(target, level, internalformat, width, height, depth, border,
                                   imageSize, reinterpret_cast<const GLvoid*>(offset));
}

static void glCompressedTexSubImage2DOffsetAEMU(GLenum target, GLint level, GLint xoffset,
                                                GLint yoffset, GLsizei width, GLsizei height,
                                                GLenum format, GLsizei imageSize, GLuint offset) {
    s_gles3.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format,
                                      imageSize, reinterpret_cast<const GLvoid*>(offset));
}

static void glCompressedTexSubImage3DOffsetAEMU(GLenum target, GLint level, GLint xoffset,
                                                GLint yoffset, GLint zoffset, GLsizei width,
                                                GLsizei height, GLsizei depth, GLenum format,
                                                GLsizei imageSize, GLuint offset) {
    s_gles3.glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth,
                                      format, imageSize, reinterpret_cast<const GLvoid*>(offset));
}

static GLuint glCreateShaderProgramvAEMU(GLenum type, GLsizei, const char* packedStrings, GLuint) {
    return s_gles3.glCreateShaderProgramv(type, 1, &packedStrings);
}

static void glDeleteSyncAEMU(void* ctx_, uint64_t to_delete) {
    GLESv3* ctx = static_cast<GLESv3*>(ctx_);

    std::map<uint64_t, GlSync*>::iterator it;
    it = ctx->sync_map.find(to_delete);
    if (it == ctx->sync_map.end())
        return;

    GlSync* sync = it->second;
    s_gles3.glDeleteSync(sync->sync);
    delete sync;
}

static void glDrawArraysIndirectDataAEMU(GLenum mode, const void* indirect, GLuint) {
    s_gles3.glDrawArraysIndirect(mode, indirect);
}

static void glDrawArraysIndirectOffsetAEMU(GLenum mode, GLuint offset) {
    s_gles3.glDrawArraysIndirect(mode, reinterpret_cast<const void*>(offset));
}

static void glDrawElementsIndirectDataAEMU(GLenum mode, GLenum type, const void* indirect, GLuint) {
    s_gles3.glDrawElementsIndirect(mode, type, indirect);
}

static void glDrawElementsIndirectOffsetAEMU(GLenum mode, GLenum type, GLuint offset) {
    s_gles3.glDrawElementsIndirect(mode, type, reinterpret_cast<const void*>(offset));
}

static void glDrawElementsInstancedDataAEMU(GLenum mode, GLsizei count, GLenum type,
                                            const void* indices, GLsizei primcount, GLsizei) {
    s_gles3.glDrawElementsInstanced(mode, count, type, indices, primcount);
}

static void glDrawElementsInstancedOffsetAEMU(GLenum mode, GLsizei count, GLenum type,
                                              GLuint offset, GLsizei primcount) {
    s_gles3.glDrawElementsInstanced(mode, count, type, reinterpret_cast<const void*>(offset),
                                    primcount);
}

static void glDrawRangeElementsDataAEMU(GLenum mode, GLuint start, GLuint end, GLsizei count,
                                        GLenum type, const GLvoid* indices, GLsizei) {
    s_gles3.glDrawRangeElements(mode, start, end, count, type, indices);
}

static void glDrawRangeElementsOffsetAEMU(GLenum mode, GLuint start, GLuint end, GLsizei count,
                                          GLenum type, GLuint offset) {
    s_gles3.glDrawRangeElements(mode, start, end, count, type,
                                reinterpret_cast<const GLvoid*>(offset));
}

static uint64_t glFenceSyncAEMU(void* ctx_, GLenum condition, GLbitfield flags) {
    GLsync sync_ = s_gles3.glFenceSync(condition, flags);
    if (sync_ == 0)
        return 0U;

    GLESv3* ctx = static_cast<GLESv3*>(ctx_);
    GlSync* sync = new (std::nothrow) GlSync(ctx, sync_);
    if (!sync) {
        s_gles3.glDeleteSync(sync_);
        return 0U;
    }

    return sync->id;
}

static void glFlushMappedBufferRangeAEMU(GLenum target, GLintptr offset, GLsizeiptr length,
                                         GLbitfield access, void* guest_buffer) {
    if (guest_buffer && length) {
        void* gpuPtr = s_gles3.glMapBufferRange(target, offset, length, access);
        if (gpuPtr) {
            memcpy(gpuPtr, guest_buffer, length);
            s_gles3.glFlushMappedBufferRange(target, 0, length);
            s_gles3.glUnmapBuffer(target);
        }
    }
}

static void glGetSyncivAEMU(void* ctx_, uint64_t sync_, GLenum pname, GLsizei bufSize,
                            GLsizei* length, GLint* values) {
    GLESv3* ctx = static_cast<GLESv3*>(ctx_);

    std::map<uint64_t, GlSync*>::iterator it;
    it = ctx->sync_map.find(sync_);
    if (it == ctx->sync_map.end())
        return;

    GlSync* sync = it->second;
    s_gles3.glGetSynciv(sync->sync, pname, bufSize, length, values);
}

static std::vector<std::string> sUnpackVarNames(GLsizei count, const char* packedNames) {
    std::vector<std::string> unpacked;
    GLsizei current = 0;

    while (current < count) {
        const char* delimPos = strstr(packedNames, ";");
        size_t nameLen = delimPos - packedNames;
        std::string next;
        next.resize(nameLen);
        memcpy(&next[0], packedNames, nameLen);
        unpacked.push_back(next);
        packedNames = delimPos + 1;
        current++;
    }

    return unpacked;
}

static void glGetUniformIndicesAEMU(GLuint program, GLsizei uniformCount, const GLchar* packedNames,
                                    GLsizei packedLen, GLuint* uniformIndices) {
    std::vector<std::string> unpacked = sUnpackVarNames(uniformCount, packedNames);
    GLchar** unpackedArray = new GLchar*[unpacked.size()];
    GLsizei i = 0;
    for (auto& elt : unpacked) {
        unpackedArray[i] = (GLchar*)&elt[0];
        i++;
    }

    s_gles3.glGetUniformIndices(program, uniformCount, const_cast<const GLchar**>(unpackedArray),
                                uniformIndices);
    delete[] unpackedArray;
}

static GLboolean glIsSyncAEMU(void* ctx_, uint64_t sync) {
    GLESv3* ctx = static_cast<GLESv3*>(ctx_);
    return ctx->sync_map.count(sync) ? GL_TRUE : GL_FALSE;
}

static void glMapBufferRangeAEMU(GLenum target, GLintptr offset, GLsizeiptr length,
                                 GLbitfield access, void* mapped) {
    if ((access & GL_MAP_READ_BIT) ||
        ((access & GL_MAP_WRITE_BIT) &&
         (!(access & GL_MAP_INVALIDATE_RANGE_BIT) && !(access & GL_MAP_INVALIDATE_BUFFER_BIT)))) {
        void* gpuPtr = s_gles3.glMapBufferRange(target, offset, length, access);
        if (gpuPtr) {
            if (mapped)
                memcpy(mapped, gpuPtr, length);
            s_gles3.glUnmapBuffer(target);
        }
    }
}

static void glReadPixelsOffsetAEMU(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
                                   GLenum type, GLuint offset) {
    s_gles3.glReadPixels(x, y, width, height, format, type, reinterpret_cast<GLvoid*>(offset));
}

static void glShaderString(GLuint shader, const GLchar* string, GLsizei) {
    s_gles3.glShaderSource(shader, 1, &string, NULL);
}

static void glTexImage2DOffsetAEMU(GLenum target, GLint level, GLint internalformat, GLsizei width,
                                   GLsizei height, GLint border, GLenum format, GLenum type,
                                   GLuint offset) {
    s_gles3.glTexImage2D(target, level, internalformat, width, height, border, format, type,
                         reinterpret_cast<const GLvoid*>(offset));
}

static void glTexImage3DOffsetAEMU(GLenum target, GLint level, GLint internalFormat, GLsizei width,
                                   GLsizei height, GLsizei depth, GLint border, GLenum format,
                                   GLenum type, GLuint offset) {
    s_gles3.glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type,
                         reinterpret_cast<const GLvoid*>(offset));
}

static void glTexSubImage2DOffsetAEMU(GLenum target, GLint level, GLint xoffset, GLint yoffset,
                                      GLsizei width, GLsizei height, GLenum format, GLenum type,
                                      GLuint offset) {
    s_gles3.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
                            reinterpret_cast<const GLvoid*>(offset));
}

static void glTexSubImage3DOffsetAEMU(GLenum target, GLint level, GLint xoffset, GLint yoffset,
                                      GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
                                      GLenum format, GLenum type, GLuint offset) {
    s_gles3.glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format,
                            type, reinterpret_cast<const GLvoid*>(offset));
}

static void glTransformFeedbackVaryingsAEMU(GLuint program, GLsizei count,
                                            const char* packedVaryings, GLuint packedVaryingsLen,
                                            GLenum bufferMode) {
    std::vector<std::string> unpacked = sUnpackVarNames(count, packedVaryings);
    char** unpackedArray = new char*[unpacked.size()];
    GLsizei i = 0;
    for (auto& elt : unpacked) {
        unpackedArray[i] = &elt[0];
        i++;
    }

    s_gles3.glTransformFeedbackVaryings(program, count, const_cast<const char**>(unpackedArray),
                                        bufferMode);
    delete[] unpackedArray;
}

static void glUnmapBufferAEMU(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access,
                              void* guest_buffer, GLboolean* out_res) {
    *out_res = GL_TRUE;

    if (access & GL_MAP_WRITE_BIT) {
        if (guest_buffer) {
            void* gpuPtr = s_gles3.glMapBufferRange(target, offset, length, access);
            if (gpuPtr)
                memcpy(gpuPtr, guest_buffer, length);
        }

        *out_res = s_gles3.glUnmapBuffer(target);
    }
}

static void glVertexAttribIPointerDataAEMU(GLuint index, GLint size, GLenum type, GLsizei,
                                           void* data, GLuint) {
    s_gles3.glVertexAttribIPointer(index, size, type, 0, data);
}

static void glVertexAttribIPointerOffsetAEMU(GLuint index, GLint size, GLenum type, GLsizei,
                                             GLuint offset) {
    s_gles3.glVertexAttribIPointer(index, size, type, 0, reinterpret_cast<const GLvoid*>(offset));
}

static void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized,
                                      GLsizei, void* data, GLuint) {
    s_gles3.glVertexAttribPointer(indx, size, type, normalized, 0, data);
}

static void glVertexAttribPointerOffset(GLuint indx, GLint size, GLenum type, GLboolean normalized,
                                        GLsizei, GLuint offset) {
    s_gles3.glVertexAttribPointer(indx, size, type, normalized, 0,
                                  reinterpret_cast<const GLvoid*>(offset));
}

static void glWaitSyncAEMU(void* ctx_, uint64_t wait_on, GLbitfield flags, GLuint64 timeout) {
    GLESv3* ctx = static_cast<GLESv3*>(ctx_);

    std::map<uint64_t, GlSync*>::iterator it;
    it = ctx->sync_map.find(wait_on);
    if (it == ctx->sync_map.end())
        return;

    GlSync* sync = it->second;
    s_gles3.glWaitSync(sync->sync, flags, timeout);
}

#define KNIT(return_type, function_name, signature, callargs) function_name = s_gles3.function_name;

GLESv3::GLESv3() {
    LIST_GLES3_FUNCTIONS(KNIT, KNIT)

    // Remap some ES 2.0 extensions that become core in ES 3.1
    glBindVertexArrayOES = glBindVertexArray;
    glDeleteVertexArraysOES = glDeleteVertexArrays;
    glGenVertexArraysOES = glGenVertexArrays;
    glGetProgramBinaryOES = glGetProgramBinary;
    glIsVertexArrayOES = glIsVertexArray;
    glProgramBinaryOES = glProgramBinary;
    glUnmapBufferOES = glUnmapBuffer;

    // Entrypoints requiring custom wrappers (common)
    glDrawElementsData = ::glDrawElementsData;
    glDrawElementsOffset = ::glDrawElementsOffset;
    glFinishRoundTrip = ::glFinishRoundTrip;
    glGetCompressedTextureFormats = ::glGetCompressedTextureFormats;

    // Entrypoints requiring custom wrappers (ES 3.1)
    glClientWaitSyncAEMU = ::glClientWaitSyncAEMU;
    glCompressedTexImage2DOffsetAEMU = ::glCompressedTexImage2DOffsetAEMU;
    glCompressedTexImage3DOffsetAEMU = ::glCompressedTexImage3DOffsetAEMU;
    glCompressedTexSubImage2DOffsetAEMU = ::glCompressedTexSubImage2DOffsetAEMU;
    glCompressedTexSubImage3DOffsetAEMU = ::glCompressedTexSubImage3DOffsetAEMU;
    glCreateShaderProgramvAEMU = ::glCreateShaderProgramvAEMU;
    glDeleteSyncAEMU = ::glDeleteSyncAEMU;
    glDrawArraysIndirectDataAEMU = ::glDrawArraysIndirectDataAEMU;
    glDrawArraysIndirectOffsetAEMU = ::glDrawArraysIndirectOffsetAEMU;
    glDrawElementsIndirectDataAEMU = ::glDrawElementsIndirectDataAEMU;
    glDrawElementsIndirectOffsetAEMU = ::glDrawElementsIndirectOffsetAEMU;
    glDrawElementsInstancedDataAEMU = ::glDrawElementsInstancedDataAEMU;
    glDrawElementsInstancedOffsetAEMU = ::glDrawElementsInstancedOffsetAEMU;
    glDrawRangeElementsDataAEMU = ::glDrawRangeElementsDataAEMU;
    glDrawRangeElementsOffsetAEMU = ::glDrawRangeElementsOffsetAEMU;
    glFenceSyncAEMU = ::glFenceSyncAEMU;
    glFlushMappedBufferRangeAEMU = ::glFlushMappedBufferRangeAEMU;
    glGetSyncivAEMU = ::glGetSyncivAEMU;
    glGetUniformIndicesAEMU = ::glGetUniformIndicesAEMU;
    glIsSyncAEMU = ::glIsSyncAEMU;
    glMapBufferRangeAEMU = ::glMapBufferRangeAEMU;
    glReadPixelsOffsetAEMU = ::glReadPixelsOffsetAEMU;
    glShaderString = ::glShaderString;
    glTexImage2DOffsetAEMU = ::glTexImage2DOffsetAEMU;
    glTexImage3DOffsetAEMU = ::glTexImage3DOffsetAEMU;
    glTexSubImage2DOffsetAEMU = ::glTexSubImage2DOffsetAEMU;
    glTexSubImage3DOffsetAEMU = ::glTexSubImage3DOffsetAEMU;
    glTransformFeedbackVaryingsAEMU = ::glTransformFeedbackVaryingsAEMU;
    glUnmapBufferAEMU = ::glUnmapBufferAEMU;
    glVertexAttribIPointerDataAEMU = ::glVertexAttribIPointerDataAEMU;
    glVertexAttribIPointerOffsetAEMU = ::glVertexAttribIPointerOffsetAEMU;
    glVertexAttribPointerData = ::glVertexAttribPointerData;
    glVertexAttribPointerOffset = ::glVertexAttribPointerOffset;
    glWaitSyncAEMU = ::glWaitSyncAEMU;

    // Stub some extensions we will never implement (common)
    glDeleteFencesNV = ::glDeleteFencesNV;
    glDisableDriverControlQCOM = ::glDisableDriverControlQCOM;
    glDiscardFramebufferEXT = ::glDiscardFramebufferEXT;
    glEnableDriverControlQCOM = ::glEnableDriverControlQCOM;
    glEndTilingQCOM = ::glEndTilingQCOM;
    glExtGetBufferPointervQCOM = ::glExtGetBufferPointervQCOM;
    glExtGetBuffersQCOM = ::glExtGetBuffersQCOM;
    glExtGetFramebuffersQCOM = ::glExtGetFramebuffersQCOM;
    glExtGetProgramBinarySourceQCOM = ::glExtGetProgramBinarySourceQCOM;
    glExtGetProgramsQCOM = ::glExtGetProgramsQCOM;
    glExtGetRenderbuffersQCOM = ::glExtGetRenderbuffersQCOM;
    glExtGetShadersQCOM = ::glExtGetShadersQCOM;
    glExtGetTexLevelParameterivQCOM = ::glExtGetTexLevelParameterivQCOM;
    glExtGetTexSubImageQCOM = ::glExtGetTexSubImageQCOM;
    glExtGetTexturesQCOM = ::glExtGetTexturesQCOM;
    glExtIsProgramBinaryQCOM = ::glExtIsProgramBinaryQCOM;
    glExtTexObjectStateOverrideiQCOM = ::glExtTexObjectStateOverrideiQCOM;
    glFinishFenceNV = ::glFinishFenceNV;
    glFramebufferTexture2DMultisampleIMG = ::glFramebufferTexture2DMultisampleIMG;
    glGenFencesNV = ::glGenFencesNV;
    glGetDriverControlsQCOM = ::glGetDriverControlsQCOM;
    glGetDriverControlStringQCOM = ::glGetDriverControlStringQCOM;
    glGetFenceivNV = ::glGetFenceivNV;
    glIsFenceNV = ::glIsFenceNV;
    glMapBufferOES = ::glMapBufferOES;
    glMultiDrawArraysEXT = ::glMultiDrawArraysEXT;
    glMultiDrawElementsEXT = ::glMultiDrawElementsEXT;
    glRenderbufferStorageMultisampleIMG = ::glRenderbufferStorageMultisampleIMG;
    glSetFenceNV = ::glSetFenceNV;
    glStartTilingQCOM = ::glStartTilingQCOM;
    glTestFenceNV = ::glTestFenceNV;

    // Stub some extensions we will never implement (ES 3.1)
    glBeginPerfMonitorAMD = ::glBeginPerfMonitorAMD;
    glCoverageMaskNV = ::glCoverageMaskNV;
    glCoverageOperationNV = ::glCoverageOperationNV;
    glDeletePerfMonitorsAMD = ::glDeletePerfMonitorsAMD;
    glEndPerfMonitorAMD = ::glEndPerfMonitorAMD;
    glGenPerfMonitorsAMD = ::glGenPerfMonitorsAMD;
    glGetPerfMonitorCounterDataAMD = ::glGetPerfMonitorCounterDataAMD;
    glGetPerfMonitorCounterInfoAMD = ::glGetPerfMonitorCounterInfoAMD;
    glGetPerfMonitorCountersAMD = ::glGetPerfMonitorCountersAMD;
    glGetPerfMonitorCounterStringAMD = ::glGetPerfMonitorCounterStringAMD;
    glGetPerfMonitorGroupsAMD = ::glGetPerfMonitorGroupsAMD;
    glGetPerfMonitorGroupStringAMD = ::glGetPerfMonitorGroupStringAMD;
    glSelectPerfMonitorCountersAMD = ::glSelectPerfMonitorCountersAMD;
}