aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Host1x/Devices.cs
blob: 5b3bed6b066e6cc60f749aaebdaec13617129fbf (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 Dictionary<ClassId, IDeviceState>();

        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();
                }
            }
        }
    }
}