Introduce optimized conversion methods for RGBA-like types#751
Merged
JimBobSquarePants merged 19 commits intomasterfrom Oct 27, 2018
Merged
Introduce optimized conversion methods for RGBA-like types#751JimBobSquarePants merged 19 commits intomasterfrom
JimBobSquarePants merged 19 commits intomasterfrom
Conversation
(cherry picked from commit 0d79d4eb58fa1002979f4157eb18c6291a164b06)
JimBobSquarePants
approved these changes
Oct 26, 2018
Member
JimBobSquarePants
left a comment
There was a problem hiding this comment.
This is an extraordinary piece of work!
The masking code is excellent and really nicely annotated also. I would never have in a million years thought of it.
Member
Author
|
I also needed to browse corefx code for hours. Everything is based on Levi Boderick's ideas in dotnet/corefx#26303. |
antonfirsov
pushed a commit
to antonfirsov/ImageSharp
that referenced
this pull request
Nov 11, 2019
…sion Introduce optimized conversion methods for RGBA-like types
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prerequisites
Description
@JimBobSquarePants unleashed the beast in #729 by introducing T4 generators for several pixel types. This PR introduces optimized bulk conversion methods for most of them, making them first class citizens, reducing the privileged role of
Rgba32.SixLabors.ImageSharp.PixelFormats.Utils.PixelConverter: Optimized conversion primitives forRgba32<->Bgra32<->Argb32_Common.ttincludenow generates code usingPixelConverterforRgba32,Bgra32,Argb32Configurationparameter to all conversion methods so they can allocate. (And maybe do other configuration-dependent stuff in the future)ToVector4()andFromVector4()for all "RGBA-compatible" types (Argb32,Bgra32,Rgb24,Bgr24): converting to/fromRgba32and utilizeSimdUtilsVector4conversion code moved toVector4Converters,PixelOperationsTestshave been split into separate files, etc.Performance gain
Rgba32<->Bgra32conversion time reduced by 30%Bgra32->Vector4conversion time reduced by 55% on CoreCLR 2.1, and by 15% on .NET Framework on my PC. (Anyone any idea why? I have 4.7.2 installed!)Argb32path should be even faster.