Skip to main content

cvkg_render_gpu/
types.rs

1//! Core data types, internal structs, and rendering contexts.
2use cvkg_core::Rect;
3use crate::vertex::Vertex;
4
5/// SvgModel — A collection of tessellated triangles representing a vector icon.
6#[derive(Clone, Debug)]
7pub struct SvgModel {
8    pub vertices: Vec<Vertex>,
9    pub indices: Vec<u32>,
10    pub view_box: Rect,
11    pub animations: Vec<SvgAnimation>,
12}
13
14#[derive(Clone, Debug)]
15pub struct SvgAnimation {
16    pub target_id: String,
17    pub attribute_name: String,
18    pub from_val: f32,
19    pub to_val: f32,
20    pub duration: f32,
21    pub vertex_range: std::ops::Range<usize>,
22}
23
24/// Represents a single batched GPU draw call.
25/// Batches are broken whenever the active texture or primitive mode changes.
26#[derive(Debug, Clone)]
27pub(crate) struct DrawCall {
28    pub texture_id: Option<u32>,
29    pub scissor_rect: Option<Rect>,
30    pub index_start: u32,
31    pub index_count: u32,
32    /// Material routing tag — determines which pass this draw call is routed to
33    /// in the multi-pass Backdrop Capture pipeline.
34    pub material: cvkg_core::DrawMaterial,
35}
36
37#[derive(Debug, Clone, Copy)]
38pub(crate) struct ShadowState {
39    pub radius: f32,
40    pub color: [f32; 4],
41    pub _offset: [f32; 2],
42}
43
44#[allow(dead_code)]
45pub(crate) struct SurfaceContext {
46    pub(crate) surface: wgpu::Surface<'static>,
47    pub(crate) config: wgpu::SurfaceConfiguration,
48    pub(crate) scene_texture: wgpu::TextureView,
49    pub(crate) scene_bind_group: wgpu::BindGroup,
50    pub(crate) scene_texture_bind_group: wgpu::BindGroup,
51    pub(crate) depth_texture_view: wgpu::TextureView,
52    // Dedicated backdrop blur textures - used only for glass backdrop blur
53    // Stores raw Texture (for mip view creation) and default view (for binding)
54    pub(crate) blur_tex_a: wgpu::Texture,
55    pub(crate) blur_texture_a: wgpu::TextureView,
56    pub(crate) blur_tex_b: wgpu::Texture,
57    pub(crate) blur_texture_b: wgpu::TextureView,
58    pub(crate) blur_bind_group_a: wgpu::BindGroup,
59    pub(crate) blur_bind_group_b: wgpu::BindGroup,
60    pub(crate) blur_env_bind_group_a: wgpu::BindGroup,
61    // Dedicated bloom textures - used only for bloom extraction and blur
62    pub(crate) bloom_tex_a: wgpu::Texture,
63    pub(crate) bloom_texture_a: wgpu::TextureView,
64    pub(crate) bloom_tex_b: wgpu::Texture,
65    pub(crate) bloom_texture_b: wgpu::TextureView,
66    pub(crate) bloom_bind_group_a: wgpu::BindGroup,
67    pub(crate) bloom_bind_group_b: wgpu::BindGroup,
68    pub(crate) bloom_env_bind_group_a: wgpu::BindGroup,
69    pub(crate) scale_factor: f32,
70    pub(crate) sampler: wgpu::Sampler,
71}
72
73/// HeadlessContext — A rendering target for surface-less execution.
74#[allow(dead_code)]
75pub struct HeadlessContext {
76    pub scene_texture: wgpu::TextureView,
77    pub scene_bind_group: wgpu::BindGroup,
78    pub scene_texture_bind_group: wgpu::BindGroup,
79    pub depth_texture_view: wgpu::TextureView,
80    // Dedicated backdrop blur textures - used only for glass backdrop blur
81    pub blur_tex_a: wgpu::Texture,
82    pub blur_texture_a: wgpu::TextureView,
83    pub blur_tex_b: wgpu::Texture,
84    pub blur_texture_b: wgpu::TextureView,
85    pub blur_bind_group_a: wgpu::BindGroup,
86    pub blur_bind_group_b: wgpu::BindGroup,
87    pub blur_env_bind_group_a: wgpu::BindGroup,
88    // Dedicated bloom textures - used only for bloom extraction and blur
89    pub bloom_tex_a: wgpu::Texture,
90    pub bloom_texture_a: wgpu::TextureView,
91    pub bloom_tex_b: wgpu::Texture,
92    pub bloom_texture_b: wgpu::TextureView,
93    pub bloom_bind_group_a: wgpu::BindGroup,
94    pub bloom_bind_group_b: wgpu::BindGroup,
95    pub bloom_env_bind_group_a: wgpu::BindGroup,
96    pub scale_factor: f32,
97    pub sampler: wgpu::Sampler,
98    pub width: u32,
99    pub height: u32,
100    pub output_texture: wgpu::Texture,
101    pub output_view: wgpu::TextureView,
102}
103
104pub(crate) const MAX_VERTICES: usize = 100_000;
105pub(crate) const MAX_INDICES: usize = 150_000;