1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! A query object is used to fetch some data from rendering operations asynchronously. See
//! [`GpuQueryTrait`] docs for more info.
use cratedefine_shared_wrapper;
use define_as_any_trait;
use Debug;
/// Kind of a GPU query.
/// Result of a query.
define_as_any_trait!;
/// A query object is used to fetch some data from rendering operations asynchronously. Usually it
/// is used to perform occlusion queries.
///
/// ## Examples
///
/// The following examples shows how to create a new GPU query, run it and fetch the result.
///
/// ```rust
/// use fyrox_graphics::{
/// error::FrameworkError,
/// query::{QueryKind, QueryResult},
/// server::GraphicsServer,
/// };
///
/// fn query(server: &dyn GraphicsServer) -> Result<(), FrameworkError> {
/// // Initialization.
/// let query = server.create_query()?;
///
/// // Somewhere in the rendering loop.
/// if !query.is_started() {
/// query.begin(QueryKind::AnySamplesPassed);
///
/// // Draw something.
///
/// query.end();
/// } else if let Some(QueryResult::AnySamplesPassed(any_samples_passed)) =
/// query.try_get_result()
/// {
/// println!("{any_samples_passed}");
/// }
///
/// Ok(())
/// }
/// ```
///
/// Keep in mind that you should always re-use the queries instead of creating them on the fly!
/// This is much more efficient, because it removes all redundant memory allocations and calls
/// to the GPU driver.
define_shared_wrapper!;