From 527f47436aed10a4a92adb311a48ed6d3501f1f2 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 4 Mar 2022 13:21:52 -0800 Subject: [PATCH] Refresh 1.2.0 --- lib/RefreshCS | 2 +- src/Graphics/CommandBuffer.cs | 18 +++++++++++++++++ src/Graphics/RefreshStructs.cs | 13 ++++++++++++ src/Graphics/Resources/GraphicsPipeline.cs | 16 --------------- .../State/GraphicsPipelineCreateInfo.cs | 1 - src/Graphics/State/ViewportState.cs | 20 ------------------- 6 files changed, 32 insertions(+), 38 deletions(-) delete mode 100644 src/Graphics/State/ViewportState.cs diff --git a/lib/RefreshCS b/lib/RefreshCS index 4531e04..5fe9dd8 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit 4531e04911e10e2e28f7241b59d05defb8a2a7f3 +Subproject commit 5fe9dd8587b05ac2b766a0218a33667aed4c113d diff --git a/src/Graphics/CommandBuffer.cs b/src/Graphics/CommandBuffer.cs index c93ca99..2f1a752 100644 --- a/src/Graphics/CommandBuffer.cs +++ b/src/Graphics/CommandBuffer.cs @@ -311,6 +311,24 @@ namespace MoonWorks.Graphics ); } + public void SetViewport(Viewport viewport) + { + Refresh.Refresh_SetViewport( + Device.Handle, + Handle, + viewport.ToRefresh() + ); + } + + public void SetScissor(Rect scissor) + { + Refresh.Refresh_SetScissor( + Device.Handle, + Handle, + scissor.ToRefresh() + ); + } + /// /// Binds vertex buffers to be used by subsequent draw calls. /// diff --git a/src/Graphics/RefreshStructs.cs b/src/Graphics/RefreshStructs.cs index 49c58a8..d0cfc5e 100644 --- a/src/Graphics/RefreshStructs.cs +++ b/src/Graphics/RefreshStructs.cs @@ -105,6 +105,19 @@ namespace MoonWorks.Graphics MinDepth = minDepth; MaxDepth = maxDepth; } + + public Refresh.Viewport ToRefresh() + { + return new Refresh.Viewport + { + x = X, + y = Y, + w = W, + h = H, + minDepth = MinDepth, + maxDepth = MaxDepth + }; + } } [StructLayout(LayoutKind.Sequential)] diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index 101ec3b..7c68c10 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -27,7 +27,6 @@ namespace MoonWorks.Graphics RasterizerState rasterizerState = graphicsPipelineCreateInfo.RasterizerState; PrimitiveType primitiveType = graphicsPipelineCreateInfo.PrimitiveType; VertexInputState vertexInputState = graphicsPipelineCreateInfo.VertexInputState; - ViewportState viewportState = graphicsPipelineCreateInfo.ViewportState; GraphicsPipelineAttachmentInfo attachmentInfo = graphicsPipelineCreateInfo.AttachmentInfo; BlendConstants blendConstants = graphicsPipelineCreateInfo.BlendConstants; @@ -39,14 +38,6 @@ namespace MoonWorks.Graphics vertexInputState.VertexBindings, GCHandleType.Pinned ); - var viewportHandle = GCHandle.Alloc( - viewportState.Viewports, - GCHandleType.Pinned - ); - var scissorHandle = GCHandle.Alloc( - viewportState.Scissors, - GCHandleType.Pinned - ); var colorAttachmentDescriptions = stackalloc Refresh.ColorAttachmentDescription[ (int) attachmentInfo.ColorAttachmentDescriptions.Length @@ -104,11 +95,6 @@ namespace MoonWorks.Graphics refreshGraphicsPipelineCreateInfo.vertexInputState.vertexBindings = vertexBindingsHandle.AddrOfPinnedObject(); refreshGraphicsPipelineCreateInfo.vertexInputState.vertexBindingCount = (uint) vertexInputState.VertexBindings.Length; - refreshGraphicsPipelineCreateInfo.viewportState.viewports = viewportHandle.AddrOfPinnedObject(); - refreshGraphicsPipelineCreateInfo.viewportState.viewportCount = (uint) viewportState.Viewports.Length; - refreshGraphicsPipelineCreateInfo.viewportState.scissors = scissorHandle.AddrOfPinnedObject(); - refreshGraphicsPipelineCreateInfo.viewportState.scissorCount = (uint) viewportState.Scissors.Length; - refreshGraphicsPipelineCreateInfo.primitiveType = (Refresh.PrimitiveType) primitiveType; refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentCount = (uint) attachmentInfo.ColorAttachmentDescriptions.Length; @@ -120,8 +106,6 @@ namespace MoonWorks.Graphics vertexAttributesHandle.Free(); vertexBindingsHandle.Free(); - viewportHandle.Free(); - scissorHandle.Free(); VertexShaderInfo = vertexShaderInfo; FragmentShaderInfo = fragmentShaderInfo; diff --git a/src/Graphics/State/GraphicsPipelineCreateInfo.cs b/src/Graphics/State/GraphicsPipelineCreateInfo.cs index 78aca68..ca8fda9 100644 --- a/src/Graphics/State/GraphicsPipelineCreateInfo.cs +++ b/src/Graphics/State/GraphicsPipelineCreateInfo.cs @@ -9,7 +9,6 @@ public RasterizerState RasterizerState; public PrimitiveType PrimitiveType; public VertexInputState VertexInputState; - public ViewportState ViewportState; public GraphicsPipelineAttachmentInfo AttachmentInfo; public BlendConstants BlendConstants; } diff --git a/src/Graphics/State/ViewportState.cs b/src/Graphics/State/ViewportState.cs deleted file mode 100644 index 5f789ad..0000000 --- a/src/Graphics/State/ViewportState.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MoonWorks.Graphics -{ - /// - /// Describes the dimensions of viewports and scissor areas. - /// - public struct ViewportState - { - public Viewport[] Viewports; - public Rect[] Scissors; - - /// - /// A default single viewport with no scissor area. - /// - public ViewportState(int width, int height) - { - Viewports = new Viewport[] { new Viewport(width, height) }; - Scissors = new Rect[] { new Rect(width, height) }; - } - } -}