euv-core 0.52.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
/// Fallback device label when executing on headless or software-only hosts.
pub const GPU_DEVICE_FALLBACK: &str = "euv-software-fallback";
/// Device label for Web WebGL2 / WebGPU browsers.
pub const GPU_DEVICE_WEB: &str = "Browser WebGL2 / WebGPU";
/// Device label when Windows Direct3D 12 runtime is present.
pub const GPU_DEVICE_D3D12: &str = "Windows Direct3D 12";
/// Device label when Vulkan ICD runtime is present.
pub const GPU_DEVICE_VULKAN: &str = "Vulkan Physical GPU";
/// Number of hardware-fenced staging ring buffer slots used by `NativeGpuDriver` (triple-buffered).
pub const GPU_DRIVER_RING_SLOTS: usize = 3;
/// Maximum disjoint dirty rectangles emitted in a single `MultiRect` upload plan before merging.
pub const MOBILE_MAX_MULTI_UPLOAD_RECTS: usize = 12;
/// Equivalent byte cost per texture sub-rectangle upload driver call (`glTexSubImage2D` / `MTLTexture.replaceRegion`).
pub const MOBILE_UPLOAD_PER_RECT_OVERHEAD_BYTES: usize = 16_384;
/// Coverage ratio threshold (`0.70`) above which a full-frame upload beats sub-rectangle stride overhead.
pub const MOBILE_UPLOAD_FULL_FRAME_COVERAGE_THRESHOLD: f32 = 0.70;
/// Pixel gap tolerance (`4` px) used to coalesce nearly adjacent dirty rectangles before upload cost comparison.
pub const MOBILE_UPLOAD_COALESCE_PAD_PX: u32 = 4;
/// OpenGL ES 3.0 / WebGL 2 fullscreen triangle vertex shader paired with `GLSL_ES3_BACKDROP_BLUR_FRAGMENT_SHADER`.
pub const GLSL_ES3_BACKDROP_BLUR_VERTEX_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
out highp vec2 v_uv;\n\
void main() {\n\
    vec2 p = vec2((gl_VertexID == 1) ? 3.0 : -1.0, (gl_VertexID == 2) ? 3.0 : -1.0);\n\
    gl_Position = vec4(p, 0.0, 1.0);\n\
    v_uv = vec2(p.x * 0.5 + 0.5, p.y * 0.5 + 0.5);\n\
}\n";
/// Unobservable timing status label for simulator or headless hosts lacking compositor present timestamps.
pub const MOBILE_TIMING_UNOBSERVABLE_REASON_SIMULATOR: &str = "simulator_compositor_unobservable";
/// Unobservable timing status label when an OS driver does not expose presentation timestamps.
pub const MOBILE_TIMING_UNOBSERVABLE_REASON_UNSUPPORTED: &str = "presentation_time_unsupported";
/// Fullscreen triangle vertex shader for WebGL2 GPU-composited framebuffer/dirty-rect presentation (`highp` positions).
pub const WEB_GL2_BLIT_VERT_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
void main() {\n\
    vec2 pos = vec2((gl_VertexID == 1) ? 3.0 : -1.0, (gl_VertexID == 2) ? 3.0 : -1.0);\n\
    gl_Position = vec4(pos, 0.0, 1.0);\n\
}\n";
/// Fullscreen triangle fragment shader presenting the uploaded RGBA8 WebGL2 texture bit-exactly.
///
/// Uses `highp` math and integer `texelFetch` keyed on `gl_FragCoord` when the drawing buffer matches the
/// texture 1:1, so FP16 `mediump` varyings on mobile GPUs can never quantize UVs into blocky mosaics. Falls back
/// to `highp` normalized `GL_LINEAR` sampling only when the drawing buffer and texture sizes differ.
pub const WEB_GL2_BLIT_FRAG_SHADER: &str = "#version 300 es\n\
precision highp float;\n\
precision highp int;\n\
precision highp sampler2D;\n\
uniform highp sampler2D u_tex;\n\
uniform highp vec2 u_view;\n\
out highp vec4 out_color;\n\
void main() {\n\
    ivec2 tex_size = textureSize(u_tex, 0);\n\
    highp vec2 view = max(u_view, vec2(1.0));\n\
    ivec2 view_size = ivec2(view + vec2(0.5));\n\
    if (tex_size == view_size) {\n\
        ivec2 texel = ivec2(int(gl_FragCoord.x), tex_size.y - 1 - int(gl_FragCoord.y));\n\
        out_color = texelFetch(u_tex, clamp(texel, ivec2(0), tex_size - ivec2(1)), 0);\n\
    } else {\n\
        highp vec2 uv = vec2(gl_FragCoord.x, view.y - gl_FragCoord.y) / view;\n\
        out_color = texture(u_tex, uv);\n\
    }\n\
}\n";

