WIP: VSE: speedup Alpha Over blend with SIMD #115892
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115892
Loading…
Reference in New Issue
No description provided.
Delete Branch "aras_p/blender:vse-alphaover-opt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Alpha Over is default blend mode used by all strips (images, text etc.), so while SIMD arguably could be used in all of them, this one is probably most important.
Makes
straight_uchar_to_premul_float
+ actual blending math +premul_float_to_straight_uchar
use SIMD in a 4-wide fashion, i.e. still works on one pixel at a time.At 4K UHD resolution, Windows Ryzen 5950X:
do_alphaover_effect_byte
time 6.82ms -> 4.93msSame setup on a Mac M1 Max: sequencer playback 15.2FPS -> 18.1FPS
Code design question
The added functions
straight_uchar_to_premul_float_simd
andpremul_float_to_straight_uchar_simd
would be generally useful in other places (90% within Sequencer code only though). But it's a good question where to put them:BLI_math_color.h
has large downside if needing to includeBLI_simd.h
which drags in<emmintrin.h>
or<sse2neon.h>
depending on the platform, both of which are very large headers.BLI_math_color_simd.h
or similar.VSE: speedup Alpha Over blend with SIMDto WIP: VSE: speedup Alpha Over blend with SIMD@blender-bot build
WIP: VSE: speedup Alpha Over blend with SIMDto VSE: speedup Alpha Over blend with SIMDThat does not sound like much. I was thinking, whether there is chance, that compiler does optimize these to simd already. AFAIK it should especially if code in question is pure for loop, but I think we only call for SSE optimization. Will do some testing locally.
BLI_math_color.h
sounds like good place to me.More in general I wanted to suggest making pure simd functions and don't just inline the code if that is practical and possible. This is already done by
#if BLI_HAVE_SSE2
inBLI_math_color.h
.VSE: speedup Alpha Over blend with SIMDto WIP: VSE: speedup Alpha Over blend with SIMDHold on, while I think the idea makes sense, I'll also try to do the same using OIIO
simd.h
and see whether that achieves same performance with way more readable code.Hmm so OIIO simd.h is mixed bag. It's fairly extensive, large (perhaps too large for Blender's needs), but at the same time NEON coverage is not their primary interest, plus they are lacking some efficient ways of e.g. converting "packed bytes to a float4" and back, which is what you need in images all the time (they do have those, but e.g. for AVX2 or AVX512 minspec, both of which Blender does not have). I have submitted some PRs upstream there to add some lacking bits, but then we get into a "ok so which exactly OIIO version are we compiling against" mess (some distros build Blender using external OIIO that is just "some other version").
I'm thinking that for Blender's needs, a much smaller simd library would be much better. No versioning conundrums, and it would do exactly what is needed.
But also at the same time, SIMD in VSE effects code does not give huge benefits in most of them, since they are more or less memory bandwidth limited, i.e. amount of math that is being done is pretty small compared to amount of memory traffic. So maybe I'll park this for now.
Checkout
From your project repository, check out a new branch and test the changes.