1#[derive(Debug, Clone)]
8pub struct ParamDebugInfo {
9 pub name: String,
11 pub param_type: String,
13 pub widget: String,
15 pub current_value: String,
17 pub offset: u64,
19 pub size: u64,
21}
22
23#[derive(Debug, Clone)]
25pub struct PortDebugInfo {
26 pub name: String,
28 pub direction: String,
30 pub port_type: String,
32 pub binding: u32,
34 pub format: Option<String>,
36 pub is_connected: bool,
38}
39
40#[derive(Debug, Clone)]
42pub struct ActionDebugInfo {
43 pub id: String,
45 pub label: String,
47 pub action_type: String,
49}
50
51#[derive(Debug, Clone)]
53pub struct NodeDebugInfo {
54 pub id: String,
56 pub def_id: String,
58 pub name: String,
60 pub kind: String,
62 pub inputs: Vec<(usize, String)>,
64 pub output_texture: Option<TextureDebugInfo>,
66 pub buffer_offset: Option<u64>,
68 pub buffer_size: Option<u64>,
70 pub actions: Vec<ActionDebugInfo>,
72 pub params: Vec<ParamDebugInfo>,
74 pub ports: Vec<PortDebugInfo>,
76}
77
78#[derive(Debug, Clone)]
80pub struct TextureDebugInfo {
81 pub name: String,
83 pub width: u32,
85 pub height: u32,
87 pub format: String,
89 pub is_external: bool,
91}
92
93#[derive(Debug, Clone, Default)]
95pub struct GraphDebugInfo {
96 pub nodes: Vec<NodeDebugInfo>,
98 pub external_textures: Vec<TextureDebugInfo>,
100 pub intermediate_textures: Vec<TextureDebugInfo>,
102 pub is_compiled: bool,
104 pub param_buffer_size: Option<u64>,
106 pub execution_steps: usize,
108}
109
110impl GraphDebugInfo {
111 pub fn empty() -> Self {
113 Self::default()
114 }
115}
116
117#[cfg(test)]
118mod tests {
119 use super::*;
120
121 #[test]
122 fn test_node_debug_info_creation() {
123 let info = NodeDebugInfo {
124 id: "node_1".to_string(),
125 def_id: "solid-color".to_string(),
126 name: "Solid Color".to_string(),
127 kind: "Shader(Fragment)".to_string(),
128 inputs: vec![(0, "node_0".to_string())],
129 output_texture: None,
130 buffer_offset: Some(0),
131 buffer_size: Some(16),
132 actions: vec![ActionDebugInfo {
133 id: "flash".to_string(),
134 label: "Flash".to_string(),
135 action_type: "BeatSync".to_string(),
136 }],
137 params: vec![ParamDebugInfo {
138 name: "intensity".to_string(),
139 param_type: "f32".to_string(),
140 widget: "slider".to_string(),
141 current_value: "0.5".to_string(),
142 offset: 0,
143 size: 4,
144 }],
145 ports: vec![PortDebugInfo {
146 name: "output".to_string(),
147 direction: "output".to_string(),
148 port_type: "texture".to_string(),
149 binding: 0,
150 format: None,
151 is_connected: true,
152 }],
153 };
154
155 assert_eq!(info.id, "node_1");
156 assert_eq!(info.def_id, "solid-color");
157 assert_eq!(info.inputs.len(), 1);
158 assert_eq!(info.buffer_offset, Some(0));
159 assert_eq!(info.actions.len(), 1);
160 assert_eq!(info.actions[0].id, "flash");
161 assert_eq!(info.params.len(), 1);
162 assert_eq!(info.params[0].name, "intensity");
163 assert_eq!(info.ports.len(), 1);
164 }
165
166 #[test]
167 fn test_texture_debug_info_creation() {
168 let info = TextureDebugInfo {
169 name: "intermediate_0".to_string(),
170 width: 1920,
171 height: 1080,
172 format: "Rgba8Unorm".to_string(),
173 is_external: false,
174 };
175
176 assert_eq!(info.width, 1920);
177 assert_eq!(info.height, 1080);
178 assert!(!info.is_external);
179 }
180
181 #[test]
182 fn test_graph_debug_info_empty() {
183 let info = GraphDebugInfo::empty();
184
185 assert!(info.nodes.is_empty());
186 assert!(info.external_textures.is_empty());
187 assert!(info.intermediate_textures.is_empty());
188 assert!(!info.is_compiled);
189 assert_eq!(info.param_buffer_size, None);
190 assert_eq!(info.execution_steps, 0);
191 }
192
193 #[test]
194 fn test_graph_debug_info_with_nodes() {
195 let mut info = GraphDebugInfo::empty();
196
197 info.nodes.push(NodeDebugInfo {
198 id: "1v1".to_string(),
199 def_id: "empty".to_string(),
200 name: "Empty".to_string(),
201 kind: "Shader(Fragment)".to_string(),
202 inputs: vec![],
203 output_texture: Some(TextureDebugInfo {
204 name: "intermediate_0".to_string(),
205 width: 1920,
206 height: 1080,
207 format: "Rgba8Unorm".to_string(),
208 is_external: false,
209 }),
210 buffer_offset: None,
211 buffer_size: None,
212 actions: vec![],
213 params: vec![],
214 ports: vec![],
215 });
216
217 info.is_compiled = true;
218 info.execution_steps = 2;
219
220 assert_eq!(info.nodes.len(), 1);
221 assert!(info.is_compiled);
222 assert_eq!(info.execution_steps, 2);
223 assert!(info.nodes[0].output_texture.is_some());
224 }
225
226 #[test]
227 fn test_debug_info_clone() {
228 let info = NodeDebugInfo {
229 id: "test".to_string(),
230 def_id: "test-def".to_string(),
231 name: "Test".to_string(),
232 kind: "Shader".to_string(),
233 inputs: vec![(0, "other".to_string())],
234 output_texture: None,
235 buffer_offset: Some(256),
236 buffer_size: Some(32),
237 actions: vec![],
238 params: vec![],
239 ports: vec![],
240 };
241
242 let cloned = info.clone();
243 assert_eq!(info.id, cloned.id);
244 assert_eq!(info.buffer_offset, cloned.buffer_offset);
245 }
246}