Skip to content

Commit

Permalink
Add sparse image querying functions (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua authored Sep 11, 2022
1 parent c5a04f9 commit f82d13a
Show file tree
Hide file tree
Showing 7 changed files with 723 additions and 197 deletions.
2 changes: 1 addition & 1 deletion vulkano/src/command_buffer/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
use crate::{
buffer::{sys::UnsafeBuffer, BufferAccess},
command_buffer::CommandBufferInheritanceRenderingInfo,
device::{physical::QueueFamilyProperties, Device, DeviceOwned, Queue},
device::{Device, DeviceOwned, Queue, QueueFamilyProperties},
format::Format,
image::{sys::UnsafeImage, ImageAccess, ImageLayout, ImageSubresourceRange},
query::{QueryControlFlags, QueryType},
Expand Down
82 changes: 82 additions & 0 deletions vulkano/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ use crate::{
command_buffer::pool::StandardCommandPool,
descriptor_set::pool::StandardDescriptorPool,
instance::{debug::DebugUtilsLabel, Instance},
macros::vulkan_bitflags,
memory::{pool::StandardMemoryPool, ExternalMemoryHandleType},
sync::PipelineStage,
OomError, RequirementNotMet, RequiresOneOf, SynchronizedVulkanObject, Version, VulkanError,
VulkanObject,
};
Expand Down Expand Up @@ -1247,6 +1249,86 @@ impl Hash for Queue {
}
}

/// Properties of a queue family in a physical device.
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct QueueFamilyProperties {
/// Attributes of the queue family.
pub queue_flags: QueueFlags,

/// The number of queues available in this family.
///
/// This guaranteed to be at least 1 (or else that family wouldn't exist).
pub queue_count: u32,

/// If timestamps are supported, the number of bits supported by timestamp operations.
/// The returned value will be in the range 36..64.
///
/// If timestamps are not supported, this is `None`.
pub timestamp_valid_bits: Option<u32>,

/// The minimum granularity supported for image transfers, in terms of `[width, height, depth]`.
pub min_image_transfer_granularity: [u32; 3],
}

impl QueueFamilyProperties {
/// Returns whether the queues of this family support a particular pipeline stage.
#[inline]
pub fn supports_stage(&self, stage: PipelineStage) -> bool {
ash::vk::QueueFlags::from(self.queue_flags).contains(stage.required_queue_flags())
}
}

impl From<ash::vk::QueueFamilyProperties> for QueueFamilyProperties {
#[inline]
fn from(val: ash::vk::QueueFamilyProperties) -> Self {
Self {
queue_flags: val.queue_flags.into(),
queue_count: val.queue_count,
timestamp_valid_bits: (val.timestamp_valid_bits != 0)
.then_some(val.timestamp_valid_bits),
min_image_transfer_granularity: [
val.min_image_transfer_granularity.width,
val.min_image_transfer_granularity.height,
val.min_image_transfer_granularity.depth,
],
}
}
}

vulkan_bitflags! {
/// Attributes of a queue or queue family.
#[non_exhaustive]
QueueFlags = QueueFlags(u32);

/// Queues of this family can execute graphics operations.
graphics = GRAPHICS,

/// Queues of this family can execute compute operations.
compute = COMPUTE,

/// Queues of this family can execute transfer operations.
transfer = TRANSFER,

/// Queues of this family can execute sparse memory management operations.
sparse_binding = SPARSE_BINDING,

/// Queues of this family can be created using the `protected` flag.
protected = PROTECTED {
api_version: V1_1,
},

/// Queues of this family can execute video decode operations.
video_decode = VIDEO_DECODE_KHR {
device_extensions: [khr_video_decode_queue],
},

/// Queues of this family can execute video encode operations.
video_encode = VIDEO_ENCODE_KHR {
device_extensions: [khr_video_encode_queue],
},
}

/// Error that can happen when submitting a debug utils command to a queue.
#[derive(Clone, Debug)]
pub enum DebugUtilsError {
Expand Down
Loading

0 comments on commit f82d13a

Please # to comment.