more presentation API improvements

main
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(
Device,
Refresh.Refresh_AcquireSwapchainTexture(Device.Handle, Handle, window.Handle),
(TextureFormat) Refresh.Refresh_GetSwapchainFormat(Device.Handle, window.Handle),
Device.GetSwapchainFormat(window),
window.Width,
window.Height
);

View File

@ -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)

View File

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

View File

@ -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;