update WriteOptions

refresh2
cosmonaut 2024-03-11 10:20:54 -07:00
parent b66dc20768
commit 39daf3cad4
9 changed files with 25 additions and 24 deletions

View File

@ -69,6 +69,7 @@ namespace MoonWorks.Test
TransferBuffer transferBuffer = new TransferBuffer(
GraphicsDevice,
TransferUsage.Buffer,
squaresBuffer.Size
);
@ -105,12 +106,12 @@ namespace MoonWorks.Test
// This should result in a bright yellow texture!
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);
// This calculates the squares of the first N integers!
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.EndComputePass();
@ -120,7 +121,7 @@ namespace MoonWorks.Test
GraphicsDevice.ReleaseFence(fence);
// Print the squares!
GraphicsDevice.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Overwrite);
GraphicsDevice.DownloadFromBuffer(squaresBuffer, transferBuffer, TransferOptions.Unsafe);
transferBuffer.GetData<uint>(squares, 0);
Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares));
}

View File

@ -102,7 +102,7 @@ namespace MoonWorks.Test
cmdbuf.CopyTextureToTexture(
originalTexture,
textureCopy,
WriteOptions.SafeOverwrite
WriteOptions.Unsafe
);
cmdbuf.EndCopyPass();
@ -113,19 +113,19 @@ namespace MoonWorks.Test
textureSmallCopy = new Texture(GraphicsDevice, textureCreateInfo);
// 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);
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Copy the texture to a transfer buffer
TransferBuffer compareBuffer = new TransferBuffer(GraphicsDevice, byteCount);
TransferBuffer compareBuffer = new TransferBuffer(GraphicsDevice, TransferUsage.Texture, byteCount);
GraphicsDevice.DownloadFromTexture(
textureCopy,
compareBuffer,
TransferOptions.Overwrite
TransferOptions.Unsafe
);
// Compare the original bytes to the copied bytes.

View File

@ -157,7 +157,7 @@ namespace MoonWorks.Test
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);
Task loadingTask = Task.Run(() => UploadGPUAssets());
@ -441,7 +441,7 @@ namespace MoonWorks.Test
if (depthOnlyEnabled)
{
// 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.BindFragmentSamplers(new TextureSamplerBinding(depthTexture, depthSampler));
@ -455,7 +455,7 @@ namespace MoonWorks.Test
if (takeScreenshot)
{
cmdbuf.BeginCopyPass();
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture, WriteOptions.SafeOverwrite);
cmdbuf.CopyTextureToTexture(swapchainTexture, screenshotTexture, WriteOptions.Unsafe);
cmdbuf.EndCopyPass();
swapchainCopied = true;
@ -486,7 +486,7 @@ namespace MoonWorks.Test
GraphicsDevice.DownloadFromTexture(
screenshotTexture,
screenshotTransferBuffer,
TransferOptions.Overwrite
TransferOptions.Unsafe
);
ImageUtils.SavePNG(

View File

@ -235,7 +235,7 @@ namespace MoonWorks.Test
renderTargets[index],
backbuffer,
Filter.Nearest,
WriteOptions.SafeOverwrite
WriteOptions.Safe
);
}
GraphicsDevice.Submit(cmdbuf);

View File

@ -37,13 +37,13 @@ namespace MoonWorks.Test
resourceUploader.UploadAndWait();
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
GraphicsDevice.DownloadFromBuffer(
vertexBuffer,
transferBuffer,
TransferOptions.Overwrite
TransferOptions.Unsafe
);
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
@ -54,11 +54,11 @@ namespace MoonWorks.Test
}
// Change the first three vertices and upload
transferBuffer.SetData(otherVerts, TransferOptions.Overwrite);
transferBuffer.SetData(otherVerts, TransferOptions.Unsafe);
var cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.BeginCopyPass();
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer, WriteOptions.SafeOverwrite);
cmdbuf.UploadToBuffer(transferBuffer, vertexBuffer, WriteOptions.Unsafe);
cmdbuf.EndCopyPass();
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
GraphicsDevice.WaitForFences(fence);
@ -68,7 +68,7 @@ namespace MoonWorks.Test
GraphicsDevice.DownloadFromBuffer(
vertexBuffer,
transferBuffer,
TransferOptions.Overwrite
TransferOptions.Unsafe
);
// Read the updated buffer
@ -82,7 +82,7 @@ namespace MoonWorks.Test
// Change the last two vertices and upload
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
var lastTwoSpan = otherVerts.Slice(1, 2);
transferBuffer.SetData(lastTwoSpan, TransferOptions.Overwrite);
transferBuffer.SetData(lastTwoSpan, TransferOptions.Unsafe);
cmdbuf.BeginCopyPass();
cmdbuf.UploadToBuffer<PositionVertex>(
transferBuffer,
@ -90,7 +90,7 @@ namespace MoonWorks.Test
0,
(uint)(vertices.Length - 2),
2,
WriteOptions.SafeOverwrite
WriteOptions.Unsafe
);
cmdbuf.EndCopyPass();
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
@ -100,7 +100,7 @@ namespace MoonWorks.Test
GraphicsDevice.DownloadFromBuffer(
vertexBuffer,
transferBuffer,
TransferOptions.Overwrite
TransferOptions.Unsafe
);
// Read the updated buffer

View File

@ -5,7 +5,7 @@ namespace MoonWorks.Test
public static class TestUtils
{
// change this to test different backends
public static Backend[] PreferredBackends = [Backend.Vulkan];
public static Backend[] PreferredBackends = [Backend.D3D11];
public static WindowCreateInfo GetStandardWindowCreateInfo()
{

View File

@ -130,7 +130,7 @@ namespace MoonWorks.Test
ClearColor = colors[i],
LoadOp = LoadOp.Clear,
StoreOp = StoreOp.Store,
WriteOption = WriteOptions.SafeOverwrite
WriteOption = WriteOptions.Safe
};
cmdbuf.BeginRenderPass(attachmentInfo);
cmdbuf.EndRenderPass();

View File

@ -35,7 +35,7 @@ namespace MoonWorks.Test
cmdbuf.BindGraphicsPipeline(fillPipeline);
cmdbuf.DrawPrimitives(0, 1);
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();
}
GraphicsDevice.Submit(cmdbuf);

View File

@ -151,7 +151,7 @@ namespace MoonWorks.Test
Height = 16,
Depth = 1
},
WriteOptions.SafeOverwrite
WriteOptions.Unsafe
);
}
cmdbuf.EndCopyPass();