-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrender_api_opengles.cpp
More file actions
3069 lines (2865 loc) · 137 KB
/
render_api_opengles.cpp
File metadata and controls
3069 lines (2865 loc) · 137 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
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <common/image/image_processor.hpp>
#include "gles/common.hpp"
#include "gles/context_storage.hpp"
#include "gles/framebuffer.hpp"
#include "gles/object_manager.hpp"
#include "gles/gpu_device_impl.hpp"
#include "math/matrix.hpp"
#include "runtime/content.hpp"
#include "xr/device.hpp"
#include "./render_api.hpp"
#include "./content_renderer.hpp"
using namespace std;
using namespace renderer;
using namespace commandbuffers;
#if SUPPORT_OPENGL_UNIFIED
#define TR_OPENGL_FUNC inline
#define TR_OPENGL_GET_NUMBER(v) isnan(v) ? 0 : v
void getline(const string &input, string &line, size_t &pos, char delim = '\n')
{
if (pos >= input.size())
{
line.clear();
return;
}
size_t startPos = pos;
while (pos < input.size() && input[pos] != delim)
{
++pos;
}
line = input.substr(startPos, pos - startPos);
if (pos < input.size())
{
++pos; // Move past the delimiter
}
}
class RHI_OpenGL : public TrRenderHardwareInterface
{
private:
bool m_DebugEnabled = true;
float m_TmpMatrixL[16];
float m_TmpMatrixR[16];
float m_TmpMatrices[32];
public:
RHI_OpenGL(RHIBackendType backend_type)
: TrRenderHardwareInterface(backend_type, make_unique<gles::GPUDeviceImpl>())
{
memset(m_TmpMatrixL, 0, 16);
memset(m_TmpMatrixR, 0, 16);
memset(m_TmpMatrices, 0, 32);
OnCreated();
}
~RHI_OpenGL()
{
}
void ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces *interfaces) override;
bool SupportsWebGL2() override;
int GetDrawingBufferWidth() override;
int GetDrawingBufferHeight() override;
void EnableGraphicsDebugLog(bool apiOnly) override;
void DisableGraphicsDebugLog() override;
public: // Execute command buffer
bool ExecuteCommandBuffer();
bool ExecuteCommandBuffer(vector<TrCommandBufferBase *> &list,
renderer::TrContentRenderer *,
xr::DeviceFrame *,
ExecutingPassType) override;
private:
/**
* Check if the current context has binding vao, if not create a new and bind it.
*/
void EnsureVertexArrayObject(ContextGLApp *glContext)
{
if (glContext->vertexArrayObject() != 0)
return;
GLuint vao = glContext->ObjectManagerRef().CreateVertexArray();
glBindVertexArray(vao);
glContext->onVertexArrayObjectChanged(vao);
}
private:
template <typename RequestType>
GLenum CheckError(RequestType *req, renderer::TrContentRenderer *reqContentRenderer, const char *help = nullptr)
{
/**
* TODO: check the request content is still valid.
*/
auto commandType = req->type;
auto contentId = reqContentRenderer->getContent()->id;
GLenum error = glGetError();
if (TR_UNLIKELY(error != GL_NO_ERROR))
{
reqContentRenderer->increaseFrameErrorsCount();
DEBUG(LOG_TAG_ERROR,
"Occurs an %s error at %s",
gles::glErrorToString(error).c_str(),
commandTypeToStr(commandType).c_str());
DEBUG(LOG_TAG_ERROR, " command: %d", commandType);
DEBUG(LOG_TAG_ERROR, " content: %d", contentId);
DEBUG(LOG_TAG_ERROR, " context: %d", req->contextId);
if (help != nullptr)
DEBUG(LOG_TAG_ERROR, " detail: %s", help);
if (error == GL_OUT_OF_MEMORY)
{
reqContentRenderer->markOccurOutOfMemoryError();
{
// Check memory
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
glObjectManager.PrintMemoryUsage();
}
}
}
return error;
}
void PrintDebugInfo(const TrCommandBufferRequest *request,
const char *result,
const TrCommandBufferResponse *response,
const ApiCallOptions &options)
{
assert(request != nullptr);
string pass_type = "";
if (options.executingPassType == ExecutingPassType::kXRFrame)
pass_type = "XR";
else if (options.executingPassType == ExecutingPassType::kCachedXRFrame)
pass_type = "XR(Cached)";
else if (options.executingPassType == ExecutingPassType::kOffscreenPass)
pass_type = "OFFSCREEN";
else
pass_type = "INIT";
// Print request line
if (result == nullptr)
DEBUG(DEBUG_TAG, "[%s] %s", pass_type.c_str(), request->toString().c_str());
else
DEBUG(DEBUG_TAG, "[%s] %s => %s", pass_type.c_str(), request->toString().c_str(), result);
// Print response lines
if (response != nullptr)
DEBUG(DEBUG_TAG, "%s", response->toString(" " /* use 4 spaces as prefix in response */).c_str());
}
void DumpDrawCallInfo(const char *logTag,
string funcName,
bool isDefaultQueue,
GLint mode,
GLsizei count,
GLenum type,
const GLvoid *indices)
{
DEBUG(logTag,
" mode=%s, type=%s, indices=%p)",
gles::glEnumToString(mode).c_str(),
gles::glEnumToString(type).c_str(),
indices);
// Get current program
GLint program;
glGetIntegerv(GL_CURRENT_PROGRAM, &program);
DEBUG(logTag, " Program: %d", program);
// Print bond framebuffer
{
GLint binding_fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &binding_fbo);
DEBUG(logTag,
" Framebuffer: %d (%s)",
binding_fbo,
glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE ? "Complete" : "Incomplete");
// Print viewport & scissor
{
GLint viewport[4];
GLint scissor[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glGetIntegerv(GL_SCISSOR_BOX, scissor);
DEBUG(logTag, " Viewport: (%d, %d, %d, %d)", viewport[0], viewport[1], viewport[2], viewport[3]);
DEBUG(logTag, " Scissor: (%d, %d, %d, %d)", scissor[0], scissor[1], scissor[2], scissor[3]);
}
}
// Print LINK_STATUS
{
GLint linkStatus;
glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
DEBUG(logTag, " Program: LINK_STATUS=%s", linkStatus == GL_TRUE ? "Ok" : "Failed");
if (linkStatus != GL_TRUE)
{
GLchar infoLog[512];
glGetProgramInfoLog(program, 512, nullptr, infoLog);
DEBUG(logTag, " Program: INFO_LOG(%s)", infoLog);
}
}
// Print Element Array
{
GLint elementArrayBuffer;
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &elementArrayBuffer);
DEBUG(logTag, " Element Array Buffer: %d", elementArrayBuffer);
}
// Print Active Attributes
{
GLint numAttributes = 0;
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &numAttributes);
for (int i = 0; i < numAttributes; i++)
{
GLchar *name = new GLchar[256];
GLint size;
GLenum type;
glGetActiveAttrib(program, i, 256, NULL, &size, &type, name);
GLint attribIndex = glGetAttribLocation(program, name);
if (attribIndex == -1)
{
glGetError(); // Clear the error
DEBUG(logTag,
" Active Attribute(%d): Size=%d Type=%s \"%s\"",
attribIndex,
size,
gles::glEnumToString(type).c_str(),
name);
}
else
{
GLint enabled;
glGetVertexAttribiv(attribIndex, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
GLint bufferBinding;
glGetVertexAttribiv(attribIndex, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &bufferBinding);
DEBUG(logTag,
" Active Attribute(%d): Enabled=%s Size=%d Type=%s BufferBinding=%d \"%s\"",
attribIndex,
enabled ? "Yes" : "No",
size,
gles::glEnumToString(type).c_str(),
bufferBinding,
name);
}
delete[] name;
}
}
// Print Blend States
{
GLboolean blendEnabled;
glGetBooleanv(GL_BLEND, &blendEnabled);
if (blendEnabled)
{
DEBUG(logTag, " Blend State:");
GLint blendColors[4];
glGetIntegerv(GL_BLEND_COLOR, blendColors);
DEBUG(logTag, " Enabled=%s", blendEnabled ? "Yes" : "No");
DEBUG(logTag, " Color=(%d, %d, %d, %d)", blendColors[0], blendColors[1], blendColors[2], blendColors[3]);
GLint blendEquationAlpha;
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha);
GLint blendEquationRGB;
glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB);
DEBUG(logTag, " EquationAlpha=%s", gles::glEnumToString(blendEquationAlpha).c_str());
DEBUG(logTag, " EquationRGB=%s", gles::glEnumToString(blendEquationRGB).c_str());
GLint blendDstAlpha;
glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDstAlpha);
GLint blendDstRGB;
glGetIntegerv(GL_BLEND_DST_RGB, &blendDstRGB);
DEBUG(logTag, " DstAlpha=%s", gles::glBlendFuncToString(blendDstAlpha).c_str());
DEBUG(logTag, " DstRGB=%s", gles::glBlendFuncToString(blendDstRGB).c_str());
GLint blendSrcAlpha;
glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
GLint blendSrcRGB;
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
DEBUG(logTag, " SrcAlpha=%s", gles::glBlendFuncToString(blendSrcAlpha).c_str());
DEBUG(logTag, " SrcRGB=%s", gles::glBlendFuncToString(blendSrcRGB).c_str());
}
}
// Print Color State
{
GLint colorMask[4];
glGetIntegerv(GL_COLOR_WRITEMASK, colorMask);
DEBUG(logTag, " Color Mask: (%d, %d, %d, %d)", colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
}
// Print Cull State
{
GLboolean cullEnabled;
glGetBooleanv(GL_CULL_FACE, &cullEnabled);
if (cullEnabled)
{
GLint cullFace;
glGetIntegerv(GL_CULL_FACE_MODE, &cullFace);
DEBUG(logTag,
" Cull: Enabled=%s Face=%s",
cullEnabled ? "Yes" : "No",
gles::glEnumToString(cullFace).c_str());
}
}
// Print Depth State
{
GLboolean depthEnabled;
glGetBooleanv(GL_DEPTH_TEST, &depthEnabled);
{
DEBUG(logTag, " Depth State:");
DEBUG(logTag, " Enabled=%s", depthEnabled ? "Yes" : "No");
GLint depthFunc;
glGetIntegerv(GL_DEPTH_FUNC, &depthFunc);
DEBUG(logTag, " Func=%s", gles::glDepthOrStencilFuncToString(depthFunc).c_str());
GLboolean depthWriteMask;
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthWriteMask);
DEBUG(logTag, " WriteMask=%s", depthWriteMask ? "Yes" : "No");
GLfloat depthRange[2];
glGetFloatv(GL_DEPTH_RANGE, depthRange);
DEBUG(logTag, " Range=(%f, %f)", depthRange[0], depthRange[1]);
}
}
// Print Stencil State
{
GLboolean stencilEnabled;
glGetBooleanv(GL_STENCIL_TEST, &stencilEnabled);
{
DEBUG(logTag, " Stencil State:");
DEBUG(logTag, " Enabled=%s", stencilEnabled ? "Yes" : "No");
GLint stencilMask;
glGetIntegerv(GL_STENCIL_WRITEMASK, &stencilMask);
DEBUG(logTag, " Mask=%d", stencilMask);
GLint stencilFunc;
glGetIntegerv(GL_STENCIL_FUNC, &stencilFunc);
GLint stencilRef;
glGetIntegerv(GL_STENCIL_REF, &stencilRef);
GLint stencilValueMask;
glGetIntegerv(GL_STENCIL_VALUE_MASK, &stencilValueMask);
DEBUG(logTag,
" Func=%s Ref=%d ValueMask=%d",
gles::glDepthOrStencilFuncToString(stencilFunc).c_str(),
stencilRef,
stencilValueMask);
GLint stencilFail;
glGetIntegerv(GL_STENCIL_FAIL, &stencilFail);
GLint stencilZFail;
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &stencilZFail);
GLint stencilZPass;
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &stencilZPass);
DEBUG(logTag,
" Fail=%s ZFail=%s ZPass=%s",
gles::glStencilOpToString(stencilFail).c_str(),
gles::glStencilOpToString(stencilZFail).c_str(),
gles::glStencilOpToString(stencilZPass).c_str());
}
}
// Print Texture bindings
{
GLint activatedUnit;
glGetIntegerv(GL_ACTIVE_TEXTURE, &activatedUnit);
DEBUG(logTag, " Active Texture Unit(TEXTURE%d)", activatedUnit - GL_TEXTURE0);
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
for (int i = 0; i < maxTextureUnits; ++i)
{
GLint textureId;
glActiveTexture(GL_TEXTURE0 + i);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureId);
if (textureId != 0)
DEBUG(logTag, " TEXTURE%d: texture(TEXTURE_2D, %d)", i, textureId);
glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &textureId);
if (textureId != 0)
DEBUG(logTag, " TEXTURE%d: texture(TEXTURE_2D_ARRAY, %d)", i, textureId);
}
glActiveTexture(activatedUnit); // Restore the active texture unit
}
}
private:
TR_OPENGL_FUNC void OnContextInit(WebGL1ContextInitCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
WebGL1ContextInitCommandBufferResponse res(req);
res.drawingViewport = GetDrawingViewport();
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &res.maxCombinedTextureImageUnits);
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &res.maxCubeMapTextureSize);
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &res.maxFragmentUniformVectors);
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &res.maxRenderbufferSize);
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &res.maxTextureImageUnits);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &res.maxTextureSize);
glGetIntegerv(GL_MAX_VARYING_VECTORS, &res.maxVaryingVectors);
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &res.maxVertexAttribs);
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &res.maxVertexTextureImageUnits);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &res.maxVertexUniformVectors);
res.vendor = string((const char *)glGetString(GL_VENDOR));
res.version = string((const char *)glGetString(GL_VERSION));
res.renderer = string((const char *)glGetString(GL_RENDERER));
// Cache for shader precision formats.
{
auto &vertexFormats = res.vertexShaderPrecisionFormats;
glGetShaderPrecisionFormat(GL_VERTEX_SHADER, GL_LOW_FLOAT, &vertexFormats[0][0], &vertexFormats[0][2]);
glGetShaderPrecisionFormat(GL_VERTEX_SHADER, GL_MEDIUM_FLOAT, &vertexFormats[1][0], &vertexFormats[1][2]);
glGetShaderPrecisionFormat(GL_VERTEX_SHADER, GL_HIGH_FLOAT, &vertexFormats[2][0], &vertexFormats[2][2]);
auto &fragmentFormats = res.fragmentShaderPrecisionFormats;
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_LOW_FLOAT, &fragmentFormats[0][0], &fragmentFormats[0][2]);
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, &fragmentFormats[1][0], &fragmentFormats[1][2]);
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, &fragmentFormats[2][0], &fragmentFormats[2][2]);
}
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, &res, options);
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnContext2Init(WebGL2ContextInitCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
WebGL2ContextInitCommandBufferResponse res(req);
// GLint values
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &res.max3DTextureSize);
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &res.maxArrayTextureLayers);
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &res.maxColorAttachments);
glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &res.maxCombinedUniformBlocks);
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &res.maxDrawBuffers);
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &res.maxElementsIndices);
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &res.maxElementsVertices);
glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, &res.maxFragmentInputComponents);
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &res.maxFragmentUniformBlocks);
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &res.maxFragmentUniformComponents);
glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &res.maxProgramTexelOffset);
glGetIntegerv(GL_MAX_SAMPLES, &res.maxSamples);
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &res.maxTransformFeedbackInterleavedComponents);
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &res.maxTransformFeedbackSeparateAttributes);
glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, &res.maxTransformFeedbackSeparateComponents);
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &res.maxUniformBufferBindings);
glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &res.maxVaryingComponents);
glGetIntegerv(GL_MAX_VERTEX_OUTPUT_COMPONENTS, &res.maxVertexOutputComponents);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &res.maxVertexUniformBlocks);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &res.maxVertexUniformComponents);
// GLint64 values
glGetInteger64v(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &res.maxCombinedFragmentUniformComponents);
glGetInteger64v(GL_MAX_SERVER_WAIT_TIMEOUT, &res.maxServerWaitTimeout);
glGetInteger64v(GL_MAX_UNIFORM_BLOCK_SIZE, &res.maxUniformBlockSize);
// GLfloat values
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &res.maxTextureLODBias);
// Check for extensions
{
glGetIntegerv(WEBGL2_EXT_MAX_VIEWS_OVR, &res.OVR_maxViews);
glGetFloatv(WEBGL2_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &res.maxTextureMaxAnisotropy);
}
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, &res, options);
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnCreateProgram(CreateProgramCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
GLuint program = reqContentRenderer->getContextGL()->createProgram(req->clientId);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(program).c_str(), nullptr, options);
}
TR_OPENGL_FUNC void OnDeleteProgram(DeleteProgramCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
GLuint program;
reqContentRenderer->getContextGL()->deleteProgram(req->clientId, program);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnLinkProgram(LinkProgramCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
GLuint program = glContext->ObjectManagerRef().FindProgram(req->clientId);
for (const auto &attrib : req->attribLocations)
{
if (attrib.name.rfind("gl_", 0) != 0)
glBindAttribLocation(program, attrib.location, attrib.name.c_str());
}
glLinkProgram(program);
reqContentRenderer->getContextGL()->MarkAsDirty();
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
{
PrintDebugInfo(req, to_string(program).c_str(), nullptr, options);
// Check the link status of the program.
GLenum status;
glGetProgramiv(program, GL_LINK_STATUS, (GLint *)&status);
if (status == GL_FALSE)
{
GLint errorLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &errorLength);
GLchar *errorStr = new GLchar[errorLength];
glGetProgramInfoLog(program, errorLength, NULL, errorStr);
DEBUG(LOG_TAG_ERROR, "Failed to link program(%d): %s", program, errorStr);
delete[] errorStr;
return;
}
// Fetch the locations of the attributes when link successfully.
GLint numAttributes = 0;
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &numAttributes);
for (int i = 0; i < numAttributes; i++)
{
GLsizei nameLength;
GLint size; /** FIXME: need size for attribs? */
GLenum type;
GLchar name[256];
glGetActiveAttrib(program, i, sizeof(name) - 1, &nameLength, &size, &type, name);
name[nameLength] = '\0';
GLint location = glGetAttribLocation(program, name);
DEBUG(DEBUG_TAG,
" Attribute[%d](%s) => (size=%d, type=%s)",
location,
name,
size,
gles::glUniformTypesToString(type).c_str());
}
// Fetch the locations of the uniforms and attributes when link successfully.
GLint numUniforms = 0;
glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &numUniforms);
for (int i = 0; i < numUniforms; i++)
{
GLsizei nameLength;
GLint size;
GLenum type;
GLchar name[256];
glGetActiveUniform(program, i, sizeof(name) - 1, &nameLength, &size, &type, name);
name[nameLength] = '\0';
GLint location = glGetUniformLocation(program, name);
if (location <= -1)
continue;
DEBUG(DEBUG_TAG,
" Uniform[%d](%s) => (loc=%d, size=%d, type=%s)",
i,
name,
location,
size,
gles::glUniformTypesToString(type).c_str());
}
// Fetch the uniform blocks when link successfully.
GLint numUniformBlocks = 0;
glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &numUniformBlocks);
for (int i = 0; i < numUniformBlocks; i++)
{
GLsizei nameLength;
GLchar name[256];
glGetActiveUniformBlockName(program, i, sizeof(name) - 1, &nameLength, name);
name[nameLength] = '\0';
GLuint index = glGetUniformBlockIndex(program, name);
DEBUG(DEBUG_TAG, " UniformBlock[%s] => %d", name, index);
}
}
}
TR_OPENGL_FUNC void OnUseProgram(UseProgramCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
GLuint program;
reqContentRenderer->getContextGL()->useProgram(req->clientId, program);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnValidateProgram(ValidateProgramCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
GLuint program = glContext->ObjectManagerRef().FindProgram(req->clientId);
glValidateProgram(program);
reqContentRenderer->getContextGL()->MarkAsDirty();
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnBindAttribLocation(BindAttribLocationCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
auto program = glContext->ObjectManagerRef().FindProgram(req->program);
glBindAttribLocation(program, req->attribIndex, req->attribName.c_str());
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
DEBUG(DEBUG_TAG,
"[%d] GL::BindAttribLocation(program=%d, index=%d, name=%s)",
options.isDefaultQueue(),
program,
req->attribIndex,
req->attribName.c_str());
}
TR_OPENGL_FUNC void OnGetProgramParameter(GetProgramParamCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
auto program = glContext->ObjectManagerRef().FindProgram(req->clientId);
GLint value;
glGetProgramiv(program, req->pname, &value);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(value).c_str(), nullptr, options);
GetProgramParamCommandBufferResponse res(req, value);
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnGetProgramInfoLog(GetProgramInfoLogCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
auto program = glContext->ObjectManagerRef().FindProgram(req->clientId);
GLint retSize;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &retSize);
GLchar *infoLog = new GLchar[retSize];
glGetProgramInfoLog(program, retSize, NULL, infoLog);
GetProgramInfoLogCommandBufferResponse res(req, string(infoLog));
delete[] infoLog;
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
DEBUG(DEBUG_TAG,
"[%d] GL::GetProgramInfoLog: \"%s\"(%d)",
options.isDefaultQueue(),
res.infoLog.c_str(),
retSize);
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnAttachShader(AttachShaderCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto glContext = reqContentRenderer->getContextGL();
GLuint program = glContext->ObjectManagerRef().FindProgram(req->program);
GLuint shader = glContext->ObjectManagerRef().FindShader(req->shader);
glAttachShader(program, shader);
reqContentRenderer->getContextGL()->MarkAsDirty();
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnDetachShader(DetachShaderCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint program = glObjectManager.FindProgram(req->program);
GLuint shader = glObjectManager.FindShader(req->shader);
glDetachShader(program, shader);
reqContentRenderer->getContextGL()->MarkAsDirty();
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnCreateShader(CreateShaderCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint shader = glObjectManager.CreateShader(req->clientId, req->shaderType);
reqContentRenderer->getContextGL()->RecordShaderOnCreated(shader);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnDeleteShader(DeleteShaderCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto shader = glObjectManager.FindShader(req->shader);
glObjectManager.DeleteShader(req->shader);
reqContentRenderer->getContextGL()->RecordShaderOnDeleted(shader);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnShaderSource(ShaderSourceCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto shader = glObjectManager.FindShader(req->shader);
auto source = req->source();
string fixedSource;
{
string line;
size_t pos = 0;
while (pos < source.size())
{
getline(source, line, pos);
string newLine = line;
#ifdef __APPLE__
/**
* FIXME(Yorkie): This is a workaround for the shader source on macOS, we need to replace the version to 410 core
* directly, a better solution is to use the shader preprocessor like google/angle to handle this.
*/
if (line.find("#version") != string::npos)
newLine = "#version 410 core";
#endif
fixedSource += newLine + "\n";
}
}
const char *sourceStr = fixedSource.c_str();
size_t sourceSize = fixedSource.size();
glShaderSource(shader, 1, &sourceStr, (const GLint *)&sourceSize);
reqContentRenderer->getContextGL()->MarkAsDirty();
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnCompileShader(CompileShaderCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto shader = glObjectManager.FindShader(req->shader);
glCompileShader(shader);
reqContentRenderer->getContextGL()->MarkAsDirty();
GLint compileStatus;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
if (compileStatus != GL_TRUE)
{
DEBUG(LOG_TAG_ERROR, "Failed to compile shader(%d)", shader);
GLint logLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
{
std::vector<GLchar> log(logLength);
glGetShaderInfoLog(shader, logLength, nullptr, log.data());
DEBUG(LOG_TAG_ERROR, "Shader compile log: %s", log.data());
}
// Print the shader source
GLint sourceSize;
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceSize);
GLchar *source = new GLchar[sourceSize];
GLint maxLength = sourceSize;
GLint bytesWritten;
string shaderSource = "";
while (true)
{
glGetShaderSource(shader, maxLength, &bytesWritten, source);
if (bytesWritten < maxLength - 1)
break;
maxLength += sourceSize;
shaderSource += string(source);
source = (GLchar *)realloc(source, maxLength);
}
delete[] source;
DEBUG(LOG_TAG_ERROR, "=============== Shader Source ===============");
string line;
uint32_t lineNum = 1;
size_t pos = 0;
while (pos < shaderSource.size())
{
getline(shaderSource, line, pos);
int num = lineNum++;
if (num < 10)
DEBUG(LOG_TAG_ERROR, "[00%d] %s", num, line.c_str());
else if (num < 100)
DEBUG(LOG_TAG_ERROR, "[0%d] %s", num, line.c_str());
else
DEBUG(LOG_TAG_ERROR, "[%d] %s", lineNum++, line.c_str());
}
DEBUG(LOG_TAG_ERROR, "=============== Shader Source ===============");
}
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnGetShaderSource(GetShaderSourceCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GetShaderSourceCommandBufferResponse res(req);
GLint sourceSize;
GLuint shader = glObjectManager.FindShader(req->shader);
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &sourceSize);
if (sourceSize <= 0)
{
DEBUG(DEBUG_TAG, "Failed to get shader source from #%d", shader);
reqContentRenderer->sendCommandBufferResponse(res);
return;
}
GLchar *source = new GLchar[sourceSize];
GLint maxLength = sourceSize;
GLint bytesWritten;
while (true)
{
glGetShaderSource(shader, maxLength, &bytesWritten, source);
if (bytesWritten < maxLength - 1)
break;
maxLength += sourceSize;
source = (GLchar *)realloc(source, maxLength);
}
res.source = string(source);
delete[] source;
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
DEBUG(DEBUG_TAG, "[%d] GL::GetShaderSource(): %s", options.isDefaultQueue(), res.source.c_str());
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnGetShaderParameter(GetShaderParamCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint shader = glObjectManager.FindShader(req->shader);
GetShaderParamCommandBufferResponse res(req);
glGetShaderiv(shader, GL_DELETE_STATUS, reinterpret_cast<GLint *>(&res.deleteStatus));
glGetShaderiv(shader, GL_COMPILE_STATUS, reinterpret_cast<GLint *>(&res.compileStatus));
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnGetShaderInfoLog(GetShaderInfoLogCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint shader = glObjectManager.FindShader(req->shader);
GLint logSize;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logSize);
GLchar *log = new GLchar[logSize];
glGetShaderInfoLog(shader, logSize, NULL, log);
GetShaderInfoLogCommandBufferResponse res(req, string(log));
delete[] log;
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
DEBUG(DEBUG_TAG, "[%d] GL::GetShaderInfoLog: %s", options.isDefaultQueue(), res.infoLog.c_str());
reqContentRenderer->sendCommandBufferResponse(res);
}
TR_OPENGL_FUNC void OnCreateBuffer(CreateBufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint buffer = glObjectManager.CreateBuffer(req->clientId);
reqContentRenderer->getContextGL()->RecordBufferOnCreated(buffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(buffer).c_str(), nullptr, options);
}
TR_OPENGL_FUNC void OnDeleteBuffer(DeleteBufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto buffer = glObjectManager.FindBuffer(req->buffer);
glObjectManager.DeleteBuffer(req->buffer);
reqContentRenderer->getContextGL()->RecordBufferOnDeleted(buffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnBindBuffer(BindBufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
uint32_t target = req->target;
GLuint buffer = glObjectManager.FindBuffer(req->buffer);
if (req->buffer != 0 && buffer == 0) [[unlikely]]
{
reqContentRenderer->increaseFrameErrorsCount();
DEBUG(LOG_TAG_ERROR, "Could not find buffer(cid=%d) to bind", req->buffer);
glObjectManager.PrintBuffers();
return;
}
/** Update the app states for next restore. */
if (target == GL_ARRAY_BUFFER)
reqContentRenderer->getContextGL()->onArrayBufferChanged(buffer);
else if (target == GL_ELEMENT_ARRAY_BUFFER)
reqContentRenderer->getContextGL()->onElementBufferChanged(buffer);
// TODO: support other targets?
glBindBuffer(target, buffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(buffer).c_str(), nullptr, options);
}
TR_OPENGL_FUNC void OnBufferData(BufferDataCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto target = req->target;
auto size = req->dataSize;
auto data = req->data;
auto usage = req->usage;
glBufferData(target, size, data, usage);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
{
PrintDebugInfo(req, nullptr, nullptr, options);
GLint binding_buffer;
glGetIntegerv(target == GL_ARRAY_BUFFER ? GL_ARRAY_BUFFER_BINDING : GL_ELEMENT_ARRAY_BUFFER_BINDING,
&binding_buffer);
DEBUG(DEBUG_TAG, " Binding: %d", binding_buffer);
}
}
TR_OPENGL_FUNC void OnBufferSubData(BufferSubDataCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
glBufferSubData(req->target, req->offset, req->dataSize, req->data);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnCreateFramebuffer(CreateFramebufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint framebuffer = glObjectManager.CreateFramebuffer(req->clientId);
reqContentRenderer->getContextGL()->RecordFramebufferOnCreated(framebuffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(framebuffer).c_str(), nullptr, options);
}
TR_OPENGL_FUNC void OnDeleteFramebuffer(
DeleteFramebufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
GLuint framebuffer = glObjectManager.FindFramebuffer(req->framebuffer);
glObjectManager.DeleteFramebuffer(req->framebuffer);
reqContentRenderer->getContextGL()->RecordFramebufferOnDeleted(framebuffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnBindFramebuffer(
BindFramebufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto app_context = reqContentRenderer->getContextGL();
GLuint framebuffer;
app_context->bindFramebuffer(req->target,
req->isBindToDefault() ? nullopt : make_optional<uint32_t>(req->framebuffer),
framebuffer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, to_string(framebuffer).c_str(), nullptr, options);
}
TR_OPENGL_FUNC void OnFramebufferRenderbuffer(FramebufferRenderbufferCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();