Add DepthMSAA test + update other tests for new ABI + misc cleanup

pull/2/head
Caleb Cornett 2023-01-30 22:39:13 -05:00
parent d0dd3028e1
commit a356eb29c8
13 changed files with 383 additions and 98 deletions

View File

@ -80,9 +80,9 @@ namespace MoonWorks.Test
var byteCount = (uint)(width * height * channels); var byteCount = (uint)(width * height * channels);
TextureCreateInfo textureCreateInfo; TextureCreateInfo textureCreateInfo = new TextureCreateInfo();
textureCreateInfo.Width = (uint)width; textureCreateInfo.Width = (uint) width;
textureCreateInfo.Height = (uint)height; textureCreateInfo.Height = (uint) height;
textureCreateInfo.Depth = 1; textureCreateInfo.Depth = 1;
textureCreateInfo.Format = TextureFormat.R8G8B8A8; textureCreateInfo.Format = TextureFormat.R8G8B8A8;
textureCreateInfo.IsCube = false; textureCreateInfo.IsCube = false;

View File

@ -33,16 +33,6 @@ namespace MoonWorks.Test
private bool depthOnlyEnabled = false; private bool depthOnlyEnabled = false;
private Vector3 camPos = new Vector3(0, 1.5f, 4f); private Vector3 camPos = new Vector3(0, 1.5f, 4f);
struct ViewProjectionUniforms
{
public Matrix4x4 ViewProjection;
public ViewProjectionUniforms(Matrix4x4 viewProjection)
{
ViewProjection = viewProjection;
}
}
struct DepthUniforms struct DepthUniforms
{ {
public float ZNear; public float ZNear;
@ -165,7 +155,7 @@ namespace MoonWorks.Test
) )
), ),
DepthStencilState = DepthStencilState.DepthReadWrite, DepthStencilState = DepthStencilState.DepthReadWrite,
VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(cubeVertShaderModule, "main", 0), VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(cubeVertShaderModule, "main", 0),
VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(), VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(),
PrimitiveType = PrimitiveType.TriangleList, PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0), FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0),
@ -189,7 +179,7 @@ namespace MoonWorks.Test
) )
), ),
DepthStencilState = DepthStencilState.DepthReadWrite, DepthStencilState = DepthStencilState.DepthReadWrite,
VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionUniforms>(skyboxVertShaderModule, "main", 0), VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(skyboxVertShaderModule, "main", 0),
VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(), VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(),
PrimitiveType = PrimitiveType.TriangleList, PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1), FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1),
@ -376,7 +366,7 @@ namespace MoonWorks.Test
Vector3.Zero, Vector3.Zero,
Vector3.Up Vector3.Up
); );
ViewProjectionUniforms skyboxUniforms = new ViewProjectionUniforms(view * proj); TransformVertexUniform skyboxUniforms = new TransformVertexUniform(view * proj);
Matrix4x4 model = Matrix4x4.CreateFromQuaternion( Matrix4x4 model = Matrix4x4.CreateFromQuaternion(
Quaternion.Slerp( Quaternion.Slerp(
@ -385,7 +375,7 @@ namespace MoonWorks.Test
(float) alpha (float) alpha
) )
); );
ViewProjectionUniforms cubeUniforms = new ViewProjectionUniforms(model * view * proj); TransformVertexUniform cubeUniforms = new TransformVertexUniform(model * view * proj);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow);

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\MoonWorks\MoonWorks.csproj" />
<ProjectReference Include="..\MoonWorks.Test.Common\MoonWorks.Test.Common.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
</PropertyGroup>
<Import Project="$(SolutionDir)NativeAOT_Console.targets" Condition="Exists('$(SolutionDir)NativeAOT_Console.targets')" />
</Project>

296
DepthMSAA/DepthMSAAGame.cs Normal file
View File

@ -0,0 +1,296 @@
using MoonWorks;
using MoonWorks.Math.Float;
using MoonWorks.Math;
using MoonWorks.Graphics;
namespace MoonWorks.Test
{
class DepthMSAAGame : Game
{
private GraphicsPipeline[] cubePipelines = new GraphicsPipeline[4];
private GraphicsPipeline blitPipeline;
private Texture[] renderTargets = new Texture[4];
private Texture[] depthRTs = new Texture[4];
private Sampler rtSampler;
private Buffer cubeVertexBuffer1;
private Buffer cubeVertexBuffer2;
private Buffer cubeIndexBuffer;
private Buffer quadVertexBuffer;
private Buffer quadIndexBuffer;
private float cubeTimer = 0f;
private Quaternion cubeRotation = Quaternion.Identity;
private Quaternion previousCubeRotation = Quaternion.Identity;
private Vector3 camPos = new Vector3(0, 1.5f, 4f);
private SampleCount currentSampleCount = SampleCount.Four;
public DepthMSAAGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{
Logger.LogInfo("Press Left and Right to cycle between sample counts");
Logger.LogInfo("Setting sample count to: " + currentSampleCount);
// Create the cube pipelines
ShaderModule cubeVertShaderModule = new ShaderModule(
GraphicsDevice,
TestUtils.GetShaderPath("PositionColorVertWithMatrix")
);
ShaderModule cubeFragShaderModule = new ShaderModule(
GraphicsDevice,
TestUtils.GetShaderPath("SolidColor")
);
GraphicsPipelineCreateInfo pipelineCreateInfo = new GraphicsPipelineCreateInfo
{
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
TextureFormat.D32,
new ColorAttachmentDescription(
MainWindow.SwapchainFormat,
ColorAttachmentBlendState.Opaque
)
),
DepthStencilState = DepthStencilState.DepthReadWrite,
VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(cubeVertShaderModule, "main", 0),
VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(),
PrimitiveType = PrimitiveType.TriangleList,
FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0),
RasterizerState = RasterizerState.CW_CullBack,
MultisampleState = MultisampleState.None
};
for (int i = 0; i < cubePipelines.Length; i += 1)
{
pipelineCreateInfo.MultisampleState.MultisampleCount = (SampleCount) i;
cubePipelines[i] = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
}
// Create the blit pipeline
ShaderModule blitVertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadVert"));
ShaderModule blitFragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadFrag"));
pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
MainWindow.SwapchainFormat,
blitVertShaderModule,
blitFragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create the MSAA render textures and depth textures
for (int i = 0; i < renderTargets.Length; i += 1)
{
renderTargets[i] = Texture.CreateTexture2D(
GraphicsDevice,
MainWindow.Width,
MainWindow.Height,
TextureFormat.R8G8B8A8,
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
1,
(SampleCount) i
);
depthRTs[i] = Texture.CreateTexture2D(
GraphicsDevice,
MainWindow.Width,
MainWindow.Height,
TextureFormat.D32,
TextureUsageFlags.DepthStencilTarget,
1,
(SampleCount) i
);
}
// Create the sampler
rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create the buffers
quadVertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
quadIndexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
cubeVertexBuffer1 = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24);
cubeVertexBuffer2 = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24);
cubeIndexBuffer = Buffer.Create<uint>(GraphicsDevice, BufferUsageFlags.Index, 36);
// Populate the GPU resources
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
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(1, 0)),
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
}
);
cmdbuf.SetBufferData(
quadIndexBuffer,
new ushort[]
{
0, 1, 2,
0, 2, 3,
}
);
PositionColorVertex[] vertices = new PositionColorVertex[]
{
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0f)),
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0f)),
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0f, 0f)),
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(1f, 0f, 0f)),
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 1f, 0f)),
new PositionColorVertex(new Vector3(1, -1, 1), new Color(0f, 1f, 0f)),
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 1f, 0f)),
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 1f, 0f)),
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(0f, 0f, 1f)),
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0f, 1f)),
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0f, 1f)),
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 0f, 1f)),
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(1, 1, 1), new Color(1f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0.5f)),
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(1f, 0f, 0.5f)),
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0f, 0.5f)),
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0.5f)),
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 0.5f, 0f)),
new PositionColorVertex(new Vector3(1, 1, -1), new Color(0f, 0.5f, 0f))
};
cmdbuf.SetBufferData(
cubeVertexBuffer1,
vertices
);
// Scoot all the verts slightly for the second cube...
for (int i = 0; i < vertices.Length; i += 1)
{
vertices[i].Position.Z += 3;
}
cmdbuf.SetBufferData(
cubeVertexBuffer2,
vertices
);
cmdbuf.SetBufferData(
cubeIndexBuffer,
new uint[]
{
0, 1, 2, 0, 2, 3,
6, 5, 4, 7, 6, 4,
8, 9, 10, 8, 10, 11,
14, 13, 12, 15, 14, 12,
16, 17, 18, 16, 18, 19,
22, 21, 20, 23, 22, 20
}
);
GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait();
}
protected override void Update(System.TimeSpan delta)
{
SampleCount prevSampleCount = currentSampleCount;
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
{
currentSampleCount -= 1;
if (currentSampleCount < 0)
{
currentSampleCount = SampleCount.Eight;
}
}
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
{
currentSampleCount += 1;
if (currentSampleCount > SampleCount.Eight)
{
currentSampleCount = SampleCount.One;
}
}
if (prevSampleCount != currentSampleCount)
{
Logger.LogInfo("Setting sample count to: " + currentSampleCount);
}
// Rotate the cube
cubeTimer += (float) delta.TotalSeconds;
previousCubeRotation = cubeRotation;
cubeRotation = Quaternion.CreateFromYawPitchRoll(cubeTimer * 2f, 0, cubeTimer * 2f);
}
protected override void Draw(double alpha)
{
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (backbuffer != null)
{
// Set up cube model-view-projection matrix
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(75f),
(float) MainWindow.Width / MainWindow.Height,
0.01f,
100f
);
Matrix4x4 view = Matrix4x4.CreateLookAt(camPos, Vector3.Zero, Vector3.Up);
Matrix4x4 model = Matrix4x4.CreateFromQuaternion(
Quaternion.Slerp(
previousCubeRotation,
cubeRotation,
(float) alpha
)
);
TransformVertexUniform cubeUniforms = new TransformVertexUniform(model * view * proj);
// Begin the MSAA RT pass
int index = (int) currentSampleCount;
cmdbuf.BeginRenderPass(
new DepthStencilAttachmentInfo(depthRTs[index], new DepthStencilValue(1, 0)),
new ColorAttachmentInfo(renderTargets[index], Color.Black)
);
cmdbuf.BindGraphicsPipeline(cubePipelines[index]);
// Draw the first cube
cmdbuf.BindVertexBuffers(cubeVertexBuffer1);
cmdbuf.BindIndexBuffer(cubeIndexBuffer, IndexElementSize.ThirtyTwo);
uint vertexParamOffset = cmdbuf.PushVertexShaderUniforms(cubeUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
// Draw the second cube
cmdbuf.BindVertexBuffers(cubeVertexBuffer2);
cmdbuf.BindIndexBuffer(cubeIndexBuffer, IndexElementSize.ThirtyTwo);
vertexParamOffset = cmdbuf.PushVertexShaderUniforms(cubeUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
cmdbuf.EndRenderPass();
// Blit the MSAA RT to the backbuffer
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, LoadOp.DontCare));
cmdbuf.BindGraphicsPipeline(blitPipeline);
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(renderTargets[index], rtSampler));
cmdbuf.BindVertexBuffers(quadVertexBuffer);
cmdbuf.BindIndexBuffer(quadIndexBuffer, IndexElementSize.Sixteen);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
}
public static void Main(string[] args)
{
DepthMSAAGame game = new DepthMSAAGame();
game.Run();
}
}
}

View File

@ -9,7 +9,7 @@ namespace MoonWorks.Test
private GraphicsPipeline[] msaaPipelines = new GraphicsPipeline[4]; private GraphicsPipeline[] msaaPipelines = new GraphicsPipeline[4];
private GraphicsPipeline blitPipeline; private GraphicsPipeline blitPipeline;
private Texture rt; private Texture[] renderTargets = new Texture[4];
private Sampler rtSampler; private Sampler rtSampler;
private Buffer quadVertexBuffer; private Buffer quadVertexBuffer;
private Buffer quadIndexBuffer; private Buffer quadIndexBuffer;
@ -49,14 +49,21 @@ namespace MoonWorks.Test
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create the MSAA render texture and sampler // Create the MSAA render textures
rt = Texture.CreateTexture2D( for (int i = 0; i < renderTargets.Length; i += 1)
GraphicsDevice, {
MainWindow.Width, renderTargets[i] = Texture.CreateTexture2D(
MainWindow.Height, GraphicsDevice,
TextureFormat.R8G8B8A8, MainWindow.Width,
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler MainWindow.Height,
); TextureFormat.R8G8B8A8,
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
1,
(SampleCount) i
);
}
// Create the sampler
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
@ -119,14 +126,9 @@ namespace MoonWorks.Test
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (backbuffer != null) if (backbuffer != null)
{ {
cmdbuf.BeginRenderPass( Texture rt = renderTargets[(int) currentSampleCount];
new ColorAttachmentInfo(
rt, cmdbuf.BeginRenderPass(new ColorAttachmentInfo(rt, Color.Black));
Color.Black,
currentSampleCount,
StoreOp.Store
)
);
cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]); cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]);
cmdbuf.DrawPrimitives(0, 1, 0, 0); cmdbuf.DrawPrimitives(0, 1, 0, 0);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();

View File

