forked from jonasmr/microprofile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicroprofile.h
1448 lines (1336 loc) · 56.6 KB
/
microprofile.h
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
#pragma once
// MIT License
//
// Copyright (c) 2019 Jonas Meyer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ***********************************************************************
#ifdef MICROPROFILE_USE_CONFIG
#include "microprofile.config.h"
#endif
#ifndef MICROPROFILE_ENABLED
#define MICROPROFILE_ENABLED 1
#endif
#ifndef MICROPROFILE_DYNAMIC_INSTRUMENT
#if (defined(__APPLE__) && defined(__MACH__)) || (defined(_WIN32) && defined(_M_X64)) || (defined(__unix__) && defined(__x86_64__))
#ifdef MICROPROFILE_DYNAMIC_INSTRUMENT_ENABLE
#define MICROPROFILE_DYNAMIC_INSTRUMENT 1
#endif
#endif
#endif
#ifndef MICROPROFILE_DYNAMIC_INSTRUMENT
#define MICROPROFILE_DYNAMIC_INSTRUMENT 0
#endif
#ifndef MICROPROFILE_GPU_TIMERS_D3D11
#define MICROPROFILE_GPU_TIMERS_D3D11 0
#endif
#ifndef MICROPROFILE_GPU_TIMERS_GL
#define MICROPROFILE_GPU_TIMERS_GL 0
#endif
#ifndef MICROPROFILE_GPU_TIMERS_D3D12
#define MICROPROFILE_GPU_TIMERS_D3D12 0
#endif
#ifndef MICROPROFILE_BIG_ENDIAN
#define MICROPROFILE_BIG_ENDIAN 0
#endif
#ifndef MICROPROFILE_GPU_TIMERS_VULKAN
#define MICROPROFILE_GPU_TIMERS_VULKAN 0
#endif
#ifndef MICROPROFILE_ONCE
#define MICROPROFILE_ONCE
#include <stdint.h>
typedef uint64_t MicroProfileToken;
typedef uint16_t MicroProfileGroupId;
#if 0 == MICROPROFILE_ENABLED
#define MICROPROFILE_DECLARE(var)
#define MICROPROFILE_DEFINE(var, group, name, color)
#define MICROPROFILE_REGISTER_GROUP(group, color, category)
#define MICROPROFILE_DECLARE_GPU(var)
#define MICROPROFILE_DEFINE_GPU(var, name, color)
#define MICROPROFILE_SCOPE(var) do{}while(0)
#define MICROPROFILE_SCOPEI(group, name, color) do{}while(0)
#define MICROPROFILE_SCOPE_TOKEN(token) do {} while(0)
#define MICROPROFILE_SCOPEGPU_TOKEN(token)
#define MICROPROFILE_SCOPEGPU(var) do{}while(0)
#define MICROPROFILE_SCOPEGPUI( name, color) do{}while(0)
#define MICROPROFILE_SCOPEGPU_TOKEN_L(Log, token) do{}while(0)
#define MICROPROFILE_SCOPEGPU_L(Log, var) do{}while(0)
#define MICROPROFILE_SCOPEGPUI_L(Log, name, color) do{}while(0)
#define MICROPROFILE_CONDITIONAL_SCOPEI(condition, group, name, color) do{}while(0)
#define MICROPROFILE_ENTER(var) do{}while(0)
#define MICROPROFILE_ENTER_TOKEN(var) do{}while(0)
#define MICROPROFILE_ENTERI(group, name, color) do{}while(0)
#define MICROPROFILE_LEAVE() do{}while(0)
#define MICROPROFILE_GPU_ENTER(var) do{}while(0)
#define MICROPROFILE_GPU_ENTER_TOKEN(token) do{}while(0)
#define MICROPROFILE_GPU_ENTERI(group, name, color) do{}while(0)
#define MICROPROFILE_GPU_LEAVE() do{}while(0)
#define MICROPROFILE_GPU_ENTER_L(Log, var) do{}while(0)
#define MICROPROFILE_GPU_ENTER_TOKEN_L(Log, token) do{}while(0)
#define MICROPROFILE_GPU_ENTERI_L(Log, name, color) do{}while(0)
#define MICROPROFILE_GPU_LEAVE_L(Log) do{}while(0)
#define MICROPROFILE_GPU_INIT_QUEUE(QueueName) do {} while(0)
#define MICROPROFILE_GPU_GET_QUEUE(QueueName) do {} while(0)
#define MICROPROFILE_GPU_BEGIN(pContext, pLog) do {} while(0)
#define MICROPROFILE_GPU_SET_CONTEXT(pContext, pLog) do {} while(0)
#define MICROPROFILE_GPU_END(pLog) 0
#define MICROPROFILE_GPU_SUBMIT(Queue, Work) do {} while(0)
#define MICROPROFILE_TIMELINE_TOKEN(token) do{}while(0)
#define MICROPROFILE_TIMELINE_ENTER(token, color, name) do{}while(0)
#define MICROPROFILE_TIMELINE_ENTERF(token, color, fmt, ...) do{}while(0)
#define MICROPROFILE_TIMELINE_LEAVE(token) do{}while(0)
#define MICROPROFILE_TIMELINE_ENTER_STATIC(color, name) do{}while(0)
#define MICROPROFILE_TIMELINE_LEAVE_STATIC(name) do{}while(0)
#define MICROPROFILE_THREADLOGGPURESET(a) do{}while(0)
#define MICROPROFILE_META_CPU(name, count)
#define MICROPROFILE_META_GPU(name, count)
#define MICROPROFILE_FORCEENABLECPUGROUP(s) do{} while(0)
#define MICROPROFILE_FORCEDISABLECPUGROUP(s) do{} while(0)
#define MICROPROFILE_FORCEENABLEGPUGROUP(s) do{} while(0)
#define MICROPROFILE_FORCEDISABLEGPUGROUP(s) do{} while(0)
#define MICROPROFILE_COUNTER_ADD(name, count) do{} while(0)
#define MICROPROFILE_COUNTER_SUB(name, count) do{} while(0)
#define MICROPROFILE_COUNTER_SET(name, count) do{} while(0)
#define MICROPROFILE_COUNTER_SET_INT32_PTR(name, ptr) do{} while(0)
#define MICROPROFILE_COUNTER_SET_INT64_PTR(name, ptr) do{} while(0)
#define MICROPROFILE_COUNTER_CLEAR_PTR(name) do{} while(0)
#define MICROPROFILE_COUNTER_SET_LIMIT(name, count) do{} while(0)
#define MICROPROFILE_CONDITIONAL(expr)
#define MICROPROFILE_COUNTER_CONFIG(name, type, limit, flags)
#define MICROPROFILE_COUNTER_CONFIG_ONCE(name, type, limit, flags)
#define MICROPROFILE_DECLARE_LOCAL_COUNTER(var)
#define MICROPROFILE_DEFINE_LOCAL_COUNTER(var, name)
#define MICROPROFILE_DECLARE_LOCAL_ATOMIC_COUNTER(var)
#define MICROPROFILE_DEFINE_LOCAL_ATOMIC_COUNTER(var, name)
#define MICROPROFILE_COUNTER_LOCAL_ADD(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_SUB(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_SET(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD(var) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_SET(var) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_ADD_ATOMIC(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_SUB_ATOMIC(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_SET_ATOMIC(var, count) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD_ATOMIC(var) do{}while(0)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_SET_ATOMIC(var) do{}while(0)
#define MicroProfileGetTime(group, name) 0.f
#define MicroProfileOnThreadCreate(foo) do{}while(0)
#define MicroProfileOnThreadExit() do{}while(0)
#define MicroProfileFlip(pContext) do{}while(0)
#define MicroProfileFlip_CB(pContext, FreezeCB) do{}while(0)
#define MicroProfileSetAggregateFrames(a) do{}while(0)
#define MicroProfileGetAggregateFrames() 0
#define MicroProfileGetCurrentAggregateFrames() 0
#define MicroProfileTogglePause() do{}while(0)
#define MicroProfileToggleAllGroups() do{} while(0)
#define MicroProfileDumpTimers() do{}while(0)
#define MicroProfileShutdown() do{}while(0)
#define MicroProfileSetForceEnable(a) do{} while(0)
#define MicroProfileGetForceEnable() false
#define MicroProfileSetEnableAllGroups(b) do{} while(0)
#define MicroProfileEnableCategory(a) do{} while(0)
#define MicroProfileDisableCategory(a) do{} while(0)
#define MicroProfileGetEnableAllGroups() false
#define MicroProfileSetForceMetaCounters(a)
#define MicroProfileGetForceMetaCounters() 0
#define MicroProfileEnableMetaCounter(c) do{}while(0)
#define MicroProfileDisableMetaCounter(c) do{}while(0)
#define MicroProfileDumpFile(html,csv,spikecpu,spikegpu) do{} while(0)
#define MicroProfileDumpFileImmediately(html,csv,gfcontext) do{} while(0)
#define MicroProfileWebServerPort() ((uint32_t)-1)
#define MicroProfileSetWebServerPort(a) do{} while(0)
#define MicroProfileStartContextSwitchTrace() do{}while(0)
#define MicroProfileGpuInsertTimeStamp(a) 1
#define MicroProfileGpuGetTimeStamp(a) 0
#define MicroProfileTicksPerSecondGpu() 1
#define MicroProfileGetGpuTickReference(a,b) 0
#define MicroProfileGpuInitD3D12(pDevice,nNodeCount,pCommandQueue) do{}while(0)
#define MicroProfileGpuInitD3D11(pDevice,pDeviceContext) do{}while(0)
#define MicroProfileGpuShutdown() do{}while(0)
#define MicroProfileGpuInitGL() do{}while(0)
#define MicroProfileSetCurrentNodeD3D12(nNode) do{}while(0)
#define MicroProfilePlatformMarkersGetEnabled() 0
#define MicroProfilePlatformMarkersSetEnabled(bEnabled) do{}while(0)
#define MicroProfileTickToMsMultiplierCpu() 1.f
#define MicroProfileTickToMsMultiplierGpu() 0.f
#define MicroProfileTicksPerSecondCpu() 1
#define MicroProfileTick() 0
#define MicroProfileEnabled() 0
#else
#include <stdint.h>
#ifndef MICROPROFILE_API
#define MICROPROFILE_API
#endif
#ifdef MICROPROFILE_PS4
#include "microprofile_ps4.h"
#endif
#ifdef MICROPROFILE_XBOXONE
#include "microprofile_xboxone.h"
#endif
#ifdef _WIN32
typedef uint32_t MicroProfileThreadIdType;
#else
#ifdef MICROPROFILE_THREADID_SIZE_4BYTE
typedef uint32_t MicroProfileThreadIdType;
#elif MICROPROFILE_THREADID_SIZE_8BYTE
typedef uint64_t MicroProfileThreadIdType;
#else
typedef uint64_t MicroProfileThreadIdType;
#endif
#endif
typedef void (*MicroProfileOnFreeze)(int nFrozen);
#define MICROPROFILE_DECLARE(var) extern MicroProfileToken g_mp_##var
#define MICROPROFILE_DEFINE(var, group, name, color) MicroProfileToken g_mp_##var = MicroProfileGetToken(group, name, color, MicroProfileTokenTypeCpu)
#define MICROPROFILE_REGISTER_GROUP(group, category, color) MicroProfileRegisterGroup(group, category, color)
#define MICROPROFILE_DECLARE_GPU(var) extern MicroProfileToken g_mpGPU_##var
#define MICROPROFILE_DEFINE_GPU(var, name, color) MicroProfileToken g_mpGPU_##var = MicroProfileGetToken("GPU", name, color, MicroProfileTokenTypeGpu)
#define MICROPROFILE_TOKEN_PASTE0(a, b) a ## b
#define MICROPROFILE_TOKEN_PASTE(a, b) MICROPROFILE_TOKEN_PASTE0(a,b)
#define MICROPROFILE_SCOPE(var) MicroProfileScopeHandler MICROPROFILE_TOKEN_PASTE(foo, __LINE__)(g_mp_##var)
#define MICROPROFILE_SCOPE_TOKEN(token) MicroProfileScopeHandler MICROPROFILE_TOKEN_PASTE(foo, __LINE__)(token)
#define MICROPROFILE_SCOPEI(group, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__) = MicroProfileGetToken(group, name, color, MicroProfileTokenTypeCpu); MicroProfileScopeHandler MICROPROFILE_TOKEN_PASTE(foo,__LINE__)( MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__))
#define MICROPROFILE_SCOPEGPU_TOKEN(token) MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU, __LINE__)(token, MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_SCOPEGPU(var) MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU, __LINE__)(g_mpGPU_##var, MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_SCOPEGPUI(name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__) = MicroProfileGetToken("GPU", name, color, MicroProfileTokenTypeGpu); MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU,__LINE__)( MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_SCOPEGPU_TOKEN_L(Log, token) MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU, __LINE__)(token, Log)
#define MICROPROFILE_SCOPEGPU_L(Log, var) MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU, __LINE__)(g_mpGPU_##var, Log)
#define MICROPROFILE_SCOPEGPUI_L(Log, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__) = MicroProfileGetToken("GPU", name, color, MicroProfileTokenTypeGpu); MicroProfileScopeGpuHandler MICROPROFILE_TOKEN_PASTE(fooGPU,__LINE__)( MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), Log)
#define MICROPROFILE_CONDITIONAL_SCOPEI(condition, group, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp, __LINE__) = MicroProfileGetToken(group, name, color, MicroProfileTokenTypeCpu); MicroProfileConditionalScopeHandler MICROPROFILE_TOKEN_PASTE(foo, __LINE__)(MICROPROFILE_TOKEN_PASTE(g_mp, __LINE__), condition)
#define MICROPROFILE_ENTER(var) MicroProfileEnter(g_mp_##var)
#define MICROPROFILE_ENTER_TOKEN(token) MicroProfileEnter(token)
#define MICROPROFILE_ENTERI(group, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__) = MICROPROFILE_INVALID_TOKEN; if(MICROPROFILE_INVALID_TOKEN == MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__)){MicroProfileGetTokenC(&MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__), group, name, color, MicroProfileTokenTypeCpu);} MicroProfileEnter(MICROPROFILE_TOKEN_PASTE(g_mp,__LINE__))
#define MICROPROFILE_LEAVE() MicroProfileLeave()
#define MICROPROFILE_ENTER_NEGATIVE() MicroProfileEnterNegative()
#define MICROPROFILE_LEAVE_NEGATIVE() MicroProfileLeave()
#define MICROPROFILE_ENTER_NEGATIVEGPU() MicroProfileEnterNegativeGpu(MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_LEAVE_NEGATIVEGPU() MicroProfileLeaveGpu(MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_ENTER_NEGATIVEGPU_C(c) MicroProfileEnterNegativeGpu(c)
#define MICROPROFILE_LEAVE_NEGATIVEGPU_C(c) MicroProfileLeaveGpu(c)
#define MICROPROFILE_GPU_ENTER(var) MicroProfileEnterGpu(g_mpGPU_##var, MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_GPU_ENTER_TOKEN(token) MicroProfileEnterGpu(token, MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_GPU_ENTERI(group, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__) = MICROPROFILE_INVALID_TOKEN; if(MICROPROFILE_INVALID_TOKEN == MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__)){MicroProfileGetTokenC(&MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), group, name, color, MicroProfileTokenTypeGpu);} MicroProfileEnterGpu(MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_GPU_LEAVE() MicroProfileLeaveGpu(MicroProfileGetGlobalGpuThreadLog())
#define MICROPROFILE_GPU_ENTER_L(Log, var) MicroProfileEnterGpu(g_mpGPU_##var, Log)
#define MICROPROFILE_GPU_ENTER_TOKEN_L(Log, token) MicroProfileEnterGpu(token, Log)
#define MICROPROFILE_GPU_ENTERI_L(Log, name, color) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__) = MICROPROFILE_INVALID_TOKEN; if(MICROPROFILE_INVALID_TOKEN == MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__)){MicroProfileGetTokenC(&MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), group, name, color, MicroProfileTokenTypeGpu);} MicroProfileEnterGpu(MICROPROFILE_TOKEN_PASTE(g_mpGPU,__LINE__), Log)
#define MICROPROFILE_GPU_LEAVE_L(Log) MicroProfileLeaveGpu(Log)
#define MICROPROFILE_GPU_INIT_QUEUE(QueueName) MicroProfileInitGpuQueue(QueueName)
#define MICROPROFILE_GPU_FREE_QUEUE(QueueName) MicroProfileFreeGpuQueue(QueueName)
#define MICROPROFILE_GPU_GET_QUEUE(QueueName) MicroProfileGetGpuQueue(QueueName)
#define MICROPROFILE_GPU_BEGIN(pContext, pLog) MicroProfileGpuBegin(pContext, pLog)
#define MICROPROFILE_GPU_SET_CONTEXT(pContext, pLog) MicroProfileGpuSetContext(pContext, pLog)
#define MICROPROFILE_GPU_END(pLog) MicroProfileGpuEnd(pLog)
#define MICROPROFILE_GPU_SUBMIT(Queue, Work) MicroProfileGpuSubmit(Queue, Work)
#define MICROPROFILE_TIMELINE_TOKEN(token) uint32_t token = 0
#define MICROPROFILE_TIMELINE_ENTER(token, color, name) token = MicroProfileTimelineEnter(color, name)
#define MICROPROFILE_TIMELINE_ENTERF(token, color, fmt, ...) token = MicroProfileTimelineEnterf(color, fmt, ##__VA_ARGS__)
#define MICROPROFILE_TIMELINE_LEAVE(token) do{if(token){MicroProfileTimelineLeave(token);}}while(0)
// use only with static string literals
#define MICROPROFILE_TIMELINE_ENTER_STATIC(color, name) MicroProfileTimelineEnterStatic(color, name)
// use only with static string literals
#define MICROPROFILE_TIMELINE_LEAVE_STATIC(name) MicroProfileTimelineLeaveStatic(name)
#define MICROPROFILE_THREADLOGGPURESET(a) MicroProfileThreadLogGpuReset(a)
#define MICROPROFILE_META_CPU(name, count) do{}while(0)//static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp_meta,__LINE__) = MicroProfileGetMetaToken(name); MicroProfileMetaUpdate(MICROPROFILE_TOKEN_PASTE(g_mp_meta,__LINE__), count, MicroProfileTokenTypeCpu)
#define MICROPROFILE_COUNTER_ADD(name, count) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__) = MicroProfileGetCounterToken(name); MicroProfileCounterAdd(MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__), count)
#define MICROPROFILE_COUNTER_SUB(name, count) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__) = MicroProfileGetCounterToken(name); MicroProfileCounterAdd(MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__), -(int64_t)count)
#define MICROPROFILE_COUNTER_SET(name, count) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp_counter_set,__LINE__) = MicroProfileGetCounterToken(name); MicroProfileCounterSet(MICROPROFILE_TOKEN_PASTE(g_mp_counter_set,__LINE__), count)
#define MICROPROFILE_COUNTER_SET_INT32_PTR(name, ptr) MicroProfileCounterSetPtr(name, ptr, sizeof(int32_t))
#define MICROPROFILE_COUNTER_SET_INT64_PTR(name, ptr) MicroProfileCounterSetPtr(name, ptr, sizeof(int64_t))
#define MICROPROFILE_COUNTER_CLEAR_PTR(name) MicroProfileCounterSetPtr(name, 0, 0)
#define MICROPROFILE_COUNTER_SET_LIMIT(name, count) static MicroProfileToken MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__) = MicroProfileGetCounterToken(name); MicroProfileCounterSetLimit(MICROPROFILE_TOKEN_PASTE(g_mp_counter,__LINE__), count)
#define MICROPROFILE_COUNTER_CONFIG(name, type, limit, flags) MicroProfileCounterConfig(name, type, limit, flags)
#define MICROPROFILE_COUNTER_CONFIG_ONCE(name, type, limit, flags) do{static bool MICROPROFILE_TOKEN_PASTE(g_mponce,__LINE__) = false; if(!MICROPROFILE_TOKEN_PASTE(g_mponce,__LINE__)){MICROPROFILE_TOKEN_PASTE(g_mponce,__LINE__) = true; MicroProfileCounterConfig(name,type,limit,flags);}}while(0)
#define MICROPROFILE_DECLARE_LOCAL_COUNTER(var) extern int64_t g_mp_local_counter##var; extern MicroProfileToken g_mp_counter_token##var;
#define MICROPROFILE_DEFINE_LOCAL_COUNTER(var, name) int64_t g_mp_local_counter##var = 0;MicroProfileToken g_mp_counter_token##var = MicroProfileGetCounterToken(name)
#define MICROPROFILE_DECLARE_LOCAL_ATOMIC_COUNTER(var) extern MicroProfileToken g_mp_counter_token##var;
#define MICROPROFILE_DEFINE_LOCAL_ATOMIC_COUNTER(var, name) MicroProfileToken g_mp_counter_token##var = MicroProfileGetCounterToken(name)
#define MICROPROFILE_COUNTER_LOCAL_ADD(var, count) MicroProfileLocalCounterAdd(&g_mp_local_counter##var, (count))
#define MICROPROFILE_COUNTER_LOCAL_SUB(var, count) MicroProfileLocalCounterAdd(&g_mp_local_counter##var, -(int64_t)(count))
#define MICROPROFILE_COUNTER_LOCAL_SET(var, count) MicroProfileLocalCounterSet(&g_mp_local_counter##var, count)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD(var) MicroProfileCounterAdd(g_mp_counter_token##var, MicroProfileLocalCounterSet(&g_mp_local_counter##var, 0))
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_SET(var) MicroProfileCounterSet(g_mp_counter_token##var, MicroProfileLocalCounterSet(&g_mp_local_counter##var, 0))
#define MICROPROFILE_COUNTER_LOCAL_ADD_ATOMIC(var, count) MicroProfileLocalCounterAddAtomic(g_mp_counter_token##var, (count))
#define MICROPROFILE_COUNTER_LOCAL_SUB_ATOMIC(var, count) MicroProfileLocalCounterAddAtomic(g_mp_counter_token##var, -(int64_t)(count))
#define MICROPROFILE_COUNTER_LOCAL_SET_ATOMIC(var, count) MicroProfileLocalCounterSetAtomic(g_mp_counter_token##var, count)
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_ADD_ATOMIC(var) MicroProfileCounterAdd(g_mp_counter_token##var, MicroProfileLocalCounterSetAtomic(g_mp_counter_token##var, 0))
#define MICROPROFILE_COUNTER_LOCAL_UPDATE_SET_ATOMIC(var) MicroProfileCounterSet(g_mp_counter_token##var, MicroProfileLocalCounterSetAtomic(g_mp_counter_token##var, 0))
#define MICROPROFILE_FORCEENABLECPUGROUP(s) MicroProfileForceEnableGroup(s, MicroProfileTokenTypeCpu)
#define MICROPROFILE_FORCEDISABLECPUGROUP(s) MicroProfileForceDisableGroup(s, MicroProfileTokenTypeCpu)
#define MICROPROFILE_FORCEENABLEGPUGROUP(s) MicroProfileForceEnableGroup(s, MicroProfileTokenTypeGpu)
#define MICROPROFILE_FORCEDISABLEGPUGROUP(s) MicroProfileForceDisableGroup(s, MicroProfileTokenTypeGpu)
#define MICROPROFILE_CONDITIONAL(expr) expr
#ifndef MICROPROFILE_PLATFORM_MARKERS
#define MICROPROFILE_PLATFORM_MARKERS 0
#endif
#if MICROPROFILE_PLATFORM_MARKERS
#define MICROPROFILE_PLATFORM_MARKERS_ENABLED S.nPlatformMarkersEnabled
#define MICROPROFILE_PLATFORM_MARKER_BEGIN(color,marker) MicroProfilePlatformMarkerBegin(color,marker)
#define MICROPROFILE_PLATFORM_MARKER_END() MicroProfilePlatformMarkerEnd()
#else
#define MICROPROFILE_PLATFORM_MARKER_BEGIN(color,marker) do{(void)color;(void)marker;}while(0)
#define MICROPROFILE_PLATFORM_MARKER_END() do{}while(0)
#define MICROPROFILE_PLATFORM_MARKERS_ENABLED 0
#endif
#define MICROPROFILE_MAJOR_VERSION 2
#define MICROPROFILE_MINOR_VERSION 5
#ifndef MICROPROFILE_USE_THREAD_NAME_CALLBACK
#define MICROPROFILE_USE_THREAD_NAME_CALLBACK 0
#endif
#ifndef MICROPROFILE_PER_THREAD_BUFFER_SIZE
#define MICROPROFILE_PER_THREAD_BUFFER_SIZE (2048<<10)
#endif
#ifndef MICROPROFILE_PER_THREAD_GPU_BUFFER_SIZE
#define MICROPROFILE_PER_THREAD_GPU_BUFFER_SIZE (128<<10)
#endif
#ifndef MICROPROFILE_MAX_FRAME_HISTORY
#define MICROPROFILE_MAX_FRAME_HISTORY 512
#endif
#ifndef MICROPROFILE_PRINTF
#define MICROPROFILE_PRINTF printf
#endif
// #ifndef MICROPROFILE_META_MAX
// #define MICROPROFILE_META_MAX 8
// #endif
#ifndef MICROPROFILE_WEBSERVER_PORT
#define MICROPROFILE_WEBSERVER_PORT 1338
#endif
#ifndef MICROPROFILE_WEBSERVER
#define MICROPROFILE_WEBSERVER 1
#endif
#ifndef MICROPROFILE_WEBSERVER_MAXFRAMES
#define MICROPROFILE_WEBSERVER_MAXFRAMES 30
#endif
#ifndef MICROPROFILE_WEBSERVER_SOCKET_BUFFER_SIZE
#define MICROPROFILE_WEBSERVER_SOCKET_BUFFER_SIZE (16<<10)
#endif
#ifndef MICROPROFILE_GPU_TIMERS
#define MICROPROFILE_GPU_TIMERS 1
#endif
#ifndef MICROPROFILE_GPU_TIMER_CALLBACKS
#define MICROPROFILE_GPU_TIMER_CALLBACKS 0
#endif
#ifndef MICROPROFILE_GPU_FRAME_DELAY
#define MICROPROFILE_GPU_FRAME_DELAY 5 //must be > 0
#endif
#ifndef MICROPROFILE_NAME_MAX_LEN
#define MICROPROFILE_NAME_MAX_LEN 64
#endif
#ifndef MICROPROFILE_MAX_TIMERS
#define MICROPROFILE_MAX_TIMERS 1024
#endif
#ifndef MICROPROFILE_MAX_THREADS
#define MICROPROFILE_MAX_THREADS 32
#endif
#ifndef MICROPROFILE_UNPACK_RED
#define MICROPROFILE_UNPACK_RED(c) ((c)>>16)
#endif
#ifndef MICROPROFILE_UNPACK_GREEN
#define MICROPROFILE_UNPACK_GREEN(c) ((c)>>8)
#endif
#ifndef MICROPROFILE_UNPACK_BLUE
#define MICROPROFILE_UNPACK_BLUE(c) ((c))
#endif
#ifndef MICROPROFILE_DEFAULT_PRESET
#define MICROPROFILE_DEFAULT_PRESET "Default"
#endif
#ifndef MICROPROFILE_TIMELINE_MAX_ENTRIES
#define MICROPROFILE_TIMELINE_MAX_ENTRIES (4<<10)
#endif
#ifndef MICROPROFILE_MAX_STRING
#define MICROPROFILE_MAX_STRING 128
#endif
#ifndef MICROPROFILE_TIMELINE_MAX_TOKENS
#define MICROPROFILE_TIMELINE_MAX_TOKENS 64
#endif
#ifndef MICROPROFILE_THREAD_LOG_FRAMES_REUSE
#define MICROPROFILE_THREAD_LOG_FRAMES_REUSE 200
#endif
#ifndef MICROPROFILE_CONTEXT_SWITCH_TRACE
#if defined(_WIN32)
#define MICROPROFILE_CONTEXT_SWITCH_TRACE 1
#elif defined(__APPLE__)
#define MICROPROFILE_CONTEXT_SWITCH_TRACE 0 //disabled until dtrace script is working.
#else
#define MICROPROFILE_CONTEXT_SWITCH_TRACE 0
#endif
#endif
#if MICROPROFILE_CONTEXT_SWITCH_TRACE
#define MICROPROFILE_CONTEXT_SWITCH_BUFFER_SIZE (128*1024) //2mb with 16 byte entry size
#else
#define MICROPROFILE_CONTEXT_SWITCH_BUFFER_SIZE (1)
#endif
#ifndef MICROPROFILE_MINIZ
#define MICROPROFILE_MINIZ 0
#endif
#ifndef MICROPROFILE_COUNTER_HISTORY
#define MICROPROFILE_COUNTER_HISTORY 1
#endif
#ifndef MICROPROFILE_MAX_GROUPS
#define MICROPROFILE_MAX_GROUPS 128 //must be multiple of 32
#endif
#ifndef MICROPROFILE_STACK_MAX
#define MICROPROFILE_STACK_MAX 32
#endif
#ifndef MICROPROFILE_BREAK_ON_PATCH_FAIL
#define MICROPROFILE_BREAK_ON_PATCH_FAIL 0
#endif
#ifndef MICROPROFILE_INSTRUMENT_MICROPROFILE
#define MICROPROFILE_INSTRUMENT_MICROPROFILE 0
#endif
#ifndef MICROPROFILE_MAX_DYNAMIC_TOKENS
#define MICROPROFILE_MAX_DYNAMIC_TOKENS 2048
#endif
#ifndef MICROPROFILE_INSTRUMENT_SYMBOLNAME_MAXLEN
#define MICROPROFILE_INSTRUMENT_SYMBOLNAME_MAXLEN 128
#endif
#ifndef MICROPROFILE_INSTRUMENT_MAX_MODULES
#define MICROPROFILE_INSTRUMENT_MAX_MODULES 256
#endif
#ifndef MICROPROFILE_INSTRUMENT_MAX_MODULE_CHARS
#define MICROPROFILE_INSTRUMENT_MAX_MODULE_CHARS (8<<10)
#endif
#ifndef MICROPROFILE_ASSERT_LOG_FREED
#define MICROPROFILE_ASSERT_LOG_FREED 0
#endif
typedef enum MicroProfileTokenType_t
{
MicroProfileTokenTypeCpu,
MicroProfileTokenTypeGpu,
} MicroProfileTokenType;
struct MicroProfile;
struct MicroProfileThreadLogGpu;
struct MicroProfileScopeStateC;
#ifdef __cplusplus
extern "C" {
#endif
#define MICROPROFILE_INVALID_TOKEN ((uint64_t)-1)
MICROPROFILE_API void MicroProfileInit();
MICROPROFILE_API void MicroProfileShutdown();
MICROPROFILE_API void MicroProfileStartAutoFlip(uint32_t nHz);
MICROPROFILE_API void MicroProfileStopAutoFlip();
MICROPROFILE_API MicroProfileToken MicroProfileFindToken(const char* sGroup, const char* sName);
MICROPROFILE_API MicroProfileToken MicroProfileGetToken(const char* sGroup, const char* sName, uint32_t nColor, MicroProfileTokenType Token);
MICROPROFILE_API void MicroProfileGetTokenC(MicroProfileToken* pToken, const char* sGroup, const char* sName, uint32_t nColor, MicroProfileTokenType Token);
MICROPROFILE_API MicroProfileToken MicroProfileGetCounterToken(const char* pName);
MICROPROFILE_API void MicroProfileCounterAdd(MicroProfileToken nToken, int64_t nCount);
MICROPROFILE_API void MicroProfileCounterSet(MicroProfileToken nToken, int64_t nCount);
MICROPROFILE_API void MicroProfileCounterSetLimit(MicroProfileToken nToken, int64_t nCount);
MICROPROFILE_API void MicroProfileCounterConfig(const char* pCounterName, uint32_t nFormat, int64_t nLimit, uint32_t nFlags);
MICROPROFILE_API void MicroProfileCounterSetPtr(const char* pCounterName, void* pValue, uint32_t nSize);
MICROPROFILE_API void MicroProfileCounterFetchCounters();
MICROPROFILE_API void MicroProfileLocalCounterAdd(int64_t* pCounter, int64_t nCount);
MICROPROFILE_API int64_t MicroProfileLocalCounterSet(int64_t* pCounter, int64_t nCount);
MICROPROFILE_API uint64_t MicroProfileEnterInternal(MicroProfileToken nToken);
MICROPROFILE_API void MicroProfileLeaveInternal(MicroProfileToken nToken, uint64_t nTick);
MICROPROFILE_API void MicroProfileEnter(MicroProfileToken nToken);
MICROPROFILE_API void MicroProfileLeave();
MICROPROFILE_API void MicroProfileEnterGpu(MicroProfileToken nToken, struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API void MicroProfileLeaveGpu(struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API void MicroProfileEnterNegative();
MICROPROFILE_API void MicroProfileEnterNegativeGpu(struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API uint32_t MicroProfileTimelineEnterInternal(uint32_t nColor, const char* pStr, uint32_t nStrLen, int bIsStaticString);
MICROPROFILE_API uint32_t MicroProfileTimelineEnter(uint32_t nColor, const char* pStr);
MICROPROFILE_API uint32_t MicroProfileTimelineEnterf(uint32_t nColor, const char* pStr, ...);
MICROPROFILE_API void MicroProfileTimelineLeave(uint32_t id);
MICROPROFILE_API void MicroProfileTimelineEnterStatic(uint32_t nColor, const char* pStr);
MICROPROFILE_API void MicroProfileTimelineLeaveStatic(const char* pStr);
MICROPROFILE_API uint64_t MicroProfileGpuEnterInternal(struct MicroProfileThreadLogGpu* pLog, MicroProfileToken nToken);
MICROPROFILE_API void MicroProfileGpuLeaveInternal(struct MicroProfileThreadLogGpu* pLog, MicroProfileToken nToken, uint64_t nTick);
MICROPROFILE_API void MicroProfileGpuBegin(void* pContext, struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API void MicroProfileGpuSetContext(void* pContext, struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API uint64_t MicroProfileGpuEnd(struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API struct MicroProfileThreadLogGpu* MicroProfileThreadLogGpuAlloc();
MICROPROFILE_API void MicroProfileThreadLogGpuFree(struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API void MicroProfileThreadLogGpuReset(struct MicroProfileThreadLogGpu* pLog);
MICROPROFILE_API void MicroProfileGpuSubmit(int nQueue, uint64_t nWork);
MICROPROFILE_API int MicroProfileInitGpuQueue(const char* pQueueName);
MICROPROFILE_API void MicroProfileFreeGpuQueue(int nQueue);
MICROPROFILE_API int MicroProfileGetGpuQueue(const char* pQueueName);
MICROPROFILE_API void MicroProfileFlip(void* pGpuContext); //! call once per frame.
MICROPROFILE_API void MicroProfileFlip_CB(void* pGpuContext, MicroProfileOnFreeze FreezeCB); //! call once per frame.
MICROPROFILE_API void MicroProfileToggleFrozen();
MICROPROFILE_API int MicroProfileIsFrozen();
MICROPROFILE_API int MicroProfileEnabled();
MICROPROFILE_API void MicroProfileForceEnableGroup(const char* pGroup, MicroProfileTokenType Type);
MICROPROFILE_API void MicroProfileForceDisableGroup(const char* pGroup, MicroProfileTokenType Type);
MICROPROFILE_API float MicroProfileGetTime(const char* pGroup, const char* pName);
MICROPROFILE_API int MicroProfilePlatformMarkersGetEnabled(); //enable platform markers. disables microprofile markers
MICROPROFILE_API void MicroProfilePlatformMarkersSetEnabled(int bEnabled); //enable platform markers. disables microprofile markers
MICROPROFILE_API void MicroProfileContextSwitchSearch(uint32_t* pContextSwitchStart, uint32_t* pContextSwitchEnd, uint64_t nBaseTicksCpu, uint64_t nBaseTicksEndCpu);
MICROPROFILE_API void MicroProfileOnThreadCreate(const char* pThreadName); //should be called from newly created threads
MICROPROFILE_API void MicroProfileOnThreadExit(); //call on exit to reuse log
MICROPROFILE_API void MicroProfileInitThreadLog();
MICROPROFILE_API void MicroProfileSetEnableAllGroups(int bEnable);
MICROPROFILE_API void MicroProfileEnableCategory(const char* pCategory);
MICROPROFILE_API void MicroProfileDisableCategory(const char* pCategory);
MICROPROFILE_API int MicroProfileGetEnableAllGroups();
MICROPROFILE_API void MicroProfileSetForceMetaCounters(int bEnable);
MICROPROFILE_API int MicroProfileGetForceMetaCounters();
MICROPROFILE_API void MicroProfileEnableMetaCounter(const char* pMet);
MICROPROFILE_API void MicroProfileDisableMetaCounter(const char* pMet);
MICROPROFILE_API void MicroProfileSetAggregateFrames(int frames);
MICROPROFILE_API int MicroProfileGetAggregateFrames();
MICROPROFILE_API int MicroProfileGetCurrentAggregateFrames();
MICROPROFILE_API struct MicroProfile* MicroProfileGet();
MICROPROFILE_API void MicroProfileGetRange(uint32_t nPut, uint32_t nGet, uint32_t nRange[2][2]);
MICROPROFILE_API void MicroProfileStartContextSwitchTrace();
MICROPROFILE_API void MicroProfileStopContextSwitchTrace();
MICROPROFILE_API int MicroProfileIsLocalThread(uint32_t nThreadId);
MICROPROFILE_API int MicroProfileFormatCounter(int eFormat, int64_t nCounter, char* pOut, uint32_t nBufferSize);
MICROPROFILE_API struct MicroProfileThreadLogGpu* MicroProfileGetGlobalGpuThreadLog();
MICROPROFILE_API int MicroProfileGetGlobalGpuQueue();
MICROPROFILE_API void MicroProfileRegisterGroup(const char* pGroup, const char* pCategory, uint32_t nColor);
#if MICROPROFILE_PLATFORM_MARKERS
MICROPROFILE_API void MicroProfilePlatformMarkerBegin(uint32_t nColor, const char * pMarker); //not implemented by microprofile.
MICROPROFILE_API void MicroProfilePlatformMarkerEnd();//not implemented by microprofile.
#endif
MICROPROFILE_API float MicroProfileTickToMsMultiplierCpu();
MICROPROFILE_API float MicroProfileTickToMsMultiplierGpu();
MICROPROFILE_API int64_t MicroProfileTicksPerSecondCpu();
MICROPROFILE_API uint64_t MicroProfileTick();
MICROPROFILE_API void MicroProfileLocalCounterAddAtomic(MicroProfileToken Token, int64_t nCount);
MICROPROFILE_API int64_t MicroProfileLocalCounterSetAtomic(MicroProfileToken, int64_t nCount);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
struct MicroProfileThreadInfo
{
//3 first members are used to sort. dont reorder
uint32_t nIsLocal;
MicroProfileThreadIdType pid;
MicroProfileThreadIdType tid;
//3 first members are used to sort. dont reorder
const char* pThreadModule;
const char* pProcessModule;
MicroProfileThreadInfo()
:nIsLocal(0)
,pid(0)
,tid(0)
,pThreadModule("?")
,pProcessModule("?")
{
}
MicroProfileThreadInfo(uint32_t ThreadId, uint32_t ProcessId, uint32_t nIsLocal)
:nIsLocal(nIsLocal)
,pid(ProcessId)
,tid(ThreadId)
,pThreadModule("?")
,pProcessModule("?")
{
}
~MicroProfileThreadInfo() {}
};
MICROPROFILE_API MicroProfileThreadInfo MicroProfileGetThreadInfo(MicroProfileThreadIdType nThreadId);
MICROPROFILE_API uint32_t MicroProfileGetThreadInfoArray(MicroProfileThreadInfo** pThreadArray);
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#if MICROPROFILE_GPU_TIMERS_D3D12
MICROPROFILE_API void MicroProfileGpuInitD3D12(void* pDevice, uint32_t nNodeCount, void** pCommandQueues);
MICROPROFILE_API void MicroProfileGpuShutdown();
MICROPROFILE_API void MicroProfileSetCurrentNodeD3D12(uint32_t nNode);
#endif
#if MICROPROFILE_GPU_TIMERS_VULKAN
#include <vulkan/vulkan.h>
void MicroProfileGpuInitVulkan(VkDevice* pDevices, VkPhysicalDevice* pPhysicalDevices, VkQueue* pQueues, uint32_t* QueueFamily, uint32_t nNodeCount);
MICROPROFILE_API void MicroProfileGpuShutdown();
MICROPROFILE_API void MicroProfileSetCurrentNodeVulkan(uint32_t nNode);
#endif
MICROPROFILE_API void MicroProfileDumpFile(const char* pHtml, const char* pCsv, float fCpuSpike, float fGpuSpike);
MICROPROFILE_API void MicroProfileDumpFileImmediately(const char* pHtml, const char* pCsv, void* pGpuContext);
MICROPROFILE_API uint32_t MicroProfileWebServerPort();
MICROPROFILE_API void MicroProfileSetWebServerPort(uint32_t nPort);
#if MICROPROFILE_GPU_TIMERS
#if MICROPROFILE_GPU_TIMER_CALLBACKS
typedef uint32_t (*MicroProfileGpuInsertTimeStamp_CB)(void* pContext);
typedef uint64_t (*MicroProfileGpuGetTimeStamp_CB)(uint32_t nKey);
typedef uint64_t (*MicroProfileTicksPerSecondGpu_CB)();
typedef int (*MicroProfileGetGpuTickReference_CB)(int64_t* pOutCPU, int64_t* pOutGpu);
typedef uint32_t (*MicroProfileGpuFlip_CB)(void*);
typedef void (*MicroProfileGpuShutdown_CB)();
MICROPROFILE_API void MicroProfileGpuSetCallbacks(
MicroProfileGpuInsertTimeStamp_CB InsertTimeStamp,
MicroProfileGpuGetTimeStamp_CB GetTimeStamp,
MicroProfileTicksPerSecondGpu_CB TicksPerSecond,
MicroProfileGetGpuTickReference_CB GetTickReference,
MicroProfileGpuFlip_CB Flip,
MicroProfileGpuShutdown_CB Shutdown);
#else
MICROPROFILE_API uint32_t MicroProfileGpuInsertTimeStamp(void* pContext);
MICROPROFILE_API uint64_t MicroProfileGpuGetTimeStamp(uint32_t nKey);
MICROPROFILE_API uint64_t MicroProfileTicksPerSecondGpu();
MICROPROFILE_API int MicroProfileGetGpuTickReference(int64_t* pOutCPU, int64_t* pOutGpu);
MICROPROFILE_API uint32_t MicroProfileGpuFlip(void*);
MICROPROFILE_API void MicroProfileGpuShutdown();
#endif
#else
#define MicroProfileGpuInsertTimeStamp(a) 1
#define MicroProfileGpuGetTimeStamp(a) 0
#define MicroProfileTicksPerSecondGpu() 1
#define MicroProfileGetGpuTickReference(a,b) 0
#define MicroProfileGpuFlip(a) 0
#define MicroProfileGpuShutdown() do{}while(0)
#endif
#if MICROPROFILE_GPU_TIMERS_D3D11
#define MICROPROFILE_D3D_MAX_QUERIES (8<<10)
MICROPROFILE_API void MicroProfileGpuInitD3D11(void* pDevice, void* pDeviceContext);
MICROPROFILE_API void MicroProfileGpuShutdown();
#endif
#if MICROPROFILE_GPU_TIMERS_GL
#define MICROPROFILE_GL_MAX_QUERIES (8<<10)
MICROPROFILE_API void MicroProfileGpuInitGL();
#endif
#if MICROPROFILE_USE_THREAD_NAME_CALLBACK
MICROPROFILE_API const char* MicroProfileGetThreadName(char* pzName);
#else
#define MicroProfileGetThreadName(a) 0
#endif
#ifdef __cplusplus
}
#endif
struct MicroProfileScopeStateC
{
MicroProfileToken Token;
int64_t nTick;
};
#ifdef __cplusplus
struct MicroProfileScopeHandler
{
MicroProfileToken nToken;
uint64_t nTick;
MicroProfileScopeHandler(MicroProfileToken Token):nToken(Token)
{
nTick = MicroProfileEnterInternal(nToken);
}
~MicroProfileScopeHandler()
{
MicroProfileLeaveInternal(nToken, nTick);
}
};
struct MicroProfileScopeGpuHandler
{
MicroProfileToken nToken;
MicroProfileThreadLogGpu* pLog;
uint64_t nTick;
MicroProfileScopeGpuHandler(MicroProfileToken Token, MicroProfileThreadLogGpu* pLog):nToken(Token), pLog(pLog)
{
nTick = MicroProfileGpuEnterInternal(pLog, nToken);
}
~MicroProfileScopeGpuHandler()
{
MicroProfileGpuLeaveInternal(pLog, nToken, nTick);
}
};
struct MicroProfileConditionalScopeHandler
{
MicroProfileToken nToken;
uint64_t nTick;
MicroProfileConditionalScopeHandler(MicroProfileToken token, bool condition) : nToken(token)
{
nTick = condition ? MicroProfileEnterInternal(token) : MICROPROFILE_INVALID_TOKEN;
}
~MicroProfileConditionalScopeHandler()
{
if (nTick != MICROPROFILE_INVALID_TOKEN)
{
MicroProfileLeaveInternal(nToken, nTick);
}
}
};
#endif //__cplusplus
#endif //enabled
enum MicroProfileCounterFormat
{
MICROPROFILE_COUNTER_FORMAT_DEFAULT = 0,
MICROPROFILE_COUNTER_FORMAT_BYTES = 1,
};
enum MicroProfileCounterFlags
{
MICROPROFILE_COUNTER_FLAG_NONE = 0,
MICROPROFILE_COUNTER_FLAG_DETAILED = 0x1,
MICROPROFILE_COUNTER_FLAG_DETAILED_GRAPH = 0x2,
//internal:
MICROPROFILE_COUNTER_FLAG_INTERNAL_MASK = ~0x3,
MICROPROFILE_COUNTER_FLAG_HAS_LIMIT = 0x4,
MICROPROFILE_COUNTER_FLAG_CLOSED = 0x8,
MICROPROFILE_COUNTER_FLAG_MANUAL_SWAP = 0x10,
MICROPROFILE_COUNTER_FLAG_LEAF = 0x20,
};
#endif //once
#define MP_AUTO 0
//from http://fugal.net/vim/rgbtxt.html
#define MP_SNOW 0xfffafa
#define MP_GHOSTWHITE 0xf8f8ff
#define MP_WHITESMOKE 0xf5f5f5
#define MP_GAINSBORO 0xdcdcdc
#define MP_FLORALWHITE 0xfffaf0
#define MP_OLDLACE 0xfdf5e6
#define MP_LINEN 0xfaf0e6
#define MP_ANTIQUEWHITE 0xfaebd7
#define MP_PAPAYAWHIP 0xffefd5
#define MP_BLANCHEDALMOND 0xffebcd
#define MP_BISQUE 0xffe4c4
#define MP_PEACHPUFF 0xffdab9
#define MP_NAVAJOWHITE 0xffdead
#define MP_MOCCASIN 0xffe4b5
#define MP_CORNSILK 0xfff8dc
#define MP_IVORY 0xfffff0
#define MP_LEMONCHIFFON 0xfffacd
#define MP_SEASHELL 0xfff5ee
#define MP_HONEYDEW 0xf0fff0
#define MP_MINTCREAM 0xf5fffa
#define MP_AZURE 0xf0ffff
#define MP_ALICEBLUE 0xf0f8ff
#define MP_LAVENDER 0xe6e6fa
#define MP_LAVENDERBLUSH 0xfff0f5
#define MP_MISTYROSE 0xffe4e1
#define MP_WHITE 0xffffff
#define MP_BLACK 0x010101
#define MP_DARKSLATEGRAY 0x2f4f4f
#define MP_DARKSLATEGREY 0x2f4f4f
#define MP_DIMGRAY 0x696969
#define MP_DIMGREY 0x696969
#define MP_SLATEGRAY 0x708090
#define MP_SLATEGREY 0x708090
#define MP_LIGHTSLATEGRAY 0x778899
#define MP_LIGHTSLATEGREY 0x778899
#define MP_GRAY 0xbebebe
#define MP_GREY 0xbebebe
#define MP_LIGHTGREY 0xd3d3d3
#define MP_LIGHTGRAY 0xd3d3d3
#define MP_MIDNIGHTBLUE 0x191970
#define MP_NAVY 0x000080
#define MP_NAVYBLUE 0x000080
#define MP_CORNFLOWERBLUE 0x6495ed
#define MP_DARKSLATEBLUE 0x483d8b
#define MP_SLATEBLUE 0x6a5acd
#define MP_MEDIUMSLATEBLUE 0x7b68ee
#define MP_LIGHTSLATEBLUE 0x8470ff
#define MP_MEDIUMBLUE 0x0000cd
#define MP_ROYALBLUE 0x4169e1
#define MP_BLUE 0x0000ff
#define MP_DODGERBLUE 0x1e90ff
#define MP_DEEPSKYBLUE 0x00bfff
#define MP_SKYBLUE 0x87ceeb
#define MP_LIGHTSKYBLUE 0x87cefa
#define MP_STEELBLUE 0x4682b4
#define MP_LIGHTSTEELBLUE 0xb0c4de
#define MP_LIGHTBLUE 0xadd8e6
#define MP_POWDERBLUE 0xb0e0e6
#define MP_PALETURQUOISE 0xafeeee
#define MP_DARKTURQUOISE 0x00ced1
#define MP_MEDIUMTURQUOISE 0x48d1cc
#define MP_TURQUOISE 0x40e0d0
#define MP_CYAN 0x00ffff
#define MP_LIGHTCYAN 0xe0ffff
#define MP_CADETBLUE 0x5f9ea0
#define MP_MEDIUMAQUAMARINE 0x66cdaa
#define MP_AQUAMARINE 0x7fffd4
#define MP_DARKGREEN 0x006400
#define MP_DARKOLIVEGREEN 0x556b2f
#define MP_DARKSEAGREEN 0x8fbc8f
#define MP_SEAGREEN 0x2e8b57
#define MP_MEDIUMSEAGREEN 0x3cb371
#define MP_LIGHTSEAGREEN 0x20b2aa
#define MP_PALEGREEN 0x98fb98
#define MP_SPRINGGREEN 0x00ff7f
#define MP_LAWNGREEN 0x7cfc00
#define MP_GREEN 0x00ff00
#define MP_CHARTREUSE 0x7fff00
#define MP_MEDIUMSPRINGGREEN 0x00fa9a
#define MP_GREENYELLOW 0xadff2f
#define MP_LIMEGREEN 0x32cd32
#define MP_YELLOWGREEN 0x9acd32
#define MP_FORESTGREEN 0x228b22
#define MP_OLIVEDRAB 0x6b8e23
#define MP_DARKKHAKI 0xbdb76b
#define MP_KHAKI 0xf0e68c
#define MP_PALEGOLDENROD 0xeee8aa
#define MP_LIGHTGOLDENRODYELLOW 0xfafad2
#define MP_LIGHTYELLOW 0xffffe0
#define MP_YELLOW 0xffff00
#define MP_GOLD 0xffd700
#define MP_LIGHTGOLDENROD 0xeedd82
#define MP_GOLDENROD 0xdaa520
#define MP_DARKGOLDENROD 0xb8860b
#define MP_ROSYBROWN 0xbc8f8f
#define MP_INDIANRED 0xcd5c5c
#define MP_SADDLEBROWN 0x8b4513
#define MP_SIENNA 0xa0522d
#define MP_PERU 0xcd853f
#define MP_BURLYWOOD 0xdeb887
#define MP_BEIGE 0xf5f5dc
#define MP_WHEAT 0xf5deb3
#define MP_SANDYBROWN 0xf4a460
#define MP_TAN 0xd2b48c
#define MP_CHOCOLATE 0xd2691e
#define MP_FIREBRICK 0xb22222
#define MP_BROWN 0xa52a2a
#define MP_DARKSALMON 0xe9967a
#define MP_SALMON 0xfa8072
#define MP_LIGHTSALMON 0xffa07a
#define MP_ORANGE 0xffa500
#define MP_DARKORANGE 0xff8c00
#define MP_CORAL 0xff7f50
#define MP_LIGHTCORAL 0xf08080
#define MP_TOMATO 0xff6347
#define MP_ORANGERED 0xff4500
#define MP_RED 0xff0000
#define MP_HOTPINK 0xff69b4
#define MP_DEEPPINK 0xff1493
#define MP_PINK 0xffc0cb
#define MP_LIGHTPINK 0xffb6c1
#define MP_PALEVIOLETRED 0xdb7093
#define MP_MAROON 0xb03060
#define MP_MEDIUMVIOLETRED 0xc71585
#define MP_VIOLETRED 0xd02090
#define MP_MAGENTA 0xff00ff
#define MP_VIOLET 0xee82ee
#define MP_PLUM 0xdda0dd
#define MP_ORCHID 0xda70d6
#define MP_MEDIUMORCHID 0xba55d3
#define MP_DARKORCHID 0x9932cc
#define MP_DARKVIOLET 0x9400d3
#define MP_BLUEVIOLET 0x8a2be2
#define MP_PURPLE 0xa020f0
#define MP_MEDIUMPURPLE 0x9370db
#define MP_THISTLE 0xd8bfd8
#define MP_SNOW1 0xfffafa
#define MP_SNOW2 0xeee9e9
#define MP_SNOW3 0xcdc9c9
#define MP_SNOW4 0x8b8989
#define MP_SEASHELL1 0xfff5ee
#define MP_SEASHELL2 0xeee5de
#define MP_SEASHELL3 0xcdc5bf
#define MP_SEASHELL4 0x8b8682
#define MP_ANTIQUEWHITE1 0xffefdb
#define MP_ANTIQUEWHITE2 0xeedfcc
#define MP_ANTIQUEWHITE3 0xcdc0b0
#define MP_ANTIQUEWHITE4 0x8b8378
#define MP_BISQUE1 0xffe4c4
#define MP_BISQUE2 0xeed5b7
#define MP_BISQUE3 0xcdb79e
#define MP_BISQUE4 0x8b7d6b
#define MP_PEACHPUFF1 0xffdab9
#define MP_PEACHPUFF2 0xeecbad
#define MP_PEACHPUFF3 0xcdaf95
#define MP_PEACHPUFF4 0x8b7765
#define MP_NAVAJOWHITE1 0xffdead
#define MP_NAVAJOWHITE2 0xeecfa1
#define MP_NAVAJOWHITE3 0xcdb38b
#define MP_NAVAJOWHITE4 0x8b795e
#define MP_LEMONCHIFFON1 0xfffacd
#define MP_LEMONCHIFFON2 0xeee9bf
#define MP_LEMONCHIFFON3 0xcdc9a5
#define MP_LEMONCHIFFON4 0x8b8970
#define MP_CORNSILK1 0xfff8dc
#define MP_CORNSILK2 0xeee8cd
#define MP_CORNSILK3 0xcdc8b1
#define MP_CORNSILK4 0x8b8878
#define MP_IVORY1 0xfffff0
#define MP_IVORY2 0xeeeee0
#define MP_IVORY3 0xcdcdc1
#define MP_IVORY4 0x8b8b83
#define MP_HONEYDEW1 0xf0fff0
#define MP_HONEYDEW2 0xe0eee0
#define MP_HONEYDEW3 0xc1cdc1
#define MP_HONEYDEW4 0x838b83
#define MP_LAVENDERBLUSH1 0xfff0f5
#define MP_LAVENDERBLUSH2 0xeee0e5
#define MP_LAVENDERBLUSH3 0xcdc1c5
#define MP_LAVENDERBLUSH4 0x8b8386
#define MP_MISTYROSE1 0xffe4e1
#define MP_MISTYROSE2 0xeed5d2
#define MP_MISTYROSE3 0xcdb7b5
#define MP_MISTYROSE4 0x8b7d7b
#define MP_AZURE1 0xf0ffff
#define MP_AZURE2 0xe0eeee
#define MP_AZURE3 0xc1cdcd
#define MP_AZURE4 0x838b8b
#define MP_SLATEBLUE1 0x836fff
#define MP_SLATEBLUE2 0x7a67ee
#define MP_SLATEBLUE3 0x6959cd
#define MP_SLATEBLUE4 0x473c8b
#define MP_ROYALBLUE1 0x4876ff
#define MP_ROYALBLUE2 0x436eee
#define MP_ROYALBLUE3 0x3a5fcd
#define MP_ROYALBLUE4 0x27408b
#define MP_BLUE1 0x0000ff
#define MP_BLUE2 0x0000ee
#define MP_BLUE3 0x0000cd
#define MP_BLUE4 0x00008b
#define MP_DODGERBLUE1 0x1e90ff
#define MP_DODGERBLUE2 0x1c86ee
#define MP_DODGERBLUE3 0x1874cd
#define MP_DODGERBLUE4 0x104e8b
#define MP_STEELBLUE1 0x63b8ff
#define MP_STEELBLUE2 0x5cacee
#define MP_STEELBLUE3 0x4f94cd
#define MP_STEELBLUE4 0x36648b
#define MP_DEEPSKYBLUE1 0x00bfff
#define MP_DEEPSKYBLUE2 0x00b2ee
#define MP_DEEPSKYBLUE3 0x009acd