Fix #104370: Draw: Don't request the same attribute more than once #104709
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#104709
Loading…
Reference in New Issue
No description provided.
Delete Branch "pragma37/blender:pull-fix-104370"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Avoid running out of attributes when multiple material slots use the same one.
Cleanup:
Removes the return value from drw_attributes_add_request since it shouldn't be modified afterwards and it's never used.
Avoid making copies of DRW_AttributeRequest in drw_attributes_has_request.
Fix 104370: Draw: Don't request the same attribute more than onceto Fix #104370: Draw: Don't request the same attribute more than onceI'm a bit surprised this is necessary, since it looks like
drw_attributes_merge
is meant to handle this already. I don't really know why, but it looks like a function is meant to add requests to a localDRW_Attributes
, then merge it with the cache's final requests.Might be nice to just simplify that with a threadsafe (write-protected with a lock) add in the first place?
Eventually it would be much nicer to store the requests with a
VectorSet
IMO.@ -71,6 +71,14 @@ DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs,
return nullptr;
}
for (int i : blender::IndexRange(attrs->num_requests)) {
Hmm, seems like this logic should be deduplicated with
drw_attributes_has_request
, which is basically the same except it returns a boolean.The
DRW_Attributes
parameter indrw_attributes_has_request
is const, butdrw_attributes_add_request
returns a non-const one.There's not a single call to
drw_attributes_add_request
that actually uses the return value, though, so we could simply remove it or return a const result.The issue is that this is at the beginning of the function:
I guess it would be possible to call
drw_attributes_merge
for every loop iteration inmesh_cd_calc_used_gpu_layers
andpointcloud_surface_shaded_get
, but that seems more fragile to me, and likely slower.Does it worth the overhead?
In any case, I'm not sure what's the rule about converting headers to C++.
Is it ok as long as it compiles, or there's more to it?
0c7ce9d188
to71dece7bde
I've been looking into better ways to solve this as we talked about on chat, but that would require a big refactor.
While the VBOs are indeed only binded to the relevant batches, all the loading logic assumes a single batch.
I've fixed the code duplication and removed the return value since it didn't make too much sense (it shouldn't be modified afterwards) and no caller used it.
I've also updated drw_attributes_has_request to avoid making copies of DRW_AttributeRequest.
Other than that, I'd merge the fix as it is now and leave possible improvements for the future.
Looks good now. Agreed that further changes should happen separately from this.
IMO some of the info from your latest comment should end up in the commit message.