diff --git a/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs b/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs index 108d3d9b1..749f1fb07 100644 --- a/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/IGalFrameBuffer.cs @@ -12,8 +12,6 @@ namespace Ryujinx.Graphics.Gal void UnbindZeta(); - void BindTexture(long Key, int Index); - void Set(long Key); void Set(byte[] Data, int Width, int Height); diff --git a/Ryujinx.Graphics/Gal/IGalTexture.cs b/Ryujinx.Graphics/Gal/IGalTexture.cs index ea9301e54..a3714ef6d 100644 --- a/Ryujinx.Graphics/Gal/IGalTexture.cs +++ b/Ryujinx.Graphics/Gal/IGalTexture.cs @@ -11,8 +11,6 @@ namespace Ryujinx.Graphics.Gal bool TryGetCachedTexture(long Key, long DataSize, out GalImage Image); - void Bind(long Key, int Index); - - void SetSampler(long Key, GalTextureSampler Sampler); + void Bind(long Key, int Index, GalTextureSampler Sampler); } } \ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs index dc85f8fae..929d13c40 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs @@ -148,16 +148,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - public void BindTexture(long Key, int Index) - { - if (Texture.TryGetImage(Key, out ImageHandler Tex)) - { - GL.ActiveTexture(TextureUnit.Texture0 + Index); - - GL.BindTexture(TextureTarget.Texture2D, Tex.Handle); - } - } - public void Set(long Key) { if (Texture.TryGetImage(Key, out ImageHandler Tex)) diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index 35edb68ec..4bf7336b6 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -185,19 +185,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL return false; } - public void Bind(long Key, int Index) - { - if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage)) - { - TextureTarget Target = OGLEnumConverter.GetImageTarget(CachedImage.Image.Target); - - GL.ActiveTexture(TextureUnit.Texture0 + Index); - - GL.BindTexture(Target, CachedImage.Handle); - } - } - - public void SetSampler(long Key, GalTextureSampler Sampler) + public void Bind(long Key, int Index, GalTextureSampler Sampler) { if (!TextureCache.TryGetValue(Key, out ImageHandler CachedImage)) { @@ -206,6 +194,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL TextureTarget Target = OGLEnumConverter.GetImageTarget(CachedImage.Image.Target); + GL.ActiveTexture(TextureUnit.Texture0 + Index); + + GL.BindTexture(Target, CachedImage.Handle); + int WrapS = (int)OGLEnumConverter.GetTextureWrapMode(Sampler.AddressU); int WrapT = (int)OGLEnumConverter.GetTextureWrapMode(Sampler.AddressV); diff --git a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs index aa8c17cb4..3707784fc 100644 --- a/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs +++ b/Ryujinx.Graphics/Gal/Shader/ShaderDecodeMem.cs @@ -260,7 +260,6 @@ namespace Ryujinx.Graphics.Gal.Shader OperB = GetOperGpr20(OpCode); break; - //Unsure about this layout case ShaderTextureType._2dArray: OperA = GetOperGpr8 (OpCode) + 1; OperB = GetOperGpr20(OpCode); diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index 0d35da22d..fd6578d15 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -509,47 +509,32 @@ namespace Ryujinx.HLE.Gpu.Engines if (Key == -1) { - //FIXME: Should'nt ignore invalid addresses. + //FIXME: Shouldn't ignore invalid addresses. return; } - if (IsFrameBufferPosition(Key)) - { - //This texture is a frame buffer texture, - //we shouldn't read anything from memory and bind - //the frame buffer texture instead, since we're not - //really writing anything to memory. - Gpu.Renderer.FrameBuffer.BindTexture(Key, TexIndex); - } - else + //If a texture is a rendertarget texture, + //we shouldn't read anything from memory and just bind it + + if (!IsFrameBufferPosition(Key)) { GalImage NewImage = TextureFactory.MakeTexture(Vmm, TicPosition); long Size = (uint)TextureHelper.GetTextureSize(NewImage); - bool HasCachedTexture = false; + bool Exists = Gpu.Renderer.Texture.TryGetCachedTexture(Key, Size, out GalImage Image); - if (Gpu.Renderer.Texture.TryGetCachedTexture(Key, Size, out GalImage Image)) - { - if (NewImage.Equals(Image) && !QueryKeyUpload(Vmm, Key, Size, NvGpuBufferType.Texture)) - { - Gpu.Renderer.Texture.Bind(Key, TexIndex); - - HasCachedTexture = true; - } - } - - if (!HasCachedTexture) + if (!Exists || + !NewImage.Equals(Image) || + QueryKeyUpload(Vmm, Key, Size, NvGpuBufferType.Texture)) { byte[] Data = TextureFactory.GetTextureData(Vmm, TicPosition); Gpu.Renderer.Texture.Create(Key, Data, NewImage); } - - Gpu.Renderer.Texture.Bind(Key, TexIndex); } - Gpu.Renderer.Texture.SetSampler(Key, Sampler); + Gpu.Renderer.Texture.Bind(Key, TexIndex, Sampler); } private void UploadConstBuffers(NvGpuVmm Vmm, GalPipelineState State, long[] Keys)