Commit Graph

12749 Commits

Author SHA1 Message Date
Patrick Mours
7edb3ab5e0 Merge branch 'blender-v3.5-release' 2023-03-09 13:16:15 +01:00
Patrick Mours
dcfc9629c2 Fix OptiX TLAS being built with invalid traversables when a geometry is empty
The traversable handle of a BLAS may be zero when the relevant geometry
is empty (no triangles/curves/points/...), as no BLAS is built in such cases.
It is not correct to attach a zero handle to a TLAS, so filter out such instances.
2023-03-09 13:15:08 +01:00
Campbell Barton
b3625e6bfd Cleanup: comment blocks 2023-03-09 10:39:49 +11:00
Harley Acheson
56d2298271 Fix #105435: Pause Win32 Auto-Focus During Text Entry
Don't allow the hover of mouse to auto-raise another window while you
are entering data into a text or number input.

Pull Request: https://projects.blender.org/blender/blender/pulls/105446
2023-03-08 22:20:34 +01:00
Hans Goudey
5876573e14 Mesh: Move face shade smooth flag to a generic attribute
Currently the shade smooth status for mesh faces is stored as part of
`MPoly::flag`. As described in #95967, this moves that information
to a separate boolean attribute. It also flips its status, so the
attribute is now called `sharp_face`, which mirrors the existing
`sharp_edge` attribute. The attribute doesn't need to be allocated
when all faces are smooth. Forward compatibility is kept until
4.0 like the other mesh refactors.

This will reduce memory bandwidth requirements for some operations,
since the array of booleans uses 12 times less memory than `MPoly`.
It also allows faces to be stored more efficiently in the future, since
the flag is now unused. It's also possible to use generic functions to
process the values. For example, finding whether there is a sharp face
is just `sharp_faces.contains(true)`.

The `shade_smooth` attribute is no longer accessible with geometry nodes.
Since there were dedicated accessor nodes for that data, that shouldn't
be a problem. That's difficult to version automatically since the named
attribute nodes could be used in arbitrary combinations.

**Implementation notes:**
- The attribute and array variables in the code use the `sharp_faces`
  term, to be consistent with the user-facing "sharp faces" wording,
  and to avoid requiring many renames when #101689 is implemented.
- Cycles now accesses smooth face status with the generic attribute,
  to avoid overhead.
- Changing the zero-value from "smooth" to "flat" takes some care to
  make sure defaults are the same.
  - Versioning for the edge mode extrude node is particularly complex.
    New nodes are added by versioning to propagate the attribute in its
    old inverted state.
- A lot of access is still done through the `CustomData` API rather
  than the attribute API because of a few functions. That can be
  cleaned up easily in the future.
- In the future we would benefit from a way to store attributes as a
  single value for when all faces are sharp.

Pull Request: https://projects.blender.org/blender/blender/pulls/104422
2023-03-08 15:36:18 +01:00
Germano Cavalcante
7fcb262dfd Cleanup: resolve some unreferenced parameter warnings in MSVC
When the warning level is set to 4, some unreferenced parameter
warnings can appear

This commit resolves some of those warnings.
2023-03-07 21:39:44 -03:00
Xavier Hallade
0b05baeaf3 Cycles: oneAPI: fix linking for when icpx compiler is used
When compiling from MSVC environment, libs such as libircmt.lib weren't
found, we need to set the path to these in LIB environment variable.
2023-03-07 21:01:59 +01:00
Sebastian Parborg
023524765a Merge branch 'blender-v3.5-release' 2023-03-07 17:35:05 +01:00
Sebastian Parborg
68e7004e5e Fix ffmpeg warnings due to missing header include 2023-03-07 17:33:08 +01:00
Michael Jones
8f1136e018 Cycles: Use async Metal PSO compilation to avoid std::terminate on exit
When running unit tests or other fast completing renders, forced crashes can occur if there are any slow, outstanding PSO compilation requests (due to the `std::terminate` fall-back case in `~ShaderCache`).