/// Photorealistic ocean optical WGSL shader (Gerstner swells, Schlick Fresnel, GGX sun glitter, ACES filmic) for WebGPU targets.
pub const WGSL_FLUID_OCEAN_SHADER: &str = r#"struct OceanUniforms {
    viewport_time_agitation: vec4<f32>,
    sun_dir_horizon: vec4<f32>,
    roll_cos_sin_pad: vec4<f32>,
};
@group(0) @binding(0) var<uniform> u_ocean: OceanUniforms;
struct OceanVertOut {
    @builtin(position) pos: vec4<f32>,
    @location(0) uv: vec2<f32>,
};
@vertex
fn euv_ocean_vertex(@builtin(vertex_index) vid: u32) -> OceanVertOut {
    let px = select(-1.0, 3.0, vid == 1u);
    let py = select(-1.0, 3.0, vid == 2u);
    var out: OceanVertOut;
    out.pos = vec4<f32>(px, py, 0.0, 1.0);
    out.uv = vec2<f32>(px * 0.5 + 0.5, 0.5 - py * 0.5);
    return out;
}
fn euv_ocean_aces(hdr: vec3<f32>) -> vec3<f32> {
    let num = hdr * (2.51 * hdr + 0.03);
    let den = hdr * (2.43 * hdr + 0.59) + 0.14;
    return clamp(num / max(den, vec3<f32>(0.0001)), vec3<f32>(0.0), vec3<f32>(1.0));
}
@fragment
fn euv_ocean_fragment(in: OceanVertOut) -> @location(0) vec4<f32> {
    let sim_time = u_ocean.viewport_time_agitation.z;
    let agitation = max(u_ocean.viewport_time_agitation.w, 1.0);
    let sun_dir = normalize(u_ocean.sun_dir_horizon.xyz);
    let horizon_v = u_ocean.sun_dir_horizon.w;
    let ray = normalize(vec3<f32>((in.uv.x - 0.5) * 2.0, (horizon_v - in.uv.y) * 2.0, 1.62));
    var col = vec3<f32>(0.0);
    if (ray.y >= 0.0) {
        let sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
        let glow = pow(sdot, 16.0);
        let disk = smoothstep(0.9992, 0.9997, sdot);
        let sky_t = smoothstep(0.0, 0.55, ray.y);
        let horiz = vec3<f32>(0.16, 0.17, 0.19) + vec3<f32>(0.68, 0.48, 0.22) * glow;
        col = mix(horiz, vec3<f32>(0.01, 0.015, 0.024), sky_t) + vec3<f32>(3.2, 2.7, 2.0) * disk;
    } else {
        let dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
        let wp = ray.xz * dist;
        let w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
        let w1 = sin(-wp.x * 0.19 + wp.y * 1.06 + sim_time * 1.18) * 0.15 * agitation;
        let norm = normalize(vec3<f32>(-(w0 * 0.12 - w1 * 0.20), 1.0, -(w0 * 0.62 + w1 * 1.06)));
        let vdir = -ray;
        let ndv = clamp(dot(norm, vdir), 0.002, 1.0);
        let fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
        let hvec = normalize(vdir + sun_dir);
        let ndh = max(dot(norm, hvec), 0.0);
        let den = ndh * ndh * (0.00018 - 1.0) + 1.0;
        let ggx = min(0.00018 / (3.14159265 * den * den), 24.0);
        let body = vec3<f32>(0.0004, 0.052, 0.086) + vec3<f32>(0.002, 0.34, 0.43) * clamp(w0 + w1 + 0.12, 0.0, 1.0) * exp(-dist * 0.05);
        col = mix(body, vec3<f32>(0.02, 0.09, 0.16), fresnel * 0.58) + vec3<f32>(1.16, 1.02, 0.82) * ggx * 0.55;
    }
    return vec4<f32>(pow(euv_ocean_aces(col), vec3<f32>(1.0 / 2.2)), 1.0);
}
"#;
/// Photorealistic ocean optical Apple Metal (MSL) shader compiled into a resident `MTLRenderPipelineState` during precompilation.
pub const MSL_FLUID_OCEAN_SHADER: &str = r#"#include <metal_stdlib>
using namespace metal;
struct OceanUniforms {
    float4 viewport_time_agitation;
    float4 sun_dir_horizon;
    float4 roll_cos_sin_pad;
};
struct OceanVertOut {
    float4 pos [[position]];
    float2 uv;
};
vertex OceanVertOut euv_ocean_vertex(uint vid [[vertex_id]]) {
    float2 pos = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
    OceanVertOut out;
    out.pos = float4(pos, 0.0, 1.0);
    out.uv = float2(pos.x * 0.5 + 0.5, 0.5 - pos.y * 0.5);
    return out;
}
static inline float3 euv_ocean_aces(float3 hdr) {
    float3 num = hdr * (2.51 * hdr + 0.03);
    float3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
    return clamp(num / max(den, float3(0.0001)), float3(0.0), float3(1.0));
}
fragment float4 euv_ocean_fragment(
    OceanVertOut in [[stage_in]],
    constant OceanUniforms& u [[buffer(0)]]
) {
    float sim_time = u.viewport_time_agitation.z;
    float agitation = max(u.viewport_time_agitation.w, 1.0);
    float3 sun_dir = normalize(u.sun_dir_horizon.xyz);
    float horizon_v = u.sun_dir_horizon.w;
    float2 centered = float2((in.uv.x - 0.5) * 2.0, (horizon_v - in.uv.y) * 2.0);
    float3 ray = normalize(float3(centered.x, centered.y, 1.62));
    float3 color;
    if (ray.y >= 0.0) {
        float sun_dot = clamp(dot(ray, sun_dir), 0.0, 1.0);
        float glow = pow(sun_dot, 16.0);
        float disk = smoothstep(0.9992, 0.9997, sun_dot);
        float sky_t = smoothstep(0.0, 0.55, ray.y);
        float3 horiz = float3(0.16, 0.17, 0.19) + float3(0.68, 0.48, 0.22) * glow;
        float3 zenith = float3(0.01, 0.015, 0.024);
        color = mix(horiz, zenith, sky_t) + float3(3.2, 2.7, 2.0) * disk;
    } else {
        float dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
        float2 wp = ray.xz * dist;
        float w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
        float w1 = sin(-wp.x * 0.19 + wp.y * 1.06 + sim_time * 1.18) * 0.15 * agitation;
        float3 norm = normalize(float3(-(w0 * 0.12 - w1 * 0.20), 1.0, -(w0 * 0.62 + w1 * 1.06)));
        float3 view_dir = -ray;
        float ndv = clamp(dot(norm, view_dir), 0.002, 1.0);
        float fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
        float3 half_vec = normalize(view_dir + sun_dir);
        float ndh = max(dot(norm, half_vec), 0.0);
        float denom = ndh * ndh * (0.00018 - 1.0) + 1.0;
        float ggx = min(0.00018 / (3.14159265 * denom * denom), 24.0);
        float3 body = float3(0.0004, 0.052, 0.086) + float3(0.002, 0.34, 0.43) * clamp(w0 + w1 + 0.12, 0.0, 1.0) * exp(-dist * 0.05);
        float3 sky_refl = float3(0.02, 0.09, 0.16);
        color = mix(body, sky_refl, fresnel * 0.58) + float3(1.16, 1.02, 0.82) * ggx * 0.55;
    }
    float3 ldr = pow(euv_ocean_aces(color), float3(1.0 / 2.2));
    return float4(ldr, 1.0);
}
"#;
/// Photorealistic ocean optical GLSL ES 3.0 fragment shader for WebGL2, Android, and HarmonyOS targets.
pub const GLSL_ES3_FLUID_OCEAN_FRAGMENT_SHADER: &str = r#"#version 300 es
precision highp float;
in highp vec2 v_uv;
uniform highp vec4 u_viewport_time_agitation;
uniform highp vec4 u_sun_dir_horizon;
out vec4 out_color;
vec3 euv_ocean_aces(vec3 hdr) {
    vec3 num = hdr * (2.51 * hdr + 0.03);
    vec3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
    return clamp(num / max(den, vec3(0.0001)), vec3(0.0), vec3(1.0));
}
void main() {
    float sim_time = u_viewport_time_agitation.z;
    float agitation = max(u_viewport_time_agitation.w, 1.0);
    vec3 sun_dir = normalize(u_sun_dir_horizon.xyz);
    vec3 ray = normalize(vec3((v_uv.x - 0.5) * 2.0, (u_sun_dir_horizon.w - v_uv.y) * 2.0, 1.62));
    vec3 color;
    if (ray.y >= 0.0) {
        float sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
        color = mix(vec3(0.16, 0.17, 0.19) + vec3(0.68, 0.48, 0.22) * pow(sdot, 16.0), vec3(0.01, 0.015, 0.024), smoothstep(0.0, 0.55, ray.y));
    } else {
        float dist = min(1.42 / max(-ray.y, 0.0024), 240.0);
        vec2 wp = ray.xz * dist;
        float w0 = sin(wp.x * 0.05 + wp.y * 0.62 + sim_time * 0.88) * 0.22 * agitation;
        vec3 norm = normalize(vec3(-w0 * 0.12, 1.0, -w0 * 0.62));
        float ndv = clamp(dot(norm, -ray), 0.002, 1.0);
        float fresnel = clamp(0.0204 + 0.9796 * pow(1.0 - ndv, 5.0), 0.022, 0.88);
        color = mix(vec3(0.0004, 0.052, 0.086), vec3(0.02, 0.09, 0.16), fresnel * 0.58);
    }
    out_color = vec4(pow(euv_ocean_aces(color), vec3(1.0 / 2.2)), 1.0);
}
"#;
/// Photorealistic ocean optical HLSL Shader Model 6.0 shader for Windows Direct3D 12 targets.
pub const HLSL_FLUID_OCEAN_SHADER: &str = r#"cbuffer OceanUniforms : register(b0) {
    float4 viewport_time_agitation;
    float4 sun_dir_horizon;
    float4 roll_cos_sin_pad;
};
struct OceanVertOut {
    float4 pos : SV_Position;
    float2 uv : TEXCOORD0;
};
OceanVertOut euv_ocean_vertex(uint vid : SV_VertexID) {
    float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
    OceanVertOut o;
    o.pos = float4(p, 0.0, 1.0);
    o.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
    return o;
}
float3 euv_ocean_aces(float3 hdr) {
    float3 num = hdr * (2.51 * hdr + 0.03);
    float3 den = hdr * (2.43 * hdr + 0.59) + 0.14;
    return saturate(num / max(den, float3(0.0001, 0.0001, 0.0001)));
}
float4 euv_ocean_fragment(OceanVertOut i) : SV_Target {
    float3 sun_dir = normalize(sun_dir_horizon.xyz);
    float3 ray = normalize(float3((i.uv.x - 0.5) * 2.0, (sun_dir_horizon.w - i.uv.y) * 2.0, 1.62));
    float3 col = (ray.y >= 0.0) ? lerp(float3(0.16, 0.17, 0.19), float3(0.01, 0.015, 0.024), smoothstep(0.0, 0.55, ray.y)) : float3(0.002, 0.08, 0.12);
    return float4(pow(euv_ocean_aces(col), 1.0 / 2.2), 1.0);
}
"#;
/// Unified hardware GPU Ocean + Origami Boat and Instanced 3D PBR Open-World Apple Metal (MSL) shader suite.
pub const MSL_GPU_SCENE_SHADER: &str = r#"#include <metal_stdlib>
using namespace metal;
struct GpuOceanUniform {
    float4 time_agit_hor_aspect;
    float4 roll_boat_uv;
    float4 sun_dir_wake;
    float4 view_dims;
};
struct GpuOceanOut {
    float4 pos [[position]];
    float2 uv;
};
struct GpuBoatVert {
    float4 pos_ndc;
    float4 color;
};
struct GpuBoatOut {
    float4 pos [[position]];
    float4 color;
};
struct GpuWorld3dUniform {
    float4x4 view_proj;
    float4 camera_pos;
    float4 sun_dir_fog;
    float4 sun_color_ambient;
    float4 sky_horizon_tod;
    float4 sky_zenith_aspect;
};
struct GpuWorld3dVert {
    float4 position;
    float4 normal;
    float4 color_submat;
};
struct GpuWorld3dInst {
    float4x4 model;
    float4 albedo_metallic;
    float4 emissive_roughness;
};
struct GpuWorld3dOut {
    float4 pos [[position]];
    float3 world_pos;
    float3 world_normal;
    float4 base_metallic;
    float4 emissive_rough;
    float submat_mode;
    float detail_mode;
};
static inline float3 euv_scene_aces(float3 hdr) {
    float3 x = max(hdr, float3(0.0));
    float luma = dot(x, float3(0.2126, 0.7152, 0.0722));
    float sat_roll = 1.0 / (1.0 + luma * 0.14);
    float3 agx_in = mix(float3(luma), x, 0.78 + 0.22 * sat_roll);
    float3 num = agx_in * (2.51 * agx_in + 0.03);
    float3 den = agx_in * (2.43 * agx_in + 0.59) + 0.14;
    return pow(clamp(num / max(den, float3(0.0001)), float3(0.0), float3(1.0)), float3(1.0 / 2.2));
}
static inline float euv_hash_i2(int2 cell) {
    uint n = as_type<uint>(cell.x) * 374761393u + as_type<uint>(cell.y) * 668265263u;
    n = (n ^ (n >> 13u)) * 1274126177u;
    n ^= n >> 16u;
    return float(n & 0x00FFFFFFu) * (1.0 / 16777215.0);
}
static inline float euv_scene_hash(float2 p) {
    return euv_hash_i2(int2(floor(p)));
}
static inline float euv_scene_noise(float2 p) {
    float2 fl = floor(p);
    float2 f = p - fl;
    float2 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);
    int2 i = int2(fl);
    float a = euv_hash_i2(i);
    float b = euv_hash_i2(i + int2(1, 0));
    float c = euv_hash_i2(i + int2(0, 1));
    float d = euv_hash_i2(i + int2(1, 1));
    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
