diff --git a/vulkan-rs/src/descriptorset.rs b/vulkan-rs/src/descriptorset.rs index ec803dd..a64875d 100644 --- a/vulkan-rs/src/descriptorset.rs +++ b/vulkan-rs/src/descriptorset.rs @@ -344,46 +344,14 @@ mod test { use crate::prelude::*; use anyhow::Result; - use std::sync::{Arc, Mutex}; - - fn create_vk_handles() -> Result<(Arc, Arc>)> { - let instance = Instance::new( - VkApplicationInfo::new( - &VkString::new("Test: image::to_file"), - 1, - &VkString::new("no name"), - 1, - VK_MAKE_VERSION(1, 3, 0), - ), - VulkanDebugInfo::default(), - InstanceExtensions::default(), - )?; - - let physical_device = PhysicalDevice::new(instance)?; - - let queue_info = Queue::create_non_presentable_request_info( - &physical_device, - VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT, - )?; - - let device = Device::new( - physical_device, - DeviceExtensions::default(), - &[queue_info.queue_create_info], - DeviceFeatures::default(), - )?; - - let queue = device.get_queue(queue_info.queue_family_index, queue_info.queue_index); - - Ok((device, queue)) - } + use std::sync::Arc; #[test] fn create_multiple_sets_from_one_pool() -> Result<()> { const DESCRIPTOR_COUNT: u32 = 2; - let (device, _queue) = create_vk_handles()?; + let (device, _queue) = crate::create_vk_handles()?; let descriptor_layout = DescriptorSetLayout::builder() .add_layout_binding( diff --git a/vulkan-rs/src/lib.rs b/vulkan-rs/src/lib.rs index 7af27d6..7dccff5 100644 --- a/vulkan-rs/src/lib.rs +++ b/vulkan-rs/src/lib.rs @@ -58,3 +58,41 @@ pub trait VkHandle { pub trait VulkanDevice { fn device(&self) -> &std::sync::Arc; } + +#[cfg(test)] +pub fn create_vk_handles() -> anyhow::Result<( + std::sync::Arc, + std::sync::Arc>, +)> { + use crate::prelude::*; + + let instance = Instance::new( + VkApplicationInfo::new( + &VkString::new("Test: image::to_file"), + 1, + &VkString::new("no name"), + 1, + VK_MAKE_VERSION(1, 3, 0), + ), + VulkanDebugInfo::default(), + InstanceExtensions::default(), + )?; + + let physical_device = PhysicalDevice::new(instance)?; + + let queue_info = Queue::create_non_presentable_request_info( + &physical_device, + VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT, + )?; + + let device = Device::new( + physical_device, + DeviceExtensions::default(), + &[queue_info.queue_create_info], + DeviceFeatures::default(), + )?; + + let queue = device.get_queue(queue_info.queue_family_index, queue_info.queue_index); + + Ok((device, queue)) +}