This patch eliminates the need for this shutdown hack by using of the async version of `newComputePipelineStateWithDescriptor` when creating a PSO for the first time. In doing so, we are able to explicitly respond to app shutdown instead of waiting for the pipeline to finish compiling (..and then timing out and force-crashing). We still use the blocking version of `newComputePipelineStateWithDescriptor` when loading from an archive, as this can handle loading from a corrupted archive gracefully. Finally, we move `addComputePipelineFunctionsWithDescriptor` to *after* the PSO is built (as this will trigger a full blocking compile if the PSO has not yet been built, which would bring back the original issue).

Pull Request: https://projects.blender.org/blender/blender/pulls/105506
2023-03-07 17:08:30 +01:00
Bastien Montagne
067fc67bdd Merge branch 'blender-v3.5-release' 2023-03-07 11:06:19 +01:00
Damien Picard
2e5452ee87 I18n: do not extract messages explicitly marked as not translatable
Some UI functions have a "translate" argument, which if set to False
specifies that the message is not to be translated. This sometimes
means that it was already translated beforehands.

But many messages were still getting extracted, sometimes twice in
different contexts. Some featured errors because the arguments of
various functions would be concatenated, such as:

```
col.label(text=iface_("Branch: %s") % bpy.app.build_branch.decode('utf-8', 'replace'), translate=False)
```

which would get extracted as:

```
msgid "Branch: %sutf-8replace"
```

Pull Request #105417
2023-03-07 10:41:18 +01:00
Campbell Barton
5b152a4880 Docs: correct doc-string for wmEvent::customdata
Also cross-reference custom-data with GHOST_TEventType.
2023-03-07 15:57:18 +11:00
Campbell Barton
90dc655951 Cleanup: spelling in comments 2023-03-07 15:00:05 +11:00
Brecht Van Lommel
1658de6769 Merge branch 'blender-v3.5-release' 2023-03-06 23:14:18 +01:00
Brecht Van Lommel
83f28793c0 Fix missing data role in color management fallback
This would show as warning in gtests. Does not affect normal operation as
OpenColorIO should have a valid configuration file for Blender itself.
2023-03-06 23:01:50 +01:00
Brecht Van Lommel
9eee008691 Fix Cycles oneAPI build error due to conflicting CONSTANT define 2023-03-06 00:13:21 +01:00
Lukas Stockner
7d5754b8b6 Cycles: Reuse random variable for principled hair BSDF sampling
This lets us skip the hash and use a proper stratified variable instead.
Suggested by Christophe Hery.
2023-03-06 00:09:04 +01:00
Lukas Stockner
ca4486bfa1 Cleanup: format 2023-03-05 19:53:40 +01:00
Lukas Stockner
9139983f94 Cycles: Implement MaterialX OSL microfacet closures
This commit implements three OSL microfacet closures that are needed to support
MaterialX: dielectric_bsdf, conductor_bsdf and generalized_schlick_bsdf.

Internally these map to existing microfacet closures, only the Fresnel term is
different.
2023-03-05 19:52:07 +01:00
Lukas Stockner
014f6e4309 Cycles: Make Fresnel term independent of microfacet closure type
Currently, we use the closure type to encode the type of microfacet distribution
(GGX/Beckmann/Sharp/MultiGGX), the lobes we're interested in
(Reflection/Refraction/both) AND the Fresnel type (None or Principled v1).

This results in the mess of dozens of options that we currently have. Since
adding Principled v2 and the MaterialX OSL closures will involve adding more
Fresnel types, this clearly doesn't scale.

But, since the earlier Fresnel rework (D17101), the Fresnel type only matters
in one place now. This allows to significantly clean up the closure type
handling. To do this, MicrofacetBsdfs now separately store their Fresnel type,
and instead of a single MicrofacetExtra we have one struct per Fresnel type
(unless no extra data is needed).

Further, instead of having one _setup() function per combination, the Fresnel
setup is also split into separate functions. This decouples the implementation
of new Fresnel terms from most of the Microfacet logic, and makes it a very
simple and clean operation.
2023-03-05 19:52:07 +01:00
Lukas Stockner
5f9b518a8b Cycles: Use per-microfacet Fresnel term for Glass closures
This commit replaces the current Glass approach, where Glass is a virtual closure
that gets replaced with a Glossy and a Refractive closure, with a combined
closure that handles Fresnel after sampling the microfacet. That way, the Fresnel
term is more accurate since it accounts for the microfacet normal, not the
shading normal.

Also updates the BSDF sampling to use a 3D sampler now, since we need two
dimensions to pick the microfacet normal and then a third dimension to pick
reflection/refraction. This can also be used to get rid of the LCG in the
Principled Hair BSDF, which means we can remove it altogether once MultiGGX is
gone.

Also, "sharp" is now supported as a microfacet distribution in OSL, and 2
is supported as the "refract" argument to microfacet() in order to get glass.
2023-03-05 19:52:07 +01:00
Timo Gurr
0d080d1a07 Fix: Build with FFmpeg 6.0
Pull Request #105377
2023-03-03 18:42:35 +01:00
Timo Gurr
e0732b640a Fix: Build with FFmpeg 6.0
Pull Request #105377
2023-03-03 13:51:45 +01:00
Campbell Barton
b4eef99973 Cleanup: use C-style code comments, format 2023-03-03 16:29:22 +11:00
Campbell Barton
05324e2e3c Cleanup: spelling in comments 2023-03-03 10:09:20 +11:00
Hans Goudey
8fbc80be8f Merge branch 'blender-v3.5-release' 2023-02-28 11:36:20 -05:00
Michael Jones
7842347ec8 Cycles: Fix hanging unit tests when MetalRT is enabled
This patch fixes hanging unit tests when MetalRT is enabled. It simplifies and fixes the kernel selection logic by baking the MetalRT-specific options into `kernels_md5` rather than expanding out and testing MetalRT bit flags explicitly.

Pull Request #105270
2023-02-28 11:42:08 +01:00
Campbell Barton
9cee0eb7fa Cleanup: format 2023-02-28 15:44:49 +11:00
Jeroen Bakker
8d9819e07f Fix: Not all vulkan code-paths where compiled.
Fix issue where old `WITH_VULKAN` was still used. It should
have used `WITH_VULKAN_BACKEND`.
2023-02-28 05:36:06 +01:00
Campbell Barton
efb86b75ee Cleanup: comment block formatting 2023-02-27 21:51:57 +11:00
Campbell Barton
f240a16037 Cleanup: format 2023-02-27 21:34:53 +11:00
Campbell Barton
dc08ff3c2e Cleanup: spelling in comments 2023-02-27 21:00:30 +11:00
William Leeson
6c03339e48 Cycles: reduce mesh memory usage by unflattening
To improve mesh upload speeds and reduce the size of the scene data which allows larger scenes to be rendered.

The meshes in Cycles are currently stored as flattened meshes, where each triangle is stored as a set of 3 vertices. Unflattening writes out the vertices in a list according to the index buffer. This uses a lot of memory and for current hardware does not provide a noticeable benefit. This change unflattens the mesh by directly using the meshes vertex and index buffers directly and skips the unflattening. This change allows for larger scenes and also a reduction in the sizes of the meshes. Further it results in a decrease the amount of time it takes to upload the data to a GPU. This is especially important for when multiple GPUs are used in a single machine.

Pull Request #105173
2023-02-27 10:39:19 +01:00
Chris Blackbourn
86ceb6722f Cleanup: format 2023-02-26 11:55:22 +13:00
Clément Foucault
9fb1f32f06 Cleanup: GPUTexture: Remove _ex suffix from texture creation
It isn't relevant anymore now that usage flags are mandatory.

Pull Request #105197
2023-02-25 11:39:54 +01:00
Clément Foucault
3d6578b33e GPUTexture: Add texture usage flag to all texture creation
All usages are currently placeholder GPU_TEXTURE_USAGE_GENERAL.
2023-02-25 11:39:53 +01:00
Clément Foucault
e01b140fb2 GPUTexture: Remove data_format from 3D texture creation function
For every other texture types this is expected to be implicitly
`GPU_DATA_FLOAT`. There is only one case where this is not the case.

