davidhaver-WIP-realize-depth #3

Closed
David-Haver wants to merge 65 commits from David-Haver/blender-old:davidhaver-WIP-realize-depth into WIP-realize-depth

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

Resolved main conflict I think.
Please check that I didn't do something wrong.

Resolved main conflict I think. Please check that I didn't do something wrong.
David-Haver added 443 commits 2024-03-21 15:47:27 +01:00
Pull Request: blender/blender#119016
This patch adds special cases to Shader::uniform_int routine
to allow writing of small types (1 bytes, 2 bytes) to the push
constant buffer.

This previously interpreted all incoming push constant data as
integer components only, resulting in rendering artifacts such as
bad SRGB mode selection and shader editor not rendering due
to mis-aligned overlay parameter, as the uniform assignment
would overflow consecutive small types.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119285
Fixes vertex group data loss after the `Draw Tool`, `Delete`, `Dissolve` operators.

Note: This is not a exhaustive list and there are other operators that will still loss vertex group data.

Pull Request: blender/blender#119034
Missing check from [0] allowed a removed region to be set when exiting
the temporary context.

[0]: 1ec10323ff
When restoring a temporary context, account for changes to the context
made by actions (typically operators) in the script.

There was an incorrect assumption that an override which didn't change
the current context would also be unchanged when restoring the temporary
context's original values.
Implemented `VKBackend::samplers_update()`. When triggered,
if the VK Device is initialized, the `device.samplers` are
freed and reinitialized.

Implements: #117019
Pull Request: blender/blender#119109
Resolves assertion firing when creating an SSBO
from a VBO which is not aligned to 16 bytes.
Required to ensure API validation is satisfied.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119298
This patch implements the GPU Bloom glare for the CPU compositor, and
adds a new option for it, leaving the Fog Glow option unimplemented once
again for the GPU compositor.

Pull Request: blender/blender#119128
If we run into NULL `RegionView3D` `regiondata` [which e.g. happens if
we just set `bpy.context.area.type = 'VIEW_3D'` without further actions
in the text editor prior to calling the transform operator], we can make
it gracefully work just by using `t->spacetype = SPACE_EMPTY` in
`initTransInfo`.

Similar check is already done in ba229e3859 (marked /* running in the
text editor */).

Transform code is smart enough to have fallback code in place that sets
matrices etc.

Pull Request: blender/blender#119205
GPU compositor crashes when the Hue Correct and one of the Curves node
are used together. That's due to a utility function that goes by the
same name in both nodes. To fix this, rename one of them to be more
specific.
This is a side effect of the new small types
support. We need to avoid using them as local
variables.
Accessing `__class__` on a removed object raised an exception, making
`isinstance(ob, cls)` unreliable. Always allow class access.

Resolves issue raised by blender/blender-addons!104958.
Previously the CUDA context was always destroyed and the module along
with it. Now that this no longer happens, the missing module free became
a memory leak.

Also fix the same issue for HIP, though this is destroying the context
so it's not a problem yet.

Fix part of #119035

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
A debug error was thrown when the armature modifier was added to a GPv3
object that did not have vertex groups.

Pull Request: blender/blender#119301
Sets the newly drawn stroke to be deselected. (matching legacy implementation)

Previously the selection attribute was left uninitialized, and would often be outside of the valid range, causing a crash to occur during some operator.

Pull Request: blender/blender#119306
Using the previously computed L breaks shadows on reflection probes,
even if the value should be the same.

Pull Request: blender/blender#119219
The shader compilation job assumes it can only be closed on program
exit, leaving all their materials as queued.
However, render tasks can kill it, causing drw_deferred_shader_add to
get stuck in an infinite loop.

Pull Request: blender/blender#119172
When new dash segment is added in empty list, it is not set as active.
This is because active_index value becomes greater than segment_num.

Pull Request: blender/blender#119318
Moving a set of keyframes could cause crashes by setting invalid
`drawing_index` in `GreasePencilFrame` data.

The transform operator for grease pencil keyframes can add and remove
keyframes by overwriting existing frames. The `move_duplicate_frames`
function in particular has to keep track of drawing user counts to
ensure that the drawings referenced by the frames are still alive at the
end.

This was broken when moving multiple keyframes at once, such that later
keyframes would overwrite the target positions for earlier frames (for
example moving frames [1,2,3] to [2,3,4]). The `move_duplicate_frames`
was first removing the source frame and then adding it back at the
destination. In case the source frame was already the destination of an
earlier keyframe, this will cause incorrect user count because the frame
being removed is not the same as the one being added back.

To avoid this problem, remove all the source keyframes first before any
other modification of the destination layer. That way we can be sure the
frames at the source index is actually the expected frame.

Pull Request: blender/blender#119207
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: blender/blender#119267
Fix is same as 18912561b5 / 72d324bd81

Pull Request: blender/blender#119311
Pull Request: blender/blender#119169
Caused by 930b11b0fe.

The `find_best_dir` method needs to break the loop of edges that share
faces if these edges go beyond those selected for slide.
Pull Request: blender/blender#119287
The `execute_eraser_on_drawing` expects the first argument to be the layer index, but the drawing index
was passed to the lamda.
The fix makes sure to pass the active layer index.
Also return early if there is no active layer.
Pull Request: blender/blender#119315
Pull Request: blender/blender#119280
Before e05c36f56d the fallback for unsupported attributes was
white. That's arbitrary, but not worth changing.
This fixes the following name collisions:
* Compositor Box/Ellipse Mask node: `width` -> `mask_width`
  (also renamed the `height` property accordingly)
* Shader AOV Output node: `name` -> `aov_name`
* Geometry Color node: `color` -> `value`.

Those are breaking changes unfortunately, because looking up those property
names yielded the node-specific and not the common property. Therefore, this is
targeted at `main` instead of `4.1`.

Pull Request: blender/blender#119284
The issue was that calling `ensure_geometry_instances` converts all instances to a
geometry, even the ones that can't be converted. The comment already says that
non-geometry instances should stay intact, but that didn't work correctly yet:
```
  /**
   * If references have a collection or object type, convert them into geometry instances
   * recursively. After that, the geometry sets can be edited. There may still be instances of
   * other types of they can't be converted to geometry sets.
   */
```

Pull Request: blender/blender#119324
As part of #118623, we discovered that the operator used for adding images in the 3D viewport was not the same when drag and dropping as when adding it from the add menu. This lead to different and potentially confusing behaviour for the user when they use both.

This patch removes the python operator and unifies the functionality into one operator. It also renames the operator to be in line with the other "Add X" object operators.

Pull Request: blender/blender#118973
Similar to 854cdd1180
Snap for meshes without vertices raised an error in debug build.
Due to differences with the libc++ std::sort implementation that has a strong
requirement on strict weak ordering.

Pull Request: blender/blender#119189
Use `context.pose_object` when baking a pose, on on top of the objects
in `context.selected_editable_objects`. When in pose mode, it's expected
that the pose of the active will be baked, regardless of whether the
pose object is selected itself.

Pull Request: blender/blender#119317
Use the prior fixed button widths as minimum sizes for the template_ID
new and open buttons. That way they will look the same as before under
most circumstances but will still adjust rather than overflow for
longer content or larger text sizes.

Pull Request: blender/blender#119330
Header file is renamed to GEO_mesh_boolean_convert.cc and
files that included it are updated to use that path.
This is in preparation for bigger changes to the internal
boolean API, which make more sense as a "geometry" API
than a kernel API.

Pull Request: blender/blender#119336
Fix of error from 95810eec8f

Pull Request: blender/blender#119335
For node tools, I would like to give the option of invoking the operator from the
menu, but waiting for a mouse click for the future "Mouse Position" node. Not
all node tools should do that though, and they all use the same operator type,
so it needs to depend on an operator callback. That's implemented here.

Pull Request: blender/blender#118983
For various reasons, the animation system can't properly update the node tree
so that the socket availability caused by changing node enum properties
propagates completely. So animating node properties that affect
socket visibility to change isn't possible without issues like crashes.
Unfortunately that wasn't disallowed before. In this commit there is
a balance of disabling animation on sockets that could reasonably expected
to affect socket visibility, and minimizing breaking changes.

Pull Request: blender/blender#119221
There seems to be an integer overflow in OpenVDB code. For now just avoid rendering
the volume when the indices are very large, which is an extreme case anyway.

Pull Request: blender/blender#119279
The offset `-15` that's passed to `UI_GetThemeColorShade4fv` is chosen so that the color
stays almost the same in the default theme.

Pull Request: blender/blender#119283
Initialize these like other fields in the object runtime struct.
Grease Pencil provides custom vertex group attributes as VArrays that
are a view on the `MDeformVert` buffer. These attributes are not spans,
which the curve conversion code was expecting. Non-span VArrays must be
materialized first.

Pull Request: blender/blender#119212
Rendering with F12 causes some inconsistencies between canvases and areas of interest. This is due to some corrections of composite node canvas to fit to the render size, which are not necessary for the Viewer Node. This patch fixes the issue by considering the input image as a whole before translating.
Note: this is still consistent with immediate realization of transform nodes in GPU compositor, where nodes are to be evaluated from left to right.

Pull Request: blender/blender#119276
Previously, all information outside the render area did not get considered because transform operations such as translation and rotation might cause the output area to be smaller.

In this patch, the whole image gets flipped regardless of the output area, which makes the behavior consistent with the GPU compositor.

Pull Request: blender/blender#119278
This is a improved solution compared to 20dbcd8814

Caused by 930b11b0fe.

When checking edges that share faces between them, the `find_best_dir`
method cannot use edges that were added in the current loop.
Lines in the history never change, each input line is added to the
end (unless it is a duplicate of the last item).
A new history_index member keeps track of where the up/down arrows have
moved in the history.

Preserved the previous down-arrow behavior of going to the item after
the one that was copied, this is useful in Python for re-entering a
multi-line block.

Ref !119356
should fix the failing bots
Untrack all newly created objects, although this code-path only runs
when creating the type fails - which is an exceptional case.
Python's behavior changed since this feature was added causing the
object to be tracked when freed by Python's subtype_dealloc even
if Blender has not tracked the data. Detect this case and untrack
the object before freeing.
Adds copy and paste images functionality to and from the image editor
in Linux/Wayland clipboard.

Currently the only format supported is PNG.

