update VideoPlayer

refresh2
cosmonaut 2024-02-23 15:29:03 -08:00
parent 844e330a48
commit b8bbbe2327
1 changed files with 16 additions and 17 deletions

View File

@ -8,8 +8,8 @@ namespace MoonWorks.Test
{ {
private GraphicsPipeline pipeline; private GraphicsPipeline pipeline;
private Sampler sampler; private Sampler sampler;
private Buffer vertexBuffer; private GpuBuffer vertexBuffer;
private Buffer indexBuffer; private GpuBuffer indexBuffer;
private Video.VideoAV1 video; private Video.VideoAV1 video;
private VideoPlayer videoPlayer; private VideoPlayer videoPlayer;
@ -34,29 +34,28 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearClamp); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearClamp);
// Create and populate the GPU resources // Create and populate the GPU resources
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4); var resourceUploader = new ResourceUploader(GraphicsDevice);
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); vertexBuffer = resourceUploader.CreateBuffer(
cmdbuf.SetBufferData( [
vertexBuffer,
new PositionTextureVertex[]
{
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), 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, 0)),
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)), new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
} ],
BufferUsageFlags.Vertex
); );
cmdbuf.SetBufferData(
indexBuffer, indexBuffer = resourceUploader.CreateBuffer<ushort>(
new ushort[] [
{
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
} ],
BufferUsageFlags.Index
); );
GraphicsDevice.Submit(cmdbuf);
resourceUploader.Upload();
resourceUploader.Dispose();
// Load the video // Load the video
video = new VideoAV1(GraphicsDevice, TestUtils.GetVideoPath("hello.obu"), 25); video = new VideoAV1(GraphicsDevice, TestUtils.GetVideoPath("hello.obu"), 25);
@ -84,7 +83,7 @@ namespace MoonWorks.Test
cmdbuf.BindVertexBuffers(vertexBuffer); cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen); cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(videoPlayer.RenderTexture, sampler)); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(videoPlayer.RenderTexture, sampler));
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0); cmdbuf.DrawIndexedPrimitives(0, 0, 2);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);