Compositor: Port GLSL SMAA to CPU compositor #119414

Merged
Omar Emara merged 21 commits from OmarEmaraDev/blender:smaa-cpp into main 2024-03-25 14:21:12 +01:00
Member

This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between the CPU and GPU compositor.
Additionally, the SMAA texture generator was removed since it is now
unused.

Previously, we used an external C++ library for SMAA anti-aliasing,
which is itself a port of the GLSL SMAA library. However, the code
structure and results of the library were different, which made it quite
difficult to match results between CPU and GPU, hence the decision to
port the library ourselves.

The port was performed through a complete copy of the library to C++,
retaining the same function and variable names, even if they are
different from Blender's naming conversions. The necessary code changes
were done to make it work in C++, including manually doing swizzling
which changes the code structure a bit.

Even after porting the library, there were still major differences
between CPU and GPU, due to different arithmetic precision. To fix this
some of the bilinear samplers used in branches and selections were
carefully changed to use point samplers to avoid discontinuities around
branches, also resulting in a nice performance improvement. Some slight
differences still exist due to different bilinear interpolation, but
they shall be looked into later once we have a baseline implementation.

The new implementation is slower than the existing implementation, most
likely due to the liberal use of bilinear interpolation, since it is
quite cheap on GPUs and the code even does more work to use bilinear
interpolation to avoid multiple texture fetches, except this causes a
slow down on CPUs. Some of those were alleviated as mentioned in the
previous section, but we can probably look into optimizing it further.

This patch ports the GLSL SMAA library to the CPU compositor in order to unify the anti-aliasing behavior between the CPU and GPU compositor. Additionally, the SMAA texture generator was removed since it is now unused. Previously, we used an external C++ library for SMAA anti-aliasing, which is itself a port of the GLSL SMAA library. However, the code structure and results of the library were different, which made it quite difficult to match results between CPU and GPU, hence the decision to port the library ourselves. The port was performed through a complete copy of the library to C++, retaining the same function and variable names, even if they are different from Blender's naming conversions. The necessary code changes were done to make it work in C++, including manually doing swizzling which changes the code structure a bit. Even after porting the library, there were still major differences between CPU and GPU, due to different arithmetic precision. To fix this some of the bilinear samplers used in branches and selections were carefully changed to use point samplers to avoid discontinuities around branches, also resulting in a nice performance improvement. Some slight differences still exist due to different bilinear interpolation, but they shall be looked into later once we have a baseline implementation. The new implementation is slower than the existing implementation, most likely due to the liberal use of bilinear interpolation, since it is quite cheap on GPUs and the code even does more work to use bilinear interpolation to avoid multiple texture fetches, except this causes a slow down on CPUs. Some of those were alleviated as mentioned in the previous section, but we can probably look into optimizing it further.
Omar Emara added the
Interest
Compositing
Module
VFX & Video
labels 2024-03-13 10:54:28 +01:00
Omar Emara added 1 commit 2024-03-13 10:54:39 +01:00
41c7c764d7 Compositor: Port GLSL SMAA to CPU compositor
This patch ports the GLSL SMAA library to the CPU compositor in order to
unify the anti-aliasing behavior between CPU and GPU compositor.
Omar Emara added 1 commit 2024-03-14 08:17:38 +01:00
Omar Emara added 1 commit 2024-03-14 09:28:36 +01:00
Omar Emara added 3 commits 2024-03-18 10:13:35 +01:00
Omar Emara added 2 commits 2024-03-19 09:09:37 +01:00
Omar Emara added 1 commit 2024-03-19 11:56:52 +01:00
Omar Emara added 1 commit 2024-03-19 12:15:37 +01:00
Omar Emara added 1 commit 2024-03-19 13:41:22 +01:00
Omar Emara added 1 commit 2024-03-20 07:44:25 +01:00
Omar Emara added 1 commit 2024-03-20 10:17:36 +01:00
Omar Emara added 1 commit 2024-03-20 16:42:23 +01:00
Omar Emara added 1 commit 2024-03-20 16:50:39 +01:00
Omar Emara added 1 commit 2024-03-21 14:32:59 +01:00
Omar Emara added 1 commit 2024-03-21 14:35:52 +01:00
Omar Emara added 1 commit 2024-03-21 16:44:25 +01:00
Omar Emara added 1 commit 2024-03-22 09:06:45 +01:00
Omar Emara added 1 commit 2024-03-22 09:09:05 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
9da114ad46
Remove unrelated changes
Omar Emara changed title from WIP: Compositor: Port GLSL SMAA to CPU compositor to Compositor: Port GLSL SMAA to CPU compositor 2024-03-22 10:00:06 +01:00
Omar Emara requested review from Sergey Sharybin 2024-03-22 10:22:31 +01:00

@blender-bot build

@blender-bot build

I think #include "BLI_math_vector.hh" is missing in the COM_SMAAOperation.cc. Without this it did not compile for me locally.
Other than that I think it is look good!

I think `#include "BLI_math_vector.hh"` is missing in the `COM_SMAAOperation.cc`. Without this it did not compile for me locally. Other than that I think it is look good!
Omar Emara added 1 commit 2024-03-22 15:46:24 +01:00
Sergey Sharybin approved these changes 2024-03-22 16:21:23 +01:00
Omar Emara merged commit fa3e47523e into main 2024-03-25 14:21:12 +01:00
Omar Emara deleted branch smaa-cpp 2024-03-25 14:21:14 +01:00
Sign in to join this conversation.
No reviewers
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119414
No description provided.