static inline float euv_cloud_fbm(float2 p, int octs) {
    float val = 0.0;
    float amp = 0.54;
    float2 q = p;
    for (int i = 0; i < octs; ++i) {
        val += euv_scene_noise(q) * amp;
        q = float2(q.x * 1.92 - q.y * 0.58 + 3.1, q.x * 0.58 + q.y * 1.92 - 1.7);
        amp *= 0.50;
    }
    return clamp(val, 0.0, 1.0);
}
static inline float3 euv_ocean_sky(float3 ray, float3 sun_dir, float sim_time, bool high_detail) {
    float ry = max(ray.y, 0.0);
    float sdot = clamp(dot(ray, sun_dir), 0.0, 1.0);
    float sp2 = sdot * sdot;
    float sp4 = sp2 * sp2;
    float sp16 = sp4 * sp4 * sp4 * sp4;
    float sp64 = sp16 * sp16 * sp16 * sp16;
    float az = clamp(dot(normalize(float2(ray.x, ray.z)), normalize(float2(sun_dir.x, sun_dir.z))), 0.0, 1.0);
    float az2 = az * az;
    float sun_az_glow = az2 * az2;
    float disk = smoothstep(0.99905, 0.99968, sdot);
    float corona = exp(-(1.0 - sdot) * 460.0);
    float sky_t = smoothstep(0.0, 0.56, ry);
    float3 horiz = float3(0.14, 0.13, 0.17) + float3(0.76, 0.40, 0.17) * sp16 + float3(1.18, 0.82, 0.44) * sp64;
    float3 zenith = float3(0.010, 0.022, 0.048);
    float3 base_sky = mix(horiz, zenith, sky_t);
    float horiz_clear = smoothstep(0.002, 0.035, ry);
    if (horiz_clear > 0.001) {
        float strat_y = pow(ry, 0.62) * 3.95;
        float2 base_c = float2(ray.x * (1.68 + 0.42 * (1.0 - min(ry, 1.0))) + sim_time * 0.015, strat_y * 2.28 + sim_time * 0.007);
        float warp_a = euv_scene_noise(base_c * float2(0.62, 0.72) + float2(3.1, -1.4));
        float warp_b = high_detail ? euv_scene_noise(base_c * float2(1.60, 1.85) + float2(-2.3, 5.7)) : 0.5;
        float2 c_uv = base_c + float2((warp_a - 0.5) * 1.10 + (warp_b - 0.5) * 0.36, (warp_a - 0.5) * 0.62 - (warp_b - 0.5) * 0.20);
        float cloud_raw = euv_cloud_fbm(c_uv, high_detail ? 4 : 2);
        float billow = 0.0;
        float wisp_ridge = 0.0;
        if (high_detail) {
            float g1 = euv_scene_noise(c_uv * float2(3.10, 4.40) + float2(8.4, -3.9));
            float r_raw = 1.0 - abs(euv_scene_noise(c_uv * float2(5.2, 8.4) + float2(1.9, -2.6)) * 2.0 - 1.0);
            billow = g1 * 0.14;
            wisp_ridge = r_raw * r_raw * 0.09;
        }
        float cloud_field = clamp(cloud_raw * 0.78 + billow + wisp_ridge, 0.0, 1.0);
        float overhead = smoothstep(0.04, 0.26, ry);
        float clearing = sun_az_glow * exp(-ry * 7.0) * 0.56;
        float cloud_cov = smoothstep(0.25, 0.68, cloud_field + overhead * 0.34 - clearing);
        float cloud_dark = (0.52 + 0.40 * overhead) * cloud_cov;
        float rim_sample = high_detail ? euv_cloud_fbm(c_uv + float2(sun_dir.x * 0.32, 0.18), 2) : (cloud_field * 0.90);
        float edge_lacy = 1.0 - abs(cloud_cov * 2.0 - 1.0);
        float sun_lit_edge = (clamp((cloud_field - rim_sample) * 3.0 + 0.12, 0.0, 1.0) + edge_lacy * edge_lacy * 0.36) * (0.16 + 0.84 * sun_az_glow) * (1.0 - overhead * 0.58);
        float wisp_tex = high_detail ? ((cloud_field - 0.5) * 0.042 + wisp_ridge * 0.12) : 0.0;
        float3 cloud_col = high_detail
            ? max(float3(0.006, 0.010, 0.018), float3(0.012, 0.018, 0.028) + float3(0.046, 0.056, 0.076) * (1.0 - cloud_dark) + float3(0.82, 0.94, 1.08) * wisp_tex + float3(0.84 + 0.54 * sp4, 0.58 + 0.36 * sp4, 0.30 + 0.16 * sp4) * sun_lit_edge)
            : (float3(0.004, 0.018, 0.036) + float3(0.016, 0.056, 0.094) * (1.0 - cloud_dark) + float3(0.42 + 0.26 * sp4, 0.34 + 0.20 * sp4, 0.24 + 0.14 * sp4) * sun_lit_edge);
        float cloud_alpha = clamp(cloud_cov * (0.72 + 0.24 * overhead) * horiz_clear, 0.0, 0.96);
        base_sky = mix(base_sky, cloud_col, cloud_alpha);
    }
    if (high_detail) {
        base_sky += float3(4.2, 3.35, 2.30) * disk + float3(1.15, 0.78, 0.42) * (corona * 0.95);
    }
    return base_sky;
}
vertex GpuOceanOut euv_scene_ocean_vert(uint vid [[vertex_id]]) {
    float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
    GpuOceanOut out;
    out.pos = float4(p, 0.0, 1.0);
    out.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
    return out;
}
fragment float4 euv_scene_ocean_frag(
    GpuOceanOut in [[stage_in]],
    constant GpuOceanUniform& u [[buffer(0)]],
    texture2d<float> wake_tex [[texture(0)]]
) {
    constexpr sampler s_lin(address::clamp_to_edge, filter::linear);
    const float INV_TAU = 0.15915494;
    const float TAU = 6.283185307;
    float sim_time = u.time_agit_hor_aspect.x;
    float agitation = max(u.time_agit_hor_aspect.y, 1.0);
    float horizon_v = u.time_agit_hor_aspect.z;
    float aspect = max(u.time_agit_hor_aspect.w, 0.25);
    float roll_cos = u.roll_boat_uv.x;
    float roll_sin = u.roll_boat_uv.y;
    float2 boat_uv = u.roll_boat_uv.zw;
    float3 sun_dir = normalize(u.sun_dir_wake.xyz);
    float wake_active = u.sun_dir_wake.w;
    float raw_dx = (in.uv.x - 0.5) * 2.0 * aspect;
    float raw_dy = (horizon_v - in.uv.y) * 2.0;
    float rx_u = raw_dx * roll_cos + raw_dy * roll_sin;
    float ry_u = -raw_dx * roll_sin + raw_dy * roll_cos;
    float3 ray_u = float3(rx_u, ry_u, 1.62);
    float inv_rlen = rsqrt(dot(ray_u, ray_u));
    float3 ray = ray_u * inv_rlen;
    float inv_res_y = (u.view_dims.y > 0.5) ? u.view_dims.w : max(abs(dfdy(in.uv.y)), 1.0 / 16384.0);
    float d_ry = (2.0 * inv_res_y) * inv_rlen * max(1.0 - ray.y * ray.y, 0.15);
    float d_rx = (2.0 * inv_res_y) * inv_rlen;
    float3 hdr;
    if (ray.y >= 0.0) {
        hdr = euv_ocean_sky(ray, sun_dir, sim_time, true);
    } else {
        float neg_ry_true = max(-ray.y, 1.0e-4);
        float dist_true = 1.42 / neg_ry_true;
        float dist = min(dist_true, 600.0);
        float px_span_z = dist_true * (d_ry / neg_ry_true);
        float px_span_x = dist_true * d_rx;
        float px_span = max(px_span_z, px_span_x);
        float2 wp0 = ray.xz * dist;
        if (dist < 18.0) {
            float p_fade = 1.0 - smoothstep(10.0, 18.0, dist);
            float t0 = fract(sim_time * 0.84 * INV_TAU);
            float ph0 = (fract(dot(wp0, float2(0.2419, 0.9703)) * 0.56 * INV_TAU) + t0) * TAU;
            float h_p = 0.205 * agitation * (exp(-(1.0 - sin(ph0))) - 0.42) * p_fade;
            dist = clamp((1.42 - h_p) / neg_ry_true, 0.5, 600.0);
            wp0 = ray.xz * dist;
        }
        const float4 waves[8] = {
            float4( 0.2419,  0.9703,  0.56, 0.205),
            float4(-0.5592,  0.8290,  0.94, 0.145),
            float4( 0.7986,  0.6018,  1.58, 0.092),
            float4(-0.9455,  0.3256,  2.63, 0.056),
            float4( 0.5299,  0.8480,  4.38, 0.034),
            float4(-0.7880, -0.6157,  7.21, 0.021),
            float4( 0.7314, -0.6820, 11.85, 0.013),
            float4(-0.3746,  0.9272, 19.30, 0.0078)
        };
        const float speeds[8] = { 0.84, 1.12, 1.48, 1.92, 2.46, 3.08, 3.82, 4.68 };
        float2 fwd_xz = normalize(ray.xz);
        float2 right_xz = float2(fwd_xz.y, -fwd_xz.x);
        float2 wp = wp0;
        float h = 0.0;
        float2 grad = float2(0.0);
        float crest_acc = 0.0;
        float normal_var = 0.0009;
        for (int wi = 0; wi < 8; ++wi) {
            float2 wdir = waves[wi].xy;
            float freq = waves[wi].z;
            float amp = waves[wi].w * agitation;
            float w_span = max(max(abs(dot(wdir, fwd_xz)) * px_span_z, abs(dot(wdir, right_xz)) * px_span_x), px_span_z * 0.55);
            float nyq = freq * w_span * 2.25;
            float aa_w = (nyq < 4.5) ? exp(-0.5 * nyq * nyq) : 0.0;
            float rms_s = waves[wi].w * min(agitation, 1.45) * freq;
            normal_var += 0.10 * rms_s * rms_s * (1.0 - aa_w * aa_w);
            if (aa_w > 0.0005) {
                float t_ph = fract(sim_time * speeds[wi] * INV_TAU);
                float s_ph = fract(dot(wp, wdir) * freq * INV_TAU);
                float ph = (s_ph + t_ph) * TAU;
                float cp;
                float sp = sincos(ph, cp);
                float steep_k = 0.42 + 0.58 * aa_w;
                float sharp_e = exp(-(1.0 - sp) * steep_k);
                h += amp * (sharp_e - 0.42) * aa_w;
                float slope = amp * freq * steep_k * sharp_e * cp * aa_w;
                grad += wdir * slope;
                crest_acc += sharp_e * amp * aa_w;
                wp += wdir * (cp * amp * 0.78 * aa_w);
            }
        }
        float near_steep = 1.0 + 0.36 * exp(-dist * 0.082);
        grad *= near_steep;
        float cap_nyq1 = px_span * 14.5 * 2.25;
        float cap_aa1 = (cap_nyq1 < 4.5) ? exp(-0.5 * cap_nyq1 * cap_nyq1) : 0.0;
        normal_var += 0.0012 * (1.0 - cap_aa1 * cap_aa1) * min(agitation, 1.45);
        if (cap_aa1 > 0.001) {
            float p1a = (fract(dot(wp0, float2( 0.8572,  0.5150)) * 14.2 * INV_TAU) + fract(sim_time * 3.7 * INV_TAU)) * TAU;
            float p1b = (fract(dot(wp0, float2(-0.4226,  0.9063)) * 18.7 * INV_TAU) + fract(sim_time * 4.4 * INV_TAU)) * TAU;
            float p1c = (fract(dot(wp0, float2( 0.9613, -0.2756)) * 23.4 * INV_TAU) + fract(sim_time * 5.1 * INV_TAU)) * TAU;
            float g1a = cos(p1a) * 0.044 * cap_aa1 * agitation;
            float g1b = cos(p1b) * 0.036 * cap_aa1 * agitation;
            float g1c = cos(p1c) * 0.028 * cap_aa1 * agitation;
            grad += float2(0.8572, 0.5150) * g1a + float2(-0.4226, 0.9063) * g1b + float2(0.9613, -0.2756) * g1c;
        }
        float cap_nyq2 = px_span * 34.0 * 2.25;
        float cap_aa2 = (cap_nyq2 < 4.5) ? exp(-0.5 * cap_nyq2 * cap_nyq2) : 0.0;
        normal_var += 0.0006 * (1.0 - cap_aa2 * cap_aa2) * min(agitation, 1.45);
        if (cap_aa2 > 0.001) {
            float p2a = (fract(dot(wp0, float2(-0.7547, -0.6561)) * 31.8 * INV_TAU) + fract(sim_time * 6.2 * INV_TAU)) * TAU;
            float p2b = (fract(dot(wp0, float2( 0.2924, -0.9563)) * 41.3 * INV_TAU) + fract(sim_time * 7.3 * INV_TAU)) * TAU;
            float g2a = cos(p2a) * 0.022 * cap_aa2 * agitation;
            float g2b = cos(p2b) * 0.016 * cap_aa2 * agitation;
            grad += float2(-0.7547, -0.6561) * g2a + float2(0.2924, -0.9563) * g2b;
        }
        normal_var = clamp(normal_var + min(px_span * 0.006, 0.016), 0.0005, 0.036);
        float wake_foam = 0.0;
        if (wake_active > 0.001) {
            float2 wake_uv = clamp(in.uv, float2(0.5 / 96.0, 0.5 / 72.0), float2(1.0 - 0.5 / 96.0, 1.0 - 0.5 / 72.0));
            float4 wk = wake_tex.sample(s_lin, wake_uv);
            float2 edge_d = min(in.uv, float2(1.0) - in.uv);
            float edge_win = smoothstep(0.0, 0.045, edge_d.x) * smoothstep(0.0, 0.045, edge_d.y);
            float w_gain = clamp(wake_active, 0.0, 1.0) * edge_win;
            float2 flow = clamp((wk.rg - float2(128.0 / 255.0)) * 4.0 * 0.22, float2(-0.20), float2(0.20)) * w_gain;
            grad += flow;
            wake_foam = wk.b * w_gain;
        }
        float2 raw_bd = float2((in.uv.x - boat_uv.x) * aspect, in.uv.y - boat_uv.y);
        float2 rot_bd = float2(raw_bd.x * roll_cos - raw_bd.y * roll_sin, raw_bd.x * roll_sin + raw_bd.y * roll_cos);
        float2 boat_local = float2(rot_bd.x / 0.145, rot_bd.y / 0.036);
        float boat_ring_d2 = dot(boat_local, boat_local);
        if (boat_ring_d2 > 0.30 && boat_ring_d2 < 12.8) {
            float r_hull = sqrt(boat_ring_d2);
            float rip_env = exp(-max(r_hull - 0.85, 0.0) * 1.08) * smoothstep(0.55, 0.92, r_hull);
            float rip_ph = (fract(r_hull * 16.5 * INV_TAU) - fract(sim_time * 4.2 * INV_TAU)) * TAU;
            float rip_wave = cos(rip_ph) * 0.34 * rip_env;
            float inv_rh = 1.0 / max(r_hull, 0.1);
            grad += float2(boat_local.x * inv_rh * rip_wave, boat_local.y * inv_rh * rip_wave * 1.38);
        }
        float3 norm = normalize(float3(-grad.x, 1.0, -grad.y));
        float3 view_dir = -ray;
        float ndv = clamp(dot(norm, view_dir), 0.005, 1.0);
        float om_nv = 1.0 - ndv;
        float om_nv2 = om_nv * om_nv;
        float fresnel = clamp(0.0204 + (0.94 - min(normal_var * 1.8, 0.32)) * (om_nv2 * om_nv2 * om_nv), 0.022, 0.90);
        float3 refl_dir = reflect(ray, norm);
        refl_dir.y = max(refl_dir.y, 0.008);
        float3 sky_refl = euv_ocean_sky(normalize(refl_dir), sun_dir, sim_time, false);
        float3 half_vec = normalize(view_dir + sun_dir);
        float ndl = max(dot(norm, sun_dir), 0.0);
        float ndh = max(dot(norm, half_vec), 0.0);
        float vdh = clamp(dot(view_dir, half_vec), 0.0, 1.0);
        float om_vh = 1.0 - vdh;
        float om_vh2 = om_vh * om_vh;
        float fresnel_h = 0.0204 + 0.9796 * (om_vh2 * om_vh2 * om_vh);
        float a1_sq = 0.00045 + normal_var * 0.22;
        float d1 = ndh * ndh * (a1_sq - 1.0) + 1.0;
        float ndf1 = a1_sq / max(3.14159265 * d1 * d1, 1.0e-5);
        float k1 = sqrt(a1_sq) * 0.5;
        float vis1 = 0.25 / max((ndv * (1.0 - k1) + k1) * (ndl * (1.0 - k1) + k1), 0.012);
        float a2_sq = 0.0040 + normal_var * 0.34;
        float d2 = ndh * ndh * (a2_sq - 1.0) + 1.0;
        float ndf2 = a2_sq / max(3.14159265 * d2 * d2, 1.0e-5);
        float k2 = sqrt(a2_sq) * 0.5;
        float vis2 = 0.25 / max((ndv * (1.0 - k2) + k2) * (ndl * (1.0 - k2) + k2), 0.032);
        float core_e = min(ndf1 * vis1 * ndl * fresnel_h, 14.0);
        float sheen_e = min(ndf2 * vis2 * ndl * fresnel_h, 2.2);
        float3 spec = float3(1.48, 1.32, 1.06) * (core_e * 0.78) + float3(1.24, 0.86, 0.48) * (sheen_e * 0.18);
        float sss_dot = clamp(dot(-view_dir, sun_dir), 0.0, 1.0);
        float sss = clamp(h * 2.35 + 0.26, 0.0, 1.0) * exp(-dist * 0.048) * (0.45 + 0.55 * (sss_dot * sss_dot * sss_dot));
        float3 deep_body = float3(0.0002, 0.056, 0.116) + float3(0.0010, 0.40, 0.54) * sss;
        float refl_weight = clamp(fresnel * 0.52 + 0.020, 0.020, 0.68);
        hdr = mix(deep_body, sky_refl, refl_weight) + spec;
        if (rot_bd.y > -0.01 && rot_bd.y < 0.24 && abs(rot_bd.x) < 0.22) {
            float ripple = sin(rot_bd.y * 95.0 - sim_time * 4.5 + grad.x * 6.0) * 0.012;
            float rx_b = abs(rot_bd.x + ripple);
            float y_fade = smoothstep(-0.01, 0.032, rot_bd.y) * smoothstep(0.24, 0.10, rot_bd.y);
            float tri_mask = smoothstep(0.14, 0.02, rx_b + max(rot_bd.y, 0.0) * 0.55) * y_fade;
            hdr = mix(hdr, float3(0.55, 0.52, 0.48), tri_mask * 0.32);
        }
        float crest_norm = crest_acc / max(agitation, 1.0);
        float steep_foam = smoothstep(0.54, 0.74, crest_norm) * clamp(agitation - 1.08, 0.0, 1.0);
        float total_foam = clamp(steep_foam * 0.45 + wake_foam * 0.28, 0.0, 0.54);
        hdr = mix(hdr, float3(0.78, 0.90, 0.96), total_foam);
        if (boat_ring_d2 < 4.5) {
            if (boat_ring_d2 < 1.12) {
                float contact_ao = (1.0 - smoothstep(0.18, 1.06, boat_ring_d2)) * 0.44;
                hdr *= float3(1.0 - contact_ao, 1.0 - contact_ao * 0.82, 1.0 - contact_ao * 0.72);
            }
            float foam_ny = boat_local.y - 0.16;
            float foam_d2 = boat_local.x * boat_local.x * 1.16 + foam_ny * foam_ny * 1.08;
            float rim_band = smoothstep(0.42, 0.82, foam_d2) * (1.0 - smoothstep(0.88, 1.54, foam_d2)) * smoothstep(-0.45, 0.24, boat_local.y);
            float aft_wake = smoothstep(0.22, 0.82, boat_local.x) * (1.0 - smoothstep(0.88, 1.62, boat_local.x)) * (1.0 - smoothstep(0.18, 1.20, abs(boat_local.y - 0.26))) * 0.46;
            float collar_mask = clamp(rim_band + aft_wake, 0.0, 1.0);
            if (collar_mask > 0.02) {
                float lacy_a = euv_scene_noise(wp0 * 8.2 + float2(2.3, -1.7));
                float lacy_b = euv_scene_noise(wp0 * 21.0 + float2(-sim_time * 0.85, 4.1));
                float flecks = euv_scene_noise(wp0 * 42.0 + float2(7.1, -sim_time * 1.35));
                float foam_pat = smoothstep(0.46, 0.78, lacy_a * 0.42 + lacy_b * 0.36 + flecks * 0.22);
                float spray_dots = smoothstep(0.74, 0.88, flecks) * rim_band * 0.72 * smoothstep(0.08, 0.015, px_span);
                float hull_foam = clamp(collar_mask * foam_pat * 0.78 + spray_dots, 0.0, 0.86);
                hdr = mix(hdr, float3(0.92, 0.97, 1.0), hull_foam);
            }
        }
        float horiz_blend = exp(-neg_ry_true * 56.0);
        float dist_haze = 1.0 - exp(-dist * 0.0020);
        float pixel_hor_aa = 1.0 - smoothstep(0.0, d_ry * 1.75, neg_ry_true);
        float atm_mix = clamp(max(max(horiz_blend, dist_haze), pixel_hor_aa), 0.0, 1.0);
        float atm_w = clamp((atm_mix - 0.002) * (1.0 / 0.998), 0.0, 1.0);
        if (atm_w > 0.0) {
            float3 fog_col = euv_ocean_sky(normalize(float3(ray.x, max(0.0005, d_ry * 0.5), ray.z)), sun_dir, sim_time, false);
            hdr = mix(hdr, fog_col, atm_w);
        }
    }
    return float4(euv_scene_aces(hdr), 1.0);
}
vertex GpuBoatOut euv_scene_boat_vert(
    uint vid [[vertex_id]],
    device const GpuBoatVert* verts [[buffer(0)]]
) {
    GpuBoatVert v = verts[vid];
    GpuBoatOut out;
    out.pos = float4(v.pos_ndc.xy, 0.0, 1.0);
    out.color = v.color;
    return out;
}
fragment float4 euv_scene_boat_frag(GpuBoatOut in [[stage_in]]) {
    return in.color;
}
vertex GpuOceanOut euv_scene_3d_sky_vert(uint vid [[vertex_id]]) {
    float2 p = float2((vid == 1) ? 3.0 : -1.0, (vid == 2) ? 3.0 : -1.0);
    GpuOceanOut out;
    out.pos = float4(p, 0.9999, 1.0);
    out.uv = float2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5);
    return out;
}
static inline float3 euv_city_env_radiance(
    float3 origin,
    float3 refl_dir,
    float3 sun_dir,
    float3 sky_hor,
    float3 sky_zen,
    float3 sun_col,
    float roughness
) {
    float ry = clamp(refl_dir.y, 0.0, 1.0);
    float3 env = mix(sky_hor, sky_zen, smoothstep(0.0, 0.72, ry));
    float r_sun = clamp(dot(refl_dir, sun_dir), 0.0, 1.0);
    float rs2 = r_sun * r_sun;
    float rs4 = rs2 * rs2;
    float rs16 = rs4 * rs4 * rs4 * rs4;
    float sun_lobe = mix(rs16 * rs16 * rs16, rs4, clamp(roughness * 1.4, 0.0, 1.0));
    env += sun_col * (sun_lobe * (1.85 - roughness * 1.25));
    float ax = abs(refl_dir.x);
    if (ax > 0.05 && refl_dir.y > -0.25) {
        float wall_x = (refl_dir.x >= 0.0) ? 15.2 : -15.2;
        float t_hit = (wall_x - origin.x) / refl_dir.x;
        if (t_hit > 0.5 && t_hit < 110.0) {
            float hit_y = origin.y + refl_dir.y * t_hit;
            float hit_z = origin.z + refl_dir.z * t_hit;
            if (hit_y > 0.15 && hit_y < 46.0) {
                float rough_att = 1.0 / (1.0 + roughness * 8.5);
                float dist_att = exp(-t_hit * 0.016);
                float3 facade_col = sky_hor * 0.24 + float3(0.025, 0.030, 0.042);
                if (hit_y < 3.45) {
                    float su_s = hit_z * 0.26;
                    float sh = euv_scene_hash(float2(floor(su_s), 7.0));
                    float3 shop_glow = (sh < 0.40) ? float3(1.22, 0.80, 0.36) : ((sh < 0.62) ? float3(0.30, 0.92, 1.24) : ((sh < 0.80) ? float3(1.16, 0.34, 0.72) : float3(0.0)));
                    facade_col += shop_glow * (0.72 * rough_att);
                } else {
                    float su = hit_z * 0.48;
                    float sy = hit_y * 0.33;
                    float fx = fract(su);
                    float fy = fract(sy);
                    float pane = step(0.14, fx) * step(fx, 0.86) * step(0.18, fy) * step(fy, 0.84);
                    float ch = euv_scene_hash(float2(floor(su), floor(sy)));
                    float3 win_glow = (ch < 0.22) ? float3(1.28, 0.88, 0.44) : ((ch < 0.33) ? float3(0.30, 0.90, 1.28) : ((ch < 0.42) ? float3(0.98, 0.96, 0.90) : ((ch < 0.50) ? float3(1.10, 0.36, 0.74) : float3(0.0))));
                    facade_col += win_glow * (pane * (0.38 + 0.56 * rough_att));
                }
                env = mix(env, facade_col, clamp((0.42 + 0.48 * rough_att) * dist_att, 0.0, 0.90));
            }
        }
    }
    if (refl_dir.y > 0.02 && origin.y < 6.6) {
        float t_lamp = (6.8 - origin.y) / refl_dir.y;
        if (t_lamp > 0.5 && t_lamp < 95.0) {
            float lx = origin.x + refl_dir.x * t_lamp;
            float lz = origin.z + refl_dir.z * t_lamp;
            float dx_l = abs(abs(lx) - 10.4);
            float z_idx = floor((lz + 42.0) / 24.0 + 0.5);
            float dz_l = abs(lz - (z_idx * 24.0 - 42.0));
            float spread = 0.72 + roughness * 4.4;
            float lamp_glow = exp(-(dx_l * dx_l + dz_l * dz_l * 0.32) / (spread * spread)) * exp(-t_lamp * 0.020);
            float lp_h = fract(abs(z_idx) * 0.25);
            float3 lamp_c = (lp_h < 0.25) ? float3(1.48, 0.96, 0.42) : ((lp_h < 0.50) ? float3(0.45, 1.15, 1.50) : ((lp_h < 0.75) ? float3(1.40, 0.58, 0.90) : float3(1.44, 1.06, 0.58)));
            env += lamp_c * (lamp_glow * (1.28 - roughness * 0.72));
        }
    }
    return env;
}
fragment float4 euv_scene_3d_sky_frag(
    GpuOceanOut in [[stage_in]],
    constant GpuWorld3dUniform& u [[buffer(0)]]
) {
    float sky_t = clamp(1.0 - in.uv.y * 1.15, 0.0, 1.0);
    float3 col = mix(u.sky_horizon_tod.rgb, u.sky_zenith_aspect.rgb, smoothstep(0.0, 0.85, sky_t));
    float2 sun_d = float2((in.uv.x - 0.55) * max(u.sky_zenith_aspect.w, 0.5), in.uv.y - 0.34);
    float sun_r2 = dot(sun_d, sun_d);
    float sun_aureole = exp(-sun_r2 * 14.0);
    float sun_disk = smoothstep(0.0022, 0.0005, sun_r2);
    float horiz_band = exp(-sky_t * 6.5);
    float wisp = euv_scene_noise(float2(in.uv.x * 5.2 + u.sky_horizon_tod.w * 0.08, sky_t * 7.5)) * smoothstep(0.10, 0.55, sky_t) * (1.0 - smoothstep(0.60, 0.95, sky_t));
    col += u.sun_color_ambient.rgb * (sun_aureole * 0.52 + sun_disk * 2.4 + horiz_band * 0.14);
    col = mix(col, u.sky_horizon_tod.rgb * 1.15 + u.sun_color_ambient.rgb * 0.22, wisp * 0.20);
    return float4(euv_scene_aces(col * u.camera_pos.w), 1.0);
}
vertex GpuWorld3dOut euv_scene_3d_mesh_vert(
    uint vid [[vertex_id]],
    uint iid [[instance_id]],
    constant GpuWorld3dUniform& u [[buffer(0)]],
    device const GpuWorld3dVert* verts [[buffer(1)]],
    device const GpuWorld3dInst* insts [[buffer(2)]]
) {
    GpuWorld3dVert v = verts[vid];
    GpuWorld3dInst inst = insts[iid];
    float detail_mode = inst.model[3].w;
    float4x4 m = inst.model;
    m[3].w = 1.0;
    float4 world_p = m * float4(v.position.xyz, 1.0);
    float4 clip_p = u.view_proj * world_p;
    clip_p.z = clip_p.z * 0.5 + clip_p.w * 0.5;
    float3 c0 = m[0].xyz;
    float3 c1 = m[1].xyz;
    float3 c2 = m[2].xyz;
    float3x3 cof = float3x3(cross(c1, c2), cross(c2, c0), cross(c0, c1));
    float3 wn = normalize(cof * v.normal.xyz);
    GpuWorld3dOut out;
    out.pos = clip_p;
    out.world_pos = world_p.xyz;
    out.world_normal = wn;
    if (v.color_submat.w > 0.5) {
        out.base_metallic = float4(v.color_submat.rgb, inst.albedo_metallic.w);
    } else {
        out.base_metallic = float4(inst.albedo_metallic.rgb * v.color_submat.rgb, inst.albedo_metallic.w);
    }
    out.emissive_rough = inst.emissive_roughness;
    out.submat_mode = v.color_submat.w;
    out.detail_mode = detail_mode;
    return out;
}
fragment float4 euv_scene_3d_mesh_frag(
    GpuWorld3dOut in [[stage_in]],
    constant GpuWorld3dUniform& u [[buffer(0)]]
) {
    float3 norm = normalize(in.world_normal);
    float3 view_dir = normalize(u.camera_pos.xyz - in.world_pos);
    float3 sun_dir = normalize(u.sun_dir_fog.xyz);
    float dist = length(u.camera_pos.xyz - in.world_pos);
    float fw_pos = length(fwidth(in.world_pos));
    float fw_xz = length(fwidth(in.world_pos.xz));
    float3 base_col = in.base_metallic.rgb;
    float metallic = clamp(in.base_metallic.w, 0.0, 1.0);
    float roughness = clamp(in.emissive_rough.w, 0.05, 1.0);
    float3 emissive = (in.submat_mode > 1.5) ? base_col * 1.55 : in.emissive_rough.rgb;
    float env_boost = 0.95;
    float clearcoat = (in.detail_mode < 0.5 && in.submat_mode < 1.5 && (metallic > 0.22 || roughness < 0.36)) ? 0.85 : 0.0;
    float surface_ao = mix(0.56, 1.0, smoothstep(0.0, 1.85, max(in.world_pos.y, 0.0)));
    float3 local_lamp_light = float3(0.0);
    if (in.detail_mode > 0.5 && in.detail_mode < 1.5 && norm.y > 0.82) {
        float wpx = in.world_pos.x;
        float wpz = in.world_pos.z;
        float abs_x = abs(wpx);
        float edge_aa = clamp(fw_xz * 0.9, 0.035, 0.36);
        float curb_w = smoothstep(9.9 - edge_aa, 9.9 + edge_aa, abs_x);
        float walk_w = smoothstep(10.6 - edge_aa, 10.6 + edge_aa, abs_x);
        float micro_fade = 1.0 - smoothstep(22.0, 70.0, dist);
        float grain_n = euv_scene_hash(floor(float2(wpx * 4.3, wpz * 4.3))) - 0.5;
        float om_curb = 1.0 - curb_w;
        float inner_lin = 1.0 - clamp(abs(abs_x - 3.65) * 0.85, 0.0, 1.0);
        float outer_lin = 1.0 - clamp(abs(abs_x - 6.85) * 0.95, 0.0, 1.0);
        float tire_wear = clamp(inner_lin * inner_lin + outer_lin * outer_lin, 0.0, 1.0) * om_curb;
        float gutter_band = (1.0 - clamp(abs(abs_x - 9.75) * 2.8, 0.0, 1.0)) * om_curb;
        float puddle_fade = 1.0 - smoothstep(52.0, 135.0, dist);
        float p_coarse = euv_scene_noise(float2(wpx * 0.14 + 3.1, wpz * 0.08 - 1.7));
        float p_fine = euv_scene_noise(float2(wpx * 0.38 - 5.4, wpz * 0.24 + 2.9));
        float center_crown = (1.0 - clamp(abs_x * 0.65, 0.0, 1.0)) * om_curb;
        float puddle_raw = p_coarse * 0.66 + p_fine * 0.34 + tire_wear * 0.14 + gutter_band * 0.16 - center_crown * 0.24;
        float puddle = smoothstep(0.42, 0.88, puddle_raw) * om_curb * puddle_fade;
        float tarmac_scale = (1.0 + grain_n * 0.24 * micro_fade * (1.0 - puddle)) * (1.0 - 0.14 * tire_wear) * (1.0 - 0.40 * puddle) * (1.0 - 0.30 * gutter_band);
        float3 road_col = base_col * tarmac_scale;
        float yellow_w = (1.0 - smoothstep(0.085 - edge_aa, 0.085 + edge_aa, abs(abs_x - 0.22))) * om_curb;
        if (yellow_w > 0.01) {
            float pv = (1.0 - 0.14 * puddle) * (0.92 + grain_n * 0.14 * micro_fade);
            road_col = mix(road_col, float3(0.92, 0.65, 0.10) * pv, yellow_w * 0.95);
        }
        float dash_on = (fract(wpz * 0.125) < 0.42) ? 1.0 : 0.0;
        float lane_w = (1.0 - smoothstep(0.085 - edge_aa, 0.085 + edge_aa, abs(abs_x - 4.65))) * dash_on * om_curb;
        float shoulder_w = (1.0 - smoothstep(0.10 - edge_aa, 0.10 + edge_aa, abs(abs_x - 8.95))) * om_curb;
        float cross_cell = (wpz + 18.0) - 40.0 * floor((wpz + 18.0) / 40.0) - 20.0;
        float cross_w = (abs(cross_cell) < 1.80 && abs_x < 8.40 && abs_x > 0.55 && fract(wpx * 0.85) < 0.50) ? (0.88 * om_curb) : 0.0;
        float white_w = max(max(shoulder_w, lane_w), cross_w);
        if (white_w > 0.01) {
            float pv = (1.0 - 0.16 * puddle) * (0.90 + grain_n * 0.12 * micro_fade);
            road_col = mix(road_col, float3(0.82, 0.85, 0.90) * pv, white_w * 0.92);
        }
        float3 curb_col = float3(0.36, 0.38, 0.42) * (1.0 + grain_n * 0.10 * micro_fade);
        float tile_seam = (fract(wpx * 0.45) < 0.045 || fract(wpz * 0.45) < 0.045) ? 0.72 : 1.0;
        float3 walk_col = float3(0.24, 0.26, 0.30) * tile_seam * (1.0 + grain_n * 0.10 * micro_fade);
        base_col = mix(mix(road_col, curb_col, curb_w), walk_col, walk_w);
        roughness = mix(mix(roughness, 0.045, puddle), 0.76, walk_w);
        env_boost = mix(0.95, 2.25, puddle);
        clearcoat = puddle * 0.65;
        surface_ao = mix(1.0, 0.66, smoothstep(9.4, 14.0, abs_x));
        float z_idx = floor((wpz + 42.0) / 24.0 + 0.5);
        float z_lamp = z_idx * 24.0 - 42.0;
        float x_lamp = (wpx >= 0.0) ? 10.4 : -10.4;
        float3 to_lamp = float3(x_lamp - wpx, 6.8, z_lamp - wpz);
        float d2_lamp = dot(to_lamp, to_lamp);
        float lamp_att = 1.0 / (1.0 + d2_lamp * 0.018);
        float3 lamp_dir = to_lamp * rsqrt(max(d2_lamp, 0.1));
        float3 lamp_h = normalize(view_dir + lamp_dir);
        float l_ndh = max(dot(norm, lamp_h), 0.0);
        float l_a2 = max(roughness * roughness, 0.008);
        float l_den = l_ndh * l_ndh * (l_a2 - 1.0) + 1.0;
        float l_spec = min(l_a2 / max(3.14159265 * l_den * l_den, 0.0002), 16.0);
        float lp_h = fract(abs(z_idx) * 0.25);
        float3 lamp_col = (lp_h < 0.25) ? float3(1.15, 0.78, 0.34) : ((lp_h < 0.50) ? float3(0.36, 0.88, 1.18) : ((lp_h < 0.75) ? float3(1.10, 0.44, 0.72) : float3(1.12, 0.84, 0.46)));
        local_lamp_light = lamp_col * lamp_att * (base_col * 0.52 + float3(0.08 + 0.32 * puddle) * l_spec);
    } else if (in.detail_mode > 1.5 && in.detail_mode < 2.5 && abs(norm.y) < 0.35 && in.submat_mode < 0.5) {
        float u_coord = (abs(norm.x) > abs(norm.z)) ? in.world_pos.z : in.world_pos.x;
        float world_y = in.world_pos.y;
        float dist_fade = 1.0 - smoothstep(130.0, 320.0, dist);
        float px_sz = max(fw_pos * 0.75, dist * 0.0022);
        surface_ao = mix(0.54, 1.0, smoothstep(0.0, 4.2, max(world_y, 0.0)));
        if (world_y < 3.45) {
            float su_s = u_coord * 0.26;
            float fx_s = fract(su_s);
            float fy_s = clamp(world_y / 3.45, 0.0, 1.0);
            float pane_w = smoothstep(0.08, 0.14, fx_s) * (1.0 - smoothstep(0.86, 0.92, fx_s)) * smoothstep(0.14, 0.22, fy_s) * (1.0 - smoothstep(0.86, 0.92, fy_s)) * dist_fade;
            float sh = euv_scene_hash(float2(floor(su_s), 7.0));
            float3 shop_glow = (sh < 0.40) ? float3(1.24, 0.82, 0.38) : ((sh < 0.62) ? float3(0.30, 0.92, 1.24) : ((sh < 0.80) ? float3(1.18, 0.34, 0.72) : float3(0.0)));
            base_col = mix(base_col * 0.64, base_col * 0.40, pane_w);
            emissive += shop_glow * (pane_w * (0.58 + 0.56 * (1.0 - fy_s)) * 0.96);
            roughness = mix(roughness, 0.10, pane_w);
            env_boost = mix(0.95, 1.65, pane_w);
        } else {
            float su = u_coord * 0.48;
            float sy = world_y * 0.33;
            float fx_win = fract(su);
            float fy_win = fract(sy);
            float aa_u = clamp(px_sz * 0.48, 0.018, 0.32);
            float aa_v = clamp(px_sz * 0.33, 0.018, 0.32);
            float pane_u = smoothstep(0.14 - aa_u, 0.14 + aa_u, fx_win) * (1.0 - smoothstep(0.86 - aa_u, 0.86 + aa_u, fx_win));
            float pane_v = smoothstep(0.18 - aa_v, 0.18 + aa_v, fy_win) * (1.0 - smoothstep(0.84 - aa_v, 0.84 + aa_v, fy_win));
            float pane_w = clamp(pane_u * pane_v * dist_fade, 0.0, 1.0);
            float spandrel = (fy_win < 0.14 || fy_win > 0.88) ? 0.70 : 0.84;
            float3 wall_base = base_col * spandrel;
            float ch = euv_scene_hash(float2(floor(su), floor(sy)));
            float room_lvl = 0.70 + fract(ch * 17.3) * 0.46;
            float blind_grad = clamp(0.48 + 0.66 * (1.0 - fy_win), 0.38, 1.14);
            float r_scale = pane_w * room_lvl * blind_grad;
            if (ch < 0.22) {
                base_col = mix(wall_base, base_col * 0.86, pane_w);
                emissive += float3(1.28, 0.88, 0.44) * r_scale;
            } else if (ch < 0.33) {
                base_col = mix(wall_base, base_col * 0.84, pane_w);
                emissive += float3(0.30, 0.90, 1.28) * r_scale;
            } else if (ch < 0.42) {
                base_col = mix(wall_base, base_col * 0.88, pane_w);
                emissive += float3(0.98, 0.96, 0.90) * (r_scale * 0.84);
            } else if (ch < 0.50) {
                base_col = mix(wall_base, base_col * 0.84, pane_w);
                emissive += float3(1.10, 0.36, 0.74) * (r_scale * 0.88);
            } else {
                float dark_g = clamp(0.34 + 0.22 * fy_win, 0.30, 0.60);
                base_col = mix(wall_base, base_col * dark_g, pane_w);
            }
            roughness = mix(roughness, 0.08, pane_w);
            env_boost = mix(0.90, 1.65, pane_w);
        }
    } else if (in.detail_mode > 2.5 && norm.y > 0.80) {
        float2 wp = in.world_pos.xz;
        float aa_w = 1.0 / (1.0 + fw_xz * 0.85);
        float w_a = cos(wp.x * 0.42 + wp.y * 0.64 + u.sky_horizon_tod.w * 2.4) * 0.08 * aa_w;
        float w_b = cos(-wp.x * 0.78 + wp.y * 0.52 + u.sky_horizon_tod.w * 3.1) * 0.06 * aa_w;
        norm = normalize(float3(w_a - w_b, 1.0, w_a + w_b));
        base_col = float3(0.015, 0.095, 0.145);
        roughness = 0.06;
        metallic = 0.02;
        env_boost = 1.85;
        surface_ao = 1.0;
    }
    float3 half_vec = normalize(view_dir + sun_dir);
    float ndl = max(dot(norm, sun_dir), 0.0);
    float ndv = max(dot(norm, view_dir), 0.002);
    float ndh = max(dot(norm, half_vec), 0.0);
    float hdv = max(dot(half_vec, view_dir), 0.0);
    float om_hdv = 1.0 - hdv;
    float om_hdv2 = om_hdv * om_hdv;
    float fresnel_h = om_hdv2 * om_hdv2 * om_hdv;
    float om_ndv = 1.0 - ndv;
    float om_ndv2 = om_ndv * om_ndv;
    float fresnel_v = om_ndv2 * om_ndv2 * om_ndv;
    float r2 = roughness * roughness;
    float a2 = r2 * r2;
    float d_den = ndh * ndh * (a2 - 1.0) + 1.0;
    float ndf = a2 / max(3.14159265 * d_den * d_den, 0.0001);
    float3 f0 = mix(float3(0.04), base_col, metallic);
    float3 fresnel = f0 + (float3(1.0) - f0) * fresnel_h;
    float k_g = (roughness + 1.0);
    k_g = (k_g * k_g) * 0.125;
    float g_v = ndv / (ndv * (1.0 - k_g) + k_g);
    float g_l = ndl / (ndl * (1.0 - k_g) + k_g);
    float3 spec = (ndf * g_v * g_l * fresnel) / max(4.0 * ndv * ndl, 0.001);
    if (clearcoat > 0.01) {
        float cc_a2 = 0.0022;
        float cc_den = ndh * ndh * (cc_a2 - 1.0) + 1.0;
        float cc_ndf = cc_a2 / max(3.14159265 * cc_den * cc_den, 0.0001);
        float cc_f = 0.04 + 0.96 * fresnel_h;
        spec += float3(cc_ndf * cc_f * 0.25 * clearcoat);
    }
    float3 kd = (float3(1.0) - fresnel) * (1.0 - metallic);
    float contact_shadow = mix(0.68, 1.0, surface_ao);
    float3 direct = (kd * base_col / 3.14159265 + spec) * u.sun_color_ambient.rgb * (ndl * 1.48 * contact_shadow);
    float sky_w = norm.y * 0.5 + 0.5;
    float side_w = 1.0 - abs(norm.y);
    float3 upper_gi = u.sky_zenith_aspect.rgb * 0.92 + u.sky_horizon_tod.rgb * 0.38;
    float3 lower_gi = u.sky_horizon_tod.rgb * 0.28 + float3(0.07, 0.06, 0.08);
    float3 city_bounce = (float3(0.20, 0.15, 0.14) + u.sky_horizon_tod.rgb * 0.22) * side_w;
    float3 hemi = mix(lower_gi, upper_gi, sky_w) + city_bounce * 0.45;
    float3 refl_dir = reflect(-view_dir, norm);
    float3 env_refl = euv_city_env_radiance(
        in.world_pos,
        refl_dir,
        sun_dir,
        u.sky_horizon_tod.rgb,
        u.sky_zenith_aspect.rgb,
        u.sun_color_ambient.rgb,
        roughness
    );
    float3 f_env = f0 + (max(float3(1.0 - roughness), f0) - f0) * fresnel_v;
    float3 cc_refl = (clearcoat > 0.01) ? (env_refl * ((0.04 + 0.96 * fresnel_v) * clearcoat * 0.62)) : float3(0.0);
    float3 ambient = (base_col * (1.0 - metallic * 0.65) * hemi * surface_ao + (env_refl * f_env * env_boost + cc_refl) * (0.65 + 0.35 * surface_ao)) * (0.46 + u.sun_color_ambient.w);
    float3 hdr = direct + ambient + local_lamp_light + emissive;
    float v_sun = clamp(dot(-view_dir, sun_dir), 0.0, 1.0);
    float vs2 = v_sun * v_sun;
    float vs8 = (vs2 * vs2) * (vs2 * vs2);
    float3 haze_col = u.sky_horizon_tod.rgb + u.sun_color_ambient.rgb * (vs8 * 0.36);
    float height_fog = exp(-max(in.world_pos.y, 0.0) * 0.022);
    float fog_t = 1.0 - exp(-dist * u.sun_dir_fog.w * (0.72 + 0.45 * height_fog));
    hdr = mix(hdr, haze_col, clamp(fog_t, 0.0, 0.88));
    return float4(euv_scene_aces(hdr * u.camera_pos.w), 1.0);
}
"#;
/// Lowercase device-name token identifying Apple Metal simulator drivers where `MTLBinaryArchive` serialization aborts.
pub(crate) const MTL_SIMULATOR_TOKEN: &str = "simulator";

