Previously BPY_python_end wasn't called when scripts called sys.exit()
because BPY_python_end exited the Python interpreter.
Change this behavior to call BPY_python_end without exiting the Python
interpreter while freeing Blender/Python data.
While leaks in the context of sys.exit aren't especially important
it's generally preferable for sys.exit() to match Blender's code-paths
for exiting to avoid unexpected behavior.
Some of the comments for exiting were outdated & vague.
Add additional comments to clarify out SystemExit, sys.exit() & atexit
are used to handle exit requests from Python within Blender.
The pose mode 'Select Grouped' operator can now select by bone color.
This compares either the theme palette index, or the full custom color.
In other words, if custom colors are visually very similar but binary
not equal, they will be treated as different.
The last bytes of the custom colors (so `solid[3]`, `active[3]`, and
`selected[3]`) aren't used for these comparisons, as the values are
inconsistently either 0 or 255 depending on how the color was set. There
is no way to influence this with the color picker in the GUI, and AFAIK
the alpha channel isn't used for drawing either.
Add 'Bone Collection' to the 'Select Grouped' operator in pose mode.
This removes the 'Same Layer' option, and replaces it with 'Same Bone
Collection'. It selects all the bones that are in the same collections
as the active bone.
When there are multiple armatures in pose mode, the bone collections are
matched by name.
Loop cut operator should only require OpenGL in interactive mode, this
makes it possible to run background python script calling the operator.
Thanks for the help from Campbell Barton (@ideasman42)
Pull Request: https://projects.blender.org/blender/blender/pulls/112121
The "(de)select bones in collection" operators only change the selection
state on the pose (when in pose mode), and thus should be able to work
even when the armature (which contains the bone collections) is read-only.
Simplify the "(de)select bones in collection" operators by removing their
'name' property. They now only operate on the active bone collection. This
means the poll function can be more specific, making the enabled/disabled
state of the buttons more sensible.
Make it possible to select bone collections in the UI, even when the
Armature is linked & not overridden. This opens up the possibility of
(de)selecting bones via read-only bone collections.
Remove the Ctrl+G shortcut (remnant of the bone group assignment operator),
and change the 'Pose / Bone Collections' menu so that it handles linked
and overridden data properly. Shift+M now shows that menu too.
Non-matching calls to PyErr_Fetch/Restore cause a leak in v3.12,
so ensure calls are symmetrical or avoid where possible.
Simplify extraction of the exception buffer.
- Only overwrite the stderr (the stdio isn't used).
- Simplify pyc_exception_buffer_handle_system_exit usage.
- Remove goto's.
Also simplify calling conventions for PyC_ExceptionBuffer functions.
- They must be called when an error has occurred.
- Always return a string, never null since a null return value would
only happened in rare/unexpected cases which wasn't being checked
for by some callers, leading to potential crashes.
The internals of PyErr_Print/PyErr_Display & the traceback module
are different enough that it's not likely the Python traceback
implementation will be used.
Array textures stores the array length inside the size of the image. In
vulkan the size mustn't contain the array length, but it should be set
as a separate parameter. This logic wasn't implemented when updating
the mipmap chain.
Patch also includes some smaller fixes where textures would not yet be
allocated on the device, but was expected to be.
Pull Request: https://projects.blender.org/blender/blender/pulls/112518
Uniform buffers can have data provided during construction, or as
attached data. Attached data should be uploaded during bind.
This PR implements `GPU_uniformbuf_create_from_list`.
Pull Request: https://projects.blender.org/blender/blender/pulls/112517
Resources can still be in use inside the vulkan command queue, when
they are destroyed. Especially as Vulkan doesn't allow resetting
bindings to nothing.
This PR will collect the resources that needs to be destroyed inside
the VKDevice and actually destroy the resources when on frame end.
The resources currently include:
* VkBuffer
* VkImage
* VkImageView
* VkFramebuffer
* VkRenderPass
Pull Request: https://projects.blender.org/blender/blender/pulls/112514
Previous implemetation had some limitations that were not working
for complex shaders. This limitations included:
* All bindings should be bound to a location < 16.
* Collision could happen when image locations where read that
overlapped with the texture locations.
This PR replaces the fixed binding locations with a dynamic vector.
When allocating locations for images the image offset is determined
that it is always clear if the requested locations is already
offsetted or not. This is done by ensuring the offset to larger than
the max slot of samplers, but also of image slots.
When using Eevee-next materials the slot numbers can be very high
as the location of the first material texture is set to
`GPU_max_textures_frag()` On current NVIDIA drivers this number is
set to 1K. Images are stored after the textures slots upwards.
In the future driver could set this to MAX_INT which will not work
with the new implementation. This isn't the case at this moment
and perhaps also not realistic. We don't check for this situation yet.
Pull Request: https://projects.blender.org/blender/blender/pulls/112511
A mistake in some of the previous refactor which was aimed to make the
byte buffer to be stored as uint8_t. One of the array size calculation
was missing multiplication by 4 channels.
Pull Request: https://projects.blender.org/blender/blender/pulls/112508
Add bone collections to the outliner, underneath the Armature.
This basically follows the same approach as the bone groups (which were
removed from the outliner in the previous commit).
Bone groups have been replaced by bone collections. The data in DNA is
there just for versioning & forward compatibility, so the UI elements are
being removed from Blender 4.0.
The NDEBUG is a toggle define, and in debug builds it is not defined.
This change solves the warning
mtl_context.mm:2282:5: warning: 'NDEBUG' is not defined, evaluates to 0 [-Wundef]
Pull Request: https://projects.blender.org/blender/blender/pulls/112504
srna_from_self had logic to replace the exception unless there was
already an exception set. This logic isn't needed, except in some
disabled code which has been updated. If srna_from_self ran with an
exception set it would leak memory in Python 3.12.
This makes it clearer other "safe" functions should be used in
combination with the resulting offsets.
Also correct doc-string which wasn't updated from the "or_error()"
version of this function.
- rna_Event_unicode_length would return -1 if utf8_buf wasn't a valid
unicode sequence, while this shouldn't happen, assert and return zero
instead of returning a bad length.
- Move comment on wmEvent::utf8_buf null termination to a doc-string.
The functions used to calculate the UTF8 code-points already used the
safe versions (count_utf8_code_points & BLI_str_utf8_as_unicode_step).
So it makes sense to use safe accessors elsewhere too.
There were enough cases of callers ignoring a potential the error value,
using the column width for e.g. to calculate pixel sizes, or the size in
bytes to calculate buffer offsets.
Since text fields & labels can include characters that return an error
from BLI_str_utf8_as_unicode, add the suffix to make this explicit.
- Moving the cursor to the beginning/end of the line didn't work
with word-wrap enabled.
- Moving the cursor up/down without word-wrap enabled
didn't maintain the column.
Resolve using column conversion functions with tab support.
The cursor & selection weren't updated after converting between tabs
& spaces, meaning they could be invalid (in the middle of a UTF8 byte
sequence or out of bounds).
Resolve by storing the column and restoring it afterwards.
Strings that include Latin1 encoding or corrupt UTF8 byte sequences
could read past the buffer bounds (stepping over the null terminator).
Resolve by passing in the string length.
Other changes to support non-UTF8 byte sequences:
- BLI_str_utf8_offset_{to/from}_index were accumulating
the UTF8 offset without accounting for non-UTF8 characters
which could cause a buffer underflow or enter an eternal loop.
- BLI_str_utf8_offset_to_index would read past the buffer bounds if the
offset passed in if it was in the middle of a UTF8 byte sequence.
Since 34b4487844, attributes are always made mutable when
accessed from the RNA API. This can result in unnecessary copies, which
increases memory usage and reduces performance.
Cycles is the only user of the C++ RNA API, which we'd like to remove
in the future since it doesn't really make sense in the big picture.
Hydra is now a better alternative for external render engines.
To start that change and fix the unnecessary copies, this commit
moves to use Blender headers directly for accessing attribute and
other geometry data. This also removes the few places that still had
overhead from the RNA API after the changes ([0]) in 3.6. In a simple
test with a large grid, I observed a 1.76x performance improvement,
from 1.04 to 0.59 seconds to extract the mesh data to Cycles.
[0]: https://wiki.blender.org/wiki/Reference/Release_Notes/3.6/Cycles#Performance
Pull Request: https://projects.blender.org/blender/blender/pulls/112306
The main goal of this refactor is to simplify how a geometry node group is executed.
Previously, there was duplicated logic that turned the lazy-function graph of a node
group into a single lazy-function. Now this is done only in one place and others can
just execute the lazy-function directly, without having to worry about the underlying graph.
Pull Request: https://projects.blender.org/blender/blender/pulls/112482