1#[cfg_attr(not(feature = "tracy"), derive(PartialEq))]
3#[derive(thiserror::Error, Debug)]
4pub enum CreationError {
5 #[error(transparent)]
6 InvalidSettings(#[from] SettingsError),
7
8 #[cfg(feature = "tracy")]
9 #[error("Tracy client doesn't run yet.")]
10 TracyClientNotRunning,
11
12 #[cfg(feature = "tracy")]
13 #[error("Failed to create Tracy GPU context: {0}")]
14 TracyGpuContextCreationError(#[from] tracy_client::GpuContextCreationError),
15}
16
17#[cfg(feature = "tracy")]
18impl PartialEq for CreationError {
19 fn eq(&self, other: &Self) -> bool {
20 match self {
21 CreationError::InvalidSettings(left) => match other {
22 CreationError::InvalidSettings(right) => left == right,
23 _ => false,
24 },
25 CreationError::TracyClientNotRunning => {
26 matches!(other, CreationError::TracyClientNotRunning)
27 }
28 CreationError::TracyGpuContextCreationError(left) => match left {
29 tracy_client::GpuContextCreationError::TooManyContextsCreated => matches!(
30 other,
31 CreationError::TracyGpuContextCreationError(
32 tracy_client::GpuContextCreationError::TooManyContextsCreated
33 )
34 ),
35 },
36 }
37 }
38}
39
40impl Eq for CreationError {}
41
42#[derive(thiserror::Error, Debug, PartialEq, Eq)]
44pub enum SettingsError {
45 #[error("GpuProfilerSettings::max_num_pending_frames must be at least 1.")]
46 InvalidMaxNumPendingFrames,
47}
48
49#[derive(thiserror::Error, Debug, PartialEq, Eq)]
51pub enum EndFrameError {
52 #[error("All profiling queries need to be closed before ending a frame. There were still {0} open queries.")]
53 UnclosedQueries(u32),
54
55 #[error(
56 "Not all queries were resolved before ending a frame.\n
57Call `GpuProfiler::resolve_queries` after all profiling queries have been closed and before ending the frame.\n
58There were still {0} queries unresolved."
59 )]
60 UnresolvedQueries(u32),
61}