Draw: Add default material fallback detection #121137

Merged
Miguel Pozo merged 5 commits from pragma37/blender:pull-is-default-material into main 2024-04-30 19:44:16 +02:00
Member

Detect passes that are functionally equivalent to the default Material ones to skip their compilation.

Material compilation times on scene load (after clearing shader cache):

Mr. Elephant (Before) : 30s
Mr. Elephant (After)  : 20s

Barbershop (Before) : 2m:40s
Barbershop (After)  : 2m:15s
Detect passes that are functionally equivalent to the default Material ones to skip their compilation. Material compilation times on scene load (after clearing shader cache): ``` Mr. Elephant (Before) : 30s Mr. Elephant (After) : 20s Barbershop (Before) : 2m:40s Barbershop (After) : 2m:15s ```
Miguel Pozo added the
Module
EEVEE & Viewport
label 2024-04-26 17:32:54 +02:00
Miguel Pozo added 1 commit 2024-04-26 17:33:06 +02:00
Miguel Pozo added 1 commit 2024-04-29 15:54:00 +02:00
Miguel Pozo changed title from WIP: Draw: Add default material fallback detection to Draw: Add default material fallback detection 2024-04-29 15:54:08 +02:00
Miguel Pozo added the
Interest
EEVEE
label 2024-04-29 15:54:25 +02:00
Miguel Pozo requested review from Clément Foucault 2024-04-29 15:54:33 +02:00
Clément Foucault approved these changes 2024-04-30 10:54:11 +02:00
Dismissed
Clément Foucault requested changes 2024-04-30 10:59:04 +02:00
Dismissed
Clément Foucault left a comment
Member

The only thing not clear about this approach is that it doesn't create a GPUMaterial nor communicate the engine that the shader is redundant. Thus, the shader will still try to compile each frame (and be discarded each frame, but you pay the cost of the nodetree parsing).

Can you check if that's the case? and if it is, maybe have a dedicated flag on the GPUMaterial to denote this case.

The only thing not clear about this approach is that it doesn't create a GPUMaterial nor communicate the engine that the shader is redundant. Thus, the shader will still try to compile each frame (and be discarded each frame, but you pay the cost of the nodetree parsing). Can you check if that's the case? and if it is, maybe have a dedicated flag on the GPUMaterial to denote this case.
Miguel Pozo added 2 commits 2024-04-30 17:01:26 +02:00
Author
Member

The way to communicate to the engine that it should use the default pass was returning a null GPUMaterial, but you're right that this caused to re-evaluate the node tree each frame (I forgot the EEVEE material/shader maps are rebuilt every frame).

The way to communicate to the engine that it should use the default pass was returning a null `GPUMaterial`, but you're right that this caused to re-evaluate the node tree each frame (I forgot the EEVEE material/shader maps are rebuilt every frame).
Miguel Pozo added 1 commit 2024-04-30 17:07:43 +02:00
Clément Foucault requested changes 2024-04-30 17:08:23 +02:00
Dismissed
@ -767,0 +799,4 @@
eMaterialGeometry geometry_type)
{
bool is_volume = ELEM(pipeline_type, MAT_PIPE_VOLUME_MATERIAL, MAT_PIPE_VOLUME_OCCUPANCY);
::Material *blender_mat = (is_volume) ? BKE_material_default_volume() :

BKE_material_default_volume is only for volume object. I think this is also an error in the existing code.

`BKE_material_default_volume` is only for volume object. I think this is also an error in the existing code.
Author
Member

This is literally the same code that was already there, just moved to a re-usable function.
can_use_default is never true for volume pipelines, so this shouldn't introduce any new issues.
If there's an issue with the already existing code, I think that should be properly checked and fixed outside this PR.

This is literally the same code that was already there, just moved to a re-usable function. `can_use_default` is never true for volume pipelines, so this shouldn't introduce any new issues. If there's an issue with the already existing code, I think that should be properly checked and fixed outside this PR.
Clément Foucault approved these changes 2024-04-30 18:54:21 +02:00
Miguel Pozo merged commit a8f8745dcb into main 2024-04-30 19:44:16 +02:00
Miguel Pozo deleted branch pull-is-default-material 2024-04-30 19:44:19 +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#121137
No description provided.