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 potential texture corruption on Veldrid #5928

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

frenzibyte
Copy link
Member

@frenzibyte frenzibyte commented Jul 13, 2023

Resolves noticeable texture corruption on osu!:

CleanShot 2023-07-13 at 10 30 21

It's possible to have a draw frame which processes enqueued texture uploads but doesn't have any draw nodes to render to the screen (i.e. no calls to DrawVertices), therefore the texture upload commands continue to the next frame without being submitted and the staging resources incorrectly return back to the pool. This PR resolves the bug by ensuring texture upload commands are submitted before the end of the frame.

Reproducing this bug requires a fresh game state that has absolutely no draw node. Can be repro'd with this simple code in SampleGameGame:

    public partial class SampleGameGame : Game
    {
        protected override void LoadComplete()
        {
            base.LoadComplete();

            Container<Drawable> test;

            Add(test = new Container
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                RelativeSizeAxes = Axes.Both,
                Scale = new Vector2(4f),
                Alpha = 0f,
                Children = new Drawable[]
                {
                    new SpriteText
                    {
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Text = "AudioMixer",
                        Font = FrameworkFont.Condensed.With(weight: "Bold"),
                        Colour = FrameworkColour.Yellow,
                    },
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour = FrameworkColour.BlueDark,
                    },
                    new SpriteText
                    {
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Text = "AudioMixer",
                        Font = FrameworkFont.Condensed.With(weight: "Bold"),
                        Colour = FrameworkColour.Yellow,
                    },
                }
            });

            test.Delay(100).FadeIn(100);
        }
    }

Before:

CleanShot 2023-07-13 at 10 36 48

After:

CleanShot 2023-07-13 at 10 37 26

@frenzibyte frenzibyte added next-release Pull requests which are almost there area:renderer-veldrid labels Jul 13, 2023
@peppy peppy enabled auto-merge July 13, 2023 07:39
@peppy peppy merged commit 6e1c69f into ppy:master Jul 13, 2023
@frenzibyte frenzibyte deleted the fix-texture-upload-corruption branch July 13, 2023 08:28
frenzibyte added a commit to frenzibyte/osu-framework that referenced this pull request Jul 14, 2023
…d-corruption"

This reverts commit 6e1c69f, reversing
changes made to 298fecf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:renderer-veldrid next-release Pull requests which are almost there size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants