Skip to content

Speed up Util.FastCopyIntoChannel#21361

Merged
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:faster-channel-copy
Mar 9, 2024
Merged

Speed up Util.FastCopyIntoChannel#21361
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:faster-channel-copy

Conversation

@RoosterDragon
Copy link
Copy Markdown
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
Copy Markdown
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 force-pushed the faster-channel-copy branch from d9abc2f to 69b5d58 Compare March 9, 2024 19:25
@PunkPun PunkPun merged commit 6e89bef into OpenRA:bleed Mar 9, 2024
@PunkPun
Copy link
Copy Markdown
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.

2 participants