public GraphicsContext(GraphicsDevice graphicsDevice, GraphicsResourceAllocator allocator = null, CommandList commandList = null) { CommandList = commandList ?? graphicsDevice.InternalMainCommandList ?? CommandList.New(graphicsDevice).DisposeBy(graphicsDevice); Allocator = allocator ?? new GraphicsResourceAllocator(graphicsDevice).DisposeBy(graphicsDevice); // prepare some resources now, so we don't need to do it during runtime (which can cause lag spikes or worse) // DirectX doesn't seem to like this very much, though if (GraphicsDevice.Platform == GraphicsPlatform.Vulkan && AvailableAllocators == null && PrepareVulkanAllocatorCount > 0) { AvailableAllocators = new Queue <ResourceGroupAllocator>(); while (AvailableAllocators.Count < PrepareVulkanAllocatorCount) { AvailableAllocators.Enqueue(new ResourceGroupAllocator(Allocator, CommandList, 2).DisposeBy(graphicsDevice)); } } if (AvailableAllocators?.Count > 0) { ResourceGroupAllocator = AvailableAllocators.Dequeue(); } else { ResourceGroupAllocator = new ResourceGroupAllocator(Allocator, CommandList, 2).DisposeBy(graphicsDevice); } }
public GraphicsContext(GraphicsDevice graphicsDevice, GraphicsResourceAllocator allocator = null, CommandList commandList = null) { CommandList = commandList ?? graphicsDevice.InternalMainCommandList ?? CommandList.New(graphicsDevice).DisposeBy(graphicsDevice); Allocator = allocator ?? new GraphicsResourceAllocator(graphicsDevice).DisposeBy(graphicsDevice); ResourceGroupAllocator = new ResourceGroupAllocator(Allocator, CommandList).DisposeBy(graphicsDevice); }