pub struct ExecutionManager<A: Allocator = DefaultAllocator> { /* private fields */ }
Expand description
The execution manager is responsible for allocating command buffers on correct
queues. To obtain any command buffer, you must allocate it by calling
ExecutionManager::on_domain()
. An execution domain is a type that implements
the domain::ExecutionDomain
trait. Four domains are already defined, and these should cover
virtually every available use case.
domain::All
supports all operations and is essentially a combination of the other three domains.domain::Graphics
supports only graphics operations.domain::Transfer
supports only transfer operations.domain::Compute
supports only compute operations.
Note that all domains also implement a couple commands that apply to all domains with no restrictions on queue type support, such as pipeline barriers.
§Example
use phobos::prelude::*;
// Create an execution manager first. You only want one of these.
let exec = ExecutionManager::new(device.clone(), &physical_device, pool);
// Obtain a command buffer on the Transfer domain
let cmd = exec.on_domain::<domain::Transfer>()?
.copy_image(/*command parameters*/)
.finish()?;
// Submit the command buffer, either to this frame's command list,
// or to the execution manager for submitting commands outside of a
// frame context (such as on another thread).
Implementations§
Source§impl<A: Allocator> ExecutionManager<A>
impl<A: Allocator> ExecutionManager<A>
Sourcepub fn new(
device: Device,
physical_device: &PhysicalDevice,
pool: ResourcePool<A>,
) -> Result<Self>
pub fn new( device: Device, physical_device: &PhysicalDevice, pool: ResourcePool<A>, ) -> Result<Self>
Create a new execution manager. You should only ever have on instance of this struct in your program.
Sourcepub fn try_on_domain<'q, D: ExecutionDomain>(
&'q self,
) -> Result<D::CmdBuf<'q, A>>
pub fn try_on_domain<'q, D: ExecutionDomain>( &'q self, ) -> Result<D::CmdBuf<'q, A>>
Tries to obtain a command buffer over a domain, or returns an Err state if the lock is currently being held. If this command buffer needs access to pipelines or descriptor sets, pass in the relevant caches.
Sourcepub fn on_domain<'q, D: ExecutionDomain>(&'q self) -> Result<D::CmdBuf<'q, A>>
pub fn on_domain<'q, D: ExecutionDomain>(&'q self) -> Result<D::CmdBuf<'q, A>>
Obtain a command buffer capable of operating on the specified domain. If this command buffer needs access to pipelines or descriptor sets, pass in the relevant caches.
Sourcepub fn start_submit_batch<D: ExecutionDomain + 'static>(
&self,
) -> Result<SubmitBatch<D, A>>
pub fn start_submit_batch<D: ExecutionDomain + 'static>( &self, ) -> Result<SubmitBatch<D, A>>
Begin a submit batch. Note that all submits in a batch are over a single domain (currently).
§Example
use phobos::prelude::*;
let exec = ExecutionManager::new(device.clone(), &physical_device, pool)?;
let cmd1 = exec.on_domain::<domain::All>()?.finish()?;
let cmd2 = exec.on_domain::<domain::All>()?.finish()?;
let mut batch = exec.start_submit_batch()?;
// Submit the first command buffer first
batch.submit(cmd1)?
// The second command buffer waits at COLOR_ATTACHMENT_OUTPUT on the first command buffer's completion.
.then(PipelineStage::COLOR_ATTACHMENT_OUTPUT, cmd2, &mut batch)?;
batch.finish()?.wait()?;
Sourcepub fn try_get_queue<D: ExecutionDomain>(
&self,
) -> TryLockResult<MutexGuard<'_, Queue>>
pub fn try_get_queue<D: ExecutionDomain>( &self, ) -> TryLockResult<MutexGuard<'_, Queue>>
Try to get a reference to a queue matching the domain, or return an error state if this would need to block to lock the queue.
Sourcepub fn get_queue<D: ExecutionDomain>(&self) -> Option<MutexGuard<'_, Queue>>
pub fn get_queue<D: ExecutionDomain>(&self) -> Option<MutexGuard<'_, Queue>>
Obtain a reference to a queue matching the domain. Blocks if this queue is currently locked.
Source§impl<A: Allocator + 'static> ExecutionManager<A>
impl<A: Allocator + 'static> ExecutionManager<A>
Sourcepub fn submit<D: ExecutionDomain + 'static>(
&self,
cmd: CommandBuffer<D>,
) -> Result<Pooled<Fence>>
pub fn submit<D: ExecutionDomain + 'static>( &self, cmd: CommandBuffer<D>, ) -> Result<Pooled<Fence>>
Submit a command buffer to its queue.
Trait Implementations§
Source§impl<A: Clone + Allocator> Clone for ExecutionManager<A>
impl<A: Clone + Allocator> Clone for ExecutionManager<A>
Source§fn clone(&self) -> ExecutionManager<A>
fn clone(&self) -> ExecutionManager<A>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more