Realtime Compositor: cache render compositor for repeated executions #108909

Manually merged
Brecht Van Lommel merged 4 commits from brecht/blender:persistent-render-compositor into main 2023-06-23 20:15:26 +02:00

This is cached in Render, and gets cleared along with render pass GPU
textures when there is no editor open using it, or a new final render is
started.

The context and texture pool are cached. But the evaluator is re-created
every time as this only runs on compositing node changes, which require
recreating it anyway (unlike the viewport where e.g. camera navigation
does not need a new evaluator).

Note the existing code creates a (small) depsgraph and local compositor
for every update. It may be worth making that persistent as well.

This is cached in Render, and gets cleared along with render pass GPU textures when there is no editor open using it, or a new final render is started. The context and texture pool are cached. But the evaluator is re-created every time as this only runs on compositing node changes, which require recreating it anyway (unlike the viewport where e.g. camera navigation does not need a new evaluator). Note the existing code creates a (small) depsgraph and local compositor for every update. It may be worth making that persistent as well.
Brecht Van Lommel requested review from Omar Emara 2023-06-12 20:17:03 +02:00
Author
Owner

Assigning you as reviewer just so you're aware and we don't duplicate work, but this is not quite ready yet.

Assigning you as reviewer just so you're aware and we don't duplicate work, but this is not quite ready yet.
Brecht Van Lommel force-pushed persistent-render-compositor from acf41c84e7 to 00d6f3b920 2023-06-14 18:25:12 +02:00 Compare
Brecht Van Lommel changed title from WIP: Realtime Compositor: cache render compositor for repeated executions to Realtime Compositor: cache render compositor for repeated executions 2023-06-14 18:25:48 +02:00
Brecht Van Lommel force-pushed persistent-render-compositor from 00d6f3b920 to c011699110 2023-06-14 18:35:54 +02:00 Compare
Omar Emara requested changes 2023-06-21 12:50:34 +02:00
Omar Emara left a comment
Member

There is something wrong with context handling in this patch. I get the following crash when viewing an image in the compositor:

* thread #1, name = 'blender', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x0000000010039e0b blender`::GPU_matrix_ortho_set(left=-0.00100066059, right=1514.99902, bottom=-0.00104, top=25.9989605, near=-100, far=100) at gpu_matrix.cc:402:18
   399
   400  void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
   401  {
-> 402    mat4_ortho_set(Projection, left, right, bottom, top, near, far);
   403    CHECKMAT(Projection);
   404    gpu_matrix_state_active_set_dirty(true);
   405  }
(lldb) bt
* thread #1, name = 'blender', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
  * frame #0: 0x0000000010039e0b blender`::GPU_matrix_ortho_set(left=-0.00100066059, right=1514.99902, bottom=-0.00104, top=25.9989605, near=-100, far=100) at gpu_matrix.cc:402:18
    frame #1: 0x0000000006e296d3 blender`wmOrtho2(x1=-0.00100066059, x2=1514.99902, y1=-0.00104, y2=25.9989605) at wm_subwindow.c:95:3
    frame #2: 0x00000000087e276d blender`::UI_view2d_view_ortho(v2d=0x00007fffed20f598) at view2d.cc:1120:3
    frame #3: 0x0000000007a1b81c blender`::ED_region_header_layout(C=0x00007fffea7fa388, region=0x00007fffed20f588) at area.cc:3336:3
    frame #4: 0x0000000007a124c3 blender`::ED_region_do_layout(C=0x00007fffea7fa388, region=0x00007fffed20f588) at area.cc:503:3
    frame #5: 0x0000000006de300d blender`wm_draw_window_offscreen(C=0x00007fffea7fa388, win=0x00007fffe1f6de08, stereo=false) at wm_draw.c:911:9
    frame #6: 0x0000000006de27d4 blender`wm_draw_window(C=0x00007fffea7fa388, win=0x00007fffe1f6de08) at wm_draw.c:1128:3
    frame #7: 0x0000000006de23fb blender`wm_draw_update(C=0x00007fffea7fa388) at wm_draw.c:1512:7
    frame #8: 0x0000000006ddc449 blender`WM_main(C=0x00007fffea7fa388) at wm.c:638:5
    frame #9: 0x0000000005f474a7 blender`main(argc=1, argv=0x00007fffffffe9d8) at creator.c:576:5
    frame #10: 0x00007ffff7d8e790 libc.so.6`___lldb_unnamed_symbol3140 + 128
    frame #11: 0x00007ffff7d8e84a libc.so.6`__libc_start_main + 138
    frame #12: 0x0000000005f46fa5 blender`_start + 37
