use crate::effect::FrameBinding;
use crate::graph::context::PassContext;
use crate::graph::resource::ResourceId;
#[derive(Debug, Clone, Copy)]
pub enum Slot {
MainSource,
Output,
ResourceMip(ResourceId, u32),
ResourceWhole(ResourceId),
Inline(FrameBinding),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MipDirection {
Down,
Up,
}
pub type SingleDispatcher<F> = Box<dyn Fn(&PassContext<F>, &crate::types::Configuration) -> Result<(), &'static str> + Send + Sync + 'static>;
pub type MipDispatcher<F> = Box<dyn Fn(u32, &PassContext<F>, &crate::types::Configuration) -> Result<(), &'static str> + Send + Sync + 'static>;
pub type EnabledPredicate<F> = Box<dyn Fn(&PassContext<F>) -> bool + Send + Sync + 'static>;
pub(crate) struct SinglePassDecl<F> {
pub name: &'static str,
pub source: Slot,
pub input: Option<Slot>,
pub target: Slot,
pub dispatcher: SingleDispatcher<F>,
pub enabled_when: Option<EnabledPredicate<F>>,
}
pub(crate) struct MipChainPassDecl<F> {
pub name: &'static str,
pub resource: ResourceId,
pub direction: MipDirection,
pub dispatcher: MipDispatcher<F>,
pub enabled_when: Option<EnabledPredicate<F>>,
}
pub(crate) enum PassDecl<F> {
Single(SinglePassDecl<F>),
MipChain(MipChainPassDecl<F>),
}
impl<F> PassDecl<F> {
#[allow(dead_code)]
pub fn name(&self) -> &'static str {
match self {
PassDecl::Single(p) => p.name,
PassDecl::MipChain(p) => p.name,
}
}
}