-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7803718
commit e468599
Showing
12 changed files
with
201 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//! Various helper macros. | ||
#[macro_export] | ||
macro_rules! gfx_format { | ||
($name:ident : $surface:ident = $container:ident<$channel:ident>) => { | ||
impl $crate::format::Formatted for $name { | ||
type Surface = $crate::format::$surface; | ||
type Channel = $crate::format::$channel; | ||
type View = $crate::format::$container< | ||
<$crate::format::$channel as $crate::format::ChannelTyped>::ShaderType | ||
>; | ||
} | ||
} | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! gfx_descriptor_struct { | ||
($name:ident { $( $field:ident: $bind:ty, )* }) => { | ||
#[allow(missing_docs)] | ||
#[derive(Debug)] | ||
pub struct $name<B: $crate::Backend> { | ||
$( pub $field: (), )* | ||
layout: $crate::handle::raw::DescriptorSetLayout<B>, | ||
set: $crate::pso::DescriptorSet<B>, | ||
} | ||
|
||
impl<B: $crate::Backend> $crate::pso::DescriptorStruct<B> for $name<B> { | ||
fn from_raw( | ||
layout: $crate::handle::raw::DescriptorSetLayout<B>, | ||
set: $crate::pso::DescriptorSet<B> | ||
) -> Self { | ||
$name { | ||
$( $field: (), )* | ||
layout, | ||
set | ||
} | ||
} | ||
|
||
fn layout_bindings() -> Vec<$crate::core::pso::DescriptorSetLayoutBinding> { | ||
let mut bindings = Vec::new(); | ||
$({ | ||
let binding = bindings.len(); | ||
bindings.push($crate::core::pso::DescriptorSetLayoutBinding { | ||
binding, | ||
ty: <$bind as $crate::pso::Bind>::desc_type(), | ||
count: <$bind as $crate::pso::Bind>::desc_count(), | ||
// TODO: specify stage | ||
stage_flags: $crate::core::pso::ShaderStageFlags::all(), | ||
}); | ||
})* | ||
bindings | ||
} | ||
|
||
fn layout(&self) -> &B::DescriptorSetLayout { self.layout.resource() } | ||
fn set(&self) -> &B::DescriptorSet { self.set.resource() } | ||
} | ||
} | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! gfx_allocate_descriptor_structs { | ||
($device:expr; $( $name:ident: $struct:ty, )*) => { | ||
let ($( $name, )*) = { | ||
let mut layouts_sets = $device.allocate_descriptor_sets( | ||
&[$( &<$struct as $crate::pso::DescriptorStruct<_>>::layout_bindings()[..], )*] | ||
).into_iter(); | ||
($( { | ||
let (layout, set) = layouts_sets.next().unwrap(); | ||
<$struct as $crate::pso::DescriptorStruct<_>>::from_raw(layout, set) | ||
}, )*) | ||
}; | ||
} | ||
} |
Oops, something went wrong.