Workbench: Fix: Performance Regressions #113251

Merged
Miguel Pozo merged 8 commits from pragma37/blender:pull-workbench-opti-cleanup into blender-v4.0-release 2023-10-06 15:31:53 +02:00
Member

Optimize Workbench performance so it's on par with the previous implementation.
Most of these changes are barely noticeable on powerful GPUs,
but can cause a notable performance improvement on old or low-end hardware.

  • Avoid unnecessary texture copies and draw directly to the viewport textures.
  • Optimize-out depth/stencil reads, using stencil testing instead.
  • Avoid using Texture::clear and use framebuffer clears instead.
  • Avoid framebuffer state changes (always use the same attachments).
  • Avoid constant variation of acquired TextureFromPools.

Fix #113010

Optimize Workbench performance so it's on par with the previous implementation. Most of these changes are barely noticeable on powerful GPUs, but can cause a notable performance improvement on old or low-end hardware. * Avoid unnecessary texture copies and draw directly to the viewport textures. * Optimize-out depth/stencil reads, using stencil testing instead. * Avoid using `Texture::clear` and use framebuffer clears instead. * Avoid framebuffer state changes (always use the same attachments). * Avoid constant variation of acquired `TextureFromPool`s. Fix #113010
Miguel Pozo added this to the 4.0 milestone 2023-10-04 18:08:54 +02:00
Miguel Pozo added the
Module
EEVEE & Viewport
label 2023-10-04 18:08:54 +02:00
Miguel Pozo added 7 commits 2023-10-04 18:09:10 +02:00
Miguel Pozo changed title from Workbench: Fix: Performance Regressions to Workbench: Fix: Performance Regressions 2023-10-04 18:10:05 +02:00
pragma37 changed target branch from main to blender-v4.0-release 2023-10-04 18:10:07 +02:00
Miguel Pozo added the
Interest
Workbench
label 2023-10-04 18:10:32 +02:00
Miguel Pozo requested review from Clément Foucault 2023-10-04 18:10:46 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR113251) when ready.
Clément Foucault requested changes 2023-10-05 17:45:39 +02:00
Clément Foucault left a comment
Member

Overall seems good. Just have 2 questions. See my comments.

Overall seems good. Just have 2 questions. See my comments.
@ -301,3 +310,1 @@
GPU_texture_copy(depth_tx, sample0_depth_tx_);
/* There's no depth_in_front_tx in scene image renders. */
}
/** Always acquire to avoid constant allocation/deallocation. */

I don't understand this. The use of temp texture should not make them recreated every frame.

I don't understand this. The use of temp texture should not make them recreated every frame.
Author
Member

If you are using TAAx16, for example, the engine is going to acquire smaa_edge_tx_ for the first 5 samples, but not for the rest.
So, in sample 13, the texture is going to be released from the pool, and the next frame will be recreated again.

If you are using TAAx16, for example, the engine is going to acquire `smaa_edge_tx_` for the first 5 samples, but not for the rest. So, in sample 13, the texture is going to be released from the pool, and the next frame will be recreated again.

Does that manifest by small itches on low end systems?

Does that manifest by small itches on low end systems?
Author
Member

It's hard to measure, but I'm pretty sure it won't help.
Another reason for doing this is to ensure Framebuffers don't change their attachments from sample to sample (since they will if the order of acquired textures changes), which can indeed cause performance issues.
Probably not in this case, at least right now, since they're the last acquired textures.

But I think it would be good practice to ensure engines always request the same textures in the same order unless there's a feature enabled/disabled or some other kind of "long-term" change.

It's hard to measure, but I'm pretty sure it won't help. Another reason for doing this is to ensure Framebuffers don't change their attachments from sample to sample (since they will if the order of acquired textures changes), which can indeed cause performance issues. Probably not in this case, at least right now, since they're the last acquired textures. But I think it would be good practice to ensure engines always request the same textures in the same order unless there's a feature enabled/disabled or some other kind of "long-term" change.

I think it is wrong to fix the issue at the user level when it's bad API implementation. So maybe we should look into some way to make sure a call to draw::Texture::acquire() will always return in the same texture being acquired. But that's unrelated to this patch.

I think it is wrong to fix the issue at the user level when it's bad API implementation. So maybe we should look into some way to make sure a call to `draw::Texture::acquire()` will always return in the same texture being acquired. But that's unrelated to this patch.
@ -243,11 +250,16 @@ class MeshPass : public PassMain {
ImageUser *iuser = nullptr);
};
struct StencilBits {

Why not use an enum here? Also I think members should be snake case.

Why not use an `enum` here? Also I think members should be snake case.
Author
Member

To ensure the values are uint8_t.
I could enum StencilBits: unsigned char instead, but then you leak into the parent namespace.
Or use an enum class, but then you need custom operators (I know there's a macro for that, but still...).

To ensure the values are `uint8_t`. I could `enum StencilBits: unsigned char` instead, but then you leak into the parent namespace. Or use an enum class, but then you need custom operators (I know there's a macro for that, but still...).

Yes use enum class StencilBits : uint8_t and use uint8_t(StencilBits::OBJECT_IN_FRONT) for conversion.

Yes use `enum class StencilBits : uint8_t` and use `uint8_t(StencilBits::OBJECT_IN_FRONT)` for conversion.
pragma37 marked this conversation as resolved
Miguel Pozo added 1 commit 2023-10-05 20:14:32 +02:00
Clément Foucault approved these changes 2023-10-06 14:09:33 +02:00
Miguel Pozo merged commit fe39456ba5 into blender-v4.0-release 2023-10-06 15:31:53 +02:00
Miguel Pozo deleted branch pull-workbench-opti-cleanup 2023-10-06 15:31:57 +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
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#113251
No description provided.