euv_core/render/hardware/struct.rs
1use super::*;
2
3/// Tightly packed GPU instance payload uploaded directly to Metal, Vulkan, D3D12, WebGPU, or WebGL2 buffers.
4#[repr(C)]
5#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
6pub struct GpuQuadInstance {
7 /// Destination bounds `[x, y, width, height]` in physical pixels.
8 #[get(type(copy))]
9 pub(crate) rect: [f32; 4],
10 /// Clip bounds `[x0, y0, x1, y1]` in physical pixels.
11 #[get(type(copy))]
12 pub(crate) clip: [f32; 4],
13 /// Primary normalized RGBA color.
14 #[get(type(copy))]
15 pub(crate) color: [f32; 4],
16 /// Secondary color (border color or gradient end color).
17 #[get(type(copy))]
18 pub(crate) secondary_color: [f32; 4],
19 /// Corner radii `[tl, tr, br, bl]` in physical pixels.
20 #[get(type(copy))]
21 pub(crate) radii: [f32; 4],
22 /// Border width or blur radius in physical pixels.
23 #[get(type(copy))]
24 pub(crate) stroke_or_blur: f32,
25 /// Gradient angle in radians.
26 #[get(type(copy))]
27 pub(crate) angle_rad: f32,
28 /// Encoded `GpuPrimitiveKind` discriminant.
29 #[get(type(copy))]
30 pub(crate) kind: u32,
31 /// Padding for 16-byte GPU std140/std430 alignment.
32 #[get(type(copy))]
33 pub(crate) reserved: u32,
34}
35
36/// Coalesced instanced GPU draw batch submitted as a single hardware draw call.
37#[derive(Clone, Data, Debug, Default, PartialEq)]
38pub struct GpuBatch {
39 /// Active scissor rectangle in physical pixels.
40 #[get(type(copy))]
41 pub(crate) scissor: Rect,
42 /// Instanced quad stream belonging to this batch.
43 pub(crate) instances: Vec<GpuQuadInstance>,
44}
45
46/// Recording GPU driver used on headless targets and as a hardware-contract validator.
47#[derive(Clone, Data, Debug, Default)]
48pub struct RecordingGpuDriver {
49 /// Emulated or bound graphics backend tag.
50 #[get(type(copy))]
51 pub(crate) backend_kind: GraphicsBackend,
52 /// Total draw batches submitted across frames.
53 #[get(type(copy))]
54 pub(crate) total_draw_calls: usize,
55 /// Total GPU quad instances submitted in the most recent frame.
56 #[get(type(copy))]
57 pub(crate) last_instance_count: usize,
58 /// Last clear color submitted.
59 #[get(type(copy))]
60 pub(crate) last_clear: Color,
61}
62
63/// Hardware GPU renderer compiling `DisplayList` streams into coalesced instanced `GpuBatch` calls.
64#[derive(Data, Debug, Default)]
65pub struct HardwareRenderer {
66 /// Active physical OS GPU driver handling shader compilation and batch submission.
67 pub(crate) driver: NativeGpuDriver,
68 /// Reusable batch scratch buffer avoiding per-frame allocations.
69 #[get(pub(crate))]
70 #[get_mut(pub(crate))]
71 #[set(pub(crate))]
72 pub(crate) batches: Vec<GpuBatch>,
73 /// Optional software readback mirror used for deterministic pixel-parity testing.
74 pub(crate) readback: SoftwareRenderer,
75 /// Whether readback mirroring is enabled.
76 #[get(type(copy))]
77 pub(crate) enable_readback: bool,
78}