mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-14 05:26:41 +00:00
3bd357045f
* Do not allow render targets not explicitly written by the fragment shader to be modified * Shader cache version bump * Remove blank lines * Avoid redundant color mask updates * HostShaderCacheEntry can be null * Avoid more redundant glColorMask calls * nit: Mask -> Masks * Fix currentComponentMask * More efficient way to update _currentComponentMasks
42 lines
1.2 KiB
C#
42 lines
1.2 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; }
|
|
public bool IsFragment { get; }
|
|
|
|
public Shader(ShaderStage stage, string code)
|
|
{
|
|
ShaderType type = stage switch
|
|
{
|
|
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
|
|
};
|
|
|
|
Handle = GL.CreateShader(type);
|
|
IsFragment = stage == ShaderStage.Fragment;
|
|
|
|
GL.ShaderSource(Handle, code);
|
|
GL.CompileShader(Handle);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (Handle != 0)
|
|
{
|
|
GL.DeleteShader(Handle);
|
|
|
|
Handle = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|