IMB: Speedups, fixes and cleanups to various image scaling functions #126390
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#126390
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "aras_p/blender:imb_scaling_cleanup"
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?
Prompted by comments at #126234
Problem
There are multiple ways to scale images in Blender codebase:
1.
IMB_transform
is very general (can also do rotations, not only scales), and since 4.1 (#116628) it probably works "correctly". Supports Nearest, Bilinear, Box, Cubic Mitchell and Cubic BSpline filters. Internally multi-threaded, and uses some SIMD. However, destination image must have 4 channels.2.
IMB_scalefastImBuf
does Nearest filtering.instead of this:
3.
IMB_scaleImBuf
does Box (scaling down) or Bilinear (scaling up) filtering.instead of this:
4.
IMB_scaleImBuf_threaded
does Bilinear filtering.when scaled down by 2x2, produces this:
instead of this:
None of these behavior differences of
IMB_scale*
functions are documented, of course :)This PR
IMB_scalefastImBuf
,IMB_scaleImBuf
,IMB_scaleImBuf_threaded
into one functionIMB_scale
with enumIMBScaleFilter { Nearest, Bilinear, Box }
and boolthreaded
.IMB_scaleImBuf
) can be multi-threaded nowIMB_scalefastImBuf
) can be multi-threaded now. Also fixes performance regressionon float images caused by fix in #126234
IMB_scaleImBuf_threaded
) is several times faster nowIMB_scale
modesIMB_performance_test
performance test, ran manually (similar to existingBLI_map_performance_test
)All of this is with shorter code too!
scaling.cc
is 890 lines shorter than before. But, I have added 440 lines of new test coverage code.Performance
Performance test checks this sequence of steps (the dimensions used are quite arbitrary, but picked to not be "neat" on purpose):
Performance results on Mac M1 Max (Xcode 15, RelWithDebInfo config), times in ms (smaller is better):
Current usages of IMB scale within Blender codebase
Would be nice to review whether all current usages of IMB scaling are using the correct filtering modes and/or threading flags. Here's a list:
Would be nice to do someday:
IMB_scale
function that does not modify source, but scales into provided destination image. Today quite some usages of the existing function explicitly duplicate some source and callIMB_scale
on that. Would save both hassle and memory allocation/copy.IMB_performance_test
has to link a lot (e.g. it links in USD?!) because ImBuf library itself depends on many many many things. Perhaps a separate library for just image I/O stuff would make sense.WIP: IMB: cleanups and fixes to scalingto WIP: IMB: cleanups and fixes to image scalingf654cd5575
to0459c834cf
84bc0c9188
toab255a3c1e
@blender-bot build
WIP: IMB: cleanups and fixes to image scalingto IMB: Speedups, fixes and cleanups to various image scaling functions