Fix #115043: Compositor crashes for huge render sizes #115299

Merged
Omar Emara merged 6 commits from OmarEmaraDev/blender:fix-115043 into main 2023-12-01 16:16:30 +01:00
Member

The experimental GPU compositor crashes when the render size is huge.
This is just due to GPU texture allocation failing. The patch fixes that
by downscaling the render result when reading, then upscaling it again
when writing. Additionally, the render size was adapted to the
downscaled size since it is used by other input nodes. This is not an
ideal solution, but it a good temporary solution to prevent crashes
until we have proper support for huge textures.

The experimental GPU compositor crashes when the render size is huge. This is just due to GPU texture allocation failing. The patch fixes that by downscaling the render result when reading, then upscaling it again when writing. Additionally, the render size was adapted to the downscaled size since it is used by other input nodes. This is not an ideal solution, but it a good temporary solution to prevent crashes until we have proper support for huge textures.
Omar Emara added the
Interest
Compositing
Module
VFX & Video
labels 2023-11-23 13:11:43 +01:00
Omar Emara added 1 commit 2023-11-23 13:11:54 +01:00
558702dbac Fix #115043: Compositor crashes for huge render sizes
The experimental GPU compositor crashes when the render size is huge.
This is just due to GPU texture allocation failing. The patch fixes that
by downscaling the render result when reading, then upscaling it again
when writing. Additionally, the render size was adapted to the
downscaled size since it is used by other input nodes. This is not an
ideal solution, but it a good temporary solution to prevent crashes
until we have proper support for huge textures.
Omar Emara requested review from Sergey Sharybin 2023-11-23 13:12:04 +01:00

Does this scaling preserved correctness of nodes which use pixel values, like Blur? Or will scaling down make the blur look "smaller" ?

Does this scaling preserved correctness of nodes which use pixel values, like Blur? Or will scaling down make the blur look "smaller" ?
Author
Member

It will not preserve nodes that use pixel values, but it will make the blur look bigger than if you didn't scale.

It will not preserve nodes that use pixel values, but it will make the blur look bigger than if you didn't scale.

I think it is better to reject rendering and show "Out of GPU resources" warning (similarly to how Cycles handles our of RAM/VRAM) than to silently create situation when render output is wrong.

I think it is better to reject rendering and show "Out of GPU resources" warning (similarly to how Cycles handles our of RAM/VRAM) than to silently create situation when render output is wrong.
Author
Member

@Sergey Reject rendering altogether or just compositing?
It should also be noted that Images are scaled down in a similar manner to this patch. That's why I opted to handle it like this.

@Sergey Reject rendering altogether or just compositing? It should also be noted that Images are scaled down in a similar manner to this patch. That's why I opted to handle it like this.

From the "using GPU compositor for final renders" perspective it is better to just stop the render pipeline and report the error when texture allocation fails. We shouldn't silently degrade quality or make result look wrong because of re-scaling.

For the viewport it is probably fine to sacrifice some accuracy, but it shouldn't silently either.

Is this texture limitation something people run into very often? If so, we'd need to find and agree on some practical solution, so that we don't ruin someone's day.

From the "using GPU compositor for final renders" perspective it is better to just stop the render pipeline and report the error when texture allocation fails. We shouldn't silently degrade quality or make result look wrong because of re-scaling. For the viewport it is probably fine to sacrifice some accuracy, but it shouldn't silently either. Is this texture limitation something people run into very often? If so, we'd need to find and agree on some practical solution, so that we don't ruin someone's day.
Author
Member

This code path is only for final renders, the viewport will fail before the compositor is engaged as far as I can see.

I don't think people run into this very often or at all. This was only reported by Habib when stressing the full-frame and GPU compositors for this particular case.

This code path is only for final renders, the viewport will fail before the compositor is engaged as far as I can see. I don't think people run into this very often or at all. This was only reported by Habib when stressing the full-frame and GPU compositors for this particular case.

Agree it should fail in this case instead. The solution here for users is to switch to the CPU compositor, once we make that sufficiently compatible with the GPU compositor. That could even be automatic, but would not consider that to be something to add soon.

Agree it should fail in this case instead. The solution here for users is to switch to the CPU compositor, once we make that sufficiently compatible with the GPU compositor. That could even be automatic, but would not consider that to be something to add soon.
Omar Emara added 3 commits 2023-11-28 15:10:53 +01:00
Sergey Sharybin reviewed 2023-11-28 17:31:26 +01:00
Sergey Sharybin left a comment
Owner

There is some easy-to-address interface related feedback.

One thing which confuses me is that I see the error popup in debug builds, but not in release. So Blender doesn't crash for me, but it does not communicate reason why rendering did not happen. Not sure why this depends on the build type. Does it work both for release and debug for you?

There is some easy-to-address interface related feedback. One thing which confuses me is that I see the error popup in debug builds, but not in release. So Blender doesn't crash for me, but it does not communicate reason why rendering did not happen. Not sure why this depends on the build type. Does it work both for release and debug for you?
@ -1206,0 +1222,4 @@
/* There is no way to know if the render size is too large except if we actually allocate a test
* texture, which we want to avoid due its cost. So we employ a heuristic that so far has worked
* with all known GPU drivers. */
if (width * height > (max_texture_size * max_texture_size) / 4) {

Think it is good to cast first multiplier argument to size_t, to avoid integer overflow.

Think it is good to cast first multiplier argument to size_t, to avoid integer overflow.
OmarEmaraDev marked this conversation as resolved
@ -1206,0 +1225,4 @@
if (width * height > (max_texture_size * max_texture_size) / 4) {
BKE_report(render->reports,
RPT_ERROR_OUT_OF_MEMORY,
"Render size too large for GPU! Use CPU compositor instead.");

The UI shouldn't shout on artists, so Render size too large for GPU, use CPU compositor instead
Note that we also don't use full-stop.

The UI shouldn't shout on artists, so `Render size too large for GPU, use CPU compositor instead` Note that we also don't use full-stop.
OmarEmaraDev marked this conversation as resolved
Author
Member

@Sergey It actually didn't show any UI for me initially, but it suddenly started showing for some reason. Both in a debug build, so probably doesn't depend on the build type.
I will try to debug this further.

@Sergey It actually didn't show any UI for me initially, but it suddenly started showing for some reason. Both in a debug build, so probably doesn't depend on the build type. I will try to debug this further.
Omar Emara added 1 commit 2023-11-29 10:45:10 +01:00
Author
Member

There is some kind of threading issue with the popup, it sometimes appear, sometimes not. Disabling threading makes them disappear, debugging in a debugger makes them appear. Still haven't been able to identify the issue.

There is some kind of threading issue with the popup, it sometimes appear, sometimes not. Disabling threading makes them disappear, debugging in a debugger makes them appear. Still haven't been able to identify the issue.
Author
Member

Actually, it turned out to be an error on my part. The render operator does not actually check the reports, and any reports need to be added to RE_is_rendering_allowed instead, for cancelation of the operator.

Actually, it turned out to be an error on my part. The render operator does not actually check the reports, and any reports need to be added to `RE_is_rendering_allowed` instead, for cancelation of the operator.
Omar Emara added 1 commit 2023-11-29 11:44:00 +01:00
Sergey Sharybin approved these changes 2023-12-01 15:41:46 +01:00
Omar Emara merged commit 5af7d3e2be into main 2023-12-01 16:16:30 +01:00
Omar Emara deleted branch fix-115043 2023-12-01 16:16:32 +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
3 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#115299
No description provided.