diff --git a/lib/RefreshCS b/lib/RefreshCS index d844fe56..642313f7 160000 --- a/lib/RefreshCS +++ b/lib/RefreshCS @@ -1 +1 @@ -Subproject commit d844fe56ee16e7e0e0ae4f4ff1814292e499dff7 +Subproject commit 642313f78041aac9f50a6eb3c73869137c53f113 diff --git a/src/Graphics/RefreshEnums.cs b/src/Graphics/RefreshEnums.cs index f854e3e8..138b1101 100644 --- a/src/Graphics/RefreshEnums.cs +++ b/src/Graphics/RefreshEnums.cs @@ -147,16 +147,14 @@ namespace MoonWorks.Graphics public enum FillMode { Fill, - Line, - Point + Line } public enum CullMode { None, Front, - Back, - FrontAndBack + Back } public enum FrontFace @@ -198,26 +196,6 @@ namespace MoonWorks.Graphics Max } - public enum LogicOp - { - Clear, - And, - AndReverse, - Copy, - AndInverted, - NoOp, - Xor, - Or, - Nor, - Equivalent, - Invert, - OrReverse, - CopyInverted, - OrInverted, - Nand, - Set - } - public enum BlendFactor { Zero, @@ -232,8 +210,6 @@ namespace MoonWorks.Graphics OneMinusDestinationAlpha, ConstantColor, OneMinusConstantColor, - ConstantAlpha, - OneMinusConstantAlpha, SourceAlphaSaturate, SourceOneColor, OneMinusSourceOneColor, @@ -264,17 +240,10 @@ namespace MoonWorks.Graphics None = 0 } - public enum ShaderStageType - { - Vertex, - Fragment - } - public enum Filter { Nearest, - Linear, - Cubic + Linear } public enum SamplerMipmapMode diff --git a/src/Graphics/Resources/ComputePipeline.cs b/src/Graphics/Resources/ComputePipeline.cs index ed57dcbd..ad7133e3 100644 --- a/src/Graphics/Resources/ComputePipeline.cs +++ b/src/Graphics/Resources/ComputePipeline.cs @@ -8,38 +8,28 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyComputePipeline; - public ShaderStageState ComputeShaderState { get; } + public ComputeShaderInfo ComputeShaderState { get; } public unsafe ComputePipeline( GraphicsDevice device, - ShaderStageState computeShaderState, - uint bufferBindingCount, - uint imageBindingCount + ComputeShaderInfo computeShaderInfo ) : base(device) { - var computePipelineLayoutCreateInfo = new Refresh.ComputePipelineLayoutCreateInfo + var refreshComputeShaderInfo = new Refresh.ComputeShaderInfo { - bufferBindingCount = bufferBindingCount, - imageBindingCount = imageBindingCount - }; - - var computePipelineCreateInfo = new Refresh.ComputePipelineCreateInfo - { - pipelineLayoutCreateInfo = computePipelineLayoutCreateInfo, - computeShaderState = new Refresh.ShaderStageState - { - entryPointName = computeShaderState.EntryPointName, - shaderModule = computeShaderState.ShaderModule.Handle, - uniformBufferSize = computeShaderState.UniformBufferSize - } + entryPointName = computeShaderInfo.EntryPointName, + shaderModule = computeShaderInfo.ShaderModule.Handle, + uniformBufferSize = computeShaderInfo.UniformBufferSize, + bufferBindingCount = computeShaderInfo.bufferBindingCount, + imageBindingCount = computeShaderInfo.imageBindingCount }; Handle = Refresh.Refresh_CreateComputePipeline( device.Handle, - computePipelineCreateInfo + refreshComputeShaderInfo ); - ComputeShaderState = computeShaderState; + ComputeShaderState = computeShaderInfo; } } } diff --git a/src/Graphics/Resources/GraphicsPipeline.cs b/src/Graphics/Resources/GraphicsPipeline.cs index 1226fbbb..19d8730e 100644 --- a/src/Graphics/Resources/GraphicsPipeline.cs +++ b/src/Graphics/Resources/GraphicsPipeline.cs @@ -12,25 +12,24 @@ namespace MoonWorks.Graphics { protected override Action QueueDestroyFunction => Refresh.Refresh_QueueDestroyGraphicsPipeline; - public ShaderStageState VertexShaderState { get; } - public ShaderStageState FragmentShaderState { get; } + public GraphicsShaderInfo VertexShaderState { get; } + public GraphicsShaderInfo FragmentShaderState { get; } public unsafe GraphicsPipeline( GraphicsDevice device, in GraphicsPipelineCreateInfo graphicsPipelineCreateInfo ) : base(device) { - ColorBlendState colorBlendState = graphicsPipelineCreateInfo.ColorBlendState; DepthStencilState depthStencilState = graphicsPipelineCreateInfo.DepthStencilState; - ShaderStageState vertexShaderState = graphicsPipelineCreateInfo.VertexShaderState; - ShaderStageState fragmentShaderState = graphicsPipelineCreateInfo.FragmentShaderState; + GraphicsShaderInfo vertexShaderInfo = graphicsPipelineCreateInfo.VertexShaderState; + GraphicsShaderInfo fragmentShaderInfo = graphicsPipelineCreateInfo.FragmentShaderState; MultisampleState multisampleState = graphicsPipelineCreateInfo.MultisampleState; - GraphicsPipelineLayoutInfo pipelineLayoutInfo = graphicsPipelineCreateInfo.PipelineLayoutInfo; RasterizerState rasterizerState = graphicsPipelineCreateInfo.RasterizerState; PrimitiveType primitiveType = graphicsPipelineCreateInfo.PrimitiveType; VertexInputState vertexInputState = graphicsPipelineCreateInfo.VertexInputState; ViewportState viewportState = graphicsPipelineCreateInfo.ViewportState; GraphicsPipelineAttachmentInfo attachmentInfo = graphicsPipelineCreateInfo.AttachmentInfo; + BlendConstants blendConstants = graphicsPipelineCreateInfo.BlendConstants; var vertexAttributesHandle = GCHandle.Alloc( vertexInputState.VertexAttributes, @@ -62,12 +61,10 @@ namespace MoonWorks.Graphics Refresh.GraphicsPipelineCreateInfo refreshGraphicsPipelineCreateInfo; - refreshGraphicsPipelineCreateInfo.colorBlendState.logicOpEnable = Conversions.BoolToByte(colorBlendState.LogicOpEnable); - refreshGraphicsPipelineCreateInfo.colorBlendState.logicOp = (Refresh.LogicOp) colorBlendState.LogicOp; - refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[0] = colorBlendState.BlendConstants.R; - refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[1] = colorBlendState.BlendConstants.G; - refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[2] = colorBlendState.BlendConstants.B; - refreshGraphicsPipelineCreateInfo.colorBlendState.blendConstants[3] = colorBlendState.BlendConstants.A; + refreshGraphicsPipelineCreateInfo.blendConstants[0] = blendConstants.R; + refreshGraphicsPipelineCreateInfo.blendConstants[1] = blendConstants.G; + refreshGraphicsPipelineCreateInfo.blendConstants[2] = blendConstants.B; + refreshGraphicsPipelineCreateInfo.blendConstants[3] = blendConstants.A; refreshGraphicsPipelineCreateInfo.depthStencilState.backStencilState = depthStencilState.BackStencilState.ToRefresh(); refreshGraphicsPipelineCreateInfo.depthStencilState.compareOp = (Refresh.CompareOp) depthStencilState.CompareOp; @@ -79,20 +76,19 @@ namespace MoonWorks.Graphics refreshGraphicsPipelineCreateInfo.depthStencilState.minDepthBounds = depthStencilState.MinDepthBounds; refreshGraphicsPipelineCreateInfo.depthStencilState.stencilTestEnable = Conversions.BoolToByte(depthStencilState.StencilTestEnable); - refreshGraphicsPipelineCreateInfo.vertexShaderState.entryPointName = vertexShaderState.EntryPointName; - refreshGraphicsPipelineCreateInfo.vertexShaderState.shaderModule = vertexShaderState.ShaderModule.Handle; - refreshGraphicsPipelineCreateInfo.vertexShaderState.uniformBufferSize = vertexShaderState.UniformBufferSize; + refreshGraphicsPipelineCreateInfo.vertexShaderInfo.entryPointName = vertexShaderInfo.EntryPointName; + refreshGraphicsPipelineCreateInfo.vertexShaderInfo.shaderModule = vertexShaderInfo.ShaderModule.Handle; + refreshGraphicsPipelineCreateInfo.vertexShaderInfo.uniformBufferSize = vertexShaderInfo.UniformBufferSize; + refreshGraphicsPipelineCreateInfo.vertexShaderInfo.samplerBindingCount = vertexShaderInfo.SamplerBindingCount; - refreshGraphicsPipelineCreateInfo.fragmentShaderState.entryPointName = fragmentShaderState.EntryPointName; - refreshGraphicsPipelineCreateInfo.fragmentShaderState.shaderModule = fragmentShaderState.ShaderModule.Handle; - refreshGraphicsPipelineCreateInfo.fragmentShaderState.uniformBufferSize = fragmentShaderState.UniformBufferSize; + refreshGraphicsPipelineCreateInfo.fragmentShaderInfo.entryPointName = fragmentShaderInfo.EntryPointName; + refreshGraphicsPipelineCreateInfo.fragmentShaderInfo.shaderModule = fragmentShaderInfo.ShaderModule.Handle; + refreshGraphicsPipelineCreateInfo.fragmentShaderInfo.uniformBufferSize = fragmentShaderInfo.UniformBufferSize; + refreshGraphicsPipelineCreateInfo.fragmentShaderInfo.samplerBindingCount = fragmentShaderInfo.SamplerBindingCount; refreshGraphicsPipelineCreateInfo.multisampleState.multisampleCount = (Refresh.SampleCount) multisampleState.MultisampleCount; refreshGraphicsPipelineCreateInfo.multisampleState.sampleMask = multisampleState.SampleMask; - refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.vertexSamplerBindingCount = pipelineLayoutInfo.VertexSamplerBindingCount; - refreshGraphicsPipelineCreateInfo.pipelineLayoutCreateInfo.fragmentSamplerBindingCount = pipelineLayoutInfo.FragmentSamplerBindingCount; - refreshGraphicsPipelineCreateInfo.rasterizerState.cullMode = (Refresh.CullMode) rasterizerState.CullMode; refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasClamp = rasterizerState.DepthBiasClamp; refreshGraphicsPipelineCreateInfo.rasterizerState.depthBiasConstantFactor = rasterizerState.DepthBiasConstantFactor; @@ -127,8 +123,8 @@ namespace MoonWorks.Graphics viewportHandle.Free(); scissorHandle.Free(); - VertexShaderState = vertexShaderState; - FragmentShaderState = fragmentShaderState; + VertexShaderState = vertexShaderInfo; + FragmentShaderState = fragmentShaderInfo; } } } diff --git a/src/Graphics/State/ColorBlendState.cs b/src/Graphics/State/ColorBlendState.cs deleted file mode 100644 index 4e34546f..00000000 --- a/src/Graphics/State/ColorBlendState.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MoonWorks.Graphics -{ - /// - /// Describes how the graphics pipeline will blend colors. - /// - public unsafe struct ColorBlendState - { - public bool LogicOpEnable; - public LogicOp LogicOp; - public BlendConstants BlendConstants; - } -} diff --git a/src/Graphics/State/ComputeShaderInfo.cs b/src/Graphics/State/ComputeShaderInfo.cs new file mode 100644 index 00000000..50b8163b --- /dev/null +++ b/src/Graphics/State/ComputeShaderInfo.cs @@ -0,0 +1,14 @@ +namespace MoonWorks.Graphics +{ + /// + /// Information that the pipeline needs about a shader. + /// + public struct ComputeShaderInfo + { + public ShaderModule ShaderModule; + public string EntryPointName; + public uint UniformBufferSize; + public uint bufferBindingCount; + public uint imageBindingCount; + } +} diff --git a/src/Graphics/State/GraphicsPipelineCreateInfo.cs b/src/Graphics/State/GraphicsPipelineCreateInfo.cs index f5b64367..0dfe6246 100644 --- a/src/Graphics/State/GraphicsPipelineCreateInfo.cs +++ b/src/Graphics/State/GraphicsPipelineCreateInfo.cs @@ -2,16 +2,15 @@ { public struct GraphicsPipelineCreateInfo { - public ColorBlendState ColorBlendState; public DepthStencilState DepthStencilState; - public ShaderStageState VertexShaderState; - public ShaderStageState FragmentShaderState; + public GraphicsShaderInfo VertexShaderState; + public GraphicsShaderInfo FragmentShaderState; public MultisampleState MultisampleState; - public GraphicsPipelineLayoutInfo PipelineLayoutInfo; public RasterizerState RasterizerState; public PrimitiveType PrimitiveType; public VertexInputState VertexInputState; public ViewportState ViewportState; public GraphicsPipelineAttachmentInfo AttachmentInfo; + public BlendConstants BlendConstants; } } diff --git a/src/Graphics/State/GraphicsPipelineLayoutInfo.cs b/src/Graphics/State/GraphicsPipelineLayoutInfo.cs deleted file mode 100644 index 4d8913d4..00000000 --- a/src/Graphics/State/GraphicsPipelineLayoutInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MoonWorks.Graphics -{ - /// - /// Describes how many samplers will be used in each shader stage. - /// - public struct GraphicsPipelineLayoutInfo - { - public uint VertexSamplerBindingCount; - public uint FragmentSamplerBindingCount; - - public GraphicsPipelineLayoutInfo( - uint vertexSamplerBindingCount, - uint fragmentSamplerBindingCount - ) - { - VertexSamplerBindingCount = vertexSamplerBindingCount; - FragmentSamplerBindingCount = fragmentSamplerBindingCount; - } - } -} diff --git a/src/Graphics/State/ShaderStageState.cs b/src/Graphics/State/GraphicsShaderInfo.cs similarity index 58% rename from src/Graphics/State/ShaderStageState.cs rename to src/Graphics/State/GraphicsShaderInfo.cs index e691b41b..d772cad9 100644 --- a/src/Graphics/State/ShaderStageState.cs +++ b/src/Graphics/State/GraphicsShaderInfo.cs @@ -1,12 +1,13 @@ namespace MoonWorks.Graphics { /// - /// Specifies how the graphics pipeline will make use of a shader. + /// Information that the pipeline needs about a shader. /// - public struct ShaderStageState + public struct GraphicsShaderInfo { public ShaderModule ShaderModule; public string EntryPointName; public uint UniformBufferSize; + public uint SamplerBindingCount; } }