Commit Graph

12749 Commits

Author SHA1 Message Date
Jeroen Bakker
7fb1f060ff Vulkan: Initial Compute Shaders support
This patch adds initial support for compute shaders to
the vulkan backend. As the development is oriented to the test-
cases we have the implementation is limited to what is used there.

It has been validated that with this patch that the following test
cases are running as expected
- `GPUVulkanTest.gpu_shader_compute_vbo`
- `GPUVulkanTest.gpu_shader_compute_ibo`
- `GPUVulkanTest.gpu_shader_compute_ssbo`
- `GPUVulkanTest.gpu_storage_buffer_create_update_read`
- `GPUVulkanTest.gpu_shader_compute_2d`

This patch includes:
- Allocating VkBuffer on device.
- Uploading data from CPU to VkBuffer.
- Binding VkBuffer as SSBO to a compute shader.
- Execute compute shader and altering VkBuffer.
- Download the VkBuffer to CPU ram.
- Validate that it worked.
- Use device only vertex buffer as SSBO
- Use device only index buffer as SSBO
- Use device only image buffers

GHOST API has been changed as the original design was created before
we even had support for compute shaders in blender. The function
`GHOST_getVulkanBackbuffer` has been separated to retrieve the command
buffer without a backbuffer (`GHOST_getVulkanCommandBuffer`). In order
to do correct command buffer processing we needed access to the queue
owned by GHOST. This is returned as part of the `GHOST_getVulkanHandles`
function.

Open topics (not considered part of this patch)
- Memory barriers & command buffer encoding
- Indirect compute dispatching
- Rest of the test cases
- Data conversions when requested data format is different than on device.
- GPUVulkanTest.gpu_shader_compute_1d is supported on AMD devices.
  NVIDIA doesn't seem to support 1d textures.

Pull-request: #104518
2023-02-21 15:04:52 +01:00
Brecht Van Lommel
02c2970983 Cycles: add NanoVDB support for Metal on Apple Silicon
Contributed by Yulia Kuznetcova at Apple.

NanoVDB is patched to give add address spaces required by Metal. We hope that
in the future Metal will support the generic address space.

For AMD and Intel this is currently not available since it causes a performance
regression also on scenes without volumes.

Pull Request #104837
2023-02-21 15:03:52 +01:00
Brecht Van Lommel
fdf6252b5a Merge branch 'blender-v3.5-release' 2023-02-21 12:04:30 +01:00
Brecht Van Lommel
6583acb880 Fix Cycles MetalRT access of macOS 11 features when unavailable
After recent changes in 2d994de.

Pull Request #104976
2023-02-21 12:03:21 +01:00
Julian Eisel
c437a8aea8 Revert release branch only commit after merge
This is a revert of a revert, because the initial revert is only
supposed to be in the release branch.

This reverts commit 3eed00dc546b5930b255572901915ccbc26c0e69.
2023-02-20 11:51:16 +01:00
Julian Eisel
3eed00dc54 Revert "GPencil: Include UV information in simplify->sample modifier."
This reverts commit 19222627c6b57df77d3bc9ae60d7850ab7e23abb.

Something went wrong here, seems like this commit merged the main branch
into the release branch, which should never be done.
2023-02-20 11:20:07 +01:00
YimingWu
19222627c6 GPencil: Include UV information in simplify->sample modifier.
Simplify modifier sample mode didn't transfer UV parameters, now fixed.

Pull Request #104942
2023-02-19 11:45:22 +01:00
Dalai Felinto
4ec9aff2af Revert "Fix #104850: Create Geometry Nodes operators fails if not in English"
This reverts commit 68181c2560db25c1bd2b70beccf6022c5aa00f39.

I merged 3.6 into 3.5 by mistake. Basically I had a PR against main,
 then changed it in the last minute to be against 3.5 via the
 web-interface unaware that I shouldn't do it without updating the
 patch.

 Original Pull Request: #104889
2023-02-17 18:45:42 +01:00
Dalai Felinto
68181c2560 Fix #104850: Create Geometry Nodes operators fails if not in English
Note that the node group has its sockets names
translated, while the built-in nodes don't.

So we need to use data_ for the built-in nodes names,
and the sockets of the created node groups.

Pull Request #104889
2023-02-17 18:39:17 +01:00
Campbell Barton
e424931cf7 Cleanup: rename Byte to Bytes in Python string utilities
These functions operate on byte arrays, not a single byte,
match naming for CPython's PyBytes_AS_STRING.
2023-02-15 16:19:14 +11:00
Germano Cavalcante
a755e6e63f Revert "MSVC: lower C4100 warning level from 4 to 3"
This reverts commit db4e7616f3590c04484fe8a015b6a02b7a1ede44.

Caused many issues when compiling mantaflow.
2023-02-14 15:36:35 -03:00
Germano Cavalcante
db4e7616f3 MSVC: lower C4100 warning level from 4 to 3
This better aligns with OSX/Linux warnings.

