forked from baldurk/renderdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_emulated.cpp
More file actions
1422 lines (1224 loc) · 53.3 KB
/
gl_emulated.cpp
File metadata and controls
1422 lines (1224 loc) · 53.3 KB
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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2015-2017 Baldur Karlsson
*
* 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 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
******************************************************************************/
// in some cases we might need some functions (notably ARB_direct_state_access)
// emulated where possible, so we can simplify most codepaths by just assuming they're
// present elsewhere and using them unconditionally.
#include "driver/gl/gl_common.h"
#include "driver/gl/gl_hookset.h"
#include "driver/gl/gl_resources.h"
namespace glEmulate
{
const GLHookSet *hookset = NULL;
const GLHookSet *internalGL = NULL;
typedef GLenum (*BindingLookupFunc)(GLenum target);
struct PushPop
{
// we can use PFNGLBINDTEXTUREPROC since most bind functions are identical - taking GLenum and
// GLuint.
PushPop(GLenum target, PFNGLBINDTEXTUREPROC bindFunc, BindingLookupFunc bindingLookup)
{
other = bindFunc;
vao = NULL;
t = target;
hookset->glGetIntegerv(bindingLookup(target), (GLint *)&o);
}
PushPop(GLenum target, PFNGLBINDTEXTUREPROC bindFunc, GLenum binding)
{
other = bindFunc;
vao = NULL;
t = target;
hookset->glGetIntegerv(binding, (GLint *)&o);
}
PushPop(PFNGLBINDVERTEXARRAYPROC bindFunc)
{
vao = bindFunc;
other = NULL;
hookset->glGetIntegerv(eGL_VERTEX_ARRAY_BINDING, (GLint *)&o);
}
~PushPop()
{
if(vao)
vao(o);
else
other(t, o);
}
PFNGLBINDVERTEXARRAYPROC vao;
PFNGLBINDTEXTUREPROC other;
GLenum t;
GLuint o;
};
// if specifying the image or etc for a cubemap face, we must bind the cubemap itself.
GLenum TexBindTarget(GLenum target)
{
switch(target)
{
case eGL_TEXTURE_CUBE_MAP_POSITIVE_X:
case eGL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case eGL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case eGL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z: return eGL_TEXTURE_CUBE_MAP;
default: break;
}
return target;
}
#define PushPopTexture(target, obj) \
GLenum bindtarget = TexBindTarget(target); \
PushPop CONCAT(prev, __LINE__)(bindtarget, hookset->glBindTexture, &TextureBinding); \
hookset->glBindTexture(bindtarget, obj);
#define PushPopBuffer(target, obj) \
PushPop CONCAT(prev, __LINE__)(target, hookset->glBindBuffer, &BufferBinding); \
hookset->glBindBuffer(target, obj);
#define PushPopXFB(obj) \
PushPop CONCAT(prev, __LINE__)(eGL_TRANSFORM_FEEDBACK, hookset->glBindTransformFeedback, \
eGL_TRANSFORM_FEEDBACK_BINDING); \
hookset->glBindTransformFeedback(eGL_TRANSFORM_FEEDBACK, obj);
#define PushPopFramebuffer(target, obj) \
PushPop CONCAT(prev, __LINE__)(target, hookset->glBindFramebuffer, &FramebufferBinding); \
hookset->glBindFramebuffer(target, obj);
#define PushPopVertexArray(obj) \
PushPop CONCAT(prev, __LINE__)(hookset->glBindVertexArray); \
hookset->glBindVertexArray(obj);
void APIENTRY _glTransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer)
{
PushPopXFB(xfb);
hookset->glBindBufferBase(eGL_TRANSFORM_FEEDBACK_BUFFER, index, buffer);
}
void APIENTRY _glTransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
GLintptr offset, GLsizeiptr size)
{
PushPopXFB(xfb);
hookset->glBindBufferRange(eGL_TRANSFORM_FEEDBACK_BUFFER, index, buffer, offset, size);
}
void APIENTRY _glClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer, GLint drawbuffer,
const GLint *value)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
hookset->glClearBufferiv(buffer, drawbuffer, value);
}
void APIENTRY _glClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer, GLint drawbuffer,
const GLuint *value)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
hookset->glClearBufferuiv(buffer, drawbuffer, value);
}
void APIENTRY _glClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer, GLint drawbuffer,
const GLfloat *value)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
hookset->glClearBufferfv(buffer, drawbuffer, value);
}
void APIENTRY _glClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer, const GLfloat depth,
GLint stencil)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
hookset->glClearBufferfi(buffer, 0, depth, stencil);
}
void APIENTRY _glBlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0,
GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
{
PushPopFramebuffer(eGL_READ_FRAMEBUFFER, readFramebuffer);
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, drawFramebuffer);
hookset->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
void APIENTRY _glVertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
{
PushPopVertexArray(vaobj);
hookset->glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, buffer);
}
void APIENTRY _glVertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
const GLuint *buffers, const GLintptr *offsets,
const GLsizei *strides)
{
PushPopVertexArray(vaobj);
hookset->glBindVertexBuffers(first, count, buffers, offsets, strides);
}
void APIENTRY _glClearDepthf(GLfloat d)
{
hookset->glClearDepth(d);
}
void EmulateUnsupportedFunctions(GLHookSet *hooks)
{
hookset = hooks;
#define EMULATE_UNSUPPORTED(func) \
if(!hooks->func) \
hooks->func = &CONCAT(_, func);
EMULATE_UNSUPPORTED(glTransformFeedbackBufferBase)
EMULATE_UNSUPPORTED(glTransformFeedbackBufferRange)
EMULATE_UNSUPPORTED(glClearNamedFramebufferiv)
EMULATE_UNSUPPORTED(glClearNamedFramebufferuiv)
EMULATE_UNSUPPORTED(glClearNamedFramebufferfv)
EMULATE_UNSUPPORTED(glClearNamedFramebufferfi)
EMULATE_UNSUPPORTED(glBlitNamedFramebuffer)
EMULATE_UNSUPPORTED(glVertexArrayElementBuffer);
EMULATE_UNSUPPORTED(glVertexArrayVertexBuffers)
// internally glClearDepthf is used instead of glClearDepth (because OpenGL ES does support the
// non-f version), however glClearDepthf is not available before OpenGL 4.1
EMULATE_UNSUPPORTED(glClearDepthf)
// workaround for nvidia bug, which complains that GL_DEPTH_STENCIL is an invalid draw buffer.
// also some issues with 32-bit implementation of this entry point.
//
// NOTE: Vendor Checks aren't initialised by this point, so we have to do this unconditionally
// We include it just for searching: VendorCheck[VendorCheck_NV_ClearNamedFramebufferfiBugs]
hooks->glClearNamedFramebufferfi = &_glClearNamedFramebufferfi;
// workaround for AMD bug or weird behaviour. glVertexArrayElementBuffer doesn't update the
// GL_ELEMENT_ARRAY_BUFFER_BINDING global query, when binding the VAO subsequently *will*.
// I'm not sure if that's correct (weird) behaviour or buggy, but we can work around it just
// by avoiding use of the DSA function and always doing our emulated version.
//
// VendorCheck[VendorCheck_AMD_vertex_array_elem_buffer_query]
hooks->glVertexArrayElementBuffer = &_glVertexArrayElementBuffer;
}
#pragma region EXT_direct_state_access
#pragma region Framebuffers
void APIENTRY _glGetNamedFramebufferAttachmentParameterivEXT(GLuint framebuffer, GLenum attachment,
GLenum pname, GLint *params)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glGetFramebufferAttachmentParameteriv(eGL_DRAW_FRAMEBUFFER, attachment, pname, params);
}
GLenum APIENTRY _glCheckNamedFramebufferStatusEXT(GLuint framebuffer, GLenum target)
{
PushPopFramebuffer(target, framebuffer);
return internalGL->glCheckFramebufferStatus(target);
}
void APIENTRY _glGetNamedFramebufferParameterivEXT(GLuint framebuffer, GLenum pname, GLint *params)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glGetFramebufferParameteriv(eGL_DRAW_FRAMEBUFFER, pname, params);
}
void APIENTRY _glNamedFramebufferTexture1DEXT(GLuint framebuffer, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferTexture1D(eGL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level);
}
void APIENTRY _glNamedFramebufferTexture2DEXT(GLuint framebuffer, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferTexture2D(eGL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level);
}
void APIENTRY _glNamedFramebufferTexture3DEXT(GLuint framebuffer, GLenum attachment, GLenum textarget,
GLuint texture, GLint level, GLint zoffset)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferTexture3D(eGL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level,
zoffset);
}
void APIENTRY _glNamedFramebufferTextureEXT(GLuint framebuffer, GLenum attachment, GLuint texture,
GLint level)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferTexture(eGL_DRAW_FRAMEBUFFER, attachment, texture, level);
}
void APIENTRY _glNamedFramebufferTextureLayerEXT(GLuint framebuffer, GLenum attachment,
GLuint texture, GLint level, GLint layer)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferTextureLayer(eGL_DRAW_FRAMEBUFFER, attachment, texture, level, layer);
}
void APIENTRY _glNamedFramebufferParameteriEXT(GLuint framebuffer, GLenum pname, GLint param)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glFramebufferParameteri(eGL_DRAW_FRAMEBUFFER, pname, param);
}
void APIENTRY _glFramebufferDrawBufferEXT(GLuint framebuffer, GLenum mode)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glDrawBuffer(mode);
}
void APIENTRY _glFramebufferDrawBuffersEXT(GLuint framebuffer, GLsizei n, const GLenum *bufs)
{
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, framebuffer);
internalGL->glDrawBuffers(n, bufs);
}
void APIENTRY _glFramebufferReadBufferEXT(GLuint framebuffer, GLenum mode)
{
PushPopFramebuffer(eGL_READ_FRAMEBUFFER, framebuffer);
internalGL->glReadBuffer(mode);
}
#pragma endregion
#pragma region Buffers
void APIENTRY _glGetNamedBufferParameterivEXT(GLuint buffer, GLenum pname, GLint *params)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glGetBufferParameteriv(eGL_COPY_READ_BUFFER, pname, params);
}
void APIENTRY _glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void *data)
{
void *bufData = internalGL->glMapBufferRange(target, offset, size, eGL_MAP_READ_BIT);
if(!bufData)
{
RDCERR("glMapBufferRange failed to map buffer.");
return;
}
memcpy(data, bufData, (size_t)size);
internalGL->glUnmapBuffer(target);
}
void APIENTRY _glGetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
_glGetBufferSubData(eGL_COPY_READ_BUFFER, offset, size, data);
}
void *APIENTRY _glMapNamedBufferEXT(GLuint buffer, GLenum access)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
GLint size;
internalGL->glGetBufferParameteriv(eGL_COPY_READ_BUFFER, eGL_BUFFER_SIZE, &size);
return internalGL->glMapBufferRange(eGL_COPY_READ_BUFFER, 0, size, eGL_MAP_READ_BIT);
}
void *APIENTRY _glMapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length,
GLbitfield access)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
return internalGL->glMapBufferRange(eGL_COPY_READ_BUFFER, offset, length, access);
}
void APIENTRY _glFlushMappedNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glFlushMappedBufferRange(eGL_COPY_READ_BUFFER, offset, length);
}
GLboolean APIENTRY _glUnmapNamedBufferEXT(GLuint buffer)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
return internalGL->glUnmapBuffer(eGL_COPY_READ_BUFFER);
}
void APIENTRY _glClearNamedBufferDataEXT(GLuint buffer, GLenum internalformat, GLenum format,
GLenum type, const void *data)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glClearBufferData(eGL_COPY_READ_BUFFER, internalformat, format, type, data);
}
void APIENTRY _glClearNamedBufferSubDataEXT(GLuint buffer, GLenum internalformat, GLsizeiptr offset,
GLsizeiptr size, GLenum format, GLenum type,
const void *data)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glClearBufferSubData(eGL_COPY_READ_BUFFER, internalformat, offset, size, format, type,
data);
}
void APIENTRY _glNamedBufferDataEXT(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glBufferData(eGL_COPY_READ_BUFFER, size, data, usage);
}
void APIENTRY _glNamedBufferSubDataEXT(GLuint buffer, GLintptr offset, GLsizeiptr size,
const void *data)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, buffer);
internalGL->glBufferSubData(eGL_COPY_READ_BUFFER, offset, size, data);
}
void APIENTRY _glNamedCopyBufferSubDataEXT(GLuint readBuffer, GLuint writeBuffer,
GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
{
PushPopBuffer(eGL_COPY_READ_BUFFER, readBuffer);
PushPopBuffer(eGL_COPY_WRITE_BUFFER, writeBuffer);
internalGL->glCopyBufferSubData(eGL_COPY_READ_BUFFER, eGL_COPY_WRITE_BUFFER, readOffset,
writeOffset, size);
}
#pragma endregion
#pragma region Textures
void APIENTRY _glCompressedTextureImage1DEXT(GLuint texture, GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLint border,
GLsizei imageSize, const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexImage1D(target, level, internalformat, width, border, imageSize, bits);
}
void APIENTRY _glCompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height,
GLint border, GLsizei imageSize, const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexImage2D(target, level, internalformat, width, height, border,
imageSize, bits);
}
void APIENTRY _glCompressedTextureImage3DEXT(GLuint texture, GLenum target, GLint level,
GLenum internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLint border, GLsizei imageSize,
const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexImage3D(target, level, internalformat, width, height, depth, border,
imageSize, bits);
}
void APIENTRY _glCompressedTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level,
GLint xoffset, GLsizei width, GLenum format,
GLsizei imageSize, const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexSubImage1D(target, level, xoffset, width, format, imageSize, bits);
}
void APIENTRY _glCompressedTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize,
const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format,
imageSize, bits);
}
void APIENTRY _glCompressedTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *bits)
{
PushPopTexture(target, texture);
internalGL->glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height,
depth, format, imageSize, bits);
}
void APIENTRY _glGetCompressedTextureImageEXT(GLuint texture, GLenum target, GLint lod, void *img)
{
PushPopTexture(target, texture);
internalGL->glGetCompressedTexImage(target, lod, img);
}
void APIENTRY _glGetTextureImageEXT(GLuint texture, GLenum target, GLint level, GLenum format,
GLenum type, void *pixels)
{
PushPopTexture(target, texture);
internalGL->glGetTexImage(target, level, format, type, pixels);
}
void APIENTRY _glGetTextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname, GLfloat *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexParameterfv(target, pname, params);
}
void APIENTRY _glGetTextureParameterivEXT(GLuint texture, GLenum target, GLenum pname, GLint *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexParameteriv(target, pname, params);
}
void APIENTRY _glGetTextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, GLint *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexParameterIiv(target, pname, params);
}
void APIENTRY _glGetTextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
GLuint *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexParameterIuiv(target, pname, params);
}
void APIENTRY _glGetTextureLevelParameterfvEXT(GLuint texture, GLenum target, GLint level,
GLenum pname, GLfloat *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexLevelParameterfv(target, level, pname, params);
}
void APIENTRY _glGetTextureLevelParameterivEXT(GLuint texture, GLenum target, GLint level,
GLenum pname, GLint *params)
{
PushPopTexture(target, texture);
internalGL->glGetTexLevelParameteriv(target, level, pname, params);
}
void APIENTRY _glTextureImage1DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat,
GLsizei width, GLint border, GLenum format, GLenum type,
const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexImage1D(target, level, internalformat, width, border, format, type, pixels);
}
void APIENTRY _glTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format,
GLenum type, const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexImage2D(target, level, internalformat, width, height, border, format, type,
pixels);
}
void APIENTRY _glTextureImage3DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLsizei depth, GLint border,
GLenum format, GLenum type, const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexImage3D(target, level, internalformat, width, height, depth, border, format,
type, pixels);
}
// these two functions are a big hack. Internally we want to be using DSA functions for everything
// since then we don't have to track current bindings during replay for non-serialised calls.
// However, there are *no* DSA equivalents of the non-storage multisampled allocation functions.
// To get around this, we will emulate these functions whether or not ARB_texture_storage is
// present, and if it isn't just forward to the non-storage version which is equivalent
void APIENTRY _glTextureStorage2DMultisampleEXT(GLuint texture, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width,
GLsizei height, GLboolean fixedsamplelocations)
{
PushPopTexture(target, texture);
if(HasExt[ARB_texture_storage] && HasExt[ARB_texture_storage_multisample] &&
internalGL->glTexStorage2DMultisample)
{
internalGL->glTexStorage2DMultisample(target, samples, internalformat, width, height,
fixedsamplelocations);
}
else
{
internalGL->glTexImage2DMultisample(target, samples, internalformat, width, height,
fixedsamplelocations);
}
}
void APIENTRY _glTextureStorage3DMultisampleEXT(GLuint texture, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height,
GLsizei depth, GLboolean fixedsamplelocations)
{
PushPopTexture(target, texture);
if(HasExt[ARB_texture_storage] && HasExt[ARB_texture_storage_multisample] &&
internalGL->glTexStorage3DMultisample)
{
internalGL->glTexStorage3DMultisample(target, samples, internalformat, width, height, depth,
fixedsamplelocations);
}
else
{
internalGL->glTexImage3DMultisample(target, samples, internalformat, width, height, depth,
fixedsamplelocations);
}
}
void APIENTRY _glTextureParameterfEXT(GLuint texture, GLenum target, GLenum pname, GLfloat param)
{
PushPopTexture(target, texture);
internalGL->glTexParameterf(target, pname, param);
}
void APIENTRY _glTextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname,
const GLfloat *params)
{
PushPopTexture(target, texture);
internalGL->glTexParameterfv(target, pname, params);
}
void APIENTRY _glTextureParameteriEXT(GLuint texture, GLenum target, GLenum pname, GLint param)
{
PushPopTexture(target, texture);
internalGL->glTexParameteri(target, pname, param);
}
void APIENTRY _glTextureParameterivEXT(GLuint texture, GLenum target, GLenum pname,
const GLint *params)
{
PushPopTexture(target, texture);
internalGL->glTexParameteriv(target, pname, params);
}
void APIENTRY _glTextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname,
const GLint *params)
{
PushPopTexture(target, texture);
internalGL->glTexParameterIiv(target, pname, params);
}
void APIENTRY _glTextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
const GLuint *params)
{
PushPopTexture(target, texture);
internalGL->glTexParameterIuiv(target, pname, params);
}
void APIENTRY _glTextureSubImage1DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
GLsizei width, GLenum format, GLenum type, const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexSubImage1D(target, level, xoffset, width, format, type, pixels);
}
void APIENTRY _glTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLsizei width, GLsizei height, GLenum format,
GLenum type, const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
void APIENTRY _glTextureSubImage3DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLint zoffset, GLsizei width, GLsizei height,
GLsizei depth, GLenum format, GLenum type, const void *pixels)
{
PushPopTexture(target, texture);
internalGL->glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth,
format, type, pixels);
}
#pragma endregion
#pragma region Vertex Arrays
void APIENTRY _glGetVertexArrayIntegervEXT(GLuint vaobj, GLenum pname, GLint *param)
{
PushPopVertexArray(vaobj);
internalGL->glGetIntegerv(pname, param);
}
void APIENTRY _glGetVertexArrayIntegeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLint *param)
{
PushPopVertexArray(vaobj);
internalGL->glGetIntegeri_v(pname, index, param);
}
void APIENTRY _glVertexArrayVertexAttribOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index,
GLint size, GLenum type, GLboolean normalized,
GLsizei stride, GLintptr offset)
{
PushPopVertexArray(vaobj);
PushPopBuffer(eGL_ARRAY_BUFFER, buffer);
internalGL->glVertexAttribPointer(index, size, type, normalized, stride, (const void *)offset);
}
void APIENTRY _glVertexArrayVertexAttribIOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index,
GLint size, GLenum type, GLsizei stride,
GLintptr offset)
{
PushPopVertexArray(vaobj);
PushPopBuffer(eGL_ARRAY_BUFFER, buffer);
internalGL->glVertexAttribIPointer(index, size, type, stride, (const void *)offset);
}
void APIENTRY _glVertexArrayVertexAttribLOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index,
GLint size, GLenum type, GLsizei stride,
GLintptr offset)
{
PushPopVertexArray(vaobj);
PushPopBuffer(eGL_ARRAY_BUFFER, buffer);
// this depends on an extension that might not be present, GL_EXT/ARB_vertex_attrib_64bit.
// However we only use this internally if the capture used an equivalent function which would
// rely on that extension anyway. ie. when we promote it to EXT_dsa form, we were already
// assuming that the additional extension was available.
internalGL->glVertexAttribLPointer(index, size, type, stride, (const void *)offset);
}
void APIENTRY _glEnableVertexArrayAttribEXT(GLuint vaobj, GLuint index)
{
PushPopVertexArray(vaobj);
internalGL->glEnableVertexAttribArray(index);
}
void APIENTRY _glDisableVertexArrayAttribEXT(GLuint vaobj, GLuint index)
{
PushPopVertexArray(vaobj);
internalGL->glDisableVertexAttribArray(index);
}
void APIENTRY _glVertexArrayBindVertexBufferEXT(GLuint vaobj, GLuint bindingindex, GLuint buffer,
GLintptr offset, GLsizei stride)
{
PushPopVertexArray(vaobj);
internalGL->glBindVertexBuffer(bindingindex, buffer, offset, stride);
}
void APIENTRY _glVertexArrayVertexAttribFormatEXT(GLuint vaobj, GLuint attribindex, GLint size,
GLenum type, GLboolean normalized,
GLuint relativeoffset)
{
PushPopVertexArray(vaobj);
internalGL->glVertexAttribFormat(attribindex, size, type, normalized, relativeoffset);
}
void APIENTRY _glVertexArrayVertexAttribIFormatEXT(GLuint vaobj, GLuint attribindex, GLint size,
GLenum type, GLuint relativeoffset)
{
PushPopVertexArray(vaobj);
internalGL->glVertexAttribIFormat(attribindex, size, type, relativeoffset);
}
void APIENTRY _glVertexArrayVertexAttribLFormatEXT(GLuint vaobj, GLuint attribindex, GLint size,
GLenum type, GLuint relativeoffset)
{
PushPopVertexArray(vaobj);
internalGL->glVertexAttribLFormat(attribindex, size, type, relativeoffset);
}
void APIENTRY _glVertexArrayVertexAttribBindingEXT(GLuint vaobj, GLuint attribindex,
GLuint bindingindex)
{
PushPopVertexArray(vaobj);
internalGL->glVertexAttribBinding(attribindex, bindingindex);
}
void APIENTRY _glVertexArrayVertexBindingDivisorEXT(GLuint vaobj, GLuint bindingindex, GLuint divisor)
{
PushPopVertexArray(vaobj);
internalGL->glVertexBindingDivisor(bindingindex, divisor);
}
void APIENTRY _glVertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor)
{
PushPopVertexArray(vaobj);
internalGL->glVertexAttribDivisor(index, divisor);
}
#pragma endregion
#pragma endregion
#pragma region ARB_internalformat_query2
struct format_data
{
GLenum fmt;
GLenum type;
GLint numColComp, colCompBits, depthBits, stencilBits;
};
static const format_data formats[] = {
// colour formats
{eGL_R8, eGL_UNSIGNED_NORMALIZED, 1, 8, 0, 0},
{eGL_R8_SNORM, eGL_SIGNED_NORMALIZED, 1, 8, 0, 0},
{eGL_R16, eGL_UNSIGNED_NORMALIZED, 1, 16, 0, 0},
{eGL_R16_SNORM, eGL_SIGNED_NORMALIZED, 1, 16, 0, 0},
{eGL_RG8, eGL_UNSIGNED_NORMALIZED, 2, 8, 0, 0},
{eGL_RG8_SNORM, eGL_SIGNED_NORMALIZED, 2, 8, 0, 0},
{eGL_RG16, eGL_UNSIGNED_NORMALIZED, 2, 16, 0, 0},
{eGL_RG16_SNORM, eGL_SIGNED_NORMALIZED, 2, 16, 0, 0},
{eGL_RGB4, eGL_UNSIGNED_NORMALIZED, 3, 4, 0, 0},
{eGL_RGB5, eGL_UNSIGNED_NORMALIZED, 3, 5, 0, 0},
{eGL_RGB8, eGL_UNSIGNED_NORMALIZED, 3, 8, 0, 0},
{eGL_RGB8_SNORM, eGL_SIGNED_NORMALIZED, 3, 8, 0, 0},
{eGL_RGB10, eGL_UNSIGNED_NORMALIZED, 3, 10, 0, 0},
{eGL_RGB12, eGL_UNSIGNED_NORMALIZED, 3, 12, 0, 0},
{eGL_RGB16_SNORM, eGL_SIGNED_NORMALIZED, 3, 16, 0, 0},
{eGL_RGBA2, eGL_UNSIGNED_NORMALIZED, 4, 2, 0, 0},
{eGL_RGBA4, eGL_UNSIGNED_NORMALIZED, 4, 4, 0, 0},
{eGL_RGBA8, eGL_UNSIGNED_NORMALIZED, 4, 8, 0, 0},
{eGL_RGBA8_SNORM, eGL_SIGNED_NORMALIZED, 4, 8, 0, 0},
{eGL_RGBA12, eGL_UNSIGNED_NORMALIZED, 4, 12, 0, 0},
{eGL_RGBA16, eGL_UNSIGNED_NORMALIZED, 4, 16, 0, 0},
{eGL_SRGB8, eGL_UNSIGNED_NORMALIZED, 3, 8, 0, 0},
{eGL_SRGB8_ALPHA8, eGL_UNSIGNED_NORMALIZED, 4, 8, 0, 0},
{eGL_R16F, eGL_FLOAT, 1, 16, 0, 0},
{eGL_RG16F, eGL_FLOAT, 2, 16, 0, 0},
{eGL_RGB16F, eGL_FLOAT, 3, 16, 0, 0},
{eGL_RGBA16F, eGL_FLOAT, 4, 16, 0, 0},
{eGL_R32F, eGL_FLOAT, 1, 32, 0, 0},
{eGL_RG32F, eGL_FLOAT, 2, 32, 0, 0},
{eGL_RGB32F, eGL_FLOAT, 3, 32, 0, 0},
{eGL_RGBA32F, eGL_FLOAT, 4, 32, 0, 0},
{eGL_R8I, eGL_INT, 1, 8, 0, 0},
{eGL_R8UI, eGL_UNSIGNED_INT, 1, 8, 0, 0},
{eGL_R16I, eGL_INT, 1, 16, 0, 0},
{eGL_R16UI, eGL_UNSIGNED_INT, 1, 16, 0, 0},
{eGL_R32I, eGL_INT, 1, 32, 0, 0},
{eGL_R32UI, eGL_UNSIGNED_INT, 1, 32, 0, 0},
{eGL_RG8I, eGL_INT, 2, 8, 0, 0},
{eGL_RG8UI, eGL_UNSIGNED_INT, 2, 8, 0, 0},
{eGL_RG16I, eGL_INT, 2, 16, 0, 0},
{eGL_RG16UI, eGL_UNSIGNED_INT, 2, 16, 0, 0},
{eGL_RG32I, eGL_INT, 2, 32, 0, 0},
{eGL_RG32UI, eGL_UNSIGNED_INT, 2, 32, 0, 0},
{eGL_RGB8I, eGL_INT, 3, 8, 0, 0},
{eGL_RGB8UI, eGL_UNSIGNED_INT, 3, 8, 0, 0},
{eGL_RGB16I, eGL_INT, 3, 16, 0, 0},
{eGL_RGB16UI, eGL_UNSIGNED_INT, 3, 16, 0, 0},
{eGL_RGB32I, eGL_INT, 3, 32, 0, 0},
{eGL_RGB32UI, eGL_UNSIGNED_INT, 3, 32, 0, 0},
{eGL_RGBA8I, eGL_INT, 4, 8, 0, 0},
{eGL_RGBA8UI, eGL_UNSIGNED_INT, 4, 8, 0, 0},
{eGL_RGBA16I, eGL_INT, 4, 16, 0, 0},
{eGL_RGBA16UI, eGL_UNSIGNED_INT, 4, 16, 0, 0},
{eGL_RGBA32I, eGL_INT, 4, 32, 0, 0},
{eGL_RGBA32UI, eGL_UNSIGNED_INT, 4, 32, 0, 0},
// depth and stencil formats
{eGL_DEPTH_COMPONENT16, eGL_NONE, 0, 0, 16, 0},
{eGL_DEPTH_COMPONENT24, eGL_NONE, 0, 0, 24, 0},
{eGL_DEPTH_COMPONENT32, eGL_NONE, 0, 0, 32, 0},
{eGL_DEPTH_COMPONENT32F, eGL_NONE, 0, 0, 32, 0},
{eGL_DEPTH24_STENCIL8, eGL_NONE, 0, 0, 24, 8},
{eGL_DEPTH32F_STENCIL8, eGL_NONE, 0, 0, 32, 8},
{eGL_STENCIL_INDEX1, eGL_NONE, 0, 0, 0, 1},
{eGL_STENCIL_INDEX4, eGL_NONE, 0, 0, 0, 4},
{eGL_STENCIL_INDEX8, eGL_NONE, 0, 0, 0, 8},
{eGL_STENCIL_INDEX16, eGL_NONE, 0, 0, 0, 16},
};
static const GLenum viewClasses[] = {
eGL_VIEW_CLASS_8_BITS,
eGL_VIEW_CLASS_16_BITS,
eGL_VIEW_CLASS_24_BITS,
eGL_VIEW_CLASS_32_BITS,
eGL_NONE, // 40 bits
eGL_VIEW_CLASS_48_BITS,
eGL_NONE, // 56 bits
eGL_VIEW_CLASS_64_BITS,
eGL_NONE, // 72 bits
eGL_NONE, // 80 bits
eGL_NONE, // 88 bits
eGL_VIEW_CLASS_96_BITS,
eGL_NONE, // 104 bits
eGL_NONE, // 112 bits
eGL_NONE, // 120 bits
eGL_VIEW_CLASS_128_BITS,
};
void APIENTRY _glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
GLsizei bufSize, GLint *params)
{
// We only implement the subset of the queries that we care about ourselves.
// We also skip special formats, and only return values for
if(IsCompressedFormat(internalformat))
{
RDCERR("Compressed formats not supported by internal glGetInternalformativ");
return;
}
if(pname == eGL_COLOR_ENCODING)
{
if(internalformat == eGL_SRGB8 || internalformat == eGL_SRGB8_ALPHA8)
*params = eGL_SRGB;
else
*params = eGL_LINEAR;
return;
}
const format_data *data = NULL;
for(size_t i = 0; i < ARRAY_COUNT(formats); i++)
{
if(formats[i].fmt == internalformat)
{
data = &formats[i];
break;
}
}
if(data == NULL)
{
RDCERR("Format %s not supported by internal glGetInternalformativ, update database",
ToStr::Get(internalformat).c_str());
return;
}
switch(pname)
{
case eGL_VIEW_COMPATIBILITY_CLASS:
if(data->numColComp > 0)
*params = (GLint)viewClasses[data->numColComp * data->colCompBits / 8];
else
*params = (GLint)viewClasses[(data->depthBits + data->stencilBits) / 8];
break;
case eGL_COLOR_COMPONENTS: *params = (data->numColComp > 0 ? GL_TRUE : GL_FALSE); break;
case eGL_DEPTH_COMPONENTS: *params = (data->depthBits > 0 ? GL_TRUE : GL_FALSE); break;
case eGL_STENCIL_COMPONENTS: *params = (data->stencilBits > 0 ? GL_TRUE : GL_FALSE); break;
case eGL_INTERNALFORMAT_RED_SIZE:
*params = (data->numColComp > 0 ? data->colCompBits : 0);
break;
case eGL_INTERNALFORMAT_GREEN_SIZE:
*params = (data->numColComp > 1 ? data->colCompBits : 0);
break;
case eGL_INTERNALFORMAT_BLUE_SIZE:
*params = (data->numColComp > 2 ? data->colCompBits : 0);
break;
case eGL_INTERNALFORMAT_ALPHA_SIZE:
*params = (data->numColComp > 3 ? data->colCompBits : 0);
break;
case eGL_INTERNALFORMAT_RED_TYPE:
*params = GLint(data->numColComp > 0 ? data->type : eGL_NONE);
break;
case eGL_INTERNALFORMAT_GREEN_TYPE:
*params = GLint(data->numColComp > 1 ? data->type : eGL_NONE);
break;
case eGL_INTERNALFORMAT_BLUE_TYPE:
*params = GLint(data->numColComp > 2 ? data->type : eGL_NONE);
break;
case eGL_INTERNALFORMAT_ALPHA_TYPE:
*params = GLint(data->numColComp > 3 ? data->type : eGL_NONE);
break;
case eGL_INTERNALFORMAT_DEPTH_SIZE: *params = data->depthBits; break;
case eGL_INTERNALFORMAT_STENCIL_SIZE: *params = data->stencilBits; break;
default:
RDCERR("pname %s not supported by internal glGetInternalformativ", ToStr::Get(pname).c_str());
break;
}
}
#pragma endregion
#pragma region ARB_copy_image
void APIENTRY _glCopyImageSubData(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX,
GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget,
GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ,
GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth)
{
GLuint fbos[2] = {};
GLuint &readFBO = fbos[0];
GLuint &drawFBO = fbos[1];
internalGL->glGenFramebuffers(2, fbos);
RDCASSERTEQUAL(srcTarget, dstTarget);
{
PushPopFramebuffer(eGL_READ_FRAMEBUFFER, readFBO);
PushPopFramebuffer(eGL_DRAW_FRAMEBUFFER, drawFBO);
GLbitfield mask = eGL_COLOR_BUFFER_BIT;
GLenum attach = eGL_COLOR_ATTACHMENT0;
bool layered = false;
bool compressed = false;
if(srcTarget == eGL_TEXTURE_CUBE_MAP || srcTarget == eGL_TEXTURE_CUBE_MAP_ARRAY ||
srcTarget == eGL_TEXTURE_1D_ARRAY || srcTarget == eGL_TEXTURE_2D_ARRAY ||
srcTarget == eGL_TEXTURE_2D_MULTISAMPLE_ARRAY || srcTarget == eGL_TEXTURE_3D)
{
layered = true;
}
{
PushPopTexture(srcTarget, srcName);
GLenum levelQueryType = srcTarget;
if(levelQueryType == eGL_TEXTURE_CUBE_MAP)
levelQueryType = eGL_TEXTURE_CUBE_MAP_POSITIVE_X;
GLenum fmt = eGL_NONE;
internalGL->glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_INTERNAL_FORMAT,
(GLint *)&fmt);
if(IsCompressedFormat(fmt))
{
// have to do this via CPU readback, there's no alternative for GPU copies
compressed = true;
GLenum targets[] = {
eGL_TEXTURE_CUBE_MAP_POSITIVE_X, eGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
eGL_TEXTURE_CUBE_MAP_POSITIVE_Y, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
eGL_TEXTURE_CUBE_MAP_POSITIVE_Z, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
};
int count = ARRAY_COUNT(targets);
if(srcTarget != eGL_TEXTURE_CUBE_MAP)
{
targets[0] = srcTarget;