euv-core 0.50.0

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
/// 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, 0.5 - p.y * 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);
}
"#;
/// 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(any(target_os = "macos", target_os = "ios"))]
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(any(target_os = "macos", target_os = "ios"))]
pub(crate) const MTL_SEL_PRESENTED_TIME: &str = "presentedTime\0";
#[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_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_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_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;