/// Lowercase device-name token identifying virtualized GPUs where `MTLBinaryArchive` serialization is unsafe.
pub(crate) const MTL_VIRTUAL_TOKEN: &str = "virtual";

#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_STRING: &str = "NSString\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_URL: &str = "NSURL\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_NS_ARRAY: &str = "NSArray\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_PIPELINE_DESC: &str = "MTLRenderPipelineDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_PASS_DESC: &str = "MTLRenderPassDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_TEX_DESC: &str = "MTLTextureDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_BINARY_ARCHIVE_DESC: &str = "MTLBinaryArchiveDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ALLOC: &str = "alloc\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_INIT: &str = "init\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RETAIN: &str = "retain\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_STRING_UTF8: &str = "stringWithUTF8String:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_FILE_URL_WITH_PATH: &str = "fileURLWithPath:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ARRAY_WITH_OBJECT: &str = "arrayWithObject:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_UTF8_STRING: &str = "UTF8String\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NAME: &str = "name\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_CMD_QUEUE: &str = "newCommandQueue\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_LIBRARY: &str = "newLibraryWithSource:options:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_FUNCTION: &str = "newFunctionWithName:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_PIPELINE_STATE: &str = "newRenderPipelineStateWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BINARY_ARCHIVE: &str = "newBinaryArchiveWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ADD_PIPELINE_TO_ARCHIVE: &str =
    "addRenderPipelineFunctionsWithDescriptor:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SERIALIZE_TO_URL: &str = "serializeToURL:error:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_URL: &str = "setUrl:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BINARY_ARCHIVES: &str = "setBinaryArchives:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_FUNCTION: &str = "setVertexFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_FUNCTION: &str = "setFragmentFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_COLOR_ATTACHMENTS: &str = "colorAttachments\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_OBJECT_AT_INDEX: &str = "objectAtIndexedSubscript:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_PIXEL_FORMAT: &str = "setPixelFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BLENDING_ENABLED: &str = "setBlendingEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_RGB_BLEND_OP: &str = "setRgbBlendOperation:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_ALPHA_BLEND_OP: &str = "setAlphaBlendOperation:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SRC_RGB_BLEND: &str = "setSourceRGBBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DST_RGB_BLEND: &str = "setDestinationRGBBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SRC_ALPHA_BLEND: &str = "setSourceAlphaBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DST_ALPHA_BLEND: &str = "setDestinationAlphaBlendFactor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_TEX_2D_DESC: &str =
    "texture2DDescriptorWithPixelFormat:width:height:mipmapped:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_USAGE: &str = "setUsage:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_TEXTURE: &str = "newTextureWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_REPLACE_REGION: &str =
    "replaceRegion:mipmapLevel:withBytes:bytesPerRow:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BUFFER: &str = "newBufferWithBytes:length:options:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_BUFFER_LENGTH: &str = "newBufferWithLength:options:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_CONTENTS: &str = "contents\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_CMD_BUFFER: &str = "commandBuffer\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RENDER_ENCODER: &str = "renderCommandEncoderWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_PIPELINE_STATE: &str = "setRenderPipelineState:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_BUFFER: &str = "setVertexBuffer:offset:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_BYTES: &str = "setVertexBytes:length:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_TEXTURE: &str = "setFragmentTexture:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_SCISSOR_RECT: &str = "setScissorRect:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DRAW_PRIMITIVES_INSTANCED: &str =
    "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_END_ENCODING: &str = "endEncoding\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_PRESENT_DRAWABLE: &str = "presentDrawable:\0";
