src/core/VulkanDevice.cpp
uint32_t VulkanDevice::getQueueFamilyIndex(VkQueueFlagBits queueFlags) const {
    // Dedicated queue for compute
    // Try to find a queue family index that supports compute but not graphics
    if (queueFlags & VK_QUEUE_COMPUTE_BIT) {
        for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
            if ((queueFamilyProperties[i].queueFlags & queueFlags) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0)) {
                return i;
            }
        }
    }

    // Dedicated queue for transfer
    // Try to find a queue family index that supports transfer but not graphics and compute
    if (queueFlags & VK_QUEUE_TRANSFER_BIT) {
        for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
            if ((queueFamilyProperties[i].queueFlags & queueFlags) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_COMPUTE_BIT) == 0)) {
                return i;
            }
        }
    }

    // For other queue types or if no separate compute queue is present, return the first one to support the requested flags
    for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
        if (queueFamilyProperties[i].queueFlags & queueFlags) {
            return i;
        }
    }

    throw std::runtime_error("Could not find a matching queue family index");
}
/**
	* Get the index of a queue family that supports the requested queue flags
	*
	* @param queueFlags Queue flags to find a queue family index for
	*
	* @return Index of the queue family index that matches the flags
	*
	* @throw Throws an exception if no queue family index could be found that supports the requested flags
	*/
Get the index of a queue family that supports the requested queue flags
@param queueFlags Queue flags to find a queue family index for

@return Index of the queue family index that matches the flags

@throw Throws an exception if no queue family index could be found that supports the requested flags
Get the index of a queue family that supports the requested queue flags @param queueFlags Queue flags to find a queue family index for @return Index of the queue family index that matches the flags @throw Throws an exception if no queue family index could be found that supports the requested flags
uint32_t VulkanDevice::getQueueFamilyIndex(VkQueueFlagBits queueFlags) const {
    if (queueFlags & VK_QUEUE_COMPUTE_BIT) {
        for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
            if ((queueFamilyProperties[i].queueFlags & queueFlags) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0)) {
                return i;
            }
        }
    }
    if (queueFlags & VK_QUEUE_TRANSFER_BIT) {
        for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
            if ((queueFamilyProperties[i].queueFlags & queueFlags) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0) &&
                ((queueFamilyProperties[i].queueFlags & VK_QUEUE_COMPUTE_BIT) == 0)) {
                return i;
            }
        }
    }
    for (uint32_t i = 0; i < static_cast<uint32_t>(queueFamilyProperties.size()); i++) {
        if (queueFamilyProperties[i].queueFlags & queueFlags) {
            return i;
        }
    }
    throw std::runtime_error("Could not find a matching queue family index");
}
uint32_t VulkanDevice :: getQueueFamilyIndex ( VkQueueFlagBits queueFlags ) const { if ( queueFlags & VK_QUEUE_COMPUTE_BIT ) { for ( uint32_t i = 0 ; i < static_cast < uint32_t > ( queueFamilyProperties . size ( ) ) ; i ++ ) { if ( ( queueFamilyProperties [ i ] . queueFlags & queueFlags ) && ( ( queueFamilyProperties [ i ] . queueFlags & VK_QUEUE_GRAPHICS_BIT ) == 0 ) ) { return i ; } } } if ( queueFlags & VK_QUEUE_TRANSFER_BIT ) { for ( uint32_t i = 0 ; i < static_cast < uint32_t > ( queueFamilyProperties . size ( ) ) ; i ++ ) { if ( ( queueFamilyProperties [ i ] . queueFlags & queueFlags ) && ( ( queueFamilyProperties [ i ] . queueFlags & VK_QUEUE_GRAPHICS_BIT ) == 0 ) && ( ( queueFamilyProperties [ i ] . queueFlags & VK_QUEUE_COMPUTE_BIT ) == 0 ) ) { return i ; } } } for ( uint32_t i = 0 ; i < static_cast < uint32_t > ( queueFamilyProperties . size ( ) ) ; i ++ ) { if ( queueFamilyProperties [ i ] . queueFlags & queueFlags ) { return i ; } } throw std :: runtime_error ( " " ) ; }
Get the index of a queue family that supports the requested queue flags
 @param queueFlags Queue flags to find a queue family index for
Get the index of a queue family that supports the requested queue flags @param queueFlags Queue flags to find a queue family index for
// Dedicated queue for compute // Try to find a queue family index that supports compute but not graphics // Dedicated queue for transfer // Try to find a queue family index that supports transfer but not graphics and compute // For other queue types or if no separate compute queue is present, return the first one to support the requested flags