示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandPoolCreateInfo"/> structure.
 /// </summary>
 /// <param name="queueFamilyIndex">
 /// Designates a queue family.
 /// <para>
 /// All command buffers allocated from this command pool must be submitted on queues from the
 /// same queue family.
 /// </para>
 /// </param>
 /// <param name="flags">
 /// A bitmask indicating usage behavior for the pool and command buffers allocated from it.
 /// </param>
 public CommandPoolCreateInfo(int queueFamilyIndex, CommandPoolCreateFlags flags = 0)
 {
     Type             = StructureType.CommandPoolCreateInfo;
     Next             = IntPtr.Zero;
     Flags            = flags;
     QueueFamilyIndex = queueFamilyIndex;
 }
示例#2
0
        public bool SetQueueName(string qName,
                                 int famIndex, int qIndex, CommandPoolCreateFlags poolFlags)
        {
            if (mQueueNames.ContainsKey(qName))
            {
                Misc.SafeInvoke(eErrorSpam, "Queue name already in use: " + qName + " in SetQueueName()");
                return(false);
            }

            int physIndex = mPhysicals.IndexOf(mLogical.Parent);

            if (famIndex < 0 || famIndex >= mDeviceQueueFamProps[physIndex].Length)
            {
                Misc.SafeInvoke(eErrorSpam, "Bad queue family index: " + famIndex + " in SetQueueName()");
                return(false);
            }

            if (qIndex < 0 || qIndex >= mQueueLimits[physIndex][qIndex])
            {
                Misc.SafeInvoke(eErrorSpam, "Bad queue index: " + qIndex + " in SetQueueName()");
                return(false);
            }

            Queue q = mLogical.GetQueue(famIndex, qIndex);

            mQueueNames.Add(qName, q);

            //make a command pool for this queue
            CommandPoolCreateInfo cpci = new CommandPoolCreateInfo(
                famIndex, poolFlags);

            mCommandPools.Add(qName, mLogical.CreateCommandPool(cpci));

            return(true);
        }
示例#3
0
        public static CommandPoolCreateInfo CommandPoolCreateInfo(uint queueFamily, CommandPoolCreateFlags flags)
        {
            return(new CommandPoolCreateInfo()
            {
                SType = StructureType.CommandPoolCreateInfo,
                Flags = flags,

                QueueFamilyIndex = queueFamily
            });
        }
 public CommandPoolCreateInfo
 (
     StructureType sType          = StructureType.CommandPoolCreateInfo,
     void *pNext                  = default,
     CommandPoolCreateFlags flags = default,
     uint queueFamilyIndex        = default
 )
 {
     SType            = sType;
     PNext            = pNext;
     Flags            = flags;
     QueueFamilyIndex = queueFamilyIndex;
 }
示例#5
0
        /// <summary>
        /// Construct a QueueFamily referring to a queue family that supports a given queue type
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="queueType"></param>
        public QueueFamily(
            string name, Graphics graphics, QueueType queueType, int count,
            bool hasCommandPool, CommandPoolCreateFlags commandPoolFlags = default
            )
        {
            // Argument checks
            if (graphics is null)
            {
                throw new ArgumentNullException(nameof(graphics));
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), $"Queue count must be >= 0");
            }
            if (count == 0)
            {
                Debug.Warning($"Queue count for queue family \"{name}\" is 0");
            }
            // Set the object name
            Name = name;
            // Store the Graphics object
            Graphics = graphics;
            // Find a queue family index that fits the requirement
            {
                var families = graphics.PhysicalDevice.GetQueueFamilyProperties();
                Index = -1;
                for (var i = 0; i < families.Length; i++)
                {
                    switch (queueType)
                    {
                    case QueueType.Compute:
                        if (Supports(families[i], VulkanCore.Queues.Compute))
                        {
                            Index = i;
                        }
                        break;

                    case QueueType.Graphics:
                        if (Supports(families[i], VulkanCore.Queues.Graphics))
                        {
                            Index = i;
                        }
                        break;

                    case QueueType.Transfer:
                        if (Supports(families[i], VulkanCore.Queues.Transfer))
                        {
                            Index = i;
                        }
                        break;

                    case QueueType.Present:
                        if (SupportsPresenting(i, graphics.PhysicalDevice, graphics.Surface))
                        {
                            Index = i;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(queueType));
                    }
                    if (Index != -1)
                    {
                        break;
                    }
                }
                if (Index == -1)
                {
                    throw new InvalidOperationException(
                              "QueueFamily has an index of -1; no queue family found that matches the criteria?"
                              );
                }
                Debug.Info($"\"{Name}\" created with Index {Index}", nameof(QueueFamily));
            }
            // Create the queue array
            QueueArray = new Queue[count];
            // Set whether to create a command pool
            HasCommandPool = hasCommandPool;
            // Set the command pool flags
            CommandPoolFlags = commandPoolFlags;
        }