Commit Graph

117289 Commits

Author SHA1 Message Date
Clément Foucault
e90a84469f EEVEE: Simplify barycentric_distances_get
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
2024-09-16 14:19:53 +02:00
Jeroen Bakker
a407186dbf GPU: Make shader cache clearing backend independent
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
2024-09-16 14:03:14 +02:00
Aras Pranckevicius
806b0e8379 BLI: improve 2/3/4d vector codegen for debug or asserts-enabled builds
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
2024-09-16 13:06:16 +02:00
Julian Eisel
65fdb3fa30 Grease Pencil: Properly support brushes with draw mode primitive tools
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
2024-09-16 13:04:08 +02:00
Sybren A. Stüvel
c64108305e Cleanup: avoid unused parameter warning in non-experimental build
Avoid warnings about unused parameter `slot_handle` when building without
experimental features.

No functional changes.
2024-09-16 12:30:55 +02:00
Julian Eisel
b64bf66257 Refactor: Tools: Change how tools are marked as using brushes
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
2024-09-16 12:20:25 +02:00
Jacques Lucke
8af75d2fcc Geometry Nodes: improve node timings accuracy
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
2024-09-16 12:07:52 +02:00
Falk David
cb0ab83eab Fix #127527: Crash drawing with non-GP material
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
2024-09-16 12:03:05 +02:00
Campbell Barton
4ec0cce30a WM: improve thumbnail scaling performance (debug builds)
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.
2024-09-16 19:51:32 +10:00
Sybren A. Stüvel
9530852347 Anim: avoid division by zero in Action constraint
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
2024-09-16 11:49:54 +02:00
Clément Foucault
019bc5127a Overlay-Next: Xray Outline
Port the outline wire prepass shader to primitive
expansion API and enable it for xray mode.

Rel #102179

Pull Request: https://projects.blender.org/blender/blender/pulls/127657
2024-09-16 11:24:40 +02:00
Clément Foucault
11b07cf309 Overlay-Next: Motion Path
Rel #102179

Fixes discrepancies on Mac.

