aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory/GpuRegionHandle.cs
blob: 92099b6a590d21371cdb49ad6dc1f219767fafbb (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Ryujinx.Cpu.Tracking;
using Ryujinx.Memory.Tracking;
using System;

namespace Ryujinx.Graphics.Gpu.Memory
{
    class GpuRegionHandle : IRegionHandle
    {
        private readonly CpuRegionHandle[] _cpuRegionHandles;

        public bool Dirty
        {
            get
            {
                foreach (var regionHandle in _cpuRegionHandles)
                {
                    if (regionHandle.Dirty)
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        public ulong Address => throw new NotSupportedException();
        public ulong Size => throw new NotSupportedException();
        public ulong EndAddress => throw new NotSupportedException();

        public GpuRegionHandle(CpuRegionHandle[] cpuRegionHandles)
        {
            _cpuRegionHandles = cpuRegionHandles;
        }

        public void Dispose()
        {
            foreach (var regionHandle in _cpuRegionHandles)
            {
                regionHandle.Dispose();
            }
        }

        public void RegisterAction(RegionSignal action)
        {
            foreach (var regionHandle in _cpuRegionHandles)
            {
                regionHandle.RegisterAction(action);
            }
        }

        public void Reprotect(bool asDirty = false)
        {
            foreach (var regionHandle in _cpuRegionHandles)
            {
                regionHandle.Reprotect(asDirty);
            }
        }
    }
}