Commit Graph

14284 Commits

Author SHA1 Message Date
Campbell Barton
4fa3dc0dd4 Cleanup: spelling in comments, use uppercase tags 2024-10-03 12:11:52 +10:00
Alexandre Cardaillac
0315eae536 Cycles: Add more scattering phase functions
Previously, Cycles only supported the Henyey-Greenstein phase function for volume scattering.
While HG is flexible and works for a wide range of effects, sometimes a more physically accurate
phase function may be needed for realism.

Therefore, this adds three new phase functions to the code:
Rayleigh: For particles with a size below the wavelength of light, mostly athmospheric scattering.
Fournier-Forand: For realistic underwater scattering.
Draine: Fairly specific on its own (mostly for interstellar dust), but useful for the next entry.
Mie: Approximates Mie scattering in water droplets using a mix of Draine and HG phase functions.

These phase functions can be combined using Mix nodes as usual.

Co-authored-by: Lukas Stockner <lukas@lukasstockner.de>
Pull Request: https://projects.blender.org/blender/blender/pulls/123532
2024-10-02 11:12:53 +02:00
Nikita Sirgienko
fb21f3fb56 Cleanup: Cycles: oneAPI: Fix deprecation warnings about get_pointer() 2024-10-01 22:26:15 +02:00
Jonas Holzman
92d00678ac macOS: Add Image Clipboard Copy/Paste Support
This Pull Request adds support for image clipboard copy-pasting to the Image Viewer on macOS, accepting sources from both raw image data and image files.

Tracking Issue: #111404

Pull Request: https://projects.blender.org/blender/blender/pulls/126574
2024-10-01 18:32:32 +02:00
Jeroen Bakker
71b7dd8079 Vulkan: Remove core 1.2 extensions
Vulkan backend registered extensions that were already part of Vulkan
1.2 core. These extensions don't need to be registered.

Pull Request: https://projects.blender.org/blender/blender/pulls/128408
2024-10-01 13:40:13 +02:00
Kevin Chuang
9f4da19800 Vulkan: Add support for VK_KHR_fragment_shader_barycentric
This PR introduces support for the extension `VK_KHR_fragment_shader_barycentric`,
and includes a few miscellaneous improvements related to it.

1. Add support for `VK_KHR_fragment_shader_barycentric`, if the physical device
  supports it. Otherwise, gpu_BaryCoord is generated through an injected geom
  shader, like it was previously.
2. Simplify the logic of checking has_geometry_stage in vert shader.
3. Fix a potential issue of location mismatch in an injected geom shader.

Related to #127687
Resolves #126228

Pull Request: https://projects.blender.org/blender/blender/pulls/127995
2024-10-01 09:32:59 +02:00
Campbell Barton
6cbdf0223b Cleanup: defer imports on startup 2024-10-01 10:01:16 +10:00
Campbell Barton
c6fd26a3f5 Cleanup: spelling in comments 2024-10-01 09:59:33 +10:00
Xavier Hallade
284b89a0a3 Cycles: oneAPI: compile kernels with fast-relaxed-math
This enables most of the GPU compiler's optimizations while -ffast-math
isn't set at DPC++ level.
It brings an overall 1% speedup and currently doesn't change the unit
tests pass rate.
2024-09-30 21:40:00 +02:00
Lukas Stockner
f96f3c33af Cycles: Add some more math optimizations
This enables three additional math optimizations:
-ffp-contract=fast (enables FMA generation)
-freciprocal-math (enables x/y -> x*(1/y))
-fassociative-math (enables e.g. a*b + c*b -> (a+c)*b)

These are used on Windows and HIP anyways, so our code can't expect exact IEEE
semantics in any case.

The only difference between the new set and -ffast-math is that we don't use
-ffinite-math-only since this causes issues with the BVH (see ce1f2e271d) and
breaks e.g. isnan.

This causes a ~1.5% speedup in my very quick test, but might be higher for some
more math-intensive cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:40 +02:00
Lukas Stockner
908d3c387f Cleanup: Cycles: Deduplicate math optimization flags
The only difference between Windows+Clang and the others is a prefix, so use
some CMake logic to just prepend that to all flags instead of duplicating them.

Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:38 +02:00
Lukas Stockner
5f4c18c0bb Cycles: Apply SSE4.2 minimum regardless of compiler
We require it on all x86 platforms, so now it's assumed on all compilers that
support it.

Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:36 +02:00
Lukas Stockner
de80c24ed4 Cleanup: Cycles: Rename CYCLES_x_KERNEL_FLAGS to CYCLES_x_FLAGS in CMake
Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:31 +02:00
Lukas Stockner
442d99fe03 Cleanup: Cycles: Split vectorization and optimization CMake build flags
These aren't really related to each other, and not separating it caused
some issues - for example, enabling NATIVE_ONLY would disable math
optimizations.

Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:29 +02:00
Lukas Stockner
a8ee5485c2 Cleanup: Cycles: Fix flag name
Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:58:27 +02:00
Lukas Stockner
9105f9d219 Cleanup: Cycles: Remove obsolete AVX CMake logic
We only compile kernels for SSE4.2 and AVX2 nowadays, no need to keep this.

Pull Request: https://projects.blender.org/blender/blender/pulls/128342
2024-09-30 15:57:49 +02:00
Jason Fielder
eb3fe75392 Metal: Add support for parallel compilation and precompilation specialisation
This speeds up EEVEE startup and material compilation time.

Authored by Apple: James McCarthy
Pull Request: https://projects.blender.org/blender/blender/pulls/125657
2024-09-30 11:21:28 +02:00
Jeroen Bakker
3bec05518d Vulkan: Remove always failing extension
Since the introduction of vulkan loader in vulkan (not Blender) the
molten vk extension always leads to a failed registration. This
extension is only available when using the loader. Blender doesn't use
the vulkan loader so we should remove it.

Pull Request: https://projects.blender.org/blender/blender/pulls/128354
2024-09-30 10:14:10 +02:00
Jeroen Bakker
ecaa69f9cf Cleanup: Vulkan: Use optional extension for maintenance 4
Maintenance 4 is an optional extension, however it was added to required
extension when the extension is availble. This would also be checked
when adding it as an optional extension.

Detected when reviewing !127995

Pull Request: https://projects.blender.org/blender/blender/pulls/128353
2024-09-30 09:29:58 +02:00
Hans Goudey
5e46e3d28a Subdiv: Remove topology refiner C-API wrapper
Remove the indirection previously used for the topology refiner
to separate C and C++ code. Instead retrieve the base level in
calling code and call opensubdiv API functions directly. This
avoids copying arrays of mesh indices and should reduce
function call overhead since index retrieval can now be inlined.
It also lets us remove a lot of boilerplate shim code.

The downside is increased need for WITH_OPENSUBDIV defines
in various parts of blenkernel, but I think that is required to avoid
the previous indirection and have the kernel deal with OpenSubdiv
more directly.

Pull Request: https://projects.blender.org/blender/blender/pulls/120825
2024-09-27 19:01:12 +02:00
Sergey Sharybin
95f361ac31 Fix: Cycles occasional crash after Metal render
Happens for renders from command line, when kernel specialization
thread is still working after the allocators on the Blender side
have been deinitialized.

Add an explicit deinitializaiton, which ensures all Cycles worker
and cache threads are finished before the allocators are deinitialized.

This should solve occasional crashes when running regression tests
for Metal or Metal-RT.

Pull Request: https://projects.blender.org/blender/blender/pulls/128239
2024-09-27 14:39:49 +02:00
Sergey Sharybin
b96a7b7204 Fix #127622: 4.1 splash screen won't render with MetalRT
The commit which made the issue to be more easily discoverable is 4651f8a08f.

The fix is similar to #127114.

Pull Request: https://projects.blender.org/blender/blender/pulls/128173
2024-09-26 13:39:22 +02:00
Campbell Barton
381898b6dc Refactor: move BLI_path_util header to C++, rename to BLI_path_utils
Move to a C++ header to allow C++ features to be used there,
use the "utils" suffix as it's preferred for new files.

Ref !128147
2024-09-26 21:13:39 +10:00
Jacques Lucke
6810084a47 Attributes: improve API to iterate over attributes
This improve the API in multiple aspects:
* No need for an additional `lookup` call to get the current attribute. This
  would internally iterate over all attributes again. This leads to O(n^2)
  behavior. Note that there are still other reasons for O(n^2) behavior when
  processing attributes (where n is the number of attributes).
* Remove the need to return a value from the iteration code to indicate that the
  iteration should continue. This is now the default behavior. The iteration can
  still be stopped by calling `iter.stop()`.
* Easier access to `is_builtin` property.
* Iterator callback only has a single parameter instead of two (of which one is
  sometimes unused).

Pull Request: https://projects.blender.org/blender/blender/pulls/128128
2024-09-26 12:59:00 +02:00
Jacques Lucke
63a6ff3008 Fix #128144: crash when rendering generated volume
The issue was that cycles did not take ownership of the entire `VolumeGridData`.

The `VolumeTreeAccessToken` that was used already only makes sure that the
grid is not unloaded when it was read from disk for example. It does not extend
the lifetime of the `VolumeGridData` as a whole.
2024-09-26 12:53:48 +02:00
Campbell Barton
32c6f9bbd0 Cleanup: use PyModule_AddObjectRef where appropriate 2024-09-26 17:08:34 +10:00
Aras Pranckevicius
596067ea35 Fix #125446: Video decoding artifacts with some video widths
Previous fix (b17734598d) tried to fix this, but it seems that
depending on CPU and video width, ffmpeg might need at least 64
byte alignment, even if CPU we're running on is only AVX2 (32 byte
alignment). That is because some other parts of ffmpeg code
statically pick 64 or 32 byte alignment internally, depending on whether
AVX512 support is even compiled in (even if CPU might not have it).

I have checked whether this does not negatively affect a platform where
SIMD alignment is always 16 (Mac), and it does not, everything works as
expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/128107
2024-09-26 08:50:48 +02:00
Campbell Barton
0e08e8bf2d Cleanup: add missing CMake headers, update "check_cmake" config 2024-09-25 19:24:21 +10:00
Campbell Barton
840c65f442 Cleanup: spelling in comments 2024-09-25 19:24:20 +10:00
Campbell Barton
1d0f0604ac GHOST/Wayland: set cursor hand identifiers
These were added in [0] reusing the "move" cursor,
set the values to ID's used by KDE & GNOME cursor themes.

[0]: 458c60269b
2024-09-25 13:08:54 +10:00
Harley Acheson
e0352eb807 Platforms: Win32 Calm GHOST_WindowWin32 initializing Warning
Calm Warning C5038: data member 'GHOST_WindowWin32::m_debug_context'
will be initialized after... 'GHOST_WindowWin32::m_preferred_device'

Pull Request: https://projects.blender.org/blender/blender/pulls/128098
2024-09-25 01:06:19 +02:00
Sahar A. Kashi
26ed4d3892 Cycles: Linux Support for HIP-RT
This change switches Cycles to an opensource HIP-RT library which
implements hardware ray-tracing. This library is now used on
both Windows and Linux. While there should be no noticeable changes
on Windows, on Linux this adds support for hardware ray-tracing on
AMD GPUs.

The majority of the change is typical platform code to add new
library to the dependency builder, and a change in the way how
ahead-of-time (AoT) kernels are compiled. There are changes in
Cycles itself, but they are rather straightforward: some APIs
changed in the opensource version of the library.

There are a couple of extra files which are needed for this to
work: hiprt02003_6.1_amd.hipfb and oro_compiled_kernels.hipfb.
There are some assumptions in the HIP-RT library about how they
are available. Currently they follow the same rule as AoT
kernels for oneAPI:
- On Windows they are next to blender.exe
- On Linux they are in the lib/ folder

Performance comparison on Ubuntu 22.04.5:
```
GPU: AMD Radeon PRO W7800
Driver: amdgpu-install_6.1.60103-1_all.deb
                       main         hip-rt
attic                  0.1414s      0.0932s
barbershop_interior    0.1563s      0.1258s
bistro                 0.2134s      0.1597s
bmw27                  0.0119s      0.0099s
classroom              0.1006s      0.0803s
fishy_cat              0.0248s      0.0178s
junkshop               0.0916s      0.0713s
koro                   0.0589s      0.0720s
monster                0.0435s      0.0385s
pabellon               0.0543s      0.0391s
sponza                 0.0223s      0.0180s
spring                 0.1026s      1.5145s
victor                 0.1901s      0.1239s
wdas_cloud             0.1153s      0.1125s
```

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Co-authored-by: Sergey Sharybin <sergey@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/121050
2024-09-24 14:35:24 +02:00
Jeroen Bakker
ddb2179e37 Vulkan: GPU device selection
Allows users to override the auto detection for GPU
selection. Normally the GPU selection is done by looping
over the order Vulkan provides and finding the highest
performing device based on its type (discrete, integrated,
software).

However users might have multiple discrete cards and want
to switch between them. Or developers want to validate other
GPUs without rebooting.

This PR adds the ability to override the auto detection
for the vulkan backend.

![image](/attachments/5d9198a8-af08-4eee-aa73-363edea11cd9)

**Future improvements**:
- This PR does not include a command line option. This can be added
  later for render farms.

Pull Request: https://projects.blender.org/blender/blender/pulls/127860
2024-09-23 11:18:24 +02:00
Campbell Barton
7feccafbb0 Cleanup: various non functional changes
- Use const arguments.
- Quiet unused assignment warnings.
- Use explicit cast to suppress CPPCHECK's truncLongCastReturn warning.
2024-09-23 11:20:14 +10:00
Campbell Barton
4bd0cc888e Cleanup: various non functional changes
- Reduce variable scope.
- Function style casts.
- Avoid variable shadowing.
- Quiet unused assignment warnings.
- Remove redundant call in GHOST_WindowNULL constructor.
2024-09-22 18:25:40 +10:00
Lukasz Czyz
788bc5158e UV: add support for the SLIM unwrapping algorithm
Integrate an existing implementation of the SLIM unwrapping algorithm
into Blender. More info about SLIM here:
https://igl.ethz.ch/projects/slim/

This commit is based on the integration code written by Aurel Gruber
for Blender 2.7x (unfinished and never merged with the main branch).

This commit is based on Aurel's code, rebased and further improved.

Details:

- Unwrap has been moved into a sub-menu,
  slim unwrapping is exposed as: "Minimum Stretch".
- Live unwrap with SLIM refines the solutions using a timer.
- When using SLIM there are options to:
  - Set the number of iterations.
  - Weight the influence using vertex weights.
- SLIM can be disabled using the `WITH_UV_SLIM` build option.

Co-authored-by: Aurel Gruber <aurel.gruber@infix.ch>

Ref !114545
2024-09-21 16:48:53 +10:00
Campbell Barton
77617fce77 Revert "Cleanup: make format."
This reverts commit 06b8ddca8f.

Add ".clang-format" which prevents these files from being formatted.

Commit [0] missed adding this file.

[0]: f43da6fc4c
2024-09-20 19:46:56 +10:00
Bastien Montagne
06b8ddca8f Cleanup: make format. 2024-09-20 11:33:23 +02:00
Alaska
8ae944026e Cleanup: Avoid double printing the word 'size' in Cycles debug
Avoid printing the word `size` twice when printing information about
the scheduled tile size to terminal when Blender is launched with
with `--debug-cycles --verbose 3` or higher.

Pull Request: https://projects.blender.org/blender/blender/pulls/127885
2024-09-20 10:10:57 +02:00
Campbell Barton
f43da6fc4c Cleanup: format all of ./intern, use .clang-format to exclude paths
Directories in intern/ were selectively formatted based on
paths in `tools/utils_maintenance/clang_format_paths.py`.

This had the following problems:

- Editing files inside intern/ would auto-format on save with editors
  setup to auto-format as there was nothing to disable formatting.
- Some directories were missing (by accident it seems).

Resolve by formatting all of `./intern/` exclude except for
`./intern/itasc/` which includes ITASC & KDL versions we might
want to sync with upstream.
2024-09-20 16:26:42 +10:00
Campbell Barton
8485aaf105 Cleanup: correct copyright, SPDX header 2024-09-20 13:14:58 +10:00
Campbell Barton
0fc27c8d81 Cleanup: spelling in comments 2024-09-20 13:14:57 +10:00
Jeroen Bakker
214a47f15c Vulkan: Make Unused Attachments Optional
Windows/Intel and Apple drivers do not support dynamic
rendering unused attachments. Due to mistakes we made
this extension partly optional. Eg. the extension was
optional, but its settings were not.

This PR makes the extension fully optional. However
without the extension some drivers might make incorrect
assumptions. This should be solved when it is more clear
why some drivers are still crashing when using dynamic
rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/127839
2024-09-19 13:03:50 +02:00
Jonas Holzman
b427253a4d Obj-C Refactor: General Code Style cleanups
As part of a more general Objective-C GHOST refactor and in an effort to
modernize the macOS backend for further works, this commit cleans up the
codestyle of Objective-C files. Based off the Blender C/C++ style guide,
in addition to some Objective-C specific style changes.

Changes:
- `const` correctness, use nullptr, initializer list for simple struct
- Reduced variable scope for simple functions, removed unused variables
- Use braces for conditional statements, no else after return
- Annotate inheritted function of GHOST Cocoa classes with override and
  use `= default` to define trivial constructors
- Use #import instead of #include for Objective-C headers
    This is only for correctness. As the Objective-C #import directive
    is really just an #include with an implicit #pragma once.
- Use proper C-style comments instead of #pragma mark
    #pragma mark is an XCode feature to mark code chapters, to follow
    the Blender codestyle, and make the Objective-C code more editor
    agnostic, these were replaced with multi-line C-style comments.

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126770
2024-09-19 11:37:52 +02:00
Jesse Yurkovich
6385296e56 Fix #127651: Properly load generated UDIM image tiles in Cycles
Since their introduction, generated UDIM images/tiles would not be
loaded in Cycles. In relative recent history 72ab6faf5d added the
ability to track which tiles were still marked as being "generated" and
unsaved. However, that check was never implemented into the Cycles code.

With this PR, these two additional scenarios should now work:
- Properly load pixels if all tiles are generated
- Properly load pixels if a UDIM image has been loaded from a file and
  new generated tiles have been added but not saved yet etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/127673
2024-09-19 00:40:30 +02:00
Alaska
27680118db Fix #127464: Disable HIPRT point clouds to fix performance regression
Temporarily disable point cloud rendering in HIPRT to fix a performance
regression triggered by increased register preasure until
a better solution can be developed.

Pull Request: https://projects.blender.org/blender/blender/pulls/127738
2024-09-17 17:59:18 +02:00
Nikita Sirgienko
d300098ee5 Fix #125093: Cycles: oneAPI: transparent shadows opaque when bounces>=1024
Pull Request: https://projects.blender.org/blender/blender/pulls/127404
2024-09-16 16:37:55 +02:00
Campbell Barton
9b39b4c91c Cleanup: use const pointers/references 2024-09-15 23:14:09 +10:00
Campbell Barton
c6afb0e270 Core: remove sdlew/WITH_SDL_DYNLOAD & disable SDL by default
Disable dynamic SDL loading as well as disable SDL for release builds.

This was only used for audio output which can already use OpenAL
if there are back-ends not natively supported by Blender.

- Remove extern/sdlew/
- Remove the WITH_SDL_DYNLOAD build option.
- Remove `bpy.app.sdl.available`.

Ref !127554
2024-09-13 22:44:35 +10:00
Campbell Barton
bd606a3516 Cleanup: use switch statement mouse button checks
Warns if events button types are omitted.
Also use a define for GHOST_kButtonNum.
2024-09-13 12:32:56 +10:00