feat: Add SIMD pixel swizzling with tests and fuzzers#9
Merged
JacobBorden merged 5 commits intodevelopmentfrom May 30, 2025
Merged
feat: Add SIMD pixel swizzling with tests and fuzzers#9JacobBorden merged 5 commits intodevelopmentfrom
JacobBorden merged 5 commits intodevelopmentfrom
Conversation
This commit introduces SIMD (AVX2, SSSE3, NEON) optimizations for pixel format conversion and swizzling operations, along with corresponding unit tests and fuzz targets. Optimizations Implemented: - BGR (24-bit) to BGRA (32-bit, Alpha=255) conversion in `CreateMatrixFromBitmap`. - BGRA to RGBA swizzle (e.g., for `BmpTool::load`). - RGBA to BGRA swizzle (e.g., for `BmpTool::save`). - Corrected Alpha handling for 24-bit BGR sources to set Alpha to 255 (opaque). Refactoring: - The core SIMD and scalar logic for these operations has been refactored into helper functions: - `internal_convert_bgr_to_bgra_simd` - `internal_swizzle_bgra_to_rgba_simd` - `internal_swizzle_rgba_to_bgra_simd` - These helpers are declared in `src/bitmap/bitmap.h` and `src/format/format_internal_helpers.hpp` for testability. Testing: - Added new Google Tests in `tests/test_swizzle.cpp` for all three helper functions, covering various input sizes, edge cases (0 pixels), and content verification. - Added new fuzz targets in `tests/fuzz/` for each helper function to detect crashes and sanitizer issues with random inputs: - `fuzz_convert_bgr_to_bgra.cpp` - `fuzz_swizzle_bgra_to_rgba.cpp` - `fuzz_swizzle_rgba_to_bgra.cpp` - Updated `tests/CMakeLists.txt` to integrate the new unit tests and fuzz targets into the build system.
The declaration for `internal_convert_bgr_to_bgra_simd` was missing from `src/bitmap/bitmap.h`, causing build failures when compiling the unit tests in `tests/test_swizzle.cpp`. This commit adds the required declaration. This also includes the previous work: feat: Add SIMD pixel swizzling with tests and fuzzers This commit introduces SIMD (AVX2, SSSE3, NEON) optimizations for pixel format conversion and swizzling operations, along with corresponding unit tests and fuzz targets. Optimizations Implemented: - BGR (24-bit) to BGRA (32-bit, Alpha=255) conversion in `CreateMatrixFromBitmap`. - BGRA to RGBA swizzle (e.g., for `BmpTool::load`). - RGBA to BGRA swizzle (e.g., for `BmpTool::save`). - Corrected Alpha handling for 24-bit BGR sources to set Alpha to 255 (opaque). Refactoring: - The core SIMD and scalar logic for these operations has been refactored into helper functions: - `internal_convert_bgr_to_bgra_simd` - `internal_swizzle_bgra_to_rgba_simd` - `internal_swizzle_rgba_to_bgra_simd` - These helpers are declared in `src/bitmap/bitmap.h` and `src/format/format_internal_helpers.hpp` for testability. Testing: - Added new Google Tests in `tests/test_swizzle.cpp` for all three helper functions, covering various input sizes, edge cases (0 pixels), and content verification. - Added new fuzz targets in `tests/fuzz/` for each helper function to detect crashes and sanitizer issues with random inputs: - `fuzz_convert_bgr_to_bgra.cpp` - `fuzz_swizzle_bgra_to_rgba.cpp` - `fuzz_swizzle_rgba_to_bgra.cpp` - Updated `tests/CMakeLists.txt` to integrate the new unit tests and fuzz targets into the build system.
Corrects "undefined reference" linker errors for SIMD helper functions: - Added missing declaration for `internal_convert_bgr_to_bgra_simd` to `src/bitmap/bitmap.h`. - Placed declarations for `internal_swizzle_bgra_to_rgba_simd` and `internal_swizzle_rgba_to_bgra_simd` into the `BmpTool` namespace in `src/format/format_internal_helpers.hpp` to match their definitions. - Updated calls in `tests/test_swizzle.cpp` to use `BmpTool::` namespace qualifier for these functions. This also includes the previous work: feat: Add SIMD pixel swizzling with tests and fuzzers This commit introduces SIMD (AVX2, SSSE3, NEON) optimizations for pixel format conversion and swizzling operations, along with corresponding unit tests and fuzz targets. Optimizations Implemented: - BGR (24-bit) to BGRA (32-bit, Alpha=255) conversion in `CreateMatrixFromBitmap`. - BGRA to RGBA swizzle (e.g., for `BmpTool::load`). - RGBA to BGRA swizzle (e.g., for `BmpTool::save`). - Corrected Alpha handling for 24-bit BGR sources to set Alpha to 255 (opaque). Refactoring: - The core SIMD and scalar logic for these operations has been refactored into helper functions: - `internal_convert_bgr_to_bgra_simd` - `internal_swizzle_bgra_to_rgba_simd` - `internal_swizzle_rgba_to_bgra_simd` Testing: - Added new Google Tests in `tests/test_swizzle.cpp` for all three helper functions. - Added new fuzz targets in `tests/fuzz/` for each helper function. - Updated `tests/CMakeLists.txt` to integrate new tests and fuzzers.
Corrects build errors in fuzz targets by adding the `BmpTool::` namespace qualifier to calls of: - `internal_swizzle_bgra_to_rgba_simd` in `fuzz_swizzle_bgra_to_rgba.cpp` - `internal_swizzle_rgba_to_bgra_simd` in `fuzz_swizzle_rgba_to_bgra.cpp` This aligns the calls with the function declarations which are namespaced in `format_internal_helpers.hpp`. This also includes the previous work: fix: Resolve linker errors for swizzle helpers feat: Add SIMD pixel swizzling with tests and fuzzers
Updates `.github/workflows/fuzzing.yml` to create corpus directories for and execute the three new fuzz targets: - fuzz_convert_bgr_to_bgra - fuzz_swizzle_bgra_to_rgba - fuzz_swizzle_rgba_to_bgra This ensures these fuzzers are run as part of the CI pipeline. This also includes the previous work: fix: Qualify swizzle helper calls in fuzz targets fix: Resolve linker errors for swizzle helpers feat: Add SIMD pixel swizzling with tests and fuzzers
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.
This commit introduces SIMD (AVX2, SSSE3, NEON) optimizations for pixel format conversion and swizzling operations, along with corresponding unit tests and fuzz targets.
Optimizations Implemented:
CreateMatrixFromBitmap.BmpTool::load).BmpTool::save).Refactoring:
internal_convert_bgr_to_bgra_simdinternal_swizzle_bgra_to_rgba_simdinternal_swizzle_rgba_to_bgra_simdsrc/bitmap/bitmap.handsrc/format/format_internal_helpers.hppfor testability.Testing:
tests/test_swizzle.cppfor all three helper functions, covering various input sizes, edge cases (0 pixels), and content verification.tests/fuzz/for each helper function to detect crashes and sanitizer issues with random inputs:fuzz_convert_bgr_to_bgra.cppfuzz_swizzle_bgra_to_rgba.cppfuzz_swizzle_rgba_to_bgra.cpptests/CMakeLists.txtto integrate the new unit tests and fuzz targets into the build system.