Commit Graph

14252 Commits

Author SHA1 Message Date
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
salipourto
17ddca5017 Fix #127240: Deforming motion blurred point clouds do not render under certain conditions
Deforming motion blurred point clouds do not render in Cycles
HIP-RT when BVH timesteps != 0 if Blender is launched with
debug memory.

The root cause is that the size of allocated memory for the
bounding boxes is reported to HIP-RT not the number of valid
bounding boxes.

Pull Request: https://projects.blender.org/blender/blender/pulls/127432
2024-09-12 16:47:13 +02:00
Alaska
0e36107433 Fix: Cycles: Rendering of VDB files with HIP-RT
VDB files would fail to render in HIP-RT because NanoVDB wasn't
enabled when compiling HIP-RT kernels, resulting in NanoVDB textures
not being sampled and a blank result being returned instead.

The fix is to enable NanoVDB when compiling HIP-RT kernels.

Ref: #125086

Pull Request: https://projects.blender.org/blender/blender/pulls/127384
2024-09-12 16:26:41 +02:00
Alaska
2d611f7b45 Fix #125392: Cycles: Unnecessary recreation of denoiser
Fix the unnecessary recreation of the denoiser that occurs if
Cycles had fallen back to an alternative denoiser in a previous
interation. (E.g. Fallback from OptiX to OIDN)

This issue occured because Cycles didn't understand that when it
previously setup the denoising device, that it had fallen back to
something else. So it thinks the denoising settings have been changes
and tries to recreate the denoiser.

The solution is to first compute the settings change due to
the fallback, then check to see if it's different from the current
denoiser, then recreate the denoiser device if neccesary.

Pull Request: https://projects.blender.org/blender/blender/pulls/125453
2024-09-12 16:23:59 +02:00
salipourto
4bfee1936c Fix #126749: HIP-RT Memory leak in Cycles viewport
hiprtScene object wasn't being freed between frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/127473
2024-09-12 15:05:08 +02:00
Weizhen Huang
ee2fe7fa6c Fix: Cycles: reuse random number for sampling color channel in volume
The same random number was used for sampling color channel at each step,
which leads to bias. Fixed by rescaling the random number.

Another possibility would be to scramble `rng_offset` and use a new
random number each time, similar as in subsurface scattering, but
rescaling random number should be faster than computing a new one, and
is favorable here since the precision here is not very important

Pull Request: https://projects.blender.org/blender/blender/pulls/127454
2024-09-12 14:27:56 +02:00
Xavier Hallade
33dd8dbdac Cycles: simplify fmodf(c, 1.0f) to fractf(c) in hsv node
Pull Request: https://projects.blender.org/blender/blender/pulls/127461
2024-09-12 11:53:07 +02:00
Xavier Hallade
a1182e07b1 Build: upgrade Intel Graphics Compiler and ocloc on Linux
IGC 1.0.17384, ocloc 24.31.30508, which:
- add support for Battlemage and Lunar Lake GPUs
- recover from recent performance regression on Linux
- allow to drop older work-around
  (9d5164d472) and need for a patched
  version on Windows
- ocloc now needs "dg2,mtl" naming for fat binaries.

opencl-clang patches don't get applied anymore by igc build scripts
when llvm is not a git repository, hence I could also drop we can drop
current patch disabling patching.

I've only slightly pushed min-driver-version updates after carefull
testing, instead of jumping to the same version as ocloc as we use to.

Pull Request: https://projects.blender.org/blender/blender/pulls/127251
2024-09-12 09:11:56 +02:00
Xavier Hallade
56db2d393d Cycles: oneAPI: use ocloc 101.5972 on Windows
This new version of the graphics compiler solves a performance
regression on Arc, adds support for Battlemage and Lunar Lake GPUs, and
allows to drop older patch to build fat binaries with broad
compatibility.
This latter change requires using -device dg2,mtl naming instead of
passing architecture ids.

Pull Request: https://projects.blender.org/blender/blender/pulls/127371
2024-09-11 17:34:13 +02:00
Xavier Hallade
473711b579 Build: avoid compiling Intel GPU binaries if no devices are set
Compilation command was malformed in this case.
2024-09-11 17:34:10 +02:00
Weizhen Huang
76700680d0 Cleanup: Cycles: rename variable for clarity
rename `rphase` to `rchannel` as this variable is only used for sampling
a color channel
2024-09-11 14:31:48 +02:00
Jonas Holzman
3130f97e85 Obj-C Refactor: Use idiomatic Obj-C objects for Window/App delegates
Changes:
- Renamed `CocoaWindowDelegate` to `BlenderWindowDelegate` and
  `CocoaWindow` to `BlenderWindow` for clarity, and remove the confusion
  between `CocoaWindow` and `WindowCocoa`
- Use idiomatic Objective-C properties instead of raw instance
  variables, synthesized with the `m_` prefix instead of the default
  Objective-C `_` to be closer to the current GHOST style.
- Use idiomatic Objective-C initWith constructors instead of setter
  functions
- Function and initializer call and name adjustments

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126767
2024-09-11 11:53:59 +02:00
Aras Pranckevicius
d0ea251c33 Color management: optimize OCIO predivide processing
cpuProcessorApply_predivide was doing, for each pixel:
- Un-premultiply pixel to straight alpha
- Call OCIO processor on that one pixel
- Premultiply pixel back

This is not great due to just function call overhead, and probably
prevents whatever "batch processing SIMD optimizations" that OCIO
migth have.

Instead, do this:
- Un-premultiply whole input image,
- Call OCIO on the whole image to do whatever it does,
- Premultiply whole image back.

Doing cpuProcessorApply_predivide on a 4K resolution, float4 image
on Ryzen 5950X (Win10/VS2022) on one thread: 128ms -> 69ms

Pull Request: https://projects.blender.org/blender/blender/pulls/127307
2024-09-09 13:14:55 +02:00
Harley Acheson
458c60269b UI: Hand Cursors
Add multiple "hand" mouse cursors. These are mostly needed for Mac,
which needs open, close, and pointing hand cursors. This also adds
similar for Windows, but just for completeness and testing.

Pull Request: https://projects.blender.org/blender/blender/pulls/127164
2024-09-06 19:05:59 +02:00
Campbell Barton
11187aa9dc CMake: don't link sdlew when WITH_SDL=OFF
This caused a build error building Blender as a Python module
with !125556 applied.
2024-09-06 21:01:36 +10:00
salipourto
d4597e20b6 Fix #127131: Deforming motion blurred point clouds do not render in Cycles HIP-RT when BVH timesteps != 0
The device code was disabled for primitives with deformation blur
and the intersection function always returned false, hence no
rendered primitive.

Other than that, there were a few bugs on both device and host codes
(e.g., the order of current and previous times and the primitive name.)

Pull Request: https://projects.blender.org/blender/blender/pulls/127163
2024-09-06 12:27:17 +02:00
Jonas Holzman
73f2bdd1ed Obj-C Refactor: WindowViewCocoa refactor
Changes:
- Use macros to reduce Cocoa event forwarding boilerplate
- Use @autoreleasepool where necessary
- Use idiomatic Objective-C properties for `COCOA_VIEW_CLASS`

Style Changes:
- Use C-Style Comments
- Use braces for conditional statements
- Use Objective-C dot-notation

Ref #126772

Pull Request: https://projects.blender.org/blender/blender/pulls/126769
2024-09-06 11:15:57 +02:00
Campbell Barton
71000ebe91 Correct error in event number define 2024-09-05 11:31:47 +10:00
Campbell Barton
0f20c6ed7e Refactor: improve GHOST/Wayland pointer handling
Generate all pointer (mouse) events from the "frame" callback as this
is the intended behavior according to the wl_pointer_listener docs.

In practice it's unlikely users would notice any difference however
there are potentially subtle differences because events were previously
created before all the pointer data had been collected.

This also has some minor advantages as each frame event no longer
needs to detect if scrolling is needed and in the case of motion events:
calculate the time-stamp twice.
2024-09-05 10:45:46 +10:00
Campbell Barton
5b48e61230 Refactor: minor changes to GHOST's tablet events
- Remove "Unset" element in the enum as it's not so useful.
- Handle buttons last (in a "default" case for release builds).
2024-09-05 09:29:09 +10:00
Jacques Lucke
89ae1ba38a Attributes: remove AttributeIDRef in favor of just using strings
Previously, the `AttributeIDRef` wrapper was needed because it also had to
contain a pointer to an `AnonymousAttributeID`. However, since
b279a6d703 this is not necessary anymore.
Therefore we can use "raw" `StringRef` now which reduces the mental overhead
when working with attributes and also simplifies code.

Pull Request: https://projects.blender.org/blender/blender/pulls/127140
2024-09-04 16:13:03 +02:00
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