mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using OpenTK.Graphics.OpenGL;
|
|
using Ryujinx.Graphics.GAL;
|
|
using Ryujinx.Graphics.Shader;
|
|
|
|
namespace Ryujinx.Graphics.OpenGL
|
|
{
|
|
class Shader : IShader
|
|
{
|
|
public int Handle { get; private set; }
|
|
|
|
private ShaderProgram _program;
|
|
|
|
public ShaderProgramInfo Info => _program.Info;
|
|
|
|
public ShaderStage Stage => _program.Stage;
|
|
|
|
public Shader(ShaderProgram program)
|
|
{
|
|
_program = program;
|
|
|
|
ShaderType type = ShaderType.VertexShader;
|
|
|
|
switch (program.Stage)
|
|
{
|
|
case ShaderStage.Compute: type = ShaderType.ComputeShader; break;
|
|
case ShaderStage.Vertex: type = ShaderType.VertexShader; break;
|
|
case ShaderStage.TessellationControl: type = ShaderType.TessControlShader; break;
|
|
case ShaderStage.TessellationEvaluation: type = ShaderType.TessEvaluationShader; break;
|
|
case ShaderStage.Geometry: type = ShaderType.GeometryShader; break;
|
|
case ShaderStage.Fragment: type = ShaderType.FragmentShader; break;
|
|
}
|
|
|
|
Handle = GL.CreateShader(type);
|
|
|
|
GL.ShaderSource(Handle, program.Code);
|
|
GL.CompileShader(Handle);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (Handle != 0)
|
|
{
|
|
GL.DeleteShader(Handle);
|
|
|
|
Handle = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|