more presentation API improvements

pull/17/head
cosmonaut 2022-03-01 23:21:42 -08:00
parent 81c882bd48
commit 1fa73f0275
4 changed files with 14 additions and 5 deletions

View File

@ -664,7 +664,7 @@ namespace MoonWorks.Graphics
return new Texture( return new Texture(
Device, Device,
Refresh.Refresh_AcquireSwapchainTexture(Device.Handle, Handle, window.Handle), Refresh.Refresh_AcquireSwapchainTexture(Device.Handle, Handle, window.Handle),
(TextureFormat) Refresh.Refresh_GetSwapchainFormat(Device.Handle, window.Handle), Device.GetSwapchainFormat(window),
window.Width, window.Width,
window.Height window.Height
); );

View File

@ -57,6 +57,11 @@ namespace MoonWorks.Graphics
Refresh.Refresh_Wait(Handle); Refresh.Refresh_Wait(Handle);
} }
public TextureFormat GetSwapchainFormat(Window window)
{
return (TextureFormat) Refresh.Refresh_GetSwapchainFormat(Handle, window.Handle);
}
internal void SubmitDestroyCommandBuffer() internal void SubmitDestroyCommandBuffer()
{ {
if (resourcesToDestroy.Count > 0) if (resourcesToDestroy.Count > 0)

View File

@ -12,12 +12,15 @@ namespace MoonWorks.Graphics
private WeakReference<GraphicsResource> selfReference; private WeakReference<GraphicsResource> selfReference;
public GraphicsResource(GraphicsDevice device) public GraphicsResource(GraphicsDevice device, bool trackResource = true)
{ {
Device = device; Device = device;
selfReference = new WeakReference<GraphicsResource>(this); if (trackResource)
Device.AddResourceReference(selfReference); {
selfReference = new WeakReference<GraphicsResource>(this);
Device.AddResourceReference(selfReference);
}
} }
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)

View File

@ -200,13 +200,14 @@ namespace MoonWorks.Graphics
} }
// Used by AcquireSwapchainTexture. // Used by AcquireSwapchainTexture.
// Should not be tracked, because swapchain textures are managed by Vulkan.
internal Texture( internal Texture(
GraphicsDevice device, GraphicsDevice device,
IntPtr handle, IntPtr handle,
TextureFormat format, TextureFormat format,
uint width, uint width,
uint height uint height
) : base(device) ) : base(device, false)
{ {
Handle = handle; Handle = handle;