diff --git a/vulkano/src/command_buffer/cb/auto_barriers.rs b/vulkano/src/command_buffer/cb/auto_barriers.rs index 34c74a6a..1098362f 100644 --- a/vulkano/src/command_buffer/cb/auto_barriers.rs +++ b/vulkano/src/command_buffer/cb/auto_barriers.rs @@ -97,6 +97,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); //pass_through!((B), cmd::CmdUpdateBuffer); diff --git a/vulkano/src/command_buffer/cb/buffered.rs b/vulkano/src/command_buffer/cb/buffered.rs index 9566e4a1..d7fe9fb1 100644 --- a/vulkano/src/command_buffer/cb/buffered.rs +++ b/vulkano/src/command_buffer/cb/buffered.rs @@ -196,6 +196,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/commands_list.rs b/vulkano/src/command_buffer/cb/commands_list.rs index ab69bb68..8f463d88 100644 --- a/vulkano/src/command_buffer/cb/commands_list.rs +++ b/vulkano/src/command_buffer/cb/commands_list.rs @@ -112,6 +112,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/context_check.rs b/vulkano/src/command_buffer/cb/context_check.rs index a13a9730..2236694a 100644 --- a/vulkano/src/command_buffer/cb/context_check.rs +++ b/vulkano/src/command_buffer/cb/context_check.rs @@ -100,6 +100,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/device_check.rs b/vulkano/src/command_buffer/cb/device_check.rs index 69285255..213adc18 100644 --- a/vulkano/src/command_buffer/cb/device_check.rs +++ b/vulkano/src/command_buffer/cb/device_check.rs @@ -115,6 +115,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass, no-device); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/queue_ty_check.rs b/vulkano/src/command_buffer/cb/queue_ty_check.rs index 5b2a5456..b4a65eb6 100644 --- a/vulkano/src/command_buffer/cb/queue_ty_check.rs +++ b/vulkano/src/command_buffer/cb/queue_ty_check.rs @@ -100,6 +100,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/state_cache.rs b/vulkano/src/command_buffer/cb/state_cache.rs index 6cc4ddc1..c23dde54 100644 --- a/vulkano/src/command_buffer/cb/state_cache.rs +++ b/vulkano/src/command_buffer/cb/state_cache.rs @@ -213,5 +213,6 @@ pass_through!((), cmd::CmdEndRenderPass); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/submit_sync.rs b/vulkano/src/command_buffer/cb/submit_sync.rs index c9ac470c..78bb9296 100644 --- a/vulkano/src/command_buffer/cb/submit_sync.rs +++ b/vulkano/src/command_buffer/cb/submit_sync.rs @@ -91,6 +91,7 @@ pass_through!((C), cmd::CmdExecuteCommands); pass_through!((B), cmd::CmdFillBuffer); pass_through!((), cmd::CmdNextSubpass); pass_through!((Pc, Pl), cmd::CmdPushConstants); +pass_through!((S, D), cmd::CmdResolveImage); pass_through!((), cmd::CmdSetEvent); pass_through!((), cmd::CmdSetState); pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cmd/mod.rs b/vulkano/src/command_buffer/cmd/mod.rs index 881c5c6a..65c6e6f2 100644 --- a/vulkano/src/command_buffer/cmd/mod.rs +++ b/vulkano/src/command_buffer/cmd/mod.rs @@ -32,6 +32,7 @@ pub use self::fill_buffer::{CmdFillBuffer, CmdFillBufferError}; pub use self::next_subpass::CmdNextSubpass; pub use self::pipeline_barrier::CmdPipelineBarrier; pub use self::push_constants::{CmdPushConstants, CmdPushConstantsError}; +pub use self::resolve_image::{CmdResolveImage, CmdResolveImageError}; pub use self::set_event::CmdSetEvent; pub use self::set_state::{CmdSetState}; pub use self::update_buffer::{CmdUpdateBuffer, CmdUpdateBufferError}; @@ -58,6 +59,7 @@ mod fill_buffer; mod next_subpass; mod pipeline_barrier; mod push_constants; +mod resolve_image; mod set_event; mod set_state; mod update_buffer; diff --git a/vulkano/src/command_buffer/cmd/resolve_image.rs b/vulkano/src/command_buffer/cmd/resolve_image.rs new file mode 100644 index 00000000..e8106c7f --- /dev/null +++ b/vulkano/src/command_buffer/cmd/resolve_image.rs @@ -0,0 +1,134 @@ +// Copyright (c) 2016 The vulkano developers +// Licensed under the Apache License, Version 2.0 +// or the MIT +// license , +// at your option. All files in the project carrying such +// notice may not be copied, modified, or distributed except +// according to those terms. + +use std::error; +use std::fmt; +use std::sync::Arc; +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; + +/// Command that resolves a multisample image into a non-multisample one. +#[derive(Debug, Clone)] +pub struct CmdResolveImage { + // The source image. + source: S, + // Raw source image. + source_raw: vk::Image, + // Layout of the source image. + source_layout: vk::ImageLayout, + // Offset in the source. + source_offset: [i32; 3], + source_aspect_mask: vk::ImageAspectFlags, + source_mip_level: u32, + source_base_array_layer: u32, + source_layer_count: u32, + // The destination image. + destination: D, + // Raw destination image. + destination_raw: vk::Image, + // Layout of the destination image. + destination_layout: vk::ImageLayout, + // Offset in the destination. + destination_offset: [i32; 3], + destination_aspect_mask: vk::ImageAspectFlags, + destination_mip_level: u32, + destination_base_array_layer: u32, + destination_layer_count: u32, + // Size. + extent: [u32; 3], +} + +// TODO: add constructor + +unsafe impl DeviceOwned for CmdResolveImage where S: DeviceOwned { + #[inline] + fn device(&self) -> &Arc { + self.source.device() + } +} + +unsafe impl<'a, P, S, D> AddCommand<&'a CmdResolveImage> for UnsafeCommandBufferBuilder

+ where P: CommandPool +{ + type Out = UnsafeCommandBufferBuilder

; + + #[inline] + fn add(self, command: &'a CmdResolveImage) -> Self::Out { + 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 _); + } + + self + } +} + +/// Error that can happen when creating a `CmdResolveImage`. +#[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)) + } +}