Example #1
0
            private unsafe bool TryAllocateDescriptorSets(ReadOnlySpan <DescriptorSetLayout> layouts, bool isTry, out DescriptorSetCollection dsc)
            {
                Debug.Assert(!_done);

                DescriptorSet[] descriptorSets = new DescriptorSet[layouts.Length];

                fixed(DescriptorSet *pDescriptorSets = descriptorSets)
                {
                    fixed(DescriptorSetLayout *pLayouts = layouts)
                    {
                        var descriptorSetAllocateInfo = new DescriptorSetAllocateInfo()
                        {
                            SType              = StructureType.DescriptorSetAllocateInfo,
                            DescriptorPool     = _pool,
                            DescriptorSetCount = (uint)layouts.Length,
                            PSetLayouts        = pLayouts
                        };

                        var result = Api.AllocateDescriptorSets(Device, &descriptorSetAllocateInfo, pDescriptorSets);

                        if (isTry && result == Result.ErrorOutOfPoolMemory)
                        {
                            _totalSets = (int)_capacity;
                            _done      = true;
                            DestroyIfDone();
                            dsc = default;
                            return(false);
                        }

                        result.ThrowOnError();
                    }
                }

                _totalSets += layouts.Length;
                _setsInUse += layouts.Length;

                dsc = new DescriptorSetCollection(this, descriptorSets);
                return(true);
            }
Example #2
0
 public bool TryAllocateDescriptorSets(ReadOnlySpan <DescriptorSetLayout> layouts, out DescriptorSetCollection dsc)
 {
     return(TryAllocateDescriptorSets(layouts, isTry: true, out dsc));
 }
Example #3
0
 public void FreeDescriptorSets(DescriptorSetCollection dsc)
 {
     _setsInUse -= dsc.SetsCount;
     Debug.Assert(_setsInUse >= 0);
     DestroyIfDone();
 }