Pull Request: https://projects.blender.org/blender/blender/pulls/127623
2024-09-16 11:22:54 +02:00
Nathan Vegdahl
68a6317207 Fix: build fails when experimental features are disabled
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.
2024-09-16 11:01:54 +02:00
Jeroen Bakker
0311d8082b Fix #127636: Inconsistent GPU module doc
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
2024-09-16 09:51:04 +02:00
Campbell Barton
f392d9edad Cleanup: use int2 for WMInitStruct & screen size accessors 2024-09-16 12:40:07 +10:00
Hans Goudey
a0eccb4550 Cleanup: Multires: Use FunctionRef and lambdas in reshape 2024-09-15 22:01:13 -04:00
Hans Goudey
aba29c655a Cleanup: Multires: Use C++ threading API in reshape file 2024-09-15 22:01:13 -04:00
Campbell Barton
276d47095d Cleanup: use explicit cast when comparing size_t to -1 2024-09-16 11:39:03 +10:00
Campbell Barton
a988a85a5e Cleanup: use const variables/arguments 2024-09-16 11:39:02 +10:00
Campbell Barton
2360a3911c BLI_listbase: add a utility to check the number of items in the list
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)`.
2024-09-16 11:39:00 +10:00
Campbell Barton
47c6ac2930 Refactor: use integer values for cursor width in BLF
As all the values involved in cursor offset calculation are integers,
treating the cursor width to a float doesn't give any benefits.
2024-09-16 11:38:58 +10:00
Campbell Barton
94183b9e2e Refactor: add a function to access the window size in pixels
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(..).
2024-09-16 11:38:57 +10:00
Campbell Barton
bf7c52cfd5 Fix error in stereo3d side-by-side display
Regression in [0] for side-by-side & top-bottom display.

[0]: e01cadd657
2024-09-16 11:38:56 +10:00
Sean Kim
5c38eb0d81 Refactor: Sculpt: Add face set offset parameter for BMesh functions
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
2024-09-15 23:24:13 +02:00
Harley Acheson
2278f8eb1b UI: Small Corrections to Text Caret Placement
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
2024-09-15 21:43:49 +02:00
Jacques Lucke
13d30e22a1 Fix: modifier execution time not set for grease pencil modifiers 2024-09-15 18:02:51 +02:00
Jacques Lucke
f2e557725d Fix: Geometry Nodes: crash when using gizmo after changing area type 2024-09-15 17:46:32 +02:00
Campbell Barton
10e8f2f889 Cleanup: various non-functional changes 2024-09-15 23:22:22 +10:00
Campbell Barton
8b2ab34ec6 Cleanup: avoid redundant copy to access the filename 2024-09-15 23:14:13 +10:00
Campbell Barton
a42611be92 Cleanup: remove redundant checks 2024-09-15 23:14:11 +10:00
Campbell Barton
17f809718a Cleanup: avoid shadowing variables 2024-09-15 23:14:10 +10:00
Campbell Barton
9b39b4c91c Cleanup: use const pointers/references 2024-09-15 23:14:09 +10:00
Campbell Barton
1104e4233d Cleanup: pass string by const reference 2024-09-15 23:14:08 +10:00
Campbell Barton
9be29e1bbc Cleanup: match function & declaration names 2024-09-15 23:14:07 +10:00
Campbell Barton
1d21c98fc8 Cleanup: quiet dangling-reference GCC warning 2024-09-15 23:14:05 +10:00
Campbell Barton
0d9c4bc5b3 BKE_lib: avoid potential read uninitialized memory in BKE_id_copy_*
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.
2024-09-15 23:07:17 +10:00
Campbell Barton
085da6a08a Fix error in font scale rounding for the animation player 2024-09-15 23:07:16 +10:00
Campbell Barton
630eff9b5e Fix fake_retiming_key_init returning uninitialized stack memory
The SeqRetimingKey returned from fake_retiming_key_init left
original_strip_frame_index & retiming_factor uninitialized.
2024-09-15 23:07:15 +10:00
Jacques Lucke
35bb4f4711 Geometry Nodes: support accessing repeat zone lazy-function graph from Python
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.
2024-09-15 00:56:53 +02:00
Sean Kim
c8ff7f41a1 Fix: Invalid default value for vert_face_set_get with empty Span
The default value is expected to be 0, not INT_MIN

Pull Request: https://projects.blender.org/blender/blender/pulls/127628
2024-09-14 21:16:07 +02:00
Hans Goudey
c6ce6dbe01 BLI: Add IndexMask set_bits function
This is like "to_bits" but doesn't clear the bit span first.

Pull Request: https://projects.blender.org/blender/blender/pulls/127625
2024-09-14 21:09:41 +02:00
Kevin C. Burke
5475040906 Fix: Spelling mistake in Grease Pencil API docs
Fix: Spelling mistake in Grease Pencil API docs

https://projects.blender.org/blender/blender-manual/issues/104920

Pull Request: https://projects.blender.org/blender/blender/pulls/127597
2024-09-14 20:18:30 +02:00
Hans Goudey
c5ccc8ceea Fix #127602: Sculpt multires drawing crash with material index attribute
The evaluated mesh is empty since its data is replaced with the SubdivCCG.
2024-09-14 13:23:38 -04:00
Hans Goudey
2946a840ad Fix: Sculpt: Avoid nested threading in undo node push
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.
2024-09-14 13:01:42 -04:00
Hans Goudey
7283cbef65 Cleanup: Sculpt: Add todo comments for PBVH data to remove 2024-09-14 13:01:42 -04:00
Hans Goudey
a021dd36ef Cleanup: Sculpt: Remove unnecessary PBVH node flags
These have been made redundant by previous commits.
Part of #118145.
2024-09-14 13:01:42 -04:00
Hans Goudey
0499e061d0 Cleanup: Sculpt: Remove drawing update tests
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.
2024-09-14 13:01:42 -04:00
Hans Goudey
0b4820b563 Cleanup: Sculpt: Deduplicate node visibility update on build 2024-09-14 13:01:42 -04:00
Hans Goudey
b77ff173b0 Refactor: Sculpt: Use bit vector for visibility update tags
Also refactor topology update tags, which are used quite similarly
(they mean the same for the drawing code, except for BMesh).

Part of #118145.
2024-09-14 13:01:42 -04:00
Hans Goudey
65c2e5abde Cleanup: Sculpt: Remove unused PBVH redraw tag function 2024-09-14 13:01:42 -04:00