Commit Graph

12610 Commits

Author SHA1 Message Date
Campbell Barton
bb2dc141f2 Cleanup: spelling in comments 2023-03-27 12:08:14 +11:00
Campbell Barton
99d7816d06 Cleanup: suppress clang-tidy warnings in GHOST_Types.h 2023-03-27 11:07:27 +11:00
Campbell Barton
4e51008a82 GHOST: replace multiple functions with a single capabilities flag
Adding checks for platform capabilities involved adding functions
to multiple classes and was too involved.

Replace this with a single GHOST_System::getCapabilities() function.
2023-03-27 11:01:20 +11:00
Hans Goudey
cef82a1d39 Cleanup: Grammar: "it's" vs "its" 2023-03-24 08:34:21 -04:00
Campbell Barton
03cfa75bcc Merge branch 'blender-v3.5-release' 2023-03-24 22:42:33 +11:00
Campbell Barton
cb4f7cac24 Fix #106040: pasting long text fails in Gnome-Shell/Wayland
Workaround gnome-shell including uninitialized memory when pasting
from the clipboard. Where `read` would not write data into the range
return by the length.

Reading from the pipe into a power-of-two buffer
works around the problem.

It's not clear why this only impacts gnome-shell - as there is no
significant down-side to changing the buffer size, apply a workaround.

Ref !106091.
2023-03-24 22:25:26 +11:00
Campbell Barton
a016d142e8 Fix #106040: pasting long text fails in Gnome-Shell/Wayland
Workaround gnome-shell including uninitialized memory when pasting
from the clipboard. Where `read` woud

Reading from the pipe into a power-of-two buffer
works around the problem.

It's not clear why this only impacts gnome-shell - as there is no
significant down-side to changing the buffer size, apply a workaround.
2023-03-24 17:12:02 +11:00
Campbell Barton
3dcd4df70c UI: support the primary clipboard for console & 3D text selection
Only the text editor supported the primary clipboard & only for modal
selection. Now selecting text in the console & 3D text editing also
sets the primary clipboard under X11 & Wayland.

Notes:

- Pasting from the primary clipboard isn't yet exposed in the key-map
  so in practice it's only useful for pasting text outside of Blender.
- Use skip-save option when pasting from the primary selection
  so this is never used by the regular paste shortcut.
- This commit adds a primary-clipboard flag to WM_capabilities_flag() so
  creating the the copy-buffer is only performed when necessary.
2023-03-24 17:09:39 +11:00
Weizhen Huang
1111ce3472 Fix rotate around zero vector in #OrientationBounds 2023-03-23 18:42:39 +01:00
Jeroen Bakker
fda65ad5ca GPU: Renderdoc Frame Capturing
This PR uses renderdoc for frame capturing when enabled.
It enabled an easier workflow for frame capturing.

- Capture GPU API calls from test cases
- Capture GPU API calls from background threads
- Capture GPU API calls from background rendering.

Renderdoc is an important GPU debugger used by the Eevee/
Viewport module. Previously we needed to change code in
order to record background rendering, that could on its own
lead to other side-effects.

The integration with renderdoc can be enabled using
`WITH_RENDERDOC=On` compiler option. `GPU_debug_capture_begin`
and `GPU_debug_capture_end` can be added to the section
of the code you want to debug. When running Blender inside
renderdoc this part will automatically be captured.

All GPU test cases are now guarded by these calls. In order
to capture the test cases you need to start the test cases
from renderdoc and the captured GPU API calls will appear
where each capture is a single test case.

Pull Request: https://projects.blender.org/blender/blender/pulls/105921
2023-03-23 16:37:52 +01:00
Weizhen Huang
e77b666ae9 Fix normalize zero vector in light tree #OrientationBounds
was assuming such cases are already handled before this function is
called, but seems to be broken on windows and linux. Do
`safe_normalize()` so the tests pass, will check the problem afterwards.
2023-03-23 12:38:25 +01:00
Weizhen Huang
791f35e2c0 Fix rotation axis not normalized in light tree #OrientationBounds 2023-03-23 11:11:54 +01:00
Sergey Sharybin
b77e6aaa0f Fix warnings in Cycles graph test output
Harmless, but is quite noisy and easy to avoid.

