Commit Graph

213 Commits

Author SHA1 Message Date
Xavier Hallade
d26a2b09bc Cycles: oneAPI: use hardware cos
Speckles and missing lights were experienced in scenes with Nishita Sky
Texture and a Sun Size smaller than 1.5°, such as in Lone Monk and Attic
scenes.
We previously worked around these by using a more precise
software implementation of cosine.
After recent changes in Cycles, it turns out this workaround isn't
currently needed.
2023-10-06 13:10:27 +02:00
Michael Jones
1c1c6ac457 Cycles: Fix last failing unit test (T39823) on MetalRT
This PR fixes T39823, the sole failing unit test when running with MetalRT.  It does so by implementing and binding a missing intersection handler (`__anyhit__cycles_metalrt_volume_test_tri`) which is required for `scene_intersect_volume` (as used by `integrator_volume_stack_update_for_subsurface`) to work as intended. This scene exposed the error as it uses subsurface scattering on a sphere which is intersected by volume.

Pull Request: https://projects.blender.org/blender/blender/pulls/112876
2023-09-25 22:41:27 +02:00
Campbell Barton
2721b937fb Cleanup: use braces in headers 2023-09-24 14:52:38 +10:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Harley Acheson
092b568a90 Cleanup: Make format
Formatting changes resulting from Make Format
2023-09-13 11:03:43 -07:00
Michael Jones
6c98cb73ac Cycles: Use new MetalRT curve primitives for 3D curves and ribbons
This patch updates the experimental MetalRT code path to use new [curve primitives](https://developer.apple.com/videos/play/wwdc2023/10128/) which were recently added in macOS 14. This replaces the previous custom box intersection implementation, allowing the driver to better optimise curve acceleration structures for the GPU. On existing hardware, this can speed up MetalRT renders by up to 40% for scenes that use hair / curve primitives extensively.

The MetalRT option will only be available on macOS >= 14, and requires Xcode >= 15 to build (otherwise the option will be compiled out).

Authored by Marco Giordano, Michael Jones, and Jason Fielder

---
Before / after render times (M1 Max MacBook Pro, macOS 14 beta, MetalRT enabled):
```
                  Custom box intersection      MetalRT curve primitives       Speedup
fishy_cat           111.5                         80.5                         1.39
koro                114.4                         86.7                         1.32
sinosauropteryx     291.8                        279.2                         1.05
spring              142.3                        142.2                         1.00
victor              442.7                        347.7                         1.27
```

---

Pull Request: https://projects.blender.org/blender/blender/pulls/111795
2023-09-13 16:02:49 +02:00
Xavier Hallade
01931e213f Cycles: oneAPI: only export necessary symbols
The API for the kernels library is defined, there is no need to
export more than that. This change only affects linux since hidden
visiblity is the default on Windows.
2023-09-08 15:44:39 +02:00
Campbell Barton
9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Sergey Sharybin
7e4a51329b Fix shadow linking for Cycles Metal RT
The shadow intersection kernels needs to perform extra checks
to see whether object is really considered a blocker.

Pull Request: https://projects.blender.org/blender/blender/pulls/112012
2023-09-06 15:25:30 +02:00
Sergey Sharybin
8e49bc4a05 Refactor: Make Cycles shadow linking primitives receive ray self primitives
No functional changes.

Makes it closer to other self-intersection checks, making it easier to
re-use functions from the HW RT kernels.

Pull Request: https://projects.blender.org/blender/blender/pulls/111971
2023-09-06 09:53:29 +02:00
Campbell Barton
1f01a64403 Cleanup: spelling in comments 2023-09-06 14:23:01 +10:00
Sergey Sharybin
71b4a97cbc Refactor: De-duplicate Metal RT self intersection checks
Use the common BVH utilities header for this.

Added a special type qualifier ccl_ray_data which is defined to ccl_private
for all platforms but Metal. On Metal it is defined to ray_data.

The tricky part is that the BVH utilities are wrapped into the Metal context
class. In some of the BVH functions the context has been already constructed,
but it wasn't done in all the callbacks.

From a quick render tests of the Junkshop benchmark scene there is no render
time difference,

No functional changes are expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/111967
2023-09-05 17:21:49 +02:00
Sergey Sharybin
7365f0b094 Cleanup: Cover .metal files with make format
Pull Request: https://projects.blender.org/blender/blender/pulls/111930
2023-09-05 09:59:47 +02:00
Sergey Sharybin
c59c97c947 Cleanup: Ensure correct order of headers in Metal kernel
Explicitly splint into groups of headers, so that clang-format
does not ruin the required order of headers.
2023-09-05 09:59:41 +02:00
salipourto
359bbf6af2 Fix Cycles HIP RT issues with curves and transparent shadows
Ref #104110

Pull Request: https://projects.blender.org/blender/blender/pulls/111414
2023-09-04 17:55:21 +02:00
Xavier Hallade
40a39c2976 Cycles: oneAPI: cleanup: drop __spirv_ocl_cos workaround
As __FAST_MATH__ isn't defined anymore since
09df1f4caf, sycl::cos uses the precise
implementation, no need to call __spirv_ocl_cos anymore.
2023-08-31 13:10:29 +02:00
Nikita Sirgienko
abab47a805 Cycles: oneAPI: Refactoring of local size choice logic 2023-08-22 19:04:16 +02:00
Campbell Barton
7f34ad736a Cleanup: spelling in comments 2023-08-05 13:54:25 +10:00
Campbell Barton
0caf227530 License headers: use SPDX-FileCopyrightText for *.inl and *.osl files 2023-08-04 13:24:17 +10:00
Xavier Hallade
aefc9835f8 Cycles: oneAPI: fix kernel host-side compilation with MSVC 17.7
<algorithm> header include is missing from some sycl headers, this will
be fixed upstream with https://github.com/intel/llvm/pull/10424,
meanwhile, we work around it by including it directly.
2023-07-25 12:01:09 +02:00
Ray Molenkamp
235c564aa0 Cycles: re-Fixed oneAPI build on Windows
fixes one uint missed in a0846a60c9
2023-07-06 14:47:35 -06:00
Stefan Werner
a0846a60c9 Cycles: Fixed oneAPI build on Windows
Turns out uint wasn't defined this early in our kernels on Windows.
Using unsigned int instead should fix this.
2023-07-06 21:50:03 +02:00
Werner, Stefan
7befc40386 Cycles: Use sycl::bitcast in oneAPI backend
Using sycl::bitcast instead of union hack
2023-07-06 15:06:33 +02:00
Nikita Sirgienko
d801ffddff Cycles: oneAPI: Fix execution error with cryptomatte kernel 2023-06-29 14:51:49 +02:00
Jeroen Bakker
60a3dbaba9 Cleanup make format 2023-06-26 14:20:31 +02:00
Stephen Luce
659c7f6050 Cycles: remove redundant bounds checks in CPU image sampling
For repeat / extend / mirror mode, both wrap and read_clip functions did
the bounds check. Removing it improves performance between 0.5% and 1.5%
in the classroom scene in one test. Clip mode is unchanged.

Pull Request: https://projects.blender.org/blender/blender/pulls/109304
2023-06-26 14:13:02 +02:00
Brecht Van Lommel
c7319e6c79 Merge branch 'blender-v3.6-release' into main 2023-06-20 20:49:44 +02:00
salipourto
b84d4dd16d Fix various HIP RT issues
* Motion blur issues due to missing ray time
* Wrong bitcode path for runtime compilation
* Quiet logging

Pull Request: https://projects.blender.org/blender/blender/pulls/109170
2023-06-20 20:47:10 +02:00
Campbell Barton
c12994612b License headers: use SPDX-FileCopyrightText in intern/cycles 2023-06-14 16:53:23 +10:00
Xavier Hallade
398b8428dd Merge branch 'blender-v3.6-release' 2023-06-08 09:22:18 +02:00
Nikita Sirgienko
bc5275e204 Fix #107414: Cycles: [3/3] Don't rely on tfar in callbacks with embree
In Embree, tfar modification is taken into account by rtcIntersect1
only when hits are accepted. In order to overcome this, we now check
manually for a max_t value in the filter function.

Pull Request: https://projects.blender.org/blender/blender/pulls/108706
2023-06-08 09:21:32 +02:00
Nikita Sirgienko
dd282bd853 Fix #107414: Cycles: [2/3] Fix closest hits recording in embree
Previously, all hits were processed yet ignored as soon as the
hits stack limit had been exceeded, which made miss closer hits.
2023-06-08 09:21:31 +02:00
Nikita Sirgienko
54dd4c0e79 Fix #107414: Cycles: [1/3] Ignore hits beyond the furthest one in embree
We should be recording only the N closest hits in case the number of
hits is exceeding the maximum allowed or the size of the hits stack.
Previously, some cases made it record hits beyond the furthest recorded
one due to lack of hit distance check.
2023-06-08 09:21:31 +02:00
Sergey Sharybin
ba3f26fac5 Cycles: light and shadow linking
With light linking, lights can be set to affect only specific objects in the
scene. Shadow linking additionally gives control over which objects acts a
shadow blockers for a light.

Usage:
https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Cycles

Implementation:
https://wiki.blender.org/wiki/Source/Render/Cycles/LightLinking

Ref #104972
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-05-24 14:11:47 +02:00
Campbell Barton
bf36a61e62 Cleanup: spelling in comments & some corrections 2023-05-20 21:17:09 +10:00
Nikita Sirgienko
bafd82c9c1 Cycles: oneAPI: use local memory for faster shader sorting
Co-authored-by: Stefan Werner <stefan.werner@intel.com>

Pull Request: https://projects.blender.org/blender/blender/pulls/107994
2023-05-17 11:07:57 +02:00
Nikita Sirgienko
b8173278b0 Cycles: oneAPI: set correct work group sizes for kernels that have a predefined one 2023-05-17 00:02:12 +02:00
Nikita Sirgienko
a17d07ee87 Cycles: oneAPI: Fix prevented execution with sycl runtime > 20230323
NanoVDB headers have unused code using "double" type, which is not supported on Arc GPUs.
Recent DPC++ changes enforced runtime verifications:
7663dc201d
which prevents execution when such type has been present even if unused.
This is a solution to avoid double to be compiled at all, similar as how it is done for Metal.
2023-05-17 00:00:52 +02:00
Xavier Hallade
5ec2495550 Cycles: oneAPI: enable Hardware Raytracing for Raytrace/MNEE kernels
We do so if Embree 4.1+ is present.
2023-05-12 14:17:50 +02:00
Campbell Barton
ba3d7499fa Cleanup: spelling, use term polygons in polygon callbacks 2023-05-05 09:46:28 +10:00
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +10:00
Campbell Barton
db1af0e325 Cleanup: spelling in comments 2023-04-26 16:14:07 +10:00
Sahar A. Kashi
557a245dd5 Cycles: add HIP RT device, for AMD hardware ray tracing on Windows
HIP RT enables AMD hardware ray tracing on RDNA2 and above, and falls back to a
to shader implementation for older graphics cards. It offers an average 25%
sample rendering rate improvement in Cycles benchmarks, on a W6800 card.

The ray tracing feature functions are accessed through HIP RT SDK, available on
GPUOpen. HIP RT traversal functionality is pre-compiled in bitcode format and
shipped with the SDK.

This is not yet enabled as there are issues to be resolved, but landing the
code now makes testing and further changes easier.

Known limitations:
* Not working yet with current public AMD drivers.
* Visual artifact in motion blur.
* One of the buffers allocated for traversal has a static size. Allocating it
  dynamically would reduce memory usage.
* This is for Windows only currently, no Linux support.

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

Ref #105538
2023-04-25 20:19:43 +02:00
Michael Jones
d0467a277a Cycles: MetalRT: Don't apply local object transform if it is baked
This patch fixes the failing shader/bevel unit test when MetalRT is enabled. The ray was being transformed into local object space even when the SD_OBJECT_TRANSFORM_APPLIED flag was set.

Pull Request: https://projects.blender.org/blender/blender/pulls/107292
2023-04-24 15:20:21 +02:00
Nikita Sirgienko
4babb7c02e Cycles: oneAPI: Fix volume intersection for Embree GPU execution 2023-04-20 21:20:33 +02:00
Nikita Sirgienko
7e92fb92ec Cycles: oneAPI: Fix kernels preloading in case of incompatible AoT binaries
When running oneAPI with AoT binaries, on hardware that's not compatible with
these, recompilation could have been missing from the kernels loading phase and
happen during execution instead.

These changes fixes it, any kernel compilation will now happen during the
kernels loading phase.
2023-04-20 21:20:33 +02:00
Campbell Barton
eb2867de90 Cleanup: spelling in comments 2023-04-19 08:02:41 +10:00
Xavier Hallade
70892e82ac Cycles: oneAPI: use specialization constant to compile with/without Embree on GPU 2023-04-18 22:09:42 +02:00
Nikita Sirgienko
3f8c995109 Cycles: add hardware raytracing support to oneAPI device
Updated Embree 4 library with GPU support is required for it to be
compiled - compatiblity with Embree 3 and Embree 4 without GPU support
is maintained.
Enabling hardware raytracing is an opt-in user setting for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/106266
2023-04-18 22:09:42 +02:00
Xavier Hallade
9e9baa9085 Cycles: Upgrade to new Embree 4 while staying compatible with Embree 3
For more information about Embree 3->4 API changes:
https://github.com/embree/embree/blob/master/doc/src/api.md#upgrading-from-embree-3-to-embree-4

This is not yet enabling HW RT on Arc GPUs using Embree, which is worked on in https://projects.blender.org/blender/blender/pulls/106266

Co-authored-by: Nikita Sirgienko <nikita.sirgienko@intel.com>
Co-authored-by: Stefan Werner <stefan.werner@intel.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/105974
2023-04-05 11:03:06 +02:00