Eevee preview nodes performance drop #71214

Closed
opened 2019-10-30 11:03:28 +01:00 by Danila · 11 comments

System Information
Operating system:Windows 10
Graphics card: GeForce GTX 1060

Blender Version
Broken: Blender 2.81 Beta aff6446e06
Worked: 2.8

Short description of error
Complex shader with large amount of math nodes slow down performance
in 2.8 60 fps
in 2.81 30 fps

Exact steps for others to reproduce the error
Create material with 30 node groups contains 30 math nodes. Set viewport to material preview and watch performance droping NodesPerformanceDrop.blend

**System Information** Operating system:Windows 10 Graphics card: GeForce GTX 1060 **Blender Version** Broken: Blender 2.81 Beta aff6446e064f Worked: 2.8 **Short description of error** Complex shader with large amount of math nodes slow down performance in 2.8 60 fps in 2.81 30 fps **Exact steps for others to reproduce the error** Create material with 30 node groups contains 30 math nodes. Set viewport to material preview and watch performance droping [NodesPerformanceDrop.blend](https://archive.blender.org/developer/F7871941/NodesPerformanceDrop.blend)
Author

Added subscriber: @DanilaPryamonosov

Added subscriber: @DanilaPryamonosov

Added subscribers: @fclem, @Sergey, @dfelinto, @mano-wii

Added subscribers: @fclem, @Sergey, @dfelinto, @mano-wii
Clément Foucault was assigned by Germano Cavalcante 2019-10-31 16:25:34 +01:00

I can confirm, but I don't know if the solution is simple.
The problem arose because now all the shader tree is flattened before evaluation.

But the main reason for slowness is because of animated materials (see 9d59d209).
Blender doesn't differentiate whether a material is animated or not, so the BKE_material_eval simply clears all gpumaterials references with each frame change.
Then DRW_manager needs to recreate the gpumaterial, but first check for similar passes.
And to do this check, it has to go through the entire node tree to create a hash.
And so finds the pass of the original gpumaterial.

Removing this line, the problem is solved:

diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 73c278a0ab6..2e87f04a4bc 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1613,5 +1613,4 @@ void paste_matcopybuf(Main *bmain, Material *ma)
 void BKE_material_eval(struct Depsgraph *depsgraph, Material *material)
 {
   DEG_debug_print_eval(depsgraph, __func__, material->id.name, material);
-  GPU_material_free(&material->gpumaterial);
 }

But then it would bring a problem for the animated materials.
It would be nice to find another solution for animated materials (updating only uniforms for example).

Assigning to @fclem, but @dfelinto and @Sergey may also have some remarks about it.

I can confirm, but I don't know if the solution is simple. The problem arose because now all the shader tree is flattened before evaluation. But the main reason for slowness is because of animated materials (see 9d59d209). Blender doesn't differentiate whether a material is animated or not, so the `BKE_material_eval` simply clears all `gpumaterials` references with each frame change. Then `DRW_manager` needs to recreate the `gpumaterial`, but first check for similar passes. And to do this check, it has to go through the entire node tree to create a hash. And so finds the pass of the original `gpumaterial`. Removing this line, the problem is solved: ``` diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 73c278a0ab6..2e87f04a4bc 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1613,5 +1613,4 @@ void paste_matcopybuf(Main *bmain, Material *ma) void BKE_material_eval(struct Depsgraph *depsgraph, Material *material) { DEG_debug_print_eval(depsgraph, __func__, material->id.name, material); - GPU_material_free(&material->gpumaterial); } ``` But then it would bring a problem for the animated materials. It would be nice to find another solution for animated materials (updating only uniforms for example). Assigning to @fclem, but @dfelinto and @Sergey may also have some remarks about it.

Part of the issue here is that material is not supposed to be re-evaluating on playback here.
The reason it was is because of some rather uncommon (in my experience) situation when ID has action but no f-curve. This can be fixed with something like P1149.

But there should be a way to speed up things even for the case when there is a real animation involved.

Not sure about current implementation, but we can calculate hash of every node group from dependency graph (which will happen in nice and threaded environment). We can even do things like constant folding and removal of unconnected nodes from there.

Now, even if that is still by-passed (imagine, that all the groups are connected and such) we can re-use hashes calculated for every group and use those to save on calculating hashes.

Part of the issue here is that material is not supposed to be re-evaluating on playback here. The reason it was is because of some rather uncommon (in my experience) situation when ID has action but no f-curve. This can be fixed with something like [P1149](https://archive.blender.org/developer/P1149.txt). But there should be a way to speed up things even for the case when there is a real animation involved. Not sure about current implementation, but we can calculate hash of every node group from dependency graph (which will happen in nice and threaded environment). We can even do things like constant folding and removal of unconnected nodes from there. Now, even if that is still by-passed (imagine, that all the groups are connected and such) we can re-use hashes calculated for every group and use those to save on calculating hashes.

I was a bit hasty, the hash is not the problem (obtained from GPU_generate_pass),
but it is GPU_material_from_nodetree in general (it should not even be called again),
especially ntreeGPUMaterialNodes (68,66% of the frame time).

I was a bit hasty, the hash is not the problem (obtained from `GPU_generate_pass`), but it is `GPU_material_from_nodetree` in general (it should not even be called again), especially `ntreeGPUMaterialNodes` (68,66% of the frame time).

If the material changes then i don't see how you can avoid GPU_material_from_nodetree.

If the material changes then i don't see how you can avoid `GPU_material_from_nodetree`.

Added subscriber: @StanislavOvcharov

Added subscriber: @StanislavOvcharov
Author

dews any hope this bug will be fixed?

dews any hope this bug will be fixed?
Clément Foucault was unassigned by Dalai Felinto 2019-12-23 13:45:21 +01:00

This can be a task for #68908 (Faster Animation Playback)

This can be a task for #68908 (Faster Animation Playback)

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Clément Foucault self-assigned this 2020-02-05 14:27:08 +01:00

This has been fixed by 32f0bb0523

This has been fixed by 32f0bb0523
Sign in to join this conversation.
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
5 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#71214
No description provided.