mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2025-02-17 01:23:00 +00:00
Draft for new attachments list system
This commit is contained in:
parent
859887ccf6
commit
19b346471f
@ -56,6 +56,7 @@ impl<Rp, A> Framebuffer<Rp, A> {
|
||||
pub fn new<Ia>(render_pass: Rp, dimensions: [u32; 3],
|
||||
attachments: Ia) -> Result<Arc<Framebuffer<Rp, A>>, FramebufferCreationError>
|
||||
where Rp: RenderPassRef,
|
||||
Rp::Desc: RenderPassAttachmentsList<Ia>,
|
||||
Ia: IntoAttachmentsList<List = A>,
|
||||
A: AttachmentsList
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
/// Builds a `CustomRenderPassDesc` object that provides a safe wrapper around `RenderPass`.
|
||||
/// Builds a `RenderPass` object whose template parameter is of undeterminate type.
|
||||
#[macro_export]
|
||||
macro_rules! single_pass_renderpass {
|
||||
(
|
||||
@ -32,7 +32,7 @@ macro_rules! single_pass_renderpass {
|
||||
)
|
||||
}
|
||||
|
||||
/// Builds a `CustomRenderPassDesc` object that provides a safe wrapper around `RenderPass`.
|
||||
/// Builds a `RenderPass` object whose template parameter is of undeterminate type.
|
||||
#[macro_export]
|
||||
macro_rules! ordered_passes_renderpass {
|
||||
(
|
||||
@ -73,7 +73,7 @@ macro_rules! ordered_passes_renderpass {
|
||||
use $crate::framebuffer::LayoutPassDependencyDescription;
|
||||
use $crate::framebuffer::FramebufferCreationError;
|
||||
use $crate::framebuffer::RenderPassCreationError;
|
||||
use $crate::framebuffer::framebuffer::IntoAttachmentsList;
|
||||
use $crate::framebuffer::IntoAttachmentsList;
|
||||
use $crate::image::Layout;
|
||||
use $crate::image::traits::ImageView;
|
||||
use $crate::sync::AccessFlagBits;
|
||||
@ -85,6 +85,17 @@ macro_rules! ordered_passes_renderpass {
|
||||
)*
|
||||
}
|
||||
|
||||
impl CustomRenderPassDesc {
|
||||
#[inline]
|
||||
pub fn start_attachments(&self) -> AttachmentsStart {
|
||||
AttachmentsStart
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AttachmentsStart;
|
||||
|
||||
ordered_passes_renderpass!{[] __impl_attachments__ [] [] [$($atch_name),*] [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe impl RenderPassDesc for CustomRenderPassDesc {
|
||||
#[inline]
|
||||
@ -334,6 +345,56 @@ macro_rules! ordered_passes_renderpass {
|
||||
}.build_render_pass($device)
|
||||
});
|
||||
|
||||
([] __impl_attachments__ [] [] [] [$($params:ident),*]) => {
|
||||
unsafe impl RenderPassAttachmentsList<AttachmentsStart> for CustomRenderPassDesc {
|
||||
fn check_attachments_list(&self, attachments: &AttachmentsStart) -> Result<(), FramebufferCreationError> {
|
||||
Ok(()) // FIXME:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
([] __impl_attachments__ [] [] [$next:ident $(, $rest:ident)*] [$first_param:ident, $($rest_params:ident),*]) => {
|
||||
pub struct $next<$first_param> {
|
||||
current: $first_param,
|
||||
}
|
||||
|
||||
impl AttachmentsStart {
|
||||
pub fn $next<$first_param>(self, next: $first_param) -> $next<$first_param> {
|
||||
$next {
|
||||
current: next,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ordered_passes_renderpass!{[] __impl_attachments__ [$next] [$first_param] [$($rest),*] [$($rest_params),*]}
|
||||
};
|
||||
|
||||
([] __impl_attachments__ [$prev:ident] [$($prev_params:ident),*] [] [$($params:ident),*]) => {
|
||||
unsafe impl<$($prev_params,)*> RenderPassAttachmentsList<$prev<$($prev_params,)*>> for CustomRenderPassDesc {
|
||||
fn check_attachments_list(&self, attachments: &$prev<$($prev_params,)*>) -> Result<(), FramebufferCreationError> {
|
||||
Ok(()) // FIXME:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
([] __impl_attachments__ [$prev:ident] [$($prev_params:ident),*] [$next:ident $(, $rest:ident)*] [$first_param:ident, $($rest_params:ident),*]) => {
|
||||
pub struct $next<$($prev_params,)* $first_param> {
|
||||
prev: $prev,
|
||||
current: $first_param,
|
||||
}
|
||||
|
||||
impl<$($prev_params,)*> $prev<$($prev_params,)*> {
|
||||
pub fn $next<$first_param>(self, next: $first_param) -> $next<$($prev_params,)* $first_param> {
|
||||
$next {
|
||||
prev: self,
|
||||
current: next,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ordered_passes_renderpass!{[] __impl_attachments__ [$next] [$($prev_params,)* $first_param] [$($rest),*] [$($rest_params),*]}
|
||||
};
|
||||
|
||||
([] __impl_clear_values__ [$num:expr] [$($s:tt)*] [$atch_name:ident $format:ty, Clear, $($rest:tt)*]) => {
|
||||
ordered_passes_renderpass!{[] __impl_clear_values__ [$num+1] [$($s)* $atch_name [$num] $format,] [$($rest)*] }
|
||||
};
|
||||
|
@ -78,7 +78,8 @@
|
||||
//! TODO
|
||||
|
||||
pub use self::empty::EmptySinglePassRenderPassDesc;
|
||||
pub use self::framebuffer::AttachmentsList;
|
||||
pub use self::framebuffer::AttachmentsList; // TODO: rework and remove
|
||||
pub use self::framebuffer::IntoAttachmentsList; // TODO: rework and remove
|
||||
pub use self::framebuffer::Framebuffer;
|
||||
pub use self::framebuffer::FramebufferCreationError;
|
||||
pub use self::sys::RenderPass;
|
||||
|
@ -95,6 +95,10 @@ unsafe impl<'a, T: ?Sized> RenderPassRef for &'a T where T: RenderPassRef {
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for objects that contain the description of a a render pass.
|
||||
///
|
||||
/// See also `RenderPassAttachmentsList` and `RenderPassClearValues` which are extensions to this
|
||||
/// trait.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
@ -414,7 +418,11 @@ impl<'a, R: ?Sized + 'a> Iterator for RenderPassDescDependencies<'a, R> where R:
|
||||
}
|
||||
}
|
||||
|
||||
/// Extension trait for `RenderPassRef`. Defines which types are allowed as an attachments list.
|
||||
/// Extension trait for `RenderPassDesc`. Defines which types are allowed as an attachments list.
|
||||
///
|
||||
/// When the user creates a framebuffer, they need to pass a render pass object and a list of
|
||||
/// attachments. In order for it to work, the `RenderPassDesc` object of the render pass must
|
||||
/// implement `RenderPassAttachmentsList<A>` where `A` is the type of the list of attachments.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
@ -434,11 +442,11 @@ pub unsafe trait RenderPassAttachmentsList<A>: RenderPassDesc {
|
||||
fn check_attachments_list(&self, &A) -> Result<(), FramebufferCreationError>;
|
||||
}
|
||||
|
||||
unsafe impl<A, R> RenderPassAttachmentsList<A> for R where R: RenderPassDesc {
|
||||
/*unsafe impl<A, R> RenderPassAttachmentsList<A> for R where R: RenderPassDesc {
|
||||
fn check_attachments_list(&self, attachments: &A) -> Result<(), FramebufferCreationError> {
|
||||
Ok(()) // FIXME:
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/// Extension trait for `RenderPassDesc`. Defines which types are allowed as a list of clear values.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user