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/// Physical OS GPU driver wrapping Metal, D3D12, Vulkan, or WebGL2 with automatic recording fallback.
20#[derive(Debug, Getter)]
21pub struct NativeGpuDriver {
22 /// Probed physical adapter and shader status.
23 pub(crate) adapter: GpuAdapterInfo,
24 /// Opaque OS GPU device handle (`id<MTLDevice>` on Apple, `0` when fallback).
25 #[get(type(copy))]
26 pub(crate) device_handle: usize,
27 /// Opaque OS GPU command queue handle (`id<MTLCommandQueue>` on Apple, `0` when fallback).
28 #[get(type(copy))]
29 pub(crate) queue_handle: usize,
30 /// Opaque compiled shader library handle (`id<MTLLibrary>` on Apple, `0` when fallback).
31 #[get(type(copy))]
32 pub(crate) library_handle: usize,
33 /// Persistent grow-only Metal staging `id<MTLBuffer>` handle reused across frames (`0` when unallocated).
34 #[get(skip)]
35 pub(crate) staging_buffer_handle: usize,
36 /// Cached CPU-writable `contents()` address of the active shared-mode staging `MTLBuffer` (`0` when unallocated).
37 #[get(skip)]
38 pub(crate) staging_contents_ptr: usize,
39 /// Byte capacity of the retained staging `MTLBuffer`.
40 #[get(skip)]
41 pub(crate) staging_buffer_capacity: usize,
42 /// Total GPU frames submitted through this driver.
43 #[get(type(copy))]
44 pub(crate) submitted_frames: u64,
45 /// Total instanced quad uploads submitted to the GPU.
46 #[get(type(copy))]
47 pub(crate) uploaded_instances: u64,
48 /// Cumulative instance payload bytes uploaded to the GPU across all frames.
49 #[get(type(copy))]
50 pub(crate) uploaded_bytes: u64,
51 /// Instance payload bytes uploaded during the most recent submitted frame.
52 #[get(type(copy))]
53 pub(crate) last_upload_bytes: usize,
54 /// Number of draw batches submitted during the most recent frame.
55 #[get(type(copy))]
56 pub(crate) last_submitted_batches: usize,
57 /// Number of persistent staging buffer allocations or grows across the driver's lifetime.
58 #[get(type(copy))]
59 pub(crate) staging_reallocations: u64,
60 /// Fallback command recorder active on headless hosts.
61 pub(crate) fallback: RecordingGpuDriver,
62}
63
64/// Process-wide cached Objective-C selector pointers for Apple Metal hot-path submission.
65#[cfg(any(target_os = "macos", target_os = "ios"))]
66#[derive(Clone, Copy, Debug)]
67pub(crate) struct MetalSelectors {
68 /// Cached `newBufferWithBytes:length:options:` selector address.
69 pub(crate) new_buffer_with_bytes: usize,
70 /// Cached `newBufferWithLength:options:` selector address.
71 pub(crate) new_buffer_with_length: usize,
72 /// Cached `contents` selector address.
73 pub(crate) contents: usize,
74 /// Cached `commandBuffer` selector address.
75 pub(crate) command_buffer: usize,
76 /// Cached `commit` selector address.
77 pub(crate) commit: usize,
78 /// Cached `release` selector address.
79 pub(crate) release: usize,
80}