Commit Graph

7250 Commits

Author SHA1 Message Date
Jesse Yurkovich
4fdf760412 Cleanup: format 2025-07-10 03:49:24 +02:00
Campbell Barton
96c214b0d2 Build: add missing include for Linux & GCC15 2025-07-10 10:38:03 +10:00
Hans Goudey
5bdec246ea Cleanup: Fix build error from missing include in threads.cc
`<algorithm>` was missing for me, though the build passed on the
build bots. Also remove some unused includes.
2025-07-09 14:32:30 -04:00
Miguel Pozo
f46aa9a1ea Core: Add BLI_thread_queue priority and cancel support
Add functionality required for using BLI_thread_queue for shader compilation, as
discussed in #140214.

Pull Request: https://projects.blender.org/blender/blender/pulls/140992
2025-07-09 18:04:51 +02:00
Harley Acheson
619968eb87 merge blender-v4.5-release 2025-07-03 09:31:55 -07:00
Lukas Tönne
b0bd7531df Fix #140558: No cache reset on every subframe of the bake range start frame
The `reset_invalid_node_bakes` function resets caches on or before
the first frame of the bake frame range. This works fine for full-frame
steps, but with stretched-out frames the `SubFrame` comparator is true
for every substep when the integer frames match. This keeps resetting
the cache at the beginning of the bake range for all subframes.

The comparison function must take the subframe into account when the
integer part is equal.

Pull Request: https://projects.blender.org/blender/blender/pulls/141220
2025-07-01 07:28:05 +02:00
Campbell Barton
b914416613 Merge branch 'blender-v4.5-release' 2025-06-26 18:17:13 +10:00
Campbell Barton
d9eea24b06 Merge branch 'blender-v4.5-release' 2025-06-26 18:17:08 +10:00
Campbell Barton
6d06fc3979 Fix immediate exit when displaying an invalid UTF8 title on Wayland
A non UTF8 title on Wayland causes disconnection from the server.
Resolve by using the path as-is unless invalid UTF8 byte sequences
are found, in that case they're replaced by `?`.

This is skipped on WIN32 & macOS since the issue only exists on Wayland.
2025-06-26 18:01:06 +10:00
Campbell Barton
c5bae85893 BLI_string: add BLI_str_utf8_invalid_substitute
Similar to BLI_str_utf8_invalid_strip except that it substitutes
invalid characters and doesn't change the string length.

Useful for displaying strings that include invalid UTF8 code-points.
2025-06-26 18:01:06 +10:00
Sean Kim
14bf22ffb5 Merge branch 'blender-v4.5-release' 2025-06-23 08:58:52 -07:00
Sean Kim
ffcbe6205b BLI: Add assert for indexed_data_equal
Typically, we use this function to determine whether or not a subset of
data that has been collected with `gather` needs to be then persisted
into a larger array with `scatter`. As such, it makes sense to assert on
equality of the indices and smaller array size.

Pull Request: https://projects.blender.org/blender/blender/pulls/140752
2025-06-23 17:57:59 +02:00
Michal Krupa
fdaaea6328 Core: Increase MAX_ID_NAME length from 66 to 258 (Blender 5.0)
Change the maximum data-block name from 64 to 256 bytes by increasing MAX_ID_NAME value.

Also increase a few related non-ID data name max size, essentially the action slots identifiers, as these are the primary key used to match an Action's slot to an ID by name.

Other sub-data (bones, modifiers, etc.) lengths are not modified here, as these can be made actual dynamic strings in the future, while keeping (a reasonable level of) forward compatibility, during the course of Blender 5 release cycles.

Implements #137608.

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/137196
2025-06-19 16:39:20 +02:00
Brecht Van Lommel
aa25b4d3c2 Merge branch 'blender-v4.5-release' 2025-06-17 20:21:00 +02:00
wszqkzqk
3999975c29 Build: Add loong64 support in BLI_build_config.h
LoongArch is a new RISC ISA developed by Loongson, this adds the missing
entry to BLI_build_config.h. It has been verified to work on Arch Linux's
loong64 port.

Pull Request: https://projects.blender.org/blender/blender/pulls/130916
2025-06-17 20:20:26 +02:00
Mattias Fredriksson
407dcb39d4 Tests: EXPECT_EQ_SPAN utility macro
Replaces pointer based EXPECT_EQ_ARRAY with EXPECT_EQ_SPAN in most cases
as they already used spans (or span compatible datastructures).
Currently EXPECT_EQ_ARRAY only takes in one size variable and doesn't
compare the  number of elements between arguments (requiring an
additional line to do so).

This should make the code cleaner and safer. Goal is also to promote
the use Spans in new test code.

Pull Request: https://projects.blender.org/blender/blender/pulls/140340
2025-06-16 20:31:00 +02:00
Hans Goudey
c16ee2c939 Refactor: Use C++ bounds corners function
Remove the last uses of `BKE_boundbox_init_from_minmax` in
favor of the newer `bounds::corners`. Besides clearer naming
and better ergonomics, it's also inline-able which seems to be a
good thing for such a simple function.

In order to get the same behavior as before I changed the
C++ bounds function to give the same vertex order as the
older function.

Pull Request: https://projects.blender.org/blender/blender/pulls/140401
2025-06-16 15:49:14 +02:00
Campbell Barton
63600f806b Cleanup: spelling in comments (make check_spelling_*) 2025-06-13 11:23:28 +10:00
Aras Pranckevicius
68111db969 Nodes: Speedup Voronoi by changing the hash function
The 2D->2D, 3D->3D, 4D->4D hash functions used in Voronoi node were
using quite an expensive hash function. Switch these to dedicated
2D/3D/4D hash functions (pcg2d, pcg3d, pcg4d) -- these are still very
good quality, but the hash function itself is 3x-4x faster.
Which makes Voronoi node calculation overall be around 2x faster. In
some cases when using OSL, the speedup is even larger.

This visibly changes output of the Voronoi noise however. The actual
noise "behaves" the same, just if someone was depending on the noise
pattern being exactly like it was before, this will change the pattern.

Images, more performance results and details wrt OSL are in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/139520
2025-06-12 20:07:52 +02:00
Hans Goudey
72e49ba20a Cleanup: Add protection for void CPPType and GPointer
Previously using these types with a void type would give a
linker error. Compile errors are much easier to diagnose.

Pull Request: https://projects.blender.org/blender/blender/pulls/140296
2025-06-12 18:44:58 +02:00
Bastien Montagne
bc80ef136e Big Endian Support Removal.
This commit implements #125759.

It removes:
* Blender does not build on big endian systems anymore.
* Support for opening blendfiles written from a big endian system is
  removed.

It keeps:
* Support to generate thumbnails from big endian blendfiles.
* BE support in `extern` or `intern` libraries, including Cycles.
* Support to open big endian versions of third party file formats:
  - PLY files.
  - Some image files (cineon, ...).

Pull Request: https://projects.blender.org/blender/blender/pulls/140138
2025-06-12 10:37:47 +02:00
Hans Goudey
14a42c0928 Cleanup: Use C++ vector types for convex hull API
Pull Request: https://projects.blender.org/blender/blender/pulls/140233
2025-06-11 22:46:27 +02:00
Campbell Barton
07121d44ae Cleanup: use braces (follow own style guide) 2025-06-11 09:05:26 +00:00
Bastien Montagne
ccdf23e2d3 Merge branch 'blender-v4.5-release' 2025-06-06 14:30:54 +02:00
Bastien Montagne
a883f555ae Blender 4.5 Forward Compatibility for Long ID Names.
This commit enables Blender 4.5 to use (to some extent) blendfiles from
Blender 5.0 and later using 'long' ID names (i.e. ID names over 63 bytes).

On a more general perspective, it also introduces safer handling of
potentially corrupted ID names in a blendfile.

This is achieved by carefully checking for non-null terminated ID names
early on in readfile process, and then:
* Truncating and ensuring uniqueness of ID names.
* Doing similar process for action slot and slot users identifiers.
* In linking (and appending) context, such IDs are totally ignored. They are
  not listed, and are considered as missing if some other (valid) linked ID
  attempt to indirectly link them).
* Informing users through usual reporting ways.

Technically, this mainly changes two areas of the readfile code related to IDs
themselves:
* The utils `blo_bhead_id_name` that returns the ID name of an ID BHead,
  without actually reading that ID, now check for a valid null-terminated
  string of `MAX_ID_NAME` max size, and returns a `nullptr` on error.
  _This essentially prevents listing and linking such IDs, in any way._
* The actual ID reading code (`read_id_struct`) does the same check, and
  truncate the ID name to its maximum allowed length.
* Both of above checks also set a new FileData flag
  (`FD_FLAGS_HAS_LONG_ID_NAME`), which is used to ensure that ID names (and
  related actions slots identifiers) remain unique, and report to info to the
  user.

Implements #137608.

Branched out from !137196.

Co-authored-by: michal.krupa <michal.krupa@cdprojektred.com>
Co-authored-by: Campbell Barton <ideasman42@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/139336
2025-06-06 14:19:00 +02:00
Mohamed El Shorbagy
9dd02f355d Cleanup: Assert normalized first before performing any operation
Pull Request: https://projects.blender.org/blender/blender/pulls/139408
2025-06-05 15:56:10 +02:00
Campbell Barton
9d3974f37a Merge branch 'blender-v4.5-release' 2025-06-05 17:35:13 +10:00
Campbell Barton
2f60e37936 Fix command line help text mixing up "-a" arguments
The argument `-a` is used twice (render animation & animation playback).

Parsing logic works since their handled at different passes however
printing help text could return either since passes aren't used
for matching.

Workaround the problem using a deterministic lookup when printing
help text which that skips arguments that have already been handled.
2025-06-05 17:27:29 +10:00
илья _
f140926186 Core: lock stack trace printing
If multiple threads fail at the same time (usually on the same assert), the
stack trace print can be all mixed up. This patch adds a lock to the stack trace
printing, so that they are printed on after the other.

Pull Request: https://projects.blender.org/blender/blender/pulls/139237
2025-06-05 07:32:22 +02:00
Campbell Barton
6a1fa176ef Cleanup: spelling in comments & duplicate terms (check_spelling.py)
Also minor clarification in doc-string.
2025-06-04 01:51:29 +00:00
Hans Goudey
77b14f2dcb Cleanup: Grammar: Fallback vs. fall back
The former is a noun or adjective, the latter is a verb.
2025-06-02 17:13:56 -04:00
Sybren A. Stüvel
f9a9080f16 Cleanup: correct documentation of BLI_uniquename_cb for dynamic strings
Correct the documentation of the `BLI_uniquename_cb()` variant that was
introduced in 7afa5aaa59 to support
dynamically-allocated strings.

Contrary to the other functions with the same name, this variant does
not actually assign the name. It returns the new name and leaves the
assignment to the caller.

Pull Request: https://projects.blender.org/blender/blender/pulls/139639
2025-06-02 12:20:23 +02:00
Hans Goudey
91803e130f Cleanup: Grammar: Fix uses of "for e.g."
e.g. stands for "exempli gratia" in Latin which means "for example".
The best way to make sure it makes sense when writing is to just expand
it to "for example". In these cases where the text was "for e.g.", that
leaves us with "for for example" which makes no sense. This commit fixes
all 110 cases, mostly just just replacing the words with "for example",
but also restructuring the text a bit more in a few cases, mostly by
moving "e.g." to the beginning of a list in parentheses.

Pull Request: https://projects.blender.org/blender/blender/pulls/139596
2025-05-29 21:21:18 +02:00
Aras Pranckevicius
4a328b5a63 Nodes: Voronoi node CPU optimizations
Several small speedups for Voronoi node (no behavior change). This
affects Cycles and CPU execution of Voronoi node e.g. in Compositor.

- F1 mode: when evaluating distance for Voronoi cells, use a faster
  distance estimation, and only do final distance calculation on the
  resulting closest cell. This is only really relevant for the default
  Euclidian distance, where this saves a square root per evaluated cell
  (in 3D Voronoi case saves 26 square roots; in 4D case saves 80 square
  roots).
- N-Sphere Radius mode: speedup by doing squared distance calculations.
  We only need to find the closest one, so again doing the square root
  per cell is not needed here.

Something like 5%-10% speedup for F1 3D Voronoi; more performance details
in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/139490
2025-05-29 15:40:31 +02:00
Campbell Barton
479d1f1d16 Cleanup: use doxygen doc-strings, spelling (make check_spelling_*) 2025-05-29 11:00:53 +10:00
Miguel Pozo
cfa8c9d4ad Fix: Core: VectorList iterator after clear
Check for `used_vectors_` instead of the allocated size.
Improve iterator tests.

Pull Request: https://projects.blender.org/blender/blender/pulls/139541
2025-05-28 18:59:44 +02:00
Campbell Barton
be2b8aca91 Fix out of bounds read from recent undo optimization
Error in [0] could read past the array bounds for small arrays
containing uniform values.

For tests this wasn't reporting issues with ASAN unless `malloc` was
used (instead of `MEM_malloc_arrayN`).

Resolve and add tests that run with different alignments.

[0]: f9842107aa
2025-05-28 08:38:56 +00:00
YimingWu
34cd681a48 Fix #139387: Try to handle mmap exception on Win32
`IMB_load_image_from_file_descriptor` use mmap to read images, and mmap
sometimes can have erroreous state llike accessing a file from network
drives. This patch tries to handle these exceptions like `BLI_mmap_read`
on Win32 (On unix the `sigbus_handler` will be called instead).

