aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.GAL/Multithreading/Resources/Programs/SourceProgramRequest.cs
blob: d40ce6a4636920e79aa32fb70f62133b3679575c (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 System.Linq;

namespace Ryujinx.Graphics.GAL.Multithreading.Resources.Programs
{
    class SourceProgramRequest : IProgramRequest
    {
        public ThreadedProgram Threaded { get; set; }

        private IShader[] _shaders;
        private TransformFeedbackDescriptor[] _transformFeedbackDescriptors;

        public SourceProgramRequest(ThreadedProgram program, IShader[] shaders, TransformFeedbackDescriptor[] transformFeedbackDescriptors)
        {
            Threaded = program;

            _shaders = shaders;
            _transformFeedbackDescriptors = transformFeedbackDescriptors;
        }

        public IProgram Create(IRenderer renderer)
        {
            IShader[] shaders = _shaders.Select(shader =>
            {
                var threaded = (ThreadedShader)shader;
                threaded?.EnsureCreated();
                return threaded?.Base;
            }).ToArray();

            return renderer.CreateProgram(shaders, _transformFeedbackDescriptors);
        }
    }
}