diff --git a/examples/src/bin/image.rs b/examples/src/bin/image.rs index 55cc2af5..cb0337c7 100644 --- a/examples/src/bin/image.rs +++ b/examples/src/bin/image.rs @@ -198,7 +198,7 @@ fn main() { color: &image, }; - vulkano::framebuffer::Framebuffer::new(&renderpass, (images[0].dimensions()[0], images[0].dimensions()[1], 1), attachments).unwrap() + vulkano::framebuffer::Framebuffer::new(&renderpass, [images[0].dimensions()[0], images[0].dimensions()[1], 1], attachments).unwrap() }).collect::>(); diff --git a/examples/src/bin/teapot.rs b/examples/src/bin/teapot.rs index ea87ff96..6419fc64 100644 --- a/examples/src/bin/teapot.rs +++ b/examples/src/bin/teapot.rs @@ -200,7 +200,7 @@ fn main() { depth: &depth_buffer, }; - vulkano::framebuffer::Framebuffer::new(&renderpass, (image.dimensions()[0], image.dimensions()[1], 1), attachments).unwrap() + vulkano::framebuffer::Framebuffer::new(&renderpass, [image.dimensions()[0], image.dimensions()[1], 1], attachments).unwrap() }).collect::>(); diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index 4a952cf2..4594747d 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -356,7 +356,7 @@ fn main() { // Since we need to draw to multiple images, we are going to create a different framebuffer for // each image. let framebuffers = images.iter().map(|image| { - let dimensions = (image.dimensions()[0], image.dimensions()[1], 1); + let dimensions = [image.dimensions()[0], image.dimensions()[1], 1]; Framebuffer::new(&render_pass, dimensions, render_pass::AList { // The `AList` struct was generated by the render pass macro above, and contains one // member for each attachment. diff --git a/vulkano/src/framebuffer/framebuffer.rs b/vulkano/src/framebuffer/framebuffer.rs index 757b6473..61fd6f5d 100644 --- a/vulkano/src/framebuffer/framebuffer.rs +++ b/vulkano/src/framebuffer/framebuffer.rs @@ -40,7 +40,7 @@ pub struct Framebuffer { device: Arc, render_pass: Arc, framebuffer: vk::Framebuffer, - dimensions: (u32, u32, u32), + dimensions: [u32; 3], resources: SmallVec<[(Arc, Arc, ImageLayout, ImageLayout); 8]>, } @@ -56,7 +56,7 @@ impl Framebuffer { /// - Additionally, some methods in the `RenderPassAttachmentsList` implementation may panic /// if you pass invalid attachments. // TODO: should be error instead /// - pub fn new<'a, A>(render_pass: &Arc, dimensions: (u32, u32, u32), // TODO: what about [u32; 3] instead? + pub fn new<'a, A>(render_pass: &Arc, dimensions: [u32; 3], attachments: A) -> Result>, FramebufferCreationError> where L: RenderPass + RenderPassAttachmentsList { @@ -71,7 +71,7 @@ impl Framebuffer { let limits = render_pass.render_pass().device().physical_device().limits(); let limits = [limits.max_framebuffer_width(), limits.max_framebuffer_height(), limits.max_framebuffer_layers()]; - if dimensions.0 > limits[0] || dimensions.1 > limits[1] || dimensions.2 > limits[2] { + if dimensions[0] > limits[0] || dimensions[1] > limits[1] || dimensions[2] > limits[2] { return Err(FramebufferCreationError::DimensionsTooLarge); } } @@ -84,8 +84,8 @@ impl Framebuffer { // TODO: add more checks with debug_assert! let atch_dims = a.parent().dimensions(); - if atch_dims.width() < dimensions.0 || atch_dims.height() < dimensions.1 || - atch_dims.array_layers() < dimensions.2 // TODO: wrong, since it must be the array layers of the view and not of the image + if atch_dims.width() < dimensions[0] || atch_dims.height() < dimensions[1] || + atch_dims.array_layers() < dimensions[2] // TODO: wrong, since it must be the array layers of the view and not of the image { return Err(FramebufferCreationError::AttachmentTooSmall); } @@ -104,9 +104,9 @@ impl Framebuffer { renderPass: render_pass.render_pass().internal_object(), attachmentCount: ids.len() as u32, pAttachments: ids.as_ptr(), - width: dimensions.0, - height: dimensions.1, - layers: dimensions.2, + width: dimensions[0], + height: dimensions[1], + layers: dimensions[2], }; let mut output = mem::uninitialized(); @@ -139,25 +139,25 @@ impl Framebuffer { /// Returns the width, height and layers of this framebuffer. #[inline] pub fn dimensions(&self) -> [u32; 3] { - [self.dimensions.0, self.dimensions.1, self.dimensions.2] + self.dimensions } /// Returns the width of the framebuffer in pixels. #[inline] pub fn width(&self) -> u32 { - self.dimensions.0 + self.dimensions[0] } /// Returns the height of the framebuffer in pixels. #[inline] pub fn height(&self) -> u32 { - self.dimensions.1 + self.dimensions[1] } /// Returns the number of layers (or depth) of the framebuffer. #[inline] pub fn layers(&self) -> u32 { - self.dimensions.2 + self.dimensions[2] } /// Returns the device that was used to create this framebuffer. @@ -294,7 +294,7 @@ mod tests { let image = AttachmentImage::new(&device, [1024, 768], R8G8B8A8Unorm).unwrap(); - let _ = Framebuffer::new(&render_pass, (1024, 768, 1), example::AList { + let _ = Framebuffer::new(&render_pass, [1024, 768, 1], example::AList { color: &image }).unwrap(); } @@ -310,7 +310,7 @@ mod tests { let image = AttachmentImage::new(&device, [1024, 768], R8G8B8A8Unorm).unwrap(); let alist = example::AList { color: &image }; - match Framebuffer::new(&render_pass, (0xffffffff, 0xffffffff, 0xffffffff), alist) { + match Framebuffer::new(&render_pass, [0xffffffff, 0xffffffff, 0xffffffff], alist) { Err(FramebufferCreationError::DimensionsTooLarge) => (), _ => panic!() } @@ -327,7 +327,7 @@ mod tests { let image = AttachmentImage::new(&device, [512, 512], R8G8B8A8Unorm).unwrap(); let alist = example::AList { color: &image }; - match Framebuffer::new(&render_pass, (600, 600, 1), alist) { + match Framebuffer::new(&render_pass, [600, 600, 1], alist) { Err(FramebufferCreationError::AttachmentTooSmall) => (), _ => panic!() }