euv_core/render/gpu/struct.rs
1use super::*;
2
3/// Probed physical GPU adapter and native shader compilation telemetry.
4#[derive(Clone, Debug, Eq, Getter, New, PartialEq)]
5pub struct GpuAdapterInfo {
6 /// Active graphics backend identifier.
7 #[get(type(copy))]
8 pub(crate) backend: GraphicsBackend,
9 /// Detected physical GPU adapter name (for example `"Apple M3 Max"`).
10 pub(crate) device_name: String,
11 /// True when a real physical OS GPU device/runtime was successfully initialized.
12 #[get(type(copy))]
13 pub(crate) hardware_verified: bool,
14 /// True when the native UI shader (`MSL`/`HLSL`/`GLSL`/`WGSL`) compiled on the host GPU.
15 #[get(type(copy))]
16 pub(crate) shader_compiled: bool,
17}
18
19/// One hardware-fenced staging buffer slot inside `NativeGpuDriver`'s triple-buffered GPU ring.
20#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
21pub struct NativeGpuRingSlot {
22 /// Native OS shared-memory buffer handle (`id<MTLBuffer>` on Apple, `0` when unallocated).
23 #[get(type(copy))]
24 pub(crate) buffer_handle: usize,
25 /// CPU-writable mapped memory address (`[MTLBuffer contents]` on Apple, `0` when unallocated).
26 #[get(type(copy))]
27 pub(crate) contents_ptr: usize,
28 /// Allocated byte capacity of this ring slot buffer.
29 #[get(type(copy))]
30 pub(crate) capacity_bytes: usize,
31 /// Retained in-flight command buffer handle guarding reuse (`id<MTLCommandBuffer>` on Apple).
32 #[get(type(copy))]
33 pub(crate) in_flight_cmd_buffer: usize,
34}
35
36/// Physical OS GPU driver wrapping Metal, D3D12, Vulkan, or WebGL2 with real fenced ring submission and automatic fallback.
37#[derive(Debug, Getter)]
38pub struct NativeGpuDriver {
39 /// Probed physical adapter and shader status.
40 pub(crate) adapter: GpuAdapterInfo,
41 /// Opaque OS GPU device handle (`id<MTLDevice>` on Apple, `0` when fallback).
42 #[get(type(copy))]
43 pub(crate) device_handle: usize,
44 /// Opaque OS GPU command queue handle (`id<MTLCommandQueue>` on Apple, `0` when fallback).
45 #[get(type(copy))]
46 pub(crate) queue_handle: usize,
47 /// Opaque compiled shader library handle (`id<MTLLibrary>` on Apple, `0` when fallback).
48 #[get(type(copy))]
49 pub(crate) library_handle: usize,
50 /// Opaque compiled uber-shader render pipeline handle (`id<MTLRenderPipelineState>` on Apple).
51 #[get(type(copy))]
52 pub(crate) pipeline_handle: usize,
53 /// Opaque compiled Dual-Kawase `BackdropBlur` downsample pipeline handle (`id<MTLRenderPipelineState>` on Apple).
54 #[get(type(copy))]
55 pub(crate) blur_pipeline_handle: usize,
56 /// Opaque compiled Dual-Kawase `BackdropBlur` upsample pipeline handle (`id<MTLRenderPipelineState>` on Apple).
57 #[get(type(copy))]
58 pub(crate) blur_up_pipeline_handle: usize,
59 /// Opaque precompiled 3D Engine PBR pipeline handle (`id<MTLRenderPipelineState>` on Apple).
60 #[get(type(copy))]
61 pub(crate) engine3d_pipeline_handle: usize,
62 /// Opaque precompiled Fluid Ocean optical pipeline handle (`id<MTLRenderPipelineState>` on Apple).
63 #[get(type(copy))]
64 pub(crate) ocean_pipeline_handle: usize,
65 /// Opaque hardware GPU Ocean scene render pipeline handle (`id<MTLRenderPipelineState>`).
66 #[get(type(copy))]
67 pub(crate) scene_ocean_pipeline_handle: usize,
68 /// Opaque hardware GPU Origami Boat overlay pipeline handle (`id<MTLRenderPipelineState>`).
69 #[get(type(copy))]
70 pub(crate) scene_boat_pipeline_handle: usize,
71 /// Opaque hardware GPU 3D Sky gradient pipeline handle (`id<MTLRenderPipelineState>`).
72 #[get(type(copy))]
73 pub(crate) scene_3d_sky_pipeline_handle: usize,
74 /// Opaque hardware GPU 3D PBR instanced depth-buffered pipeline handle (`id<MTLRenderPipelineState>`).
75 #[get(type(copy))]
76 pub(crate) scene_3d_mesh_pipeline_handle: usize,
77 /// Opaque Metal depth-stencil state (`Less`, depth write enabled) for 3D Z-buffered rendering.
78 #[get(type(copy))]
79 pub(crate) scene_depth_stencil_handle: usize,
80 /// Resident offscreen GPU scene color target `MTLTexture` (`BGRA8Unorm`, bound to UI slot `3`).
81 #[get(type(copy))]
82 pub(crate) scene_color_texture_handle: usize,
83 /// Resident offscreen GPU scene depth target `MTLTexture` (`Depth32Float`).
84 #[get(type(copy))]
85 pub(crate) scene_depth_texture_handle: usize,
86 /// Resident GPU PBF interactive wake `MTLTexture` mirror for the active ring slot (`RGBA8Unorm`, `96x72`).
87 #[get(type(copy))]
88 pub(crate) scene_wake_texture_handle: usize,
89 /// Triple-buffered GPU PBF wake `MTLTexture` handles eliminating CPU `replaceRegion` vs in-flight GPU read hazards.
90 #[get(skip)]
91 pub(crate) scene_wake_texture_handles: [usize; GPU_DRIVER_RING_SLOTS],
92 /// Physical `(width, height)` dimensions of `scene_color_texture_handle` and `scene_depth_texture_handle`.
93 #[get(type(copy))]
94 pub(crate) scene_texture_dims: (u32, u32),
95 /// Resident shared-memory static 3D mesh `MTLBuffer` uploaded once per `GpuWorld3dMeshBuffer::revision`.
96 #[get(type(copy))]
97 pub(crate) scene_3d_vertex_buffer_handle: usize,
98 /// Uploaded mesh revision matching `scene_3d_vertex_buffer_handle`.
99 #[get(type(copy))]
100 pub(crate) scene_3d_vertex_revision: u64,
101 /// Byte capacity of `scene_3d_vertex_buffer_handle`.
102 #[get(type(copy))]
103 pub(crate) scene_3d_vertex_capacity: usize,
104 /// Resident shared-memory per-frame 3D instance `MTLBuffer` mirror for the active ring slot.
105 #[get(type(copy))]
106 pub(crate) scene_3d_instance_buffer_handle: usize,
107 /// Byte capacity mirror of `scene_3d_instance_buffer_handle`.
108 #[get(type(copy))]
109 pub(crate) scene_3d_instance_capacity: usize,
110 /// Triple-buffered per-frame 3D instance `MTLBuffer` handles eliminating CPU/GPU write hazards.
111 #[get(skip)]
112 pub(crate) scene_3d_instance_buffer_handles: [usize; GPU_DRIVER_RING_SLOTS],
113 /// Triple-buffered byte capacities matching `scene_3d_instance_buffer_handles`.
114 #[get(skip)]
115 pub(crate) scene_3d_instance_capacities: [usize; GPU_DRIVER_RING_SLOTS],
116 /// Resident shared-memory origami boat triangle `MTLBuffer` mirror for the active ring slot.
117 #[get(type(copy))]
118 pub(crate) scene_boat_buffer_handle: usize,
119 /// Byte capacity mirror of `scene_boat_buffer_handle`.
120 #[get(type(copy))]
121 pub(crate) scene_boat_capacity: usize,
122 /// Triple-buffered origami boat triangle `MTLBuffer` handles eliminating CPU/GPU write hazards.
123 #[get(skip)]
124 pub(crate) scene_boat_buffer_handles: [usize; GPU_DRIVER_RING_SLOTS],
125 /// Triple-buffered byte capacities matching `scene_boat_buffer_handles`.
126 #[get(skip)]
127 pub(crate) scene_boat_capacities: [usize; GPU_DRIVER_RING_SLOTS],
128 /// Pending direct-GPU Ocean or 3D scene pass executed inline at the start of the next frame's command buffer.
129 #[get(skip)]
130 pub(crate) pending_gpu_scene_pass: Option<DirectGpuScenePass>,
131 /// Attached native presentation layer handle (`CAMetalLayer*` on Apple, `0` when headless).
132 #[get(type(copy))]
133 pub(crate) surface_layer_handle: usize,
134 /// Resident R8Unorm monochrome glyph atlas `MTLTexture` handle (`0` when unallocated).
135 #[get(type(copy))]
136 pub(crate) glyph_r8_texture_handle: usize,
137 /// Resident RGBA8Unorm color glyph atlas `MTLTexture` handle (`0` when unallocated).
138 #[get(type(copy))]
139 pub(crate) glyph_rgba8_texture_handle: usize,
140 /// Resident RGBA8Unorm UI image/sprite `MTLTexture` handle (`0` when unallocated).
141 #[get(type(copy))]
142 pub(crate) image_texture_handle: usize,
143 /// Bound external GPU texture handle (3D game render target or hardware video surface).
144 #[get(type(copy))]
145 pub(crate) external_texture_handle: usize,
146 /// Persistent full-resolution offscreen scene `MTLTexture` used for inline Dual-Kawase backdrop blur sampling (`0` when unallocated).
147 #[get(type(copy))]
148 pub(crate) blur_scene_texture_handle: usize,
149 /// Persistent half-resolution Dual-Kawase blur downsample `MTLTexture` handle (`0` when unallocated).
150 #[get(type(copy))]
151 pub(crate) blur_half_texture_handle: usize,
152 /// Persistent full-resolution Dual-Kawase blur upsample `MTLTexture` handle (`0` when unallocated).
153 #[get(type(copy))]
154 pub(crate) blur_full_texture_handle: usize,
155 /// Physical `(width, height)` dimensions of the resident Dual-Kawase blur textures.
156 #[get(type(copy))]
157 pub(crate) blur_texture_dims: (u32, u32),
158 /// Triple-buffered fenced GPU staging ring slots eliminating CPU/GPU buffer hazards.
159 pub(crate) ring_slots: [NativeGpuRingSlot; GPU_DRIVER_RING_SLOTS],
160 /// Active ring slot cursor cycling `0 -> 1 -> 2 -> 0` across frames.
161 #[get(type(copy))]
162 pub(crate) ring_cursor: usize,
163 /// Persistent grow-only staging handle mirror reflecting the active ring slot.
164 #[get(skip)]
165 pub(crate) staging_buffer_handle: usize,
166 /// Cached CPU-writable contents pointer mirror reflecting the active ring slot.
167 #[get(skip)]
168 pub(crate) staging_contents_ptr: usize,
169 /// Byte capacity mirror reflecting the active ring slot.
170 #[get(skip)]
171 pub(crate) staging_buffer_capacity: usize,
172 /// Total GPU frames submitted through this driver.
173 #[get(type(copy))]
174 pub(crate) submitted_frames: u64,
175 /// Total instanced draw primitives uploaded to the GPU.
176 #[get(type(copy))]
177 pub(crate) uploaded_instances: u64,
178 /// Cumulative instance payload bytes uploaded to the GPU across all frames.
179 #[get(type(copy))]
180 pub(crate) uploaded_bytes: u64,
181 /// Instance payload bytes uploaded during the most recent submitted frame.
182 #[get(type(copy))]
183 pub(crate) last_upload_bytes: usize,
184 /// Number of draw batches submitted during the most recent frame.
185 #[get(type(copy))]
186 pub(crate) last_submitted_batches: usize,
187 /// Number of staging ring slot allocations or grows across the driver's lifetime.
188 #[get(type(copy))]
189 pub(crate) staging_reallocations: u64,
190 /// Most recent hardware presentation timestamp in nanoseconds reported by Metal `addPresentedHandler:`.
191 #[get(type(copy))]
192 pub(crate) last_presented_time_ns: u64,
193 /// Most recent GPU execution duration in nanoseconds (`GPUEndTime - GPUStartTime`).
194 #[get(type(copy))]
195 pub(crate) last_gpu_exec_ns: u64,
196 /// Scratch buffer packing 64-byte `GpuPrimitiveInstance` records when legacy batches lack pre-packed primitives.
197 #[cfg(any(target_os = "macos", target_os = "ios"))]
198 #[get(skip)]
199 pub(crate) scratch_primitives: Vec<GpuPrimitiveInstance>,
200 /// Retained Metal GPU buffers, triple-buffered dynamic rings, PSOs, and mipmapped texture pool for `DirectGpuScenePass::PbrScene`.
201 #[cfg(any(target_os = "macos", target_os = "ios"))]
202 #[get(skip)]
203 pub(crate) pbr_scene_resources: MetalPbrSceneResources,
204 /// Fallback command recorder active on headless hosts.
205 pub(crate) fallback: RecordingGpuDriver,
206}
207
208/// Resident mipmapped `MTLTexture` entry with zero-copy `minLodClamp` view tracking for progressive texture streaming.
209#[cfg(any(target_os = "macos", target_os = "ios"))]
210#[derive(Clone, Copy, Debug, Default)]
211pub(crate) struct MetalResidentMipTexture {
212 /// Retained base mipmapped `id<MTLTexture>` handle.
213 pub(crate) tex_handle: usize,
214 /// Retained zero-copy `id<MTLTexture>` view clamped to `[min_lod_clamp .. total_mips)` (`0` when using full base texture).
215 pub(crate) view_handle: usize,
216 /// Base `LOD0` width in texels.
217 pub(crate) base_width: u32,
218 /// Base `LOD0` height in texels.
219 pub(crate) base_height: u32,
220 /// Total allocated mipmap levels.
221 pub(crate) total_mips: u8,
222 /// Active minimum resident mip clamp (`0 = FullRes`, higher = coarser mip-tail).
223 pub(crate) min_lod_clamp: u8,
224}
225
226/// Retained native Metal pipelines, cached geometry VBO/IBO, triple-buffered per-frame buffers, and mipmapped texture pool for `DirectGpuScenePass::PbrScene`.
227#[cfg(any(target_os = "macos", target_os = "ios"))]
228#[derive(Clone, Debug, Default)]
229pub(crate) struct MetalPbrSceneResources {
230 /// Precompiled PBR pipelines `[sky, opaque, skinned, alpha_blend, depth_read_only]`.
231 pub(crate) pipelines: [usize; 5],
232 /// Resident 24-byte `QuantizedVertex3D` static vertex buffer handle.
233 pub(crate) vert_buf: usize,
234 /// Byte capacity of `vert_buf`.
235 pub(crate) vert_cap: usize,
236 /// Resident `u32` triangle index buffer handle.
237 pub(crate) idx_buf: usize,
238 /// Byte capacity of `idx_buf`.
239 pub(crate) idx_cap: usize,
240 /// Resident 16-byte `QuantizedSkinVertex3D` sidecar buffer handle.
241 pub(crate) skin_buf: usize,
242 /// Byte capacity of `skin_buf`.
243 pub(crate) skin_cap: usize,
244 /// Resident morph target delta `[f32; 4]` buffer handle.
245 pub(crate) morph_delta_buf: usize,
246 /// Byte capacity of `morph_delta_buf`.
247 pub(crate) morph_delta_cap: usize,
248 /// Uploaded `GpuPbrMeshBuffer::revision` matching static geometry buffers.
249 pub(crate) mesh_rev: u64,
250 /// Triple-buffered per-frame `GpuPbrInstance3D` handles.
251 pub(crate) inst_bufs: [usize; GPU_DRIVER_RING_SLOTS],
252 /// Byte capacities matching `inst_bufs`.
253 pub(crate) inst_caps: [usize; GPU_DRIVER_RING_SLOTS],
254 /// Triple-buffered per-frame `GpuMaterialData3D` storage handles.
255 pub(crate) mat_bufs: [usize; GPU_DRIVER_RING_SLOTS],
256 /// Byte capacities matching `mat_bufs`.
257 pub(crate) mat_caps: [usize; GPU_DRIVER_RING_SLOTS],
258 /// Triple-buffered per-frame skeletal bone matrix handles.
259 pub(crate) bone_bufs: [usize; GPU_DRIVER_RING_SLOTS],
260 /// Byte capacities matching `bone_bufs`.
261 pub(crate) bone_caps: [usize; GPU_DRIVER_RING_SLOTS],
262 /// Triple-buffered per-frame morph target weight handles.
263 pub(crate) morph_w_bufs: [usize; GPU_DRIVER_RING_SLOTS],
264 /// Byte capacities matching `morph_w_bufs`.
265 pub(crate) morph_w_caps: [usize; GPU_DRIVER_RING_SLOTS],
266 /// Triple-buffered per-frame local light buffer handles.
267 pub(crate) light_bufs: [usize; GPU_DRIVER_RING_SLOTS],
268 /// Byte capacities matching `light_bufs`.
269 pub(crate) light_caps: [usize; GPU_DRIVER_RING_SLOTS],
270 /// Resident mipmapped texture pool indexed by `texture_slot`.
271 pub(crate) textures: HashMap<u32, MetalResidentMipTexture>,
272}
273
274/// Retained native GPU device, queue, library, compiled pipelines, and dummy texture handles returned by `probe_native_gpu_full`.
275#[derive(Clone, Debug)]
276pub(crate) struct NativeGpuProbeOutput {
277 /// Probed adapter capabilities and hardware backend descriptor.
278 pub(crate) adapter: GpuAdapterInfo,
279 /// Retained native GPU device handle (`0` when headless).
280 pub(crate) device_handle: usize,
281 /// Retained native GPU command queue handle (`0` when headless).
282 pub(crate) queue_handle: usize,
283 /// Retained compiled native shader library handle (`0` when headless).
284 pub(crate) library_handle: usize,
285 /// Retained cached uber-shader render pipeline handle (`0` when headless).
286 pub(crate) pipeline_handle: usize,
287 /// Retained cached Dual-Kawase blur downsample render pipeline handle (`0` when headless).
288 pub(crate) blur_pipeline_handle: usize,
289 /// Retained cached Dual-Kawase blur upsample render pipeline handle (`0` when headless).
290 pub(crate) blur_up_pipeline_handle: usize,
291 /// Retained cached 3D Engine PBR render pipeline handle (`0` when headless).
292 pub(crate) engine3d_pipeline_handle: usize,
293 /// Retained cached Fluid Ocean optical render pipeline handle (`0` when headless).
294 pub(crate) ocean_pipeline_handle: usize,
295 /// Retained GPU Ocean scene render pipeline handle (`0` when headless).
296 pub(crate) scene_ocean_pipeline_handle: usize,
297 /// Retained GPU Origami Boat overlay pipeline handle (`0` when headless).
298 pub(crate) scene_boat_pipeline_handle: usize,
299 /// Retained GPU 3D Sky gradient pipeline handle (`0` when headless).
300 pub(crate) scene_3d_sky_pipeline_handle: usize,
301 /// Retained GPU 3D PBR instanced mesh pipeline handle (`0` when headless).
302 pub(crate) scene_3d_mesh_pipeline_handle: usize,
303 /// Retained GPU 3D depth-stencil state handle (`0` when headless).
304 pub(crate) scene_depth_stencil_handle: usize,
305 /// Retained 1x1 fallback R8Unorm texture handle (`0` when headless).
306 pub(crate) dummy_r8_tex: usize,
307 /// Retained 1x1 fallback RGBA8Unorm texture handle (`0` when headless).
308 pub(crate) dummy_rgba8_tex: usize,
309 /// Retained PBR scene pipelines `[sky, opaque, skinned, alpha_blend, depth_read_only]`.
310 pub(crate) scene_pbr_pipelines: [usize; 5],
311}
312
313/// Process-wide cached Objective-C selector pointers for Apple Metal hot-path submission and encoding.
314#[cfg(any(target_os = "macos", target_os = "ios"))]
315#[derive(Clone, Copy, Debug)]
316pub(crate) struct MetalSelectors {
317 /// Cached `retain` selector address.
318 pub(crate) retain: usize,
319 /// Cached `newBufferWithBytes:length:options:` selector address.
320 pub(crate) new_buffer_with_bytes: usize,
321 /// Cached `newBufferWithLength:options:` selector address.
322 pub(crate) new_buffer_with_length: usize,
323 /// Cached `contents` selector address.
324 pub(crate) contents: usize,
325 /// Cached `commandBuffer` selector address.
326 pub(crate) command_buffer: usize,
327 /// Cached `renderCommandEncoderWithDescriptor:` selector address.
328 pub(crate) render_encoder: usize,
329 /// Cached `setRenderPipelineState:` selector address.
330 pub(crate) set_pipeline_state: usize,
331 /// Cached `setVertexBuffer:offset:atIndex:` selector address.
332 pub(crate) set_vertex_buffer: usize,
333 /// Cached `setVertexBytes:length:atIndex:` selector address.
334 pub(crate) set_vertex_bytes: usize,
335 /// Cached `setFragmentTexture:atIndex:` selector address.
336 pub(crate) set_fragment_texture: usize,
337 /// Cached `setFragmentBytes:length:atIndex:` selector address.
338 pub(crate) set_fragment_bytes: usize,
339 /// Cached `setScissorRect:` selector address.
340 pub(crate) set_scissor_rect: usize,
341 /// Cached `setViewport:` selector address.
342 pub(crate) set_viewport: usize,
343 /// Cached `drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:` selector address.
344 pub(crate) draw_primitives_instanced: usize,
345 /// Cached `endEncoding` selector address.
346 pub(crate) end_encoding: usize,
347 /// Cached `presentDrawable:` selector address.
348 pub(crate) present_drawable: usize,
349 /// Cached `addPresentedHandler:` selector address (on `MTLDrawable`).
350 #[cfg(not(target_abi = "sim"))]
351 pub(crate) add_presented_handler: usize,
352 /// Cached `addCompletedHandler:` selector address (on `MTLCommandBuffer`).
353 pub(crate) add_completed_handler: usize,
354 /// Cached `presentedTime` selector address (on `MTLDrawable`).
355 #[cfg(not(target_abi = "sim"))]
356 pub(crate) presented_time: usize,
357 /// Cached `respondsToSelector:` selector address.
358 pub(crate) responds_to_sel: usize,
359 /// Cached `status` selector address.
360 pub(crate) status: usize,
361 /// Cached `waitUntilCompleted` selector address.
362 pub(crate) wait_until_completed: usize,
363 /// Cached `GPUStartTime` selector address.
364 pub(crate) gpu_start_time: usize,
365 /// Cached `GPUEndTime` selector address.
366 pub(crate) gpu_end_time: usize,
367 /// Cached `nextDrawable` selector address.
368 pub(crate) next_drawable: usize,
369 /// Cached `drawableSize` selector address on `CAMetalLayer`.
370 pub(crate) drawable_size: usize,
371 /// Cached `setDrawableSize:` selector address on `CAMetalLayer`.
372 pub(crate) set_drawable_size: usize,
373 /// Cached `texture` selector address.
374 pub(crate) texture: usize,
375 /// Cached `width` selector address.
376 pub(crate) width: usize,
377 /// Cached `height` selector address.
378 pub(crate) height: usize,
379 /// Cached `renderPassDescriptor` selector address.
380 pub(crate) render_pass_desc: usize,
381 /// Cached `colorAttachments` selector address.
382 pub(crate) color_attachments: usize,
383 /// Cached `objectAtIndexedSubscript:` selector address.
384 pub(crate) object_at_index: usize,
385 /// Cached `setTexture:` selector address.
386 pub(crate) set_texture: usize,
387 /// Cached `setLoadAction:` selector address.
388 pub(crate) set_load_action: usize,
389 /// Cached `setStoreAction:` selector address.
390 pub(crate) set_store_action: usize,
391 /// Cached `setClearColor:` selector address.
392 pub(crate) set_clear_color: usize,
393 /// Cached `depthAttachment` selector address.
394 pub(crate) depth_attachment: usize,
395 /// Cached `setClearDepth:` selector address.
396 pub(crate) set_clear_depth: usize,
397 /// Cached `setDepthStencilState:` selector address.
398 pub(crate) set_depth_stencil_state: usize,
399 /// Cached `replaceRegion:mipmapLevel:withBytes:bytesPerRow:` selector address.
400 pub(crate) replace_region: usize,
401 /// Cached `setFragmentBuffer:offset:atIndex:` selector address.
402 pub(crate) set_fragment_buffer: usize,
403 /// Cached `drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:` selector address.
404 pub(crate) draw_indexed_instanced: usize,
405 /// Cached `newTextureViewWithPixelFormat:textureType:levels:slices:` selector address.
406 pub(crate) new_texture_view: usize,
407 /// Cached `commit` selector address.
408 pub(crate) commit: usize,
409 /// Cached `release` selector address.
410 pub(crate) release: usize,
411}
412
413/// Objective-C `NSRange` ABI struct passed to Metal texture view level/slice range selectors.
414#[cfg(any(target_os = "macos", target_os = "ios"))]
415#[repr(C)]
416#[derive(Clone, Copy, Debug, Default)]
417pub(crate) struct MtlNsRange {
418 /// Starting index of the range.
419 pub(crate) location: usize,
420 /// Element length of the range.
421 pub(crate) length: usize,
422}
423
424/// Process-wide cached Apple Metal runtime pipeline state eliminating redundant 40-180ms shader compiles.
425#[cfg(any(target_os = "macos", target_os = "ios"))]
426#[derive(Clone, Debug)]
427pub(crate) struct MetalSharedPipelineCache {
428 /// Probed physical adapter description and shader compile status.
429 pub(crate) adapter: GpuAdapterInfo,
430 /// Retained `id<MTLDevice>` handle.
431 pub(crate) device: usize,
432 /// Retained `id<MTLCommandQueue>` handle.
433 pub(crate) queue: usize,
434 /// Retained `id<MTLLibrary>` handle.
435 pub(crate) library: usize,
436 /// Retained `id<MTLRenderPipelineState>` handle for the 64-byte uber-shader.
437 pub(crate) pipeline: usize,
438 /// Retained `id<MTLRenderPipelineState>` handle for the Dual-Kawase blur downsample shader.
439 pub(crate) blur_pipeline: usize,
440 /// Retained `id<MTLRenderPipelineState>` handle for the Dual-Kawase blur upsample shader.
441 pub(crate) blur_up_pipeline: usize,
442 /// Retained `id<MTLRenderPipelineState>` handle for the 3D Engine PBR shader.
443 pub(crate) engine3d_pipeline: usize,
444 /// Retained `id<MTLRenderPipelineState>` handle for the Fluid Ocean optical shader.
445 pub(crate) ocean_pipeline: usize,
446 /// Retained `id<MTLRenderPipelineState>` handle for the GPU Ocean scene pass.
447 pub(crate) scene_ocean_pipeline: usize,
448 /// Retained `id<MTLRenderPipelineState>` handle for the GPU Origami Boat overlay pass.
449 pub(crate) scene_boat_pipeline: usize,
450 /// Retained `id<MTLRenderPipelineState>` handle for the GPU 3D Sky pass.
451 pub(crate) scene_3d_sky_pipeline: usize,
452 /// Retained `id<MTLRenderPipelineState>` handle for the GPU 3D PBR depth-buffered mesh pass.
453 pub(crate) scene_3d_mesh_pipeline: usize,
454 /// Retained `id<MTLDepthStencilState>` handle (`Less`, depth writes enabled) for 3D rendering.
455 pub(crate) scene_depth_stencil: usize,
456 /// Retained PBR scene pipelines `[sky, opaque, skinned, alpha_blend, depth_read_only]`.
457 pub(crate) scene_pbr_pipelines: [usize; 5],
458 /// Whether persistent disk-backed `MTLBinaryArchive` caching was enabled on this physical GPU.
459 pub(crate) binary_archive_enabled: bool,
460 /// Whether the disk-backed `MTLBinaryArchive` already existed on disk and accelerated PSO load.
461 pub(crate) binary_archive_hit: bool,
462 /// Measured UI uber-shader compilation time in microseconds.
463 pub(crate) ui_compile_us: u64,
464 /// Measured Dual-Kawase blur shader compilation time in microseconds.
465 pub(crate) blur_compile_us: u64,
466 /// Measured 3D Engine PBR shader compilation time in microseconds.
467 pub(crate) engine3d_compile_us: u64,
468 /// Measured Fluid Ocean optical shader compilation time in microseconds.
469 pub(crate) ocean_compile_us: u64,
470 /// Total cold pipeline precompilation time in microseconds.
471 pub(crate) total_compile_us: u64,
472 /// Retained 1x1 fallback R8Unorm `MTLTexture` bound when glyph atlas is empty.
473 pub(crate) dummy_r8_tex: usize,
474 /// Retained 1x1 fallback RGBA8Unorm `MTLTexture` bound when color/image textures are unbound.
475 pub(crate) dummy_rgba8_tex: usize,
476}
477
478/// CoreGraphics `CGSize` 2D extent ABI struct passed to `CAMetalLayer.setDrawableSize:`.
479#[cfg(any(target_os = "macos", target_os = "ios"))]
480#[repr(C)]
481#[derive(Clone, Copy, Debug, Default)]
482pub(crate) struct MtlCgSize {
483 /// Physical surface width in pixels.
484 pub(crate) width: f64,
485 /// Physical surface height in pixels.
486 pub(crate) height: f64,
487}
488
489/// Metal `MTLOrigin` 3D texel origin ABI struct.
490#[cfg(any(target_os = "macos", target_os = "ios"))]
491#[repr(C)]
492#[derive(Clone, Copy, Debug, Default)]
493pub(crate) struct MtlOrigin {
494 /// Horizontal texel origin.
495 pub(crate) x: usize,
496 /// Vertical texel origin.
497 pub(crate) y: usize,
498 /// Slice depth origin (`0`).
499 pub(crate) z: usize,
500}
501
502/// Metal `MTLSize` 3D texel extent ABI struct.
503#[cfg(any(target_os = "macos", target_os = "ios"))]
504#[repr(C)]
505#[derive(Clone, Copy, Debug, Default)]
506pub(crate) struct MtlSize {
507 /// Extent width in texels.
508 pub(crate) width: usize,
509 /// Extent height in texels.
510 pub(crate) height: usize,
511 /// Extent depth in slices (`1`).
512 pub(crate) depth: usize,
513}
514
515/// Metal `MTLRegion` 3D sub-texture upload rectangle ABI struct.
516#[cfg(any(target_os = "macos", target_os = "ios"))]
517#[repr(C)]
518#[derive(Clone, Copy, Debug, Default)]
519pub(crate) struct MtlRegion {
520 /// Sub-region origin.
521 pub(crate) origin: MtlOrigin,
522 /// Sub-region extent.
523 pub(crate) size: MtlSize,
524}
525
526/// Metal `MTLScissorRect` physical scissor ABI struct.
527#[cfg(any(target_os = "macos", target_os = "ios"))]
528#[repr(C)]
529#[derive(Clone, Copy, Debug, Default)]
530pub(crate) struct MtlScissorRect {
531 /// Left physical pixel edge.
532 pub(crate) x: usize,
533 /// Top physical pixel edge.
534 pub(crate) y: usize,
535 /// Scissor width in physical pixels.
536 pub(crate) width: usize,
537 /// Scissor height in physical pixels.
538 pub(crate) height: usize,
539}
540
541/// Metal `MTLViewport` physical viewport ABI struct passed to `setViewport:`.
542#[cfg(any(target_os = "macos", target_os = "ios"))]
543#[repr(C)]
544#[derive(Clone, Copy, Debug, Default)]
545pub(crate) struct MtlViewport {
546 /// Viewport X origin in physical pixels.
547 pub(crate) origin_x: f64,
548 /// Viewport Y origin in physical pixels.
549 pub(crate) origin_y: f64,
550 /// Viewport width in physical pixels.
551 pub(crate) width: f64,
552 /// Viewport height in physical pixels.
553 pub(crate) height: f64,
554 /// Near depth plane (`0.0`).
555 pub(crate) znear: f64,
556 /// Far depth plane (`1.0`).
557 pub(crate) zfar: f64,
558}
559
560/// Metal `MTLClearColor` RGBA64F clear color ABI struct.
561#[cfg(any(target_os = "macos", target_os = "ios"))]
562#[repr(C)]
563#[derive(Clone, Copy, Debug, Default)]
564pub(crate) struct MtlClearColor {
565 /// Red channel in `[0.0..=1.0]`.
566 pub(crate) red: f64,
567 /// Green channel in `[0.0..=1.0]`.
568 pub(crate) green: f64,
569 /// Blue channel in `[0.0..=1.0]`.
570 pub(crate) blue: f64,
571 /// Alpha channel in `[0.0..=1.0]`.
572 pub(crate) alpha: f64,
573}
574
575/// Objective-C runtime global block descriptor ABI layout.
576#[cfg(any(target_os = "macos", target_os = "ios"))]
577#[repr(C)]
578pub(crate) struct ObjcBlockDescriptor {
579 /// Reserved word (`0`).
580 pub(crate) reserved: usize,
581 /// Byte size of the block struct.
582 pub(crate) size: usize,
583}
584
585/// Objective-C runtime zero-allocation global block ABI struct for Metal `addPresentedHandler:`.
586#[cfg(any(target_os = "macos", target_os = "ios"))]
587#[repr(C)]
588pub(crate) struct ObjcGlobalBlock {
589 /// Pointer to `_NSConcreteGlobalBlock`.
590 pub(crate) isa: *const c_void,
591 /// Block flags (`OBJC_BLOCK_IS_GLOBAL`).
592 pub(crate) flags: i32,
593 /// Reserved flags (`0`).
594 pub(crate) reserved: i32,
595 /// Block invoke C callback `(block, cmd_buffer)`.
596 pub(crate) invoke: unsafe extern "C" fn(*mut c_void, *mut c_void),
597 /// Descriptor pointer.
598 pub(crate) descriptor: *const ObjcBlockDescriptor,
599}
600
601/// Process-wide cached Windows Direct3D 12 probe status eliminating repeated `LoadLibraryA`/`FreeLibrary` thrashing.
602#[cfg(target_os = "windows")]
603#[derive(Clone, Copy, Debug)]
604pub(crate) struct WindowsD3d12ProbeCache {
605 /// True when `d3d12.dll` exports `D3D12CreateDevice`.
606 pub(crate) has_d3d12: bool,
607 /// True when `d3dcompiler_47.dll` exports `D3DCompile`.
608 pub(crate) has_compiler: bool,
609}
610
611/// Process-wide cached Vulkan loader probe status eliminating repeated `dlopen`/`dlclose` thrashing.
612#[cfg(any(target_os = "linux", target_os = "android"))]
613#[derive(Clone, Copy, Debug)]
614pub(crate) struct VulkanProbeCache {
615 /// True when Vulkan loader exports `vkCreateInstance` and `vkEnumeratePhysicalDevices`.
616 pub(crate) available: bool,
617 /// Cached `dlopen` handle kept resident for process lifetime.
618 pub(crate) lib_handle: usize,
619}
620
621/// Physical pixel dirty sub-rectangle used by adaptive GLES 3.0 and Metal texture upload planners.
622#[repr(C)]
623#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
624pub struct PixelDirtyRect {
625 /// Left inclusive pixel coordinate.
626 #[get(type(copy))]
627 pub(crate) x: u32,
628 /// Top inclusive pixel coordinate.
629 #[get(type(copy))]
630 pub(crate) y: u32,
631 /// Sub-rectangle width in pixels.
632 #[get(type(copy))]
633 pub(crate) width: u32,
634 /// Sub-rectangle height in pixels.
635 #[get(type(copy))]
636 pub(crate) height: u32,
637}
638
639/// Selected adaptive texture-upload plan choosing `MultiRect`, `MergedBbox`, `FullFrame`, or `None` by measured byte and driver cost.
640#[derive(Clone, Data, Debug, Default, PartialEq)]
641pub struct AdaptiveUploadPlan {
642 /// Selected upload strategy for this frame.
643 #[get(type(copy))]
644 pub(crate) strategy: MobileUploadStrategy,
645 /// Ordered physical rectangles to upload under `strategy`.
646 pub(crate) rects: Vec<PixelDirtyRect>,
647 /// Total RGBA8 pixel payload bytes transferred under `strategy`.
648 #[get(type(copy))]
649 pub(crate) total_upload_bytes: usize,
650 /// Equivalent RGBA8 payload bytes of the single merged bounding box.
651 #[get(type(copy))]
652 pub(crate) merged_bbox_bytes: usize,
653 /// Equivalent RGBA8 payload bytes of a full-frame texture upload.
654 #[get(type(copy))]
655 pub(crate) full_frame_bytes: usize,
656 /// Estimated total upload cost score (pixel bytes plus per-call driver overhead).
657 #[get(type(copy))]
658 pub(crate) estimated_cost_score: f32,
659}
660
661/// One scissor-bounded instanced draw range inside a compiled `DirectGpuFrameBatch`.
662#[repr(C)]
663#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
664pub struct DirectGpuBatchRange {
665 /// First primitive index inside `DirectGpuFrameBatch::primitives`.
666 #[get(type(copy))]
667 pub(crate) base_instance: u32,
668 /// Number of consecutive 64-byte `GpuPrimitiveInstance` records drawn in this call.
669 #[get(type(copy))]
670 pub(crate) instance_count: u32,
671 /// Physical scissor left coordinate in pixels (top-left origin).
672 #[get(type(copy))]
673 pub(crate) scissor_x: u32,
674 /// Physical scissor top coordinate in pixels (top-left origin).
675 #[get(type(copy))]
676 pub(crate) scissor_y: u32,
677 /// Physical scissor width in pixels.
678 #[get(type(copy))]
679 pub(crate) scissor_w: u32,
680 /// Physical scissor height in pixels.
681 #[get(type(copy))]
682 pub(crate) scissor_h: u32,
683 /// Horizontal retained-layer scroll translation in physical pixels.
684 #[get(type(copy))]
685 pub(crate) scroll_x: f32,
686 /// Vertical retained-layer scroll translation in physical pixels.
687 #[get(type(copy))]
688 pub(crate) scroll_y: f32,
689 /// Bound texture slot discriminant (`0` = default glyph/image textures).
690 #[get(type(copy))]
691 pub(crate) texture_slot: u8,
692 /// Owning retained layer identifier (`0` = root).
693 #[get(type(copy))]
694 pub(crate) layer_id: u8,
695 /// Explicit C-ABI alignment padding bytes.
696 #[get(type(copy))]
697 pub(crate) pad: [u8; 2],
698}
699
700/// Borrowed RGBA8 image or sprite-sheet sub-region queued for frame-level direct-GPU image atlas packing.
701#[derive(Clone, Copy, Debug)]
702pub(crate) struct DirectGpuImageSlice<'a> {
703 /// Full source image width in pixels.
704 pub(crate) src_w: u32,
705 /// Full source image height in pixels.
706 pub(crate) src_h: u32,
707 /// Borrowed RGBA8 pixel bytes (`src_w * src_h * 4`).
708 pub(crate) pixels: &'a [u8],
709 /// Source crop rectangle `(x, y, width, height)` in pixels.
710 pub(crate) crop: PixelDirtyRect,
711}
712
713/// Packed R8 monochrome glyph atlas or RGBA8 image texture sheet ready for direct GLES 3.0 or Metal upload.
714#[derive(Clone, Data, Debug, Default, PartialEq)]
715pub struct DirectGpuAtlasUpload {
716 /// Backing texture width in texels (`0` when no upload is required).
717 #[get(type(copy))]
718 pub(crate) width: u32,
719 /// Backing texture height in texels (`0` when no upload is required).
720 #[get(type(copy))]
721 pub(crate) height: u32,
722 /// Monotonic revision tag avoiding redundant uploads when unchanged.
723 #[get(type(copy))]
724 pub(crate) revision: u64,
725 /// Tightly packed texel payload bytes (`width * height` for R8, `width * height * 4` for RGBA8).
726 pub(crate) pixels: Vec<u8>,
727}
728
729/// Complete direct-GPU frame payload targeting GLES 3.0 `EGLSurface` or Metal `CAMetalDrawable` with zero CPU framebuffer mirror.
730#[derive(Clone, Data, Debug, Default, PartialEq)]
731pub struct DirectGpuFrameBatch {
732 /// Physical surface width in pixels.
733 #[get(type(copy))]
734 pub(crate) viewport_width: u32,
735 /// Physical surface height in pixels.
736 #[get(type(copy))]
737 pub(crate) viewport_height: u32,
738 /// Normalized sRGB clear color `[r, g, b, a]` applied to the native surface.
739 #[get(type(copy))]
740 pub(crate) clear_rgba: [f32; 4],
741 /// Flat tightly packed 64-byte `GpuPrimitiveInstance` array uploaded once per frame.
742 pub(crate) primitives: Vec<GpuPrimitiveInstance>,
743 /// Ordered scissor-bounded draw calls indexing into `primitives`.
744 pub(crate) draw_ranges: Vec<DirectGpuBatchRange>,
745 /// Ordered Dual-Kawase `BackdropBlur` GPU passes for this frame.
746 pub(crate) backdrop_blurs: Vec<GpuBackdropBlurPass>,
747 /// Optional R8 monochrome glyph atlas update when new glyphs were rasterized.
748 pub(crate) glyph_r8_atlas: Option<DirectGpuAtlasUpload>,
749 /// Optional RGBA8 color/image texture sheet update for `Image` / `SharedImage` / `SpriteRegion`.
750 pub(crate) image_rgba8_atlas: Option<DirectGpuAtlasUpload>,
751 /// Total instance + atlas bytes uploaded to GPU memory for this frame.
752 #[get(type(copy))]
753 pub(crate) instance_upload_bytes: usize,
754 /// Always `false` on the direct GPU draw path (zero full-frame CPU RGBA mirror).
755 #[get(type(copy))]
756 pub(crate) cpu_mirror_active: bool,
757 /// Upload strategy tag (`MobileUploadStrategy::DirectGpu`).
758 #[get(type(copy))]
759 pub(crate) upload_strategy: MobileUploadStrategy,
760}
761
762/// GLES 3.0 instanced vertex attribute binding specification matching `GLSL_ES3_UI_VERTEX_SHADER` byte-for-byte.
763#[repr(C)]
764#[derive(Clone, Copy, Debug, Eq, Getter, New, PartialEq)]
765pub struct Gles3InstanceAttribSpec {
766 /// Vertex attribute layout location (`1..=5`).
767 #[get(type(copy))]
768 pub(crate) location: u32,
769 /// Number of scalar components (`2` or `4`).
770 #[get(type(copy))]
771 pub(crate) components: i32,
772 /// True when bound with `glVertexAttribIPointer` (`GL_UNSIGNED_INT`), false for `glVertexAttribPointer` (`GL_FLOAT`).
773 #[get(type(copy))]
774 pub(crate) is_integer: bool,
775 /// Byte offset inside the 64-byte `GpuPrimitiveInstance` struct.
776 #[get(type(copy))]
777 pub(crate) byte_offset: usize,
778 /// Stride in bytes (`64`).
779 #[get(type(copy))]
780 pub(crate) stride: i32,
781}
782
783/// Honest cross-platform mobile presentation telemetry ready to feed into `AdaptiveRenderRouter` and `report-v1` JSON.
784#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
785pub struct MobilePresentTelemetry {
786 /// Currently active presentation path (`GpuDirect`, `GpuUpload`, or `Software`).
787 #[get(type(copy))]
788 pub(crate) active_path: MobilePresentPath,
789 /// Upload strategy executed on the most recent frame.
790 #[get(type(copy))]
791 pub(crate) upload_strategy: MobileUploadStrategy,
792 /// True only when a CPU framebuffer mirror is active (`false` on `GpuDirect`, `true` on `GpuUpload`/`Software`).
793 #[get(type(copy))]
794 pub(crate) cpu_mirror_active: bool,
795 /// Provenance of presentation timestamps (`CompositorMeasured`, `SubmissionProxy`, or `Unobservable`).
796 #[get(type(copy))]
797 pub(crate) timing_source: MobilePresentTimingSource,
798 /// Explicit reason when compositor presentation timing is unobservable (never masked as `0.0`).
799 #[get(type(copy))]
800 pub(crate) unobservable_reason: Option<&'static str>,
801 /// True when executing inside an iOS/Android software simulator rather than physical GPU hardware.
802 #[get(type(copy))]
803 pub(crate) is_simulator: bool,
804 /// Active display refresh rate in Hertz (`60.0`, `90.0`, `120.0`, `144.0`, etc.).
805 #[get(type(copy))]
806 pub(crate) display_mode_hz: f32,
807 /// Total VSync frame callbacks received (`Choreographer.doFrame` or `CADisplayLink`).
808 #[get(type(copy))]
809 pub(crate) frame_callback_count: u64,
810 /// Most recent VSync frame callback timestamp in nanoseconds.
811 #[get(type(copy))]
812 pub(crate) last_callback_timestamp_ns: u64,
813 /// Measured interval between consecutive VSync callbacks in milliseconds (`None` before 2nd callback).
814 #[get(type(copy))]
815 pub(crate) last_callback_interval_ms: Option<f64>,
816 /// Target presentation timestamp in nanoseconds (`CADisplayLink.targetTimestamp` or Choreographer deadline).
817 #[get(type(copy))]
818 pub(crate) last_target_timestamp_ns: Option<u64>,
819 /// Measured compositor presentation timestamp in nanoseconds (`None` when unobservable on simulator).
820 #[get(type(copy))]
821 pub(crate) last_presented_timestamp_ns: Option<u64>,
822 /// Cumulative count of frames actually submitted and presented.
823 #[get(type(copy))]
824 pub(crate) actual_presented_frames: u64,
825 /// Payload bytes uploaded on the most recent frame (instance+atlas on `GpuDirect`; pixel rects on `GpuUpload`/`Software`).
826 #[get(type(copy))]
827 pub(crate) upload_bytes_last_frame: u64,
828 /// Cumulative payload bytes uploaded across the session.
829 #[get(type(copy))]
830 pub(crate) upload_bytes_total: u64,
831 /// Number of 64-byte `GpuPrimitiveInstance` records drawn on the most recent `GpuDirect` frame.
832 #[get(type(copy))]
833 pub(crate) primitive_count_last_frame: u32,
834 /// Number of GPU draw calls emitted on the most recent frame.
835 #[get(type(copy))]
836 pub(crate) draw_calls_last_frame: u32,
837 /// Cumulative count of submission errors (lock/encode/commit failures).
838 #[get(type(copy))]
839 pub(crate) submit_failures: u64,
840 /// Cumulative count of compositor presentation failures (`eglSwapBuffers` / drawable errors).
841 #[get(type(copy))]
842 pub(crate) present_failures: u64,
843 /// Cumulative count of GPU context-loss events (`EGL_CONTEXT_LOST` / Metal device reset).
844 #[get(type(copy))]
845 pub(crate) context_loss_count: u64,
846 /// Count of blank frames actively prevented by retaining the last valid surface frame during failover.
847 #[get(type(copy))]
848 pub(crate) blank_frames_prevented: u64,
849 /// True when the native surface holds a valid previously presented frame.
850 #[get(type(copy))]
851 pub(crate) last_valid_frame_retained: bool,
852}
853
854/// Immediate zero-blank-frame failover state machine for Android EGL/GLES3 and iOS Metal presentation.
855#[derive(Clone, Copy, Data, Debug, Eq, PartialEq)]
856pub struct MobileFailoverController {
857 /// Currently active presentation path.
858 #[get(type(copy))]
859 pub(crate) active_path: MobilePresentPath,
860 /// Preferred startup presentation path before faults.
861 #[get(type(copy))]
862 pub(crate) preferred_path: MobilePresentPath,
863 /// True once at least one valid frame has been presented to the current window surface.
864 #[get(type(copy))]
865 pub(crate) has_valid_presented_frame: bool,
866 /// True while the OS native window / Metal layer remains attached and valid.
867 #[get(type(copy))]
868 pub(crate) window_valid: bool,
869 /// True when direct GPU uber-shader pipeline is available on this surface.
870 #[get(type(copy))]
871 pub(crate) direct_gpu_available: bool,
872 /// True when texture-upload GPU pipeline is available on this surface.
873 #[get(type(copy))]
874 pub(crate) gpu_upload_available: bool,
875 /// Cumulative context-loss faults observed.
876 #[get(type(copy))]
877 pub(crate) context_loss_count: u64,
878 /// Cumulative blank frames prevented by retaining the last valid frame during fault switchover.
879 #[get(type(copy))]
880 pub(crate) blank_frames_prevented: u64,
881 /// Cumulative immediate fallback path transitions executed without waiting for perf comparisons.
882 #[get(type(copy))]
883 pub(crate) fallback_transitions: u64,
884}
885
886/// Per-shader telemetry entry recorded inside `ShaderPrecompileReport`.
887#[derive(Clone, Data, Debug, Eq, PartialEq)]
888pub struct ShaderProgramCacheEntry {
889 /// Canonical built-in shader program identifier.
890 #[get(type(copy))]
891 pub(crate) program: ShaderProgramId,
892 /// Human-readable shader pipeline title.
893 pub(crate) name: String,
894 /// Target shading language compiled or validated (`MSL`, `WGSL`, `GLSL ES 3.0`, `HLSL SM 6.0`).
895 pub(crate) language: String,
896 /// Current compilation/caching lifecycle state.
897 #[get(type(copy))]
898 pub(crate) state: ShaderCompileState,
899 /// Deterministic 64-bit FNV-1a cache key over shader source and target GPU identity.
900 #[get(type(copy))]
901 pub(crate) source_hash: u64,
902 /// Total shader source payload length in UTF-8 bytes.
903 #[get(type(copy))]
904 pub(crate) source_bytes: usize,
905 /// Measured cold compilation or validation latency in microseconds.
906 #[get(type(copy))]
907 pub(crate) compile_time_us: u64,
908 /// True when the pipeline state object or validated shader cache is ready for zero-hitch drawing.
909 #[get(type(copy))]
910 pub(crate) pipeline_ready: bool,
911}
912
913/// Comprehensive telemetry report returned by ahead-of-time GPU shader precompilation and PSO cache queries.
914#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
915pub struct ShaderPrecompileReport {
916 /// Graphics API backend targeted by this precompilation run.
917 #[get(type(copy))]
918 pub(crate) backend: GraphicsBackend,
919 /// Probed physical GPU adapter name or software fallback label.
920 pub(crate) device_name: String,
921 /// True when real OS GPU hardware compiled the pipelines.
922 #[get(type(copy))]
923 pub(crate) hardware_gpu: bool,
924 /// True when persistent disk-backed binary shader archive caching is active on this device.
925 #[get(type(copy))]
926 pub(crate) binary_archive_enabled: bool,
927 /// True when compiled pipeline binaries were loaded from disk archive instead of fresh compilation.
928 #[get(type(copy))]
929 pub(crate) binary_archive_hit: bool,
930 /// True when this call hit the process-wide warm in-memory PSO cache with zero recompilation.
931 #[get(type(copy))]
932 pub(crate) cache_hit: bool,
933 /// Total built-in shader pipeline programs registered for precompilation.
934 #[get(type(copy))]
935 pub(crate) total_programs: usize,
936 /// Number of shader pipeline programs currently ready for zero-hitch rendering.
937 #[get(type(copy))]
938 pub(crate) ready_programs: usize,
939 /// Number of shader programs compiled into live hardware GPU pipeline state objects.
940 #[get(type(copy))]
941 pub(crate) hardware_compiled_programs: usize,
942 /// Cold first-time compilation duration across all shader programs in microseconds.
943 #[get(type(copy))]
944 pub(crate) cold_compile_us: u64,
945 /// Measured wall-clock duration of this specific `precompile_shaders` invocation in microseconds.
946 #[get(type(copy))]
947 pub(crate) last_call_us: u64,
948 /// Detailed per-shader cache entries ordered by `ShaderProgramId`.
949 pub(crate) entries: Vec<ShaderProgramCacheEntry>,
950}