Refactor ImBuf buffer access #107609
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107609
Loading…
Reference in New Issue
No description provided.
Delete Branch "Sergey/blender:imbuf_buffer_data_refactor"
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?
The goal is to make it more explicit and centralized operation to
assign and steal buffer data, with proper ownership tracking.
The buffers and ownership flags are wrapped into their dedicated
structures now.
There should be no functional changes currently, it is a preparation
for allowing implicit sharing of the ImBuf buffers. Additionally, in
the future it is possible to more buffer-specific information (such
as color space) next to the buffer data itself. It is also possible
to clean up the allocation flags (IB_rect, ...) to give them more
clear naming and not have stored in the ImBuf->flags as they are only
needed for allocation.
The most dangerous part of this change is the change of byte buffer
data from
int*
touint8_t*
. In a lot of cases the byte buffer wascast to
uchar*
, so those casts are now gone. But some code isoperating on
int*
so now there are casts in there. In practice thisshould be fine, since we only support 64bit platforms, so allocations
are aligned. The real things to watch out for here is the fact that
allocation and offsetting from the byte buffer now need an explicit 4
channel multiplier.
Once everything is C++ it will be possible to simplify public
functions even further.
@blender-bot build
@blender-bot build
@blender-bot build
Mainly looked for potential issues in
byte_buffer.data
math but did not spot any.@ -197,3 +197,3 @@
/* Here we store the rect in the icon - same as before */
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) {
memcpy(iimg->rect, bbuf->rect, size * size * sizeof(int));
memcpy(iimg->rect, bbuf->byte_buffer.data, size * size * sizeof(int));
sizeof(int)
->4 * sizeof(uint8_t)
@ -206,1 +205,3 @@
&iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
memcpy(&iimg->rect[y * size],
&bbuf->byte_buffer.data[(y + yofs) * imgsize + xofs],
size * sizeof(int));
sizeof(int)
->4 * sizeof(uint8_t)
@ -92,3 +172,2 @@
ibuf->rect_float = nullptr;
ibuf->mall &= ~IB_rectfloat;
ibuf->flags &= ~IB_rectfloat;
Doesn't have to be cleaned up as part of this refactor, but it seems this and various other flags are not used for anything. We should probably move them to a separate enum that is used only for arguments when allocating imbufs, and not stored in
ibuf->flags
.I totally agree. I probably should have written about it in the description. That is something I was planning to do, but wanted to have a dedicated look into it.
@ -553,3 +687,3 @@
if (flags & IB_rect) {
memcpy(ibuf2->rect, ibuf1->rect, size_t(x) * y * sizeof(int));
memcpy(ibuf2->byte_buffer.data, ibuf1->byte_buffer.data, size_t(x) * y * sizeof(int));
sizeof(int)
->4 * sizeof(uint8_t)
I checked the core change and familiar areas and those changes seems fine.
Consider an other name for the struct or its attributes for more clarity.
@ -154,0 +159,4 @@
/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
* assignment API. */
typedef enum ImBufOwnership {
Naming might be confusing as the enum name can be read as a state type, but the values represent an action/transition.
@ -154,0 +160,4 @@
/* Specialization of an ownership whenever a bare pointer is provided to the ImBuf buffers
* assignment API. */
typedef enum ImBufOwnership {
/* The ImBug simply shares pointer with data owned by someone else, and will not perform any
ImBuf
I've fixed the typo.
For the enum I do see your concerns, but I can not think of a better naming. To me this is very the same than Ceres data ownership for residual blocks (so something I just got used to, so a bit hard to think out of the box).
If we want to change the naming before commit, I really wouldn't mind having some proposed changes, it would help a lot :)
Fine by me!
We have
GeometryOwnershipType
currently (which is very similar in purpose actually), maybe just adding aType
to the end of the name would make it clearer? Not a big deal though IMO.@blender-bot build
@HooglyBoogly It might be good to align to the
GeometryOwnershipType
. Although, after implementing the implicit sharing between imBuf and RenderResult it seems we can simplify the internal ImBuf storage to a simple boolean flag. So in this case it reads kinda neatIMB_assign_float_buffer(imbuf, data, IB_TAKE_OWNERSHIP)
.In any case, to me it seemed that it is something we can easily re-iterate if needed, and decided to merge the current state, so that keeping such big-ish change up to the main branch is not becoming too much of a burden now when we allow all sort of refactors in the main :)