aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-05-17 15:25:42 -0300
committergdkchan <gab.dark.100@gmail.com>2018-05-17 15:25:42 -0300
commitb19c4740823ed8fcebf62bf5741a7614a2ac0aa0 (patch)
tree8cdede3fdb90aa35ffe50c004559b80d4704bea3 /Ryujinx.Graphics/Gal/OpenGL
parent9b9ead94cd2f25a85468ecf91b7898bf34e10825 (diff)
Added more shader instructions, including BFE, BRA (partial), FMNMX, ISCADD, SHL, LD_C, some shader related fixes, added support for texture component selection
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs16
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs20
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs10
3 files changed, 41 insertions, 5 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
index 4cc0a039..d266a87a 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
@@ -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)
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
index fff6362b..e740a32e 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
@@ -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);
+ }
+ }
}
}
}
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
index 9ea25056..8dcfb2bd 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
@@ -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)