Commit Graph

14763 Commits

Author SHA1 Message Date
Michael Jones
1a93dfe4fc Cycles: Apple Silicon tidy: Remove non-UMA codepaths
This PR removes a bunch of dead code following #123551 (removal of AMD and Intel GPU support). It is safe to assume that UMA will be available, so a lot of codepaths that dealt with copying between CPU and GPU are now just clutter.

Pull Request: https://projects.blender.org/blender/blender/pulls/136117
2025-03-18 19:09:25 +01:00
Philipp Oeser
d6da557358 Fix #135955: OSL Window texture coordinate wrong for panoramic cameras
There is code that properly handles panoramic cameras in
`camera_world_to_ndc`, the transform matrices (e.g.
`OSLRenderServices::get_inverse_matrix`) in the `transform("NDC", P)`
call dont do the "full work" here (maybe they should though?).

But we can get to `camera_world_to_ndc` by just getting the "NDC"
attribute, so use that for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/136097
2025-03-18 09:11:45 +01:00
Brecht Van Lommel
9984adc7de Merge branch 'blender-v4.4-release' 2025-03-17 16:19:46 +01:00
Brecht Van Lommel
f896f7ffc3 Fix #136047: Cycles OSL gettextureinfo crash with missing image
Missing null pointer check.

Pull Request: https://projects.blender.org/blender/blender/pulls/136075
2025-03-17 16:18:31 +01:00
Lukas Stockner
349306a3bd Cycles: Handle OSL parameter query from Python
Now that we're packaging the Python oslquery module, we can get rid of the C++-side code here and handle this purely in Python.

Pull Request: https://projects.blender.org/blender/blender/pulls/136032
2025-03-16 18:04:38 +01:00
Brecht Van Lommel
a687a02578 Cycles: Enable HIP RT by default
For 4.4 there was not enough time to fully test it and be confident it is
stable, but for 4.5 we enable it.

Ref #135760
2025-03-14 18:44:41 +01:00
Brecht Van Lommel
990f8df7cc Fix: Build error with OpenImageIO 2.x after OSL manager changes
Ref #135050
2025-03-14 18:44:27 +01:00
Sergey Sharybin
f243f13549 Merge branch 'blender-v4.4-release' 2025-03-14 18:36:53 +01:00
salipour
dd3640ef0f Cycles: Move HIP-RT out of experimental flag
The full regression suit passes, so there is no real background towards
considering it experimental.

It is still stays disabled by default for Blender 4.4.

Pull Request: https://projects.blender.org/blender/blender/pulls/135760
2025-03-14 18:35:42 +01:00
Bastien Montagne
dd98cede18 Merge branch 'blender-v4.4-release' 2025-03-14 18:20:26 +01:00
Sahar A. Kashi
9ad3b74867 Fix: SSS and Motion Blur or Curves not working on HIP-RT
This change fixes the remaining failing tests with SSS when using HIP-RT.
This includes crash when SSS is used on curves, and objects with motion
blur and SSS rendering black.

The root cause for both cases was the fact that traversal was always
assuming regular BVH (built for triangles), while curves and motion
triangles are using custom primitives, which requires specialized BVH
traversal.

This change includes:

- Early output from `scene_intersect_local()` for non-triangle and
  non-motion-triangle primitives. This fixes `sss_hair.blend` test,
  and also avoids unnecessary BVH traversal when the local intersection
  is requested from curve object. The same early-output could be added
  to other BVH traversal implementation.

- Use `hiprtGeomCustomTraversalAnyHitCustomStack` for motion triangles
  primitives. This fixes motion blur on objects with SSS render black.

Fixes #135856

