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); } }
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); }
public bool TryTake(out AmtDescriptorSet dSet) { return(FreeSets.TryTake(out dSet)); }
public void Add(AmtDescriptorSet localSet) { FreeSets.Add(localSet); }