Rename ImageResource and BufferResource to AbstractImage and AbstractBuffer

This commit is contained in:
Pierre Krieger 2016-02-23 21:25:03 +01:00
parent 154c4458c8
commit a6b166c7b6
9 changed files with 81 additions and 55 deletions

View File

@ -269,7 +269,7 @@ fn write_descriptor_sets(doc: &parse::Spirv) -> String {
&parse::Instruction::TypeStruct { result_id, .. } if result_id == pointed_ty => {
Some((
"::vulkano::descriptor_set::DescriptorType::UniformBuffer",
"::vulkano::buffer::BufferResource",
"::vulkano::buffer::AbstractBuffer",
"::vulkano::descriptor_set::DescriptorBind::UniformBuffer"
))
},
@ -279,7 +279,7 @@ fn write_descriptor_sets(doc: &parse::Spirv) -> String {
{
Some((
"::vulkano::descriptor_set::DescriptorType::SampledImage",
"::vulkano::image::ImageResource",
"::vulkano::image::AbstractImageView",
"::vulkano::descriptor_set::DescriptorBind::UniformBuffer" // FIXME:
))
},
@ -288,7 +288,7 @@ fn write_descriptor_sets(doc: &parse::Spirv) -> String {
{
Some((
"::vulkano::descriptor_set::DescriptorType::SampledImage",
"::vulkano::image::ImageResource",
"::vulkano::image::AbstractImageView",
"::vulkano::descriptor_set::DescriptorBind::UniformBuffer" // FIXME:
))
},

View File

@ -39,7 +39,7 @@ use VulkanPointers;
use check_errors;
use vk;
pub unsafe trait BufferResource: Resource + ::VulkanObjectU64 {
pub unsafe trait AbstractBuffer: Resource + ::VulkanObjectU64 {
/// Returns the size of the buffer in bytes.
fn size(&self) -> usize;
@ -239,7 +239,7 @@ unsafe impl<T: ?Sized, M> Resource for Buffer<T, M> where M: MemorySourceChunk {
}
}
unsafe impl<T: ?Sized, M> BufferResource for Buffer<T, M> where M: MemorySourceChunk {
unsafe impl<T: ?Sized, M> AbstractBuffer for Buffer<T, M> where M: MemorySourceChunk {
#[inline]
fn size(&self) -> usize {
self.inner.size
@ -443,7 +443,7 @@ impl Usage {
#[derive(Clone)]
pub struct BufferSlice<'a, T: ?Sized + 'a, M: 'a> {
marker: PhantomData<T>,
resource: Arc<BufferResource>,
resource: Arc<AbstractBuffer>,
inner: &'a Inner<M>,
offset: usize,
size: usize,
@ -451,7 +451,7 @@ pub struct BufferSlice<'a, T: ?Sized + 'a, M: 'a> {
impl<'a, T: ?Sized + 'a, M: 'a> BufferSlice<'a, T, M> {
/// Returns the buffer that this slice belongs to.
pub fn buffer(&self) -> &Arc<BufferResource> {
pub fn buffer(&self) -> &Arc<AbstractBuffer> {
&self.resource
}

View File

@ -4,7 +4,7 @@ use std::sync::Arc;
use buffer::Buffer;
use buffer::BufferSlice;
use buffer::BufferResource;
use buffer::AbstractBuffer;
use command_buffer::CommandBufferPool;
use command_buffer::DynamicState;
use descriptor_set::PipelineLayoutDesc;
@ -14,7 +14,7 @@ use framebuffer::ClearValue;
use framebuffer::Framebuffer;
use framebuffer::RenderPass;
use framebuffer::RenderPassLayout;
use image::ImageViewResource;
use image::AbstractImageView;
use memory::MemorySourceChunk;
use pipeline::GenericPipeline;
use pipeline::GraphicsPipeline;
@ -40,11 +40,11 @@ pub struct InnerCommandBufferBuilder {
cmd: Option<vk::CommandBuffer>,
// List of all resources that are used by this command buffer.
buffer_resources: Vec<Arc<BufferResource>>,
buffer_resources: Vec<Arc<AbstractBuffer>>,
// Same as `resources`. Should be merged with `resources` once Rust allows turning a
// `Arc<ImageViewResource>` into an `Arc<BufferResource>`.
image_resources: Vec<Arc<ImageViewResource>>,
// `Arc<AbstractImageView>` into an `Arc<AbstractBuffer>`.
image_resources: Vec<Arc<AbstractImageView>>,
// List of pipelines that are used by this command buffer.
//
@ -264,6 +264,32 @@ impl InnerCommandBufferBuilder {
self
}
/*pub unsafe fn copy_buffer_to_image<'a, S, Sm>(mut self, source: S, )
where S: Into<BufferSlice<'a, [], Sm>
{
{
let vk = self.device.pointers();
let source = source.into();
self.buffer_resources.push(source.buffer().clone());
let region = vk::BufferImageCopy {
bufferOffset: source.offset() as vk::DeviceSize,
bufferRowLength: ,
bufferImageHeight: ,
imageSubresource: ,
imageOffset: ,
imageExtent: ,
};
vk.CmdCopyBufferToImage(self.cmd.unwrap(), source.internal_object(), ,
vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL /* FIXME */,
1, &region);
}
self
}*/
/// Calls `vkCmdDraw`.
// FIXME: push constants
pub unsafe fn draw<V, Pl, L>(mut self, pipeline: &Arc<GraphicsPipeline<V, Pl>>,
@ -522,8 +548,8 @@ pub struct InnerCommandBuffer {
device: Arc<Device>,
pool: Arc<CommandBufferPool>,
cmd: vk::CommandBuffer,
buffer_resources: Vec<Arc<BufferResource>>,
image_resources: Vec<Arc<ImageViewResource>>,
buffer_resources: Vec<Arc<AbstractBuffer>>,
image_resources: Vec<Arc<AbstractImageView>>,
pipelines: Vec<Arc<GenericPipeline>>,
}

View File

@ -1,9 +1,9 @@
use std::sync::Arc;
use buffer::BufferResource;
use buffer::AbstractBuffer;
use descriptor_set::AbstractDescriptorSet;
use descriptor_set::AbstractDescriptorSetLayout;
use image::ImageViewResource;
use image::AbstractImageView;
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<ImageViewResource>, ImageLayout),
StorageImage(Arc<AbstractImageView>, ImageLayout),
Sampler(Arc<Sampler>),
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<ImageViewResource>, ImageLayout),
SampledImage(Arc<AbstractImageView>, ImageLayout),
CombinedImageSampler(Arc<Sampler>, Arc<AbstractImageView>, ImageLayout),
//UniformTexelBuffer(Arc<AbstractBuffer>), // FIXME: requires buffer views
//StorageTexelBuffer(Arc<AbstractBuffer>), // FIXME: requires buffer views
UniformBuffer(Arc<AbstractBuffer>),
StorageBuffer(Arc<AbstractBuffer>),
DynamicUniformBuffer(Arc<AbstractBuffer>),
DynamicStorageBuffer(Arc<AbstractBuffer>),
InputAttachment(Arc<AbstractImageView>, ImageLayout),
}
impl DescriptorBind {

View File

@ -99,13 +99,13 @@ macro_rules! pipeline_layout {
use $crate::descriptor_set::PipelineLayout;
use $crate::descriptor_set::PipelineLayoutDesc;
use $crate::descriptor_set::ShaderStages;
use $crate::buffer::BufferResource;
use $crate::buffer::AbstractBuffer;
$(
pub struct $set_name;
unsafe impl DescriptorSetDesc for $set_name {
type Write = ( // FIXME: variable number of elems
Arc<BufferResource> // FIXME: strong typing
Arc<AbstractBuffer> // FIXME: strong typing
);
type Init = Self::Write;

View File

@ -2,14 +2,14 @@ use std::mem;
use std::ptr;
use std::sync::Arc;
use buffer::BufferResource;
use buffer::AbstractBuffer;
use descriptor_set::layout_def::PipelineLayoutDesc;
use descriptor_set::layout_def::DescriptorSetDesc;
use descriptor_set::layout_def::DescriptorWrite;
use descriptor_set::layout_def::DescriptorBind;
use descriptor_set::pool::DescriptorPool;
use device::Device;
use image::ImageViewResource;
use image::AbstractImageView;
use sampler::Sampler;
use OomError;
@ -27,8 +27,8 @@ pub struct DescriptorSet<S> {
// Here we store the resources used by the descriptor set.
// TODO: for the moment even when a resource is overwritten it stays in these lists
resources_samplers: Vec<Arc<Sampler>>,
resources_image_views: Vec<Arc<ImageViewResource>>,
resources_buffers: Vec<Arc<BufferResource>>,
resources_image_views: Vec<Arc<AbstractImageView>>,
resources_buffers: Vec<Arc<AbstractBuffer>>,
}
impl<S> DescriptorSet<S> where S: DescriptorSetDesc {

View File

@ -32,7 +32,7 @@ use std::sync::Arc;
use device::Device;
use formats::Format;
use formats::FormatMarker;
use image::ImageViewResource;
use image::AbstractImageView;
use image::Layout as ImageLayout;
use Error;
@ -83,8 +83,8 @@ pub unsafe trait RenderPassLayout {
type AttachmentsList;
/// A decoded `AttachmentsList`.
// TODO: should be ImageViewResource or something like that, so that images can't get passed
type AttachmentsIter: ExactSizeIterator<Item = Arc<ImageViewResource>>;
// TODO: should be AbstractImageView or something like that, so that images can't get passed
type AttachmentsIter: ExactSizeIterator<Item = Arc<AbstractImageView>>;
/// 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<ImageViewResource>>;
type AttachmentsIter = EmptyIter<Arc<AbstractImageView>>;
#[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::ImageViewResource>>;
type AttachmentsIter = std::vec::IntoIter<std::sync::Arc<$crate::image::AbstractImageView>>;
// FIXME: should be stronger-typed
type AttachmentsList = (
Arc<$crate::image::ImageViewResource>,
Arc<$crate::image::ImageViewResource>
Arc<$crate::image::AbstractImageView>,
Arc<$crate::image::AbstractImageView>
); // FIXME:
#[inline]
@ -726,7 +726,7 @@ pub struct Framebuffer<L> {
renderpass: Arc<RenderPass<L>>,
framebuffer: vk::Framebuffer,
dimensions: (u32, u32, u32),
resources: Vec<Arc<ImageViewResource>>,
resources: Vec<Arc<AbstractImageView>>,
}
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<ImageViewResource>] {
pub fn attachments(&self) -> &[Arc<AbstractImageView>] {
&self.resources
}
}

View File

@ -38,7 +38,7 @@ use VulkanPointers;
use check_errors;
use vk;
pub unsafe trait ImageResource: Resource + ::VulkanObjectU64 {
pub unsafe trait AbstractImage: Resource + ::VulkanObjectU64 {
/// All images in vulkano must have a *default layout*. Whenever this image is used in a
/// command buffer, it is switched from this default layout to something else (if necessary),
/// then back again to the default.
@ -68,7 +68,7 @@ pub unsafe trait ImageResource: Resource + ::VulkanObjectU64 {
semaphore: Option<Arc<Semaphore>>) -> Option<Arc<Semaphore>>;
}
pub unsafe trait ImageViewResource: Resource + ::VulkanObjectU64 {
pub unsafe trait AbstractImageView: Resource + ::VulkanObjectU64 {
fn default_layout(&self) -> Layout;
unsafe fn gpu_access(&self, write: bool, queue: &mut Queue, fence: Option<Arc<Fence>>,
@ -388,7 +388,7 @@ unsafe impl<Ty, F, M> Resource for Image<Ty, F, M>
}
}
unsafe impl<Ty, F, M> ImageResource for Image<Ty, F, M>
unsafe impl<Ty, F, M> AbstractImage for Image<Ty, F, M>
where Ty: ImageTypeMarker, M: MemorySourceChunk
{
#[inline]
@ -716,7 +716,7 @@ unsafe impl<Ty, F, M> Resource for ImageView<Ty, F, M>
}
}
unsafe impl<Ty, F, M> ImageViewResource for ImageView<Ty, F, M>
unsafe impl<Ty, F, M> AbstractImageView for ImageView<Ty, F, M>
where Ty: ImageTypeMarker, M: MemorySourceChunk
{
#[inline]

View File

@ -4,7 +4,7 @@ use std::sync::Arc;
use std::vec::IntoIter as VecIntoIter;
use buffer::Buffer;
use buffer::BufferResource;
use buffer::AbstractBuffer;
use formats::Format;
use memory::MemorySourceChunk;
use vk;
@ -30,7 +30,7 @@ pub struct VertexAttribute {
/// Trait for types that contain the layout of a collection of vertex buffers.
pub unsafe trait MultiVertex {
type BuffersIter: ExactSizeIterator<Item = Arc<BufferResource>>;
type BuffersIter: ExactSizeIterator<Item = Arc<AbstractBuffer>>;
fn attrib(name: &str) -> Option<(u32, VertexAttribute)>;
@ -45,7 +45,7 @@ pub unsafe trait MultiVertex {
unsafe impl<T, M> MultiVertex for Arc<Buffer<T, M>>
where T: 'static + Vertex, M: 'static + MemorySourceChunk
{
type BuffersIter = OptionIntoIter<Arc<BufferResource>>;
type BuffersIter = OptionIntoIter<Arc<AbstractBuffer>>;
#[inline]
fn attrib(name: &str) -> Option<(u32, VertexAttribute)> {
@ -64,7 +64,7 @@ unsafe impl<T, M> MultiVertex for Arc<Buffer<T, M>>
}
#[inline]
fn buffers(&self) -> OptionIntoIter<Arc<BufferResource>> {
fn buffers(&self) -> OptionIntoIter<Arc<AbstractBuffer>> {
Some(self.clone() as Arc<_>).into_iter()
}
}
@ -72,7 +72,7 @@ unsafe impl<T, M> MultiVertex for Arc<Buffer<T, M>>
unsafe impl<T, M> MultiVertex for Arc<Buffer<[T], M>>
where T: 'static + Vertex, M: 'static + MemorySourceChunk
{
type BuffersIter = OptionIntoIter<Arc<BufferResource>>;
type BuffersIter = OptionIntoIter<Arc<AbstractBuffer>>;
#[inline]
fn attrib(name: &str) -> Option<(u32, VertexAttribute)> {
@ -91,7 +91,7 @@ unsafe impl<T, M> MultiVertex for Arc<Buffer<[T], M>>
}
#[inline]
fn buffers(&self) -> OptionIntoIter<Arc<BufferResource>> {
fn buffers(&self) -> OptionIntoIter<Arc<AbstractBuffer>> {
Some(self.clone() as Arc<_>).into_iter()
}
}
@ -101,7 +101,7 @@ macro_rules! impl_mv {
unsafe impl<$t1, M> MultiVertex for Arc<Buffer<$t2, M>>
where T: 'static + Vertex, M: 'static + MemorySourceChunk
{
type BuffersIter = OptionIntoIter<Arc<BufferResource>>;
type BuffersIter = OptionIntoIter<Arc<AbstractBuffer>>;
#[inline]
fn attrib(name: &str) -> Option<(u32, VertexAttribute)> {
@ -120,7 +120,7 @@ macro_rules! impl_mv {
}
#[inline]
fn buffers(&self) -> OptionIntoIter<Arc<BufferResource>> {
fn buffers(&self) -> OptionIntoIter<Arc<AbstractBuffer>> {
Some(self.clone() as Arc<_>).into_iter()
}
}
@ -157,7 +157,7 @@ unsafe impl<A, B, Ma, Mb> MultiVertex for (Arc<Buffer<[A], Ma>>, Arc<Buffer<[B],
where A: 'static + Vertex, B: 'static + Vertex, Ma: 'static + MemorySourceChunk,
Mb: 'static + MemorySourceChunk
{
type BuffersIter = VecIntoIter<Arc<BufferResource>>;
type BuffersIter = VecIntoIter<Arc<AbstractBuffer>>;
#[inline]
fn attrib(name: &str) -> Option<(u32, VertexAttribute)> {
@ -187,7 +187,7 @@ unsafe impl<A, B, Ma, Mb> MultiVertex for (Arc<Buffer<[A], Ma>>, Arc<Buffer<[B],
}
#[inline]
fn buffers(&self) -> VecIntoIter<Arc<BufferResource>> {
fn buffers(&self) -> VecIntoIter<Arc<AbstractBuffer>> {
vec![self.0.clone() as Arc<_>, self.1.clone() as Arc<_>].into_iter()
}
}