There is something wrong with context handling in this patch. I get the following crash when viewing an image in the compositor: ``` * thread #1, name = 'blender', stop reason = signal SIGSEGV: invalid address (fault address: 0x18) frame #0: 0x0000000010039e0b blender`::GPU_matrix_ortho_set(left=-0.00100066059, right=1514.99902, bottom=-0.00104, top=25.9989605, near=-100, far=100) at gpu_matrix.cc:402:18 399 400 void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far) 401 { -> 402 mat4_ortho_set(Projection, left, right, bottom, top, near, far); 403 CHECKMAT(Projection); 404 gpu_matrix_state_active_set_dirty(true); 405 } (lldb) bt * thread #1, name = 'blender', stop reason = signal SIGSEGV: invalid address (fault address: 0x18) * frame #0: 0x0000000010039e0b blender`::GPU_matrix_ortho_set(left=-0.00100066059, right=1514.99902, bottom=-0.00104, top=25.9989605, near=-100, far=100) at gpu_matrix.cc:402:18 frame #1: 0x0000000006e296d3 blender`wmOrtho2(x1=-0.00100066059, x2=1514.99902, y1=-0.00104, y2=25.9989605) at wm_subwindow.c:95:3 frame #2: 0x00000000087e276d blender`::UI_view2d_view_ortho(v2d=0x00007fffed20f598) at view2d.cc:1120:3 frame #3: 0x0000000007a1b81c blender`::ED_region_header_layout(C=0x00007fffea7fa388, region=0x00007fffed20f588) at area.cc:3336:3 frame #4: 0x0000000007a124c3 blender`::ED_region_do_layout(C=0x00007fffea7fa388, region=0x00007fffed20f588) at area.cc:503:3 frame #5: 0x0000000006de300d blender`wm_draw_window_offscreen(C=0x00007fffea7fa388, win=0x00007fffe1f6de08, stereo=false) at wm_draw.c:911:9 frame #6: 0x0000000006de27d4 blender`wm_draw_window(C=0x00007fffea7fa388, win=0x00007fffe1f6de08) at wm_draw.c:1128:3 frame #7: 0x0000000006de23fb blender`wm_draw_update(C=0x00007fffea7fa388) at wm_draw.c:1512:7 frame #8: 0x0000000006ddc449 blender`WM_main(C=0x00007fffea7fa388) at wm.c:638:5 frame #9: 0x0000000005f474a7 blender`main(argc=1, argv=0x00007fffffffe9d8) at creator.c:576:5 frame #10: 0x00007ffff7d8e790 libc.so.6`___lldb_unnamed_symbol3140 + 128 frame #11: 0x00007ffff7d8e84a libc.so.6`__libc_start_main + 138 frame #12: 0x0000000005f46fa5 blender`_start + 37 ```
Author
Owner

Thanks, it should be resolved now.

Thanks, it should be resolved now.
Omar Emara requested changes 2023-06-22 09:37:33 +02:00
Omar Emara left a comment
Member

RE_FreeGPUTextureCaches is always freeing upon node tree edits because Render->scene is always nullptr because compo_initjob does not initialize the scene. So caching is not really working for interactive editing.

`RE_FreeGPUTextureCaches` is always freeing upon node tree edits because `Render->scene` is always `nullptr` because `compo_initjob` does not initialize the scene. So caching is not really working for interactive editing.
Brecht Van Lommel requested review from Omar Emara 2023-06-23 18:27:23 +02:00
Omar Emara approved these changes 2023-06-23 18:47:45 +02:00
Omar Emara left a comment
Member

I am not the best person to review the context related changes, but the other changes looks good.

I am not the best person to review the context related changes, but the other changes looks good.
Brecht Van Lommel force-pushed persistent-render-compositor from f2f5c18504 to 9bb12edac0 2023-06-23 19:24:24 +02:00 Compare
Author
Owner

@blender-bot build

@blender-bot build
Brecht Van Lommel added 1 commit 2023-06-23 19:44:43 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
19e40c99b7
Fix merge error
Brecht Van Lommel manually merged commit 711fb3e386 into main 2023-06-23 20:15:26 +02: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#108909
No description provided.