Eevee: Animated Eevee values slowdown. #51925

Closed
opened 2017-06-28 21:05:10 +02:00 by Dalai Felinto · 11 comments

Short description of error
Eevee is recompiling/linking the shader every frame if one of the values is animated.

Exact steps for others to reproduce the error
Playback this file with a cube and keyframes in the metallic input of the eevee shader, it gets really, really slow:
animated_metallic.blend

**Short description of error** Eevee is recompiling/linking the shader every frame if one of the values is animated. **Exact steps for others to reproduce the error** Playback this file with a cube and keyframes in the metallic input of the eevee shader, it gets really, really slow: [animated_metallic.blend](https://archive.blender.org/developer/F645723/animated_metallic.blend)
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

Added subscriber: @dfelinto

Added subscriber: @dfelinto
Dalai Felinto self-assigned this 2017-06-28 21:05:39 +02:00
Author
Owner

Confirmed in both NVidia and AMD. On NVidia at least since the shader is eventually cached, the second playback runs smoothly.

Confirmed in both NVidia and AMD. On NVidia at least since the shader is eventually cached, the second playback runs smoothly.
Dalai Felinto removed their assignment 2017-06-29 16:54:45 +02:00
Sergey Sharybin was assigned by Dalai Felinto 2017-06-29 16:54:45 +02:00
Author
Owner

Added subscriber: @Sergey

Added subscriber: @Sergey
Author
Owner

@Sergey, in the new depsgraph (2.78 --enable-new-depsgraph, or 2.8) material_changed is called every frame if one of the node elements is keyframed, even if it's a dynamic uniform.

Since GPU_material_free is called in this function, the shaders have to be re-compiled every frame, leading to a massive slowdown.

@Sergey, in the new depsgraph (2.78 --enable-new-depsgraph, or 2.8) `material_changed` is called every frame if one of the node elements is keyframed, even if it's a dynamic uniform. Since `GPU_material_free` is called in this function, the shaders have to be re-compiled every frame, leading to a massive slowdown.

This is caused by code which ensures changes in node groups properly triggers viewport update of Cycles, which required adding relations between all node trees and material they are used in. As a side effect, this exposed really weak aspect of editor ID update callback system: the callback is called for any ID when any update is flushed on it, without distinguishing source or purpose of the update.

One of the ideas here will be to get rig of editor ID update callback and do everything from dependency graph updates, by splitting material update into two separate operations: one for building actual GLSL shader and one for updating parameters of existing GLSL shader. This will require the following bits to be implemented:

  • Delayed GL shader delection, since the update function of material will be called by dependency graph from non-main thread, so we can't perform existing GPU_material_free() from material rebuild operation.
  • Some smart system in dependency graph which will prevent conflicts between this two operations (we don't want update to be called when the whole GLSL is re-built anyway).
  • Some more granular update tags for DEG_id_tag_update(), so we can differentiate between updates which needs to re-build GLSL and which only needs to update parameters.

All those are rather simple steps, but we need a working parameters update without GLSL re-compilation first. Otherwise any work we do about this bug report will effectively revert to old depsgraph behavior which does not do any material updates on playback and doesn't trigger updates on node groups changes.

This is caused by code which ensures changes in node groups properly triggers viewport update of Cycles, which required adding relations between all node trees and material they are used in. As a side effect, this exposed really weak aspect of editor ID update callback system: the callback is called for any ID when any update is flushed on it, without distinguishing source or purpose of the update. One of the ideas here will be to get rig of editor ID update callback and do everything from dependency graph updates, by splitting material update into two separate operations: one for building actual GLSL shader and one for updating parameters of existing GLSL shader. This will require the following bits to be implemented: - Delayed GL shader delection, since the update function of material will be called by dependency graph from non-main thread, so we can't perform existing `GPU_material_free()` from material rebuild operation. - Some smart system in dependency graph which will prevent conflicts between this two operations (we don't want update to be called when the whole GLSL is re-built anyway). - Some more granular update tags for `DEG_id_tag_update()`, so we can differentiate between updates which needs to re-build GLSL and which only needs to update parameters. All those are rather simple steps, but we need a working parameters update without GLSL re-compilation first. Otherwise any work we do about this bug report will effectively revert to old depsgraph behavior which does not do any material updates on playback and doesn't trigger updates on node groups changes.
Author
Owner

Added subscriber: @MikePan

Added subscriber: @MikePan

This issue was referenced by dfcb568c16

This issue was referenced by dfcb568c165913a15679f6b55b0b76e49a747a2e

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Added subscriber: @JanisGrinvalds

Added subscriber: @JanisGrinvalds

This comment was removed by @JanisGrinvalds

*This comment was removed by @JanisGrinvalds*
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
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
4 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#51925
No description provided.