Added more shader instructions, including BFE, BRA (partial), FMNMX, ISCADD, SHL, LD_C, some shader related fixes, added support for texture component selection

This commit is contained in:
gdkchan 2018-05-17 15:25:42 -03:00
parent 9b9ead94cd
commit b19c474082
28 changed files with 806 additions and 118 deletions

View file

@ -81,6 +81,22 @@ namespace Ryujinx.Graphics.Gal.OpenGL
throw new NotImplementedException(Format.ToString());
}
public static All GetTextureSwizzle(GalTextureSource Source)
{
switch (Source)
{
case GalTextureSource.Zero: return All.Zero;
case GalTextureSource.Red: return All.Red;
case GalTextureSource.Green: return All.Green;
case GalTextureSource.Blue: return All.Blue;
case GalTextureSource.Alpha: return All.Alpha;
case GalTextureSource.OneInt: return All.One;
case GalTextureSource.OneFloat: return All.One;
}
throw new ArgumentException(nameof(Source));
}
public static TextureWrapMode GetTextureWrapMode(GalTextureWrap Wrap)
{
switch (Wrap)

View file

@ -87,10 +87,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
public void Create(long Tag, GalShaderType Type, byte[] Data)
{
Stages.GetOrAdd(Tag, (Key) => ShaderStageFactory(Type, Data));
Stages.GetOrAdd(Tag, (Key) => ShaderStageFactory(Type, Tag, Data));
}
private ShaderStage ShaderStageFactory(GalShaderType Type, byte[] Data)
private ShaderStage ShaderStageFactory(GalShaderType Type, long Tag, byte[] Data)
{
GlslProgram Program = GetGlslProgram(Data, Type);
@ -140,11 +140,21 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
foreach (ShaderDeclInfo DeclInfo in Stage.UniformUsage.Where(x => x.Cbuf == Cbuf))
{
float Value = BitConverter.ToSingle(Data, DeclInfo.Index * 4);
int Location = GL.GetUniformLocation(CurrentProgramHandle, DeclInfo.Name);
GL.Uniform1(Location, Value);
int Count = Data.Length >> 2;
//The Index is the index of the last element,
//so we can add 1 to get the uniform array size.
Count = Math.Min(Count, DeclInfo.Index + 1);
unsafe
{
fixed (byte* Ptr = Data)
{
GL.Uniform1(Location, Count, (float*)Ptr);
}
}
}
}
}

View file

@ -51,6 +51,16 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Type,
Texture.Data);
}
int SwizzleR = (int)OGLEnumConverter.GetTextureSwizzle(Texture.XSource);
int SwizzleG = (int)OGLEnumConverter.GetTextureSwizzle(Texture.YSource);
int SwizzleB = (int)OGLEnumConverter.GetTextureSwizzle(Texture.ZSource);
int SwizzleA = (int)OGLEnumConverter.GetTextureSwizzle(Texture.WSource);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, SwizzleR);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, SwizzleG);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, SwizzleB);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleA, SwizzleA);
}
public void Bind(int Index)