2019-10-13 08:02:07 +02:00
|
|
|
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; }
|
|
|
|
|
2020-11-08 12:10:00 +01:00
|
|
|
public Shader(ShaderStage stage, string code)
|
2019-10-13 08:02:07 +02:00
|
|
|
{
|
2020-11-08 12:10:00 +01:00
|
|
|
ShaderType type = stage switch
|
2019-10-13 08:02:07 +02:00
|
|
|
{
|
2020-11-08 12:10:00 +01:00
|
|
|
ShaderStage.Compute => ShaderType.ComputeShader,
|
|
|
|
ShaderStage.Vertex => ShaderType.VertexShader,
|
|
|
|
ShaderStage.TessellationControl => ShaderType.TessControlShader,
|
|
|
|
ShaderStage.TessellationEvaluation => ShaderType.TessEvaluationShader,
|
|
|
|
ShaderStage.Geometry => ShaderType.GeometryShader,
|
|
|
|
ShaderStage.Fragment => ShaderType.FragmentShader,
|
|
|
|
_ => ShaderType.VertexShader
|
|
|
|
};
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
|
|
Handle = GL.CreateShader(type);
|
|
|
|
|
2020-11-08 12:10:00 +01:00
|
|
|
GL.ShaderSource(Handle, code);
|
2019-10-13 08:02:07 +02:00
|
|
|
GL.CompileShader(Handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
if (Handle != 0)
|
|
|
|
{
|
|
|
|
GL.DeleteShader(Handle);
|
|
|
|
|
|
|
|
Handle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|