aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/layers/radv_sqtt_layer.c
blob: 5f61937367fd089923d093c02a3df534a33ce049 (plain)
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 Valve Corporation
 *
 * 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 (including the next
 * paragraph) 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.
 */

#include "radv_private.h"

/**
 * Identifiers for RGP SQ thread-tracing markers (Table 1)
 */
enum rgp_sqtt_marker_identifier {
	RGP_SQTT_MARKER_IDENTIFIER_EVENT		= 0x0,
	RGP_SQTT_MARKER_IDENTIFIER_CB_START             = 0x1,
	RGP_SQTT_MARKER_IDENTIFIER_CB_END               = 0x2,
	RGP_SQTT_MARKER_IDENTIFIER_BARRIER_START        = 0x3,
	RGP_SQTT_MARKER_IDENTIFIER_BARRIER_END          = 0x4,
	RGP_SQTT_MARKER_IDENTIFIER_USER_EVENT           = 0x5,
	RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API          = 0x6,
	RGP_SQTT_MARKER_IDENTIFIER_SYNC			= 0x7,
	RGP_SQTT_MARKER_IDENTIFIER_PRESENT		= 0x8,
	RGP_SQTT_MARKER_IDENTIFIER_LAYOUT_TRANSITION    = 0x9,
	RGP_SQTT_MARKER_IDENTIFIER_RENDER_PASS          = 0xA,
	RGP_SQTT_MARKER_IDENTIFIER_RESERVED2		= 0xB,
	RGP_SQTT_MARKER_IDENTIFIER_BIND_PIPELINE        = 0xC,
	RGP_SQTT_MARKER_IDENTIFIER_RESERVED4		= 0xD,
	RGP_SQTT_MARKER_IDENTIFIER_RESERVED5		= 0xE,
	RGP_SQTT_MARKER_IDENTIFIER_RESERVED6		= 0xF
};

/**
 * RGP SQ thread-tracing marker for the start of a command buffer. (Table 2)
 */
struct rgp_sqtt_marker_cb_start {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t cb_id : 20;
			uint32_t queue : 5;
		};
		uint32_t dword01;
	};
	union {
		uint32_t device_id_low;
		uint32_t dword02;
	};
	union {
		uint32_t device_id_high;
		uint32_t dword03;
	};
	union {
		uint32_t queue_flags;
		uint32_t dword04;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_cb_start) == 16,
	      "rgp_sqtt_marker_cb_start doesn't match RGP spec");

/**
 *
 * RGP SQ thread-tracing marker for the end of a command buffer. (Table 3)
 */
struct rgp_sqtt_marker_cb_end {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t cb_id : 20;
			uint32_t reserved : 5;
		};
		uint32_t dword01;
	};
	union {
		uint32_t device_id_low;
		uint32_t dword02;
	};
	union {
		uint32_t device_id_high;
		uint32_t dword03;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_cb_end) == 12,
	      "rgp_sqtt_marker_cb_end doesn't match RGP spec");

/**
 * API types used in RGP SQ thread-tracing markers for the "General API"
 * packet.
 */
enum rgp_sqtt_marker_general_api_type {
	ApiCmdBindPipeline                     = 0,
	ApiCmdBindDescriptorSets               = 1,
	ApiCmdBindIndexBuffer                  = 2,
	ApiCmdBindVertexBuffers                = 3,
	ApiCmdDraw                             = 4,
	ApiCmdDrawIndexed                      = 5,
	ApiCmdDrawIndirect                     = 6,
	ApiCmdDrawIndexedIndirect              = 7,
	ApiCmdDrawIndirectCountAMD             = 8,
	ApiCmdDrawIndexedIndirectCountAMD      = 9,
	ApiCmdDispatch                         = 10,
	ApiCmdDispatchIndirect                 = 11,
	ApiCmdCopyBuffer                       = 12,
	ApiCmdCopyImage                        = 13,
	ApiCmdBlitImage                        = 14,
	ApiCmdCopyBufferToImage                = 15,
	ApiCmdCopyImageToBuffer                = 16,
	ApiCmdUpdateBuffer                     = 17,
	ApiCmdFillBuffer                       = 18,
	ApiCmdClearColorImage                  = 19,
	ApiCmdClearDepthStencilImage           = 20,
	ApiCmdClearAttachments                 = 21,
	ApiCmdResolveImage                     = 22,
	ApiCmdWaitEvents                       = 23,
	ApiCmdPipelineBarrier                  = 24,
	ApiCmdBeginQuery                       = 25,
	ApiCmdEndQuery                         = 26,
	ApiCmdResetQueryPool                   = 27,
	ApiCmdWriteTimestamp                   = 28,
	ApiCmdCopyQueryPoolResults             = 29,
	ApiCmdPushConstants                    = 30,
	ApiCmdBeginRenderPass                  = 31,
	ApiCmdNextSubpass                      = 32,
	ApiCmdEndRenderPass                    = 33,
	ApiCmdExecuteCommands                  = 34,
	ApiCmdSetViewport                      = 35,
	ApiCmdSetScissor                       = 36,
	ApiCmdSetLineWidth                     = 37,
	ApiCmdSetDepthBias                     = 38,
	ApiCmdSetBlendConstants                = 39,
	ApiCmdSetDepthBounds                   = 40,
	ApiCmdSetStencilCompareMask            = 41,
	ApiCmdSetStencilWriteMask              = 42,
	ApiCmdSetStencilReference              = 43,
	ApiCmdDrawIndirectCount                = 44,
	ApiCmdDrawIndexedIndirectCount         = 45,
	ApiInvalid                             = 0xffffffff
};

/**
 * RGP SQ thread-tracing marker for a "General API" instrumentation packet.
 */
struct rgp_sqtt_marker_general_api {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t api_type : 20;
			uint32_t is_end : 1;
			uint32_t reserved : 4;
		};
		uint32_t dword01;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_general_api) == 4,
	      "rgp_sqtt_marker_general_api doesn't match RGP spec");

/**
 * API types used in RGP SQ thread-tracing markers (Table 16).
 */
enum rgp_sqtt_marker_event_type {
	EventCmdDraw                             = 0,
	EventCmdDrawIndexed                      = 1,
	EventCmdDrawIndirect                     = 2,
	EventCmdDrawIndexedIndirect              = 3,
	EventCmdDrawIndirectCountAMD             = 4,
	EventCmdDrawIndexedIndirectCountAMD      = 5,
	EventCmdDispatch                         = 6,
	EventCmdDispatchIndirect                 = 7,
	EventCmdCopyBuffer                       = 8,
	EventCmdCopyImage                        = 9,
	EventCmdBlitImage                        = 10,
	EventCmdCopyBufferToImage                = 11,
	EventCmdCopyImageToBuffer                = 12,
	EventCmdUpdateBuffer                     = 13,
	EventCmdFillBuffer                       = 14,
	EventCmdClearColorImage                  = 15,
	EventCmdClearDepthStencilImage           = 16,
	EventCmdClearAttachments                 = 17,
	EventCmdResolveImage                     = 18,
	EventCmdWaitEvents                       = 19,
	EventCmdPipelineBarrier                  = 20,
	EventCmdResetQueryPool                   = 21,
	EventCmdCopyQueryPoolResults             = 22,
	EventRenderPassColorClear                = 23,
	EventRenderPassDepthStencilClear         = 24,
	EventRenderPassResolve                   = 25,
	EventInternalUnknown                     = 26,
	EventCmdDrawIndirectCount                = 27,
	EventCmdDrawIndexedIndirectCount         = 28,
	EventInvalid                             = 0xffffffff
};

/**
 * "Event (Per-draw/dispatch)" RGP SQ thread-tracing marker. (Table 4)
 */
struct rgp_sqtt_marker_event {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t api_type : 24;
			uint32_t has_thread_dims : 1;
		};
		uint32_t dword01;
	};
	union {
		struct {
			uint32_t cb_id : 20;
			uint32_t vertex_offset_reg_idx : 4;
			uint32_t instance_offset_reg_idx : 4;
			uint32_t draw_index_reg_idx : 4;
		};
		uint32_t dword02;
	};
	union {
		uint32_t cmd_id;
		uint32_t dword03;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_event) == 12,
	      "rgp_sqtt_marker_event doesn't match RGP spec");

/**
 * Per-dispatch specific marker where workgroup dims are included.
 */
struct rgp_sqtt_marker_event_with_dims {
	struct rgp_sqtt_marker_event event;
	uint32_t thread_x;
	uint32_t thread_y;
	uint32_t thread_z;
};

static_assert(sizeof(struct rgp_sqtt_marker_event_with_dims) == 24,
	      "rgp_sqtt_marker_event_with_dims doesn't match RGP spec");

/**
 * "Barrier Start" RGP SQTT instrumentation marker (Table 5)
 */
struct rgp_sqtt_marker_barrier_start {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t cb_id : 20;
			uint32_t reserved : 5;
		};
		uint32_t dword01;
	};
	union {
		struct {
			uint32_t driver_reason : 31;
			uint32_t internal : 1;
		};
		uint32_t dword02;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_barrier_start) == 8,
	      "rgp_sqtt_marker_barrier_start doesn't match RGP spec");

/**
 * "Barrier End" RGP SQTT instrumentation marker (Table 6)
 */
struct rgp_sqtt_marker_barrier_end {
	union {
		struct {
			uint32_t identifier : 4;
			uint32_t ext_dwords : 3;
			uint32_t cb_id : 20;
			uint32_t wait_on_eop_ts : 1;
			uint32_t vs_partial_flush : 1;
			uint32_t ps_partial_flush : 1;
			uint32_t cs_partial_flush : 1;
			uint32_t pfp_sync_me : 1;
		};
		uint32_t dword01;
	};
	union {
		struct {
			uint32_t sync_cp_dma : 1;
			uint32_t inval_ccp : 1;
			uint32_t inval_sqI : 1;
			uint32_t inval_sqK : 1;
			uint32_t flush_tcc : 1;
			uint32_t inval_tcc : 1;
			uint32_t flush_cb : 1;
			uint32_t inval_cb : 1;
			uint32_t flush_db : 1;
			uint32_t inval_db : 1;
			uint32_t num_layout_transitions : 16;
			uint32_t inval_gl1 : 1;
			uint32_t reserved : 5;
		};
		uint32_t dword02;
	};
};

static_assert(sizeof(struct rgp_sqtt_marker_barrier_end) == 8,
	      "rgp_sqtt_marker_barrier_end doesn't match RGP spec");

