public StreamingChunkGenerator( StreamingStageMeshFactory meshFactory, MaterialInstance material, GraphicsDevice device) { Contracts.Requires.That(meshFactory != null); Contracts.Requires.That(material != null); Contracts.Requires.That(device != null); this.meshFactory = meshFactory; this.material = material; this.proceduralMesh = new ProceduralMeshFactory16 <VertexPositionNormalColorTexture>( VertexPositionNormalColorTexture.Format, device); var transferOptions = new TrackingPoolOptions <MeshDataTransfer16 <VertexPositionNormalColorTexture> >() { BoundedCapacity = this.meshFactory.ThreadsCount, }; this.transferPool = Pool.New(transferOptions); var meshOptions = MeshDataTransferOptions.New16Bit(); meshOptions.InitialIndices = meshOptions.InitialVertices * 2; this.maxVertices = meshOptions.MaxVertices; this.transferPool.GiveUntilFull( Factory.From(() => new MeshDataTransfer16 <VertexPositionNormalColorTexture>(meshOptions))); this.throttler = new AsyncTaskThrottler <ChunkKey, Model>( this.DoGenerateModelAsync, this.meshFactory.ThreadsCount); ////key => Task.Run(() => this.DoGenerateModelAsync(key)), this.meshFactory.ThreadsCount); }
public static TrackingPool <TResource> CreateAndAssignTrackingResourceStash <TKey, TResource>( this IChunkCacheBuilder <TKey, TResource> builder, long approximateCapacityInBytes, ChunkCacheBuilderOptions <TResource> options = null) { Contracts.Requires.That(builder != null); Contracts.Requires.That(approximateCapacityInBytes > 0); var poolOptions = new TrackingPoolOptions <TResource>(); options = HandleOptions(poolOptions, options); poolOptions.BoundedCapacity = builder.CalculateResourcePoolCapacity(approximateCapacityInBytes); TrackingPool <TResource> pool; if (options.EagerFillPool) { pool = Pool.Tracking.New(poolOptions); pool.GiveUntilFull(builder.ResourceFactory); } else { pool = Pool.Tracking.WithFactory.Bounded.New(builder.ResourceFactory, poolOptions); } builder.ResourceStash = PoolStash.Create <TKey, TResource>(pool, options.StashCapacityMultiplier); return(pool); }