diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index ade8a06..efe359c 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -9,16 +9,16 @@ namespace MoonWorks.Graphics /// Command buffers are used to apply render state and issue draw calls. /// NOTE: it is not recommended to hold references to command buffers long term. /// - public class CommandBuffer + public struct CommandBuffer { public GraphicsDevice Device { get; } public IntPtr Handle { get; internal set; } // called from RefreshDevice - internal CommandBuffer(GraphicsDevice device) + internal CommandBuffer(GraphicsDevice device, IntPtr handle) { Device = device; - Handle = IntPtr.Zero; + Handle = handle; } /// diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index d0bfabf..7890f7a 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -10,8 +10,6 @@ namespace MoonWorks.Graphics public bool IsDisposed { get; private set; } - private readonly Queue commandBufferPool; - private readonly List> resources = new List>(); public GraphicsDevice( @@ -30,26 +28,11 @@ namespace MoonWorks.Graphics presentationParameters, Conversions.BoolToByte(debugMode) ); - - commandBufferPool = new Queue(initialCommandBufferPoolSize); - for (var i = 0; i < initialCommandBufferPoolSize; i += 1) - { - commandBufferPool.Enqueue(new CommandBuffer(this)); - } } public CommandBuffer AcquireCommandBuffer() { - var commandBufferHandle = Refresh.Refresh_AcquireCommandBuffer(Handle, 0); - if (commandBufferPool.Count == 0) - { - commandBufferPool.Enqueue(new CommandBuffer(this)); - } - - var commandBuffer = commandBufferPool.Dequeue(); - commandBuffer.Handle = commandBufferHandle; - - return commandBuffer; + return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle, 0)); } public unsafe void Submit(params CommandBuffer[] commandBuffers) @@ -66,13 +49,6 @@ namespace MoonWorks.Graphics (uint) commandBuffers.Length, (IntPtr) commandBufferPtrs ); - - // return to pool - for (var i = 0; i < commandBuffers.Length; i += 1) - { - commandBuffers[i].Handle = IntPtr.Zero; - commandBufferPool.Enqueue(commandBuffers[i]); - } } public void Wait()