using Ryujinx.Graphics.GAL.Multithreading.Model; using Ryujinx.Graphics.GAL.Multithreading.Resources; using System; using System.Buffers; namespace Ryujinx.Graphics.GAL.Multithreading.Commands { struct SetRenderTargetsCommand : IGALCommand, IGALCommand { public static readonly ArrayPool ArrayPool = ArrayPool.Create(512, 50); public readonly CommandType CommandType => CommandType.SetRenderTargets; private int _colorsCount; private TableRef _colors; private TableRef _depthStencil; public void Set(int colorsCount, TableRef colors, TableRef depthStencil) { _colorsCount = colorsCount; _colors = colors; _depthStencil = depthStencil; } public static void Run(ref SetRenderTargetsCommand command, ThreadedRenderer threaded, IRenderer renderer) { ITexture[] colors = command._colors.Get(threaded); Span colorsSpan = colors.AsSpan(0, command._colorsCount); for (int i = 0; i < colorsSpan.Length; i++) { colorsSpan[i] = ((ThreadedTexture)colorsSpan[i])?.Base; } renderer.Pipeline.SetRenderTargets(colorsSpan, command._depthStencil.GetAs(threaded)?.Base); ArrayPool.Return(colors); } } }