destroy update
parent
42754ef80d
commit
17333cfb67
|
@ -1 +1 @@
|
|||
Subproject commit 1a9495366722c0334b563d6c7daa73bcc49d00eb
|
||||
Subproject commit 06466292d5e6dae3b73324c251c9484f1edeef09
|
|
@ -135,8 +135,6 @@ namespace MoonWorks
|
|||
Draw(timestep, alpha);
|
||||
|
||||
}
|
||||
|
||||
GraphicsDevice.SubmitDestroyCommandBuffer();
|
||||
}
|
||||
|
||||
OnDestroy();
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace MoonWorks.Graphics
|
|||
public bool IsDisposed { get; private set; }
|
||||
|
||||
private readonly List<WeakReference<GraphicsResource>> resources = new List<WeakReference<GraphicsResource>>();
|
||||
private Dictionary<IntPtr, Action<IntPtr, IntPtr, IntPtr>> resourcesToDestroy = new Dictionary<IntPtr, Action<IntPtr, IntPtr, IntPtr>>();
|
||||
|
||||
public GraphicsDevice(
|
||||
IntPtr deviceWindowHandle,
|
||||
|
@ -62,26 +61,6 @@ namespace MoonWorks.Graphics
|
|||
return (TextureFormat) Refresh.Refresh_GetSwapchainFormat(Handle, window.Handle);
|
||||
}
|
||||
|
||||
internal void SubmitDestroyCommandBuffer()
|
||||
{
|
||||
if (resourcesToDestroy.Count > 0)
|
||||
{
|
||||
var commandBuffer = AcquireCommandBuffer();
|
||||
|
||||
foreach (var kv in resourcesToDestroy)
|
||||
{
|
||||
kv.Value.Invoke(Handle, commandBuffer.Handle, kv.Key);
|
||||
}
|
||||
|
||||
Submit(commandBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
internal void PrepareDestroyResource(GraphicsResource resource, Action<IntPtr, IntPtr, IntPtr> destroyFunction)
|
||||
{
|
||||
resourcesToDestroy.Add(resource.Handle, destroyFunction);
|
||||
}
|
||||
|
||||
internal void AddResourceReference(WeakReference<GraphicsResource> resourceReference)
|
||||
{
|
||||
lock (resources)
|
||||
|
@ -117,7 +96,6 @@ namespace MoonWorks.Graphics
|
|||
resources.Clear();
|
||||
}
|
||||
|
||||
SubmitDestroyCommandBuffer();
|
||||
Refresh.Refresh_DestroyDevice(Handle);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MoonWorks.Graphics
|
|||
public IntPtr Handle { get; protected set; }
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
protected abstract Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction { get; }
|
||||
protected abstract Action<IntPtr, IntPtr> QueueDestroyFunction { get; }
|
||||
|
||||
private WeakReference<GraphicsResource> selfReference;
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace MoonWorks.Graphics
|
|||
{
|
||||
if (selfReference != null)
|
||||
{
|
||||
Device.PrepareDestroyResource(this, QueueDestroyFunction);
|
||||
QueueDestroyFunction(Device.Handle, Handle);
|
||||
Device.RemoveResourceReference(selfReference);
|
||||
selfReference = null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace MoonWorks.Graphics
|
|||
/// </summary>
|
||||
public class Buffer : GraphicsResource
|
||||
{
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyBuffer;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a buffer of appropriate size given a type and element count.
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace MoonWorks.Graphics
|
|||
{
|
||||
public class ComputePipeline : GraphicsResource
|
||||
{
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline;
|
||||
|
||||
public ComputeShaderInfo ComputeShaderInfo { get; }
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MoonWorks.Graphics
|
|||
/// </summary>
|
||||
public class GraphicsPipeline : GraphicsResource
|
||||
{
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyGraphicsPipeline;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyGraphicsPipeline;
|
||||
|
||||
public GraphicsShaderInfo VertexShaderInfo { get; }
|
||||
public GraphicsShaderInfo FragmentShaderInfo { get; }
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MoonWorks.Graphics
|
|||
/// </summary>
|
||||
public class Sampler : GraphicsResource
|
||||
{
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroySampler;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroySampler;
|
||||
|
||||
public Sampler(
|
||||
GraphicsDevice device,
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MoonWorks.Graphics
|
|||
/// </summary>
|
||||
public class ShaderModule : GraphicsResource
|
||||
{
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule;
|
||||
|
||||
public unsafe ShaderModule(GraphicsDevice device, string filePath) : base(device)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace MoonWorks.Graphics
|
|||
public SampleCount SampleCount { get; }
|
||||
public TextureUsageFlags UsageFlags { get; }
|
||||
|
||||
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
||||
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
|
||||
|
||||
/// <summary>
|
||||
/// Loads a PNG from a file path.
|
||||
|
|
Loading…
Reference in New Issue