diff --git a/osu.Framework.Tests/Graphics/RendererTest.cs b/osu.Framework.Tests/Graphics/RendererTest.cs index 1f77e8e1cb..fd84554e2c 100644 --- a/osu.Framework.Tests/Graphics/RendererTest.cs +++ b/osu.Framework.Tests/Graphics/RendererTest.cs @@ -26,5 +26,28 @@ public void TestWhitePixelReuseUpdatesTextureWrapping() Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None)); Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None)); } + + [Test] + public void TestTextureAtlasReuseUpdatesTextureWrapping() + { + DummyRenderer renderer = new DummyRenderer(); + + TextureAtlas atlas = new TextureAtlas(renderer, 1024, 1024); + + Texture textureWrapNone = atlas.Add(100, 100, WrapMode.None, WrapMode.None)!; + Texture textureWrapClamp = atlas.Add(100, 100, WrapMode.ClampToEdge, WrapMode.ClampToEdge)!; + + renderer.BindTexture(textureWrapNone, 0, null, null); + Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None)); + Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.None)); + + renderer.BindTexture(textureWrapClamp, 0, null, null); + Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.ClampToEdge)); + Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.ClampToEdge)); + + renderer.BindTexture(textureWrapNone, 0, null, null); + Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None)); + Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.None)); + } } } diff --git a/osu.Framework/Graphics/Rendering/Renderer.cs b/osu.Framework/Graphics/Rendering/Renderer.cs index 8066d379ed..01a8a1f39a 100644 --- a/osu.Framework/Graphics/Rendering/Renderer.cs +++ b/osu.Framework/Graphics/Rendering/Renderer.cs @@ -818,7 +818,10 @@ public bool BindTexture(Texture texture, int unit, WrapMode? wrapModeS, WrapMode public bool BindTexture(INativeTexture texture, int unit = 0, WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = WrapMode.None) { if (lastActiveTextureUnit == unit && lastBoundTexture[unit] == texture) + { + setWrapMode(wrapModeS, wrapModeT); return true; + } FlushCurrentBatch(FlushBatchSource.BindTexture);