aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/GpuContext.cs
blob: 51961522a05ad5a34d72ce30bc73dd870977e140 (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
61
62
63
64
65
66
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine;
using Ryujinx.Graphics.Gpu.Memory;
using System;

namespace Ryujinx.Graphics.Gpu
{
    public class GpuContext
    {
        public IRenderer Renderer { get; }

        internal IPhysicalMemory PhysicalMemory { get; private set; }

        public MemoryManager MemoryManager { get; }

        internal MemoryAccessor MemoryAccessor { get; }

        internal Methods Methods { get; }

        internal NvGpuFifo Fifo { get; }

        public DmaPusher DmaPusher { get; }

        public Window Window { get; }

        internal int SequenceNumber { get; private set; }

        private Lazy<Capabilities> _caps;

        internal Capabilities Capabilities => _caps.Value;

        public GpuContext(IRenderer renderer)
        {
            Renderer = renderer;

            MemoryManager = new MemoryManager();

            MemoryAccessor = new MemoryAccessor(this);

            Methods = new Methods(this);

            Fifo = new NvGpuFifo(this);

            DmaPusher = new DmaPusher(this);

            Window = new Window(this);

            _caps = new Lazy<Capabilities>(GetCapabilities);
        }

        internal void AdvanceSequence()
        {
            SequenceNumber++;
        }

        private Capabilities GetCapabilities()
        {
            return Renderer.GetCapabilities();
        }

        public void SetVmm(IPhysicalMemory mm)
        {
            PhysicalMemory = mm;
        }
    }
}