Modernize PorterDuffFunctions with operators and add tests#3109
Merged
JimBobSquarePants merged 3 commits intomainfrom Apr 8, 2026
Merged
Modernize PorterDuffFunctions with operators and add tests#3109JimBobSquarePants merged 3 commits intomainfrom
JimBobSquarePants merged 3 commits intomainfrom
Conversation
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
This pull request introduces AVX-512 (Vector512) support for image blending operations in ImageSharp, enabling faster processing for large spans of pixel data on hardware that supports AVX-512 instructions. It also refactors and extends several vectorized helper methods to support the new vector width, and moves some utility methods to more appropriate files. The main focus is on improving performance and maintainability by leveraging the latest SIMD capabilities.
AVX-512 SIMD support for pixel blending:
Added AVX-512 (Vector512) code paths to the generated pixel blender implementations in
DefaultPixelBlenders.Generated.tt, enabling batch processing of 16 floats at a time for various blend functions. This includes handling for both constant and variable opacity, as well as proper remainder handling for non-multiple-of-four lengths. [1] [2] [3] [4]Implemented AVX-512 (Vector512) versions of the main Porter-Duff blend functions (
Src,SrcAtop,SrcOver,SrcIn) inPorterDuffFunctions.Generated.tt, using AVX-512-specific blend and mask intrinsics. [1] [2] [3] [4]Vectorized math utilities and refactoring:
Added new
UnPremultiplyandMultiplyAddNegatedmethods forVector512<float>inNumerics.csandVector512Utilities.csto support AVX-512 math operations. [1] [2]Moved and refactored
MultiplyAddNegatedforVector256<float>fromSimdUtils.HwIntrinsics.cstoVector256Utilities.csfor better organization and maintainability. [1] [2]Benchmarks
NormalSrcOver shows significant improvement.