diff --git a/lib/MoonWorks b/lib/MoonWorks index 278db7d..7d3a790 160000 --- a/lib/MoonWorks +++ b/lib/MoonWorks @@ -1 +1 @@ -Subproject commit 278db7d55b572cf7fc0090b101f02a49770521ec +Subproject commit 7d3a7901b25d9544e47e2f0ea5baf9089d4ccb08 diff --git a/src/SpriteBatch.cs b/src/SpriteBatch.cs index b23319d..2db9b2c 100644 --- a/src/SpriteBatch.cs +++ b/src/SpriteBatch.cs @@ -44,8 +44,8 @@ namespace MoonWorksComputeSpriteBatch ShaderModule = computeShaderModule, EntryPointName = "main", UniformBufferSize = (uint)Marshal.SizeOf(), - bufferBindingCount = 2, - imageBindingCount = 0 + BufferBindingCount = 2, + ImageBindingCount = 0 }; ComputePipeline = new ComputePipeline(graphicsDevice, computeShaderInfo); diff --git a/src/TestGame.cs b/src/TestGame.cs index 897b9d0..aafa321 100644 --- a/src/TestGame.cs +++ b/src/TestGame.cs @@ -35,103 +35,31 @@ namespace MoonWorksComputeSpriteBatch /* Pipeline */ - DepthStencilState depthStencilState = DepthStencilState.Disable; - - GraphicsShaderInfo vertexShaderInfo = new GraphicsShaderInfo - { - ShaderModule = vertexShaderModule, - EntryPointName = "main", - UniformBufferSize = (uint)Marshal.SizeOf(), - SamplerBindingCount = 0 - }; - - GraphicsShaderInfo fragmentShaderInfo = new GraphicsShaderInfo - { - ShaderModule = fragmentShaderModule, - EntryPointName = "main", - UniformBufferSize = 0, - SamplerBindingCount = 1 - }; - - MultisampleState multisampleState = MultisampleState.None; - - RasterizerState rasterizerState = RasterizerState.CCW_CullNone; - - var vertexBindings = new VertexBinding[1] - { - new VertexBinding + spritePipeline = new GraphicsPipeline( + GraphicsDevice, + new GraphicsPipelineCreateInfo { - Binding = 0, - InputRate = VertexInputRate.Vertex, - Stride = (uint) Marshal.SizeOf() + AttachmentInfo = new GraphicsPipelineAttachmentInfo( + new ColorAttachmentDescription( + GraphicsDevice.GetSwapchainFormat(Window), + ColorAttachmentBlendState.None + ) + ), + DepthStencilState = DepthStencilState.Disable, + VertexShaderInfo = GraphicsShaderInfo.Create(vertexShaderModule, "main", 0), + VertexInputState = new VertexInputState( + VertexBinding.Create(), + VertexAttribute.Create("position", 0), + VertexAttribute.Create("texcoord", 1), + VertexAttribute.Create("color", 2) + ), + PrimitiveType = PrimitiveType.TriangleList, + FragmentShaderInfo = GraphicsShaderInfo.Create(fragmentShaderModule, "main", 1), + RasterizerState = RasterizerState.CW_CullBack, + ViewportState = new ViewportState((int)Window.Width, (int)Window.Height), + MultisampleState = MultisampleState.None } - }; - - var vertexAttributes = new VertexAttribute[3] - { - new VertexAttribute - { - Binding = 0, - Location = 0, - Format = VertexElementFormat.Vector3, - Offset = 0 - }, - new VertexAttribute - { - Binding = 0, - Location = 1, - Format = VertexElementFormat.Vector2, - Offset = (uint) Marshal.OffsetOf("texcoord") - }, - new VertexAttribute - { - Binding = 0, - Location = 2, - Format = VertexElementFormat.Vector4, - Offset = (uint) Marshal.OffsetOf("color") - } - }; - - VertexInputState vertexInputState = new VertexInputState - { - VertexBindings = vertexBindings, - VertexAttributes = vertexAttributes - }; - - ViewportState viewportState = new ViewportState((int)windowWidth, (int)windowHeight); - - var colorAttachmentDescriptions = new ColorAttachmentDescription[1] - { - new ColorAttachmentDescription - { - Format = GraphicsDevice.GetSwapchainFormat(Window), - SampleCount = SampleCount.One, - BlendState = ColorAttachmentBlendState.None - } - }; - - GraphicsPipelineAttachmentInfo graphicsPipelineAttachmentInfo = new GraphicsPipelineAttachmentInfo - { - ColorAttachmentDescriptions = colorAttachmentDescriptions, - HasDepthStencilAttachment = false, - DepthStencilFormat = 0 - }; - - var graphicsPipelineCreateInfo = new GraphicsPipelineCreateInfo - { - DepthStencilState = depthStencilState, - VertexShaderInfo = vertexShaderInfo, - FragmentShaderInfo = fragmentShaderInfo, - MultisampleState = multisampleState, - RasterizerState = rasterizerState, - PrimitiveType = PrimitiveType.TriangleList, - VertexInputState = vertexInputState, - ViewportState = viewportState, - AttachmentInfo = graphicsPipelineAttachmentInfo, - BlendConstants = new BlendConstants() - }; - - spritePipeline = new GraphicsPipeline(GraphicsDevice, graphicsPipelineCreateInfo); + ); spriteBatch = new SpriteBatch(GraphicsDevice);