Update DrawIndirectGame for new IndirectDrawCommand in MoonWorks + fix uniform offset usage in ComputeUniforms

pull/1/head
Caleb Cornett 2023-01-04 15:45:10 -05:00
parent 535830f580
commit c7aefe4b3a
2 changed files with 7 additions and 7 deletions

View File

@ -100,8 +100,8 @@ namespace MoonWorks.Test
cmdbuf.BindComputePipeline(gradientTextureComputePipeline); cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
cmdbuf.BindComputeTextures(texture); cmdbuf.BindComputeTextures(texture);
cmdbuf.PushComputeShaderUniforms(gradientUniforms); uint offset = cmdbuf.PushComputeShaderUniforms(gradientUniforms);
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, 0); cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, offset);
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<DrawIndirectCommand>(GraphicsDevice, BufferUsageFlags.Indirect, 2); drawBuffer = Buffer.Create<IndirectDrawCommand>(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 DrawIndirectCommand[] new IndirectDrawCommand[]
{ {
new DrawIndirectCommand(3, 1, 3, 0), new IndirectDrawCommand(3, 1, 3, 0),
new DrawIndirectCommand(3, 1, 0, 0), new IndirectDrawCommand(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<DrawIndirectCommand>(), 0, 0); cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<IndirectDrawCommand>(), 0, 0);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);