Commit Graph

14111 Commits

Author SHA1 Message Date
Jeroen Bakker
5705065db1 Fix: GHOST: Incorrect check for compilation with wayland 2024-07-11 08:34:30 +02:00
Jeroen Bakker
c929e251db Fix 102994: GHOST: Fix transparent viewports
On specific platforms the viewport could be rendered transparent on
top of the OS desktop. Mesa adviced us to enable a `EGL_PRESENT_OPAQUE`
when its extension exists.

Partially fixes #102994; mesa-zink (https://docs.mesa3d.org/drivers/zink.html)
still shows transparent viewports. As this PR already improves the situation we
it will be merged.

Pull Request: https://projects.blender.org/blender/blender/pulls/124395

Pull Request: https://projects.blender.org/blender/blender/pulls/124485
2024-07-10 22:02:24 +02:00
Fermin
ad58c9eaca XR: Add passthrough support for Meta Quest devices
Uses the OpenXR extension XR_FB_PASSTHROUGH_EXTENSION_NAME,
compatible mainly with the Meta Quest family of devices.

Currently, passthrough support over OpenXR is disabled by default
in the Quest Link app, and must be manually enabled in its settings
to use this feature.

The performance of the passthrough render varies with the quality
of the connection between the headset and the PC. For better results,
connecting the headset directly through USB to the PC, or at least
connecting the PC to the local network over ethernet, is recommended.

Thanks a lot to [KISKA](https://kiska.com/)
for their support in the development of this feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/124204
2024-07-09 06:10:17 +02:00
Weizhen Huang
204407ca11 Cleanup: make format 2024-07-08 16:22:51 +02:00
Weizhen Huang
4a4270d73c Merge branch 'blender-v4.2-release' 2024-07-08 16:19:41 +02:00
Michael Jones
5a29be3c75 Cycles: Fix #116243, #122022 - MetalRT live viewport stability issues
This PR fixes live viewport stability issues on Mac when MetalRT is enabled.

There were two sources of instability:

1) `MTLAccelerationStructure` instances were not being correctly retained meaning that use-after-free crashes could occur following a geometry sync.
2) `MTLIntersectionFunctionTable` objects could be unsafely shared between multiple `MetalDeviceQueue` instances (in this case, `setBuffer` being the unsafe mutation)

The solution to 2 involves creating a new `MetalDispatchPipeline` type which is strictly used by only 1 `MetalDeviceQueue` instance.

Pull Request: https://projects.blender.org/blender/blender/pulls/124055
2024-07-08 16:18:34 +02:00
Weizhen Huang
204b99dd3f Fix #124241: Light-linked objects render incorrectly in volumes
the object in volume stack should be used instead of `isect.object`.

NOTE: this solution does not work for overlapping volumes. But since
light linking of overlapping volumes did not work before, it should be
fine to implement this partial solution. We read the bottom of the stack
instead of the top to avoid looping through the entire stack.

Pull Request: https://projects.blender.org/blender/blender/pulls/124341
2024-07-08 16:17:39 +02:00
Michael Jones
3c38bff667 Cycles: Fix MetalRT motion blur setup buffer overrun
This PR fixes a buffer overrun crash in the MetalRT backend. When non-traceable objects are in the scene, 'num_motion_transforms' is undercounting and the downstream buffer writes (i.e.`motion_transforms[motion_transform_index++]`) are overrunning.

Pull Request: https://projects.blender.org/blender/blender/pulls/124351
2024-07-08 16:17:19 +02:00
Philipp Oeser
90c03bd040 Merge branch 'blender-v4.2-release' 2024-07-08 15:59:40 +02:00
Michael Jones
ea3c376b4d Cycles: Avoid spam Metal pipeline creation during viewport animation
This PR adds a tag to prevent `kernel_data.integrator.seed` being baked into Metal pipelines as a specialisation constant when full kernel specialisation is enabled. This stops new pipelines from being continually compiled when animation is playing in live viewport mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/124349
2024-07-08 15:53:35 +02:00
Campbell Barton
67bb5b25b1 Cleanup: add printf function attributes, quiet GCC warnings 2024-07-08 22:32:53 +10:00
Bastien Montagne
4195e9e1a7 MEM_guarded: Improve error reporting usefulness.
The main change from this commit is the usage of ASAN poisoning (if
available) to trigger an ASAN report on the erroring memory block.

The main benefit is the report of the allocation backtrace of that
faulty memory block.

Pull Request: https://projects.blender.org/blender/blender/pulls/124231
2024-07-08 12:10:37 +02:00
Campbell Barton
cd1dbab348 Cleanup: spelling in comments 2024-07-07 00:29:39 +10:00
Campbell Barton
2b88bcdd3a Merge branch 'blender-v4.2-release' 2024-07-05 20:49:38 +10:00
Campbell Barton
a796589ed1 Fix memory leak in GHOST_WindowX11::getDPIHint
XrmDatabase wasn't destroyed when it successfully found the DPI.
2024-07-05 20:33:36 +10:00
Alaska
9d1e613292 Cycles: Refactor and add use_gpu() to UI code
Add a `use_gpu()` function to the UI code for Cycles.
This is done to clean up some of the other code (`use_{backend}()`)
and to help isolate `use_multi_device` and `show_device_active` from
their context making them more robust to changes made in other parts
of the UI code.

Pull Request: https://projects.blender.org/blender/blender/pulls/124134
2024-07-04 11:21:45 +02:00
Jeroen Bakker
84cbf33b38 Vulkan: Enable multi draw indirect feature
Multi draw indirect is used by the overlay engine and can lead
to a validation error when multiple instances are drawn.

This PR enabled the feature. We expect that all our devices can handle
this feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/124141
2024-07-04 10:42:20 +02:00
Alexander Brock
717c970297 Add round-trip tests for *_to_direction functions and fix some of them
The function `direction_to_<some projection model>` computes the inverse of `<some projection model>_to_direction`.
Some of these functions had a bug where they mirror the x-axis, and some of them could be simplified.
I added round-trip tests for all of them.
This MR might change the behavior of the renderer when using equiangular_cubemap_face_to_direction:
I normalized the result vector. I looked at the usages and I think it's normalized later anyways, but someone else should probably verify that this doesn't cause issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/123932
2024-07-04 09:54:50 +02:00
Bastien Montagne
06be295946 Add detection of mismatches usages of MEM_new/MEM_freeN.
This commit will error (and abort if enabled) when trying to call
`MEM_freeN` (and related `MEM_dupallocN`, `MEM_reallocN` and
`MEM_recallocN` functions) with a pointer created the C++ way (i.e.
through `MEM_new`, or the guardedalloc-overloaded `new` operator).

To do so, it adds internal use only implementations for `malloc_alligned`
and `free`, which take an extra parameter indicating whether they are
dealing with data created/deleted the 'C++ way' (using `new`/`delete`
and similar).

The cpp-created data are flagged with the new
`MEMHEAD_FLAG_FROM_CPP_NEW`, either in the lower two-bytes len value for
lockfree allocator, or as a new flag member of the guarded allocator
header data.

The public `MEM_new`/`MEM_delete` template functions, and the
guardedalloc-overloaded versions of `new`/`delete` operators are updated
accordingly.

These changes have been successfully tested both with and without
`WITH_CXX_GUARDEDALLOC`.

NOTE: A lot of mismatches have already been fixed in `main` before merging
this change. There are likely some less easy to trigger ones still in our
codebase though.

Pull Request: https://projects.blender.org/blender/blender/pulls/123740
2024-07-03 17:23:03 +02:00
Bastien Montagne
4afb48acad Cleanup: Move internal guardedalloc headers to C++.
Pull Request: https://projects.blender.org/blender/blender/pulls/124106
2024-07-03 16:04:18 +02:00
Sergey Sharybin
35788ca3c9 Merge branch 'blender-v4.2-release' 2024-07-03 16:01:21 +02:00
Alaska
659e19607d Cycles: Cleanup calls to _cycles.available_devices
Refactor the call to `_cycles.available_devices` into it's own function
and update `self.device` at the same time to avoid mis-matches between
`_cycles.available_devices` and `self.device`.

Pull Request: https://projects.blender.org/blender/blender/pulls/124079
2024-07-03 16:00:42 +02:00
Alaska
090fed06a9 Cycles: Fix automatic OptiX denoiser section criteria
Only select OptiX as the automatic denoiser if an OptiX
device is selected in preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/124032
2024-07-03 16:00:02 +02:00
Nikita Sirgienko
74c09b2e63 Cycles: oneAPI: Fix undefined behavior when embree fails initializing
Embree device pointer can end up being nullptr even when Embree on GPU is
expected to be used.  Previous implementation overlooked this possibility,
leading to a completely silent fallback to the non-Hardware ray-tracing path,
this commit fixes it.  We've noticed this as now Embree relies on a driver
component: https://github.com/intel/level-zero-raytracing-support that can
potentially be missing from a system.

Pull Request: https://projects.blender.org/blender/blender/pulls/124085
2024-07-03 14:13:01 +02:00
Xavier Hallade
4477641467 Cycles: oneAPI: Fix driver version check for future Intel GPU drivers
SYCL runtime currently relies on an internal driver behavior that will
break the driver version string returned by SYCL if it changes:
https://github.com/oneapi-src/unified-runtime/issues/1777
This will be fixed at SYCL runtime level but until we use a new enough
one, we need to add additional verifications to avoid blocking execution
on a driver that will change this internal behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/124084
2024-07-03 14:12:16 +02:00
Xavier Hallade
275b6ee008 Merge branch 'blender-v4.2-release' 2024-07-03 14:03:37 +02:00
Sergey Sharybin
368143c4f2 Merge branch 'blender-v4.2-release' 2024-07-02 16:03:21 +02:00
Alaska
f3fb3a9ecd Cycles: Update device entries more often
This resolves two issues:
1. On macOS the GPU Compute device would be disabled by default unless
the user opens user preferences. This is unexpected behaviour ever
since 09ba1486f8
2. Fixes incorrect automatic denoiser display settings and errors in
terminal related to the denoising UI on macOS if the user hasn't opened
user preferences.

Pull Request: https://projects.blender.org/blender/blender/pulls/123911
2024-07-02 16:02:53 +02:00
Sergey Sharybin
de6037c43d Merge branch 'blender-v4.2-release' 2024-07-02 15:59:33 +02:00
Alaska
4961b93136 Cycles: Fix crash using OptiX denoiser with unsupported device selected
Fixes an issue where Blender would crash if the OptiX denoiser was
selected, but an unsupported GPU device (E.g. Intel GPU) was
selected in preferences.

This crash would occur because Cycles uses the device in preferences
to setup the denoiser, and there was no check stopping an unsupported
GPU from being used to try and setup and run the denoiser.

Pull Request: https://projects.blender.org/blender/blender/pulls/124001
2024-07-02 15:58:56 +02:00
Lukas Stockner
87159b2871 Cycles: Add Diffuse Roughness option to Principled BSDF
Setting this option to a value above zero replaces the lambertian Diffuse term
with the modified energy-preserving Oren-Nayar BSDF, which matches the OpenPBR
behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/123616
2024-07-01 15:49:09 +02:00
Weizhen Huang
f2215d7564 Fix: safe_normalize() not defined for float2 on Metal 2024-07-01 13:58:30 +02:00
Alexander Brock
1b09654530 Fix and test direction_to_fisheye_lens_polynomial
The function direction_to_fisheye_lens_polynomial computes the inverse of
fisheye_lens_polynomial_to_direction.

Previously the function worked almost correctly if all parameters except k_0
and k_1 were zero (in that case it was correct except for flipping the x-axis).

I replaced the fixed-point iteration (?) by Newton's method and implemented a
test to make sure it works correctly with a wider range of parameter sets.

Pull Request: https://projects.blender.org/blender/blender/pulls/123737
2024-07-01 13:56:35 +02:00
Weizhen Huang
4c5c5e2fd7 Fix: safe_normalize() not defined for float2 on Metal 2024-06-29 07:56:46 +02:00
Alexander Brock
fe54824f24 Fix and test direction_to_fisheye_lens_polynomial
The function direction_to_fisheye_lens_polynomial computes the inverse of
fisheye_lens_polynomial_to_direction.

Previously the function worked almost correctly if all parameters except k_0
and k_1 were zero (in that case it was correct except for flipping the x-axis).

I replaced the fixed-point iteration (?) by Newton's method and implemented a
test to make sure it works correctly with a wider range of parameter sets.

Pull Request: https://projects.blender.org/blender/blender/pulls/123737
2024-06-28 20:33:17 +02:00
Lukas Stockner
6967255906 Color management: Support white balance as part of the display transform
This implements a von-Kries-style chromatic adaption using the Bradford matrix.
The adaption is performed in scene linear space in the OCIO GLSL shader, with
the matrix being computed on the host.

The parameters specify the white point of the input, which is to be mapped to
the white point of the scene linear space. The main parameter is temperature,
specified in Kelvin, which defines the blackbody spectrum that is used as the
input white point. Additionally, a tint parameter can be used to shift the
white point away from pure blackbody spectra (e.g. to match a D illuminant).

The defaults are set to match D65 so there is no immediate color shift when
enabling the option. Tint = 10 is needed since the D-series illuminants aren't
perfect blackbody emitters.

As an alternative to manually specifying the values, there's also a color
picker. When a color is selected, temperature and tint are set such that this
color ends up being balanced to white.
This only works if the color is close enough to a blackbody emitter -
specifically, for tint values within +-150. Beyond this, there can be ambiguity
in the representation.
Currently, in this case, the input is just ignored and temperature/tint aren't
changed. Ideally, we'd eventually give UI feedback for this.

Presets are supported, and all the CIE standard illuminants are included.

One part that I'm not quite happy with is that the tint parameter starts to
give weird results at moderate values when the temperature is low.
The reason for this can be seen here:
https://commons.wikimedia.org/wiki/File:Planckian-locus.png
Tint is moving along the isotherm lines (with the plot corresponding to +-150),
but below 4000K some of that range is outside of the gamut. Not much can
be done there, other than possibly clipping those values...

Adding support for this to the compositor should be quite easy and is planned
as a next step.

Pull Request: https://projects.blender.org/blender/blender/pulls/123278
2024-06-27 23:27:58 +02:00
Brecht Van Lommel
3072e6f518 Merge branch 'blender-v4.2-release' 2024-06-26 21:30:39 +02:00
Brecht Van Lommel
4b47a48ea2 Hydra: Fix Cycles render delegate to build with USD 24.x 2024-06-26 21:06:40 +02:00
Brecht Van Lommel
a060de65a4 Cycles: Sync minor build related changes with standalone repo 2024-06-26 20:39:03 +02:00
howetuft
5e40dcc95d Cycles: Expose object node in XML API
The Object node is not currently exposed in the XML API, but rather
implicitly created along with Mesh nodes. This prevents accessing
features that are dependent on this node, like caustics settings.

Pull Request: https://projects.blender.org/blender/cycles/pulls/8
2024-06-26 20:39:03 +02:00
howetuft
dc35852107 Cycles: Expose vertex normals and tangent space attributes in XML API
The vertex normals and tangent space attributes are not currently exposed by
the XML API, in the Mesh node. This notably prevents the XML API user
from applying normal maps to meshes in tangent space.

To overcome this situation, this commit adds three attributes to the Mesh node:
N: vertex normals
tangent: tangents
tangent_sign: tangent signs

Nota: at the moment, these attributes are only available for non-subdivided
meshes.

Pull Request: https://projects.blender.org/blender/cycles/pulls/9
2024-06-26 20:39:02 +02:00
Pierre Pontier
3be050ed47 Fix: Cycles build error with GCC and Clang with some build options
Pull Request: https://projects.blender.org/blender/cycles/pulls/5
2024-06-26 20:39:02 +02:00
Alaska
c8340cf754 Cycles: Remove AMD and Intel GPU support from Metal backend
This is because with the addition of new features to Cycles, these GPUs
experienced significant performance regressions and bugs, all stemming
from bugs in the Metal GPU driver/compiler. The only reasonable way to
work around these issues was to disable parts of Cycles code on
these GPUs to avoid the driver/compiler bugs.

This resulted in increased development time maintaining these platforms
while being unable to deliver feature parity with other
GPU backends.

It has been decided that this development time is better spent
maintaining platforms that are still actively maintained by
hardware/software vendors, and so AMD and Intel GPU support will be
removed from the Metal backend for Cycles.

Pull Request: https://projects.blender.org/blender/blender/pulls/123551
2024-06-26 17:16:20 +02:00
Sergey Sharybin
af71cb6485 Merge branch 'blender-v4.2-release' 2024-06-26 14:16:30 +02:00
Alaska
3232458152 Fix #123763: Cycles Metal renders with MNEE stuck on some Macs
On some Macs, MNEE would be disabled in Cycles to work around a bug.
However this just led to these devices skipping over MNEE related
parts of the rendering pipeline and not properly progressing through
the render.

This commit fixes this issue by properly disabling MNEE on these devices.

Pull Request: https://projects.blender.org/blender/blender/pulls/123765
2024-06-26 14:15:01 +02:00
Bastien Montagne
2d7f00e410 Merge branch 'blender-v4.2-release' 2024-06-26 11:50:27 +02:00
Bastien Montagne
c525e4db83 Revert "GHOST/Wayland: reference the stable tablet-v2 API"
The currently available `wayland-protocol` libraries in lib-linux_x64
repo do not appear to be advertised 1.36 (or 1.35) versions, since the
tablet protocol is not available among the stable ones.

This reverts commit 2a85eaaf16.

Pull Request: https://projects.blender.org/blender/blender/pulls/123774
2024-06-26 11:48:55 +02:00
Campbell Barton
9ee6da08ab Merge branch 'blender-v4.2-release' 2024-06-26 16:29:57 +10:00
Campbell Barton
2a85eaaf16 GHOST/Wayland: reference the stable tablet-v2 API
The tablet API become stable in wayland-protocol 1.35
2024-06-26 16:26:18 +10:00
Brecht Van Lommel
31de58e161 Merge branch 'blender-v4.2-release' 2024-06-26 02:40:26 +02:00