-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvk_runtime_sweep.py
More file actions
3910 lines (3607 loc) · 151 KB
/
Copy pathvk_runtime_sweep.py
File metadata and controls
3910 lines (3607 loc) · 151 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from __future__ import annotations
import argparse
import json
import math
import re
import struct
import subprocess
import sys
import zlib
from datetime import datetime, timezone
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_SWEEP_ROOT = ROOT / ".tmp" / "vk-runtime-sweeps"
CVAR_NAME_RE = re.compile(r"^[A-Za-z0-9_]+$")
Q3_COMMAND_TOKEN_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9_.\-/]*$")
FS_GAME_RE = re.compile(r"^[A-Za-z0-9_.-]+$")
WINDOWS_RESERVED_DIR_NAMES = {
"CON",
"PRN",
"AUX",
"NUL",
*(f"COM{index}" for index in range(1, 10)),
*(f"LPT{index}" for index in range(1, 10)),
}
TIMEDEMO_FPS_RE = re.compile(
r"(?P<frames>\d+)\s+frames[, ]+\s*"
r"(?P<seconds>\d+(?:\.\d+)?)\s+seconds:?\s*"
r"(?P<fps>\d+(?:\.\d+)?)\s+fps",
re.IGNORECASE,
)
PIPELINE_CACHE_RE = re.compile(
r"pipeline cache:\s*(?P<path>.*?),\s*loaded:\s*(?P<loaded>\d+)Kb,\s*saved:\s*(?P<saved>\d+)Kb",
re.IGNORECASE,
)
DISPLAY_HDR_RE = re.compile(
r"display HDR:\s*(?P<state>.*?),\s*metadata:\s*(?P<metadata>\w+),\s*"
r"paper white\s*(?P<paperWhite>\d+(?:\.\d+)?)\s*nits,\s*max\s*(?P<maxLuminance>\d+(?:\.\d+)?)\s*nits",
re.IGNORECASE,
)
OUTPUT_BACKEND_RE = re.compile(
r"output backend:\s*request\s+(?P<request>[A-Za-z0-9_-]+),\s*"
r"selected\s+(?P<selected>[A-Za-z0-9_-]+),\s*"
r"native\s+(?P<native>[A-Za-z0-9_-]+),\s*"
r"display HDR\s+(?P<displayHdr>\w+),\s*"
r"headroom\s+(?P<headroom>-?\d+(?:\.\d+)?),\s*"
r"SDR white\s+(?P<sdrWhite>-?\d+(?:\.\d+)?)\s*nits,\s*"
r"display max\s+(?P<displayMax>-?\d+(?:\.\d+)?)\s*nits,\s*"
r"ICC\s+(?P<icc>\w+)/(?P<iccBytes>\d+)",
re.IGNORECASE,
)
TONE_MAP_RE = re.compile(
r"tone map:\s*(?P<mode>.*?),\s*exposure\s*(?P<exposure>\d+(?:\.\d+)?)",
re.IGNORECASE,
)
POST_GAMMA_RE = re.compile(
r"post gamma:\s*domain\s*(?P<domain>[A-Za-z0-9_-]+),\s*"
r"shader\s*(?P<shader>\w+),\s*"
r"r_gamma\s*(?P<gamma>-?\d+(?:\.\d+)?),\s*"
r"exponent\s*(?P<exponent>-?\d+(?:\.\d+)?),\s*"
r"overbright scale\s*(?P<overbright>-?\d+(?:\.\d+)?)",
re.IGNORECASE,
)
BLOOM_RE = re.compile(
r"bloom:\s*threshold\s*(?P<threshold>\d+(?:\.\d+)?),\s*"
r"soft knee\s*(?P<softKnee>\d+(?:\.\d+)?),\s*"
r"intensity\s*(?P<intensity>\d+(?:\.\d+)?)",
re.IGNORECASE,
)
MODERN_VULKAN_RE = re.compile(
r"modern Vulkan:\s*sync2\s*(?P<sync2>\w+),\s*dynamic rendering\s*(?P<dynamic>.*)",
re.IGNORECASE,
)
BARRIERS_RE = re.compile(
r"barriers:\s*(?P<sync2>\d+)\s*sync2\s*/\s*(?P<legacy>\d+)\s*legacy",
re.IGNORECASE,
)
DESCRIPTORS_RE = re.compile(
r"descriptor writes:\s*(?P<writes>\d+),\s*binds:\s*(?P<bindCalls>\d+)\s*calls\s*/\s*"
r"(?P<bindSets>\d+)\s*sets,\s*material cache:\s*(?P<hits>\d+)\s*hits\s*/\s*(?P<misses>\d+)\s*misses",
re.IGNORECASE,
)
COMMAND_POOLS_RE = re.compile(
r"command pool resets:\s*(?P<frame>\d+)\s*frame\s*/\s*(?P<upload>\d+)\s*upload",
re.IGNORECASE,
)
MEMORY_RE = re.compile(
r"memory:\s*(?P<allocs>\d+)\s*allocs\s*\((?P<peakAllocs>\d+)\s*peak\),\s*"
r"(?P<liveKb>\d+)Kb\s*live\s*/\s*(?P<peakKb>\d+)Kb\s*peak",
re.IGNORECASE,
)
GPU_TIMING_RE = re.compile(
r"\s*(?P<from>.*?)\s*->\s*(?P<to>.*?):\s*(?P<msec>\d+(?:\.\d+)?)\s*ms",
re.IGNORECASE,
)
DLIGHT_SHADOW_PLAN_RE = re.compile(
r"dlight shadows plan:(?P<planned>\d+)/(?P<considered>\d+)\s+"
r"cand:(?P<candidates>\d+)\s+"
r"atlas:(?P<atlasWidth>\d+)x(?P<atlasHeight>\d+)/(?P<faceSize>\d+)\s+"
r"fill:(?P<fill>\d+)%\s+"
r"(?:filter:\S+\s+taps:\d+\s+offsets:[+-]?\d+(?:\.\d+)?/[+-]?\d+(?:\.\d+)?\s+)?"
r"render lights:(?P<renderLights>\d+)\s+"
r"faces:(?P<faces>\d+)\s+batches:(?P<batches>\d+)\s+"
r"draws:(?P<draws>\d+)\s+surfs:(?P<surfs>\d+)\s+"
r"cpu:(?P<cpuMsec>\d+)ms",
re.IGNORECASE,
)
SHADOW_MANAGER_RE = re.compile(
r"shadow manager view:(?P<view>\d+)\s+frame:(?P<frame>\d+)\s+"
r"noworld:(?P<noworld>\d+)\s+sched:(?P<scheduledPasses>\d+)\s+"
r"mask:(?P<scheduledMask>[0-9a-fA-F]+)\s+"
r"p:(?P<pointScheduled>\d+)\s+s:(?P<spotScheduled>\d+)\s+"
r"ca:(?P<csmAtlasScheduled>\d+)\s+cr:(?P<csmReceiverScheduled>\d+)\s+"
r"pub p:(?P<pointPublished>\d+)\s+s:(?P<spotPublished>\d+)\s+"
r"c:(?P<csmPublished>\d+)\s+inputs dlight:(?P<inputDlights>\d+)\s+"
r"point:(?P<pointPlanned>\d+)/(?P<pointConsidered>\d+)\s+"
r"cand:(?P<pointCandidates>\d+)\s+"
r"records:(?P<pointRecords>\d+)/(?P<pointCandidateRecords>\d+)\s+"
r"atlas:(?P<pointAtlasWidth>\d+)x(?P<pointAtlasHeight>\d+)/(?P<pointAtlasFaceSize>\d+)\s+"
r"fill:(?P<pointAtlasFill>\d+)%\s+gen:(?P<pointGeneration>\d+)\s+"
r"spot:(?P<spotPlans>\d+)/(?P<spotCandidates>\d+)\s+"
r"(?:src\s+static:(?P<spotStaticPlans>\d+)/(?P<spotStaticCandidates>\d+)\s+"
r"surface:(?P<spotSurfacePlans>\d+)/(?P<spotSurfaceCandidates>\d+)\s+)?"
r"atlas:(?P<spotAtlasWidth>\d+)x(?P<spotAtlasHeight>\d+)/(?P<spotAtlasTileSize>\d+)\s+"
r"fill:(?P<spotAtlasFill>\d+)%\s+gen:(?P<spotGeneration>\d+)\s+"
r"csm:(?P<csmCascadeCount>\d+)\s+"
r"atlas:(?P<csmAtlasWidth>\d+)x(?P<csmAtlasHeight>\d+)\s+"
r"gen:(?P<csmGeneration>\d+)",
re.IGNORECASE,
)
SHADOW_ATLAS_CONTRACT_RE = re.compile(
r"shadow atlas contract backend:(?P<shadowAtlasBackend>\S+)\s+"
r"atlas:(?P<shadowAtlasName>\S+)\s+"
r"active:(?P<shadowAtlasActive>\d+)\s+"
r"tile:(?P<shadowAtlasTileSize>\d+)\s+"
r"size:(?P<shadowAtlasWidth>\d+)x(?P<shadowAtlasHeight>\d+)\s+"
r"records:(?P<shadowAtlasRecords>\d+)\s+"
r"fill:(?P<shadowAtlasFill>\d+)%\s+"
r"filter:(?P<shadowAtlasFilter>\S+)\s+"
r"pad:(?P<shadowAtlasPadTexels>\d+)\s+"
r"clamp:(?P<shadowAtlasClampTexels>\d+)\s+"
r"sampler:(?P<shadowAtlasSampler>\S+)\s+"
r"allocation:(?P<shadowAtlasAllocation>\S+)\s+"
r"deterministic:(?P<shadowAtlasDeterministic>\d+)",
re.IGNORECASE,
)
SURFACELIGHT_SPOT_PLAN_RE = re.compile(
r"surfacelight spot plan cand:(?P<surfaceSpotCandidates>\d+)\s+"
r"plan:(?P<surfaceSpotPlans>\d+)\s+"
r"req:(?P<surfaceSpotRequestedTileMin>\d+)-(?P<surfaceSpotRequestedTileMax>\d+)\s+"
r"foot:(?P<surfaceSpotFootprintMin>\d+)-(?P<surfaceSpotFootprintMax>\d+)\s+"
r"caster:(?P<surfaceSpotCasterRadiusMin>\d+)-(?P<surfaceSpotCasterRadiusMax>\d+)\s+"
r"planreq:(?P<surfaceSpotPlanRequestedTileMin>\d+)-(?P<surfaceSpotPlanRequestedTileMax>\d+)\s+"
r"tile:(?P<surfaceSpotTileMin>\d+)-(?P<surfaceSpotTileMax>\d+)\s+"
r"cone:(?P<surfaceSpotConeInnerMin>\d+)-(?P<surfaceSpotConeInnerMax>\d+)/"
r"(?P<surfaceSpotConeOuterMin>\d+)-(?P<surfaceSpotConeOuterMax>\d+)\s+"
r"alloc:(?P<surfaceSpotAllocated>\d+)\s+"
r"atlas:(?P<surfaceSpotAtlasWidth>\d+)x(?P<surfaceSpotAtlasHeight>\d+)/"
r"(?P<surfaceSpotAtlasTileSize>\d+)\s+"
r"fill:(?P<surfaceSpotAtlasFill>\d+)%\s+"
r"reject weak:(?P<surfaceSpotRejectedWeak>\d+)\s+"
r"offview:(?P<surfaceSpotRejectedOffView>\d+)\s+"
r"budget:(?P<surfaceSpotRejectedBudget>\d+)\s+"
r"malformed:(?P<surfaceSpotRejectedMalformed>\d+)",
re.IGNORECASE,
)
CSM_SHADOWS_RE = re.compile(
r"csm shadows sky:(?P<csmSky>\S+)\s+"
r"cascades:(?P<csmDebugCascades>\d+)\s+"
r"res:(?P<csmDebugResolution>\d+)\s+"
r"max:(?P<csmDebugMaxDistance>\d+)\s+"
r"lambda:\S+\s+filter:\S+\s+strength:\S+\s+rbias:\S+\s+"
r"cbias:\S+\s+light-dir:\S+\s+\S+\s+\S+\s+to-sun:\S+\s+\S+\s+\S+\s+"
r"split far:\S+\s+\S+\s+\S+\s+\S+\s+texel:\S+\s+\S+\s+\S+\s+\S+\s+"
r"(?:(?:depth center|snap depth):(?P<csmSnapDepth0>-?\d+(?:\.\d+)?)\s+"
r"(?P<csmSnapDepth1>-?\d+(?:\.\d+)?)\s+"
r"(?P<csmSnapDepth2>-?\d+(?:\.\d+)?)\s+"
r"(?P<csmSnapDepth3>-?\d+(?:\.\d+)?)\s+)?"
r"caster:(?P<csmCasterSurfaces>\d+)\s+"
r"cache h/m/u:(?P<csmCacheHits>\d+)/(?P<csmCacheMisses>\d+)/(?P<csmCacheUncacheable>\d+)\s+"
r"cpu:(?P<csmCpuMsec>\d+)ms\s+"
r"recv world:(?P<csmReceiverWorldSurfaces>\d+)\s+ent:(?P<csmReceiverEntitySurfaces>\d+)",
re.IGNORECASE,
)
CSM_CASCADE_RE = re.compile(
r"csm cascade backend:(?P<csmCascadeBackend>\S+)\s+"
r"index:(?P<csmCascadeIndex>\d+)\s+"
r"split:(?P<csmCascadeSplitNear>-?\d+(?:\.\d+)?)\.\.(?P<csmCascadeSplitFar>-?\d+(?:\.\d+)?)\s+"
r"atlas:(?P<csmCascadeAtlasX>-?\d+),(?P<csmCascadeAtlasY>-?\d+)/(?P<csmCascadeAtlasSize>\d+)\s+"
r"view:(?P<csmCascadeViewX>-?\d+),(?P<csmCascadeViewY>-?\d+)\s+(?P<csmCascadeViewWidth>\d+)x(?P<csmCascadeViewHeight>\d+)\s+"
r"api:(?P<csmCascadeApiX>-?\d+),(?P<csmCascadeApiY>-?\d+)\s+(?P<csmCascadeApiWidth>\d+)x(?P<csmCascadeApiHeight>\d+)\s+"
r"sample-y:(?P<csmCascadeSampleY>\S+)\s+clip-y:(?P<csmCascadeClipY>\S+)\s+"
r"depth:(?P<csmCascadeDepth>\S+)\s+ndc:(?P<csmCascadeNdc>\S+)\s+"
r"clear:(?P<csmCascadeClear>-?\d+(?:\.\d+)?)\s+compare:(?P<csmCascadeCompare>\S+)\s+"
r"bounds x:(?P<csmCascadeBoundMinX>-?\d+(?:\.\d+)?)\.\.(?P<csmCascadeBoundMaxX>-?\d+(?:\.\d+)?)\s+"
r"y:(?P<csmCascadeBoundMinY>-?\d+(?:\.\d+)?)\.\.(?P<csmCascadeBoundMaxY>-?\d+(?:\.\d+)?)\s+"
r"z:(?P<csmCascadeBoundMinZ>-?\d+(?:\.\d+)?)\.\.(?P<csmCascadeBoundMaxZ>-?\d+(?:\.\d+)?)\s+"
r"origin:(?P<csmCascadeOriginX>-?\d+(?:\.\d+)?)\s+(?P<csmCascadeOriginY>-?\d+(?:\.\d+)?)\s+(?P<csmCascadeOriginZ>-?\d+(?:\.\d+)?)\s+"
r"texel:(?P<csmCascadeTexel>-?\d+(?:\.\d+)?)",
re.IGNORECASE,
)
CSM_PLAN_SKIP_RE = re.compile(
r"csm plan cascades:(?P<csmFallbackCascades>\d+)\s+skip\s+"
r"(?P<csmFallbackReason>[A-Za-z0-9_-]+)",
re.IGNORECASE,
)
DLIGHT_SHADOW_SCENE_BEGIN_RE = re.compile(
r"DLIGHT_SHADOW_SCENE_BEGIN\s+(?P<scene>[A-Za-z0-9_.-]+)",
re.IGNORECASE,
)
DLIGHT_SHADOW_SCENE_END_RE = re.compile(
r"DLIGHT_SHADOW_SCENE_END\s+(?P<scene>[A-Za-z0-9_.-]+)",
re.IGNORECASE,
)
VULKAN_FAILURE_RE = re.compile(
r"(VK_ERROR_[A-Z0-9_]+|device lost|validation error|returned VK_ERROR)",
re.IGNORECASE,
)
DEFAULT_OPTIONS = {
"profile": "vk-modern",
"maps": "q3dm1",
"demos": "",
"width": 640,
"height": 480,
"startup_wait": 30,
"map_wait": 180,
"screenshot_wait": 8,
"perf_sample_wait": 4,
"timeout": 240.0,
"dlight_shadow_scenes": False,
}
COMMON_CVARS = {
"r_fullscreen": "0",
"r_mode": "-1",
"r_swapInterval": "0",
"r_screenshotWriteViewpos": "1",
}
DLIGHT_SHADOW_SCENE_CVARS = {
"developer": "1",
"logfile": "2",
"r_dynamiclight": "1",
"r_dlightMode": "2",
"r_dlightShadows": "1",
"r_dlightShadowDebug": "1",
"r_dlightShadowFilter": "2",
"r_dlightShadowMaxLights": "8",
"r_dlightShadowResolution": "256",
"r_staticLights": "1",
"r_staticLightDebug": "1",
"r_staticLightMaxLights": "8",
"r_staticLightShadows": "1",
"r_staticLightShadowMaxLights": "2",
"r_csmShadows": "1",
"r_csmDebug": "1",
"r_csmCascadeCount": "4",
"r_csmDebugFallback": "0",
"r_csmResolution": "512",
"r_csmShadowFilter": "2",
"r_spotShadows": "1",
"r_spotShadowDebug": "1",
"r_spotShadowMaxLights": "16",
"r_spotShadowResolution": "512",
"r_surfaceLightProxies": "1",
"r_surfaceLightProxyDebug": "1",
"r_surfaceLightProxyShadows": "1",
}
SURFACELIGHT_SPOT_EVIDENCE_CATEGORIES = (
"surfacelight-large-planar",
)
CSM_SKY_SUN_EVIDENCE_CATEGORIES = (
"csm-sky-sun",
)
CSM_SHIMMER_EVIDENCE_CATEGORIES = (
"csm-shimmer-path",
)
COMBINED_SHADOW_ATLAS_SCENE_ID = "combined-shadow-atlas"
COMBINED_SHADOW_ATLAS_EVIDENCE_CATEGORIES = (
COMBINED_SHADOW_ATLAS_SCENE_ID,
)
CSM_FALLBACK_SCENE_REASONS = {
"csm-fallback-no-world": "no-world",
"csm-fallback-no-sun": "no-sky-sun",
"csm-fallback-atlas-unavailable": "atlas",
"csm-fallback-zero-cascade": "zero-cascade",
}
CSM_FALLBACK_EVIDENCE_CATEGORIES = tuple(CSM_FALLBACK_SCENE_REASONS)
CSM_FALLBACK_REQUIRED_REASONS = tuple(CSM_FALLBACK_SCENE_REASONS.values())
CSM_SHADOW_EVIDENCE_CATEGORIES = (
*CSM_SKY_SUN_EVIDENCE_CATEGORIES,
*CSM_SHIMMER_EVIDENCE_CATEGORIES,
)
DLIGHT_SHADOW_EVIDENCE_CATEGORIES = (
"world-geometry",
"brush-models",
"entities",
"alpha-tested-surfaces",
"portals-mirrors",
"stress-light-budget",
*CSM_SHADOW_EVIDENCE_CATEGORIES,
*SURFACELIGHT_SPOT_EVIDENCE_CATEGORIES,
*COMBINED_SHADOW_ATLAS_EVIDENCE_CATEGORIES,
*CSM_FALLBACK_EVIDENCE_CATEGORIES,
)
SURFACELIGHT_SPOT_LOD_TILES = {
"low": 128,
"nominal": 256,
"promoted": 512,
}
SURFACELIGHT_SPOT_REQUESTED_TILE_CAP = 512
SURFACELIGHT_SPOT_LOD_MAX_FILL_PERCENT = 85
CSM_SHIMMER_MIN_SAMPLES = 4
CSM_SHIMMER_MAX_GENERATION_DELTA = 1
CSM_SHIMMER_MAX_SNAP_DEPTH_DELTA_MILLI = 1000
CSM_SHIMMER_BASELINE_STEP = "baseline"
CSM_SHIMMER_SCREENSHOT_MAX_RMS = 6.0
CSM_SHIMMER_SCREENSHOT_MAX_CHANGED_PIXEL_RATIO = 0.10
PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n"
COMBINED_SHADOW_ATLAS_SIDECAR_LIGHTS = (
{
"name": "combined-sidecar-spot",
"type": "spot",
"origin": [0.0, 0.0, 768.0],
"direction": [0.0, 0.0, -1.0],
"color": [1.0, 0.82, 0.55],
"intensity": 900.0,
"radius": 2048.0,
"innerAngle": 18.0,
"outerAngle": 48.0,
"castsShadows": True,
"resolution": 256,
"priority": 8.0,
},
)
CSM_SHIMMER_CAMERA_PATH = (
{
"id": "baseline",
"setviewpos": "setviewpos 0.000 0.000 512.000 -10.000 90.000 0.000",
"originDelta": "0 0 0",
"axisDelta": "0 0 0",
},
{
"id": "nudge-forward",
"setviewpos": "setviewpos 0.125 0.000 512.000 -10.000 90.000 0.000",
"originDelta": "0.125 0 0",
"axisDelta": "0 0 0",
},
{
"id": "nudge-side",
"setviewpos": "setviewpos 0.000 0.125 512.000 -10.000 90.000 0.000",
"originDelta": "0 0.125 0",
"axisDelta": "0 0 0",
},
{
"id": "micro-yaw",
"setviewpos": "setviewpos 0.000 0.000 512.000 -10.000 90.030 0.000",
"originDelta": "0 0 0",
"axisDelta": "yaw +0.03",
},
)
DLIGHT_SHADOW_EVIDENCE_SCENES = (
{
"id": "world-geometry",
"map": "q3dm6",
"categories": ("world-geometry",),
"description": "Large retail geometry scene for world caster and receiver coverage.",
"dlight": {"count": 8, "intensity": 720, "distance": 224, "height": 48, "seconds": 0},
},
{
"id": "brush-models",
"map": "q3dm1",
"categories": ("brush-models",),
"description": "Small retail scene with interactive brush-model coverage near player start.",
"dlight": {"count": 6, "intensity": 700, "distance": 192, "height": 48, "seconds": 0},
},
{
"id": "entities",
"map": "q3dm1",
"categories": ("entities",),
"description": "Entity-model dlight shadow coverage with r_dlightMode 2 enabled.",
"dlight": {"count": 8, "intensity": 760, "distance": 208, "height": 56, "seconds": 0},
},
{
"id": "alpha-tested-surfaces",
"map": "q3dm11",
"categories": ("alpha-tested-surfaces",),
"description": "Shader-heavy retail scene for alpha-test and material-stage receivers.",
"dlight": {"count": 8, "intensity": 740, "distance": 224, "height": 48, "seconds": 0},
},
{
"id": "portals-mirrors",
"map": "q3dm17",
"categories": ("portals-mirrors",),
"description": "Open retail scene with portals and mirrors explicitly left enabled.",
"cvars": {"r_noportals": "0", "r_portalOnly": "0"},
"dlight": {"count": 8, "intensity": 720, "distance": 240, "height": 64, "seconds": 0},
},
{
"id": "stress-light-budget",
"map": "q3dm6",
"categories": ("stress-light-budget",),
"description": "Over-budget dynamic-light ring to exercise atlas budget and skip logging.",
"dlight": {"count": 16, "intensity": 900, "distance": 256, "height": 72, "seconds": 0},
},
{
"id": "csm-sky-sun",
"map": "q3dm17",
"categories": CSM_SKY_SUN_EVIDENCE_CATEGORIES,
"description": "Outdoor sky-sun scene for CSM schedule, atlas publication, and cache telemetry evidence.",
"dlight": {"count": 8, "intensity": 720, "distance": 240, "height": 64, "seconds": 0},
},
{
"id": "csm-shimmer-path",
"map": "q3dm17",
"categories": CSM_SHIMMER_EVIDENCE_CATEGORIES,
"description": "Deterministic tiny camera path for CSM snapped-coordinate, cache, and atlas generation churn evidence.",
"dlight": {"count": 4, "intensity": 640, "distance": 192, "height": 48, "seconds": 0},
"csmCameraPath": CSM_SHIMMER_CAMERA_PATH,
},
{
"id": "surfacelight-large-planar",
"map": "q3dm6",
"categories": SURFACELIGHT_SPOT_EVIDENCE_CATEGORIES,
"description": "Large planar q3map_surfaceLight emitters with surfacelight proxies and the 2D spot atlas enabled.",
"dlight": {"count": 8, "intensity": 720, "distance": 224, "height": 64, "seconds": 0},
},
{
"id": COMBINED_SHADOW_ATLAS_SCENE_ID,
"map": "q3dm6",
"categories": COMBINED_SHADOW_ATLAS_EVIDENCE_CATEGORIES,
"description": "One-frame point, static sidecar spot, surfacelight spot, and CSM atlas publication smoke.",
"setviewpos": "setviewpos 0.000 0.000 512.000 -10.000 90.000 0.000",
"dlight": {"count": 8, "intensity": 780, "distance": 224, "height": 56, "seconds": 0},
"sidecarLights": COMBINED_SHADOW_ATLAS_SIDECAR_LIGHTS,
},
{
"id": "csm-fallback-no-world",
"map": "q3dm17",
"categories": ("csm-fallback-no-world",),
"description": "Forced no-world CSM fallback smoke with no CSM atlas or receiver publication.",
"cvars": {"r_csmDebugFallback": "1"},
"dlight": {"count": 4, "intensity": 640, "distance": 192, "height": 48, "seconds": 0},
},
{
"id": "csm-fallback-no-sun",
"map": "q3dm17",
"categories": ("csm-fallback-no-sun",),
"description": "Forced no-sky-sun CSM fallback smoke with no CSM atlas or receiver publication.",
"cvars": {"r_csmDebugFallback": "2"},
"dlight": {"count": 4, "intensity": 640, "distance": 192, "height": 48, "seconds": 0},
},
{
"id": "csm-fallback-atlas-unavailable",
"map": "q3dm17",
"categories": ("csm-fallback-atlas-unavailable",),
"description": "Forced atlas-unavailable CSM fallback smoke with no CSM receiver publication.",
"cvars": {"r_csmDebugFallback": "3"},
"dlight": {"count": 4, "intensity": 640, "distance": 192, "height": 48, "seconds": 0},
},
{
"id": "csm-fallback-zero-cascade",
"map": "q3dm17",
"categories": ("csm-fallback-zero-cascade",),
"description": "Forced zero-cascade CSM fallback smoke with no CSM atlas or receiver publication.",
"cvars": {"r_csmDebugFallback": "4"},
"dlight": {"count": 4, "intensity": 640, "distance": 192, "height": 48, "seconds": 0},
},
)
STARTUP_CVAR_NAMES = {
"developer",
"logfile",
"r_fullscreen",
"r_mode",
"r_customWidth",
"r_customHeight",
"r_fbo",
"r_hdr",
"r_hdrPrecision",
"r_hdrDisplay",
"r_bloom",
"r_motionBlur",
"r_bloom_soft_knee",
"r_ext_multisample",
"r_tonemap",
"r_tonemapExposure",
"r_colorGrade",
"r_colorGradeLift",
"r_colorGradeGamma",
"r_colorGradeGain",
"r_colorGradeWhitePoint",
"r_colorGradeAdaptWhitePoint",
"r_colorGradeLUT",
"r_colorGradeLUTScale",
"r_vbo",
"r_dynamiclight",
"r_dlightMode",
"r_dlightShadows",
"r_dlightShadowDebug",
"r_dlightShadowFilter",
"r_dlightShadowMaxLights",
"r_dlightShadowResolution",
"r_staticLights",
"r_staticLightDebug",
"r_staticLightMaxLights",
"r_staticLightShadows",
"r_staticLightShadowMaxLights",
"r_csmShadows",
"r_csmDebug",
"r_csmDebugFallback",
"r_csmCascadeCount",
"r_csmResolution",
"r_csmShadowFilter",
"r_spotShadows",
"r_spotShadowDebug",
"r_spotShadowMaxLights",
"r_spotShadowResolution",
"r_surfaceLightProxies",
"r_surfaceLightProxyDebug",
"r_surfaceLightProxyShadows",
}
PROFILE_CVARS = {
"baseline": {
"r_fbo": "0",
"r_vbo": "1",
},
"vk-modern": {
"r_fbo": "1",
"r_vbo": "1",
"r_hdr": "1",
"r_bloom": "1",
"r_bloom_soft_knee": "0.5",
"r_ext_multisample": "4",
"r_tonemap": "2",
"r_tonemapExposure": "1.0",
"r_colorGrade": "3",
"r_colorGradeLift": "0 0 0",
"r_colorGradeGamma": "1 1 1",
"r_colorGradeGain": "1 1 1",
"r_colorGradeWhitePoint": "6504",
"r_colorGradeAdaptWhitePoint": "6504",
"r_colorGradeLUTScale": "4.0",
},
"vk-hdr": {
"r_fbo": "1",
"r_vbo": "1",
"r_hdr": "1",
"r_bloom": "1",
"r_bloom_soft_knee": "0.5",
"r_ext_multisample": "4",
"r_tonemap": "2",
"r_tonemapExposure": "1.0",
"r_colorGrade": "3",
"r_colorGradeLift": "0 0 0",
"r_colorGradeGamma": "1 1 1",
"r_colorGradeGain": "1 1 1",
"r_colorGradeWhitePoint": "6504",
"r_colorGradeAdaptWhitePoint": "6504",
"r_colorGradeLUTScale": "4.0",
"r_hdrDisplay": "1",
"r_outputBackend": "3",
"r_hdrDisplayPaperWhite": "203",
"r_hdrDisplayMaxLuminance": "1000",
"r_hdrDisplayMaxCLL": "1000",
"r_hdrDisplayMaxFALL": "400",
},
}
RC_GATE_PRESETS = {
"vk-smoke": {
"description": "Vulkan renderer lifecycle smoke gate for module load, map load, screenshots, and vkinfo diagnostics.",
"defaults": {
"profile": "baseline",
"maps": "q3dm1",
"demos": "",
"timeout": 240.0,
},
"requirements": {
"require_screenshots": True,
"require_vkinfo": True,
},
},
"vk-modern": {
"description": "Modern Vulkan gate for FBO/HDR/bloom/MSAA path, vkinfo counters, GPU timings, and timedemo metrics.",
"defaults": {
"profile": "vk-modern",
"maps": "q3dm1,q3dm17",
"demos": "demo1",
"timeout": 360.0,
"dlight_shadow_scenes": True,
},
"requirements": {
"require_screenshots": True,
"require_vkinfo": True,
"require_gpu_timings": True,
"require_timedemo_metrics": True,
"require_dlight_shadow_scenes": True,
"required_dlight_shadow_categories": DLIGHT_SHADOW_EVIDENCE_CATEGORIES,
"required_surface_light_spot_categories": SURFACELIGHT_SPOT_EVIDENCE_CATEGORIES,
"required_csm_shadow_categories": CSM_SHADOW_EVIDENCE_CATEGORIES,
"require_csm_shimmer_screenshot_diff": True,
"require_combined_shadow_atlas_smoke": True,
"require_csm_fallback_smoke": True,
},
},
"vk-hdr": {
"description": "Native-HDR request gate for the HDR10 swapchain path on capable runtime runners.",
"defaults": {
"profile": "vk-hdr",
"maps": "q3dm1",
"demos": "",
"timeout": 300.0,
},
"requirements": {
"require_screenshots": True,
"require_vkinfo": True,
"require_hdr_request": True,
},
},
}
def split_csv(value: str | None) -> list[str]:
if not value:
return []
return [part.strip() for part in value.split(",") if part.strip()]
def sanitize(value: str) -> str:
cleaned = re.sub(r"[^A-Za-z0-9_.-]+", "-", value.strip())
return cleaned.strip("-") or "item"
def validate_q3_command_token(value: str, option: str) -> str:
token = value.strip()
parts = token.split("/")
if (
not Q3_COMMAND_TOKEN_RE.fullmatch(token)
or any(part in {"", ".", ".."} for part in parts)
):
raise ValueError(f"{option} must contain safe Quake 3 qpath tokens")
return token
def validate_q3_command_tokens(values: list[str], option: str) -> list[str]:
return [validate_q3_command_token(value, option) for value in values]
def validate_fs_game(value: str) -> str:
name = value.strip()
if not name:
return ""
if (
not FS_GAME_RE.fullmatch(name)
or name in {".", ".."}
or name.startswith(".")
or name.endswith(".")
or name.split(".", 1)[0].upper() in WINDOWS_RESERVED_DIR_NAMES
):
raise ValueError("--fs-game must be a single safe mod directory name")
return name
def q3_quote(value: object) -> str:
text = str(value).replace("\\", "/").replace('"', '\\"')
return f'"{text}"'
def q3_path(path: Path) -> str:
return str(path).replace("\\", "/")
def command_to_string(command: list[str]) -> str:
quoted: list[str] = []
for part in command:
if re.search(r"\s", part):
quoted.append('"' + part.replace('"', '\\"') + '"')
else:
quoted.append(part)
return " ".join(quoted)
def game_dir(fs_game: str) -> str:
return fs_game if fs_game else "baseq3"
def parse_extra_sets(values: list[str]) -> dict[str, str]:
result: dict[str, str] = {}
for item in values:
if "=" not in item:
raise ValueError(f"--extra-set expects NAME=VALUE, got {item!r}")
name, value = item.split("=", 1)
name = name.strip()
if not name:
raise ValueError("--extra-set cvar name must not be empty")
if not CVAR_NAME_RE.fullmatch(name):
raise ValueError(f"--extra-set cvar name is not safe: {name!r}")
if any(char in value for char in ("\r", "\n", "\x00", ";")):
raise ValueError(f"--extra-set value for {name!r} contains an unsafe control character")
result[name] = value.strip()
return result
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Run or plan FnQuake3 Vulkan runtime verification gates."
)
parser.add_argument("--gate", choices=sorted(RC_GATE_PRESETS))
parser.add_argument("--list-gates", action="store_true")
parser.add_argument("--exe", type=Path, help="Client executable to launch.")
parser.add_argument(
"--basepath",
type=Path,
help="Game asset basepath. Defaults to the executable directory.",
)
parser.add_argument(
"--homepath",
type=Path,
help="Temporary fs_homepath. Defaults under .tmp/vk-runtime-sweeps/<run-id>/home.",
)
parser.add_argument(
"--output-dir",
type=Path,
default=DEFAULT_SWEEP_ROOT,
help="Sweep output root for configs, logs, manifests, and default homepath.",
)
parser.add_argument("--fs-game", default="")
parser.add_argument("--profile", choices=sorted(PROFILE_CVARS))
parser.add_argument("--maps")
parser.add_argument("--demos")
parser.add_argument("--width", type=int)
parser.add_argument("--height", type=int)
parser.add_argument("--startup-wait", type=int)
parser.add_argument("--map-wait", type=int)
parser.add_argument("--screenshot-wait", type=int)
parser.add_argument("--perf-sample-wait", type=int)
parser.add_argument("--timeout", type=float)
parser.add_argument("--extra-set", action="append", default=[], metavar="NAME=VALUE")
shadow_group = parser.add_mutually_exclusive_group()
shadow_group.add_argument(
"--dlight-shadow-scenes",
dest="dlight_shadow_scenes",
action="store_true",
default=None,
help="Add dedicated r_dlightTest dynamic-light shadow map scenes to the sweep.",
)
shadow_group.add_argument(
"--no-dlight-shadow-scenes",
dest="dlight_shadow_scenes",
action="store_false",
help="Disable dlight shadow scenes requested by a gate preset.",
)
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("--no-map-sweep", action="store_true")
parser.add_argument("--no-demo-sweep", action="store_true")
parser.add_argument("--no-perf-samples", action="store_true")
parser.add_argument("--summary-markdown", type=Path)
return parser.parse_args()
def apply_gate_defaults(args: argparse.Namespace) -> None:
defaults = dict(DEFAULT_OPTIONS)
if args.gate:
defaults.update(RC_GATE_PRESETS[args.gate]["defaults"]) # type: ignore[arg-type]
for name, value in defaults.items():
attr = name
if getattr(args, attr, None) is None:
setattr(args, attr, value)
def validate_runtime_options(args: argparse.Namespace) -> None:
if args.width <= 0 or args.height <= 0:
raise ValueError("--width and --height must be positive")
if not math.isfinite(args.timeout) or args.timeout <= 0:
raise ValueError("--timeout must be finite and positive")
for attr in ("startup_wait", "map_wait", "screenshot_wait", "perf_sample_wait"):
if getattr(args, attr) < 0:
raise ValueError(f"--{attr.replace('_', '-')} must be non-negative")
def int_metric(value: object, default: int = 0) -> int:
if isinstance(value, bool):
return default
try:
return int(value) # type: ignore[arg-type]
except (TypeError, ValueError, OverflowError):
return default
def print_gate_list() -> None:
for name in sorted(RC_GATE_PRESETS):
gate = RC_GATE_PRESETS[name]
defaults = gate["defaults"]
print(f"{name}: {gate['description']}")
print(
" "
f"profile={defaults['profile']} maps={defaults['maps']} demos={defaults['demos'] or '-'}"
f" dlight-shadow-scenes={defaults.get('dlight_shadow_scenes', False)}"
)
def make_cvars(args: argparse.Namespace) -> dict[str, str]:
cvars = dict(COMMON_CVARS)
cvars.update(PROFILE_CVARS[args.profile])
cvars.update(
{
"r_customWidth": str(args.width),
"r_customHeight": str(args.height),
}
)
cvars.update(parse_extra_sets(args.extra_set))
return cvars
def dlight_shadow_scene_cvars(cvars: dict[str, str]) -> dict[str, str]:
shadow_cvars = dict(cvars)
for name, value in DLIGHT_SHADOW_SCENE_CVARS.items():
shadow_cvars.setdefault(name, value)
return shadow_cvars
def dlight_shadow_evidence_scenes() -> list[dict[str, object]]:
scenes: list[dict[str, object]] = []
for scene in DLIGHT_SHADOW_EVIDENCE_SCENES:
copied = {
**scene,
"categories": list(scene["categories"]),
"cvars": dict(scene.get("cvars", {})),
"dlight": dict(scene["dlight"]),
}
if scene.get("csmCameraPath"):
copied["csmCameraPath"] = [
dict(step)
for step in scene.get("csmCameraPath", []) # type: ignore[union-attr]
if isinstance(step, dict)
]
if scene.get("sidecarLights"):
copied["sidecarLights"] = [
dict(light)
for light in scene.get("sidecarLights", []) # type: ignore[union-attr]
if isinstance(light, dict)
]
scenes.append(copied)
return scenes
def dlight_shadow_scene_categories(screenshots: list[dict[str, object]]) -> set[str]:
categories: set[str] = set()
for shot in screenshots:
if not shot.get("shadowScene"):
continue
for category in shot.get("evidenceCategories", []):
text = str(category).strip()
if text:
categories.add(text)
return categories
def write_dlight_shadow_sidecar_lights(
homepath: Path,
fs_game: str,
scenes: list[dict[str, object]],
) -> list[dict[str, object]]:
lights_by_map: dict[str, list[dict[str, object]]] = {}
scene_ids_by_map: dict[str, list[str]] = {}
for scene in scenes:
sidecar_lights = scene.get("sidecarLights", [])
if not isinstance(sidecar_lights, list) or not sidecar_lights:
continue
map_name = str(scene.get("map", "")).strip()
if not map_name:
continue
lights_by_map.setdefault(map_name, []).extend(
dict(light) for light in sidecar_lights if isinstance(light, dict)
)
scene_ids_by_map.setdefault(map_name, []).append(str(scene.get("id", "")))
records: list[dict[str, object]] = []
maps_dir = homepath / game_dir(fs_game) / "maps"
for map_name, lights in sorted(lights_by_map.items()):
if not lights:
continue
path = maps_dir / f"{map_name}.lights.json"
payload = {
"version": 1,
"lights": lights,
}
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(
json.dumps(payload, indent=2, sort_keys=True) + "\n",
encoding="utf-8",
newline="\n",
)
records.append(
{
"map": map_name,
"path": str(path),
"lightCount": len(lights),
"scenes": [scene_id for scene_id in scene_ids_by_map.get(map_name, []) if scene_id],
}
)
return records
def shadow_manager_summary_active(summary: object) -> bool:
if not isinstance(summary, dict) or not summary.get("found"):
return False
maximum = summary.get("max")
if not isinstance(maximum, dict):
return False
def field(name: str) -> int:
return int_metric(maximum.get(name, 0))
return (
field("scheduledPasses") > 0
and field("scheduledMask") > 0
and field("pointScheduled") > 0
and field("pointPublished") > 0
and field("pointPlanned") > 0
and field("pointRecords") > 0
and field("pointAtlasWidth") > 0
and field("pointAtlasHeight") > 0
and field("pointAtlasFaceSize") > 0
)
def surface_light_spot_summary_active(summary: object) -> bool:
if not isinstance(summary, dict) or not summary.get("found"):
return False
maximum = summary.get("max")
if not isinstance(maximum, dict):
return False
def field(name: str) -> int:
return int_metric(maximum.get(name, 0))
return (
field("surfaceSpotCandidates") > 0
and field("surfaceSpotPlans") > 0
and field("surfaceSpotAllocated") > 0
and field("surfaceSpotAtlasWidth") > 0
and field("surfaceSpotAtlasHeight") > 0
and field("surfaceSpotAtlasTileSize") > 0
and field("surfaceSpotFootprintMax") > 0
and field("surfaceSpotCasterRadiusMax") > 0
and field("surfaceSpotTileMax") > 0
)
def surface_light_spot_lod_summary_active(summary: object) -> bool:
return (
isinstance(summary, dict)
and bool(summary.get("found"))
and str(summary.get("status", "")).lower() == "passed"
)
def csm_shadow_runtime_summary_active(summary: object) -> bool:
return (
isinstance(summary, dict)
and bool(summary.get("found"))
and str(summary.get("status", "")).lower() == "passed"
)
def combined_shadow_atlas_summary_active(summary: object) -> bool:
return (
isinstance(summary, dict)
and bool(summary.get("found"))
and str(summary.get("status", "")).lower() == "passed"
)
def shadow_profile_summary_active(summary: object) -> bool:
return (
isinstance(summary, dict)
and bool(summary.get("found"))
and bool(summary.get("profileReady"))
and str(summary.get("status", "")).lower() == "passed"
)
def combined_shadow_atlas_summary(dlight_shadow: object) -> dict[str, object]:
if not isinstance(dlight_shadow, dict):
return {