Commit Graph

4478 Commits

Author SHA1 Message Date
Aras Pranckevicius
008483fe8a Cleanup: Remove non-working channels parameter of BLF_buffer
BLF_buffer was trying to accept "how many colors channels in output
image?" argument and doing math with it, but in the lowest level code
was always writing out full 4 channels for each pixel.

All the call sites would ever call it with argument of 4 however, and
that is why no one noticed the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/121630
2024-05-10 18:54:53 +02:00
Sergey Sharybin
7b4232e8aa Compositor: Move Execution Mode and Precision from bNodeTree to Scene
This allows to expose these settings in the Performance panel in the
render buttons. Also moves compositor-specific options away from the
generic node tree structure.

For the backwards-compatibility the options are still present in the
DNA for the bNodeTree. This is to minimize the impact on the Studio
which has used the GPU compositor for a while now. They can be
removed in a future release.

There is no functional changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/121583
2024-05-10 18:08:33 +02:00
Clément Foucault
7859e0f606 EEVEE-Next: Rename engines and set it default in startup file
Finally.

Pull Request: https://projects.blender.org/blender/blender/pulls/121592
2024-05-08 20:57:00 +02:00
Anthony Roberts
570b76f600 Enable sse2neon in BLI_simd except for hydra/USD
This should get all of the tests to pass on Windows ARM64 platforms.

Sadly it needs disabling for hydra/USD stuff as currently it doesn't play nicely with the new preprocessor. @LazyDodo suggested a USD version update may fix this, which is something I can investigate in due course - right now, let's get daily builds up and working :)

Pull Request: https://projects.blender.org/blender/blender/pulls/121361
2024-05-02 20:05:51 +02:00
Brecht Van Lommel
5e772390af Fix #119997: Multires bake wrong result with sharp edges or faces 2024-04-30 16:34:40 +02:00
Campbell Barton
c0def6c93d Cleanup: spelling in comments 2024-04-27 11:58:02 +10:00
Omar Emara
757da9dbc1 Cleanup: Remove redundant compositor arguments
The compositor execute functions have a `rendering` argument to specify
if the compositor is executing as part of the render pipeline. But the
render context argument is null if we are not rendering, so the
`rendering` arguement is redundant and can be removed.

Additionally, we no longer use use_file_output as a hack to detect
rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/120659
2024-04-16 09:11:39 +02:00
Omar Emara
2cf8b5c4e1 Compositor: Improve interactivity for GPU compositing
This patch improves the interactivity of the GPU compositor for
interactive node tree edits by waiting on GPU work to finish to support
more granular canceling.

This does have a performance penalty, but it does not affect final
rendering and it seems worth it because even though it is slower it will
feel faster for users.

Pull Request: https://projects.blender.org/blender/blender/pulls/120656
2024-04-16 09:10:36 +02:00
Philipp Oeser
605de2f094 Fix #120421: Animated "Burn metadata into image" ignored during render
Seems like scene `RenderData` only gets synched once from `Scene` to
`BaseRender` in `RE_InitState` .
Animation on it is only evaluating on the scene, so the the `BaseRender`
`RenderData` is not properly updated here.

However `R_STAMP_DRAW` is part of that and it is the `BaseRender`
`RenderData` that is checked in `do_render_full_pipeline` (not the
`Scene` one) to determine if we want to stamp.

Later calls to `BKE_render_result_stamp_info` / `renderresult_stampinfo`
/ `stampdata` always get passed the scene, so individual animation stamp
details (such as Render Time) work properly.

So to resolve, use the `Scene` `RenderData` (rather than the
`BaseRender` one) for proper animation update.

NOTE: this (not updating animation of members of `RenderData`) might
actually be a problem elsewhere, too -- havent checked on this in detail
though

Pull Request: https://projects.blender.org/blender/blender/pulls/120429
2024-04-10 11:19:02 +02:00
Campbell Barton
38e4e9c68b Fix potential null pointer dereference from the RenderView::imbuf
This member is checked for null elsewhere, account for a null imbuf
when accessing pixels too.
2024-04-09 14:07:17 +10:00
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