Skip to content

Commit

Permalink
Merge pull request #6410 from Jumprocks1/fix-atlas-texture-wrap
Browse files Browse the repository at this point in the history
Fix texture wrapping not updating when atlas is already bound
  • Loading branch information
smoogipoo authored Nov 5, 2024
2 parents 6a1a7a6 + 7459894 commit ac962a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions osu.Framework.Tests/Graphics/RendererTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
3 changes: 3 additions & 0 deletions osu.Framework/Graphics/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ac962a6

Please sign in to comment.