diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-12-26 12:39:07 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 12:39:07 -0300 |
commit | 451673ada576ecd7b8e98fb03e063b5d37152c39 (patch) | |
tree | c7c180a9a87856a825cd286d28b95d9496b2d862 | |
parent | 0b1185284c311510d08eb4a3442823356a785e24 (diff) |
Fix I2M texture copies when line length is not a multiple of 4 (#2938)
* Fix I2M texture copies when line length is not a multiple of 4
* Do not copy padding bytes for 1D copies
* Nit
-rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs b/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs index 9649841f..c0939057 100644 --- a/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs +++ b/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs @@ -99,9 +99,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory _isLinear = (argument & 1) != 0; _offset = 0; - _size = (int)(state.LineLengthIn * state.LineCount); + _size = (int)(BitUtils.AlignUp(state.LineLengthIn, 4) * state.LineCount); - int count = BitUtils.DivRoundUp(_size, 4); + int count = _size / 4; if (_buffer == null || _buffer.Length < count) { @@ -171,7 +171,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory if (_isLinear && _lineCount == 1) { - memoryManager.WriteTrackedResource(_dstGpuVa, data); + memoryManager.WriteTrackedResource(_dstGpuVa, data.Slice(0, _lineLengthIn)); _context.AdvanceSequence(); } else @@ -224,6 +224,15 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory memoryManager.Write(dstAddress, data[srcOffset]); } + + // All lines must be aligned to 4 bytes, as the data is pushed one word at a time. + // If our copy length is not a multiple of 4, then we need to skip the padding bytes here. + int misalignment = _lineLengthIn & 3; + + if (misalignment != 0) + { + srcOffset += 4 - misalignment; + } } _context.AdvanceSequence(); |