use std::error;
use std::fmt;
use std::sync::Arc;
use command_buffer::CommandAddError;
use command_buffer::cb::AddCommand;
use command_buffer::cb::UnsafeCommandBufferBuilder;
use command_buffer::pool::CommandPool;
use device::Device;
use device::DeviceOwned;
use VulkanObject;
use VulkanPointers;
use vk;
#[derive(Debug, Clone)]
pub struct CmdResolveImage<S, D> {
source: S,
source_raw: vk::Image,
source_layout: vk::ImageLayout,
source_offset: [i32; 3],
source_aspect_mask: vk::ImageAspectFlags,
source_mip_level: u32,
source_base_array_layer: u32,
source_layer_count: u32,
destination: D,
destination_raw: vk::Image,
destination_layout: vk::ImageLayout,
destination_offset: [i32; 3],
destination_aspect_mask: vk::ImageAspectFlags,
destination_mip_level: u32,
destination_base_array_layer: u32,
destination_layer_count: u32,
extent: [u32; 3],
}
impl<S, D> CmdResolveImage<S, D> {
#[inline]
pub fn source(&self) -> &S {
&self.source
}
#[inline]
pub fn destination(&self) -> &D {
&self.destination
}
}
unsafe impl<S, D> DeviceOwned for CmdResolveImage<S, D> where S: DeviceOwned {
#[inline]
fn device(&self) -> &Arc<Device> {
self.source.device()
}
}
unsafe impl<'a, P, S, D> AddCommand<&'a CmdResolveImage<S, D>> for UnsafeCommandBufferBuilder<P>
where P: CommandPool
{
type Out = UnsafeCommandBufferBuilder<P>;
#[inline]
fn add(self, command: &'a CmdResolveImage<S, D>) -> Result<Self::Out, CommandAddError> {
unsafe {
debug_assert!(command.source_layout == vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL ||
command.source_layout == vk::IMAGE_LAYOUT_GENERAL);
debug_assert!(command.destination_layout == vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL ||
command.destination_layout == vk::IMAGE_LAYOUT_GENERAL);
let region = vk::ImageResolve {
srcSubresource: vk::ImageSubresourceLayers {
aspectMask: command.source_aspect_mask,
mipLevel: command.source_mip_level,
baseArrayLayer: command.source_base_array_layer,
layerCount: command.source_layer_count,
},
srcOffset: vk::Offset3D {
x: command.source_offset[0],
y: command.source_offset[1],
z: command.source_offset[2],
},
dstSubresource: vk::ImageSubresourceLayers {
aspectMask: command.destination_aspect_mask,
mipLevel: command.destination_mip_level,
baseArrayLayer: command.destination_base_array_layer,
layerCount: command.destination_layer_count,
},
dstOffset: vk::Offset3D {
x: command.destination_offset[0],
y: command.destination_offset[1],
z: command.destination_offset[2],
},
extent: vk::Extent3D {
width: command.extent[0],
height: command.extent[1],
depth: command.extent[2],
},
};
let vk = self.device().pointers();
let cmd = self.internal_object();
vk.CmdResolveImage(cmd, command.source_raw, command.source_layout,
command.destination_raw, command.destination_layout,
1, ®ion as *const _);
}
Ok(self)
}
}
#[derive(Debug, Copy, Clone)]
pub enum CmdResolveImageError {
}
impl error::Error for CmdResolveImageError {
#[inline]
fn description(&self) -> &str {
match *self {
}
}
}
impl fmt::Display for CmdResolveImageError {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "{}", error::Error::description(self))
}
}