Replace ImageResource with ImageViewResource

This commit is contained in:
Pierre Krieger 2016-02-23 18:18:31 +01:00
parent 7b50a54086
commit 25bc5f64e6
4 changed files with 25 additions and 18 deletions

View File

@ -14,7 +14,7 @@ use framebuffer::ClearValue;
use framebuffer::Framebuffer;
use framebuffer::RenderPass;
use framebuffer::RenderPassLayout;
use image::ImageResource;
use image::ImageViewResource;
use memory::MemorySourceChunk;
use pipeline::GenericPipeline;
use pipeline::GraphicsPipeline;
@ -43,8 +43,8 @@ pub struct InnerCommandBufferBuilder {
buffer_resources: Vec<Arc<BufferResource>>,
// Same as `resources`. Should be merged with `resources` once Rust allows turning a
// `Arc<ImageResource>` into an `Arc<BufferResource>`.
image_resources: Vec<Arc<ImageResource>>,
// `Arc<ImageViewResource>` into an `Arc<BufferResource>`.
image_resources: Vec<Arc<ImageViewResource>>,
// List of pipelines that are used by this command buffer.
//
@ -518,7 +518,7 @@ pub struct InnerCommandBuffer {
pool: Arc<CommandBufferPool>,
cmd: vk::CommandBuffer,
buffer_resources: Vec<Arc<BufferResource>>,
image_resources: Vec<Arc<ImageResource>>,
image_resources: Vec<Arc<ImageViewResource>>,
pipelines: Vec<Arc<GenericPipeline>>,
}

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use buffer::BufferResource;
use descriptor_set::AbstractDescriptorSet;
use descriptor_set::AbstractDescriptorSetLayout;
use image::ImageResource;
use image::ImageViewResource;
use image::Layout as ImageLayout;
use sampler::Sampler;
@ -66,17 +66,17 @@ pub struct DescriptorWrite {
// FIXME: incomplete
#[derive(Clone)] // TODO: Debug
pub enum DescriptorBind {
StorageImage(Arc<ImageResource>, ImageLayout), // FIXME: ImageViewResource instead of ImageResource
StorageImage(Arc<ImageViewResource>, ImageLayout),
Sampler(Arc<Sampler>),
SampledImage(Arc<ImageResource>, ImageLayout), // FIXME: ImageViewResource instead of ImageResource
CombinedImageSampler(Arc<Sampler>, Arc<ImageResource>, ImageLayout), // FIXME: ImageViewResource instead of ImageResource
SampledImage(Arc<ImageViewResource>, ImageLayout),
CombinedImageSampler(Arc<Sampler>, Arc<ImageViewResource>, ImageLayout),
//UniformTexelBuffer(Arc<BufferResource>), // FIXME: requires buffer views
//StorageTexelBuffer(Arc<BufferResource>), // FIXME: requires buffer views
UniformBuffer(Arc<BufferResource>),
StorageBuffer(Arc<BufferResource>),
DynamicUniformBuffer(Arc<BufferResource>),
DynamicStorageBuffer(Arc<BufferResource>),
InputAttachment(Arc<ImageResource>, ImageLayout), // FIXME: ImageViewResource instead of ImageResource
InputAttachment(Arc<ImageViewResource>, ImageLayout),
}
impl DescriptorBind {

View File

@ -32,7 +32,7 @@ use std::sync::Arc;
use device::Device;
use formats::Format;
use formats::FormatMarker;
use image::ImageResource;
use image::ImageViewResource;
use image::Layout as ImageLayout;
use Error;
@ -84,7 +84,7 @@ pub unsafe trait RenderPassLayout {
/// A decoded `AttachmentsList`.
// TODO: should be ImageViewResource or something like that, so that images can't get passed
type AttachmentsIter: ExactSizeIterator<Item = Arc<ImageResource>>;
type AttachmentsIter: ExactSizeIterator<Item = Arc<ImageViewResource>>;
/// Decodes a `AttachmentsList` into a list of attachments.
fn convert_attachments_list(&self, Self::AttachmentsList) -> Self::AttachmentsIter;
@ -275,7 +275,7 @@ unsafe impl RenderPassLayout for EmptySinglePassLayout {
}
type AttachmentsList = ();
type AttachmentsIter = EmptyIter<Arc<ImageResource>>;
type AttachmentsIter = EmptyIter<Arc<ImageViewResource>>;
#[inline]
fn convert_attachments_list(&self, _: Self::AttachmentsList) -> Self::AttachmentsIter {
@ -302,12 +302,12 @@ macro_rules! single_pass_renderpass {
type AttachmentsDescIter = std::vec::IntoIter<$crate::framebuffer::AttachmentDescription>;
type PassesIter = std::option::IntoIter<$crate::framebuffer::PassDescription>;
type PassDependenciesIter = std::option::IntoIter<$crate::framebuffer::PassDependencyDescription>;
type AttachmentsIter = std::vec::IntoIter<std::sync::Arc<$crate::image::ImageResource>>;
type AttachmentsIter = std::vec::IntoIter<std::sync::Arc<$crate::image::ImageViewResource>>;
// FIXME: should be stronger-typed
type AttachmentsList = (
Arc<$crate::image::ImageResource>,
Arc<$crate::image::ImageResource>
Arc<$crate::image::ImageViewResource>,
Arc<$crate::image::ImageViewResource>
); // FIXME:
#[inline]
@ -726,7 +726,7 @@ pub struct Framebuffer<L> {
renderpass: Arc<RenderPass<L>>,
framebuffer: vk::Framebuffer,
dimensions: (u32, u32, u32),
resources: Vec<Arc<ImageResource>>,
resources: Vec<Arc<ImageViewResource>>,
}
impl<L> Framebuffer<L> {
@ -832,7 +832,7 @@ impl<L> Framebuffer<L> {
/// Returns all the resources attached to that framebuffer.
#[inline]
pub fn attachments(&self) -> &[Arc<ImageResource>] {
pub fn attachments(&self) -> &[Arc<ImageViewResource>] {
&self.resources
}
}

View File

@ -68,6 +68,13 @@ pub unsafe trait ImageResource: Resource + ::VulkanObjectU64 {
semaphore: Option<Arc<Semaphore>>) -> Option<Arc<Semaphore>>;
}
pub unsafe trait ImageViewResource: Resource + ::VulkanObjectU64 {
fn default_layout(&self) -> Layout;
unsafe fn gpu_access(&self, write: bool, queue: &mut Queue, fence: Option<Arc<Fence>>,
semaphore: Option<Arc<Semaphore>>) -> Option<Arc<Semaphore>>;
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)]
pub enum Layout {
@ -740,7 +747,7 @@ unsafe impl<Ty, F, M> Resource for ImageView<Ty, F, M>
}
}
unsafe impl<Ty, F, M> ImageResource for ImageView<Ty, F, M>
unsafe impl<Ty, F, M> ImageViewResource for ImageView<Ty, F, M>
where Ty: ImageTypeMarker, M: MemorySourceChunk
{
#[inline]