Pull Request: https://projects.blender.org/blender/blender/pulls/105985
2023-03-23 09:55:54 +01:00
Campbell Barton
ebd7298594 Cleanup: avoid repeating defaults for pointer scroll under Wayland 2023-03-23 15:19:00 +11:00
Campbell Barton
e39b358a2f Guarded allocator: print memory-in-use as a size_t, not uint
There is no reason to cast to a smaller value which could overflow.
2023-03-23 14:20:14 +11:00
Brecht Van Lommel
16b93486ca Fix Cycles CUDA compiler warnings with if constexpr 2023-03-22 15:57:06 +01:00
Brecht Van Lommel
410ef5342e Fix Cycles build warning on Windows with unused argument 2023-03-22 15:57:06 +01:00
Campbell Barton
e4300bbf2d Cleanup: quiet warnings by using system-includes for ./extern/
extern/json & extern/fmtlib reported warnings with GCC 12.2.1.
As these libraries aren't maintained as part of Blender, treat them as
system-includes.
2023-03-22 14:18:14 +11:00
Campbell Barton
3afe88b6c7 Cleanup: cmake indentation 2023-03-22 14:14:15 +11:00
Campbell Barton
d3bab78d05 Merge branch 'blender-v3.5-release' 2023-03-22 12:25:26 +11:00
Campbell Barton
2ba1556e69 Cleanup: spelling in comments, use doxygen syntax 2023-03-22 12:22:55 +11:00
Campbell Barton
cf82e5fe57 Fix incorrect cursor size on Wayland with the RIVER compositor
Use XCURSOR_THEME & XCURSOR_SIZE environment variables for Wayland.
While this isn't an official part of the spec, many Wayland compositors
& applications use these variables.
2023-03-22 11:17:24 +11:00
Aras Pranckevicius
ed7c90c13b Cycles: fix build failure due to lack of std:: specifier 2023-03-21 18:15:45 +02:00
Weizhen Huang
17c8e0d309 Refactor Light Tree to improve readability and efficiency
* Group bounding box, bounding cone and energy to a struct called `LightTreePrimitivesMeasure`
* Add utility functions to add primitives to nodes or buckets
* Precompute the split bucket cost to improve efficiency (about 1.4x expected)

Pull Request: https://projects.blender.org/blender/blender/pulls/105931
2023-03-21 11:06:41 +01:00
Campbell Barton
f54af343f1 Merge branch 'blender-v3.5-release' 2023-03-21 12:57:20 +11:00
Campbell Barton
5332537fc5 Cleanup: add struct comments for GHOST/Wayland 2023-03-21 12:54:19 +11:00
Campbell Barton
5404841421 Merge branch 'blender-v3.5-release' 2023-03-21 11:53:44 +11:00
Campbell Barton
98272e5bb2 Fix #104272: Inverted (natural) option ignored on Wayland
Detect axis inversion, depends on the upcoming Wayland v1.22 release
which will need Linux libs to be upgraded too.
2023-03-21 11:47:10 +11:00
Weizhen Huang
23c5e06932 Cycles: build Light Tree in parallel
Push a task to `TaskPool` when more than `MIN_PRIMS_PER_THREAD` primitives are to be processed. The nodes are rearranged in a depth-first order when copied to the device.
Tested with the scene in #105550 on an Apple M1 Ultra (20 cores), about 11x speedup.

Pull Request: https://projects.blender.org/blender/blender/pulls/105862
2023-03-20 18:02:11 +01:00
Hans Goudey
16fbadde36 Mesh: Replace MLoop struct with generic attributes
Implements #102359.

Split the `MLoop` struct into two separate integer arrays called
`corner_verts` and `corner_edges`, referring to the vertex each corner
is attached to and the next edge around the face at each corner. These
arrays can be sliced to give access to the edges or vertices in a face.
Then they are often referred to as "poly_verts" or "poly_edges".

The main benefits are halving the necessary memory bandwidth when only
one array is used and simplifications from using regular integer indices
instead of a special-purpose struct.

The commit also starts a renaming from "loop" to "corner" in mesh code.

Like the other mesh struct of array refactors, forward compatibility is
kept by writing files with the older format. This will be done until 4.0
to ease the transition process.

Looking at a small portion of the patch should give a good impression
for the rest of the changes. I tried to make the changes as small as
possible so it's easy to tell the correctness from the diff. Though I
found Blender developers have been very inventive over the last decade
when finding different ways to loop over the corners in a face.

For performance, nearly every piece of code that deals with `Mesh` is
slightly impacted. Any algorithm that is memory bottle-necked should
see an improvement. For example, here is a comparison of interpolating
a vertex float attribute to face corners (Ryzen 3700x):

**Before** (Average: 3.7 ms, Min: 3.4 ms)
```
threading::parallel_for(loops.index_range(), 4096, [&](IndexRange range) {
  for (const int64_t i : range) {
    dst[i] = src[loops[i].v];
  }
});
```

**After** (Average: 2.9 ms, Min: 2.6 ms)
```
array_utils::gather(src, corner_verts, dst);
```

That's an improvement of 28% to the average timings, and it's also a
simplification, since an index-based routine can be used instead.
For more examples using the new arrays, see the design task.

Pull Request: https://projects.blender.org/blender/blender/pulls/104424
2023-03-20 15:55:13 +01:00
Weizhen Huang
7484a1504d Cleanup: rename function
The name #ensure_valid_reflection seems to indicate that the resulted
reflection must be valid, whereas in the reality it only ensure validity
for specular reflections. The new name matches the behavior better.
2023-03-20 14:35:02 +01:00
Weizhen Huang
dfe7b839bc Cycles: only apply function #ensure_valid_reflection to glossy materials
This function checks if the shading normal would result in an invalid reflection into the lower hemisphere; if it is the case, the function raises the shading normal just enough so that the specular reflection lies above the surface. This is a trick to prevent dark regions at grazing angles caused by normal/bump maps. However, the specular direction is not a good representation for a diffuse material, applying this function sometimes brightens the result too much and causes unexpected results. This patch applies the function to only glossy materials instead.

Pull Request: #105776
2023-03-20 14:35:02 +01:00
Weizhen Huang
70f3382c45 Refactor: simplify computations in function #ensure_valid_reflection
Actually both potential roots lie in the interval [0, 1], so the
function ended up checking both roots all the time.
The new implementation explains why only one of the roots is valid; it
saves two square roots and a bunch of other computations.
2023-03-20 14:35:02 +01:00
Campbell Barton
7cda559d7c Cleanup: format, spelling, struct member comment 2023-03-20 11:12:34 +11:00
Brecht Van Lommel
74de2e23a5 Merge branch 'blender-v3.5-release' 2023-03-17 21:53:51 +01:00
Brecht Van Lommel
cc6d8cd573 Fix #105442: Cycles CUDA and HIP host memory fallback not working
Transforming the host pointer should not be done in an assert, it only works
in debug builds then. Caused by 6dcfb6d.
2023-03-17 21:52:29 +01:00
Weizhen Huang
728694b4e4 Cleanup: use array instead of vector for LightTreeBucket with fixed size 2023-03-17 19:57:04 +01:00
Weizhen Huang
a1a11b08d8 Cleanup: added a bunch of const qualifiers in Light Tree 2023-03-17 19:57:04 +01:00
Weizhen Huang
d9273d8578 Fix Cycles growing BoundBox with empty BoundBox modifies the original BoundBox 2023-03-17 15:28:27 +01:00
Alaska
0963ee559e Cycles: adjust resolution divider to achieve a more usable viewport
This changes the maximum viewport resolution divider for Cycles to
help users get a more responsive viewport.

This is done by changing the maximum viewport resolution divider
to a divider that aims to have the largest axis of the viewport
roughly equal to 128 pixels.

Depending on the circumstances, this change can result in a few
noticeable differences:
 - Users with slow hardware and a large pixel_size, or slow hardware
 and a low resolution screen, may observe a higher resolution viewport
 during navigation, making the scene more readable. However this comes
 at the cost of reduced responsiveness.

 - Users with slow hardware and a low pixel_size and high
 resolution screen may observe a lower resolution viewport during
 navigation, providing a more responsive viewport during navigation.

Along with that, how Cycles iterates through resolution dividers
is changed to promote quick transitions between resolution dividers.
Meaning users don't need to wait through as many iterations to get
from a low navigation resolution to a 1:1 viewport resolution.

Pull Request: https://projects.blender.org/blender/blender/pulls/105581
2023-03-17 11:15:58 +01:00
Campbell Barton
b6b0bc4531 Cleanup: spelling in comments 2023-03-17 16:45:42 +11:00
Julian Eisel
7317da80fe Merge branch 'blender-v3.5-release' (won't build, see followup) 2023-03-16 15:26:23 +01:00
Brecht Van Lommel
4fba59c55d Fix #105803: Cycles slow light tree build when previewing shader nodes
When linking a texture directly to the material output, it's likely being
done for the purpose of previewing. In that case, bias the heuristic towards
not building a light tree, as it's likely not needed and slow on dense meshes.
2023-03-16 14:58:47 +01:00
Nikita Sirgienko
7ee0bf671e Cycles: use 8-bit type for number of ray hits when possible
INTEGRATOR_SHADOW_ISECT_SIZE is lower than 256 for GPUs, this allows
using only a 8-bit type for storing intersection counts there.
2023-03-15 22:01:48 +01:00
Nikita Sirgienko
f9922b7074 Cycles: Use ray->tfar in Embree filter functions
This allows to tell embree to stop intersecting beyond the distance
when max number of hits is reached.
2023-03-15 22:01:48 +01:00
Nikita Sirgienko
1a580dbfdd Cycles: Use IntegratorShadowState directly in Embree filter functions 2023-03-15 22:01:48 +01:00
Nikita Sirgienko
b97a6daa9a Cycles: Use geometryUserPtr from Embree filter functions arguments
This saves calls to rtcGetGeometryUserData.
2023-03-15 22:01:47 +01:00
Chris Blackbourn
59a083e948 Cleanup: format 2023-03-16 09:34:38 +13:00
Julian Eisel
30e517c3ca Merge branch 'blender-v3.5-release' 2023-03-15 13:07:26 +01:00
Michael Jones
089e8a1887 Cycles: Fix Metal API validation error (use uint instead of ushort)
This PR fixes an error that is given when Metal API validation is enabled. The compute grid can exceed 65536 threads so `ushort` is not sufficient for `metal_grid_id [[threadgroup_position_in_grid]]`.

This PR also fixes OS version warnings ([Cycles Metal: Unguarded access to newer macOS features #105630](https://projects.blender.org/blender/blender/issues/105630))

Pull Request: https://projects.blender.org/blender/blender/pulls/105763
2023-03-14 22:05:55 +01:00