Co-authored-by: Sahar A. Kashi <sahar.alipourkashi@amd.com>
Co-authored-by: Sergey Sharybin <sergey@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/135943
2025-03-14 18:17:54 +01:00
Xavier Hallade
0ebce03d41 Cycles: Reorder ShaderData elements to improve cache utilization
Profiling on Arc B580 shown that sd->num_closure queries were often
stalling.
Packing it closer to other often accessed elements within ShaderData
(type, flag..) does speedup rendering by ~5% in most scenes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135980
2025-03-14 16:11:17 +01:00
Sergey Sharybin
b8bd8ba36d Merge branch 'blender-v4.4-release' 2025-03-14 14:52:02 +01:00
Sergey Sharybin
1d4a211d6c Fix: Incorrect check of device pointers in HIP-RT code
The code was checking the same device pointer instead of
checking that both allocations are successful.

Pull Request: https://projects.blender.org/blender/blender/pulls/135977
2025-03-14 14:51:49 +01:00
Jeroen Bakker
15d88e544a GPU: Storage buffer allocation alignment
Since the introduction of storage buffers in Blender, the calling
code has been responsible for ensuring the buffer meets allocation
requirements. All backends require the allocation size to be divisible
by 16 bytes. Until now, this was sufficient, but with GPU subdivision
changes, an external library must also adhere to these requirements.

For OpenSubdiv (OSD), some buffers are not 16-byte aligned, leading
to potential misallocation. Currently, this is mitigated by allocating
a few extra bytes, but this approach has the drawback of potentially
reading unintended bytes beyond the source buffer.

This PR adopts a similar approach to vertex buffers: the backend handles
extra byte allocation while ensuring data uploads and downloads function
correctly without requiring those additional bytes.

No changes were needed for Metal, as its allocation size is already
aligned to 256 bytes.

**Alternative solutions considered**:

- Copying the CPU buffer to a larger buffer when needed (performance impact).
- Modifying OSD buffers to allocate extra space (requires changes to an external library).
- Implementing GPU_storagebuf_update_sub.

Ref #135873

Pull Request: https://projects.blender.org/blender/blender/pulls/135716
2025-03-13 15:05:16 +01:00
Xavier Hallade
3de1a60c6a Cycles: oneAPI: Force large GRF for shade_surface_* kernels
While auto lets the compiler make the right choice for shade_surface
kernel when compiling for Battlemage and Lunar Lake, that's not the case
for Alchemist and Meteor Lake, so now we force this mode.
2025-03-13 14:22:48 +01:00
Jeroen Bakker
1ea1f4c92c Refactor: GHOST/Vulkan: Wrap handles in a struct
Vulkan handles are currently only requested once. In the future OpenXR
also needs acces to these handles and additional handles will be needed
when introducing copy queues and async compute.

This PR will collect the handles in a struct to ensure we don't need to
alter the GHOST interface for every change.

Pull Request: https://projects.blender.org/blender/blender/pulls/135905
2025-03-13 11:06:20 +01:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00
Sergey Sharybin
977a334f6f Merge branch 'blender-v4.4-release' 2025-03-12 19:24:01 +01:00
Sergey Sharybin
a3eb0faa3f Fix: Incorrect ray time used for HIP-RT local intersections
It was always hard-coded to be 0.

It does not seem to result in any extra tests passing, but they are
probably not sophisticated enough.

Noticed while looking into details for the #135856.

Pull Request: https://projects.blender.org/blender/blender/pulls/135878
2025-03-12 19:23:38 +01:00
Brecht Van Lommel
71a4f1ab96 Merge branch 'blender-v4.4-release' 2025-03-12 11:40:08 +01:00
Brecht Van Lommel
73ea95a56a Fix #135644: HIP-RT crash with host memory fallback
Avoid manipulating the host pointer in device memory, this fails when host
mapped memory gets used and the pointers gets re-allocated.

Pull Request: https://projects.blender.org/blender/blender/pulls/135724
2025-03-12 11:38:07 +01:00
Brecht Van Lommel
0ff2635131 Fix #135644: Cycles HIP-RT crash when running out of memory
Tightehn up checks for failed allocations, early out on errors.

Pull Request: https://projects.blender.org/blender/blender/pulls/135724
2025-03-12 11:37:59 +01:00
Brecht Van Lommel
b1559b3ff4 Cycles: Adaptive subdivision patches without inner grid
Means low res patches can have 2 instead of 4 triangles.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:36 +01:00
Brecht Van Lommel
de821416c7 Cycles: Adaptive subdivision dicing and splitting improvements
* Share vertices between patches instead of using stitch map
* Switch to OpenSubdiv compatible counter-clockwise indexing
* Simplify patch edge reverse direction logic
* Add more comments to splitting and dicing

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:33 +01:00
Brecht Van Lommel
e84b377eae Refactor: Simplify subd patch code
* Remove unused linear patch normals
* Renaming for consistency and clarity
* Shuffle order of function definitions

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:20 +01:00
Brecht Van Lommel
42846caca1 Cycles: Adaptive subdivision support for modifier options
* Use creases
* Boundary interpolation
* UV interpolation

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:17 +01:00
Brecht Van Lommel
82751ca10c Cycles: Adaptive subdivision motion blur support
* Smooth interpolation of vertex coordinates and normals of motion steps
* Fix issues with Blender sync and object device update

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:14 +01:00
Brecht Van Lommel
62201eb372 Cycles: Adaptive subdivision smooth UV interpolation
Using OpenSubdiv FVar interpolation.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:10 +01:00
Brecht Van Lommel
07b60c189b Cycles: Perform attribute subdivision on the host side
* Add SubdAttributeInterpolation class for linear attribute interpolation.
* Dicing computes ptex UV and face ID for interpolation.
* Simplify mesh storage of subd primitive counts
* Remove kernel code for subd attribute interpolation
* Remove patch table packing and upload

The old optimization adds a fair amount of complexity to the kernel, affecting
performance even when not using the feature. It's also not that useful as it
does not work for UVs that needs special interpolation. With this simpler code
it should be easier to make it feature complete.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:07 +01:00
Brecht Van Lommel
afd139f07e Refactor: Split OsdMesh off from OsdData
Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:05 +01:00
Brecht Van Lommel
7685b9016a Cycles: Use fixed instead of adaptive subdivision max isolation level
Same as what Blender does by default.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:03 +01:00
Brecht Van Lommel
e9a20b8ce8 Refactor: Better handling of OpenSubdiv namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:58:01 +01:00
Brecht Van Lommel
189efd8eeb Refactor: Move more subdivision code into subd/
No logic or functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:57:59 +01:00
Brecht Van Lommel
6ec541ca4e Refactor: Cycles: Remove face normal attribute
It's already computed on demand in the kernel, no need to have it host side.

Pull Request: https://projects.blender.org/blender/blender/pulls/135681
2025-03-11 20:57:51 +01:00
Brecht Van Lommel
221dd26604 Cleanup: Cycles + lite build compiler warnings 2025-03-11 19:56:04 +01:00
Jeroen Bakker
96c9f480b3 Cleanup: Subdiv: Remove 2nd derivatives
2nd derivatives aren't used within Blender but all
logic branches end up with checking for it. This PR
removes the 2nd derivatives from the code so we
can skip this test.

Pull Request: https://projects.blender.org/blender/blender/pulls/135745
2025-03-11 09:26:35 +01:00
Jeroen Bakker
46cfba075d Subdiv: Split eval shaders
Both eval shaders were implemented in osd_kernel_comp.glsl. This PR
separates them for easier understanding of the shaders.

Pull Request: https://projects.blender.org/blender/blender/pulls/135719
2025-03-10 16:06:00 +01:00
Lukas Stockner
dbe275895e Cleanup: Cycles: Deduplicate OptiX OSL code
Not a big difference for now, but will be nicer for #129495.

