aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Engine/Inline2Memory.cs
blob: d2816ac593b474318cb77963f7ba3df111926df8 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Ryujinx.Graphics.Gpu.State;
using System;

namespace Ryujinx.Graphics.Gpu.Engine
{
    partial class Methods
    {
        private Inline2MemoryParams _params;

        private bool _isLinear;

        private int _offset;
        private int _size;

        public void Execute(int argument)
        {
            _params = _context.State.Get<Inline2MemoryParams>(MethodOffset.Inline2MemoryParams);

            _isLinear = (argument & 1) != 0;

            _offset = 0;
            _size   = _params.LineLengthIn * _params.LineCount;
        }

        public void PushData(int argument)
        {
            if (_isLinear)
            {
                for (int shift = 0; shift < 32 && _offset < _size; shift += 8, _offset++)
                {
                    ulong gpuVa = _params.DstAddress.Pack() + (ulong)_offset;

                    _context.MemoryAccessor.Write(gpuVa, new byte[] { (byte)(argument >> shift) });
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
    }
}