From 40b21cc3c4d2622bbd4f88d43073341854d9a671 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sun, 11 Jul 2021 17:20:40 -0300 Subject: Separate GPU engines (part 2/2) (#2440) * 3D engine now uses DeviceState too, plus new state modification tracking * Remove old methods code * Remove GpuState and friends * Optimize DeviceState, force inline some functions * This change was not supposed to go in * Proper channel initialization * Optimize state read/write methods even more * Fix debug build * Do not dirty state if the write is redundant * The YControl register should dirty either the viewport or front face state too, to update the host origin * Avoid redundant vertex buffer updates * Move state and get rid of the Ryujinx.Graphics.Gpu.State namespace * Comments and nits * Fix rebase * PR feedback * Move changed = false to improve codegen * PR feedback * Carry RyuJIT a bit more --- Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs | 134 --------------------------- 1 file changed, 134 deletions(-) delete mode 100644 Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs (limited to 'Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs b/Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs deleted file mode 100644 index 3d23b785..00000000 --- a/Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs +++ /dev/null @@ -1,134 +0,0 @@ -using Ryujinx.Common; -using Ryujinx.Graphics.Gpu.State; -using Ryujinx.Graphics.Texture; -using System; -using System.Runtime.InteropServices; - -namespace Ryujinx.Graphics.Gpu.Engine -{ - partial class Methods - { - private Inline2MemoryParams _params; - - private bool _isLinear; - - private int _offset; - private int _size; - - private bool _finished; - - private int[] _buffer; - - /// - /// Launches Inline-to-Memory engine DMA copy. - /// - /// Current GPU state - /// Method call argument - public void LaunchDma(GpuState state, int argument) - { - _params = state.Get(MethodOffset.I2mParams); - - _isLinear = (argument & 1) != 0; - - _offset = 0; - _size = _params.LineLengthIn * _params.LineCount; - - int count = BitUtils.DivRoundUp(_size, 4); - - if (_buffer == null || _buffer.Length < count) - { - _buffer = new int[count]; - } - - ulong dstBaseAddress = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack()); - - // Trigger read tracking, to flush any managed resources in the destination region. - state.Channel.MemoryManager.Physical.GetSpan(dstBaseAddress, _size, true); - - _finished = false; - } - - /// - /// Pushes a word of data to the Inline-to-Memory engine. - /// - /// Current GPU state - /// Method call argument - public void LoadInlineData(GpuState state, int argument) - { - if (!_finished) - { - _buffer[_offset++] = argument; - - if (_offset * 4 >= _size) - { - FinishTransfer(state); - } - } - } - - /// - /// Performs actual copy of the inline data after the transfer is finished. - /// - /// Current GPU state - private void FinishTransfer(GpuState state) - { - Span data = MemoryMarshal.Cast(_buffer).Slice(0, _size); - - if (_isLinear && _params.LineCount == 1) - { - ulong address = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack()); - - state.Channel.MemoryManager.Physical.Write(address, data); - } - else - { - var dstCalculator = new OffsetCalculator( - _params.DstWidth, - _params.DstHeight, - _params.DstStride, - _isLinear, - _params.DstMemoryLayout.UnpackGobBlocksInY(), - 1); - - int srcOffset = 0; - - ulong dstBaseAddress = state.Channel.MemoryManager.Translate(_params.DstAddress.Pack()); - - for (int y = _params.DstY; y < _params.DstY + _params.LineCount; y++) - { - int x1 = _params.DstX; - int x2 = _params.DstX + _params.LineLengthIn; - int x2Trunc = _params.DstX + BitUtils.AlignDown(_params.LineLengthIn, 16); - - int x; - - for (x = x1; x < x2Trunc; x += 16, srcOffset += 16) - { - int dstOffset = dstCalculator.GetOffset(x, y); - - ulong dstAddress = dstBaseAddress + (ulong)dstOffset; - - Span pixel = data.Slice(srcOffset, 16); - - state.Channel.MemoryManager.Physical.Write(dstAddress, pixel); - } - - for (; x < x2; x++, srcOffset++) - { - int dstOffset = dstCalculator.GetOffset(x, y); - - ulong dstAddress = dstBaseAddress + (ulong)dstOffset; - - Span pixel = data.Slice(srcOffset, 1); - - state.Channel.MemoryManager.Physical.Write(dstAddress, pixel); - } - } - } - - _finished = true; - - _context.AdvanceSequence(); - } - } -} \ No newline at end of file -- cgit v1.2.3