forked from MoonsideGames/MoonWorks
get rid of badly conceived command buffer queue
parent
9df9aaeb3a
commit
1fe256a479
|
@ -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.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -10,8 +10,6 @@ namespace MoonWorks.Graphics
|
|||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
private readonly Queue<CommandBuffer> commandBufferPool;
|
||||
|
||||
private readonly List<WeakReference<GraphicsResource>> resources = new List<WeakReference<GraphicsResource>>();
|
||||
|
||||
public GraphicsDevice(
|
||||
|
@ -30,26 +28,11 @@ namespace MoonWorks.Graphics
|
|||
presentationParameters,
|
||||
Conversions.BoolToByte(debugMode)
|
||||
);
|
||||
|
||||
commandBufferPool = new Queue<CommandBuffer>(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()
|
||||
|
|
Loading…
Reference in New Issue