2023-01-14 12:03:01 +00:00
|
|
|
//! `vulkan` module is a collection of abstractions for vulkan functions
|
|
|
|
#![deny(rust_2018_idioms)]
|
|
|
|
|
|
|
|
pub mod prelude;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod macros;
|
|
|
|
|
|
|
|
// mod error;
|
|
|
|
|
|
|
|
// pub use error::Result;
|
|
|
|
|
|
|
|
pub mod acceleration_structure;
|
|
|
|
pub mod address;
|
|
|
|
pub mod buffer;
|
|
|
|
pub mod commandbuffer;
|
|
|
|
pub mod commandpool;
|
|
|
|
pub mod deferred_operation;
|
|
|
|
pub mod descriptorpool;
|
|
|
|
pub mod descriptorset;
|
|
|
|
pub mod descriptorsetlayout;
|
|
|
|
pub mod device;
|
|
|
|
pub mod fence;
|
|
|
|
pub mod framebuffer;
|
|
|
|
pub mod image;
|
|
|
|
pub mod instance;
|
|
|
|
pub mod memory;
|
|
|
|
pub mod physicaldevice;
|
|
|
|
pub mod pipeline;
|
|
|
|
pub mod pipelinecache;
|
|
|
|
pub mod pipelinelayout;
|
|
|
|
pub mod pipelines;
|
|
|
|
pub mod querypool;
|
|
|
|
pub mod queue;
|
|
|
|
pub mod render_target;
|
|
|
|
pub mod renderpass;
|
|
|
|
pub mod semaphore;
|
|
|
|
pub mod shadermodule;
|
|
|
|
pub mod surface;
|
|
|
|
pub mod swapchain;
|
|
|
|
|
|
|
|
pub mod ffi;
|
|
|
|
|
|
|
|
mod sampler_manager;
|
2023-01-20 06:24:54 +00:00
|
|
|
mod single_submit;
|
2023-01-14 12:03:01 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub enum OutOfDate<T> {
|
|
|
|
Ok(T),
|
|
|
|
OutOfDate,
|
|
|
|
TimeOut,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait VkHandle<T> {
|
|
|
|
fn vk_handle(&self) -> T;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait VulkanDevice {
|
|
|
|
fn device(&self) -> &std::sync::Arc<device::Device>;
|
|
|
|
}
|
2023-04-15 07:21:08 +00:00
|
|
|
|
|
|
|
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],
|
2023-04-19 06:52:23 +00:00
|
|
|
DeviceFeatures {
|
|
|
|
samplerAnisotropy: VK_TRUE,
|
|
|
|
|
|
|
|
..DeviceFeatures::default()
|
|
|
|
},
|
2023-04-15 07:21:08 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
let queue = device.get_queue(queue_info.queue_family_index, queue_info.queue_index);
|
|
|
|
|
|
|
|
Ok((device, queue))
|
|
|
|
}
|