Pull Request: https://projects.blender.org/blender/blender/pulls/135049
2025-03-10 13:30:58 +01:00
Jeroen Bakker
40696ca452 SubDiv: Migrate GPU subdivision to use GPU module
Blender already had its own copy of OpenSubDiv containing some local fixes
and code-style. This code still used gl-calls. This PR updates the calls
to use GPU module. This allows us to use OpenSubDiv to be usable on other
backends as well.

This PR was tested on OpenGL, Vulkan and Metal. Metal can be enabled,
but Vulkan requires some API changes to work with loose geometry.

![metal.png](/attachments/bb042c3a-1a87-4140-9958-a80da10d417b)

# Considerations

**ShaderCreateInfo**

intern/opensubdiv now requires access to GPU module. This to create buffers
in the correct context and trigger correct dispatches. ShaderCreateInfo is used
to construct the shader for cross compilation to Metal/Vulkan. However opensubdiv
shader caching structures are still used.

**Vertex buffers vs storage buffers**

Implementation tries to keep as close to the original OSD implementation. If
they used storage buffers for data, we will use GPUStorageBuf. If it uses vertex
buffers, we will use gpu::VertBuf.

**Evaluator const**

The evaluator cannot be const anymore as the GPU module API only allows
updating SSBOs when constructing. API could be improved to support updating
SSBOs.

Current implementation has a change to use reads out of bounds when constructing
SSBOs. An API change is in the planning to remove this issue. This will be fixed in
an upcoming PR. We wanted to land this PR as the visibility of the issue is not
common and multiple other changes rely on this PR to land.

Pull Request: https://projects.blender.org/blender/blender/pulls/135296
2025-03-10 07:31:59 +01:00
Brecht Van Lommel
8076fa10e0 Fix: Cycles BVH2 issue causing Metal crashes, after recent cleanup
Ref 48398b223b
2025-03-07 19:20:25 +01:00
Sergey Sharybin
32d49541c0 Fix #135572: Cycles shadow linking through transparency is broken on GPU
Make the ray self primitives store and restore reliable for cases when
the intersect_shadow kernel is called multiple times:

- Light object and primitive are stored in dedicated fields in the
  state. This adds 2 integers per state.

- The self object and primitive are used from the previous intersection
  when the intersect_shadow is called multiple times.

There is more detailed explanation added in the code.

The issue was introduced by the light refactor to be objects in #134846.

Pull Request: https://projects.blender.org/blender/blender/pulls/135573
2025-03-07 17:16:04 +01:00
Brecht Van Lommel
48398b223b Cleanup: Fix various divisions by zero reported by ASAN
Pull Request: https://projects.blender.org/blender/blender/pulls/135326
2025-03-06 22:34:23 +01:00
Brecht Van Lommel
b75b2e883d Cleanup: Always use fullsize ShaderData on the CPU
This avoids compiler and ASAN warnings. This optimization exist for
GPU rendering.
2025-03-06 22:34:22 +01:00
Brecht Van Lommel
5a9d4fd613 Cleanup: Use default member initializers 2025-03-06 22:34:22 +01:00
Brecht Van Lommel
ab394c8e8d Refactor: Use std::bitset to avoid overflow in device queue logging 2025-03-06 22:34:22 +01:00
Brecht Van Lommel
dd20f31302 Cleanup: Fix clang-tidy warnings from recent OSL changes 2025-03-06 22:34:22 +01:00
Xavier Hallade
91f332e7c6 Cycles: oneAPI: Force normal GRF for integrator_intersect_* kernels
With auto mode, integrator_intersect_subsurface still ended up being
compiled in large GRF mode on Intel Arc B580, while normal GRF provides
the best performance for this kernel.
2025-03-06 22:24:45 +01:00
Falk David
e39c83c881 Merge branch 'blender-v4.4-release' 2025-03-06 21:19:31 +01:00
Jesse Yurkovich
4c38380cc6 Fix #134043: Account for frame_offset in Alembic procedurals
There's two places which perform the frame start and end time
calculation and only one of them was respecting the frame_offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/134149
2025-03-06 20:54:22 +01:00