Skip to main content

naga/common/
external_texture.rs

1/// A member of the `ExternalTextureParams` struct.
2///
3/// The numeric values of this enum are used to generate struct access operations in the
4/// SPIR-V backend.
5///
6/// This definition must match `wgpu_core::device::resource::ExternalTextureParams`
7/// and the special type definition generated by
8/// [`crate::Module::generate_external_texture_types`].
9#[derive(Clone, Copy, Debug, Eq, PartialEq)]
10#[cfg_attr(test, derive(strum::EnumCount))]
11#[repr(u32)]
12pub(crate) enum ExternalTextureParameter {
13    YuvConversionMatrix = 0,
14    GamutConversionMatrix,
15    SrcTf,
16    DstTf,
17    SampleTransform,
18    LoadTransform,
19    Size,
20    NumPlanes,
21}
22
23impl ExternalTextureParameter {
24    pub const COUNT: usize = 8;
25
26    pub const fn name(&self) -> &'static str {
27        use ExternalTextureParameter as P;
28        match *self {
29            P::YuvConversionMatrix => "yuv_conversion_matrix",
30            P::GamutConversionMatrix => "gamut_conversion_matrix",
31            P::SrcTf => "src_tf",
32            P::DstTf => "dst_tf",
33            P::SampleTransform => "sample_transform",
34            P::LoadTransform => "load_transform",
35            P::Size => "size",
36            P::NumPlanes => "num_planes",
37        }
38    }
39}
40
41#[cfg(test)]
42mod tests {
43    #[test]
44    fn parameter_count() {
45        use super::ExternalTextureParameter as P;
46        assert_eq!(P::COUNT, <P as strum::EnumCount>::COUNT);
47    }
48}