engine_vulkan: Fixes of queue allocation
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m48s

- Avoid to allocate dedicated queue for presentation and use graphics queue for it
- Use queueCount of Queue Family Properties for queue support checking
This commit is contained in:
Florian RICHER 2025-05-24 16:44:51 +02:00
parent 4676b1b5b8
commit d10212ac3b
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77

View file

@ -45,7 +45,6 @@ impl From<Option<&DisplayHandleWrapper>> for VulkanQueueFamilyStatus {
#[derive(Debug)] #[derive(Debug)]
pub struct VulkanQueueFamilyIndices { pub struct VulkanQueueFamilyIndices {
pub present_queue_family_index: VulkanQueueFamilyStatus,
pub graphics_queue_family_index: VulkanQueueFamilyStatus, pub graphics_queue_family_index: VulkanQueueFamilyStatus,
pub compute_queue_family_index: VulkanQueueFamilyStatus, pub compute_queue_family_index: VulkanQueueFamilyStatus,
pub transfer_queue_family_index: VulkanQueueFamilyStatus, pub transfer_queue_family_index: VulkanQueueFamilyStatus,
@ -54,7 +53,6 @@ pub struct VulkanQueueFamilyIndices {
impl From<VulkanQueueFamilyIndices> for Vec<VulkanQueueFamilyStatus> { impl From<VulkanQueueFamilyIndices> for Vec<VulkanQueueFamilyStatus> {
fn from(indices: VulkanQueueFamilyIndices) -> Self { fn from(indices: VulkanQueueFamilyIndices) -> Self {
vec![ vec![
indices.present_queue_family_index,
indices.graphics_queue_family_index, indices.graphics_queue_family_index,
indices.compute_queue_family_index, indices.compute_queue_family_index,
indices.transfer_queue_family_index, indices.transfer_queue_family_index,
@ -93,7 +91,6 @@ impl From<VulkanQueueFamilyIndices> for Vec<QueueCreateInfo> {
impl<'a> From<&'a VulkanQueuesQuery<'a>> for VulkanQueueFamilyIndices { impl<'a> From<&'a VulkanQueuesQuery<'a>> for VulkanQueueFamilyIndices {
fn from(query: &'a VulkanQueuesQuery<'a>) -> Self { fn from(query: &'a VulkanQueuesQuery<'a>) -> Self {
VulkanQueueFamilyIndices { VulkanQueueFamilyIndices {
present_queue_family_index: query.with_surface.into(),
graphics_queue_family_index: query.with_graphics_queue.into(), graphics_queue_family_index: query.with_graphics_queue.into(),
compute_queue_family_index: query.with_compute_queue.into(), compute_queue_family_index: query.with_compute_queue.into(),
transfer_queue_family_index: query.with_transfer_queue.into(), transfer_queue_family_index: query.with_transfer_queue.into(),
@ -116,36 +113,40 @@ pub fn find_queues_family_indices(
for (i, queue_family_properties) in physical_device.queue_family_properties().iter().enumerate() for (i, queue_family_properties) in physical_device.queue_family_properties().iter().enumerate()
{ {
if indices.present_queue_family_index.can_be_set() let mut available_queue_count = queue_family_properties.queue_count;
&& check_presentation_support(
physical_device,
i as u32,
&query.with_surface.as_ref().unwrap(),
)
{
indices.present_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32);
}
if indices.graphics_queue_family_index.can_be_set() if indices.graphics_queue_family_index.can_be_set()
&& check_queue_support(queue_family_properties, QueueFlags::GRAPHICS) && check_queue_support(queue_family_properties, QueueFlags::GRAPHICS)
&& available_queue_count > 0
{ {
indices.graphics_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32); if query.with_surface.is_none()
|| check_presentation_support(
physical_device,
i as u32,
&query.with_surface.as_ref().unwrap(),
)
{
indices.graphics_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32);
available_queue_count -= 1;
}
} }
if indices.compute_queue_family_index.can_be_set() if indices.compute_queue_family_index.can_be_set()
&& check_queue_support(queue_family_properties, QueueFlags::COMPUTE) && check_queue_support(queue_family_properties, QueueFlags::COMPUTE)
&& available_queue_count > 0
{ {
indices.compute_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32); indices.compute_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32);
available_queue_count -= 1;
} }
if indices.transfer_queue_family_index.can_be_set() if indices.transfer_queue_family_index.can_be_set()
&& check_queue_support(queue_family_properties, QueueFlags::TRANSFER) && check_queue_support(queue_family_properties, QueueFlags::TRANSFER)
&& available_queue_count > 0
{ {
indices.transfer_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32); indices.transfer_queue_family_index = VulkanQueueFamilyStatus::Supported(i as u32);
} }
if !indices.present_queue_family_index.can_be_set() if !indices.graphics_queue_family_index.can_be_set()
&& !indices.graphics_queue_family_index.can_be_set()
&& !indices.compute_queue_family_index.can_be_set() && !indices.compute_queue_family_index.can_be_set()
&& !indices.transfer_queue_family_index.can_be_set() && !indices.transfer_queue_family_index.can_be_set()
{ {