From da90d28c33f65cbcb44f0677081e1834c1777552 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 5 Jun 2024 14:19:43 -0700 Subject: [PATCH] restructure graphics tests --- BasicCompute/BasicCompute.csproj | 16 -- BasicCompute/BasicComputeGame.cs | 153 -------------- BasicStencil/BasicStencil.csproj | 16 -- BasicTriangle/BasicTriangle.csproj | 16 -- ClearScreen/ClearScreen.csproj | 16 -- .../ClearScreen_MultiWindow.csproj | 16 -- .../Compiled/CalculateSquares.comp.refresh | Bin .../Shaders/Compiled/FillTexture.comp.refresh | Bin .../Compiled/GradientTexture.comp.refresh | Bin .../Compiled/PositionColor.vert.refresh | Bin .../PositionColorInstanced.vert.refresh | Bin .../PositionColorWithMatrix.vert.refresh | Bin .../Compiled/PositionSampler.vert.refresh | Bin .../Shaders/Compiled/RawTriangle.vert.refresh | Bin .../Shaders/Compiled/Skybox.frag.refresh | Bin .../Shaders/Compiled/Skybox.vert.refresh | Bin .../Shaders/Compiled/SolidColor.frag.refresh | Bin .../Compiled/TexturedDepthQuad.frag.refresh | Bin .../Compiled/TexturedQuad.frag.refresh | Bin .../Compiled/TexturedQuad.vert.refresh | Bin .../Compiled/TexturedQuad2DArray.frag.refresh | Bin .../Compiled/TexturedQuad3D.frag.refresh | Bin .../TexturedQuadWithMatrix.vert.refresh | Bin ...TexturedQuadWithMultiplyColor.frag.refresh | Bin .../Shaders/Source/CalculateSquares.comp | 0 .../Content/Shaders/Source/FillTexture.comp | 0 .../Shaders/Source/GradientTexture.comp | 0 .../Content/Shaders/Source/PositionColor.vert | 0 .../Source/PositionColorInstanced.vert | 0 .../Source/PositionColorWithMatrix.vert | 0 .../Shaders/Source/PositionSampler.vert | 0 .../Content/Shaders/Source/RawTriangle.vert | 0 .../Content/Shaders/Source/Skybox.frag | 0 .../Content/Shaders/Source/Skybox.vert | 0 .../Content/Shaders/Source/SolidColor.frag | 0 .../Shaders/Source/TexturedDepthQuad.frag | 0 .../Content/Shaders/Source/TexturedQuad.frag | 0 .../Content/Shaders/Source/TexturedQuad.vert | 0 .../Shaders/Source/TexturedQuad2DArray.frag | 0 .../Shaders/Source/TexturedQuad3D.frag | 0 .../Source/TexturedQuadWithMatrix.vert | 0 .../Source/TexturedQuadWithMultiplyColor.frag | 0 .../Content/Textures/BC1.dds | Bin .../Content/Textures/BC2.dds | Bin .../Content/Textures/BC3.dds | Bin .../Content/Textures/BC7.dds | Bin .../Content/Textures/back.png | Bin .../Content/Textures/bottom.png | Bin .../Content/Textures/front.png | Bin .../Content/Textures/left.png | Bin .../Content/Textures/mip0.png | Bin .../Content/Textures/mip1.png | Bin .../Content/Textures/mip2.png | Bin .../Content/Textures/mip3.png | Bin .../Content/Textures/ravioli.png | Bin .../Content/Textures/ravioli.qoi | Bin .../Content/Textures/right.png | Bin .../Content/Textures/tex3d_0.png | Bin .../Content/Textures/tex3d_1.png | Bin .../Content/Textures/tex3d_2.png | Bin .../Content/Textures/tex3d_3.png | Bin .../Content/Textures/tex3d_4.png | Bin .../Content/Textures/tex3d_5.png | Bin .../Content/Textures/tex3d_6.png | Bin .../Content/Textures/top.png | Bin .../Content/Videos/hello.obu | Bin Common/TestUtils.cs | 136 +++++++++++++ Common/UniformTypes.cs | 13 ++ Common/VertexTypes.cs | 74 +++++++ CompressedTextures/CompressedTextures.csproj | 16 -- ComputeUniforms/ComputeUniforms.csproj | 16 -- ...pyMoonlibs.targets => CopyMoonlibs.targets | 0 CopyTexture/CopyTexture.csproj | 17 -- Cube/Cube.csproj | 17 -- CullFace/CullFace.csproj | 16 -- DepthMSAA/DepthMSAA.csproj | 16 -- DrawIndirect/DrawIndirect.csproj | 16 -- Examples/BasicComputeGame.cs | 191 ++++++++++++++++++ .../BasicStencilGame.cs | 74 ++++--- .../BasicTriangleGame.cs | 0 {ClearScreen => Examples}/ClearScreenGame.cs | 0 .../ClearScreen_MultiWindowGame.cs | 0 .../CompressedTexturesGame.cs | 0 .../ComputeUniformsGame.cs | 0 {CopyTexture => Examples}/CopyTextureGame.cs | 0 {Cube => Examples}/CubeGame.cs | 0 {CullFace => Examples}/CullFaceGame.cs | 0 {DepthMSAA => Examples}/DepthMSAAGame.cs | 0 .../DrawIndirectGame.cs | 0 Examples/Example.cs | 16 ++ .../GetBufferDataGame.cs | 0 .../InstancingAndOffsetsGame.cs | 0 {MSAACube => Examples}/MSAACubeGame.cs | 0 {MSAA => Examples}/MSAAGame.cs | 0 .../RenderTexture2DArrayGame.cs | 0 .../RenderTexture2DGame.cs | 0 .../RenderTextureCubeGame.cs | 0 .../RenderTextureMipmapsGame.cs | 0 {StoreLoad => Examples}/StoreLoadGame.cs | 0 {Texture3DCopy => Examples}/Texture3DCopy.cs | 0 {Texture3D => Examples}/Texture3DGame.cs | 0 .../TextureMipmapsGame.cs | 0 .../TexturedAnimatedQuadGame.cs | 0 .../TexturedQuadGame.cs | 0 .../TriangleVertexBufferGame.cs | 0 .../VertexSamplerGame.cs | 0 {VideoPlayer => Examples}/VideoPlayerGame.cs | 0 .../WindowResizingGame.cs | 0 GetBufferData/GetBufferData.csproj | 16 -- .../InstancingAndOffsets.csproj | 16 -- MSAA/MSAA.csproj | 16 -- MSAACube/MSAACube.csproj | 16 -- .../MoonWorks.Test.Common.csproj | 22 -- MoonWorks.Test.Common/TestUtils.cs | 138 ------------- MoonWorks.Test.Common/UniformTypes.cs | 14 -- MoonWorks.Test.Common/VertexTypes.cs | 75 ------- MoonWorksGraphicsTests.csproj | 21 ++ MoonWorksGraphicsTests.sln | 190 +---------------- Program.cs | 93 +++++++++ RenderTexture2D/RenderTexture2D.csproj | 16 -- .../RenderTexture2DArray.csproj | 16 -- RenderTextureCube/RenderTextureCube.csproj | 16 -- .../RenderTextureMipmaps.csproj | 16 -- StoreLoad/StoreLoad.csproj | 16 -- Texture3D/Texture3D.csproj | 16 -- Texture3DCopy/Texture3DCopy.csproj | 16 -- TextureMipmaps/TextureMipmaps.csproj | 16 -- .../TexturedAnimatedQuad.csproj | 16 -- TexturedQuad/TexturedQuad.csproj | 17 -- .../TriangleVertexBuffer.csproj | 16 -- VertexSampler/VertexSampler.csproj | 16 -- VideoPlayer/VideoPlayer.csproj | 16 -- WindowResizing/WindowResizing.csproj | 16 -- 133 files changed, 593 insertions(+), 1100 deletions(-) delete mode 100644 BasicCompute/BasicCompute.csproj delete mode 100644 BasicCompute/BasicComputeGame.cs delete mode 100644 BasicStencil/BasicStencil.csproj delete mode 100644 BasicTriangle/BasicTriangle.csproj delete mode 100644 ClearScreen/ClearScreen.csproj delete mode 100644 ClearScreen_MultiWindow/ClearScreen_MultiWindow.csproj rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/CalculateSquares.comp.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/FillTexture.comp.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/GradientTexture.comp.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/PositionColor.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/PositionColorInstanced.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/PositionColorWithMatrix.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/PositionSampler.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/RawTriangle.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/Skybox.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/Skybox.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/SolidColor.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedDepthQuad.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuad.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuad.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuad2DArray.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuad3D.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuadWithMatrix.vert.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Compiled/TexturedQuadWithMultiplyColor.frag.refresh (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/CalculateSquares.comp (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/FillTexture.comp (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/GradientTexture.comp (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/PositionColor.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/PositionColorInstanced.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/PositionColorWithMatrix.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/PositionSampler.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/RawTriangle.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/Skybox.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/Skybox.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/SolidColor.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedDepthQuad.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuad.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuad.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuad2DArray.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuad3D.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuadWithMatrix.vert (100%) rename {MoonWorks.Test.Common => Common}/Content/Shaders/Source/TexturedQuadWithMultiplyColor.frag (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/BC1.dds (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/BC2.dds (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/BC3.dds (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/BC7.dds (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/back.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/bottom.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/front.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/left.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/mip0.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/mip1.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/mip2.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/mip3.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/ravioli.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/ravioli.qoi (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/right.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_0.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_1.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_2.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_3.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_4.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_5.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/tex3d_6.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Textures/top.png (100%) rename {MoonWorks.Test.Common => Common}/Content/Videos/hello.obu (100%) create mode 100644 Common/TestUtils.cs create mode 100644 Common/UniformTypes.cs create mode 100644 Common/VertexTypes.cs delete mode 100644 CompressedTextures/CompressedTextures.csproj delete mode 100644 ComputeUniforms/ComputeUniforms.csproj rename MoonWorks.Test.Common/CopyMoonlibs.targets => CopyMoonlibs.targets (100%) delete mode 100644 CopyTexture/CopyTexture.csproj delete mode 100644 Cube/Cube.csproj delete mode 100644 CullFace/CullFace.csproj delete mode 100644 DepthMSAA/DepthMSAA.csproj delete mode 100644 DrawIndirect/DrawIndirect.csproj create mode 100644 Examples/BasicComputeGame.cs rename {BasicStencil => Examples}/BasicStencilGame.cs (59%) rename {BasicTriangle => Examples}/BasicTriangleGame.cs (100%) rename {ClearScreen => Examples}/ClearScreenGame.cs (100%) rename {ClearScreen_MultiWindow => Examples}/ClearScreen_MultiWindowGame.cs (100%) rename {CompressedTextures => Examples}/CompressedTexturesGame.cs (100%) rename {ComputeUniforms => Examples}/ComputeUniformsGame.cs (100%) rename {CopyTexture => Examples}/CopyTextureGame.cs (100%) rename {Cube => Examples}/CubeGame.cs (100%) rename {CullFace => Examples}/CullFaceGame.cs (100%) rename {DepthMSAA => Examples}/DepthMSAAGame.cs (100%) rename {DrawIndirect => Examples}/DrawIndirectGame.cs (100%) create mode 100644 Examples/Example.cs rename {GetBufferData => Examples}/GetBufferDataGame.cs (100%) rename {InstancingAndOffsets => Examples}/InstancingAndOffsetsGame.cs (100%) rename {MSAACube => Examples}/MSAACubeGame.cs (100%) rename {MSAA => Examples}/MSAAGame.cs (100%) rename {RenderTexture2DArray => Examples}/RenderTexture2DArrayGame.cs (100%) rename {RenderTexture2D => Examples}/RenderTexture2DGame.cs (100%) rename {RenderTextureCube => Examples}/RenderTextureCubeGame.cs (100%) rename {RenderTextureMipmaps => Examples}/RenderTextureMipmapsGame.cs (100%) rename {StoreLoad => Examples}/StoreLoadGame.cs (100%) rename {Texture3DCopy => Examples}/Texture3DCopy.cs (100%) rename {Texture3D => Examples}/Texture3DGame.cs (100%) rename {TextureMipmaps => Examples}/TextureMipmapsGame.cs (100%) rename {TexturedAnimatedQuad => Examples}/TexturedAnimatedQuadGame.cs (100%) rename {TexturedQuad => Examples}/TexturedQuadGame.cs (100%) rename {TriangleVertexBuffer => Examples}/TriangleVertexBufferGame.cs (100%) rename {VertexSampler => Examples}/VertexSamplerGame.cs (100%) rename {VideoPlayer => Examples}/VideoPlayerGame.cs (100%) rename {WindowResizing => Examples}/WindowResizingGame.cs (100%) delete mode 100644 GetBufferData/GetBufferData.csproj delete mode 100644 InstancingAndOffsets/InstancingAndOffsets.csproj delete mode 100644 MSAA/MSAA.csproj delete mode 100644 MSAACube/MSAACube.csproj delete mode 100644 MoonWorks.Test.Common/MoonWorks.Test.Common.csproj delete mode 100644 MoonWorks.Test.Common/TestUtils.cs delete mode 100644 MoonWorks.Test.Common/UniformTypes.cs delete mode 100644 MoonWorks.Test.Common/VertexTypes.cs create mode 100644 MoonWorksGraphicsTests.csproj create mode 100644 Program.cs delete mode 100644 RenderTexture2D/RenderTexture2D.csproj delete mode 100644 RenderTexture2DArray/RenderTexture2DArray.csproj delete mode 100644 RenderTextureCube/RenderTextureCube.csproj delete mode 100644 RenderTextureMipmaps/RenderTextureMipmaps.csproj delete mode 100644 StoreLoad/StoreLoad.csproj delete mode 100644 Texture3D/Texture3D.csproj delete mode 100644 Texture3DCopy/Texture3DCopy.csproj delete mode 100644 TextureMipmaps/TextureMipmaps.csproj delete mode 100644 TexturedAnimatedQuad/TexturedAnimatedQuad.csproj delete mode 100644 TexturedQuad/TexturedQuad.csproj delete mode 100644 TriangleVertexBuffer/TriangleVertexBuffer.csproj delete mode 100644 VertexSampler/VertexSampler.csproj delete mode 100644 VideoPlayer/VideoPlayer.csproj delete mode 100644 WindowResizing/WindowResizing.csproj diff --git a/BasicCompute/BasicCompute.csproj b/BasicCompute/BasicCompute.csproj deleted file mode 100644 index a7937ba..0000000 --- a/BasicCompute/BasicCompute.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/BasicCompute/BasicComputeGame.cs b/BasicCompute/BasicComputeGame.cs deleted file mode 100644 index 568ee29..0000000 --- a/BasicCompute/BasicComputeGame.cs +++ /dev/null @@ -1,153 +0,0 @@ -using MoonWorks; -using MoonWorks.Graphics; -using MoonWorks.Math.Float; - -namespace MoonWorks.Test -{ - class BasicComputeGame : Game - { - private GraphicsPipeline drawPipeline; - private Texture texture; - private Sampler sampler; - private GpuBuffer vertexBuffer; - - public BasicComputeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), TestUtils.PreferredBackends, 60, true) - { - // Create the compute pipeline that writes texture data - ShaderModule fillTextureComputeShaderModule = new ShaderModule( - GraphicsDevice, - TestUtils.GetShaderPath("FillTexture.comp") - ); - - ComputePipeline fillTextureComputePipeline = new ComputePipeline( - GraphicsDevice, - ComputeShaderInfo.Create(fillTextureComputeShaderModule, "main", 0, 1) - ); - - // Create the compute pipeline that calculates squares of numbers - ShaderModule calculateSquaresComputeShaderModule = new ShaderModule( - GraphicsDevice, - TestUtils.GetShaderPath("CalculateSquares.comp") - ); - - ComputePipeline calculateSquaresComputePipeline = new ComputePipeline( - GraphicsDevice, - ComputeShaderInfo.Create(calculateSquaresComputeShaderModule, "main", 1, 0) - ); - - // Create the graphics pipeline - ShaderModule vertShaderModule = new ShaderModule( - GraphicsDevice, - TestUtils.GetShaderPath("TexturedQuad.vert") - ); - - ShaderModule fragShaderModule = new ShaderModule( - GraphicsDevice, - TestUtils.GetShaderPath("TexturedQuad.frag") - ); - - GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo( - MainWindow.SwapchainFormat, - vertShaderModule, - fragShaderModule - ); - drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding(); - drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1; - - drawPipeline = new GraphicsPipeline( - GraphicsDevice, - drawPipelineCreateInfo - ); - - // Create buffers and textures - uint[] squares = new uint[64]; - GpuBuffer squaresBuffer = GpuBuffer.Create( - GraphicsDevice, - BufferUsageFlags.Compute, - (uint) squares.Length - ); - - TransferBuffer transferBuffer = new TransferBuffer( - GraphicsDevice, - TransferUsage.Buffer, - squaresBuffer.Size - ); - - texture = Texture.CreateTexture2D( - GraphicsDevice, - MainWindow.Width, - MainWindow.Height, - TextureFormat.R8G8B8A8, - TextureUsageFlags.Compute | TextureUsageFlags.Sampler - ); - - sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo()); - - // Upload GPU resources and dispatch compute work - var resourceUploader = new ResourceUploader(GraphicsDevice); - vertexBuffer = resourceUploader.CreateBuffer( - [ - 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, 0)), - new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)), - new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), - ], - BufferUsageFlags.Vertex - ); - - resourceUploader.Upload(); - resourceUploader.Dispose(); - - CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); - - cmdbuf.BeginComputePass(); - - // This should result in a bright yellow texture! - cmdbuf.BindComputePipeline(fillTextureComputePipeline); - cmdbuf.BindComputeTextures(new ComputeTextureBinding(texture, WriteOptions.Unsafe)); - cmdbuf.DispatchCompute(texture.Width / 8, texture.Height / 8, 1); - - // This calculates the squares of the first N integers! - cmdbuf.BindComputePipeline(calculateSquaresComputePipeline); - cmdbuf.BindComputeBuffers(new ComputeBufferBinding(squaresBuffer, WriteOptions.Unsafe)); - cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1); - - cmdbuf.EndComputePass(); - - var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf); - GraphicsDevice.WaitForFences(fence); - GraphicsDevice.ReleaseFence(fence); - - // Print the squares! - GraphicsDevice.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Unsafe); - transferBuffer.GetData(squares, 0); - Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares)); - } - - 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(backbuffer, WriteOptions.Cycle, Color.CornflowerBlue)); - cmdbuf.BindGraphicsPipeline(drawPipeline); - cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler)); - cmdbuf.BindVertexBuffers(vertexBuffer); - cmdbuf.DrawPrimitives(0, 2); - cmdbuf.EndRenderPass(); - } - GraphicsDevice.Submit(cmdbuf); - } - - public static void Main(string[] args) - { - BasicComputeGame game = new BasicComputeGame(); - game.Run(); - } - } -} diff --git a/BasicStencil/BasicStencil.csproj b/BasicStencil/BasicStencil.csproj deleted file mode 100644 index a7937ba..0000000 --- a/BasicStencil/BasicStencil.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/BasicTriangle/BasicTriangle.csproj b/BasicTriangle/BasicTriangle.csproj deleted file mode 100644 index a7937ba..0000000 --- a/BasicTriangle/BasicTriangle.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/ClearScreen/ClearScreen.csproj b/ClearScreen/ClearScreen.csproj deleted file mode 100644 index a7937ba..0000000 --- a/ClearScreen/ClearScreen.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/ClearScreen_MultiWindow/ClearScreen_MultiWindow.csproj b/ClearScreen_MultiWindow/ClearScreen_MultiWindow.csproj deleted file mode 100644 index a7937ba..0000000 --- a/ClearScreen_MultiWindow/ClearScreen_MultiWindow.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/CalculateSquares.comp.refresh b/Common/Content/Shaders/Compiled/CalculateSquares.comp.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/CalculateSquares.comp.refresh rename to Common/Content/Shaders/Compiled/CalculateSquares.comp.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/FillTexture.comp.refresh b/Common/Content/Shaders/Compiled/FillTexture.comp.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/FillTexture.comp.refresh rename to Common/Content/Shaders/Compiled/FillTexture.comp.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/GradientTexture.comp.refresh b/Common/Content/Shaders/Compiled/GradientTexture.comp.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/GradientTexture.comp.refresh rename to Common/Content/Shaders/Compiled/GradientTexture.comp.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColor.vert.refresh b/Common/Content/Shaders/Compiled/PositionColor.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColor.vert.refresh rename to Common/Content/Shaders/Compiled/PositionColor.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColorInstanced.vert.refresh b/Common/Content/Shaders/Compiled/PositionColorInstanced.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColorInstanced.vert.refresh rename to Common/Content/Shaders/Compiled/PositionColorInstanced.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColorWithMatrix.vert.refresh b/Common/Content/Shaders/Compiled/PositionColorWithMatrix.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/PositionColorWithMatrix.vert.refresh rename to Common/Content/Shaders/Compiled/PositionColorWithMatrix.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/PositionSampler.vert.refresh b/Common/Content/Shaders/Compiled/PositionSampler.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/PositionSampler.vert.refresh rename to Common/Content/Shaders/Compiled/PositionSampler.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/RawTriangle.vert.refresh b/Common/Content/Shaders/Compiled/RawTriangle.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/RawTriangle.vert.refresh rename to Common/Content/Shaders/Compiled/RawTriangle.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/Skybox.frag.refresh b/Common/Content/Shaders/Compiled/Skybox.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/Skybox.frag.refresh rename to Common/Content/Shaders/Compiled/Skybox.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/Skybox.vert.refresh b/Common/Content/Shaders/Compiled/Skybox.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/Skybox.vert.refresh rename to Common/Content/Shaders/Compiled/Skybox.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/SolidColor.frag.refresh b/Common/Content/Shaders/Compiled/SolidColor.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/SolidColor.frag.refresh rename to Common/Content/Shaders/Compiled/SolidColor.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedDepthQuad.frag.refresh b/Common/Content/Shaders/Compiled/TexturedDepthQuad.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedDepthQuad.frag.refresh rename to Common/Content/Shaders/Compiled/TexturedDepthQuad.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad.frag.refresh b/Common/Content/Shaders/Compiled/TexturedQuad.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad.frag.refresh rename to Common/Content/Shaders/Compiled/TexturedQuad.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad.vert.refresh b/Common/Content/Shaders/Compiled/TexturedQuad.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad.vert.refresh rename to Common/Content/Shaders/Compiled/TexturedQuad.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad2DArray.frag.refresh b/Common/Content/Shaders/Compiled/TexturedQuad2DArray.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad2DArray.frag.refresh rename to Common/Content/Shaders/Compiled/TexturedQuad2DArray.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad3D.frag.refresh b/Common/Content/Shaders/Compiled/TexturedQuad3D.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuad3D.frag.refresh rename to Common/Content/Shaders/Compiled/TexturedQuad3D.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuadWithMatrix.vert.refresh b/Common/Content/Shaders/Compiled/TexturedQuadWithMatrix.vert.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuadWithMatrix.vert.refresh rename to Common/Content/Shaders/Compiled/TexturedQuadWithMatrix.vert.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuadWithMultiplyColor.frag.refresh b/Common/Content/Shaders/Compiled/TexturedQuadWithMultiplyColor.frag.refresh similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Compiled/TexturedQuadWithMultiplyColor.frag.refresh rename to Common/Content/Shaders/Compiled/TexturedQuadWithMultiplyColor.frag.refresh diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/CalculateSquares.comp b/Common/Content/Shaders/Source/CalculateSquares.comp similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/CalculateSquares.comp rename to Common/Content/Shaders/Source/CalculateSquares.comp diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/FillTexture.comp b/Common/Content/Shaders/Source/FillTexture.comp similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/FillTexture.comp rename to Common/Content/Shaders/Source/FillTexture.comp diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/GradientTexture.comp b/Common/Content/Shaders/Source/GradientTexture.comp similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/GradientTexture.comp rename to Common/Content/Shaders/Source/GradientTexture.comp diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/PositionColor.vert b/Common/Content/Shaders/Source/PositionColor.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/PositionColor.vert rename to Common/Content/Shaders/Source/PositionColor.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/PositionColorInstanced.vert b/Common/Content/Shaders/Source/PositionColorInstanced.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/PositionColorInstanced.vert rename to Common/Content/Shaders/Source/PositionColorInstanced.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/PositionColorWithMatrix.vert b/Common/Content/Shaders/Source/PositionColorWithMatrix.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/PositionColorWithMatrix.vert rename to Common/Content/Shaders/Source/PositionColorWithMatrix.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/PositionSampler.vert b/Common/Content/Shaders/Source/PositionSampler.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/PositionSampler.vert rename to Common/Content/Shaders/Source/PositionSampler.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/RawTriangle.vert b/Common/Content/Shaders/Source/RawTriangle.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/RawTriangle.vert rename to Common/Content/Shaders/Source/RawTriangle.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/Skybox.frag b/Common/Content/Shaders/Source/Skybox.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/Skybox.frag rename to Common/Content/Shaders/Source/Skybox.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/Skybox.vert b/Common/Content/Shaders/Source/Skybox.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/Skybox.vert rename to Common/Content/Shaders/Source/Skybox.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/SolidColor.frag b/Common/Content/Shaders/Source/SolidColor.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/SolidColor.frag rename to Common/Content/Shaders/Source/SolidColor.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedDepthQuad.frag b/Common/Content/Shaders/Source/TexturedDepthQuad.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedDepthQuad.frag rename to Common/Content/Shaders/Source/TexturedDepthQuad.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad.frag b/Common/Content/Shaders/Source/TexturedQuad.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad.frag rename to Common/Content/Shaders/Source/TexturedQuad.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad.vert b/Common/Content/Shaders/Source/TexturedQuad.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad.vert rename to Common/Content/Shaders/Source/TexturedQuad.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad2DArray.frag b/Common/Content/Shaders/Source/TexturedQuad2DArray.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad2DArray.frag rename to Common/Content/Shaders/Source/TexturedQuad2DArray.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad3D.frag b/Common/Content/Shaders/Source/TexturedQuad3D.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuad3D.frag rename to Common/Content/Shaders/Source/TexturedQuad3D.frag diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuadWithMatrix.vert b/Common/Content/Shaders/Source/TexturedQuadWithMatrix.vert similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuadWithMatrix.vert rename to Common/Content/Shaders/Source/TexturedQuadWithMatrix.vert diff --git a/MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuadWithMultiplyColor.frag b/Common/Content/Shaders/Source/TexturedQuadWithMultiplyColor.frag similarity index 100% rename from MoonWorks.Test.Common/Content/Shaders/Source/TexturedQuadWithMultiplyColor.frag rename to Common/Content/Shaders/Source/TexturedQuadWithMultiplyColor.frag diff --git a/MoonWorks.Test.Common/Content/Textures/BC1.dds b/Common/Content/Textures/BC1.dds similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/BC1.dds rename to Common/Content/Textures/BC1.dds diff --git a/MoonWorks.Test.Common/Content/Textures/BC2.dds b/Common/Content/Textures/BC2.dds similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/BC2.dds rename to Common/Content/Textures/BC2.dds diff --git a/MoonWorks.Test.Common/Content/Textures/BC3.dds b/Common/Content/Textures/BC3.dds similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/BC3.dds rename to Common/Content/Textures/BC3.dds diff --git a/MoonWorks.Test.Common/Content/Textures/BC7.dds b/Common/Content/Textures/BC7.dds similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/BC7.dds rename to Common/Content/Textures/BC7.dds diff --git a/MoonWorks.Test.Common/Content/Textures/back.png b/Common/Content/Textures/back.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/back.png rename to Common/Content/Textures/back.png diff --git a/MoonWorks.Test.Common/Content/Textures/bottom.png b/Common/Content/Textures/bottom.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/bottom.png rename to Common/Content/Textures/bottom.png diff --git a/MoonWorks.Test.Common/Content/Textures/front.png b/Common/Content/Textures/front.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/front.png rename to Common/Content/Textures/front.png diff --git a/MoonWorks.Test.Common/Content/Textures/left.png b/Common/Content/Textures/left.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/left.png rename to Common/Content/Textures/left.png diff --git a/MoonWorks.Test.Common/Content/Textures/mip0.png b/Common/Content/Textures/mip0.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/mip0.png rename to Common/Content/Textures/mip0.png diff --git a/MoonWorks.Test.Common/Content/Textures/mip1.png b/Common/Content/Textures/mip1.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/mip1.png rename to Common/Content/Textures/mip1.png diff --git a/MoonWorks.Test.Common/Content/Textures/mip2.png b/Common/Content/Textures/mip2.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/mip2.png rename to Common/Content/Textures/mip2.png diff --git a/MoonWorks.Test.Common/Content/Textures/mip3.png b/Common/Content/Textures/mip3.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/mip3.png rename to Common/Content/Textures/mip3.png diff --git a/MoonWorks.Test.Common/Content/Textures/ravioli.png b/Common/Content/Textures/ravioli.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/ravioli.png rename to Common/Content/Textures/ravioli.png diff --git a/MoonWorks.Test.Common/Content/Textures/ravioli.qoi b/Common/Content/Textures/ravioli.qoi similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/ravioli.qoi rename to Common/Content/Textures/ravioli.qoi diff --git a/MoonWorks.Test.Common/Content/Textures/right.png b/Common/Content/Textures/right.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/right.png rename to Common/Content/Textures/right.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_0.png b/Common/Content/Textures/tex3d_0.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_0.png rename to Common/Content/Textures/tex3d_0.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_1.png b/Common/Content/Textures/tex3d_1.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_1.png rename to Common/Content/Textures/tex3d_1.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_2.png b/Common/Content/Textures/tex3d_2.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_2.png rename to Common/Content/Textures/tex3d_2.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_3.png b/Common/Content/Textures/tex3d_3.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_3.png rename to Common/Content/Textures/tex3d_3.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_4.png b/Common/Content/Textures/tex3d_4.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_4.png rename to Common/Content/Textures/tex3d_4.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_5.png b/Common/Content/Textures/tex3d_5.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_5.png rename to Common/Content/Textures/tex3d_5.png diff --git a/MoonWorks.Test.Common/Content/Textures/tex3d_6.png b/Common/Content/Textures/tex3d_6.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/tex3d_6.png rename to Common/Content/Textures/tex3d_6.png diff --git a/MoonWorks.Test.Common/Content/Textures/top.png b/Common/Content/Textures/top.png similarity index 100% rename from MoonWorks.Test.Common/Content/Textures/top.png rename to Common/Content/Textures/top.png diff --git a/MoonWorks.Test.Common/Content/Videos/hello.obu b/Common/Content/Videos/hello.obu similarity index 100% rename from MoonWorks.Test.Common/Content/Videos/hello.obu rename to Common/Content/Videos/hello.obu diff --git a/Common/TestUtils.cs b/Common/TestUtils.cs new file mode 100644 index 0000000..bd378e3 --- /dev/null +++ b/Common/TestUtils.cs @@ -0,0 +1,136 @@ +using MoonWorks; +using MoonWorks.Graphics; + +namespace MoonWorksGraphicsTests; + +public static class TestUtils +{ + // change this to test different backends + public static BackendFlags PreferredBackends = BackendFlags.Vulkan | BackendFlags.D3D11 | BackendFlags.Metal; + + public static WindowCreateInfo GetStandardWindowCreateInfo() + { + return new WindowCreateInfo( + "Main Window", + 640, + 480, + ScreenMode.Windowed, + SwapchainComposition.SDR, + PresentMode.VSync + ); + } + + public static FrameLimiterSettings GetStandardFrameLimiterSettings() + { + return new FrameLimiterSettings( + FrameLimiterMode.Capped, + 60 + ); + } + + public static GraphicsPipelineCreateInfo GetStandardGraphicsPipelineCreateInfo( + TextureFormat swapchainFormat, + Shader vertShader, + Shader fragShader + ) { + return new GraphicsPipelineCreateInfo + { + AttachmentInfo = new GraphicsPipelineAttachmentInfo( + new ColorAttachmentDescription( + swapchainFormat, + ColorAttachmentBlendState.Opaque + ) + ), + DepthStencilState = DepthStencilState.Disable, + MultisampleState = MultisampleState.None, + PrimitiveType = PrimitiveType.TriangleList, + RasterizerState = RasterizerState.CCW_CullNone, + VertexInputState = VertexInputState.Empty, + VertexShader = vertShader, + FragmentShader = fragShader + }; + } + + public static string GetShaderPath(string shaderName) + { + return SDL2.SDL.SDL_GetBasePath() + "Content/Shaders/Compiled/" + shaderName + ".refresh"; + } + + public static string GetTexturePath(string textureName) + { + return SDL2.SDL.SDL_GetBasePath() + "Content/Textures/" + textureName; + } + + public static string GetVideoPath(string videoName) + { + return SDL2.SDL.SDL_GetBasePath() + "Content/Videos/" + videoName; + } + + public enum ButtonType + { + Left, // A/left arrow on keyboard, left face button on gamepad + Bottom, // S/down arrow on keyboard, bottom face button on gamepad + Right // D/right arrow on keyboard, right face button on gamepad + } + + public static bool CheckButtonPressed(Input.Inputs inputs, ButtonType buttonType) + { + bool pressed = false; + + if (buttonType == ButtonType.Left) + { + pressed = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsPressed) || + inputs.Keyboard.IsPressed(Input.KeyCode.Left) + ); + } + else if (buttonType == ButtonType.Bottom) + { + pressed = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsPressed) || + inputs.Keyboard.IsPressed(Input.KeyCode.Down) + ); + } + else if (buttonType == ButtonType.Right) + { + pressed = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsPressed) || + inputs.Keyboard.IsPressed(Input.KeyCode.Right) + ); + } + + return pressed; + } + + public static bool CheckButtonDown(Input.Inputs inputs, ButtonType buttonType) + { + bool down = false; + + if (buttonType == ButtonType.Left) + { + down = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsDown) || + inputs.Keyboard.IsDown(Input.KeyCode.A) || + inputs.Keyboard.IsDown(Input.KeyCode.Left) + ); + } + else if (buttonType == ButtonType.Bottom) + { + down = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsDown) || + inputs.Keyboard.IsDown(Input.KeyCode.S) || + inputs.Keyboard.IsDown(Input.KeyCode.Down) + ); + } + else if (buttonType == ButtonType.Right) + { + down = ( + (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsDown) || + inputs.Keyboard.IsDown(Input.KeyCode.D) || + inputs.Keyboard.IsDown(Input.KeyCode.Right) + ); + } + + return down; + } +} diff --git a/Common/UniformTypes.cs b/Common/UniformTypes.cs new file mode 100644 index 0000000..882fe3a --- /dev/null +++ b/Common/UniformTypes.cs @@ -0,0 +1,13 @@ +using MoonWorks.Math.Float; + +namespace MoonWorksGraphicsTests; + +public struct TransformVertexUniform +{ + public Matrix4x4 ViewProjection; + + public TransformVertexUniform(Matrix4x4 viewProjection) + { + ViewProjection = viewProjection; + } +} diff --git a/Common/VertexTypes.cs b/Common/VertexTypes.cs new file mode 100644 index 0000000..cbd8eb7 --- /dev/null +++ b/Common/VertexTypes.cs @@ -0,0 +1,74 @@ +using System.Runtime.InteropServices; +using MoonWorks.Graphics; +using MoonWorks.Math.Float; + +namespace MoonWorksGraphicsTests; + +[StructLayout(LayoutKind.Sequential)] +public struct PositionVertex : IVertexType +{ + public Vector3 Position; + + public PositionVertex(Vector3 position) + { + Position = position; + } + + public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[1] + { + VertexElementFormat.Vector3 + }; + + public override string ToString() + { + return Position.ToString(); + } +} + +[StructLayout(LayoutKind.Sequential)] +public struct PositionColorVertex : IVertexType +{ + public Vector3 Position; + public Color Color; + + public PositionColorVertex(Vector3 position, Color color) + { + Position = position; + Color = color; + } + + public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2] + { + VertexElementFormat.Vector3, + VertexElementFormat.Color + }; + + public override string ToString() + { + return Position + " | " + Color; + } +} + +[StructLayout(LayoutKind.Sequential)] +public struct PositionTextureVertex : IVertexType +{ + public Vector3 Position; + public Vector2 TexCoord; + + public PositionTextureVertex(Vector3 position, Vector2 texCoord) + { + Position = position; + TexCoord = texCoord; + } + + public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2] + { + VertexElementFormat.Vector3, + VertexElementFormat.Vector2 + }; + + public override string ToString() + { + return Position + " | " + TexCoord; + } +} diff --git a/CompressedTextures/CompressedTextures.csproj b/CompressedTextures/CompressedTextures.csproj deleted file mode 100644 index a7937ba..0000000 --- a/CompressedTextures/CompressedTextures.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/ComputeUniforms/ComputeUniforms.csproj b/ComputeUniforms/ComputeUniforms.csproj deleted file mode 100644 index a7937ba..0000000 --- a/ComputeUniforms/ComputeUniforms.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/MoonWorks.Test.Common/CopyMoonlibs.targets b/CopyMoonlibs.targets similarity index 100% rename from MoonWorks.Test.Common/CopyMoonlibs.targets rename to CopyMoonlibs.targets diff --git a/CopyTexture/CopyTexture.csproj b/CopyTexture/CopyTexture.csproj deleted file mode 100644 index c6860a7..0000000 --- a/CopyTexture/CopyTexture.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - true - - - - - diff --git a/Cube/Cube.csproj b/Cube/Cube.csproj deleted file mode 100644 index a809634..0000000 --- a/Cube/Cube.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - true - - - - - diff --git a/CullFace/CullFace.csproj b/CullFace/CullFace.csproj deleted file mode 100644 index a7937ba..0000000 --- a/CullFace/CullFace.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/DepthMSAA/DepthMSAA.csproj b/DepthMSAA/DepthMSAA.csproj deleted file mode 100644 index a7937ba..0000000 --- a/DepthMSAA/DepthMSAA.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/DrawIndirect/DrawIndirect.csproj b/DrawIndirect/DrawIndirect.csproj deleted file mode 100644 index a7937ba..0000000 --- a/DrawIndirect/DrawIndirect.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/Examples/BasicComputeGame.cs b/Examples/BasicComputeGame.cs new file mode 100644 index 0000000..a4c204b --- /dev/null +++ b/Examples/BasicComputeGame.cs @@ -0,0 +1,191 @@ +using MoonWorks; +using MoonWorks.Graphics; +using MoonWorks.Math.Float; + +namespace MoonWorksGraphicsTests; + +class BasicComputeExample : Example +{ + private GraphicsPipeline DrawPipeline; + private Texture Texture; + private Sampler Sampler; + private GpuBuffer VertexBuffer; + + public override void Init(Window window, GraphicsDevice graphicsDevice) + { + Window = window; + GraphicsDevice = graphicsDevice; + + // Create the compute pipeline that writes texture data + Shader fillTextureComputeShader = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("FillTexture.comp"), + "main", + ShaderStage.Compute, + ShaderFormat.SPIRV + ); + + ComputePipeline fillTextureComputePipeline = new ComputePipeline( + GraphicsDevice, + fillTextureComputeShader, + new ComputePipelineResourceInfo { ReadWriteStorageTextureCount = 1 } + ); + + fillTextureComputeShader.Dispose(); + + // Create the compute pipeline that calculates squares of numbers + Shader calculateSquaresComputeShader = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("CalculateSquares.comp"), + "main", + ShaderStage.Compute, + ShaderFormat.SPIRV + ); + + ComputePipeline calculateSquaresComputePipeline = new ComputePipeline( + GraphicsDevice, + calculateSquaresComputeShader, + new ComputePipelineResourceInfo { ReadWriteStorageBufferCount = 1 } + ); + + calculateSquaresComputeShader.Dispose(); + + // Create the graphics pipeline + Shader vertShaderModule = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("TexturedQuad.vert"), + "main", + ShaderStage.Vertex, + ShaderFormat.SPIRV + ); + + Shader fragShaderModule = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("TexturedQuad.frag"), + "main", + ShaderStage.Fragment, + ShaderFormat.SPIRV + ); + + GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo( + Window.SwapchainFormat, + vertShaderModule, + fragShaderModule + ); + drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding(); + drawPipelineCreateInfo.FragmentShaderResourceInfo.SamplerCount = 1; + + DrawPipeline = new GraphicsPipeline( + GraphicsDevice, + drawPipelineCreateInfo + ); + + // Create buffers and textures + uint[] squares = new uint[64]; + GpuBuffer squaresBuffer = GpuBuffer.Create( + GraphicsDevice, + BufferUsageFlags.ComputeStorageWrite, + (uint) squares.Length + ); + + TransferBuffer transferBuffer = new TransferBuffer( + GraphicsDevice, + TransferUsage.Buffer, + TransferBufferMapFlags.Read, + squaresBuffer.Size + ); + + Texture = Texture.CreateTexture2D( + GraphicsDevice, + Window.Width, + Window.Height, + TextureFormat.R8G8B8A8, + TextureUsageFlags.ComputeStorageWrite | TextureUsageFlags.Sampler + ); + + Sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo()); + + // Upload GPU resources and dispatch compute work + var resourceUploader = new ResourceUploader(GraphicsDevice); + VertexBuffer = resourceUploader.CreateBuffer( + [ + 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, 0)), + new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)), + new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), + ], + BufferUsageFlags.Vertex + ); + + resourceUploader.Upload(); + resourceUploader.Dispose(); + + CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); + + // This should result in a bright yellow texture! + var computePass = cmdbuf.BeginComputePass(new StorageTextureReadWriteBinding + { + TextureSlice = Texture, + Cycle = false + }); + + computePass.BindComputePipeline(fillTextureComputePipeline); + computePass.Dispatch(Texture.Width / 8, Texture.Height / 8, 1); + + cmdbuf.EndComputePass(computePass); + + // This calculates the squares of the first N integers! + computePass = cmdbuf.BeginComputePass(new StorageBufferReadWriteBinding + { + Buffer = squaresBuffer, + Cycle = false + }); + + computePass.BindComputePipeline(calculateSquaresComputePipeline); + computePass.Dispatch((uint) squares.Length / 8, 1, 1); + + cmdbuf.EndComputePass(computePass); + + var copyPass = cmdbuf.BeginCopyPass(); + + copyPass.DownloadFromBuffer(squaresBuffer, transferBuffer, new BufferCopy(0, 0, squaresBuffer.Size)); + + cmdbuf.EndCopyPass(copyPass); + + var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf); + GraphicsDevice.WaitForFences(fence); + GraphicsDevice.ReleaseFence(fence); + + // Print the squares! + transferBuffer.GetData(squares, 0); + Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares)); + } + + public override void Update(System.TimeSpan delta) { } + + public override void Draw(double alpha) + { + CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); + Texture swapchainTexture = cmdbuf.AcquireSwapchainTexture(Window); + if (swapchainTexture != null) + { + var renderPass = cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, false, Color.CornflowerBlue)); + renderPass.BindGraphicsPipeline(DrawPipeline); + renderPass.BindFragmentSampler(new TextureSamplerBinding(Texture, Sampler)); + renderPass.BindVertexBuffer(VertexBuffer); + renderPass.DrawPrimitives(0, 2); + cmdbuf.EndRenderPass(renderPass); + } + GraphicsDevice.Submit(cmdbuf); + } + + public override void Destroy() + { + DrawPipeline.Dispose(); + Texture.Dispose(); + Sampler.Dispose(); + VertexBuffer.Dispose(); + } +} diff --git a/BasicStencil/BasicStencilGame.cs b/Examples/BasicStencilGame.cs similarity index 59% rename from BasicStencil/BasicStencilGame.cs rename to Examples/BasicStencilGame.cs index de6cb29..0fdbdf0 100644 --- a/BasicStencil/BasicStencilGame.cs +++ b/Examples/BasicStencilGame.cs @@ -2,29 +2,44 @@ using MoonWorks.Graphics; using MoonWorks.Math.Float; -namespace MoonWorks.Test +namespace MoonWorksGraphicsTests { - class BasicStencilGame : Game + class BasicStencilGame : Example { private GraphicsPipeline maskerPipeline; private GraphicsPipeline maskeePipeline; private GpuBuffer vertexBuffer; private Texture depthStencilTexture; - public BasicStencilGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), TestUtils.PreferredBackends, 60, true) + public override void Init(Window window, GraphicsDevice graphicsDevice) { + Window = window; + GraphicsDevice = graphicsDevice; + // Load the shaders - ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColor.vert")); - ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag")); + Shader vertShaderModule = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("PositionColor.vert"), + "main", + ShaderStage.Vertex, + ShaderFormat.SPIRV + ); + Shader fragShaderModule = new Shader( + GraphicsDevice, + TestUtils.GetShaderPath("SolidColor.frag"), + "main", + ShaderStage.Fragment, + ShaderFormat.SPIRV + ); // Create the graphics pipelines GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo( - MainWindow.SwapchainFormat, + Window.SwapchainFormat, vertShaderModule, fragShaderModule ); pipelineCreateInfo.AttachmentInfo.HasDepthStencilAttachment = true; - pipelineCreateInfo.AttachmentInfo.DepthStencilFormat = TextureFormat.D16S8; + pipelineCreateInfo.AttachmentInfo.DepthStencilFormat = TextureFormat.D24_UNORM_S8_UINT; pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding(); pipelineCreateInfo.DepthStencilState = new DepthStencilState { @@ -55,10 +70,10 @@ namespace MoonWorks.Test // Create and populate the GPU resources depthStencilTexture = Texture.CreateTexture2D( GraphicsDevice, - MainWindow.Width, - MainWindow.Height, - TextureFormat.D16S8, - TextureUsageFlags.DepthStencilTarget + Window.Width, + Window.Height, + TextureFormat.D24_UNORM_S8_UINT, + TextureUsageFlags.DepthStencil ); var resourceUploader = new ResourceUploader(GraphicsDevice); @@ -80,32 +95,31 @@ namespace MoonWorks.Test resourceUploader.Dispose(); } - protected override void Update(System.TimeSpan delta) { } + public override void Update(System.TimeSpan delta) { } - protected override void Draw(double alpha) + public override void Draw(double alpha) { CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); - Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow); - if (backbuffer != null) + Texture swapchainTexture = cmdbuf.AcquireSwapchainTexture(Window); + if (swapchainTexture != null) { - cmdbuf.BeginRenderPass( - new DepthStencilAttachmentInfo(depthStencilTexture, WriteOptions.Cycle, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare), - new ColorAttachmentInfo(backbuffer, WriteOptions.Cycle, Color.Black) + var renderPass = cmdbuf.BeginRenderPass( + new DepthStencilAttachmentInfo(depthStencilTexture, true, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare), + new ColorAttachmentInfo(swapchainTexture, false, Color.Black) ); - cmdbuf.BindGraphicsPipeline(maskerPipeline); - cmdbuf.BindVertexBuffers(vertexBuffer); - cmdbuf.DrawPrimitives(0, 1); - cmdbuf.BindGraphicsPipeline(maskeePipeline); - cmdbuf.DrawPrimitives(3, 1); - cmdbuf.EndRenderPass(); + renderPass.BindGraphicsPipeline(maskerPipeline); + renderPass.BindVertexBuffer(vertexBuffer); + renderPass.DrawPrimitives(0, 1); + renderPass.BindGraphicsPipeline(maskeePipeline); + renderPass.DrawPrimitives(3, 1); + cmdbuf.EndRenderPass(renderPass); } GraphicsDevice.Submit(cmdbuf); } - public static void Main(string[] args) - { - BasicStencilGame p = new BasicStencilGame(); - p.Run(); - } - } + public override void Destroy() + { + throw new System.NotImplementedException(); + } + } } diff --git a/BasicTriangle/BasicTriangleGame.cs b/Examples/BasicTriangleGame.cs similarity index 100% rename from BasicTriangle/BasicTriangleGame.cs rename to Examples/BasicTriangleGame.cs diff --git a/ClearScreen/ClearScreenGame.cs b/Examples/ClearScreenGame.cs similarity index 100% rename from ClearScreen/ClearScreenGame.cs rename to Examples/ClearScreenGame.cs diff --git a/ClearScreen_MultiWindow/ClearScreen_MultiWindowGame.cs b/Examples/ClearScreen_MultiWindowGame.cs similarity index 100% rename from ClearScreen_MultiWindow/ClearScreen_MultiWindowGame.cs rename to Examples/ClearScreen_MultiWindowGame.cs diff --git a/CompressedTextures/CompressedTexturesGame.cs b/Examples/CompressedTexturesGame.cs similarity index 100% rename from CompressedTextures/CompressedTexturesGame.cs rename to Examples/CompressedTexturesGame.cs diff --git a/ComputeUniforms/ComputeUniformsGame.cs b/Examples/ComputeUniformsGame.cs similarity index 100% rename from ComputeUniforms/ComputeUniformsGame.cs rename to Examples/ComputeUniformsGame.cs diff --git a/CopyTexture/CopyTextureGame.cs b/Examples/CopyTextureGame.cs similarity index 100% rename from CopyTexture/CopyTextureGame.cs rename to Examples/CopyTextureGame.cs diff --git a/Cube/CubeGame.cs b/Examples/CubeGame.cs similarity index 100% rename from Cube/CubeGame.cs rename to Examples/CubeGame.cs diff --git a/CullFace/CullFaceGame.cs b/Examples/CullFaceGame.cs similarity index 100% rename from CullFace/CullFaceGame.cs rename to Examples/CullFaceGame.cs diff --git a/DepthMSAA/DepthMSAAGame.cs b/Examples/DepthMSAAGame.cs similarity index 100% rename from DepthMSAA/DepthMSAAGame.cs rename to Examples/DepthMSAAGame.cs diff --git a/DrawIndirect/DrawIndirectGame.cs b/Examples/DrawIndirectGame.cs similarity index 100% rename from DrawIndirect/DrawIndirectGame.cs rename to Examples/DrawIndirectGame.cs diff --git a/Examples/Example.cs b/Examples/Example.cs new file mode 100644 index 0000000..885a2e0 --- /dev/null +++ b/Examples/Example.cs @@ -0,0 +1,16 @@ +using System; +using MoonWorks; +using MoonWorks.Graphics; + +namespace MoonWorksGraphicsTests; + +public abstract class Example +{ + protected Window Window; + protected GraphicsDevice GraphicsDevice; + + public abstract void Init(Window window, GraphicsDevice graphicsDevice); + public abstract void Update(TimeSpan delta); + public abstract void Draw(double alpha); + public abstract void Destroy(); +} diff --git a/GetBufferData/GetBufferDataGame.cs b/Examples/GetBufferDataGame.cs similarity index 100% rename from GetBufferData/GetBufferDataGame.cs rename to Examples/GetBufferDataGame.cs diff --git a/InstancingAndOffsets/InstancingAndOffsetsGame.cs b/Examples/InstancingAndOffsetsGame.cs similarity index 100% rename from InstancingAndOffsets/InstancingAndOffsetsGame.cs rename to Examples/InstancingAndOffsetsGame.cs diff --git a/MSAACube/MSAACubeGame.cs b/Examples/MSAACubeGame.cs similarity index 100% rename from MSAACube/MSAACubeGame.cs rename to Examples/MSAACubeGame.cs diff --git a/MSAA/MSAAGame.cs b/Examples/MSAAGame.cs similarity index 100% rename from MSAA/MSAAGame.cs rename to Examples/MSAAGame.cs diff --git a/RenderTexture2DArray/RenderTexture2DArrayGame.cs b/Examples/RenderTexture2DArrayGame.cs similarity index 100% rename from RenderTexture2DArray/RenderTexture2DArrayGame.cs rename to Examples/RenderTexture2DArrayGame.cs diff --git a/RenderTexture2D/RenderTexture2DGame.cs b/Examples/RenderTexture2DGame.cs similarity index 100% rename from RenderTexture2D/RenderTexture2DGame.cs rename to Examples/RenderTexture2DGame.cs diff --git a/RenderTextureCube/RenderTextureCubeGame.cs b/Examples/RenderTextureCubeGame.cs similarity index 100% rename from RenderTextureCube/RenderTextureCubeGame.cs rename to Examples/RenderTextureCubeGame.cs diff --git a/RenderTextureMipmaps/RenderTextureMipmapsGame.cs b/Examples/RenderTextureMipmapsGame.cs similarity index 100% rename from RenderTextureMipmaps/RenderTextureMipmapsGame.cs rename to Examples/RenderTextureMipmapsGame.cs diff --git a/StoreLoad/StoreLoadGame.cs b/Examples/StoreLoadGame.cs similarity index 100% rename from StoreLoad/StoreLoadGame.cs rename to Examples/StoreLoadGame.cs diff --git a/Texture3DCopy/Texture3DCopy.cs b/Examples/Texture3DCopy.cs similarity index 100% rename from Texture3DCopy/Texture3DCopy.cs rename to Examples/Texture3DCopy.cs diff --git a/Texture3D/Texture3DGame.cs b/Examples/Texture3DGame.cs similarity index 100% rename from Texture3D/Texture3DGame.cs rename to Examples/Texture3DGame.cs diff --git a/TextureMipmaps/TextureMipmapsGame.cs b/Examples/TextureMipmapsGame.cs similarity index 100% rename from TextureMipmaps/TextureMipmapsGame.cs rename to Examples/TextureMipmapsGame.cs diff --git a/TexturedAnimatedQuad/TexturedAnimatedQuadGame.cs b/Examples/TexturedAnimatedQuadGame.cs similarity index 100% rename from TexturedAnimatedQuad/TexturedAnimatedQuadGame.cs rename to Examples/TexturedAnimatedQuadGame.cs diff --git a/TexturedQuad/TexturedQuadGame.cs b/Examples/TexturedQuadGame.cs similarity index 100% rename from TexturedQuad/TexturedQuadGame.cs rename to Examples/TexturedQuadGame.cs diff --git a/TriangleVertexBuffer/TriangleVertexBufferGame.cs b/Examples/TriangleVertexBufferGame.cs similarity index 100% rename from TriangleVertexBuffer/TriangleVertexBufferGame.cs rename to Examples/TriangleVertexBufferGame.cs diff --git a/VertexSampler/VertexSamplerGame.cs b/Examples/VertexSamplerGame.cs similarity index 100% rename from VertexSampler/VertexSamplerGame.cs rename to Examples/VertexSamplerGame.cs diff --git a/VideoPlayer/VideoPlayerGame.cs b/Examples/VideoPlayerGame.cs similarity index 100% rename from VideoPlayer/VideoPlayerGame.cs rename to Examples/VideoPlayerGame.cs diff --git a/WindowResizing/WindowResizingGame.cs b/Examples/WindowResizingGame.cs similarity index 100% rename from WindowResizing/WindowResizingGame.cs rename to Examples/WindowResizingGame.cs diff --git a/GetBufferData/GetBufferData.csproj b/GetBufferData/GetBufferData.csproj deleted file mode 100644 index a7937ba..0000000 --- a/GetBufferData/GetBufferData.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/InstancingAndOffsets/InstancingAndOffsets.csproj b/InstancingAndOffsets/InstancingAndOffsets.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/InstancingAndOffsets/InstancingAndOffsets.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/MSAA/MSAA.csproj b/MSAA/MSAA.csproj deleted file mode 100644 index a7937ba..0000000 --- a/MSAA/MSAA.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/MSAACube/MSAACube.csproj b/MSAACube/MSAACube.csproj deleted file mode 100644 index 7ce1c70..0000000 --- a/MSAACube/MSAACube.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/MoonWorks.Test.Common/MoonWorks.Test.Common.csproj b/MoonWorks.Test.Common/MoonWorks.Test.Common.csproj deleted file mode 100644 index 92b9bef..0000000 --- a/MoonWorks.Test.Common/MoonWorks.Test.Common.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - library - net8.0 - enable - - - - - Content\%(RecursiveDir)%(Filename)%(Extension) - Always - - - - - - diff --git a/MoonWorks.Test.Common/TestUtils.cs b/MoonWorks.Test.Common/TestUtils.cs deleted file mode 100644 index 1aba0d3..0000000 --- a/MoonWorks.Test.Common/TestUtils.cs +++ /dev/null @@ -1,138 +0,0 @@ -using MoonWorks.Graphics; - -namespace MoonWorks.Test -{ - public static class TestUtils - { - // change this to test different backends - public static Backend[] PreferredBackends = [Backend.Vulkan]; - - public static WindowCreateInfo GetStandardWindowCreateInfo() - { - return new WindowCreateInfo( - "Main Window", - 640, - 480, - ScreenMode.Windowed, - PresentMode.FIFO - ); - } - - public static FrameLimiterSettings GetStandardFrameLimiterSettings() - { - return new FrameLimiterSettings( - FrameLimiterMode.Capped, - 60 - ); - } - - public static GraphicsPipelineCreateInfo GetStandardGraphicsPipelineCreateInfo( - TextureFormat swapchainFormat, - ShaderModule vertShaderModule, - ShaderModule fragShaderModule - ) { - return new GraphicsPipelineCreateInfo - { - AttachmentInfo = new GraphicsPipelineAttachmentInfo( - new ColorAttachmentDescription( - swapchainFormat, - ColorAttachmentBlendState.Opaque - ) - ), - DepthStencilState = DepthStencilState.Disable, - MultisampleState = MultisampleState.None, - PrimitiveType = PrimitiveType.TriangleList, - RasterizerState = RasterizerState.CCW_CullNone, - VertexInputState = VertexInputState.Empty, - VertexShaderInfo = GraphicsShaderInfo.Create(vertShaderModule, "main", 0), - FragmentShaderInfo = GraphicsShaderInfo.Create(fragShaderModule, "main", 0) - }; - } - - public static string GetShaderPath(string shaderName) - { - return SDL2.SDL.SDL_GetBasePath() + "Content/Shaders/Compiled/" + shaderName + ".refresh"; - } - - public static string GetTexturePath(string textureName) - { - return SDL2.SDL.SDL_GetBasePath() + "Content/Textures/" + textureName; - } - - public static string GetVideoPath(string videoName) - { - return SDL2.SDL.SDL_GetBasePath() + "Content/Videos/" + videoName; - } - - public enum ButtonType - { - Left, // A/left arrow on keyboard, left face button on gamepad - Bottom, // S/down arrow on keyboard, bottom face button on gamepad - Right // D/right arrow on keyboard, right face button on gamepad - } - - public static bool CheckButtonPressed(Input.Inputs inputs, ButtonType buttonType) - { - bool pressed = false; - - if (buttonType == ButtonType.Left) - { - pressed = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsPressed) || - inputs.Keyboard.IsPressed(Input.KeyCode.A) || - inputs.Keyboard.IsPressed(Input.KeyCode.Left) - ); - } - else if (buttonType == ButtonType.Bottom) - { - pressed = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsPressed) || - inputs.Keyboard.IsPressed(Input.KeyCode.S) || - inputs.Keyboard.IsPressed(Input.KeyCode.Down) - ); - } - else if (buttonType == ButtonType.Right) - { - pressed = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsPressed) || - inputs.Keyboard.IsPressed(Input.KeyCode.D) || - inputs.Keyboard.IsPressed(Input.KeyCode.Right) - ); - } - - return pressed; - } - - public static bool CheckButtonDown(Input.Inputs inputs, ButtonType buttonType) - { - bool down = false; - - if (buttonType == ButtonType.Left) - { - down = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsDown) || - inputs.Keyboard.IsDown(Input.KeyCode.A) || - inputs.Keyboard.IsDown(Input.KeyCode.Left) - ); - } - else if (buttonType == ButtonType.Bottom) - { - down = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsDown) || - inputs.Keyboard.IsDown(Input.KeyCode.S) || - inputs.Keyboard.IsDown(Input.KeyCode.Down) - ); - } - else if (buttonType == ButtonType.Right) - { - down = ( - (inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsDown) || - inputs.Keyboard.IsDown(Input.KeyCode.D) || - inputs.Keyboard.IsDown(Input.KeyCode.Right) - ); - } - - return down; - } - } -} diff --git a/MoonWorks.Test.Common/UniformTypes.cs b/MoonWorks.Test.Common/UniformTypes.cs deleted file mode 100644 index 3005fb8..0000000 --- a/MoonWorks.Test.Common/UniformTypes.cs +++ /dev/null @@ -1,14 +0,0 @@ -using MoonWorks.Math.Float; - -namespace MoonWorks.Test -{ - public struct TransformVertexUniform - { - public Matrix4x4 ViewProjection; - - public TransformVertexUniform(Matrix4x4 viewProjection) - { - ViewProjection = viewProjection; - } - } -} diff --git a/MoonWorks.Test.Common/VertexTypes.cs b/MoonWorks.Test.Common/VertexTypes.cs deleted file mode 100644 index 9564f1a..0000000 --- a/MoonWorks.Test.Common/VertexTypes.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Runtime.InteropServices; -using MoonWorks.Graphics; -using MoonWorks.Math.Float; - -namespace MoonWorks.Test -{ - [StructLayout(LayoutKind.Sequential)] - public struct PositionVertex : IVertexType - { - public Vector3 Position; - - public PositionVertex(Vector3 position) - { - Position = position; - } - - public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[1] - { - VertexElementFormat.Vector3 - }; - - public override string ToString() - { - return Position.ToString(); - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct PositionColorVertex : IVertexType - { - public Vector3 Position; - public Color Color; - - public PositionColorVertex(Vector3 position, Color color) - { - Position = position; - Color = color; - } - - public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2] - { - VertexElementFormat.Vector3, - VertexElementFormat.Color - }; - - public override string ToString() - { - return Position + " | " + Color; - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct PositionTextureVertex : IVertexType - { - public Vector3 Position; - public Vector2 TexCoord; - - public PositionTextureVertex(Vector3 position, Vector2 texCoord) - { - Position = position; - TexCoord = texCoord; - } - - public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2] - { - VertexElementFormat.Vector3, - VertexElementFormat.Vector2 - }; - - public override string ToString() - { - return Position + " | " + TexCoord; - } - } -} diff --git a/MoonWorksGraphicsTests.csproj b/MoonWorksGraphicsTests.csproj new file mode 100644 index 0000000..cd114f5 --- /dev/null +++ b/MoonWorksGraphicsTests.csproj @@ -0,0 +1,21 @@ + + + + net8.0 + true + + + + + Content\%(RecursiveDir)%(Filename)%(Extension) + Always + + + + + + + + + + diff --git a/MoonWorksGraphicsTests.sln b/MoonWorksGraphicsTests.sln index b84b76d..dae8d70 100644 --- a/MoonWorksGraphicsTests.sln +++ b/MoonWorksGraphicsTests.sln @@ -3,69 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30717.126 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTriangle", "BasicTriangle\BasicTriangle.csproj", "{595FE5AC-8699-494D-816A-89A2DE3786FB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClearScreen", "ClearScreen\ClearScreen.csproj", "{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClearScreen_MultiWindow", "ClearScreen_MultiWindow\ClearScreen_MultiWindow.csproj", "{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CullFace", "CullFace\CullFace.csproj", "{6567E2AD-189C-4994-9A27-72FB57546B8A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonWorks.Test.Common", "MoonWorks.Test.Common\MoonWorks.Test.Common.csproj", "{550D1B95-B475-4EF8-A235-626505D7710F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSAA", "MSAA\MSAA.csproj", "{970D18B0-0D05-4360-8208-41A2769C647E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TexturedAnimatedQuad", "TexturedAnimatedQuad\TexturedAnimatedQuad.csproj", "{B9DE9133-9C1C-4592-927A-D3485CB493A2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TexturedQuad", "TexturedQuad\TexturedQuad.csproj", "{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TriangleVertexBuffer", "TriangleVertexBuffer\TriangleVertexBuffer.csproj", "{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GetBufferData", "GetBufferData\GetBufferData.csproj", "{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonWorks", "..\MoonWorks\MoonWorks.csproj", "{1695B1D8-4935-490C-A5EC-E2F2AA94B150}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cube", "Cube\Cube.csproj", "{C3808AFD-23DD-4622-BFA7-981A344D0C19}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicCompute", "BasicCompute\BasicCompute.csproj", "{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeUniforms", "ComputeUniforms\ComputeUniforms.csproj", "{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawIndirect", "DrawIndirect\DrawIndirect.csproj", "{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompressedTextures", "CompressedTextures\CompressedTextures.csproj", "{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CopyTexture", "CopyTexture\CopyTexture.csproj", "{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoPlayer", "VideoPlayer\VideoPlayer.csproj", "{FCD63849-9D3C-4D48-A8BD-39671096F03A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Texture3D", "Texture3D\Texture3D.csproj", "{9D0F0573-7FD4-4480-8F9B-CDD52120A170}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstancingAndOffsets", "InstancingAndOffsets\InstancingAndOffsets.csproj", "{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VertexSampler", "VertexSampler\VertexSampler.csproj", "{C525B6DE-3003-45D5-BB83-89679B108C08}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture2DArray", "RenderTexture2DArray\RenderTexture2DArray.csproj", "{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTextureCube", "RenderTextureCube\RenderTextureCube.csproj", "{D7A8452F-123F-4965-8716-9E39F677A831}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTextureMipmaps", "RenderTextureMipmaps\RenderTextureMipmaps.csproj", "{2219C628-5593-4C23-86CB-0E1E96EBD6C5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TextureMipmaps", "TextureMipmaps\TextureMipmaps.csproj", "{5A1AC35B-EF18-426D-A633-D4899E84EAA7}" -EndProject -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 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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}" -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}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Texture3DCopy", "Texture3DCopy\Texture3DCopy.csproj", "{A18B6D92-A699-480C-9ABC-4000A3FE4B94}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonWorksGraphicsTests", "MoonWorksGraphicsTests.csproj", "{8AA61DD7-07CE-45B7-BD1A-52AA0D4DDC92}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -73,134 +13,14 @@ Global Release|Any CPU = Release|Any CPU 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 - {A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Release|Any CPU.Build.0 = Release|Any CPU + {8AA61DD7-07CE-45B7-BD1A-52AA0D4DDC92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AA61DD7-07CE-45B7-BD1A-52AA0D4DDC92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AA61DD7-07CE-45B7-BD1A-52AA0D4DDC92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AA61DD7-07CE-45B7-BD1A-52AA0D4DDC92}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..a264907 --- /dev/null +++ b/Program.cs @@ -0,0 +1,93 @@ +using System; +using MoonWorks; +using MoonWorks.Graphics; +using MoonWorks.Test; + +namespace MoonWorksGraphicsTests; + +class Program : Game +{ + Example[] Examples = + [ + new BasicComputeExample(), + new BasicStencilGame() + ]; + + int ExampleIndex = 0; + + public Program( + WindowCreateInfo windowCreateInfo, + FrameLimiterSettings frameLimiterSettings, + BackendFlags preferredBackends, + int targetTimestep = 60, + bool debugMode = false + ) : base(windowCreateInfo, frameLimiterSettings, preferredBackends, targetTimestep, debugMode) + { + } + + protected override void Update(TimeSpan delta) + { + if (Inputs.Keyboard.IsPressed(MoonWorks.Input.KeyCode.A)) + { + Examples[ExampleIndex].Destroy(); + + ExampleIndex -= 1; + if (ExampleIndex < 0) + { + ExampleIndex = Examples.Length - 1; + } + + Examples[ExampleIndex].Init(MainWindow, GraphicsDevice); + } + else if (Inputs.Keyboard.IsPressed(MoonWorks.Input.KeyCode.D)) + { + Examples[ExampleIndex].Destroy(); + + ExampleIndex = (ExampleIndex + 1) % Examples.Length; + + Examples[ExampleIndex].Init(MainWindow, GraphicsDevice); + } + else + { + Examples[ExampleIndex].Update(delta); + } + } + + protected override void Draw(double alpha) + { + Examples[ExampleIndex].Draw(alpha); + } + + static void Main(string[] args) + { + var debugMode = false; + + #if DEBUG + debugMode = true; + #endif + + var windowCreateInfo = new WindowCreateInfo( + "MoonWorksGraphicsTests", + 1280, + 720, + ScreenMode.Windowed, + SwapchainComposition.SDR, + PresentMode.VSync + ); + + var frameLimiterSettings = new FrameLimiterSettings( + FrameLimiterMode.Capped, + 60 + ); + + var game = new Program( + windowCreateInfo, + frameLimiterSettings, + BackendFlags.Vulkan | BackendFlags.D3D11 | BackendFlags.Metal, + 60, + debugMode + ); + + game.Run(); + } +} diff --git a/RenderTexture2D/RenderTexture2D.csproj b/RenderTexture2D/RenderTexture2D.csproj deleted file mode 100644 index 7ce1c70..0000000 --- a/RenderTexture2D/RenderTexture2D.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/RenderTexture2DArray/RenderTexture2DArray.csproj b/RenderTexture2DArray/RenderTexture2DArray.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/RenderTexture2DArray/RenderTexture2DArray.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/RenderTextureCube/RenderTextureCube.csproj b/RenderTextureCube/RenderTextureCube.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/RenderTextureCube/RenderTextureCube.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/RenderTextureMipmaps/RenderTextureMipmaps.csproj b/RenderTextureMipmaps/RenderTextureMipmaps.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/RenderTextureMipmaps/RenderTextureMipmaps.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/StoreLoad/StoreLoad.csproj b/StoreLoad/StoreLoad.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/StoreLoad/StoreLoad.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/Texture3D/Texture3D.csproj b/Texture3D/Texture3D.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/Texture3D/Texture3D.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/Texture3DCopy/Texture3DCopy.csproj b/Texture3DCopy/Texture3DCopy.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/Texture3DCopy/Texture3DCopy.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/TextureMipmaps/TextureMipmaps.csproj b/TextureMipmaps/TextureMipmaps.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/TextureMipmaps/TextureMipmaps.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/TexturedAnimatedQuad/TexturedAnimatedQuad.csproj b/TexturedAnimatedQuad/TexturedAnimatedQuad.csproj deleted file mode 100644 index a7937ba..0000000 --- a/TexturedAnimatedQuad/TexturedAnimatedQuad.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/TexturedQuad/TexturedQuad.csproj b/TexturedQuad/TexturedQuad.csproj deleted file mode 100644 index 5a7b3aa..0000000 --- a/TexturedQuad/TexturedQuad.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - false - - - - - diff --git a/TriangleVertexBuffer/TriangleVertexBuffer.csproj b/TriangleVertexBuffer/TriangleVertexBuffer.csproj deleted file mode 100644 index a7937ba..0000000 --- a/TriangleVertexBuffer/TriangleVertexBuffer.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/VertexSampler/VertexSampler.csproj b/VertexSampler/VertexSampler.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/VertexSampler/VertexSampler.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/VideoPlayer/VideoPlayer.csproj b/VideoPlayer/VideoPlayer.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/VideoPlayer/VideoPlayer.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - - diff --git a/WindowResizing/WindowResizing.csproj b/WindowResizing/WindowResizing.csproj deleted file mode 100644 index 5c541ff..0000000 --- a/WindowResizing/WindowResizing.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - Exe - net8.0 - enable - - - - -