public static uint FindSuitableQueueFamily(Vk api, PhysicalDevice physicalDevice, SurfaceKHR surface, out uint queueCount) { const QueueFlags RequiredFlags = QueueFlags.QueueGraphicsBit | QueueFlags.QueueComputeBit; var khrSurface = new KhrSurface(api.Context); uint propertiesCount; api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, null); QueueFamilyProperties[] properties = new QueueFamilyProperties[propertiesCount]; fixed(QueueFamilyProperties *pProperties = properties) { api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, pProperties); } for (uint index = 0; index < propertiesCount; index++) { var queueFlags = properties[index].QueueFlags; khrSurface.GetPhysicalDeviceSurfaceSupport(physicalDevice, index, surface, out var surfaceSupported).ThrowOnError(); if (queueFlags.HasFlag(RequiredFlags) && surfaceSupported) { queueCount = properties[index].QueueCount; return(index); } } queueCount = 0; return(InvalidIndex); }
public CommandBuffer CreateCommandBuffer(QueueFlags type) { return(Device.AllocateCommandBuffers(new CommandBufferAllocateInfo { CommandPool = GetPool(type), Level = CommandBufferLevel.Primary, CommandBufferCount = 1, })); }
public bool SupportsType(QueueFlags G) { foreach (QueueFamilyProperties A in this.QueueFamilyProperties) { if ((A.QueueFlags & G) == G) { return(true); } } return(false); }
QueueInfo GetQueue(QueueFlags flags) { foreach (QueueInfo info in queueInfoList) { if ((info.flags & flags) == flags) { return(info); } } throw new Exception("No Queue with flags:" + flags); }
public int GetQueueFamilyIndexByType(QueueFlags G) { for (int i = 0; i < this.QueueFamilyProperties.Length; i++) { var A = this.QueueFamilyProperties[i]; if ((A.QueueFlags & G) == G) { return(i); } } return(-1); }
public QueueFamilyProperties ( QueueFlags queueFlags = default, uint queueCount = default, uint timestampValidBits = default, Extent3D minImageTransferGranularity = default ) { QueueFlags = queueFlags; QueueCount = queueCount; TimestampValidBits = timestampValidBits; MinImageTransferGranularity = minImageTransferGranularity; }
private IEnumerable <uint> GetSuitableQueues(SharpVk.PhysicalDevice device, QueueFlags type) { // - Gets GPU command queues var queues = device.GetQueueFamilyProperties(); for (uint i = 0; i < queues.Length; ++i) { var queue = queues[i]; if (queue.QueueFlags.HasFlag(type)) { yield return(i); } } }
CommandPool GetPool(QueueFlags type) { CommandPool pool; if (pools.TryGetValue(type, out pool)) { return(pool); } CommandPoolCreateInfo info = new CommandPoolCreateInfo { QueueFamilyIndex = GetQueue(type).queueFamilyIndex, Flags = (uint)CommandPoolCreateFlags.ResetCommandBuffer, }; pool = Device.CreateCommandPool(info, null); pools.Add(type, pool); return(pool); }
static int ScoreQueue(QueueFamilyProperties queueFamilyProperties, QueueFlags flags) { // Check if all flags are pressent if ((queueFamilyProperties.QueueFlags & flags) == flags) { int score = 256; // base score this was we can remove a lot and are still over 0 int targetFlagCount = CountFlags((int)flags); int flagsCount = CountFlags((int)queueFamilyProperties.QueueFlags); score -= flagsCount - targetFlagCount * 16; // remove 16 for for overmaching the falgs score += (int)queueFamilyProperties.QueueCount; // add score for QueueCount; if (score <= 0) { // always return minimum of 1 if it maches the flags return(1); } return(score); } return(0); }
public bool Supports(QueueFlags flags) { return(QueueFlags.HasFlag(flags)); }
public static IEnumerable <PhysicalDevice> GetSuitablePhysicalDevices(this Instance @this, string[] requiredPhysicalDeviceExtensions, PhysicalDeviceFeatures requiredPhysicalDeviceFeatures, QueueFlags requiredQueueFlags, SurfaceKhr surface) { var suitablePhysicalDevices = new List <PhysicalDevice>(); foreach (var physicalDevice in @this.EnumeratePhysicalDevices()) { // Make sure device supports required extensions if (physicalDevice.SupportsExtensions(requiredPhysicalDeviceExtensions) == false) { continue; } // Make sure device supports required features if (physicalDevice.SupportsFeatures(requiredPhysicalDeviceFeatures) == false) { continue; } // Make sure device has a queue family with required flags if (physicalDevice.GetIndexOfFirstAvailableGraphicsQueueFamily() < 0) { continue; } // Make sure device has a queue family with required flags if (physicalDevice.GetIndexOfFirstAvailablePresentQueueFamily(surface) < 0) { continue; } suitablePhysicalDevices.Add(physicalDevice); } if (suitablePhysicalDevices.Count() == 0) { throw new VulkanException("No suitable physical device found"); } return(suitablePhysicalDevices); }
internal int GetFreeQueueCount(QueueFlags graphics) { return(myQueueLookup[graphics].GetRemainingQueueCount()); }