-
Notifications
You must be signed in to change notification settings - Fork 1
/
ogles2_module.c
3894 lines (3130 loc) · 127 KB
/
ogles2_module.c
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
#include "ogles2_module.h"
#include "common.h"
#include "filter.h"
#include "timer.h"
#include "profiling.h"
#include "logger.h"
#include <proto/exec.h>
#include <proto/ogles2.h>
#include <proto/utility.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdio.h>
#include <string.h>
struct Library* OGLES2Base;
static unsigned errorCount;
static BOOL profilingStarted = TRUE;
typedef enum Ogles2Function {
ActiveTexture,
AttachShader,
BindAttribLocation,
BindBuffer,
BindFramebuffer,
BindRenderbuffer,
BindTexture,
BlendColor,
BlendEquation,
BlendEquationSeparate,
BlendFunc,
BlendFuncSeparate,
BufferData,
BufferSubData,
CheckFramebufferStatus,
Clear,
ClearColor,
ClearDepthf,
ClearStencil,
ColorMask,
CompileShader,
CompressedTexImage2D,
CompressedTexSubImage2D,
CopyTexImage2D,
CopyTexSubImage2D,
CreateContext_AVOID,
CreateContext2,
CreateProgram,
CreateShader,
CullFace,
DeleteBuffers,
DeleteFramebuffers,
DeleteProgram,
DeleteRenderbuffers,
DeleteShader,
DeleteTextures,
DepthFunc,
DepthMask,
DepthRangef,
DestroyContext,
DetachShader,
Disable,
DisableVertexAttribArray,
DrawArrays,
DrawElements,
DrawElementsBaseVertexOES,
Enable,
EnableVertexAttribArray,
Finish,
Flush,
FramebufferRenderbuffer,
FramebufferTexture2D,
FrontFace,
GenBuffers,
GenerateMipmap,
GenFramebuffers,
GenRenderbuffers,
GenTextures,
GetActiveAttrib,
GetActiveUniform,
GetAttachedShaders,
GetAttribLocation,
GetBooleanv,
GetBufferParameteriv,
GetBufferParameterivOES,
GetBufferPointervOES,
GetError,
GetFloatv,
GetFramebufferAttachmentParameteriv,
GetIntegerv,
GetProcAddress,
GetProgramBinaryOES,
GetProgramiv,
GetProgramInfoLog,
GetRenderbufferParameteriv,
GetShaderiv,
GetShaderInfoLog,
GetShaderPrecisionFormat,
GetShaderSource,
GetString,
GetTexParameterfv,
GetTexParameteriv,
GetUniformfv,
GetUniformiv,
GetUniformLocation,
GetVertexAttribfv,
GetVertexAttribiv,
GetVertexAttribPointerv,
Hint,
IsBuffer,
IsEnabled,
IsFramebuffer,
IsProgram,
IsRenderbuffer,
IsShader,
IsTexture,
LineWidth,
LinkProgram,
MakeCurrent,
MapBufferOES,
PixelStorei,
PolygonMode,
PolygonOffset,
ProgramBinaryOES,
ProvokingVertex,
ReadPixels,
ReleaseShaderCompiler,
RenderbufferStorage,
SampleCoverage,
Scissor,
SetBitmap,
SetParams_AVOID,
SetParams2,
ShaderBinary,
ShaderSource,
StencilFunc,
StencilFuncSeparate,
StencilMask,
StencilMaskSeparate,
StencilOp,
StencilOpSeparate,
SwapBuffers,
TexImage2D,
TexParameterf,
TexParameterfv,
TexParameteri,
TexParameteriv,
TexSubImage2D,
Uniform1f,
Uniform1fv,
Uniform1i,
Uniform1iv,
Uniform2f,
Uniform2fv,
Uniform2i,
Uniform2iv,
Uniform3f,
Uniform3fv,
Uniform3i,
Uniform3iv,
Uniform4f,
Uniform4fv,
Uniform4i,
Uniform4iv,
UniformMatrix2fv,
UniformMatrix3fv,
UniformMatrix4fv,
UnmapBufferOES,
UseProgram,
ValidateProgram,
VertexAttrib1f,
VertexAttrib1fv,
VertexAttrib2f,
VertexAttrib2fv,
VertexAttrib3f,
VertexAttrib3fv,
VertexAttrib4f,
VertexAttrib4fv,
VertexAttribPointer,
Viewport,
// Keep last
Ogles2FunctionCount
} Ogles2Function;
static const char* mapOgles2Function(const Ogles2Function func)
{
#define MAP_ENUM(x) case x: return #x;
switch (func) {
MAP_ENUM(ActiveTexture)
MAP_ENUM(AttachShader)
MAP_ENUM(BindAttribLocation)
MAP_ENUM(BindBuffer)
MAP_ENUM(BindFramebuffer)
MAP_ENUM(BindRenderbuffer)
MAP_ENUM(BindTexture)
MAP_ENUM(BlendColor)
MAP_ENUM(BlendEquation)
MAP_ENUM(BlendEquationSeparate)
MAP_ENUM(BlendFunc)
MAP_ENUM(BlendFuncSeparate)
MAP_ENUM(BufferData)
MAP_ENUM(BufferSubData)
MAP_ENUM(CheckFramebufferStatus)
MAP_ENUM(Clear)
MAP_ENUM(ClearColor)
MAP_ENUM(ClearDepthf)
MAP_ENUM(ClearStencil)
MAP_ENUM(ColorMask)
MAP_ENUM(CompileShader)
MAP_ENUM(CompressedTexImage2D)
MAP_ENUM(CompressedTexSubImage2D)
MAP_ENUM(CopyTexImage2D)
MAP_ENUM(CopyTexSubImage2D)
MAP_ENUM(CreateContext_AVOID)
MAP_ENUM(CreateContext2)
MAP_ENUM(CreateProgram)
MAP_ENUM(CreateShader)
MAP_ENUM(CullFace)
MAP_ENUM(DeleteBuffers)
MAP_ENUM(DeleteFramebuffers)
MAP_ENUM(DeleteProgram)
MAP_ENUM(DeleteRenderbuffers)
MAP_ENUM(DeleteShader)
MAP_ENUM(DeleteTextures)
MAP_ENUM(DepthFunc)
MAP_ENUM(DepthMask)
MAP_ENUM(DepthRangef)
MAP_ENUM(DestroyContext)
MAP_ENUM(DetachShader)
MAP_ENUM(Disable)
MAP_ENUM(DisableVertexAttribArray)
MAP_ENUM(DrawArrays)
MAP_ENUM(DrawElements)
MAP_ENUM(DrawElementsBaseVertexOES)
MAP_ENUM(Enable)
MAP_ENUM(EnableVertexAttribArray)
MAP_ENUM(Finish)
MAP_ENUM(Flush)
MAP_ENUM(FramebufferRenderbuffer)
MAP_ENUM(FramebufferTexture2D)
MAP_ENUM(FrontFace)
MAP_ENUM(GenBuffers)
MAP_ENUM(GenerateMipmap)
MAP_ENUM(GenFramebuffers)
MAP_ENUM(GenRenderbuffers)
MAP_ENUM(GenTextures)
MAP_ENUM(GetActiveAttrib)
MAP_ENUM(GetActiveUniform)
MAP_ENUM(GetAttachedShaders)
MAP_ENUM(GetAttribLocation)
MAP_ENUM(GetBooleanv)
MAP_ENUM(GetBufferParameteriv)
MAP_ENUM(GetBufferParameterivOES)
MAP_ENUM(GetBufferPointervOES)
MAP_ENUM(GetError)
MAP_ENUM(GetFloatv)
MAP_ENUM(GetFramebufferAttachmentParameteriv)
MAP_ENUM(GetIntegerv)
MAP_ENUM(GetProcAddress)
MAP_ENUM(GetProgramBinaryOES)
MAP_ENUM(GetProgramiv)
MAP_ENUM(GetProgramInfoLog)
MAP_ENUM(GetRenderbufferParameteriv)
MAP_ENUM(GetShaderiv)
MAP_ENUM(GetShaderInfoLog)
MAP_ENUM(GetShaderPrecisionFormat)
MAP_ENUM(GetShaderSource)
MAP_ENUM(GetString)
MAP_ENUM(GetTexParameterfv)
MAP_ENUM(GetTexParameteriv)
MAP_ENUM(GetUniformfv)
MAP_ENUM(GetUniformiv)
MAP_ENUM(GetUniformLocation)
MAP_ENUM(GetVertexAttribfv)
MAP_ENUM(GetVertexAttribiv)
MAP_ENUM(GetVertexAttribPointerv)
MAP_ENUM(Hint)
MAP_ENUM(IsBuffer)
MAP_ENUM(IsEnabled)
MAP_ENUM(IsFramebuffer)
MAP_ENUM(IsProgram)
MAP_ENUM(IsRenderbuffer)
MAP_ENUM(IsShader)
MAP_ENUM(IsTexture)
MAP_ENUM(LineWidth)
MAP_ENUM(LinkProgram)
MAP_ENUM(MakeCurrent)
MAP_ENUM(MapBufferOES)
MAP_ENUM(PixelStorei)
MAP_ENUM(PolygonMode)
MAP_ENUM(PolygonOffset)
MAP_ENUM(ProgramBinaryOES)
MAP_ENUM(ProvokingVertex)
MAP_ENUM(ReadPixels)
MAP_ENUM(ReleaseShaderCompiler)
MAP_ENUM(RenderbufferStorage)
MAP_ENUM(SampleCoverage)
MAP_ENUM(Scissor)
MAP_ENUM(SetBitmap)
MAP_ENUM(SetParams_AVOID)
MAP_ENUM(SetParams2)
MAP_ENUM(ShaderBinary)
MAP_ENUM(ShaderSource)
MAP_ENUM(StencilFunc)
MAP_ENUM(StencilFuncSeparate)
MAP_ENUM(StencilMask)
MAP_ENUM(StencilMaskSeparate)
MAP_ENUM(StencilOp)
MAP_ENUM(StencilOpSeparate)
MAP_ENUM(SwapBuffers)
MAP_ENUM(TexImage2D)
MAP_ENUM(TexParameterf)
MAP_ENUM(TexParameterfv)
MAP_ENUM(TexParameteri)
MAP_ENUM(TexParameteriv)
MAP_ENUM(TexSubImage2D)
MAP_ENUM(Uniform1f)
MAP_ENUM(Uniform1fv)
MAP_ENUM(Uniform1i)
MAP_ENUM(Uniform1iv)
MAP_ENUM(Uniform2f)
MAP_ENUM(Uniform2fv)
MAP_ENUM(Uniform2i)
MAP_ENUM(Uniform2iv)
MAP_ENUM(Uniform3f)
MAP_ENUM(Uniform3fv)
MAP_ENUM(Uniform3i)
MAP_ENUM(Uniform3iv)
MAP_ENUM(Uniform4f)
MAP_ENUM(Uniform4fv)
MAP_ENUM(Uniform4i)
MAP_ENUM(Uniform4iv)
MAP_ENUM(UniformMatrix2fv)
MAP_ENUM(UniformMatrix3fv)
MAP_ENUM(UniformMatrix4fv)
MAP_ENUM(UnmapBufferOES)
MAP_ENUM(UseProgram)
MAP_ENUM(ValidateProgram)
MAP_ENUM(VertexAttrib1f)
MAP_ENUM(VertexAttrib1fv)
MAP_ENUM(VertexAttrib2f)
MAP_ENUM(VertexAttrib2fv)
MAP_ENUM(VertexAttrib3f)
MAP_ENUM(VertexAttrib3fv)
MAP_ENUM(VertexAttrib4f)
MAP_ENUM(VertexAttrib4fv)
MAP_ENUM(VertexAttribPointer)
MAP_ENUM(Viewport)
case Ogles2FunctionCount: break;
}
#undef MAP_ENUM
return "Unknown";
}
static const char* mapOgles2Error(const GLenum code)
{
#define MAP_ENUM(x) case x: ++errorCount; return #x;
switch (code) {
MAP_ENUM(GL_INVALID_ENUM)
MAP_ENUM(GL_INVALID_VALUE)
MAP_ENUM(GL_INVALID_OPERATION)
MAP_ENUM(GL_OUT_OF_MEMORY)
MAP_ENUM(GL_INVALID_FRAMEBUFFER_OPERATION)
}
#undef MAP_ENUM
return "Unknown error";
}
static const char* decodeTexture(const GLenum texture)
{
#define MAP_ENUM(x) case x: return #x;
switch (texture) {
MAP_ENUM(GL_TEXTURE0)
MAP_ENUM(GL_TEXTURE1)
MAP_ENUM(GL_TEXTURE2)
MAP_ENUM(GL_TEXTURE3)
MAP_ENUM(GL_TEXTURE4)
MAP_ENUM(GL_TEXTURE5)
MAP_ENUM(GL_TEXTURE6)
MAP_ENUM(GL_TEXTURE7)
MAP_ENUM(GL_TEXTURE8)
MAP_ENUM(GL_TEXTURE9)
MAP_ENUM(GL_TEXTURE10)
MAP_ENUM(GL_TEXTURE11)
MAP_ENUM(GL_TEXTURE12)
MAP_ENUM(GL_TEXTURE13)
MAP_ENUM(GL_TEXTURE14)
MAP_ENUM(GL_TEXTURE15)
MAP_ENUM(GL_TEXTURE16)
MAP_ENUM(GL_TEXTURE17)
MAP_ENUM(GL_TEXTURE18)
MAP_ENUM(GL_TEXTURE19)
MAP_ENUM(GL_TEXTURE20)
MAP_ENUM(GL_TEXTURE21)
MAP_ENUM(GL_TEXTURE22)
MAP_ENUM(GL_TEXTURE23)
MAP_ENUM(GL_TEXTURE24)
MAP_ENUM(GL_TEXTURE25)
MAP_ENUM(GL_TEXTURE26)
MAP_ENUM(GL_TEXTURE27)
MAP_ENUM(GL_TEXTURE28)
MAP_ENUM(GL_TEXTURE29)
MAP_ENUM(GL_TEXTURE30)
MAP_ENUM(GL_TEXTURE31)
}
#undef MAP_ENUM
return "Unknown texture";
}
static const char* decodeValue(const GLenum value)
{
#define MAP_ENUM(x) case x: return #x;
switch (value) {
MAP_ENUM(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH)
MAP_ENUM(GL_ACTIVE_ATTRIBUTES)
MAP_ENUM(GL_ACTIVE_TEXTURE)
MAP_ENUM(GL_ACTIVE_UNIFORM_MAX_LENGTH)
MAP_ENUM(GL_ACTIVE_UNIFORMS)
MAP_ENUM(GL_ALIASED_POINT_SIZE_RANGE)
MAP_ENUM(GL_ALIASED_LINE_WIDTH_RANGE)
MAP_ENUM(GL_ALPHA)
MAP_ENUM(GL_ALPHA_BITS)
MAP_ENUM(GL_ALWAYS)
MAP_ENUM(GL_ARRAY_BUFFER)
MAP_ENUM(GL_AR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ENUM(GL_RGB565)
MAP_ENUM(GL_RGB8_OES)
MAP_ENUM(GL_RGBA)
MAP_ENUM(GL_RGBA4)
MAP_ENUM(GL_RGBA8_OES)
MAP_ENUM(GL_SAMPLE_COVERAGE_VALUE)
MAP_ENUM(GL_SAMPLE_COVERAGE_INVERT)
MAP_ENUM(GL_SAMPLER_2D)
MAP_ENUM(GL_SAMPLER_CUBE)
MAP_ENUM(GL_SCISSOR_BOX)
MAP_ENUM(GL_SHADER_SOURCE_LENGTH)
MAP_ENUM(GL_SHADER_TYPE)
MAP_ENUM(GL_SHADING_LANGUAGE_VERSION)
MAP_ENUM(GL_SHORT)
MAP_ENUM(GL_SRC_ALPHA)
MAP_ENUM(GL_SRC_ALPHA_SATURATE)
MAP_ENUM(GL_SRC_COLOR)
MAP_ENUM(GL_STATIC_DRAW)
MAP_ENUM(GL_STENCIL_ATTACHMENT)
MAP_ENUM(GL_STENCIL_BACK_FAIL)
MAP_ENUM(GL_STENCIL_BACK_FUNC)
MAP_ENUM(GL_STENCIL_BACK_PASS_DEPTH_FAIL)
MAP_ENUM(GL_STENCIL_BACK_PASS_DEPTH_PASS)
MAP_ENUM(GL_STENCIL_BACK_REF)
MAP_ENUM(GL_STENCIL_BACK_VALUE_MASK)
MAP_ENUM(GL_STENCIL_BACK_WRITEMASK)
MAP_ENUM(GL_STENCIL_BITS)
MAP_ENUM(GL_STENCIL_CLEAR_VALUE)
MAP_ENUM(GL_STENCIL_FAIL)
MAP_ENUM(GL_STENCIL_FUNC)
MAP_ENUM(GL_STENCIL_INDEX1_OES)
MAP_ENUM(GL_STENCIL_INDEX4_OES)
MAP_ENUM(GL_STENCIL_INDEX8)
MAP_ENUM(GL_STENCIL_PASS_DEPTH_FAIL)
MAP_ENUM(GL_STENCIL_REF)
MAP_ENUM(GL_STENCIL_VALUE_MASK)
MAP_ENUM(GL_STENCIL_WRITEMASK)
MAP_ENUM(GL_STREAM_DRAW)
MAP_ENUM(GL_SUBPIXEL_BITS)
MAP_EN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ERTEX_SHADER)
MAP_ENUM(GL_VIEWPORT)
MAP_ENUM(GL_ZERO)
// GL_ARB_provoking_vertex
MAP_ENUM(GL_FIRST_VERTEX_CONVENTION)
MAP_ENUM(GL_LAST_VERTEX_CONVENTION)
MAP_ENUM(GL_PROVOKING_VERTEX)
MAP_ENUM(GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION)
// GL_ARB_texture_mirror_clamp_to_edge
MAP_ENUM(GL_TEXTURE_WRAP_R_OES)
MAP_ENUM(GL_MIRROR_CLAMP_TO_EDGE)
// GL_ARB_texture_rectangle
MAP_ENUM(GL_TEXTURE_RECTANGLE)
MAP_ENUM(GL_TEXTURE_BINDING_RECTANGLE)
MAP_ENUM(GL_PROXY_TEXTURE_RECTANGLE)
MAP_ENUM(GL_MAX_RECTANGLE_TEXTURE_SIZE)
MAP_ENUM(GL_SAMPLER_2D_RECT)
// MAP_ENUM(GL_SAMPLER_2D_RECT_SHADOW) - may be added later?
// GL_EXT_blend_minmax
// MAP_ENUM(GL_FUNC_ADD)
MAP_ENUM(GL_MIN)
MAP_ENUM(GL_MAX)
// MAP_ENUM(GL_BLEND_EQUATION)
// GL_EXT_texture_filter_anisotropic
MAP_ENUM(GL_TEXTURE_MAX_ANISOTROPY_EXT)
MAP_ENUM(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
// GL_EXT_texture_format_BGRA8888
MAP_ENUM(GL_BGRA_EXT)
// GL_EXT_texture_lod_bias
// MAP_ENUM(GL_TEXTURE_FILTER_CONTROL_EXT) - there is no texture env
MAP_ENUM(GL_TEXTURE_LOD_BIAS)
MAP_ENUM(GL_MAX_TEXTURE_LOD_BIAS)
// GL_OES_element_index_uint
// MAP_ENUM(GL_UNSIGNED_INT)
// GL_OES_texture_float
// MAP_ENUM(GL_HALF_FLOAT_OES)
// MAP_ENUM(GL_FLOAT)
// GL_OES_get_program_binary
MAP_ENUM(GL_PROGRAM_BINARY_LENGTH_OES)
MAP_ENUM(GL_NUM_PROGRAM_BINARY_FORMATS_OES)
MAP_ENUM(GL_PROGRAM_BINARY_FORMATS_OES)
// GL_OES_mapbuffer
MAP_ENUM(GL_WRITE_ONLY_OES)
// MAP_ENUM(GL_BUFFER_ACCESS_OES)
// MAP_ENUM(GL_BUFFER_MAPPED_OES)
// MAP_ENUM(GL_BUFFER_MAP_POINTER_OES)
// GL_OES_packed_depth_stencil
MAP_ENUM(GL_DEPTH_STENCIL_OES)
MAP_ENUM(GL_UNSIGNED_INT_24_8_OES)
//MAP_ENUM(GL_DEPTH24_STENCIL8_OES)
// GL_SGIS_texture_lod
MAP_ENUM(GL_TEXTURE_MIN_LOD)
MAP_ENUM(GL_TEXTURE_MAX_LOD)
MAP_ENUM(GL_TEXTURE_BASE_LEVEL)
MAP_ENUM(GL_TEXTURE_MAX_LEVEL)
//MAP_ENUM(GL_)
//MAP_ENUM(GL_)
//MAP_ENUM(GL_)
//MAP_ENUM(GL_)
}
#undef MAP_ENUM
return "Unknown enum";
}
static const char* decodeCapability(const GLenum value)
{
#define MAP_ENUM(x) case x: return #x;
switch (value) {
MAP_ENUM(GL_CULL_FACE)
MAP_ENUM(GL_POLYGON_OFFSET_FILL)
MAP_ENUM(GL_SCISSOR_TEST)
MAP_ENUM(GL_SAMPLE_COVERAGE)
MAP_ENUM(GL_SAMPLE_ALPHA_TO_COVERAGE)
// TODO: MAP_ENUM(GL_SAMPLE_COVERAGE_TO_ALPHA) ? Typo?
MAP_ENUM(GL_STENCIL_TEST)
MAP_ENUM(GL_DEPTH_TEST)
MAP_ENUM(GL_BLEND)
MAP_ENUM(GL_DITHER)
//MAP_ENUM()
}
#undef MAP_ENUM
return "Unknown capability";
}
static const char* decodePrimitive(const GLenum value)
{
#define MAP_ENUM(x) case x: return #x;
switch (value) {
MAP_ENUM(GL_LINES)
MAP_ENUM(GL_LINE_LOOP)
MAP_ENUM(GL_LINE_STRIP)
MAP_ENUM(GL_POINTS)
MAP_ENUM(GL_TRIANGLES)
MAP_ENUM(GL_TRIANGLE_STRIP)
MAP_ENUM(GL_TRIANGLE_FAN)
}
#undef MAP_ENUM
return "Unknown primitive";
}
#define MAX_GL_ERRORS 10
// Store original function pointers so that they can be still called
struct Ogles2Context
{
struct OGLES2IFace* interface;
struct Task* task;
char name[NAME_LEN];
char tagBuffer[TAG_BUFFER_LEN];
MyClock start;
uint64 ticks;
ProfilingItem profiling[Ogles2FunctionCount];
PrimitiveCounter counter;
GLenum errors[MAX_GL_ERRORS];
size_t errorRead;
size_t errorWritten;
void* (*old_aglCreateContext_AVOID)(struct OGLES2IFace *Self, ULONG * errcode, struct TagItem * tags);
void* (*old_aglCreateContext2)(struct OGLES2IFace *Self, ULONG * errcode, struct TagItem * tags);
void (*old_aglDestroyContext)(struct OGLES2IFace *Self, void* context);
void* (*old_aglGetProcAddress)(struct OGLES2IFace *Self, const char *name);
void (*old_aglMakeCurrent)(struct OGLES2IFace *Self, void* context);
void (*old_aglSetBitmap)(struct OGLES2IFace *Self, struct BitMap *bitmap);
void (*old_aglSetParams_AVOID)(struct OGLES2IFace *Self, struct TagItem * tags);
void (*old_aglSetParams2)(struct OGLES2IFace *Self, struct TagItem * tags);
void (*old_aglSwapBuffers)(struct OGLES2IFace *Self);
void (*old_glActiveTexture)(struct OGLES2IFace *Self, GLenum texture);
void (*old_glAttachShader)(struct OGLES2IFace *Self, GLuint program, GLuint shader);
void (*old_glBindAttribLocation)(struct OGLES2IFace *Self, GLuint program, GLuint index, const GLchar * name);
void (*old_glBindBuffer)(struct OGLES2IFace *Self, GLenum target, GLuint buffer);
void (*old_glBindFramebuffer)(struct OGLES2IFace *Self, GLenum target, GLuint framebuffer);
void (*old_glBindRenderbuffer)(struct OGLES2IFace *Self, GLenum target, GLuint renderbuffer);
void (*old_glBindTexture)(struct OGLES2IFace *Self, GLenum target, GLuint texture);
void (*old_glBlendColor)(struct OGLES2IFace *Self, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (*old_glBlendEquation)(struct OGLES2IFace *Self, GLenum mode);
void (*old_glBlendEquationSeparate)(struct OGLES2IFace *Self, GLenum modeRGB, GLenum modeAlpha);
void (*old_glBlendFunc)(struct OGLES2IFace *Self, GLenum sfactor, GLenum dfactor);
void (*old_glBlendFuncSeparate)(struct OGLES2IFace *Self, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
void (*old_glBufferData)(struct OGLES2IFace *Self, GLenum target, GLsizeiptr size, const void * data, GLenum usage);
void (*old_glBufferSubData)(struct OGLES2IFace *Self, GLenum target, GLintptr offset, GLsizeiptr size, const void * data);
GLenum (*old_glCheckFramebufferStatus)(struct OGLES2IFace *Self, GLenum target);
void (*old_glClear)(struct OGLES2IFace *Self, GLbitfield mask);
void (*old_glClearColor)(struct OGLES2IFace *Self, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (*old_glClearDepthf)(struct OGLES2IFace *Self, GLfloat d);
void (*old_glClearStencil)(struct OGLES2IFace *Self, GLint s);
void (*old_glColorMask)(struct OGLES2IFace *Self, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void (*old_glCompileShader)(struct OGLES2IFace *Self, GLuint shader);
void (*old_glCompressedTexImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data);
void (*old_glCompressedTexSubImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data);
void (*old_glCopyTexImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void (*old_glCopyTexSubImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GLuint (*old_glCreateProgram)(struct OGLES2IFace *Self);
GLuint (*old_glCreateShader)(struct OGLES2IFace *Self, GLenum type);
void (*old_glCullFace)(struct OGLES2IFace *Self, GLenum mode);
void (*old_glDeleteBuffers)(struct OGLES2IFace *Self, GLsizei n, GLuint * buffers);
void (*old_glDeleteFramebuffers)(struct OGLES2IFace *Self, GLsizei n, const GLuint * framebuffers);
void (*old_glDeleteProgram)(struct OGLES2IFace *Self, GLuint program);
void (*old_glDeleteRenderbuffers)(struct OGLES2IFace *Self, GLsizei n, const GLuint * renderbuffers);
void (*old_glDeleteShader)(struct OGLES2IFace *Self, GLuint shader);
void (*old_glDeleteTextures)(struct OGLES2IFace *Self, GLsizei n, const GLuint * textures);
void (*old_glDepthFunc)(struct OGLES2IFace *Self, GLenum func);
void (*old_glDepthMask)(struct OGLES2IFace *Self, GLboolean flag);
void (*old_glDepthRangef)(struct OGLES2IFace *Self, GLfloat n, GLfloat f);
void (*old_glDetachShader)(struct OGLES2IFace *Self, GLuint program, GLuint shader);
void (*old_glDisable)(struct OGLES2IFace *Self, GLenum cap);
void (*old_glDisableVertexAttribArray)(struct OGLES2IFace *Self, GLuint index);
void (*old_glDrawArrays)(struct OGLES2IFace *Self, GLenum mode, GLint first, GLsizei count);
void (*old_glDrawElements)(struct OGLES2IFace *Self, GLenum mode, GLsizei count, GLenum type, const void * indices);
void (*old_glDrawElementsBaseVertexOES)(struct OGLES2IFace *Self, GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex);
void (*old_glEnable)(struct OGLES2IFace *Self, GLenum cap);
void (*old_glEnableVertexAttribArray)(struct OGLES2IFace *Self, GLuint index);
void (*old_glFinish)(struct OGLES2IFace *Self);
void (*old_glFlush)(struct OGLES2IFace *Self);
void (*old_glFramebufferRenderbuffer)(struct OGLES2IFace *Self, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void (*old_glFramebufferTexture2D)(struct OGLES2IFace *Self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void (*old_glFrontFace)(struct OGLES2IFace *Self, GLenum mode);
void (*old_glGenBuffers)(struct OGLES2IFace *Self, GLsizei n, GLuint * buffers);
void (*old_glGenerateMipmap)(struct OGLES2IFace *Self, GLenum target);
void (*old_glGenFramebuffers)(struct OGLES2IFace *Self, GLsizei n, GLuint * framebuffers);
void (*old_glGenRenderbuffers)(struct OGLES2IFace *Self, GLsizei n, GLuint * renderbuffers);
void (*old_glGenTextures)(struct OGLES2IFace *Self, GLsizei n, GLuint * textures);
void (*old_glGetActiveAttrib)(struct OGLES2IFace *Self, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
void (*old_glGetActiveUniform)(struct OGLES2IFace *Self, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name);
void (*old_glGetAttachedShaders)(struct OGLES2IFace *Self, GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders);
GLint (*old_glGetAttribLocation)(struct OGLES2IFace *Self, GLuint program, const GLchar * name);
void (*old_glGetBooleanv)(struct OGLES2IFace *Self, GLenum pname, GLboolean * data);
void (*old_glGetBufferParameteriv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLint * params);
void (*old_glGetBufferParameterivOES)(struct OGLES2IFace *Self, GLenum target, GLenum value, GLint *data);
void (*old_glGetBufferPointervOES)(struct OGLES2IFace *Self, GLenum target, GLenum pname, void **params);
GLenum (*old_glGetError)(struct OGLES2IFace *Self);
void (*old_glGetFloatv)(struct OGLES2IFace *Self, GLenum pname, GLfloat * data);
void (*old_glGetFramebufferAttachmentParameteriv)(struct OGLES2IFace *Self, GLenum target, GLenum attachment, GLenum pname, GLint * params);
void (*old_glGetIntegerv)(struct OGLES2IFace *Self, GLenum pname, GLint * data);
void (*old_glGetProgramBinaryOES)(struct OGLES2IFace *Self, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
void (*old_glGetProgramiv)(struct OGLES2IFace *Self, GLuint program, GLenum pname, GLint * params);
void (*old_glGetProgramInfoLog)(struct OGLES2IFace *Self, GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
void (*old_glGetRenderbufferParameteriv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLint * params);
void (*old_glGetShaderiv)(struct OGLES2IFace *Self, GLuint shader, GLenum pname, GLint * params);
void (*old_glGetShaderInfoLog)(struct OGLES2IFace *Self, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
void (*old_glGetShaderPrecisionFormat)(struct OGLES2IFace *Self, GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision);
void (*old_glGetShaderSource)(struct OGLES2IFace *Self, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);
const GLubyte * (*old_glGetString)(struct OGLES2IFace *Self, GLenum name);
void (*old_glGetTexParameterfv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLfloat * params);
void (*old_glGetTexParameteriv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLint * params);
void (*old_glGetUniformfv)(struct OGLES2IFace *Self, GLuint program, GLint location, GLfloat * params);
void (*old_glGetUniformiv)(struct OGLES2IFace *Self, GLuint program, GLint location, GLint * params);
GLint (*old_glGetUniformLocation)(struct OGLES2IFace *Self, GLuint program, const GLchar * name);
void (*old_glGetVertexAttribfv)(struct OGLES2IFace *Self, GLuint index, GLenum pname, GLfloat * params);
void (*old_glGetVertexAttribiv)(struct OGLES2IFace *Self, GLuint index, GLenum pname, GLint * params);
void (*old_glGetVertexAttribPointerv)(struct OGLES2IFace *Self, GLuint index, GLenum pname, void ** pointer);
void (*old_glHint)(struct OGLES2IFace *Self, GLenum target, GLenum mode);
GLboolean (*old_glIsBuffer)(struct OGLES2IFace *Self, GLuint buffer);
GLboolean (*old_glIsEnabled)(struct OGLES2IFace *Self, GLenum cap);
GLboolean (*old_glIsFramebuffer)(struct OGLES2IFace *Self, GLuint framebuffer);
GLboolean (*old_glIsProgram)(struct OGLES2IFace *Self, GLuint program);
GLboolean (*old_glIsRenderbuffer)(struct OGLES2IFace *Self, GLuint renderbuffer);
GLboolean (*old_glIsShader)(struct OGLES2IFace *Self, GLuint shader);
GLboolean (*old_glIsTexture)(struct OGLES2IFace *Self, GLuint texture);
void (*old_glLineWidth)(struct OGLES2IFace *Self, GLfloat width);
void (*old_glLinkProgram)(struct OGLES2IFace *Self, GLuint program);
void* (*old_glMapBufferOES)(struct OGLES2IFace *Self, GLenum target, GLenum access);
void (*old_glPixelStorei)(struct OGLES2IFace *Self, GLenum pname, GLint param);
void (*old_glPolygonMode)(struct OGLES2IFace *Self, GLenum face, GLenum mode);
void (*old_glPolygonOffset)(struct OGLES2IFace *Self, GLfloat factor, GLfloat units);
void (*old_glProgramBinaryOES)(struct OGLES2IFace *Self, GLuint program, GLenum binaryFormat, const void *binary, GLint length);
void (*old_glProvokingVertex)(struct OGLES2IFace *Self, GLenum provokeMode);
void (*old_glReadPixels)(struct OGLES2IFace *Self, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels);
void (*old_glReleaseShaderCompiler)(struct OGLES2IFace *Self);
void (*old_glRenderbufferStorage)(struct OGLES2IFace *Self, GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void (*old_glSampleCoverage)(struct OGLES2IFace *Self, GLfloat value, GLboolean invert);
void (*old_glScissor)(struct OGLES2IFace *Self, GLint x, GLint y, GLsizei width, GLsizei height);
void (*old_glShaderBinary)(struct OGLES2IFace *Self, GLsizei count, const GLuint * shaders, GLenum binaryformat, const void * binary, GLsizei length);
void (*old_glShaderSource)(struct OGLES2IFace *Self, GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length);
void (*old_glStencilFunc)(struct OGLES2IFace *Self, GLenum func, GLint ref, GLuint mask);
void (*old_glStencilFuncSeparate)(struct OGLES2IFace *Self, GLenum face, GLenum func, GLint ref, GLuint mask);
void (*old_glStencilMask)(struct OGLES2IFace *Self, GLuint mask);
void (*old_glStencilMaskSeparate)(struct OGLES2IFace *Self, GLenum face, GLuint mask);
void (*old_glStencilOp)(struct OGLES2IFace *Self, GLenum fail, GLenum zfail, GLenum zpass);
void (*old_glStencilOpSeparate)(struct OGLES2IFace *Self, GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
void (*old_glTexImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels);
void (*old_glTexParameterf)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLfloat param);
void (*old_glTexParameterfv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, const GLfloat * params);
void (*old_glTexParameteri)(struct OGLES2IFace *Self, GLenum target, GLenum pname, GLint param);
void (*old_glTexParameteriv)(struct OGLES2IFace *Self, GLenum target, GLenum pname, const GLint * params);
void (*old_glTexSubImage2D)(struct OGLES2IFace *Self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels);
void (*old_glUniform1f)(struct OGLES2IFace *Self, GLint location, GLfloat v0);
void (*old_glUniform1fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLfloat * value);
void (*old_glUniform1i)(struct OGLES2IFace *Self, GLint location, GLint v0);
void (*old_glUniform1iv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLint * value);
void (*old_glUniform2f)(struct OGLES2IFace *Self, GLint location, GLfloat v0, GLfloat v1);
void (*old_glUniform2fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLfloat * value);
void (*old_glUniform2i)(struct OGLES2IFace *Self, GLint location, GLint v0, GLint v1);
void (*old_glUniform2iv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLint * value);
void (*old_glUniform3f)(struct OGLES2IFace *Self, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
void (*old_glUniform3fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLfloat * value);
void (*old_glUniform3i)(struct OGLES2IFace *Self, GLint location, GLint v0, GLint v1, GLint v2);
void (*old_glUniform3iv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLint * value);
void (*old_glUniform4f)(struct OGLES2IFace *Self, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
void (*old_glUniform4fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLfloat * value);
void (*old_glUniform4i)(struct OGLES2IFace *Self, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
void (*old_glUniform4iv)(struct OGLES2IFace *Self, GLint location, GLsizei count, const GLint * value);
void (*old_glUniformMatrix2fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
void (*old_glUniformMatrix3fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
void (*old_glUniformMatrix4fv)(struct OGLES2IFace *Self, GLint location, GLsizei count, GLboolean transpose, const GLfloat * value);
GLboolean (*old_glUnmapBufferOES)(struct OGLES2IFace *Self, GLenum target);
void (*old_glUseProgram)(struct OGLES2IFace *Self, GLuint program);
void (*old_glValidateProgram)(struct OGLES2IFace *Self, GLuint program);
void (*old_glVertexAttrib1f)(struct OGLES2IFace *Self, GLuint index, GLfloat x);
void (*old_glVertexAttrib1fv)(struct OGLES2IFace *Self, GLuint index, const GLfloat * v);
void (*old_glVertexAttrib2f)(struct OGLES2IFace *Self, GLuint index, GLfloat x, GLfloat y);
void (*old_glVertexAttrib2fv)(struct OGLES2IFace *Self, GLuint index, const GLfloat * v);
void (*old_glVertexAttrib3f)(struct OGLES2IFace *Self, GLuint index, GLfloat x, GLfloat y, GLfloat z);
void (*old_glVertexAttrib3fv)(struct OGLES2IFace *Self, GLuint index, const GLfloat * v);
void (*old_glVertexAttrib4f)(struct OGLES2IFace *Self, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void (*old_glVertexAttrib4fv)(struct OGLES2IFace *Self, GLuint index, const GLfloat * v);
void (*old_glVertexAttribPointer)(struct OGLES2IFace *Self, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer);
void (*old_glViewport)(struct OGLES2IFace *Self, GLint x, GLint y, GLsizei width, GLsizei height);
};
static struct Ogles2Context* contexts[MAX_CLIENTS];
static APTR mutex;
static void patch_ogles2_functions(struct Ogles2Context *);
static void find_process_name(struct Ogles2Context * context)
{
find_process_name2((struct Node *)context->task, context->name);
}
static char versionBuffer[64] = "ogles2.library version unknown";
static BOOL open_ogles2_library(void)
{
OGLES2Base = IExec->OpenLibrary("ogles2.library", 0);
if (OGLES2Base) {
snprintf(versionBuffer, sizeof(versionBuffer), "ogles2.library version %u.%u", OGLES2Base->lib_Version, OGLES2Base->lib_Revision);
logLine("%s", versionBuffer);
return TRUE;
} else {
printf("Failed to open ogles2.library\n");
}
return FALSE;
}
const char* ogles2_version_string(void)
{
return versionBuffer;
}