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