From b8bbbe2327b1e900f4d9712a1224b3dfdba09726 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 23 Feb 2024 15:29:03 -0800 Subject: [PATCH] update VideoPlayer --- VideoPlayer/VideoPlayerGame.cs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/VideoPlayer/VideoPlayerGame.cs b/VideoPlayer/VideoPlayerGame.cs index 812abcb..7b56694 100644 --- a/VideoPlayer/VideoPlayerGame.cs +++ b/VideoPlayer/VideoPlayerGame.cs @@ -8,8 +8,8 @@ namespace MoonWorks.Test { private GraphicsPipeline pipeline; private Sampler sampler; - private Buffer vertexBuffer; - private Buffer indexBuffer; + private GpuBuffer vertexBuffer; + private GpuBuffer indexBuffer; private Video.VideoAV1 video; private VideoPlayer videoPlayer; @@ -34,29 +34,28 @@ namespace MoonWorks.Test sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearClamp); // Create and populate the GPU resources - vertexBuffer = Buffer.Create(GraphicsDevice, BufferUsageFlags.Vertex, 4); - indexBuffer = Buffer.Create(GraphicsDevice, BufferUsageFlags.Index, 6); + var resourceUploader = new ResourceUploader(GraphicsDevice); - CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); - cmdbuf.SetBufferData( - vertexBuffer, - new PositionTextureVertex[] - { + vertexBuffer = resourceUploader.CreateBuffer( + [ new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)), new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), - } + ], + BufferUsageFlags.Vertex ); - cmdbuf.SetBufferData( - indexBuffer, - new ushort[] - { + + indexBuffer = resourceUploader.CreateBuffer( + [ 0, 1, 2, 0, 2, 3, - } + ], + BufferUsageFlags.Index ); - GraphicsDevice.Submit(cmdbuf); + + resourceUploader.Upload(); + resourceUploader.Dispose(); // Load the video video = new VideoAV1(GraphicsDevice, TestUtils.GetVideoPath("hello.obu"), 25); @@ -84,7 +83,7 @@ namespace MoonWorks.Test cmdbuf.BindVertexBuffers(vertexBuffer); cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(videoPlayer.RenderTexture, sampler)); - cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0); + cmdbuf.DrawIndexedPrimitives(0, 0, 2); cmdbuf.EndRenderPass(); } GraphicsDevice.Submit(cmdbuf);