update bindings and WriteOptions API
parent
52f4e361ae
commit
0855bf6e26
|
@ -105,18 +105,18 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
// This should result in a bright yellow texture!
|
// This should result in a bright yellow texture!
|
||||||
cmdbuf.BindComputePipeline(fillTextureComputePipeline);
|
cmdbuf.BindComputePipeline(fillTextureComputePipeline);
|
||||||
cmdbuf.BindComputeTextures(new TextureLevelBinding(texture, 0));
|
cmdbuf.BindComputeTextures(new ComputeTextureBinding(texture, WriteOptions.SafeOverwrite));
|
||||||
cmdbuf.DispatchCompute(texture.Width / 8, texture.Height / 8, 1);
|
cmdbuf.DispatchCompute(texture.Width / 8, texture.Height / 8, 1);
|
||||||
|
|
||||||
// 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(new ComputeBufferBinding(squaresBuffer, WriteOptions.SafeOverwrite));
|
||||||
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1);
|
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1);
|
||||||
|
|
||||||
cmdbuf.EndComputePass();
|
cmdbuf.EndComputePass();
|
||||||
|
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.DownloadFromBuffer(squaresBuffer, transferBuffer);
|
cmdbuf.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Overwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
|
@ -136,7 +136,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, 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);
|
||||||
|
|
|
@ -89,8 +89,8 @@ namespace MoonWorks.Test
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthStencilTexture, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare),
|
new DepthStencilAttachmentInfo(depthStencilTexture, WriteOptions.SafeDiscard, new DepthStencilValue(0, 0), StoreOp.DontCare, StoreOp.DontCare),
|
||||||
new ColorAttachmentInfo(backbuffer, Color.Black)
|
new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Black)
|
||||||
);
|
);
|
||||||
cmdbuf.BindGraphicsPipeline(maskerPipeline);
|
cmdbuf.BindGraphicsPipeline(maskerPipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(useWireframeMode ? linePipeline : fillPipeline);
|
cmdbuf.BindGraphicsPipeline(useWireframeMode ? linePipeline : fillPipeline);
|
||||||
|
|
||||||
if (useSmallViewport)
|
if (useSmallViewport)
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.CornflowerBlue));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace MoonWorks.Test
|
||||||
backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.CornflowerBlue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.CornflowerBlue));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
@ -41,7 +41,7 @@ namespace MoonWorks.Test
|
||||||
backbuffer = cmdbuf.AcquireSwapchainTexture(secondaryWindow);
|
backbuffer = cmdbuf.AcquireSwapchainTexture(secondaryWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Aquamarine));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Aquamarine));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
cmdbuf.BeginComputePass();
|
cmdbuf.BeginComputePass();
|
||||||
cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
|
cmdbuf.BindComputePipeline(gradientTextureComputePipeline);
|
||||||
cmdbuf.BindComputeTextures(new TextureLevelBinding(texture, 0));
|
cmdbuf.BindComputeTextures(new ComputeTextureBinding(texture, 0));
|
||||||
cmdbuf.PushComputeShaderUniforms(gradientUniforms);
|
cmdbuf.PushComputeShaderUniforms(gradientUniforms);
|
||||||
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1);
|
cmdbuf.DispatchCompute(gradientUniforms.groupCountX, gradientUniforms.groupCountY, 1);
|
||||||
cmdbuf.EndComputePass();
|
cmdbuf.EndComputePass();
|
||||||
|
@ -113,7 +113,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, 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);
|
||||||
|
|
|
@ -88,6 +88,7 @@ namespace MoonWorks.Test
|
||||||
Height = originalTexture.Height,
|
Height = originalTexture.Height,
|
||||||
Depth = originalTexture.Depth,
|
Depth = originalTexture.Depth,
|
||||||
IsCube = originalTexture.IsCube,
|
IsCube = originalTexture.IsCube,
|
||||||
|
LayerCount = originalTexture.LayerCount,
|
||||||
LevelCount = originalTexture.LevelCount,
|
LevelCount = originalTexture.LevelCount,
|
||||||
SampleCount = originalTexture.SampleCount,
|
SampleCount = originalTexture.SampleCount,
|
||||||
Format = originalTexture.Format,
|
Format = originalTexture.Format,
|
||||||
|
@ -100,7 +101,8 @@ namespace MoonWorks.Test
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.CopyTextureToTexture(
|
cmdbuf.CopyTextureToTexture(
|
||||||
originalTexture,
|
originalTexture,
|
||||||
textureCopy
|
textureCopy,
|
||||||
|
WriteOptions.SafeOverwrite
|
||||||
);
|
);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
|
@ -111,16 +113,17 @@ namespace MoonWorks.Test
|
||||||
textureSmallCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
textureSmallCopy = new Texture(GraphicsDevice, textureCreateInfo);
|
||||||
|
|
||||||
// Render the half-size copy
|
// Render the half-size copy
|
||||||
cmdbuf.Blit(originalTexture, textureSmallCopy, Filter.Linear);
|
cmdbuf.Blit(originalTexture, textureSmallCopy, Filter.Linear, WriteOptions.SafeOverwrite);
|
||||||
|
|
||||||
// Copy the texture to a transfer buffer
|
// Copy the texture to a transfer buffer
|
||||||
TransferBuffer compareBuffer = new TransferBuffer(GraphicsDevice, byteCount);
|
TransferBuffer compareBuffer = new TransferBuffer(GraphicsDevice, byteCount);
|
||||||
|
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.DownloadFromTexture(
|
cmdbuf.DownloadFromTexture(
|
||||||
new TextureSlice(originalTexture),
|
originalTexture,
|
||||||
compareBuffer,
|
compareBuffer,
|
||||||
new BufferImageCopy(0, 0, 0)
|
new BufferImageCopy(0, 0, 0),
|
||||||
|
TransferOptions.Overwrite
|
||||||
);
|
);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
|
@ -156,7 +159,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -59,12 +59,14 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
for (uint i = 0; i < imagePaths.Length; i++)
|
for (uint i = 0; i < imagePaths.Length; i++)
|
||||||
{
|
{
|
||||||
var textureSlice = new TextureSlice
|
var textureRegion = new TextureRegion
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = skyboxTexture,
|
Texture = skyboxTexture,
|
||||||
MipLevel = 0,
|
MipLevel = 0,
|
||||||
BaseLayer = i,
|
Layer = i,
|
||||||
LayerCount = 1,
|
},
|
||||||
X = 0,
|
X = 0,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
Z = 0,
|
Z = 0,
|
||||||
|
@ -74,7 +76,7 @@ namespace MoonWorks.Test
|
||||||
};
|
};
|
||||||
|
|
||||||
cubemapUploader.SetTextureDataFromCompressed(
|
cubemapUploader.SetTextureDataFromCompressed(
|
||||||
textureSlice,
|
textureRegion,
|
||||||
imagePaths[i]
|
imagePaths[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -398,7 +400,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, clearColor));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -406,14 +408,14 @@ namespace MoonWorks.Test
|
||||||
if (!depthOnlyEnabled)
|
if (!depthOnlyEnabled)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0)),
|
new DepthStencilAttachmentInfo(depthTexture, WriteOptions.SafeDiscard, new DepthStencilValue(1f, 0)),
|
||||||
new ColorAttachmentInfo(swapchainTexture, LoadOp.DontCare)
|
new ColorAttachmentInfo(swapchainTexture, WriteOptions.SafeDiscard, LoadOp.DontCare)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthTexture, new DepthStencilValue(1f, 0))
|
new DepthStencilAttachmentInfo(depthTexture, WriteOptions.SafeDiscard, new DepthStencilValue(1f, 0), StoreOp.Store)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +439,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeOverwrite, LoadOp.Load));
|
||||||
|
|
||||||
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
||||||
|
@ -451,7 +453,7 @@ namespace MoonWorks.Test
|
||||||
if (takeScreenshot)
|
if (takeScreenshot)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture);
|
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture, WriteOptions.SafeOverwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
swapchainCopied = true;
|
swapchainCopied = true;
|
||||||
|
@ -477,7 +479,8 @@ namespace MoonWorks.Test
|
||||||
commandBuffer.BeginCopyPass();
|
commandBuffer.BeginCopyPass();
|
||||||
commandBuffer.DownloadFromTexture(
|
commandBuffer.DownloadFromTexture(
|
||||||
screenshotTexture,
|
screenshotTexture,
|
||||||
screenshotTransferBuffer
|
screenshotTransferBuffer,
|
||||||
|
TransferOptions.Overwrite
|
||||||
);
|
);
|
||||||
commandBuffer.EndCopyPass();
|
commandBuffer.EndCopyPass();
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
|
|
||||||
// Need to bind a pipeline before binding vertex buffers
|
// Need to bind a pipeline before binding vertex buffers
|
||||||
cmdbuf.BindGraphicsPipeline(CW_CullNonePipeline);
|
cmdbuf.BindGraphicsPipeline(CW_CullNonePipeline);
|
||||||
|
|
|
@ -8,15 +8,11 @@ namespace MoonWorks.Test
|
||||||
class DepthMSAAGame : Game
|
class DepthMSAAGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline[] cubePipelines = new GraphicsPipeline[4];
|
private GraphicsPipeline[] cubePipelines = new GraphicsPipeline[4];
|
||||||
private GraphicsPipeline blitPipeline;
|
|
||||||
private Texture[] renderTargets = new Texture[4];
|
private Texture[] renderTargets = new Texture[4];
|
||||||
private Texture[] depthRTs = new Texture[4];
|
private Texture[] depthRTs = new Texture[4];
|
||||||
private Sampler rtSampler;
|
|
||||||
private GpuBuffer cubeVertexBuffer1;
|
private GpuBuffer cubeVertexBuffer1;
|
||||||
private GpuBuffer cubeVertexBuffer2;
|
private GpuBuffer cubeVertexBuffer2;
|
||||||
private GpuBuffer cubeIndexBuffer;
|
private GpuBuffer cubeIndexBuffer;
|
||||||
private GpuBuffer quadVertexBuffer;
|
|
||||||
private GpuBuffer quadIndexBuffer;
|
|
||||||
|
|
||||||
private float cubeTimer = 0f;
|
private float cubeTimer = 0f;
|
||||||
private Quaternion cubeRotation = Quaternion.Identity;
|
private Quaternion cubeRotation = Quaternion.Identity;
|
||||||
|
@ -64,19 +60,6 @@ namespace MoonWorks.Test
|
||||||
cubePipelines[i] = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
cubePipelines[i] = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the blit pipeline
|
|
||||||
ShaderModule blitVertShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.vert"));
|
|
||||||
ShaderModule blitFragShaderModule = new ShaderModule(GraphicsDevice, TestUtils.GetShaderPath("TexturedQuad.frag"));
|
|
||||||
|
|
||||||
pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
|
||||||
MainWindow.SwapchainFormat,
|
|
||||||
blitVertShaderModule,
|
|
||||||
blitFragShaderModule
|
|
||||||
);
|
|
||||||
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
|
||||||
pipelineCreateInfo.FragmentShaderInfo.SamplerBindingCount = 1;
|
|
||||||
blitPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
|
||||||
|
|
||||||
// Create the MSAA render textures and depth textures
|
// Create the MSAA render textures and depth textures
|
||||||
for (int i = 0; i < renderTargets.Length; i += 1)
|
for (int i = 0; i < renderTargets.Length; i += 1)
|
||||||
{
|
{
|
||||||
|
@ -101,30 +84,9 @@ namespace MoonWorks.Test
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the sampler
|
|
||||||
rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
|
||||||
|
|
||||||
// Create the buffers
|
// Create the buffers
|
||||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||||
|
|
||||||
quadVertexBuffer = resourceUploader.CreateBuffer(
|
|
||||||
[
|
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1))
|
|
||||||
],
|
|
||||||
BufferUsageFlags.Vertex
|
|
||||||
);
|
|
||||||
|
|
||||||
quadIndexBuffer = resourceUploader.CreateBuffer<ushort>(
|
|
||||||
[
|
|
||||||
0, 1, 2,
|
|
||||||
0, 2, 3,
|
|
||||||
],
|
|
||||||
BufferUsageFlags.Index
|
|
||||||
);
|
|
||||||
|
|
||||||
var cubeVertexData = new System.Span<PositionColorVertex>(
|
var cubeVertexData = new System.Span<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)),
|
||||||
|
@ -248,8 +210,8 @@ namespace MoonWorks.Test
|
||||||
// Begin the MSAA RT pass
|
// Begin the MSAA RT pass
|
||||||
int index = (int) currentSampleCount;
|
int index = (int) currentSampleCount;
|
||||||
cmdbuf.BeginRenderPass(
|
cmdbuf.BeginRenderPass(
|
||||||
new DepthStencilAttachmentInfo(depthRTs[index], new DepthStencilValue(1, 0)),
|
new DepthStencilAttachmentInfo(depthRTs[index], WriteOptions.SafeDiscard, new DepthStencilValue(1, 0)),
|
||||||
new ColorAttachmentInfo(renderTargets[index], Color.Black)
|
new ColorAttachmentInfo(renderTargets[index], WriteOptions.SafeDiscard, Color.Black)
|
||||||
);
|
);
|
||||||
cmdbuf.BindGraphicsPipeline(cubePipelines[index]);
|
cmdbuf.BindGraphicsPipeline(cubePipelines[index]);
|
||||||
|
|
||||||
|
@ -267,14 +229,13 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
// Blit the MSAA RT to the backbuffer
|
// Copy the MSAA RT to the backbuffer
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, LoadOp.DontCare));
|
cmdbuf.Blit(
|
||||||
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
renderTargets[index],
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(renderTargets[index], rtSampler));
|
backbuffer,
|
||||||
cmdbuf.BindVertexBuffers(quadVertexBuffer);
|
Filter.Nearest,
|
||||||
cmdbuf.BindIndexBuffer(quadIndexBuffer, IndexElementSize.Sixteen);
|
WriteOptions.SafeOverwrite
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2);
|
);
|
||||||
cmdbuf.EndRenderPass();
|
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, 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>());
|
cmdbuf.DrawPrimitivesIndirect(drawBuffer, 0, 2, (uint) Marshal.SizeOf<IndirectDrawCommand>());
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace MoonWorks.Test
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer);
|
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer, TransferOptions.Overwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
|
@ -60,9 +60,9 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
// Change the first three vertices and upload
|
// Change the first three vertices and upload
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
transferBuffer.SetData(otherVerts, SetDataOptions.Overwrite);
|
transferBuffer.SetData(otherVerts, TransferOptions.Overwrite);
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer);
|
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer, WriteOptions.SafeOverwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
|
@ -71,7 +71,7 @@ namespace MoonWorks.Test
|
||||||
// Download the data
|
// Download the data
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer);
|
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer, TransferOptions.Overwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
|
@ -88,14 +88,15 @@ namespace MoonWorks.Test
|
||||||
// Change the last two vertices and upload
|
// Change the last two vertices and upload
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
var lastTwoSpan = otherVerts.Slice(1, 2);
|
var lastTwoSpan = otherVerts.Slice(1, 2);
|
||||||
transferBuffer.SetData(lastTwoSpan, SetDataOptions.Overwrite);
|
transferBuffer.SetData(lastTwoSpan, TransferOptions.Overwrite);
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.UploadToBuffer<PositionVertex>(
|
cmdbuf.UploadToBuffer<PositionVertex>(
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
0,
|
0,
|
||||||
(uint)(vertices.Length - 2),
|
(uint)(vertices.Length - 2),
|
||||||
2
|
2,
|
||||||
|
WriteOptions.SafeOverwrite
|
||||||
);
|
);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
|
@ -104,7 +105,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer);
|
cmdbuf.DownloadFromBuffer(vertexBuffer, transferBuffer, TransferOptions.Overwrite);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
|
@ -127,7 +128,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -126,12 +126,12 @@ namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
Texture rt = renderTargets[(int) currentSampleCount];
|
Texture rt = renderTargets[(int) currentSampleCount];
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(rt, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(rt, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]);
|
cmdbuf.BindGraphicsPipeline(msaaPipelines[(int) currentSampleCount]);
|
||||||
cmdbuf.DrawPrimitives(0, 1);
|
cmdbuf.DrawPrimitives(0, 1);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, LoadOp.DontCare));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, LoadOp.DontCare));
|
||||||
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, rtSampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, rtSampler));
|
||||||
cmdbuf.BindVertexBuffers(quadVertexBuffer);
|
cmdbuf.BindVertexBuffers(quadVertexBuffer);
|
||||||
|
|
|
@ -67,7 +67,8 @@ namespace MoonWorks.Test
|
||||||
LevelCount = 1,
|
LevelCount = 1,
|
||||||
SampleCount = (SampleCount)i,
|
SampleCount = (SampleCount)i,
|
||||||
UsageFlags = TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
|
UsageFlags = TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler,
|
||||||
IsCube = true
|
IsCube = true,
|
||||||
|
LayerCount = 6
|
||||||
};
|
};
|
||||||
renderTargets[i] = new Texture(GraphicsDevice, cubeCreateInfo);
|
renderTargets[i] = new Texture(GraphicsDevice, cubeCreateInfo);
|
||||||
}
|
}
|
||||||
|
@ -185,13 +186,14 @@ namespace MoonWorks.Test
|
||||||
Texture rt = renderTargets[rtIndex];
|
Texture rt = renderTargets[rtIndex];
|
||||||
ColorAttachmentInfo rtAttachmentInfo = new ColorAttachmentInfo(
|
ColorAttachmentInfo rtAttachmentInfo = new ColorAttachmentInfo(
|
||||||
rt,
|
rt,
|
||||||
|
WriteOptions.SafeDiscard,
|
||||||
Color.Black
|
Color.Black
|
||||||
);
|
);
|
||||||
|
|
||||||
// Render a triangle to each slice of the cubemap
|
// Render a triangle to each slice of the cubemap
|
||||||
for (uint i = 0; i < 6; i += 1)
|
for (uint i = 0; i < 6; i += 1)
|
||||||
{
|
{
|
||||||
rtAttachmentInfo.Layer = i;
|
rtAttachmentInfo.TextureSlice.Layer = i;
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(rtAttachmentInfo);
|
cmdbuf.BeginRenderPass(rtAttachmentInfo);
|
||||||
cmdbuf.BindGraphicsPipeline(msaaPipelines[rtIndex]);
|
cmdbuf.BindGraphicsPipeline(msaaPipelines[rtIndex]);
|
||||||
|
@ -199,7 +201,7 @@ namespace MoonWorks.Test
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(cubemapPipeline);
|
cmdbuf.BindGraphicsPipeline(cubemapPipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,17 @@
|
||||||
|
#version 450
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 TexCoord;
|
||||||
|
|
||||||
|
layout (location = 0) out vec4 FragColor;
|
||||||
|
|
||||||
|
layout(binding = 0, set = 1) uniform sampler2DArray Sampler;
|
||||||
|
|
||||||
|
layout (binding = 0, set = 3) uniform UniformBlock
|
||||||
|
{
|
||||||
|
float depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = texture(Sampler, vec3(TexCoord, depth));
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InstancingAndOffsets", "Ins
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VertexSampler", "VertexSampler\VertexSampler.csproj", "{C525B6DE-3003-45D5-BB83-89679B108C08}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VertexSampler", "VertexSampler\VertexSampler.csproj", "{C525B6DE-3003-45D5-BB83-89679B108C08}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture3D", "RenderTexture3D\RenderTexture3D.csproj", "{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture2DArray", "RenderTexture2DArray\RenderTexture2DArray.csproj", "{6D625A4C-8618-4DFC-A6AD-AA3BE3488D70}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTextureCube", "RenderTextureCube\RenderTextureCube.csproj", "{D7A8452F-123F-4965-8716-9E39F677A831}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTextureCube", "RenderTextureCube\RenderTextureCube.csproj", "{D7A8452F-123F-4965-8716-9E39F677A831}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -65,6 +65,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RenderTexture2D", "RenderTe
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSAACube", "MSAACube\MSAACube.csproj", "{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSAACube", "MSAACube\MSAACube.csproj", "{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Texture3DCopy", "Texture3DCopy\Texture3DCopy.csproj", "{A18B6D92-A699-480C-9ABC-4000A3FE4B94}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -195,6 +197,10 @@ Global
|
||||||
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
|
||||||
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A1568AAF-DD02-4A6E-9C68-9AE07130A60D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A18B6D92-A699-480C-9ABC-4000A3FE4B94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -92,19 +92,19 @@ namespace MoonWorks.Test
|
||||||
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (backbuffer != null)
|
if (backbuffer != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[0], Color.Red));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[0], WriteOptions.SafeDiscard, Color.Red));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[1], Color.Blue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[1], WriteOptions.SafeDiscard, Color.Blue));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[2], Color.Green));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[2], WriteOptions.SafeDiscard, Color.Green));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[3], Color.Yellow));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(textures[3], WriteOptions.SafeDiscard, Color.Yellow));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
using MoonWorks.Graphics;
|
using System;
|
||||||
|
using MoonWorks.Graphics;
|
||||||
using MoonWorks.Math.Float;
|
using MoonWorks.Math.Float;
|
||||||
|
|
||||||
namespace MoonWorks.Test
|
namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
class RenderTexture3DGame : Game
|
class RenderTexture2DArrayGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private GpuBuffer vertexBuffer;
|
private GpuBuffer vertexBuffer;
|
||||||
|
@ -29,11 +30,11 @@ namespace MoonWorks.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderTexture3DGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
public RenderTexture2DArrayGame() : 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("TexturedQuad2DArray.frag"));
|
||||||
|
|
||||||
// Create the graphics pipeline
|
// Create the graphics pipeline
|
||||||
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
|
@ -46,7 +47,7 @@ namespace MoonWorks.Test
|
||||||
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.PointWrap);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||||
|
@ -72,7 +73,7 @@ namespace MoonWorks.Test
|
||||||
resourceUploader.Upload();
|
resourceUploader.Upload();
|
||||||
resourceUploader.Dispose();
|
resourceUploader.Dispose();
|
||||||
|
|
||||||
rt = Texture.CreateTexture3D(
|
rt = Texture.CreateTexture2DArray(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
|
@ -87,12 +88,14 @@ namespace MoonWorks.Test
|
||||||
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
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = rt,
|
Texture = rt,
|
||||||
|
Layer = i,
|
||||||
|
MipLevel = 0
|
||||||
|
},
|
||||||
ClearColor = colors[i],
|
ClearColor = colors[i],
|
||||||
Depth = i,
|
|
||||||
Layer = 0,
|
|
||||||
Level = 0,
|
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store
|
||||||
};
|
};
|
||||||
|
@ -108,13 +111,14 @@ namespace MoonWorks.Test
|
||||||
protected override void Draw(double alpha)
|
protected override void Draw(double alpha)
|
||||||
{
|
{
|
||||||
t += 0.01f;
|
t += 0.01f;
|
||||||
FragUniform fragUniform = new FragUniform(t);
|
t %= 3;
|
||||||
|
FragUniform fragUniform = new FragUniform(MathF.Floor(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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
@ -128,7 +132,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
RenderTexture3DGame game = new RenderTexture3DGame();
|
RenderTexture2DArrayGame game = new RenderTexture2DArrayGame();
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -113,12 +113,14 @@ namespace MoonWorks.Test
|
||||||
for (uint i = 0; i < 6; i += 1)
|
for (uint i = 0; i < 6; i += 1)
|
||||||
{
|
{
|
||||||
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = cubemap,
|
Texture = cubemap,
|
||||||
ClearColor = colors[i],
|
|
||||||
Depth = 0,
|
|
||||||
Layer = i,
|
Layer = i,
|
||||||
Level = 0,
|
MipLevel = 0
|
||||||
|
},
|
||||||
|
ClearColor = colors[i],
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store
|
||||||
};
|
};
|
||||||
|
@ -156,7 +158,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -120,14 +120,17 @@ namespace MoonWorks.Test
|
||||||
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
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = texture,
|
Texture = texture,
|
||||||
ClearColor = colors[i],
|
|
||||||
Depth = 0,
|
|
||||||
Layer = 0,
|
Layer = 0,
|
||||||
Level = i,
|
MipLevel = i
|
||||||
|
},
|
||||||
|
ClearColor = colors[i],
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store
|
StoreOp = StoreOp.Store,
|
||||||
|
WriteOption = WriteOptions.SafeOverwrite
|
||||||
};
|
};
|
||||||
cmdbuf.BeginRenderPass(attachmentInfo);
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
@ -163,7 +166,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -31,11 +31,11 @@ namespace MoonWorks.Test
|
||||||
Texture? swapchain = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
Texture? swapchain = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
if (swapchain != null)
|
if (swapchain != null)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, Color.Blue));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, WriteOptions.SafeDiscard, Color.Blue));
|
||||||
cmdbuf.BindGraphicsPipeline(fillPipeline);
|
cmdbuf.BindGraphicsPipeline(fillPipeline);
|
||||||
cmdbuf.DrawPrimitives(0, 1);
|
cmdbuf.DrawPrimitives(0, 1);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, LoadOp.Load, StoreOp.Store));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, WriteOptions.SafeOverwrite, LoadOp.Load, StoreOp.Store));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -65,17 +65,26 @@ namespace MoonWorks.Test
|
||||||
BufferUsageFlags.Index
|
BufferUsageFlags.Index
|
||||||
);
|
);
|
||||||
|
|
||||||
texture = Texture.CreateTexture3D(GraphicsDevice, 16, 16, 7, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
texture = Texture.CreateTexture3D(
|
||||||
|
GraphicsDevice,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
7,
|
||||||
|
TextureFormat.R8G8B8A8,
|
||||||
|
TextureUsageFlags.Sampler
|
||||||
|
);
|
||||||
|
|
||||||
// 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
|
var region = new TextureRegion
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = texture,
|
Texture = texture,
|
||||||
MipLevel = 0,
|
MipLevel = 0,
|
||||||
BaseLayer = 0,
|
Layer = 0
|
||||||
LayerCount = 1,
|
},
|
||||||
X = 0,
|
X = 0,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
Z = i,
|
Z = i,
|
||||||
|
@ -85,7 +94,7 @@ namespace MoonWorks.Test
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceUploader.SetTextureDataFromCompressed(
|
resourceUploader.SetTextureDataFromCompressed(
|
||||||
slice,
|
region,
|
||||||
TestUtils.GetTexturePath($"tex3d_{i}.png")
|
TestUtils.GetTexturePath($"tex3d_{i}.png")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +139,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
using MoonWorks.Graphics;
|
||||||
|
using MoonWorks.Math.Float;
|
||||||
|
|
||||||
|
namespace MoonWorks.Test
|
||||||
|
{
|
||||||
|
class RenderTexture3DGame : Game
|
||||||
|
{
|
||||||
|
private GraphicsPipeline pipeline;
|
||||||
|
private GpuBuffer vertexBuffer;
|
||||||
|
private GpuBuffer indexBuffer;
|
||||||
|
private Texture rt;
|
||||||
|
private Texture texture3D;
|
||||||
|
private Sampler sampler;
|
||||||
|
|
||||||
|
private float t;
|
||||||
|
private Color[] colors = new Color[]
|
||||||
|
{
|
||||||
|
Color.Red,
|
||||||
|
Color.Green,
|
||||||
|
Color.Blue,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragUniform
|
||||||
|
{
|
||||||
|
public float Depth;
|
||||||
|
|
||||||
|
public FragUniform(float depth)
|
||||||
|
{
|
||||||
|
Depth = depth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderTexture3DGame() : 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("TexturedQuad3D.frag"));
|
||||||
|
|
||||||
|
// Create the graphics pipeline
|
||||||
|
GraphicsPipelineCreateInfo pipelineCreateInfo = TestUtils.GetStandardGraphicsPipelineCreateInfo(
|
||||||
|
MainWindow.SwapchainFormat,
|
||||||
|
vertShaderModule,
|
||||||
|
fragShaderModule
|
||||||
|
);
|
||||||
|
pipelineCreateInfo.VertexInputState = VertexInputState.CreateSingleBinding<PositionTextureVertex>();
|
||||||
|
pipelineCreateInfo.FragmentShaderInfo = GraphicsShaderInfo.Create<FragUniform>(fragShaderModule, "main", 1);
|
||||||
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
|
// Create samplers
|
||||||
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
|
||||||
|
|
||||||
|
// Create and populate the GPU resources
|
||||||
|
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||||
|
|
||||||
|
vertexBuffer = resourceUploader.CreateBuffer(
|
||||||
|
[
|
||||||
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
||||||
|
],
|
||||||
|
BufferUsageFlags.Vertex
|
||||||
|
);
|
||||||
|
|
||||||
|
indexBuffer = resourceUploader.CreateBuffer<ushort>(
|
||||||
|
[
|
||||||
|
0, 1, 2,
|
||||||
|
0, 2, 3,
|
||||||
|
],
|
||||||
|
BufferUsageFlags.Index
|
||||||
|
);
|
||||||
|
|
||||||
|
resourceUploader.Upload();
|
||||||
|
resourceUploader.Dispose();
|
||||||
|
|
||||||
|
rt = Texture.CreateTexture2DArray(
|
||||||
|
GraphicsDevice,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
(uint) colors.Length,
|
||||||
|
TextureFormat.R8G8B8A8,
|
||||||
|
TextureUsageFlags.ColorTarget | TextureUsageFlags.Sampler
|
||||||
|
);
|
||||||
|
|
||||||
|
texture3D = new Texture(GraphicsDevice, new TextureCreateInfo
|
||||||
|
{
|
||||||
|
Width = 16,
|
||||||
|
Height = 16,
|
||||||
|
Depth = 3,
|
||||||
|
IsCube = false,
|
||||||
|
LayerCount = 1,
|
||||||
|
LevelCount = 1,
|
||||||
|
SampleCount = SampleCount.One,
|
||||||
|
Format = TextureFormat.R8G8B8A8,
|
||||||
|
UsageFlags = TextureUsageFlags.Sampler
|
||||||
|
});
|
||||||
|
|
||||||
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
|
||||||
|
// Clear each layer slice of the RT to a different color
|
||||||
|
for (uint i = 0; i < colors.Length; i += 1)
|
||||||
|
{
|
||||||
|
ColorAttachmentInfo attachmentInfo = new ColorAttachmentInfo
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
|
{
|
||||||
|
Texture = rt,
|
||||||
|
Layer = i,
|
||||||
|
MipLevel = 0
|
||||||
|
},
|
||||||
|
ClearColor = colors[i],
|
||||||
|
LoadOp = LoadOp.Clear,
|
||||||
|
StoreOp = StoreOp.Store
|
||||||
|
};
|
||||||
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
|
cmdbuf.EndRenderPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy each layer slice to a different 3D depth
|
||||||
|
cmdbuf.BeginCopyPass();
|
||||||
|
for (var i = 0; i < 3; i += 1)
|
||||||
|
{
|
||||||
|
cmdbuf.CopyTextureToTexture(
|
||||||
|
new TextureRegion
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
|
{
|
||||||
|
Texture = rt,
|
||||||
|
Layer = (uint) i,
|
||||||
|
MipLevel = 0
|
||||||
|
},
|
||||||
|
X = 0,
|
||||||
|
Y = 0,
|
||||||
|
Z = 0,
|
||||||
|
Width = 16,
|
||||||
|
Height = 16,
|
||||||
|
Depth = 1
|
||||||
|
},
|
||||||
|
new TextureRegion
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
|
{
|
||||||
|
Texture = texture3D,
|
||||||
|
Layer = 0,
|
||||||
|
MipLevel = 0
|
||||||
|
},
|
||||||
|
X = 0,
|
||||||
|
Y = 0,
|
||||||
|
Z = (uint) i,
|
||||||
|
Width = 16,
|
||||||
|
Height = 16,
|
||||||
|
Depth = 1
|
||||||
|
},
|
||||||
|
WriteOptions.SafeOverwrite
|
||||||
|
);
|
||||||
|
}
|
||||||
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update(System.TimeSpan delta) { }
|
||||||
|
|
||||||
|
protected override void Draw(double alpha)
|
||||||
|
{
|
||||||
|
t += 0.01f;
|
||||||
|
FragUniform fragUniform = new FragUniform(t);
|
||||||
|
|
||||||
|
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
|
Texture? backbuffer = cmdbuf.AcquireSwapchainTexture(MainWindow);
|
||||||
|
if (backbuffer != null)
|
||||||
|
{
|
||||||
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, WriteOptions.SafeDiscard, Color.Black));
|
||||||
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(texture3D, sampler));
|
||||||
|
cmdbuf.PushFragmentShaderUniforms(fragUniform);
|
||||||
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2);
|
||||||
|
cmdbuf.EndRenderPass();
|
||||||
|
}
|
||||||
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
RenderTexture3DGame game = new RenderTexture3DGame();
|
||||||
|
game.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<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>
|
|
@ -69,12 +69,14 @@ namespace MoonWorks.Test
|
||||||
{
|
{
|
||||||
var w = texture.Width >> (int) i;
|
var w = texture.Width >> (int) i;
|
||||||
var h = texture.Height >> (int) i;
|
var h = texture.Height >> (int) i;
|
||||||
var slice = new TextureSlice
|
var region = new TextureRegion
|
||||||
|
{
|
||||||
|
TextureSlice = new TextureSlice
|
||||||
{
|
{
|
||||||
Texture = texture,
|
Texture = texture,
|
||||||
MipLevel = i,
|
Layer = 0,
|
||||||
BaseLayer = 0,
|
MipLevel = i
|
||||||
LayerCount = 1,
|
},
|
||||||
X = 0,
|
X = 0,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
Z = 0,
|
Z = 0,
|
||||||
|
@ -84,7 +86,7 @@ namespace MoonWorks.Test
|
||||||
};
|
};
|
||||||
|
|
||||||
resourceUploader.SetTextureDataFromCompressed(
|
resourceUploader.SetTextureDataFromCompressed(
|
||||||
slice,
|
region,
|
||||||
TestUtils.GetTexturePath($"mip{i}.png")
|
TestUtils.GetTexturePath($"mip{i}.png")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +116,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.DrawPrimitives(0, 1);
|
cmdbuf.DrawPrimitives(0, 1);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MoonWorks;
|
using System;
|
||||||
|
using MoonWorks;
|
||||||
using MoonWorks.Graphics;
|
using MoonWorks.Graphics;
|
||||||
using MoonWorks.Math.Float;
|
using MoonWorks.Math.Float;
|
||||||
|
|
||||||
|
@ -28,7 +29,6 @@ namespace MoonWorks.Test
|
||||||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
texture = Texture.CreateTexture2D(GraphicsDevice, 3, 1, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
|
||||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||||
|
|
||||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||||
|
@ -42,9 +42,10 @@ namespace MoonWorks.Test
|
||||||
BufferUsageFlags.Vertex
|
BufferUsageFlags.Vertex
|
||||||
);
|
);
|
||||||
|
|
||||||
resourceUploader.SetTextureData(
|
texture = resourceUploader.CreateTexture2D(
|
||||||
texture,
|
new Span<Color>([Color.Yellow, Color.Indigo, Color.HotPink]),
|
||||||
[Color.Yellow, Color.Indigo, Color.HotPink]
|
3,
|
||||||
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
resourceUploader.Upload();
|
resourceUploader.Upload();
|
||||||
|
@ -59,7 +60,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, 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));
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.CornflowerBlue));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace MoonWorks.Test
|
||||||
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, WriteOptions.SafeDiscard, Color.Black));
|
||||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||||
cmdbuf.DrawPrimitives(0, 1);
|
cmdbuf.DrawPrimitives(0, 1);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
Loading…
Reference in New Issue