@ -0,0 +1,14 @@
using MoonWorks.Math.Float;
namespace MoonWorks.Test
{
public struct TransformVertexUniform
{
public Matrix4x4 ViewProjection;
public TransformVertexUniform(Matrix4x4 viewProjection)
{
ViewProjection = viewProjection;
}
}
}

View File

@ -53,7 +53,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTextureMipmaps", "Ren
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextureMipmaps", "TextureMipmaps\TextureMipmaps.csproj", "{5A1AC35B-EF18-426D-A633-D4899E84EAA7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextureMipmaps", "TextureMipmaps\TextureMipmaps.csproj", "{5A1AC35B-EF18-426D-A633-D4899E84EAA7}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicStencil", "Stencil\BasicStencil.csproj", "{E3FCEDC2-BAE3-4E21-AEBA-2AC3504526CD}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicStencil", "BasicStencil\BasicStencil.csproj", "{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthMSAA", "DepthMSAA\DepthMSAA.csproj", "{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -161,10 +163,14 @@ Global
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|x64.Build.0 = Debug|x64 {5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|x64.Build.0 = Debug|x64
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.ActiveCfg = Release|x64 {5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.ActiveCfg = Release|x64
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.Build.0 = Release|x64 {5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.Build.0 = Release|x64
{E3FCEDC2-BAE3-4E21-AEBA-2AC3504526CD}.Debug|x64.ActiveCfg = Debug|x64 {1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.ActiveCfg = Debug|x64
{E3FCEDC2-BAE3-4E21-AEBA-2AC3504526CD}.Debug|x64.Build.0 = Debug|x64 {1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.Build.0 = Debug|x64
{E3FCEDC2-BAE3-4E21-AEBA-2AC3504526CD}.Release|x64.ActiveCfg = Release|x64 {1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|x64.ActiveCfg = Release|x64
{E3FCEDC2-BAE3-4E21-AEBA-2AC3504526CD}.Release|x64.Build.0 = Release|x64 {1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|x64.Build.0 = Release|x64
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|x64.ActiveCfg = Debug|x64
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|x64.Build.0 = Debug|x64
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|x64.ActiveCfg = Release|x64
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -95,3 +95,7 @@ Displays a quad that can be scaled to reveal various mip levels. The mips are so
**BasicStencil** **BasicStencil**
Demonstrates stencil masking using two triangles. Tests stencil buffers and basic stencil operations. Demonstrates stencil masking using two triangles. Tests stencil buffers and basic stencil operations.
**DepthMSAA**
Displays two cubes floating around each other on a multisampled surface. Tests multisampled depth buffers.

View File

@ -93,8 +93,7 @@ namespace MoonWorks.Test
Layer = 0, Layer = 0,
Level = 0, Level = 0,
LoadOp = LoadOp.Clear, LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store, StoreOp = StoreOp.Store
SampleCount = SampleCount.One,
}; };
cmdbuf.BeginRenderPass(attachmentInfo); cmdbuf.BeginRenderPass(attachmentInfo);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();

View File

@ -26,16 +26,6 @@ namespace MoonWorks.Test
Color.Purple, Color.Purple,
}; };
struct ViewProjectionUniforms
{
public Matrix4x4 ViewProjection;
public ViewProjectionUniforms(Matrix4x4 viewProjection)
{
ViewProjection = viewProjection;
}
}
public RenderTextureCubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true) public RenderTextureCubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{ {
Logger.LogInfo("Press Down to view the other side of the cubemap"); Logger.LogInfo("Press Down to view the other side of the cubemap");
@ -51,7 +41,7 @@ namespace MoonWorks.Test
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(); pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
pipelineCreateInfo.VertexShaderInfo.UniformBufferSize = (uint) Marshal.SizeOf<ViewProjectionUniforms>(); pipelineCreateInfo.VertexShaderInfo.UniformBufferSize = (uint) Marshal.SizeOf<TransformVertexUniform>();
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
@ -129,8 +119,7 @@ namespace MoonWorks.Test
Layer = i, Layer = i,
Level = 0, Level = 0,
LoadOp = LoadOp.Clear, LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store, StoreOp = StoreOp.Store
SampleCount = SampleCount.One,
}; };
cmdbuf.BeginRenderPass(attachmentInfo); cmdbuf.BeginRenderPass(attachmentInfo);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
@ -160,7 +149,7 @@ namespace MoonWorks.Test
Vector3.Zero, Vector3.Zero,
Vector3.Up Vector3.Up
); );
ViewProjectionUniforms vertUniforms = new ViewProjectionUniforms(view * proj); TransformVertexUniform vertUniforms = new TransformVertexUniform(view * proj);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);

View File

@ -23,16 +23,6 @@ namespace MoonWorks.Test
Color.Yellow, Color.Yellow,
}; };
private struct VertexUniforms
{
public Matrix4x4 TransformMatrix;
public VertexUniforms(Matrix4x4 transformMatrix)
{
TransformMatrix = transformMatrix;
}
}
private string GetSamplerString(int index) private string GetSamplerString(int index)
{ {
switch (index) switch (index)
@ -69,7 +59,7 @@ namespace MoonWorks.Test
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>(); pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<VertexUniforms>(vertShaderModule, "main", 0); pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
@ -135,8 +125,7 @@ namespace MoonWorks.Test
Layer = 0, Layer = 0,
Level = i, Level = i,
LoadOp = LoadOp.Clear, LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store, StoreOp = StoreOp.Store
SampleCount = SampleCount.One,
}; };
cmdbuf.BeginRenderPass(attachmentInfo); cmdbuf.BeginRenderPass(attachmentInfo);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
@ -166,7 +155,7 @@ namespace MoonWorks.Test
protected override void Draw(double alpha) protected override void Draw(double alpha)
{ {
VertexUniforms vertUniforms = new VertexUniforms(Matrix4x4.CreateScale(scale, scale, 1)); TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);

View File

@ -15,16 +15,6 @@ namespace MoonWorks.Test
private float scale = 0.5f; private float scale = 0.5f;
private struct VertexUniforms
{
public Matrix4x4 TransformMatrix;
public VertexUniforms(Matrix4x4 transformMatrix)
{
TransformMatrix = transformMatrix;
}
}
public TextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true) public TextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{ {
Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad"); Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad");
@ -40,7 +30,7 @@ namespace MoonWorks.Test
fragShaderModule fragShaderModule
); );
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>(); pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<VertexUniforms>(vertShaderModule, "main", 0); pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
@ -121,7 +111,7 @@ namespace MoonWorks.Test
protected override void Draw(double alpha) protected override void Draw(double alpha)
{ {
VertexUniforms vertUniforms = new VertexUniforms(Matrix4x4.CreateScale(scale, scale, 1)); TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);

View File

@ -15,17 +15,6 @@ namespace MoonWorks.Test
private float t; private float t;
[StructLayout(LayoutKind.Sequential)]
private struct VertexUniforms
{
public Matrix4x4 TransformMatrix;
public VertexUniforms(Matrix4x4 transformMatrix)
{
TransformMatrix = transformMatrix;
}
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
private struct FragmentUniforms private struct FragmentUniforms
{ {
@ -51,7 +40,7 @@ namespace MoonWorks.Test
); );
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend; pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>(); pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<VertexUniforms>(vertShaderModule, "main", 0); pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragmentUniforms>(fragShaderModule, "main", 1); pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragmentUniforms>(fragShaderModule, "main", 1);
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
@ -91,7 +80,7 @@ namespace MoonWorks.Test
protected override void Draw(double alpha) protected override void Draw(double alpha)
{ {
VertexUniforms vertUniforms; TransformVertexUniform vertUniforms;
FragmentUniforms fragUniforms; FragmentUniforms fragUniforms;
uint vertParamOffset, fragParamOffset; uint vertParamOffset, fragParamOffset;
@ -106,28 +95,28 @@ namespace MoonWorks.Test
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler)); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
// Top-left // Top-left
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(-0.5f, -0.5f, 0))); vertUniforms = new TransformVertexUniform(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)); fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Sin(t) * 0.5f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms); vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms); fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset); cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Top-right // Top-right
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ((2 * System.MathF.PI) - t) * Matrix4x4.CreateTranslation(new Vector3(0.5f, -0.5f, 0))); vertUniforms = new TransformVertexUniform(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)); fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Cos(t) * 0.5f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms); vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms); fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset); cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Bottom-left // Bottom-left
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(-0.5f, 0.5f, 0))); vertUniforms = new TransformVertexUniform(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)); fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Sin(t) * 0.2f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms); vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms); fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset); cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, fragParamOffset);
// Bottom-right // Bottom-right
vertUniforms = new VertexUniforms(Matrix4x4.CreateRotationZ(t) * Matrix4x4.CreateTranslation(new Vector3(0.5f, 0.5f, 0))); vertUniforms = new TransformVertexUniform(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)); fragUniforms = new FragmentUniforms(new Vector4(1f, 0.5f + System.MathF.Cos(t) * 1f, 1f, 1f));
vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms); vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms); fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniforms);