Compare commits

..

No commits in common. "c7aefe4b3ada48b355fe8f5a4de9c14f2487a3bb" and "76dc472072f048e86929eef14d45472f14b45eeb" have entirely different histories.

3 changed files with 15 additions and 43 deletions

View File

@ -100,8 +100,8 @@ namespace MoonWorks.Test
cmdbuf.BindComputePipeline(gradientTextureComputePipeline); cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
cmdbuf.BindComputeTextures(texture); cmdbuf.BindComputeTextures(texture);
uint offset = cmdbuf.PushComputeShaderUniforms(gradientUniforms); cmdbuf.PushComputeShaderUniforms(gradientUniforms);
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, offset); cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, 0);
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait(); GraphicsDevice.Wait();

View File

@ -32,7 +32,7 @@ namespace MoonWorks.Test
// Create and populate the vertex buffer // Create and populate the vertex buffer
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6); vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
drawBuffer = Buffer.Create<IndirectDrawCommand>(GraphicsDevice, BufferUsageFlags.Indirect, 2); drawBuffer = Buffer.Create<DrawIndirectCommand>(GraphicsDevice, BufferUsageFlags.Indirect, 2);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData( cmdbuf.SetBufferData(
@ -50,10 +50,10 @@ namespace MoonWorks.Test
); );
cmdbuf.SetBufferData( cmdbuf.SetBufferData(
drawBuffer, drawBuffer,
new IndirectDrawCommand[] new DrawIndirectCommand[]
{ {
new IndirectDrawCommand(3, 1, 3, 0), new DrawIndirectCommand(3, 1, 3, 0),
new IndirectDrawCommand(3, 1, 0, 0), new DrawIndirectCommand(3, 1, 0, 0),
} }
); );
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);
@ -71,7 +71,7 @@ namespace MoonWorks.Test
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue)); cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
cmdbuf.BindGraphicsPipeline(graphicsPipeline); cmdbuf.BindGraphicsPipeline(graphicsPipeline);
cmdbuf.BindVertexBuffers(new BufferBinding(vertexBuffer, 0)); cmdbuf.BindVertexBuffers(new BufferBinding(vertexBuffer, 0));
cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<IndirectDrawCommand>(), 0, 0); cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<DrawIndirectCommand>(), 0, 0);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);

View File

@ -49,7 +49,6 @@ namespace MoonWorks.Test
vertShaderModule, vertShaderModule,
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
pipelineCreateInfo.VertexInputState = new VertexInputState( pipelineCreateInfo.VertexInputState = new VertexInputState(
VertexBinding.Create<PositionTextureVertex>(), VertexBinding.Create<PositionTextureVertex>(),
VertexAttribute.Create<PositionTextureVertex>("Position", 0), VertexAttribute.Create<PositionTextureVertex>("Position", 0),
@ -69,10 +68,10 @@ namespace MoonWorks.Test
vertexBuffer, vertexBuffer,
new PositionTextureVertex[] new PositionTextureVertex[]
{ {
new PositionTextureVertex(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 1)), new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 1)), new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
} }
); );
cmdbuf.SetBufferData( cmdbuf.SetBufferData(
@ -95,9 +94,8 @@ namespace MoonWorks.Test
protected override void Draw(double alpha) protected override void Draw(double alpha)
{ {
VertexUniforms vertUniforms; VertexUniforms vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t));
FragmentUniforms fragUniforms; FragmentUniforms fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Sin(t) * 0.5f, 1f, 1f));
uint vertParamOffset, fragParamOffset;
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
@ -108,35 +106,9 @@ namespace MoonWorks.Test
cmdbuf.BindVertexBuffers(vertexBuffer); cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen); cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler)); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
uint vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
// Top-left uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(-0.5f, -0.5f, 0)));
fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Sin(t) * 0.5f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset); cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Top-right
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ((2 * System.MathF.PI) - t) * Matrix4x4.CreateTranslation(new Vector3(0.5f, -0.5f, 0)));
fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Cos(t) * 0.5f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Bottom-left
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(-0.5f, 0.5f, 0)));
fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Sin(t) * 0.2f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Bottom-right
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(0.5f, 0.5f, 0)));
fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Cos(t) * 1f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);