Commit Graph

215 Commits

Author SHA1 Message Date
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
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
Alaska
9e267bbd57 Cycles: Use denoising device info to pick automatic denoiser
Ever since the introduction of GPU OIDN denoising on CPU devices,
using the path_tracing_device info to pick the automatic denoiser has
typically led to incorrect results.

This commit fixes this issue by using the denoising device info to pick
the denoiser.

Pull Request: https://projects.blender.org/blender/blender/pulls/123593
2024-06-24 11:28:02 +02:00
Alaska
47158e1606 Fix #123528: Cycles viewport denoiser not using GPU for CPU render
Cycles automatic denoiser picker assumed that OIDN could not be
run on the GPU while the CPU was the render device. So if the user was
using their CPU for rendering, the automatic denoiser picker would
"fallback" to a different denoiser (OptiX or CPU OIDN). This was true
in Blender 4.1, but changed in 4.2. The UI assumed that OIDN could run
on the GPU if there was a compatible OIDN GPU device.

This lead to a issue on systems using the CPU for rendering
while having a NVIDIA GPU installed in the system. The
UI suggested that OIDN would be used, and would switch between
CPU and GPU depending on user preferences. But the automatic
denoiser picker in Cycle's backend said OIDN could not run on
the GPU in this situation and would always "fallback" to the
OptiX denoiser running on the NVIDIA GPU.
This created a mismatch between the UI and what Cycles was
acutally doing. This issue did not effect other GPU vendors because
their "fallback" was the OIDN denoiser.

This commit fixes this issue by aligning the Cycles automatic
denoiser picker in the backend with the UI. Using OIDN if a GPU
is supported, falling back to OptiX if it's not supported,
falling back to OIDN CPU if OptiX isn't supported,
then falling back to no denoiser if that's not supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/123530
2024-06-21 14:06:50 +02:00
Brecht Van Lommel
3a7a9c60df Cleanup: Compiler warning building without OIDN 2024-06-12 18:29:49 +02:00
Sergey Sharybin
b803d7fabb Fix: Command line Cycles render crash on multi-CUDA device
Since #118841 there are more cases where Cycles would check for the
graphics interop support. This could lead to a crash when graphics
interop functions are called without having active graphics context.

This change makes it so there is no graphics interop calls when doing
headless render. In order to achieve this the device creation is now
aware of the headless mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/122844
2024-06-07 17:53:44 +02:00
Nikita Sirgienko
1790314f89 Cycles: Fix multiple "Loading denoising kernels" messages
Pull Request: https://projects.blender.org/blender/blender/pulls/122880
2024-06-07 16:05:48 +02:00
Sergey Sharybin
7886ce7bd4 Fix: Cycles crash when using multiple devices
Additional requirement is to have OpenImageDenoiser, and the devices
should not support OIDN denoiser.

Reproduced here in the studio with a system on Linux with either double
Quadro GP100 cards, and Limnux with Quadro 6000 + Quadro 6000 ADA.

The reason for the crash is that the find_best_device() might return
nullptr, and it was never checked.

Pull Request: https://projects.blender.org/blender/blender/pulls/122823
2024-06-06 12:31:31 +02:00
Campbell Barton
7f7648c6ed Cleanup: spelling in code comments & minor edits
- Use uppercase NOTE: tags.
- Correct bNote -> bNode.
- Use colon after parameters.
- Use doxy-style doc-strings.
2024-06-06 09:55:13 +10:00
Lukas Stockner
a4d933e93e Cycles: Clamp sample number during viewport navigation to max samples
Previously, Cycles would render up to 4SPP during viewport navigation when
using reduced resolution, even when the overall number of samples was set
lower.

This causes problems with the blue-noise pattern, so ensure that the
number of samples is always clamped to the configured maximum.
2024-06-05 23:17:09 +02:00
Lukas Stockner
27ec99c568 Cycles: Fix building without OpenImageDenoise 2024-06-05 20:24:51 +02:00
Michael Jones
5be30b7d2b Cycles: "Struct-of-array-of-packed-structs" for parts of the integrator state
On a M3 MacBook Pro, this change increases the benchmark score by 8% (with classroom seeing a path-tracing speedup of 15%).

The integrator state is currently store using struct-of-arrays, with one array per field. Such fine grained separation can result in poor GPU cache utilisation in cases where multiple fields of the same parent struct are accessed together. This PR changes the layout of the `ray`, `isect`, `subsurface`, and `shadow_ray` structs so that the data is interleaved (per parent struct) instead of separate. To try and keep this change localised, I encapsulated the layout change by extending the integrator state access macros, however maybe we want to do this more explicitly? (e.g. by updating every bit of code that accesses these parts of the state). Feedback welcome.

Pull Request: https://projects.blender.org/blender/blender/pulls/122015
2024-06-04 14:53:30 +02:00
Sergey Sharybin
6e0a49265a Fix #122622: Cycles GPU performance regression in certain scenes
This is an oversight of #122543, for which benchmarking was done in
the headless mode.

The solution is to tweak policy a little bit, and keep refresh intervals
low for the first 10 seconds of render, after which increase updates to
every 15 seconds. Doing so allows:

- Have quick cancel of complex files when the error is noticed during
  the first few samples.
- Have more predictable cancel time after long render.
- Mitigate the performance regression.

This does not fully solve the regression, but it makes it much more
manageable. There are some compromises to be done from the performance
for the UI renders. The interactivity is also not as fantastic, but it
could be solved later by introducing some "Instant Cancel" operations
which would be able to also stop render in the middle of a sample.

Performance measured with the Spring file (path tracing time in seconds):

    Samples:                  300    1024    2048
    Base (prior to #122543):  29.1   85.4    174.1
    This patch:               37.0   95.7    180.2

This is measured on M2 Ultra GPU render.

The penalty is close to a constant time (the time within which a more
interactive cancel is possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/122658
2024-06-04 14:45:46 +02:00
Lukas Stockner
0566bf11b3 Cycles: Add debugging option to load custom OIDN weights
Pull Request: https://projects.blender.org/blender/blender/pulls/122591
2024-06-04 01:22:44 +02:00
Nikita Sirgienko
4651f8a08f Fix: Respect Blender Cycles setting for GPU denoising
Previously, GPU denoisers were ignoring settings about render
configuration and were using any available GPU. With these changes,
GPU denoisers will use the device selected in Blender Cycles
settings.
This allows any GPU denoiser to be used with CPU rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/118841
2024-06-03 22:41:25 +02:00
Nikita Sirgienko
e0ecf443d4 Cycles: Fix compile error in 1465076a0a47 2024-06-03 11:33:28 +02:00
Nikita Sirgienko
6d87a5d9ed Cleanup: Cycles: Fix type in the OpenImageDenoise name.
There are no functional changes expected.
2024-06-03 11:11:20 +02:00
Nikita Sirgienko
1465076a0a Refactor: Cycles: Unify error reporting code from denoiser's classes
There are no functional changes expected.
2024-06-03 11:11:19 +02:00
Nikita Sirgienko
cb8d2bf4ad Fix: Cycles: Add missing queue init in run_film_convert_kernels 2024-06-03 11:11:19 +02:00
Sergey Sharybin
5f11ae70ea Fix: Cycles is not responsive to cancel render in complex scenes
In some of the complex scenes it could a very long time for Cycles
to respond to cancel request. This is because Cycles only cancels
render at a consistent state of render buffer: when all scheduled
samples are rendered.

This was caused by the render scheduler over-scheduling the number
of samples in an attempt to improve occupancy of the GPU.

This fix makes it so the scheduler only compensates for the low
occupancy if rendering can happen within a desired update time.

There is no visible difference in the benchmark scenes with this
change.

Pull Request: https://projects.blender.org/blender/blender/pulls/122543
2024-05-31 15:54:14 +02:00
Michael Jones
e82d69daa1 Cycles: Disambiguate shadow integrator state buffer names
This patch adds a "shadow" prefix & array index suffixes to the shadow integrator state buffer names. This eliminates confusion when looking at GPU traces etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/121745
2024-05-15 23:19:24 +02:00
Attila Áfra
26c93c8359 Cycles: Enable OIDN 2.3 lazy device module loading
This enables the new lazy module loading behavior introduced in OIDN 2.3,
without breaking compatibility with older versions of OIDN (using separate
code paths).

Also, the detection of OIDN support for devices is now much cleaner, and
devices do not need to be matched by PCI address or device name anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/121362
2024-05-07 14:07:39 +02:00
Attila Áfra
2a0a6f18cc Cycles: Add OpenImageDenoise quality option
This adds a new "Quality" option for OIDN to switch between the existing
"High" and "Balanced" modes and the new "Fast" mode introduced in OIDN 2.3.

Pull Request: https://projects.blender.org/blender/blender/pulls/121374
2024-05-06 18:56:16 +02:00
Weizhen Huang
2e1380fa0c Cleanup: use available function to compute render buffer pointer
use available `film_pass_pixel_render_buffer()` to access the pointer
to the render buffer.
For shadow state, a similar function `film_pass_pixel_render_buffer_shadow()`
is created, because `shadow_path` instead of `path` is needed.
2024-04-17 18:49:00 +02:00
Campbell Barton
7e9f7320e4 Cleanup: spelling in comments & comment blocks 2024-04-04 11:26:28 +11:00
Brecht Van Lommel
9d0f49c843 Merge branch 'blender-v4.1-release' 2024-03-11 13:11:36 +01:00
Brecht Van Lommel
f7a071bd60 Fix: Build failing when WITH_OPENIMAGEDENOISE is OFF 2024-03-11 12:59:46 +01:00
Alaska
989e9ef890 Fix: Assert in Cycles multi-device OIDN check
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119267
2024-03-11 12:54:45 +01:00
Hans Goudey
2d3d8c80c3 Cleanup: Make format 2024-03-08 18:29:11 -05:00
Brecht Van Lommel
2e8e2be0af Merge branch 'blender-v4.1-release' 2024-03-08 22:55:42 +01:00
Brecht Van Lommel
9bebd39197 Cycles: Default to OIDN for NVIDIA in the viewport
For consistency across GPU devices, and between viewport and final
render.

Pull Request: https://projects.blender.org/blender/blender/pulls/119213
2024-03-08 22:52:36 +01:00
Brecht Van Lommel
f278e4138c Fix #118016: OpenImageDenoise not using GPU for CPU + GPU render
Thanks to Alaska for pointing out the cause of the problem.
2024-03-08 22:52:35 +01:00
Sergey Sharybin
032a24d8ac Fix Cycles compilation error with OIDN < 2.2
The enumerator values for various GPU compute platforms were
added starting with OIDN 2.0, with the Metal GPU type added
in OIDN 2.2.

This is an alternative fix to ebb781675dd, which does not lead to
unhandled cases in switch statement, and follows the configuration
of OIDN and not Cycles (as OIDN might report devices which are
disabled in local Cycles build).

Pull Request: https://projects.blender.org/blender/blender/pulls/119155
2024-03-07 11:13:41 +01:00
Sebastian Parborg
ebb781675d Fix: Add missing ifdef guards for OIDN GPU devices
It is not guaranteed that the GPU variables will be available depending
on the current OIDN configuration
2024-03-06 19:19:23 +01:00
Sergey Sharybin
d88686fb2b Cycles: Add debug logging to the OIDN GPU checks
No functional changes, just something that could help troubleshooting
cases when option to use GPU for denoising is grayed out.

Pull Request: https://projects.blender.org/blender/blender/pulls/119123
2024-03-06 14:54:19 +01:00
bartus
5d06b7b906 Cycles: Add support for OpenPGL 0.6.0
Replace PGLFieldArguments with FieldConfig class for this version.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/118328
2024-02-19 12:36:04 +01:00
Attila Afra
7b8c438715 Fix: Set OIDN GPU memory limit for all filters 2024-02-12 18:13:23 +01:00
Brecht Van Lommel
1e1a8d5c8f Fix: Cycles denoise fails with multi tile render and Use GPU off 2024-02-09 15:11:21 +01:00
Brecht Van Lommel
f98468c988 Fix: Cycles uses GPU device for denoise even if disabled for scene 2024-02-09 15:02:46 +01:00
Nikita Sirgienko
9d0b811da6 Fix #117931: Swap oidn device when changing "Use GPU" during viewport render 2024-02-08 14:53:12 +01:00
Attila Afra
e7dcad8599 Fix: Release all OIDN GPU resources when recreating denoiser 2024-02-07 19:44:40 +01:00
Attila Afra
8e80b44796 Cycles: Fix initial OIDN GPU denoiser quality 2024-02-07 17:54:50 +01:00
Attila Áfra
c1f55288e9 Fix: Cycles OIDN GPU denoiser bugs
- Incorrect accurate prefiltering of albedo and normal (lower than expected quality)
- Changing the prefiltering mode has no immediate effect
- Default memory limit is too high (more than OIDN default)
- Memory limit is applied only to the main filter
- Quality setting applied only to the main filter

Pull Request: https://projects.blender.org/blender/blender/pulls/117930
2024-02-07 13:34:35 +01:00
Stefan Werner
31d55e87f9 Cycles: Metal support for OpenImageDenoise
This is supported on Apple Silicon GPUs and macOS 13.0+.

Co-authored-by: Stefan Werner <stefan.werner@intel.com>
Co-authored-by: Attila Afra <attila.t.afra@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/116124
2024-02-06 21:13:23 +01:00
Nikita Sirgienko
280b5c89ae Cycles: Set quality parameter for OIDN
OpenImageDenoise API exposes two modes, high quality and balanced.
This currently only has effect on Nvidia devices, on which it
provides a noticeable performance improvement without visible
difference in quality. This change sets quality to balanced for
the viewport, and high quality for final frame rendering, as
it's what makes the most sense.

Ref #115045

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: #115265
2024-02-06 20:58:17 +01:00
Nikita Sirgienko
bc886857f3 Cycles: Option to disable OpenImageDenoise GPU per scene
To reduce memory usage if needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/117874
2024-02-06 17:46:21 +01:00
Stefan Werner
d16d2bbd3a Cycles: Adding OIDN support for CUDA and OptiX devices
Small changes to turn on support and to build OIDN with the CUDA backend.

Co-authored-by: Werner, Stefan <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115828
2024-01-24 08:19:39 +01:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Nikita Sirgienko
3cadec1892 Cycles: Log number of scheduled tiles
Pull Request: https://projects.blender.org/blender/blender/pulls/116379
2023-12-21 09:39:16 +01:00
Brecht Van Lommel
ac753fe9ae Fix: Cycles assert with CPU denoiser 2023-12-13 22:27:46 +01:00