Commit Graph

13161 Commits

Author SHA1 Message Date
Lukas Stockner
e20f86547a Cycles: Fix compilation of the shader table precomputing tool 2023-09-10 18:58:43 +02:00
Weizhen Huang
063a9e8964 Fix: Cycles: inconsistent normal checks when sampling and evaluating BSDF
was mixing real geometry normal, smoothed geometry normal and
bump-mapped normal.
Use `(sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng` consistently instead.
2023-09-08 19:00:01 +02:00
Weizhen Huang
4c6164e292 Cleanup: fix typo in path guiding code 2023-09-08 17:17:12 +02:00
Weizhen Huang
1b7d41eba7 Cleanup: add TODOs in bsdf_microfacet.h 2023-09-08 16:53:26 +02:00
Weizhen Huang
f96b9db610 Cleanup: remove redundant fresnel_dielectric()
We already have two other functions doing very much the same thing.
`bsdf_microfacet_sample()` seems to be the only place where this
function was used; there we always sample visible normals, so the extra
`inside` check is not needed.
2023-09-08 16:53:12 +02:00
Weizhen Huang
21ca47d81f Cleanup: rearrange code in bsdf_microfacet.h for better readability
1. move early-out logic even earlier
2. reduced the scope of some variables
3. return `label` at the end of `bsdf_microfacet_sample()`. Return
`LABEL_NONE` in the invalid case. The previous distinction was
unnecessary because samples with zero contribution are assigned with
`LABEL_NONE` in `integrate_surface_bsdf_bssrdf_bounce()` anyway.
2023-09-08 16:52:59 +02:00
Weizhen Huang
bf82f9442c Cycles: remove defensive sampling in BSDF picking
the motivation was to give closures with low weight a higher pdf to pick
at the first bounce, in case the next interaction has high contribution.
However, there are several issues:

1. this is too much fine-tuned for a specific case, and only works well
when there is a strong contribution after reflection and very little
contribution after the transmission;
2. the logic in `bsdf_microfacet.h` was added when merging reflection
and refraction into a glass closure, since then it doesn't even work
well in the above case when mixed with other closures;
3. The behavior is inconsistent in `bsdf_microfacet_eval()` and
`bsdf_microfacet_sample()`;
4. such cases should be handled by more modern and more general methods
such as path guiding and denoiser;
5. it makes the code flow harder to follow

Delete this trick for now to pick the closures solely based on their
`sample_weight`. Can be added back (with proper fix in
`bsdf_microfacet`) if indeed necessary.
2023-09-08 16:52:42 +02:00
Xavier Hallade
7c9a02f138 Cycles: oneAPI: keep disabling use of copy engine with new compiler versions
Recent versions of DPC++ dropped using the environment variable
SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE=0 we were setting.
We're now also setting SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE=0 by default
to keep a consistent behavior.
2023-09-08 15:51:51 +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
Sergey Sharybin
4b217df080 Fix crash in Cycles when cancelling render during light tree building
The recursive building has an early output, which could leave the node
without the requested child initialized, causing the access to the left
child to crash later on in the builder function.

Simply add an extra is-canceled check to avoid access of possibly
non-initialized tree structure.

Pull Request: https://projects.blender.org/blender/blender/pulls/112132
2023-09-08 15:21:54 +02:00
Campbell Barton
9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Campbell Barton
4fc5d287ac Cleanup: doxygen parameters, blank comment lines 2023-09-08 16:53:30 +10:00
Weizhen Huang
fedeaab30f Fix #112005: increase ray_sphere_intersect() precision
by doing the subtraction first and then take the dot product. This
offers higher precision than taking the dot product first and then
subtract the result, especially in the cases where the ray origin is
very far away from the sphere center.
2023-09-06 16:23:39 +02:00
ChengduLittleA
bf8d3c157a Fix #111820: Missing type casting in XrGraphicsBinding.cc
The line `oxr_binding.egl.getProcAddress = eglGetProcAddress` supposedly
needs a type casting for it to compile successfully under llvm16.

Pull Request: https://projects.blender.org/blender/blender/pulls/111915
2023-09-06 15:26:51 +02: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
Weizhen Huang
077022e45f Fix #112003: Principled Huang Hair renders black on horizontal particle hair
Curve normal is not available in legacy particle hair system. Construct
a local coordinate system instead of using a fixed normal direction [1,
0, 0] to avoid black appearance.
2023-09-06 14:18:29 +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
4dd5385807 GHOST/Wayland: remove exception if wl_keyboard_listener::keymap fails
This would cause Blender to exist, log the message & return instead.
2023-09-06 16:19:33 +10:00
Campbell Barton
d06bd5d1f0 GHOST: remove prefix from exception messages
The back-end name is already included remove duplicate information.
2023-09-06 16:08:06 +10:00
Campbell Barton
51e3cd1603 Fix Wayland error message displaying when running on X11
Problem caused by [0], resolve by only printing error messages
when none of the GHOST back-ends are able to start.

[0]: f58d596c36c81245ed8c5723e5fa8369106a7a80
2023-09-06 15:38:34 +10:00
Campbell Barton
1f01a64403 Cleanup: spelling in comments 2023-09-06 14:23:01 +10:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Weizhen Huang
df26271db4 Fix NaN in Principled Huang Hair sphg_dir()
thanks Christophe Hery for spotting and fixing the issue
2023-09-05 18:03:43 +02: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
b3e73ac733 Cycles: Improve compilation error logs for Metal kernels
The Metal backend combines all kernel sources into a single string
and passes it to the compiler. Doing so natively has a disadvantage
of making it hard to find sources of mistakes in code when working
on the kernel source as the source file name and line number info
is lost. For example, the error would look like:

```
program_source:187004:3: error: use of undeclared identifier 'metalrt_intersection_point_shadow_force_error'
  metalrt_intersection_point_shadow_force_error(launch_params_metal,
  ^
```

This patch makes it so the #line pragmas are inserted into the
combined source source code, so that the compiler errors are easier
to find immediately. For example the error from above becomes

```
source/kernel/device/metal/kernel.metal:809:3: error: use of undeclared identifier 'metalrt_intersection_point_shadow_force_error'
  metalrt_intersection_point_shadow_force_error(launch_params_metal,
  ^
```

The code is a slightly modified functionality from the source
processing used for OpenCL in Blender 2.80.

Pull Request: https://projects.blender.org/blender/blender/pulls/111959
2023-09-05 17:21:20 +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
Campbell Barton
bedfc68e3f Cleanup: use function style integer casts, modernize headers 2023-09-05 11:10:44 +10:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10: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
Nikita Sirgienko
56ff55ed09 Cycles: oneAPI: Resolve an compilation error in assert 2023-09-04 15:41:05 +02:00
Campbell Barton
e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Hans Goudey
fe7412bbdc Cleanup: Fix else after return 2023-09-01 10:10:08 -04:00
Campbell Barton
e3fd80dd64 Fix building with GHOST/Wayland & Vulkan 2023-09-01 22:04:34 +10:00
Campbell Barton
cc5dd9e3d3 Cleanup: use libdecor_ prefix for libdecor_frame_interface callbacks
These names weren't obviously related to libdecor.
2023-09-01 16:09:16 +10:00
Campbell Barton
e711af8987 GHOST/Wayland: correction to xdg_toplevel_listener::configure use
Zero width/height should be ignored, don't overwrite the window
size set by the client in this case.
2023-09-01 16:09:16 +10:00
Hoshinova
af54b16778 Nodes: fix Voronoi Noise discontinuities when Lacunarity is 0.0.
When the Lacunarity input is driven by e.g. a Texture discontinuities can
arise because the `for` loop breaks prematurely.

Pull Request: https://projects.blender.org/blender/blender/pulls/111395
2023-08-31 14:20:27 +02:00
Xavier Hallade
40a39c2976 Cycles: oneAPI: cleanup: drop __spirv_ocl_cos workaround
As __FAST_MATH__ isn't defined anymore since
09df1f4cafb996802af4c89ab8af0630f750d599, sycl::cos uses the precise
implementation, no need to call __spirv_ocl_cos anymore.
2023-08-31 13:10:29 +02:00
Xavier Hallade
09df1f4caf Fix #111162: Overlay drawing issues due to shared library using fastmath
Cycles oneAPI kernel library was compiled using -ffast-math. The current
version of Clang makes it link to crtfastmath.o in that case, bringing a
static constructor that does set the FTZ/DAZ bits in MXCSR for the whole
program, leading to unwanted behavior with other components.
Instead of -ffast-math, we switch to a safer subset of compile flags.

Pull Request: https://projects.blender.org/blender/blender/pulls/111708
2023-08-31 10:43:27 +02:00
Xavier Hallade
6a301cf07f Cycles: oneAPI: increase windows min driver requirement to 101.4644
101.4644 has been released 2023-08-15 and fixes the Windows specific
issue #109282.
2023-08-31 10:22:51 +02:00
Jesse Yurkovich
9a1c66d503 Cycles: Match Eevee when processing ramp/camera curves
Slightly increase the number of times ramps/curves are sampled to better
align with the results produced by Eevee.

Pull Request: https://projects.blender.org/blender/blender/pulls/111082
2023-08-31 05:08:04 +02:00
Campbell Barton
0026d20c8c Cleanup: quiet compiler warnings, correct doxy section 2023-08-30 10:57:17 +10:00
Jeroen Bakker
bee3f645d8 Vulkan: Rewrite GHOST_ContextVK
This is a rewrite of GHOST_ContextVK to align with Metal backend as described
in #111389 - solution 3 with the adaptation that GHOST is still responsible
for presenting the swap chain image and a post callback is still needed in
case the swapchain is recreated.

This PR also includes some smaller improvements in stability.

Technical documentation: https://developer.blender.org/docs/eevee_and_viewport/gpu/vulkan/swap_chain/

* Renderpasses and framebuffers are not owned anymore by GHOST_ContextVK
* VKFramebuffer doesn't contain a swap chain image.
* Swapchain images can only be used as a blit destination or present source.
  Not as an attachment.
* GHOST_ContextVK::swapBuffers would call a callback with the image the
  GPU module needs to blit the results to.
* Clearing of depth/stencil attachments when no depth write state is set.
* Enable VK_KHR_maintenance4 to relax the stage interface mapping.
* Removes most vulkan validation warnings/errors.
* Detection of frame buffer changes that needs to be applied before
  performing a command requiring render pass (draw/clear attachment)

**Benefits**

* Late retrieval of a swap chain image results in better overall performance as
  Blender doesn't need to wait until the image is presented on the screen.
* Easier API and clearer state (transitions)
* More control over Image layouts and command buffer states. (Better alignment with
  Vulkan API)

Pull Request: https://projects.blender.org/blender/blender/pulls/111473
2023-08-29 15:05:08 +02:00
Campbell Barton
eec449ffe8 Cleanup: correct spelling, comments
Hyphenate words in GLSL code-comments.
2023-08-29 15:55:09 +10:00
Hans Goudey
eafe8332c7 Fix: Compile error with Ghost X11 off and Wayland on
‘const’ qualifiers cannot be applied to ‘const std::runtime_error&’
2023-08-28 16:15:21 -04:00
Vitor Boschi
e5a0d11c4e UI: Allow eyedropper outside of Blender (X11)
Implements the GHOST_GetPixelAtCursor for the X11 backend, allowing
the user to sample any color displayed on the screen.

Noted some limitations in the code-comments.

Ref !111493.
2023-08-26 17:20:05 +10:00
Harley Acheson
f69c7afe57 Fix #111295: Add Missing Win32 Platform-Specific Window functions
Add platform-specific (Windows) versions of getOSWindow() and
getWindowUnderCursor().

Pull Request: https://projects.blender.org/blender/blender/pulls/111359
2023-08-25 22:09:54 +02:00
Campbell Barton
3de8900ed6 Cleanup: spelling in comments 2023-08-25 09:40:42 +10:00
Campbell Barton
24a8d6425a CMake: include missing files in source files 2023-08-24 11:51:25 +10:00
Campbell Barton
0148293520 License headers: add SPDX licenses for '*.glsl' files
When GLSL sources were first included in Blender they were treated as
data (like blend files) and had no license header.
Since then GLSL has been used for more sophisticated features
(EEVEE & real-time compositing)
where it makes sense to include licensing information.

Add SPDX copyright headers to *.glsl files, matching headers used for
C/C++, also include GLSL files in the license checking script.

As leading C-comments are now stripped,
added binary size of comments is no longer a concern.

Ref !111247
2023-08-24 10:57:03 +10:00