Commit Graph

4621 Commits

Author SHA1 Message Date
Clément Foucault
626118984e Compositor: Use last_update for ID update
This replaces the deprecated DrawData mechanism by the
usage of the update timestamp `last_update`.

The compositor keeps the `last_update` value of the cached ID
and compares it with the value on the ID at the time of evaluation.

Rel #134690

Pull Request: https://projects.blender.org/blender/blender/pulls/134878
2025-03-14 10:25:32 +01:00
Clément Foucault
94c7c84bcd Refactor: DRW: Simplify the DRWContext classes and methods
This refactor part of `draw_manager_c.cc` to make it more understandable
and less bug prone.

- Splits the context handing to `draw_gpu_context.cc`
- Rename `draw_manager_c.cc` to `draw_context.cc`
- Merge `DRWContextState` into `DRWContext`
- Merge lots of static functions into `DRWContext` to avoid global access
- Deduplicate code between entry point functions
- Move context init logic to `DRWContext` constructor
- Move resource init logic to `DRWContext::acquire_data`
- Move extraction `TaskGraph` out of `DRWContext`
- Reduce / centralize complexity of enabling draw engines
- Reduce the amount of `drw_get` calls
- Remove unused code

Pull Request: https://projects.blender.org/blender/blender/pulls/135821
2025-03-13 13:47:02 +01:00
Brecht Van Lommel
3ff3c2bf21 Merge branch 'blender-v4.4-release' 2025-03-12 15:33:26 +01:00
Brecht Van Lommel
a80f4ceb24 Fix #135837: Crash cancelling render with stamp burn into image
The image buffer might not exist if cancelling happens early enough.

Pull Request: https://projects.blender.org/blender/blender/pulls/135861
2025-03-12 15:31:29 +01:00
Brecht Van Lommel
dc488b99a5 Merge branch 'blender-v4.4-release' 2025-03-12 13:39:50 +01:00
Brecht Van Lommel
92f2027f62 Fix #135806: Wrong error message on render to directory without permission
Make MOV_write_begin always report an error on failure, and remove the
generic one from the caller.

Regression from 974efe7d23.

Pull Request: https://projects.blender.org/blender/blender/pulls/135859
2025-03-12 13:39:00 +01:00
Bastien Montagne
9f697c7cc6 Cleanup: render: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/135813
2025-03-12 10:31:06 +01:00
Omar Emara
918e01a61f Merge branch 'blender-v4.4-release' 2025-03-10 13:37:14 +02:00
Omar Emara
c14706e5c9 Fix #135647: Compositor viewer doesn't update on render
Since the introduction of e53ac805af, viewer and previews were not
computed when rendering, because we assumed those would only be useful
during interactive compositing. But we received multiple reports that
this is broken. So users generally expect rendering to compute viewers
and previews.

This patch makes a distinction between background rendering and F12
renders, where the latter computes viewer and previews. This should not
have significant effect on the render time, because typically viewer
results are already computed as part of computing composite results.

Pull Request: https://projects.blender.org/blender/blender/pulls/135723
2025-03-10 12:31:00 +01:00
Clément Foucault
5a32440edf Refactor: DRW: Replace by enabled engine list by static members
Iteration is done through templates.

Removes the need for the enabled engine list/vector.

Reduces API complexity.
2025-03-06 15:20:35 +01:00
Richard Antalik
68abed543b Refactor: Remove module prefix form symbols in sequnecer namespaces
Remove
SEQ_ prefix for blender::seq namespace and
ED_sequencer for blender::ed::vse namespace

Pull Request: https://projects.blender.org/blender/blender/pulls/135560
2025-03-06 13:04:39 +01:00
Omar Emara
39d0cff1dc Refactor: Compositor: Remove initial reference count
This patch removes the initial reference count mechanism from the Result
class. That's because results are no longer cached across evaluations
ever since 97ada4f307, so it is no longer useful.

Pull Request: https://projects.blender.org/blender/blender/pulls/135526
2025-03-06 08:50:22 +01:00
Richard Antalik
a08246a1a2 Refactor: Move VSE code to namespaces
This PR creates 2 namespaces for VSE code:
- `blender::seq` for sequencer core code
- `blender::ed::vse` for editor code

These names are chosen to not be in conflict with each other.
No namespace was used for RNA.

Finally, file `BKE_sequencer_offscreen.h` was moved from BKE to sequencer.

Pull Request: https://projects.blender.org/blender/blender/pulls/135500
2025-03-06 06:22:14 +01:00
Jesse Yurkovich
1512adc536 Merge branch 'blender-v4.4-release' 2025-03-05 11:49:45 -08:00
Jesse Yurkovich
2d915869f7 Fix #135441: integer overflow with large displacement modifier image
The offset calculation would overflow inside `ibuf_get_color` given the
incoming arguments and image size.

Another similar problem, found from quick inspection, would occur inside
`ibuf_get_color_clip` as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/135476
2025-03-05 20:48:47 +01:00
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Omar Emara
97ada4f307 Cleanup: Compositor: Remove operation stream cache
This patch removes the operation stream cache code from the compositor.
This code path has been disabled already since 4137fdf555, so this patch
just removes the dead code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135513
2025-03-05 14:01:12 +01:00
Omar Emara
85a78774da Merge branch 'blender-v4.4-release' 2025-03-04 09:34:41 +02:00
Omar Emara
a50144e55c Fix #134914: Backdrop remain after loading new file
The compositor backdrop is still visible even after a new completely
different file is loaded. This is because compositor contexts cache
things like the backdrop, and contexts are stored on interactive
compositor renders, which are not freed until Blender is closed. To fix
this, we cleanup the interactive compositor renders that were created
upon file load.

Pull Request: https://projects.blender.org/blender/blender/pulls/135390
2025-03-04 08:33:17 +01:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Brecht Van Lommel
6c29dbff10 Merge branch 'blender-v4.4-release' 2025-02-28 17:38:28 +01:00
Gracjan Jeżewski
901353ce4c Fix: Hydra camera missing depth of field parameters
Add the missing F-Stop and Focus Distance.

Pull Request: https://projects.blender.org/blender/blender/pulls/134896
2025-02-28 17:37:35 +01:00
Brecht Van Lommel
9e44514b46 Fix: Hydra incorrect assmes camera object is always a camera 2025-02-28 17:37:35 +01:00
Aras Pranckevicius
d64aa0112f VSE: speedup RE_render_result_rect_from_ibuf by avoiding memory clear
The RE_render_result_rect_from_ibuf function (used only by VSE) was
allocating memory for the render result, clearing it to zero and
immediately overwriting it with the image pixel data. Remove the
"clear to zero" part.

Rendering a 1920x1080 resolution movie with VSE (using float
pixel data), average RE_render_result_rect_from_ibuf time goes from
6.8ms down to 3.8ms

Pull Request: https://projects.blender.org/blender/blender/pulls/135170
2025-02-26 16:17:48 +01:00
Aras Pranckevicius
148aa54398 ImBuf: unify color space transform threaded/non-threaded functions
There's no point in having non-threaded image color space conversion functions.
So merge the threaded and non-threaded functions and clarify names while at it:

- IMB_colormanagement_transform & IMB_colormanagement_transform_threaded
    -> IMB_colormanagement_transform_float
- IMB_colormanagement_transform_byte & IMB_colormanagement_transform_byte_threaded
    -> IMB_colormanagement_transform_byte
- IMB_colormanagement_transform_from_byte & IMB_colormanagement_transform_from_byte_threaded
    -> IMB_colormanagement_transform_byte_to_float

These places were doing single-threaded colorspace conversion previously, and
thus now are potentially faster:
- IMB_rect_from_float (used in many places)
- EXR image "save as render" saving (image_exr_from_scene_linear_to_output)
- Object baking (write_internal_bake_pixels, write_external_bake_pixels)
- General image saving, clipboard copy, movie preparation
  (IMB_colormanagement_imbuf_for_write)
- Linear conversion when reading HDR images/movies
  (colormanage_imbuf_make_linear)
- EXR multi-layer conversion (render_result_new_from_exr)

For one case I benchmarked, which is to render out a 2D stabilized 10 bit input
movie clip out of VSE, the total render time went from 49sec down to 44sec
(Ryzen 5950X), one of the single-threaded parts was the colorspace conversion
in the movieclip code.

Pull Request: https://projects.blender.org/blender/blender/pulls/135155
2025-02-26 12:11:47 +01:00
Brecht Van Lommel
4b10c63617 Merge branch 'blender-v4.4-release' 2025-02-20 16:34:00 +01:00
Gracjan Jeżewski
4b348453db Fix: Hydra: Make final render run render loop
Hydra's viewport and final engines conflict on whether the rendering loop
is internal or external. The old approach works for Hydra Delegates that
converge with a single sample (hdStorm) but causes engines relying on sample
accumulation (hdEmrbee) to become stuck.

This minimal change retains compatibility with delegates like Storm while
replicating the behavior of the viewport engine in the final engine.

Pull Request: https://projects.blender.org/blender/blender/pulls/134804
2025-02-20 16:32:24 +01:00
Omar Emara
a5ecde48ae Compositor: Add Float4 type
The compositor previously overloaded the vector type to represent
multiple dimensions that are always stored in a 4D float vector. This
patch introduce a dedicated type for float4, leaving the vector type to
always represent a 3D vector, which will be done in a later commit.

This is not exposed to the user as a separate socket type with a
different color, it is only an internal type that uses the same vector
socket shape and color.

Since the vector socket represents both 4D and 3D vectors, code
generally assumes that such sockets represents 3D vectors, and the
developer is expected to set it to a 4D vector if needed in the node
operation constructor, or use the newly added skip_type_conversion flag
for nodes that do not care about types, like the File Output node.
Though this should be redundant once we add a dimension property for
vector sockets.

Pull Request: https://projects.blender.org/blender/blender/pulls/134486
2025-02-20 10:38:40 +01:00
Brecht Van Lommel
4786fbe774 Refactor: Remove extern "C" from most headers
The only remaining code in source/blender that must be compiled as C
is now datatoc generated code and the DNA defaults that use designated
initializers.

Pull Request: https://projects.blender.org/blender/blender/pulls/134469
2025-02-13 18:58:08 +01:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Omar Emara
89e0472e49 Compositor: Use gpu::TexturePool instead of DRW pool
This patch removes the compositor texture pool implementation which
relies on the DRW texture pool, and replaces it with the new texture
pool implementation from the GPU module.

Since the GPU module texture pool does not rely on the global DST, we
can use it for both the viewport compositor engine and the GPU
compositor, so the virtual texture pool implementation is removed and
the GPU texture pool is used directly.

The viewport compositor engine does not need to reset the pool because
that is done by the draw manager. But the GPU compositor needs to reset
the pool every evaluation. The pool is deleted directly after rendering
using the render pipeline or through RE_FreeUnusedGPUResources for the
interactive compositor.

Pull Request: https://projects.blender.org/blender/blender/pulls/134437
2025-02-12 15:59:45 +01:00
Omar Emara
31444fe5b1 Refactor: Compositor: Use generic container for results
This patch refactors the Result class in the compositor to use
GMutableSpan and std::variant to wrap the result's data. This reduces
the complexity of the code and slightly optimizes performance. This will
also make it easier to add new types and interface with other code like
multi-function procedures.

Pull Request: https://projects.blender.org/blender/blender/pulls/134112
2025-02-06 13:49:44 +01:00
Omar Emara
e53ac805af Compositor: Avoid redundant output computations
This patch allows the compositor context to specify exactly which
outputs it needs, selecting from: Composite, Viewer, File Output, and
Previews. Previously, the compositor fully executed if any of those were
needed, without granular control on which outputs are needed exactly.

For the viewport compositor engine, it requests Composite and Viewer,
with no Previews or File Outputs.

For the render pipeline, it requests Composite and File Output, with
node Viewer or Previews.

For the interactive compositor, it requests Viewer if the backdrop is
visible or an image editor with the viewer image is visible, it requests
Compositor if an image editor with the render result is visible, it
requests Previews if a node editor has previews overlay enabled. File
outputs are never requested.

Pull Request: https://projects.blender.org/blender/blender/pulls/133960
2025-02-04 08:34:48 +01:00
Brecht Van Lommel
4c2fb20e93 Tests: Fix and workaround Metal difference for Storm
* Disable Metal multisampling to match OpenGL.
* Block list all image half/float tests, these can all fail randomly.
* Blocklist tests failing due to issues in OpenUSD Metal implementation.
2025-02-01 13:03:39 +01:00
Brecht Van Lommel
b78fa81ed4 Cleanup: Various clang-tidy warnings in render
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Omar Emara
75f1cbb6dd Refactor: Clarify code around scheduling composite nodes
There is a special case in the compositor code where viewer nodes are
treated as composite nodes. This patch renames relevant methods and
updates comments to clarify this use case.

Pull Request: https://projects.blender.org/blender/blender/pulls/133811
2025-01-31 07:43:00 +01:00
Campbell Barton
2be282a8f3 Cleanup: spelling in comments (check_spelling target) 2025-01-31 13:27:05 +11:00
Aras Pranckevicius
2b39897d18 Fix #133799: render of VSE 10/12bpp videos broken unless source strips are float
10/12bpp movie writing code assumes that input image is properly
floating point for these cases. That is always true for regular
rendering, however VSE can produce 8bpp images, if there
are no float/HDR strips in there. Make these convert into a float
image in the render pipeline when needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/133802
2025-01-30 14:55:41 +01:00
Sergey Sharybin
0c4e76fb78 Fix #125642: Cycles OptiX background render crash with GPU compositor
Apple same workaround for driver issue as was done for grease pencil,
the OpenGL context needs to be initialized before OptiX.

Pull Request: https://projects.blender.org/blender/blender/pulls/133759
2025-01-30 08:49:06 +01:00
Hans Goudey
7d6e098ca1 Cleanup: Remove unused includes in blenkernel
Pull Request: https://projects.blender.org/blender/blender/pulls/133688
2025-01-28 15:27:34 +01:00
Omar Emara
2028bc8d7d Compositor: Add derived resources optimization
This patch introduces a new Derived Resources concept to the compositor.
Derived resources are resources that are computed from a particular
result and cached in it in case it is needed by another operation, which
can greatly improve performance in some cases at the cost of more memory
usage.

The first use case is to store denoised versions of the Denoising Albedo
and Denoising Normals passes if auxiliary pass denoising is enabled in
the denoise node. Consequently, multi-pass denoising setups where the
same auxiliary passes are used in multiple denoise nodes should be much
faster due to caching of the derived resources.

This implementation has the limitation that it can't preemptively
invalidate the cache when the derived resources are no longer needed to
free up memory. This requires a special resource tracking mechanism that
need to happen during node tree compilation, and will be submitted
later. The limitation is not significant in the particular derived
resources that is currently implemented. Since the auxiliary passes are
rarely used outside of denoising.

Fixes #131171.

Pull Request: https://projects.blender.org/blender/blender/pulls/125671
2025-01-27 14:58:09 +01:00
Brecht Van Lommel
7584ccc28d Fix #125711: Crash saving stereo EXR image from command line
* Ensure valid bit depth is set along with file type
* Guard against invalid inputs in stereo imbuf creation
* Remove some unused code

Thanks Yiming Wu for finding the cause.

Pull Request: https://projects.blender.org/blender/blender/pulls/133499
2025-01-23 19:15:17 +01:00
Brecht Van Lommel
c749f6c376 Cleanup: Remove unnecessary usage of Boost in the build system
* Some libraries like Alembic and OpenColorIO for a long time removed
  header dependencies on Boost.
* No need to have BOOST_LIBRARIES anymore, only BOOST_PYTHON_LIBRARIES
  is a direct dependency through USD headers.
* OpenVDB is no longer a static library, no need to link its dependencies.

Pull Request: https://projects.blender.org/blender/blender/pulls/133424
2025-01-22 10:02:22 +01:00
Campbell Barton
d1e3db71a6 Cleanup: use "_num" suffix instead of "tot_" prefix
Also group array with its length argument.
2025-01-21 16:51:41 +11:00
Jacques Lucke
987003d456 Nodes: replace some node checks with accessor method calls
This uses the following accessor methods in more places in more places:
`is_group()`, `is_group_input()`, `is_group_output()`, `is_muted()`,
`is_frame()` and `is_reroute()`.

This results in simpler code and reduces the use of `bNode.type_legacy`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132899
2025-01-17 12:17:49 +01:00
Hans Goudey
f2c9fccee0 Cleanup: Move legacy node integer types defines to separate header
Moving these defines to a separate header makes their "legacy" status
more obvious. This commit just adds the include wherever necessary.

Followup to 971c96a92c.

Pull Request: https://projects.blender.org/blender/blender/pulls/132875
2025-01-09 20:03:08 +01:00
Jacques Lucke
971c96a92c Nodes: rename integer type of nodes to type_legacy
The new description for `bNode.type_legacy`:
```
  /**
   * Legacy integer type for nodes. It does not uniquely identify a node type, only the `idname`
   * does that. For example, all custom nodes use #NODE_CUSTOM but do have different idnames.
   * This is mainly kept for compatibility reasons.
   *
   * Currently, this type is also used in many parts of Blender, but that should slowly be phased
   * out by either relying on idnames, accessor methods like `node.is_reroute()`.
   *
   * A main benefit of this integer type over using idnames currently is that integer comparison is
   * much cheaper than string comparison, especially if many idnames have the same prefix (e.g.
   * "GeometryNode"). Eventually, we could introduce cheap-to-compare runtime identifier for node
   * types. That could mean e.g. using `ustring` for idnames (where string comparison is just
   * pointer comparison), or using a run-time generated integer that is automatically assigned when
   * node types are registered.
   */
```

Pull Request: https://projects.blender.org/blender/blender/pulls/132858
2025-01-09 15:28:57 +01:00
Falk David
ff91c27481 Cleanup: VSE: Rename SequenceType to StripType as well as flags
Rename the flags from `SEQ_TYPE_*` to `STRIP_TYPE_*`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132753
2025-01-07 16:10:36 +01:00
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Falk David
655a17a6ab Refactor: VSE: Rename Sequence to Strip
This renames the struct `Sequence` to `Strip`.

While the motivation for this partially comes from
the "Sequence Design" #131329, it seems like this
is a good refactor whether the design gets implemented
or not.

The `Sequence` represents what users see as strips in the
VSE. Many places in the code already refere to a `Sequence`
as "strip". It's the C-style "base class" of all strip types.

This also renames the python RNA type `bpy.types.Sequence`
to `bpy.types.Strip` which means that this technically breaks
the python API.

Pull Request: https://projects.blender.org/blender/blender/pulls/132179
2025-01-06 14:19:24 +01:00