Ref: !119117
The function didn't return early in case the domain was empty.
The fix makes sure we return an empty `MutableSpan` in this case
(add doesn't try to create a new custom data layer).
Account for actions themselves being selected in the outliner as well
as ID-types that don't have any animation data.
fd92647f added an early return so now this check is no longer needed.
A follow-up to previous commit that moved these files to geometry.
The _convert suffix made sense at one point but is now just confusing.
Fix is same as 18912561b5 / 72d324bd81

Pull Request: blender/blender#119311
`char4` are defined as `int4` from now on. This
created a compiler error.
I think the issue is that the run-node-group operator overwrites the data stored in the
`Mesh` while mesh edit mode operations typically only change the `BMEditMesh`. It
seems like that causes issues because the mesh edit mode undo stack does not
keep track of changes to the `Mesh`. When hitting undo, Blender assumes that the
`Mesh` stored in the object has not changed and therefore it does not have to be
read from the undo step again.

The preliminary fix implemented here is to just not change the `Mesh` but only the
`BMEditMesh` like any other edit mode operator. This seems to solve the issue.
I haven't quite figured out yet how to tell the undo system that the `Mesh` has to be
loaded from the undo step when undoing out of mesh edit mode. Doing that might
provide a better solution.

Pull Request: blender/blender#119015
The regression happened because object instances were turned into normal geometry
instances which don't have object-level visibility settings. Long term, this may not be
something we can support, but it's also not something we should break unnecessarily
and accidentally.

Pull Request: blender/blender#119370
This commit adapts the existing Edge Slide and Vert Slide to work with
UVs as well.

It addresses [0] for the addition of an edge slide tool to the UV
Editor.

This feature allows users to slide UVs towards adjacent edges,
providing more convenient ways to edit UV maps.

[0]: https://blender.community/c/rightclickselect/66dbbc

Pull Request: blender/blender#119041
This commit adds the `SCULPT_OT_hide_show_lasso_gesture` and the
corresponding Lasso Hide tool.

* Exposes the selection type for both the lasso and box hide tools
  as a option in the header
* Adds functionality into `sculpt_gesture.cc` for handling lasso
  selections with the `Outside` selection type

For `SelectionType::Outside`, the current implementation opts to not
do any filtering on the PBVH node level due to cases where the node
is mostly covered by a single gesture.

Addresses one of the tools in #80390

Pull Request: blender/blender#119140
The core of the issue was that `sculpt_flag` was used by three different enums (`eGP_Sculpt_Flag`, `eGP_Sculpt_Mode_Flag`, and `eBrushFlags`). This resulted in the flag getting overriden because `ENUM_OPERATORS` expected the maximum value of `eGP_Sculpt_Flag` to be `(1 << 3)` which it wasn't.

The `sculpt_flag` was exposed through python as `"direction"`.
In the UI this meant that it was effectively used as `brush.direction`. This fix replaces `brush.gpencil_settings.direction` with `brush.direction`.
It also makes sure `sculpt_flag` is only ever used with values from `eGP_Sculpt_Flag`.

Pull Request: blender/blender#119373
Pull Request: blender/blender#118916
Added a null check for RE_GetRenderLayer() which could possibly return
null and then stored in `render_layer`, in order to prevent members of
`render_layer` being accessed in RE_pass_find_by_name(), and thus solved
the segmentation fault.

Pull Request: blender/blender#119200
In bf17fc8d79  after extending buffer to multiple of 4 there appeared trailing
space in buffer not covered by shader's `for` loop.

Pull Request: blender/blender#119346
With some data-type conversions we can do a best-effort conversion of
UI data like default values and min and max to the new data type.
This can help to make Python scripts simpler and to avoid bugs like
#105965.

Pull Request: blender/blender#106161
`PBVHVertexIter::g` is the grid index within the node, not the the global grid index.
Fix of error introduced in c31718649d. Attribute names will
be freed on domain resizing. This mean, ref-names which is attribute
ids is will be invalid. To avoid this, make sure names will be gathered
only after resize. To avoid unnecessary topology map computation before
mesh resize, check if attributes on required domain exists, instead
of gathering them and check if span is not empty.

Pull Request: blender/blender#119242
- Updated the `tinygltf` lib to version `2.8.21` [1]
- Fixed a typo in the `extern/README` file
- Updated `tinygltf`'s entry in the `THIRD-PARTY-LICENSES.txt` file

Pull Request: blender/blender#118427

[1] https://github.com/syoyo/tinygltf/releases/tag/v2.8.21
This could happen if objects were hidden after going to editmode and
knife was used on them.

In that case, raycasting would (rightfully) fail, but there is a
fallback in place using the back-buffer selection method (in which the
hidden object is still present). So a face would be found, but this
makes all following code confusing/wrong since we are working with
coordinates / faces under the assumption there would be a valid/
corresponding object to it in `KnifeTool_OpData` > `objects` -- which is
not the case...

So to resolve, just check if the object is visible before calling
`EDBM_face_find_nearest` in knife code.

Alternativeliy, we could also add a check for Base viewport visibility
to all the bmesh `find_nearest` functions (a bit hesitant though since i
am not sure this would be desired in all cases)

Pull Request: blender/blender#119383
Unfortunately the only versioning code that can "properly" add data-
blocks is not run when linking or appending (`do_versions_after_setup`
has details). The versioning has to be done manually for this case.
Fortunately that is simple since the versioning function already just
operators on a main database.
This PR applies a fix for the comparator being passed into std::sort to
avoid potential Mac / libc++ issues as seen in #119189

Pull Request: blender/blender#119385
The issue was that the object location was taken into account twice using
`object_to_world` and `ob->loc`.

Pull Request: blender/blender#119378
The issue was that the clamping to the bounds happened before the rounding to the increment step.
In the reported case this led to a divide by 0 error.
The fix is to do the increment first, then the clamp to bounds.

This was reported by Raymond Luc on #117287

Pull Request: blender/blender#119367
I ran into this issue a while ago too, where the vertex iteration
macro didn't process all of the vertices. I didn't figure it out yet,
but it makes more sense in the context of the surrounding code
to specialize this anyway.
"Bright" is an adjective, not a noun.
This PR extracts the `SCULPT_OT_trim_box_gesture` and
`SCULPT_OT_trim_lasso_gesture` into a separate file and
namespace from `blender::ed::sculpt_paint::mask`.

Pull Request: blender/blender#119390
Just like for objects in 3D View, UVs can also benefit from the
`Set Snap Base` feature (key `B`).
This PR moves the `SCULPT_OT_face_set_lasso_gesture` and
`SCULPT_OT_face_set_box_gesture` operator out of the `paint_mask.cc`
file and `blender::ed::sculpt_paint::mask` namespace to
`sculpt_face_set.cc` and `blender::ed::sculpt_paint::face_set`.

Pull Request: blender/blender#119392
This PR extracts the `SCULPT_OT_project_line_gesture` operator into its
own file and namespace out of the `paint_mask.cc` file and
`blender::ed::sculpt_paint::mask` namespace.

Pull Request: blender/blender#119394
Remove more use of the redundant storage in SculptSession here.
Remove one function from the API.
This PR adjusts the behavior of the Texture Paint mask icon to behave
similarly to the automasking icon in Sculpt mode. This behavior was
missed in the original task: #102585

Pull Request: blender/blender#119399
The Weighted Normal modifier has a "Keep Sharp" option that used to
recalculate the sharp edge tags based on the mesh's smoothing angle.
To keep the same behavior, an auto smooth versioning modifier has to
be added before that modifier when the option is on.

Pull Request: blender/blender#119400
The current naming for node groups is "Socket" rather than "Input".
Also remove translation which is unnecessary since these are just identifiers.
Small operator confirmations get separate confirm and cancel buttons,
better descriptions and configurable confirm button text. But still
popup at cursor location and can be cancelled with mouse movement.

Pull Request: blender/blender#118346
Add an icon called INTERNET that looks like our current URL without the
mouse cursor, so it looks less specifically like a web document. So can
be used to represent other internet and cloud-based services.

Pull Request: blender/blender#119186
We recently added a new "Internet" icon, meant to represent internet
services and protocols generally, in contrast with the existing "url"
icon which can be seen as being http (web link) specifically.  This
PR just uses this icon for cloud storage uses and for remote extension
repository.

Pull Request: blender/blender#119409
Our `node_shader_utils.py` module needs to be updated to account for API
changes made during the 4.0 release cycle [1].

Here we need to guard against accessing the "Location" node input if not
dealing with the appropriate type of Mapping node.

[1] e4ad58114b

Pull Request: blender/blender#119354
Now there is no difference between omitting remote_path or passing
in an empty string.
When bone collection is moved to root collection by drag-drop,
visibility of dropped collection is lost. This is due to missing flags
for the root bone collection which cleared `BONE_COLLECTION_ANCESTORS_VISIBLE`
flag of dropped bcol.

Pull Request: blender/blender#119366
Caused by b40a9ce60b.

For the non-edit mode code path, the mesh is freed as part of
`BKE_mesh_nomain_to_mesh`.
EEVEE-Next performes less on integrated GPUs then discrete GPUs.
Most shaders have been analyzed, but there will always be bottlenecks
related to architectural differences.

In order to make EEVEE-Next run smooth on integrated GPUs this change
will implement viewport pixel size option similar to Cycles. The main difference
is that the samples will still be weighted and up-sampled to the final film
resolution. This makes the pixels not look squared in the viewport but will
resolve to something close to the results without up-scaling.

This improves the performance especially on integrated GPUs. The improvement
for discrete GPUs are less noticeable. See here the stats when playing
`rain_restaurant.blend` back on a RAPHAEL_MENDOCINO iGPU.

| Pixel size | Frames per second |
|------------|-------------------|
| 1x         | 0.25 FPS          |
| 2x         | 4.14 FPS          |
| 4x         | 6.90 FPS          |
| 8x         | 9.95 FPS          |

Related to: #114597
See PR for some example images.

Pull Request: blender/blender#118903
This was likely a typo in bd4c310a19.

Pull Request: blender/blender#119413
It's possible for an object to be in edit mode without being selected. Use the
`FOREACH_OBJECT_IN_MODE_BEGIN` iterator to find all objects in the mode instead.

Pull Request: blender/blender#119412
Caused by dd0e60fb51

That commit was an optimization attempt to reuse the depth buffer
updated by the engines.

But it fails when `GPU_clear_depth` is called for gizmos.

So, due to error proneness, revert that solution for now.
It's typically only worth specifying specific captures when the lambda
is stored as a function object for use later. Since this is just passed
as a FunctionRef as an iteration callback, we can use a less complex
capture here. That also helps clarify that this isn't a callback.
Splash screen by Lynxsdesign
This reverts commit 51a3c03072.
`transform_poll_property` can be smarter in the conditions.
Changes:
- Add Vert Slide and Edge Slide to 'UV -> Transform' menu.
- Add a separator for Vert Slide and Edge Slide in the context menu.
- Don't display the "Correct UVs" option in the Redo menu of UV Editor.
21 icons slightly reworked to be a bit smaller. Icons like "solo", some
arrows including "file_refesh", etc are just a little large within the
bounds that they are displayed in. This gives them a bit more breathing
room.

Pull Request: blender/blender#119425
Also simplify iteration over map keys and slightly simplify string hash.
The `AssetEntryReader` and `AssetEntryWriter` classes were only used
once and just added indirection hiding the actual logic of reading and writing
asset metadata from the index. It also hid double map lookups and extra
string copies/allocations.
- Remove the unnecessary `ContainerValue` from the class hierarchy
- Construct `StringValue` with a `std::string` by value to avoid copies
- Remove some indirection by using type names directly instead of aliases
- Use utility methods to lookup/append specific data types for arrays/dicts
- Simplify conversion from unique_ptr to shared_ptr
- Avoid use of `new` and `delete`
- Avoid creating maps of all elements in vector for a single lookup
Pull Request: blender/blender#118917
The current font style can be overridden with a input or other widget text style,
this change ensures that the right font style is set so `BLF_width` don't use a
overridden font text style.

Pull Request: blender/blender#119442
When workspace is switched, send notifier to clear `view_layer->stats`
then update the stats with repsect to new object interaction mode.

Pull Request: blender/blender#119418
Regression in [0] caused precision fail to activate in the graph editor
and when pressing shift then control (#119395).

[0]: 060174cf14
Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119093
This adds the `viewlayername` property to grease pencil v3 layers.
It's exposed as `viewlayer_render` in python.

Note: this is not used in the renderer yet. Will be used in a following PR.
Pull Request: blender/blender#119422
Use snapping increments matching values used before this was
customizable. [0] changed snapping increments from 5 degrees to 15,
from 1 to 5 degrees with precision enabled.

[0]: 060174cf14
The Anti-Aliasing node contrast limit has no effect. This is due to a
typo in the code, where the threshold was used internally as the
contrast limit instead.
This PR changes the motion path appearance by using the
`Vertex` color as defined in the 3D viewport theme settings
instead of hardcoding it to white.

The issue with setting it to white is that it is too visually distracting,
overshadowing the points that are keyframes, which are drawn in
the selection color for vertices (also defined in the Theme)

Pull Request: blender/blender#119382
The CustomData API automatically creates a unique attribute with
a unique name for generic data types. Caused by f2bcd73bd2.

Pull Request: blender/blender#119441
- Fix a typo
- Remove unnecessary namespace specification
- Use "this" to access class methods
Adds the `blend_mode` property to RNA and exposes it in the UI.

Note: This is not used by the renderer yet. Will be added in a following PR.

Pull Request: blender/blender#119460
Layer masks were partly already there. This PR completes the implementation and expose them through the UI.

This also adds three operators to:
- add a layer mask
- remove a layer mask
- reorder layer masks

Note: These are not used by the renderer yet. Will be done in a following PR.

Pull Request: blender/blender#119433
Pull Request: blender/blender#119435
* If required roles are not found, refuse to load the config
* Use "default" role as fallback for all roles, following the
  OpenColorIO docs.
* Use bundled config if loading environment config fails,
  instead using very limited fallback config.
* Fix OCIO_exit get called on failed config load, causing
  crash when trying to load the next config.

Pull Request: blender/blender#119435
The Metal shader compiler was previously fully unrolling
lightprobe sampling, resulting in long compile times of
70+ seconds and high instruction counts.

Implementing Chunked unrolling to retain benefits of
unrolling e.g. latency hiding, while reducing register
pressure and improving compile time significantly.
(Only 800ms vs 70,000ms).

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119333
Flip conditions and use early returns to simplify `ANIM_nla_mapping_get()`.

No functional changes.

Pull Request: blender/blender#119463
This fixes an issue where the `use_masks` functions on layers
and groups returned the wrong value.
The issue was that the root group doesn't have this flag set
which then propagates to all the layers and groups.
To fix this we invert the `GP_LAYER_TREE_NODE_USE_MASKS` flag (now called `GP_LAYER_TREE_NODE_HIDE_MASKS`).

The API still uses the `use_masks` function.
Change Preferences panel "Translation" to "Language" and replace
"Affect" with "Translate".

Pull Request: blender/blender#119430
Fix for a crash after undo "Mask slice to new object"

When creating a new mesh object in the mask slice operator in
sculpt mode it caused a crash when undo to the initial undo step.
Moreover saving the sculpt undo state seems not necessary in
this function since undo/redo doesn't really work reliably for this
operator from the start, but there is nothing can be done about it
without systemic changes.

Note: this PR replaces #119401
Pull Request: blender/blender#119443
The IMB_dupImBuf() function does not copy the GPU texture as it might
not be possible if the GPU context is not active, but it also was not
clearing the pointer in the result ImBuf. This could potentially lead
to situation when the texture gets freed via IMB_freeImBuf of either
original or copied image buffer, leaving the other pointing to a freed
GPU texture.

It is not known whether it ever was an actual problem for artists,
but it is nice to avoid such possibility.

Pull Request: blender/blender#119469
Fix for a crash after undo "Mask slice to new object"

When creating a new mesh object in the mask slice operator in
sculpt mode it caused a crash when undo to the initial undo step.
Moreover saving the sculpt undo state seems not necessary in
this function since undo/redo doesn't really work reliably for this
operator from the start, but there is nothing can be done about it
without systemic changes.

Note: this PR replaces #119401
Pull Request: blender/blender#119443
With default sizes the Timeline "Playback" popover clips the text of
two items in English. This PR just makes it just wide enough plus a
bit of breathing room.

Pull Request: blender/blender#119474
Our splash screen rounds the top corners of the featured image. However
this requires an alpha channel, so an RGB image will not look rounded.
This PR just ensures a 32 plane count.

Pull Request: blender/blender#119473
This adds conversion for the following flags:
- `GREASE_PENCIL_ANIM_CHANNEL_EXPANDED`
- `GREASE_PENCIL_AUTOLOCK_LAYERS`
- `GREASE_PENCIL_STROKE_ORDER_3D`

Note: The last two are not expose through the UI yet.
This exposes the `stroke_depth_order` setting.
The enum is added to a `Settings` panel in the object-data properties.
Cryptomatte passes would generate a feathered outline
in Metal due to missing texture fence in chained
read->modify->write->read->... patterns.

Added imageFence function to explicitly state that
imageStore's should be visible to future imageLoad's.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119163
This adds the submodule for Windows ARM64 devices, so blender
can be built without having to build the libraries yourself also.

Ref #119126

Pull Request: blender/blender#119459
In older drivers with an integrated GPU, this may crash. This not only
affects HIP, but also can crash when using Cycles with an NVIDIA or
Intel GPU in combination with an AMD CPU.

Fixes for this are expected to be coming, but there will not be enough
time for user testing, and it is difficult to be certain that the fix
is complete.

So to be careful, this is postponed until it has had more testing.

Pull Request: blender/blender#119476
Note this leaves out the changes from 335ff6efab, to disable
OpenImageDenoise for AMD GPUs. That is only for Blender 4.1.
In File Browser list view show tooltips for both the icon and the name
portion of the line to consistently show them no matter where you hover

Pull Request: blender/blender#118071
This adds a "Solver" option to the geo boolean node, with the options
Exact and Float.
The current geo boolean node only uses the Exact solver.
This adds the ability to use the faster original floating point boolean solver.
The float solver has issues with coplanar and other coincident geometry,
but is generally much faster than the Exact solver, and users have asked
for this option (which is available in the Boolean Modifier and edit mode
boolean tool).

Like the modifier, the Float solver needs to convert the Mesh to BMesh,
do the operation, and then convert back to Mesh. It also has to do it
iteratively if more than two operands are supplied.

This is the first of a planned series of commits that will add a
new exact boolean solver, based on the Ember paper, as a solver option.
Ember will be much faster than the current exact solver, but may still not
be as fast as float, and also will not handle some non-volume-enclosing
inputs as well as Float, so it is likely that the Float solver will always remain.
We may eventually retire the old Exact Solver, however.

This commit also prepares for more sensible code in the future by
changing the internal enum names for the solvers to better reflect the
algorithms used: Fast -> Float, and Exact -> Mesh_Arr (which means
"Mesh Arrangments, the name of the paper upon which the current
exact solver is based).

Co-authored-by: Howard Trickey <trickey@google.com>
Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: blender/blender#119294
Move tooltip position to mouse position rather than bottom of the
region for labels that are taller than one line.

Pull Request: blender/blender#117879
With #118346 we want the new small confirmations to have no icon by
default. I forgot to set this as the default when called via Python.

Pull Request: blender/blender#119489
Changes to python operators that add and remove custom themes. Removal
gets poll function, separate name and description, and confirmation.

Pull Request: blender/blender#118775
Similar to the recently introduced `Solver` enum. This is just friendlier
and doesn't require including `DNA_node_types.h` in the geometry
module header. There's no strong benefit to declaring these enums in
DNA in practice.
Changes to python operators that add and remove custom keyconfigs.
Removal gets poll function, separate name and description, and
confirmation.

Pull Request: blender/blender#118778
This PR adds an explanation to the Lasso Gesture doxygen
section of the generic `wm_gesture_ops.cc` file.

Pull Request: blender/blender#119490
Clarify that these blocks are unreachable so the intention is clear
if they're ever encountered.
Titles can't be used because this text is indented.

Ref: !119320
As part of PR #118396 the "generator" effect strips (color, text,
adjustment) also started to put their "raw" images into the cache.
However, seq_cache_timeline_frame_to_frame_index that has optimization
that tries to use only one cache entry based on how many frames are
present in the strip was not expecting to see effect strips, ever.

As a result, something like adjustment layer would effectively just
cache a single frame, since it has no "source frames" to speak of.

Fixed that by only doing this optimization for non-effect strips.
Pull Request: blender/blender#119492
With the recent changes introduced by the mixed resolution rendering
overscan and border rendering broke. Overscan is also used by the test
cases and fails the current tests.

This is a quick fix to get the overscan working.

NOTE: overscan + mixed resolution rendering will look blurry.
NOTE: this doesn't fix border rendering.
When drawing is visible in 3d-view and playhead is not over keyframe, in
such case erase tool is erases everything (or let's say it adds empty
keyframe). Erasing works correctly if additive drawing is enabled but
this is also expected to work when additive drawing is disabled.

Pull Request: blender/blender#119051
In this case, the situation in which edges share faces connected to
each other could fail as it could pass through a slide edge.
Without the update tag, the tree topology cache is not recomputed.

Pull Request: blender/blender#119506
Since 4a78d7dc4c blending is turned ON, but apparently the background
color is not receiving full alpha in this scenario.

Resolve by using immUniformThemeColorAlpha (with 1.0 alpha)

Pull Request: blender/blender#119504
This is a regression since d579ac2b3f

Ensure that the image buffers used by render passes have metadata at the
end of render, similarly to how stamping happens. This solves the reported
issue, and makes the metadata behave consistently, independent on how the
image buffer is accessed.

Thanks Philipp Oeser for investigation and pin-pointing the bad commit!

Pull Request: blender/blender#119503
An alternative fix would be calling `update_on_change_` in the
attribute `try_create`function, but sticking with this more
conservative fix seems better for 4.1.

Pull Request: blender/blender#119515
On some GPUs/drivers (seemingly nvidia) and screen sizes, VSE
vectorscope and sometimes waveform have "garbage" artifacts around
them.

Root cause unknown (driver bug?), for now similar fix as a while ago
in #112665: explicitly draw opaque background (with alpha=1), and then
use alpha blending for the scopes texture display on top of that.

Pull Request: blender/blender#119512
When using mixed resolution rendering with an orthographic projection
the display was not correct. The reason was that the view boundaries
were decomposed from the winmat correctly, but when re-composing
the matrix it assumed to be in perspective.

This is fixed by composing an orthographic winmat when it was sourced
from a orthographic winmat.

Fixes #119514

Pull Request: blender/blender#119517
Previously I misunderstood the subsurf modifier's handling of custom
normals. The "use custom normals" check in 4.0 checked if there were
custom normals and whether the auto smooth flag was checked. I wrongly
changed that to check the mesh normals domain instead of whether there
was custom normals. In 4.1, auto smooth isn't required to use custom
normals, but that should be the only change here.

In this PR, that change is done for CPU and GPU subdivision, and for
the versioning which adds a modifier. The versioning now only puts the
new modifier before the subsurf modifier if it would have used the
custom normals interpolation in 4.0.

The last change causes two test failures which I also misunderstood
before. The previous results were arguably incorrect, because the
Cycles experimental adaptive subdivision ignored the auto smooth
angle, which was 5 degrees. It should have been 180 degrees.
I will modify those test files to remove auto smooth from the meshes.

Pull Request: blender/blender#119485
Ref: #118534
turns out `in_volume_segment` does need to be checked. If the ray origin
lies on the wrong side of the mesh light, part of the ray could still be
lit by the other side, so the sample should not be considered invalid.

Pull Request: blender/blender#119529
which resulted in bias when self intersection is excluded in forward scattering.
Below is a comparison using principled BSDF with emission. NEE and MIS were much brighter.

Pull Request: blender/blender#119440
When appending objects from an older file, versioning needs to run to add
an auto smooth modifier if necessary. However, this was running for all
objects rather than just the newly appended objects. It's quite wrong to
modify existing objects here, so add an explicit check for that. This could
improve performance as well, but skipping checks for objects when
the work is unnecessary.

The crash will hopefully be resolved by other improvements to the auto
smooth versioning (making it properly idempotent and running it again
should fix the problem with the hidden legacy flags still set). But I still think
this PR is worth committing, to be very explicit about only modifying new
objects in versioning code.

Pull Request: blender/blender#119467
For small confirmations that appear at mouse position, change the
position slightly so that the mouse pointer is less likely to obscure
the confirm button text.

Pull Request: blender/blender#119536
This reverts commit c6497dd9f7.

This wasn't working the way I expected, it seems the LIB_TAG_NEW isn't
set here. Better to address the fundamental issues anyway. Sorry for
the noise.
Fixing memory leak reported in #119035, and crashes with old AMD
drivers and unsupported GPUs.

Pull Request: blender/blender#119538
In Preferences / Extensions / Repositories / Add, show the correct
"Internet" icon on the menu item for remote repository.

Pull Request: blender/blender#119541
Makes sure the GPv3 component doesn't show up unless the experimental
flag is set.

Pull Request: blender/blender#118915
This affect all local lights (non-sun light).

We hide the artifact caused by different tracing results from
two adjacent projection. This is visible as the shading point
switches projections.

We fix this by randomizing which shadow map projection (face)
to trace. We do that by using the point at half the ray instead
of the shading point to choose the projection. This gives
a soft enough look proportional to the light shape.
This also has the benefit of being stupidly simple.

Pull Request: blender/blender#119555
Experimental flag for "Extensions Development Utilities" that can be
enabled separately from "Extensions". Note this PR does not enable the
use of this flag (coming later) as uses are in addons-contrib. This
flag is requested in #119521

Pull Request: blender/blender#119562
Pull Request: blender/blender#119547
Excludes properties tagged as `SKIP_PRESET` from being reset.

Pull Request: blender/blender#119550
The buttons to sync and update individual repositories only work for
remote repositories. This PR just updates their poll functions to
disable them for local repos.

Pull Request: blender/blender#119568
Resolves render pass export for EEVEE Next on Metal.
Reads from texture views was previously utilising the
root texture rather than the view variant, resulting
in views into texture arrays being incorrectly sampled.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119563
Suppresses unused import warnings with "ruff check".
Pull Request: blender/blender#119577
The `IndexMask` data structure was designed to allow us to implement set
operations like `union`, `intersection` and `difference` efficiently
(2cfcb8b0b8). This patch adds an evaluator for
arbitrary expressions involving the mentioned operations. The evaluator makes
use of the design of the `IndexMask` data structure to be quite efficient.

In some common cases, the evaluator runs in constant time. So it's very fast
even if the mask contains many millions of indices. If possible the evaluator
works on entire segments at once instead of looking at the individual indices.
This results in a very low constant factor even if the evaluation time is
linear. If the evaluator has to look at the individual indices to be able to
perform the operation, it can make use of multi-threading.

The evaluation consists of the following steps:
1. A coarse evaluation that looks at entire segments at once.
2. All segments that couldn't be fully evaluated by the coarse evaluation are
   evaluated exactly by looking at the actual indices. There are two evaluators
   for this case. One that is based on `std::set_union` etc. The other one first
   converts the index masks to bit spans, then does bit operations to evaluate
   the expression, and then converts the bits back into indices. Depending on
   the expression, one or the other can be more efficient.
3. Construct an index mask from the evaluated segments.

Showing the performance of the evaluator is kind of difficult because it highly
depends on the input data. Comparing the performance to something that does not
short-circuit when there are full ranges is meaningless, because one can
construct an example where the new evaluator is arbitrarily faster. I'm still
working on a case where performance can be compared to e.g. using
`std::set_union`. This comparison is only fair when the input data when
constructing a case where the new evaluator can't short-circuit.

One of the main remaining bottlenecks are the calls to `slice_content` on large
index masks. I think the impact of those can still be reduced.

We are not using this evaluator much yet, except through `IndexMask::complement`
calls. I intend to use it when I get to refactoring the field evaluator for
geometry nodes to optimize the evaluation of selections.

Pull Request: blender/blender#117805
Not quite sure how I missed this before. It's quite unfortunate that this
causes issues like #119179 in Blender 4.0.
There is a Deadband built in the sensor of SpaceMouse,
therefore the default value of Deadzone field can be equal to 0.0
instead of 0.100.

Pull Request: blender/blender#119522
The BVH has been freed at this point, but the Metal queue sets it on
every invocation. Make sure it's null so it doesn't get used anymore.

Pull Request: blender/blender#119581
This makes it so GPv3 objects are rendered using the current grease pencil render engine.

A new `gpencil_next` engine was added at the beginning of the project, but it couldn't
be finished in time. This commit removes the `gpencil_next` engine as it is no longer
used. The current status of the new engine been pushed to the `gpencil-next` branch on
the `blender` repository.

Note: Onion skinning is not supported yet. This work will be done in a separate PR.

Fixes #115467 and #116347.

Pull Request: blender/blender#118664
A tone mapper designed specifically for PBR color accuracy, to get sRGB
colors in the output render that match as faithfully as possible the input
sRGB baseColor under gray-scale lighting. This is aimed toward product
photography use cases, where the scene is well-exposed and HDR color values
are mostly restricted to small specular highlights.

Fixes #118824: Proposal: add a view transform for Khronos PBR Neutral Tone Mapper

Co-authored-by: Emmett Lalish <elalish@google.com>
Pull Request: blender/blender#118936
If a bone was specified (but now missing), the driver would fallback to
using the object as a target (which can lead to unintended behavior).

So now check if a bone is specified, if it is missing, mark the driver
invalid. If no bone is specified at all, then use the armature object as
the target.

NOTE: `DTAR_FLAG_INVALID` is not granular enough to distinguish the
object and bone targets, so both will be marked in red in the UI (there
is already comments about it in code). If necessary, we could introduce
an additional DTAR_FLAG_BONE_INVALID and use that in a couple of places.

Pull Request: blender/blender#119533
Resolves custom attribute types for ints and booleans by ensuring
conversion mode is correct. Previously, the attribute declarations
were assumed to be linear. However, patch ensures the correct
attribute index is now fetched, ensuring the conversion mode
is correctly specified for non-linear attribute ID's.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119569
This was caused by 62bd0ea5fd. Now the socket is
always created but made unavailable if the feature is disabled.

Pull Request: blender/blender#119620
Support for having an input and output socket in the same socket declaration
builder was added for the original node panels to be able to support inline
sockets. However, those were generally disabled for now. As can be seen in the
simulation and repeat zone, inline sockets can work differently too. Having an
input and output in the same socket declaration builder builder makes some
things simpler but makes other things much harder. For example, the current
design wouldn't work all that well if the input and output socket has different
types. This is easier to do with the `align_with_previous_socket` approach.

I'm not yet entirely sure whether we want to use the same approach for
corresponding sockets in the node tree interface, but that can be tried and
decided separately.

Pull Request: blender/blender#119599
This was simply missing a check and error message. The same error message
is shown when the node group is used as modifier.

Pull Request: blender/blender#119604
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
Mixed resolution rendering had some issues with overscan and border
rendering.

- `render_offset` was in display space and not in render space. Is
  now replaced by the `overscan_extent`.
- `overscan_extent` introduced that stored the overscan of the render
  extent.
- Fixed issues to determine the film sample weight when `scaling_factor`
  was used. It didn't match decompose the actual offset making the
  length of the same to large, what blurred the final samples.

NOTE: there are some other issues related to border rendering which was
already in main before mixed resolution rendering was added. I assume
that viewport render image in camera view still adds an additional
offset, which should be ignored.

Fixes #119510
Fixes #119511

Pull Request: blender/blender#119524
Since 660867fa00, having tree-view items uncollapsed by default using
the `set_collapsed()` functions wouldn't work anymore. An attempt to do
this would assert even, so eb71d9f7bc disabled the assert.

I think a function designed to handle exactly this is the best solution,
it makes the intent & behavior more clear than before, and highlights
that this is a special case.

Mitigates #117957, in that it solves the regression, but tree-views still
don't remember their state on screen-layout changes. This is a known
limitation and not supported.

Pull Request: blender/blender#119166
This PR fixes several issues with the versioning that replaces the old
auto smooth flag with a modifier.

One issue is that the flag wasn't cleared in the initial versioning
code. That means some objects have the replacement modifier but their
meshes still have the flag set. The fix for that is to make the
versioning idempotent by trying to find an existing node group before
adding a new one. The versioning is now re-run on all objects to clear
the flags. Flags on all meshes are cleared too, even unused meshes.
That could cause loss of the auto-smooth when the mesh is linked from
a different blend-file, but that situation should be very rare.

Another issue was that the versioning wasn't run when linking objects.
That was simple to solve by adding the versioning where the proxy
versioning already existed for that case.

Finally, arguably the largest issue was that the the newly added node
groups were always added as local data-blocks. When linking, having
library data-blocks point to local data-blocks not in that library is
quite bad and breaks assumptions around Blender. This is solved by
having an auto smooth node group per library.

Resolves #119516, #119455, #119447

Pull Request: blender/blender#119539
Avoid motion blur on regular scene editing.

Pull Request: blender/blender#119484
If the bevel "Harden Normals" option is on, custom normals will be
generated. In that case, the automatic sharp edge tagging based on the
angle shouldn't run. This PR extends the earlier fix to #116395 to
handle this case and also extends the check to not just check the last
modifier, which doesn't work in this test file which has a collision
modifier at the end. That makes sense anyway, since what we really care
about is whether the evaluated mesh has custom normals or not.

Pull Request: blender/blender#119638
Add more flexibility to tooltip images by adding the ability to specify
if (one of two) checkerboards are added, border, premultiplied
blending, or recoloring.

Pull Request: blender/blender#119437
The include was removed by a cleanup in main, not in 4.1.
Also correct references source files.
Fix of wrong destination for scale and non-normalized rotation matrix.

Pull Request: blender/blender#119602
Call the install operators directly instead of using bpy.app.handlers.
Now reports from installing are in the status bar.
This became a bottleneck in one of the test files during playback.

A grease pencil object was using an array modifier which tags the triangle
caches to be invalidated. Then it re computed the fills on every frame, which
was slow (when single threaded).

With this patch, the playback went from ~43fps to 60+fps.

Pull Request: blender/blender#119531
Bring back the `INSERTKEY_XYZ_TO_RGB` enum item for the
`keyframe_insert()` function (it was removed in 30b0c5b225). This way
any Python code that targets Blender 4.x can safely pass this flag,
without having to check specific Blender versions.

Note that the flag is implemented as a no-op, as the behaviour change
introduced in 30b0c5b225 (just looking at the user preference) is still
retained. The purpose of this commit is simply to avoid the `ValueError`
exception that would otherwise be raised.

This should also fix Rigify report blender/blender-addons#105241.

Pull Request: blender/blender#119625
This error was introuced by 5e2955d3cd.
Instead of trying to use the function name
with `__func__` use a string literal.
Mistake in a96f1208cc.
When markers are present, offset should be added to the height.
Earlier it was subtracted like so `v2d->tot.ymin -= MarkerMargin` and that worked
because ymin is assigned like so `v2d->tot.ymin = -height`.
Now that the marker margin is added to the height it needs to be additive.

Pull Request: blender/blender#119647
This makes the edit mode drawing for the new curves data more similar
to the old edit mode. Specifically, it draws the evaluated curves now instead
of just a poly curve. Furthermore, it now draws bezier handles as well as
a separate control curve for nurbs curves.

Pull Request: blender/blender#119053
Fix a crash when inserting a key with tweak mode enabled, but where
`AnimData::actstrip` was NULL.

The root cause of this is that two pointers in the `AnimData` struct
(`act_track` and `actstrip`) are expected to be set when NLA tweak mode
is enabled, BUT these are not exposed to RNA and thus invisible to the
library overrides system. As such, they are NULL when loading from disk,
while the `ADT_NLA_EDIT_ON` flag still indicates they are to be used.

Rather than adding a NULL pointer check (and having to add that in many
more places), I used this two-pronged approach:

- Extend the 'NLA tweakmode' override apply code, to set the `act_track`
  and `actstrip` pointers when they are incorrectly NULL. This is done
  by lookup of the track and strip by name.
- Add versioning code to exit out of tweak mode whenever the
  `ADT_NLA_EDIT_ON` flag is set, but those two pointers are still NULL.

The last step was necessary with the example file attached to the bug
report, as that was saved with a buggy blender version. New saves work
just fine.

Pull Request: blender/blender#119632
It seems that the compiler on windows struggled to
correctly assign the namespace of the `LocalMemArena`
destructor because the struct was defined locally
in a lambda.

This moves the struct definition out of the lambda.
This was caused by 745fd2a2cb.
The issue was that there was an attempt at calling
`uncollapse_by_default` on a `LayerViewItem`
which can't be collapsed (because it can't have any children).
This then triggered the assert.

