update WriteOptions
parent
b66dc20768
commit
39daf3cad4
|
@ -69,6 +69,7 @@ namespace MoonWorks.Test
|
||||||
|
|
||||||
TransferBuffer transferBuffer = new TransferBuffer(
|
TransferBuffer transferBuffer = new TransferBuffer(
|
||||||
GraphicsDevice,
|
GraphicsDevice,
|
||||||
|
TransferUsage.Buffer,
|
||||||
squaresBuffer.Size
|
squaresBuffer.Size
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -105,12 +106,12 @@ 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 ComputeTextureBinding(texture, WriteOptions.SafeOverwrite));
|
cmdbuf.BindComputeTextures(new ComputeTextureBinding(texture, WriteOptions.Unsafe));
|
||||||
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(new ComputeBufferBinding(squaresBuffer, WriteOptions.SafeOverwrite));
|
cmdbuf.BindComputeBuffers(new ComputeBufferBinding(squaresBuffer, WriteOptions.Unsafe));
|
||||||
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1);
|
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1);
|
||||||
|
|
||||||
cmdbuf.EndComputePass();
|
cmdbuf.EndComputePass();
|
||||||
|
@ -120,7 +121,7 @@ namespace MoonWorks.Test
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// Print the squares!
|
// Print the squares!
|
||||||
GraphicsDevice.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Overwrite);
|
GraphicsDevice.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Unsafe);
|
||||||
transferBuffer.GetData<uint>(squares, 0);
|
transferBuffer.GetData<uint>(squares, 0);
|
||||||
Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares));
|
Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares));
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace MoonWorks.Test
|
||||||
cmdbuf.CopyTextureToTexture(
|
cmdbuf.CopyTextureToTexture(
|
||||||
originalTexture,
|
originalTexture,
|
||||||
textureCopy,
|
textureCopy,
|
||||||
WriteOptions.SafeOverwrite
|
WriteOptions.Unsafe
|
||||||
);
|
);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
|
@ -113,19 +113,19 @@ 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, WriteOptions.SafeOverwrite);
|
cmdbuf.Blit(originalTexture, textureSmallCopy, Filter.Linear, WriteOptions.Unsafe);
|
||||||
|
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
GraphicsDevice.ReleaseFence(fence);
|
GraphicsDevice.ReleaseFence(fence);
|
||||||
|
|
||||||
// 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, TransferUsage.Texture, byteCount);
|
||||||
|
|
||||||
GraphicsDevice.DownloadFromTexture(
|
GraphicsDevice.DownloadFromTexture(
|
||||||
textureCopy,
|
textureCopy,
|
||||||
compareBuffer,
|
compareBuffer,
|
||||||
TransferOptions.Overwrite
|
TransferOptions.Unsafe
|
||||||
);
|
);
|
||||||
|
|
||||||
// Compare the original bytes to the copied bytes.
|
// Compare the original bytes to the copied bytes.
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace MoonWorks.Test
|
||||||
6
|
6
|
||||||
);
|
);
|
||||||
|
|
||||||
screenshotTransferBuffer = new TransferBuffer(GraphicsDevice, MainWindow.Width * MainWindow.Height * 4);
|
screenshotTransferBuffer = new TransferBuffer(GraphicsDevice, TransferUsage.Texture, MainWindow.Width * MainWindow.Height * 4);
|
||||||
screenshotTexture = Texture.CreateTexture2D(GraphicsDevice, MainWindow.Width, MainWindow.Height, MainWindow.SwapchainFormat, TextureUsageFlags.Sampler);
|
screenshotTexture = Texture.CreateTexture2D(GraphicsDevice, MainWindow.Width, MainWindow.Height, MainWindow.SwapchainFormat, TextureUsageFlags.Sampler);
|
||||||
|
|
||||||
Task loadingTask = Task.Run(() => UploadGPUAssets());
|
Task loadingTask = Task.Run(() => UploadGPUAssets());
|
||||||
|
@ -441,7 +441,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, WriteOptions.SafeOverwrite, LoadOp.Load));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchainTexture, WriteOptions.Safe, LoadOp.Load));
|
||||||
|
|
||||||
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
cmdbuf.BindGraphicsPipeline(blitPipeline);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
|
||||||
|
@ -455,7 +455,7 @@ namespace MoonWorks.Test
|
||||||
if (takeScreenshot)
|
if (takeScreenshot)
|
||||||
{
|
{
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture, WriteOptions.SafeOverwrite);
|
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture, WriteOptions.Unsafe);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
||||||
swapchainCopied = true;
|
swapchainCopied = true;
|
||||||
|
@ -486,7 +486,7 @@ namespace MoonWorks.Test
|
||||||
GraphicsDevice.DownloadFromTexture(
|
GraphicsDevice.DownloadFromTexture(
|
||||||
screenshotTexture,
|
screenshotTexture,
|
||||||
screenshotTransferBuffer,
|
screenshotTransferBuffer,
|
||||||
TransferOptions.Overwrite
|
TransferOptions.Unsafe
|
||||||
);
|
);
|
||||||
|
|
||||||
ImageUtils.SavePNG(
|
ImageUtils.SavePNG(
|
||||||
|
|
|
@ -235,7 +235,7 @@ namespace MoonWorks.Test
|
||||||
renderTargets[index],
|
renderTargets[index],
|
||||||
backbuffer,
|
backbuffer,
|
||||||
Filter.Nearest,
|
Filter.Nearest,
|
||||||
WriteOptions.SafeOverwrite
|
WriteOptions.Safe
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -37,13 +37,13 @@ namespace MoonWorks.Test
|
||||||
resourceUploader.UploadAndWait();
|
resourceUploader.UploadAndWait();
|
||||||
resourceUploader.Dispose();
|
resourceUploader.Dispose();
|
||||||
|
|
||||||
var transferBuffer = new TransferBuffer(GraphicsDevice, vertexBuffer.Size);
|
var transferBuffer = new TransferBuffer(GraphicsDevice, TransferUsage.Buffer, vertexBuffer.Size);
|
||||||
|
|
||||||
// Read back and print out the vertex values
|
// Read back and print out the vertex values
|
||||||
GraphicsDevice.DownloadFromBuffer(
|
GraphicsDevice.DownloadFromBuffer(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
TransferOptions.Overwrite
|
TransferOptions.Unsafe
|
||||||
);
|
);
|
||||||
|
|
||||||
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
|
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
|
||||||
|
@ -54,11 +54,11 @@ namespace MoonWorks.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the first three vertices and upload
|
// Change the first three vertices and upload
|
||||||
transferBuffer.SetData(otherVerts, TransferOptions.Overwrite);
|
transferBuffer.SetData(otherVerts, TransferOptions.Unsafe);
|
||||||
|
|
||||||
var cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
var cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer, WriteOptions.SafeOverwrite);
|
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer, WriteOptions.Unsafe);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
GraphicsDevice.WaitForFences(fence);
|
GraphicsDevice.WaitForFences(fence);
|
||||||
|
@ -68,7 +68,7 @@ namespace MoonWorks.Test
|
||||||
GraphicsDevice.DownloadFromBuffer(
|
GraphicsDevice.DownloadFromBuffer(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
TransferOptions.Overwrite
|
TransferOptions.Unsafe
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read the updated buffer
|
// Read the updated buffer
|
||||||
|
@ -82,7 +82,7 @@ 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, TransferOptions.Overwrite);
|
transferBuffer.SetData(lastTwoSpan, TransferOptions.Unsafe);
|
||||||
cmdbuf.BeginCopyPass();
|
cmdbuf.BeginCopyPass();
|
||||||
cmdbuf.UploadToBuffer<PositionVertex>(
|
cmdbuf.UploadToBuffer<PositionVertex>(
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
|
@ -90,7 +90,7 @@ namespace MoonWorks.Test
|
||||||
0,
|
0,
|
||||||
(uint)(vertices.Length - 2),
|
(uint)(vertices.Length - 2),
|
||||||
2,
|
2,
|
||||||
WriteOptions.SafeOverwrite
|
WriteOptions.Unsafe
|
||||||
);
|
);
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
|
||||||
|
@ -100,7 +100,7 @@ namespace MoonWorks.Test
|
||||||
GraphicsDevice.DownloadFromBuffer(
|
GraphicsDevice.DownloadFromBuffer(
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
transferBuffer,
|
transferBuffer,
|
||||||
TransferOptions.Overwrite
|
TransferOptions.Unsafe
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read the updated buffer
|
// Read the updated buffer
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace MoonWorks.Test
|
||||||
public static class TestUtils
|
public static class TestUtils
|
||||||
{
|
{
|
||||||
// change this to test different backends
|
// change this to test different backends
|
||||||
public static Backend[] PreferredBackends = [Backend.Vulkan];
|
public static Backend[] PreferredBackends = [Backend.D3D11];
|
||||||
|
|
||||||
public static WindowCreateInfo GetStandardWindowCreateInfo()
|
public static WindowCreateInfo GetStandardWindowCreateInfo()
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace MoonWorks.Test
|
||||||
ClearColor = colors[i],
|
ClearColor = colors[i],
|
||||||
LoadOp = LoadOp.Clear,
|
LoadOp = LoadOp.Clear,
|
||||||
StoreOp = StoreOp.Store,
|
StoreOp = StoreOp.Store,
|
||||||
WriteOption = WriteOptions.SafeOverwrite
|
WriteOption = WriteOptions.Safe
|
||||||
};
|
};
|
||||||
cmdbuf.BeginRenderPass(attachmentInfo);
|
cmdbuf.BeginRenderPass(attachmentInfo);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace MoonWorks.Test
|
||||||
cmdbuf.BindGraphicsPipeline(fillPipeline);
|
cmdbuf.BindGraphicsPipeline(fillPipeline);
|
||||||
cmdbuf.DrawPrimitives(0, 1);
|
cmdbuf.DrawPrimitives(0, 1);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, WriteOptions.SafeOverwrite, LoadOp.Load, StoreOp.Store));
|
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(swapchain, WriteOptions.Safe, LoadOp.Load, StoreOp.Store));
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
|
@ -151,7 +151,7 @@ namespace MoonWorks.Test
|
||||||
Height = 16,
|
Height = 16,
|
||||||
Depth = 1
|
Depth = 1
|
||||||
},
|
},
|
||||||
WriteOptions.SafeOverwrite
|
WriteOptions.Unsafe
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
cmdbuf.EndCopyPass();
|
cmdbuf.EndCopyPass();
|
||||||
|
|
Loading…
Reference in New Issue