Compare commits

..

3 Commits

Author SHA1 Message Date
cosmonaut c6f87cce55 more sprite batch implementation 2024-01-26 22:29:20 -08:00
cosmonaut b0583f934b more 2024-01-23 12:43:47 -08:00
cosmonaut 7eb2477870 starting on sprite batch example 2024-01-23 12:43:34 -08:00
35 changed files with 2503 additions and 2595 deletions

1
.gitignore vendored
View File

@ -2,4 +2,3 @@ bin/
obj/
.vs/
*.csproj.user
Properties/

View File

@ -1,223 +0,0 @@
using MoonWorks;
using MoonWorks.Graphics;
using MoonWorks.Math.Float;
using MoonWorks.Math;
using System.Runtime.InteropServices;
namespace MoonWorks.Test
{
class MSAACubeGame : Game
{
private GraphicsPipeline[] msaaPipelines = new GraphicsPipeline[4];
private GraphicsPipeline cubemapPipeline;
private Texture[] renderTargets = new Texture[4];
private Buffer vertexBuffer;
private Buffer indexBuffer;
private Sampler sampler;
private Vector3 camPos = new Vector3(0, 0, 4f);
private SampleCount currentSampleCount = SampleCount.Four;
public MSAACubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{
Logger.LogInfo("Press Down to view the other side of the cubemap");
Logger.LogInfo("Press Left and Right to cycle between sample counts");
Logger.LogInfo("Setting sample count to: " + currentSampleCount);
// Create the MSAA pipelines
ShaderModule triangleVertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert"));
ShaderModule triangleFragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
TextureFormat.R8G8B8A8,
triangleVertShaderModule,
triangleFragShaderModule
);
for (int i = 0; i < msaaPipelines.Length; i += 1)
{
pipelineCreateInfo.MultisampleState.MultisampleCount = (SampleCount)i;
msaaPipelines[i] = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
}
// Create the cubemap pipeline
ShaderModule cubemapVertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.vert"));
ShaderModule cubemapFragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.frag"));
pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
MainWindow.SwapchainFormat,
cubemapVertShaderModule,
cubemapFragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
pipelineCreateInfo.VertexShaderInfo.UniformBufferSize = (uint)Marshal.SizeOf<TransformVertexUniform>();
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
cubemapPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create the MSAA render targets
for (int i = 0; i < renderTargets.Length; i++)
{
TextureCreateInfo cubeCreateInfo = new TextureCreateInfo
{
Width = 16,
Height = 16,
Format = TextureFormat.R8G8B8A8,
Depth = 1,
LevelCount = 1,
SampleCount = (SampleCount)i,
UsageFlags = TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
IsCube = true
};
renderTargets[i] = new Texture(GraphicsDevice, cubeCreateInfo);
}
// Create samplers
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the GPU resources
vertexBuffer = Buffer.Create<PositionVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24);
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 36);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData(
vertexBuffer,
new PositionVertex[]
{
new PositionVertex(new Vector3(-10, -10, -10)),
new PositionVertex(new Vector3(10, -10, -10)),
new PositionVertex(new Vector3(10, 10, -10)),
new PositionVertex(new Vector3(-10, 10, -10)),
new PositionVertex(new Vector3(-10, -10, 10)),
new PositionVertex(new Vector3(10, -10, 10)),
new PositionVertex(new Vector3(10, 10, 10)),
new PositionVertex(new Vector3(-10, 10, 10)),
new PositionVertex(new Vector3(-10, -10, -10)),
new PositionVertex(new Vector3(-10, 10, -10)),
new PositionVertex(new Vector3(-10, 10, 10)),
new PositionVertex(new Vector3(-10, -10, 10)),
new PositionVertex(new Vector3(10, -10, -10)),
new PositionVertex(new Vector3(10, 10, -10)),
new PositionVertex(new Vector3(10, 10, 10)),
new PositionVertex(new Vector3(10, -10, 10)),
new PositionVertex(new Vector3(-10, -10, -10)),
new PositionVertex(new Vector3(-10, -10, 10)),
new PositionVertex(new Vector3(10, -10, 10)),
new PositionVertex(new Vector3(10, -10, -10)),
new PositionVertex(new Vector3(-10, 10, -10)),
new PositionVertex(new Vector3(-10, 10, 10)),
new PositionVertex(new Vector3(10, 10, 10)),
new PositionVertex(new Vector3(10, 10, -10))
}
);
cmdbuf.SetBufferData(
indexBuffer,
new ushort[]
{
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);
}
protected override void Update(System.TimeSpan delta)
{
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
{
camPos.Z *= -1;
}
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);
}
}
protected override void Draw(double alpha)
{
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(75f),
(float)MainWindow.Width / MainWindow.Height,
0.01f,
100f
);
Matrix4x4 view = Matrix4x4.CreateLookAt(
camPos,
Vector3.Zero,
Vector3.Up
);
TransformVertexUniform vertUniforms = new TransformVertexUniform(view * proj);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (backbuffer != null)
{
// Get a reference to the RT for the given sample count
int rtIndex = (int) currentSampleCount;
Texture rt = renderTargets[rtIndex];
ColorAttachmentInfo rtAttachmentInfo = new ColorAttachmentInfo(
rt,
Color.Black
);
// Render a triangle to each slice of the cubemap
for (uint i = 0; i < 6; i += 1)
{
rtAttachmentInfo.Layer = i;
cmdbuf.BeginRenderPass(rtAttachmentInfo);
cmdbuf.BindGraphicsPipeline(msaaPipelines[rtIndex]);
cmdbuf.DrawPrimitives(0, 1, 0, 0);
cmdbuf.EndRenderPass();
}
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
cmdbuf.BindGraphicsPipeline(cubemapPipeline);
cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, sampler));
uint vertexUniformOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexUniformOffset, 0);
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
}
public static void Main(string[] args)
{
MSAACubeGame game = new MSAACubeGame();
game.Run();
}
}
}

