Merge pull request #467 from tomaka/img-layout-extract

Extract Layout to its own module and rename to ImageLayout
This commit is contained in:
tomaka 2017-05-20 11:25:10 +02:00 committed by GitHub
commit 97160086c6
23 changed files with 179 additions and 151 deletions

View File

@ -24,7 +24,7 @@ use command_buffer::pool::StandardCommandPool;
use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::Layout;
use image::ImageLayout;
use image::ImageAccess;
use instance::QueueFamily;
use sync::AccessCheckError;
@ -108,7 +108,7 @@ unsafe impl<P> CommandBuffer for AutoCommandBufferBuilder<P>
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
self.inner.check_image_access(image, layout, exclusive, queue)

View File

@ -22,7 +22,7 @@ use command_buffer::CommandBufferExecError;
use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::Layout;
use image::ImageLayout;
use image::ImageAccess;
use instance::QueueFamily;
use sync::AccessCheckError;
@ -68,7 +68,7 @@ unsafe impl<I> CommandBuffer for AbstractStorageLayer<I> where I: CommandBuffer
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
self.inner.check_image_access(image, layout, exclusive, queue)

View File

@ -22,7 +22,7 @@ use command_buffer::CommandBufferBuilder;
use command_buffer::CommandBufferExecError;
use command_buffer::commands_raw;
use framebuffer::FramebufferAbstract;
use image::Layout;
use image::ImageLayout;
use image::ImageAccess;
use instance::QueueFamily;
use device::Device;
@ -159,8 +159,8 @@ struct ResourceEntry {
final_stages: PipelineStages,
final_access: AccessFlagBits,
exclusive: bool,
initial_layout: Layout,
final_layout: Layout,
initial_layout: ImageLayout,
final_layout: ImageLayout,
}
impl<I> SubmitSyncBuilderLayer<I> {
@ -187,8 +187,8 @@ impl<I> SubmitSyncBuilderLayer<I> {
final_stages: stages,
final_access: access,
exclusive: exclusive,
initial_layout: Layout::Undefined,
final_layout: Layout::Undefined,
initial_layout: ImageLayout::Undefined,
final_layout: ImageLayout::Undefined,
});
},
@ -198,7 +198,7 @@ impl<I> SubmitSyncBuilderLayer<I> {
entry.final_stages = entry.final_stages | stages;
entry.final_access = entry.final_access | access;
entry.exclusive = entry.exclusive || exclusive;
entry.final_layout = Layout::Undefined;
entry.final_layout = ImageLayout::Undefined;
},
}
}
@ -257,7 +257,7 @@ impl<I> SubmitSyncBuilderLayer<I> {
SubmitSyncBuilderLayerBehavior::Explicit => desc.initial_layout,
SubmitSyncBuilderLayerBehavior::UseLayoutHint => {
match desc.initial_layout {
Layout::Undefined | Layout::Preinitialized => desc.initial_layout,
ImageLayout::Undefined | ImageLayout::Preinitialized => desc.initial_layout,
_ => image.parent().initial_layout_requirement(),
}
},
@ -267,7 +267,7 @@ impl<I> SubmitSyncBuilderLayer<I> {
SubmitSyncBuilderLayerBehavior::Explicit => desc.final_layout,
SubmitSyncBuilderLayerBehavior::UseLayoutHint => {
match desc.final_layout {
Layout::Undefined | Layout::Preinitialized => desc.final_layout,
ImageLayout::Undefined | ImageLayout::Preinitialized => desc.final_layout,
_ => image.parent().final_layout_requirement(),
}
},
@ -830,7 +830,7 @@ unsafe impl<I> CommandBuffer for SubmitSyncLayer<I> where I: CommandBuffer {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
// TODO: check the queue family
@ -844,7 +844,7 @@ unsafe impl<I> CommandBuffer for SubmitSyncLayer<I> where I: CommandBuffer {
continue;
}
if layout != Layout::Undefined && value.final_layout != layout {
if layout != ImageLayout::Undefined && value.final_layout != layout {
return Err(AccessCheckError::Denied(AccessError::UnexpectedImageLayout {
allowed: value.final_layout,
requested: layout,

View File

@ -28,7 +28,7 @@ use framebuffer::FramebufferAbstract;
use framebuffer::RenderPass;
use framebuffer::RenderPassAbstract;
use framebuffer::Subpass;
use image::Layout;
use image::ImageLayout;
use image::ImageAccess;
use instance::QueueFamily;
use sync::AccessCheckError;
@ -317,7 +317,7 @@ unsafe impl<P> CommandBuffer for UnsafeCommandBuffer<P> where P: CommandPool {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
Err(AccessCheckError::Unknown)

View File

@ -20,7 +20,7 @@ use command_buffer::cb::AddCommand;
use command_buffer::cb::UnsafeCommandBufferBuilder;
use command_buffer::pool::CommandPool;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use sync::AccessFlagBits;
use sync::PipelineStages;
@ -197,7 +197,7 @@ impl<'a> CmdPipelineBarrier<'a> {
pub unsafe fn add_image_memory_barrier<I: ?Sized>(&mut self, image: &'a I, mipmaps: Range<u32>,
layers: Range<u32>, source_stage: PipelineStages, source_access: AccessFlagBits,
dest_stage: PipelineStages, dest_access: AccessFlagBits, by_region: bool,
queue_transfer: Option<(u32, u32)>, current_layout: Layout, new_layout: Layout)
queue_transfer: Option<(u32, u32)>, current_layout: ImageLayout, new_layout: ImageLayout)
where I: ImageAccess
{
self.add_execution_dependency(source_stage, dest_stage, by_region);

View File

@ -22,7 +22,7 @@ use command_buffer::submit::SubmitCommandBufferBuilder;
use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::Layout;
use image::ImageLayout;
use image::ImageAccess;
use instance::QueueFamily;
use sync::now;
@ -136,7 +136,7 @@ pub unsafe trait CommandBuffer: DeviceOwned {
fn check_buffer_access(&self, buffer: &BufferAccess, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>;
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>;
// FIXME: lots of other methods
@ -174,7 +174,7 @@ unsafe impl<T> CommandBuffer for T where T: SafeDeref, T::Target: CommandBuffer
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
(**self).check_image_access(image, layout, exclusive, queue)
@ -284,7 +284,7 @@ unsafe impl<F, Cb> GpuFuture for CommandBufferExecFuture<F, Cb>
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
match self.command_buffer.check_image_access(image, layout, exclusive, queue) {

View File

@ -27,7 +27,7 @@ use device::Device;
use device::DeviceOwned;
use image::ImageAccess;
use image::ImageView;
use image::sys::Layout;
use image::ImageLayout;
use sampler::Sampler;
use sync::AccessFlagBits;
use sync::PipelineStages;
@ -290,7 +290,7 @@ unsafe impl<L, R, T> SimpleDescriptorSetImageExt<L, R> for T
num_mipmaps: 1, // FIXME:
first_layer: 0, // FIXME:
num_layers: 1, // FIXME:
layout: Layout::General, // FIXME:
layout: ImageLayout::General, // FIXME:
stage: PipelineStages::none(), // FIXME:
access: AccessFlagBits::none(), // FIXME:
})
@ -332,7 +332,7 @@ unsafe impl<L, R, T> SimpleDescriptorSetImageExt<L, R> for (T, Arc<Sampler>)
num_mipmaps: 1, // FIXME:
first_layer: 0, // FIXME:
num_layers: 1, // FIXME:
layout: Layout::General, // FIXME:
layout: ImageLayout::General, // FIXME:
stage: PipelineStages::none(), // FIXME:
access: AccessFlagBits::none(), // FIXME:
})
@ -375,7 +375,7 @@ unsafe impl<L, R, T> SimpleDescriptorSetImageExt<L, R> for Vec<(T, Arc<Sampler>)
num_mipmaps: 1, // FIXME:
first_layer: 0, // FIXME:
num_layers: 1, // FIXME:
layout: Layout::General, // FIXME:
layout: ImageLayout::General, // FIXME:
stage: PipelineStages::none(), // FIXME:
access: AccessFlagBits::none(), // FIXME:
});
@ -475,7 +475,7 @@ pub struct SimpleDescriptorSetImg<I> {
num_mipmaps: u32,
first_layer: u32,
num_layers: u32,
layout: Layout,
layout: ImageLayout,
stage: PipelineStages,
access: AccessFlagBits,
}

View File

@ -18,7 +18,7 @@ use framebuffer::RenderPassDescAttachmentsList;
use framebuffer::RenderPassDescClearValues;
use framebuffer::RenderPassCompatible;
use framebuffer::RenderPassCreationError;
use image::Layout as ImageLayout;
use image::ImageLayout as ImageLayout;
use image::ImageViewAccess;
use sync::AccessFlagBits;
use sync::PipelineStages;

View File

@ -76,7 +76,7 @@ macro_rules! ordered_passes_renderpass {
use $crate::framebuffer::LayoutAttachmentDescription;
use $crate::framebuffer::LayoutPassDescription;
use $crate::framebuffer::LayoutPassDependencyDescription;
use $crate::image::Layout;
use $crate::image::ImageLayout;
use $crate::image::ImageViewAccess;
use $crate::sync::AccessFlagBits;
use $crate::sync::PipelineStages;
@ -233,19 +233,19 @@ macro_rules! ordered_passes_renderpass {
if id == cur_pass_num {
let mut depth = None;
$(
depth = Some(($depth_atch, Layout::DepthStencilAttachmentOptimal));
depth = Some(($depth_atch, ImageLayout::DepthStencilAttachmentOptimal));
)*
return Some(LayoutPassDescription {
color_attachments: vec![
$(
($color_atch, Layout::ColorAttachmentOptimal)
($color_atch, ImageLayout::ColorAttachmentOptimal)
),*
],
depth_stencil: depth,
input_attachments: vec![
$(
($input_atch, Layout::ShaderReadOnlyOptimal)
($input_atch, ImageLayout::ShaderReadOnlyOptimal)
),*
],
resolve_attachments: vec![],
@ -291,7 +291,7 @@ macro_rules! ordered_passes_renderpass {
/// Returns the initial and final layout of an attachment, given its num.
///
/// The value always correspond to the first and last usages of an attachment.
fn attachment_layouts(num: usize) -> (Layout, Layout) {
fn attachment_layouts(num: usize) -> (ImageLayout, ImageLayout) {
#![allow(unused_assignments)]
#![allow(unused_mut)]
#![allow(unused_variables)]
@ -309,40 +309,40 @@ macro_rules! ordered_passes_renderpass {
$(
if $depth_atch == num {
if initial_layout.is_none() {
initial_layout = Some(Layout::DepthStencilAttachmentOptimal);
initial_layout = Some(ImageLayout::DepthStencilAttachmentOptimal);
}
final_layout = Some(Layout::DepthStencilAttachmentOptimal);
final_layout = Some(ImageLayout::DepthStencilAttachmentOptimal);
}
)*
$(
if $color_atch == num {
if initial_layout.is_none() {
initial_layout = Some(Layout::ColorAttachmentOptimal);
initial_layout = Some(ImageLayout::ColorAttachmentOptimal);
}
final_layout = Some(Layout::ColorAttachmentOptimal);
final_layout = Some(ImageLayout::ColorAttachmentOptimal);
}
)*
$(
if $input_atch == num {
if initial_layout.is_none() {
initial_layout = Some(Layout::ShaderReadOnlyOptimal);
initial_layout = Some(ImageLayout::ShaderReadOnlyOptimal);
}
final_layout = Some(Layout::ShaderReadOnlyOptimal);
final_layout = Some(ImageLayout::ShaderReadOnlyOptimal);
}
)*
})*
$(if $atch_name == num {
// If the clear OP is Clear or DontCare, default to the Undefined layout.
if initial_layout == Some(Layout::DepthStencilAttachmentOptimal) ||
initial_layout == Some(Layout::ColorAttachmentOptimal)
if initial_layout == Some(ImageLayout::DepthStencilAttachmentOptimal) ||
initial_layout == Some(ImageLayout::ColorAttachmentOptimal)
{
if $crate::framebuffer::LoadOp::$load == $crate::framebuffer::LoadOp::Clear ||
$crate::framebuffer::LoadOp::$load == $crate::framebuffer::LoadOp::DontCare
{
initial_layout = Some(Layout::Undefined);
initial_layout = Some(ImageLayout::Undefined);
}
}

View File

@ -23,7 +23,7 @@ use image::Dimensions;
use image::ImageDimensions;
use image::ViewType;
use image::sys::ImageCreationError;
use image::sys::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::UnsafeImageView;
use image::sys::Usage;
@ -84,7 +84,7 @@ pub struct AttachmentImage<F, A = StdMemoryPoolAlloc> {
// Layout to use when the image is used as a framebuffer attachment.
// Must be either "depth-stencil optimal" or "color optimal".
attachment_layout: Layout,
attachment_layout: ImageLayout,
// Number of times this image is locked on the GPU side.
gpu_lock: AtomicUsize,
@ -178,8 +178,8 @@ impl<F> AttachmentImage<F> {
view: view,
memory: mem,
format: format,
attachment_layout: if is_depth { Layout::DepthStencilAttachmentOptimal }
else { Layout::ColorAttachmentOptimal },
attachment_layout: if is_depth { ImageLayout::DepthStencilAttachmentOptimal }
else { ImageLayout::ColorAttachmentOptimal },
gpu_lock: AtomicUsize::new(0),
}))
}
@ -220,12 +220,12 @@ unsafe impl<F, A> ImageAccess for AttachmentImageAccess<F, A>
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
fn initial_layout_requirement(&self) -> ImageLayout {
self.img.attachment_layout
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
fn final_layout_requirement(&self) -> ImageLayout {
self.img.attachment_layout
}
@ -341,23 +341,23 @@ unsafe impl<F, A> ImageViewAccess for AttachmentImageAccess<F, A>
}
#[inline]
fn descriptor_set_storage_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_storage_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_sampled_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_input_attachment_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]

View File

@ -18,7 +18,7 @@ use image::Dimensions;
use image::ImageDimensions;
use image::MipmapsCount;
use image::sys::ImageCreationError;
use image::sys::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::UnsafeImageView;
use image::sys::Usage;
@ -173,13 +173,13 @@ unsafe impl<F, A> ImageAccess for ImmutableImage<F, A> where F: 'static + Send +
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
Layout::ShaderReadOnlyOptimal // TODO: ?
fn initial_layout_requirement(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal // TODO: ?
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
Layout::ShaderReadOnlyOptimal // TODO: ?
fn final_layout_requirement(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal // TODO: ?
}
#[inline]
@ -226,23 +226,23 @@ unsafe impl<F: 'static, A> ImageViewAccess for ImmutableImage<F, A>
}
#[inline]
fn descriptor_set_storage_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_storage_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_sampled_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_input_attachment_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]

View File

@ -0,0 +1,42 @@
// Copyright (c) 2016 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.
use vk;
/// Layout of an image.
///
/// > **Note**: In vulkano, image layouts are mostly a low-level detail. You can ignore them,
/// > unless you use an unsafe function that states in its documentation that you must take care of
/// > an image's layout.
///
/// In the Vulkan API, each mipmap level of each array layer is in one of the layouts of this enum.
///
/// Unless you use some short of high-level shortcut function, an image always starts in either
/// the `Undefined` or the `Preinitialized` layout.
/// Before you can use an image for a given purpose, you must ensure that the image in question is
/// in the layout required for that purpose. For example if you want to write data to an image, you
/// must first transition the image to the `TransferDstOptimal` layout. The `General` layout can
/// also be used as a general-purpose fit-all layout, but using it will result in slower operations.
///
/// Transitionning between layouts can only be done through a GPU-side operation that is part of
/// a command buffer.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)]
pub enum ImageLayout {
Undefined = vk::IMAGE_LAYOUT_UNDEFINED,
General = vk::IMAGE_LAYOUT_GENERAL,
ColorAttachmentOptimal = vk::IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
DepthStencilAttachmentOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
DepthStencilReadOnlyOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
ShaderReadOnlyOptimal = vk::IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
TransferSrcOptimal = vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
TransferDstOptimal = vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
Preinitialized = vk::IMAGE_LAYOUT_PREINITIALIZED,
PresentSrc = vk::IMAGE_LAYOUT_PRESENT_SRC_KHR,
}

View File

@ -48,10 +48,10 @@
pub use self::attachment::AttachmentImage;
pub use self::immutable::ImmutableImage;
pub use self::layout::ImageLayout;
pub use self::storage::StorageImage;
pub use self::swapchain::SwapchainImage;
pub use self::sys::ImageCreationError;
pub use self::sys::Layout;
pub use self::sys::Usage;
pub use self::traits::ImageAccess;
pub use self::traits::ImageViewAccess;
@ -60,6 +60,7 @@ pub use self::traits::ImageView;
pub mod attachment; // TODO: make private
pub mod immutable; // TODO: make private
mod layout;
mod storage;
pub mod swapchain; // TODO: make private
pub mod sys;

View File

@ -22,7 +22,7 @@ use format::Format;
use image::Dimensions;
use image::ImageDimensions;
use image::sys::ImageCreationError;
use image::sys::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::UnsafeImageView;
use image::sys::Usage;
@ -190,13 +190,13 @@ unsafe impl<F, A> ImageAccess for StorageImage<F, A> where F: 'static + Send + S
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
Layout::General
fn initial_layout_requirement(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
Layout::General
fn final_layout_requirement(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]
@ -259,23 +259,23 @@ unsafe impl<F, A> ImageViewAccess for StorageImage<F, A>
}
#[inline]
fn descriptor_set_storage_image_layout(&self) -> Layout {
Layout::General
fn descriptor_set_storage_image_layout(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout {
Layout::General
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]
fn descriptor_set_sampled_image_layout(&self) -> Layout {
Layout::General
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]
fn descriptor_set_input_attachment_layout(&self) -> Layout {
Layout::General
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout {
ImageLayout::General
}
#[inline]

View File

@ -22,7 +22,7 @@ use image::traits::ImageContent;
use image::traits::ImageViewAccess;
use image::traits::Image;
use image::traits::ImageView;
use image::sys::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::UnsafeImageView;
use swapchain::Swapchain;
@ -99,13 +99,13 @@ unsafe impl ImageAccess for SwapchainImage {
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
Layout::PresentSrc
fn initial_layout_requirement(&self) -> ImageLayout {
ImageLayout::PresentSrc
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
Layout::PresentSrc
fn final_layout_requirement(&self) -> ImageLayout {
ImageLayout::PresentSrc
}
#[inline]
@ -157,23 +157,23 @@ unsafe impl ImageViewAccess for SwapchainImage {
}
#[inline]
fn descriptor_set_storage_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_storage_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_sampled_image_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]
fn descriptor_set_input_attachment_layout(&self) -> Layout {
Layout::ShaderReadOnlyOptimal
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout {
ImageLayout::ShaderReadOnlyOptimal
}
#[inline]

View File

@ -1086,21 +1086,6 @@ impl Usage {
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)]
pub enum Layout {
Undefined = vk::IMAGE_LAYOUT_UNDEFINED,
General = vk::IMAGE_LAYOUT_GENERAL,
ColorAttachmentOptimal = vk::IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
DepthStencilAttachmentOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
DepthStencilReadOnlyOptimal = vk::IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL,
ShaderReadOnlyOptimal = vk::IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
TransferSrcOptimal = vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
TransferDstOptimal = vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
Preinitialized = vk::IMAGE_LAYOUT_PREINITIALIZED,
PresentSrc = vk::IMAGE_LAYOUT_PRESENT_SRC_KHR,
}
#[cfg(test)]
mod tests {
use std::iter::Empty;

View File

@ -19,7 +19,7 @@ use format::PossibleStencilFormatDesc;
use format::PossibleDepthStencilFormatDesc;
use image::Dimensions;
use image::ImageDimensions;
use image::sys::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::UnsafeImageView;
use sampler::Sampler;
@ -110,10 +110,10 @@ pub unsafe trait ImageAccess {
}
/// Returns the layout that the image has when it is first used in a primary command buffer.
fn initial_layout_requirement(&self) -> Layout;
fn initial_layout_requirement(&self) -> ImageLayout;
/// Returns the layout that the image must be returned to before the end of the command buffer.
fn final_layout_requirement(&self) -> Layout;
fn final_layout_requirement(&self) -> ImageLayout;
/// Wraps around this `ImageAccess` and returns an identical `ImageAccess` but whose initial
/// layout requirement is either `Undefined` or `Preinitialized`.
@ -224,12 +224,12 @@ unsafe impl<T> ImageAccess for T where T: SafeDeref, T::Target: ImageAccess {
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
fn initial_layout_requirement(&self) -> ImageLayout {
(**self).initial_layout_requirement()
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
fn final_layout_requirement(&self) -> ImageLayout {
(**self).final_layout_requirement()
}
@ -268,16 +268,16 @@ unsafe impl<I> ImageAccess for ImageAccessFromUndefinedLayout<I>
}
#[inline]
fn initial_layout_requirement(&self) -> Layout {
fn initial_layout_requirement(&self) -> ImageLayout {
if self.preinitialized {
Layout::Preinitialized
ImageLayout::Preinitialized
} else {
Layout::Undefined
ImageLayout::Undefined
}
}
#[inline]
fn final_layout_requirement(&self) -> Layout {
fn final_layout_requirement(&self) -> ImageLayout {
self.image.final_layout_requirement()
}
@ -342,13 +342,13 @@ pub unsafe trait ImageViewAccess {
}
/// Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_storage_image_layout(&self) -> Layout;
fn descriptor_set_storage_image_layout(&self) -> ImageLayout;
/// Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout;
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout;
/// Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_sampled_image_layout(&self) -> Layout;
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout;
/// Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_input_attachment_layout(&self) -> Layout;
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout;
/// Returns true if the view doesn't use components swizzling.
///
@ -383,19 +383,19 @@ unsafe impl<T> ImageViewAccess for T where T: SafeDeref, T::Target: ImageViewAcc
}
#[inline]
fn descriptor_set_storage_image_layout(&self) -> Layout {
fn descriptor_set_storage_image_layout(&self) -> ImageLayout {
(**self).descriptor_set_storage_image_layout()
}
#[inline]
fn descriptor_set_combined_image_sampler_layout(&self) -> Layout {
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout {
(**self).descriptor_set_combined_image_sampler_layout()
}
#[inline]
fn descriptor_set_sampled_image_layout(&self) -> Layout {
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout {
(**self).descriptor_set_sampled_image_layout()
}
#[inline]
fn descriptor_set_input_attachment_layout(&self) -> Layout {
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout {
(**self).descriptor_set_input_attachment_layout()
}
@ -411,5 +411,5 @@ unsafe impl<T> ImageViewAccess for T where T: SafeDeref, T::Target: ImageViewAcc
}
pub unsafe trait AttachmentImageView: ImageViewAccess {
fn accept(&self, initial_layout: Layout, final_layout: Layout) -> bool;
fn accept(&self, initial_layout: ImageLayout, final_layout: ImageLayout) -> bool;
}

View File

@ -29,7 +29,7 @@ use format::Format;
use format::FormatDesc;
use image::ImageAccess;
use image::ImageDimensions;
use image::Layout;
use image::ImageLayout;
use image::sys::UnsafeImage;
use image::sys::Usage as ImageUsage;
use image::swapchain::SwapchainImage;
@ -332,7 +332,7 @@ impl Swapchain {
// Normally if `check_image_access` returns false we're supposed to call the `gpu_access`
// function on the image instead. But since we know that this method on `SwapchainImage`
// always returns false anyway (by design), we don't need to do it.
assert!(before.check_image_access(&swapchain_image, Layout::PresentSrc, true, &queue).is_ok()); // TODO: return error instead
assert!(before.check_image_access(&swapchain_image, ImageLayout::PresentSrc, true, &queue).is_ok()); // TODO: return error instead
PresentFuture {
previous: before,
@ -500,7 +500,7 @@ unsafe impl GpuFuture for SwapchainAcquireFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
if let Some(sc_img) = self.image.upgrade() {
@ -508,15 +508,15 @@ unsafe impl GpuFuture for SwapchainAcquireFuture {
return Err(AccessCheckError::Unknown);
}
if self.undefined_layout && layout != Layout::Undefined {
if self.undefined_layout && layout != ImageLayout::Undefined {
return Err(AccessCheckError::Denied(AccessError::ImageNotInitialized {
requested: layout
}));
}
if layout != Layout::Undefined && layout != Layout::PresentSrc {
if layout != ImageLayout::Undefined && layout != ImageLayout::PresentSrc {
return Err(AccessCheckError::Denied(AccessError::UnexpectedImageLayout {
allowed: Layout::PresentSrc,
allowed: ImageLayout::PresentSrc,
requested: layout,
}));
}
@ -707,7 +707,7 @@ unsafe impl<P> GpuFuture for PresentFuture<P> where P: GpuFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
unimplemented!() // TODO: VK specs don't say whether it is legal to do that

View File

@ -20,7 +20,7 @@ use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use sync::AccessCheckError;
use sync::AccessFlagBits;
use sync::FlushError;
@ -305,7 +305,7 @@ unsafe impl<F> GpuFuture for FenceSignalFuture<F> where F: GpuFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError> {
let state = self.state.lock().unwrap();
if let Some(previous) = state.get_prev() {
@ -393,7 +393,7 @@ unsafe impl<F> GpuFuture for Arc<FenceSignalFuture<F>> where F: GpuFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
(**self).check_image_access(image, layout, exclusive, queue)

View File

@ -15,7 +15,7 @@ use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use sync::AccessCheckError;
use sync::AccessFlagBits;
use sync::FlushError;
@ -173,7 +173,7 @@ unsafe impl<A, B> GpuFuture for JoinFuture<A, B> where A: GpuFuture, B: GpuFutur
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
let first = self.first.check_image_access(image, layout, exclusive, queue);

View File

@ -21,7 +21,7 @@ use command_buffer::submit::SubmitCommandBufferError;
use device::DeviceOwned;
use device::Queue;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use swapchain::Swapchain;
use swapchain::PresentFuture;
use sync::AccessFlagBits;
@ -124,7 +124,7 @@ pub unsafe trait GpuFuture: DeviceOwned {
///
/// > **Note**: Keep in mind that changing the layout of an image also requires exclusive
/// > access.
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool,
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool,
queue: &Queue) -> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>;
/// Joins this future with another one, representing the moment when both events have happened.
@ -268,7 +268,7 @@ unsafe impl<F: ?Sized> GpuFuture for Box<F> where F: GpuFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
(**self).check_image_access(image, layout, exclusive, queue)
@ -282,15 +282,15 @@ pub enum AccessError {
ExclusiveDenied,
UnexpectedImageLayout {
allowed: Layout,
requested: Layout,
allowed: ImageLayout,
requested: ImageLayout,
},
/// Trying to use an image without transitionning it from the "undefined" or "preinitialized"
/// layouts first.
ImageNotInitialized {
/// The layout that was requested for the image.
requested: Layout,
requested: ImageLayout,
},
}

View File

@ -15,7 +15,7 @@ use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use sync::AccessCheckError;
use sync::AccessFlagBits;
use sync::FlushError;
@ -72,7 +72,7 @@ unsafe impl GpuFuture for NowFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
Err(AccessCheckError::Unknown)

View File

@ -20,7 +20,7 @@ use device::Device;
use device::DeviceOwned;
use device::Queue;
use image::ImageAccess;
use image::Layout;
use image::ImageLayout;
use sync::AccessCheckError;
use sync::AccessFlagBits;
use sync::FlushError;
@ -136,7 +136,7 @@ unsafe impl<F> GpuFuture for SemaphoreSignalFuture<F> where F: GpuFuture {
}
#[inline]
fn check_image_access(&self, image: &ImageAccess, layout: Layout, exclusive: bool, queue: &Queue)
fn check_image_access(&self, image: &ImageAccess, layout: ImageLayout, exclusive: bool, queue: &Queue)
-> Result<Option<(PipelineStages, AccessFlagBits)>, AccessCheckError>
{
self.previous.check_image_access(image, layout, exclusive, queue).map(|_| None)