static void
radv_write_begin_general_api_marker(struct radv_cmd_buffer *cmd_buffer,
				    enum rgp_sqtt_marker_general_api_type api_type)
{
	struct rgp_sqtt_marker_general_api marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API;
	marker.api_type = api_type;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

static void
radv_write_end_general_api_marker(struct radv_cmd_buffer *cmd_buffer,
				  enum rgp_sqtt_marker_general_api_type api_type)
{
	struct rgp_sqtt_marker_general_api marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_GENERAL_API;
	marker.api_type = api_type;
	marker.is_end = 1;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

static void
radv_write_event_marker(struct radv_cmd_buffer *cmd_buffer,
			enum rgp_sqtt_marker_event_type api_type,
			uint32_t vertex_offset_user_data,
			uint32_t instance_offset_user_data,
			uint32_t draw_index_user_data)
{
	struct rgp_sqtt_marker_event marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_EVENT;
	marker.api_type = api_type;
	marker.cmd_id = cmd_buffer->state.num_events++;
	marker.cb_id = 0;

	if (vertex_offset_user_data == UINT_MAX ||
	    instance_offset_user_data == UINT_MAX) {
		vertex_offset_user_data = 0;
		instance_offset_user_data = 0;
	}

	if (draw_index_user_data == UINT_MAX)
		draw_index_user_data = vertex_offset_user_data;

	marker.vertex_offset_reg_idx = vertex_offset_user_data;
	marker.instance_offset_reg_idx = instance_offset_user_data;
	marker.draw_index_reg_idx = draw_index_user_data;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

static void
radv_write_event_with_dims_marker(struct radv_cmd_buffer *cmd_buffer,
				  enum rgp_sqtt_marker_event_type api_type,
				  uint32_t x, uint32_t y, uint32_t z)
{
	struct rgp_sqtt_marker_event_with_dims marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	marker.event.identifier = RGP_SQTT_MARKER_IDENTIFIER_EVENT;
	marker.event.api_type = api_type;
	marker.event.cmd_id = cmd_buffer->state.num_events++;
	marker.event.cb_id = 0;
	marker.event.has_thread_dims = 1;

	marker.thread_x = x;
	marker.thread_y = y;
	marker.thread_z = z;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

void
radv_describe_begin_cmd_buffer(struct radv_cmd_buffer *cmd_buffer)
{
	uint64_t device_id = (uintptr_t)cmd_buffer->device;
	struct rgp_sqtt_marker_cb_start marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_CB_START;
	marker.cb_id = 0;
	marker.device_id_low = device_id;
	marker.device_id_high = device_id >> 32;
	marker.queue = cmd_buffer->queue_family_index;
	marker.queue_flags = VK_QUEUE_COMPUTE_BIT |
			     VK_QUEUE_TRANSFER_BIT |
			     VK_QUEUE_SPARSE_BINDING_BIT;

	if (cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL)
		marker.queue_flags |= VK_QUEUE_GRAPHICS_BIT;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

void
radv_describe_end_cmd_buffer(struct radv_cmd_buffer *cmd_buffer)
{
	uint64_t device_id = (uintptr_t)cmd_buffer->device;
	struct rgp_sqtt_marker_cb_end marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_CB_END;
	marker.cb_id = 0;
	marker.device_id_low = device_id;
	marker.device_id_high = device_id >> 32;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

void
radv_describe_draw(struct radv_cmd_buffer *cmd_buffer)
{
	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	radv_write_event_marker(cmd_buffer, cmd_buffer->state.current_event_type,
				UINT_MAX, UINT_MAX, UINT_MAX);
}

void
radv_describe_dispatch(struct radv_cmd_buffer *cmd_buffer, int x, int y, int z)
{
	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	radv_write_event_with_dims_marker(cmd_buffer,
					  cmd_buffer->state.current_event_type,
					  x, y, z);
}

void
radv_describe_begin_render_pass_clear(struct radv_cmd_buffer *cmd_buffer,
				      VkImageAspectFlagBits aspects)
{
	cmd_buffer->state.current_event_type = (aspects & VK_IMAGE_ASPECT_COLOR_BIT) ?
		EventRenderPassColorClear : EventRenderPassDepthStencilClear;
}

void
radv_describe_end_render_pass_clear(struct radv_cmd_buffer *cmd_buffer)
{
	cmd_buffer->state.current_event_type = EventInternalUnknown;
}

void
radv_describe_barrier_start(struct radv_cmd_buffer *cmd_buffer,
			   enum rgp_barrier_reason reason)
{
	struct rgp_sqtt_marker_barrier_start marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_BARRIER_START;
	marker.cb_id = 0;
	marker.dword02 = reason;

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

void
radv_describe_barrier_end(struct radv_cmd_buffer *cmd_buffer)
{
	struct rgp_sqtt_marker_barrier_end marker = {};
	struct radeon_cmdbuf *cs = cmd_buffer->cs;

	if (likely(!cmd_buffer->device->thread_trace_bo))
		return;

	marker.identifier = RGP_SQTT_MARKER_IDENTIFIER_BARRIER_END;
	marker.cb_id = 0;

	/* TODO: fill pipeline stalls, cache flushes, etc */

	radv_emit_thread_trace_userdata(cs, &marker, sizeof(marker) / 4);
}

#define EVENT_MARKER(cmd_name, args...) \
	RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); \
	radv_write_begin_general_api_marker(cmd_buffer, ApiCmd##cmd_name); \
	cmd_buffer->state.current_event_type = EventCmd##cmd_name; \
	radv_Cmd##cmd_name(args); \
	cmd_buffer->state.current_event_type = EventInternalUnknown; \
	radv_write_end_general_api_marker(cmd_buffer, ApiCmd##cmd_name);

void sqtt_CmdDraw(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    vertexCount,
	uint32_t                                    instanceCount,
	uint32_t                                    firstVertex,
	uint32_t                                    firstInstance)
{
	EVENT_MARKER(Draw, commandBuffer, vertexCount, instanceCount,
		     firstVertex, firstInstance);
}

void sqtt_CmdDrawIndexed(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    indexCount,
	uint32_t                                    instanceCount,
	uint32_t                                    firstIndex,
	int32_t                                     vertexOffset,
	uint32_t                                    firstInstance)
{
	EVENT_MARKER(DrawIndexed, commandBuffer, indexCount, instanceCount,
		     firstIndex, vertexOffset, firstInstance);
}

void sqtt_CmdDrawIndirect(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    buffer,
	VkDeviceSize                                offset,
	uint32_t                                    drawCount,
	uint32_t                                    stride)
{
	EVENT_MARKER(DrawIndirect, commandBuffer, buffer, offset, drawCount,
		     stride);
}

void sqtt_CmdDrawIndexedIndirect(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    buffer,
	VkDeviceSize                                offset,
	uint32_t                                    drawCount,
	uint32_t                                    stride)
{
	EVENT_MARKER(DrawIndexedIndirect, commandBuffer, buffer, offset,
		     drawCount, stride);
}

void sqtt_CmdDrawIndirectCount(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    buffer,
	VkDeviceSize                                offset,
	VkBuffer                                    countBuffer,
	VkDeviceSize                                countBufferOffset,
	uint32_t                                    maxDrawCount,
	uint32_t                                    stride)
{
	EVENT_MARKER(DrawIndirectCount,commandBuffer, buffer, offset,
		     countBuffer, countBufferOffset, maxDrawCount, stride);
}

void sqtt_CmdDrawIndexedIndirectCount(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    buffer,
	VkDeviceSize                                offset,
	VkBuffer                                    countBuffer,
	VkDeviceSize                                countBufferOffset,
	uint32_t                                    maxDrawCount,
	uint32_t                                    stride)
{
	EVENT_MARKER(DrawIndexedIndirectCount, commandBuffer, buffer, offset,
		     countBuffer, countBufferOffset, maxDrawCount, stride);
}

void sqtt_CmdDispatch(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    x,
	uint32_t                                    y,
	uint32_t                                    z)
{
	EVENT_MARKER(Dispatch, commandBuffer, x, y, z);
}

void sqtt_CmdDispatchIndirect(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    buffer,
	VkDeviceSize                                offset)
{
	EVENT_MARKER(DispatchIndirect, commandBuffer, buffer, offset);
}

void sqtt_CmdCopyBuffer(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    srcBuffer,
	VkBuffer                                    destBuffer,
	uint32_t                                    regionCount,
	const VkBufferCopy*                         pRegions)
{
	EVENT_MARKER(CopyBuffer, commandBuffer, srcBuffer, destBuffer,
		     regionCount, pRegions);
}

void sqtt_CmdFillBuffer(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    dstBuffer,
	VkDeviceSize                                dstOffset,
	VkDeviceSize                                fillSize,
	uint32_t                                    data)
{
	EVENT_MARKER(FillBuffer, commandBuffer, dstBuffer, dstOffset, fillSize,
		     data);
}

void sqtt_CmdUpdateBuffer(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    dstBuffer,
	VkDeviceSize                                dstOffset,
	VkDeviceSize                                dataSize,
	const void*                                 pData)
{
	EVENT_MARKER(UpdateBuffer, commandBuffer, dstBuffer, dstOffset,
		     dataSize, pData);
}

void sqtt_CmdCopyImage(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     srcImage,
	VkImageLayout                               srcImageLayout,
	VkImage                                     destImage,
	VkImageLayout                               destImageLayout,
	uint32_t                                    regionCount,
	const VkImageCopy*                          pRegions)
{
	EVENT_MARKER(CopyImage, commandBuffer, srcImage, srcImageLayout,
		     destImage, destImageLayout, regionCount, pRegions);
}

void sqtt_CmdCopyBufferToImage(
	VkCommandBuffer                             commandBuffer,
	VkBuffer                                    srcBuffer,
	VkImage                                     destImage,
	VkImageLayout                               destImageLayout,
	uint32_t                                    regionCount,
	const VkBufferImageCopy*                    pRegions)
{
	EVENT_MARKER(CopyBufferToImage, commandBuffer, srcBuffer, destImage,
		     destImageLayout, regionCount, pRegions);
}

void sqtt_CmdCopyImageToBuffer(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     srcImage,
	VkImageLayout                               srcImageLayout,
	VkBuffer                                    destBuffer,
	uint32_t                                    regionCount,
	const VkBufferImageCopy*                    pRegions)
{
	EVENT_MARKER(CopyImageToBuffer, commandBuffer, srcImage, srcImageLayout,
		     destBuffer, regionCount, pRegions);
}

void sqtt_CmdBlitImage(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     srcImage,
	VkImageLayout                               srcImageLayout,
	VkImage                                     destImage,
	VkImageLayout                               destImageLayout,
	uint32_t                                    regionCount,
	const VkImageBlit*                          pRegions,
	VkFilter                                    filter)
{
	EVENT_MARKER(BlitImage, commandBuffer, srcImage, srcImageLayout,
		     destImage, destImageLayout, regionCount, pRegions, filter);
}

void sqtt_CmdClearColorImage(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     image_h,
	VkImageLayout                               imageLayout,
	const VkClearColorValue*                    pColor,
	uint32_t                                    rangeCount,
	const VkImageSubresourceRange*              pRanges)
{
	EVENT_MARKER(ClearColorImage, commandBuffer, image_h, imageLayout,
		     pColor, rangeCount, pRanges);
}

void sqtt_CmdClearDepthStencilImage(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     image_h,
	VkImageLayout                               imageLayout,
	const VkClearDepthStencilValue*             pDepthStencil,
	uint32_t                                    rangeCount,
	const VkImageSubresourceRange*              pRanges)
{
	EVENT_MARKER(ClearDepthStencilImage, commandBuffer, image_h,
		     imageLayout, pDepthStencil, rangeCount, pRanges);
}

void sqtt_CmdClearAttachments(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    attachmentCount,
	const VkClearAttachment*                    pAttachments,
	uint32_t                                    rectCount,
	const VkClearRect*                          pRects)
{
	EVENT_MARKER(ClearAttachments, commandBuffer, attachmentCount,
		     pAttachments, rectCount, pRects);
}

void sqtt_CmdResolveImage(
	VkCommandBuffer                             commandBuffer,
	VkImage                                     src_image_h,
	VkImageLayout                               src_image_layout,
	VkImage                                     dest_image_h,
	VkImageLayout                               dest_image_layout,
	uint32_t                                    region_count,
	const VkImageResolve*                       regions)
{
	EVENT_MARKER(ResolveImage, commandBuffer, src_image_h, src_image_layout,
		     dest_image_h, dest_image_layout, region_count, regions);
}

void sqtt_CmdWaitEvents(VkCommandBuffer commandBuffer,
			uint32_t eventCount,
			const VkEvent* pEvents,
			VkPipelineStageFlags srcStageMask,
			VkPipelineStageFlags dstStageMask,
			uint32_t memoryBarrierCount,
			const VkMemoryBarrier* pMemoryBarriers,
			uint32_t bufferMemoryBarrierCount,
			const VkBufferMemoryBarrier* pBufferMemoryBarriers,
			uint32_t imageMemoryBarrierCount,
			const VkImageMemoryBarrier* pImageMemoryBarriers)
{
	EVENT_MARKER(WaitEvents, commandBuffer, eventCount, pEvents,
		     srcStageMask, dstStageMask, memoryBarrierCount,
		     pMemoryBarriers, bufferMemoryBarrierCount,
		     pBufferMemoryBarriers, imageMemoryBarrierCount,
		     pImageMemoryBarriers);
}

void sqtt_CmdPipelineBarrier(
	VkCommandBuffer                             commandBuffer,
	VkPipelineStageFlags                        srcStageMask,
	VkPipelineStageFlags                        destStageMask,
	VkBool32                                    byRegion,
	uint32_t                                    memoryBarrierCount,
	const VkMemoryBarrier*                      pMemoryBarriers,
	uint32_t                                    bufferMemoryBarrierCount,
	const VkBufferMemoryBarrier*                pBufferMemoryBarriers,
	uint32_t                                    imageMemoryBarrierCount,
	const VkImageMemoryBarrier*                 pImageMemoryBarriers)
{
	EVENT_MARKER(PipelineBarrier, commandBuffer, srcStageMask,
		     destStageMask, byRegion, memoryBarrierCount,
		     pMemoryBarriers, bufferMemoryBarrierCount,
		     pBufferMemoryBarriers, imageMemoryBarrierCount,
		     pImageMemoryBarriers);
}

void sqtt_CmdResetQueryPool(
	VkCommandBuffer                             commandBuffer,
	VkQueryPool                                 queryPool,
	uint32_t                                    firstQuery,
	uint32_t                                    queryCount)
{
	EVENT_MARKER(ResetQueryPool, commandBuffer, queryPool, firstQuery,
		     queryCount);
}

void sqtt_CmdCopyQueryPoolResults(
	VkCommandBuffer                             commandBuffer,
	VkQueryPool                                 queryPool,
	uint32_t                                    firstQuery,
	uint32_t                                    queryCount,
	VkBuffer                                    dstBuffer,
	VkDeviceSize                                dstOffset,
	VkDeviceSize                                stride,
	VkQueryResultFlags                          flags)
{
	EVENT_MARKER(CopyQueryPoolResults, commandBuffer, queryPool, firstQuery,
				     queryCount, dstBuffer, dstOffset, stride,
				     flags);
}

#undef EVENT_MARKER
#define API_MARKER(cmd_name, args...) \
	RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); \
	radv_write_begin_general_api_marker(cmd_buffer, ApiCmd##cmd_name); \
	radv_Cmd##cmd_name(args); \
	radv_write_end_general_api_marker(cmd_buffer, ApiCmd##cmd_name);

void sqtt_CmdBindPipeline(
	VkCommandBuffer                             commandBuffer,
	VkPipelineBindPoint                         pipelineBindPoint,
	VkPipeline                                  pipeline)
{
	API_MARKER(BindPipeline, commandBuffer, pipelineBindPoint, pipeline);
}

void sqtt_CmdBindDescriptorSets(
	VkCommandBuffer                             commandBuffer,
	VkPipelineBindPoint                         pipelineBindPoint,
	VkPipelineLayout                            layout,
	uint32_t                                    firstSet,
	uint32_t                                    descriptorSetCount,
	const VkDescriptorSet*                      pDescriptorSets,
	uint32_t                                    dynamicOffsetCount,
	const uint32_t*                             pDynamicOffsets)
{
	API_MARKER(BindDescriptorSets, commandBuffer, pipelineBindPoint,
		   layout, firstSet, descriptorSetCount,
		   pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
}

void sqtt_CmdBindIndexBuffer(
	VkCommandBuffer                             commandBuffer,
	VkBuffer				    buffer,
	VkDeviceSize				    offset,
	VkIndexType				    indexType)
{
	API_MARKER(BindIndexBuffer, commandBuffer, buffer, offset, indexType);
}

void sqtt_CmdBindVertexBuffers(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    firstBinding,
	uint32_t                                    bindingCount,
	const VkBuffer*                             pBuffers,
	const VkDeviceSize*                         pOffsets)
{
	API_MARKER(BindVertexBuffers, commandBuffer, firstBinding, bindingCount,
		   pBuffers, pOffsets);
}

void sqtt_CmdBeginQuery(
	VkCommandBuffer                             commandBuffer,
	VkQueryPool                                 queryPool,
	uint32_t                                    query,
	VkQueryControlFlags                         flags)
{
	API_MARKER(BeginQuery, commandBuffer, queryPool, query, flags);
}

void sqtt_CmdEndQuery(
	VkCommandBuffer                             commandBuffer,
	VkQueryPool                                 queryPool,
	uint32_t                                    query)
{
	API_MARKER(EndQuery, commandBuffer, queryPool, query);
}

void sqtt_CmdWriteTimestamp(
	VkCommandBuffer                             commandBuffer,
	VkPipelineStageFlagBits                     pipelineStage,
	VkQueryPool                                 queryPool,
	uint32_t				    flags)
{
	API_MARKER(WriteTimestamp, commandBuffer, pipelineStage, queryPool, flags);
}

void sqtt_CmdPushConstants(
	VkCommandBuffer				    commandBuffer,
	VkPipelineLayout			    layout,
	VkShaderStageFlags			    stageFlags,
	uint32_t				    offset,
	uint32_t				    size,
	const void*				    pValues)
{
	API_MARKER(PushConstants, commandBuffer, layout, stageFlags, offset,
		   size, pValues);
}

void sqtt_CmdBeginRenderPass(
	VkCommandBuffer                             commandBuffer,
	const VkRenderPassBeginInfo*                pRenderPassBegin,
	VkSubpassContents                           contents)
{
	API_MARKER(BeginRenderPass, commandBuffer, pRenderPassBegin, contents);
}

void sqtt_CmdNextSubpass(
	VkCommandBuffer                             commandBuffer,
	VkSubpassContents                           contents)
{
	API_MARKER(NextSubpass, commandBuffer, contents);
}

void sqtt_CmdEndRenderPass(
	VkCommandBuffer                             commandBuffer)
{
	API_MARKER(EndRenderPass, commandBuffer);
}

void sqtt_CmdExecuteCommands(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    commandBufferCount,
	const VkCommandBuffer*                      pCmdBuffers)
{
	API_MARKER(ExecuteCommands, commandBuffer, commandBufferCount,
		   pCmdBuffers);
}

void sqtt_CmdSetViewport(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    firstViewport,
	uint32_t                                    viewportCount,
	const VkViewport*                           pViewports)
{
	API_MARKER(SetViewport, commandBuffer, firstViewport, viewportCount,
		   pViewports);
}

void sqtt_CmdSetScissor(
	VkCommandBuffer                             commandBuffer,
	uint32_t                                    firstScissor,
	uint32_t                                    scissorCount,
	const VkRect2D*                             pScissors)
{
	API_MARKER(SetScissor, commandBuffer, firstScissor, scissorCount,
		   pScissors);
}

void sqtt_CmdSetLineWidth(
	VkCommandBuffer                             commandBuffer,
	float                                       lineWidth)
{
	API_MARKER(SetLineWidth, commandBuffer, lineWidth);
}

void sqtt_CmdSetDepthBias(
	VkCommandBuffer                             commandBuffer,
	float                                       depthBiasConstantFactor,
	float                                       depthBiasClamp,
	float                                       depthBiasSlopeFactor)
{
	API_MARKER(SetDepthBias, commandBuffer, depthBiasConstantFactor,
		   depthBiasClamp, depthBiasSlopeFactor);
}

void sqtt_CmdSetBlendConstants(
	VkCommandBuffer                             commandBuffer,
	const float                                 blendConstants[4])
{
	API_MARKER(SetBlendConstants, commandBuffer, blendConstants);
}

void sqtt_CmdSetDepthBounds(
	VkCommandBuffer                             commandBuffer,
	float                                       minDepthBounds,
	float                                       maxDepthBounds)
{
	API_MARKER(SetDepthBounds, commandBuffer, minDepthBounds,
		   maxDepthBounds);
}

void sqtt_CmdSetStencilCompareMask(
	VkCommandBuffer                             commandBuffer,
	VkStencilFaceFlags                          faceMask,
	uint32_t                                    compareMask)
{
	API_MARKER(SetStencilCompareMask, commandBuffer, faceMask, compareMask);
}

void sqtt_CmdSetStencilWriteMask(
	VkCommandBuffer                             commandBuffer,
	VkStencilFaceFlags                          faceMask,
	uint32_t                                    writeMask)
{
	API_MARKER(SetStencilWriteMask, commandBuffer, faceMask, writeMask);
}

void sqtt_CmdSetStencilReference(
	VkCommandBuffer                             commandBuffer,
	VkStencilFaceFlags                          faceMask,
	uint32_t                                    reference)
{
	API_MARKER(SetStencilReference, commandBuffer, faceMask, reference);
}

#undef API_MARKER