Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix texture wrapping not updating when atlas is already bound #6410

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading