mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 14:56:42 +00:00
Image and teapot examples now working simultaneously
This commit is contained in:
parent
9822ed35de
commit
5901915ee9
@ -169,7 +169,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let framebuffers = images.iter().map(|image| {
|
let framebuffers = images.iter().map(|image| {
|
||||||
vulkano::framebuffer::Framebuffer::new(&renderpass, (1244, 699, 1), image.clone() as std::sync::Arc<_>).unwrap()
|
vulkano::framebuffer::Framebuffer::new(&renderpass, (1244, 699, 1), (image.clone() as std::sync::Arc<_>,)).unwrap()
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,8 +294,10 @@ macro_rules! single_pass_renderpass {
|
|||||||
|
|
||||||
// FIXME: should be stronger-typed
|
// FIXME: should be stronger-typed
|
||||||
type AttachmentsList = (
|
type AttachmentsList = (
|
||||||
Arc<$crate::image::AbstractImageView>
|
$(
|
||||||
); // FIXME:
|
Arc<$crate::image::AbstractTypedImageView<$crate::image::Type2d, $crate::formats::$format>>,
|
||||||
|
)*
|
||||||
|
);
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn convert_clear_values(&self, val: Self::ClearValues) -> Self::ClearValuesIter {
|
fn convert_clear_values(&self, val: Self::ClearValues) -> Self::ClearValuesIter {
|
||||||
@ -338,7 +340,7 @@ macro_rules! single_pass_renderpass {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn convert_attachments_list(&self, l: Self::AttachmentsList) -> Self::AttachmentsIter {
|
fn convert_attachments_list(&self, l: Self::AttachmentsList) -> Self::AttachmentsIter {
|
||||||
vec![l.clone()/*, l.1.clone()*/].into_iter()
|
$crate::image::AbstractTypedImageViewsTuple::iter(l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::vec::IntoIter as VecIntoIter;
|
||||||
|
|
||||||
use command_buffer::CommandBufferPool;
|
use command_buffer::CommandBufferPool;
|
||||||
use device::Device;
|
use device::Device;
|
||||||
@ -91,6 +92,50 @@ pub unsafe trait AbstractImageView: Resource + ::VulkanObjectU64 {
|
|||||||
fn usage_input_attachment(&self) -> bool;
|
fn usage_input_attachment(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMPORTANT: we transmute some Arc<AbstractTypedImageView> into Arc<AbstractImageView>, so
|
||||||
|
// the signature of AbstractTypedImageView should never require another trait
|
||||||
|
pub unsafe trait AbstractTypedImageView<Ty, F>: AbstractImageView
|
||||||
|
where Ty: ImageTypeMarker, F: FormatMarker
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe trait AbstractTypedImageViewsTuple {
|
||||||
|
type Iter: Iterator<Item = Arc<AbstractImageView>>;
|
||||||
|
fn iter(self) -> Self::Iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! impl_abstract_typed_image_views_tuple {
|
||||||
|
({$f_ty:ident, $f_m:ident} $({$o_ty:ident, $o_m:ident})*) => (
|
||||||
|
unsafe impl<$f_ty, $f_m $(, $o_ty, $o_m)*> AbstractTypedImageViewsTuple for
|
||||||
|
(Arc<AbstractTypedImageView<$f_ty, $f_m>>, $(Arc<AbstractTypedImageView<$o_ty, $o_m>>),*)
|
||||||
|
{
|
||||||
|
type Iter = VecIntoIter<Arc<AbstractImageView>>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
fn iter(self) -> VecIntoIter<Arc<AbstractImageView>> {
|
||||||
|
// TODO: Holy shit that transmute is ultra dangerous, but it's the only
|
||||||
|
// solution to turn that Arc<AbstractTypedImageView> into an
|
||||||
|
// Arc<AbstractImageView>.
|
||||||
|
// See https://github.com/rust-lang/rust/issues/5665.
|
||||||
|
unsafe {
|
||||||
|
let ($f_ty, $($o_ty,)*) = self;
|
||||||
|
vec![
|
||||||
|
mem::transmute($f_ty) $(, mem::transmute($o_ty))*
|
||||||
|
].into_iter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_abstract_typed_image_views_tuple!($({$o_ty, $o_m})*);
|
||||||
|
);
|
||||||
|
|
||||||
|
() => ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_abstract_typed_image_views_tuple!({Aty, Am} {Bty, Bm}); // TODO: finish
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum Layout {
|
pub enum Layout {
|
||||||
@ -771,6 +816,11 @@ unsafe impl<Ty, F, M> AbstractImageView for ImageView<Ty, F, M>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl<Ty, F, M> AbstractTypedImageView<Ty, F> for ImageView<Ty, F, M>
|
||||||
|
where Ty: ImageTypeMarker, F: FormatMarker, M: MemorySourceChunk
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
impl<Ty, F, M> Drop for ImageView<Ty, F, M> where Ty: ImageTypeMarker {
|
impl<Ty, F, M> Drop for ImageView<Ty, F, M> where Ty: ImageTypeMarker {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user