Esempio n. 1
0
        internal static DescriptorSet[] Allocate(DescriptorPool parent, ref DescriptorSetAllocateInfo createInfo)
        {
            fixed(long *setLayoutsPtr = createInfo.SetLayouts)
            {
                createInfo.ToNative(out DescriptorSetAllocateInfo.Native nativeCreateInfo, parent, setLayoutsPtr);

                int count = createInfo.SetLayouts?.Length ?? 0;

                var    descriptorSetsPtr = stackalloc long[count];
                Result result            = vkAllocateDescriptorSets(parent.Parent, &nativeCreateInfo, descriptorSetsPtr);

                VulkanException.ThrowForInvalidResult(result);

                var descriptorSets = new DescriptorSet[count];

                for (int i = 0; i < count; i++)
                {
                    descriptorSets[i] = new DescriptorSet(parent, descriptorSetsPtr[i]);
                }
                return(descriptorSets);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Allocate one or more descriptor sets.
 /// <para>
 /// The pool must have enough free descriptor capacity remaining to allocate the descriptor
 /// sets of the specified layouts.
 /// </para>
 /// <para>
 /// When a descriptor set is allocated, the initial state is largely uninitialized and all
 /// descriptors are undefined. However, the descriptor set can be bound in a command buffer
 /// without causing errors or exceptions. All entries that are statically used by a pipeline
 /// in a drawing or dispatching command must have been populated before the descriptor set is
 /// bound for use by that command. Entries that are not statically used by a pipeline can
 /// have uninitialized descriptors or descriptors of resources that have been destroyed, and
 /// executing a draw or dispatch with such a descriptor set bound does not cause undefined
 /// behavior. This means applications need not populate unused entries with dummy descriptors.
 /// </para>
 /// <para>
 /// If an allocation fails due to fragmentation, an indeterminate error is returned with an
 /// unspecified error code. Any returned error other than <see
 /// cref="Result.ErrorFragmentedPool"/> does not imply its usual meaning: applications should
 /// assume that the allocation failed due to fragmentation, and create a new descriptor pool.
 /// </para>
 /// </summary>
 /// <param name="allocateInfo">The structure describing parameters of the allocation.</param>
 public DescriptorSet[] AllocateSets(DescriptorSetAllocateInfo allocateInfo)
 {
     return(DescriptorSet.Allocate(this, ref allocateInfo));
 }