#[cfg(all(any(target_os = "macos", target_os = "ios"), not(target_abi = "sim")))]
pub(crate) const MTL_SEL_ADD_PRESENTED_HANDLER: &str = "addPresentedHandler:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ADD_COMPLETED_HANDLER: &str = "addCompletedHandler:\0";
#[cfg(all(any(target_os = "macos", target_os = "ios"), not(target_abi = "sim")))]
pub(crate) const MTL_SEL_PRESENTED_TIME: &str = "presentedTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_STORAGE_MODE: &str = "storageMode\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_COPY_FROM_TEX_TO_BUF: &str = "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const ENV_METAL_DISPLAY_SYNC: &str = "EUV_METAL_DISPLAY_SYNC";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const ENV_UNCAPPED_PRESENT: &str = "EUV_UNCAPPED_PRESENT";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ENV_VALUE_OFF: &str = "0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ENV_VALUE_FALSE: &str = "false";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ENV_VALUE_ON: &str = "1";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ENV_VALUE_TRUE: &str = "true";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_STATUS: &str = "status\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_WAIT_UNTIL_COMPLETED: &str = "waitUntilCompleted\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_GPU_START_TIME: &str = "GPUStartTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_GPU_END_TIME: &str = "GPUEndTime\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEXT_DRAWABLE: &str = "nextDrawable\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_TEXTURE: &str = "texture\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_WIDTH: &str = "width\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_HEIGHT: &str = "height\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RENDER_PASS_DESC: &str = "renderPassDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_TEXTURE: &str = "setTexture:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_LOAD_ACTION: &str = "setLoadAction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STORE_ACTION: &str = "setStoreAction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_CLEAR_COLOR: &str = "setClearColor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEVICE: &str = "setDevice:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAMEBUFFER_ONLY: &str = "setFramebufferOnly:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_MAX_DRAWABLE_COUNT: &str = "setMaximumDrawableCount:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DISPLAY_SYNC: &str = "setDisplaySyncEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DRAWABLE_SIZE: &str = "drawableSize\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DRAWABLE_SIZE: &str = "setDrawableSize:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RESPONDS_TO_SEL: &str = "respondsToSelector:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FRAGMENT_BYTES: &str = "setFragmentBytes:length:atIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VIEWPORT: &str = "setViewport:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_COMMIT: &str = "commit\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_RELEASE: &str = "release\0";
/// Display label for validated fallback shader precompilation state (CPU LUT + source hash warm).
pub(crate) const SHADER_STATE_LABEL_VALIDATED_FALLBACK: &str = "LUT + Hash Warm";

