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

Halve the renderer's allocation rate #1621

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

wixoaGit
Copy link
Member

@wixoaGit wixoaGit commented Jan 15, 2024

Some renderer optimizations with a focus on memory allocation rate.

  1. Split DrawIconAction() (now DrawIcon()) into several methods (ProcessKeepTogether(), DrawIconFast(), and DrawIconSlow()) so it no longer holds any lambdas. The C# compiler was allocating the lambdas' closures even though the closures weren't used in a majority of cases. Now they're only allocated when necessary.
  2. DrawIcon() now draws the icon directly instead of returning two actions for drawing the icon and its mouse map. This allows for less lambda usage.
  3. Deprecated RT component methods were replaced with their system equivalent.

Before:
image

After:
image

Large majority of allocations now are in shader setup, GetBlendAndColorShader()

@wixoaGit wixoaGit marked this pull request as draft January 15, 2024 06:21
Apparently you can't set the shader outside `RenderInRenderTarget()`. A little saddening, but not a huge hit to allocation rate.
@wixoaGit wixoaGit marked this pull request as ready for review January 17, 2024 05:43
@wixoaGit wixoaGit changed the title Optimize the renderer Halve the renderer's allocation rate Jan 17, 2024
@wixoaGit wixoaGit enabled auto-merge (squash) January 17, 2024 05:49
@wixoaGit wixoaGit merged commit 545e3af into OpenDreamProject:master Jan 17, 2024
6 checks passed
@wixoaGit wixoaGit deleted the renderer_optimizations branch February 6, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant