From 795331c133a9b5d3ffce4c37586fb3497b9f9c2d Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 23 Feb 2024 14:30:53 -0800 Subject: [PATCH] convert Cube test to use UploadAndWait --- Cube/CubeGame.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Cube/CubeGame.cs b/Cube/CubeGame.cs index be88d48..96045e5 100644 --- a/Cube/CubeGame.cs +++ b/Cube/CubeGame.cs @@ -52,15 +52,13 @@ namespace MoonWorks.Test } } + // Upload cubemap layers one at a time to minimize transfer size unsafe void LoadCubemap(string[] imagePaths) { - var cubemapTransferBuffer = new TransferBuffer(GraphicsDevice, skyboxTexture.Width * skyboxTexture.Height * 4); + var cubemapUploader = new ResourceInitializer(GraphicsDevice); - /* Upload cubemap layers one at a time to minimize transfer size */ for (uint i = 0; i < imagePaths.Length; i++) { - var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); - var textureSlice = new TextureSlice { Texture = skyboxTexture, @@ -75,18 +73,15 @@ namespace MoonWorks.Test Depth = 1 }; - ImageUtils.DecodeIntoTransferBuffer(imagePaths[i], cubemapTransferBuffer, 0, SetDataOptions.Overwrite); + cubemapUploader.SetTextureDataFromCompressed( + textureSlice, + imagePaths[i] + ); - commandBuffer.BeginCopyPass(); - commandBuffer.UploadToTexture(cubemapTransferBuffer, textureSlice, new BufferImageCopy(0, 0, 0)); - commandBuffer.EndCopyPass(); - - var fence = GraphicsDevice.SubmitAndAcquireFence(commandBuffer); - GraphicsDevice.WaitForFences(fence); - GraphicsDevice.ReleaseFence(fence); + cubemapUploader.UploadAndWait(); } - cubemapTransferBuffer.Dispose(); + cubemapUploader.Dispose(); } public CubeGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)