From a6ea645e9197c4db02f04fbf02015739d855d323 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 21 Jan 2021 14:05:10 -0800 Subject: [PATCH] some API tweaks --- src/Graphics/CommandBuffer.cs | 43 +++++++++++++++++++++++---- src/Graphics/Resources/ColorTarget.cs | 8 ++--- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index 316b7627..103f5f66 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -327,8 +327,39 @@ namespace MoonWorks.Graphics } public void QueuePresent( - ref TextureSlice textureSlice, - ref Rect destinationRectangle, + in Texture texture, + in Rect destinationRectangle, + Filter filter + ) + { + var refreshRect = destinationRectangle.ToRefresh(); + var refreshTextureSlice = new Refresh.TextureSlice + { + texture = texture.Handle, + rectangle = new Refresh.Rect + { + x = 0, + y = 0, + w = (int)texture.Width, + h = (int)texture.Height + }, + layer = 0, + level = 0, + depth = 0 + }; + + Refresh.Refresh_QueuePresent( + Device.Handle, + Handle, + ref refreshTextureSlice, + ref refreshRect, + (Refresh.Filter)filter + ); + } + + public void QueuePresent( + in TextureSlice textureSlice, + in Rect destinationRectangle, Filter filter ) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); @@ -344,7 +375,7 @@ namespace MoonWorks.Graphics } public void QueuePresent( - ref TextureSlice textureSlice, + in TextureSlice textureSlice, Filter filter ) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); @@ -387,8 +418,8 @@ namespace MoonWorks.Graphics } public void CopyTextureToTexture( - ref TextureSlice sourceTextureSlice, - ref TextureSlice destinationTextureSlice, + in TextureSlice sourceTextureSlice, + in TextureSlice destinationTextureSlice, Filter filter ) { var sourceRefreshTextureSlice = sourceTextureSlice.ToRefreshTextureSlice(); @@ -404,7 +435,7 @@ namespace MoonWorks.Graphics } public void CopyTextureToBuffer( - ref TextureSlice textureSlice, + in TextureSlice textureSlice, Buffer buffer ) { var refreshTextureSlice = textureSlice.ToRefreshTextureSlice(); diff --git a/src/Graphics/Resources/ColorTarget.cs b/src/Graphics/Resources/ColorTarget.cs index 84fd208b..eb66c689 100644 --- a/src/Graphics/Resources/ColorTarget.cs +++ b/src/Graphics/Resources/ColorTarget.cs @@ -5,11 +5,8 @@ namespace MoonWorks.Graphics { public class ColorTarget : GraphicsResource { - public uint Width { get; } - public uint Height { get; } - - public Texture Texture { get; } - public ColorFormat Format => Texture.Format; + public TextureSlice TextureSlice { get; } + public ColorFormat Format => TextureSlice.Texture.Format; protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget; @@ -49,6 +46,7 @@ namespace MoonWorks.Graphics (Refresh.SampleCount) sampleCount, ref refreshTextureSlice ); + TextureSlice = textureSlice; } } }