Viewport Compositor: Render passes support #108618
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#108618
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Scope
This design task describes integration of multiple render passes of the same view layer to the viewport compositor.
While ultimately multiple view layers would need to be supported as well, it will be handled separately as there more design considerations to be solved to keep performance and memory usage under control/
Overview
The overall overview of the proposal is quite simple:
Breakdown
GPU texture management
The render engine manages GPU textures on the engine side, and allows them to be bound for the viewport compositor shaders. This allows the engine to have full control over data management and synchronization for updates. For example, it allows engine to do proper initialization order for the graphics interoperability.
Overlays
Some of the data which a render engine wants to visualize does not fit into the compositing pipeline, and is better suitable as an overlay. On example of such visualization is the
Active Pixels
(available withCycles Debug
).Such overlays will be moved from "being" baked into the combined pass and instead will become a dedicated call in the render engine
draw_overlay()
.On the render engine side it will behave the same way as the current
draw()
: "just" draw a texture(s) with overlays.Data structures
The proposal is to base the data passed in the API on the
RenderResult
, and not to create a dedicated specialized data structures. This will allow maximum code re-usaiblity between the viewport, viewport compositor, final renders, and eventually GPU compositor for the final renders.There are changes which needs to be done in the
RenderResult
in order to support this, with the final goal is to allowRenderResult
to point to a GPU texture instead of CPU-side memory buffer. The proposal here is to:RenderResult
useImBuf
to store passes data.ImBuf
have GPU texture without CPU side buffer.Considerations for such decision:
RenderResult
is heavily integrated into the image drawing (for theRender Result
image data-block, multi-layer EXR images). If theRenderResult
stores data asImBuf
then it will simplify drawing, which will no longer need to do shallow copies.Image
data-block already uses GPU textures, which can be moved to theImBuf
.Synchronization
Update of the GPU texture and its use by the draw manager happens from different thread, . This is already the case where
DisplayDriver
takes care of synchronization.To start with the synchronization strategy will not change:
RenderResult
it will lock the textures, and will hold the lock until the drawing and compositing pipeline is finished.This potentially introduces wait-on-a-lock for the render thread: if the compositing takes longer than sampling.
When CPU rendering is used it is relatively easy and beneficial to allow "interleaving": render more samples while the draw manager is still busy with compositing. In the case of Cycles it will mean that the
PathTrace
will need to take time spent in drawing into account and schedule more samples to fill it in.For the GPU rendering the story is more complicated:
For the latter either engine could do a guess which GPU is used for viewport, or it would need to be a dedicated API call to provide this information explicitly.
Used render passes
Currently for the viewport render the used render passes are in the full control of the render engine. This needs to be changed to something:
The former is probably already covered with the render passes integration used to create sockets in the Render Layers nodes.
The latter one is needed to make it so unused passes do not take memory: for example if some passes are only used to write to file.
The render pass display option (currently available in Cycles, and allows to choose which render pass is displayed in the viewport) will behave more like it does in the Image Editor where it is possible to choose between Composite output and View Layer / Passes, can then can work for any render engine.
The GPU textures are currently cached on Image level for the next reason:
So there is some flexibility in changing the caching location, but it might have some aspects to check.
Interleaving compute and graphics pipelines (and transfer operations) are known bottleneck in both Metal/Vulkan. In OpenGL this isn't clear as it is hidden by the driver. Eevee(-next) and the Viewport compositor are relying heavily on compute shaders. If cycles would use compute shaders/direct buffer access we could use synchronizations (semaphores/fences). It would not remove all issues, but put the a different weight on the issues.
In future we could also think about using Async Compute, but that isn't supported by all GPU backends (IntelArc doesn't support this to my knowledge).
The plan still is to upgrade OpenGL to 4.3 in Blender 4.0 what would make (non-async) compute shaders available on all supported platforms.
Not sure if it matters, the viewport compositor uses half float texture formats for performance reasons. If data conversion takes place we should consider doing this in the render engine that provides the render passes. Only exception would be cryptomatte that require F32.
Additional benefit would be that cpu imbuf data can be freed, but gpu textures could still be kept around.
Would mention that textures views should also be supported. For example EEVEE next stores render passes in small set layered textures (values, vec4 half precision, vec4 full floats). With texture views it would be possible to point to a single layer in one of those textures. Should be transparent as GPUTexture can be a texture or a texture view.