Skip to main content

rhyoea/extends/
mod.rs

1// Rhyoea. Vulkan FFI bindings for Rust
2// Copyright © 2019 Adrien Jeser <adrien@jeser.me>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Affero General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU Affero General Public License for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Extends Vulkan
18//!
19//! Additional functionality may be provided by layers or extensions. A layer
20//! cannot add or modify Vulkan commands, while an extension may do so.
21//!
22//! The set of layers to enable is specified when creating an instance, and
23//! those layers are able to intercept any Vulkan command dispatched to that
24//! instance or any of its child objects.
25//!
26//! Extensions can operate at either the instance or device extension scope.
27//! Enabled instance extensions are able to affect the operation of the
28//! instance and any of its child objects, while device extensions may only be
29//! available on a subset of physical devices, must be individually enabled
30//! per-device, and only affect the operation of the devices where they are
31//! enabled.
32//!
33//! Examples of these might be:
34//!
35//! * Whole API validation is an example of a layer.
36//!
37//! * Debug capabilities might make a good instance extension.
38//!
39//! * A layer that provides hardware-specific performance telemetry and
40//! analysis could be a layer that is only active for devices created from
41//! compatible physical devices.
42//!
43//! * Functions to allow an application to use additional hardware features
44//! beyond the core would be a good candidate for a device extension.
45
46pub mod extension;
47mod extension_bind;
48pub mod layer;
49mod layer_bind;
50
51pub use crate::extends::extension::{Extension, Extensions};
52pub use crate::extends::layer::{Layer, Layers};
53
54/// Vulkan extends
55pub trait Extends {
56    /// Returns the name
57    ///
58    /// # Example
59    /// ```
60    /// use rhyoea::extends::{Extends, Extensions, Extension};
61    ///
62    /// let extensions = Extensions::available();
63    /// let name_extensions: Vec<_> = extensions
64    ///   .into_iter()
65    ///   .map(|extension| extension.name().clone())
66    ///   .collect();
67    fn name(&self) -> &String;
68}
69
70/// TODO: Doc
71pub trait Filtrable {
72    /// TODO: Doc
73    #[must_use]
74    fn require_extension(_extension: &Extension) -> bool {
75        false
76    }
77
78    /// TODO: Doc
79    #[must_use]
80    fn require_layer(_layer: &Layer) -> bool {
81        false
82    }
83
84    /// TODO: Doc
85    #[must_use]
86    fn suggest_extension(_extension: &Extension) -> bool {
87        false
88    }
89
90    /// TODO: Doc
91    #[must_use]
92    fn suggest_layer(_layer: &Layer) -> bool {
93        false
94    }
95}