diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 380b586d..e083f6b6 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -664,7 +664,7 @@ namespace MoonWorks.Graphics return new Texture( Device, Refresh.Refresh_AcquireSwapchainTexture(Device.Handle, Handle, window.Handle), - (TextureFormat) Refresh.Refresh_GetSwapchainFormat(Device.Handle, window.Handle), + Device.GetSwapchainFormat(window), window.Width, window.Height ); diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 74f1a4f0..e54f32ea 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -57,6 +57,11 @@ namespace MoonWorks.Graphics Refresh.Refresh_Wait(Handle); } + public TextureFormat GetSwapchainFormat(Window window) + { + return (TextureFormat) Refresh.Refresh_GetSwapchainFormat(Handle, window.Handle); + } + internal void SubmitDestroyCommandBuffer() { if (resourcesToDestroy.Count > 0) diff --git a/src/Graphics/GraphicsResource.cs b/src/Graphics/GraphicsResource.cs index e6f749ed..f60b19e8 100644 --- a/src/Graphics/GraphicsResource.cs +++ b/src/Graphics/GraphicsResource.cs @@ -12,12 +12,15 @@ namespace MoonWorks.Graphics private WeakReference selfReference; - public GraphicsResource(GraphicsDevice device) + public GraphicsResource(GraphicsDevice device, bool trackResource = true) { Device = device; - selfReference = new WeakReference(this); - Device.AddResourceReference(selfReference); + if (trackResource) + { + selfReference = new WeakReference(this); + Device.AddResourceReference(selfReference); + } } protected virtual void Dispose(bool disposing) diff --git a/src/Graphics/Resources/Texture.cs b/src/Graphics/Resources/Texture.cs index 1e8ff79d..41e460f9 100644 --- a/src/Graphics/Resources/Texture.cs +++ b/src/Graphics/Resources/Texture.cs @@ -200,13 +200,14 @@ namespace MoonWorks.Graphics } // Used by AcquireSwapchainTexture. + // Should not be tracked, because swapchain textures are managed by Vulkan. internal Texture( GraphicsDevice device, IntPtr handle, TextureFormat format, uint width, uint height - ) : base(device) + ) : base(device, false) { Handle = handle;