I believe this was previously needed because the data type was
conditionning the texture creation. This is not the case anymore.
2023-02-25 11:39:53 +01:00
Clément Foucault
75e3371aef GPUTexture: Remove obsolete GPU_texture_bind_ex argument set_number
This was previously used when the binding number wasn't always stored
inside the texture itself.
2023-02-25 11:39:53 +01:00
Pratik Borhade
e3538546f2 Merge branch 'blender-v3.5-release' 2023-02-24 22:36:18 +05:30
Michael Jones
82ff277528 Fix #100066: Cycles hangs when MSL->AIR compilation fails
This fixes [#100066](https://projects.blender.org/blender/blender/issues/100066) by failing hard when front-end MSL->AIR compilation errors are encountered.

Pull Request #105122
2023-02-24 17:55:27 +01:00
Michael Jones
626c233dd2 Fix #104087: Cycles crashes (Metal / AMD)
This is a workaround for [issue #104087](https://projects.blender.org/blender/blender/issues/104087). We encounter crashes when using shader binary archives on AMD, so this disables them while we investigate a proper fix. Kernels will still be cached automatically by the OS file system cache. This cache may occasionally be purged due to external factors, in which case kernels will get compiled again.

Pull Request #105186
2023-02-24 17:52:35 +01:00
Brecht Van Lommel
25a5ff7670 Merge branch 'blender-v3.5-release' into main 2023-02-23 14:57:40 +01:00
Jason Fielder
4bfe4e5d49 Fix: Cycles display without OpenColorIO not working for Metal
Cycles fallback display shader previously did not use viewport.
This would crash or cause the display not to show when using
GPU backends other than OpenGL, if another display shader
was unavailable.

Now use ShaderCreateInfo for Cycles fallback display.

Authored by Apple: Michael Parkin-White

Ref #96261

Pull Request #104987
2023-02-23 14:25:08 +01:00
c8ed48d5ca Merge remote-tracking branch 'origin/blender-v3.5-release' 2023-02-23 11:28:02 +01:00
Michael Jones
482fb791ce Fix #105100: Metal using wrong kernels in multi-pass renders
This fixes issue [#105100](https://projects.blender.org/blender/blender/issues/105100) where multi-pass renders can be incorrect due to kernels using stale specialisation constants (e.g. when rendering Pokedstudio).

This patch adds a new group of md5 hashes (`global_defines_md5`) to track whether the injected block of #defines is stale and regenerate the source string as appropriate. It also renames the existing group of md5 hashes from `source_md5` to `kernels_md5` to clarify that these refer to a specific kernel set rather than just the source (which might build an arbitrarily large number of kernel sets).

Pull Request #105103
2023-02-23 11:07:28 +01:00
Harley Acheson
defd95afcd Win32: Auto-Raise and -Focus Windows on Hover
On the Windows platform, raise windows and give them focus as the mouse
hovers over them. This allows keyboard shortcuts for the area under the
mouse without having to click the window caption to make them active.

Pull Request #104681
2023-02-22 10:26:43 -08:00
Harley Acheson
8b63966236 Revert 104438: Windows Spanning Multiple Monitors
Revert of commits that allowed non-temp Blender windows to be saved
and restored that spanned multiple monitors on the Windows platform.
This causes problems with temp windows (like Preferences & Render) that
cannot currently be fixed.

See 104956 for much more details.

This change is being redone after it was accidentally reverted.

Differential Revision: https://projects.blender.org/blender/blender/pulls/104956

Reviewed by Ray Molenkamp
2023-02-21 15:45:45 -08:00
Sergey Sharybin
7fe42ea566 Merge branch 'blender-v3.5-release' 2023-02-21 16:50:35 +01:00
Sergey Sharybin
dd65e9901f Fix Light Tree option causing wrong renders on macOS AMD
The light tree itself is disabled on the AMD GPUs due to a compiler issue.

There are couple of places where this was not fully checked:

- The `light_sample` function in the kernel.
- The light threshold during synchronization

The former one is solved as easy as just adding an ifdef block.
The latter one is solved by delaying the threshold assignment for
later on.

Pull Request #105022
2023-02-21 16:50:06 +01:00
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