Commit Graph

4468 Commits

Author SHA1 Message Date
Omar Emara 0c91ad9008 Fix #120175: File Output node has wrong BW output
The File Output node produces wrong output when the output is set to BW.
This is because the image saving logic assumes float buffers always have
4 channels and ignores the image buffer channels member. So for single
channel images, the code weighted sum neighbouring pixels and asigned
them as a single pixel, producing bleeding at best and crashes at worst.

To fix this, we skip Color to BW conversion if the image is already BW.
And, we fix the functions that assume 4 channels for float buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/120206
2024-04-04 08:51:57 +02:00
Campbell Barton d5d1025e94 Cleanup: use const pointer arguments 2024-04-03 10:22:05 +11:00
Sergey Sharybin 598819049e Fix #120007: Crash rendering when using OptiX and Grease Pencil on recent drivers
The issue seems to be caused with the recent NVidia drivers, which will
crash if OptiX context is created prior to the OpenGL context on Linux.
This happens with drivers 545.29.06, 550.54.14, 550.67 and kernel 6.8
on Ubuntu 24.04, and also happens with NVidia driver 550.67 on Gentoo.

While it does seem the issue is likely on the driver side, the timeline
for it being resolved there is unknown. Until then it is possible to
apply workaround on Blender side, which will initialize GPU context
prior to rendering with an external render engine when it is known the
GPU context will be needed later on.

Note this is not a complex fix, because in general it's still possible to
render a frame without and then with grease pencil, in which case OptiX
will still be initialized first. But we don't want to always initialize
OpenGL, and we can't predict future operations.

Pull Request: https://projects.blender.org/blender/blender/pulls/120026
2024-03-28 18:00:30 +01:00
Campbell Barton b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Campbell Barton 2a892012be Render: correct buffer sizes for render cache paths
FILE_CACHE_MAX was meant to be larger than FILE_MAX to make room
for additional layers in the path. An error in the define used
`FILE_MAXFILE + FILE_MAXFILE` instead of `FILE_MAXDIR + FILE_MAXFILE`
causing the value to be smaller allowing a buffer overflow when passing
the string into BLI_path_abs.

Correct the define and call on the directory component before
the file is added so it doesn't clamp the string length unnecessarily.

Note that some values weren't correct since the original commit [0],
although [1] moved them to a shared incorrect define.

[0]: 78cdc707ab
[1]: cef1b9c30f
2024-03-28 12:12:05 +11:00
Campbell Barton db466e9578 Fix buffer overflow from passing undersized buffers to BLI_path_abs 2024-03-28 11:40:50 +11:00
Campbell Barton 155dae94d7 Cleanup: code-comments, use doxygen formatting & spelling corrections
Also move some function doc-strings from the implementation
to their declarations.
2024-03-26 17:55:20 +11:00
Omar Emara 6d7b4e049e Compositor: Refactor backdrop offset
This patch refactors the backdrop offset to be stored as a float instead
of an int and to be stored in the image runtime structure instead of the
image itself.

Pull Request: https://projects.blender.org/blender/blender/pulls/119877
2024-03-26 07:49:33 +01:00
Hans Goudey 893130e6fe Refactor: Remove unnecessary C wrapper for GPUBatch class
Similar to fe76d8c946

Pull Request: https://projects.blender.org/blender/blender/pulls/119898
2024-03-26 03:06:25 +01:00
Sergey Sharybin 7e2d54e786 Fix: Assert when exiting Metal rendered viewport
This commit fixes the following assert:
  mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'

It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.

This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.

Pull Request: https://projects.blender.org/blender/blender/pulls/119868
2024-03-25 11:28:28 +01:00
Lukas Stockner 05a9f96446 Fix: Add missing callback reset in RE_InitRenderCB
This caused an ASan abort while looking into #101993.

From what I can tell, the issue is that when you click the render button on
the Render Layer node, RENDER_OT_render sets the callback. Then, when you
hit F12 later, it reuses the Render from before, including the callback,
but the corresponding handle has been freed already.
2024-03-25 01:38:55 +01:00
Hans Goudey fe76d8c946 Refactor: Remove unnecessary C wrappers for vertex and index buffers
Now that all relevant code is C++, the indirection from the C struct
`GPUVertBuf` to the C++ `blender::gpu::VertBuf` class just adds
complexity and necessitates a wrapper API, making more cleanups like
use of RAII or other C++ types more difficult.

This commit replaces the C wrapper structs with direct use of the
vertex and index buffer base classes. In C++ we can choose which parts
of a class are private, so we don't risk exposing too many
implementation details here.

Pull Request: https://projects.blender.org/blender/blender/pulls/119825
2024-03-24 16:38:30 +01:00
Hans Goudey 8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Sergey Sharybin 444bc3154a Merge branch 'blender-v4.1-release' 2024-03-15 15:24:52 +01:00
Sergey Sharybin e2d7bd199e Fix #119427: UI: The Metadata is gone for the rendered image
This is a regression since d579ac2b3f

Ensure that the image buffers used by render passes have metadata at the
end of render, similarly to how stamping happens. This solves the reported
issue, and makes the metadata behave consistently, independent on how the
image buffer is accessed.

Thanks Philipp Oeser for investigation and pin-pointing the bad commit!

Pull Request: https://projects.blender.org/blender/blender/pulls/119503
2024-03-15 15:24:33 +01:00
Hans Goudey f6f767b879 Cleanup: Rename "me_eval" to "mesh_eval"
Similar to 854cdd1180
2024-03-11 11:21:18 -04:00
Hans Goudey 744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own",  "her own", or "the object's own".
It also isn't used separately to mean something like "separate".

Also, "its own" is correct instead of "it's own" which is a misues of the verb.
2024-03-07 16:23:35 -05:00
Campbell Barton 0cd414120b Unbreak build on macOS with AppleClang from recent cleanup
Exact an exact match with Clang broke building when the compiler ID
was "AppleClang", reverting parts of [0].

[0]: 6549019ae1
2024-03-07 19:56:58 +11:00
Campbell Barton 6549019ae1 Cleanup: use STREQUAL instead of MATCHES for exact comparisons
MATCHES takes a REGEX and searches the input for a match,
this isn't necessary for CMAKE_SYSTEM_PROCESSOR & CMAKE_*_COMPILER_ID.
2024-03-07 17:56:41 +11:00
Anthony Roberts 445fd42c61 Windows: Add ARM64 support
* Only works on machines with a Qualcomm Snapdragon 8cx Gen3 or above.
  Older generation devices are not and will not be supported due to
  some driver issues
* Requires VS2022 for building.
* Uses new MSVC preprocessor for sse2neon compatibility.
* SIMD is not enabled, waiting on conversion of blenlib to C++.

Ref #119126

Pull Request: https://projects.blender.org/blender/blender/pulls/117036
2024-03-06 16:14:34 +01:00
Sergey Sharybin 3fcd7ccbc0 Compositor: Enable lock-free GPU context activation on macOS
This required to apply a small fix in the Metal texture uploader.

Without synchronization pixels of a wrong pass can be uploaded to
a wrong texture. This is because this code path is heavily reusing
temporary allocations, and at some point the allocation is not
considered as still in use, unless the command buffer used by the
texture uploader is submitted.

Ref #118919

Pull Request: https://projects.blender.org/blender/blender/pulls/118920
2024-03-01 14:38:09 +01:00
Campbell Barton ca8dc11a85 Merge branch 'blender-v4.1-release' 2024-03-01 16:25:29 +11:00
Campbell Barton 65f5e8b775 Cleanup: undefined defined variable warnings with CMake 2024-03-01 16:22:06 +11:00
Sergey Sharybin d5bd5415ec Compositor: Enable lock-free GPU context activation on Windows
Pull Request: https://projects.blender.org/blender/blender/pulls/118909
2024-02-29 17:22:08 +01:00
Bastien Montagne de5451b112 Cleanup: Move `BKE_anim_data` header to be fully C++. 2024-02-28 11:51:03 +01:00
Campbell Barton 7db790c4b7 Cleanup: spelling in comments 2024-02-28 12:13:20 +11:00
Aras Pranckevicius e76b848697 Cleanup: Video: change bMovieHandle function to take ImBuf as input
Towards #118493: make movie writing functionality take ImBuf instead
of int* to pixel data.

While at it, make other bMovieHandle functions use "bool" return type
when it is strictly a success/failure result.

Pull Request: https://projects.blender.org/blender/blender/pulls/118559
2024-02-21 12:57:36 +01:00
Aras Pranckevicius 447bb9a4b9 Cleanup: Move BKE_writeavi.h to C++ and rename to BKE_writemovie.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/118506
2024-02-20 14:49:23 +01:00
Sergey Sharybin 43ed74f7a2 Fix crash in GPU compositor when running from command line
The non-locking context activation expects the render engine to
have its own GPU contexts, which is not necessarily the case when
compositing happens from the command line.

Ensure that the contexts exist prior to attempt of activating them.

Pull Request: https://projects.blender.org/blender/blender/pulls/118496
2024-02-20 12:22:43 +01:00
Brecht Van Lommel 0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Omar Emara 4780cd3368 Fix: GPU compositor ignores border region
The GPU compositor does not take the border region into consideration,
which means it reads more than it should, leading to corruption. Fix
this by taking the border region into account when computing render
width and height.
2024-02-15 12:56:16 +02:00
Campbell Barton 5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11:00
Sergey Sharybin 33af56f13e GPU Compositor: Avoid global DST lock on Linux
It is not required to hold the lock of DST when performing
compositing on GPU, as the compositor implementation uses the
GPU module directly, bypassing the draw manager.

However, currently this is known to cause issues on macOS,
and is not yet tested on Windows.

On Linux it works correctly, and avoids lock while compositor
is running.

There could still be a small locking hiccup, when the GPU
context is created and disposed. This needs to be looked
into.

Pull Request: https://projects.blender.org/blender/blender/pulls/118286
2024-02-14 19:30:38 +01:00
Hans Goudey 1c0f374ec3 Object: Move transform matrices to runtime struct
The `object_to_world` and `world_to_object` matrices are set during
depsgraph evaluation, calculated from the object's animated location,
rotation, scale, parenting, and constraints. It's confusing and
unnecessary to store them with the original data in DNA.

This commit moves them to `ObjectRuntime` and moves the matrices to
use the C++ `float4x4` type, giving the potential for simplified code
using the C++ abstractions. The matrices are accessible with functions
on `Object` directly since they are used so commonly. Though for write
access, directly using the runtime struct is necessary.

The inverse `world_to_object` matrix is often calculated before it's
used, even though it's calculated as part of depsgraph evaluation.
Long term we might not want to store this in `ObjectRuntime` at all,
and just calculate it on demand. Or at least we should remove the
redundant calculations. That should be done separately though.

Pull Request: https://projects.blender.org/blender/blender/pulls/118210
2024-02-14 16:14:49 +01:00
Sergey Sharybin a8a05ebba1 Compositor: Switch CPU compositor to Full-Frame
The tiled compositor code is mainly still around, which is only
expected to be a short-lived period. Eventually it will also be
removed.

The OpenCL, Group Buffers, and Chunk size options are already removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/118010
2024-02-14 14:23:49 +01:00
Campbell Barton 976c56e69c Cleanup: unused includes in source/blender/render
Remove 37 includes.
2024-02-13 19:20:59 +11:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 29fe777445 Cleanup: Make `BKE_report.h` a full Cpp header. 2024-02-10 18:34:29 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne deab8c085a Cleanup: Move `BKE_callbacks.h` and `BKE_cachefile.h` to CPP headers. 2024-02-09 19:29:34 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Sergey Sharybin a18324ff10 Fix compilation error when WITH_COMPOSITOR_CPU is OFF
The render only uses `ProfilerData` for which it is enough to only
have header. No linking is needed to the bf_compositor for things
to work.

Pull Request: https://projects.blender.org/blender/blender/pulls/118030
2024-02-09 10:55:23 +01:00
Sergey Sharybin 467a132166 Compositor: Implement per-node execution time report
Visually it is the same as the execution time implemented for the
geometry nodes, and it is to be enabled in the overlay popover.

The implementation is separate from the geometry nodes, as it is
not easy or practical to re-use the geometry nodes implementation.

The execution time is stored in a run-time hash, indexed by a node
instance key. This is similar to the storage of the mode preview
images, but is stored on the scene runtime data and not on the node
tree. Indexing the storage by key allows to easily copy execution
statistics from localized tree to its original version.

The time is only implemented for full-frame compositor, as for the
tiled compositor it could be tricky to calculate reliable time for
pixel processing nodes which process one pixel at a time.

Pull Request: https://projects.blender.org/blender/blender/pulls/117885
2024-02-09 10:19:24 +01:00
Bastien Montagne 9a1651533d Cleanup: Make `io/usd/hydra` and `render/hydra` headers fully Cpp ones.
This code was actually already full Cpp, so it's essentially a massive
filenames cleanup.
2024-02-06 12:00:34 +01:00
Damien Picard fa77e9142d UI: fix and improve a few messages
- "can not" -> "cannot" in many places (ambiguous, also see
  Writing Style guide).
- "Bezier" -> "Bézier": proper spelling of the eponym.
- Tool keymaps: make "Uv" all caps.
- "FFMPEG" -> "FFmpeg" (official spelling)
- Use MULTIPLICATION SIGN U+00D7 instead of MULTIPLICATION X U+2715.
- "LClick" -> "LMB", "RClick" -> "RMB": this convention is used
  everywhere else.
- "Save rendered the image..." -> "Save the rendered image...": typo.
- "Preserve Current retiming": title case for property.
- Bend status message: punctuation.
- "... class used to define the panel" -> "header": copy-paste error.
- "... class used to define the menu" -> "asset": copy-paste error.
- "Lights user to display objects..." -> "Lights used...": typo.
- "-setaudio require one argument" -> "requires": typo.

Some issues reported by Joan Pujolar and Tamar Mebonia.

Pull Request: https://projects.blender.org/blender/blender/pulls/117856
2024-02-05 17:08:17 +01:00
Jacques Lucke 319b911784 Cleanup: move hash and ghash utils to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/117761
2024-02-02 19:55:06 +01:00
Aras Pranckevicius 0bfffdaf82 VSE: bilinear upscaling no longer adds transparent border around the image
Part of overall "improve image filtering situation" (#116980), this PR addresses
two issues:
- Bilinear (default) image filtering makes half a source pixel wide transparent
  border around the image. This is very noticeable when scaling images/movies up
  in VSE. However, when there is no scaling up but you have slightly rotated
  image, this creates a "somewhat nice" anti-aliasing around the edge.
- The other filtering kinds (e.g. cubic) do not have this behavior. So they do
  not create unexpected transparency when scaling up (yay), however for slightly
  rotated images the edge is "jagged" (oh no).

More detail and images in PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/117717
2024-02-02 16:28:51 +01:00
Philipp Oeser 5e2bad1589 Fix #117674: stereoscopy rendering with overwrite disabled broken
This would still overwrite (even though frames existed).

Mistake in 6b9a500a3a.

char "filepath" was already in use/shadowed, instead use "filepath_view" to
correctly glue path/suffix together (as done already a bit below for the
R_TOUCH case).

Pull Request: https://projects.blender.org/blender/blender/pulls/117696
2024-02-01 09:50:48 +01:00
Hans Goudey fac27b1b6b Cleanup: Replace most used of SWAP macro with std::swap
Also remove / replace use of the math vector double swapping functions.
2024-01-31 21:12:16 -05:00
Campbell Barton 948e806a1a Cleanup: add PyC_UnicodeFromStdStr utility function
Add a std::string wrapper for PyC_UnicodeFromBytesAndSize.
2024-01-30 15:56:08 +11:00