wgpu/api/
common_pipeline.rs

1use crate::*;
2
3#[derive(Clone, Debug)]
4/// Advanced options for use when a pipeline is compiled
5///
6/// This implements `Default`, and for most users can be set to `Default::default()`
7pub struct PipelineCompilationOptions<'a> {
8    /// Specifies the values of pipeline-overridable constants in the shader module.
9    ///
10    /// If an `@id` attribute was specified on the declaration,
11    /// the key must be the pipeline constant ID as a decimal ASCII number; if not,
12    /// the key must be the constant's identifier name.
13    ///
14    /// If the given constant is specified more than once, the last value specified is used.
15    ///
16    /// The value may represent any of WGSL's concrete scalar types.
17    pub constants: &'a [(&'a str, f64)],
18    /// Whether workgroup scoped memory will be initialized with zero values for this stage.
19    ///
20    /// This is required by the WebGPU spec, but may have overhead which can be avoided
21    /// for cross-platform applications
22    pub zero_initialize_workgroup_memory: bool,
23}
24
25impl Default for PipelineCompilationOptions<'_> {
26    fn default() -> Self {
27        Self {
28            constants: Default::default(),
29            zero_initialize_workgroup_memory: true,
30        }
31    }
32}
33
34/// Describes a pipeline cache, which allows reusing compilation work
35/// between program runs.
36///
37/// For use with [`Device::create_pipeline_cache`].
38///
39/// This type is unique to the Rust API of `wgpu`.
40#[derive(Clone, Debug)]
41pub struct PipelineCacheDescriptor<'a> {
42    /// Debug label of the pipeline cache. This might show up in some logs from `wgpu`
43    pub label: Label<'a>,
44    /// The data used to initialise the cache initialise
45    ///
46    /// # Safety
47    ///
48    /// This data must have been provided from a previous call to
49    /// [`PipelineCache::get_data`], if not `None`
50    pub data: Option<&'a [u8]>,
51    /// Whether to create a cache without data when the provided data
52    /// is invalid.
53    ///
54    /// Recommended to set to true
55    pub fallback: bool,
56}
57#[cfg(send_sync)]
58static_assertions::assert_impl_all!(PipelineCacheDescriptor<'_>: Send, Sync);