aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-05-22 22:43:31 -0300
committergdkchan <gab.dark.100@gmail.com>2018-05-22 22:43:31 -0300
commit79e007036383b11cd53c2563fbb7f139a02c90ec (patch)
treec7ddfc097282b98afd16f08cc5042636f9283224 /Ryujinx.Graphics/Gal/OpenGL
parent84996ccd36a5fa13892c1f02acb1c79031c35aa5 (diff)
Improve shader sending method to GAL, use a memory interface instead of reading a fixed array size and sending every time
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs27
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs8
2 files changed, 10 insertions, 25 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
index e740a32e..a8941d69 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs
@@ -3,7 +3,6 @@ using Ryujinx.Graphics.Gal.Shader;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
namespace Ryujinx.Graphics.Gal.OpenGL
@@ -85,14 +84,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Programs = new Dictionary<ShaderProgram, int>();
}
- public void Create(long Tag, GalShaderType Type, byte[] Data)
+ public void Create(IGalMemory Memory, long Tag, GalShaderType Type)
{
- Stages.GetOrAdd(Tag, (Key) => ShaderStageFactory(Type, Tag, Data));
+ Stages.GetOrAdd(Tag, (Key) => ShaderStageFactory(Memory, Tag, Type));
}
- private ShaderStage ShaderStageFactory(GalShaderType Type, long Tag, byte[] Data)
+ private ShaderStage ShaderStageFactory(IGalMemory Memory, long Position, GalShaderType Type)
{
- GlslProgram Program = GetGlslProgram(Data, Type);
+ GlslProgram Program = GetGlslProgram(Memory, Position, Type);
return new ShaderStage(
Type,
@@ -101,25 +100,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Program.Uniforms);
}
- private GlslProgram GetGlslProgram(byte[] Data, GalShaderType Type)
+ private GlslProgram GetGlslProgram(IGalMemory Memory, long Position, GalShaderType Type)
{
- int[] Code = new int[(Data.Length - 0x50) >> 2];
-
- using (MemoryStream MS = new MemoryStream(Data))
- {
- MS.Seek(0x50, SeekOrigin.Begin);
-
- BinaryReader Reader = new BinaryReader(MS);
-
- for (int Index = 0; Index < Code.Length; Index++)
- {
- Code[Index] = Reader.ReadInt32();
- }
- }
-
GlslDecompiler Decompiler = new GlslDecompiler();
- return Decompiler.Decompile(Code, Type);
+ return Decompiler.Decompile(Memory, Position + 0x50, Type);
}
public IEnumerable<ShaderDeclInfo> GetTextureUsage(long Tag)
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
index f9410573..69e344c7 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
@@ -198,14 +198,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
ActionsQueue.Enqueue(() => Rasterizer.DrawElements(VbIndex, First, PrimType));
}
- public void CreateShader(long Tag, GalShaderType Type, byte[] Data)
+ public void CreateShader(IGalMemory Memory, long Tag, GalShaderType Type)
{
- if (Data == null)
+ if (Memory == null)
{
- throw new ArgumentNullException(nameof(Data));
+ throw new ArgumentNullException(nameof(Memory));
}
- Shader.Create(Tag, Type, Data);
+ Shader.Create(Memory, Tag, Type);
}
public void SetConstBuffer(long Tag, int Cbuf, byte[] Data)