aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Host1x/Devices.cs
blob: 9de2b81a94234e89059ab1a126fc74cef5c49365 (plain) (blame)
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
using Ryujinx.Graphics.Device;
using System;
using System.Collections.Generic;

namespace Ryujinx.Graphics.Host1x
{
    class Devices : IDisposable
    {
        private readonly Dictionary<ClassId, IDeviceState> _devices = new();

        public void RegisterDevice(ClassId classId, IDeviceState device)
        {
            _devices[classId] = device;
        }

        public IDeviceState GetDevice(ClassId classId)
        {
            return _devices.TryGetValue(classId, out IDeviceState device) ? device : null;
        }

        public void Dispose()
        {
            foreach (var device in _devices.Values)
            {
                if (device is ThiDevice thi)
                {
                    thi.Dispose();
                }
            }
        }
    }
}