Make queue optional
This commit is contained in:
parent
358c3c5182
commit
f82fad411f
1 changed files with 19 additions and 9 deletions
|
@ -168,6 +168,8 @@ pub struct SubPassBuilder<'a> {
|
|||
height: u32,
|
||||
sample_count: VkSampleCountFlags,
|
||||
|
||||
queue: Option<Arc<Mutex<Queue>>>,
|
||||
|
||||
target_infos: Vec<CustomTarget>,
|
||||
|
||||
input_info: Option<InputAttachmentInfo>,
|
||||
|
@ -227,8 +229,14 @@ impl<'a> SubPassBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn build(self, device: &Arc<Device>, queue: &Arc<Mutex<Queue>>) -> Result<SubPass> {
|
||||
let attachments = self.create_images(device, queue)?;
|
||||
pub fn use_queue(mut self, queue: Arc<Mutex<Queue>>) -> Self {
|
||||
self.queue = Some(queue);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self, device: &Arc<Device>) -> Result<SubPass> {
|
||||
let attachments = self.create_images(device)?;
|
||||
|
||||
Ok(SubPass {
|
||||
extent: VkExtent2D {
|
||||
|
@ -244,11 +252,7 @@ impl<'a> SubPassBuilder<'a> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn create_images(
|
||||
&self,
|
||||
device: &Arc<Device>,
|
||||
queue: &Arc<Mutex<Queue>>,
|
||||
) -> Result<Vec<AttachmentInfo>> {
|
||||
fn create_images(&self, device: &Arc<Device>) -> Result<Vec<AttachmentInfo>> {
|
||||
// check for correct sample count
|
||||
let checked_sample_count = device.max_supported_sample_count(self.sample_count);
|
||||
|
||||
|
@ -262,7 +266,9 @@ impl<'a> SubPassBuilder<'a> {
|
|||
for target_info in self.target_infos.iter() {
|
||||
attachment_infos.push(target_info.to_attachment_info(
|
||||
device,
|
||||
queue,
|
||||
self.queue.as_ref().ok_or(anyhow::anyhow!(
|
||||
"Using custom targets requires a queue to be attached!"
|
||||
))?,
|
||||
self.width,
|
||||
self.height,
|
||||
self.sample_count,
|
||||
|
@ -301,7 +307,9 @@ impl<'a> SubPassBuilder<'a> {
|
|||
ResolveTarget::CustomTarget(custom_target) => {
|
||||
let mut attachment_info = custom_target.to_attachment_info(
|
||||
device,
|
||||
queue,
|
||||
self.queue.as_ref().ok_or(anyhow::anyhow!(
|
||||
"Using custom targets requires a queue to be attached!"
|
||||
))?,
|
||||
self.width,
|
||||
self.height,
|
||||
VK_SAMPLE_COUNT_1_BIT,
|
||||
|
@ -409,6 +417,8 @@ impl SubPass {
|
|||
height,
|
||||
sample_count: VK_SAMPLE_COUNT_1_BIT,
|
||||
|
||||
queue: None,
|
||||
|
||||
input_info: None,
|
||||
|
||||
target_infos: Vec::new(),
|
||||
|
|
Loading…
Reference in a new issue