summaryrefslogtreecommitdiffstats
path: root/third_party/rust/gfx-backend-empty/src/image.rs
blob: c83af2366ec67f4acd9e49b5920a84acff3d5c27 (plain)
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
use hal::image::Kind;
use hal::memory::Requirements as MemoryRequirements;

#[derive(Debug)]
pub struct Image {
    /// What type of image this is, as well as its extent.
    kind: Kind,
}

impl Image {
    pub fn new(kind: Kind) -> Self {
        Image { kind }
    }

    pub fn get_requirements(&self) -> MemoryRequirements {
        let size = match self.kind {
            Kind::D2(width, height, layers, samples) => {
                assert_eq!(layers, 1, "Multi-layer images are not supported");
                assert_eq!(samples, 1, "Multisampled images are not supported");
                u64::from(width) * u64::from(height)
            }
            _ => unimplemented!("Unsupported image kind"),
        };
        MemoryRequirements {
            size,
            alignment: 1,
            type_mask: !0,
        }
    }
}