Commit Graph

1752 Commits

Author SHA1 Message Date
Aras Pranckevicius 2f060706a4 Cleanup: fewer BLI_color.hh et al includes
Include counts of some headers while making full blender build:
- BLI_color.hh 1771 -> 1718
- BLI_math_color.h 1828 -> 1783
- BLI_math_vector.hh 496 -> 405
- BLI_index_mask.hh 1341 -> 1267
- BLI_task.hh 958 -> 903
- BLI_generic_virtual_array.hh 509 -> 435
- IMB_colormanagement.h 437 -> 130
- GPU_texture.h 806 -> 780
- FN_multi_function.hh 331 -> 257

Note: DNA_node_tree_interface_types.h needs color include only
for the currently unused (but soon to be used) socket_color function.
Future step is to figure out how to include
DNA_node_tree_interface_types.h less.

Pull Request: #111113
2023-08-16 14:48:53 +03:00
Aras Pranckevicius acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +02:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton ddf9e4be1b Fix missing headers, caused by recent cleanups with the compositor 2023-08-11 14:57:56 +10:00
Jacques Lucke cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Campbell Barton faaac97239 Cleanup: format 2023-08-09 10:46:10 +10:00
Hoshinova b880485492 Nodes: add Floored Modulo mode to Math nodes
Both the `Math` node and the `Vector Math` currently only explicitly
support modulo using truncated division which is oftentimes not the
type of modulo desired as it behaves differently for negative numbers
and positive numbers.

Floored Modulo can be created by either using the `Wrap` operation or
a combination of multiple `Math` nodes. However both methods obfuscate
the actual intend of the artist and the math operation that is actually
used.

This patch adds modulo using floored division to the scalar `Math` node,
explicitly stating the intended math operation and renames the already
existing `"Modulo"` operation to `"Truncated Modulo"` to avoid confusion.
Only the ui name is changed, so this should not break compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/110728
2023-08-08 12:13:00 +02:00
Habib Gahbiche 2f907a0b53 Cleanup: Compositor: Remove outdated TODO
Done in #108858 but comment was not removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/110856
2023-08-07 18:29:59 +02:00
Jeroen Bakker 8de4b5a5ed Vulkan: Shader Compilation Errors
Fixing several shader compilation errors when using the vulkan backend.

* `eevee_lightprobe_irradiance_load_comp`: local variables used same name as push constants.
* `compositor_summed_area_table_compute_complete_y_prologues`: loop with texture_size call

Pull Request: https://projects.blender.org/blender/blender/pulls/110891
2023-08-07 14:49:08 +02:00
Campbell Barton adf58a77ff Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros 2023-08-04 08:51:13 +10:00
Campbell Barton 8c8ff6b85b Cleanup: spelling in comments, use C-style comments 2023-08-03 09:44:28 +10:00
Clément Foucault 1e7f27ec55 Fix Realtime Compositor: Broken keying node on MacOS
This was caused by `mod` not being available to integer
types. It isn't part of the GLSL stadard officially.
In this particular case, it is not needed. so replace it
with the `%` operator.
2023-08-01 17:48:57 +02:00
Sergey Sharybin 63e2832057 Color management: Remove old name-based exceptions
Historically, the OCIO based color management implementation in Blender
had exceptions to treat specific configurations differently. It was a
compatibility with the legacy "No color management" option.

With time and more development in the area there are better ways of
achieving this goal, if needed.

This commit removes the named-based exception, which also solves confusion
about why certain similar configurations (from OCIO stand point) give
different results. As well as allows to create a cleaner plate for an
upcoming additions in the OCIO configuration such as AgX.

Quite simple and technical change which constant-folds the check for
whether the scene color management enabled or not with "true" value.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110580
2023-08-01 14:39:29 +02:00
Campbell Barton 52acf6a6ec Cleanup: correct file names in comments after C -> C++ renaming
Use back-tick quotes to differentiate these from plain text.
2023-07-31 13:02:30 +10:00
Ray molenkamp 4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Campbell Barton 530ee6e7fa Cleanup: make class doc-strings directly above classes
In some cases it wasn't clear if a comment before a class was meant
to be it's doc-string. Remove blank lines between the class & it's
doc-string.
2023-07-25 14:11:42 +10:00
Campbell Barton 7210b80895 Cleanup: run code_clean, remove struct, use utility macros & nullptr 2023-07-25 13:32:21 +10:00
Ray Molenkamp 0f541db97c Cleanup: CMake: Modernize bf_intern_clog dependencies
Pretty straightforward

- Remove any clog paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110350
2023-07-21 18:37:30 +02:00
Ray molenkamp be516e8c81 Cleanup: CMake: Modernize bf_blentranslation dependencies
Pretty straightforward:

- Remove any blentranslation paths from INC
- Add a dependency though LIB when needed

Slightly different than usual:

blentranslation still had a dependency on imbuf, from a time long
gone, cleaned that up since I was in the area

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110324
2023-07-21 16:22:10 +02:00
Ray molenkamp 3e88a2f44c Cleanup: CMake: Modernize bf_depsgraph dependencies
Pretty straightforward

- Remove any depsgraph paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/110317
2023-07-20 22:13:00 +02:00
Ray molenkamp 4e64b772f5 Cleanup: CMake: Modernize bf_windowmanager dependencies
Pretty straightforward

- Remove any windowmanager paths from INC
- Add a dependency though LIB when needed

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109984
2023-07-20 18:52:52 +02:00
Omar Emara a939f46350 Compositor: Use average color variance in Kuwahara node
This patch uses the average variance of individual color channel as the
condition for choosing the appropriate quadrant. This will produce
different visual results, but ones that are consistent with the
intention of the Kuwahara filter.

This is done to be compatible with the GPU implementation, which uses
that method due to superior performance and memory saving.
2023-07-20 11:42:20 +03:00
Omar Emara 6400190836 Fix #110281: Keying node despill is wrong on GPU
The Keying node produces wrong despilling on the GPU evaluator.

That's because the despill amount could be negative, which was not
accounted for.

Additionally, the saturation indices were changed to match the CPU
implementation, just as was done in bdb042c243.
2023-07-20 09:44:58 +03:00
Omar Emara bdb042c243 Fix #109868: Keying node differ between GPU and CPU
The Keying node produces different mattes between the GPU and CPU
evaluators.

That's because the CPU implementation doesn't use the full argmax to
determine indices, rather, it only considers the first argmax and uses
the minimum and maximum of the other two as a form of determinism or
stability.

The algorithm seems arbitrary and makes little sense to me, so for now,
the CPU implementation was ported for consistent results.
2023-07-19 21:02:20 +03:00
Omar Emara a79680b4d1 Fix: End of non void function error in previous commit 2023-07-19 15:51:36 +03:00
Omar Emara 817a1a5c8f Fix: End of non void function error in last commit 2023-07-19 15:20:01 +03:00
Omar Emara 940558f9ac Realtime Compositor: Implement Classic Kuwahara
This patch implements the Classic Kuwahara node for the Realtime Compositor.

A naive O(radius^2) implementation is used for radii up to 5 pixels, and a
constant O(1) implementation based on summed area tables is used for higher
radii at the cost of building and storing the tables.

This is different from the CPU implementation in that it computes the variance
as the average of the variance of each of the individual channels. This is done
to avoid computing yet another SAT table for luminance. The CPU implementation
will be adapted to match this in a future commit.

The SAT implementation is based on the algorithm described in:

Nehab, Diego, et al. "GPU-efficient recursive filtering and summed-area tables."

Additionally, the Result class now allows full precision texture allocation, which
was necessary for storing the SAT tables.

Pull Request: https://projects.blender.org/blender/blender/pulls/109292
2023-07-19 14:04:18 +02:00
Omar Emara 5be226699f Fix #109676: GPU compositor crashes on muting output nodes
The Realtime GPU compositor crashes when muting output or viewer nodes.

This happens because output nodes are scheduled regardless of their
muted statued, however, the initial reference count takes the muted
status into account, resulting in a use after free error, hence the
crash.

To fix this, we simply do not schedule muted output nodes.
2023-07-18 19:12:56 +03:00
Ray Molenkamp eec5c867d3 Cleanup: Make format 2023-07-17 13:00:30 -06:00
Colin Marmond 899f8a8500 Refactor: use ImBuf instead of a raw buffer for compositor previews
In order to better suit the upcoming changes of shader node previews, this
patch replaces the old implementation of the storage of the compositor
previews. It also prevents memory loss for future modification.

BKE_node_preview_clear_tree was removed as it is no longer needed and
will not be used by the new shader node previews.

Pull Request: https://projects.blender.org/blender/blender/pulls/110064
2023-07-17 20:13:52 +02:00
Brecht Van Lommel 3d86417777 Fix build error without unity build 2023-07-12 16:18:26 +02:00
Jacques Lucke 3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Ray molenkamp 07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp 04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp 57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Sergey Sharybin d579ac2b3f Refactor: Use ImBuf to store passes in RenderResult
Doing so avoids having duplicated logic for working with pixel
data which is being passed throughout the render pipeline.

Notable changes:

- ImBug can now store GPU texture.
  This is not very finished part of the API, which will be
  worked further to support tiling for very-high-res images.

- Implicit sharing is removed from the image buffer, as it is
  no longer needed.

There should be no functional changes on user level with this
change.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109788
2023-07-10 16:33:32 +02:00
Ray Molenkamp 7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Ray Molenkamp f0ee4c3ffe Cleanup: Cmake: use alias target for bf_intern_atomic
This introduces an alias target `bf::intern::atomic` for
`bf_intern_atomic`. This has the following benefits:

- Any target name with `::` in it will be recognized as an actual
target by cmake, rather than a library name it may not know about.
and will be validated by cmake to exist. Which means if you make
a typo in the LIB section, CMake will error out telling you it
doesn't know about this specific target rather than passing it on
to the build system, where you'll either get build or linker errors
because of said typo.

- Given there is quite a cleanup still to do in the build system,
it won't always be obvious which targets have been updated to
modern targets and which still need to be done. Having a namespaced
target name is a good indicator there.

Pull Request: https://projects.blender.org/blender/blender/pulls/109784
2023-07-07 15:37:02 +02:00
Campbell Barton 6a79639ef7 Cleanup: use function style casts, remove void function argument
Also remove redundant parenthesis.
2023-07-06 10:40:25 +10:00
Brecht Van Lommel 4c6653274c Fix full frame compositor crash when Image node can't load image
Ref #109168
2023-07-05 20:51:28 +02:00
Ray Molenkamp c591eb1b40 Fix #109596: Xcode project generation fails
Remove dead code that is causing problems with dependencies in Xcode.

Pull Request: https://projects.blender.org/blender/blender/pulls/109751
2023-07-05 18:46:55 +02:00
Sergey Sharybin e1b60fdb91 Remove Z Buffer from ImBuf
It was only used by OpenEXR and Iris images, and saving the Z Buffer
in those formats was disabled by default. This option comes from the
times prior to the addition of the Multilayer EXR.

It also worth noting that it was not possible to save Iris with Depth
pass from Blender as internally it is called IRIZ format and it was
not exposed. But even after exposing this format option something still
was missing as saving and loading ITIZ did not show up the Depth pass.

The reason of removal is to make it a more clear match of the ImBuf
with a render pass, and use it instead of a custom type in the render
result and render pass API. This will simplify the API and also avoid
stealing buffers and making shallow copies when showing the render
result.

For the cases when Depth is needed a Multilayer EXR is to be used,
as most likely more than just the Depth will be needed.

On a user level this change:

- Removes the "Z Buffer" option from the interface.

- It preserves existing sockets in compositor nodes, but it will
  output black image. Also changing the image data-block will
  remove the socket unless a Multilayer EXR with Depth pass image
  is selected.

- Removes "Depth" socket of the Viewer and Composite nodes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109687
2023-07-04 17:03:02 +02:00
Sergey Sharybin 5907ab0364 Fix redefinition SSE2NEON_PRECISE_SQRT on Apple Silicon
After some recent changes BLI_math_base got (indirectly) included
from DNA file, causing defines conflict in Cycles: Cycles wants the
default fast behavior of square root, and BLI color wants it to be
more preciese.

Proposed solution is to move the SSE block away from the math_base
closer to code which uses it. The initial intent was to make those
functions reusable, but for a long long time the color utilities
are the only users of those functions.

This change does not prevent the error from re-occurring in the
future if some code includes sse2neon and BLI color utilities, but
it makes such conflict situation much less likely to happen, for
now.

The downside of this change is that the code now need to include
BLI_simd.h explicitly to access BLI_HAVE_SSE2 instead of relying
on it being included indirectly with math headers. The mitigation
for this is to change semantic of the BLI_HAVE_SSE2: now it is
defined to 1 if SSE2 is supported and to 0 otherwise. This makes
it so the code needs to check if using `#if BLI_HAVE_SSE2` and
if the BLI_simd.h is not included it will generate warning when
using GCC or Clang.

This change in semantic is is something the current patches would
need to ensure is handled correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/109664
2023-07-03 19:18:30 +02:00
Ray molenkamp 2dac20e35f CMake/Cleanup: Use bf_intern_atomic target
Use the bf_intern_atomic target rather than adding a relative path
to it in the INC section.

Pull Request: https://projects.blender.org/blender/blender/pulls/109424
2023-06-28 19:12:55 +02:00
Campbell Barton d1e6c8f5a6 Cleanup: spelling in comments 2023-06-28 12:27:48 +10:00
Campbell Barton 85029da289 Cleanup: compiler warnings 2023-06-25 11:39:25 +10:00
Habib Gahbiche c8f434e685 Compositor: improve edge detection of Kuwahara filter
Compute edges of image once based on luminance instead of all 3 channels.

This also gives a modest performance improvement of 8%. Measured on intel i9 CPU using a 1920 x 3199 image.

Pull Request: https://projects.blender.org/blender/blender/pulls/108858
2023-06-24 21:39:07 +02:00
Omar Emara c9e6399fe1 Realtime Compositor: Implement Keying node
This patch implements the Keying node for the realtime compositor. To
ease the implementation, some morphological operators were moved into
algorithms and a mechanism to steal data between results was added to
the Result class.

Pull Request: https://projects.blender.org/blender/blender/pulls/108393
2023-06-24 13:02:33 +02:00
Campbell Barton ec428c3f7f CMake: sort file lists, add missing header 2023-06-24 19:05:09 +10:00