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

Speed up Util.FastCopyIntoChannel #21361

Merged
merged 1 commit into from Mar 9, 2024

Conversation

RoosterDragon
Copy link
Member

Depends on #21358

The assets for the Tiberian Dawn HD mod are much larger than assets for the default mods, causing a lot of load time to be spent in Util.FastCopyIntoChannel.

We can provide a special case for the SpriteFrameType.Bgra32 format, which is the same format as the destination buffer. In this scenario we can just perform memory copies between the source and destination. Additionally, whilst the default mods require all their assets to get their alpha premultiplied, many of the Tiberian Dawn assets are already premultiplied. Being able to skip this step for these assets saves us having to interpret the bytes into colors and back again.

For the default mods, there isn't a noticeable timing difference. For Tiberian Dawn HD or other mods with modern assets sizes, a large speedup is achieved.

Timings for TD HD on my machine, split by assets for which premultiplied was true or false. When true, a bigger speedup is seen as the method doesn't have to do the premultiplication step.

Already premultipled? Before After
true 740ms 220ms
false 340ms 210ms
total 1080ms 430ms

PunkPun
PunkPun previously approved these changes Mar 9, 2024
Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM

The assets for the Tiberian Dawn HD mod are much larger than assets for the default mods, causing a lot of load time to be spent in Util.FastCopyIntoChannel.

We can provide a special case for the SpriteFrameType.Bgra32 format, which is the same format as the destination buffer. In this scenario we can just perform memory copies between the source and destination. Additionally, whilst the default mods require all their assets to get their alpha premultiplied, many of the Tiberian Dawn assets are already premultiplied. Being able to skip this step for these assets saves us having to interpret the bytes into colors and back again.

For the default mods, there isn't a noticeable timing difference. For Tiberian Dawn HD or other mods with modern assets sizes, a large speedup is achieved.
@PunkPun PunkPun dismissed their stale review March 9, 2024 19:25

The merge-base changed after approval.

@PunkPun PunkPun merged commit 6e89bef into OpenRA:bleed Mar 9, 2024
3 checks passed
@PunkPun
Copy link
Member

PunkPun commented Mar 9, 2024

changelog

@RoosterDragon RoosterDragon deleted the faster-channel-copy branch March 10, 2024 14:05
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.

None yet

2 participants