Fix #124038: Performance issue with color sampling in 3D Viewport #126072

Merged
Lukas Stockner merged 1 commits from LukasStockner/blender:colorpicker-3dview into main 2024-08-12 14:52:46 +02:00
Member

The issue here is that copying the GPU viewport back to the CPU is an expensive
operation, so doing it for every frame when dragging the eyedropper is not ideal.

Instead, copy it once at the start and keep reading from it until the user
releases the eyedropper.

The issue here is that copying the GPU viewport back to the CPU is an expensive operation, so doing it for every frame when dragging the eyedropper is not ideal. Instead, copy it once at the start and keep reading from it until the user releases the eyedropper.
Lukas Stockner added this to the User Interface project 2024-08-08 02:26:05 +02:00
Lukas Stockner requested review from Clément Foucault 2024-08-08 02:26:14 +02:00
Hans Goudey reviewed 2024-08-08 03:11:03 +02:00
Hans Goudey left a comment
Member

Just reading out of curiosity and added a few small comments.

Just reading out of curiosity and added a few small comments.
@ -892,1 +892,3 @@
bool ED_view3d_viewport_color_sample(ARegion *region, const int mval[2], float r_col[3]);
class ViewportColorSampleSession {
public:
ViewportColorSampleSession() {}
Member

ViewportColorSampleSession() = default; is the more canonical way to write this I think

`ViewportColorSampleSession() = default;` is the more canonical way to write this I think
@ -893,0 +898,4 @@
bool sample(const int mval[2], float r_col[3]);
protected:
GPUTexture *tex = nullptr;
Member

Typically class variables come first in the declaration:
https://developer.blender.org/docs/handbook/guidelines/c_cpp/#class-layout

Typically class variables come first in the declaration: https://developer.blender.org/docs/handbook/guidelines/c_cpp/#class-layout
@ -2743,2 +2743,3 @@
GPU_texture_copy(copy_tx, color_tx);
GPU_texture_copy(tex, color_tex);
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
data = (blender::ushort4 *)GPU_texture_read(tex, GPU_DATA_HALF_FLOAT, 0);
Member
Use C++ style casts https://developer.blender.org/docs/handbook/guidelines/c_cpp/#c-type-cast
Lukas Stockner force-pushed colorpicker-3dview from d062a245a4 to ab031d958d 2024-08-08 03:37:18 +02:00 Compare
Clément Foucault approved these changes 2024-08-12 14:50:19 +02:00
Lukas Stockner merged commit d8f550875b into main 2024-08-12 14:52:46 +02:00
Lukas Stockner deleted branch colorpicker-3dview 2024-08-12 14:52:50 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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#126072
No description provided.