Publish create vk handles for tests
This commit is contained in:
parent
591aba8c12
commit
c5a5588696
2 changed files with 40 additions and 34 deletions
|
@ -344,46 +344,14 @@ mod test {
|
|||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
fn create_vk_handles() -> Result<(Arc<Device>, Arc<Mutex<Queue>>)> {
|
||||
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(
|
||||
|
|
|
@ -58,3 +58,41 @@ pub trait VkHandle<T> {
|
|||
pub trait VulkanDevice {
|
||||
fn device(&self) -> &std::sync::Arc<device::Device>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn create_vk_handles() -> anyhow::Result<(
|
||||
std::sync::Arc<prelude::Device>,
|
||||
std::sync::Arc<std::sync::Mutex<prelude::Queue>>,
|
||||
)> {
|
||||
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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue