aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-05 22:02:28 -0300
committerGitHub <noreply@github.com>2020-05-06 11:02:28 +1000
commitb8eb6abeccbd4a468214a4d2ad3a9b6e5e06973c (patch)
treecd3d71ebde0f4f32eb674778adae89c0efcb75df /Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs
parent7f500e7cae940958289abe1a3461e52684742053 (diff)
Refactor shader GPU state and memory access (#1203)
* Refactor shader GPU state and memory access * Fix NVDEC project build * Address PR feedback and add missing XML comments
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs
new file mode 100644
index 00000000..de06e5e0
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/Shader/ShaderBundle.cs
@@ -0,0 +1,46 @@
+using Ryujinx.Graphics.GAL;
+using System;
+
+namespace Ryujinx.Graphics.Gpu.Shader
+{
+ /// <summary>
+ /// Represents a program composed of one or more shader stages (for graphics shaders),
+ /// or a single shader (for compute shaders).
+ /// </summary>
+ class ShaderBundle : IDisposable
+ {
+ /// <summary>
+ /// Host shader program object.
+ /// </summary>
+ public IProgram HostProgram { get; }
+
+ /// <summary>
+ /// Compiled shader for each shader stage.
+ /// </summary>
+ public ShaderCodeHolder[] Shaders { get; }
+
+ /// <summary>
+ /// Creates a new instance of the shader bundle.
+ /// </summary>
+ /// <param name="hostProgram">Host program with all the shader stages</param>
+ /// <param name="shaders">Shaders</param>
+ public ShaderBundle(IProgram hostProgram, params ShaderCodeHolder[] shaders)
+ {
+ HostProgram = hostProgram;
+ Shaders = shaders;
+ }
+
+ /// <summary>
+ /// Dispose of the host shader resources.
+ /// </summary>
+ public void Dispose()
+ {
+ HostProgram.Dispose();
+
+ foreach (ShaderCodeHolder holder in Shaders)
+ {
+ holder?.HostShader.Dispose();
+ }
+ }
+ }
+}