Pull Request: https://projects.blender.org/blender/blender/pulls/139472
2025-05-27 10:01:41 +02:00
Campbell Barton
79eea8208d BLI_array_store: support run-length encoding / decoding
Add RLE encoding/decoding functions for byte arrays for the purpose
of pre-processing arrays with large spans of (mostly) uniform values
before storing them in a BArrayState.

Part of a fix for #136737.
2025-05-27 15:48:53 +10:00
Jacques Lucke
64a13f4be2 Refactor: BLI: simplify extending get_default_hash function
This simplifies extending `blender::get_default_hash` to more than 4 parameters
by just adding extra factors to the list. The behavior should be the same as
before.

Pull Request: https://projects.blender.org/blender/blender/pulls/139392
2025-05-24 21:01:05 +02:00
Jacques Lucke
a6486d11c2 Cleanup: add missing include 2025-05-24 18:55:53 +02:00
Miguel Pozo
4f00a470cd Core: VectorList improvements
- Add a custom Iterator, so it can be iterated as a 1D list.
- Add missing functions like `first`, `is_empty`, `clear`, and
  subscript operator.
- Add a `size_` member variable for faster `size` calls.
- Add compile-time asserts to ensure the Capacity sizes are valid.
- Add unit tests.

See #138947 for the motivation behind this.

Pull Request: https://projects.blender.org/blender/blender/pulls/139102
2025-05-23 15:34:26 +02:00
Miguel Pozo
9222daacb7 Fix: Core: bitscan_reverse_uint64 on Windows
Pull Request: https://projects.blender.org/blender/blender/pulls/139283
2025-05-22 17:30:45 +02:00
Campbell Barton
b5d3b3c1a3 Refactor: const-correctness in BLI_array_store API 2025-05-22 17:18:39 +10:00
Brecht Van Lommel
ee1a460f42 Revert "Refactor: Add and use MEMCPY_STRUCT_AFTER_CHECKED"
Needs more review, see #138830.

This reverts commit 5ac631d02b.
2025-05-20 17:32:49 +02:00
Brecht Van Lommel
5ac631d02b Refactor: Add and use MEMCPY_STRUCT_AFTER_CHECKED
Check if either the memory is zero or already matches the default value,
and copy. This simplifies a common pattern to a single line.

Preparing for default initializers in DNA (#134531).

Pull Request: https://projects.blender.org/blender/blender/pulls/138830
2025-05-20 13:27:08 +02:00
Jacques Lucke
0837037d13 Geometry Nodes: initial support for volume grids in function nodes
This patch implements basic support for evaluating function nodes on volume
grids. Conceptually, a function node always creates a new grid for the output,
though the output is often a modified version of the input. The topology of the
output grid is a union of all the input grids.

All input grids have to have the same transform. Otherwise one has to use
resampling to make grids compatible.

Non-grid inputs are allowed to be single values or fields. The fields are
evaluated in a voxel/tile context, so they compute a value per voxel or per
tile.

One optimization is missing that will probably be key in the future: the ability
to merge multiple function nodes and execute them at the same time. Currently
the entire function evaluation is started and finished for every function node
that outputs a grid. This will add significant overhead in some situations.
Implementing this optimization requires some more changes outside of the scope
of this patch though. It's good to have something that works first.

Note: Not all function nodes are supported yet, because we don't have grid types
for all of them yet. Most notably, there are no color/float4 grids yet.
Implementing those properly is not super straight forward and may require some
more changes, because there isn't a 1-to-1 mapping between grid types and socket
types (a float4 grid may correspond to a color or vector socket later on).

Using grids with function nodes and fields can result in false positive warnings
in the UI currently. That's a limitation of our current socket type inferencing
and can be improved once we have better socket shape inferencing.

Pull Request: https://projects.blender.org/blender/blender/pulls/125110
2025-05-19 18:30:58 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Jacques Lucke
5a449439ef Refactor: BLI: simplify compute context hash generation and make it lazy
Currently, there was a lot of boilerplate to compute the compute context hash.
Now, the complexity is abstracted away to make it a simple function call.

Furthermore, this makes the compute context hash generation lazy. The goal here
is to make it very cheap to construct the compute context hash in the first,
while making it a little bit more expensive (still quite cheap overall) to
access the hash when any data has to be logged. This trade-off makes sense when
we want to pass the compute context to more lower-level places in order to be
able to create better error messages with more contextual information. For
example, we'd want to create error messages during multi-function evaluation
which happens during field evaluation within a node.

Pull Request: https://projects.blender.org/blender/blender/pulls/138912
2025-05-15 21:18:23 +02:00
Campbell Barton
e97e9c2904 Cleanup: various non functional changes for C++ 2025-05-15 10:26:47 +10:00