diff --git a/Ryujinx.Graphics/Gal/IGalShader.cs b/Ryujinx.Graphics/Gal/IGalShader.cs index e906e6cdc..4b951fa61 100644 --- a/Ryujinx.Graphics/Gal/IGalShader.cs +++ b/Ryujinx.Graphics/Gal/IGalShader.cs @@ -11,8 +11,6 @@ namespace Ryujinx.Graphics.Gal IEnumerable GetConstBufferUsage(long Key); IEnumerable GetTextureUsage(long Key); - void EnsureTextureBinding(string UniformName, int Value); - void Bind(long Key); void Unbind(GalShaderType Type); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs index 9c7b8668f..0108a0da2 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs @@ -96,15 +96,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL return Enumerable.Empty(); } - public void EnsureTextureBinding(string UniformName, int Value) - { - BindProgram(); - - int Location = GL.GetUniformLocation(CurrentProgramHandle, UniformName); - - GL.Uniform1(Location, Value); - } - public unsafe void SetFlip(float X, float Y) { BindProgram(); @@ -188,6 +179,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL CheckProgramLink(Handle); BindUniformBlocks(Handle); + BindTextureLocations(Handle); Programs.Add(Current, Handle); } @@ -258,6 +250,34 @@ namespace Ryujinx.Graphics.Gal.OpenGL BindUniformBlocksIfNotNull(Current.Fragment); } + private void BindTextureLocations(int ProgramHandle) + { + int Index = 0; + + void BindTexturesIfNotNull(OGLShaderStage Stage) + { + if (Stage != null) + { + foreach (ShaderDeclInfo Decl in Stage.TextureUsage) + { + int Location = GL.GetUniformLocation(ProgramHandle, Decl.Name); + + GL.Uniform1(Location, Index); + + Index++; + } + } + } + + GL.UseProgram(ProgramHandle); + + BindTexturesIfNotNull(Current.Vertex); + BindTexturesIfNotNull(Current.TessControl); + BindTexturesIfNotNull(Current.TessEvaluation); + BindTexturesIfNotNull(Current.Geometry); + BindTexturesIfNotNull(Current.Fragment); + } + private static void CheckProgramLink(int Handle) { int Status = 0; diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index 1d0834ddb..419f6901e 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -442,8 +442,6 @@ namespace Ryujinx.HLE.Gpu.Engines UploadTexture(Vmm, TexIndex, TextureHandle); - Gpu.Renderer.Shader.EnsureTextureBinding(DeclInfo.Name, TexIndex); - TexIndex++; } }