Commit Graph

14702 Commits

Author SHA1 Message Date
Brecht Van Lommel
28f7e2ae91 Merge branch 'blender-v4.4-release' 2025-03-04 17:53:08 +01:00
Brecht Van Lommel
a3baf60df4 Fix: Cycles device info uninitialized variable
It's unclear if this caused an actual bug, detected by ASAN.
2025-03-04 17:46:04 +01:00
Lukas Stockner
39a6c222b2 Cycles: Split OSLManager out of OSLShaderManager
This is preparation for #129495.

Currently, all of OSL is managed by the OSLShaderManager. This makes it so that the general OSL setup is handled by a general OSLManager, and both the OSLShaderManager and (in the future) the Camera can use it to manage their scripts.

Pull Request: https://projects.blender.org/blender/blender/pulls/135050
2025-03-04 17:27:10 +01:00
Jeroen Bakker
4a95c0405c Cleanup: Subdiv: Remove wrapper OpenSubdiv_Buffer
`OpenSubdiv_Buffer` is a wrapper that was introduced at the time
that Blender couldn't use CPP directly. It contains a pointer to
a VertBuf and callbacks to use GPU module on that buffer.

This PR replaces OpenSubdiv_Buffer with `blender::gpu::VertBuf` and
removes the wrapper.

NOTE: OpenSubdiv tests are added to blender_test executable to make the
library dependencies not to complicated.

Pull Request: https://projects.blender.org/blender/blender/pulls/135389
2025-03-04 07:51:15 +01:00
Xavier Hallade
90a10dcd50 Cycles: Adjust inlining attributes for oneAPI device
Now ccl_device sets inlining and ccl_device_inline forces inlining.
This matches more closely with what is currently done for cuda and metal
backends.
I've measured from 1% to 6% overall performance improvement in rendering
benchmark scenes on Arc B580, as well as a small decrease in compile
time.
2025-03-03 18:20:02 +01:00
Aras Pranckevicius
cc2c6692c0 Cleanup: Name more IMB things as "byte" or "float" instead of "rect" and "rectFloat"
- IB_rect -> IB_byte_data
- IB_rectfloat -> IB_float_data
- Rename some functions:
	- IMB_get_rect_len -> IMB_get_pixel_count
	- IMB_rect_from_float -> IMB_byte_from_float
	- IMB_float_from_rect_ex -> IMB_float_from_byte_ex
	- IMB_float_from_rect -> IMB_float_from_byte
	- imb_addrectImBuf -> IMB_alloc_byte_pixels
	- imb_freerectImBuf -> IMB_free_byte_pixels
	- imb_addrectfloatImBuf -> IMB_alloc_float_pixels
	- imb_freerectfloatImBuf -> IMB_free_float_pixels
	- imb_freemipmapImBuf -> IMB_free_mipmaps
	- imb_freerectImbuf_all -> IMB_free_all_data
- Remove IB_multiview (not used at all)
- Remove obsolete "module" comments in public IMB headers

Pull Request: https://projects.blender.org/blender/blender/pulls/135348
2025-03-03 17:11:45 +01:00
Sergey Sharybin
ad30bdd470 Merge branch 'blender-v4.4-release' 2025-02-28 19:02:39 +01:00
Sahar A. Kashi
99a487a07c Fix: Cycles HIP-RT curve motion blur and motion pass
Various fixes in the HIP-RT BVH building related on making sure
curves motion blur is supported and is working correctly, as well
as properly handle motion pass configuration when path tracing is
to ignore motion blur (and instead write vector pass).

This PR contains #134797 with fixes needed to fully finish it:
moving commits from that PR here made it easier to ensure all
moving parts are tested without mental overhead.

Fixes #134510

Co-authored-by: Sahar A. Kashi  <sahar.alipourkashi@amd.com>
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/135125
2025-02-28 19:02:03 +01:00
Sean Stirling
5372346978 Cycles: oneAPI: Use linear USM memory for 1D images
Rewrite the ONEAPI Blender texture allocation code to make use of
1D images backed by linear USM memory. This increases parity
with the CUDA implementation and sets the ground work for enabling
host USM allocations in Blender. By enabling this functionality,
previously failing benchmarks are now passing.

Together with the previous commit, no functional changes are expected.
2025-02-28 17:52:41 +01:00
Nikita Sirgienko
dcbc7c1623 Cycles: oneAPI: Remove some texture code from the squished bindless texture commit
This code will be reintroduced back shortly, but under proper credentials.

No functional changes are expected along with the next commit.
2025-02-28 17:51:35 +01:00
Brecht Van Lommel
5caeac4474 Fix: Cycles performance regression after refactor for light objects
Thanks to Xavier Hallade for finding the cause.

Caused by #134846, e813e46327.

Pull Request: https://projects.blender.org/blender/blender/pulls/135309
2025-02-28 17:40:03 +01:00
Brecht Van Lommel
3cf21ceaf4 Merge branch 'blender-v4.4-release' 2025-02-28 13:28:20 +01:00
Brecht Van Lommel
8f00d8b0c8 Fix: Cycles hardware RT is only supported if all multi devices have it
Pull Request: https://projects.blender.org/blender/blender/pulls/135179
2025-02-28 13:21:33 +01:00
Brecht Van Lommel
8ce58f2973 Cycles: Disable HIP-RT and MNEE on RDNA1 generation GPUs
These have bugs in with the latest HIP-RT and HIP SDK, so just disable them
as we do not expect a fix in time, and rolling back would re-introduce other
bugs. As RDNA1 does not have hardware raytracing, it is also less important
to use HIP-RT.

Note that only RDNA2+ is officially supported by HIP, so these GPUs working
at all is somewhat lucky.

Fix #134979
Fix #134978
Fix #134975

Pull Request: https://projects.blender.org/blender/blender/pulls/135179
2025-02-28 13:21:14 +01:00
Campbell Barton
86c0190924 GHOST/Wayland: set the size of custom cursors based on the DPI
HI-DPI screens now select larger custom cursors on Wayland,
previously small cursors would be scaled up.

This only works well when all outputs have the same scaling
as custom-cursors don't support sending multiple sized cursors
to GHOST at once, see code-comments for details.
2025-02-28 22:36:03 +11:00
Sergey Sharybin
d853d994ae Merge branch 'blender-v4.4-release' 2025-02-28 10:42:54 +01:00
Sergey Sharybin
b9c727e255 Fix #135200: Linking linking artifacts with light trees
Ensure that the light tree flattening code does not try to
share node in cases when we need to modify its bit trail.

Pull Request: https://projects.blender.org/blender/blender/pulls/135249
2025-02-28 10:42:29 +01:00
Aras Pranckevicius
02869cc6c8 Color management: Dithering consistency/perf improvements
Float->byte rendered image dithering uses triangle noise algorithm. Keep
the algorithm the same, just make some improvements and fix some issues:

1) The hash function for noise was using "trig" hash from "On generating
random numbers" (Rey 1998), but that is not a great quality hash, plus it
can produce very different results between CPUs/GPUs. Replace it with
"iqint3" (recommended by "Hash Functions for GPU Rendering", JCGT 2020),
which is same performance on GPU, faster on CPU, and much better quality.
This is the same hash as Cycles already uses elsewhere. Also it is purely
integer based, so exactly the same results on all platforms.

2) For the above point, replace `dither_random_value` to take integer
pixel coordinates and adjust calling code accordingly. Some previous
callers were (accidentally?) passing integer coordinates already. Other
places actually get a tiny bit simpler, since they now no longer need an
extra multiplication.

3) The CPU dithering path was wrongly introducing bias, i.e. making the
image lighter. The CPU path also needs dither noise to be in [-1..+1]
range (not [-0.5..+1.5]!) just like GPU path does, since the later
float->byte conversion already does rounding.

4) The CPU dithering path was using thread-slice-local Y coordinate,
meaning the dithering pattern was repeating vertically. The more CPU cores
you use, the worse the repetition.

5) Change the way that uniform noise is converted to triangle noise.
Previous implementation was based on one shadertoy from 2015, change it
to another shadertoy from 2020. The new one fixes issues with the old way,
and it just works on the CPU too, so now both CPU and GPU code paths are
exactly the same.

6) Cleanup: remove DitherContext, just a single float is enough

Performance and image comparisons in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/135224
2025-02-27 15:52:45 +01:00
Alaska
88f848bb7a Merge branch 'blender-v4.4-release' 2025-02-27 15:11:03 +13:00
Alaska
b42b5d85ff Cycles: Increase minimum supported HIP GPU driver
After the recent HIP SDK 6.3 update on Windows, the minimum GPU driver
required to use HIP in Cycles has increased.

This commit increases the required driver version listed in the UI and
adds a check to avoid showing HIP devices if they're below a certain
driver version number as they don't work properly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134965
2025-02-27 03:09:37 +01:00
Alaska
fb7b53143e Merge branch 'blender-v4.4-release' 2025-02-27 12:03:30 +13:00
Alaska
d840d249b3 Cycles: Re-enable HIPRT point cloud rendering
Previously point cloud rendering was disabled on the HIPRT backend due
to unexpected performance regressions introduce by it.

With the recent update to HIP SDK 6.3 and HIPRT 2.5, these performance
regressions have been resolved and so this commit re-enables
point cloud rendering on HIPRT.

Pull Request: https://projects.blender.org/blender/blender/pulls/134902
2025-02-27 00:01:35 +01:00
Xavier Hallade
a5d8bd2e29 Cycles: Drop inline hint on light_tree_pdf
Dropping the inlining hint for `light_tree_pdf` and reverting to the
default inlining thresholds for DPC++ compiler gives a ~4% speedup on
classroom and other scenes on Arc B580.

Pull Request: https://projects.blender.org/blender/blender/pulls/135042
2025-02-26 20:14:05 +01:00
Weizhen Huang
7b3f7ccae0 Merge branch 'blender-v4.4-release' 2025-02-26 15:51:55 +01:00
Lukas Stockner
9254532b8b Fix #129306: Cycles: Principled coat doesn't pass furnace test
This implements three improvements to the energy preservation and albedo
scaling logic, which help the Principled BSDF pass the white-furnace test
when using the coat layers at high roughness.

Specifically, at roughness 0.3, the albedo scaling brings it from 60% at
the edge to 95%, and with the energy preservation it's 99.8%.

Pull Request: https://projects.blender.org/blender/blender/pulls/134620
2025-02-26 15:47:21 +01:00
Weizhen Huang
9ee9a2b789 Fix #135145: object visible to volume scatter when ray visibility is off
The comment was added in e0857ad152, and volume scatter visibility is
supported since cdd1d5a93c.

Pull Request: https://projects.blender.org/blender/blender/pulls/135168
2025-02-26 15:45:58 +01:00
Brecht Van Lommel
655ccf1d7a Fix #135086: Light ray visibility not taken into account without light tree
Re-enable tests that were temporarily disabled for this.

Caused by #134846, e813e46327
2025-02-25 17:24:04 +01:00
Brecht Van Lommel
10482f5fba Fix #135087: Cycles light properties not updating in viewport
Caused by #134846, e813e46327
2025-02-25 17:20:56 +01:00
Jonas Holzman
45ec90efd5 Merge branch 'blender-v4.4-release' 2025-02-25 16:28:57 +01:00
Jonas Holzman
8f1d03cd75 Fix #133713: Crash when drag and dropping bitmap images on macOS
Drag and dropping bitmap images (as in drag and dropping directly from
another software such as a web browser, not from an image file in
Finder) inside the Blender window on macOS would segfault due to the
dropped image being [autorelease]d even though its data was meant to
outlive the function scope.

Fixed by removing the superflous autorelease and adding a comment note.
The only caller of this function (GHOST_SystemCocoa::handleDraggingEvent)
already properly [release]s the image in question.

Note that currently, non-file/bitmap image drag and drop is not
implemented on the WM side, and as such this feature/GHOST event does
not do anything practical.

Pull Request: https://projects.blender.org/blender/blender/pulls/135076
2025-02-25 16:24:55 +01:00
Pratik Borhade
d961f8f9ec Grease Pencil: Remove legacy object type references
Remove GP legacy obtype and unused functions
Few hidden bugs are fixed with that:
- Outliner drag-drop for GP material/effect elements now works
- Correct stats are shown in status bar.

Pull Request: https://projects.blender.org/blender/blender/pulls/133957
2025-02-25 10:46:27 +01:00
Brecht Van Lommel
e813e46327 Cycles: Refactor lights to be objects
This is an intermediate steps towards making lights actual geometry.
Light is now a subclass of Geometry, which simplifies some code.

The geometry is not added to the BVH yet, which would be the next
step and improve light intersection performance with many lights.

This makes object attributes work on lights.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/134846
2025-02-24 23:44:14 +01:00
Lukas Stockner
e6839df2a3 Cleanup: Cycles: Deduplicate code in geometry_attributes.cpp
#134644 would make this even worse, so it's time to clean up a bit.

Pull Request: https://projects.blender.org/blender/blender/pulls/134645
2025-02-23 16:34:34 +01:00
Bastien Montagne
e0829f9e55 Cleanup: Update comment in MEM_freeN<T> about MSVC and triviality check. 2025-02-21 10:37:13 +01:00
Bastien Montagne
718d4ffe9f Add some type-check to MEM_freeN<T> with MSVC.
Using `DNA_DEFINE_CXX_METHODS` in DNA structs make them non-trivially
copyable for MSVC, so use a narrower check that should still catch most
issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/134875
2025-02-21 10:30:29 +01:00
Lukas Stockner
8cb5e05c48 Cleanup: Cycles: Deduplicate kernel attribute code using templating
The attribute handling code in the kernel is currently highly duplicated since
it needs to handle five different data types and we couldn't use templates
back then.
We can now, so might as well make use of it and get rid of ~1000 lines.

There are also some small fixes for the GPU OSL code:
- Wrong derivative for .w component when converting float2/float3->float4
- Different conversion for float2->float (CPU averages, GPU used to take .x)
- Removed useless code for converting to float2, not used by OSL

Pull Request: https://projects.blender.org/blender/blender/pulls/134694
2025-02-20 19:28:45 +01:00
Sergey Sharybin
c114ac97be Merge branch 'blender-v4.4-release' 2025-02-20 17:36:37 +01:00
Sahar A. Kashi
6363181af9 Cycles: HIP-RT 2.5 integration and gfx12 support
This change brings the following improvements on the user level
- Support of GPUs with gfx12 architecture
- New HIP-RT library which in addition to the gfx12 support brings
  various bug-fixes.

The known limitation of gfx12 is that OpenImageDenoiser does not yet
support this GPU architecture. This means that while Cycles will use the
full advantage of the gfx12 (including hardware accelerated ray-tracing),
denoising will only be possible on CPU, or secondary gfx11 or below GPU.
This is something that requires a change in OIDN and it is to late to do
it for Blender 4.4, but it is something to look forward for Blender 4.5.

The gfx12 changes for the pre-compiled kernels is rather trivial,
so it comes together (in the same PR) as the bigger HIP-RT change.

On the development side this change brings the following improvements:
- One step compile and link (much simpler CMake rules)
- Embedding BVH binaries in hiprt dll (which makes it easier to package
  and load, without relying on special path configuration)

Co-authored-by: Sahar Kashi <sahar.kashi@amd.com>
Co-authored-by: Sergey Sharybin <sergey@blender.org>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/133129
2025-02-20 17:34:14 +01:00
Bastien Montagne
318ae49f1e Cleanup: Remove void * handling from MEM_freen<T>.
Followup to 48e26c3afe, and discussions in !134771 about keeping
'C-style' and 'C++ template type-safe style' implementations of our
guardedalloc separated. And it makes `MEM_freeN<T>` code simpler.

Also skip type-checking in `MEM_freeN<T>` only with MSVC, as clang-cl on
windows-arm64 does work fine with DNA structs using
`DNA_DEFINE_CXX_METHODS`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134861
2025-02-20 16:42:22 +01:00
Brecht Van Lommel
4b10c63617 Merge branch 'blender-v4.4-release' 2025-02-20 16:34:00 +01:00
Brecht Van Lommel
b0fcd55aed Fix: Cycles OSL random texture issue on macOS ARM
Shader compilation is multithreaded, this needs to be atomic.

Pull Request: https://projects.blender.org/blender/blender/pulls/134854
2025-02-20 16:32:44 +01:00
Bastien Montagne
48e26c3afe MEM_guardedalloc: Refactor to add more type-safety.
The main goal of these changes are to improve static (i.e. build-time)
checks on whether a given data can be allocated and freed with `malloc`
and `free` (C-style), or requires proper C++-style construction and
destruction (`new` and `delete`).

* Add new `MEM_malloc_arrayN_aligned` API.
* Make `MEM_freeN` a template function in C++, which does static assert on
  type triviality.
* Add `MEM_SAFE_DELETE`, similar to `MEM_SAFE_FREE` but calling
  `MEM_delete`.

The changes to `MEM_freeN` was painful and useful, as it allowed to fix a bunch
of invalid calls in existing codebase already.

It also highlighted a fair amount of places where it is called to free incomplete
type pointers, which is likely a sign of badly designed code (there should
rather be an API to destroy and free these data then, if the data type is not fully
publicly exposed). For now, these are 'worked around' by explicitly casting the
freed pointers to `void *` in these cases - which also makes them easy to search for.
Some of these will be addressed separately (see blender/blender!134765).

Finally, MSVC seems to consider structs defining new/delete operators (e.g. by
using the `MEM_CXX_CLASS_ALLOC_FUNCS` macro) as non-trivial. This does not
seem to follow the definition of type triviality, so for now static type checking in
`MEM_freeN` has been disabled for Windows. We'll likely have to do the same
with type-safe `MEM_[cm]allocN` API being worked on in blender/blender!134771

Based on ideas from Brecht in blender/blender!134452

Pull Request: https://projects.blender.org/blender/blender/pulls/134463
2025-02-20 10:37:10 +01:00
Hans Goudey
2555f68267 Merge branch 'blender-v4.4-release' 2025-02-18 10:55:49 -05:00
Brecht Van Lommel
c0f0e2ca6f Fix #129596: Cycles oneAPI crash with interactive BVH updates
There is a bug in Embree that makes BVH updates crash. Disabling multithreaded
BVH updates after the initial BVH build appears to work around it, at the cost
of some performance.

This will not affect performance of the initial BVH build, transforming objects
or editing a single mesh. It will only affect performance when multiple smaller
meshes are edited together, as those can no longer have their BVH updated in
parallel or benefit from parallellization over many primitives.

Pull Request: https://projects.blender.org/blender/blender/pulls/134747
2025-02-18 16:20:59 +01:00
Sergey Sharybin
0a59c7f0ea Cycles: Rudimentary utilities to plot light tree
Plotting happens from the given root node into a graphviz file.
Supports plotting from both scene level LightTreeNode and the kernel
level KernelLightTreeNode.

An external graphviz command is to be used to convert generated file
to an image.

Pull Request: https://projects.blender.org/blender/blender/pulls/134738
2025-02-18 14:29:00 +01:00
Sergey Sharybin
55e45123f5 Merge branch 'blender-v4.4-release' 2025-02-18 13:12:04 +01:00
Sergey Sharybin
24fbd71a56 Fix #130829: Incorrect render result with light trees
The original report stumbled upon this issue with a more tricky
configuration when light linking is combined with light tress.
However, the actual contributing factor was a mesh with emission
shader which is not assigned to any triangles. This triggered a
bug in the BoundBox::transformed() which converted non-valid bounds
to bounds by performing per-corner growing.

Additionally fix incorrect handling of shared nodes which only
worked for leaf nodes. This was due to the fact how the measure
was accumulated: it is possible that add() is called with an empty
measure.

Pull Request: https://projects.blender.org/blender/blender/pulls/134699
2025-02-18 13:11:46 +01:00
Julian Eisel
152c6c54e4 Cleanup: Improve API comment for MEM_new()
194e233d86 caused a discussion in the chat about the initialization
behavior of `MEM_new()`, and agreement was to not rely on
zero-initialization ever. Noted this in the API comment now.

Some people found the existing comment useful but it still left some
questions. Tried to clarify that now.

This is a crucial memory management function, it's important to have
behavior documented well, even if a full explanation is out-of-scope.
Also added another link in case people want to check more details.

Pull Request: https://projects.blender.org/blender/blender/pulls/134577
2025-02-17 16:18:04 +01:00
Jonas Holzman
3c4a4282ea Merge branch 'blender-v4.4-release' 2025-02-16 23:41:30 +01:00
kgalik
c3d92f32dc NDOF: Rework input handling on macOS
This patch modifies the logic behind handling NDOF device events on
macOS so that it can benefit from the `Blender` profile available in
3DConnexion driver v10.8.7 and later.

A new device command was introduced: `kConnexionCmdAppEvent`, which is
sent by the driver upong getting an apprioriate NDOF device button
input. This allow the driver to consumes all NDOF device input and then
send appropriate app events based on its configuration instead of
forwarding raw data to the application directly.

When using 3DConnexion driver versions prior to v10.8.7, the behavior
is unchanged. This approach allows for supporting all of the SpaceMouse
Enterprise buttons, long presses included (solving issue #119206 on macOS)

Co-authored-by: Sergey Sharybin <sergey@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/126694
2025-02-16 23:39:24 +01:00