1use serde::{Deserialize, Serialize};
10
11#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
13#[serde(rename_all = "snake_case")]
14pub enum D3d12Call {
15 QueueSubmit,
17 Signal,
19 Wait,
21 ResourceCreate,
23 ResourceUpload,
25 ResourceBarrier,
27 DescriptorCopy,
29 DescriptorWrite,
31 CommandListReset,
33 CommandListClose,
35 CommandListExecute,
37 PipelineStateCreate,
39 RootSignatureCreate,
41 MakeResident,
43 Evict,
45 Present,
47 GetCopyableFootprints,
49 Map,
51 Unmap,
53}
54
55#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
57#[serde(rename_all = "snake_case")]
58pub enum VulkanCall {
59 QueueSubmit,
61 QueuePresent,
63 CommandBufferBegin,
65 CommandBufferEnd,
67 PipelineCreate,
69 MemoryAllocate,
71 MemoryMap,
73 ObjectCreate,
75 CmdCopy,
77 CmdCopyBufferToImage,
79 CmdPipelineBarrier,
81 TimelineSignal,
83 TimelineWait,
85 DescriptorUpdate,
87 FenceCreate,
89}
90
91#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
93#[serde(rename_all = "snake_case")]
94pub enum Phase {
95 Instant,
97 Begin,
99 End,
101 Counter,
103}
104
105#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
109#[serde(rename_all = "snake_case")]
110pub enum EventKind {
111 NtReadFile,
114 ReadFile,
116 FileRead,
118 FileOpen,
120 FileClose,
122 MemoryMap,
124 MemoryUnmap,
126 SyncWait,
128 SyncSignal,
130 ThreadCreate,
132 ThreadWakeup,
134 MemoryAlloc,
136 MemoryFree,
138 D3d12(D3d12Call),
140 ResourceUpload,
142 FenceOperation,
144 ShaderCreate,
146 PsoCreate,
148 Present,
150 WinUnixTransition,
153 ServerCall,
155 PathTranslation,
157 CompatibilityAlloc,
159 Syscall,
162 IoUringSubmit,
164 IoUringComplete,
166 IoRead,
168 PageFault,
170 ContextSwitch,
172 SchedulerWakeup,
174 FsLatency,
176 CommandListCreate,
179 Barrier,
181 DescriptorOp,
183 ResourceStateTrack,
185 PipelineCreate,
187 ShaderTranslate,
189 CacheHit,
191 CacheMiss,
193 FenceWait,
195 FenceSignal,
197 VkQueueSubmit,
200 VkCommandBuffer,
202 VkPipelineCreate,
204 VkMemoryAlloc,
206 VkCopy,
208 VkBarrier,
210 VkTimelineSync,
212 VkPresent,
214 GpuTimestamp,
217 GpuIdleBubble,
219 GpuUtilization,
221 GpuDraw,
223 GpuComputeDispatch,
225 KatraSubsystemState,
228 KatraGraphOp,
230 KatraCounter,
232 KatraPrefetch,
234 KatraDecompress,
236 KatraStaging,
238 KatraEpoch,
240 KatraAllocate,
242 KatraIoWait,
244}
245
246impl EventKind {
247 pub fn as_str(self) -> &'static str {
249 match self {
250 EventKind::NtReadFile => "nt_read_file",
251 EventKind::ReadFile => "read_file",
252 EventKind::FileRead => "file_read",
253 EventKind::FileOpen => "file_open",
254 EventKind::FileClose => "file_close",
255 EventKind::MemoryMap => "memory_map",
256 EventKind::MemoryUnmap => "memory_unmap",
257 EventKind::SyncWait => "sync_wait",
258 EventKind::SyncSignal => "sync_signal",
259 EventKind::ThreadCreate => "thread_create",
260 EventKind::ThreadWakeup => "thread_wakeup",
261 EventKind::MemoryAlloc => "memory_alloc",
262 EventKind::MemoryFree => "memory_free",
263 EventKind::D3d12(c) => match c {
264 D3d12Call::QueueSubmit => "d3d12_queue_submit",
265 D3d12Call::Signal => "d3d12_signal",
266 D3d12Call::Wait => "d3d12_wait",
267 D3d12Call::ResourceCreate => "d3d12_resource_create",
268 D3d12Call::ResourceUpload => "d3d12_resource_upload",
269 D3d12Call::ResourceBarrier => "d3d12_resource_barrier",
270 D3d12Call::DescriptorCopy => "d3d12_descriptor_copy",
271 D3d12Call::DescriptorWrite => "d3d12_descriptor_write",
272 D3d12Call::CommandListReset => "d3d12_cmdlist_reset",
273 D3d12Call::CommandListClose => "d3d12_cmdlist_close",
274 D3d12Call::CommandListExecute => "d3d12_cmdlist_execute",
275 D3d12Call::PipelineStateCreate => "d3d12_pso_create",
276 D3d12Call::RootSignatureCreate => "d3d12_root_signature_create",
277 D3d12Call::MakeResident => "d3d12_make_resident",
278 D3d12Call::Evict => "d3d12_evict",
279 D3d12Call::Present => "d3d12_present",
280 D3d12Call::GetCopyableFootprints => "d3d12_copyable_footprints",
281 D3d12Call::Map => "d3d12_map",
282 D3d12Call::Unmap => "d3d12_unmap",
283 },
284 EventKind::ResourceUpload => "resource_upload",
285 EventKind::FenceOperation => "fence_operation",
286 EventKind::ShaderCreate => "shader_create",
287 EventKind::PsoCreate => "pso_create",
288 EventKind::Present => "present",
289 EventKind::WinUnixTransition => "win_unix_transition",
290 EventKind::ServerCall => "server_call",
291 EventKind::PathTranslation => "path_translation",
292 EventKind::CompatibilityAlloc => "compatibility_alloc",
293 EventKind::Syscall => "syscall",
294 EventKind::IoUringSubmit => "io_uring_submit",
295 EventKind::IoUringComplete => "io_uring_complete",
296 EventKind::IoRead => "io_read",
297 EventKind::PageFault => "page_fault",
298 EventKind::ContextSwitch => "context_switch",
299 EventKind::SchedulerWakeup => "scheduler_wakeup",
300 EventKind::FsLatency => "fs_latency",
301 EventKind::CommandListCreate => "command_list_create",
302 EventKind::Barrier => "barrier",
303 EventKind::DescriptorOp => "descriptor_op",
304 EventKind::ResourceStateTrack => "resource_state_track",
305 EventKind::PipelineCreate => "pipeline_create",
306 EventKind::ShaderTranslate => "shader_translate",
307 EventKind::CacheHit => "cache_hit",
308 EventKind::CacheMiss => "cache_miss",
309 EventKind::FenceWait => "fence_wait",
310 EventKind::FenceSignal => "fence_signal",
311 EventKind::VkQueueSubmit => "vk_queue_submit",
312 EventKind::VkCommandBuffer => "vk_command_buffer",
313 EventKind::VkPipelineCreate => "vk_pipeline_create",
314 EventKind::VkMemoryAlloc => "vk_memory_alloc",
315 EventKind::VkCopy => "vk_copy",
316 EventKind::VkBarrier => "vk_barrier",
317 EventKind::VkTimelineSync => "vk_timeline_sync",
318 EventKind::VkPresent => "vk_present",
319 EventKind::GpuTimestamp => "gpu_timestamp",
320 EventKind::GpuIdleBubble => "gpu_idle_bubble",
321 EventKind::GpuUtilization => "gpu_utilization",
322 EventKind::GpuDraw => "gpu_draw",
323 EventKind::GpuComputeDispatch => "gpu_compute_dispatch",
324 EventKind::KatraSubsystemState => "katra_subsystem_state",
325 EventKind::KatraGraphOp => "katra_graph_op",
326 EventKind::KatraCounter => "katra_counter",
327 EventKind::KatraPrefetch => "katra_prefetch",
328 EventKind::KatraDecompress => "katra_decompress",
329 EventKind::KatraStaging => "katra_staging",
330 EventKind::KatraEpoch => "katra_epoch",
331 EventKind::KatraAllocate => "katra_allocate",
332 EventKind::KatraIoWait => "katra_io_wait",
333 }
334 }
335}
336
337impl std::fmt::Display for EventKind {
338 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
339 f.write_str(self.as_str())
340 }
341}