use std::cell::Cell;
use crate::Result;
pub(super) struct ComposeImage {
pub(super) bindless_index: u32,
pub(super) width: u32,
pub(super) height: u32,
engine_handle: crate::runtime::EngineHandle,
raw_image: ash::vk::Image,
layout: Cell<ash::vk::ImageLayout>,
}
impl ComposeImage {
pub(super) fn new(
engine: &crate::runtime::EngineHandle,
width: u32,
height: u32,
) -> Result<Self> {
let (raw_image, bindless_index) = engine.create_compose_image(width, height)?;
Ok(Self {
bindless_index,
width,
height,
engine_handle: engine.clone(),
raw_image,
layout: Cell::new(ash::vk::ImageLayout::UNDEFINED),
})
}
pub(super) const fn raw_image(&self) -> ash::vk::Image {
self.raw_image
}
pub(super) fn layout(&self) -> ash::vk::ImageLayout {
self.layout.get()
}
pub(super) fn set_layout(&self, layout: ash::vk::ImageLayout) {
self.layout.set(layout);
}
}
impl Drop for ComposeImage {
fn drop(&mut self) {
self
.engine_handle
.destroy_compose_image(self.raw_image, self.bindless_index);
}
}