aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Renderer/CreateBufferSparseCommand.cs
blob: 965529ad196c14638a00ff1dfe3ba3991689b266 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Ryujinx.Graphics.GAL.Multithreading.Model;
using System;

namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
{
    struct CreateBufferSparseCommand : IGALCommand, IGALCommand<CreateBufferSparseCommand>
    {
        public readonly CommandType CommandType => CommandType.CreateBufferSparse;
        private BufferHandle _threadedHandle;
        private SpanRef<BufferRange> _buffers;

        public void Set(BufferHandle threadedHandle, SpanRef<BufferRange> buffers)
        {
            _threadedHandle = threadedHandle;
            _buffers = buffers;
        }

        public static void Run(ref CreateBufferSparseCommand command, ThreadedRenderer threaded, IRenderer renderer)
        {
            Span<BufferRange> buffers = command._buffers.Get(threaded);
            threaded.Buffers.AssignBuffer(command._threadedHandle, renderer.CreateBufferSparse(threaded.Buffers.MapBufferRanges(buffers)));
            command._buffers.Dispose(threaded);
        }
    }
}