Commit Graph

14100 Commits

Author SHA1 Message Date
Campbell Barton
e8de8ee85a Fix hang on startup under Wayland with the WayFire compositor (#2)
Disable use of LIBDECOR on WAYFIRE as it causes Blender to hang
on window creation.

Detect WAYFIRE using the presence of the `zwf_shell_manager_v*`
interface, don't use LIBDECOR if this is found.

This is an alternative fix to [0] which also disabled LIBDECOR
but caused LIBDECOR not to be used in GNOME on some systems.

I'm not keen on this solution, but it seems alternatives are less
reliable. See code-comment for details.

[0]: 3a5389d5abe00aa229b5c6d35d346cb8f7cbe649
2024-04-30 14:50:56 +10:00
Campbell Barton
3a2fafba73 Revert "Fix hang on startup under Wayland with the WayFire compositor"
This reverts commit 3a5389d5abe00aa229b5c6d35d346cb8f7cbe649.

It seems XDG_CURRENT_DESKTOP isn't reliably set,
causing no titlebar on GNOME, see #121241.

The WAYFIRE workaround will need to be resolved another way.
2024-04-30 14:34:55 +10:00
Michael Jones
9b833fdeba Cycles: Use more accurate GPU counter timestamps for profiling in Metal
This PR replaces the existing CPU wall-clock based profiling mechanism with more precise GPU counter based timestamps. As before, it is enabled by setting the env var `CYCLES_METAL_PROFILING=1`. Original implementation by Morteza Mostajabodaveh.

Pull Request: https://projects.blender.org/blender/blender/pulls/121208
2024-04-29 15:25:32 +02:00
Brecht Van Lommel
4832abf108 Cleanup: Compiler warning when building without OSL 2024-04-29 15:22:21 +02:00
David Murmann
ee51f643b0 Cycles: Ray Portal BSDF
Transport rays that enter to another location in the scene, with
specified ray position and normal. This may be used to render portals
for visual effects, and other production rendering tricks.

This acts much like a Transparent BSDF. Render passes are passed
through, and this is affected by light path max transparent bounces.

Pull Request: https://projects.blender.org/blender/blender/pulls/114386
2024-04-29 12:37:51 +02:00
Alaska
f8c0050a25 Shaders: Add Roughness to Subsurface Scattering Node
Matching the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/114499
2024-04-29 10:54:29 +02:00
Campbell Barton
3a5389d5ab Fix hang on startup under Wayland with the WayFire compositor
Use XDG_CURRENT_DESKTOP to check if GNOME is running.

Previously the existence of a `gtk_shell*` interface was used however
the WAYFIRE compositor provides this interface which made GHOST require
LIBDECOR.

Initializing LIBDECOR was hanging as the initial configuration was
never seen. From a quick check it doesn't seem like a bug in Blender's
LIBDECOR use, the issue may be in either LIBDECOR or WAYFIRE.
Whatever the case, LIBDECOR isn't needed so workaround the bug by
changing how GNOME is detected.
2024-04-29 12:32:22 +10:00
Campbell Barton
c0def6c93d Cleanup: spelling in comments 2024-04-27 11:58:02 +10:00
Brecht Van Lommel
b306b3bd32 Fix #121097: Cycles issue with sharp edges in mesh edit mode
The normal domain needs to be checked after converting the editmesh to
mesh.
2024-04-26 20:08:41 +02:00
Alaska
afa66fc628 Shader: Clamp invalid inputs of various BSDF nodes
Clamp some of the inputs of the Glossy BSDF, Glass BSDF, Sheen BSDF,
and Subsurface Scattering nodes to improve consistency between render
engines and to avoid unexpected results.

* Clamp roughness to 0..1
* Clamp subsurface radius to 0..inf
* Clamp colors to 0..inf

Pull Request: https://projects.blender.org/blender/blender/pulls/120390
2024-04-26 17:39:39 +02:00
Alaska
03cb588529 Refactor: Cycles: Replace fixed Tangent input with custom input
This replaces the fixed Tangent input in BsdfNode::compile
with a custom input.

This is done because very few nodes actually use the tangent input
and it would be better to have this slot available for other inputs
on different nodes in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/119042
2024-04-26 15:25:14 +02:00
Campbell Barton
c444f128d3 WM: add a capability flag for physical trackpad direction
Support detecting if the trackpad direction flag is propertly set
(currently unused).

Needed so Wayland compositors that don't support seat-version 9 or
newer (GNOME-46 & KDE5 for e.g) can have a working trackpad.

Eventually this option will be removed when the functionality is
widely supported.
2024-04-26 21:26:49 +10:00
Sergey Sharybin
b24c91e93e Fix #119791: Cycles: Transparent hair curves render slow with volumes
The slowdown was caused by the volume step calculation returning an
infinite value. This was caused by the calculation happening before
the object bounds are calculated via the code path which does some
early update for the displacement and hair transparency. The actual
value was never re-calculated after bounds are valid.

The solution is to only clear need-update after the final call of
the device_update_flags().

Pull Request: https://projects.blender.org/blender/blender/pulls/121042
2024-04-24 20:15:58 +02:00
Ben-7
0136289cb6 CMake: Windows: clang-cl fixes
Support for building blender with clang on windows on x64 was added
years ago but given there are no active users support has crumbled a
bit.

This PR brings the build system back into working order but upstream
patches in openVDB are still required for a successful build see PR
#120317 for details.

Blender when build with clang the classroom scenes rendered on the cpu
with cycles is seeing a 5% reduction in render time on both an
AMD 7700x and an Intel 14900k.
2024-04-24 15:59:47 +02:00
YimingWu
ab72da8b5c Fix #120763: Fix memory leak in itasc cache
`Cache::addChannel` would return early when new cache entry insertion
isn't success, but the newly created cache entry isn't deleted upon
return, this patch fixes this.

Pull Request: https://projects.blender.org/blender/blender/pulls/120766
2024-04-24 09:35:04 +02:00
Campbell Barton
d544082e1d Fix #120925: Smooth scrolling mouse wheel broken on Wayland
Accumulate scrolling for mouse wheels that create scroll values below
a single "click".

Regression in [0], caused by bumping the seat API.

[0]: 8d86fb43a4eab6e538796fd0d9f310e58a209315
2024-04-23 13:34:59 +10:00
Fermin
821b773d95 FIX #109121: VR: Render controllers only if they are active
When turning on VR mode, if no controllers are available,
a fallback model (a sphere) is rendered in the middle of the VR area.

This change uses the OpenXR API to check if the controllers are
available, sets new properties in `GHOST_XrPose` and `wmXrController`
that store if each controller is active or not, and uses
those properties to render the controllers in the VR view only
when they are active.

NOTE: in `wmXrController`, two state properties have been included,
but only `grip_active` is currently used. `aim_active` has been
included for consistency, but it could be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119989
2024-04-21 03:28:35 +02:00
Campbell Barton
fd589fdca4 Cleanup: various non functional C++ changes 2024-04-20 13:46:14 +10:00
Campbell Barton
c6a9b11ef6 Cleanup: use const pointers 2024-04-20 12:41:23 +10:00
Hans Goudey
7f5dd29abd Subdiv: Make OpenSubdiv_TopologyRefiner into a C++ class
Replace the C-class pattern function pointers with actual class methods.
Other than the obvious benefit of not requiring the "this" pointer to be
explicitly passed into every function call, this will make it much simpler
to remove the entire C-API class and replace it with its "impl" next.

For that next step we need to expose code to the implementation
of the topology refiner, so instead of defining stubs locally in the
opensubdiv intern class, we spread some WITH_OPENSUBDIV checks
in the blenkernel. As far as I know this is the only way to remove the
intermediate C-API and call opensubdiv functions directly from there.
2024-04-19 09:03:48 -04:00
Hans Goudey
ec09931d55 Subdiv: Use nested namespaces and static for opensubdiv module
Declaring the `blender::opensubdiv` namespace on one line is just shorter.
`static` is preferred over anonymous namespaces since it's locally visible.
2024-04-19 09:03:23 -04:00
Campbell Barton
4e8b24f1d1 Cleanup: spelling in comments & punctuation 2024-04-19 15:57:06 +10:00
Weizhen Huang
8e5840359f Refactor: deduplicate assignment of background light group
by ensuring `KernelLight.lightgroup` is properly assigned in
`device_update_light()`. The value is later retrieved via
`lamp_lightgroup(kg, lamp)`.

`light_manager->device_update()` is called after
`background->device_update()`, so the background light group should
already been assigned when `device_update_lights()` is called.

Pull Request: https://projects.blender.org/blender/blender/pulls/120714
2024-04-17 18:49:03 +02:00
Weizhen Huang
a6330cad7f Refactor: wrap block of codes into a function 2024-04-17 18:49:00 +02:00
Weizhen Huang
45d2e46752 Cleanup: remove unnecessary shader flag in Chiang Hair BSDF
lcg is not needed since 5f9b518a8bf2f87e8aba19f661d526a3d93d7364
2024-04-17 18:49:00 +02:00
Weizhen Huang
481b50e06d Cleanup: pass shader flag as parameter instead of ShaderData 2024-04-17 18:49:00 +02:00
Weizhen Huang
2e1380fa0c Cleanup: use available function to compute render buffer pointer
use available `film_pass_pixel_render_buffer()` to access the pointer
to the render buffer.
For shadow state, a similar function `film_pass_pixel_render_buffer_shadow()`
is created, because `shadow_path` instead of `path` is needed.
2024-04-17 18:49:00 +02:00
Weizhen Huang
0c9ce4ba4f Refactor: handle MIS weight in lower-level functions
it is difficult to keep in mind when MIS weight is needed, better to
handle this logic in the lower-level functions.
This reduces code duplication in many places.
2024-04-17 18:49:00 +02:00
Weizhen Huang
418acfe8bb Cleanup: remove unused function parameters
This is not a complete list of all the unused parameters in kernel, but
those I touch often, so I am more confident that it's safe to delete them.
2024-04-17 18:49:00 +02:00
Hans Goudey
6a21ff9154 Cleanup: Remove includes and "using std" for opensubdiv wrapper
Avoid unnecessary indirect includes for the module, which would slow
down compilation. Avoid "using std" which is generally not considered
good practice since it's helpful to see what namespace things are from.

This is just a general cleanup of the area. I was trying to understand
it better to reduce redundant mesh topology storage but finding that
some intermediate cleanups would be helpful to ease the change.

Pull Request: https://projects.blender.org/blender/blender/pulls/120743
2024-04-17 17:22:22 +02:00
Campbell Barton
cf37424203 Cleanup: use const pointers, quiet cppcheck unreadVariable warning 2024-04-17 11:36:38 +10:00
Campbell Barton
8680976dc9 Cleanup: match function/declaration names 2024-04-17 11:36:36 +10:00
Campbell Barton
20b0805213 Cleanup: use const pointers where possible 2024-04-16 12:27:47 +10:00
Campbell Barton
90f1d1cc61 Cleanup: use doxygen formatting for guarded-allocator 2024-04-16 12:27:13 +10:00
Jacques Lucke
00648411ea MEM: support overaligned types in MEM_cnew_array
This is similar to the recent change for `MEM_cnew`: 60a3d85b888c70330b7f9e691d8e82d66561d0f1.
A new function called `MEM_calloc_arrayN_aligned` is added that is used by both `cnew` functions now.

Pull Request: https://projects.blender.org/blender/blender/pulls/120632
2024-04-15 19:11:06 +02:00
Lukas Stockner
c9c777ddaa Fix #70114: Cycles: Particle systems missing in headless multiview render
The problem here was that `free_data_after_sync` frees the particle cache in headless or locked-UI mode, but the second view doesn't regenerate them.

For multi-view renders, dropping caches is a tradeoff between compute and memory - dropping allows to reduce peak memory usage, but requires recomputation for the next view. With the current design however, dropping is not something that is easily achievable anyways (see the referenced bugs). So until something more reliable and better fitting is implemented, keep the data from Blender side until the last view.

Since `free_data_after_sync` doesn't do anything for baking or viewport renders anyways, it's easiest to just move this out into `BlenderSession::render` since that already checks whether another view is still outstanding.

Also fixes #73221 and #107589.

Pull Request: https://projects.blender.org/blender/blender/pulls/120543
2024-04-15 17:40:53 +02:00
Alaska
1dede89eee Refactor: Allow get_apple_gpu_architecture to report non Apple GPUs
get_apple_gpu_architecture will now report if the GPU being checked
is not an Apple GPU.

At the moment this has no functional changes. But it reduces the
chances of mistakes in the future where a developer tries to enable
a feature on newer Apple GPUs using get_apple_gpu_architecture,
and accidentally enables it on unsupported AMD and Intel GPUs.

Pull Request: https://projects.blender.org/blender/blender/pulls/120448
2024-04-15 15:04:23 +02:00
Jacques Lucke
e3b8d45c93 Cleanup: move mallocn to c++
Required for a cleaner solution for #120632.
2024-04-15 13:02:17 +02:00
Patrick Mours
33d7fa8cb3 Fix #119959: Enabling "Distribute memory between devices" for Cycles results in error
With the switch to using the primary CUDA context it became possible
for peer access between CUDA devices to already have been enabled for
that context, either by a previous Cycles session or third-party library,
thus causing the call to `cuCtxEnablePeerAccess` to return
`CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED`. This is not a failure
state however, so just needs to be handled like a success return value.

Pull Request: https://projects.blender.org/blender/blender/pulls/120255
2024-04-15 12:17:32 +02:00
Damien Picard
c306677119 I18n: extract and disambiguate a few messages
Extract
- Statuses for the external text editor
- Newly created enum node item
- Newly created plane track data
- Newly created custom orientation data
- Operator names in drag and drop menu (need to use operator's
  translation context)
- GN attribute statistic node inputs

Disambiguate
- Single-letter colors: A and B can mean Alpha and Blue, or simply A
  and B as in two operands in an operation
- Dissolve: issue reported by Tamar Mebonia in #43295
- Translate in the User Preferences. This introduces a new
  BLT_I18NCONTEXT_EDITOR_PREFERENCES ("Preferences") translation
  context
- Planar (reported by deathblood)
  This one is incomplete, because there is currently no way to
  disambiguate presets or GN fields. I don't see how either could be
  achieved cleanly.
  The former would need to define the context inside the preset and
  evaluate the file prior to showing it in the presets menu, which
  sound bad.
  The latter would need to introduce an additional string inside
  `FieldInput`s, which would be controversial given how little it
  would be used.

Remove
- Unused translation `iface_("%s")` in toolbar
- Remove obsolete N_() tags in a few node descriptions.

Pull Request: https://projects.blender.org/blender/blender/pulls/119065
2024-04-15 12:02:17 +02:00
Campbell Barton
1f44a74947 Fix inverted table wheel on wayland
The tablet wheel direction matches the mouse wheel which also needed
to be inverted.
2024-04-15 11:39:04 +10:00
Campbell Barton
1e6716a903 Fix inverted mouse wheel on wayland after recent changes
Recent change from [0] inverted mouse wheel direction.

[0]: c9a79f9a3c283ba8269da253411b6c9ec49aaf28.
2024-04-15 11:06:47 +10:00
dupoxy
1079f0918e Cleanup: use function style cast in MAKE_ID macro
Ref: !120630
2024-04-14 23:08:45 +10:00
Campbell Barton
b405bb3268 GHOST/Wayland: constrain new window size on startup with XDG-decor
On KDE, running "blender -w" (windowed with borders) created window
which was too big: the window contents matched the screen-size
causing the window decorations be outside the screen-bounds.

Un-maximizing the default startup file would also move window to the
same over-sized location.

Resolve by clamping the size of new windows to the requested bounds.
2024-04-14 22:19:24 +10:00
Jacques Lucke
0a192c5da4 Cleanup: fix compilation
Missing from e27889dc12e16a9a7f2c72210fa3e6cb3b968100.
2024-04-14 10:50:54 +02:00
Campbell Barton
c9a79f9a3c WM: handle multiple wheel events from GHOST
Scrolling the mouse wheel fast can generate multiple click-steps
which were ignored by window manager events.

This meant scrolling fast with a trackpad (with "Multi-touch gestures"
disabled) for e.g. would zoom less than the gesture made more slowly.
2024-04-14 17:55:20 +10:00
Campbell Barton
c4745a24b2 GHOST/Wayland: bump xdg_toplevel_listener version from 1 to 6 2024-04-14 17:55:17 +10:00
Campbell Barton
cc9edd2d35 GHOST/Wayland: bump zxdg_output_manager_v1 version from 2 to 3 2024-04-14 17:55:15 +10:00
Campbell Barton
dcec5ce635 GHOST/Wayland: bump wl_compositor_interface version from 3 to 6 2024-04-14 17:55:14 +10:00
Campbell Barton
6689053e43 GHOST/Wayland: bump wl_output_listener version from 2 to 4 2024-04-14 17:55:13 +10:00
Campbell Barton
8d86fb43a4 GHOST/Wayland: bump wl_seat_interface version from 5 to 9
This ensures callbacks are called to detect "natural" scroll direction
on the touch-pad, see: #107676.
2024-04-14 17:55:11 +10:00
Campbell Barton
98cb5da6d1 GHOST/Wayland: add an interface version clamping macro
This macro makes it convenient to define a supported version range for
an interface.

Uncommenting USE_VERBOSE_OLD_IFACE_PRINT prints when newer versions
of an interface are supported by the compositor which Blender could
be updated to support.

This makes it more convenient to bump interface versions as they
become available so bumping multiple versions at once doesn't
cause unexpected changes in behavior as happened with #120587.
2024-04-14 17:55:10 +10:00
Campbell Barton
df87770ca1 GHOST/Wayland: resolve mouse wheel being treated like touchpad scroll
Resolves the issue reported in #120587, which occurred when bumping the
supported version of the seat API to 9.

Smooth scrolling values were set in without calling the discrete step
callback. Resolve by calculating discrete values from the:
wl_pointer_listener::axis_value120 handler.

The functional changes from this commit only apply once the version
of the seat API is increased - which isn't part of this commit.
2024-04-14 17:55:09 +10:00
Campbell Barton
e27889dc12 Cleanup: use const references for GWL_RegistryHandler parameters 2024-04-14 17:54:59 +10:00
Campbell Barton
dce8668b1f GHOST/Wayland: use discrete zoom steps with multi-touch disabled
This matches behavior on macOS as well as the property description.

On Wayland, smooth scrolling doesn't use the touchpad API,
so disabling multi-touch gestures doesn't change the behavior as it
does on macOS.

Resolve by converting vertical touch scrolling to mouse-wheel events.
2024-04-14 14:56:30 +10:00
Campbell Barton
f12d20a819 Cleanup: always reset discrete mouse-wheel
A correctness issue, this didn't cause any bugs.
2024-04-14 14:23:36 +10:00
Campbell Barton
a70d6d79dd Cleanup: various non-functional C++ changes 2024-04-14 12:24:17 +10:00
Campbell Barton
6e3eaae299 Cleanup: spelling in comments 2024-04-14 12:13:55 +10:00
Campbell Barton
bf3ca83df9 Cleanup: use C-style comments for descriptive text in GHOST/Cocoa 2024-04-14 09:40:19 +10:00
Clément Foucault
d1d90ecbec Cleanup: MEM: Remove outdated comment 2024-04-12 18:01:26 +02:00
Clément Foucault
60a3d85b88 MEM: Make MEM_cnew return aligned memory
Now made it so that `MEM_cnew()` can be used for types with any
alignment.

Fixes #120407.

Pull Request: https://projects.blender.org/blender/blender/pulls/120569
2024-04-12 17:52:27 +02:00
Hans Goudey
30c3f8eafb Revert "Fix #107676 detection of "natural" touchpad scrolling on Wayland"
This reverts commit af88ff04848b1ff299514514fb18ecf401553bb4.

That commit broke scrolling (at least in some cases).
Reverting the commit resolves #120587
2024-04-12 11:47:03 -04:00
Sergey Sharybin
a4b36cd0d5 Guarded allocator: Ensure alignment and size of MemHead
Ensure that the MemHead and MemHeadAligned are such that memory
allocation followed with the head offset keeps the allocation
aligned to at least MEM_MIN_CPP_ALIGNMENT.

Pull Request: https://projects.blender.org/blender/blender/pulls/120582
2024-04-12 17:22:46 +02:00
Sergey Sharybin
fac451e513 Cleanup: Convert guarded allocator to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/120577
2024-04-12 16:44:49 +02:00
Campbell Barton
af88ff0484 Fix #107676 detection of "natural" touchpad scrolling on Wayland
The callback to set the relative direction wasn't running because
it required GHOST to request version 9 of the wl_seat_interface.

Natural touchpad events now work for KDE 6 and recent versions
of WLROOTS based compositors, GNOME 46 is uses wl_seat_interface
version 8 which still wont work.
2024-04-13 00:18:21 +10:00
Campbell Barton
72e6191c89 PyAPI: include a filepath in preset pre_cb/post_cb callbacks
This is needed so the presets path can be stored in the theme,
so it's possible to keep track of the current theme.

Needed for fixing #120289.
2024-04-12 13:21:42 +10:00
Jeroen Bakker
c15e5116ab Vulkan: MoltenVK Support for Developers
MoltenVK original intent was to let developers work on a mac system developing
for the vulkan eco-system. MoltenVK doesn't support all the features that we
require and would require additional workarounds to be actually supported.

It is not expected that we will release Blender with MoltenVK for this reason.
But it still has value for shader developers to validate shaders on metal and
vulkan on a single platform.

![image](/attachments/9a4a9904-a5f6-4922-896d-744dfb78244c)

Pull Request: https://projects.blender.org/blender/blender/pulls/117940
2024-04-11 11:04:43 +02:00
Sergey Sharybin
56cbde568b Fix #120046: Broken render on AMD Metal GPUs
This is a regression since fdc2962bebb

The size of state can not be different between CPU and GPU.

This change replaces compile-time condition with a kernel feature
check, which solves the render regression on AMD Metal. It also
minimizes the state size on other GPUs when Light Tree is disabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/120476
2024-04-11 10:51:45 +02:00
Campbell Barton
09ee8d97e6 Cleanup: use C-style comments for descriptive text 2024-04-11 17:44:27 +10:00
Alaska
eff4fe24cf Cycles: Properly default to Metal-RT off unless GPU is a M3 or newer
Ever since commit [1], `use_metalrt_by_default` will be True
if the GPU being used is not a M1 or M2 based system.
The intention of this was to enable MetalRT by default for
M3 and newer devices that have hardware for ray traversal.

However the side effect of this change was that all AMD GPUs would
have `use_metalrt_by_default` set to True. Which appears to be the
main culprit causing crashes on older AMD GPUs in #120126.
Since these GPUs don't support MetalRT.

This commit fixes this issue by only setting
`use_metalrt_by_default` to True if the GPU is not M1 or M2 based,
and the GPU is Apple Silicon based. Which equates to M3 or newer.
Which is the original intent of this code.

This resolves the issue where AMD GPUs were being told to use MetalRT
by default, when they shouldn't be.

[1] 322a2f7b12bba610a70df3af90e236d0c0ef03f6

Pull Request: https://projects.blender.org/blender/blender/pulls/120299
2024-04-09 16:19:24 +02:00
Campbell Barton
e01525cf2c Cleanup: remove redundant variables & assignments
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
2024-04-09 13:52:41 +10:00
Campbell Barton
6b14b67a29 Cleanup: spelling in comments 2024-04-08 16:23:25 +10:00
Campbell Barton
01187dfc8e GHOST: add missing check for end full-screen failing 2024-04-08 12:03:01 +10:00
Sergey Sharybin
958bc91867 Fix #120308: GP3 objects with geonodes renders original data from CLI
The issue was caused by the special code in Cycles which clears object
caches when it thinks they are not needed. We should not free caches of
grease pencils because it is needed later by a separate render engine.

Pull Request: https://projects.blender.org/blender/blender/pulls/120315
2024-04-05 18:13:12 +02:00
Sergey Sharybin
f6bff96ac5 Fix #120119: Area lamp artifacts in Cycles with light trees
This is a regression in 4.1, caused by 36e603c430.

For unbiased MIS weight in light tree, we should use sd->N for
mis_origin_n, since sc->N is not available in NEE.

The change also makes it so we do not sample lights below sd->N even
when bump map correction is disabled. This diverges from the original
idea of giving full control to artists, but ensures the internal math
is happy.

Pull Request: https://projects.blender.org/blender/blender/pulls/120216
2024-04-05 10:11:33 +02:00
Harley Acheson
b32effdaa8 GHOST/WIN32: Remove Initial UpdateWindow
We call UpdateWindow very early in our window creation, before we get
an openGl surface and before our message queue is ready. This results
in WM_ACTIVATE, WM_SIZE, WM_MOVE, and WM_PAINT messages sent to us
at a time when GetMessageTime() returns zero. This makes our event
message times have a gap between the fourth and fifth messages, equal
to the time since system start. There is no downside to not calling
this at this time.

Pull Request: https://projects.blender.org/blender/blender/pulls/117965
2024-04-05 00:34:23 +02:00
Xavier Hallade
cbc7962a73 Cycles: Tune kernel sizes for oneAPI device
This brings a 1-3% performance improvement depending on the scenes, on
the Arc A770.
2024-04-04 16:04:13 +02:00
Campbell Barton
7e9f7320e4 Cleanup: spelling in comments & comment blocks 2024-04-04 11:26:28 +11:00
Campbell Barton
4d84a45e7e Cleanup: simplify CLG logging append function
- Remove redundant length calculation.
- Remove else-after-break.
2024-04-04 10:55:11 +11:00
Campbell Barton
52ce8d408f Cleanup: use const arguments & variables 2024-04-04 10:55:10 +11:00
Xavier Hallade
891d71a4d4 Cycles: Drop noinline keyword for oneAPI device
fdc2962bebb47e5d55564fcf30b4586f57f4311a indirectly introduced a change
in inlining (light_tree_pdf started getting inlined) that led to a 5-10%
drop in performance for most scenes.
Dropping the noinline keyword for oneAPI device recovers it.
It however brings another performance regression to MNEE and Raytrace
kernels, that we'll look into separately.
2024-04-02 18:29:35 +02:00
Campbell Barton
97d93c7e33 GHOST/Wayland: pass in null when the cursor theme isn't set
While an empty string resolves to the default theme, it's not following
the API specification for wl_cursor_theme_load as it's written.

Checking on wayland internals this looks only to add an unnecessary
theme lookup on an empty string which falls back to the default.

Noticed when investigating #105895 although it seems unlikely
that this chagne would resolve the issue.
2024-04-02 15:11:05 +11:00
Campbell Barton
2be407fc82 Cleanup: spelling in comments 2024-04-01 16:47:57 +11:00
Hoshinova
c78c6b0bdf Fix #119797: Noise Texture Precision Issues
The Perlin noise algorithms suffer from precision issues when a coordinate
is greater than about 250000.

To fix this the Perlin noise texture is repeated every 100000 on each axis.
This causes discontinuities every 100000, however at such scales this
usually shouldn't be noticeable.

Pull Request: https://projects.blender.org/blender/blender/pulls/119884
2024-03-29 16:12:23 +01:00
Brecht Van Lommel
bd1f4343c3 Build: Improve OSL library dependency handling in Cycles
Might fix some missing symbols when the OSL library gets updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/119391
2024-03-29 15:24:30 +01:00
Hans Goudey
bf04da96f3 Fix: Missing change in declaration from previous commit 2024-03-28 19:01:32 -04:00
Hans Goudey
82b88f130a Cleanup: Use const for evaluated cage meshes and related data
Also access the evaluated deform mesh with a function rather than
directly from object runtime data. The goal is to make it easier to use
implicit sharing for these meshes and to improve overall const
correctness.
2024-03-28 18:57:57 -04:00
Campbell Barton
686605a6dd Cleanup: declare arrays as const where possible 2024-03-28 22:57:57 +11:00
Campbell Barton
b2e00d1285 Cleanup: use const pointer arguments 2024-03-28 20:57:50 +11:00
Brecht Van Lommel
53e9fb6b78 Fix #117566: Cycles persistent data not updated by device preferences
Pull Request: https://projects.blender.org/blender/blender/pulls/119970
2024-03-27 18:55:46 +01:00
Brecht Van Lommel
d2b38a475f Fix: Cycles Python error after previous commit 2024-03-27 18:04:19 +01:00
Alaska
a0d5d9137b Fix #119937: Outdated tool tip for Automatic denoiser
Pull Request: https://projects.blender.org/blender/blender/pulls/119940
2024-03-27 17:49:58 +01:00
Weizhen Huang
68253b4937 Fix: Cycles volume light tree using wrong point to compute uncertainty angle
it is not clear from which point the `cos_theta_u` should be computed in
volume segment, so the original implementation was mixing the closest point
and the point where the minimal angle is formed.
Use the closest point on segment as a conservative measure.

Pull Request: https://projects.blender.org/blender/blender/pulls/119965
2024-03-27 15:06:05 +01:00
Weizhen Huang
72780c3769 Fix: Cycles light tree assertion failing on Intel Mac
in the test scene `all_light_types_in_volume.blend`, `theta - theta_o -
theta_u` is slightly above the threshold. Even if we do a strict check
with `acos` on the failing cases, it will go to the other branch and
deliver a result which is also 1.0f. Better to relax the threshold.
2024-03-27 13:46:57 +01:00
Campbell Barton
3f7742f65d GHOST/Wayland: only apply #119871 workaround with LIBDECOR
Disable fix from [0] unless LIBDECOR is used.

This caused:
- KDE 6.0.2 to fail to start full-screen.
- RIVERWM to show a blank preferences.
- HYPRLAND to assert with a negative window height
  when starting full-screen.

Also replace flush & dispatch with a round-trip which fixes an error
on GNOME with non maximized/full-screen windows not showing any contents
on startup until a redraw was triggered.

[0]: 7371b11bb5a5eed0205fba2c8400546073a628d6
2024-03-27 15:04:03 +11:00
Campbell Barton
40ab214c0a Cleanup: spelling in comments 2024-03-27 10:25:31 +11:00
Weizhen Huang
c16fd219a8 Fix #70210: Cycles environment map sampling not accounting for negative values
Cycles samples environment map with a PDF proportional to the luminance.
This computation was assuming positive values, but generated texture
coordinates from world could have negative values, so the resulted CDF
was almost zero in the bug report scene.
Fixed by taking the absolute value when computing luminance in CDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/119896
2024-03-26 16:24:36 +01:00
Weizhen Huang
1bf467aff6 Cleanup: make format 2024-03-26 09:39:22 +01:00
Alaska
a4f1a52a5c Fix #119903: Cycles compilation on device that don't use the light tree
During the some of the shading for volumetrics, Cycles would try to
write to a variable that does not exist if the device has the
light tree disabled.

At the moment this only impacts AMD GPUs with the Metal backend.

Pull Request: https://projects.blender.org/blender/blender/pulls/119906
2024-03-26 08:20:09 +01:00
Hans Goudey
fc0d8ba012 Cleanup: Remove C++ ifdef checks in C++ headers
Pull Request: https://projects.blender.org/blender/blender/pulls/119900
2024-03-26 04:56:03 +01:00
Weizhen Huang
fdc2962beb Fix #114634: correlated samples in volume when using equiangular sampling and light tree
The same random number was used when sampling from the volume segment
and from the direct scattering position, causing correlation issues with
light tree.

To solve this problem, we ensure the same light is picked for
volume segment/direct scattering, equiangular/distance sampling by
sampling the light tree only once in volume segment. From the direct
scattering position in volume, we sample a position on the picked light
as usual. If sampling from the light tree fails, we continue with
indirect scattering.
For unbiased MIS weight for forward sampling, we retrieve the `P`, `D`
and `t` used in volume segment for traversing the light tree.

The main changes are:
1. `light_tree_sample()` and `light_distribution_sample()` now only pick
lights. Sampling a position on light is done separately via
`light_sample()`.
2. `light_tree_sample()` is now only called only once from volume
segment. For direct lighting we call `light_sample()`.
3. `light_tree_pdf()` now has a template `<in_volume_segment>`.
4. A new field `emitter_id` is added to struct `LightSample`, which just
stores the picked emitter index.
5. Additional field `previous_dt = ray->tmax - ray->tmin` is added to
`state->ray`, because we need this quantity for computing the pdf.
6. Distant/Background lights are also picked by light tree in volume
segment now, because we have no way to pick them afterwards. The direct
sample event for these lights will be handled by
`VOLUME_SAMPLE_DISTANCE`.
7. Original paper suggests to use the maximal importance, this results
in very poor sampling probability for distant and point lights therefore
excessive noise. We have a minimal importance for surface to balance, we
could do the same for volume but I do not want to spend much time on
this now. Just doing `min_importance = 0.0f` seems to do the job
okayish. This way we still won't sample the light with zero
`max_importance`.

The current solution might perform worse with distance sampling, because
the light tree measure is biased towards equiangular sampling. However,
it is difficult to perform MIS between equiangular and distance sampling
if different lights are picked for each method. This is something we can
look into in the future if proved to be a serious regression.

Pull Request: https://projects.blender.org/blender/blender/pulls/119389
2024-03-25 18:50:52 +01:00
Alaska
43cef92f66 Fix #119692: Cycles render issue with light tree and light linking
When using light linking with the light tree, the root index of a
mesh light subtree can be 0. The current code assumed this wasn't
possible, and as such it caused rendering issues, specifically the
incorrect computation of the PDF of certain mesh lights during
forward path tracing.

So we adjust the code to allow mesh light subtree root node
indices of 0.

This was worked on by Alaska, Sergey, and Weizhen

Pull Request: https://projects.blender.org/blender/blender/pulls/119770
2024-03-25 14:47:18 +01:00
Weizhen Huang
082b68fcb9 Cycles: improve equiangular sampling in volume
By restricting the sample range along the ray to the valid segment.

Supports

**Mesh Light**
- [x] restrict the ray segment to the side with MIS

**Area Light**
- [x] when the spread is zero, find the intersection of the ray and the bounding box/cylinder of the rectangle/ellipse area light beam
- [x] when the spread is non-zero, find the intersection of the ray and the minimal enclosing cone of the area light beam
*note the result is also unbiased when we just consider the cone from the sampled point in volume segment. Far away from the light source it's less noisy than the current solution, but near the light source it's much noisier. We have to restrict the sample region on the area light to the part that lits the ray then, I haven't tried yet to see if it would be less noisy.*

**Point Light**
- [x] the complete ray segment should be valid.

**Spot Light**
- [x] intersect the ray with the spot light cone
- [x] support non-zero radius

Pull Request: https://projects.blender.org/blender/blender/pulls/119438
2024-03-25 13:02:02 +01:00
Campbell Barton
7371b11bb5 Fix #119871: Window contents invalid on startup under Wayland & GNOME
Resolve a glitch where the window contents didn't fit the window
on startup under GNOME. This also avoids flickering whenever the
window manager changed the window size from the requested size.

See code-comments for details.
2024-03-25 22:08:27 +11:00
Sergey Sharybin
bffcb000e8 Fix: Cycles crash on Metal GPU with ASAN builds
Running a very simple files when Blender is built with the
WITH_COMPILER_ASAN=ON and WITH_CYCLES_KERNEL_ASAN=ON CMake options
leads to ASAN reporting an unknown-crash at line where the worker
pool is being filled in.

It is not entirely clear if it is a real issue in the code, since
placing debug prints with `this` address report proper addresses,
however there is no harm on capturing `this` pointer by value and
it does solve the ASAN reporting issues.

It is possible to reproduce the ASAN crash with the following steps:
- Start with --factory-startup
- Enable Metal device in User Preferences
- Switch render device to GPU Compute
- Switch viewport more to Rendered

Pull Request: https://projects.blender.org/blender/blender/pulls/119867
2024-03-25 11:36:15 +01:00
Lukas Stockner
02a488d0fe Fix #61042: Cycles: Various Toon BSDF issues
The original bug report was that the Glossy Toon BSDF behaves incorrectly
when mixed with other closures.
The underlying issue here was that the eval function didn't check whether
the reflection angle is inside the valid cone and always returned its PDF,
which is very high compared to e.g. the diffuse closure's PDF for small
sizes (since the cone is supposed to be quite tight) and therefore breaks
MIS mixing.

However, while looking into this, I found a number of other issues, and so
this commit also contains several other changes to the Toon BSDFs:
- The angle that was used to compute the intensity wasn't the actual angle
  between the vectors. From what I can see, the formula that was used goes
  back all the way to the initial commit 12 years ago, so this probably was
  something that happened to work with one particular cone sampling method.
  Now, however, it caused weird asymmetric highlights, so replace it with
  the actual angle (which we already compute anyways).
- Setting size to zero caused the BSDF to go black, so clamp to 1e-5.
- The code was overall a bit repetitive, so I've cleaned it up a bit.
2024-03-24 23:52:16 +01:00
Lukas Stockner
d4d5281d45 Fix: Cycles: Metal compilation error 2024-03-24 19:39:25 +01:00
Lukas Stockner
1f44be97e6 Fix #56355: Cycles: Wrong differentials for panoramic camera
The code to compute differentials mixed up the camera-space locations
of the raster coordinate and the camera itself, which caused the dP
differential to be set even when the ray origin is always the same.

This commit fixes that, reorganizes the code so that the Px/Py are
no longer used for both values to avoid future confusion, and skips
some unnecessary calculations stereo rendering isn't being used.
2024-03-24 17:52:22 +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
Campbell Barton
57dd9c21d3 Cleanup: spelling in comments 2024-03-21 10:02:53 +11:00
Weizhen Huang
b81b0308fd Fix: WITH_CYCLES_DEBUG flag not enabled on Metal
seems to be enabled on other GPUs already

Pull Request: https://projects.blender.org/blender/blender/pulls/119701
2024-03-20 16:42:42 +01:00
Weizhen Huang
a2bb547b9a Fix: Cycles spot light spread sampling not considering non-uniform scaling
For spherical spot light, when the shading point is close to the light
source, we switch to sampling the light spread instead of the visible
cone from the shading point. This has the benefit of less noise when the
spread is small.
However, the light spread sampling was not considering non-uniform
object scaling, where the actual spread might be different.
This patch switches sampling method only when the smallest enclosing
spread cone is smaller than the visible cone from the shading point.

An alternative method would be to compute the actual solid angle of the
scaled cone, and sample from the scaled cone. However, that involves
ray transformation and modifying the sampling pdf and angle. Since
non-uniform scaling is rather a niche case, it's probably not worth the
computation effort.

Pull Request: https://projects.blender.org/blender/blender/pulls/119661
2024-03-19 18:55:35 +01:00
Weizhen Huang
a6fba7b59d Cleanup: Cycles: remove unnecessary storage of the spot light axes 2024-03-19 18:55:34 +01:00
Weizhen Huang
8536575263 Fix: Cycles area light ignores some valid samples in volume segment 2024-03-19 14:48:43 +01:00
Weizhen Huang
f5f10201ca Cleanup: remove unused function 2024-03-19 14:48:14 +01:00
Brecht Van Lommel
433d91fca8 Merge branch 'blender-v4.1-release' 2024-03-18 11:00:49 +01:00
Brecht Van Lommel
f57e4c5b98 Fix #119551: Cycles denoising crash canceling tiled render with MetalRT
The BVH has been freed at this point, but the Metal queue sets it on
every invocation. Make sure it's null so it doesn't get used anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/119581
2024-03-18 11:00:21 +01:00
Brecht Van Lommel
b8ea467475 Merge branch 'blender-v4.1-release' 2024-03-16 19:45:51 +01:00
Alaska
b8a3560a77 Fix #119545: Error drawing Cycles denoising settings with NONE device
Pull Request: https://projects.blender.org/blender/blender/pulls/119547
2024-03-16 19:34:16 +01:00
Weizhen Huang
8cbc386152 Fix: Cycles NEE not excluding self intersection
which resulted in bias when self intersection is excluded in forward scattering.
Below is a comparison using principled BSDF with emission. NEE and MIS were much brighter.

Pull Request: https://projects.blender.org/blender/blender/pulls/119440
2024-03-15 18:31:24 +01:00
Weizhen Huang
161881322e Merge branch 'blender-v4.1-release' 2024-03-15 18:13:40 +01:00
Weizhen Huang
682f984dbe Fix: Cycles mesh light ignores some valid samples in volume segment
Ref: #118534
turns out `in_volume_segment` does need to be checked. If the ray origin
lies on the wrong side of the mesh light, part of the ray could still be
lit by the other side, so the sample should not be considered invalid.

Pull Request: https://projects.blender.org/blender/blender/pulls/119529
2024-03-15 18:11:40 +01:00
Sergey Sharybin
f3f79ef4bd Merge branch 'blender-v4.1-release' 2024-03-15 09:53:25 +01:00
Alaska
7ec0ebf30c Cycles: Fix grammar issues in OIDN GPU command line reporting
Pull Request: https://projects.blender.org/blender/blender/pulls/119492
2024-03-15 09:52:47 +01:00
Brecht Van Lommel
335ff6efab Cycles: Disable OpenImageDenoise support for AMD GPUs in Blender 4.1
In older drivers with an integrated GPU, this may crash. This not only
affects HIP, but also can crash when using Cycles with an NVIDIA or
Intel GPU in combination with an AMD CPU.

Fixes for this are expected to be coming, but there will not be enough
time for user testing, and it is difficult to be certain that the fix
is complete.

So to be careful, this is postponed until it has had more testing.

Pull Request: https://projects.blender.org/blender/blender/pulls/119476
2024-03-14 18:18:18 +01:00
Campbell Barton
fc13d2c165 Cleanup: format 2024-03-12 20:56:48 +11:00
Jose Vicente Barrachina
692de6d380 GHOST/Wayland: copy & paste image to clipboard support
Adds copy and paste images functionality to and from the image editor
in Linux/Wayland clipboard.

Currently the only format supported is PNG.

Ref: !119117
2024-03-12 17:42:02 +11:00
Campbell Barton
fff99c2e62 Merge branch 'blender-v4.1-release' 2024-03-12 17:08:53 +11:00
Campbell Barton
dd42a9718d Cleanup: format 2024-03-12 17:08:29 +11:00
Campbell Barton
8c276cb073 Merge branch 'blender-v4.1-release' 2024-03-12 17:04:59 +11:00
Campbell Barton
353ec1090a Unbreak build with USE_EVENT_BACKGROUND_THREAD disabled 2024-03-12 17:03:09 +11:00
Jacques Lucke
deb332601c Fix #113090, #111450, #104909: node rna properties collide with built-in names
This fixes the following name collisions:
* Compositor Box/Ellipse Mask node: `width` -> `mask_width`
  (also renamed the `height` property accordingly)
* Shader AOV Output node: `name` -> `aov_name`
* Geometry Color node: `color` -> `value`.

Those are breaking changes unfortunately, because looking up those property
names yielded the node-specific and not the common property. Therefore, this is
targeted at `main` instead of `4.1`.

Pull Request: https://projects.blender.org/blender/blender/pulls/119284
2024-03-11 15:57:30 +01:00
Brecht Van Lommel
92f6ba5a5f Merge branch 'blender-v4.1-release' 2024-03-11 15:09:55 +01:00
Brecht Van Lommel
c388ed1e53 Fix #118709: Crash in OIDN GPU detection for unsupported HIP device
Pull Request: https://projects.blender.org/blender/blender/pulls/119315
2024-03-11 15:09:24 +01:00
Brecht Van Lommel
9d0f49c843 Merge branch 'blender-v4.1-release' 2024-03-11 13:11:36 +01:00
Brecht Van Lommel
f7a071bd60 Fix: Build failing when WITH_OPENIMAGEDENOISE is OFF 2024-03-11 12:59:46 +01:00
Alaska
989e9ef890 Fix: Assert in Cycles multi-device OIDN check
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119267
2024-03-11 12:54:45 +01:00
Miguel Pozo
a53e8d6d24 Merge branch 'blender-v4.1-release' 2024-03-11 12:27:39 +01:00
Attila Afra
60e8b56bcd Fix: CUDA module memory leak since using primary context
Previously the CUDA context was always destroyed and the module along
with it. Now that this no longer happens, the missing module free became
a memory leak.

Also fix the same issue for HIP, though this is destroying the context
so it's not a problem yet.

Fix part of #119035

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2024-03-11 10:39:24 +01:00
Jacques Lucke
2c5f51e683 Merge branch 'blender-v4.1-release' 2024-03-10 14:04:35 +01:00
Campbell Barton
e33f5e36ac Cleanup: spacing around C-style comment blocks 2024-03-09 23:40:57 +11:00
Brecht Van Lommel
0f1e93e78a Cleanup: Remove debug print 2024-03-09 12:27:16 +01:00
Campbell Barton
74d9fb60ba Cleanup: use 'const' where possible, remove redundant check 2024-03-09 16:38:25 +11:00
Hans Goudey
2d3d8c80c3 Cleanup: Make format 2024-03-08 18:29:11 -05:00
Brecht Van Lommel
2e8e2be0af Merge branch 'blender-v4.1-release' 2024-03-08 22:55:42 +01:00
Brecht Van Lommel
9bebd39197 Cycles: Default to OIDN for NVIDIA in the viewport
For consistency across GPU devices, and between viewport and final
render.

Pull Request: https://projects.blender.org/blender/blender/pulls/119213
2024-03-08 22:52:36 +01:00
Brecht Van Lommel
f278e4138c Fix #118016: OpenImageDenoise not using GPU for CPU + GPU render
Thanks to Alaska for pointing out the cause of the problem.
2024-03-08 22:52:35 +01:00
Hans Goudey
04a9790035 Merge branch 'blender-v4.1-release' 2024-03-08 16:35:33 -05:00
Clément Foucault
4205718dce GPU: Cleanup type aliases
This define all aliases for supported types,
document which one to use in C++ shared code,
move relevant defines to their backend file.

Rename `bool1` to `bool32_t` and cleanup
its usage as mentioned in #118961.

Rel. #118961

Pull Request: https://projects.blender.org/blender/blender/pulls/119098
2024-03-08 19:09:10 +01:00
Brecht Van Lommel
898187cfab Fix #118466: Cycles renders black on Metal + AMD
Global built-ins appear to not work on AMD cards.

Also add a tweak to avoid a performance regression, similar
to what was done before. Disable adaptive subdivision kernel
code if not used.

Pull Request: https://projects.blender.org/blender/blender/pulls/119175
2024-03-08 16:41:27 +01:00
Alaska
2a18bbbdbc Fix #119141: Cycles Metal compilation errors
Correct order for alignment attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/119148
2024-03-07 11:41:37 +01:00
Sergey Sharybin
032a24d8ac Fix Cycles compilation error with OIDN < 2.2
The enumerator values for various GPU compute platforms were
added starting with OIDN 2.0, with the Metal GPU type added
in OIDN 2.2.

This is an alternative fix to ebb781675dd, which does not lead to
unhandled cases in switch statement, and follows the configuration
of OIDN and not Cycles (as OIDN might report devices which are
disabled in local Cycles build).

Pull Request: https://projects.blender.org/blender/blender/pulls/119155
2024-03-07 11:13:41 +01: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]: 6549019ae19cecbea524782054dca0e99cb833b8
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
Hans Goudey
1e1d7034ec Cleanup: Move GPU_uniform_buffer.h to C++ 2024-03-06 21:54:28 -05:00
Campbell Barton
a975c7096a Cleanup: line length in CMake files 2024-03-07 13:26:55 +11:00
Sebastian Parborg
ebb781675d Fix: Add missing ifdef guards for OIDN GPU devices
It is not guaranteed that the GPU variables will be available depending
on the current OIDN configuration
2024-03-06 19:19:23 +01: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
Anthony Roberts
3d5fa7698f Cycles: Add Windows ARM64 support
Ref #119126

Pull Request: https://projects.blender.org/blender/blender/pulls/117036
2024-03-06 16:14:34 +01:00
Sergey Sharybin
d88686fb2b Cycles: Add debug logging to the OIDN GPU checks
No functional changes, just something that could help troubleshooting
cases when option to use GPU for denoising is grayed out.

Pull Request: https://projects.blender.org/blender/blender/pulls/119123
2024-03-06 14:54:19 +01:00
Brecht Van Lommel
44d418143e Merge branch 'blender-v4.1-release' 2024-03-05 19:55:07 +01:00
Sahar A. Kashi
3e09fbf062 Fix #112983: Cycles HIP-RT crash on deleting all objects
Pull Request: https://projects.blender.org/blender/blender/pulls/118944
2024-03-05 19:52:58 +01:00
Campbell Barton
76867ad4c2 Cleanup: redundant "void" in function declarations for C++ 2024-03-05 11:25:35 +11:00
Lukas Stockner
14a8149318 Cleanup: Cycles: Remove unused function 2024-03-02 02:16:54 +01:00
Brecht Van Lommel
6788b7e87f Merge branch 'blender-v4.1-release' 2024-02-29 17:55:37 +01:00
Brecht Van Lommel
36c11ee482 Fix #118514: Cycles MetalRT crash with empty scene
Pull Request: https://projects.blender.org/blender/blender/pulls/118907
2024-02-29 17:28:13 +01:00
Brecht Van Lommel
1355285c0e Merge branch 'blender-v4.1-release' 2024-02-29 13:52:19 +01:00
Brecht Van Lommel
1e44d811ac Fix #117485: Crash rendering motion blur with changing curve count
This is not supported so there can be artifacts, but it should not
crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/118859
2024-02-29 13:49:51 +01:00
Alaska
659f05ef28 Fix: Cycles HIP incorrect rendering of clip image textures
This was fixed in the driver quite a while ago:
https://github.com/ROCm/HIP/pull/2229

Ref: #91571
Pull Request: https://projects.blender.org/blender/blender/pulls/118540
2024-02-29 13:49:29 +01:00
Alaska
0a173b942b Cycles: Improve reporting of HIP texture allocation failures
HIP fails to allocate textures, typically when they are too large.
This commit lets the user know what might be causing the issue
rather than providing a confusing internal error message.

Pull Request: https://projects.blender.org/blender/blender/pulls/118239
2024-02-29 13:49:11 +01:00
Xavier Hallade
b8fdef965d Merge branch 'blender-v4.1-release' 2024-02-28 18:25:21 +01:00
Xavier Hallade
98343c0c17 Build: Upgrade Intel Graphics Compiler to 1.0.15468 on Linux
This corresponds the latest stable LTS release:
https://dgpu-docs.intel.com/releases/LTS_803.29_20240131.html

Graphics compiler upgrades require increasing the mininum required
driver (compute-runtime) version to the corresponding one to guarantee
compatibility, which is XX.XX.27642.38 in this release, so we bump this
requirement accordingly.

Fixes #118713

Pull Request: https://projects.blender.org/blender/blender/pulls/118814
2024-02-28 18:24:30 +01:00
Campbell Barton
4701879f52 Merge branch 'blender-v4.1-release' 2024-02-28 16:09:47 +11:00
Campbell Barton
7f8fcddba5 Merge branch 'blender-v4.1-release' 2024-02-28 16:09:42 +11:00
Campbell Barton
503de16353 Fix #117583: Inaccessible title bar buttons on GNOME/Wayland
New windows on GNOME with LIBDECOR windowing would sometimes have an
unusable title-bar with the whole title-bar acting as the edge-resize.

Would happen predictably when opening large windows which the window
manager would resize to fit the display.

The cause of this was Blender receiving a window configure event
without a window size for new windows. This configure event
would be ignored, causing the title bar not to work properly.

This is a regression from [0] which removed logic to calculate the
window size from the arguments passed to GHOST for window creation.
This wasn't correct either as the it could temporarily set the
window size before the requested size configuration was received.

Resolve the problem by queuing configuration requests,
handling them then the requested window size is known.

[0]: 1455315111ae769d101413fe600662484ff46d62
2024-02-28 16:07:10 +11:00
Campbell Barton
cec6d57107 Fix memory leak with Wayland & LIBDECOR
The configuration was cleared before freeing.
2024-02-28 16:05:05 +11:00
Thomas Dinges
2b095c97fa Cycles: Increase minimum target on x86 to SSE4.2
* Compile regular host code with SSE4.2
* Remove the SSE2 kernel, only the SSE4.2 and AVX2 kernel remain

Pull Request: https://projects.blender.org/blender/blender/pulls/118471
2024-02-26 14:49:19 +01:00
Weizhen Huang
95d11b0d33 Fix Cycles area light using MIS when the spread is zero
area light with zero spread was introduced in bf18032977. Such paths can
only be sampled with NEE, so MIS should not be used.
This fixes the discrepancy when Direct Light Sampling is set to MIS or NEE.

Pull Request: #118584
2024-02-23 12:40:48 +01:00
Weizhen Huang
c292d4dbee Fix assigning value to nullptr 2024-02-23 12:29:39 +01:00
Weizhen Huang
63dd44c810 Cleanup: avoid implicit conversion from int to float 2024-02-23 12:28:46 +01:00
Weizhen Huang
92c4a5fa09 Fix Principled Hair Huang wrong TIR condition
`cos_theta_t` was not initialized for TIR case

Thanks Christophe Hery for spotting the bug
2024-02-23 12:28:23 +01:00
Weizhen Huang
65d910aef7 Fix wrong roughness in Principled Hair Huang trrt+ component 2024-02-23 12:28:08 +01:00
Jeroen Bakker
5698fb2049 RenderDoc: Set Capture Title
Adds an option to set the capture title when using renderdoc
`GPU_debug_capture_begin` has an optional `title` parameter to set
the title of the renderdoc capture.

Pull Request: https://projects.blender.org/blender/blender/pulls/118649
2024-02-23 10:57:37 +01:00
Brecht Van Lommel
b0b1c55a49 Merge branch 'blender-v4.1-release' 2024-02-22 19:08:48 +01:00
Alaska
56bfd56735 Fix: Cycles incorrect rendering of certain negative strength lights
This fixes an issue where lights that make use of constant negative strength
emission shaders would render with the absolute of their strength.

Pull Request: https://projects.blender.org/blender/blender/pulls/118541
2024-02-22 19:06:22 +01:00
Hans Goudey
caf567e241 Cleanup: Resolve unused variable warning in GHOST EGL code 2024-02-22 12:45:57 -05:00
Weizhen Huang
a3f0ff6184 Cycles: make Principled Hair Huang a near- and far-field model
for a camera ray, compute the actual range of the hair width that the
current pixel covers, and only integrate that subset, to prevent a
ribbon-like appearance in close-up looks.
When the hair covers less than one pixel on the screen or when the ray
is not camera ray, the model works the same as before.

Pull Request: https://projects.blender.org/blender/blender/pulls/116094
2024-02-22 18:18:14 +01:00
Weizhen Huang
8a47c6b169 Cleanup: simplify computation of h_to_gamma() in Principled Hair Huang 2024-02-22 18:18:13 +01:00
Weizhen Huang
1906a14cf3 Refactor: pre-compute valid integration interval in Principled Hair Huang
The valid interval from incoming direction was shared between
`...eval_r()` and `...eval_residual()`, so compute that in `...eval()` instead.
The valid interval from outgoing direction was computed for
`...eval_r()` to further reduce the integration interval. This part is
removed because the check `dot(wo, wm) > 0` is relatively cheap inside the loop.
2024-02-22 18:18:13 +01:00
Weizhen Huang
c592fa14f1 Cycles: adjust normal in Principled Hair Huang to be orthogonal to the tangent
The geometry normal of the curve might not be precisely orthogonal to
the tangent due to interpolation. Previously, the tangent was adjusted
to be orthogonal to the normal. However, the normal is linearly
interpolated, which is less accurate than the tangent computed using Catmull-Rom.
This commit keeps the tangent and adjust the normal instead, besides
better accuracy, it ensures a smooth transition when the cross-section
shifts between circular and elliptical.
2024-02-22 18:18:13 +01:00
Weizhen Huang
1d8ec32473 Fix Cycles area light using MIS when the spread is zero
area light with zero spread was introduced in bf18032977. Such paths can
only be sampled with NEE, so MIS should not be used.
This fixes the discrepancy when Direct Light Sampling is set to MIS or NEE.

Pull Request: https://projects.blender.org/blender/blender/pulls/118584
2024-02-22 17:10:46 +01:00
Weizhen Huang
69f26a7c18 Fix assigning value to nullptr 2024-02-22 15:45:33 +01:00
Weizhen Huang
5782555c47 Merge branch 'blender-v4.1-release' 2024-02-22 12:26:37 +01:00
Weizhen Huang
0007c7a6b2 Fix #115997: Emission sampling setting ignored when not using light tree
if emission sampling is not set, we do not use MIS weight when sampling
from the BSDF, but we were still drawing samples from the light,
resulting in double contribution.

Pull Request: https://projects.blender.org/blender/blender/pulls/118534
2024-02-22 12:24:12 +01:00
Weizhen Huang
6f4ef97962 Cleanup: avoid implicit conversion from int to float 2024-02-22 12:09:58 +01:00
Weizhen Huang
ca389c7b56 Fix Principled Hair Huang wrong TIR condition
`cos_theta_t` was not initialized for TIR case

Thanks Christophe Hery for spotting the bug
2024-02-22 12:09:58 +01:00
Weizhen Huang
0550d864f1 Fix wrong roughness in Principled Hair Huang trrt+ component 2024-02-22 12:09:58 +01:00
Brecht Van Lommel
ca8a7c7054 Merge branch 'blender-v4.1-release' into main 2024-02-21 18:35:59 +01:00
Brecht Van Lommel
4c708a8c3e Linux: Avoid XDG_RUNTIME_DIR warnings running headless Blender
Pull Request: https://projects.blender.org/blender/blender/pulls/118530
2024-02-21 18:35:15 +01:00
Brecht Van Lommel
873472b747 Linux: Improve headless EGL initialization messages
When it succeeds, don't print an error message. When it fails, print
errors for both display and headless attempts.

Pull Request: https://projects.blender.org/blender/blender/pulls/118530
2024-02-21 18:35:10 +01:00
Bastien Montagne
4e544e5e59 Merge branch 'blender-v4.1-release' 2024-02-21 18:19:01 +01:00
Jacques Lucke
8ea425d95d Fix #118402: enforce expected minimum alignment in MEM_CXX_CLASS_ALLOC_FUNCS
This `operator new` added in ecc3e78d787cce8a3f202e7de26575e2d47baea2
are only called if the alignment is greater than `__STDCPP_DEFAULT_NEW_ALIGNMENT__`.
This is generally 8 or 16 depending on the platform. `MEM_mallocN` does
guarantee 16 byte alignment currently (in fact it's usually not 16 byte aligned
because of `MemHead`). Now `MEM_mallocN_aligned` is used with the default
alignment, even if we don't know that the type does not require it.

An alternative would be to pass the alignment to `MEM_CXX_CLASS_ALLOC_FUNCS`,
but that would be more intrusive.

Pull Request: https://projects.blender.org/blender/blender/pulls/118568
2024-02-21 18:14:11 +01:00
Campbell Barton
63f482d550 Merge branch 'blender-v4.1-release' 2024-02-21 14:10:00 +11:00
Campbell Barton
479b46ca93 Fix #117896: Key-modifiers on window activation fails under Wayland
Register the last held key when activating a window
(not only modifiers keys) under Wayland.

This resolves a bug where holding the D-key and clicking on a window
wouldn't activate grease pencil drawing.
2024-02-21 14:09:04 +11:00
Jacques Lucke
4c15ce5ad5 Merge branch 'blender-v4.1-release' 2024-02-20 18:45:07 +01:00
Jacques Lucke
ecc3e78d78 Fix #118402: support overaligned types in MEM_CXX_CLASS_ALLOC_FUNCS
Previously, the alignment of structs that use `MEM_CXX_CLASS_ALLOC_FUNCS`
were not taken into account when doing the allocation. This can cause some data
to be mis-aligned and leads to crashes when cpu instructions or code expect the
data to be aligned.

The fix is to provide an overload of `operator new` that accepts the alignment as parameter.

More info: https://en.cppreference.com/w/cpp/language/new (search for `align_val_t`).

Pull Request: https://projects.blender.org/blender/blender/pulls/118526
2024-02-20 18:44:26 +01:00
Lukas Stockner
06b42313a6 Cleanup: Cycles: Replace cos with cosf 2024-02-20 02:57:29 +01:00
Harley Acheson
9e852d9471 UI: Mac Incorrect Hand Cursor for Move
On the MacOS platform, use openHandCursor for GHOST_kStandardCursorMove
not pointingHandCursor. This cursor is meant to indicate an item that
you can move or adjust. The pointingHandCursor is meant for links to
documents, web pages, etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/118423
2024-02-19 18:00:36 +01:00
Brecht Van Lommel
0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564ad2.
2024-02-19 15:59:59 +01:00
Hans Goudey
81a63153d0 Despgraph: Rename "copy-on-write" to "copy-on-evaluation"
The depsgraph CoW mechanism is a bit of a misnomer. It creates an
evaluated copy for data-blocks regardless of whether the copy will
actually be written to. The point is to have physical separation between
original and evaluated data. This is in contrast to the commonly used
performance improvement of keeping a user count and copying data
implicitly when it needs to be changed. In Blender code we call this
"implicit sharing" instead. Importantly, the dependency graph has no
idea about the _actual_ CoW behavior in Blender.

Renaming this functionality in the despgraph removes some of the
confusion that comes up when talking about this, and will hopefully
make the depsgraph less confusing to understand initially too. Wording
like "the evaluated copy" (as opposed to the original data-block) has
also become common anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/118338
2024-02-19 15:54:08 +01:00
Brecht Van Lommel
05f6a32b18 Merge branch 'blender-v4.1-release' into main 2024-02-19 13:18:27 +01:00
bartus
5d06b7b906 Cycles: Add support for OpenPGL 0.6.0
Replace PGLFieldArguments with FieldConfig class for this version.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/118328
2024-02-19 12:36:04 +01:00
Harley Acheson
4acbda91f8 Merge branch 'blender-v4.1-release' 2024-02-17 11:30:55 -08:00
Harley Acheson
a677518cb5 Fix #118351: Pixel Shift with Win32 Clipboard DibV5 Image Transfer
My misreading of the Microsoft BITMAPV5HEADER specification causes a
shift of three pixels when transferring between applications using this
format. This does not occur when moving within or between Blender
instances. This PR just removes the incorrect 12-byte offset. Note
that many applications prefer PNG transfers over DibV5 so testing this
might be non-obvious.

Pull Request: https://projects.blender.org/blender/blender/pulls/118417
2024-02-17 20:29:41 +01:00
Campbell Barton
c47c1275a9 Merge branch 'blender-v4.1-release' 2024-02-17 14:57:07 +11:00
Campbell Barton
a8ca12f2a8 Fix #118233: No preference to disable multi-touch gestures on Wayland
Support this preference for Wayland, following macOS & WIN32 support.
2024-02-17 14:55:12 +11:00
Brecht Van Lommel
7453c5ed67 Merge branch 'blender-v4.1-release' into main 2024-02-16 19:31:31 +01:00
Raul Fernandez
324ff4ddef macOS: Remove unnecessary checks now that minimum version is macOS 11.2
MacOS minimum version is now 11.2 we no longer need to check for lower API versions.

Pull Request: https://projects.blender.org/blender/blender/pulls/118388
2024-02-16 19:03:23 +01:00
Campbell Barton
07ff3bcb70 GHOST/Wayland: support dropping text
This matches X11's support for GHOST_kDragnDropTypeString.

Dropping URL's from a web-browser uses this mime-type.
2024-02-16 14:27:00 +11:00
Campbell Barton
82c753a940 GHOST/Wayland: drag & drop cleanup, minor changes
- Don't generate a drop event when the drop data failed to read.
- Remove redundant drop-buffer duplication.
2024-02-16 14:26:58 +11:00
Campbell Barton
67481dcd47 Merge branch 'blender-v4.1-release' 2024-02-15 21:22:56 +11:00
Campbell Barton
4b7d44d015 Fix incorrect use of sizeof() for Wayland
The size of the string in bytes happened to match the the pointer size
on 64bit systems, nevertheless the logic was wrong would would fail on
32bit systems. Also use a character to search the string instead of a
single character string.
2024-02-15 20:56:45 +11:00
Hans Goudey
e6c919830c Cleanup: Remove unused logging macros that free the input string 2024-02-14 21:08:58 -05:00
Campbell Barton
bdd40f167e Merge branch 'blender-v4.1-release' 2024-02-15 11:03:42 +11:00
Hans Goudey
a52323d711 Cleanup: Move BKE_duplilist.hh to C++ 2024-02-14 10:51:46 -05:00
Brecht Van Lommel
088ae8d905 Build: Remove LLVM linking no longer needed by OSL
These are now included in the OSL shared libraries, so no reason to
link against it.

The CMake code for WITH_LLVM remains in case it is useful in the future,
but is not enabled by any Blender feature now.

Pull Request: https://projects.blender.org/blender/blender/pulls/118229
2024-02-14 12:06:52 +01:00
Campbell Barton
156fffbfde Merge branch 'blender-v4.1-release' 2024-02-14 14:29:55 +11:00
Brecht Van Lommel
dd382be067 Fix #118020: Cycles OptiX OSL crashes
Turns out we were not building OSL with OptiX enabled anymore.
Also check now if the OSL builds has OptiX support and if not
disable it in Cycles.

Building OSL with support for this (still) does not require
either the OptiX SDK or CUDA, it only needs LLVM.

Pull Request: https://projects.blender.org/blender/blender/pulls/118234
2024-02-14 03:40:01 +01:00
Damien Picard
1410615079 Nodes: expose multi-input sockets to custom nodes in the Python API
Currently the multi-input sockets are not exposed to the custom nodes
Python API. This makes some features cumbersome to implement if one
wants a node to process an arbitrary number of inputs.
One workaround is to make inputs duplicate themselves when a link is
created, but a proper multi-input would be easier to use for both
add-on developers and users.

This commit exposes a new `use_multi_input` boolean parameter when
creating a new node socket. This makes it possible to declare a
multi-input, while still leaving the existing `is_multi_input`
property read-only so that existing nodes cannot be made unstable.

The parameter is optional so existing scripts stay compatible. It also
raises an error when used on output sockets, since it makes no sense
for those to be multi-input.

The Custom Node Tree Python template was updated to reflect this
change by making one of the inputs of the custom node multi-input.

Pull Request: https://projects.blender.org/blender/blender/pulls/114474
2024-02-12 20:28:56 +01:00
Nikita Sirgienko
c48ea92429 Merge branch 'blender-v4.1-release' 2024-02-12 18:16:19 +01:00
Attila Afra
7b8c438715 Fix: Set OIDN GPU memory limit for all filters 2024-02-12 18:13:23 +01:00
Campbell Barton
3dbbc013de Cleanup: spelling in comments 2024-02-10 22:35:35 +11:00
Thomas Dinges
30a22b92ca Cycles: Rename SSE4.1 kernel to SSE4.2
This commit updates all defines, compiler flags and cleans up some code for unused CPU capabilities.

There should be no functional change, unless it's run on a CPU that supports sse41 but not sse42. It will fallback to the SSE2 kernel in this case.

In preparation for the new SSE4.2 minimum in Blender 4.2.

Pull Request: https://projects.blender.org/blender/blender/pulls/118043
2024-02-09 17:25:58 +01:00
Brecht Van Lommel
01f2c32700 Merge branch 'blender-v4.1-release' into main 2024-02-09 15:16:55 +01:00
Brecht Van Lommel
1e1a8d5c8f Fix: Cycles denoise fails with multi tile render and Use GPU off 2024-02-09 15:11:21 +01:00
Brecht Van Lommel
f98468c988 Fix: Cycles uses GPU device for denoise even if disabled for scene 2024-02-09 15:02:46 +01:00
JonasDichelle
f2e27ef7b6 Cycles: Override World option per View Layer
This feature is useful for many production scenarios as it allows for the
creation of separate render passes with specific worlds. This would help
workflows that require different skies or other backgrounds for compositing.

Ref #117919

Pull Request: https://projects.blender.org/blender/blender/pulls/117920
2024-02-09 12:16:16 +01:00
Sergey Sharybin
4196cbd175 Merge branch 'blender-v4.1-release' 2024-02-08 17:03:19 +01:00
Miguel Pozo
74b8f99b43 Render: Merge EEVEE and Cycles motion blur settings
Merge duplicated motion blur settings between Cycles and EEVEE,
and move them to `RenderData`/`scene.render`:
* `scene.cycles.motion_blur_position` -> `scene.render.motion_blur_position`
* `scene.eevee.use_motion_blur` -> `scene.render.user_motion_blur`
* `scene.eevee.motion_blur_position` -> `scene.render.motion_blur_position`
* `scene.eevee.motion_blur_shutter` -> `scene.render.motion_blur_shutter`

On the C/C++ side, this also renames `RenderData::blurfac` to
`RenderData::motion_blur_shutter`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117913
2024-02-08 16:49:18 +01:00
Michael Jones
322a2f7b12 Cycles: Future-proof ordering of AppleGPUArchitecture enum
_No response_

Pull Request: https://projects.blender.org/blender/blender/pulls/117982
2024-02-08 16:31:52 +01:00
Nikita Sirgienko
0ed2d3e260 Merge branch 'blender-v4.1-release' 2024-02-08 14:54:13 +01:00
Nikita Sirgienko
9d0b811da6 Fix #117931: Swap oidn device when changing "Use GPU" during viewport render 2024-02-08 14:53:12 +01:00
Campbell Barton
510a7ff452 Merge branch 'blender-v4.1-release' 2024-02-08 12:42:23 +11:00
Koranir
bba1893f67 Fix crash with fractional scaling on Wayland with NVIDIA graphics
Ref: !117531
2024-02-08 12:34:35 +11:00
Campbell Barton
67c12236e6 GHOST/WIN32: remove start time offset from getMilliSeconds
This isn't necessary and has been removed from macOS & X11,
Wayland never did this.

Besides removing the offset GetTickCount() has been replaced by
GetTickCount64 to prevent 32bit rollover when high resolution timers
aren't supported.

Ref !117618
2024-02-08 08:53:34 +11:00
Attila Afra
e7dcad8599 Fix: Release all OIDN GPU resources when recreating denoiser 2024-02-07 19:44:40 +01:00
Brecht Van Lommel
bd8a44e169 Lights: Option to use old point light falloff
Add new "Soft Falloff" option on point and spot light that uses
the old light behavior from Blender versions before 4.0. Blend
files saved with those older versions will use the option.

This option is enabled by default on new lights.

Fix #114241

Co-authored-by: Weizhen Huang <weizhen@blender.org>
Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/117832
2024-02-07 19:07:11 +01:00
Attila Afra
8e80b44796 Cycles: Fix initial OIDN GPU denoiser quality 2024-02-07 17:54:50 +01:00
Attila Áfra
c1f55288e9 Fix: Cycles OIDN GPU denoiser bugs
- Incorrect accurate prefiltering of albedo and normal (lower than expected quality)
- Changing the prefiltering mode has no immediate effect
- Default memory limit is too high (more than OIDN default)
- Memory limit is applied only to the main filter
- Quality setting applied only to the main filter

Pull Request: https://projects.blender.org/blender/blender/pulls/117930
2024-02-07 13:34:35 +01:00
Nikita Sirgienko
06dc5363a9 Cycles: Denoise on CPU by default for offline render 2024-02-07 09:43:28 +01:00