Refresh 1.2.0

pull/17/head
cosmonaut 2022-03-04 13:21:52 -08:00
parent 40d9cdd33a
commit 527f47436a
6 changed files with 32 additions and 38 deletions

@ -1 +1 @@
Subproject commit 4531e04911e10e2e28f7241b59d05defb8a2a7f3 Subproject commit 5fe9dd8587b05ac2b766a0218a33667aed4c113d

View File

@ -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()
);
}
/// <summary> /// <summary>
/// Binds vertex buffers to be used by subsequent draw calls. /// Binds vertex buffers to be used by subsequent draw calls.
/// </summary> /// </summary>

View File

@ -105,6 +105,19 @@ namespace MoonWorks.Graphics
MinDepth = minDepth; MinDepth = minDepth;
MaxDepth = maxDepth; 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)] [StructLayout(LayoutKind.Sequential)]

View File

@ -27,7 +27,6 @@ namespace MoonWorks.Graphics
RasterizerState rasterizerState = graphicsPipelineCreateInfo.RasterizerState; RasterizerState rasterizerState = graphicsPipelineCreateInfo.RasterizerState;
PrimitiveType primitiveType = graphicsPipelineCreateInfo.PrimitiveType; PrimitiveType primitiveType = graphicsPipelineCreateInfo.PrimitiveType;
VertexInputState vertexInputState = graphicsPipelineCreateInfo.VertexInputState; VertexInputState vertexInputState = graphicsPipelineCreateInfo.VertexInputState;
ViewportState viewportState = graphicsPipelineCreateInfo.ViewportState;
GraphicsPipelineAttachmentInfo attachmentInfo = graphicsPipelineCreateInfo.AttachmentInfo; GraphicsPipelineAttachmentInfo attachmentInfo = graphicsPipelineCreateInfo.AttachmentInfo;
BlendConstants blendConstants = graphicsPipelineCreateInfo.BlendConstants; BlendConstants blendConstants = graphicsPipelineCreateInfo.BlendConstants;
@ -39,14 +38,6 @@ namespace MoonWorks.Graphics
vertexInputState.VertexBindings, vertexInputState.VertexBindings,
GCHandleType.Pinned GCHandleType.Pinned
); );
var viewportHandle = GCHandle.Alloc(
viewportState.Viewports,
GCHandleType.Pinned
);
var scissorHandle = GCHandle.Alloc(
viewportState.Scissors,
GCHandleType.Pinned
);
var colorAttachmentDescriptions = stackalloc Refresh.ColorAttachmentDescription[ var colorAttachmentDescriptions = stackalloc Refresh.ColorAttachmentDescription[
(int) attachmentInfo.ColorAttachmentDescriptions.Length (int) attachmentInfo.ColorAttachmentDescriptions.Length
@ -104,11 +95,6 @@ namespace MoonWorks.Graphics
refreshGraphicsPipelineCreateInfo.vertexInputState.vertexBindings = vertexBindingsHandle.AddrOfPinnedObject(); refreshGraphicsPipelineCreateInfo.vertexInputState.vertexBindings = vertexBindingsHandle.AddrOfPinnedObject();
refreshGraphicsPipelineCreateInfo.vertexInputState.vertexBindingCount = (uint) vertexInputState.VertexBindings.Length; 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.primitiveType = (Refresh.PrimitiveType) primitiveType;
refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentCount = (uint) attachmentInfo.ColorAttachmentDescriptions.Length; refreshGraphicsPipelineCreateInfo.attachmentInfo.colorAttachmentCount = (uint) attachmentInfo.ColorAttachmentDescriptions.Length;
@ -120,8 +106,6 @@ namespace MoonWorks.Graphics
vertexAttributesHandle.Free(); vertexAttributesHandle.Free();
vertexBindingsHandle.Free(); vertexBindingsHandle.Free();
viewportHandle.Free();
scissorHandle.Free();
VertexShaderInfo = vertexShaderInfo; VertexShaderInfo = vertexShaderInfo;
FragmentShaderInfo = fragmentShaderInfo; FragmentShaderInfo = fragmentShaderInfo;

View File

@ -9,7 +9,6 @@
public RasterizerState RasterizerState; public RasterizerState RasterizerState;
public PrimitiveType PrimitiveType; public PrimitiveType PrimitiveType;
public VertexInputState VertexInputState; public VertexInputState VertexInputState;
public ViewportState ViewportState;
public GraphicsPipelineAttachmentInfo AttachmentInfo; public GraphicsPipelineAttachmentInfo AttachmentInfo;
public BlendConstants BlendConstants; public BlendConstants BlendConstants;
} }

View File

@ -1,20 +0,0 @@
namespace MoonWorks.Graphics
{
/// <summary>
/// Describes the dimensions of viewports and scissor areas.
/// </summary>
public struct ViewportState
{
public Viewport[] Viewports;
public Rect[] Scissors;
/// <summary>
/// A default single viewport with no scissor area.
/// </summary>
public ViewportState(int width, int height)
{
Viewports = new Viewport[] { new Viewport(width, height) };
Scissors = new Rect[] { new Rect(width, height) };
}
}
}