update MSAA

refresh2
cosmonaut 2024-02-23 13:09:23 -08:00
parent 683fffad16
commit c2a029ce85
1 changed files with 19 additions and 20 deletions

View File

@ -11,8 +11,8 @@ namespace MoonWorks.Test
private Texture[] renderTargets = new Texture[4]; private Texture[] renderTargets = new Texture[4];
private Sampler rtSampler; private Sampler rtSampler;
private Buffer quadVertexBuffer; private GpuBuffer quadVertexBuffer;
private Buffer quadIndexBuffer; private GpuBuffer quadIndexBuffer;
private SampleCount currentSampleCount = SampleCount.Four; private SampleCount currentSampleCount = SampleCount.Four;
@ -67,29 +67,28 @@ namespace MoonWorks.Test
rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the vertex and index buffers // Create and populate the vertex and index buffers
quadVertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4); var resourceInitializer = new ResourceInitializer(GraphicsDevice);
quadIndexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); quadVertexBuffer = resourceInitializer.CreateBuffer(
cmdbuf.SetBufferData( [
quadVertexBuffer,
new PositionTextureVertex[]
{
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)), new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1))
} ],
BufferUsageFlags.Vertex
); );
cmdbuf.SetBufferData(
quadIndexBuffer, quadIndexBuffer = resourceInitializer.CreateBuffer<ushort>(
new ushort[] [
{
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3
} ],
BufferUsageFlags.Index
); );
GraphicsDevice.Submit(cmdbuf);
resourceInitializer.Upload();
resourceInitializer.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)
@ -129,7 +128,7 @@ namespace MoonWorks.Test
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(rt, Color.Black)); cmdbuf.BeginRenderPass(new ColorAttachmentInfo(rt, Color.Black));
cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]); cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]);
cmdbuf.DrawPrimitives(0, 1, 0, 0); cmdbuf.DrawPrimitives(0, 1);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, LoadOp.DontCare)); cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, LoadOp.DontCare));
@ -137,7 +136,7 @@ namespace MoonWorks.Test
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, rtSampler)); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, rtSampler));
cmdbuf.BindVertexBuffers(quadVertexBuffer); cmdbuf.BindVertexBuffers(quadVertexBuffer);
cmdbuf.BindIndexBuffer(quadIndexBuffer, IndexElementSize.Sixteen); cmdbuf.BindIndexBuffer(quadIndexBuffer, IndexElementSize.Sixteen);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0); cmdbuf.DrawIndexedPrimitives(0, 0, 2);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);