update examples to use WaitForFences

spritebatch
cosmonaut 2023-09-18 23:28:32 -07:00
parent 0d48af5f7d
commit 5709a063ae
3 changed files with 15 additions and 10 deletions

View File

@ -106,8 +106,9 @@ namespace MoonWorks.Test
cmdbuf.BindComputeBuffers(squaresBuffer);
cmdbuf.DispatchCompute((uint) squares.Length / 8, 1, 1, 0);
GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait();
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Print the squares!
squaresBuffer.GetData(squares);

View File

@ -127,8 +127,9 @@ namespace MoonWorks.Test
Buffer compareBuffer = Buffer.Create<byte>(GraphicsDevice, 0, (uint) byteCount);
cmdbuf.CopyTextureToBuffer(new TextureSlice(originalTexture), compareBuffer);
GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait();
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Compare the original bytes to the copied bytes.
var copiedBytes = NativeMemory.Alloc((nuint) byteCount);

View File

@ -38,10 +38,11 @@ namespace MoonWorks.Test
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData(vertexBuffer, vertices);
GraphicsDevice.Submit(cmdbuf);
var fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
// Wait for the vertices to finish uploading...
GraphicsDevice.Wait();
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Read back and print out the vertex values
PositionVertex[] readbackVertices = new PositionVertex[vertices.Length];
@ -54,8 +55,9 @@ namespace MoonWorks.Test
// Change the first three vertices
cmdbuf = GraphicsDevice.AcquireCommandBuffer();
cmdbuf.SetBufferData(vertexBuffer, otherVerts);
GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait();
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Read the updated buffer
vertexBuffer.GetData(readbackVertices);
@ -74,8 +76,9 @@ namespace MoonWorks.Test
1,
2
);
GraphicsDevice.Submit(cmdbuf);
GraphicsDevice.Wait();
fence = GraphicsDevice.SubmitAndAcquireFence(cmdbuf);
GraphicsDevice.WaitForFences(fence);
GraphicsDevice.ReleaseFence(fence);
// Read the updated buffer
vertexBuffer.GetData(readbackVertices);