public unsafe bool TryAllocate(ResourceSet myResources) { myEnumValues = (DescriptorType[])Enum.GetValues(typeof(DescriptorType)); int PoolItems = myEnumValues.Count(); DescriptorPoolSize[] myPoolSizeValues = new DescriptorPoolSize[PoolItems]; uint *myValues = stackalloc uint[PoolItems]; if (TotalSetsRemaining > 0) { for (int i = 0; i < myEnumValues.Length; i++) { myValues[i] = myResources.GetRequestedDescriptorSetSize(myEnumValues[i]); if (DescriptorSetTypesRemainingInPool[i] < myValues[i]) { return(false); } } } for (int i = 0; i < PoolItems; i++) { DescriptorSetTypesRemainingInPool[i] -= myValues[i]; } myResources.AllocateFrom(myNewPoolObject); return(true); }