Although `__pragma(warning(suppress:4100))` is not the same as
`__attribute__((__unused__))` in gcc (which only affects the attribute
instead of the line), it still seems to be better to use it than to
hide the warning entirely.
2023-02-14 14:38:18 -03:00
Julian Eisel
4126284e46 Allocator: Fail building when trying to MEM_delete a void pointer
`MEM_delete()` is designed for type safe destruction and freeing, void
pointers make that impossible.
Was reviewing a patch that was trying to free a C-style custom data
pointer this way. Apparently MSVC compiles this just fine, other
compilers error out. Make sure this is a build error on all platforms
with a useful message.
2023-02-14 12:48:26 +01:00
Lukas Stockner
1e449bee21 Cycles: Temporary fix for Principled Hair albedo
The proper fix (bb9eb262d4d3) caused compilation problems with HIP, so we're
delaying it until 3.6.
To fix the original bug report (#104586), this is a quick workaround that'll
hopefully not upset the compiler.

Pull Request #104723
2023-02-14 12:18:10 +01:00
Campbell Barton
0fa34aa0ec Cleanup: spelling in comments, reference enum types in doc-strings
Also use doxy formatting for structs in sculpt_uv.c.
2023-02-14 10:29:48 +11:00
Lukas Stockner
bb9eb262d4 Revert "Cycles: Clean up the Principled Hair BSDF implementation"
This reverts commit cb77865c21a0a91f25a26011559d1ddab87c2c73.

Appears to break HIP compilation, so delay until 3.6.
2023-02-13 23:32:53 +01:00
Sebastian Parborg
1f615690e6 Cycles: Add support for CUDA 12
CUDA 12 no longer supports sm_3*, in particular 35 and sm_37,
so skip building those if only CUDA 12+ is available.

Pull Request #104713
2023-02-13 23:04:02 +01:00
Brecht Van Lommel
6a0b1eae8c Fix #104097: re-enable Cycles AMD Vega support
The internal compiler error appears to be gone. Unclear why it appeared in the
first place and why it's gone now. Just random kernel code changes causing it.

Pull Request #104719
2023-02-13 22:53:08 +01:00
Lukas Stockner
cb77865c21 Cycles: Clean up the Principled Hair BSDF implementation
- Rename roughness variables for more clarity - before, the SVM/OSL code would
  set s and v to the linear roughness values, and the setup function would over-
  write them with the distribution parameters. This actually caused a bug in the
  albedo code, since it intended to use the linear roughness value, but ended up
  getting the remapped value.
- Deduplicate the evaluation and sample functions. Most of their code is the
  same, only the middle part is different.
- Changed albedo computation to return the sum of the intensities of the four
  BSDF lobes. Previously, the code applied the inverse of the color->sigma
  mapping from the paper - this returns the color specified in the node, but
  for very dark hair (e.g. when using the Melanin controls) the result is
  extremely low (e.g. 0.000001) despite the hair still reflecting a significant
  amount of light (since the R lobe is independent of sigma). This causes issues
  with the light component passes, so this change fixes #104586.
- There's quite a few computations at the start of the evaluation function that
  are needed for sampling, evaluation and albedo computation, but only depend on
  the view direction. Therefore, just precompute them - we still have space in
  PrincipledHairExtra after all.
- Fix a tiny bug - the direction sampling code did not account for the R lobe
  roughness modifier.

Pull Request #104669
2023-02-13 22:49:01 +01:00
Alaska
9fecf1f8b8 Cycles: Replace resolution divider loop with an analytical formula
As a side effect of this change, more resolution divisions are now available.
Before this patch the possible resolution divisions were all powers of two.
Now the possible resolution divisions are the multiples of pixel_size.

This increase in possible resolution divisions is the same idea proposed in https://archive.blender.org/developer/D13590.
In that patch there were concerns that this will increase the time between a user navigating
and seeing the 1:1 render. To my knowledge this is a non-issue and there should be
little to no increase in time between those two events.

Pull Request #104450
2023-02-13 13:02:47 +01:00
Clément Foucault
da0c182a61 Cycles: Fix compilation after recent GPU cleanups 2023-02-13 12:17:46 +01:00
Clément Foucault
dd171f7743 Cleanup: GPUShader: Rename GPU_shader_uniform_vector
Rename to `GPU_shader_uniform_float/int_ex` to make more sense as a
general purpose function.
2023-02-13 11:22:38 +01:00
Clément Foucault
b68bac7ced Cleanup: GPUShader: Remove GPU_shader_uniform_int/float
Simplify the API, leaving only one function to set uniform without the
uniform name.
2023-02-13 11:22:38 +01:00
Hans Goudey
86b3073c9e Cleanup: Quiet unused variable warning
Also name another argument for consistency.
2023-02-12 22:27:07 -05:00
Campbell Barton
91346755ce Cleanup: use '#' prefix for issues instead of 'T'
Match the convention from Gitea instead of Phabricator's T for tasks.
2023-02-12 14:56:05 +11:00
Campbell Barton
ce44953933 Cleanup: various C++ cleanups 2023-02-11 14:04:35 +11:00
Michael Jones (Apple)
01480229b1 Cycles: Fix MetalRT checkbox not hooked up to device on AMD
(Follow on from D17043)
On AMD Navi2 devices the MetalRT checkbox was not hooked up properly and had no effect. This patch fixes it.

Co-authored-by: Michael Jones <michael_p_jones@apple.com>
Pull Request #104520
2023-02-10 10:55:39 +01:00
Campbell Barton
4cbe0bff34 Cleanup: spelling in comments 2023-02-10 11:34:20 +11:00
Damien Picard
22edf04458 I18n: use format strings for Cycles version error messages
The required version numbers for various devices was hardcoded in the
UI messages. The result was that every time one of these versions was
bumped, every language team had to update the message in question.

Instead, the version numbers can be extracted, and injected into the
error messages using string formatting so that translation updates
need happen less frequently.

Pull Request #104488
2023-02-09 15:48:19 +01:00
Campbell Barton
ca183993a5 Fix freeing uninitialized pointer in GHOST/Wayland + X11 fallback
Freeing the timer manager didn't account for Wayland being partially
initialized.
2023-02-09 23:41:03 +11:00
Campbell Barton
0381fe7bfe Cleanup: update username in code-comments: campbellbarton -> ideasman42
Gitea migration changed my username, update code-comments.
2023-02-09 11:33:48 +11:00
Brecht Van Lommel
9c03a1c92f Fix Cycles link error with debug/asan builds after recent bugfix
Pull Request #104487
2023-02-08 23:20:29 +01:00
Lucas Tadeu
a1282ab015 Fix Cycles debug build error after host falback changes
Introduced in dcfb6df9ce6.

Co-authored-by: Lucas Tadeu Teixeira <lucas@lucastadeu.com>

Pull Request #104454
2023-02-08 19:27:40 +01:00
Brecht Van Lommel
cb5318b651 Docs: change Git URLs to point projects.blender.org instead of git.blender.org 2023-02-07 14:23:05 +01:00
Sergey Sharybin
bd6b0bac88 Update references to the new projects platform and main branch 2023-02-07 14:18:19 +01:00
Campbell Barton
2609ca2b8e Cleanup: tweaks to cycles/metal preferences
- Auto-format.
- Use raw string for regex.
- Remove redundant assignment.
- Remove duplicate arm64 check.
- Break early out of loop.
2023-02-07 17:30:13 +11:00
Campbell Barton
dbca0cc9d5 Fix crash on exit under Wayland
Order of free error from [0] caused the timer manager
to be freed before the timer.

[0]: 7de1a4d1d81ffd4cd2e75d911426edc847267244
2023-02-07 15:12:05 +11:00
Campbell Barton
a99022e22d Cleanup: spelling in comments 2023-02-07 14:17:01 +11:00
Nikita Sirgienko
6dcfb6df9c Cycles: Abstract host memory fallback for GPU devices
Host memory fallback in CUDA and HIP devices is almost identical.
We remove duplicated code and create a shared generic version that
other devices (oneAPI) will be able to use.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17173
2023-02-06 22:19:32 +01:00
Michael Jones
2d994de77c Cycles: MetalRT optimisation for subsurface intersection queries
This patch optimises subsurface intersection queries on MetalRT. Currently intersect_local traverses from the scene root, retrospectively discarding all non-local hits. Using a lookup of bottom level acceleration structures, we can explicitly query only the relevant instance. On M1 Max, with MetalRT selected, this can give a render speedup of 15-20% for scenes like Monster which make heavy use of subsurface scattering.

Patch authored by Marco Giordano.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17153
2023-02-06 19:12:29 +00:00
Brecht Van Lommel
773a36d2f8 Fix Cycles OneAPI build error after recent changes 2023-02-06 15:36:49 +01:00
Patrick Mours
f2538c7173 Fix T104335: MNEE + OptiX OSL results in illegal address error
The OptiX pipeline created for OSL was missing sufficient continuation
stack to handle the MNEE ray generation program.
2023-02-06 15:06:52 +01:00
Brecht Van Lommel
9ad3a85f8b Fix Cycles GPU binaries build error after recent changes for Metal 2023-02-06 13:17:57 +01:00
Michael Jones
654e1e901b Cycles: Use local atomics for faster shader sorting (enabled on Metal)
This patch adds two new kernels: SORT_BUCKET_PASS and SORT_WRITE_PASS. These replace PREFIX_SUM and SORTED_PATHS_ARRAY on supported devices (currently implemented on Metal, but will be trivial to enable on the other backends). The new kernels exploit sort partitioning (see D15331) by sorting each partition separately using local atomics. This can give an overall render speedup of 2-3% depending on architecture. As before, we fall back to the original non-partitioned sorting when the shader count is "too high".

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16909
2023-02-06 11:18:26 +00:00
Michael Jones
46c9f7702a Cycles: Enable MetalRT opt-in for AMD/Navi2 GPUs
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17043
2023-02-06 11:14:11 +00:00
Michael Jones
be0912a402 Cycles: Prevent use of both AMD and Intel Metal devices at same time
This patch removes the option to select both AMD and Intel GPUs on system that have both. Currently both devices will be selected by default which results in crashes and other poorly understood behaviour. This patch adds precedence for using any discrete AMD GPU over an integrated Intel one. This can be overridden with CYCLES_METAL_FORCE_INTEL.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17166
2023-02-06 11:13:33 +00:00
Michael Jones
0a3df611e7 Fix T103393: Cycles: Undefine __LIGHT_TREE__ on Metal/AMD to fix perf
This patch fixes T103393 by undefining `__LIGHT_TREE__` on Metal/AMD as it has an unexpected & major impact on performance even when light trees are not in use.

Patch authored by Prakash Kamliya.

Reviewed By: brecht

Maniphest Tasks: T103393

Differential Revision: https://developer.blender.org/D17167
2023-02-06 11:12:34 +00:00
Lukas Stockner
329eeacc66 Cleanup: Cycles: Remove isotropic microfacet closure setup functions
Turns out these are 100% redundant, so get rid of them.
2023-02-06 04:26:36 +01:00
Campbell Barton
731c3efd97 Cleanup: format 2023-02-06 12:32:45 +11:00
Campbell Barton
7de1a4d1d8 Fix GHOST/Wayland thread-unsafe timer-manager manipulation
Mutex locks for manipulating GHOST_System::m_timerManager from
GHOST_SystemWayland relied on WAYLAND being the only user of the
timer-manager.

This isn't the case as timers are fired from
`GHOST_System::dispatchEvents`.

Resolve by using a separate timer-manager for wayland key-repeat timers.
2023-02-06 12:25:04 +11:00
Campbell Barton
d3949a4fdb Fix GHOST/Wayland thread-unsafe key-repeat timer checks
Resolve a thread safety issue reported by valgrind's helgrind checker,
although I wasn't able to redo the error in practice.

NULL check on the key-repeat timer also needs to lock, otherwise it's
possible the timer is set in another thread before the lock is acquired.

Now all key-repeat timer access which may run from a thread
locks the timer mutex before any checks or timer manipulation.
2023-02-06 12:25:04 +11:00
Lukas Stockner
73000c792d Cycles: Reorganize Fresnel handling in Microfacet closures
This is both a cleanup and a preparation for the Principled v2 changes.
Notable changes:
- Clearcoat weight is now folded into the closure weight, there's no reason
  to track this separately.
- There's a general-purpose helper for computing a Closure's albedo, which is
  currently used by the denoising albedo and diffuse/gloss/transmission color
  passes.
- The d/g/t color passes didn't account for closure albedo before, this means
  that e.g. metallic shaders with Principled v2 now have their color texture
  included in the glossy color pass. Also fixes T104041 (sheen albedo).
- Instead of precomputing and storing the albedo during shader setup, compute
  it when needed. This is technically redundant since we still need to compute
  it on shader setup to adjust the sample weight, but the operation is cheap
  enough that freeing up the storage seems worth it.
- Future changes (Principled v2) are easier to integrate since the Fresnel
  handling isn't all over the place anymore.
- Fresnel handling in the Multiscattering GGX code is still ugly, but since
  removing that entirely is the next step, putting effort into cleaning it up
  doesn't seem worth it.
- Apart from the d/g/t color passes, no changes to render results are expected.

Differential Revision: https://developer.blender.org/D17101
2023-02-03 21:03:48 +01:00
Weizhen Huang
b454416927 Cycles: add non-uniform scaling to spot light size
Cycles ignores the size of spot lights, therefore the illuminated area doesn't match the gizmo. This patch resolves this discrepancy.
| Before (Cycles) | After (Cycles) | Eevee
|{F14200605}|{F14200595}|{F14200600}|
This is done by scaling the ray direction by the size of the cone. The implementation of `spot_light_attenuation()` in `spot.h` matches `spot_attenuation()` in `lights_lib.glsl`.
**Test file**:
{F14200728}

Differential Revision: https://developer.blender.org/D17129
2023-02-03 18:51:14 +01:00
Jeroen Bakker
ab3e1809b6 Vulkan: Select graphics queue with compute capabilities.
There might be cases that the graphics queue and compute
queue are separated, but that would be something that we
will solve in the future.
2023-02-03 10:16:01 +01:00
Jeroen Bakker
a45a881534 Spelling: familly -> family.
Fix spelling mistake originated from tmp-vulkan branch.
2023-02-03 10:16:01 +01:00
Campbell Barton
266d8de687 Cleanup: spelling in comments 2023-02-03 12:41:01 +11:00
Patrick Mours
fa9fc59b56 Fix T104240: OptiX OSL texture loading broken with displacement
The image manager used to handle OSL textures on the GPU by
default loads images after displacement is evaluated. This is a
problem when the displacement shader uses any textures, hence
why the geometry manager already makes the image manager
load any images used in the displacement shader graph early
(`GeometryManager::device_update_displacement_images`).
This only handled Cycles image nodes however, not OSL nodes, so
if any `texture` calls were made in OSL those would be missed and
therefore crash when accessed on the GPU. Unfortunately it is not
simple to determine which textures referenced by OSL are needed
for displacement, so the solution for now is to simply load all of
them early if true displacement is used.
This patch also fixes the result of the displacement shader not
being used properly in OptiX.

Maniphest Tasks: T104240

Differential Revision: https://developer.blender.org/D17162
2023-01-31 16:41:00 +01:00
Campbell Barton
79c82fc1c5 Cleanup: trailing space 2023-01-31 15:49:04 +11:00
Campbell Barton
27b4916b1a Cleanup: spelling in comments
Also minor changes in comments:
- Reference BLENDER_HISTORY_FILE instead of the literal file-name
  (simplifies looking up usage).
- Use usernames in tags, as noted in code-style.
2023-01-31 14:22:23 +11:00
Patrick Mours
129093fbce Cycles: Fix crash when rendering with OSL on multiple GPUs
The `MultiDevice` implementation of `get_cpu_osl_memory` returns a
nullptr when there is no CPU device in the mix. As such access to that
crashed in `update_osl_globals`. But that only updates maps that are not
currently used on the GPU anyway, so can just skip that when the CPU
is not used for rendering.

Maniphest Tasks: T104216
2023-01-30 19:40:22 +01:00
Jeroen Bakker
a36c1cabce Vulkan: Changes to CMake config.
Paths to vulkan libraries, paths and related components were
hardcoded in the platform cmake file. This patch separates
this by using adding CMake modules for Vulkan and ShaderC.

This change has only been applied to the macOs configuration as
that is currently our main platform for development. Other platforms
will be added during the development of the Vulkan back-end.
2023-01-30 12:04:44 +01:00
Patrick Mours
4635dd6aed Fix T104157: Deleting an active OSL node causes issues
Removing all OSL script nodes from the shader graph would cause that
graph to no longer report it using `KERNEL_FEATURE_SHADER_RAYTRACE`
via `ShaderManager::get_graph_kernel_features`, but the shader object
itself still would have the `has_surface_raytrace` field set.
This caused kernels to be reloaded without shader raytracing support, but
later the `DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE`
kernel would still be invoked since the shader continued to report it
requiring that through the `SD_HAS_RAYTRACE` flag set because of
`has_surface_raytrace`.
Fix that by ensuring `has_surface_raytrace` is reset on every shader update,
so that when all OSL script nodes are deleted it is set to false, and only
stays true when there are still OSL script nodes (or other nodes using it).

Maniphest Tasks: T104157

Differential Revision: https://developer.blender.org/D17140
2023-01-27 16:14:25 +01:00
Weizhen Huang
b898e00edc Cleanup: remove unused KernelGlobals in microfacet BSDF 2023-01-25 11:26:51 +01:00
Campbell Barton
adcb0edca0 Cleanup: clang-tidy, replace defines with enum, redundant parenthesis 2023-01-25 11:53:06 +11:00
Lukas Stockner
e308b891c8 Cycles: Use faster and exact GGX VNDF sampling algorithm
Based on "Sampling the GGX Distribution of Visible Normals" by Eric Heitz
(https://jcgt.org/published/0007/04/01/).

Also, this removes the lambdaI computation from the Beckmann sampling code and
just recomputes it below. We already need to recompute for two other cases
(GGX and clearcoat), so this makes the code more consistent.

In terms of performance, I don't expect a notable impact since the earlier
computation also was non-trivial, and while it probably was slightly more
accurate, I'd argue that being consistent between evaluation and sampling is
more important than absolute numerical accuracy anyways.

Differential Revision: https://developer.blender.org/D17100
2023-01-24 17:59:29 +01:00
Lukas Stockner
fdcb55b285 Cycles: Switch microfacet code to non-separable shadowing-masking term
This gives closer results to what I've seen in papers and other renderers when
using the code to precompute albedo later (to replace MultiGGX).

It's usually a tiny difference, the only case where I've seen it matter is
in the `shader/node_group_float.blend` test - but that's a (single-scatter) GGX
closure with 0.9 roughness, so it's not too surprising. In any case, the new
result looks closer to Eevee, so that's good I guess.

Differential Revision: https://developer.blender.org/D17099
2023-01-24 17:59:29 +01:00
Lukas Stockner
ce25e3e581 Cycles: Cleanup: Add general-purpose conversion between sin and cos 2023-01-24 17:59:29 +01:00
Xavier Hallade
1c90f8209d Cycles: fix rendering with Nishita Sky Texture on Intel Arc GPUs
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.
Increasing the precision of cosf fixes it.
2023-01-24 09:58:22 +01:00
Xavier Hallade
8afcecdf1f Cycles: update Intel Graphics compiler to 101.4032 on Windows
A noticeable (>5%) performance regression in oneAPI backend came with
a501a2dbff797829b61f21c5aeb9d19dba3e3874. Updating to latest graphics
compiler from driver 101.4032 fixes it.

I've tested it with current min-supported drivers and it runs well but
since compatibility of graphics compiler with older drivers isn't
guaranteed, I'm also bumping the min-supported driver versions.

If end-users consider latest drivers too fresh to switch to (version
isn't released as stable on Linux as of today but should be before
Blender 3.5 release), CYCLES_ONEAPI_ALL_DEVICES=1 env variable can be
used.

Intel Graphics Compiler on Linux will be updated in a later commit
so we can then close D16984.

Reviewed By: sergey, LazyDodo
2023-01-23 19:36:34 +01:00
Jason Fielder
84c25fdcaa Metal: Improve command buffer handling and workload scheduling.
Improve handling for cases where maximum in-flight command buffer count is exceeded. This can occur during light-baking operations. Ensures the application handles this gracefully and also improves workload pipelining by situationally stalling until GPU work has completed, if too much work is queued up.

This may have a tangible benefit for T103742 by ensuring Blender does not queue up too much GPU work.

Authored by Apple: Michael Parkin-White

Ref T96261
Ref T103742
Depends on D17018

Reviewed By: fclem

Maniphest Tasks: T103742, T96261

Differential Revision: https://developer.blender.org/D17019
2023-01-23 17:47:21 +01:00
Brecht Van Lommel
8e56ded86d Cycles: temporarily disable AMD Vega GPU rendering due to compiler bug
To make daily builds pass while we figure this out.

Ref T104097
2023-01-23 17:30:12 +01:00
Campbell Barton
537db96fb7 GHOST/NDOF: don't send button events when there is no active window
NDOF events without an active window were ignored and printed
warnings in the console.
2023-01-22 21:06:10 +11:00
Campbell Barton
cbd15d387f GHOST/Wayland: don't send activate/deactivate on pointer enter/leave
This isn't correct as window activation is handled separately
from the cursor entering/leaving a window.

This would call de-activate when the cursor moved outside the window
even though the window remained focused.

Rely on focus changes which already handle activate/deactivate events.
2023-01-21 23:09:22 +11:00
Brecht Van Lommel
37dfce550f Fix Cycles CUDA compiler warning with if constexpr
This is a C++17 feature, compiler should be able to figure this out
without the hint.
2023-01-20 20:31:40 +01:00
Thomas Dinges
f31f7e3ef0 Cleanup: Remove unused light_sample_is_light() function.
This also fixes compile warnings on MSVC.
2023-01-20 17:36:48 +01:00
Campbell Barton
721bd5e6cf Fix invalid swapBuffer calls & outdated window decorations on Wayland
Swap-buffers was being deferred (to prevent it being called
from the event handling thread) however when it was called the
OpenGL context might not be active (especially with multiple windows).

Moving the cursor between windows made eglSwapBuffers report:
EGL Error (0x300D): EGL_BAD_SURFACE.

Resolve this by removing swapBuffer calls and instead add a
GHOST_kEventWindowUpdateDecor event intended for redrawing
client-side-decoration.

Besides the warning, this results an error with LIBDECOR window frames
not redrawing when a window became inactive.
2023-01-20 18:05:52 +11:00
Campbell Barton
844cca9984 Cleanup: spelling in comments 2023-01-20 15:19:32 +11:00
Jeffrey Liu
05bdef7ce6 Fix T103094: Cycles ignores small suns in Nishita sky
The background evaluation samples the sky discretely, so if the sun is
too small, it can be missed in the evaluation. To solve this, the sun is
ignored during the background evaluation and its contribution is
computed separately.
2023-01-19 18:31:54 -06:00
Brecht Van Lommel
fe552bf236 Cleanup: make format 2023-01-19 22:48:05 +01:00
Brecht Van Lommel
670b3c5013 Cleanup: compiler warnings 2023-01-19 22:48:05 +01:00
Weizhen Huang
f71bfe4655 Fix anisotropic Beckmann regression test failing on Metal
The lookup table method on CPU and the numerical root finding method on
GPU give quite different results. This commit deletes the Beckmann lookup
table and uses numerical root finding on all devices. For the numerical
root finding, a combined bisection-Newton method with precision control
is used.

Differential Revision: https://developer.blender.org/D17050
2023-01-19 20:12:05 +01:00
Patrick Mours
9066f2e043 Cycles: Add support for OSL texture intrinsic on the GPU
This makes it possible to use `texture` and `texture3d` in custom
OSL shaders with a constant image file name as argument on the
GPU, where previously texturing was only possible through Cycles
nodes.
For constant file name arguments, OSL calls
`OSL::RendererServices::get_texture_handle()` with the file name
string to convert it into an opaque handle for use on the GPU.
That is now used to load the respective image file using the Cycles
image manager and generate a SVM handle that can be used on
the GPU. Some care is necessary as the renderer services class is
shared across multiple Cycles instances, whereas the Cycles image
manager is local to each.

Maniphest Tasks: T101222

Differential Revision: https://developer.blender.org/D17032
2023-01-19 19:14:48 +01:00
Michael Jones
e270a198a5 Cycles: Markup to disable specialisation of kernel data fields (Metal)
This patch adds markup to specify that certain kernel data constants should not be specialised. Currently it is used for `tabulated_sobol_sequence_size` and `sobol_index_mask` which change frequently based on the aa sample count, trash the shader cache, and have little bearing on performance.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16968
2023-01-19 17:57:42 +00:00
Michael Jones
08b3426df9 Cycles: Occupancy tuning for new higher end M2 machines
This patch adds occupancy tuning for the newly announced high-end M2 machines, giving 10-15% render speedup over a pre-tuned build.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D17037
2023-01-19 17:56:40 +00:00
Weizhen Huang
9b7c2cca3d Refactor: replace bool beckmann with enum MicrofacetType for readability
Differential Revision: https://developer.blender.org/D17044
2023-01-19 15:55:07 +01:00
Weizhen Huang
320757bc61 Refactor microfacet BSDF to reduce repetition 2023-01-19 12:07:53 +01:00
Weizhen Huang
eb657633ed Fix anisotropic Beckmann using isotropic sampling 2023-01-19 11:22:16 +01:00
Campbell Barton
66dee44088 CMake: quiet references to undeclared variable warnings
These warnings can reveal errors in logic, so quiet them by checking
if the features are enabled before using variables or by assigning
empty strings in some cases.

- Check CMAKE_THREAD_LIBS_INIT is set before use as CMake docs
  note that this may be left unset if it's not needed.
- Remove BOOST/OPENVDB/VULKAN references when disable.
- Define INC_SYS even when empty.
- Remove PNG_INC from freetype (not defined anywhere).
2023-01-19 17:10:42 +11:00
Campbell Barton
8b7d2d8eb2 CMake: use BULLET_LIBRARIES for both extern_bullet and system libraries
There was no need to differentiate between these and it made
the CMake files more verbose.
2023-01-19 17:10:42 +11:00
Campbell Barton
c2120b8c4f CMake: suppress missing-variable-declarations warnings with Clang
Code generated by wayland-scanner contained missing declarations.
2023-01-19 17:10:42 +11:00
Campbell Barton
9676dce317 Cleanup: CMake indentation 2023-01-19 17:10:42 +11:00
Brecht Van Lommel
e8d1d1486e Fix T103960: build issue with GCC 13 in Cycles thread code 2023-01-18 16:43:47 +01:00
Weizhen Huang
6e6ae17335 Fix reversed cosNI and cosNO in Cycles anisotropic beckmann G1 2023-01-18 13:10:45 +01:00
Weizhen Huang
543bf28fb1 Refactor: renamed I -> wi, omega_in -> wo in Cycles
wi is the viewing direction, and wo is the illumination direction. Under this notation, BSDF sampling always samples from wi and outputs wo, which is consistent with most of the papers and mitsuba. This order is reversed compared with PBRT, although PBRT also traces from the camera.
2023-01-17 18:07:13 +01:00
Brecht Van Lommel
93ca4eeec1 Cleanup: remove unused functions 2023-01-16 19:40:25 +01:00
Brecht Van Lommel
a84a8a528d Cycles: remove SSE3 and AVX kernel optimization levels
While keeping SSE2, SSE4.1 and AVX2. This does not affect hardware support, it
only slightly reduces performance for some older CPUs.

To reduce maintenance cost and improve compile times.

Differential Revision: https://developer.blender.org/D16978
2023-01-16 17:53:36 +01:00
Campbell Barton
5cbc8ce3b1 Fix ASAN error when Wayland fell back to X11
An alternative fix to [0] which caused an error with ASAN
(freeing an GHOST_ISystem instead of a GHOST_System).
Reported by @Baardaap in chat, I'm unable to reproduce the issue.

Instead of calling the destructor directly, add a private method that
deletes data before raising an exception.

[0]: fd36221930e35efd2c09af8fb91234a510e3b9dc
2023-01-16 15:29:22 +11:00
Campbell Barton
33c30af742 Cleanup: comments in struct declarations
Use a consistent style for declaring the names of struct members
in their declarations. Note that this convention was already used in
many places but not everywhere.

Remove spaces around the text (matching commented arguments) with
the advantage that the the spell checking utility skips these terms.
Making it possible to extract & validate these comments automatically.

Also use struct names for `bAnimChannelType` & `bConstraintTypeInfo`
which were using brief descriptions.
2023-01-16 13:27:35 +11:00
Campbell Barton
0c2a3054ba Fix high CPU use when idle under Wayland
Recently the event handling thread for Wayland sometimes used 100% of a
CPU core while idle.

Resolve by waiting for changes to the Wayland file-handle when
there are no events to read.
2023-01-13 17:48:52 +11:00
Campbell Barton
bbe7183cd3 GHOST/Wayland: fix threaded event handling
The previous fix from T100855 [0] no longer works on my system
(3.4.1 release also fails for GNOME/KDE/WLROOTS compositors).

Resolve by removing the loop from the wait-on-file handle check.
Also reduce locking/unlocking calls.

[0]: 37b256e26feb454d9febd84dac1b1ce8b8d84d90
2023-01-13 17:48:50 +11:00
Jeroen Bakker
eeff49a3b1 macOS: Replace PboardTypes with PasteboardTypes.
Related to {T103758}.

- NSStringPboardType is replaced by NSPasteboardTypeString
- NSTIFFPboardType is replaced by NSPasteboardTypeTIFF
2023-01-12 08:48:48 +01:00
Jeroen Bakker
3590e263e0 macOS: Remove user notifications.
User notifications in Blender were always annoying and therefore by default turned off.
- When tweaking compositor/material tree a notification was shown.
- When rendering an animation for each frame a notification was shown.

The reason for this was that it was automatically shown when a background job was
finished and Blender wasn't the top most application.

In stead of migrating user notification to UserNotification.framework it was decided
to remove it for now. If in the future notifications should be added back we should
start with a design to figure out where notifications makes sense.

Reviewed By: sergey, brecht

Maniphest Tasks: T103757

Differential Revision: https://developer.blender.org/D16955
2023-01-12 08:39:56 +01:00
Lukas Stockner
2b4bf586ad Fix T102920: Cycles doesn't support multiple outputs on muted nodes
Cycles converts internal links to converter nodes which don't do anything and
later on get collapsed by the graph optimization. However, the previous code
assumed that one Blender input socket maps to one Cycles input socket.

When a node is muted, there might be internal links from one input to multiple
outputs. In Cycles, this meant that one Blender input socket now mapped to
multiple input sockets on all the converter nodes, so only the last one survived.

THe fix is simple, just make the mapping a MultiMap.
2023-01-12 00:53:05 +01:00
Lukas Stockner
ff86573d72 Fix T102313: Enabling shadow catcher in viewport render shows self-shadowing
The problem here is that whether an object is a shadow catcher or not affects the
visibility flags, but changes to the shadow catcher property did not trigger a
visibility flag update.
2023-01-11 21:36:46 +01:00
Brecht Van Lommel
df5ebd348b Fix T103556: Cycles viewport unexpected pixel changes when hovering over UI
With the GPU API the sampler can not be set after texture binding, which caused
a delay of the actual change. Now do both in a single call for correctness and
performance.
2023-01-10 16:35:19 +01:00
Jeroen Bakker
387fc9b40b MacOS: Silence OpenGL deprecation warnings.
OpenGL is deprecated by Apple and triggers a warning when used. The goal
is that OpenGL is replaced by Metal backend, but we are not there yet.

To improve tracability of new warnings we hide deprecation warnings
when the GHOST_ContextCGL.h file is included.

NOTE: This change silences other deprecation warnings as well.
2023-01-10 14:57:23 +01:00
Campbell Barton
ed66321996 GHOST/Wayland: simplify logic for disconnecting monitors under Wayland
The T103586 fix effectively ran the wl_surface_listener.leave callback
to as WLROOTS based compositors doesn't run them. Remove the workaround
since it's an error in WLROOTS to be fixed upstream.

Temporarily using the wrong window scale when disconnecting a monitor
on configurations that use different DPI per monitor is a minor enough
issue that I don't think it makes sense to workaround in GHOST.
2023-01-10 17:50:29 +11:00
Campbell Barton
fdcbad37be Fix window creation with Hi-DPI exiting under Wayland
Wayland requires the windows surface size is divisible by the surface
scale. This wasn't guaranteed when creating new temporary windows.

This meant opening the preferences could exit Blender with an error
with Hi-DPI configurations.
2023-01-10 16:27:11 +11:00
Hans Goudey
1af62cb3bf Mesh: Move positions to a generic attribute
**Changes**
As described in T93602, this patch removes all use of the `MVert`
struct, replacing it with a generic named attribute with the name
`"position"`, consistent with other geometry types.

Variable names have been changed from `verts` to `positions`, to align
with the attribute name and the more generic design (positions are not
vertices, they are just an attribute stored on the point domain).

This change is made possible by previous commits that moved all other
data out of `MVert` to runtime data or other generic attributes. What
remains is mostly a simple type change. Though, the type still shows up
859 times, so the patch is quite large.

One compromise is that now `CD_MASK_BAREMESH` now contains
`CD_PROP_FLOAT3`. With the general move towards generic attributes
over custom data types, we are removing use of these type masks anyway.

**Benefits**
The most obvious benefit is reduced memory usage and the benefits
that brings in memory-bound situations. `float3` is only 3 bytes, in
comparison to `MVert` which was 4. When there are millions of vertices
this starts to matter more.

The other benefits come from using a more generic type. Instead of
writing algorithms specifically for `MVert`, code can just use arrays
of vectors. This will allow eliminating many temporary arrays or
wrappers used to extract positions.

Many possible improvements aren't implemented in this patch, though
I did switch simplify or remove the process of creating temporary
position arrays in a few places.

The design clarity that "positions are just another attribute" brings
allows removing explicit copying of vertices in some procedural
operations-- they are just processed like most other attributes.

**Performance**
This touches so many areas that it's hard to benchmark exhaustively,
but I observed some areas as examples.
* The mesh line node with 4 million count was 1.5x (8ms to 12ms) faster.
* The Spring splash screen went from ~4.3 to ~4.5 fps.
* The subdivision surface modifier/node was slightly faster
RNA access through Python may be slightly slower, since now we need
a name lookup instead of just a custom data type lookup for each index.

**Future Improvements**
* Remove uses of "vert_coords" functions:
  * `BKE_mesh_vert_coords_alloc`
  * `BKE_mesh_vert_coords_get`
  * `BKE_mesh_vert_coords_apply{_with_mat4}`
* Remove more hidden copying of positions
* General simplification now possible in many areas
* Convert more code to C++ to use `float3` instead of `float[3]`
  * Currently `reinterpret_cast` is used for those C-API functions

Differential Revision: https://developer.blender.org/D15982
2023-01-10 00:10:43 -05:00
Lukas Stockner
39c30f6983 Cycles: Account for negative scale when using one-sided light tree sampling
Differential Revision: https://developer.blender.org/D16952
2023-01-10 02:55:52 +01:00
Lukas Stockner
c41601becd Fix T89037: Cycles: Backfacing node can be wrong for lights with negative scale
When rendering in the viewport (or probably on instanced objects, but I didn't
test that), emissive objects whose scale is negative give the wrong value on the
"backfacing" input when multiple sampling is enabled.

The underlying problem was a corner case in how normal transformation is handled,
which is generally a bit messy.

From what I can tell, the pattern appears to be:
- If you first transform vertices to world space and then compute the normal from
  them (as triangle light samping, MNEE and light tree do), you need to flip
  whenever the transform has negative scale regardless of whether the transform
  has been applied
- If you compute the normal in object space and then transform it to world space
  (as the regular shader_setup_from_ray path does), you only need to flip if the
  transform was already applied and was negative
- If you get the normal from a local intersection result (as bevel and SSS do),
  you only need to flip if the transform was already applied and was negative
- If you get the normal from vertex normals, you don't need to do anything since
  the host-side code does the flip for you (arguably it'd be more consistent to
  do this in the kernel as well, but meh, not worth the potential slowdown)

So, this patch fixes the logic in the triangle emission code.

Also, turns out that the MNEE code had the same problem and was also having
problems in the viewport on negative-scale objects, this is also fixed now.

Differential Revision: https://developer.blender.org/D16952
2023-01-10 02:55:23 +01:00
Lukas Stockner
317a5f61f0 Cycles: Fix recently introduced off-by-one error in an assert
This was added in rB95696d09bc07, but I got the index wrong.
2023-01-10 02:10:20 +01:00
Brecht Van Lommel
b314d92e7d Fix T102942: Cycles wrong alpha for multi-layer PSD files 2023-01-09 19:05:24 +01:00
Bastien Montagne
4887401789 Usual UI messages and i18n fixes and tweaks. 2023-01-09 09:20:37 +01:00
Campbell Barton
63c985e0f7 Cleanup: format 2023-01-09 18:56:54 +11:00
Lukas Stockner
4546e35c92 Fix T95244: Cycles produces incorrect AO pass for shadow catchers
Differential Revision: https://developer.blender.org/D16951
2023-01-09 03:55:10 +01:00
Lukas Stockner
95696d09bc Fix T88849: Motion blur in cycles leaves bright edge on trailing end of blur
The code that computes and inverts the shutter CDF had some issues that caused
the result to be asymmetric, this tweaks it to be more robust and produce
symmetric outputs for symmetric inputs.
2023-01-09 03:08:36 +01:00
Lukas Stockner
e7a554e551 Fix T94698: Cycles: Volume-scattered light is always counted as diffuse
At the first bounce, the diffuse/glossy/transmission weights are stored so that
contributions along the path can be split into the d/g/t indirect passes.

However, volume bounces always set the weight even at indirect bounces, so
even paths that had their first bounce on a purely glossy object would suddenly
start counting towards the diffuse indirect pass after a secondary volume bounce.
2023-01-08 23:09:37 +01:00
Lukas Stockner
2895c67086 Fix T103408: Cycles deadlock during GPU viewport rendering
This was caused by rB0d73d5c1a2, which releases the scene mutex during kernel
loading. However, the reset mutex was still held, which can cause a deadlock
if another thread tries to reset the session, since it will acquire the
released scene mutex and then wait for the reset mutex.

Turns out there's no point in keeping the reset mutex locked after the delayed
reset section, so now we just release it earlier, which resolves the deadlock.
2023-01-07 20:33:32 +01:00
Philipp Oeser
940fd87e77 Fix T103615: OSL image box mapping has flipped textures
This breaks backwards compatibility some in that 3 sides will be mapped
differently now, but difficult to avoid and can be considered a bugfix.

Similar to rBdd8016f7081f.

Maniphest Tasks: T103615

Differential Revision: https://developer.blender.org/D16910
2023-01-06 19:21:33 +01:00
Jacques Lucke
ae7163007d Allocator: improve protection against false sharing
On Apple Silicon, the cache line size is 128 bytes.
2023-01-06 13:04:49 +01:00
Campbell Barton
14fc02f91d Cleanup: spelling in comments 2023-01-06 14:00:36 +11:00
Lukas Stockner
00a20aec07 Fix T103403: Lightgroup passes can contain lighting on shadow catchers 2023-01-06 02:33:22 +01:00
Lukas Stockner
bc5337a05a Fix T103507: Distant lights partially contribute to wrong lightgroup
The the BSDF-sampling half of MIS next-event estimation for distant lights was
using the background lightgroup instead of the lamp's lightgroup.
2023-01-06 01:40:44 +01:00
Brecht Van Lommel
87f7b630b5 Cleanup: make format 2023-01-05 19:43:19 +01:00
Brecht Van Lommel
084b52bcd8 Cycles: take into account IES texture node strength input for light tree
To better estimate light contribution. Note that estimating the texture
from the IES file is still missing.

Contributed by Alaska.

Differential Revision: https://developer.blender.org/D16901
2023-01-05 19:43:19 +01:00
Jacques Lucke
862d08bb97 Fix: use-after-free when threadlocal is destructed after static variable
This issue was introduced in rB78f28b55d39288926634d0cc.

The fix is to use a `std::shared_ptr` to ensure that the `Global` will live
long enough until all `Local` objects are destructed.
2023-01-05 14:38:34 +01:00
Michael Jones
a7cc6e015c Cycles: Additional Metal kernel specialisation exposed through UI
This patch adds a new "Kernel Optimization Level" dropdown menu to control Metal kernel specialisation. Currently this defaults to "full" optimisation, on the assumption that the changes proposed in D16371 will address usability concerns around app responsiveness and shader cache housekeeping.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16514
2023-01-04 23:36:52 +00:00
Chris Blackbourn
496d736adc Cleanup: format 2023-01-05 11:21:51 +13:00
Jacques Lucke
2540a52f91 Cleanup: quiet unused parameter warning 2023-01-04 17:30:55 +01:00
Michael Jones
77c3e67d3d Cycles: Improved render start/stop responsiveness on Metal
All kernel specialisation is now performed in the background regardless of kernel type, meaning that the first render will be visible a few seconds sooner. The only exception is during benchmark warm up, in which case we wait for all kernels to be cached. When stopping a render, we call a new `cancel()` method on the device which causes any outstanding compilation work to be cancelled, and we destroy the device in a detached thread so that any stale queued compilations can be safely purged without blocking the UI for longer than necessary.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16371
2023-01-04 16:00:53 +00:00
Sebastian Parborg
79837c5ed4 Fix building with boost >= 1.81
In boost 1.81 they no longer implicitly include <iostream> anymore.
2023-01-04 15:23:26 +01:00
Jacques Lucke
78f28b55d3 Allocator: improve multi-threaded allocation performance
Both, the guarded and lockfree allocator, are keeping track of current
and peak memory usage. Even the lockfree allocator used to use a
global atomic variable for the memory usage. When multiple threads
use the allocator at the same time, this variable is highly contended.
This can result in significant slowdowns as presented in D16862.

While specific cases could always be optimized by reducing the number
of allocations, having this synchronization point in functions used by
almost every part of Blender is not great.

The solution is use thread-local memory counters which are only added
together when the memory usage is actually requested. For more details
see in-code comments and D16862.

Differential Revision: https://developer.blender.org/D16862
2023-01-04 14:55:46 +01:00
Jacques Lucke
c9ab76db5c Cleanup: don't use designated initializers in c++
This is a c++20 feature.
2023-01-04 12:31:59 +01:00
Brecht Van Lommel
d28588f31e Cleanup: compiler warning on Arm with sse2neon
Reorder includes to avoid BLI_simd.h redefining SSE2NEON_PRECISE macros.
2023-01-04 11:20:02 +01:00
Brecht Van Lommel
32b861b14a Cleanup: fix deprecation warnings after OpenImageIO upgrade 2023-01-04 11:20:02 +01:00
Campbell Barton
cdd07ddb93 Cleanup: move doc-string to header 2023-01-04 16:06:42 +11:00
Campbell Barton
cbd12e730a Fix T103586: Crash removing monitor under Wayland & WLROOTS compositors
WLROOTS compositors don't run surface leave callbacks,
while this may be considered a bug in WLROOTS, neither GTK/SDL crash
so workaround the crash too.

This also fixes a minor glitch where the cursor scale wasn't updated
when changing monitor scale at run-time.
2023-01-04 16:04:12 +11:00
Campbell Barton
50dbedf0d8 GHOST/Wayland: add missing call to destroy xdg_output
Match logic from SDL.
2023-01-04 16:04:12 +11:00
Nikita Sirgienko
858fffc2df Cycles: oneAPI: add support for SYCL host task
This functionality is related only to debugging of SYCL implementation
via single-threaded CPU execution and is disabled by default.
Host device has been deprecated in SYCL 2020 spec and we removed it
in 305b92e05f748a0fd9cb62b9829791d717ba2d57.
Since this is still very useful for debugging, we're restoring a
similar functionality here through SYCL 2020 Host Task.
2023-01-03 20:47:24 +01:00
Patrick Mours
153e1dc31a Fix T103513: Images lose their alpha channel when OSL is enabled for GPU Compute
The "osl_texture" intrinsic was not implemented correctly. It should handle alpha
separately from color, the number of channels input parameter only counts color
channels.
2023-01-02 13:52:59 +01:00
Aaron Carlisle
4701421dbe UI: Remove unused light object panel (Correction)
This panel showed a duplication of options that were in the main light panel and only mistakenly shows up in the workbench engine where lights should have no options.

This panel was also used by the POV-Ray add-on but that was removed recently.
2022-12-23 19:06:29 -05:00
Lukas Stockner
4c295276f0 Cycles: Fix Metal kernel compilation 2022-12-21 04:24:22 +01:00
Germano Cavalcante
1a986f7eba Revert "Fix erratic mouse wrapping movement on Windows (2)"
This reverts commit a3a9459050a96e75138b3441c069898f211f179c.

And fixes T103337.

a3a9459050a9 has some flaws and it needs to go through review (See D16803).

Conflicts:
	intern/ghost/intern/GHOST_SystemWin32.cpp
2022-12-19 10:41:05 -03:00
Campbell Barton
0cc573c8c4 Cleanup: white space around comment blocks 2022-12-17 15:58:30 +11:00
Campbell Barton
2ac6e26c25 Cleanup: cmake formatting 2022-12-17 13:33:27 +11:00
Campbell Barton
6797de4e10 Cleanup: spelling in comments 2022-12-17 13:15:33 +11:00
Lukas Stockner
347c82be6d Fix T98951: Shadow catcher objects are double-counting data passes
Differential Revision: https://developer.blender.org/D16627
2022-12-17 01:45:07 +01:00
Lukas Stockner
7c85f11c42 Cycles: Change bake jittering to avoid issues with skinny triangles
Partially addresses T72011.

The problem here is that the previous barycentric clamping did not deal well
with skinny triangles and would end up generating "sub-pixel jittering"
locations that were actually >20 pixels away.

Differential Revision: https://developer.blender.org/D16727
2022-12-17 01:16:14 +01:00
Charlie Jolly
bea5fe6505 Nodes: Add Exclusion color mix mode
Expands Color Mix nodes with new Exclusion mode.

Similar to Difference but produces less contrast.

Requested by Pierre Schiller @3D_director and
@OmarSquircleArt on twitter.

Differential Revision: https://developer.blender.org/D16543
2022-12-16 15:42:41 +00:00
Patrick Mours
a8530d31c2 Fix T103258: Deleting a shader with OptiX OSL results in an illegal address error
Materials without connections to the output node would crash with OSL
in OptiX, since the Cycles `OSLCompiler` generates an empty shader
group reference for them, which resulted in the OptiX device
implementation setting an empty SBT entry for the corresponding direct
callables, which then crashed when calling those direct callables was
attempted in `osl_eval_nodes`. This fixes that by setting the SBT entries
for empty shader groups to a dummy direct callable that does nothing.
2022-12-16 15:41:21 +01:00
Patrick Mours
c9eb583460 Fix T103257: Enabling or disabling viewport denoising while using OptiX OSL results in an error
Switching viewport denoising causes kernels to be reloaded with a new
feature mask, which would destroy the existing OptiX pipelines. But OSL
kernels were not reloaded as well, leaving the shading pipeline
uninitialized and therefore causing an error when it is later attempted to
execute it. This fixes that by ensuring OSL kernels are always reloaded
when the normal kernels are too.
2022-12-16 14:04:03 +01:00
Campbell Barton
79a34758f5 Fix T103253: Infinite drag of number buttons is broken on WIN32
Recent reverting of changes to cursor grabbing intended to match
Blender 3.3 release. This is the case for 3.4x branch, however there is
an additional change to grabbing on WIN32 by Germano [0] which is a
significant improvement on old grabbing logic for Windows.
So instead of matching 3.3x behavior, restore logic that keeps
the cursor centered while grabbing & hidden.

This re-introduces T102792 issue displaying the paint-brush while
dragging buttons, this will have to be solved separately.

Re-apply [1] & [2], revert [3] & [4].

[4]: a3a9459050a96e75138b3441c069898f211f179c
[0]: 9fd6dae7939a65b67045749a0eadeb6864ded183
[1]: 4cac8025f00798938813f52dcb117be83db97f22
[2]: 230744d6fd96dcf5afe66a8f9b9f6f8bbe1f41bb
[3]: 0240b895994aa58258db6897ae0d6478da7fce5f
2022-12-16 18:38:22 +11:00
Campbell Barton
2c22795dfd Build: upgrade pre-built libraries for Linux
Replace ../lib/linux_centos7_x86_64 with ../lib/linux_x86_64_glibc_228,
built with Rocky8 Linux, compatible with the VFX platform CY2023,
see: T99618.

- Update build-bot configuration.
- Remove unnecessary check for Blosc, this is part of OpenVDB lib now.
- Remove WITH_CXX11_ABI, always use new C++11 ABI now
- Replace centos7 by glibc_228 everywhere

Note that existing builds with cached paths pointing to
"../lib/linux_centos7_x86_64" will need to be updated.

Includes contributions by Brecht.
2022-12-16 10:42:40 +11:00
Brecht Van Lommel
3d29bbcc38 Fix T103049: Cycles specular light leak regression
The logic here is not ideal but was unintentionally changed in refactoring
for path guiding, now restore it back to 3.3 behavior again.
2022-12-15 21:49:59 +01:00
Brecht Van Lommel
62f8d0d8c8 Fix T103170: missing Cycles viewport light threshold update after exposure edit 2022-12-15 19:13:55 +01:00
Thomas Dinges
ba347d7c9e Fix Cycles UI for Scrambling Distance, only works with Tabulated Sobol.
Thanks to Alaska for finding this.
2022-12-15 10:44:56 +01:00
Thomas Dinges
69d1ddd4c6 Fix Cycles Light Tree UI after recent changes. 2022-12-15 10:25:06 +01:00
Campbell Barton
7571222a69 Cleanup: add trailing commas for multi-line collections
Avoid accidentally missing commas between strings, see: T101020.
Also use single quotes for enum identifiers.
2022-12-15 17:34:09 +11:00
Campbell Barton
18cc1b1108 Fix cursor warping display under Wayland
Under Wayland the transform cursor wasn't displaying the warped cursor.

This worked on other platforms because cursor motion is warped where as
Wayland simulates cursor warping, so it's necessary to apply warping
when requesting the cursor location too.
2022-12-15 15:22:52 +11:00
Campbell Barton
d715573aea Cleanup: declare GHOST_Window::getCursorGrabBounds as const
Needed so it the method can be called on a cosnt GHOST_Window.
2022-12-15 15:10:51 +11:00
Campbell Barton
b147af2b7e Cleanup: remove duplicate doc-strings 2022-12-15 14:56:58 +11:00
Campbell Barton
230744d6fd Revert "Fix T102346: Mouse escapes window during walk navigation"
This reverts commits
9fd6dae7939a65b67045749a0eadeb6864ded183,
4cac8025f00798938813f52dcb117be83db97f22 (minor cleanup).

Re-introducing T102346, which will be fixed in isolation.

Unfortunately even when the cursor is hidden & grabbed,
the underlying cursor coordinates are still shown in some cases.

This caused bug where dragging a button in the sculpt-context popup
would draw the brush at unexpected locations because internally
the cursor was warping in the middle of the window, reported as T102792.

Resolving this issue with the paint cursor is possible but tend towards
over-complicated solutions.

Revert this change in favor of a more localized workaround for walk-mode
(as was done prior [0] to fix T99021).

[0]: 4c4e8cc926a672ac60692b3fb8c20249f9cae679
2022-12-15 12:15:23 +11:00
Germano Cavalcante
a3a9459050 Fix erratic mouse wrapping movement on Windows (2)
This is a solution in response to the issues mentioned in comments on
rBe4f1d719080a and T103088.

Apparently the workaround of checking if the mouse is already inside
the area on the next event doesn't work for some tablets.

Perhaps the order of events or some very small jitter is causing this
issue on tablets. (Couldn't confirm).

Whatever the cause, the solution of checking the timestamp of the event
and thus ignoring the outdated ones is theoretically safer.

It is the same solution seen in MacOS.

Also calling `SendInput` 3 times every warp ensures that at least one
event is dispatched.
2022-12-14 16:08:21 -03:00
Hallam Roberts
a501a2dbff Images: add mirror extension type
This adds a new mirror image extension type for shaders and
geometry nodes (next to the existing repeat, extend and clip
options).

See D16432 for a more detailed explanation of `wrap_mirror`.

This also adds a new sampler flag `GPU_SAMPLER_MIRROR_REPEAT`.
It acts as a modifier to `GPU_SAMPLER_REPEAT`, so any `REPEAT`
flag must be set for the `MIRROR` flag to have an effect.

Differential Revision: https://developer.blender.org/D16432
2022-12-14 19:27:29 +01:00
Brecht Van Lommel
8c14992db2 Fix syntax errors in Cycles float8 test 2022-12-14 19:01:42 +01:00
Brecht Van Lommel
77a4ab3ccf Fix wrong syntax in Cycles float8 test fix 2022-12-14 18:36:48 +01:00
Hans Goudey
9fd834fbb3 Fix T103143: Cycles can lose default color attribute
The `render_color_index` skips attributes with different types
and domains in order to give the proper order for the UI list.
That is a different than an index in the group of all attributes.

The most solid solution I could think of is exposing the name of
the default color attribute. It's "solid" because we always address
attributes by name internally. Doing something different is bound
to create problems. It's also aligned with the design in T98366 and
D15169.

Another option would be to change the way the "attribute index"
is incremented in Cycles. That would be a valid solution, but would
be more complex and annoying.

For consistency, I also exposed the name of the active color attribute
the same way, though it isn't necessary to fix this particular bug.

The properties aren't editable, that can come in 3.5 as part of D15169.

Differential Revision: https://developer.blender.org/D16769
2022-12-14 11:26:11 -06:00
Nathan Vegdahl
d9192aaa6d Cycles: limit the internal sample index of Sobol-Burley for performance
This is done based on the render sample count so that it doesn't impact
sampling quality. It's similar in spirit to the adaptive table size in D16561,
but in this case for performance rather than memory usage.

Differential Revision: https://developer.blender.org/D16726
2022-12-14 17:39:13 +01:00
Nathan Vegdahl
b0cc8e8dde Cycles: switch from pretabulated 2D PMJ02 to pretabulated 4D Sobol
The first two dimensions of scrambled, shuffled Sobol and shuffled PMJ02 are
equivalent, so this makes no real difference for the first two dimensions.
But Sobol allows us to naturally extend to more dimensions.

Pretabulated Sobol is now always used, and the sampling pattern settings is now
only available as a debug option.

This in turn allows the following two things (also implemented):

* Use proper 3D samples for combined lens + motion blur sampling. This
  notably reduces the noise on objects that are simultaneously out-of-focus
  and motion blurred.
* Use proper 3D samples for combined light selection + light sampling.
  Cycles was already doing something clever here with 2D samples, but using
  3D samples is more straightforward and avoids overloading one of the
  dimensions.

In the future this will also allow for proper sampling of e.g. volumetric
light sources and other things that may need three or four dimensions.

Differential Revision: https://developer.blender.org/D16443
2022-12-14 17:39:13 +01:00
Brecht Van Lommel
ecfcf1b97b Cycles: disable light tree for existing scenes, enable on new scenes
While it helps on many scenes, it can be disruptive for existing scenes and
for benchmarks the differences in timing can be confusing. So be a bit more
conservative and only it enable it for new scenes.
2022-12-14 17:39:13 +01:00
Brecht Van Lommel
2221cfc044 Cleanup: GCC compiler warnings in Cycles float8 test 2022-12-14 17:39:13 +01:00
Germano Cavalcante
fe3110a285 Fix FallbackCyclesBlitShader compilation error
Error: C0204: version directive must be first statement and may not be
repeated
2022-12-14 11:59:40 -03:00
Patrick Mours
c30fdb9cf5 Fix mismatching PTX function declarations for OSL intrinsics with string parameters
The use of a struct for device strings caused the CUDA compiler to
generate byte arrays as the argument type, whereas OSL generated
primitive integer types (for the hash). Fix that by using a typedef
instead so that the CUDA compiler too will use an integer type in the
PTX it generates.

Maniphest Tasks: T101222
2022-12-14 15:23:27 +01:00
Campbell Barton
fd36221930 GHOST/Wayland: fix memory leak when Wayland fails to start 2022-12-14 17:09:55 +11:00
Harley Acheson
93a629f147 Fix T103119: Allow Win32 Diacritical Composition
Allow keyboard layouts which include "dead keys" to enter diacritics
by calling MapVirtualKeyW even when not key_down.

See D16770 for more details.

Differential Revision: https://developer.blender.org/D16770

Reviewed by Campbell Barton
2022-12-13 18:30:20 -08:00
Hans Goudey
75ad8da1ea Refactor: Replace old Mesh edge split implementation
Recently a new geometry node for splitting edges was added in D16399.
However, there was already a similar implementation in mesh.cc that was
mainly used to fake auto smooth support in Cycles by splitting sharp
edges and edges around sharp faces.

While there are still possibilities for optimization in the new code,
the implementation is safer and simpler, multi-threaded, and aligns
better with development plans for caching topology on Mesh and other
recent developments with attributes.

This patch removes the old code and moves the node implementation to
the geometry module so it can be used in editors and RNA. The "free
loop normals" argument is deprecated now, since it was only an internal
optimization exposed for Cycles.

The new mesh `editors` function creates an `IndexMask` of edges to
split by reusing some of the code from the corner normal calculation.

This change will help to simplify the changes in D16530 and T102858.

Differential Revision: https://developer.blender.org/D16732
2022-12-13 18:40:06 -06:00
Jacques Lucke
b50c475cd2 Cleanup: move listbase.c to c++ 2022-12-13 18:13:10 +01:00
Weizhen Huang
f56488c20f Fix Cycles ellipse area light returns zero pdf in volume segment 2022-12-12 21:38:23 +01:00
Weizhen Huang
e378bd70ed Cleanup: remove code duplication in cycles light sampling
There has been an attempt to reorganize this part, however, it seems that didn't compile on HIP, and is reverted in
rBc2dc65dfa4ae60fa5d2c3b0cfe86f99dcb5bf16f. This is another attempt of refactoring. as I have no idea why some things don't work on HIP, it's
best to check whether this compiles on other platforms.
The main changes are creating a new struct named `MeshLight` that is shared between `KernelLightDistribution` and `KernelLightTreeEmitter`,
and a bit of renaming, so that light sampling with or without light tree could call the same function.
Also, I noticed a patch D16714 referring to HIP compilation error. Not sure if it's related, but browsing
https://builder.blender.org/admin/#/builders/30/builds/7826/steps/7/logs/stdio, it didn't work on gfx1102, not gfx9*.

Differential Revision: https://developer.blender.org/D16722
2022-12-12 21:25:09 +01:00
Brecht Van Lommel
e4f9c50928 Fix T102990: OpenVDB files load very slow from network drives
The OpenVDB delay loading of voxel leaf data using mmap works poorly on network
drives. It has a mechanism to make a temporary local file copy to avoid this,
but we disabled that as it leads to other problems.

Now disable delay loading entirely. It's not clear that this has much benefit
in Blender. For rendering we need to load the entire grid to convert to NanoVDB,
and for geometry nodes there also are no cases where we only need part of grids.
2022-12-12 18:28:09 +01:00
Brecht Van Lommel
95a792a633 Fix wrong Cycles standalone exposure default value, should be 1 2022-12-12 18:28:09 +01:00
Brecht Van Lommel
f53bd17836 Cycles: take into account film exposure for light sampling threshold
To avoid issues with lights being either skipped or sampled unnecessarily
when the exposure is set low or high.

Contributed by Alaska.

Differential Revision: https://developer.blender.org/D16703
2022-12-12 18:28:09 +01:00
Brecht Van Lommel
312e42708f Fix T103066: Cycles missing full constant foler for mix float and mix vector 2022-12-12 18:28:09 +01:00
Brecht Van Lommel
18abc2feaa Fix Cycles light tree not working with negative light strength
Use absolute value of emission as estimate to make this work.

Contributed by Alaska.

Differential Revision: https://developer.blender.org/D16718
2022-12-12 18:28:09 +01:00
Thomas Dinges
54aec4629e Cleanup: Remove unused code in Cycles
* preempt_attr was copied from CUDA, but not used in HIP.
* Remove shadowed variable before conditional in EnvironmentTextureNode code.

Differential Revision: https://developer.blender.org/D16741
2022-12-12 18:15:41 +01:00
Weizhen Huang
014ffc4615 Cycles: using concentric mapping when sampling disk 2022-12-12 17:15:55 +01:00
Weizhen Huang
d17858cb37 Fix Cycles rectangular area light in volume segment sampled by ellipse 2022-12-12 15:59:04 +01:00
Alaska
3e1152428d Cleanup: Code comments in tree.h
Differential Revision: https://developer.blender.org/D16751
2022-12-12 12:37:50 +01:00
Damien Picard
538d4cc998 UI: Fix and improve various labels and tooltips
Improve a few messages, but mostly fix typos in many areas of the UI.
See inline comments in the differential revisiion for the rationale
behind the various changes.

Differential Revision: https://developer.blender.org/D16716
2022-12-09 16:10:14 -06:00
Jason Fielder
2e61c446ac GPU: Explicit Texture Usage Flags for enabling GPU Backend optimizations.
Texture usage flags can now be provided during texture creation specifying
the ways in which a texture can be used. This allows the GPU backends to
perform contextual optimizations which were not previously possible. This
includes enablement of hardware lossless compression which can result in
a 15%+ performance uplift for bandwidth-limited scenes on hardware such
as Apple-Silicon using Metal.

GPU_TEXTURE_USAGE_GENERAL can be used by default if usage is not known
ahead of time. Patch will also be relevant for the Vulkan backend.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem
Differential Revision: https://developer.blender.org/D15967
2022-12-08 23:31:05 +01:00
Weizhen Huang
009047ee0a Cleanup: remove unused variable and simplify computation in the light tree 2022-12-08 18:24:49 +01:00
Alaska
a21d948fd7 Fix mesh light brightness when not using the light tree
The PDF of mesh lights were not being scaled by `pdf_selection` when
the light tree was disable. This resulted in the mesh lights having
the wrong PDF and thus the wrong brightness.

Differential Revision: https://developer.blender.org/D16717
2022-12-08 11:54:28 +01:00
Campbell Barton
a132b068bc Cleanup: use ELEM macro 2022-12-08 13:59:42 +11:00
Campbell Barton
cb45b0bb2a Cleanup: spelling in comments 2022-12-08 13:47:55 +11:00
Weizhen Huang
bf18032977 Cycles: support spread angle 0 for area lights
Ref: T87053
2022-12-07 20:05:20 +01:00
Brecht Van Lommel
c2dc65dfa4 Fix Cycles HIP compiler error for some architectures even with light tree off
Revert some refactoring that is not strictly necessary and causes issues for
unknown reasons.
2022-12-07 19:56:51 +01:00
Weizhen Huang
f68634a379 Cleanup: store tan instead of cot in area lights to increase precision 2022-12-07 18:54:41 +01:00
Leszek Godlewski
07d3a3962a Fix Cycles build in VS2022, use explicit two's complement in find_first_set()
Compiling Cycles in Visual Studio 2022 yields the error:
C4146: unary minus operator applied to unsigned type, result still unsigned

Replacing it with explicit two's complement achieves the same result as signed
negation but avoids the error.

Differential Revision: https://developer.blender.org/D16616
2022-12-07 18:34:57 +01:00
howetuft
937130a294 Cycles: apply basic gamma correction in stadalone OpenImageIO output driver
For file formats like PNG, JPEG and TIFF. Eventually this should use
the OpenColorIO view transform, but this at least makes the image
closer to what it should be in most cases.

Differential Revision: https://developer.blender.org/D16482
2022-12-07 18:34:57 +01:00
Brecht Van Lommel
ec04870091 Fix Cycles standalone float textures not taking into account colorspace metadata
This got lost in colorspace refactoring at some point. It probably does not
affect many files in practice, but implementation was wrong regardless.
2022-12-07 18:34:57 +01:00
Brecht Van Lommel
f627abea2d Fix Cycles Hydra build issue with USD 22.05
Thanks to Alex Fuller for proposing the solution.
2022-12-07 18:34:57 +01:00
Thomas Lindemeier
d70ef8dbf1 Fix Cycles Hydra segmentation fault in usdview
Ensure render buffer is allocated when calling WritePixels.

Differential Revision: https://developer.blender.org/D16272
2022-12-07 18:34:57 +01:00
Brecht Van Lommel
904cab0418 Fix Cycles Hydra build errors
Still initializing GLEW after libepoxy switch, and ellipse area light.
2022-12-07 18:34:27 +01:00
Weizhen Huang
53ef52f165 Cycles: improve sampling of ellipse area light with spread
**Problem**:
Area lights in Cycles have spread angle, in which case some part of the area light might be invisible to a shading point. The current implementation samples the whole area light, resulting some samples invisible and thus simply discarded. A technique is applied on rectangular light to sample a subset of the area light that is potentially visible (rB3f24cfb9582e1c826406301d37808df7ca6aa64c), however, ellipse (including disk) area lights remained untreated. The purpose of this patch is to apply a techniques to ellipse area light.
**Related Task**:
T87053
**Results**:
These are renderings before and after the patch:
|16spp|Disk light|Ellipse light|Square light (for reference, no changes)
|Before|{F13996789}|{F13996788}|{F13996822}
|After|{F13996759}|{F13996787}|{F13996852}
**Explanation**:
The visible region on an area light is found by drawing a cone from the shading point to the plane where the area light lies, with the aperture of the cone being the light spread.
{F13990078,height=200}
Ideally, we would like to draw samples only from the intersection of the area light and the projection of the cone onto the plane (forming a circle). However, the shape of the intersection is often irregular and thus hard to sample from directly.
{F13990104,height=200}
Instead, the current implementation draws samples from the bounding rectangle of the intersection. In this case, we still end up with some invalid samples outside of the circle, but already much less than sampling the original area light, and the bounding rectangle is easy to sample from.
{F13990125}
The above technique is only applied to rectangle area lights, ellipse area light still suffers from poor sampling. We could apply a similar technique to ellipse area lights, that is, find the
smallest regular shape (rectangle, circle, or ellipse) that covers the intersection (or maybe not the smallest but easy to compute).
For disk area light, we consider the relative position of both circles. Denoting `dist` as the distance between the centre of two circles, and `r1`, `r2` their radii. If `dist > r1 + r2`, the area light is completely invisible, we directly return `false`. If `dist < abs(r1 - r2)`, the smaller circle lies inside the larger one, and we sample whichever circle is smaller. Otherwise, the two circles intersect, we compute the bounding rectangle of the intersection, in which case `axis_u`, `len_u`, `axis_v`, `len_v` needs to be computed anew. Depending on the distance between the two circles, `len_v` is either the diameter of the smaller circle or the length of the common chord.
|{F13990211,height=195}|{F13990225,height=195}|{F13990274,height=195}|{F13990210,height=195}
|`dist > r1 + r2`|`dist < abs(r1 - r2)`|`dist^2 < abs(r1^2 - r2^2)`|`dist^2 > abs(r1^2 - r2^2)`
For ellipse area light, it's hard to find the smallest bounding shape of the intersection, therefore, we compute the bounding rectangle of the ellipse itself, then treat it as a rectangle light.
|{F13990386,height=195}|{F13990385,height=195}|{F13990387,height=195}
We also check the areas of the bounding rectangle of the intersection, the ellipse (disk) light, and the spread circle, then draw samples from the smallest shape of the three. For ellipse light, this also detects where one shape lies inside the other. I am not sure if we should add this measure to rectangle area light and sample from the spread circle when it has smaller area, as we seem to have a better sampling technique for rectangular (uniformly sample the solid angle). Maybe we could add [area-preserving parameterization for spherical
ellipse](https://arxiv.org/pdf/1805.09048.pdf) in the future.
**Limitation**:
At some point we switch from sampling the ellipse to sampling the rectangle, depending on the area of the both, and there seems to be a visible line (with |slope| =1) on the final rendering
which demonstrate at which point we switch between the two methods. We could see that the new sampling method clearly has lower variance near the boundaries, but close to that visible line,
the rectangle sampling method seems to have larger variance. I could not spot any bug in the implementation, and I am not sure if this happens because different sampling patterns for ellipse and rectangle are used.
|Before (256spp)|After (256spp)
|{F13996995}|{F13996998}

Differential Revision: https://developer.blender.org/D16694
2022-12-07 18:21:55 +01:00
Jason Fielder
96b6ea9ee6 Fix T102944: fix Cycles viewport issues on macOS + NVIDIA
Part of the workaround for NVIDIA driver issue got lost in the changes to
switch to the GPU module.

Differential Revision: https://developer.blender.org/D16709
2022-12-07 18:18:33 +01:00
Weizhen Huang
f423c4191f Cycles: credit the original light tree paper and explain modifications 2022-12-07 15:38:09 +01:00
Ray Molenkamp
388bbc3290 Build: library updates for Blender 3.5
This updates the libraries dependencies for VFX platform 2023, and adds various
new libraries. It also enables Python bindings and switches from static to
shared for various libraries.

The precompiled libraries for all platforms will be updated to these new
versions in the coming weeks.

New:

Fribidi 1.0.12
Harfbuzz 5.1.0
MaterialX 1.38.6 (shared lib with python bindings)
Minizipng 3.0.7
Pybind11 2.10.1
Shaderc 2022.3
Vulkan 1.2.198

Updated:

Boost 1.8.0 (shared lib)
Cython 0.29.30
Numpy 1.23.2
OpenColorIO 2.2.0 (shared lib with python bindings)
OpenImageIO 2.4.6.0 (shared lib with python bindings)
OpenSubdiv 3.5.0
OpenVDB 10.0.0 (shared lib with python bindings)
OSL 1.12.7.1 (enable nvptx backend)
TBB (shared lib)
USD 22.11 (shared lib with python bindings, enable hydra)
yaml-cpp 0.8.0

Includes contributions by Ray Molenkamp, Brecht Van Lommel, Georgiy Markelov
and Campbell Barton.

Ref T99618
2022-12-07 15:28:17 +01:00
Brecht Van Lommel
ebff39d5bb Build: make running executables as part of build/tests work with shared libs
Ensure the environment is set up for blender_test, idiff and oslc so that they
can find the required shared libraries.

Also deduplicate add_bundled_libraries() between Linux and macOS.

Includes contributions by Ray Molenkamp and Brecht Van Lommel.

Ref T99618
2022-12-07 15:28:17 +01:00
Michael Jones
2dc51fccb8 Fix T101787, T102786. Cycles: Improved out-of-memory messaging on Metal
This patch adds a new `max_working_set_exceeded()` check on Metal so that we can display a "System is out of GPU memory" message to the user. Without this, we get obtuse "CommandBuffer failed" errors at render time due to exceeding the size limit of resident resources.

Likely fix for T101787 & T102786.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16713
2022-12-07 13:56:21 +00:00
Weizhen Huang
4d05a000cb Fix light tree header file included while feature disabled 2022-12-07 14:47:11 +01:00
Sergey Sharybin
f8ddf16e5a Cleanup: Typo in comment 2022-12-07 14:44:45 +01:00
Thomas Dinges
3124241256 Fix Cycles SSE4 define for fast math rint function.
Differential Revision: https://developer.blender.org/D16708
2022-12-06 19:06:43 +01:00
Thomas Dinges
de9f32a666 Merge branch 'blender-v3.4-release' 2022-12-06 18:27:44 +01:00
Campbell Barton
38e1b92b7a Fix T102964: Key-map event type values changed for NDOF buttons
Regression in [0] changed NDOF key-map values.

Restore the previous values & add missing view buttons to
rna_enum_event_type_items.

[0]: ecda118be407163096641db36b6ee8bf1d88ee55

Differential Revision: https://developer.blender.org/D16701
2022-12-06 18:26:24 +01:00
Brecht Van Lommel
7d99c51e17 Cycles: enable light tree again
Bugs that caused wrong renders should be fixed now, and tests that showed minor
floating point differences on platforms were tweaked to sidestep the problem.

Ref T77889
2022-12-06 18:18:53 +01:00
16b6116b9d Fix Cycles light tree render errors on Windows
Due to mistake in popcount implementation. Thanks to Weizhen for help
figuring this out.
2022-12-06 16:52:15 +01:00
Xavier Hallade
6428c847fd Cycles oneAPI: clarify Linux Driver requirements in GUI
"Linux Driver" wasn't precise enough for users, the actual driver
requirement is on "Intel® Graphics Compute Runtime for oneAPI Level Zero
and OpenCL™ Driver", ie. https://github.com/intel/compute-runtime /
intel-level-zero-gpu package.

This follows-up the discussion on
https://developer.blender.org/rBff89c1793d8c75615ed43248def25812ec13e6e3
2022-12-06 13:21:19 +01:00
Campbell Barton
979b295154 Fix incorrect cursor motion coordinates for WIN32
Cursor motion events on windows read the position from GetCursorPos()
which wasn't always the same location stored in `lParam`.

In situations where events were handled immediately this wasn't often a
problem, for heavier scenes or when updates between event handling was
slow - many in-between cursor events would be incorrect.

This behavior dates back to the initial commit, there doesn't seem to be
a good reason not to use the cursor coordinates from the event.

Noticed when investigating T102346.
2022-12-06 17:18:01 +11:00
Campbell Barton
d486f33d63 GHOST: OpenGL errors now use "file:line: " contention for errors
Make OpenGL errors match formatting used by GCC & clang
(as well as Blender's logging), so utilities that recognize this
convention can be used to quickly access this location.
2022-12-06 14:48:38 +11:00
Brecht Van Lommel
0808eaf44e Cycles: temporarily disable light tree again due to platform differences
Regression tests are failing with some platform/compiler combinations, and
fixing this is taking some time.

Ref T77889
2022-12-05 21:57:43 +01:00
Brecht Van Lommel
5270610b29 Fix Cycles uninitialized variables in mesh light sampling
Causing wrong renders and differences between platforms.
2022-12-05 20:20:51 +01:00
Weizhen Huang
f646a4f22c Cleanup: renaming tan_spread to cot_half_spread to avoid ambiguity
Differential Revision: https://developer.blender.org/D16695
2022-12-05 17:04:04 +01:00
Weizhen Huang
ee89f213de Cycles: improve many lights sampling using light tree
Uses a light tree to more effectively sample scenes with many lights. This can
significantly reduce noise, at the cost of a somewhat longer render time per
sample.

Light tree sampling is enabled by default. It can be disabled in the Sampling >
Lights panel. Scenes using light clamping or ray visibility tricks may render
different as these are biased techniques that depend on the sampling strategy.

The implementation is currently disabled on AMD HIP. This is planned to be fixed
before the release.

Implementation by Jeffrey Liu, Weizhen Huang, Alaska and Brecht Van Lommel.

Ref T77889
2022-12-05 16:09:03 +01:00
Brecht Van Lommel
0731d78d00 Cycles: remove shadow pass
This was not working well in non-trivial scenes before the light tree, and now
it is even harder to make it work well with the light tree. It would average the
with equal weight for every light object regardless of intensity or distance, and
be quite noisy due to not working with multiple importance sampling.

We may restore this if were enough good use cases for the previous implementation,
but let's wait and see what the feedback is.

Some uses cases for this have been replaced by the shadow catcher passes, which
did not exist when this was added.

Ref T77889
2022-12-05 15:52:10 +01:00
Campbell Barton
9cb061f4f0 Cleanup: spelling in comments 2022-12-05 12:58:18 +11:00
Campbell Barton
0dee238c8c Cleanup: remove duplicate doc-strings
Duplicating doc-strings in both header & implementation
should be avoided as they often diverge & maintaining them is more work.
2022-12-05 12:54:04 +11:00
Campbell Barton
cc6bdac921 Cleanup: format 2022-12-05 12:54:00 +11:00
Brecht Van Lommel
948f13a8e7 Cleanup: compiler warning 2022-12-02 19:13:38 +01:00
Sergey Sharybin
c5e71cebaa Cycles: Remove OpenGL header
It is not really used from any of the sources, including the
standalone app. Since we are moving to a more backend-independent
drawing it makes sense to remove header which was specific to
how Blender integrates Cycles into viewport.

There is probably some cleanup in CMake files is possible, but
there is some inter-dependency with USD.

Differential Revision: https://developer.blender.org/D16681
2022-12-02 17:19:00 +01:00
Sergey Sharybin
3d9f4012dc Cycles: Fixes for viewport render on Metal drawing backend
This change fixes issues with viewport rendering when Metal
GPU backend is used for drawing. This is not a default build
configuration and requires the following tweaks:

- Enable WITH_METAL_BACKEND CMake option (set it to on)
- Use `--gpu-backend metal` command line arguments

It also helps using the `--factory-startup` command line
argument to ensure Eevee is not used (it is not ported and
will crash).

The root of the problem was in the use of glViewport().
It is replaced with the GPU_viewport_size_get_i() which
is supposed to be portable equivalent form the GPU module.
Without this change the viewport size is detected to be 0
which backfired in few places.

The rest of the changes were to make the code more robust
in the extreme conditions instead of asserting or crashing.

Simplified and streamlined GPU resources creation in the
display driver. It was a bit convoluted mix of creation of
the GPU resources and resizing them to the proper size. It
even seemed to be done in the reverse order. Now it is as
simple as "just ensure GPU resources are there for the
given texture or buffer size".

Also avoid division by zero in the tile manager.

Differential Revision: https://developer.blender.org/D16679
2022-12-02 16:46:43 +01:00
Weizhen Huang
e028662f78 Cycles: store axis and length of an area light instead of their product 2022-12-02 15:23:09 +01:00
Brecht Van Lommel
009f7de619 Cleanup: use better matching integer types for graphics interop handle
Ref D16042
2022-12-01 15:55:48 +01:00
Jason Fielder
b132e3b3ce Cycles: use GPU module for viewport display
To make GPU backends other than OpenGL work. Adds required pixel buffer and
fence objects to GPU module.

Authored by Apple: Michael Parkin-White

Ref T96261
Ref T92212

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D16042
2022-12-01 15:55:48 +01:00
Brecht Van Lommel
222b64fcdc Fix Cycles CUDA crash when building kernels without optimizations (for debug)
In this case the blocksize may not the one we requested, which was assumed to be
the case. Instead get the effective block size from the compiler as was already
done for Metal and OneAPI.
2022-11-30 21:46:17 +01:00
Brecht Van Lommel
b25c301c15 Build: make CUDA kernel compilation output not verbose
Unless using WITH_CYCLES_DEBUG.

This is convenient for investigating kernel performance, but too verbose to
always have in the buildbot logs especially now that we are also compiling HIP
and OneAPI kernels.
2022-11-30 21:19:51 +01:00
Brecht Van Lommel
396b407c7d Cycles: new setting and heuristics for mesh light importance sampling
Materials now have an enum to set the emission sampling method, to be
either None, Auto, Front, Back or Front & Back. This replace the
previous "Multiple Importance Sample" option.

Auto is the new default, and uses a heuristic to estimate the emitted
light intensity to determine of the mesh should be considered as a light
for sampling. Shaders sometimes have a bit of emission but treating them
as a light source is not worth the memory/performance overhead.

The Front/Back settings are not important yet, but will help when a
light tree is added. In that case setting emission to Front only on
closed meshes can help ignore emission from inside the mesh interior that
does not contribute anything.

Includes contributions by Brecht Van Lommel and Alaska.

Ref T77889
2022-11-30 21:19:51 +01:00
Brecht Van Lommel
ac51d331df Refactor: Cycles light sampling code reorganization
* Split light types into own files, move light type specific code from
  light tree and MNEE.
* Move flat light distribution code into own kernel file and host side
  building function, in preparation of light tree addition. Add light/sample.h
  as main entry point to kernel light sampling.
* Better separate calculation of pdf for selecting a light, and pdf for
  sampling a point on the light. The selection pdf is now also stored in
  LightSampling for MNEE to correctly recalculate the full pdf when the
  shading position changes but the point on the light remains fixed.
* Improvement to kernel light storage, using packed_float3, better variable
  names, etc.

Includes contributions by Brecht Van Lommel and Weizhen Huang.

Ref T77889
2022-11-30 21:19:51 +01:00
Hans Goudey
d1d2946f59 Merge branch 'blender-v3.4-release' 2022-11-28 14:12:04 -06:00
Hans Goudey
1bacd09abb Fix: Mishandled creases in Cycles adaptive subdivision
Caused by a8a454287a27 which assumed it was possible
to access the raw data of the edge creases layer. Also allow
processing vertex creases even if there aren't any edge creases.
2022-11-28 14:06:25 -06:00
Brecht Van Lommel
719ad4f93f Fix T100537: wrong depth pass for background after recent fix for gaps
Also have to write if we hit the background and have not written any valid
value for the pass yet.
2022-11-28 21:03:07 +01:00
Brecht Van Lommel
6d52975019 Cleanup: remove Cycles standalone repository lib detection
This is only needed in the Cycles repo and having it in the Blender repo
is making merging more complicated than it is helping.
2022-11-28 21:03:07 +01:00
Brecht Van Lommel
ca5062071c Fix T100537: wrong depth pass for background after recent fix for gaps
Also have to write if we hit the background and have not written any valid
value for the pass yet.
2022-11-28 20:36:56 +01:00
Brecht Van Lommel
1a34bbc27c Cleanup: remove Cycles standalone repository lib detection
This is only needed in the Cycles repo and having it in the Blender repo
is making merging more complicated than it is helping.
2022-11-28 20:18:26 +01:00
Nikita Sirgienko
f07b09da27 Cycles: Improve oneAPI backend support for non-Intel platforms 2022-11-25 17:46:59 +01:00
Nikita Sirgienko
412642865d Cleanup: Resolve a warning for the ambiguity on the parenthesis in oneAPI code
No functional changes.
2022-11-24 18:05:02 +01:00
Joseph Eagar
14a0fb0cc6 Merge branch 'blender-v3.4-release' 2022-11-24 09:02:23 -08:00
Sebastian Herholz
008cc625aa Fix T102250: Cycles path guiding issue with equiangular sampling
The wrong guiding distribution was used when direct and indirect light
scattering happened at different locations. Now use a different distribution
for each location.

Recording is not quite correct since OpenPGL does not support spliting the
path like this, instead recording at the start of the volume ray. In practice
this seems to make little difference.

Differential Revision: https://developer.blender.org/D16448
2022-11-24 17:12:38 +01:00
Brecht Van Lommel
38c4f40159 Fix Cycles OSL issue with constant folding after recent fix
Constant folded values from linked nodes should override the OSL initializer.

Ref T102450
2022-11-24 16:59:58 +01:00
Thomas Dinges
bbf09eb59c Merge branch 'blender-v3.4-release' 2022-11-24 10:15:36 +01:00
Thomas Dinges
b3daf61ddf Fix T101020: Cycles Add Performance Preset is broken 2022-11-24 10:13:57 +01:00
Brecht Van Lommel
f4e1f62c62 Merge branch 'blender-v3.4-release' 2022-11-23 19:35:39 +01:00
Brecht Van Lommel
dc1ed9c1aa Cycles: add OSL support for hiding input socket value
When either initializing with a non-constant value, or using the standard
[[ string widget = "null" ]] metadata. This can be used for inputs like
normals and texture coordinates, where you don't want to default to a
constant value.

In previous OSL versions the input value was automatically ignore when it
was left unchanged for such inputs. However that's no longer the case in
the latest version, breaking existing nodes. There is no good entirely
backwards compatible fix, but I believe the new behavior is better and will
keep most existing cases working.

Fix T102450: OSL node with normal input not working
2022-11-23 18:59:52 +01:00
Brecht Van Lommel
c3d6f5ecf3 Merge branch 'blender-v3.4-release' 2022-11-23 16:39:09 +01:00
Brecht Van Lommel
fe1b8b671a Fix part of T102696: Cycles Python error with macOS version 13.0.1 2022-11-23 16:03:19 +01:00
Sergey Sharybin
5938e97a24 Merge branch 'blender-v3.4-release' 2022-11-23 10:36:11 +01:00
Sergey Sharybin
0d73d5c1a2 Fix frozen image editor when Cycles compiles kernels
It is possible that the image editor redraw happens prior to the
"Loading render kernels" status is reported from status but after
the display driver is created. This will make the image editor to
wait on the scene mutex to update the display pass in the film.
If it happens to be that the kernels are actually to be compiled
then the Blender interface appears to be completely frozen, without
any information line in the image editor.

This change makes it so the amount of time the scene mutex is held
during the kernel compilation is minimal.

It is a bit unideal to unlock and re-lock the scene mutex in the
middle of update, while nested reset mutex is held, but this is
already what is needed for the OptiX denoiser optimization some
lines below. We can probably reduce the lifetime of some locks,
avoiding such potential out-of-order re-locking. Doing so is
outside of the scope of this patch.

The scene update only happens from the single place in the session,
which makes it easy to ensure the kernels are loaded prior the rest
of the scene update.

Not only this change makes it so that the "Loading render kernels"
status appears in the image editor, but also allows to pan and zoom
in the image editor, potentially allowing artists to re-adjust their
point of interest.

Differential Revision: https://developer.blender.org/D16581
2022-11-23 10:23:05 +01:00
Peter Kim
63ae0939ed Merge branch 'blender-v3.4-release' 2022-11-23 10:22:42 +09:00
Peter Kim
db28a8b3d1 Fix T102322: Crash on exiting VR session when using DirectX backend
This prevents Blender from crashing with an access violation when
stopping a VR session using the DirectX backend. The issue occurred for
any headset on Windows+Nvidia when using the SteamVR runtime and thus
affected a large number of users.

The workaround presented here is to simply skip unregistering the
shared resources on exit, as either of the calls to
`wglDXUnregisterObjectNV()` or `wglDXCloseDeviceNV()` will result in an
access violation. While not ideal, this avoids the crash and doesn't
present any issues when starting a new VR session.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D16569
2022-11-23 10:21:17 +09:00
Jeroen Bakker
dd5fdb9370 GPU: Add MoltenVK as dependencies to Vulkan SDK.
MoltenVK is part of the vulkan SDK. Blender requires the vulkan SDK
to compile. This patch adds the MoltenVK includes and libraries to
the Vulkan includes and libraries.
2022-11-22 14:07:34 +01:00
Jeroen Bakker
b79e5ae4f2 GHOST: Add missing C_API function to header file.
- GHOST_GetDrawingContext was missing.
2022-11-22 12:45:49 +01:00
Jeroen Bakker
6dac345a64 GHOST: Vulkan Backend.
This adds a vulkan backend to GHOST. The code was extracted from the
tmp-vulkan branch. The main difference with the original code is that
GHOST isn't responsible for fallback. For Metal backend there is already
an idea that the GPU module is responsible for the fallback, not the system.

For Blender we target Vulkan 1.2 at the time of this patch.
MoltenVK (needed to convert Vulkan calls to Metal) has been added as
a separate package.

This patch isn't useful for end-users, currently when starting blender with
`--gpu-backend vulkan` it would crash as the `VBBackend` doesn't initialize
the expected global structs in the GPU module.

Validated to be working on Windows and Apple. Linux still needs to be tested.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13155
2022-11-22 11:29:09 +01:00
Brecht Van Lommel
02e045ffbe Merge branch 'blender-v3.4-release' 2022-11-21 19:19:58 +01:00
Nathan Vegdahl
03b5be4e3c Cycles: use more PMJ patterns and make their size adaptive.
This resolves some issues with correlation artifacts at higher sample counts.

Fix T101356, correlation issues in new PMJ pattern.

Differential Revision: https://developer.blender.org/D16561
2022-11-21 18:49:13 +01:00
Patrick Mours
41a3de878f Fix part of T102450: Cycles OSL render issues for with normals in shader nodes
Commit c8dd33f5a37b6a6db0b6950d24f9a7cff5ceb799 in OSL changed behavior of
parameters that reference each other and are also overwritten with an
instance value. This is causing the "NormalIn" parameter of a few OSL nodes
in Cycles to be set to zero somehow, which should instead have received the
value from a "node_geometry" node Cycles generates and connects automatically.

I am not entirely sure why that is happening, but these parameters are
superfluous anyway, since OSL already provides the necessary data in the
global variable "N". So this patch simply removes those parameters (which
mimics SVM, where these parameters do not exist either), which also fixes
the rendering artifacts that occured with recent OSL.

While this fixes built-in shader nodes, custom OSL scripts can still have
this problem.

Ref T101222

Differential Revision: https://developer.blender.org/D16470
2022-11-21 18:15:35 +01:00
Campbell Barton
9100cc0f39 Merge branch 'blender-v3.4-release' 2022-11-20 10:41:19 +11:00
Campbell Barton
4cac8025f0 Cleanup: use int32_t type, update comments
Reference WIP patches for warping on the spot, follow up to T102346.
2022-11-20 10:39:43 +11:00
Campbell Barton
7ca9fb9865 Merge branch 'blender-v3.4-release' 2022-11-19 21:15:28 +11:00
Campbell Barton
9fd6dae793 Fix T102346: Mouse escapes window during walk navigation
Regression in [0] which exposed a problem with GHOST_kGrabHide on Win32
and to some extent X11.

Prior to [0], walk mode used it's own warping logic (hiding the cursor
& recording the motion between events). Using GHOST's grabbing makes
sense in this case as it's not very convenient for operators to
implement their own cursor warping, however doing so exposed a problem
where the mouse cursor could leave the window.
This would happen because the cursor needed to be within 2px of the
screen edge before warping.

Resolve by warping within a small region in the middle of the window.

Note that warping to the window center on each motion would be ideal
but is more involved as the logic for Win32 & X11 doesn't work properly
when every motion warps, so this needs further investigation to support.

This problem doesn't apply to GHOST/Cocoa which warps every motion event
on the spot and GHOST/Wayland doesn't set the mouse position at all to
implement this functionality.

[0]: 4c4e8cc926a672ac60692b3fb8c20249f9cae679
2022-11-19 20:57:59 +11:00
Brecht Van Lommel
b211266226 Merge branch 'blender-v3.4-release' 2022-11-18 16:05:10 +01:00
Brecht Van Lommel
3d41d0b1b5 Fix T100537: gaps in Cycles depth pass with transparency
For some pixels with transparent surfaces, no depth value would be written
when sampling chooses a reflection/refraction BSDF instead of transparent
BSDF. Now ensure we always write at some some depth value to the pass.

This is still not ideal as the resulting depth values are noisy same as they
are for depth of field and motion blur, but at least there should be no gaps.
2022-11-18 15:52:34 +01:00
Brecht Van Lommel
4e38771d5c Merge branch 'blender-v3.4-release' 2022-11-18 13:56:43 +01:00
Sayak Biswas
c94583cd64 Cycles: enable AMD RDNA3 GPUs and upgrade HIP compiler
* Enable AMD RDNA3 GPUs
* Fix T100891: performance regression with RDNA2 cards
* Workaround new compiler issue with Vega, by using -O1

Differential Revision: https://developer.blender.org/D16507
2022-11-18 13:54:21 +01:00
Thomas Dinges
f74234895a Merge branch 'blender-v3.4-release' 2022-11-17 17:05:03 +01:00
Lukas Stockner
1c27cc5529 Fix T92416: First render with unknown image colorspace looks different
The issue here was that the Barbershop benchmark scene was saved with a
custom OCIO config, which leads to some textures having a unknown
colorspace when loading with a default installation.

This is automatically fixed by Blender during image loading, but since
Cycles queried the colorspace before actually loading the image, it
didn't get the updated value in the first render.

To fix this, just re-query the colorspace after the image is loaded.

Note that non-packed images still get treated as raw data if the
colorspace is unknown, but this is at least consistent and doesn't
magically change when you press F12 a second time.

Differential Revision: https://developer.blender.org/D16427
2022-11-17 16:52:04 +01:00
Pablo Vazquez
011c2a37eb Cycles: Sort properties in Path Guiding panel
* Sort Training Samples first, since it affects both Surface and Volume guiding.
* Remove "Guiding" from Surface and Volume entries (UI only, the property
  still has Guiding in the name)

Change reviewed in the render-cycles module channel.
2022-11-17 16:18:28 +01:00
Brecht Van Lommel
780b29109c Merge branch 'blender-v3.4-release' 2022-11-17 16:05:01 +01:00
Brecht Van Lommel
617cf2f291 Cycles: remove cubin compiler build option
This was previously needed due to poor compatibility between Visual Studio and
NVCC. But it has not been used for a while now as compatibility seems to have
improved.
2022-11-17 16:04:07 +01:00
Lukas Stockner
cacfaaa9a5 Fix T92416: First render with unknown image colorspace looks different
The issue here was that the Barbershop benchmark scene was saved with a
custom OCIO config, which leads to some textures having a unknown
colorspace when loading with a default installation.

This is automatically fixed by Blender during image loading, but since
Cycles queried the colorspace before actually loading the image, it
didn't get the updated value in the first render.

To fix this, just re-query the colorspace after the image is loaded.

Note that non-packed images still get treated as raw data if the
colorspace is unknown, but this is at least consistent and doesn't
magically change when you press F12 a second time.

Differential Revision: https://developer.blender.org/D16427
2022-11-16 23:42:23 +01:00
Campbell Barton
ec9acdeac2 Merge branch 'blender-v3.4-release' 2022-11-16 21:37:01 +11:00
Campbell Barton
91d3cc51c3 Merge branch 'blender-v3.4-release' 2022-11-16 21:36:55 +11:00
Campbell Barton
33fa053fe8 GHOST/Wayland: add missing lock in setWindowCursorShape
Also add some comments for locking.
2022-11-16 21:35:56 +11:00
Campbell Barton
02fa3a8128 Cleanup: remove unused window_manger reference in GHOST_WindowWayland 2022-11-16 21:04:30 +11:00
Campbell Barton
550c51b08b Merge branch 'blender-v3.4-release' 2022-11-16 12:33:59 +11:00
Campbell Barton
71067a58ec Merge branch 'blender-v3.4-release' 2022-11-16 12:33:55 +11:00
Campbell Barton
6940c4b602 Merge branch 'blender-v3.4-release' 2022-11-16 12:33:53 +11:00
Campbell Barton
0ac19425d4 Merge branch 'blender-v3.4-release' 2022-11-16 12:33:49 +11:00
Campbell Barton
e3ddfedbb6 Merge branch 'blender-v3.4-release' 2022-11-16 12:33:46 +11:00
Campbell Barton
5e203c4f4b Merge branch 'blender-v3.4-release' 2022-11-16 12:33:43 +11:00
Campbell Barton
25630ab2a1 Merge branch 'blender-v3.4-release' 2022-11-16 12:33:38 +11:00
Campbell Barton
88c9f1266d GHOST/Wayland: add additional locks for correctness
Some of these functions should use locks although they didn't show up
as needing locks at runtime (using valgrind's helgrind), as some aren't
called often or aren't used at all. Add locks for correctness & to
prevent errors in the future.

- GHOST_SystemWayland::disposeContext
- GHOST_SystemWayland::getAllDisplayDimensions
- GHOST_SystemWayland::getButtons
- GHOST_SystemWayland::getMainDisplayDimensions
- GHOST_SystemWayland::getNumDisplays
- GHOST_WindowWayland::setWindowCustomCursorShape
2022-11-16 12:32:13 +11:00
Campbell Barton
1f5e1b59a3 GHOST/Wayland: quiet key modifier warning under gnome-shell
This was already suppressed in `getModifierKeys`,
but `keyboard_depressed_state_key_event` was still warning.
2022-11-16 12:31:30 +11:00
Campbell Barton
c2c41fb14c Fix missing title-bar redrawing with Wayland & libdecor
Regression in [0], changing active/inactive missed redrawing the
title-bar,

[0]: 37b256e26feb454d9febd84dac1b1ce8b8d84d90
2022-11-16 12:31:30 +11:00
Campbell Barton
64a114d11c GHOST/Wayland: add build option to set the XDG app-id
Add WITH_GHOST_WAYLAND_APP_ID so people making custom builds may
differentiate the blender instance by version/branch etc.
2022-11-16 12:31:30 +11:00
Campbell Barton
d1a5f24e73 Cleanup: move GHOST_WindowWayland::swapBuffers behind ifdef
The callback is only used for an assertion.
2022-11-16 12:31:30 +11:00
Campbell Barton
aee5fcc120 GHOST/Wayland: improve workaround for libdecor setting the window state
libdecor has a workaround where creating the window would loop until
the windows configure callback ran.

Simplify this workaround by setting the initial state on the underlying
xdg_toplevel struct.

Also correct mixup between bool / GHOST_TSuccess types.
2022-11-16 12:31:29 +11:00
Campbell Barton
9f0e9f36be GHOST/Wayland: extend on comments regarding locking 2022-11-16 12:31:29 +11:00
Chris Blackbourn
60523ea523 Cleanup: format 2022-11-16 12:59:47 +13:00
Patrick Mours
a859837cde Cleanup: Move OptiX denoiser code from device into denoiser class
Cycles already treats denoising fairly separate in its code, with a
dedicated `Denoiser` base class used to describe denoising
behavior. That class has been fully implemented for OIDN
(`denoiser_oidn.cpp`), but for OptiX was mostly empty
(`denoiser_optix.cpp`) and denoising was instead implemented in
the OptiX device. That meant denoising code was split over various
files and directories, making it a bit awkward to work with. This
patch moves the OptiX denoising implementation into the existing
`OptiXDenoiser` class, so that everything is in one place. There are
no functional changes, code has been mostly moved as-is. To
retain support for potential other denoiser implementations based
on a GPU device in the future, the `DeviceDenoiser` base class was
kept and slightly extended (and its file renamed to
`denoiser_gpu.cpp` to follow similar naming rules as
`path_trace_work_*.cpp`).

Differential Revision: https://developer.blender.org/D16502
2022-11-15 15:50:01 +01:00
Campbell Barton
2a41cd46ba Cleanup: format 2022-11-15 16:43:18 +11:00