The fix removes the call to `uncollapse_by_default` for
`LayerViewItem`.
For historical reasons, the `multi_input_socket_index` was actually reversed
(large index comes first). This patch renames it to `multi_input_sort_id` and
adds a comment. This new name makes it less confusing that the id is reversed.

Pull Request: blender/blender#119652
For example, copying and moving a trivial type ends is the same.
However, currently we generate the code for both cases independently
instead of reusing the same underlying function.

This reduces the size of the Blender binary from `218.548.896` to
`218.355.552` bytes for me. So it's a reduction of about 200kb.

It's probably possible to reduce this even more, but that's for another day.
The main tricky thing here is telling the compiler that a `const` from a
function parameter can be cast away for trivial types (see code comment).
Maybe there is a better way to do this while making sure the compiler
doesn't generate unnecessary code.

Pull Request: blender/blender#119601
Caused by a96f1208cc

For `SPACE_ACTION` (`SACTCONT_ACTION`), `actedit_get_context` will
return true, but `ANIM_animdata_context_getdata` also checks the
`bAnimContext` data [which in this case is the action], so will **not**
return true.

As a result we are skipping drawing the background and the search, which
is now done again.

Pull Request: blender/blender#119621
This change reverts 14500953ed. This commit improved the performance
but introduced the regression. The wireframe shader checks the normal
buffer to detect if attributes are being rendered. The VBO contains both
positions and normals.

