Skip to content
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
Space-Wizards-Federation:masterfrom
metalgearsloth:2026-06-07-batch-33
Closed

Add batched drawing methods#142
metalgearsloth wants to merge 6 commits into
Space-Wizards-Federation:masterfrom
metalgearsloth:2026-06-07-batch-33

Conversation

@metalgearsloth

Copy link
Copy Markdown
Contributor

Title.

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.
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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark TODO so we know this issue exists

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Box2Rotated PR also changes this a bit and does actually use the SIMD path but it will remind me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants