Compare commits
3 Commits
main
...
spritebatc
Author | SHA1 | Date |
---|---|---|
cosmonaut | c6f87cce55 | |
cosmonaut | b0583f934b | |
cosmonaut | 7eb2477870 |
|
@ -2,4 +2,3 @@ bin/
|
||||||
obj/
|
obj/
|
||||||
.vs/
|
.vs/
|
||||||
*.csproj.user
|
*.csproj.user
|
||||||
Properties/
|
|
|
@ -4,139 +4,139 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class BasicComputeGame : Game
|
class BasicComputeGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline drawPipeline;
|
private GraphicsPipeline drawPipeline;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
|
|
||||||
public BasicComputeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public BasicComputeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Create the compute pipeline that writes texture data
|
// Create the compute pipeline that writes texture data
|
||||||
ShaderModule fillTextureComputeShaderModule = new ShaderModule(
|
ShaderModule fillTextureComputeShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("FillTexture.comp")
|
TestUtils.GetShaderPath("FillTexture.comp")
|
||||||
);
|
);
|
||||||
|
|
||||||
ComputePipeline fillTextureComputePipeline = new ComputePipeline(
|
ComputePipeline fillTextureComputePipeline = new ComputePipeline(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
ComputeShaderInfo.Create(fillTextureComputeShaderModule, "main", 0, 1)
|
ComputeShaderInfo.Create(fillTextureComputeShaderModule, "main", 0, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the compute pipeline that calculates squares of numbers
|
// Create the compute pipeline that calculates squares of numbers
|
||||||
ShaderModule calculateSquaresComputeShaderModule = new ShaderModule(
|
ShaderModule calculateSquaresComputeShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("CalculateSquares.comp")
|
TestUtils.GetShaderPath("CalculateSquares.comp")
|
||||||
);
|
);
|
||||||
|
|
||||||
ComputePipeline calculateSquaresComputePipeline = new ComputePipeline(
|
ComputePipeline calculateSquaresComputePipeline = new ComputePipeline(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
ComputeShaderInfo.Create(calculateSquaresComputeShaderModule, "main", 1, 0)
|
ComputeShaderInfo.Create(calculateSquaresComputeShaderModule, "main", 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
ShaderModule vertShaderModule = new ShaderModule(
|
ShaderModule vertShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedQuad.vert")
|
TestUtils.GetShaderPath("TexturedQuad.vert")
|
||||||
);
|
);
|
||||||
|
|
||||||
ShaderModule fragShaderModule = new ShaderModule(
|
ShaderModule fragShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedQuad.frag")
|
TestUtils.GetShaderPath("TexturedQuad.frag")
|
||||||
);
|
);
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
|
|
||||||
drawPipeline = new GraphicsPipeline(
|
drawPipeline = new GraphicsPipeline(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
drawPipelineCreateInfo
|
drawPipelineCreateInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create buffers and textures
|
// Create buffers and textures
|
||||||
uint[] squares = new uint[64];
|
uint[] squares = new uint[64];
|
||||||
Buffer squaresBuffer = Buffer.Create<uint>(
|
Buffer squaresBuffer = Buffer.Create<uint>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Compute,
|
BufferUsageFlags.Compute,
|
||||||
(uint) squares.Length
|
(uint) squares.Length
|
||||||
);
|
);
|
||||||
|
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
6
|
6
|
||||||
);
|
);
|
||||||
|
|
||||||
texture = Texture.CreateTexture2D(
|
texture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
MainWindow.Width,
|
MainWindow.Width,
|
||||||
MainWindow.Height,
|
MainWindow.Height,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.Compute | TextureUsageFlags.Sampler
|
TextureUsageFlags.Compute | TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
|
|
||||||
sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
||||||
|
|
||||||
// Upload GPU resources and dispatch compute work
|
// Upload GPU resources and dispatch compute work
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
|
||||||
cmdbuf.SetBufferData(vertexBuffer, new PositionTextureVertex[]
|
cmdbuf.SetBufferData(vertexBuffer, new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
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(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
});
|
});
|
||||||
|
|
||||||
// This should result in a bright yellow texture!
|
// This should result in a bright yellow texture!
|
||||||
cmdbuf.BindComputePipeline(fillTextureComputePipeline);
|
cmdbuf.BindComputePipeline(fillTextureComputePipeline);
|
||||||
cmdbuf.BindComputeTextures(texture);
|
cmdbuf.BindComputeTextures(texture);
|
||||||
cmdbuf.DispatchCompute(texture.Width / 8, texture.Height / 8, 1, 0);
|
cmdbuf.DispatchCompute(texture.Width / 8, texture.Height / 8, 1, 0);
|
||||||
|
|
||||||
// This calculates the squares of the first N integers!
|
// This calculates the squares of the first N integers!
|
||||||
cmdbuf.BindComputePipeline(calculateSquaresComputePipeline);
|
cmdbuf.BindComputePipeline(calculateSquaresComputePipeline);
|
||||||
cmdbuf.BindComputeBuffers(squaresBuffer);
|
cmdbuf.BindComputeBuffers(squaresBuffer);
|
||||||
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1, 0);
|
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1, 0);
|
||||||
|
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Print the squares!
|
// Print the squares!
|
||||||
squaresBuffer.GetData(squares);
|
squaresBuffer.GetData(squares);
|
||||||
Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares));
|
Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
||||||
cmdbuf.BindGraphicsPipeline(drawPipeline);
|
cmdbuf.BindGraphicsPipeline(drawPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.DrawPrimitives(0, 2, 0, 0);
|
cmdbuf.DrawPrimitives(0, 2, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
BasicComputeGame game = new BasicComputeGame();
|
BasicComputeGame game = new BasicComputeGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,107 +4,107 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class BasicStencilGame : Game
|
class BasicStencilGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline maskerPipeline;
|
private GraphicsPipeline maskerPipeline;
|
||||||
private GraphicsPipeline maskeePipeline;
|
private GraphicsPipeline maskeePipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Texture depthStencilTexture;
|
private Texture depthStencilTexture;
|
||||||
|
|
||||||
public BasicStencilGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public BasicStencilGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColor.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColor.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
||||||
// Create the graphics pipelines
|
// Create the graphics pipelines
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.AttachmentInfo.HasDepthStencilAttachment = true;
|
pipelineCreateInfo.AttachmentInfo.HasDepthStencilAttachment = true;
|
||||||
pipelineCreateInfo.AttachmentInfo.DepthStencilFormat = TextureFormat.D16S8;
|
pipelineCreateInfo.AttachmentInfo.DepthStencilFormat = TextureFormat.D16S8;
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
||||||
pipelineCreateInfo.DepthStencilState = new DepthStencilState
|
pipelineCreateInfo.DepthStencilState = new DepthStencilState
|
||||||
{
|
{
|
||||||
StencilTestEnable = true,
|
StencilTestEnable = true,
|
||||||
FrontStencilState = new StencilOpState
|
FrontStencilState = new StencilOpState
|
||||||
{
|
{
|
||||||
Reference = 1,
|
Reference = 1,
|
||||||
WriteMask = 0xFF,
|
WriteMask = 0xFF,
|
||||||
CompareOp = CompareOp.Never,
|
CompareOp = CompareOp.Never,
|
||||||
FailOp = StencilOp.Replace,
|
FailOp = StencilOp.Replace,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
maskerPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
maskerPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
pipelineCreateInfo.DepthStencilState = new DepthStencilState
|
pipelineCreateInfo.DepthStencilState = new DepthStencilState
|
||||||
{
|
{
|
||||||
StencilTestEnable = true,
|
StencilTestEnable = true,
|
||||||
FrontStencilState = new StencilOpState
|
FrontStencilState = new StencilOpState
|
||||||
{
|
{
|
||||||
Reference = 0,
|
Reference = 0,
|
||||||
CompareMask = 0xFF,
|
CompareMask = 0xFF,
|
||||||
WriteMask = 0,
|
WriteMask = 0,
|
||||||
CompareOp = CompareOp.Equal,
|
CompareOp = CompareOp.Equal,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
maskeePipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
maskeePipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
depthStencilTexture = Texture.CreateTexture2D(
|
depthStencilTexture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
MainWindow.Width,
|
MainWindow.Width,
|
||||||
MainWindow.Height,
|
MainWindow.Height,
|
||||||
TextureFormat.D16S8,
|
TextureFormat.D16S8,
|
||||||
TextureUsageFlags.DepthStencilTarget
|
TextureUsageFlags.DepthStencilTarget
|
||||||
);
|
);
|
||||||
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
|
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionColorVertex[]
|
new PositionColorVertex[]
|
||||||
{
|
{
|
||||||
new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow),
|
new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow),
|
||||||
new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow),
|
new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow),
|
||||||
new PositionColorVertex(new Vector3(0, -0.5f, 0), Color.Yellow),
|
new PositionColorVertex(new Vector3(0, -0.5f, 0), Color.Yellow),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
|
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
|
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
|
||||||
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
|
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthStencilTexture, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare),
|
new DepthStencilAttachmentInfo(depthStencilTexture, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare),
|
||||||
new ColorAttachmentInfo(backbuffer, Color.Black)
|
new ColorAttachmentInfo(backbuffer, Color.Black)
|
||||||
);
|
);
|
||||||
cmdbuf.BindGraphicsPipeline(maskerPipeline);
|
cmdbuf.BindGraphicsPipeline(maskerPipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
||||||
cmdbuf.BindGraphicsPipeline(maskeePipeline);
|
cmdbuf.BindGraphicsPipeline(maskeePipeline);
|
||||||
cmdbuf.DrawPrimitives(3, 1, 0, 0);
|
cmdbuf.DrawPrimitives(3, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
BasicStencilGame p = new BasicStencilGame();
|
BasicStencilGame p = new BasicStencilGame();
|
||||||
p.Run();
|
p.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
public BasicTriangleGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public BasicTriangleGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left to toggle wireframe mode\nPress Down to toggle small viewport\nPress Right to toggle scissor rect");
|
Logger.LogInfo("Press Left to toggle wireframe mode\nPress Down to toggle small viewport\nPress Right to toggle scissor rect");
|
||||||
|
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
|
@ -5,129 +5,129 @@ using System.IO;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class CompressedTexturesGame : Game
|
class CompressedTexturesGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
private Texture[] textures;
|
private Texture[] textures;
|
||||||
private string[] textureNames = new string[]
|
private string[] textureNames = new string[]
|
||||||
{
|
{
|
||||||
"BC1",
|
"BC1",
|
||||||
"BC2",
|
"BC2",
|
||||||
"BC3",
|
"BC3",
|
||||||
"BC7"
|
"BC7"
|
||||||
};
|
};
|
||||||
|
|
||||||
private int currentTextureIndex;
|
private int currentTextureIndex;
|
||||||
|
|
||||||
public CompressedTexturesGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public CompressedTexturesGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left and Right to cycle between textures");
|
Logger.LogInfo("Press Left and Right to cycle between textures");
|
||||||
Logger.LogInfo("Setting texture to: " + textureNames[0]);
|
Logger.LogInfo("Setting texture to: " + textureNames[0]);
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
|
||||||
|
|
||||||
// Create texture array
|
// Create texture array
|
||||||
textures = new Texture[textureNames.Length];
|
textures = new Texture[textureNames.Length];
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
for (int i = 0; i < textureNames.Length; i += 1)
|
for (int i = 0; i < textureNames.Length; i += 1)
|
||||||
{
|
{
|
||||||
Logger.LogInfo(textureNames[i]);
|
Logger.LogInfo(textureNames[i]);
|
||||||
using (FileStream fs = new FileStream(TestUtils.GetTexturePath(textureNames[i] + ".dds"), FileMode.Open, FileAccess.Read))
|
using (FileStream fs = new FileStream(TestUtils.GetTexturePath(textureNames[i] + ".dds"), FileMode.Open, FileAccess.Read))
|
||||||
textures[i] = Texture.LoadDDS(GraphicsDevice, cmdbuf, fs);
|
textures[i] = Texture.LoadDDS(GraphicsDevice, cmdbuf, fs);
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
int prevSamplerIndex = currentTextureIndex;
|
int prevSamplerIndex = currentTextureIndex;
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
currentTextureIndex -= 1;
|
currentTextureIndex -= 1;
|
||||||
if (currentTextureIndex < 0)
|
if (currentTextureIndex < 0)
|
||||||
{
|
{
|
||||||
currentTextureIndex = textureNames.Length - 1;
|
currentTextureIndex = textureNames.Length - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
currentTextureIndex += 1;
|
currentTextureIndex += 1;
|
||||||
if (currentTextureIndex >= textureNames.Length)
|
if (currentTextureIndex >= textureNames.Length)
|
||||||
{
|
{
|
||||||
currentTextureIndex = 0;
|
currentTextureIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevSamplerIndex != currentTextureIndex)
|
if (prevSamplerIndex != currentTextureIndex)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Setting texture to: " + textureNames[currentTextureIndex]);
|
Logger.LogInfo("Setting texture to: " + textureNames[currentTextureIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textures[currentTextureIndex], sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textures[currentTextureIndex], sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CompressedTexturesGame game = new CompressedTexturesGame();
|
CompressedTexturesGame game = new CompressedTexturesGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,126 +4,126 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class ComputeUniformsGame : Game
|
class ComputeUniformsGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline drawPipeline;
|
private GraphicsPipeline drawPipeline;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
|
|
||||||
struct GradientTextureComputeUniforms
|
struct GradientTextureComputeUniforms
|
||||||
{
|
{
|
||||||
public uint groupCountX;
|
public uint groupCountX;
|
||||||
public uint groupCountY;
|
public uint groupCountY;
|
||||||
|
|
||||||
public GradientTextureComputeUniforms(uint w, uint h)
|
public GradientTextureComputeUniforms(uint w, uint h)
|
||||||
{
|
{
|
||||||
groupCountX = w;
|
groupCountX = w;
|
||||||
groupCountY = h;
|
groupCountY = h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputeUniformsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public ComputeUniformsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Create the compute pipeline that writes texture data
|
// Create the compute pipeline that writes texture data
|
||||||
ShaderModule gradientTextureComputeShaderModule = new ShaderModule(
|
ShaderModule gradientTextureComputeShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("GradientTexture.comp")
|
TestUtils.GetShaderPath("GradientTexture.comp")
|
||||||
);
|
);
|
||||||
|
|
||||||
ComputePipeline gradientTextureComputePipeline = new ComputePipeline(
|
ComputePipeline gradientTextureComputePipeline = new ComputePipeline(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
ComputeShaderInfo.Create<GradientTextureComputeUniforms>(gradientTextureComputeShaderModule, "main", 0, 1)
|
ComputeShaderInfo.Create<GradientTextureComputeUniforms>(gradientTextureComputeShaderModule, "main", 0, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
ShaderModule vertShaderModule = new ShaderModule(
|
ShaderModule vertShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedQuad.vert")
|
TestUtils.GetShaderPath("TexturedQuad.vert")
|
||||||
);
|
);
|
||||||
|
|
||||||
ShaderModule fragShaderModule = new ShaderModule(
|
ShaderModule fragShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedQuad.frag")
|
TestUtils.GetShaderPath("TexturedQuad.frag")
|
||||||
);
|
);
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo drawPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
drawPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
drawPipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
|
|
||||||
drawPipeline = new GraphicsPipeline(
|
drawPipeline = new GraphicsPipeline(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
drawPipelineCreateInfo
|
drawPipelineCreateInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create buffers and textures
|
// Create buffers and textures
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
6
|
6
|
||||||
);
|
);
|
||||||
|
|
||||||
texture = Texture.CreateTexture2D(
|
texture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
MainWindow.Width,
|
MainWindow.Width,
|
||||||
MainWindow.Height,
|
MainWindow.Height,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.Compute | TextureUsageFlags.Sampler
|
TextureUsageFlags.Compute | TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
|
|
||||||
sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
||||||
|
|
||||||
// Upload GPU resources and dispatch compute work
|
// Upload GPU resources and dispatch compute work
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(vertexBuffer, new PositionTextureVertex[]
|
cmdbuf.SetBufferData(vertexBuffer, new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
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(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
});
|
});
|
||||||
|
|
||||||
GradientTextureComputeUniforms gradientUniforms = new GradientTextureComputeUniforms(
|
GradientTextureComputeUniforms gradientUniforms = new GradientTextureComputeUniforms(
|
||||||
texture.Width / 8,
|
texture.Width / 8,
|
||||||
texture.Height / 8
|
texture.Height / 8
|
||||||
);
|
);
|
||||||
|
|
||||||
cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
|
cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
|
||||||
cmdbuf.BindComputeTextures(texture);
|
cmdbuf.BindComputeTextures(texture);
|
||||||
uint offset = cmdbuf.PushComputeShaderUniforms(gradientUniforms);
|
uint offset = cmdbuf.PushComputeShaderUniforms(gradientUniforms);
|
||||||
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, offset);
|
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1, offset);
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
||||||
cmdbuf.BindGraphicsPipeline(drawPipeline);
|
cmdbuf.BindGraphicsPipeline(drawPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.DrawPrimitives(0, 2, 0, 0);
|
cmdbuf.DrawPrimitives(0, 2, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
ComputeUniformsGame game = new ComputeUniformsGame();
|
ComputeUniformsGame game = new ComputeUniformsGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,72 +5,72 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class CopyTextureGame : Game
|
class CopyTextureGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture originalTexture;
|
private Texture originalTexture;
|
||||||
private Texture textureCopy;
|
private Texture textureCopy;
|
||||||
private Texture textureSmallCopy;
|
private Texture textureSmallCopy;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
public unsafe CopyTextureGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public unsafe CopyTextureGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
|
pipelineCreateInfo.AttachmentInfo.ColorAttachmentDescriptions[0].BlendState = ColorAttachmentBlendState.AlphaBlend;
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 12);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 12);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 12);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 12);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1f, 0f, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1f, 0f, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3( 0f, 0f, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3( 0f, 0f, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3( 0f, 1f, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3( 0f, 1f, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1f, 1f, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1f, 1f, 0), new Vector2(0, 1)),
|
||||||
|
|
||||||
new PositionTextureVertex(new Vector3(0f, 0f, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(0f, 0f, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1f, 0f, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1f, 0f, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1f, 1f, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1f, 1f, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(0f, 1f, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(0f, 1f, 0), new Vector2(0, 1)),
|
||||||
|
|
||||||
new PositionTextureVertex(new Vector3(-0.5f, -1f, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-0.5f, -1f, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3( 0.5f, -1f, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3( 0.5f, -1f, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3( 0.5f, 0f, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3( 0.5f, 0f, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-0.5f, 0f, 0), new Vector2(0, 1))
|
new PositionTextureVertex(new Vector3(-0.5f, 0f, 0), new Vector2(0, 1))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Load the texture. Storing the texture bytes so we can compare them.
|
// Load the texture. Storing the texture bytes so we can compare them.
|
||||||
var fileStream = new System.IO.FileStream(TestUtils.GetTexturePath("ravioli.png"), System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
var fileStream = new System.IO.FileStream(TestUtils.GetTexturePath("ravioli.png"), System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
||||||
var fileLength = fileStream.Length;
|
var fileLength = fileStream.Length;
|
||||||
var fileBuffer = NativeMemory.Alloc((nuint) fileLength);
|
var fileBuffer = NativeMemory.Alloc((nuint) fileLength);
|
||||||
|
@ -87,54 +87,54 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
NativeMemory.Free(fileBuffer);
|
NativeMemory.Free(fileBuffer);
|
||||||
|
|
||||||
TextureCreateInfo textureCreateInfo = new TextureCreateInfo();
|
TextureCreateInfo textureCreateInfo = new TextureCreateInfo();
|
||||||
textureCreateInfo.Width = (uint) width;
|
textureCreateInfo.Width = (uint) width;
|
||||||
textureCreateInfo.Height = (uint) height;
|
textureCreateInfo.Height = (uint) height;
|
||||||
textureCreateInfo.Depth = 1;
|
textureCreateInfo.Depth = 1;
|
||||||
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
|
textureCreateInfo.Format = TextureFormat.R8G8B8A8;
|
||||||
textureCreateInfo.IsCube = false;
|
textureCreateInfo.IsCube = false;
|
||||||
textureCreateInfo.LevelCount = 1;
|
textureCreateInfo.LevelCount = 1;
|
||||||
textureCreateInfo.UsageFlags = TextureUsageFlags.Sampler;
|
textureCreateInfo.UsageFlags = TextureUsageFlags.Sampler;
|
||||||
|
|
||||||
originalTexture = new Texture(GraphicsDevice, textureCreateInfo);
|
originalTexture = new Texture(GraphicsDevice, textureCreateInfo);
|
||||||
cmdbuf.SetTextureData(originalTexture, pixels, (uint) byteCount);
|
cmdbuf.SetTextureData(originalTexture, pixels, (uint) byteCount);
|
||||||
|
|
||||||
// Create a 1:1 copy of the texture
|
// Create a 1:1 copy of the texture
|
||||||
textureCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
textureCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
||||||
cmdbuf.CopyTextureToTexture(
|
cmdbuf.CopyTextureToTexture(
|
||||||
new TextureSlice(originalTexture),
|
new TextureSlice(originalTexture),
|
||||||
new TextureSlice(textureCopy),
|
new TextureSlice(textureCopy),
|
||||||
Filter.Linear
|
Filter.Linear
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a half-sized copy of this texture
|
// Create a half-sized copy of this texture
|
||||||
textureCreateInfo.Width /= 2;
|
textureCreateInfo.Width /= 2;
|
||||||
textureCreateInfo.Height /= 2;
|
textureCreateInfo.Height /= 2;
|
||||||
textureSmallCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
textureSmallCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
||||||
cmdbuf.CopyTextureToTexture(
|
cmdbuf.CopyTextureToTexture(
|
||||||
new TextureSlice(originalTexture),
|
new TextureSlice(originalTexture),
|
||||||
new TextureSlice(
|
new TextureSlice(
|
||||||
textureSmallCopy,
|
textureSmallCopy,
|
||||||
new Rect(
|
new Rect(
|
||||||
(int) textureCreateInfo.Width,
|
(int) textureCreateInfo.Width,
|
||||||
(int) textureCreateInfo.Height
|
(int) textureCreateInfo.Height
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Filter.Linear
|
Filter.Linear
|
||||||
);
|
);
|
||||||
|
|
||||||
// Copy the texture to a buffer
|
// Copy the texture to a buffer
|
||||||
Buffer compareBuffer = Buffer.Create<byte>(GraphicsDevice, 0, (uint) byteCount);
|
Buffer compareBuffer = Buffer.Create<byte>(GraphicsDevice, 0, (uint) byteCount);
|
||||||
cmdbuf.CopyTextureToBuffer(new TextureSlice(originalTexture), compareBuffer);
|
cmdbuf.CopyTextureToBuffer(new TextureSlice(originalTexture), compareBuffer);
|
||||||
|
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Compare the original bytes to the copied bytes.
|
// Compare the original bytes to the copied bytes.
|
||||||
var copiedBytes = NativeMemory.Alloc((nuint) byteCount);
|
var copiedBytes = NativeMemory.Alloc((nuint) byteCount);
|
||||||
var copiedSpan = new System.Span<byte>(copiedBytes, byteCount);
|
var copiedSpan = new System.Span<byte>(copiedBytes, byteCount);
|
||||||
compareBuffer.GetData(copiedSpan);
|
compareBuffer.GetData(copiedSpan);
|
||||||
|
|
||||||
var originalSpan = new System.Span<byte>((void*) pixels, byteCount);
|
var originalSpan = new System.Span<byte>((void*) pixels, byteCount);
|
||||||
|
|
||||||
|
@ -149,35 +149,35 @@ namespace MoonWorks.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshCS.Refresh.Refresh_Image_Free(pixels);
|
RefreshCS.Refresh.Refresh_Image_Free(pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(originalTexture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(originalTexture, sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textureCopy, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textureCopy, sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(4, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(4, 0, 2, 0, 0);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textureSmallCopy, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textureSmallCopy, sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(8, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(8, 0, 2, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CopyTextureGame game = new CopyTextureGame();
|
CopyTextureGame game = new CopyTextureGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
722
Cube/CubeGame.cs
722
Cube/CubeGame.cs
|
@ -6,52 +6,52 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class CubeGame : Game
|
class CubeGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline cubePipeline;
|
private GraphicsPipeline cubePipeline;
|
||||||
private GraphicsPipeline cubePipelineDepthOnly;
|
private GraphicsPipeline cubePipelineDepthOnly;
|
||||||
private GraphicsPipeline skyboxPipeline;
|
private GraphicsPipeline skyboxPipeline;
|
||||||
private GraphicsPipeline skyboxPipelineDepthOnly;
|
private GraphicsPipeline skyboxPipelineDepthOnly;
|
||||||
private GraphicsPipeline blitPipeline;
|
private GraphicsPipeline blitPipeline;
|
||||||
|
|
||||||
private Texture depthTexture;
|
private Texture depthTexture;
|
||||||
private Sampler depthSampler;
|
private Sampler depthSampler;
|
||||||
private DepthUniforms depthUniforms;
|
private DepthUniforms depthUniforms;
|
||||||
|
|
||||||
private Buffer cubeVertexBuffer;
|
private Buffer cubeVertexBuffer;
|
||||||
private Buffer skyboxVertexBuffer;
|
private Buffer skyboxVertexBuffer;
|
||||||
private Buffer blitVertexBuffer;
|
private Buffer blitVertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
|
|
||||||
private Texture skyboxTexture;
|
private Texture skyboxTexture;
|
||||||
private Sampler skyboxSampler;
|
private Sampler skyboxSampler;
|
||||||
|
|
||||||
private bool finishedLoading = false;
|
private bool finishedLoading = false;
|
||||||
private float cubeTimer = 0f;
|
private float cubeTimer = 0f;
|
||||||
private Quaternion cubeRotation = Quaternion.Identity;
|
private Quaternion cubeRotation = Quaternion.Identity;
|
||||||
private Quaternion previousCubeRotation = Quaternion.Identity;
|
private Quaternion previousCubeRotation = Quaternion.Identity;
|
||||||
private bool depthOnlyEnabled = false;
|
private bool depthOnlyEnabled = false;
|
||||||
private Vector3 camPos = new Vector3(0, 1.5f, 4f);
|
private Vector3 camPos = new Vector3(0, 1.5f, 4f);
|
||||||
|
|
||||||
private TaskFactory taskFactory = new TaskFactory();
|
private TaskFactory taskFactory = new TaskFactory();
|
||||||
private bool takeScreenshot;
|
private bool takeScreenshot;
|
||||||
|
|
||||||
struct DepthUniforms
|
struct DepthUniforms
|
||||||
{
|
{
|
||||||
public float ZNear;
|
public float ZNear;
|
||||||
public float ZFar;
|
public float ZFar;
|
||||||
|
|
||||||
public DepthUniforms(float zNear, float zFar)
|
public DepthUniforms(float zNear, float zFar)
|
||||||
{
|
{
|
||||||
ZNear = zNear;
|
ZNear = zNear;
|
||||||
ZFar = zFar;
|
ZFar = zFar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadCubemap(CommandBuffer cmdbuf, string[] imagePaths)
|
void LoadCubemap(CommandBuffer cmdbuf, string[] imagePaths)
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < imagePaths.Length; i++)
|
for (uint i = 0; i < imagePaths.Length; i++)
|
||||||
{
|
{
|
||||||
var textureSlice = new TextureSlice(
|
var textureSlice = new TextureSlice(
|
||||||
skyboxTexture,
|
skyboxTexture,
|
||||||
new Rect(0, 0, (int) skyboxTexture.Width, (int) skyboxTexture.Height),
|
new Rect(0, 0, (int) skyboxTexture.Width, (int) skyboxTexture.Height),
|
||||||
|
@ -61,383 +61,383 @@ namespace MoonWorks.Test
|
||||||
);
|
);
|
||||||
|
|
||||||
Texture.SetDataFromImageFile(cmdbuf, textureSlice, imagePaths[i]);
|
Texture.SetDataFromImageFile(cmdbuf, textureSlice, imagePaths[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public CubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
ShaderModule cubeVertShaderModule = new ShaderModule(
|
ShaderModule cubeVertShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("PositionColorWithMatrix.vert")
|
TestUtils.GetShaderPath("PositionColorWithMatrix.vert")
|
||||||
);
|
);
|
||||||
ShaderModule cubeFragShaderModule = new ShaderModule(
|
ShaderModule cubeFragShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("SolidColor.frag")
|
TestUtils.GetShaderPath("SolidColor.frag")
|
||||||
);
|
);
|
||||||
|
|
||||||
ShaderModule skyboxVertShaderModule = new ShaderModule(
|
ShaderModule skyboxVertShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("Skybox.vert")
|
TestUtils.GetShaderPath("Skybox.vert")
|
||||||
);
|
);
|
||||||
ShaderModule skyboxFragShaderModule = new ShaderModule(
|
ShaderModule skyboxFragShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("Skybox.frag")
|
TestUtils.GetShaderPath("Skybox.frag")
|
||||||
);
|
);
|
||||||
|
|
||||||
ShaderModule blitVertShaderModule = new ShaderModule(
|
ShaderModule blitVertShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedQuad.vert")
|
TestUtils.GetShaderPath("TexturedQuad.vert")
|
||||||
);
|
);
|
||||||
ShaderModule blitFragShaderModule = new ShaderModule(
|
ShaderModule blitFragShaderModule = new ShaderModule(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
TestUtils.GetShaderPath("TexturedDepthQuad.frag")
|
TestUtils.GetShaderPath("TexturedDepthQuad.frag")
|
||||||
);
|
);
|
||||||
|
|
||||||
depthTexture = Texture.CreateTexture2D(
|
depthTexture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
MainWindow.Width,
|
MainWindow.Width,
|
||||||
MainWindow.Height,
|
MainWindow.Height,
|
||||||
TextureFormat.D16,
|
TextureFormat.D16,
|
||||||
TextureUsageFlags.DepthStencilTarget | TextureUsageFlags.Sampler
|
TextureUsageFlags.DepthStencilTarget | TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
depthSampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
depthSampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
||||||
depthUniforms = new DepthUniforms(0.01f, 100f);
|
depthUniforms = new DepthUniforms(0.01f, 100f);
|
||||||
|
|
||||||
skyboxTexture = Texture.CreateTextureCube(
|
skyboxTexture = Texture.CreateTextureCube(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
2048,
|
2048,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.Sampler
|
TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
skyboxSampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
skyboxSampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
|
||||||
|
|
||||||
cubeVertexBuffer = Buffer.Create<PositionColorVertex>(
|
cubeVertexBuffer = Buffer.Create<PositionColorVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
24
|
24
|
||||||
);
|
);
|
||||||
skyboxVertexBuffer = Buffer.Create<PositionVertex>(
|
skyboxVertexBuffer = Buffer.Create<PositionVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
24
|
24
|
||||||
);
|
);
|
||||||
indexBuffer = Buffer.Create<uint>(
|
indexBuffer = Buffer.Create<uint>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Index,
|
BufferUsageFlags.Index,
|
||||||
36
|
36
|
||||||
); // Using uint here just to test IndexElementSize=32
|
); // Using uint here just to test IndexElementSize=32
|
||||||
|
|
||||||
blitVertexBuffer = Buffer.Create<PositionTextureVertex>(
|
blitVertexBuffer = Buffer.Create<PositionTextureVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
6
|
6
|
||||||
);
|
);
|
||||||
|
|
||||||
Task loadingTask = Task.Run(() => UploadGPUAssets());
|
Task loadingTask = Task.Run(() => UploadGPUAssets());
|
||||||
|
|
||||||
// Create the cube pipelines
|
// Create the cube pipelines
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo cubePipelineCreateInfo = new GraphicsPipelineCreateInfo
|
GraphicsPipelineCreateInfo cubePipelineCreateInfo = new GraphicsPipelineCreateInfo
|
||||||
{
|
{
|
||||||
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
||||||
TextureFormat.D16,
|
TextureFormat.D16,
|
||||||
new ColorAttachmentDescription(
|
new ColorAttachmentDescription(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
ColorAttachmentBlendState.Opaque
|
ColorAttachmentBlendState.Opaque
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
DepthStencilState = DepthStencilState.DepthReadWrite,
|
DepthStencilState = DepthStencilState.DepthReadWrite,
|
||||||
VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(cubeVertShaderModule, "main", 0),
|
VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(cubeVertShaderModule, "main", 0),
|
||||||
VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(),
|
VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>(),
|
||||||
PrimitiveType = PrimitiveType.TriangleList,
|
PrimitiveType = PrimitiveType.TriangleList,
|
||||||
FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0),
|
FragmentShaderInfo = GraphicsShaderInfo.Create(cubeFragShaderModule, "main", 0),
|
||||||
RasterizerState = RasterizerState.CW_CullBack,
|
RasterizerState = RasterizerState.CW_CullBack,
|
||||||
MultisampleState = MultisampleState.None
|
MultisampleState = MultisampleState.None
|
||||||
};
|
};
|
||||||
cubePipeline = new GraphicsPipeline(GraphicsDevice, cubePipelineCreateInfo);
|
cubePipeline = new GraphicsPipeline(GraphicsDevice, cubePipelineCreateInfo);
|
||||||
|
|
||||||
cubePipelineCreateInfo.AttachmentInfo = new GraphicsPipelineAttachmentInfo(TextureFormat.D16);
|
cubePipelineCreateInfo.AttachmentInfo = new GraphicsPipelineAttachmentInfo(TextureFormat.D16);
|
||||||
cubePipelineDepthOnly = new GraphicsPipeline(GraphicsDevice, cubePipelineCreateInfo);
|
cubePipelineDepthOnly = new GraphicsPipeline(GraphicsDevice, cubePipelineCreateInfo);
|
||||||
|
|
||||||
// Create the skybox pipelines
|
// Create the skybox pipelines
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo skyboxPipelineCreateInfo = new GraphicsPipelineCreateInfo
|
GraphicsPipelineCreateInfo skyboxPipelineCreateInfo = new GraphicsPipelineCreateInfo
|
||||||
{
|
{
|
||||||
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
||||||
TextureFormat.D16,
|
TextureFormat.D16,
|
||||||
new ColorAttachmentDescription(
|
new ColorAttachmentDescription(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
ColorAttachmentBlendState.Opaque
|
ColorAttachmentBlendState.Opaque
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
DepthStencilState = DepthStencilState.DepthReadWrite,
|
DepthStencilState = DepthStencilState.DepthReadWrite,
|
||||||
VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(skyboxVertShaderModule, "main", 0),
|
VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(skyboxVertShaderModule, "main", 0),
|
||||||
VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(),
|
VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>(),
|
||||||
PrimitiveType = PrimitiveType.TriangleList,
|
PrimitiveType = PrimitiveType.TriangleList,
|
||||||
FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1),
|
FragmentShaderInfo = GraphicsShaderInfo.Create(skyboxFragShaderModule, "main", 1),
|
||||||
RasterizerState = RasterizerState.CW_CullNone,
|
RasterizerState = RasterizerState.CW_CullNone,
|
||||||
MultisampleState = MultisampleState.None,
|
MultisampleState = MultisampleState.None,
|
||||||
};
|
};
|
||||||
skyboxPipeline = new GraphicsPipeline(GraphicsDevice, skyboxPipelineCreateInfo);
|
skyboxPipeline = new GraphicsPipeline(GraphicsDevice, skyboxPipelineCreateInfo);
|
||||||
|
|
||||||
skyboxPipelineCreateInfo.AttachmentInfo = new GraphicsPipelineAttachmentInfo(TextureFormat.D16);
|
skyboxPipelineCreateInfo.AttachmentInfo = new GraphicsPipelineAttachmentInfo(TextureFormat.D16);
|
||||||
skyboxPipelineDepthOnly = new GraphicsPipeline(GraphicsDevice, skyboxPipelineCreateInfo);
|
skyboxPipelineDepthOnly = new GraphicsPipeline(GraphicsDevice, skyboxPipelineCreateInfo);
|
||||||
|
|
||||||
// Create the blit pipeline
|
// Create the blit pipeline
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo blitPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo blitPipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
blitVertShaderModule,
|
blitVertShaderModule,
|
||||||
blitFragShaderModule
|
blitFragShaderModule
|
||||||
);
|
);
|
||||||
blitPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
blitPipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
blitPipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<DepthUniforms>(blitFragShaderModule, "main", 1);
|
blitPipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<DepthUniforms>(blitFragShaderModule, "main", 1);
|
||||||
blitPipeline = new GraphicsPipeline(GraphicsDevice, blitPipelineCreateInfo);
|
blitPipeline = new GraphicsPipeline(GraphicsDevice, blitPipelineCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UploadGPUAssets()
|
private void UploadGPUAssets()
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Loading...");
|
Logger.LogInfo("Loading...");
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
cubeVertexBuffer,
|
cubeVertexBuffer,
|
||||||
new PositionColorVertex[]
|
new PositionColorVertex[]
|
||||||
{
|
{
|
||||||
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0f)),
|
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0f)),
|
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0f, 0f)),
|
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(1f, 0f, 0f)),
|
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(1f, 0f, 0f)),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 1f, 0f)),
|
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 1f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, -1, 1), new Color(0f, 1f, 0f)),
|
new PositionColorVertex(new Vector3(1, -1, 1), new Color(0f, 1f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 1f, 0f)),
|
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 1f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 1f, 0f)),
|
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 1f, 0f)),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(0f, 0f, 1f)),
|
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(0f, 0f, 1f)),
|
||||||
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0f, 1f)),
|
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0f, 1f)),
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0f, 1f)),
|
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0f, 1f)),
|
||||||
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 0f, 1f)),
|
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(0f, 0f, 1f)),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(1, 1, -1), new Color(1f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 1), new Color(1f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(1, 1, 1), new Color(1f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0.5f, 0f)),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0.5f)),
|
new PositionColorVertex(new Vector3(-1, -1, -1), new Color(1f, 0f, 0.5f)),
|
||||||
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(1f, 0f, 0.5f)),
|
new PositionColorVertex(new Vector3(-1, -1, 1), new Color(1f, 0f, 0.5f)),
|
||||||
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0f, 0.5f)),
|
new PositionColorVertex(new Vector3(1, -1, 1), new Color(1f, 0f, 0.5f)),
|
||||||
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0.5f)),
|
new PositionColorVertex(new Vector3(1, -1, -1), new Color(1f, 0f, 0.5f)),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(-1, 1, -1), new Color(0f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(-1, 1, 1), new Color(0f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 0.5f, 0f)),
|
new PositionColorVertex(new Vector3(1, 1, 1), new Color(0f, 0.5f, 0f)),
|
||||||
new PositionColorVertex(new Vector3(1, 1, -1), new Color(0f, 0.5f, 0f))
|
new PositionColorVertex(new Vector3(1, 1, -1), new Color(0f, 0.5f, 0f))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
skyboxVertexBuffer,
|
skyboxVertexBuffer,
|
||||||
new PositionVertex[]
|
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)),
|
||||||
|
|
||||||
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(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new uint[]
|
new uint[]
|
||||||
{
|
{
|
||||||
0, 1, 2, 0, 2, 3,
|
0, 1, 2, 0, 2, 3,
|
||||||
6, 5, 4, 7, 6, 4,
|
6, 5, 4, 7, 6, 4,
|
||||||
8, 9, 10, 8, 10, 11,
|
8, 9, 10, 8, 10, 11,
|
||||||
14, 13, 12, 15, 14, 12,
|
14, 13, 12, 15, 14, 12,
|
||||||
16, 17, 18, 16, 18, 19,
|
16, 17, 18, 16, 18, 19,
|
||||||
22, 21, 20, 23, 22, 20
|
22, 21, 20, 23, 22, 20
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
blitVertexBuffer,
|
blitVertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
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(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
LoadCubemap(cmdbuf, new string[]
|
LoadCubemap(cmdbuf, new string[]
|
||||||
{
|
{
|
||||||
TestUtils.GetTexturePath("right.png"),
|
TestUtils.GetTexturePath("right.png"),
|
||||||
TestUtils.GetTexturePath("left.png"),
|
TestUtils.GetTexturePath("left.png"),
|
||||||
TestUtils.GetTexturePath("top.png"),
|
TestUtils.GetTexturePath("top.png"),
|
||||||
TestUtils.GetTexturePath("bottom.png"),
|
TestUtils.GetTexturePath("bottom.png"),
|
||||||
TestUtils.GetTexturePath("front.png"),
|
TestUtils.GetTexturePath("front.png"),
|
||||||
TestUtils.GetTexturePath("back.png")
|
TestUtils.GetTexturePath("back.png")
|
||||||
});
|
});
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
||||||
finishedLoading = true;
|
finishedLoading = true;
|
||||||
Logger.LogInfo("Finished loading!");
|
Logger.LogInfo("Finished loading!");
|
||||||
Logger.LogInfo("Press Left to toggle Depth-Only Mode");
|
Logger.LogInfo("Press Left to toggle Depth-Only Mode");
|
||||||
Logger.LogInfo("Press Down to move the camera upwards");
|
Logger.LogInfo("Press Down to move the camera upwards");
|
||||||
Logger.LogInfo("Press Right to save a screenshot");
|
Logger.LogInfo("Press Right to save a screenshot");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
cubeTimer += (float) delta.TotalSeconds;
|
cubeTimer += (float) delta.TotalSeconds;
|
||||||
|
|
||||||
previousCubeRotation = cubeRotation;
|
previousCubeRotation = cubeRotation;
|
||||||
|
|
||||||
cubeRotation = Quaternion.CreateFromYawPitchRoll(
|
cubeRotation = Quaternion.CreateFromYawPitchRoll(
|
||||||
cubeTimer * 2f,
|
cubeTimer * 2f,
|
||||||
0,
|
0,
|
||||||
cubeTimer * 2f
|
cubeTimer * 2f
|
||||||
);
|
);
|
||||||
|
|
||||||
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Bottom))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Bottom))
|
||||||
{
|
{
|
||||||
camPos.Y = System.MathF.Min(camPos.Y + 0.2f, 15f);
|
camPos.Y = System.MathF.Min(camPos.Y + 0.2f, 15f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
camPos.Y = System.MathF.Max(camPos.Y - 0.4f, 1.5f);
|
camPos.Y = System.MathF.Max(camPos.Y - 0.4f, 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
depthOnlyEnabled = !depthOnlyEnabled;
|
depthOnlyEnabled = !depthOnlyEnabled;
|
||||||
Logger.LogInfo("Depth-Only Mode enabled: " + depthOnlyEnabled);
|
Logger.LogInfo("Depth-Only Mode enabled: " + depthOnlyEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
takeScreenshot = true;
|
takeScreenshot = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
|
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
|
||||||
MathHelper.ToRadians(75f),
|
MathHelper.ToRadians(75f),
|
||||||
(float) MainWindow.Width / MainWindow.Height,
|
(float) MainWindow.Width / MainWindow.Height,
|
||||||
depthUniforms.ZNear,
|
depthUniforms.ZNear,
|
||||||
depthUniforms.ZFar
|
depthUniforms.ZFar
|
||||||
);
|
);
|
||||||
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
||||||
camPos,
|
camPos,
|
||||||
Vector3.Zero,
|
Vector3.Zero,
|
||||||
Vector3.Up
|
Vector3.Up
|
||||||
);
|
);
|
||||||
TransformVertexUniform skyboxUniforms = new TransformVertexUniform(view * proj);
|
TransformVertexUniform skyboxUniforms = new TransformVertexUniform(view * proj);
|
||||||
|
|
||||||
Matrix4x4 model = Matrix4x4.CreateFromQuaternion(
|
Matrix4x4 model = Matrix4x4.CreateFromQuaternion(
|
||||||
Quaternion.Slerp(
|
Quaternion.Slerp(
|
||||||
previousCubeRotation,
|
previousCubeRotation,
|
||||||
cubeRotation,
|
cubeRotation,
|
||||||
(float) alpha
|
(float) alpha
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
TransformVertexUniform cubeUniforms = new TransformVertexUniform(model * view * proj);
|
TransformVertexUniform cubeUniforms = new TransformVertexUniform(model * view * proj);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (swapchainTexture != null)
|
if (swapchainTexture != null)
|
||||||
{
|
{
|
||||||
if (!finishedLoading)
|
if (!finishedLoading)
|
||||||
{
|
{
|
||||||
float sine = System.MathF.Abs(System.MathF.Sin(cubeTimer));
|
float sine = System.MathF.Abs(System.MathF.Sin(cubeTimer));
|
||||||
Color clearColor = new Color(sine, sine, sine);
|
Color clearColor = new Color(sine, sine, sine);
|
||||||
|
|
||||||
// Just show a clear screen.
|
// Just show a clear screen.
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, clearColor));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, clearColor));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!depthOnlyEnabled)
|
if (!depthOnlyEnabled)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0)),
|
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0)),
|
||||||
new ColorAttachmentInfo(swapchainTexture, LoadOp.DontCare)
|
new ColorAttachmentInfo(swapchainTexture, LoadOp.DontCare)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0))
|
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw cube
|
// Draw cube
|
||||||
cmdbuf.BindGraphicsPipeline(depthOnlyEnabled ? cubePipelineDepthOnly : cubePipeline);
|
cmdbuf.BindGraphicsPipeline(depthOnlyEnabled ? cubePipelineDepthOnly : cubePipeline);
|
||||||
cmdbuf.BindVertexBuffers(cubeVertexBuffer);
|
cmdbuf.BindVertexBuffers(cubeVertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.ThirtyTwo);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.ThirtyTwo);
|
||||||
uint vertexParamOffset = cmdbuf.PushVertexShaderUniforms(cubeUniforms);
|
uint vertexParamOffset = cmdbuf.PushVertexShaderUniforms(cubeUniforms);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
|
||||||
|
|
||||||
// Draw skybox
|
// Draw skybox
|
||||||
cmdbuf.BindGraphicsPipeline(depthOnlyEnabled ? skyboxPipelineDepthOnly : skyboxPipeline);
|
cmdbuf.BindGraphicsPipeline(depthOnlyEnabled ? skyboxPipelineDepthOnly : skyboxPipeline);
|
||||||
cmdbuf.BindVertexBuffers(skyboxVertexBuffer);
|
cmdbuf.BindVertexBuffers(skyboxVertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.ThirtyTwo);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.ThirtyTwo);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(skyboxTexture, skyboxSampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(skyboxTexture, skyboxSampler));
|
||||||
vertexParamOffset = cmdbuf.PushVertexShaderUniforms(skyboxUniforms);
|
vertexParamOffset = cmdbuf.PushVertexShaderUniforms(skyboxUniforms);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexParamOffset, 0);
|
||||||
|
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
if (depthOnlyEnabled)
|
if (depthOnlyEnabled)
|
||||||
{
|
{
|
||||||
// Draw the depth buffer as a grayscale image
|
// Draw the depth buffer as a grayscale image
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, LoadOp.DontCare));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, LoadOp.DontCare));
|
||||||
|
|
||||||
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
||||||
cmdbuf.BindVertexBuffers(blitVertexBuffer);
|
cmdbuf.BindVertexBuffers(blitVertexBuffer);
|
||||||
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(depthUniforms);
|
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(depthUniforms);
|
||||||
cmdbuf.DrawPrimitives(0, 2, vertexParamOffset, fragParamOffset);
|
cmdbuf.DrawPrimitives(0, 2, vertexParamOffset, fragParamOffset);
|
||||||
|
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
||||||
if (takeScreenshot)
|
if (takeScreenshot)
|
||||||
{
|
{
|
||||||
|
@ -448,7 +448,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
takeScreenshot = false;
|
takeScreenshot = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private System.Action<object?> TakeScreenshot = texture =>
|
private System.Action<object?> TakeScreenshot = texture =>
|
||||||
{
|
{
|
||||||
|
@ -458,10 +458,10 @@ namespace MoonWorks.Test
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CubeGame game = new CubeGame();
|
CubeGame game = new CubeGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,12 +185,12 @@ namespace MoonWorks.Test
|
||||||
cubeIndexBuffer,
|
cubeIndexBuffer,
|
||||||
new uint[]
|
new uint[]
|
||||||
{
|
{
|
||||||
0, 1, 2, 0, 2, 3,
|
0, 1, 2, 0, 2, 3,
|
||||||
6, 5, 4, 7, 6, 4,
|
6, 5, 4, 7, 6, 4,
|
||||||
8, 9, 10, 8, 10, 11,
|
8, 9, 10, 8, 10, 11,
|
||||||
14, 13, 12, 15, 14, 12,
|
14, 13, 12, 15, 14, 12,
|
||||||
16, 17, 18, 16, 18, 19,
|
16, 17, 18, 16, 18, 19,
|
||||||
22, 21, 20, 23, 22, 20
|
22, 21, 20, 23, 22, 20
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -5,77 +5,77 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class DrawIndirectGame : Game
|
class DrawIndirectGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline graphicsPipeline;
|
private GraphicsPipeline graphicsPipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer drawBuffer;
|
private Buffer drawBuffer;
|
||||||
|
|
||||||
public DrawIndirectGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public DrawIndirectGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColor.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColor.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
||||||
graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the vertex buffer
|
// Create and populate the vertex buffer
|
||||||
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
|
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 6);
|
||||||
drawBuffer = Buffer.Create<IndirectDrawCommand>(GraphicsDevice, BufferUsageFlags.Indirect, 2);
|
drawBuffer = Buffer.Create<IndirectDrawCommand>(GraphicsDevice, BufferUsageFlags.Indirect, 2);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionColorVertex[]
|
new PositionColorVertex[]
|
||||||
{
|
{
|
||||||
new PositionColorVertex(new Vector3(-0.5f, -1, 0), Color.Blue),
|
new PositionColorVertex(new Vector3(-0.5f, -1, 0), Color.Blue),
|
||||||
new PositionColorVertex(new Vector3(-1f, 1, 0), Color.Green),
|
new PositionColorVertex(new Vector3(-1f, 1, 0), Color.Green),
|
||||||
new PositionColorVertex(new Vector3(0f, 1, 0), Color.Red),
|
new PositionColorVertex(new Vector3(0f, 1, 0), Color.Red),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(.5f, -1, 0), Color.Blue),
|
new PositionColorVertex(new Vector3(.5f, -1, 0), Color.Blue),
|
||||||
new PositionColorVertex(new Vector3(1f, 1, 0), Color.Green),
|
new PositionColorVertex(new Vector3(1f, 1, 0), Color.Green),
|
||||||
new PositionColorVertex(new Vector3(0f, 1, 0), Color.Red),
|
new PositionColorVertex(new Vector3(0f, 1, 0), Color.Red),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
drawBuffer,
|
drawBuffer,
|
||||||
new IndirectDrawCommand[]
|
new IndirectDrawCommand[]
|
||||||
{
|
{
|
||||||
new IndirectDrawCommand(3, 1, 3, 0),
|
new IndirectDrawCommand(3, 1, 3, 0),
|
||||||
new IndirectDrawCommand(3, 1, 0, 0),
|
new IndirectDrawCommand(3, 1, 0, 0),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
||||||
cmdbuf.BindGraphicsPipeline(graphicsPipeline);
|
cmdbuf.BindGraphicsPipeline(graphicsPipeline);
|
||||||
cmdbuf.BindVertexBuffers(new BufferBinding(vertexBuffer, 0));
|
cmdbuf.BindVertexBuffers(new BufferBinding(vertexBuffer, 0));
|
||||||
cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<IndirectDrawCommand>(), 0, 0);
|
cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<IndirectDrawCommand>(), 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
DrawIndirectGame game = new DrawIndirectGame();
|
DrawIndirectGame game = new DrawIndirectGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,109 +5,109 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class GetBufferDataGame : Game
|
class GetBufferDataGame : Game
|
||||||
{
|
{
|
||||||
public GetBufferDataGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public GetBufferDataGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
PositionVertex[] vertices = new PositionVertex[]
|
PositionVertex[] vertices = new PositionVertex[]
|
||||||
{
|
{
|
||||||
new PositionVertex(new Vector3(0, 0, 0)),
|
new PositionVertex(new Vector3(0, 0, 0)),
|
||||||
new PositionVertex(new Vector3(0, 0, 1)),
|
new PositionVertex(new Vector3(0, 0, 1)),
|
||||||
new PositionVertex(new Vector3(0, 1, 0)),
|
new PositionVertex(new Vector3(0, 1, 0)),
|
||||||
new PositionVertex(new Vector3(0, 1, 1)),
|
new PositionVertex(new Vector3(0, 1, 1)),
|
||||||
new PositionVertex(new Vector3(1, 0, 0)),
|
new PositionVertex(new Vector3(1, 0, 0)),
|
||||||
new PositionVertex(new Vector3(1, 0, 1)),
|
new PositionVertex(new Vector3(1, 0, 1)),
|
||||||
new PositionVertex(new Vector3(1, 1, 0)),
|
new PositionVertex(new Vector3(1, 1, 0)),
|
||||||
new PositionVertex(new Vector3(1, 1, 1)),
|
new PositionVertex(new Vector3(1, 1, 1)),
|
||||||
};
|
};
|
||||||
|
|
||||||
PositionVertex[] otherVerts = new PositionVertex[]
|
PositionVertex[] otherVerts = new PositionVertex[]
|
||||||
{
|
{
|
||||||
new PositionVertex(new Vector3(1, 2, 3)),
|
new PositionVertex(new Vector3(1, 2, 3)),
|
||||||
new PositionVertex(new Vector3(4, 5, 6)),
|
new PositionVertex(new Vector3(4, 5, 6)),
|
||||||
new PositionVertex(new Vector3(7, 8, 9))
|
new PositionVertex(new Vector3(7, 8, 9))
|
||||||
};
|
};
|
||||||
|
|
||||||
int vertexSize = Marshal.SizeOf<PositionVertex>();
|
int vertexSize = Marshal.SizeOf<PositionVertex>();
|
||||||
|
|
||||||
Buffer vertexBuffer = Buffer.Create<PositionVertex>(
|
Buffer vertexBuffer = Buffer.Create<PositionVertex>(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
BufferUsageFlags.Vertex,
|
BufferUsageFlags.Vertex,
|
||||||
(uint) vertices.Length
|
(uint) vertices.Length
|
||||||
);
|
);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(vertexBuffer, vertices);
|
cmdbuf.SetBufferData(vertexBuffer, vertices);
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
|
|
||||||
// Wait for the vertices to finish uploading...
|
// Wait for the vertices to finish uploading...
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Read back and print out the vertex values
|
// Read back and print out the vertex values
|
||||||
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
|
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
|
||||||
vertexBuffer.GetData(readbackVertices);
|
vertexBuffer.GetData(readbackVertices);
|
||||||
for (int i = 0; i < readbackVertices.Length; i += 1)
|
for (int i = 0; i < readbackVertices.Length; i += 1)
|
||||||
{
|
{
|
||||||
Logger.LogInfo(readbackVertices[i].ToString());
|
Logger.LogInfo(readbackVertices[i].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the first three vertices
|
// Change the first three vertices
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(vertexBuffer, otherVerts);
|
cmdbuf.SetBufferData(vertexBuffer, otherVerts);
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Read the updated buffer
|
// Read the updated buffer
|
||||||
vertexBuffer.GetData(readbackVertices);
|
vertexBuffer.GetData(readbackVertices);
|
||||||
Logger.LogInfo("=== Change first three vertices ===");
|
Logger.LogInfo("=== Change first three vertices ===");
|
||||||
for (int i = 0; i < readbackVertices.Length; i += 1)
|
for (int i = 0; i < readbackVertices.Length; i += 1)
|
||||||
{
|
{
|
||||||
Logger.LogInfo(readbackVertices[i].ToString());
|
Logger.LogInfo(readbackVertices[i].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the last two vertices
|
// Change the last two vertices
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
otherVerts,
|
otherVerts,
|
||||||
(uint) (vertexSize * (vertices.Length - 2)),
|
(uint) (vertexSize * (vertices.Length - 2)),
|
||||||
1,
|
1,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Read the updated buffer
|
// Read the updated buffer
|
||||||
vertexBuffer.GetData(readbackVertices);
|
vertexBuffer.GetData(readbackVertices);
|
||||||
Logger.LogInfo("=== Change last two vertices ===");
|
Logger.LogInfo("=== Change last two vertices ===");
|
||||||
for (int i = 0; i < readbackVertices.Length; i += 1)
|
for (int i = 0; i < readbackVertices.Length; i += 1)
|
||||||
{
|
{
|
||||||
Logger.LogInfo(readbackVertices[i].ToString());
|
Logger.LogInfo(readbackVertices[i].ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? swapchainTexture = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (swapchainTexture != null)
|
if (swapchainTexture != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, Color.Black));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
GetBufferDataGame game = new GetBufferDataGame();
|
GetBufferDataGame game = new GetBufferDataGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,103 +4,103 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class InstancingAndOffsetsGame : Game
|
class InstancingAndOffsetsGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
|
|
||||||
private bool useVertexOffset;
|
private bool useVertexOffset;
|
||||||
private bool useIndexOffset;
|
private bool useIndexOffset;
|
||||||
|
|
||||||
public InstancingAndOffsetsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public InstancingAndOffsetsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left to toggle vertex offset\nPress Right to toggle index offset");
|
Logger.LogInfo("Press Left to toggle vertex offset\nPress Right to toggle index offset");
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColorInstanced.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionColorInstanced.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionColorVertex>();
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the vertex and index buffers
|
// Create and populate the vertex and index buffers
|
||||||
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 9);
|
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 9);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionColorVertex[]
|
new PositionColorVertex[]
|
||||||
{
|
{
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
|
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
|
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
|
||||||
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
|
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Orange),
|
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Orange),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 0), Color.Green),
|
new PositionColorVertex(new Vector3(1, 1, 0), Color.Green),
|
||||||
new PositionColorVertex(new Vector3(0, -1, 0), Color.Aqua),
|
new PositionColorVertex(new Vector3(0, -1, 0), Color.Aqua),
|
||||||
|
|
||||||
new PositionColorVertex(new Vector3(-1, 1, 0), Color.White),
|
new PositionColorVertex(new Vector3(-1, 1, 0), Color.White),
|
||||||
new PositionColorVertex(new Vector3(1, 1, 0), Color.White),
|
new PositionColorVertex(new Vector3(1, 1, 0), Color.White),
|
||||||
new PositionColorVertex(new Vector3(0, -1, 0), Color.White),
|
new PositionColorVertex(new Vector3(0, -1, 0), Color.White),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
3, 4, 5,
|
3, 4, 5,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
useVertexOffset = !useVertexOffset;
|
useVertexOffset = !useVertexOffset;
|
||||||
Logger.LogInfo("Using vertex offset: " + useVertexOffset);
|
Logger.LogInfo("Using vertex offset: " + useVertexOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
useIndexOffset = !useIndexOffset;
|
useIndexOffset = !useIndexOffset;
|
||||||
Logger.LogInfo("Using index offset: " + useIndexOffset);
|
Logger.LogInfo("Using index offset: " + useIndexOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
uint vertexOffset = useVertexOffset ? 3u : 0;
|
uint vertexOffset = useVertexOffset ? 3u : 0;
|
||||||
uint indexOffset = useIndexOffset ? 3u : 0;
|
uint indexOffset = useIndexOffset ? 3u : 0;
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.DrawInstancedPrimitives(vertexOffset, indexOffset, 1, 16, 0, 0);
|
cmdbuf.DrawInstancedPrimitives(vertexOffset, indexOffset, 1, 16, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
InstancingAndOffsetsGame p = new InstancingAndOffsetsGame();
|
InstancingAndOffsetsGame p = new InstancingAndOffsetsGame();
|
||||||
p.Run();
|
p.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Binary file not shown.
|
@ -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;
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -36,7 +36,7 @@
|
||||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="..\..\moonlibs\windows\libdav1dfile.*">
|
<Content Include="..\..\moonlibs\lib64\libdav1dfile.*">
|
||||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -56,80 +56,80 @@ namespace MoonWorks.Test
|
||||||
return SDL2.SDL.SDL_GetBasePath() + "Content/Textures/" + textureName;
|
return SDL2.SDL.SDL_GetBasePath() + "Content/Textures/" + textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetVideoPath(string videoName)
|
public static string GetVideoPath(string videoName)
|
||||||
{
|
{
|
||||||
return SDL2.SDL.SDL_GetBasePath() + "Content/Videos/" + videoName;
|
return SDL2.SDL.SDL_GetBasePath() + "Content/Videos/" + videoName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ButtonType
|
public enum ButtonType
|
||||||
{
|
{
|
||||||
Left, // A/left arrow on keyboard, left face button on gamepad
|
Left, // A/left arrow on keyboard, left face button on gamepad
|
||||||
Bottom, // S/down arrow on keyboard, bottom 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
|
Right // D/right arrow on keyboard, right face button on gamepad
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckButtonPressed(Input.Inputs inputs, ButtonType buttonType)
|
public static bool CheckButtonPressed(Input.Inputs inputs, ButtonType buttonType)
|
||||||
{
|
{
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
|
|
||||||
if (buttonType == ButtonType.Left)
|
if (buttonType == ButtonType.Left)
|
||||||
{
|
{
|
||||||
pressed = (
|
pressed = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsPressed) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsPressed) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.A) ||
|
inputs.Keyboard.IsPressed(Input.KeyCode.A) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.Left)
|
inputs.Keyboard.IsPressed(Input.KeyCode.Left)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (buttonType == ButtonType.Bottom)
|
else if (buttonType == ButtonType.Bottom)
|
||||||
{
|
{
|
||||||
pressed = (
|
pressed = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsPressed) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsPressed) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.S) ||
|
inputs.Keyboard.IsPressed(Input.KeyCode.S) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.Down)
|
inputs.Keyboard.IsPressed(Input.KeyCode.Down)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (buttonType == ButtonType.Right)
|
else if (buttonType == ButtonType.Right)
|
||||||
{
|
{
|
||||||
pressed = (
|
pressed = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsPressed) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsPressed) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.D) ||
|
inputs.Keyboard.IsPressed(Input.KeyCode.D) ||
|
||||||
inputs.Keyboard.IsPressed(Input.KeyCode.Right)
|
inputs.Keyboard.IsPressed(Input.KeyCode.Right)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckButtonDown(Input.Inputs inputs, ButtonType buttonType)
|
public static bool CheckButtonDown(Input.Inputs inputs, ButtonType buttonType)
|
||||||
{
|
{
|
||||||
bool down = false;
|
bool down = false;
|
||||||
|
|
||||||
if (buttonType == ButtonType.Left)
|
if (buttonType == ButtonType.Left)
|
||||||
{
|
{
|
||||||
down = (
|
down = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsDown) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadLeft.IsDown) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.A) ||
|
inputs.Keyboard.IsDown(Input.KeyCode.A) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.Left)
|
inputs.Keyboard.IsDown(Input.KeyCode.Left)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (buttonType == ButtonType.Bottom)
|
else if (buttonType == ButtonType.Bottom)
|
||||||
{
|
{
|
||||||
down = (
|
down = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsDown) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadDown.IsDown) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.S) ||
|
inputs.Keyboard.IsDown(Input.KeyCode.S) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.Down)
|
inputs.Keyboard.IsDown(Input.KeyCode.Down)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (buttonType == ButtonType.Right)
|
else if (buttonType == ButtonType.Right)
|
||||||
{
|
{
|
||||||
down = (
|
down = (
|
||||||
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsDown) ||
|
(inputs.GamepadExists(0) && inputs.GetGamepad(0).DpadRight.IsDown) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.D) ||
|
inputs.Keyboard.IsDown(Input.KeyCode.D) ||
|
||||||
inputs.Keyboard.IsDown(Input.KeyCode.Right)
|
inputs.Keyboard.IsDown(Input.KeyCode.Right)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return down;
|
return down;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
public struct TransformVertexUniform
|
public struct TransformVertexUniform
|
||||||
{
|
{
|
||||||
public Matrix4x4 ViewProjection;
|
public Matrix4x4 ViewProjection;
|
||||||
|
|
||||||
public TransformVertexUniform(Matrix4x4 viewProjection)
|
public TransformVertexUniform(Matrix4x4 viewProjection)
|
||||||
{
|
{
|
||||||
ViewProjection = viewProjection;
|
ViewProjection = viewProjection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ namespace MoonWorks.Test
|
||||||
};
|
};
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Position.ToString();
|
return Position.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct PositionColorVertex : IVertexType
|
public struct PositionColorVertex : IVertexType
|
||||||
{
|
{
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
|
@ -67,9 +67,9 @@ namespace MoonWorks.Test
|
||||||
VertexElementFormat.Vector2
|
VertexElementFormat.Vector2
|
||||||
};
|
};
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Position + " | " + TexCoord;
|
return Position + " | " + TexCoord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,144 +57,138 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicStencil", "BasicStenci
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthMSAA", "DepthMSAA\DepthMSAA.csproj", "{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthMSAA", "DepthMSAA\DepthMSAA.csproj", "{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}"
|
||||||
EndProject
|
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
|
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
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture2D", "RenderTexture2D\RenderTexture2D.csproj", "{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteBatch", "SpriteBatch\SpriteBatch.csproj", "{40E25B99-1196-4695-99A6-C0A8EF385539}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSAACube", "MSAACube\MSAACube.csproj", "{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|x64 = Debug|x64
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Debug|x64.Build.0 = Debug|x64
|
||||||
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|x64.ActiveCfg = Release|x64
|
||||||
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{595FE5AC-8699-494D-816A-89A2DE3786FB}.Release|x64.Build.0 = Release|x64
|
||||||
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Debug|x64.Build.0 = Debug|x64
|
||||||
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|x64.ActiveCfg = Release|x64
|
||||||
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C9B46D3A-1FA4-426E-BF84-F068FD6E0CC4}.Release|x64.Build.0 = Release|x64
|
||||||
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Debug|x64.Build.0 = Debug|x64
|
||||||
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|x64.ActiveCfg = Release|x64
|
||||||
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3EB54E8A-3C4E-4EE2-9DD2-6D345A92319A}.Release|x64.Build.0 = Release|x64
|
||||||
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Debug|x64.Build.0 = Debug|x64
|
||||||
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|x64.ActiveCfg = Release|x64
|
||||||
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6567E2AD-189C-4994-9A27-72FB57546B8A}.Release|x64.Build.0 = Release|x64
|
||||||
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{550D1B95-B475-4EF8-A235-626505D7710F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{550D1B95-B475-4EF8-A235-626505D7710F}.Release|x64.Build.0 = Release|x64
|
||||||
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{970D18B0-0D05-4360-8208-41A2769C647E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{970D18B0-0D05-4360-8208-41A2769C647E}.Release|x64.Build.0 = Release|x64
|
||||||
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Debug|x64.Build.0 = Debug|x64
|
||||||
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|x64.ActiveCfg = Release|x64
|
||||||
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B9DE9133-9C1C-4592-927A-D3485CB493A2}.Release|x64.Build.0 = Release|x64
|
||||||
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|x64.ActiveCfg = Release|x64
|
||||||
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{22173AEA-9E5A-4DA8-B943-DEC1EA67232F}.Release|x64.Build.0 = Release|x64
|
||||||
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Debug|x64.Build.0 = Debug|x64
|
||||||
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|x64.ActiveCfg = Release|x64
|
||||||
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7EC935B1-DCD1-4ADD-96C8-614B4CA76501}.Release|x64.Build.0 = Release|x64
|
||||||
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{37BDB4E6-FCDC-4F04-A9E3-C6B9D6C3AB4E}.Release|x64.Build.0 = Release|x64
|
||||||
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Debug|x64.Build.0 = Debug|x64
|
||||||
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|x64.ActiveCfg = Release|x64
|
||||||
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1695B1D8-4935-490C-A5EC-E2F2AA94B150}.Release|x64.Build.0 = Release|x64
|
||||||
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Debug|x64.Build.0 = Debug|x64
|
||||||
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|x64.ActiveCfg = Release|x64
|
||||||
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C3808AFD-23DD-4622-BFA7-981A344D0C19}.Release|x64.Build.0 = Release|x64
|
||||||
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{68D47057-BBCB-4F86-9C0A-D6D730B18D9E}.Release|x64.Build.0 = Release|x64
|
||||||
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Debug|x64.Build.0 = Debug|x64
|
||||||
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|x64.ActiveCfg = Release|x64
|
||||||
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5F8BBD49-6C39-4186-A4A3-91D6662D3ABD}.Release|x64.Build.0 = Release|x64
|
||||||
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Debug|x64.Build.0 = Debug|x64
|
||||||
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|x64.ActiveCfg = Release|x64
|
||||||
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CA6E0ACF-3698-452F-B71F-51286EB5E1B2}.Release|x64.Build.0 = Release|x64
|
||||||
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Debug|x64.Build.0 = Debug|x64
|
||||||
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|x64.ActiveCfg = Release|x64
|
||||||
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E90D236C-BD0F-4420-ADD0-867D21F4DCA5}.Release|x64.Build.0 = Release|x64
|
||||||
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Debug|x64.Build.0 = Debug|x64
|
||||||
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|x64.ActiveCfg = Release|x64
|
||||||
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CF25A5A2-A0BD-4C9B-BB07-19CCD97C1C4E}.Release|x64.Build.0 = Release|x64
|
||||||
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Debug|x64.Build.0 = Debug|x64
|
||||||
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|x64.ActiveCfg = Release|x64
|
||||||
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FCD63849-9D3C-4D48-A8BD-39671096F03A}.Release|x64.Build.0 = Release|x64
|
||||||
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Debug|x64.Build.0 = Debug|x64
|
||||||
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|x64.ActiveCfg = Release|x64
|
||||||
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9D0F0573-7FD4-4480-8F9B-CDD52120A170}.Release|x64.Build.0 = Release|x64
|
||||||
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Debug|x64.Build.0 = Debug|x64
|
||||||
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|x64.ActiveCfg = Release|x64
|
||||||
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5CDA8D41-F96C-4DE7-AD53-5A76C4C0CC31}.Release|x64.Build.0 = Release|x64
|
||||||
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C525B6DE-3003-45D5-BB83-89679B108C08}.Debug|x64.Build.0 = Debug|x64
|
||||||
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|x64.ActiveCfg = Release|x64
|
||||||
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C525B6DE-3003-45D5-BB83-89679B108C08}.Release|x64.Build.0 = Release|x64
|
||||||
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Debug|x64.Build.0 = Debug|x64
|
||||||
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|x64.ActiveCfg = Release|x64
|
||||||
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}.Release|x64.Build.0 = Release|x64
|
||||||
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D7A8452F-123F-4965-8716-9E39F677A831}.Debug|x64.Build.0 = Debug|x64
|
||||||
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|x64.ActiveCfg = Release|x64
|
||||||
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D7A8452F-123F-4965-8716-9E39F677A831}.Release|x64.Build.0 = Release|x64
|
||||||
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Debug|x64.Build.0 = Debug|x64
|
||||||
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|x64.ActiveCfg = Release|x64
|
||||||
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2219C628-5593-4C23-86CB-0E1E96EBD6C5}.Release|x64.Build.0 = Release|x64
|
||||||
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Debug|x64.Build.0 = Debug|x64
|
||||||
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.ActiveCfg = Release|x64
|
||||||
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5A1AC35B-EF18-426D-A633-D4899E84EAA7}.Release|x64.Build.0 = Release|x64
|
||||||
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Debug|x64.Build.0 = Debug|x64
|
||||||
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|x64.ActiveCfg = Release|x64
|
||||||
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1B370BAD-966A-49B2-9EA0-2463F6C8F9AD}.Release|x64.Build.0 = Release|x64
|
||||||
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Debug|x64.Build.0 = Debug|x64
|
||||||
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|x64.ActiveCfg = Release|x64
|
||||||
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B36C9F65-F3F4-4EB4-8EBF-A1EDCD4261F8}.Release|x64.Build.0 = Release|x64
|
||||||
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{AF5F2804-663D-4C46-BD02-AB178002180B}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AF5F2804-663D-4C46-BD02-AB178002180B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Debug|x64.Build.0 = Debug|x64
|
||||||
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.ActiveCfg = Release|x64
|
||||||
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CD31F1B5-C76A-428A-A812-8DFD6CAB20A9}.Release|x64.Build.0 = Release|x64
|
||||||
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{40E25B99-1196-4695-99A6-C0A8EF385539}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{40E25B99-1196-4695-99A6-C0A8EF385539}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{40E25B99-1196-4695-99A6-C0A8EF385539}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{F9C9E15D-1000-46DA-BA39-1D4C0D43F023}.Release|Any CPU.Build.0 = Release|Any CPU
|
{40E25B99-1196-4695-99A6-C0A8EF385539}.Release|x64.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
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
12
README.md
12
README.md
|
@ -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.
|
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**
|
**TexturedQuad**
|
||||||
|
|
||||||
Draws a textured quad to the screen. Tests texture binding, index buffers, and sampler states.
|
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.
|
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**
|
**RenderTexture3D**
|
||||||
|
|
||||||
Fades through 2D slices of a 3D render texture. Tests binding and sampling 3D render textures.
|
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.
|
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**
|
**WindowResizing**
|
||||||
|
|
||||||
Tests resizing the window to various resolutions.
|
Tests resizing the window to various resolutions.
|
||||||
|
|
|
@ -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>
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,130 +5,130 @@ using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class RenderTexture3DGame : Game
|
class RenderTexture3DGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture rt;
|
private Texture rt;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
private float t;
|
private float t;
|
||||||
private Color[] colors = new Color[]
|
private Color[] colors = new Color[]
|
||||||
{
|
{
|
||||||
Color.Red,
|
Color.Red,
|
||||||
Color.Green,
|
Color.Green,
|
||||||
Color.Blue,
|
Color.Blue,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FragUniform
|
struct FragUniform
|
||||||
{
|
{
|
||||||
public float Depth;
|
public float Depth;
|
||||||
|
|
||||||
public FragUniform(float depth)
|
public FragUniform(float depth)
|
||||||
{
|
{
|
||||||
Depth = depth;
|
Depth = depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderTexture3DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public RenderTexture3DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad3D.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad3D.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragUniform>(fragShaderModule, "main", 1);
|
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragUniform>(fragShaderModule, "main", 1);
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create samplers
|
// Create samplers
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
rt = Texture.CreateTexture3D(
|
rt = Texture.CreateTexture3D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
(uint) colors.Length,
|
(uint) colors.Length,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
|
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clear each depth slice of the RT to a different color
|
// Clear each depth slice of the RT to a different color
|
||||||
for (uint i = 0; i < colors.Length; i += 1)
|
for (uint i = 0; i < colors.Length; i += 1)
|
||||||
{
|
{
|
||||||
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
||||||
{
|
{
|
||||||
Texture = rt,
|
Texture = rt,
|
||||||
ClearColor = colors[i],
|
ClearColor = colors[i],
|
||||||
Depth = i,
|
Depth = i,
|
||||||
Layer = 0,
|
Layer = 0,
|
||||||
Level = 0,
|
Level = 0,
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store
|
||||||
};
|
};
|
||||||
cmdbuf.BeginRenderPass(attachmentInfo);
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
t += 0.01f;
|
t += 0.01f;
|
||||||
FragUniform fragUniform = new FragUniform(t);
|
FragUniform fragUniform = new FragUniform(t);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, sampler));
|
||||||
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniform);
|
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniform);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, fragParamOffset);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, fragParamOffset);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RenderTexture3DGame game = new RenderTexture3DGame();
|
RenderTexture3DGame game = new RenderTexture3DGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,171 +6,171 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class RenderTextureCubeGame : Game
|
class RenderTextureCubeGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture cubemap;
|
private Texture cubemap;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
private Vector3 camPos = new Vector3(0, 0, 4f);
|
private Vector3 camPos = new Vector3(0, 0, 4f);
|
||||||
|
|
||||||
private Color[] colors = new Color[]
|
private Color[] colors = new Color[]
|
||||||
{
|
{
|
||||||
Color.Red,
|
Color.Red,
|
||||||
Color.Green,
|
Color.Green,
|
||||||
Color.Blue,
|
Color.Blue,
|
||||||
Color.Orange,
|
Color.Orange,
|
||||||
Color.Yellow,
|
Color.Yellow,
|
||||||
Color.Purple,
|
Color.Purple,
|
||||||
};
|
};
|
||||||
|
|
||||||
public RenderTextureCubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public RenderTextureCubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Down to view the other side of the cubemap");
|
Logger.LogInfo("Press Down to view the other side of the cubemap");
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("Skybox.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionVertex>();
|
||||||
pipelineCreateInfo.VertexShaderInfo.UniformBufferSize = (uint) Marshal.SizeOf<TransformVertexUniform>();
|
pipelineCreateInfo.VertexShaderInfo.UniformBufferSize = (uint) Marshal.SizeOf<TransformVertexUniform>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create samplers
|
// Create samplers
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24);
|
vertexBuffer = Buffer.Create<PositionVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 36);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 36);
|
||||||
cubemap = Texture.CreateTextureCube(
|
cubemap = Texture.CreateTextureCube(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
16,
|
16,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
|
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
|
||||||
);
|
);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionVertex[]
|
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)),
|
||||||
|
|
||||||
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(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2, 0, 2, 3,
|
0, 1, 2, 0, 2, 3,
|
||||||
6, 5, 4, 7, 6, 4,
|
6, 5, 4, 7, 6, 4,
|
||||||
8, 9, 10, 8, 10, 11,
|
8, 9, 10, 8, 10, 11,
|
||||||
14, 13, 12, 15, 14, 12,
|
14, 13, 12, 15, 14, 12,
|
||||||
16, 17, 18, 16, 18, 19,
|
16, 17, 18, 16, 18, 19,
|
||||||
22, 21, 20, 23, 22, 20
|
22, 21, 20, 23, 22, 20
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clear each slice of the cubemap to a different color
|
// Clear each slice of the cubemap to a different color
|
||||||
for (uint i = 0; i < 6; i += 1)
|
for (uint i = 0; i < 6; i += 1)
|
||||||
{
|
{
|
||||||
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
||||||
{
|
{
|
||||||
Texture = cubemap,
|
Texture = cubemap,
|
||||||
ClearColor = colors[i],
|
ClearColor = colors[i],
|
||||||
Depth = 0,
|
Depth = 0,
|
||||||
Layer = i,
|
Layer = i,
|
||||||
Level = 0,
|
Level = 0,
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store
|
||||||
};
|
};
|
||||||
cmdbuf.BeginRenderPass(attachmentInfo);
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
|
||||||
{
|
{
|
||||||
camPos.Z *= -1;
|
camPos.Z *= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
|
Matrix4x4 proj = Matrix4x4.CreatePerspectiveFieldOfView(
|
||||||
MathHelper.ToRadians(75f),
|
MathHelper.ToRadians(75f),
|
||||||
(float) MainWindow.Width / MainWindow.Height,
|
(float) MainWindow.Width / MainWindow.Height,
|
||||||
0.01f,
|
0.01f,
|
||||||
100f
|
100f
|
||||||
);
|
);
|
||||||
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
Matrix4x4 view = Matrix4x4.CreateLookAt(
|
||||||
camPos,
|
camPos,
|
||||||
Vector3.Zero,
|
Vector3.Zero,
|
||||||
Vector3.Up
|
Vector3.Up
|
||||||
);
|
);
|
||||||
TransformVertexUniform vertUniforms = new TransformVertexUniform(view * proj);
|
TransformVertexUniform vertUniforms = new TransformVertexUniform(view * proj);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(cubemap, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(cubemap, sampler));
|
||||||
uint vertexUniformOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
uint vertexUniformOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexUniformOffset, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexUniformOffset, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RenderTextureCubeGame game = new RenderTextureCubeGame();
|
RenderTextureCubeGame game = new RenderTextureCubeGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,179 +4,179 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class RenderTextureMipmapsGame : Game
|
class RenderTextureMipmapsGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
|
|
||||||
private Sampler[] samplers = new Sampler[5];
|
private Sampler[] samplers = new Sampler[5];
|
||||||
|
|
||||||
private float scale = 0.5f;
|
private float scale = 0.5f;
|
||||||
private int currentSamplerIndex = 0;
|
private int currentSamplerIndex = 0;
|
||||||
private Color[] colors = new Color[]
|
private Color[] colors = new Color[]
|
||||||
{
|
{
|
||||||
Color.Red,
|
Color.Red,
|
||||||
Color.Green,
|
Color.Green,
|
||||||
Color.Blue,
|
Color.Blue,
|
||||||
Color.Yellow,
|
Color.Yellow,
|
||||||
};
|
};
|
||||||
|
|
||||||
private string GetSamplerString(int index)
|
private string GetSamplerString(int index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return "PointClamp";
|
return "PointClamp";
|
||||||
case 1:
|
case 1:
|
||||||
return "LinearClamp";
|
return "LinearClamp";
|
||||||
case 2:
|
case 2:
|
||||||
return "PointClamp with Mip LOD Bias = 0.25";
|
return "PointClamp with Mip LOD Bias = 0.25";
|
||||||
case 3:
|
case 3:
|
||||||
return "PointClamp with Min LOD = 1";
|
return "PointClamp with Min LOD = 1";
|
||||||
case 4:
|
case 4:
|
||||||
return "PointClamp with Max LOD = 1";
|
return "PointClamp with Max LOD = 1";
|
||||||
default:
|
default:
|
||||||
throw new System.Exception("Unknown sampler!");
|
throw new System.Exception("Unknown sampler!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderTextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public RenderTextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad");
|
Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad");
|
||||||
Logger.LogInfo("Press Down to cycle through sampler states");
|
Logger.LogInfo("Press Down to cycle through sampler states");
|
||||||
Logger.LogInfo(GetSamplerString(currentSamplerIndex));
|
Logger.LogInfo(GetSamplerString(currentSamplerIndex));
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
|
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create samplers
|
// Create samplers
|
||||||
SamplerCreateInfo samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
SamplerCreateInfo samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
||||||
samplers[0] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
samplers[0] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
||||||
|
|
||||||
samplerCreateInfo = SamplerCreateInfo.LinearClamp;
|
samplerCreateInfo = SamplerCreateInfo.LinearClamp;
|
||||||
samplers[1] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
samplers[1] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
||||||
|
|
||||||
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
||||||
samplerCreateInfo.MipLodBias = 0.25f;
|
samplerCreateInfo.MipLodBias = 0.25f;
|
||||||
samplers[2] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
samplers[2] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
||||||
|
|
||||||
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
||||||
samplerCreateInfo.MinLod = 1;
|
samplerCreateInfo.MinLod = 1;
|
||||||
samplers[3] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
samplers[3] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
||||||
|
|
||||||
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
samplerCreateInfo = SamplerCreateInfo.PointClamp;
|
||||||
samplerCreateInfo.MaxLod = 1;
|
samplerCreateInfo.MaxLod = 1;
|
||||||
samplers[4] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
samplers[4] = new Sampler(GraphicsDevice, samplerCreateInfo);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
texture = Texture.CreateTexture2D(
|
texture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
MainWindow.Width,
|
MainWindow.Width,
|
||||||
MainWindow.Height,
|
MainWindow.Height,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
|
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
|
||||||
4
|
4
|
||||||
);
|
);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clear each mip level to a different color
|
// Clear each mip level to a different color
|
||||||
for (uint i = 0; i < texture.LevelCount; i += 1)
|
for (uint i = 0; i < texture.LevelCount; i += 1)
|
||||||
{
|
{
|
||||||
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
||||||
{
|
{
|
||||||
Texture = texture,
|
Texture = texture,
|
||||||
ClearColor = colors[i],
|
ClearColor = colors[i],
|
||||||
Depth = 0,
|
Depth = 0,
|
||||||
Layer = 0,
|
Layer = 0,
|
||||||
Level = i,
|
Level = i,
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store
|
||||||
};
|
};
|
||||||
cmdbuf.BeginRenderPass(attachmentInfo);
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
scale = System.MathF.Max(0.01f, scale - 0.01f);
|
scale = System.MathF.Max(0.01f, scale - 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
scale = System.MathF.Min(1f, scale + 0.01f);
|
scale = System.MathF.Min(1f, scale + 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Bottom))
|
||||||
{
|
{
|
||||||
currentSamplerIndex = (currentSamplerIndex + 1) % samplers.Length;
|
currentSamplerIndex = (currentSamplerIndex + 1) % samplers.Length;
|
||||||
Logger.LogInfo(GetSamplerString(currentSamplerIndex));
|
Logger.LogInfo(GetSamplerString(currentSamplerIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
|
TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, samplers[currentSamplerIndex]));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, samplers[currentSamplerIndex]));
|
||||||
uint vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
uint vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RenderTextureMipmapsGame game = new RenderTextureMipmapsGame();
|
RenderTextureMipmapsGame game = new RenderTextureMipmapsGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\MoonWorks\MoonWorks.csproj" />
|
<ProjectReference Include="..\..\MoonWorks\MoonWorks.csproj" />
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="$(SolutionDir)NativeAOT_Console.targets" Condition="Exists('$(SolutionDir)NativeAOT_Console.targets')" />
|
<Import Project="$(SolutionDir)NativeAOT_Console.targets" Condition="Exists('$(SolutionDir)NativeAOT_Console.targets')" />
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,143 +5,143 @@ using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class Texture3DGame : Game
|
class Texture3DGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
private int currentDepth = 0;
|
private int currentDepth = 0;
|
||||||
|
|
||||||
struct FragUniform
|
struct FragUniform
|
||||||
{
|
{
|
||||||
public float Depth;
|
public float Depth;
|
||||||
|
|
||||||
public FragUniform(float depth)
|
public FragUniform(float depth)
|
||||||
{
|
{
|
||||||
Depth = depth;
|
Depth = depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture3DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public Texture3DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left and Right to cycle between depth slices");
|
Logger.LogInfo("Press Left and Right to cycle between depth slices");
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad3D.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad3D.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragUniform>(fragShaderModule, "main", 1);
|
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragUniform>(fragShaderModule, "main", 1);
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create samplers
|
// Create samplers
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
texture = Texture.CreateTexture3D(GraphicsDevice, 16, 16, 7, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
texture = Texture.CreateTexture3D(GraphicsDevice, 16, 16, 7, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Load each depth subimage of the 3D texture
|
// Load each depth subimage of the 3D texture
|
||||||
for (uint i = 0; i < texture.Depth; i += 1)
|
for (uint i = 0; i < texture.Depth; i += 1)
|
||||||
{
|
{
|
||||||
TextureSlice slice = new TextureSlice(
|
TextureSlice slice = new TextureSlice(
|
||||||
texture,
|
texture,
|
||||||
new Rect(0, 0, (int) texture.Width, (int) texture.Height),
|
new Rect(0, 0, (int) texture.Width, (int) texture.Height),
|
||||||
i
|
i
|
||||||
);
|
);
|
||||||
|
|
||||||
Texture.SetDataFromImageFile(
|
Texture.SetDataFromImageFile(
|
||||||
cmdbuf,
|
cmdbuf,
|
||||||
slice,
|
slice,
|
||||||
TestUtils.GetTexturePath($"tex3d_{i}.png")
|
TestUtils.GetTexturePath($"tex3d_{i}.png")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
int prevDepth = currentDepth;
|
int prevDepth = currentDepth;
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
currentDepth -= 1;
|
currentDepth -= 1;
|
||||||
if (currentDepth < 0)
|
if (currentDepth < 0)
|
||||||
{
|
{
|
||||||
currentDepth = (int) texture.Depth - 1;
|
currentDepth = (int) texture.Depth - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
currentDepth += 1;
|
currentDepth += 1;
|
||||||
if (currentDepth >= texture.Depth)
|
if (currentDepth >= texture.Depth)
|
||||||
{
|
{
|
||||||
currentDepth = 0;
|
currentDepth = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevDepth != currentDepth)
|
if (prevDepth != currentDepth)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Setting depth to: " + currentDepth);
|
Logger.LogInfo("Setting depth to: " + currentDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
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();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
||||||
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniform);
|
uint fragParamOffset = cmdbuf.PushFragmentShaderUniforms(fragUniform);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, fragParamOffset);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, fragParamOffset);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Texture3DGame game = new Texture3DGame();
|
Texture3DGame game = new Texture3DGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,124 +5,124 @@ using RefreshCS;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class TextureMipmapsGame : Game
|
class TextureMipmapsGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
private float scale = 0.5f;
|
private float scale = 0.5f;
|
||||||
|
|
||||||
public TextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public TextureMipmapsGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad");
|
Logger.LogInfo("Press Left and Right to shrink/expand the scale of the quad");
|
||||||
|
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuadWithMatrix.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
|
pipelineCreateInfo.VertexShaderInfo = GraphicsShaderInfo.Create<TransformVertexUniform>(vertShaderModule, "main", 0);
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
texture = Texture.CreateTexture2D(
|
texture = Texture.CreateTexture2D(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
256,
|
256,
|
||||||
256,
|
256,
|
||||||
TextureFormat.R8G8B8A8,
|
TextureFormat.R8G8B8A8,
|
||||||
TextureUsageFlags.Sampler,
|
TextureUsageFlags.Sampler,
|
||||||
4
|
4
|
||||||
);
|
);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set the various mip levels
|
// Set the various mip levels
|
||||||
for (int i = 0; i < texture.LevelCount; i += 1)
|
for (int i = 0; i < texture.LevelCount; i += 1)
|
||||||
{
|
{
|
||||||
int w = (int) texture.Width >> i;
|
int w = (int) texture.Width >> i;
|
||||||
int h = (int) texture.Height >> i;
|
int h = (int) texture.Height >> i;
|
||||||
TextureSlice slice = new TextureSlice(
|
TextureSlice slice = new TextureSlice(
|
||||||
texture,
|
texture,
|
||||||
new Rect(0, 0, w, h),
|
new Rect(0, 0, w, h),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
(uint) i
|
(uint) i
|
||||||
);
|
);
|
||||||
|
|
||||||
Texture.SetDataFromImageFile(cmdbuf, slice, TestUtils.GetTexturePath($"mip{i}.png"));
|
Texture.SetDataFromImageFile(cmdbuf, slice, TestUtils.GetTexturePath($"mip{i}.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
scale = System.MathF.Max(0.01f, scale - 0.01f);
|
scale = System.MathF.Max(0.01f, scale - 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonDown(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
scale = System.MathF.Min(1f, scale + 0.01f);
|
scale = System.MathF.Min(1f, scale + 0.01f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
|
TransformVertexUniform vertUniforms = new TransformVertexUniform(Matrix4x4.CreateScale(scale, scale, 1));
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture, sampler));
|
||||||
uint vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
uint vertParamOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms);
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, vertParamOffset, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
TextureMipmapsGame game = new TextureMipmapsGame();
|
TextureMipmapsGame game = new TextureMipmapsGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,70 +4,70 @@ using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class VertexSamplerGame : Game
|
class VertexSamplerGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
|
|
||||||
public VertexSamplerGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public VertexSamplerGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionSampler.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("PositionSampler.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.VertexShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.VertexShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 3);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 3);
|
||||||
texture = Texture.CreateTexture2D(GraphicsDevice, 3, 1, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
texture = Texture.CreateTexture2D(GraphicsDevice, 3, 1, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(0.334f, 0)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(0.334f, 0)),
|
||||||
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(0.667f, 0)),
|
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(0.667f, 0)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetTextureData(texture, new Color[] { Color.Yellow, Color.Indigo, Color.HotPink });
|
cmdbuf.SetTextureData(texture, new Color[] { Color.Yellow, Color.Indigo, Color.HotPink });
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta) { }
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindVertexSamplers(new TextureSamplerBinding(texture, sampler));
|
cmdbuf.BindVertexSamplers(new TextureSamplerBinding(texture, sampler));
|
||||||
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
VertexSamplerGame p = new VertexSamplerGame();
|
VertexSamplerGame p = new VertexSamplerGame();
|
||||||
p.Run();
|
p.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,96 +4,96 @@ using MoonWorks.Video;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class VideoPlayerGame : Game
|
class VideoPlayerGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
private Buffer vertexBuffer;
|
private Buffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private Buffer indexBuffer;
|
||||||
|
|
||||||
private Video.VideoAV1 video;
|
private Video.VideoAV1 video;
|
||||||
private VideoPlayer videoPlayer;
|
private VideoPlayer videoPlayer;
|
||||||
|
|
||||||
public VideoPlayerGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public VideoPlayerGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
// Load the shaders
|
// Load the shaders
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create the sampler
|
// Create the sampler
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearClamp);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
new PositionTextureVertex[]
|
new PositionTextureVertex[]
|
||||||
{
|
{
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
cmdbuf.SetBufferData(
|
||||||
indexBuffer,
|
indexBuffer,
|
||||||
new ushort[]
|
new ushort[]
|
||||||
{
|
{
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
||||||
// Load the video
|
// Load the video
|
||||||
video = new VideoAV1(GraphicsDevice, TestUtils.GetVideoPath("hello.obu"), 25);
|
video = new VideoAV1(GraphicsDevice, TestUtils.GetVideoPath("hello.obu"), 25);
|
||||||
|
|
||||||
// Play the video
|
// Play the video
|
||||||
videoPlayer = new VideoPlayer(GraphicsDevice);
|
videoPlayer = new VideoPlayer(GraphicsDevice);
|
||||||
videoPlayer.Load(video);
|
videoPlayer.Load(video);
|
||||||
videoPlayer.Loop = true;
|
videoPlayer.Loop = true;
|
||||||
videoPlayer.Play();
|
videoPlayer.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
videoPlayer.Render();
|
videoPlayer.Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(videoPlayer.RenderTexture, sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(videoPlayer.RenderTexture, sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
VideoPlayerGame game = new VideoPlayerGame();
|
VideoPlayerGame game = new VideoPlayerGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,83 +3,83 @@ using MoonWorks.Graphics;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class WindowResizingGame : Game
|
class WindowResizingGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
|
|
||||||
private int currentResolutionIndex;
|
private int currentResolutionIndex;
|
||||||
private record struct Res(uint Width, uint Height);
|
private record struct Res(uint Width, uint Height);
|
||||||
private Res[] resolutions = new Res[]
|
private Res[] resolutions = new Res[]
|
||||||
{
|
{
|
||||||
new Res(640, 480),
|
new Res(640, 480),
|
||||||
new Res(1280, 720),
|
new Res(1280, 720),
|
||||||
new Res(1024, 1024),
|
new Res(1024, 1024),
|
||||||
new Res(1600, 900),
|
new Res(1600, 900),
|
||||||
new Res(1920, 1080),
|
new Res(1920, 1080),
|
||||||
new Res(3200, 1800),
|
new Res(3200, 1800),
|
||||||
new Res(3840, 2160),
|
new Res(3840, 2160),
|
||||||
};
|
};
|
||||||
|
|
||||||
public WindowResizingGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public WindowResizingGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||||
{
|
{
|
||||||
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert"));
|
ShaderModule vertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("RawTriangle.vert"));
|
||||||
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
ShaderModule fragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("SolidColor.frag"));
|
||||||
|
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
MainWindow.SwapchainFormat,
|
MainWindow.SwapchainFormat,
|
||||||
vertShaderModule,
|
vertShaderModule,
|
||||||
fragShaderModule
|
fragShaderModule
|
||||||
);
|
);
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
{
|
{
|
||||||
int prevResolutionIndex = currentResolutionIndex;
|
int prevResolutionIndex = currentResolutionIndex;
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Left))
|
||||||
{
|
{
|
||||||
currentResolutionIndex -= 1;
|
currentResolutionIndex -= 1;
|
||||||
if (currentResolutionIndex < 0)
|
if (currentResolutionIndex < 0)
|
||||||
{
|
{
|
||||||
currentResolutionIndex = resolutions.Length - 1;
|
currentResolutionIndex = resolutions.Length - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
if (TestUtils.CheckButtonPressed(Inputs, TestUtils.ButtonType.Right))
|
||||||
{
|
{
|
||||||
currentResolutionIndex += 1;
|
currentResolutionIndex += 1;
|
||||||
if (currentResolutionIndex >= resolutions.Length)
|
if (currentResolutionIndex >= resolutions.Length)
|
||||||
{
|
{
|
||||||
currentResolutionIndex = 0;
|
currentResolutionIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevResolutionIndex != currentResolutionIndex)
|
if (prevResolutionIndex != currentResolutionIndex)
|
||||||
{
|
{
|
||||||
Logger.LogInfo("Setting resolution to: " + resolutions[currentResolutionIndex]);
|
Logger.LogInfo("Setting resolution to: " + resolutions[currentResolutionIndex]);
|
||||||
MainWindow.SetWindowSize(resolutions[currentResolutionIndex].Width, resolutions[currentResolutionIndex].Height);
|
MainWindow.SetWindowSize(resolutions[currentResolutionIndex].Width, resolutions[currentResolutionIndex].Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
WindowResizingGame game = new WindowResizingGame();
|
WindowResizingGame game = new WindowResizingGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue