Skip to content

Commit

Permalink
Merge pull request #6366 from EVAST9919/blending-test
Browse files Browse the repository at this point in the history
Fix renderers can't batch vertices with the same blending parameters in some cases
  • Loading branch information
smoogipoo authored Aug 28, 2024
2 parents 4e3ef47 + 1b28393 commit a4a2b68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ private void updateQuadBatch(IRenderer renderer)
quadBatch = renderer.CreateQuadBatch<TexturedVertex2D>(100, 1000);
}

// Children will set their own blending parameters.
internal override bool SetBlending => false;

protected override void Draw(IRenderer renderer)
{
updateQuadBatch(renderer);
Expand Down
9 changes: 8 additions & 1 deletion osu.Framework/Graphics/DrawNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public virtual void ApplyState()
InvalidationID = Source.InvalidationID;
}

/// <summary>
/// Whether the renderer should set blending parameters of this <see cref="DrawNode"/>.
/// </summary>
internal virtual bool SetBlending => true;

/// <summary>
/// Draws this <see cref="DrawNode"/> to the screen.
/// </summary>
Expand All @@ -76,7 +81,9 @@ public virtual void ApplyState()
/// <param name="renderer">The renderer to draw with.</param>
protected virtual void Draw(IRenderer renderer)
{
renderer.SetBlend(DrawColourInfo.Blending);
if (SetBlending)
renderer.SetBlend(DrawColourInfo.Blending);

renderer.BackbufferDepth.Set(drawDepth);
}

Expand Down

0 comments on commit a4a2b68

Please sign in to comment.