From 6ce1ce21b8a9e268e0885ac1f24959dfd4d03c05 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 26 Jan 2021 17:39:20 -0800 Subject: [PATCH] remove more of refresh from the API --- src/Graphics/Resources/GraphicsPipeline.cs | 8 +- src/Graphics/State/ColorBlendState.cs | 2 - src/Graphics/State/ColorTargetBlendState.cs | 86 ++++++++++----------- src/Graphics/State/MultisampleState.cs | 6 +- src/Graphics/State/RasterizerState.cs | 56 +++++++------- src/Graphics/State/VertexInputState.cs | 2 - src/Graphics/State/ViewportState.cs | 2 - 7 files changed, 76 insertions(+), 86 deletions(-) diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index bdc4071e..0f3d34a4 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -64,20 +64,20 @@ namespace MoonWorks.Graphics graphicsPipelineCreateInfo.fragmentShaderState.shaderModule = fragmentShaderState.ShaderModule.Handle; graphicsPipelineCreateInfo.fragmentShaderState.uniformBufferSize = fragmentShaderState.UniformBufferSize; - graphicsPipelineCreateInfo.multisampleState.multisampleCount = multisampleState.MultisampleCount; + graphicsPipelineCreateInfo.multisampleState.multisampleCount = (Refresh.SampleCount)multisampleState.MultisampleCount; graphicsPipelineCreateInfo.multisampleState.sampleMask = multisampleState.SampleMask; graphicsPipelineCreateInfo.pipelineLayoutCreateInfo.vertexSamplerBindingCount = pipelineLayoutCreateInfo.VertexSamplerBindingCount; graphicsPipelineCreateInfo.pipelineLayoutCreateInfo.fragmentSamplerBindingCount = pipelineLayoutCreateInfo.FragmentSamplerBindingCount; - graphicsPipelineCreateInfo.rasterizerState.cullMode = rasterizerState.CullMode; + graphicsPipelineCreateInfo.rasterizerState.cullMode = (Refresh.CullMode)rasterizerState.CullMode; graphicsPipelineCreateInfo.rasterizerState.depthBiasClamp = rasterizerState.DepthBiasClamp; graphicsPipelineCreateInfo.rasterizerState.depthBiasConstantFactor = rasterizerState.DepthBiasConstantFactor; graphicsPipelineCreateInfo.rasterizerState.depthBiasEnable = Conversions.BoolToByte(rasterizerState.DepthBiasEnable); graphicsPipelineCreateInfo.rasterizerState.depthBiasSlopeFactor = rasterizerState.DepthBiasSlopeFactor; graphicsPipelineCreateInfo.rasterizerState.depthClampEnable = Conversions.BoolToByte(rasterizerState.DepthClampEnable); - graphicsPipelineCreateInfo.rasterizerState.fillMode = rasterizerState.FillMode; - graphicsPipelineCreateInfo.rasterizerState.frontFace = rasterizerState.FrontFace; + graphicsPipelineCreateInfo.rasterizerState.fillMode = (Refresh.FillMode)rasterizerState.FillMode; + graphicsPipelineCreateInfo.rasterizerState.frontFace = (Refresh.FrontFace)rasterizerState.FrontFace; graphicsPipelineCreateInfo.rasterizerState.lineWidth = rasterizerState.LineWidth; graphicsPipelineCreateInfo.vertexInputState.vertexAttributes = vertexAttributesHandle.AddrOfPinnedObject(); diff --git a/src/Graphics/State/ColorBlendState.cs b/src/Graphics/State/ColorBlendState.cs index fd785db7..34082f9f 100644 --- a/src/Graphics/State/ColorBlendState.cs +++ b/src/Graphics/State/ColorBlendState.cs @@ -1,5 +1,3 @@ -using RefreshCS; - namespace MoonWorks.Graphics { public unsafe struct ColorBlendState diff --git a/src/Graphics/State/ColorTargetBlendState.cs b/src/Graphics/State/ColorTargetBlendState.cs index 6506c1c5..f5c082ea 100644 --- a/src/Graphics/State/ColorTargetBlendState.cs +++ b/src/Graphics/State/ColorTargetBlendState.cs @@ -5,66 +5,66 @@ namespace MoonWorks.Graphics public struct ColorTargetBlendState { public bool BlendEnable; - public Refresh.BlendOp AlphaBlendOp; - public Refresh.BlendOp ColorBlendOp; - public Refresh.ColorComponentFlags ColorWriteMask; - public Refresh.BlendFactor DestinationAlphaBlendFactor; - public Refresh.BlendFactor DestinationColorBlendFactor; - public Refresh.BlendFactor SourceAlphaBlendFactor; - public Refresh.BlendFactor SourceColorBlendFactor; + public BlendOp AlphaBlendOp; + public BlendOp ColorBlendOp; + public ColorComponentFlags ColorWriteMask; + public BlendFactor DestinationAlphaBlendFactor; + public BlendFactor DestinationColorBlendFactor; + public BlendFactor SourceAlphaBlendFactor; + public BlendFactor SourceColorBlendFactor; public static readonly ColorTargetBlendState Additive = new ColorTargetBlendState { BlendEnable = true, - AlphaBlendOp = Refresh.BlendOp.Add, - ColorBlendOp = Refresh.BlendOp.Add, - ColorWriteMask = Refresh.ColorComponentFlags.RGBA, - SourceColorBlendFactor = Refresh.BlendFactor.SourceAlpha, - SourceAlphaBlendFactor = Refresh.BlendFactor.SourceAlpha, - DestinationColorBlendFactor = Refresh.BlendFactor.One, - DestinationAlphaBlendFactor = Refresh.BlendFactor.One + AlphaBlendOp = BlendOp.Add, + ColorBlendOp = BlendOp.Add, + ColorWriteMask = ColorComponentFlags.RGBA, + SourceColorBlendFactor = BlendFactor.SourceAlpha, + SourceAlphaBlendFactor = BlendFactor.SourceAlpha, + DestinationColorBlendFactor = BlendFactor.One, + DestinationAlphaBlendFactor = BlendFactor.One }; public static readonly ColorTargetBlendState AlphaBlend = new ColorTargetBlendState { BlendEnable = true, - AlphaBlendOp = Refresh.BlendOp.Add, - ColorBlendOp = Refresh.BlendOp.Add, - ColorWriteMask = Refresh.ColorComponentFlags.RGBA, - SourceColorBlendFactor = Refresh.BlendFactor.One, - SourceAlphaBlendFactor = Refresh.BlendFactor.One, - DestinationColorBlendFactor = Refresh.BlendFactor.OneMinusSourceAlpha, - DestinationAlphaBlendFactor = Refresh.BlendFactor.OneMinusSourceAlpha + AlphaBlendOp = BlendOp.Add, + ColorBlendOp = BlendOp.Add, + ColorWriteMask = ColorComponentFlags.RGBA, + SourceColorBlendFactor = BlendFactor.One, + SourceAlphaBlendFactor = BlendFactor.One, + DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha, + DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha }; public static readonly ColorTargetBlendState NonPremultiplied = new ColorTargetBlendState { BlendEnable = true, - AlphaBlendOp = Refresh.BlendOp.Add, - ColorBlendOp = Refresh.BlendOp.Add, - ColorWriteMask = Refresh.ColorComponentFlags.RGBA, - SourceColorBlendFactor = Refresh.BlendFactor.SourceAlpha, - SourceAlphaBlendFactor = Refresh.BlendFactor.SourceAlpha, - DestinationColorBlendFactor = Refresh.BlendFactor.OneMinusSourceAlpha, - DestinationAlphaBlendFactor = Refresh.BlendFactor.OneMinusSourceAlpha + AlphaBlendOp = BlendOp.Add, + ColorBlendOp = BlendOp.Add, + ColorWriteMask = ColorComponentFlags.RGBA, + SourceColorBlendFactor = BlendFactor.SourceAlpha, + SourceAlphaBlendFactor = BlendFactor.SourceAlpha, + DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha, + DestinationAlphaBlendFactor = BlendFactor.OneMinusSourceAlpha }; public static readonly ColorTargetBlendState Opaque = new ColorTargetBlendState { BlendEnable = true, - AlphaBlendOp = Refresh.BlendOp.Add, - ColorBlendOp = Refresh.BlendOp.Add, - ColorWriteMask = Refresh.ColorComponentFlags.RGBA, - SourceColorBlendFactor = Refresh.BlendFactor.One, - SourceAlphaBlendFactor = Refresh.BlendFactor.One, - DestinationColorBlendFactor = Refresh.BlendFactor.Zero, - DestinationAlphaBlendFactor = Refresh.BlendFactor.Zero + AlphaBlendOp = BlendOp.Add, + ColorBlendOp = BlendOp.Add, + ColorWriteMask = ColorComponentFlags.RGBA, + SourceColorBlendFactor = BlendFactor.One, + SourceAlphaBlendFactor = BlendFactor.One, + DestinationColorBlendFactor = BlendFactor.Zero, + DestinationAlphaBlendFactor = BlendFactor.Zero }; public static readonly ColorTargetBlendState None = new ColorTargetBlendState { BlendEnable = false, - ColorWriteMask = Refresh.ColorComponentFlags.RGBA + ColorWriteMask = ColorComponentFlags.RGBA }; public Refresh.ColorTargetBlendState ToRefreshColorTargetBlendState() @@ -72,13 +72,13 @@ namespace MoonWorks.Graphics return new Refresh.ColorTargetBlendState { blendEnable = Conversions.BoolToByte(BlendEnable), - alphaBlendOp = AlphaBlendOp, - colorBlendOp = ColorBlendOp, - colorWriteMask = ColorWriteMask, - destinationAlphaBlendFactor = DestinationAlphaBlendFactor, - destinationColorBlendFactor = DestinationColorBlendFactor, - sourceAlphaBlendFactor = SourceAlphaBlendFactor, - sourceColorBlendFactor = SourceColorBlendFactor + alphaBlendOp = (Refresh.BlendOp)AlphaBlendOp, + colorBlendOp = (Refresh.BlendOp)ColorBlendOp, + colorWriteMask = (Refresh.ColorComponentFlags)ColorWriteMask, + destinationAlphaBlendFactor = (Refresh.BlendFactor)DestinationAlphaBlendFactor, + destinationColorBlendFactor = (Refresh.BlendFactor)DestinationColorBlendFactor, + sourceAlphaBlendFactor = (Refresh.BlendFactor)SourceAlphaBlendFactor, + sourceColorBlendFactor = (Refresh.BlendFactor)SourceColorBlendFactor }; } } diff --git a/src/Graphics/State/MultisampleState.cs b/src/Graphics/State/MultisampleState.cs index 10f29f26..18bd7d5a 100644 --- a/src/Graphics/State/MultisampleState.cs +++ b/src/Graphics/State/MultisampleState.cs @@ -1,15 +1,13 @@ -using RefreshCS; - namespace MoonWorks.Graphics { public struct MultisampleState { - public Refresh.SampleCount MultisampleCount; + public SampleCount MultisampleCount; public uint SampleMask; public static readonly MultisampleState None = new MultisampleState { - MultisampleCount = Refresh.SampleCount.One, + MultisampleCount = SampleCount.One, SampleMask = uint.MaxValue }; } diff --git a/src/Graphics/State/RasterizerState.cs b/src/Graphics/State/RasterizerState.cs index b9216f39..18891430 100644 --- a/src/Graphics/State/RasterizerState.cs +++ b/src/Graphics/State/RasterizerState.cs @@ -1,87 +1,85 @@ -using RefreshCS; - namespace MoonWorks.Graphics { public struct RasterizerState { - public Refresh.CullMode CullMode; + public CullMode CullMode; public float DepthBiasClamp; public float DepthBiasConstantFactor; public bool DepthBiasEnable; public float DepthBiasSlopeFactor; public bool DepthClampEnable; - public Refresh.FillMode FillMode; - public Refresh.FrontFace FrontFace; + public FillMode FillMode; + public FrontFace FrontFace; public float LineWidth; public static readonly RasterizerState CW_CullFront = new RasterizerState { - CullMode = Refresh.CullMode.Front, - FrontFace = Refresh.FrontFace.Clockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.Front, + FrontFace = FrontFace.Clockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CW_CullBack = new RasterizerState { - CullMode = Refresh.CullMode.Back, - FrontFace = Refresh.FrontFace.Clockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.Back, + FrontFace = FrontFace.Clockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CW_CullNone = new RasterizerState { - CullMode = Refresh.CullMode.None, - FrontFace = Refresh.FrontFace.Clockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.None, + FrontFace = FrontFace.Clockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CW_Wireframe = new RasterizerState { - CullMode = Refresh.CullMode.None, - FrontFace = Refresh.FrontFace.Clockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.None, + FrontFace = FrontFace.Clockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CCW_CullFront = new RasterizerState { - CullMode = Refresh.CullMode.Front, - FrontFace = Refresh.FrontFace.CounterClockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.Front, + FrontFace = FrontFace.CounterClockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CCW_CullBack = new RasterizerState { - CullMode = Refresh.CullMode.Back, - FrontFace = Refresh.FrontFace.CounterClockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.Back, + FrontFace = FrontFace.CounterClockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CCW_CullNone = new RasterizerState { - CullMode = Refresh.CullMode.None, - FrontFace = Refresh.FrontFace.CounterClockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.None, + FrontFace = FrontFace.CounterClockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; public static readonly RasterizerState CCW_Wireframe = new RasterizerState { - CullMode = Refresh.CullMode.None, - FrontFace = Refresh.FrontFace.CounterClockwise, - FillMode = Refresh.FillMode.Fill, + CullMode = CullMode.None, + FrontFace = FrontFace.CounterClockwise, + FillMode = FillMode.Fill, DepthBiasEnable = false, LineWidth = 1f }; diff --git a/src/Graphics/State/VertexInputState.cs b/src/Graphics/State/VertexInputState.cs index f106c1d3..216404d6 100644 --- a/src/Graphics/State/VertexInputState.cs +++ b/src/Graphics/State/VertexInputState.cs @@ -1,5 +1,3 @@ -using RefreshCS; - namespace MoonWorks.Graphics { public struct VertexInputState diff --git a/src/Graphics/State/ViewportState.cs b/src/Graphics/State/ViewportState.cs index bc84a595..02bb35b6 100644 --- a/src/Graphics/State/ViewportState.cs +++ b/src/Graphics/State/ViewportState.cs @@ -1,5 +1,3 @@ -using RefreshCS; - namespace MoonWorks.Graphics { public struct ViewportState