Пример #1
0
        public AmtDescriptorPool(MgDescriptorPoolCreateInfo createInfo)
        {
            if (createInfo == null)
            {
                throw new ArgumentNullException(nameof(createInfo));
            }

            PoolSize     = createInfo.MaxSets;
            FreeSets     = new ConcurrentBag <AmtDescriptorSet> ();
            AttachedSets = new AmtDescriptorSet[PoolSize];

            for (var i = 0; i < PoolSize; ++i)
            {
                var descriptorSet = new AmtDescriptorSet(i);
                AttachedSets[i] = descriptorSet;
                FreeSets.Add(descriptorSet);
            }
        }
Пример #2
0
        public Result AllocateDescriptorSets(MgDescriptorSetAllocateInfo pAllocateInfo, out IMgDescriptorSet[] pDescriptorSets)
        {
            if (pAllocateInfo == null)
            {
                throw new ArgumentNullException(nameof(pAllocateInfo));
            }

            var pool = (AmtDescriptorPool)pAllocateInfo.DescriptorPool;

            if (pool == null)
            {
                throw new ArgumentNullException(nameof(pAllocateInfo.DescriptorPool));
            }

            var noOfSetsRequested = pAllocateInfo.SetLayouts.Length;

            if (pool.RemainingSets < noOfSetsRequested)
            {
                throw new InvalidOperationException();
            }

            pDescriptorSets = new AmtDescriptorSet[noOfSetsRequested];

            for (int i = 0; i < noOfSetsRequested; ++i)
            {
                var setLayout = (AmtDescriptorSetLayout)pAllocateInfo.SetLayouts[i];

                AmtDescriptorSet dSet;
                if (!pool.TryTake(out dSet))
                {
                    throw new InvalidOperationException();
                }
                // copy here
                dSet.Initialize(setLayout);
                pDescriptorSets[i] = dSet;
            }

            return(Result.SUCCESS);
        }
Пример #3
0
 public bool TryTake(out AmtDescriptorSet dSet)
 {
     return(FreeSets.TryTake(out dSet));
 }
Пример #4
0
 public void Add(AmtDescriptorSet localSet)
 {
     FreeSets.Add(localSet);
 }