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

Submit vertices in local space to avoid cross-thread access #29204

Merged
merged 1 commit into from
Jul 30, 2024
Merged
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
16 changes: 8 additions & 8 deletions osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ private class TrailDrawNode : DrawNode
private float fadeExponent;

private readonly TrailPart[] parts = new TrailPart[max_sprites];
private Vector2 size;
private Vector2 originPosition;

private IVertexBatch<TexturedTrailVertex> vertexBatch;
Expand All @@ -236,7 +235,6 @@ public override void ApplyState()

shader = Source.shader;
texture = Source.texture;
size = Source.partSize;
time = Source.time;
fadeExponent = Source.FadeExponent;

Expand Down Expand Up @@ -277,6 +275,8 @@ protected override void Draw(IRenderer renderer)

RectangleF textureRect = texture.GetTextureRect();

renderer.PushLocalMatrix(DrawInfo.Matrix);

foreach (var part in parts)
{
if (part.InvalidationID == -1)
Expand All @@ -285,11 +285,9 @@ protected override void Draw(IRenderer renderer)
if (time - part.Time >= 1)
continue;

Vector2 screenSpacePos = Source.ToScreenSpace(part.Position);

vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(screenSpacePos.X - size.X * originPosition.X, screenSpacePos.Y + size.Y * (1 - originPosition.Y)),
Position = new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X, part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y)),
TexturePosition = textureRect.BottomLeft,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.BottomLeft.Linear,
Expand All @@ -298,7 +296,7 @@ protected override void Draw(IRenderer renderer)

vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(screenSpacePos.X + size.X * (1 - originPosition.X), screenSpacePos.Y + size.Y * (1 - originPosition.Y)),
Position = new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X), part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y)),
TexturePosition = textureRect.BottomRight,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.BottomRight.Linear,
Expand All @@ -307,7 +305,7 @@ protected override void Draw(IRenderer renderer)

vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(screenSpacePos.X + size.X * (1 - originPosition.X), screenSpacePos.Y - size.Y * originPosition.Y),
Position = new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X), part.Position.Y - texture.DisplayHeight * originPosition.Y),
TexturePosition = textureRect.TopRight,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.TopRight.Linear,
Expand All @@ -316,14 +314,16 @@ protected override void Draw(IRenderer renderer)

vertexBatch.Add(new TexturedTrailVertex
{
Position = new Vector2(screenSpacePos.X - size.X * originPosition.X, screenSpacePos.Y - size.Y * originPosition.Y),
Position = new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X, part.Position.Y - texture.DisplayHeight * originPosition.Y),
TexturePosition = textureRect.TopLeft,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.TopLeft.Linear,
Time = part.Time
});
}

renderer.PopLocalMatrix();

vertexBatch.Draw();
shader.Unbind();
}
Expand Down
Loading