Commit Graph

14214 Commits

Author SHA1 Message Date
Campbell Barton
ad00f9657b GHOST/Wayland: update the cursor scale even when hidden
When the output scale changes, the theme scale wasn't updated
when the current cursor had no surface.
2024-09-04 19:34:15 +10:00
Campbell Barton
842f87d1de Cleanup: unused parameter warnings 2024-09-04 19:34:15 +10:00
Nikita Sirgienko
94c9898f41 Fix #124811: Cycles: oneAPI: no hair strands in viewport with Embree
oneAPI kernels preloading logic was letting un-needed kernels to be
compiled without features, which would then miss when these kernels
were needed later.

Pull Request: https://projects.blender.org/blender/blender/pulls/127114
2024-09-04 11:08:00 +02:00
Alaska
8cf4d47fe2 Fix: Improve Cycles point clouds in HIPRT
Fixes a few issues with point clouds with HIPRT.
1. Crashing when building the BLAS due to an incorrect sized array.
2. A typo leading to all point cloud intersections being skipped.
3. A typo leading to some motion blurred point clouds rendering
as if they were stationary, or not rendering at all.

Pointclouds, with deformable motion blur, with BVH time steps set to >0
still do not render. Curves seem to have the same issue.

Ref #125086

Pull Request: https://projects.blender.org/blender/blender/pulls/125834
2024-09-03 16:31:41 +02:00
Campbell Barton
e34d9eeac7 Cleanup: use C-style comments, double quote Python text 2024-09-03 21:22:34 +10:00
Bastien Montagne
16eff5af62 Cleanup: Update documentation of MEM module API.
Make it clearer that C++-style MEM_new/MEM_delete and
C-style MEM_cnew/MEM_malloc/etc./MEM_freeN calls should never be mixed
on the same data.
2024-09-03 13:00:21 +02:00
Weizhen Huang
77035192c9 Fix #126799: undefined behavior of shader node Arctan2 at (0, 0)
`atan2(0, 0)` is undefined on many platforms. To ensure consistent
result across platforms, we return `0` in this case.

Note only the behavior of the shader node `Artan2` is changed here.
During shading, we might still produce `atan2(0, 0)` internally and
cause different results across platforms, but that usually happens with
single samples and is not obvious, plus checking this condition all the
time is costly. If later we find out it's indeed necessary to change all
the invocation of `atan2(0, 0)`, we could change the wrapper functions
in `metal/compat.h` and `mtl_shader_defines.msl`.

Pull Request: https://projects.blender.org/blender/blender/pulls/126951
2024-09-03 11:44:59 +02:00
Jonas Holzman
8b569bac0d Obj-C Refactor: Autoreleasepool and property dot-notation refactor
Autoreleasepool:
- Replace outdated `NSAutoreleasePool` `init`/`drain` mechanism with
  the modern `@autoreleasepool {}` block. Leading to simpler and
  cleaner code, and more flexible functions return placement.
- Add missing `autoreleasepool` in code.
  The rule being that in an MRR (Manual Retain-Release / non-automatic
  reference counting) environments, "Cocoa expects there to be an
  autorelease pool always available. If a pool is not available,
  autoreleased objects do not get released and you leak memory"
  (quote from Apple Dev Docs).
  As we cannot make safe assumptions about function call sites, and
  cannot rely on a main autoreleasepool like a standard Obj-C
  application, every piece of Objective-C code that calls any sort of
  Cocoa function should be wrapped in an `autoreleasepool {}` block for
  eventual internal `autorelease` call to be honored.
- Add missing `release` / `autorelease`, make correct MRR pairs

A next step would be to start transitioning the Blender Obj-C codebase
from MRR to automatic reference counting (ARC).

Dot-Notation:
- Use Objective-C dot notation to follow modern Objective-C practices,
  and provide a more familiar syntax to programmers coming from C/C++,
  (`foo.prop` instead of `[foo prop]` for access, `foo.prop = bar`
  instead of `[foo setProp:bar]` for setting).
- Exception for singleton class properties / methods
  (`[NSPasteboard generalPasteboard]` instead of
  `NSPasteboard.generalPasteboard`) and nested method calls that mix
  property and methods.
  (Example: [NSApp windowWithWindowNumber:[window_number integerValue]]`
   or `[view convertRectToBacking:[view bounds]]`)

When possible, or necessary, refactored functions were simplified or
refactored, in which case the Blender code style was applied. As such
there is some overlap with PR #126770, especially when it comes to const
correctness.

Due to the fact that these two refactors are quite interlinked, and for
easier reviewing / avoiding complicated merge conflicts, they're shipped
in a single PR.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126771
2024-09-03 11:38:32 +02:00
Campbell Barton
d19c13eb82 Cleanup: spelling & punctuation in comments 2024-09-03 12:59:37 +10:00
Xavier Hallade
1a0dbbd242 Fix: Cannot render Victor and Spring with embree disabled on Intel GPUs
The kernel zeroing memory since we've added host memory fallback didn't
expect large inputs, so with these scenes, it was running into
"Provided range is out of integer limits. Pass
`-fno-sycl-id-queries-fit-in-int' to disable range check" error.

This kernel was used instead of memset to avoid some issues with the
free_memory queries not always being updated.
As we can't reproduce these with recent drivers, we now use memset,
which fixes rendering with BVH2.
2024-09-02 18:35:51 +02:00
Jeroen Bakker
509123c877 Vulkan: Initial support for multiple windows
- Resource pools are shared between multiple swap chains to reduce
  code complexity
- Fix issue where activating a new graphical context could still leave
  the previous context rendering.
- Known issue: opening files with more windows require a redraw.

Reference: #126499
Pull Request: https://projects.blender.org/blender/blender/pulls/126961
2024-08-30 10:01:56 +02:00
Jeroen Bakker
b710194876 Cleanup: Remove unused code
Pull Request: https://projects.blender.org/blender/blender/pulls/126960
2024-08-30 09:23:01 +02:00
Nathan Vegdahl
dc2272e538 Cleanup: run make format 2024-08-29 17:46:54 +02:00
Jonas Holzman
4449fba2f3 Obj-C Refactor: Remove unsound use of const in Objective-C code
The use of `const` for Objective-C object pointer is not standard and
generally unsound. Unlike a C++ class, which has support for const and
non-const methods. An Objective-C object will still respond to mutable
selectors even if its object pointer is const, making it semantically
useless.

Another problem with const Objective-C object is that they cannot be
properly passed into other Objective-C object selectors due to type
differences. Even if that selector didn't modify the underlying object.

For consistency with general Objective-C code style guidelines, usage of
const pointer syntax (`Class *const`) were also removed.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126768
2024-08-29 15:59:07 +02:00
Campbell Barton
d497452a73 Cleanup: typo, spaces in comments, comment blocks & use double quotes 2024-08-29 17:16:44 +10:00
Alaska
84bab7f300 Fix #126592: Cycles light tree subtended angle not covering the entire bounding box
Use a bounding sphere instead of the corners of a bounding box to
compute the subtended angle of a light tree node.

Using the corners of the bounding box was an underestimate in some
scenes, causing some light tree nodes being incorrectly skipped.

Using the subtended angle of a bounding sphere is an overestimate, but
it covers the entire node and would not skip any valid contribution,
and no other reliable algorithm to compute the minimal enclosing angle
is known to us.

We expect some increase in noise due to overestimation, but this has
not been observed yet, in our benchmark scenes only a difference in
noise is visible.

Thanks to Weizhen for the suggestion to use the bounding sphere.

Pull Request: https://projects.blender.org/blender/blender/pulls/126625
2024-08-28 11:53:53 +02:00
Alaska
6ccb33e9fe Shader: Add Metallic BSDF Node
Add Metallic BSDF Node to the shader editor.

This node can primarily be used to create more realistic looking
metallic materials than the existing Glossy BSDF node.

This commit does not add any new closures to Cycles, it simply exposes
existing closures that were previous hard to access on their own.

- Exposes the F82 fresnel type that is currently used by the
metallic component of the Principled BSDF. Results should match
between the Metallic BSDF and Principled BSDF when using the same
settings.
- Exposes the Physical Conductor fresnel type that was previously
limited to custom OSL scripts. The Conductor fresnel type accepts
IOR and Extinction coefficients to define the appearance of the
material based off real life measurements.

EEVEE only supports the F82 fresnel type with internal code to convert
the the physical conductor inputs in to a colour format for F82,
which can lead to noticeable rendering differences with
some configurations.

Pull Request: https://projects.blender.org/blender/blender/pulls/114958
2024-08-27 17:20:46 +02:00
Sergey Sharybin
92733a9415 Fix: Cycles memory leak in HIP-RT
Some of the device memory objects had their host_pointer overwritten
with another CPU-side buffer after allocation. This leads to a leak of
host memory allocated by the device_memory.

There are few remaining places where the host_pointer is assigned and
those seems to be fine because the memory was not yet allocated with
a alloc() call.

While the approach in this change is not very ideal, it is small and
potentially could be ported to the LTS tracks. More ideal solution
would be to utilize device_vector::give_data().

Pull Request: https://projects.blender.org/blender/blender/pulls/126788
2024-08-27 12:46:54 +02:00
Campbell Barton
5cb29528e6 Cleanup: spelling in comments 2024-08-26 11:50:15 +10:00
Campbell Barton
fdd0b93cfa Cleanup: spelling in comments 2024-08-23 10:19:53 +10:00
Aras Pranckevicius
246a0ec46a Fix #126394: ffmpeg on win64 is built without SIMD optimizations
Since ee1b2f53cc the ffmpeg libraries for Windows x64 are built effectively
without CPU specific SIMD optimizations. `--arch=x64` is not an architecture
that ffmpeg configure understands, so it falls back to "nothing is known,
turn any architecture specific bits off" code path.

Pull Request: https://projects.blender.org/blender/blender/pulls/126396
2024-08-22 10:36:18 +02:00
Campbell Barton
08d5eb8f9c Cleanup: cmake formatting 2024-08-21 23:20:34 +10:00
Campbell Barton
5a0e8317f4 Cleanup: use const vars/args 2024-08-21 19:19:38 +10:00
Campbell Barton
bf529e248a Fix #124693: Wrong cursor after saving with multiple windows on Wayland
The last set cursor of any window was being used under Wayland.
Support for per-window cursor shapes to resolve the problem.
2024-08-21 17:29:55 +10:00
Campbell Barton
9ab9aab3d7 Cleanup: use "Helper" suffix for mix-in panel classes
This clarifies that they aren't themselves panel types.
2024-08-20 14:25:56 +10:00
Campbell Barton
ec759b6caf Cleanup: suppress debug warning with unregistered Panel sub-classes 2024-08-20 14:25:55 +10:00
Weizhen Huang
be0d2e19b5 Fix #115998: Cycles volume too dark when shadow ray visibility is off
when tracing shadow ray through a volume and no hit is registered, we
consider the whole ray segment inside the volume.

However, no hit registered could also happen when the volume is
invisible to shadow ray. We should explicitly check this case and skip
rendering the volume segment instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/126139
2024-08-19 15:52:35 +02:00
Jeroen Bakker
ef3ceb3629 Vulkan: Resource Pools
This PR implements #126353; In short: keep discard list as part of swap chain images. This allows
better determination when resources are actually not in use anymore.

## Resource pool

Resource pools keep track of the resources for a swap chain image.

In Blender this is a bit more complicated due to the way GPUContext work. A single thread can have
multiple contexts. Some of them have a swap chain (GHOST Window) other don't (draw manager). The
resource pool should be shared between the contexts running on the same thread.

When opening multiple windows there are also multiple swap chains to consider.

### Discard pile

Resource handles that are deleted and stored in the discard pile. When we are sure that these
resources are not used on the GPU anymore these are destroyed.

### Reusable resources

There are other resources as well like:
- Descriptor sets
- Descriptor pools

## Open issues

There are some limitations that require future PRs to fix including:
- Background rendering
- Handling multiple windows
- Improve CPU/GPU synchronization
- Reuse staging buffers

Pull Request: https://projects.blender.org/blender/blender/pulls/126353
2024-08-19 15:37:48 +02:00
Sergey Sharybin
51461d0561 Cleanup: Spelling of data-block in a comment 2024-08-19 11:54:36 +02:00
Campbell Barton
92f633e7cb Fix #105895: tiny mouse cursor with 125% fractional scaling on Wayland
This only impacted configurations that don't include large cursor sizes
which isn't so common.

However when it does happen the cursors are small enough that they're
difficult to see.
2024-08-16 22:59:41 +10:00
Sergey Sharybin
c5008d2de9 Fix #124679: Certain OSL scripts have artifacts in the world shader on Windows
Pull Request: https://projects.blender.org/blender/blender/pulls/126374
2024-08-16 10:35:32 +02:00
Campbell Barton
d71d325692 Cleanup: spelling in comments, strings 2024-08-16 09:33:20 +10:00
David Murmann
58aa349f68 Fix #126354: Cycles: Calculate correct bounds for hair objects
Hair objects did not take the curves into account that could go
outside the bounds set by the keys of the curves. These bounds
are used in the dynamic bvh, leading to clipped curves in the
viewport.

Pull Request: https://projects.blender.org/blender/blender/pulls/126157
2024-08-15 16:39:15 +02:00
Patrick Mours
013a2ce765 Cycles: Change OptiX curve vertex data generation to use more compact representation
OptiX has accepted Catmull-Rom curve data natively since OptiX 7.4, but due to the previous conversion to B-Spline code, the format that data is fed to OptiX wasn't optimal.

Each curve segment was put in the vertex buffer as four independent control points, even though continuous segments actually share control points between each other. This patch compacts that so shared control points only occur once in the vertex buffer.
This compact form uses less memory and also allows OptiX to easily identify segments that belong together into a curve (those where the step between indices is one).

Pull Request: https://projects.blender.org/blender/blender/pulls/125899
2024-08-15 15:00:56 +02:00
Campbell Barton
da94978cc4 Cleanup: format 2024-08-15 21:26:12 +10:00
Campbell Barton
b5e0b59736 Cleanup: remove space around identifiers in C-style comments 2024-08-15 20:46:00 +10:00
YimingWu
04c5a9f053 Fix #126136: Show GUI message box for unsupported GPUs on X11
On X11 windowing systems there's no `MessageBox` prompt like on
win32 that could show users that they have unsupported GPUs,
this leads to confusion to them as they typically don't open
blender from a command line so none of the messages could be
available. This patch utilizes `system->showMessageBox` to display
a GUI message box telling the user that the GPU is unsupported.

Pull Request: https://projects.blender.org/blender/blender/pulls/126220
2024-08-15 08:37:03 +02:00
Jesse Yurkovich
92d935a205 Build: Ambiguous call to isfinite for MSVC 17.11
Overload resolution must have changed and is causing issues for one
particular code path attempting to use `isfinite(ccl::uchar)`.
Compiler output attached.

It turns out that the code in question can be simplified to just remove
the ambiguity because only the float codepath wants to check for finite
values.

----
Reduced repro: https://godbolt.org/z/YWz3Yc3x8

Pull Request: https://projects.blender.org/blender/blender/pulls/125348
2024-08-14 19:52:48 +02:00
Omar Emara
075bdbcd63 Nodes: Improve isotropic Gabor noise UI controls
This patch improves the isotropic Gabor noise UI controls such that
variations happen in both directions of the base orientation, as opposed
to being biased in the positive direction only.

Thanks to Charlie Jolly for suggesting this improvement.
2024-08-14 15:26:03 +03:00
Omar Emara
ce89d7949c Nodes: Optimize Gabor noise variance estimation
This patch optimizes the Gabor noise standard deviation estimation by
computing the upper limit of the integral as the frequency approaches
infinity, since the integral is mostly constant for the relevant
frequency range. The limits are 0.25 for the 2D case and 1 / 4 * sqrt2
for the 3D case.

This also improves normalization for low frequencies, possibly due to
the effect of windowing.

Thanks to Charlie Jolly for spotting the optimization.
2024-08-14 14:27:23 +03:00
Sergey Sharybin
f1fe232e89 Cycles: Add parallel_reduce() to the ccl namespace
Currently unused, but is a good utility to have to make code
threaded in the future.
2024-08-14 12:33:40 +02:00
Omar Emara
847a3a7ea3 Nodes: Optimize Gabor noise with early exit
Optimize the Gabor noise texture code with an early exit for points that
are further away from the kernel center. This was already done for the
kernel, but is now being done earlier before computing the weight, so
its computation is now skipped.

Thanks to Charlie Jolly for the suggestion.
2024-08-14 12:12:34 +03:00
Alaska
a3b0c68ca9 Fix #123634: Missing 3D curve intersections with Metal BVH2
Fixes missing intersections on straight 3D curves with the
Metal backend, with BVH2.

This issue could of manifested on other devices, but didn't seem to
in practice.

Pull Request: https://projects.blender.org/blender/blender/pulls/126197
2024-08-13 16:49:28 +02:00
Anthony Roberts
07d0ecb9d6 Windows: Fix OpenVDB errors when compiling with clang-cl
Pull Request: https://projects.blender.org/blender/blender/pulls/126236
2024-08-13 11:36:36 +02:00
Anthony Roberts
9576576039 Windows: Enable clang-cl for ARM64
This gets Windows ARM64 to compile with clang-cl, which gives up to 40% performance improvements in certain scenes rendered with cycles, compared to MSVC.

This is all tested using LLVM 18.1.8 and a VS2022 `vcvarsall` window.

Subsequent PRs with various lib version updates, etc to go in at a later point.

Pull Request: https://projects.blender.org/blender/blender/pulls/124182
2024-08-12 16:50:07 +02:00
Sergey Sharybin
ce6454d02f Fix #126005: x64 Blender on Apple Silicon doesn't render properly in Cycles GPU
The GPU packed state is a static check from the Cycles core perspective,
and it is disabled for non-Apple Silicon GPUs. However, the Metal kernel
always used packed integrator.

This change makes it so the Host and Device side checks for the Host CPU
are aligned, and that Device-side packed state check does not differ from
the Host side.

Pull Request: https://projects.blender.org/blender/blender/pulls/126082
2024-08-08 16:01:23 +02:00
Eoin Mcloughlin
5ee7d02840 Fix #91369: Remove physics constraint references to avoid crash on undo
Fixes #91369, where a pointer to a deleted btTypedConstraint instance
was being dereferenced, causing a crash.

What was happening was:
1. When the animation starts the first time, BKE_rigidbody_rebuild_sim
  eventually calls btDiscreteDynamicsWorld::addConstraint, which in turn
  will store a pointer to the btTypedConstraint in
  btRigidBody::m_constraintRefs for each body in the constraint
2. When undoing, the btDynamicsWorld is deleted, then the Object
  containing the btTypedConstraint (taking the btTypedConstraint with
  it) - however, the pointer to the btTypedConstraint is still in the
  btRigidBody!
3. When playing the animation a second time, rigidbody_update_simulation
  will rebuild the simulation, which causes RB_body_delete to be called,
  which iterates over all the body's m_constraintRefs and dereferences
  the deleted pointer.

Co-authored-by: Eoin Mcloughlin <hkeoin@eoinrul.es>
Pull Request: https://projects.blender.org/blender/blender/pulls/126079
2024-08-08 14:05:14 +02:00
Sergey Sharybin
7e9776a167 Fix #125863: Crash baking textures with Cycles Metal
The issue was caused by an attempt to write buffer pass which is
actually supposed to be calculated as compositing (either summing
direct/indirect lights, optionally diving by albedo).

The fact that the crash was only observed on Metal is a lucky
con-incident: it just happened to be so that writing at offset
-1 to the render buffer did not trigger obvious issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/126057
2024-08-08 12:08:35 +02:00
Lukas Stockner
90bcc3b5dc Fix #124646: Cycles: Point Density node still works on surfaces in OSL
This was already sort of disabled in 4.0 (in #109712), but still worked in OSL,
so let's make it consistent.

Pull Request: https://projects.blender.org/blender/blender/pulls/125928
2024-08-08 00:48:35 +02:00
Sergey Sharybin
f1e82c99b9 Fix: Division by zero in Cycles render scheduler 2024-08-07 18:24:19 +02:00