In Blender 4.2 this VBO was separated (#116902)and this solved the rendering. It is
to late and risky to add this separation to 4.1 in the last minute so we
decided to revert the performance improvement as it was already an issue
for several years.

The performance improvement will still be in Blender 4.2 where it doesn't
have these artifacts.

Pull Request: blender/blender#119656
This change reverts 14500953ed. This commit improved the performance
but introduced the regression. The wireframe shader checks the normal
buffer to detect if attributes are being rendered. The VBO contains both
positions and normals.

In Blender 4.2 this VBO was separated (#116902)and this solved the rendering. It is
to late and risky to add this separation to 4.1 in the last minute so we
decided to revert the performance improvement as it was already an issue
for several years.

The performance improvement will still be in Blender 4.2 where it doesn't
have these artifacts.

Pull Request: blender/blender#119656
This fix should only be committed to blender-v4.1-release branch
Blender 4.2 the pos/nor buffers are separated and doesn't lead
to drawing artifacts.

This reverts commit 02379f3200
This fix should only be committed to blender-v4.1-release branch
Blender 4.2 the pos/nor buffers are separated and doesn't lead
to drawing artifacts.

This reverts commit 02379f3200
Don't assume armature of active object is what is displayed in the properties editor, both in C++ and Python code.

Object pointer was left out from some notifiers, as this means only that object was changed. But an armature datablock can be shared by multiple objects.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: blender/blender#119663
Simplifies/optimizes the "font" shader. It runs faster now too, but primarily
this is so that it loads/initializes faster.

* Instead of doing blur via individual bilinear samples (where each sample is 4
  texel fetches), do raw texel fetches of the kernel footprint and compute final
  result by shifting the kernel weights according to bilinear fraction weight.
  For 5x5 blur, this reduces number of texel fetches from 64 down to 36.
* Instead of checking "is the texel inside the glyph box? if so, then fetch it",
  first fetch it, and then set result to zero if it was outside. Simplifies the
  branching code flow in the compiled GPU shader.
* Avoid costly integer modulo/division for "unwrapping" the font texture. The
  texture width is always power of two size, so division/modulo can be replaced
  by masking and a shift. Setup uniforms to contain the needed data.

### Fixes

* The 3x3 blur was not doing a 3x3 blur, due to a copy-pasta typo (one of the
  sample offsets was repeated twice, and thus another sample offset was
  missing).
* Blur towards left/top edges of the glyphs had artifacts, because float->int
  casting in GLSL rounds towards zero, but the code actually wanted to round
  towards floor.

Image of how the blur has changed in the PR.

### First time initialization

* Windows 10, NVIDIA RTX 3080Ti, OpenGL: 274.4ms -> 51.3ms
* macOS, Apple M1 Max, Metal: 456ms -> 289ms (this is including PSO creation
  time).

### Shader performance/complexity

Performance I only measured on macOS (M1 Max), by making a BLF text that is
scaled up to cover most of screen via Python. Using Xcode Metal profiler,
drawing that text with 5x5 shadow blur: 1.5ms -> 0.3ms.

More performance analysis details in PR.

Pull Request: blender/blender#119653
".sculpt_mask" is handled as a special case for dynamic topology
but wasn't detected that way in the warning.

Pull Request: blender/blender#119665
The change in 23ebc45f70 was slightly incorrect.
This file is generated by the attribution builder for every release
and it's up to the release team to check the log for extern and others to make sure this is up to date.
Same as fd92647f34.
Without this check, the function would try to create a new
attribute even if `num` was 0.
This PR limits adding the RNA property `use_limit_to_segment`
to `ShapeType::Line` based sculpt gesture operators, as the
property is inapplicable for the other two types.

Pull Request: blender/blender#119670
Ensure depsgraph tag happens when strokes are cleared, otherwise the
next depsgraph evaluation tries to use freed stroke data.

Pull Request: blender/blender#119662
This uses parallel reduction when doing the octahedral map re-mapping.

The goal is not the speedup but the accuracy of the computation (temporal
stability) and to pave the way for sunlight extraction.

This weight each individual samples using texel solid angle for correct
energy.

After optimization, the cost is not so expensive (1024px² octahedral map):
- new: 263µs remap + 12µs sum
- old: 75µs remap + 180µs irradiance update

We could optimize it more, but that feels unecessary given that the first
two filter pass are 7ms and a more pressing optimization.

The old irradiance update was fast because it was using the mip2 which
was already pre-filtered and using way less pixels (which already yield a
temporally stable output).

This new implementation does consider all pixel in the LOD0 which will
allow for more precise sunlight extraction.

This also comes with a cleanup of the update tagging.

Pull Request: blender/blender#119537
Using the existing OIDN_DEVICE_HIP, don't overwrite it if it was
already set.

Ref #115045

Pull Request: blender/blender#119672
Pull Request: blender/blender#119331
This improves performance by **reducing** the amounts of threads used for tasks
which require a high memory bandwidth.

This works because the underlying hardware has a certain maximum memory
bandwidth. If that is used up by a few threads already, any additional threads
wanting to use a lot of memory will just cause more contention which actually
slows things down. By reducing the number of threads that can perform certain
tasks, the remaining threads are also not locked up doing work that they can't
do efficiently. It's best if there is enough scheduled work so that these tasks
can do more compute intensive tasks instead.

To use this new functionality, one has to put the parallel code in question into
a `threading::memory_bandwidth_bound_task(...)` block. Additionally, one also
has to provide a (very) rough approximation for how many bytes are accessed. If
the number is low, the number of threads shouldn't be reduced because it's
likely that all touched memory can be in L3 cache which generally has a much
higher bandwidth than main memory.

The exact number of threads that are allowed to do bandwidth bound tasks at the
same time is generally highly context and hardware dependent. It's also not
really possible to measure reliably because it depends on so many static and
dynamic factors. The thread count is now hardcoded to 8. It seems that this many
threads are easily capable of maxing out the bandwidth capacity.

With this technique I can measure surprisingly good performance improvements:
* Generating a 3000x3000 grid: 133ms -> 103ms.
* Generating a mesh line with 100'000'000 vertices: 212ms -> 189ms.
* Realize mesh instances resulting in ~27'000'000 vertices: 460ms -> 305ms.

In all of these cases, only 8 instead of 24 threads are used. The remaining
threads are idle in these cases, but they could do other work if available.

Pull Request: blender/blender#118939
Buttons for mesh symmetry on the toolbar, and other buttons of the same
functionality located in other areas of the window, weren't updated when
clicking on them.

Pull Request: blender/blender#118508
For spherical spot light, when the shading point is close to the light
source, we switch to sampling the light spread instead of the visible
cone from the shading point. This has the benefit of less noise when the
spread is small.
However, the light spread sampling was not considering non-uniform
object scaling, where the actual spread might be different.
This patch switches sampling method only when the smallest enclosing
spread cone is smaller than the visible cone from the shading point.

An alternative method would be to compute the actual solid angle of the
scaled cone, and sample from the scaled cone. However, that involves
ray transformation and modifying the sampling pdf and angle. Since
non-uniform scaling is rather a niche case, it's probably not worth the
computation effort.

Pull Request: blender/blender#119661
This adds the approximation of phase function convolution
of the distant lighting captured inside probe volumes.

This is based on a publication at siggraph from Bartlomiej Wronsky
"Volumetric Fog: Unified compute shader based solution to
atmospheric scattering"

Implementation is quite straightforward. However this isn't as
good as one can expect as there isn't self shadowing from the
volume themself, so the lighting is still quite flat.

To fix this, we have to add support for volumetrics inside
probe volumes baking. But this approach would still be static
so a more general solution is still to be found for dynamic
volumes like smoke simulations.

Pull Request: blender/blender#119479
This uses Spherical Harmonics to store the indirect lighting and
distant lighting visibility.

We can then reuse this information for each closure which divide
the cost of it by 2 or 3 in many cases, doing the scanning once.

The storage cost is higher than previous method, so we split the
resolution scaling to be independant of raytracing.

The spatial filtering has been split to its own pass for performance
reason. Upsampling now only uses 4 bilinearly interpolated samples
(instead of 9) using bilateral weights to avoid bleeding.

This also add a missing dot product (which soften the lighting
around corners) and fixes the blocky artifacts seen at lower
resolution.

Pull Request: blender/blender#118924
Converting a color attribute to a non-color domain or type causes vertex
paint mode to try to change the attribute even though it's unsupported.
That leads to a crash here and unpredictable behavior elsewhere.

This PR modifies some poll functions to check for the proper domain and
data type before continuing. Even if converting an attribute properly
updates the active color attribute, we can still run into situations where
the active name references an attribute with incorrect metadata.

Pull Request: blender/blender#119657
* Extract function for building anonymous attribute references.
* Use is-function-node state directly during building instead of during finalization.

Pull Request: blender/blender#119677
Use more standard _num suffix and standard mesh variable names.
Try to add a bit more clarity and use more consistent wording.
Add notifier when changing sculpt voxel size so that the new value is
shown in the sidebar.

Pull Request: blender/blender#119646
This PR converts the three `enum` definitions to `enum class` in sculpt_trim.cc

Pull Request: blender/blender#119679
Not quite a 1:1 match, some customizations have to be made for the API URL differences and the face that there are no translations.

This also enables the version switch publicly now that this change fixes a few bugs.
The wrong persistent attribute was set when disabling an add-on,
also correct the message when disabling an already disabled add-on.
This PR strips the `sculpt_gesture_trim` prefix and other similar
prefixes from the `sculpt_trim.cc` code, as it is already contained
within the `blender::ed::sculpt_paint::trim` namespace.

Pull Request: blender/blender#119680
The list identifier includes the class name and an list_id,
see: WM_uilisttype_to_full_list_id

This requires using UI_MAX_NAME_STR (as noted in doc-string).
- Prefix comments before members is used practically everywhere,
  remove C99 syntax from inside comments.
- Replace double quotes with backticks for code styling.
Since [0] some comments referencing UI_MAX_NAME_STR were incorrect.
Also correct buffer size for preview_id in uiTemplatePreview so newly
created names are guarantee to be the correct size.

[0]: a180314ac5
Ref !119521
UI would sometimes disappear with the Metal backend.
This occured in situations where there was only a single
GPUContext within a single GHOST window, meaning
the activation routine for the context was never run.

Context activation is required to ensure the backbuffer
was up to date upon resize. Otherwise, re-sizing the
window would cause the screen to turn grey as the
new drawables would not be rendered to.

Authored by Apple: Michael Parkin-White

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: blender/blender#119299
Those shouldn't really exist at all currently, since we forbid them in 354915cf3c.
Unfortunately, not all cases were removed, and many node trees with such sockets
have been created during the development of 4.1 due to the auto-smooth changes.

I'm not entirely sure if it's still possible to properly remove them now. The commit
above mentions that we might lose links due to changed identifiers. Maybe we're
better off just supporting these inlined sockets while also allowing the "align with
previous socket" functionality.

Either way, not creating more of such node trees for now is reasonable, since we
explicitly disabled that functionality for now.

Pull Request: blender/blender#119654
Previously, we haven't added this because there were plans to use these
declarations at a higher abstraction level where one declaration potentially
contains more than one socket. This hasn't happened yet, and we are also using
other ways to achieve dynamic socket amounts (using dynamic declarations).
Therefore, it is reasonable to simplify the code by storing the integer socket
type in the declaration directly.

Pull Request: blender/blender#119691
Since there is no special case for drawing redo panel, this callback is
not required. Panel will be generated automatically because `undo` and `register`
flags are added to operator.
This improves alignment in redo panel.

Pull Request: blender/blender#119494
Reimplemented build modifier using the new `CurvesGeometry` logic.

Pull Request: blender/blender#118739
Initializing the uid of the geom nodes modifier created
by the point instancer reader to prevent an assertion failure
(in a call to to BKE_modifiers_persistent_uids_are_valid())
when reading any USD point instancers in debug builds.

Pull Request: blender/blender#119683
Add a null pointer check around CPU processor, matching the rest of the
processor access.

This solves crash in cases when the OCIO configuration exists but is
invalid: i.e. by removing a lookup table. It could lead to an invalid
render result, but is better than a crash.

The original issue with running Blender from within .zip archive might
still need investigation, as there might be a way to make it work.

Pull Request: blender/blender#119693
The code tried to retrieve the bounds from the data
synced back to the original object at the end of depsgraph
evaluation. That data is only set on original objects.

Instead just retrieve the bounds directly from the evaluated
object. Also make two variables const now that it's possible.

Pull Request: blender/blender#119674
Resolves an issue with stroke rendering in
Metal using the geometry shader fallback
path. Stroke rendering now matches OpenGL
which should enable the GPencil fill tool to
function correctly at all zoom levels.

Authored by Apple: Michael Parkin-White

Pull Request: blender/blender#119660
Allow the user to scale shadow-map resolution per-light.
Adapt the PCF scale based on shadow-map to pixel footprint ratio,
since we can no longer assume that higher LODs don't need filtering.
This allows using much lower shadow resolutions, which can yield
quite significant performance improvements, with relatively little
perceptual quality loss (at the cost of softening shadow edges).
The per-light resolution scale is a literal scale, so for example 0.5
means half the resolution. The Scene Simplify Shadows setting has
been updated to match this behavior.

Pull Request: blender/blender#119436
Smooth transparent shadows by jittering their opacity threshold every
sample.
Always enabled on final renders, optionally enabled in the viewport with
`scene.eevee.shadow_jittered_transparency`.

Pull Request: blender/blender#119480
Also restore a fix that was lost in the merge commit from 4.1.
Replace the hashed alpha function in shadows for a fully random one.
Add pcg functions to `gpu_shader_common_hash.glsl`
(Split from #119480)

Pull Request: blender/blender#119526
The issue was caused by 29aaa2922d.

With the change from the offended commit there was nothing that
would have informed objects previously linked to a light that they
need to re-calculate their light linking collections.

This change makes it so scene's hierarchy is tagged for update,
which propagates to all dependencies which do depend on hierarchy
of objects and collections in the scene.

This brings behavior closer to what it used to be, without causing
slowdown with full re-evaluation (which was fixed by the offending
commit).

Pull Request: blender/blender#119698
seems to be enabled on other GPUs already

Pull Request: blender/blender#119701
File Browser listings can clip content, remove columns, etc as the
available space narrows. This PR just makes this never happen for
the horizontal display mode, where files are shown in multiple columns,
as this is not applicable.

Pull Request: blender/blender#119673
Missing from #119436
Compilation errors after #119436

Pull Request: blender/blender#119709
Since moving from the Wiki we have used the `sphinx_rtd_theme` which has worked well but has become a little dated and has had slow development. This changes to use "Furo" instead.

[Furo](https://github.com/pradyunsg/furo) is a lightweight theme that is responsive and has native dark mode support.

Dark mode is one of the major enhancements but this change also brings:

- Content is slightly larger making text and images easier to view
- Site navigation and page navigation is split into two navigation trees. The site navigation is on the left and page on the right if the page has multiple headings.
- Return to top button
- Content is centered on the screen which helps with wide monitors
- No more breadcrumbs
- Remove google analytics

So far the caveat that I have noticed with this is slower compile times and larger pages, this is due to the better sidebar navigation.

This change also brings a lot of simplifications to customizations that we made to the `sphinx_rtd_theme`. There is still likely room for improvement in the future.

Pull Request: #119684
Not quite a 1:1 match, some customizations have to be made for the API URL differences and the face that there are no translations.

This also enables the version switch publicly now that this change fixes a few bugs.
Because sphinx-basic-ng does not have an official release on BYPI, pip could not satisfy the dependency.
When the edit mesh modifier stack first deforms the original edit mesh,
it creates deformed positions in a separate array. That array is copied
to the mesh's vertex positions if a subsequent modifier requires an
actual mesh rather than a mesh wrapper.

However, if that last deform modifier is the last "on cage" modifier
and the next modifier requires a real Mesh, we hit a code path that
didn't copy the temporary position array, since it was contained in the
separate `EditMeshData` struct that must be handled manually.

This was a regression in 91b27ab637. In the future I hope to
make this simpler by expanding the use of implicit sharing and making
the conversion from original BMesh to a Mesh more lazy / const correct.

Pull Request: blender/blender#119718
While this isn't an error avoid ambiguity for recursive deletion
as it's not meaningful to delete a file.
GPv3 uses `OB_MODE_EDIT` so it falsely shows empty mesh data in stats.
This worked in legacy gp because it had special edit_mode type.
To show correct grease pencil data in edit mode, rearrange if conditions and
add special check for `OB_GREASE_PENCIL`

Pull Request: blender/blender#119689
Even though there is a dialog users must accept when removing a
repository & directory being removed is shown, it's possible users
assume this only removes files which are part of the repository after
pointing the custom-directory to their home directory or similar.

Removing repositories which point to a custom-directory now only
remove packages and server meta-data to prevent accidents.

Resolves #119481.
In general it's best practice to forward events when available.
In these cases, the Mesh is defined as an instance of the object.
These instances need to be ignored when in edit mode.
Although this error isn't specific to extensions, extensions containing
a blender_manifest.toml but no __init__.py would import a module
with the __file__ set to None.
While there is logic to handle this case, it didn't account for modules
already in sys.modules with __file__ set to None.

From a user perspective enabling the extension silently failed raising
an error on the second attempt to enable.
When loading an add-on without a __file__ set the "cause" was empty.

Now the modules __path__ is included (when available) which points
to the path that failed to load to help with troubleshooting.
Failure to import the module would print a message but not show
any feedback to the user - failing silently.
The full stack-trace is mainly useful to developers which is printed
to the console. Only include a single exception in the error report.
It's not necessary to check for `points.size() >= 3` since the extra
point space is always added thus the point should always be filled with
valid attribute to avoid erroneous "closing stroke".

Pull Request: blender/blender#119727
Enables operators that uses `WM_operator_props_dialog_popup`
or `redo` popup to use layout panels.

Other popups would likely also support layout panels, only
they need to set its dummy panel with `UI_popup_dummy_panel_set`.
Popups don't normally use `Panel`, but that's the type that stores the
layout panel states. Therefore, to use layout panels in a popup, one
currently needs to create a dummy panel whose purpose is to store the
layout panel states for as long as the popup is open.

Alternatively, we could potentially also store the layout panel states
somewhere else in the future for popups, but that might be a more involved
change for now.

See #119519 for an example script that uses layout panels in a popup.

Pull Request: blender/blender#119519
This patch adds a step function that is equivalent to the GLSL step
function to the BLI math library.

Needed by #119414.

Pull Request: blender/blender#119731
The `bounds` is `nullopt` when the number of points is 0 at current frame.
The fix uses `value_or()` to make sure we get some bounds.
Also uses `Bounds<float3>` instead of `std::optional<Bounds<float3>>`
in `gpencil_object_cache_add`.

Pull Request: blender/blender#119690
The Volume input of the world didn't show up inside the property panel.
Reason was that the panel didn't have EEVEE-Next inside its list of compatible
engines.

Pull Request: blender/blender#119729
No functional changes.

The `BeztMap` struct is used when sorting Keyframes during transformations
in the Graph Editor.

Things that were changed:
* Removed unneeded `newIndex`. This was just the index of the
`BeztMap` in the array, which we already have since we iterate with a for loop.
* Access the `BezTriple` array by index instead of pointer offsets.
This makes it a bit easier to see what's happening.
* Renamed struct members to clarify their use.
* Remove forward declaration of certain variables (e.g. loop counter vars)

Pull Request: blender/blender#119733
Caused by 98bf7a8d7a / ff7b8f3412

Since the `curve_weights` array was created uninitialized, and the above
commits were doing `math::max_inplace` on the uninitialized data, this
could end up with garbage values.

Now initialize the array properly to prevent this.

Pull Request: blender/blender#119730
Curves cage overlay for sculpt mode restored to prior #119053 state.

Pull Request: blender/blender#119717
This patch adds clamped boundaries variants of the nearest interpolation
functions in the BLI module. The naming convention used by the bilinear
functions were followed.

Needed by #119414.

Pull Request: blender/blender#119732
Before this PR the sorting function would receive all FCurves from
the `anim_data` ListBase and sort them + recalculate the handles.

Considering we are already checking
IF an `FCurve` needs sorting we might as well use
that and limit the sorting to FCurves that actually need it.
Doing that gives the following performance uplift.

| - | Before | After |
| - | - | - |
| Moving 1 key only | 109ms | 0.72ms |
| Moving 1 key of each FCurve | ~2000ms | ~2000ms |

Pull Request: blender/blender#119735
David-Haver closed this pull request 2024-03-21 15:57:33 +01:00
Arye Ramaty referenced this issue from a commit 2024-04-30 15:14:33 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 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: aryeramaty/blender#3
No description provided.