From 39daf3cad4fce40396c7a4c56243c1fe89ef114a Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 11 Mar 2024 10:20:54 -0700 Subject: [PATCH] update WriteOptions --- BasicCompute/BasicComputeGame.cs | 7 ++++--- CopyTexture/CopyTextureGame.cs | 8 ++++---- Cube/CubeGame.cs | 8 ++++---- DepthMSAA/DepthMSAAGame.cs | 2 +- GetBufferData/GetBufferDataGame.cs | 16 ++++++++-------- MoonWorks.Test.Common/TestUtils.cs | 2 +- RenderTextureMipmaps/RenderTextureMipmapsGame.cs | 2 +- StoreLoad/StoreLoadGame.cs | 2 +- Texture3DCopy/Texture3DCopy.cs | 2 +- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/BasicCompute/BasicComputeGame.cs b/BasicCompute/BasicComputeGame.cs index d8dd597..568ee29 100644 --- a/BasicCompute/BasicComputeGame.cs +++ b/BasicCompute/BasicComputeGame.cs @@ -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(squares, 0); Logger.LogInfo("Squares of the first " + squares.Length + " integers: " + string.Join(", ", squares)); } diff --git a/CopyTexture/CopyTextureGame.cs b/CopyTexture/CopyTextureGame.cs index 5395ad2..1c943e9 100644 --- a/CopyTexture/CopyTextureGame.cs +++ b/CopyTexture/CopyTextureGame.cs @@ -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. diff --git a/Cube/CubeGame.cs b/Cube/CubeGame.cs index ebc7550..31c4137 100644 --- a/Cube/CubeGame.cs +++ b/Cube/CubeGame.cs @@ -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( diff --git a/DepthMSAA/DepthMSAAGame.cs b/DepthMSAA/DepthMSAAGame.cs index f0e0b2d..833370d 100644 --- a/DepthMSAA/DepthMSAAGame.cs +++ b/DepthMSAA/DepthMSAAGame.cs @@ -235,7 +235,7 @@ namespace MoonWorks.Test renderTargets[index], backbuffer, Filter.Nearest, - WriteOptions.SafeOverwrite + WriteOptions.Safe ); } GraphicsDevice.Submit(cmdbuf); diff --git a/GetBufferData/GetBufferDataGame.cs b/GetBufferData/GetBufferDataGame.cs index bf8d146..45787f8 100644 --- a/GetBufferData/GetBufferDataGame.cs +++ b/GetBufferData/GetBufferDataGame.cs @@ -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( 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 diff --git a/MoonWorks.Test.Common/TestUtils.cs b/MoonWorks.Test.Common/TestUtils.cs index 1aba0d3..8ffd179 100644 --- a/MoonWorks.Test.Common/TestUtils.cs +++ b/MoonWorks.Test.Common/TestUtils.cs @@ -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() { diff --git a/RenderTextureMipmaps/RenderTextureMipmapsGame.cs b/RenderTextureMipmaps/RenderTextureMipmapsGame.cs index 73a9306..d5bcf95 100644 --- a/RenderTextureMipmaps/RenderTextureMipmapsGame.cs +++ b/RenderTextureMipmaps/RenderTextureMipmapsGame.cs @@ -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(); diff --git a/StoreLoad/StoreLoadGame.cs b/StoreLoad/StoreLoadGame.cs index e0a35ac..8e4c728 100644 --- a/StoreLoad/StoreLoadGame.cs +++ b/StoreLoad/StoreLoadGame.cs @@ -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); diff --git a/Texture3DCopy/Texture3DCopy.cs b/Texture3DCopy/Texture3DCopy.cs index 40c973c..940867c 100644 --- a/Texture3DCopy/Texture3DCopy.cs +++ b/Texture3DCopy/Texture3DCopy.cs @@ -151,7 +151,7 @@ namespace MoonWorks.Test Height = 16, Depth = 1 }, - WriteOptions.SafeOverwrite + WriteOptions.Unsafe ); } cmdbuf.EndCopyPass();