aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedShader.cs
blob: dcbecf38918831576505990eafab263ee2e1f4cc (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
33
34
35
36
37
38
using Ryujinx.Graphics.GAL.Multithreading.Commands.Shader;
using Ryujinx.Graphics.GAL.Multithreading.Model;
using Ryujinx.Graphics.Shader;

namespace Ryujinx.Graphics.GAL.Multithreading.Resources
{
    class ThreadedShader : IShader
    {
        private ThreadedRenderer _renderer;
        private ShaderStage _stage;
        private string _code;

        public IShader Base;

        public ThreadedShader(ThreadedRenderer renderer, ShaderStage stage, string code)
        {
            _renderer = renderer;
            
            _stage = stage;
            _code = code;
        }

        internal void EnsureCreated()
        {
            if (_code != null && Base == null)
            {
                Base = _renderer.BaseRenderer.CompileShader(_stage, _code);
                _code = null;
            }
        }

        public void Dispose()
        {
            _renderer.New<ShaderDisposeCommand>().Set(new TableRef<ThreadedShader>(_renderer, this));
            _renderer.QueueCommand();
        }
    }
}