This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Add batched drawing methods#142
Closed
metalgearsloth wants to merge 6 commits into
Closed
Conversation
Internally Clyde batches drawing, however when drawing hundreds / thousands of the same quad the batch checks add up. This just omits those checks and directly draws instead. Same with skipping color modulation. Long-term could probably figure out a way to SIMD the transforms better.
metalgearsloth
commented
Jun 23, 2026
Comment on lines
+687
to
+703
| for (var i = 0; i < count; i++) | ||
| { | ||
| ref readonly var rect = ref rects[rectIndex + i]; | ||
| var color = rect.Modulate ?? Color.White; | ||
|
|
||
| if (applyModulation) | ||
| color *= modulate; | ||
|
|
||
| // Can probably SIMD this more somehow but future concern. | ||
| var quad = rect.Quad; | ||
| var transform = quad.Transform * _currentMatrixModel; | ||
|
|
||
| var bl = Vector2.Transform(quad.Box.BottomLeft, transform); | ||
| var br = Vector2.Transform(quad.Box.BottomRight, transform); | ||
| var tr = Vector2.Transform(quad.Box.TopRight, transform); | ||
| var tl = tr + bl - br; | ||
|
|
Contributor
Author
There was a problem hiding this comment.
I think color and the transform multiplication are the 2 biggest pertformance sinks now.
| if (applyModulation) | ||
| color *= modulate; | ||
|
|
||
| // Can probably SIMD this more somehow but future concern. |
Member
There was a problem hiding this comment.
Mark TODO so we know this issue exists
Contributor
Author
There was a problem hiding this comment.
Box2Rotated PR also changes this a bit and does actually use the SIMD path but it will remind me.
# Conflicts: # RELEASE-NOTES.md
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Title.