From 1f554c1093dde6a4d3ed80fae2675abfb6c12fac Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sun, 3 Mar 2019 19:45:25 -0600 Subject: Do naming refactoring on Ryujinx.Graphics (#611) * Renaming part 1 * Renaming part 2 * Renaming part 3 * Renaming part 4 * Renaming part 5 * Renaming part 6 * Renaming part 7 * Renaming part 8 * Renaming part 9 * Renaming part 10 * General cleanup * Thought I got all of these * Apply #595 * Additional renaming * Tweaks from feedback * Rename files --- Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs (limited to 'Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs') diff --git a/Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs b/Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs new file mode 100644 index 00000000..9e68a8e6 --- /dev/null +++ b/Ryujinx.Graphics/Gal/OpenGL/OglShaderProgram.cs @@ -0,0 +1,86 @@ +using OpenTK.Graphics.OpenGL; +using System; +using System.Collections.Generic; + +namespace Ryujinx.Graphics.Gal.OpenGL +{ + struct OglShaderProgram + { + public OglShaderStage Vertex; + public OglShaderStage TessControl; + public OglShaderStage TessEvaluation; + public OglShaderStage Geometry; + public OglShaderStage Fragment; + } + + class OglShaderStage : IDisposable + { + public int Handle { get; private set; } + + public bool IsCompiled { get; private set; } + + public GalShaderType Type { get; private set; } + + public string Code { get; private set; } + + public IEnumerable ConstBufferUsage { get; private set; } + public IEnumerable TextureUsage { get; private set; } + + public OglShaderStage( + GalShaderType type, + string code, + IEnumerable constBufferUsage, + IEnumerable textureUsage) + { + Type = type; + Code = code; + ConstBufferUsage = constBufferUsage; + TextureUsage = textureUsage; + } + + public void Compile() + { + if (Handle == 0) + { + Handle = GL.CreateShader(OglEnumConverter.GetShaderType(Type)); + + CompileAndCheck(Handle, Code); + } + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && Handle != 0) + { + GL.DeleteShader(Handle); + + Handle = 0; + } + } + + public static void CompileAndCheck(int handle, string code) + { + GL.ShaderSource(handle, code); + GL.CompileShader(handle); + + CheckCompilation(handle); + } + + private static void CheckCompilation(int handle) + { + int status = 0; + + GL.GetShader(handle, ShaderParameter.CompileStatus, out status); + + if (status == 0) + { + throw new ShaderException(GL.GetShaderInfoLog(handle)); + } + } + } +} \ No newline at end of file -- cgit v1.2.3