forked from google/angle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TracePerfTest.cpp
2572 lines (2227 loc) · 85.5 KB
/
TracePerfTest.cpp
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
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TracePerf:
// Performance test for ANGLE replaying traces.
//
#include <gtest/gtest.h>
#include "common/PackedEnums.h"
#include "common/string_utils.h"
#include "common/system_utils.h"
#include "tests/perf_tests/ANGLEPerfTest.h"
#include "tests/perf_tests/ANGLEPerfTestArgs.h"
#include "tests/perf_tests/DrawCallPerfParams.h"
#include "util/capture/frame_capture_test_utils.h"
#include "util/capture/traces_export.h"
#include "util/egl_loader_autogen.h"
#include "util/png_utils.h"
#include "util/test_utils.h"
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <cassert>
#include <fstream>
#include <functional>
#include <sstream>
// When --minimize-gpu-work is specified, we want to reduce GPU work to minimum and lift up the CPU
// overhead to surface so that we can see how much CPU overhead each driver has for each app trace.
// On some driver(s) the bufferSubData/texSubImage calls end up dominating the frame time when the
// actual GPU work is minimized. Even reducing the texSubImage calls to only update 1x1 area is not
// enough. The driver may be implementing copy on write by cloning the entire texture to another
// memory storage for texSubImage call. While this information is also important for performance,
// they should be evaluated separately in real app usage scenario, or write stand alone tests for
// these. For the purpose of CPU overhead and avoid data copy to dominate the trace, I am using this
// flag to noop the texSubImage and bufferSubData call when --minimize-gpu-work is specified. Feel
// free to disable this when you have other needs. Or it can be turned to another run time option
// when desired.
#define NOOP_SUBDATA_SUBIMAGE_FOR_MINIMIZE_GPU_WORK
using namespace angle;
using namespace egl_platform;
namespace
{
constexpr size_t kMaxPath = 1024;
struct TracePerfParams final : public RenderTestParams
{
// Common default options
TracePerfParams(const TraceInfo &traceInfoIn,
GLESDriverType driverType,
EGLenum platformType,
EGLenum deviceType)
: traceInfo(traceInfoIn)
{
majorVersion = traceInfo.contextClientMajorVersion;
minorVersion = traceInfo.contextClientMinorVersion;
windowWidth = traceInfo.drawSurfaceWidth;
windowHeight = traceInfo.drawSurfaceHeight;
colorSpace = traceInfo.drawSurfaceColorSpace;
// Display the frame after every drawBenchmark invocation
iterationsPerStep = 1;
driver = driverType;
eglParameters.renderer = platformType;
eglParameters.deviceType = deviceType;
ASSERT(!gOffscreen || !gVsync);
if (gOffscreen)
{
surfaceType = SurfaceType::Offscreen;
if (!IsAndroid())
{
windowWidth /= 4;
windowHeight /= 4;
}
}
if (gVsync)
{
surfaceType = SurfaceType::WindowWithVSync;
}
// Force on features if we're validating serialization.
if (gTraceTestValidation)
{
// Enable limits when validating traces because we usually turn off capture.
eglParameters.enable(Feature::EnableCaptureLimits);
// This feature should also be enabled in capture to mirror the replay.
eglParameters.enable(Feature::ForceInitShaderVariables);
}
}
std::string story() const override
{
std::stringstream strstr;
strstr << RenderTestParams::story() << "_" << traceInfo.name;
return strstr.str();
}
TraceInfo traceInfo = {};
};
class TracePerfTest : public ANGLERenderTest
{
public:
TracePerfTest(std::unique_ptr<const TracePerfParams> params);
void startTest() override;
void initializeBenchmark() override;
void destroyBenchmark() override;
void drawBenchmark() override;
// TODO(http://www.anglebug.com/5878): Add support for creating EGLSurface:
// - eglCreatePbufferSurface()
// - eglCreateWindowSurface()
EGLContext onEglCreateContext(EGLDisplay display,
EGLConfig config,
EGLContext share_context,
EGLint const *attrib_list);
void onEglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context);
EGLContext onEglGetCurrentContext();
EGLImage onEglCreateImage(EGLDisplay display,
EGLContext context,
EGLenum target,
EGLClientBuffer buffer,
const EGLAttrib *attrib_list);
EGLImageKHR onEglCreateImageKHR(EGLDisplay display,
EGLContext context,
EGLenum target,
EGLClientBuffer buffer,
const EGLint *attrib_list);
EGLBoolean onEglDestroyImage(EGLDisplay display, EGLImage image);
EGLBoolean onEglDestroyImageKHR(EGLDisplay display, EGLImage image);
EGLSync onEglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list);
EGLSync onEglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLBoolean onEglDestroySync(EGLDisplay dpy, EGLSync sync);
EGLBoolean onEglDestroySyncKHR(EGLDisplay dpy, EGLSync sync);
EGLint onEglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTimeKHR timeout);
EGLint onEglClientWaitSyncKHR(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTimeKHR timeout);
EGLint onEglGetError();
EGLDisplay onEglGetCurrentDisplay();
void onReplayFramebufferChange(GLenum target, GLuint framebuffer);
void onReplayInvalidateFramebuffer(GLenum target,
GLsizei numAttachments,
const GLenum *attachments);
void onReplayInvalidateSubFramebuffer(GLenum target,
GLsizei numAttachments,
const GLenum *attachments,
GLint x,
GLint y,
GLsizei width,
GLsizei height);
void onReplayDrawBuffers(GLsizei n, const GLenum *bufs);
void onReplayReadBuffer(GLenum src);
void onReplayDiscardFramebufferEXT(GLenum target,
GLsizei numAttachments,
const GLenum *attachments);
void validateSerializedState(const char *serializedState, const char *fileName, uint32_t line);
bool isDefaultFramebuffer(GLenum target) const;
double getHostTimeFromGLTime(GLint64 glTime);
uint32_t frameCount() const
{
const TraceInfo &traceInfo = mParams->traceInfo;
return traceInfo.frameEnd - traceInfo.frameStart + 1;
}
int getStepAlignment() const override
{
// Align step counts to the number of frames in a trace.
return static_cast<int>(frameCount());
}
void TestBody() override { run(); }
bool traceNameIs(const char *name) const
{
return strncmp(name, mParams->traceInfo.name, kTraceInfoMaxNameLen) == 0;
}
private:
struct QueryInfo
{
GLuint beginTimestampQuery;
GLuint endTimestampQuery;
GLuint framebuffer;
};
struct TimeSample
{
GLint64 glTime;
double hostTime;
};
void sampleTime();
void saveScreenshot(const std::string &screenshotName) override;
void swap();
std::unique_ptr<const TracePerfParams> mParams;
uint32_t mStartFrame;
uint32_t mEndFrame;
// For tracking RenderPass/FBO change timing.
QueryInfo mCurrentQuery = {};
std::vector<QueryInfo> mRunningQueries;
std::vector<TimeSample> mTimeline;
bool mUseTimestampQueries = false;
static constexpr int mMaxOffscreenBufferCount = 2;
std::array<GLuint, mMaxOffscreenBufferCount> mOffscreenFramebuffers = {0, 0};
std::array<GLuint, mMaxOffscreenBufferCount> mOffscreenTextures = {0, 0};
GLuint mOffscreenDepthStencil = 0;
int mWindowWidth = 0;
int mWindowHeight = 0;
GLuint mDrawFramebufferBinding = 0;
GLuint mReadFramebufferBinding = 0;
uint32_t mCurrentFrame = 0;
uint32_t mCurrentIteration = 0;
uint32_t mOffscreenFrameCount = 0;
uint32_t mTotalFrameCount = 0;
bool mScreenshotSaved = false;
uint32_t mScreenshotFrame = gScreenshotFrame;
std::unique_ptr<TraceLibrary> mTraceReplay;
};
TracePerfTest *gCurrentTracePerfTest = nullptr;
// Don't forget to include KHRONOS_APIENTRY in override methods. Necessary on Win/x86.
EGLContext KHRONOS_APIENTRY EglCreateContext(EGLDisplay display,
EGLConfig config,
EGLContext share_context,
EGLint const *attrib_list)
{
return gCurrentTracePerfTest->onEglCreateContext(display, config, share_context, attrib_list);
}
void KHRONOS_APIENTRY EglMakeCurrent(EGLDisplay display,
EGLSurface draw,
EGLSurface read,
EGLContext context)
{
gCurrentTracePerfTest->onEglMakeCurrent(display, draw, read, context);
}
EGLContext KHRONOS_APIENTRY EglGetCurrentContext()
{
return gCurrentTracePerfTest->onEglGetCurrentContext();
}
EGLImage KHRONOS_APIENTRY EglCreateImage(EGLDisplay display,
EGLContext context,
EGLenum target,
EGLClientBuffer buffer,
const EGLAttrib *attrib_list)
{
return gCurrentTracePerfTest->onEglCreateImage(display, context, target, buffer, attrib_list);
}
EGLImageKHR KHRONOS_APIENTRY EglCreateImageKHR(EGLDisplay display,
EGLContext context,
EGLenum target,
EGLClientBuffer buffer,
const EGLint *attrib_list)
{
return gCurrentTracePerfTest->onEglCreateImageKHR(display, context, target, buffer,
attrib_list);
}
EGLBoolean KHRONOS_APIENTRY EglDestroyImage(EGLDisplay display, EGLImage image)
{
return gCurrentTracePerfTest->onEglDestroyImage(display, image);
}
EGLBoolean KHRONOS_APIENTRY EglDestroyImageKHR(EGLDisplay display, EGLImage image)
{
return gCurrentTracePerfTest->onEglDestroyImageKHR(display, image);
}
EGLSync KHRONOS_APIENTRY EglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
{
return gCurrentTracePerfTest->onEglCreateSync(dpy, type, attrib_list);
}
EGLSync KHRONOS_APIENTRY EglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
{
return gCurrentTracePerfTest->onEglCreateSyncKHR(dpy, type, attrib_list);
}
EGLBoolean KHRONOS_APIENTRY EglDestroySync(EGLDisplay dpy, EGLSync sync)
{
return gCurrentTracePerfTest->onEglDestroySync(dpy, sync);
}
EGLBoolean KHRONOS_APIENTRY EglDestroySyncKHR(EGLDisplay dpy, EGLSync sync)
{
return gCurrentTracePerfTest->onEglDestroySyncKHR(dpy, sync);
}
EGLint KHRONOS_APIENTRY EglClientWaitSync(EGLDisplay dpy,
EGLSync sync,
EGLint flags,
EGLTimeKHR timeout)
{
return gCurrentTracePerfTest->onEglClientWaitSync(dpy, sync, flags, timeout);
}
EGLint KHRONOS_APIENTRY EglClientWaitSyncKHR(EGLDisplay dpy,
EGLSync sync,
EGLint flags,
EGLTimeKHR timeout)
{
return gCurrentTracePerfTest->onEglClientWaitSyncKHR(dpy, sync, flags, timeout);
}
EGLint KHRONOS_APIENTRY EglGetError()
{
return gCurrentTracePerfTest->onEglGetError();
}
EGLDisplay KHRONOS_APIENTRY EglGetCurrentDisplay()
{
return gCurrentTracePerfTest->onEglGetCurrentDisplay();
}
void KHRONOS_APIENTRY BindFramebufferProc(GLenum target, GLuint framebuffer)
{
gCurrentTracePerfTest->onReplayFramebufferChange(target, framebuffer);
}
void KHRONOS_APIENTRY InvalidateFramebufferProc(GLenum target,
GLsizei numAttachments,
const GLenum *attachments)
{
gCurrentTracePerfTest->onReplayInvalidateFramebuffer(target, numAttachments, attachments);
}
void KHRONOS_APIENTRY InvalidateSubFramebufferProc(GLenum target,
GLsizei numAttachments,
const GLenum *attachments,
GLint x,
GLint y,
GLsizei width,
GLsizei height)
{
gCurrentTracePerfTest->onReplayInvalidateSubFramebuffer(target, numAttachments, attachments, x,
y, width, height);
}
void KHRONOS_APIENTRY DrawBuffersProc(GLsizei n, const GLenum *bufs)
{
gCurrentTracePerfTest->onReplayDrawBuffers(n, bufs);
}
void KHRONOS_APIENTRY ReadBufferProc(GLenum src)
{
gCurrentTracePerfTest->onReplayReadBuffer(src);
}
void KHRONOS_APIENTRY DiscardFramebufferEXTProc(GLenum target,
GLsizei numAttachments,
const GLenum *attachments)
{
gCurrentTracePerfTest->onReplayDiscardFramebufferEXT(target, numAttachments, attachments);
}
void KHRONOS_APIENTRY ViewportMinimizedProc(GLint x, GLint y, GLsizei width, GLsizei height)
{
glViewport(x, y, 1, 1);
}
void KHRONOS_APIENTRY ScissorMinimizedProc(GLint x, GLint y, GLsizei width, GLsizei height)
{
glScissor(x, y, 1, 1);
}
// Interpose the calls that generate actual GPU work
void KHRONOS_APIENTRY DrawElementsMinimizedProc(GLenum mode,
GLsizei count,
GLenum type,
const void *indices)
{
glDrawElements(GL_POINTS, 1, type, indices);
}
void KHRONOS_APIENTRY DrawElementsIndirectMinimizedProc(GLenum mode,
GLenum type,
const void *indirect)
{
glDrawElementsInstancedBaseVertex(GL_POINTS, 1, type, 0, 1, 0);
}
void KHRONOS_APIENTRY DrawElementsInstancedMinimizedProc(GLenum mode,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instancecount)
{
glDrawElementsInstanced(GL_POINTS, 1, type, indices, 1);
}
void KHRONOS_APIENTRY DrawElementsBaseVertexMinimizedProc(GLenum mode,
GLsizei count,
GLenum type,
const void *indices,
GLint basevertex)
{
glDrawElementsBaseVertex(GL_POINTS, 1, type, indices, basevertex);
}
void KHRONOS_APIENTRY DrawElementsInstancedBaseVertexMinimizedProc(GLenum mode,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instancecount,
GLint basevertex)
{
glDrawElementsInstancedBaseVertex(GL_POINTS, 1, type, indices, 1, basevertex);
}
void KHRONOS_APIENTRY DrawRangeElementsMinimizedProc(GLenum mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const void *indices)
{
glDrawRangeElements(GL_POINTS, start, end, 1, type, indices);
}
void KHRONOS_APIENTRY DrawArraysMinimizedProc(GLenum mode, GLint first, GLsizei count)
{
glDrawArrays(GL_POINTS, first, 1);
}
void KHRONOS_APIENTRY DrawArraysInstancedMinimizedProc(GLenum mode,
GLint first,
GLsizei count,
GLsizei instancecount)
{
glDrawArraysInstanced(GL_POINTS, first, 1, 1);
}
void KHRONOS_APIENTRY DrawArraysIndirectMinimizedProc(GLenum mode, const void *indirect)
{
glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
}
void KHRONOS_APIENTRY DispatchComputeMinimizedProc(GLuint num_groups_x,
GLuint num_groups_y,
GLuint num_groups_z)
{
glDispatchCompute(1, 1, 1);
}
void KHRONOS_APIENTRY DispatchComputeIndirectMinimizedProc(GLintptr indirect)
{
glDispatchCompute(1, 1, 1);
}
// Interpose the calls that generate data copying work
void KHRONOS_APIENTRY BufferDataMinimizedProc(GLenum target,
GLsizeiptr size,
const void *data,
GLenum usage)
{
glBufferData(target, size, nullptr, usage);
}
void KHRONOS_APIENTRY BufferSubDataMinimizedProc(GLenum target,
GLintptr offset,
GLsizeiptr size,
const void *data)
{
#if !defined(NOOP_SUBDATA_SUBIMAGE_FOR_MINIMIZE_GPU_WORK)
glBufferSubData(target, offset, 1, data);
#endif
}
void *KHRONOS_APIENTRY MapBufferRangeMinimizedProc(GLenum target,
GLintptr offset,
GLsizeiptr length,
GLbitfield access)
{
access |= GL_MAP_UNSYNCHRONIZED_BIT;
return glMapBufferRange(target, offset, length, access);
}
void KHRONOS_APIENTRY TexImage2DMinimizedProc(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const void *pixels)
{
GLint unpackBuffer = 0;
glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &unpackBuffer);
if (unpackBuffer)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
glTexImage2D(target, level, internalformat, width, height, border, format, type, nullptr);
if (unpackBuffer)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, unpackBuffer);
}
}
void KHRONOS_APIENTRY TexSubImage2DMinimizedProc(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const void *pixels)
{
#if !defined(NOOP_SUBDATA_SUBIMAGE_FOR_MINIMIZE_GPU_WORK)
glTexSubImage2D(target, level, xoffset, yoffset, 1, 1, format, type, pixels);
#endif
}
void KHRONOS_APIENTRY TexImage3DMinimizedProc(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const void *pixels)
{
GLint unpackBuffer = 0;
glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &unpackBuffer);
if (unpackBuffer)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
glTexImage3D(target, level, internalformat, width, height, depth, border, format, type,
nullptr);
if (unpackBuffer)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, unpackBuffer);
}
}
void KHRONOS_APIENTRY TexSubImage3DMinimizedProc(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const void *pixels)
{
#if !defined(NOOP_SUBDATA_SUBIMAGE_FOR_MINIMIZE_GPU_WORK)
glTexSubImage3D(target, level, xoffset, yoffset, zoffset, 1, 1, 1, format, type, pixels);
#endif
}
void KHRONOS_APIENTRY GenerateMipmapMinimizedProc(GLenum target)
{
// Noop it for now. There is a risk that this will leave an incomplete mipmap chain and cause
// other issues. If this turns out to be a real issue with app traces, we can turn this into a
// glTexImage2D call for each generated level.
}
void KHRONOS_APIENTRY BlitFramebufferMinimizedProc(GLint srcX0,
GLint srcY0,
GLint srcX1,
GLint srcY1,
GLint dstX0,
GLint dstY0,
GLint dstX1,
GLint dstY1,
GLbitfield mask,
GLenum filter)
{
glBlitFramebuffer(srcX0, srcY0, srcX0 + 1, srcY0 + 1, dstX0, dstY0, dstX0 + 1, dstY0 + 1, mask,
filter);
}
void KHRONOS_APIENTRY ReadPixelsMinimizedProc(GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
void *pixels)
{
glReadPixels(x, y, 1, 1, format, type, pixels);
}
void KHRONOS_APIENTRY BeginTransformFeedbackMinimizedProc(GLenum primitiveMode)
{
glBeginTransformFeedback(GL_POINTS);
}
angle::GenericProc KHRONOS_APIENTRY TraceLoadProc(const char *procName)
{
// EGL
if (strcmp(procName, "eglCreateContext") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglCreateContext);
}
if (strcmp(procName, "eglMakeCurrent") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglMakeCurrent);
}
if (strcmp(procName, "eglGetCurrentContext") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglGetCurrentContext);
}
if (strcmp(procName, "eglCreateImage") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglCreateImage);
}
if (strcmp(procName, "eglCreateImageKHR") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglCreateImageKHR);
}
if (strcmp(procName, "eglDestroyImage") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglDestroyImage);
}
if (strcmp(procName, "eglDestroyImageKHR") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglDestroyImageKHR);
}
if (strcmp(procName, "eglCreateSync") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglCreateSync);
}
if (strcmp(procName, "eglCreateSyncKHR") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglCreateSyncKHR);
}
if (strcmp(procName, "eglDestroySync") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglDestroySync);
}
if (strcmp(procName, "eglDestroySyncKHR") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglDestroySyncKHR);
}
if (strcmp(procName, "eglClientWaitSync") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglClientWaitSync);
}
if (strcmp(procName, "eglClientWaitSyncKHR") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglClientWaitSyncKHR);
}
if (strcmp(procName, "eglGetError") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglGetError);
}
if (strcmp(procName, "eglGetCurrentDisplay") == 0)
{
return reinterpret_cast<angle::GenericProc>(EglGetCurrentDisplay);
}
// GLES
if (strcmp(procName, "glBindFramebuffer") == 0)
{
return reinterpret_cast<angle::GenericProc>(BindFramebufferProc);
}
if (strcmp(procName, "glInvalidateFramebuffer") == 0)
{
return reinterpret_cast<angle::GenericProc>(InvalidateFramebufferProc);
}
if (strcmp(procName, "glInvalidateSubFramebuffer") == 0)
{
return reinterpret_cast<angle::GenericProc>(InvalidateSubFramebufferProc);
}
if (strcmp(procName, "glDrawBuffers") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawBuffersProc);
}
if (strcmp(procName, "glReadBuffer") == 0)
{
return reinterpret_cast<angle::GenericProc>(ReadBufferProc);
}
if (strcmp(procName, "glDiscardFramebufferEXT") == 0)
{
return reinterpret_cast<angle::GenericProc>(DiscardFramebufferEXTProc);
}
if (gMinimizeGPUWork)
{
if (strcmp(procName, "glViewport") == 0)
{
return reinterpret_cast<angle::GenericProc>(ViewportMinimizedProc);
}
if (strcmp(procName, "glScissor") == 0)
{
return reinterpret_cast<angle::GenericProc>(ScissorMinimizedProc);
}
// Interpose the calls that generate actual GPU work
if (strcmp(procName, "glDrawElements") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawElementsMinimizedProc);
}
if (strcmp(procName, "glDrawElementsIndirect") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawElementsIndirectMinimizedProc);
}
if (strcmp(procName, "glDrawElementsInstanced") == 0 ||
strcmp(procName, "glDrawElementsInstancedEXT") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawElementsInstancedMinimizedProc);
}
if (strcmp(procName, "glDrawElementsBaseVertex") == 0 ||
strcmp(procName, "glDrawElementsBaseVertexEXT") == 0 ||
strcmp(procName, "glDrawElementsBaseVertexOES") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawElementsBaseVertexMinimizedProc);
}
if (strcmp(procName, "glDrawElementsInstancedBaseVertex") == 0 ||
strcmp(procName, "glDrawElementsInstancedBaseVertexEXT") == 0 ||
strcmp(procName, "glDrawElementsInstancedBaseVertexOES") == 0)
{
return reinterpret_cast<angle::GenericProc>(
DrawElementsInstancedBaseVertexMinimizedProc);
}
if (strcmp(procName, "glDrawRangeElements") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawRangeElementsMinimizedProc);
}
if (strcmp(procName, "glDrawArrays") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawArraysMinimizedProc);
}
if (strcmp(procName, "glDrawArraysInstanced") == 0 ||
strcmp(procName, "glDrawArraysInstancedEXT") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawArraysInstancedMinimizedProc);
}
if (strcmp(procName, "glDrawArraysIndirect") == 0)
{
return reinterpret_cast<angle::GenericProc>(DrawArraysIndirectMinimizedProc);
}
if (strcmp(procName, "glDispatchCompute") == 0)
{
return reinterpret_cast<angle::GenericProc>(DispatchComputeMinimizedProc);
}
if (strcmp(procName, "glDispatchComputeIndirect") == 0)
{
return reinterpret_cast<angle::GenericProc>(DispatchComputeIndirectMinimizedProc);
}
// Interpose the calls that generate data copying work
if (strcmp(procName, "glBufferData") == 0)
{
return reinterpret_cast<angle::GenericProc>(BufferDataMinimizedProc);
}
if (strcmp(procName, "glBufferSubData") == 0)
{
return reinterpret_cast<angle::GenericProc>(BufferSubDataMinimizedProc);
}
if (strcmp(procName, "glMapBufferRange") == 0 ||
strcmp(procName, "glMapBufferRangeEXT") == 0)
{
return reinterpret_cast<angle::GenericProc>(MapBufferRangeMinimizedProc);
}
if (strcmp(procName, "glTexImage2D") == 0)
{
return reinterpret_cast<angle::GenericProc>(TexImage2DMinimizedProc);
}
if (strcmp(procName, "glTexImage3D") == 0)
{
return reinterpret_cast<angle::GenericProc>(TexImage3DMinimizedProc);
}
if (strcmp(procName, "glTexSubImage2D") == 0)
{
return reinterpret_cast<angle::GenericProc>(TexSubImage2DMinimizedProc);
}
if (strcmp(procName, "glTexSubImage3D") == 0)
{
return reinterpret_cast<angle::GenericProc>(TexSubImage3DMinimizedProc);
}
if (strcmp(procName, "glGenerateMipmap") == 0 ||
strcmp(procName, "glGenerateMipmapOES") == 0)
{
return reinterpret_cast<angle::GenericProc>(GenerateMipmapMinimizedProc);
}
if (strcmp(procName, "glBlitFramebuffer") == 0)
{
return reinterpret_cast<angle::GenericProc>(BlitFramebufferMinimizedProc);
}
if (strcmp(procName, "glReadPixels") == 0)
{
return reinterpret_cast<angle::GenericProc>(ReadPixelsMinimizedProc);
}
if (strcmp(procName, "glBeginTransformFeedback") == 0)
{
return reinterpret_cast<angle::GenericProc>(BeginTransformFeedbackMinimizedProc);
}
}
return gCurrentTracePerfTest->getGLWindow()->getProcAddress(procName);
}
void ValidateSerializedState(const char *serializedState, const char *fileName, uint32_t line)
{
gCurrentTracePerfTest->validateSerializedState(serializedState, fileName, line);
}
constexpr char kTraceTestFolder[] = "src/tests/restricted_traces";
bool FindTraceTestDataPath(const char *traceName, char *testDataDirOut, size_t maxDataDirLen)
{
char relativeTestDataDir[kMaxPath] = {};
snprintf(relativeTestDataDir, kMaxPath, "%s%c%s", kTraceTestFolder, GetPathSeparator(),
traceName);
return angle::FindTestDataPath(relativeTestDataDir, testDataDirOut, maxDataDirLen);
}
bool FindRootTraceTestDataPath(char *testDataDirOut, size_t maxDataDirLen)
{
return angle::FindTestDataPath(kTraceTestFolder, testDataDirOut, maxDataDirLen);
}
TracePerfTest::TracePerfTest(std::unique_ptr<const TracePerfParams> params)
: ANGLERenderTest("TracePerf", *params.get(), "ms"),
mParams(std::move(params)),
mStartFrame(0),
mEndFrame(0)
{
bool isAMD = IsAMD() && !mParams->isSwiftshader();
bool isAMDLinux = isAMD && IsLinux();
// bool isAMDLinuxANGLE = isAMDLinux && mParams->isANGLE();
bool isAMDLinuxNative = isAMDLinux && !mParams->isANGLE();
bool isAMDWin = isAMD && IsWindows();
bool isAMDWinANGLE = isAMDWin && mParams->isANGLE();
// bool isAMDWinNative = isAMDWin && !mParams->isANGLE();
bool isIntel = IsIntel() && !mParams->isSwiftshader();
bool isIntelLinux = isIntel && IsLinux();
bool isIntelLinuxANGLE = isIntelLinux && mParams->isANGLE();
bool isIntelLinuxNative = isIntelLinux && !mParams->isANGLE();
bool isIntelWin = IsWindows() && isIntel;
bool isIntelWinANGLE = isIntelWin && mParams->isANGLE();
bool isIntelWinNative = isIntelWin && !mParams->isANGLE();
bool isNVIDIA = IsNVIDIA() && !mParams->isSwiftshader();
bool isNVIDIALinux = isNVIDIA && IsLinux();
bool isNVIDIALinuxANGLE = isNVIDIALinux && mParams->isANGLE();
bool isNVIDIALinuxNative = isNVIDIALinux && !mParams->isANGLE();
bool isNVIDIAWin = isNVIDIA && IsWindows();
bool isNVIDIAWinANGLE = isNVIDIAWin && mParams->isANGLE();
bool isNVIDIAWinNative = isNVIDIAWin && !mParams->isANGLE();
if (!mParams->traceInfo.initialized)
{
failTest("Failed to load trace json.");
return;
}
for (std::string extension : mParams->traceInfo.requiredExtensions)
{
addExtensionPrerequisite(extension);
}
if (!mParams->traceInfo.keyFrames.empty())
{
// Only support one keyFrame for now
if (mParams->traceInfo.keyFrames.size() != 1)
{
WARN() << "Multiple keyframes detected, only using the first";
}
// Only use keyFrame if the user didn't specify a value.
if (gScreenshotFrame == kDefaultScreenshotFrame)
{
mScreenshotFrame = mParams->traceInfo.keyFrames[0];
INFO() << "Trace contains keyframe, using frame " << mScreenshotFrame
<< " for screenshot";
}
else
{
WARN() << "Ignoring keyframe, user requested frame " << mScreenshotFrame
<< " for screenshot";
}
}
if (isIntelWinANGLE && traceNameIs("manhattan_10"))
{
skipTest(
"TODO: http://anglebug.com/4533 This fails after the upgrade to the 26.20.100.7870 "
"driver");
}
if (isIntelWinNative && traceNameIs("angry_birds_2_1500"))
{
skipTest("TODO: http://anglebug.com/4731 Fails on older Intel drivers. Passes in newer");
}
if (traceNameIs("cod_mobile"))
{
// TODO: http://anglebug.com/4967 Vulkan: GL_EXT_color_buffer_float not supported on Pixel 2
// The COD:Mobile trace uses a framebuffer attachment with:
// format = GL_RGB
// type = GL_UNSIGNED_INT_10F_11F_11F_REV
// That combination is only renderable if GL_EXT_color_buffer_float is supported.
// It happens to not be supported on Pixel 2's Vulkan driver.
addExtensionPrerequisite("GL_EXT_color_buffer_float");
// TODO: http://anglebug.com/4731 This extension is missing on older Intel drivers.
addExtensionPrerequisite("GL_OES_EGL_image_external");
if (isIntelWin)
{
skipTest("http://anglebug.com/6568 Flaky on Intel/windows");
}
}
if (isIntelWinANGLE && traceNameIs("black_desert_mobile"))
{
skipTest("TODO: http://anglebug.com/7879 Non-deterministic image on 31.0.101.2111 driver");
}
if (isIntelWinANGLE && traceNameIs("the_gardens_between"))
{
skipTest("TODO: http://anglebug.com/7879 Non-deterministic image on 31.0.101.2111 driver");
}
if (traceNameIs("brawl_stars"))
{
addExtensionPrerequisite("GL_EXT_shadow_samplers");
}
if (traceNameIs("free_fire"))
{
addExtensionPrerequisite("GL_OES_EGL_image_external");
}
if (traceNameIs("marvel_contest_of_champions"))
{
addExtensionPrerequisite("GL_EXT_color_buffer_half_float");
}
if (traceNameIs("world_of_tanks_blitz"))
{
addExtensionPrerequisite("GL_EXT_disjoint_timer_query");
}
if (traceNameIs("dragon_ball_legends"))
{
addExtensionPrerequisite("GL_KHR_texture_compression_astc_ldr");
}
if (traceNameIs("lego_legacy"))
{
addExtensionPrerequisite("GL_EXT_shadow_samplers");
}
if (traceNameIs("world_war_doh"))
{
// Linux+NVIDIA doesn't support GL_KHR_texture_compression_astc_ldr (possibly others also)
addExtensionPrerequisite("GL_KHR_texture_compression_astc_ldr");
}
if (traceNameIs("saint_seiya_awakening"))
{
addExtensionPrerequisite("GL_EXT_shadow_samplers");
if (isIntelLinuxANGLE)
{
skipTest(
"TODO: https://anglebug.com/5517 Linux+Intel generates 'Framebuffer is incomplete' "
"errors");
}
}
if (traceNameIs("magic_tiles_3"))
{
// Linux+NVIDIA doesn't support GL_KHR_texture_compression_astc_ldr (possibly others also)
addExtensionPrerequisite("GL_KHR_texture_compression_astc_ldr");