This uses the path that metal was using.
This doesn't seems to create any difference in render
tests. This simplify the backend code and avoid
specific path for metal.
Idea suggested by Kevin Chuang
Pull Request: https://projects.blender.org/blender/blender/pulls/127687
Parallel shader compilation introduced `GPU_shader_cache_dir_clear_old`.
The implementation was specific to OpenGL and could not be overwritten
by other backends. This PR improves the implementation so the backend
can have its own implementation.
This is needed for upcoming changes to the Vulkan backend where we
want to use similar mechanisms to speed up shader compilation and caching.
Pull Request: https://projects.blender.org/blender/blender/pulls/127680
Majority of math operations on VecBase<> were implemented by calling into an
indexing operator, sometimes coupled with unroll<Size> template.
When compiler optimizations are off (e.g. Debug build), or when asserts are on
(e.g. usual "developer" setup), this resulted in codegen that is very
sub-optimal. Especially if these vector types are used a lot, e.g. when
scaling down a screenshot for saving as a thumbnail into the blend file.
Address that by explicit code paths for 4,3,2 dimensional vectors, that
avoids both the unroll<> template and indexing operator. To avoid repeated long
typo-prone code, do that with C preprocessor :( -- however all of the
preprocessor innards are in a separate file BLI_math_vector_unroll.hh so they
do not get into the way much.
Scaling down a screenshot to the blend file thumbnail, while saving the blend
file, on my machine: (4K screen resolution, Ryzen 5950X, VS2022 build), which
involves two calls to IMB_scale which uses float4 for pixel operations:
- Release with asserts off (what ships to users): no change at 9.4ms
- Release with asserts on ("developer" setup): 38.1ms -> 9.4ms
- Debug: 226ms -> 64ms
- Debug w/ ASAN: 314ms -> 78ms
Pull Request: https://projects.blender.org/blender/blender/pulls/127577
Part of blender/blender!125449.
Since brush assets were merged, the brush asset selector and some other brush
UIs wouldn't show up for the primitive tools. This is addressed now. The
primitive tools use the same brush as the brush tool, although only the draw
brushes will work properly. !125449 addresses this so the primitive tools
remember their own draw brush, separate from the brush tool.
Turns out that these primitive tools were never tagged as using brushes by
setting the `data_block` member (or setting the `'USE_BRUSHES'` option since
b64bf66257). The UI was just hardcoded to display things like the brush selector
for primitive tools. So as far as the tool system knew, these tools did not use
brushes.
Tagging the tools properly exposed some issues that are addressed here (see PR
for details).
Pull Request: https://projects.blender.org/blender/blender/pulls/127204
The previous way of considering tools with the `data_block` member set
as using brushes was rather unclear/confusing, but also a bit outdated
with the brush assets changes. Since then most sculpt/paint modes use a
unified brush tool, there was no tool for every brush type (aka brush
tool) anymore. So now the `data_block` member was just set dynamically to
match the active brush type which is otherwise irrelevant to the tool
system now.
Further, this will become important to bring back some of the tools that
use brushes in grease pencil draw mode, see #116337. For that we want to
keep the unified brush tool, but still allow other tools that only use a
specific brush type. So marking a tool as using brushes should be done
separately from indicating a specific brush type.
Removing/replacing the `data_block` member should happen separately
still, pending further developments (e.g. see #125449).
Pull Request: https://projects.blender.org/blender/blender/pulls/125911
Previously, we only measured the execution time of built-in nodes. To get
execution times of node groups, the time of each nested node was accumulated.
This can lead to very bad accuracy when multiple nodes are evaluated at the same
time.
With this patch, we measure the time spend in each compute context more directly
instead of relying on accumulating many small measurements. This also opens up
some potential optimization opportunities, because we can skip measuring the
time for contexts that we don't care about. However, that is not implemented
yet.
The time shown in the UI can still be misleading when many things are going on
at the same time, but it should at least be more accurate in more situations
now.
Pull Request: https://projects.blender.org/blender/blender/pulls/127658
It was possible for a Grease Pencil object to have a material
with no Grease Pencil settings. This can lead to crashes in many
places because it's often assumed that the material has
these settings.
The fix makes sure that `BKE_object_material_get` returns
a Grease Pencil material when called on a Grease Pencil
object. If the Grease Pencil settings don't exist,
it returns `nullptr`.
In the future, it should be possible to have these materials
and code that reads from the settings should fall back to
the default material.
Pull Request: https://projects.blender.org/blender/blender/pulls/127570
Saving files could take ~3-4 seconds on debug builds because of new
imbuf scaling logic.
Even though debug performance usually isn't much of a consideration,
it gets in the way of development.
Since thumbnails don't require the same accuracy as the sequencer or
compositor, use a faster scaling method that uses a box-filter clamped
to integer bounds & integer math.
In practice the difference between the resulting thumbnails isn't
noticeable in my tests.
For debug build with ASAN this gives a ~25x speedup,
for release builds it gives a ~1.4x speedup which is to be
expected with a more approximate scaling method.
Avoid a division by zero when the Action constraint has the same value
for its 'min' and 'max' parameters.
When `min` and `max` are equal, the code will now choose either `min`
(when `target value` ≤ `min`) or max (`target value` > `max`).
Pull Request: https://projects.blender.org/blender/blender/pulls/127583
Caused by using a function behind an experimental feature `ifdef`
in non-experimental code. The fix is to move the function out from
behind the `ifdef`, since it's perfectly fine to use in non-experimental
code.
Documentation of the `gpu.state.active_framebuffer_get` is inconsistent.
It mentions `framebuffer_active_get`. I believe the cause is that the
C methods in the Python wrapper are named inconsistently.
This PR fixes this by making the wrapper + documentation consistent
with the top level API.
Pull Request: https://projects.blender.org/blender/blender/pulls/127677
To avoid unnecessary looping over listbase items the function
`BLI_listbase_count_at_most` was used however it resulting in an awkward
expression: `BLI_listbase_count_at_most(list, count + 1) == count`
replace this with `BLI_listbase_count_is_equal_to(list, count)`.
Replace uses of WM_window_native_pixel_x,y with
WM_window_native_pixel_size() which returns an int2 for convenience
and avoids an unnecessary call to GHOST_GetNativePixelSize(..).
Part of #118145.
Even though BMesh face set functionality does not currently work, there
are some reasonable assumptions we can make about the needed parameters
for some APIs.
This commit changes the signature for relevant unique face set functions
so that future changes are easier when / if face sets are fully
supported within BMesh.
Pull Request: https://projects.blender.org/blender/blender/pulls/127640
This PR has very slight corrections to text cursor placement in input
widgets. The most important is a check for the situation where the
right edge of the current character can be greater than the left edge
of the next character. This can happen for some thin characters before
a space. Otherwise the code assumes RTL direction and gives an
incorrect placement. This also slightly tightens the position when at
the start of string, just after a space, or at end of the string.
Pull Request: https://projects.blender.org/blender/blender/pulls/127662
BKE_id_copy_in_lib took an argument `r_newid` which was was to
initialize `new_id` in the functions body.
While this may not have caused any user visible bugs, it's error prone,
one caller even passed in an uninitialized pointer.
- Rename `r_newid` to `new_id_p` since it's not a return argument.
- Initialize the value from all callers.
The tricky thing here is that this graph is only generated while geometry nodes
is evaluated and is generally only stored temporarily. To make it accessible via
Python, the accessor method will cause a reevaluation specifically to log the
generated graph.
This can run into problems with missing task isolation
when thread local variables are used in iteration over nodes.
It's likely to just add overhead anyway; there should be enough
parallelism coming from the number of nodes anyway.
Updating attributes is now done specifically for each attribute,
and topology and visibility updates tag the draw cache data
explicitly too. That makes checking for updates with these
tags unnecessary.