-
Notifications
You must be signed in to change notification settings - Fork 398
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
Allow enabling computed mipmaps in LargeTextureStore
#6048
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb392f6
Allow enabling computed mipmaps in LargeTextureStore
EVAST9919 1fe3df0
Add test scene
EVAST9919 0d9abf1
Make provided store a field
EVAST9919 7f837dd
Rework store caching
EVAST9919 15908a7
Rename test scene
peppy 634823f
Rework test scene to include both variants
EVAST9919 25a4ac9
Merge branch 'master' into large-texture-mipmaps
peppy 84fb4b5
Rename on screen text to match setting
peppy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
osu.Framework.Tests/Visual/Sprites/TestSceneLargeTextureStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Rendering; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Graphics.Textures; | ||
using osu.Framework.IO.Stores; | ||
using osu.Framework.Platform; | ||
using osuTK; | ||
|
||
namespace osu.Framework.Tests.Visual.Sprites | ||
{ | ||
public partial class TestSceneLargeTextureStore : FrameworkTestScene | ||
{ | ||
private DependencyContainer dependencies = null!; | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(IRenderer renderer, GameHost host, Game game) | ||
{ | ||
dependencies.CacheAs(new LargeTextureStore(renderer, host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(game.Resources, "Textures")), manualMipmaps: false)); | ||
|
||
Child = new GridContainer | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
ColumnDimensions = new[] | ||
{ | ||
new Dimension(GridSizeMode.Relative, 0.5f), | ||
new Dimension(GridSizeMode.Relative, 0.5f), | ||
}, | ||
RowDimensions = new[] | ||
{ | ||
new Dimension(GridSizeMode.Relative, 0.5f), | ||
new Dimension(GridSizeMode.Relative, 0.5f), | ||
}, | ||
Content = new[] | ||
{ | ||
new Drawable[] | ||
{ | ||
new MipmapSprite(0), | ||
new MipmapSprite(1) | ||
}, | ||
new Drawable[] | ||
{ | ||
new MipmapSprite(2), | ||
new MipmapSprite(3) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) | ||
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); | ||
|
||
private partial class MipmapSprite : Sprite | ||
{ | ||
private readonly int level; | ||
|
||
public MipmapSprite(int level) | ||
{ | ||
this.level = level; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(LargeTextureStore textures) | ||
{ | ||
Anchor = Anchor.Centre; | ||
Origin = Anchor.Centre; | ||
Texture = textures.Get("sample-texture.png"); | ||
Scale = new Vector2(0.5f); | ||
} | ||
|
||
protected override DrawNode CreateDrawNode() => new SingleMipmapSpriteDrawNode(this, level); | ||
|
||
private class SingleMipmapSpriteDrawNode : SpriteDrawNode | ||
{ | ||
private readonly int level; | ||
|
||
public SingleMipmapSpriteDrawNode(Sprite source, int level) | ||
: base(source) | ||
{ | ||
this.level = level; | ||
} | ||
|
||
protected override void Blit(IRenderer renderer) | ||
{ | ||
Texture.MipLevel = level; | ||
base.Blit(renderer); | ||
renderer.FlushCurrentBatch(null); | ||
Texture.MipLevel = null; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting
manualMipamaps: true
doesn't change anything in the test.I'd hope the test shows the difference between the two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's weird, for me the difference is very clear (I'm on D3D)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May have been hot reload failing. But I'd also hope the test can be run in both modes. I don't want to have to change code each time I want to check a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Was just trying to ensure it works for you and not a renderer issue or something.