#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_VERTEX: &str = "euv_ui_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_FRAGMENT: &str = "euv_ui_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_VERTEX: &str = "euv_blur_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_DOWN: &str = "euv_blur_downsample";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_BLUR_UP: &str = "euv_blur_upsample";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_3D_VERTEX: &str = "euv_3d_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_3D_FRAGMENT: &str = "euv_3d_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_OCEAN_VERTEX: &str = "euv_ocean_vertex";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_OCEAN_FRAGMENT: &str = "euv_ocean_fragment";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_OCEAN_VERT: &str = "euv_scene_ocean_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_OCEAN_FRAG: &str = "euv_scene_ocean_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_BOAT_VERT: &str = "euv_scene_boat_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_BOAT_FRAG: &str = "euv_scene_boat_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_SKY_VERT: &str = "euv_scene_3d_sky_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_SKY_FRAG: &str = "euv_scene_3d_sky_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_MESH_VERT: &str = "euv_scene_3d_mesh_vert";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_FN_SCENE_3D_MESH_FRAG: &str = "euv_scene_3d_mesh_frag";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_DEPTH_STENCIL_DESC: &str = "MTLDepthStencilDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_COMPARE_FN: &str = "setDepthCompareFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_WRITE_ENABLED: &str = "setDepthWriteEnabled:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_NEW_DEPTH_STENCIL_STATE: &str = "newDepthStencilStateWithDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_STENCIL_STATE: &str = "setDepthStencilState:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_DEPTH_ATTACHMENT_PIXEL_FORMAT: &str =
    "setDepthAttachmentPixelFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_DEPTH_ATTACHMENT: &str = "depthAttachment\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_CLEAR_DEPTH: &str = "setClearDepth:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_DEPTH32_FLOAT: usize = 252;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_COMPARE_FUNC_LESS: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORE_ACTION_DONT_CARE: usize = 0;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STORAGE_MODE_GPU: &str = "setStorageMode:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORAGE_MODE_PRIVATE_GPU: usize = 2;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_TEX_USAGE_RENDER_TARGET_GPU: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CLS_VERTEX_DESC: &str = "MTLVertexDescriptor\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_ATTRIBUTES: &str = "attributes\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_LAYOUTS: &str = "layouts\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_FORMAT: &str = "setFormat:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_OFFSET: &str = "setOffset:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_BUFFER_INDEX: &str = "setBufferIndex:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STRIDE: &str = "setStride:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STEP_FUNCTION: &str = "setStepFunction:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_STEP_RATE: &str = "setStepRate:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_SET_VERTEX_DESC: &str = "setVertexDescriptor:\0";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_VERTEX_FORMAT_FLOAT3: usize = 30;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_VERTEX_STEP_PER_VERTEX: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const GPU_DEVICE_APPLE_METAL: &str = "Apple Metal GPU";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ARCHIVE_FILE_PREFIX: &str = "euv-mtl-pipeline-";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_ARCHIVE_FILE_SUFFIX: &str = ".metallib.archive";
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_R8_UNORM: usize = 10;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_RGBA8_UNORM: usize = 70;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PIXEL_FORMAT_BGRA8_UNORM: usize = 80;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_LOAD_ACTION_LOAD: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_LOAD_ACTION_CLEAR: usize = 2;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_STORE_ACTION_STORE: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_PRIMITIVE_TYPE_TRIANGLE: usize = 3;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_CMD_BUFFER_STATUS_COMPLETED: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_ONE: usize = 1;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_SRC_ALPHA: usize = 4;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: usize = 5;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub(crate) const OBJC_BLOCK_IS_GLOBAL: i32 = 1 << 28;

#[cfg(target_os = "windows")]
pub(crate) const DLL_D3D12: &[u8] = b"d3d12.dll\0";
#[cfg(target_os = "windows")]
pub(crate) const DLL_D3DCOMPILER: &[u8] = b"d3dcompiler_47.dll\0";
#[cfg(target_os = "windows")]
pub(crate) const SYM_D3D12_CREATE_DEVICE: &[u8] = b"D3D12CreateDevice\0";
#[cfg(target_os = "windows")]
pub(crate) const SYM_D3D_COMPILE: &[u8] = b"D3DCompile\0";

#[cfg(target_os = "linux")]
pub(crate) const LIB_VULKAN_SONAME: &str = "libvulkan.so.1";
#[cfg(target_os = "android")]
pub(crate) const LIB_VULKAN_SONAME: &str = "libvulkan.so";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const SYM_VK_CREATE_INSTANCE: &str = "vkCreateInstance";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const SYM_VK_ENUM_DEVICES: &str = "vkEnumeratePhysicalDevices";
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) const RTLD_LAZY_GPU: i32 = 1;