View File

@ -0,0 +1,13 @@
#version 450
layout(location = 0) in vec2 inTexCoord;
layout(location = 1) in vec4 inColor;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 1) uniform sampler2D Sampler;
void main()
{
FragColor = texture(Sampler, inTexCoord) * inColor;
}

View File

@ -0,0 +1,45 @@
#version 450
layout (location = 0) in vec3 Position;
layout (location = 1) in vec3 Translation;
layout (location = 2) in float Rotation;
layout (location = 3) in vec2 Scale;
layout (location = 4) in vec4 Color;
layout (location = 5) in vec2[4] UV;
layout (location = 0) out vec2 outTexCoord;
layout (location = 1) out vec4 outVertexColor;
layout (binding = 0, set = 2) uniform UniformBlock
{
mat4x4 View;
mat4x4 Projection;
};
void main()
{
mat4 Scale = mat4(
Scale.x, 0, 0, 0,
0, Scale.y, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
float c = cos(Rotation);
float s = sin(Rotation);
mat4 Rotation = mat4(
c, s, 0, 0,
-s, c, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
mat4 Translation = mat4(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
Translation.x, Translation.y, Translation.z, 1
);
mat4 Model = Translation * Rotation * Scale;
gl_Position = Projection * View * Model * vec4(Position, 1);
outTexCoord = UV[gl_VertexIndex % 4];
outVertexColor = Color;
}

View File

@ -36,7 +36,7 @@
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\moonlibs\windows\libdav1dfile.*">
<Content Include="..\..\moonlibs\lib64\libdav1dfile.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -57,144 +57,138 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicStencil", "BasicStenci
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthMSAA", "DepthMSAA\DepthMSAA.csproj", "{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowResizing", "WindowResizing\WindowResizing.csproj", "{AF5F2804-663D-4C46-BD02-AB178002180B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowResizing", "WindowResizing\WindowResizing.csproj", "{AF5F2804-663D-4C46-BD02-AB178002180B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StoreLoad", "StoreLoad\StoreLoad.csproj", "{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StoreLoad", "StoreLoad\StoreLoad.csproj", "{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture2D", "RenderTexture2D\RenderTexture2D.csproj", "{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSAACube", "MSAACube\MSAACube.csproj", "{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteBatch", "SpriteBatch\SpriteBatch.csproj", "{40E25B99-1196-4695-99A6-C0A8EF385539}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|Any CPU.Build.0 = Release|Any CPU
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|Any CPU.Build.0 = Release|Any CPU
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|Any CPU.Build.0 = Release|Any CPU
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|Any CPU.Build.0 = Release|Any CPU
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|Any CPU.Build.0 = Release|Any CPU
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|Any CPU.Build.0 = Release|Any CPU
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|Any CPU.Build.0 = Release|Any CPU
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|Any CPU.Build.0 = Release|Any CPU
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|Any CPU.Build.0 = Release|Any CPU
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|Any CPU.Build.0 = Release|Any CPU
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|Any CPU.Build.0 = Release|Any CPU
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|Any CPU.Build.0 = Release|Any CPU
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|Any CPU.Build.0 = Release|Any CPU
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|Any CPU.Build.0 = Release|Any CPU
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|Any CPU.Build.0 = Release|Any CPU
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|Any CPU.Build.0 = Release|Any CPU
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|Any CPU.Build.0 = Release|Any CPU
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|Any CPU.Build.0 = Release|Any CPU
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|Any CPU.Build.0 = Release|Any CPU
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|Any CPU.Build.0 = Release|Any CPU
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|Any CPU.Build.0 = Release|Any CPU
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|Any CPU.Build.0 = Release|Any CPU
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|Any CPU.Build.0 = Release|Any CPU
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|Any CPU.Build.0 = Release|Any CPU
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|Any CPU.Build.0 = Release|Any CPU
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|Any CPU.Build.0 = Release|Any CPU
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|Any CPU.Build.0 = Release|Any CPU
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|Any CPU.Build.0 = Release|Any CPU
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|Any CPU.Build.0 = Release|Any CPU
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Release|Any CPU.Build.0 = Release|Any CPU
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Release|Any CPU.Build.0 = Release|Any CPU
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|x64.ActiveCfg = Debug|x64
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|x64.Build.0 = Debug|x64
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|x64.ActiveCfg = Release|x64
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|x64.Build.0 = Release|x64
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|x64.ActiveCfg = Debug|x64
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|x64.Build.0 = Debug|x64
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|x64.ActiveCfg = Release|x64
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|x64.Build.0 = Release|x64
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|x64.ActiveCfg = Debug|x64
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|x64.Build.0 = Debug|x64
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|x64.ActiveCfg = Release|x64
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|x64.Build.0 = Release|x64
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|x64.ActiveCfg = Debug|x64
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|x64.Build.0 = Debug|x64
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|x64.ActiveCfg = Release|x64
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|x64.Build.0 = Release|x64
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|x64.ActiveCfg = Debug|x64
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|x64.Build.0 = Debug|x64
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|x64.ActiveCfg = Release|x64
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|x64.Build.0 = Release|x64
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|x64.ActiveCfg = Debug|x64
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|x64.Build.0 = Debug|x64
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|x64.ActiveCfg = Release|x64
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|x64.Build.0 = Release|x64
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|x64.ActiveCfg = Debug|x64
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|x64.Build.0 = Debug|x64
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|x64.ActiveCfg = Release|x64
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|x64.Build.0 = Release|x64
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|x64.ActiveCfg = Debug|x64
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|x64.Build.0 = Debug|x64
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|x64.ActiveCfg = Release|x64
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|x64.Build.0 = Release|x64
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|x64.ActiveCfg = Debug|x64
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|x64.Build.0 = Debug|x64
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|x64.ActiveCfg = Release|x64
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|x64.Build.0 = Release|x64
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|x64.ActiveCfg = Debug|x64
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|x64.Build.0 = Debug|x64
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|x64.ActiveCfg = Release|x64
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|x64.Build.0 = Release|x64
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|x64.ActiveCfg = Debug|x64
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|x64.Build.0 = Debug|x64
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|x64.ActiveCfg = Release|x64
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|x64.Build.0 = Release|x64
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|x64.ActiveCfg = Debug|x64
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|x64.Build.0 = Debug|x64
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|x64.ActiveCfg = Release|x64
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|x64.Build.0 = Release|x64
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|x64.ActiveCfg = Debug|x64
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|x64.Build.0 = Debug|x64
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|x64.ActiveCfg = Release|x64
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|x64.Build.0 = Release|x64
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|x64.ActiveCfg = Debug|x64
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|x64.Build.0 = Debug|x64
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|x64.ActiveCfg = Release|x64
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|x64.Build.0 = Release|x64
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|x64.ActiveCfg = Debug|x64
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|x64.Build.0 = Debug|x64
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|x64.ActiveCfg = Release|x64
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|x64.Build.0 = Release|x64
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|x64.ActiveCfg = Debug|x64
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|x64.Build.0 = Debug|x64
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|x64.ActiveCfg = Release|x64
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|x64.Build.0 = Release|x64
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|x64.ActiveCfg = Debug|x64
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|x64.Build.0 = Debug|x64
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|x64.ActiveCfg = Release|x64
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|x64.Build.0 = Release|x64
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|x64.ActiveCfg = Debug|x64
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|x64.Build.0 = Debug|x64
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|x64.ActiveCfg = Release|x64
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|x64.Build.0 = Release|x64
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|x64.ActiveCfg = Debug|x64
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|x64.Build.0 = Debug|x64
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|x64.ActiveCfg = Release|x64
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|x64.Build.0 = Release|x64
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|x64.ActiveCfg = Debug|x64
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|x64.Build.0 = Debug|x64
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|x64.ActiveCfg = Release|x64
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|x64.Build.0 = Release|x64
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|x64.ActiveCfg = Debug|x64
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|x64.Build.0 = Debug|x64
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|x64.ActiveCfg = Release|x64
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|x64.Build.0 = Release|x64
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|x64.ActiveCfg = Debug|x64
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|x64.Build.0 = Debug|x64
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|x64.ActiveCfg = Release|x64
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|x64.Build.0 = Release|x64
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|x64.ActiveCfg = Debug|x64
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|x64.Build.0 = Debug|x64
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|x64.ActiveCfg = Release|x64
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|x64.Build.0 = Release|x64
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|x64.ActiveCfg = Debug|x64
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|x64.Build.0 = Debug|x64
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|x64.ActiveCfg = Release|x64
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|x64.Build.0 = Release|x64
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|x64.ActiveCfg = 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.Build.0 = Release|x64
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.ActiveCfg = Debug|x64
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.Build.0 = Debug|x64
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|x64.ActiveCfg = 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
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|x64.ActiveCfg = Debug|x64
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|x64.Build.0 = Debug|x64
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.ActiveCfg = Release|Any CPU
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.Build.0 = Release|Any CPU
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.ActiveCfg = Debug|x64
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.Build.0 = Debug|x64
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.ActiveCfg = Release|x64
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.Build.0 = Release|x64
{40E25B99-1196-4695-99A6-C0A8EF385539}.Debug|x64.ActiveCfg = Debug|Any CPU
{40E25B99-1196-4695-99A6-C0A8EF385539}.Debug|x64.Build.0 = Debug|Any CPU
{40E25B99-1196-4695-99A6-C0A8EF385539}.Release|x64.ActiveCfg = Release|Any CPU
{40E25B99-1196-4695-99A6-C0A8EF385539}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -16,10 +16,6 @@ Sets up a graphics pipeline and draws a triangle without vertex buffers. (The ve
Similar to above, but using a MoonWorks vertex buffer and custom vertex structs.
**StoreLoad**
Draws a triangle to the screen in one render pass, stores the attachment, and then loads the attachment again. Tests that load/store operations work as expected.
**TexturedQuad**
Draws a textured quad to the screen. Tests texture binding, index buffers, and sampler states.
@ -84,10 +80,6 @@ Displays a quad that can be scaled to reveal various mip levels. The mips are ge
Displays a triangle whose colors are driven by sampling a texture in the vertex shader.
**RenderTexture2D**
Clears and draws 4 render textures to the screen. Tests binding and sampling 2D render textures.
**RenderTexture3D**
Fades through 2D slices of a 3D render texture. Tests binding and sampling 3D render textures.
@ -108,10 +100,6 @@ Demonstrates stencil masking using two triangles. Tests stencil buffers and basi
Displays two cubes floating around each other on a multisampled surface. Tests multisampled depth buffers.
**MSAACube**
Same as RenderTextureCube, but with MSAA cube RTs. Draws triangles to each cubemap face so there's something to see. Tests cube render target MSAA.
**WindowResizing**
Tests resizing the window to various resolutions.

View File

@ -1,16 +0,0 @@
<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>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<Import Project="$(SolutionDir)NativeAOT_Console.targets" Condition="Exists('$(SolutionDir)NativeAOT_Console.targets')" />
</Project>

View File

@ -1,131 +0,0 @@
using MoonWorks;
using MoonWorks.Graphics;
using MoonWorks.Math.Float;
namespace MoonWorks.Test
{
class RenderTexture2DGame : Game
{
private GraphicsPipeline pipeline;
private Buffer vertexBuffer;
private Buffer indexBuffer;
private Texture[] textures = new Texture[4];
private Sampler sampler;
public RenderTexture2DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{
// Load the shaders
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
// Create the graphics pipeline
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
MainWindow.SwapchainFormat,
vertShaderModule,
fragShaderModule
);
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create sampler
SamplerCreateInfo samplerCreateInfo = SamplerCreateInfo.PointClamp;
sampler = new Sampler(GraphicsDevice, samplerCreateInfo);
// Create and populate the GPU resources
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 16);
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
for (int i = 0; i < textures.Length; i += 1)
{
textures[i] = Texture.CreateTexture2D(
GraphicsDevice,
MainWindow.Width / 4,
MainWindow.Height / 4,
TextureFormat.R8G8B8A8,
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
);
}
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData(
vertexBuffer,
new PositionTextureVertex[]
{
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(0, 0, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-1, 0, 0), new Vector2(0, 1)),
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(1, 0, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(0, 0, 0), new Vector2(0, 1)),
new PositionTextureVertex(new Vector3(-1, 0, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(0, 0, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(0, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
new PositionTextureVertex(new Vector3(0, 0, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, 0, 0), new Vector2(1, 0)),
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(0, 1, 0), new Vector2(0, 1)),
}
);
cmdbuf.SetBufferData(
indexBuffer,
new ushort[]
{
0, 1, 2,
0, 2, 3,
}
);
GraphicsDevice.Submit(cmdbuf);
}
protected override void Update(System.TimeSpan delta) { }
protected override void Draw(double alpha)
{
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (backbuffer != null)
{
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[0], Color.Red));
cmdbuf.EndRenderPass();
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[1], Color.Blue));
cmdbuf.EndRenderPass();
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[2], Color.Green));
cmdbuf.EndRenderPass();
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[3], Color.Yellow));
cmdbuf.EndRenderPass();
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
cmdbuf.BindGraphicsPipeline(pipeline);
cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
for (uint i = 0; i < textures.Length; i += 1)
{
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textures[i], sampler));
cmdbuf.DrawIndexedPrimitives(4 * i, 0, 2, 0, 0);
}
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
}
public static void Main(string[] args)
{
RenderTexture2DGame game = new RenderTexture2DGame();
game.Run();
}
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\MoonWorks\MoonWorks.csproj" />
@ -9,6 +9,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Import Project="$(SolutionDir)NativeAOT_Console.targets" Condition="Exists('$(SolutionDir)NativeAOT_Console.targets')" />

View File

@ -0,0 +1,238 @@
using System;
using MoonWorks.Graphics;
using MoonWorks.Math;
using MoonWorks.Math.Float;
namespace MoonWorks.Test
{
class SpriteBatchGame : Game
{
GraphicsPipeline spriteBatchPipeline;
Graphics.Buffer quadVertexBuffer;
Graphics.Buffer quadIndexBuffer;
SpriteBatch SpriteBatch;
Texture Texture;
Sampler Sampler;
Matrix4x4 View;
Matrix4x4 Projection;
Random Random;
public unsafe SpriteBatchGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
{
Random = new Random();
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("InstancedSpriteBatch.vert"));
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("InstancedSpriteBatch.frag"));
var vertexBufferDescription = VertexBindingAndAttributes.Create<PositionVertex>(0);
var instanceBufferDescription = VertexBindingAndAttributes.Create<SpriteInstanceData>(1, 1, VertexInputRate.Instance);
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
MainWindow.SwapchainFormat,
vertShaderModule,
fragShaderModule
);
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<ViewProjectionMatrices>(vertShaderModule, "main", 0);
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create(fragShaderModule, "main", 1);
pipelineCreateInfo.VertexInputState = new VertexInputState([
vertexBufferDescription,
instanceBufferDescription
]);
spriteBatchPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
Texture = Texture.CreateTexture2D(GraphicsDevice, 1, 1, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
Sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
quadVertexBuffer = Graphics.Buffer.Create<PositionVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
quadIndexBuffer = Graphics.Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
var vertices = stackalloc PositionVertex[4];
vertices[0].Position = new Math.Float.Vector3(0, 0, 0);
vertices[1].Position = new Math.Float.Vector3(1, 0, 0);
vertices[2].Position = new Math.Float.Vector3(0, 1, 0);
vertices[3].Position = new Math.Float.Vector3(1, 1, 0);
var indices = stackalloc ushort[6]
{
0, 1, 2,
2, 1, 3
};
var cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData(quadVertexBuffer, new Span<PositionVertex>(vertices, 4));
cmdbuf.SetBufferData(quadIndexBuffer, new Span<ushort>(indices, 6));
cmdbuf.SetTextureData(Texture, new Color[1] { Color.White });
GraphicsDevice.Submit(cmdbuf);
SpriteBatch = new SpriteBatch(GraphicsDevice);
// View = Matrix4x4.CreateLookAt(
// new Vector3(0, 0, -1),
// Vector3.Zero,
// Vector3.Up
// );
//View = Matrix4x4.Identity;
View = Matrix4x4.CreateLookAt(
new Vector3(0, 0, 1),
Vector3.Zero,
Vector3.Up
);
Projection = Matrix4x4.CreateOrthographicOffCenter(
0,
MainWindow.Width,
MainWindow.Height,
0,
0.01f,
10
);
// Projection = Matrix4x4.CreatePerspectiveFieldOfView(
// MathHelper.ToRadians(75f),
// (float) MainWindow.Width / MainWindow.Height,
// 0.01f,
// 1000
// );
}
protected override void Update(TimeSpan delta)
{
}
protected override void Draw(double alpha)
{
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? swapchain = cmdbuf.AcquireSwapchainTexture(MainWindow);
if (swapchain != null)
{
SpriteBatch.Reset();
for (var i = 0; i < 1024; i += 1)
{
var position = new Vector3(Random.Next((int) MainWindow.Width), Random.Next((int) MainWindow.Height), 1);
SpriteBatch.Add(
position,
0f,
new Vector2(100, 100),
new Color(Random.Next(255), Random.Next(255), Random.Next(255)),
new Vector2(0, 0),
new Vector2(1, 1)
);
}
SpriteBatch.Upload(cmdbuf);
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, Color.Black));
SpriteBatch.Render(cmdbuf, spriteBatchPipeline, Texture, Sampler, quadVertexBuffer, quadIndexBuffer, new ViewProjectionMatrices(View, Projection));
cmdbuf.EndRenderPass();
}
GraphicsDevice.Submit(cmdbuf);
}
public static void Main(string[] args)
{
SpriteBatchGame game = new SpriteBatchGame();
game.Run();
}
}
public readonly record struct ViewProjectionMatrices(Matrix4x4 View, Matrix4x4 Projection);
public struct SpriteInstanceData : IVertexType
{
public Vector3 Translation;
public float Rotation;
public Vector2 Scale;
public Color Color;
public Vector2 UV0;
public Vector2 UV1;
public Vector2 UV2;
public Vector2 UV3;
public static VertexElementFormat[] Formats =>
[
VertexElementFormat.Vector3,
VertexElementFormat.Float,
VertexElementFormat.Vector2,
VertexElementFormat.Color,
VertexElementFormat.Vector2,
VertexElementFormat.Vector2,
VertexElementFormat.Vector2,
VertexElementFormat.Vector2
];
}
class SpriteBatch
{
GraphicsDevice GraphicsDevice;
public Graphics.Buffer BatchBuffer;
SpriteInstanceData[] InstanceDatas;
uint Index;
public uint InstanceCount => Index;
public SpriteBatch(GraphicsDevice graphicsDevice)
{
GraphicsDevice = graphicsDevice;
BatchBuffer = Graphics.Buffer.Create<SpriteInstanceData>(GraphicsDevice, BufferUsageFlags.Vertex, 1024);
InstanceDatas = new SpriteInstanceData[1024];
Index = 0;
}
public void Reset()
{
Index = 0;
}
public void Add(
Vector3 position,
float rotation,
Vector2 size,
Color color,
Vector2 leftTopUV,
Vector2 dimensionsUV
) {
var left = leftTopUV.X;
var top = leftTopUV.Y;
var right = leftTopUV.X + dimensionsUV.X;
var bottom = leftTopUV.Y + dimensionsUV.Y;
InstanceDatas[Index].Translation = position;
InstanceDatas[Index].Rotation = rotation;
InstanceDatas[Index].Scale = size;
InstanceDatas[Index].Color = color;
InstanceDatas[Index].UV0 = leftTopUV;
InstanceDatas[Index].UV1 = new Vector2(left, bottom);
InstanceDatas[Index].UV2 = new Vector2(right, top);
InstanceDatas[Index].UV3 = new Vector2(right, bottom);
Index += 1;
}
public void Upload(CommandBuffer commandBuffer)
{
commandBuffer.SetBufferData(BatchBuffer, InstanceDatas, 0, 0, (uint) Index);
}
public void Render(CommandBuffer commandBuffer, GraphicsPipeline pipeline, Texture texture, Sampler sampler, Graphics.Buffer quadVertexBuffer, Graphics.Buffer quadIndexBuffer, ViewProjectionMatrices viewProjectionMatrices)
{
commandBuffer.BindGraphicsPipeline(pipeline);
commandBuffer.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
commandBuffer.BindVertexBuffers(
new BufferBinding(quadVertexBuffer, 0),
new BufferBinding(BatchBuffer, 0)
);
commandBuffer.BindIndexBuffer(quadIndexBuffer, IndexElementSize.Sixteen);
var vertParamOffset = commandBuffer.PushVertexShaderUniforms(viewProjectionMatrices);
commandBuffer.DrawInstancedPrimitives(0, 0, 2, InstanceCount, vertParamOffset, 0);
}
}
}

View File

@ -120,7 +120,7 @@ namespace MoonWorks.Test
protected override void Draw(double alpha)
{
FragUniform fragUniform = new FragUniform((float)currentDepth / texture.Depth + 0.01f);
FragUniform fragUniform = new FragUniform((float) currentDepth / texture.Depth);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);