Commit Graph

22 Commits

Author SHA1 Message Date
Brecht Van Lommel
d0c2e68e5f Refactor: Cycles: Automated clang-tidy fixups in Cycles
* Use .empty() and .data()
* Use nullptr instead of 0
* No else after return
* Simple class member initialization
* Add override for virtual methods
* Include C++ instead of C headers
* Remove some unused includes
* Use default constructors
* Always use braces
* Consistent names in definition and declaration
* Change typedef to using

Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:22:55 +01:00
Brecht Van Lommel
3c2a6fbb9c Refactor: Cycles: Use nullptr instead of NULL
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
2025-01-03 10:22:43 +01:00
Weizhen Huang
34b95fe3f6 Cleanup: Cycles: use existing utility functions for geometry types
Pull Request: https://projects.blender.org/blender/blender/pulls/129552
2024-10-30 16:45:56 +01: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
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
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
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
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
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
Alaska
50ba7a3033 Fix build failure after recent HIP-RT change
Fixes build failure after 6b848a9993

Pull Request: https://projects.blender.org/blender/blender/pulls/125936
2024-08-06 02:41:11 +02:00
Alaska
6b848a9993 Fix: Crash with deforming motion blurred meshes in HIPRT
Fixes a crash that can occur if motion blur was on, there is a
deforming mesh in the scene with deformable motion blur turned on,
with BVH time steps set >0.

Render results in my test scene appear to match CPU Embree.

Pull Request: https://projects.blender.org/blender/blender/pulls/125854
2024-08-05 18:38:28 +02:00
Lukas Stockner
4bde68cdd6 Cycles: Compress GPU kernels to reduce file size
Precompiled Cycles kernels make up a considerable fraction of the total size of
Blender builds nowadays. As we add more features and support for more
architectures, this will only continue to increase.

However, since these kernels tend to be quite compressible, we can save a lot
of storage by storing them in compressed form and decompressing the required
kernel(s) during loading.

By using Zstandard compression with a high level, we can get decent compression
ratios (~5x for the current kernels) while keeping decompression time low
(about 30ms in the worse case in my tests). And since we already require zstd
for Blender, this doesn't introduce a new dependency.

While the main improvement is to the size of the extracted Blender installation
(which is reduced by ~400-500MB currently), this also shrinks the download on
Windows, since .zip's deflate compression is less effective. It doesn't help on
Linux since we're already using .tar.xz there, but the smaller installed size
is still a good thing.

See #123522 for initial discussion.

Pull Request: https://projects.blender.org/blender/blender/pulls/123557
2024-06-23 00:52:30 +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
Brecht Van Lommel
c388ed1e53 Fix #118709: Crash in OIDN GPU detection for unsupported HIP device
Pull Request: https://projects.blender.org/blender/blender/pulls/119315
2024-03-11 15:09:24 +01:00
Sahar A. Kashi
3e09fbf062 Fix #112983: Cycles HIP-RT crash on deleting all objects
Pull Request: https://projects.blender.org/blender/blender/pulls/118944
2024-03-05 19:52:58 +01:00
salipourto
13171183fa Fix Cycles HIP RT issues with deformation motion blur
The first problem was triangles with motion blur were all grouped into
one category without separating the ones with and without triangle
motion steps.

The second problem was HIP RT uses the generic motion triangle
intersection function and this function checks prim_visibility buffer.
HIP RT doesn't provide the buffer per primitive but passes it to HIP RT
core per instance.

The buffer name was changed to prim_visibility from visibility to be
the same as what Cycles uses but when the motion triangle intersection
function is called from HIP RT kernels, the instance id is passed to
the function instead of primitive id.

Pull Request: https://projects.blender.org/blender/blender/pulls/114555
2023-11-09 18:22:59 +01:00
Brecht Van Lommel
7e55dfcf27 Fix #103918: Cycles point cloud motion blur artifacts on the GPU
Change storage to consistently put xyz + radius in the motion blur attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/109830
2023-07-07 20:15:36 +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
Campbell Barton
6859bb6e67 Cleanup: format (with BraceWrapping::AfterControlStatement "MultiLine") 2023-05-02 09:37:49 +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