1
1

Compare commits

...

892 Commits

Author SHA1 Message Date
RedMser
426c0865d3 Animation: Fix operator properties for redo panel
Animation: Fix operator properties for redo panel

After the redo panel is added to animation editors in D14960, many operators
must be adjusted to appear and function correctly.

A full list of changes is tracked in T98195

---

This patch only includes actual usability fixes. It does not do any changes for the user's convenience, like adding other helpful properties to operators. This can be done in a follow-up patch.

Reviewed By: sybren

Maniphest Tasks: T98195

Differential Revision: https://developer.blender.org/D14977
2022-08-01 12:21:05 +02:00
RedMser
87cc77d375 Animation: Add redo panel to Dopesheet and NLA
Animation: Add redo panel to Dopesheet and NLA

---

Also implicitly adds it for the timeline editor, since it's a kind of action editor internally.

This feature is needed for changing advanced properties of animation operators, such as select grouped (see D14811).
But it can also be useful for existing operators, like precise keyframe position tweaking.

Changes are basically the same as in D6286 (which added the redo panel for Graph Editor).

Some operators have internal properties that should be hidden. A full list can be found in T98195. These will be fixed in a follow-up patch.

{F13079611} {F13079612}

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14960
2022-08-01 12:20:40 +02:00
Jeroen Bakker
3393b7137e RenderReport: Add option to add platform specific overrides.
Reference images in the reference_override_dir will be chosen before
images in reference_dir. This allows platform specific reference
images, with a common base.

Ignored when set to None. The caller is responsible
of setting the reference override dir as the unit test is more aware
what the definition of a platform is.

Patch adds `gpu.platform.device_type_get` function to get the device
type that blender has detected.

Reviewed By: brecht

Maniphest Tasks: T99046

Differential Revision: https://developer.blender.org/D15265
2022-08-01 10:57:32 +02:00
6749a4a8f0 Cleanup: missing braces warning 2022-08-01 11:02:18 +10:00
ca172677b1 Cleanup: simplify uv parametrizer in preparation for C++
Replace `PChart` allocation with simpler calloc/free
2022-08-01 09:46:39 +12:00
17567c235a Cleanup: Remove mesh edge "tmp tag"
Ref T95966. Also fixes modification of input mesh,
which should be considered constant.
2022-07-31 11:56:44 -05:00
5b1ad3d7cf Merge branch 'blender-v3.3-release' 2022-07-31 18:32:26 +03:00
bea5281919 Fix T100075: OBJ import: images loaded multiple times instead of being reused
The new OBJ/MTL importer was creating a new image for any referenced
texture, even if another material (or another property of the same
material) already referenced the same texture. Make it use
BKE_image_load_exists function just like Collada or USD importers do.

Fixes T100075. Extended test coverage to count imported images;
without the fix import_cubes_with_textures_rel would have incorrectly
created 5 images instead of 4.
2022-07-31 18:10:48 +03:00
8c8c744f9d Merge branch 'blender-v3.3-release' 2022-07-31 13:19:35 +02:00
27e6962bed Fix T100086: GPencil Bezier curve edit not updated after smoothing
The stroke was recalculated, but the curve data was not updated.
2022-07-31 13:19:09 +02:00
a49b49d934 Cleanup: simplify uv parametrizer in preparation for C++
Replaces PCHART_HAS_PINS with `bool has_pins`.
2022-07-31 19:17:46 +12:00
3c5620aabd Cleanup: Move interface_region_tooltip.c and header to C++ 2022-07-30 16:40:41 -05:00
af6f0f1757 Fix failing blenlib test from previous commit
Commit 310be2e37c did not update UI_MENU_ARROW_SEP used in tests.
2022-07-30 09:27:32 -07:00
310be2e37c UI: UI_MENU_ARROW_SEP Unicode Character
Use a smaller arrow text character as menu item separator.

See D15578 for examples and details.

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

Reviewed by Julian Eisel
2022-07-30 07:54:12 -07:00
a581460728 UV: Add options for uv select similar in island mode
In island selection mode, add new options for uv select similar:

* Area UV
* Area 3D
* Face (number of faces in island)

See also https://developer.blender.org/T47437
Differential Revision: https://developer.blender.org/D15553
2022-07-30 23:24:11 +12:00
d31886b3fe Cleanup: braces around statements in OBJ parser 2022-07-30 13:10:35 +03:00
1a0fab56b4 Merge remote-tracking branch 'origin/blender-v3.3-release' 2022-07-29 23:23:07 -07:00
8ae14bc1d7 Fix 100035: Make UDIM detection less aggressive
There's been a handful of reports where "obviously" not a UDIM filenames
were detected as such during image open.[1]

This change makes the detection less aggressive by enforcing that the
4-digit sequence be delineated on both sides by one of the following 3
characters ., -, _

This fixes the problem for such filenames as:
"screenshot-1080p.png", "Image-1920x1080.png", "(1999) Photo.png", and
"antiguaChestnut_X_1240Wx814H.png"

[1] T97366 T98918 T99154 T100035

Differential Revision: https://developer.blender.org/D15573
2022-07-29 23:17:41 -07:00
aa7734c9da Cleanup: Clang tidy 2022-07-29 23:23:50 -05:00
599a7ddf17 Cleanup: Move five interface files to C++
Builds on all four platforms on the buildbot. Includes clang tidy fixes.
2022-07-29 23:22:31 -05:00
e6b1e97dd7 Sculpt: fix broken triangle/vertex count for DynTopo 2022-07-29 19:12:40 -07:00
d7cfb6ac71 Sculpt: Opaque vertex type for sculpt
This is a port of sculpt-dev's `SculptVertRef` refactor
(note that `SculptVertRef was renamed to PBVHVertRef`)
to master. `PBVHVertRef` is a structure that abstracts
the concept of a vertex in the sculpt code; it's simply
an `intptr_t` wrapped in a struct.

For `PBVH_FACES` and `PBVH_GRIDS` this struct stores a
vertex index, but for `BMesh` it stores a direct pointer
to a BMVert.  The intptr_t is wrapped in a struct to prevent
the accidental usage of it as an index.

There are many reasons to do this:

* Right now `BMesh` verts are not logical sculpt verts;
  to use the sculpt API they must first be converted to indices.
  This requires a lot of indirect lookups into tables, leading to performance
  loss.  It has also led to greater code complexity and duplication.
* Having an abstract vertex type makes it feasible to have one unified
  temporary attribute API for all three PBVH modes, which in turn
  made it rather trivial to port sculpt brushes to DynTopo in
  sculpt-dev (e.g. the layer brush, draw sharp, the smooth brushes,
  the paint brushes, etc).  This attribute API will be in a future patch.
* We need to do this anyway for the eventual move to C++.

Differential Revision: https://developer.blender.org/D14272
Reviewed By: Brecht Van Lommel
Ref D14272
2022-07-29 19:03:51 -07:00
27a16abe81 Sculpt: fix name collision in DynTopo temp attributes
The attributes PBVH_BMESH uss to store the owning node
for vertices and faces were being created with the same
name, which is no long allowed.
2022-07-29 18:58:36 -07:00
9b9417b661 Cleanup: Replace reinterpret_cast<> with static_cast<> in UI code 2022-07-29 18:45:12 +02:00
03cd794119 Fix attempt for MSVC build error after 42ccbb7cd1 2022-07-29 18:10:26 +02:00
091156f64a Merge branch 'blender-v3.3-release' 2022-07-29 18:00:50 +02:00
Brecht Van Lommel
cfd16c04f8 Build: hide all symbols except a few required ones on Linux
Instead of specifying which symbols to hide, we hide all and make a few
visible. Some users may be relying on calling internal Blender functions,
but Windows is already hiding all of them and this is just not supported.

Fixes T99900: crash with some third-party Python libraries since OneAPI

Ref T76442

Differential Revision: https://developer.blender.org/D14971
2022-07-29 17:54:32 +02:00
42ccbb7cd1 Cleanup: Move RNA path functions into own C++ file
Adds `rna_path.cc` and `RNA_path.h`.

`rna_access.c` is a quite big file, which makes it rather hard and
inconvenient to navigate. RNA path functions form a nicely coherent unit
that can stand well on it's own, so it makes sense to split them off to
mitigate the problem. Moreover, I was looking into refactoring the quite
convoluted/overloaded `rna_path_parse()`, and found that some C++
features may help greatly with that. So having that code compile in C++
would be helpful to attempt that.

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

Reviewed by: Brecht Van Lommel, Campbell Barton, Bastien Montagne
2022-07-29 16:56:48 +02:00
187d90f036 Merge branch 'blender-v3.3-release' 2022-07-29 15:33:25 +02:00
1665e40e16 install_deps: Add handling of libaom, update ffmpeg build for it.
Ref T98555.
2022-07-29 15:32:02 +02:00
d3879e9aaa Merge branch 'blender-v3.3-release' 2022-07-29 15:17:40 +02:00
065dfe744c install_deps: bump IMath/OpenEXR to 3.1.5.
Ref T98555.
2022-07-29 15:17:15 +02:00
3a138a74e5 install_deps: add building of Alembic binaries.
Those are used by alembic regression tests.
2022-07-29 15:17:15 +02:00
Tianhao Chai
b862cf0b9f Fix Cycles build error with CUDA on arm64
Checking arm64 assembly support before CUDA/Metal would cause NVCC to
generate inline arm64 assembly.

Differential Revision: https://developer.blender.org/D15569
2022-07-29 14:57:09 +02:00
a679164cf6 Merge branch 'blender-v3.3-release' 2022-07-29 12:25:31 +02:00
ae0b8e904c Fix (unreported) lib-linking of ID properties not taking library parameter.
While this was not a critical issue (that lib pointer is only used for
some kind of sanity check that no linked data uses local ID pointers),
better to keep `IDP_BlendReadLib` in sync with all other lib-linking
code.
2022-07-29 12:25:15 +02:00
b639e60864 Realtime Compositor: Add needed GPU module changes
This patch implements the necessary changes to the GPU module that are
needed by the realtime compositor.

A new function GPU_material_from_callbacks was added to construct a GPU
material from a number of callbacks. A callback to construct the
material graph by adding and linking the necessary GPU material nodes.
And the existing code generator callback. This essentially allows the
construction of GPU materials independent of node trees and without the
need to do any node tree localization.

A new composite source output to the code generator was added. This
output contains the serialization of nodes that are tagged with
GPU_NODE_TAG_COMPOSITOR, which are the nodes linked to the newly added
composite output links.

Two new GPU uniform setters were added for int2 and matrix3 types.

Shader create info now supports generated compute sources.

Shaders starting with gpu_shader_compositor are now considered part of
the shader library.

Additionally, two fixes were implemented. First, GPU setter node
de-duplication now appropriately increments the reference count of the
references resources. Second, unlinked sockets now get their value from
their associated GPU node stack instead of the socket itself.

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

Reviewed By: Clement
2022-07-29 08:47:52 +02:00
c3ca487498 Render: Propagate view updates to draw engines
Currently, draw engines are not notified of view updates if a render
engine is active and was updated. It is unclear why this is the case
currently, but this behavior was part of the initial commit.

This patch propagates view updates regardless if the update was handled
by an active render engine. This is needed by the realtime compositor as
it implements logic for view updates, which currently does not execute
if Cycles is rendering for instance.

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

Reviewed By: Brecht
2022-07-29 08:30:51 +02:00
4815772fda Cleanup: quiet warnings in recent BLF and rna_ui changes 2022-07-29 13:48:09 +10:00
e9bd6abde3 BLF: New Font Stack for Better Language Coverage
Replace our existing two fonts with a stack of new fonts to increase
and improve language coverage and to add many new symbols and icons.
Covers glyphs of top 44 languages - 1.5 billion more potential users.

See D10887 for lots of details.

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

Reviewed by Brecht Van Lommel
2022-07-28 20:09:20 -07:00
c0845abd89 BLF: Fonts with FT_Face Optional
Allow FontBLFs to exist with NULL FT_Face, added only when actually
needed. Speeds up startup and unused fonts are not loaded.

See D15258 for more details.

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

Reviewed by Brecht Van Lommel
2022-07-28 17:50:34 -07:00
848dd4a40a BLF: Don't Print Empty Strings
Optimize font drawing by skipping empty strings.

See D15472 for more details.

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

Reviewed by Campbell Barton
2022-07-28 17:28:05 -07:00
e261290cb6 Merge branch 'blender-v3.3-release' 2022-07-28 17:40:42 -05:00
6ca602dd9f Fix T99761: Curves sculpt mode crash with empty curves
The virtual arrays may be null if the curves are empty,
it's simple to just skip the domain interpolation completely.
2022-07-28 17:39:10 -05:00
a9c74a0cd0 Fix set iterator test failure on macOS
This is a quite interesting case, where two arguments to a function are
evaluated in different order on Apple Clang than on GCC and I guess
MSVC. Left a comment on that.
2022-07-28 23:53:33 +02:00
3d91a853b2 Cleanup: Nodes: Store node group idname in tree type
There was already a utility to retrieve the correct node group idname
from the context, `node_group_idname`, but often it's clearer to
use lower-level arguments, or the context isn't accessible.
Storing the group idname in the tree type makes it accessible
without rewriting it elsewhere.
2022-07-28 16:34:17 -05:00
4757a5ad33 Cleanup: Make BKE_idprop.h self sufficient
It relied on uint, which is defined in a separate header.
2022-07-28 16:20:36 -05:00
eea1f9b1df Merge branch 'blender-v3.3-release' 2022-07-28 16:08:36 -05:00
1adeae56e6 Fix: Grammar mistake in info message 2022-07-28 16:08:20 -05:00
5c2fff306e Cleanup: Use LISTBASE_FOREACH macro 2022-07-28 16:02:46 -05:00
72d8a40a3d Cleanup: Use const context argument for UIList callbacks 2022-07-28 16:02:15 -05:00
cf61be6190 Cleanup: Use new IDProperty creation API for geometry ndoes modifier
Use the API from 36068487d0 instead
of the uglier `IDPropertyTemplate` API.
2022-07-28 15:50:39 -05:00
543ea41569 Cleanup: Remove unused node "add and link node" operator
The link drag search from 11be151d58 implements
this now. It was added in 3ebe7d970e but never used.
2022-07-28 15:40:32 -05:00
19528cfecd Merge branch 'blender-v3.3-release' 2022-07-28 21:31:14 +02:00
79ab76e156 Cleanup: simplifications and consistency for vector types
* OneAPI: remove separate float3 definition
* OneAPI: disable operator[] to match other GPUs
* OneAPI: make int3 compact to match other GPUs
* Use #pragma once
* Add __KERNEL_NATIVE_VECTOR_TYPES__ to simplify checks
* Remove unused vector3
2022-07-28 21:27:13 +02:00
fb42c5838c Revert "Fix T98773: GPU Subdivision breaks auto selection in UV edit mode"
This reverts commit e2c02655c7. It was already
reverted in the 3.2 branch, as it caused more serious issues than it solved.

Fixes T99805, T99323, T99296.
2022-07-28 21:20:51 +02:00
d094a3722c Fix wrong post-increment operators & test for BLI containers 2022-07-28 20:45:28 +02:00
9c65af2df0 Merge branch 'blender-v3.3-release' 2022-07-28 21:27:14 +03:00
68db023329 ID namemap: fix missing removal of old name in do_versions_rename_id
Was causing an assert that the old name exists in the name map, but
is not present in the actual database. Reported in #blender-coders
2022-07-28 21:26:30 +03:00
ae89fcfdaf Merge branch 'blender-v3.3-release' 2022-07-28 14:36:49 -03:00
fafb901baa PyDoc: fix 2D builtin shaders documentation
2D shaders require the `vec2` attribute for "pos" (not `vec3`)
2022-07-28 14:36:07 -03:00
2b9d4af261 EEVEE-Next: UI: Make Vector pass greyed out when motion blur is enabled
Also clears the render result to 0 to avoid invalid motion vectors.
2022-07-28 17:01:05 +02:00
53fc9add51 EEVEE-Next: Cleanup: Isolate render result readback and prototype progress
Still not working but the idea is to read the result and display the
first image sample so that user has a better feedback of the
rendering.
2022-07-28 17:01:05 +02:00
1e0aa2612c EEVEE-Next: Motion Blur new implementation
The new implementation leverage compute shaders to reduce the
number of passes and complexity.

The max blur amount is now detected automatically, replacing the property
in the render panel by a simple checkbox.

The dilation algorithm has also been rewritten from scratch into a 1 pass
algorithm that does the dilation more efficiently and more precisely.

Some differences with the old implementation can be observed in areas with
complex motion.
2022-07-28 17:01:05 +02:00
82327ce01d DRW: TextureFromPool: Change API to use acquire / release
This removes the quirk of having to call the sync function for each new
render loop.

# Conflicts:
#	source/blender/draw/engines/eevee_next/eevee_view.cc
2022-07-28 17:00:46 +02:00
0830ff55d8 EEVEE-Next: Fix Vector render pass 2022-07-28 16:58:01 +02:00
aacdaa7b1a Merge branch 'blender-v3.3-release' 2022-07-28 16:32:27 +02:00
ea23e937ce Cleanup/refactor: Readfile: Add dedicated function to insert ID pointers in libmap.
New `oldnewmap_lib_insert` does nothing special, it just wraps around existing
`oldnewmap_insert`, but it's the logical counter part of `oldnewmap_liblookup`.

It also helps tremendously when debuging complex ID pointers issues in
readfile.c code.
2022-07-28 16:29:57 +02:00
f3be8e66d7 Fix (studio-reported) crash in some rare cases in blendfile read code.
Crash would happen when a linked ID would become missing, that was
'pre-declared' and used only once as a 'weak link' in another library
stored before the one it came from.

In that case, the place-holder generated in read code would be freed in
`read_library_clear_weak_links`, when handling its 'owner' library, but
since all previous libraries in the list had already been 'lib_linked'
and their filedata (and related libmap) freed, the update of the libmaps
in `read_library_clear_weak_links` would not apply to data from those
previous libraries, leading to ID pointers there pointing to freed
memory.

This fix should also be backported to 2.93.
2022-07-28 16:29:57 +02:00
69bf74bd76 Merge branch 'blender-v3.3-release' 2022-07-28 16:40:37 +03:00
c49717a824 Fix T100017: OBJ: new importer does not import vertices that aren't part of any face
The Python based importer had a special case handling of "no faces in
the whole file at all", where it ended up treating the whole file
as essentially a point-cloud-like object (just loose vertices, no
faces or edges). The new importer code was missing this special case.

Fixes T100017. Added gtest coverage that was failing without the fix.
2022-07-28 16:39:42 +03:00
Iliay Katueshenock
07e201ec13 Geometry Nodes: add assert to check if node supports lazyness
Only nodes supporting lazyness can mark inputs as unused. For other
nodes, this is done automatically of all outputs are unused.

Differential Revision: https://developer.blender.org/D15409
2022-07-28 13:39:40 +02:00
d892f96cb1 Cleanup: Fix typo in comment 2022-07-28 12:52:20 +02:00
d034c28f51 Merge branch 'blender-v3.3-release' 2022-07-28 11:42:46 +02:00
ccb9d5d307 Curves: enable density brush when first entering curves sculpt mode
Previously, no tool was selected, which was a bug.
2022-07-28 11:41:36 +02:00
aa7d130347 Curves: improve handling of empty surface meshes 2022-07-28 11:37:35 +02:00
6ae9565d06 Cleanup: quiet GCC stringop-overflow warning 2022-07-28 16:08:59 +10:00
d41f0c7b15 Cleanup: unused header 2022-07-28 16:01:29 +10:00
a98102e32e Merge branch 'blender-v3.3-release' 2022-07-28 09:39:57 +10:00
8d4fa03e5c BLI_math: improve symmetrical values from sin_cos_from_fraction
When plotting equally distant points around a circle support an extra
axis of symmetry so twice as many exact values are repeated than
originally added in [0], see code-comments for a detailed explanation.
Tests to ensure accuracy and exact symmetry have been added too.

Follow up on fix for T87779.

[0]: 087f27a52f
2022-07-28 09:39:54 +10:00
397731d4df BLI_math: improve symmetrical values from sin_cos_from_fraction
When plotting equally distant points around a circle support an extra
axis of symmetry so twice as many exact values are repeated than
originally added in [0], see code-comments for a detailed explanation.
Tests to ensure accuracy and exact symmetry have been added too.

Follow up on fix for T87779.

[0]: 087f27a52f
2022-07-28 09:34:46 +10:00
ff048f5d27 Curves: Avoid virtual function overhead when finding selected curves
This showed up on a profile of sculpting with the comb brush.
Use a span instead of a virtual array.
2022-07-27 15:41:32 -05:00
165fa9e2a1 Merge branch 'blender-v3.3-release' 2022-07-27 21:26:18 +02:00
38af5b0501 Cycles: switch Cycles triangle barycentric convention to match Embree/OptiX
Simplifies intersection code a little and slightly improves precision regarding
self intersection.

The parametric texture coordinate in shader nodes is still the same as before
for compatibility.
2022-07-27 21:03:33 +02:00
69f2732a13 Cleanup: remove unnecessary bvh_instance_motion_pop 2022-07-27 21:02:21 +02:00
cd47d1b2ed Fix broken BVH2 on CPU after recent changes
Runtime switching between Embree and BVH2 got lost.
2022-07-27 20:58:02 +02:00
55fb2abc81 Curves: Bring back parallel copying of curve and point attributes
This was removed in cacdea7f4a to fix a bug, but copying point
and curve attributes should be fine as long as the attribute arrays are
retrieved before-hand.

Differential Revision: https://developer.blender.org/D15541
2022-07-27 11:52:11 -05:00
0dcfd93c6e Fix: curves edit hints not propagated in Join Geometry node
Found while investigating why crazy-space editing didn't work in T100026.
2022-07-27 18:38:45 +02:00
6e5eb46d73 Fix T100026: crash with zero-sized attributes
The problem was that zero-sized and non-existant attributes were
handled the same in some parts of the attribute API, which led to
unexpected behavior.

The solution is to properly differentiate the case when an attribute
does not exist and when it is just empty (because the geometry
is empty).

Differential Revision: https://developer.blender.org/D15557
2022-07-27 18:20:22 +02:00
d6b970dd7b Merge branch 'blender-v3.3-release' 2022-07-27 18:07:29 +02:00
84a3ff63d0 Fix: missing evaluated offsets in Resample Curve node
Differential Revision: https://developer.blender.org/D15556
2022-07-27 18:05:31 +02:00
84272ce19a Fix: add missing return
It was correct but less efficient without this early return.
2022-07-27 17:54:49 +02:00
5560da7ceb Revert "Blender 3.3 splashscreen"
This reverts commit d61ab45385.
2022-07-27 17:32:21 +02:00
37ebd66570 Revert "Blender 3.3 - Beta"
This reverts commit 32a9aac3b8.
2022-07-27 17:32:05 +02:00
3b71a62390 Merge branch 'blender-v3.3-release' 2022-07-27 17:31:49 +02:00
d61ab45385 Blender 3.3 splashscreen
Credits: Piotr Krynski
2022-07-27 17:25:56 +02:00
b2dd1f8f01 Fix build include for rna_curves.c
* Since curves are no longer experimental, this should be included at any time.
2022-07-27 17:19:15 +02:00
32a9aac3b8 Blender 3.3 - Beta
* BLENDER_VERSION_CYCLE set to beta
* Update pipeline_config.yaml to point to 3.2 branches and svn tags
* Update and uncomment BLENDER_VERSION in download.cmake
2022-07-27 17:14:21 +02:00
9015952c9c Blender 3.4 Alpha: Start of new release cycle. 2022-07-27 16:53:19 +02:00
83362f87bb Blender 3.3: Finalizing version bump. 2022-07-27 16:33:49 +02:00
415f88d8b0 Fix wrong fileversion usage in own recent rB9ac81ed6abfb. 2022-07-27 16:20:50 +02:00
ea4b1d027d Geometry Nodes: Rename "Field on Domain" to "Interpolate Domain"
This name doesn't require understanding of fields, and
is phrased as an action which is consistent with other nodes.
Discussed in the latest geometry nodes sub-module meeting.
2022-07-27 08:56:17 -05:00
Erik Abrahamsson
c8ae1fce60 Geometry Nodes: Shortest Paths nodes
This adds three new nodes:
* `Shortest Edge Paths`: Actually finds the shortest paths.
* `Edge Paths to Curves`: Converts the paths to separate curves.
  This may generate a quadratic amount of data, making it slow
  for large meshes.
* `Edge Paths to Selection`: Generates an edge selection that
  contains all edges that are part of a path. This can be used
  with the Separate Geometry node to only keep the edges that
  are part of a path. For large meshes, this approach can be
  much faster than the `Edge Paths to Curves` node, because
  less data is created.

Differential Revision: https://developer.blender.org/D15274
2022-07-27 15:38:44 +02:00
9ac81ed6ab Fix corrupted blend files after issues from new name_map code.
Add a version of #BKE_main_namemap_validate that also fixes the issues,
and call it in a do_version to fix recent .blend files saved after the
regression introduced in rB7f8d05131a77.

This is mandatory to fix some production files here at the studio, among
other things.
2022-07-27 15:33:29 +02:00
9f53272df4 Fix more issues with new name map and liboverrides.
Follow-up to rB13e17507c069, forgot to handle shapekeys...
2022-07-27 15:33:29 +02:00
58dcd20998 ID namemap: Fix more issues when changing libs.
Fix tests, and some issue when making an ID local.

There are probably a few more issues still though.
2022-07-27 15:33:29 +02:00
Amelie Fondevilla
4843b161d6 Fix T99870 : Prevents crash when rearranging channels in dopesheet
The function to rearrange channels only works for F-curves channels for now, adding the `FCURVESONLY` filter prevents the function to be called for grease pencil channels, thereby fixing the crash.

Reviewed by : sybren
Differential Revision: http://developer.blender.org/D15504
2022-07-27 11:40:44 +02:00
7324f32a94 ID namemap tests: Use consistency check, fix an issue.
Massively use the new consistency check in namemap regression tests, and
fix an issue with library data tests revealed by those checks.
2022-07-27 11:22:48 +02:00
18dc611b40 ID namemap: Add check for consistency.
Add a util function to check that content of a given Main and the
namemaps in it are consistent.

Add some asserts calling this check after file read, and after some
override operations.
2022-07-27 11:22:48 +02:00
1e55b58e4f UI: Sort tools in curves sculpting mode
The previous order was based on the order of when the tools were
developed. Instead we now cluster them based on similar functionality:

* Selection
* Add/Remove
* Deform/Transform
* Annotation

Done in collaboration with Pablo Vazquez.
2022-07-27 11:15:48 +02:00
13e17507c0 Fix crashes due to non-uniqueness in ID names in some cases.
Liboverrides are doing some very low-level manipulation of IDs in apply
code, to reduce over-head of name and sorting handling.

This requires specific care to ensure thatr the new namemap runtime data
remains up-to-date and valid. Otherwise, names of existing IDs would be
missing from the map, which would later lead to having several different
IDs with the same name. Critical corruption in Blender ID management.

Reported by animators at the Blender studio.

Regression from rB7f8d05131a77.
2022-07-27 11:10:45 +02:00
4dd409a185 Fix T99976: Animated visibility not rendering properly in viewport
A mistake in the 0dcee6a386 which made specific driven visibility
to work, but did not properly handle actual time-based visibility.

The basic idea of the change is to preserve recalculation flags of
nodes which were tagged for update but were not evaluated due to
visibility constraints. In the file from the report this makes it
so tagging which is done first time ID is in the dependency graph
are handled when the ID actually becomes visible. This is what
solved the root of the problem from the report: there was missing
geometry update since it was "swallowed" by the evaluation during
the object being invisible. In other configurations this change
allows to handle pending geometry updates due to animated modifiers
be handled when object becomes visible without time change.

This change also solves visibility issue of the synchronization
component which also started to be handled badly since the
previous fix attempt. Basically, the needed exception in its
visibility handling did not happen and a regular logic was used
for it.

Tested with files from the T99733, T99976, and from the Heist
project.

Differential Revision: https://developer.blender.org/D15544
2022-07-27 10:19:42 +02:00
d706d0460c Cycles oneAPI: simplify num_concurrent_states selection
The number of Execution Units and resident "threads" (simd width * threads
per EUs) are now exposed and used to select the number of states using
a simplified heuristic.
2022-07-27 09:45:33 +02:00
38e270ae30 Cleanup: Move wm_dragdrop.c to C++ 2022-07-26 23:15:33 -05:00
e67710b908 deps/oiio: fix build issue on windows
tiff now outputs tiffd.lib for debug builds
oiio was not informed about this and had
a build error because of it.
2022-07-26 20:59:44 -06:00
f43a8835dc deps/alembic: add missing imath dependency
if alembic builds before imath it'll cause a build error.
2022-07-26 20:54:27 -06:00
Jun Mizutani
2ca18e78f9 Sculpt: Remove debug printf
Reviewed By: Joseph Eagar
Differential Revision: D15547
Ref D15547
2022-07-26 14:25:58 -07:00
b75d0c7e7a Geometry Nodes: Implement link drag search for two nodes
It was never added for the field on domain and field at index nodes.
They need special handling because they have many what should be
a multi-type socket declaration.
2022-07-26 16:12:42 -05:00
f14f81e5ac Nodes: Allow using escape key to exit node resizing 2022-07-26 16:03:43 -05:00
faa0c7aa6f Cleanup: Move mesh_tessellate.c to C++ 2022-07-26 14:41:34 -05:00
Falk David
88f0d483bd Python: Expose property to mute action groups
This patch adds a `mute` RNA property on `ActionGroup`s that allows them to be easily muted/unmuted from python.
This uses the existing `AGRP_MUTED` flag which was also accessible from the user interface.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15329
2022-07-26 21:32:05 +02:00
8571093f99 GPencil: Small UI change in overlay for consistency
To keep consistency is better add the word `Inactive` for `Fade Layers` and `Fade Objects`  to keep the same naming used in other areas of the overlay panel.

Reviewed by: Matias Mendiola
2022-07-26 16:39:17 +02:00
2b8e35eeb0 Fix T99984: Small GPencil overlay UI bugs in Edit Mode
This commit fixes the opacity for curves hiding the option.

Actually, the curve points and handles drawing is using the same code that mesh curves and the opacity is not supported. While this feature will be added for mesh curves and gpencil, now it's better to hide this option.

Reviewed: Matias Mendiola

Note: The handle problem reported in this task was fixed in  a separated commit: 203e7ba332
2022-07-26 16:34:27 +02:00
1998269b10 Refactor: Extract color attributes as generic attributes
Previously there was a special extraction process for "vertex colors"
that copied the color data to the GPU with a special format. Instead,
this patch replaces this with use of the generic attribute extraction.
This reduces the number of code paths, allowing easier optimization
in the future.

To make it possible to use the generic extraction system for attributes
but also assign aliases for use by shaders, some changes are necessary.
First, the GPU material attribute can now store whether it actually refers
to the default color attribute, rather than a specific name. This replaces
the hack to use `CD_MCOL` in the color attribute shader node. Second,
the extraction code checks the names against the default and active
names and assigns aliases if the request corresponds to a special active
attribute. Finally, support for byte color attributes was added to the
generic attribute extraction.

Differential Revision: https://developer.blender.org/D15205
2022-07-26 08:37:38 -05:00
5945a90df9 Fix T98788: bad first curve tangent when first points have same position 2022-07-26 15:25:59 +02:00
72f77598a2 Fix T98798: tag collection geometry when changing instance offset
Changing the instance offset moves the entire "collection geometry".
So other features that depend on the geometry should be reevaluated.
2022-07-26 14:59:40 +02:00
ac1554bcf6 Fix T98982: cannot change default value of some node group input types 2022-07-26 14:49:12 +02:00
5aba7f9774 Geometry Nodes: Hide value button for field at index node
Changing the value doesn't accomplish anything, since the retrieved
value would be the same for every index then. So it's best to hide it
to make the node clearer.
2022-07-26 07:42:32 -05:00
78b7140b02 deps: update TIFF and OpenEXR
* OpenEXR 3.1.4 -> 3.1.5, this fixes several issues OSS fuzz found.
* libtiff 4.3.0 -> 4.4.0, this fixes several CVE's.

This also converts the harvest of libtiff on windows to a post install handler,
there's a few left but Windows is getting close to being harvest free.

Differential Revision: https://developer.blender.org/D15478
2022-07-26 13:25:58 +02:00
aa788b759a deps: FFmpeg vpx/aom-av1 updates
This is a refresh of our current FFmpeg 5.0.0 (unchanged) version with the
following changes:

* libvpx all platforms: enable SSE3/4/AVX/AVX2 instruction sets. libvpx has a
  proper CPUID check in place and will not call the faster kernels unless it is
  sure the CPU supports it. So we can safely enable this, this partially
  resolves T95743 (completely on Linux and macOS).

* libvpx Windows - threading was disabled due to a shared dependency on
  libwinpthreads.dll which we prefer not to distribute. However when configure
  cannot find pthreads it will happily fall back on a win32 threads based
  emulation layer. This also resolves the final part of T95743.

* libaom-av1 - new dependency required for D14920, this is a somewhat odd
  dependency, it's cmake based, but still needs the perl environment setup, so
  we have to setup the env and call cmake our selves for the configure, build
  and install commands. This dep has the same libwinpthreads issue as vpx on
  Windows, however since it's cmake based, it's easier to prevent cmake from
  detecting it.

Differential Revision: https://developer.blender.org/D15399
2022-07-26 13:25:58 +02:00
caf907626d Fix T99271: modifier errors are not cleared 2022-07-26 13:01:30 +02:00
c5712c6795 Fix T99373: add some padding in spreadsheet vector columns
This improves readability in some cases (e.g. in T99373).
2022-07-26 12:36:44 +02:00
Nate Rupsis
b08c5381ac default N-panel open for animation editors
The Graph, Driver, and Dopesheet's (and sub modes) properties panel
(N-Panel) are now open by default. This includes the editors in the
default Animation workspace.

Note that, because the Timeline is implemented as a special mode of the
Dopesheet, switching between Timeline and Dopesheet will *not* change
the visibility of the properties panel.

Maniphest Tasks: T97980

Differential Revision: https://developer.blender.org/D14910
2022-07-26 11:43:05 +02:00
e4a779264c Partially revert "Build: Fix build of library dependencies on Linux aarch64"
This reverts the Flex-related parts of commit
rBef268c78933079137288e326704431432adf9ad9, as those caused a build
error on CentOS 7 (which is used for the precompiled Linux libraries).

CentOS 7 only has Automake 1.13, whereas after this commit version 1.15
seems to be required.

Since in its patch description (D15319) it's mentioned that this
"probably doesn't warrant changing", and it's actually blocking the
build of the precompiled libraries for Blender 3.3 now, I'll revert the
Flex-related part of the commit.
2022-07-26 11:43:05 +02:00
Iliay Katueshenock
c94ca54cda BLI: add use_threading parameter to parallel_invoke
`parallel_invoke` allows executing functions on separate threads.
However, creating tasks in tbb has a measurable amount of overhead.
Therefore, it can be benefitial to disable parallelization when
the amount of work done per function is small.

See D15539 for some benchmark results.

Differential Revision: https://developer.blender.org/D15539
2022-07-26 11:10:16 +02:00
203e7ba332 GPencil: Update curve handle display after change overlay option
The handles were not updated after changing the settings.

This is a partial fix of T99984
2022-07-26 11:07:28 +02:00
c597d6cb64 Fix T99979: GPencil strokes cannot be edited after set origin
The stroke points were changed but the bounding box calculation was not done and this produced a problem in any bounding box check done by different tools.
2022-07-26 10:53:08 +02:00
c869f54dcb Cleanup: Typo in comments: data-lock -> data-block. 2022-07-26 10:00:20 +02:00
bdb4ebebf1 Cleanup: quiet GCC cast-function-type warnings for gflags 2022-07-26 14:47:12 +10:00
c3bc53162a Cleanup: format 2022-07-26 13:23:45 +10:00
f1f89ca751 Cleanup: spelling in comments 2022-07-26 13:21:21 +10:00
3ae85a0d8f Fix Python SystemExit exceptions silently exiting
Any script that raised a SystemExit called by --python, --python-expr
command line args or by executing the text block would exit without
printing a message. This caused the error from T99966 to be hidden.

Add explicit handling for SystemExit to ensure the message is always
shown before exiting.

More details noted in code-comments.
2022-07-26 13:21:15 +10:00
37ad72ab23 Fix T99966: Python API docs fail to generate
The recent addition of "active_action" [0] required updating in the
API docs type information.

[0]: cd21022b78
2022-07-26 12:51:01 +10:00
4cf6524731 Fix Cycles Metal build errors after recent changes
float8 is a reserved type in Metal, but is not implemented. So rename to
float8_t for now.

Also move back intersection handlers to kernel.metal, they can't be in the
class that encapsulates the other Metal kernel functions.
2022-07-26 00:17:37 +02:00
f76a2c0d18 Fix: Fix attribute writer debug warnings in terminal
Use an imperfect solution, since this code will be replaced soon anyway.
2022-07-25 16:06:28 -05:00
462f99bf38 Sculpt: Fix T99779, pbvh gets wrong active vertex for multires
The recent multires winding fix missed a code branch.
2022-07-25 11:53:48 -07:00
fb9f12eeec UI: Nishita sky: Increase Sun Elevation UI sensitivity and remove min/max
This now use default angle precision which matches the sun rotation.
Feeling is much more natural.
2022-07-25 19:26:12 +02:00
46dbfce7fc Cycles: Nishita Sky: Fix sun disk imprecision for large elevation
The issue was introduced by rBad5e3d30a2d2 which made possible to use
unbounded elevation angle.

In order to not touch the shading code, we just remap the value to the
expected range the shading code expects. This means that elevation angles
above +/-PI/2 effectively flip the sun rotation angle.
2022-07-25 19:26:12 +02:00
703dff333c Fix T99459: GPencil: Fill tool on the surface not in the correct place
There is a 1 pixel error in the size registered for the buffer
dimensions.

NOTE: This issue indicates that the texture scale is different from the
region, so the mouse-based coordinates used are actually misaligned.
This misalignment will be fixed in another commit.

Regression probably introduced in rB1d49293b8044 + rB45f167237f0c8
2022-07-25 14:13:48 -03:00
00a3533429 Curves: Unify poll functions, add message with no surface
The "snap to surface" operators now have "disabled" poll messages
when there is no surface object.

The implementation in most curves operators is also unified.
The goal is to avoid having to define and use the poll failure messages
in multiple places, to reduce the boilerplate that tends to be
necessary to add an operator, and to increase the likelihood that
operators are implemented with proper poll messages.

Differential Revision: https://developer.blender.org/D15528
2022-07-25 11:59:33 -05:00
739136caca Fix: Assert in resample curve node with single point curve 2022-07-25 11:53:22 -05:00
f26aa186b2 Cleanup: remove __KERNEL_CPU__
This was tested in some places to check if code was being compiled for the
CPU, however this is only defined in the kernel. Checking __KERNEL_GPU__
always works.
2022-07-25 17:43:35 +02:00
Andrii Symkin
793d203139 Cycles: add math functions for float8
This patch adds required math functions for float8 to make it possible
using float8 instead of float3 for color data.

Differential Revision: https://developer.blender.org/D15525
2022-07-25 17:36:58 +02:00
7a74d91e32 Cleanup: move device BVH code to kernel/device/*/bvh.h
Having the OptiX/MetalRT/Embree/MetalRT implementations all in one file with
many #ifdefs became too confusing. Instead split it up per device, and also
move it together with device specific hit/filter/intersect functions and
associated data types.
2022-07-25 16:34:22 +02:00
Arye Ramaty
c6ce70855a Geometry Nodes: Add node descriptions/tooltips
This commit adds tooltips to the geometry nodes add menu.

Differential Revision: https://developer.blender.org/D15414
2022-07-25 08:56:24 -05:00
881ef0548a Fix wrong Cycles SSS intersection distance after ray distance changes
No need anymore to have a difference between CPU/GPU, all distances
remain in world space.
2022-07-25 15:19:29 +02:00
484ad31653 Cycles: simplify handling of ray distance in GPU rendering
All our intersections functions now work with unnormalized ray direction,
which means we no longer need to transform ray distance between world and
object space, they can all remain in world space.

There doesn't seem to be any real performance difference one way or the
other, but it does simplify the code.
2022-07-25 13:27:40 +02:00
023eb2ea7c Cycles: more closely match some math and intersection operations in Embree
This helps with debugging, and gives a slightly closer match between CPU
and CUDA/HIP/Metal renders when it comes to ray tracing precision.
2022-07-25 13:27:40 +02:00
d567785658 Fix T99816: renaming attribute works incorrectly
This fixes two issues:
* There was a crash when the new attribute name was empty.
* The attribute name was incremented (e.g. "Attribute.001") when
  the old and new name were the same.
2022-07-25 13:16:59 +02:00
332d547ab7 Fix T99850: incorrect tangents on evaluated bezier curves
Cyclic curves don't need the tangent correction based on the first
and last handle position.
2022-07-25 13:10:34 +02:00
b9e66af686 Fix T99851: Subdivide Curve node does not initialize attributes of end point 2022-07-25 12:45:04 +02:00
2c81b4d4cf Fix T99880: no node timing for frames in node groups 2022-07-25 12:27:45 +02:00
5feb3541f4 Fix T99889: Fillet Curve node uses wrong radius 2022-07-25 12:20:54 +02:00
Ramil Roosileht
cf9dd3c0d8 Fix T99036: hex color in "Add Color Attribute"
Proposed solution by @scurest The color attribute in the RNA was tagged as
 COLOR_GAMMA. This change will change it to a regular COLOR.

{F13217692}

Reviewed By: joeedh, jbakker

Maniphest Tasks: T99036

Differential Revision: https://developer.blender.org/D15272
2022-07-25 12:15:27 +02:00
6f1cdcba85 Fix T99929: lattice modifier looks up vertex group index in wrong place
It looked up the vertex group index based on the object instead of the
actual mesh that is currently used. Since geometry nodes, the number
and order of attributes can change in arbitrary ways during evaluation.
Therefore, this index has to be looked up on the mesh which contains
the most up-to-date information.

There are probably similar issues in other modifiers. That has to be
fixed step by step. Ideally by using the attribute api directly eventually.
2022-07-25 11:54:49 +02:00
c5afef1224 Fix missing disabled hint when dragging from Asset Browser in edit mode
When dragging assets into the 3D View while in any other mode than
object mode, dropping would be disabled and the cursor would indicate
that. However there was supposed to be an "Only supported in object
mode" message, that similar operators showed, but got forgotten when
this one was introduced.
2022-07-25 11:44:56 +02:00
1c05f30e4d Curves: add warning when invalid uv map is used when adding curves
UV maps that are used for surface attachment must not have overlapping
uv islands, because then the same uv coordinate would correspond to
multiple surface positions.

Ref T99936.
2022-07-25 11:42:27 +02:00
53113a2e57 Geometry: detect when the sample uv is in multiple triangles 2022-07-25 11:32:39 +02:00
c5394f3db8 EEVEE-Next: Fix float3 passes being incorrect 2022-07-25 11:25:24 +02:00
f814871e81 EEVEE-Next: Fix some Material compilation errors 2022-07-25 11:25:24 +02:00
47d1a7484c EEVEE-Next: Display compatible properties panels
Only a few are kept not available as their features are not yet supported.
2022-07-25 11:25:24 +02:00
cd9ebc816e Fix build error with WITH_CYCLES_KERNEL_NATIVE_ONLY on macOS Arm
-march=native is not supported for all architectures.
2022-07-25 11:23:25 +02:00
72fb92ded8 Fix T99961: crash when spreadsheet shows volume grids 2022-07-25 11:22:14 +02:00
cacdea7f4a Fix: crash when accessing attributes from multiple threads
Calling two non-const methods on a `MutableAttributeAccessor`
at the same time in multiple threads is not safe.

While I don't know what caused the crash here exactly, I do know
that it happens while looking up the attribute for writing, which
may modify the unterlying geometry. I couldn't reproduce the
bug with a debug build or without threading.
2022-07-25 11:14:42 +02:00
Alex Parker
44258b5ad0 Undo: Improve image undo performance
When texture painting a lot of time is spent in ED_image_paint_tile_find.
This fixes stores the PaintTiles in a blender::Map making ED_image_paint_tile_find an O(1) rather than O(n) operation.

When using threading the locking should happen during read as well,
still this gives a boost in performance as the read is now much faster.

Reviewed By: jbakker

Maniphest Tasks: T99546

Differential Revision: https://developer.blender.org/D15415
2022-07-25 08:14:32 +02:00
7808ee9bd7 Geometry Nodes: Improve UV Sphere primive performance
In a test producing 10 million vertices I observed a 3.6x improvement,
from 470ms to 130ms. The largest improvement comes from calculating
each mesh array on a separate thread. Besides that, the larger changes
come from splitting the filling of corner and face arrays, and
precalculating sines and cosines for each ring.

Using `parallel_invoke` does gives some overhead. On a small 32x16
input, the time went up from 51us to 74us. It could be disabled
for small outputs in the future. The reasoning for this parallelization
method instead of more standard data-size-based parallelism is that the
latter wouldn't be helpful except for very high resolution.
2022-07-24 20:03:16 -05:00
Lukas Stockner
6db059e3d7 Render: Update lightgroup membership in objects and world if lightgroup is renamed
As discussed, this only updates objects in and the world of the scene to which the view layer belongs, which also avoids the problem of not having a BMain available.

Differential Revision: https://developer.blender.org/D14740
2022-07-24 21:33:04 +02:00
f7d5aaa365 Alembic: speed up edge crease import
The Alembic importer uses a linear search over the mesh edges to find
the right edge when setting edge creases. Although the complexity is
`O(m * n)`, with `m` being the number of creased edges, and `n` being
the number of edges, this can lead to a quadratic complexity as `m`
approches `n`.

This patch uses `EdgeHash` to store and retrieve the edges, which
should bring complexity closer to `O(n)`, provided that lookup is
`O(1)`.

See differential for some timings. In most files, this is expected
to give at least a 2-3x speedup for this operation, but can lead
orders of magnitude speed increase for dense meshes with a significant
number of edge creases.

Differential Revision: https://developer.blender.org/D15521
2022-07-24 21:18:11 +02:00
d26c29d8e4 Fix T98367: Light group passes do not work when shadow catcher is used 2022-07-24 20:36:46 +02:00
31365c6b9e Attributes: Use new API for C-API functions
Use the C++ API to implement more of the existing C functions.
This corrects the cases where one tries to add a builtin attribute
with the wrong domain or type on curves, though a better warning
message would be helpful in the future, and also reduces duplication
of the internal logic. Not much more is possible without changing
the interface.
2022-07-24 12:46:28 -05:00
ad632a13d9 EEVEE-Next: Decorelate Large filter spiral sampling
This avoids correlation artifacts with the jitter pattern itself.
Also try to reduce the visible spiral pattern.
2022-07-24 19:24:50 +02:00
b1c49b3b2a EEVEE-Next: Fix depth accumulation and stability in viewport
The display depth is used to composite Gpencil and Overlays. For it to
be stable we bias it using the dFdx gradient functions. This makes
overlays like edit mode not flicker.

The previous approach to save the 1st center sample does not work anymore
since we jitter the projection matrix in a looping pattern when scene
is updated. So the center depth is only (almost) valid 1/8th of the times.
The biasing technique, even if not perfect, does the job of being stable.

This has a few cons:
- it makes the geometry below the ground plane unlike workbench engine.
- it makes overlays render over geometry at larger depth discontinuities.
2022-07-24 19:24:50 +02:00
a5bcb4c148 EEVEE-Next: Make animated viewport non jittered when disabling denoising 2022-07-24 19:24:50 +02:00
68101fea68 EEVEE-Next: Add back background opacity toggle 2022-07-24 19:24:50 +02:00
8ac5b1fdb3 EEVEE-Next: Make Anti-Flicker more strong
This might make the image a bit blurier but it reduces the flickering of
shiny surfaces during animation.

This uses the technique described in "High Quality Temporal Supersampling"
by Brian Karis at Siggraph 2014 (Slide 45): Reduce the exponential factor
when the history is close the bounding box border.
2022-07-24 19:24:50 +02:00
bd9bb56f18 EEVEE-Next: Fix Alt+B render borders
A few offsets were missing.
Reminder that this does not change the actual render resolution but it
reduces the VRAM consumption of accumulation buffers.
2022-07-24 19:24:50 +02:00
364babab65 EEVEE-Next: Fix background velocity 2022-07-24 19:24:50 +02:00
0fcc04e7bf Cleanup: Fix off-by-half-errors with udim search 2022-07-24 14:48:30 +12:00
f1f2c26223 Cleanup: Simplify uv sculpt tool
No functional changes.
2022-07-24 13:48:53 +12:00
c94c0d988a Fix: Removing attributes from UI invalidates caches
Use the new attribute API to implement the attribute remove function
used by RNA, except for BMesh attributes. Currently, removing curve
attributes from the panel in the property editor does not mark the
relevant caches dirty (for example, the cache of curve type counts),
because that behavior is implemented with the new attribute API.
Also, eventually we want to merge the two APIs, and removing an
attribute is the first function that can be partially implemented
with the new API.

Differential Revision: https://developer.blender.org/D15495
2022-07-23 19:59:59 -05:00
0c3851d31f EEVEE-Next: Film: Rename filter_size for clarity and add box filter ...
... as a debug option.
2022-07-23 22:57:10 +02:00
3ea2b4ac31 EEVEE-Next: Film: Fix incorrect anti-aliasing
There was a confusion about what space the offset was in.
2022-07-23 22:57:10 +02:00
7c6d546f3a Fix an assert trip in boolean tickled by D11272 example.
The face merging code in exact boolean made an assumption that
the tesselated original face was manifold except at the boundaries.
This should be true but sometimes (e.g., if the input faces have
self-intersection, as happens in the example), it is not.
This commit makes face merging tolerant of such a situation.
It might leave some stray edges from triangulation, but it should
only happen if the input is malformed.
Note: the input may be malformed if there were previous booleans
in the stack, since snapping the exact result to float coordinates
is not guaranteed to leave the mesh without defects.

This is the second try at this commit. The previous one had a typo
in it -- luckily, the tests caught the problem.
2022-07-23 12:15:59 -04:00
d53ea1d0af Fix T99905: wrong toposort when the node tree is cyclic 2022-07-23 14:37:58 +02:00
092732d113 IO: speed up import of large amounts of objects in USD/OBJ by pre-sorting objects by name
Previously, when creating "very large" (tens-hundreds of thousands)
amounts of objects, the Blender code that was ensuring name
uniqueness was the bottleneck. That got recently addressed (D14162),
however now sorting of IDs by their names is the remaining bottleneck.

Name sorting code in Blender is optimized for the pattern where names
are inserted in already sorted order (i.e. objects expect to get added
near the end of the list). By doing this pre-sorting of objects
intended to get created by an importer (USD and OBJ, in this patch),
this sorting bottleneck can be largely removed, especially with very
high object counts.

Windows, Ryzen 5950X, import times:

- OBJ, splash screen scene (26k objects): 22.0s -> 20.7s
- USD, Disney Moana scene (250k objects): 585s -> 82.2s (10 minutes -> 1.5 minutes)

Reviewed By: Michael Kowalski, Howard Trickey
Differential Revision: https://developer.blender.org/D15506
2022-07-23 15:16:14 +03:00
beb746135d Fix T99830: missing update after reordering node group sockets 2022-07-23 13:30:15 +02:00
5da807e00f Fix: Store Named Attribute node not working when attribute did not exist 2022-07-23 12:14:45 +02:00
fc8b9efb24 Update RNA to User manual mappings 2022-07-22 21:00:34 -04:00
82467e5dcf Cleanup: Typo with uv sphere normal creation
Regression from 087f27a52f
2022-07-23 09:12:13 +12:00
80b2fc59d1 Fix T99873: Use evaluated vertex groups in armature modifier
Geometry nodes has added the ability to modify mesh vertex groups
during evaluation (see 3b6ee8cee7). However, the armature
modifier always uses the vertex groups from the original object.
This is wrong for the modifier stack, where each modifier is meant
to use the output of the previous.

This commit makes the armature modifier use the evaluated vertex groups
if they are available. Otherwise it uses the originals like before.

Differential Revision: https://developer.blender.org/D15515
2022-07-22 15:49:53 -05:00
7d8b651268 EEVEE-Next: Add exposure awareness to denoising
This uses the exposure to get a better approximation of the perceptual
brighness of a sample before accumulating it.

Note that we do not modify exposure of the image. Only the samples weights
are computed differently.
2022-07-22 21:03:06 +02:00
676a2f690c EEVEE-Next: Fix render not working
The swaps during accumulation were ignored because of the way the
`SwapChain<>` implementation works.

Using external references and updating them fixes the issue.
2022-07-22 20:32:17 +02:00
35843ddcd8 Fix T99835: Incorrect title case for two node names 2022-07-22 11:36:55 -05:00
98395e0bdf Cleanup: Use r_ prefix for boolean return parameters
Also rearrange some lines to simplify logic.
2022-07-22 10:49:09 -05:00
c40971d79a Fix T99873: Store named attribute node cannot write to vertex groups
Since fd5e5dac89, the node would remove the attribute before
adding it again, which lost the vertex group status of an attribute,
meaning they were written as arbitrary attributes.

Now, the node first tries to write to attributes with the same domain
and data-type, which covers the vertex group case. Then it falls back
to removing the attribute and adding it again. Even that can fail
though, so I added an error message to make that a bit clearer.

Differential Revision: https://developer.blender.org/D15514
2022-07-22 10:31:40 -05:00
e4eaf424b9 Fix nodes not transforming
Error in {rB98bf714b37c1}
2022-07-22 12:17:22 -03:00
6bcda04d1f Geometry Nodes: Port sample curves node to new data-block
Use the newer more generic sampling and interpolation functions
developed recently (ab444a80a2) instead of the `CurveEval` type.
Functions are split up a bit more internally, to allow a separate mode
for supplying the curve index directly in the future (T92474).

In one basic test, the performance seems mostly unchanged from 3.1.

Differential Revision: https://developer.blender.org/D14621
2022-07-22 09:59:28 -05:00
1f94b56d77 Curves: support sculpting on deformed curves
Previously, curves sculpt tools only worked on original data. This was
very limiting, because one could effectively only sculpt the curves when
all procedural effects were turned off. This patch adds support for curves
sculpting while looking the result of procedural effects (like deformation
based on the surface mesh). This functionality is also known as "crazy space"
support in Blender.

For more details see D15407.

Differential Revision: https://developer.blender.org/D15407
2022-07-22 15:39:41 +02:00
Germano Cavalcante
98bf714b37 Refactor: arrange transform convert functions in 'TransConvertTypeInfo'
Simplify the transform code by bundling the TransData creation, Data
recalculation, and special updates into a single struct.

So similar functions and parameters can be accessed without special
type checks.

Differential Revision: https://developer.blender.org/D15494
2022-07-22 10:01:27 -03:00
185eeeaaac GHOST/Wayland: Fix mouse wheel events for Sway Compositor (use seat v5)
Bump the requested seat version to v5, use discreet scroll callback.

Tested with gnome, river & sway.
2022-07-22 22:15:00 +10:00
003dfae270 Cycles: enable oneAPI in Linux release builds
0f50ae131f didn't do it reliably
since it was deactivated explicitly a bit above.
2022-07-22 13:03:49 +02:00
e0d4aede4d BMesh: move bmesh_mesh to C++
This allows parts of the code to be threaded more easily.
2022-07-22 20:40:31 +10:00
95e60b4ffd Cleanup: move crazyspace.c to c++
Doing this in preparation for D15407.
2022-07-22 12:33:08 +02:00
087f27a52f Fix T87779: Asymmetric vertex positions in circles primitives
Add sin_cos_from_fraction which ensures each quadrant has matching
values when their sign is flipped.
2022-07-22 13:59:36 +10:00
08c5d99e88 Cleanup: add BKE_image_find_nearest_tile_with_offset
Every caller BKE_image_find_nearest_tile was calculating the tile offset
so add a version of this function that returns the offset too.
2022-07-22 13:07:24 +10:00
72e249974a Fix crash loading factory settings in image paint mode
Loading factory settings left the region NULL, causing the brushes
poll function to crash.
2022-07-22 12:25:10 +10:00
d3db38cfb1 Cleanup: quiet nonull-compare warnings with GCC 2022-07-22 12:23:33 +10:00
7725740543 UV: Edge support for select shortest path operator
Calculating shortest path selection in UV edge mode was done using vertex
path logic. Since the UV editor now supports proper edge selection [0],
this approach can sometimes give incorrect results.

This problem is now fixed by adding separate logic to calculate the
shortest path in UV edge mode.

Resolves T99344.

[0]: ffaaa0bcbf

Reviewed By: campbellbarton

Ref D15511.
2022-07-22 11:17:16 +10:00
aa1ffc093c Fix T99884: Crash when converting to old curve type
The conversion from Curves to CurveEval used an incorrect type
for one of the builtin attributes. Also, an incorrect default was used
for reading the nurbs_weight attribute.
2022-07-21 19:44:06 -05:00
7a4a6ccad7 Cleanups: Small changes to armature deform
Use const pointers, remove unused data member for parallel callback,
use listbase macro.
2022-07-21 17:21:56 -05:00
ada6012518 Fix T99854: Crash converting legacy NURBS curves to new type
Creating the attributes was done inside a parallel loop. Also correct a
typo for the parallel grain size, which was meant to be a power of two.
2022-07-21 12:13:42 -05:00
Sebastiano Barrera
a5c2d0018c Fix T91932: number sliders wrap around when dragged for long distance on X11
The value of number sliders (e.g. the "end frame" button) wrap around to
their pre-click value when dragging them for a very long distance (e.g.
by lifting the mouse off the desk and placing it back on to keep
dragging in the same direction).

The problem is X11-specific, and due to XTranslateCoordinates using a
signed int16 behind the curtains, while its signature and the rest of
Blender uses int32. The solution is to only use XTranslateCoordinates on
(0, 0) to get the delta between the screen and client reference systems,
and applying the delta in a second step.

Differential Revision: https://developer.blender.org/D15507
2022-07-21 19:02:03 +02:00
611be46cc9 Cleanup: compiler warning 2022-07-21 19:01:19 +02:00
a36f029459 Fix crash in some very rare case in remapping code.
Actualy 'safe' building of the base has in view layers (as part of
`BKE_main_collection_sync_remap`) would only happen when there was
already an existing one, otherwise it was skipped, and rebuilt later
(without the support for doublons) in collection sync code.

Very odd that that error was never spotted before, issue in code has
been there for a long time already. Probably only happens in rare cases
(specific conjuction of factors during remapping of old ID into itelf
new id)?

Reported by @hjalti from Blender studio. Reproducing case:
`heist/pro/shots/050_alarm/050_0160/050_0160.anim.blend`, r1407
2022-07-21 18:11:13 +02:00
ef5b435e8f DRW: Volume: Fix crash in command line render caused by null textures
This was caused by the world volume shader needing placeholder textures
that were not available until cache populate begins.

Adding a check and creating on the fly fixes the issue.
2022-07-21 16:41:51 +02:00
d431b1416b EEVEE-Next: Add back option to disable TAA (Viewport Denoising 2022-07-21 16:41:51 +02:00
b0f9639733 Fix crash due to improper handling of new library runtime name_map data on read/write.
Code handling read/write of libraries is still particular... but trying
to call `library_runtime_reset` on a random address at readtime was an
obvious mistake I should have caught during review :(

Regression from rB7f8d05131a77.
2022-07-21 16:39:07 +02:00
396b7a6ec8 Spreadsheet: Implement selection filter for curves sculpt mode
The spreadsheet can retrieve the float selection using the same
utilities as curves sculpt brushes. Theoretically this can work in
original, evaluated, and viewer node modes, at least when the
sculpt selection attributes are able to be propagated.

Differential Revision: https://developer.blender.org/D15393
2022-07-21 09:34:48 -05:00
412d93c298 GPU: Fix compilation with WITH_GPU_BUILDTIME_SHADER_BUILDER option 2022-07-21 15:50:35 +02:00
92eb59341c EEVEE-Next: Filter NaN at output to avoid propagation. 2022-07-21 15:50:35 +02:00
9f00e138ac Cleanup: DRW: common_math_geom_lib.glsl: Fix variable name style 2022-07-21 15:50:35 +02:00
e022753d7a EEVEE-Next: Add Temporal-AntiAliasing
The improvements over the old implementation are:
- Improved history reprojection filter (catmull-rom)
- Use proper velocity for history reprojection.
- History clipping is now done in YCoCg color space using better algorithm.
- Velocity is dilated to keep correct edge anti-aliasing on moving objects.

As a result, the 3x3 blocks that made the image smoother in the previous
implementation are no longer visible is replaced by correct antialiasing.

This removes the velocity resolve pass in order to reduce the bandwidth
usage. The velocities are just resolved as they are loadded in the film
pass.
2022-07-21 15:50:35 +02:00
2bad3577c0 DRW: common_math_geom_lib.glsl: Add line_aabb_clipping_dist 2022-07-21 15:50:35 +02:00
4ba6bac2f1 Fix build error in tests binary after previous commit
Also remove an unused include and add a comment,
const, use the math namespace.
2022-07-21 08:30:07 -05:00
63be57307e Cleanup: Rename length parameterization interpolation function
The name makes more sense as an action, other interpolation
methods besides linear probably don't make sense here anyway.
2022-07-21 08:15:06 -05:00
95ab16004d Cleanup: Remove debug print in test 2022-07-21 08:00:30 -05:00
03338e0270 GHOST/Wayland: fix cursor glitch after grabbing while hidden
When the cursor grabbing was disabled, Blender's internal location
(wmWindow.eventstate) kept the location before un-hiding.

This caused the paint cursor to show in the wrong location after
adjusting the color wheel for e.g.
2022-07-21 21:47:41 +10:00
a06b04f92d Cleanup: Simplify relation flags assignment 2022-07-21 12:54:35 +02:00
2034e8c42d Geometry Nodes: add debug check for whether AttributeWriter.finish is called
Calling `finish` after writing to generic attributes is currently necessary for
correctness. Previously, this was easy to forget. Now there is a check for this
in debug builds.
2022-07-21 12:47:44 +02:00
538da79c6d Curves: fix applying materials when applying modifier
The issue was that geometry nodes was run on the original curves,
and set a pointer to an evaluated material id on it. The fix is to not
mix up original and evaluated data by making sure that geometry nodes
does not modify the original data.
2022-07-21 12:23:38 +02:00
d099e0d2a4 Cleanup: Make automated code check happy.
- Assert that one of the thwo branches in
  `id_override_library_create_hierarchy` are always processed.
- Init success value regardless.
2022-07-21 12:18:57 +02:00
f7252e9692 Cleanup: Unused forward declaration 2022-07-21 12:16:31 +02:00
10b048fd9e Fix T99885: Invalid dependency graph state when curves surface is invisible
Differential Revision: https://developer.blender.org/D15510
2022-07-21 11:26:36 +02:00
Bastien Montagne
ee3facd087 LibOverride: support 'make override' for all selected items.
This commit allows to select several data-blocks in the outliner and
create overrides from all of them, not only the active one.

It properly creates a single hierarchy when several IDs from a same
hierarchy root data are selected.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D15497
2022-07-21 10:18:43 +02:00
0dcee6a386 Fix T99733: Objects with driven visibility are evaluated when not needed
The issue was caused by the fact that objects with driven or animated
visibility were considered visible by the dependency graph evaluation.

This change makes it so the dependency graph evaluation is aware of
visibility which might be changing. This is achieved by evaluating the
path of the graph which affects objects visibility and adjusts to it
before evaluating the rest of the graph.

There is some time penalty to this, but there does not seem to be a
way to fully avoid this penalty.

With the production shot from the heist project the FPS drops by a
tenth of a frame (~9.4 vs ~9.3 fps) when adding a driver to an object
which keeps it visible. Note that this is a bit hard to measure since
the FPS fluctuates quite a bit throughout the playback. On the other
hand, having a driver on a visibility of a heavy object from character
and setting visibility to false gives big speedup.

Also worth noting that there is no penalty at all when there are no
animated visibilities in the scene.

Differential Revision: https://developer.blender.org/D15498
2022-07-21 09:49:16 +02:00
4089b7b80b Depsgraph: Clear operation evaluation flags early on
The goal is to make it possible to evaluate the graph in multiple
passes without evaluating the same node multiple times.

Currently should not be any functional changes.
2022-07-21 09:48:59 +02:00
d6faee2824 Cleanup: format 2022-07-21 17:45:36 +10:00
2eeedbbca9 Cleanup: add ISMOUSE_MOTION macro
Replace verbose ELEM(..) usage, now each kind of mouse event has it's
own macro.
2022-07-21 16:23:33 +10:00
7a73685460 Fix WM_event_type_mask_test ignoring wheel and gesture events
WM_event_type_mask_test checks assumed ISMOUSE macro worked for any
kind of mouse event when it only accepted buttons & motion.

Now ISMOUSE checks for any kind of mouse event,
use ISMOUSE_BUTTON/WHEEL/GESTURE for more specific checks.
2022-07-21 16:07:11 +10:00
095b8d8688 WM: replace ISMOUSE with ISMOUSE_BUTTON
The ISMOUSE macro was used in situations only button events
needed to be checked.

The only functional difference would be MOUSEMOVE events were
previously accepted for these checks.
2022-07-21 15:54:39 +10:00
4ec0a8705b WM: categorize smart-zoom as a gesture
Event handling and the enum definition documents MOUSESMARTZOOM
as a gesture however it wasn't accepted by ISMOUSE_GESTURE,
instead it was added to the ISMOUSE macro.

Move the type check to ISMOUSE_GESTURE.
2022-07-21 15:28:01 +10:00
dd158f1cab Fix failing cycles test from previous commit
Deprecated custom data type CD_MTEXPOLY has inconsistent data usage.

Reviewed By: Campbell Barton
2022-07-21 16:28:56 +12:00
c171e8b95c Fix T90620: Ignore missing UV data caused by corrupt .blend file
Add crash protection and partial recovery for corrupt .blend files,
particularly for missing UV data.

Differential Revision: https://developer.blender.org/D15489
2022-07-21 15:24:38 +12:00
46a2592eef Cleanup: spelling in comments, typos in tool-tips 2022-07-21 13:21:53 +10:00
e75adb979b Fix T99678: Crash applying non-existent modifiers
Regression in [0] accessed the modifier type before NULL check.

[0]: 78fc5ea1c3
2022-07-21 12:52:24 +10:00
9f68369247 Fix T99687: Cloth filter crash
The code was failing to exclude the sculpt object from
the list of collision objects.
2022-07-20 15:17:07 -07:00
eb281e4b24 Fix T99878: Deleting curves or points removes anonymous attributes
Use the attribute API instead of the CustomData API, to correctly
handle anonymous attributes and simplify the code. One non-obvious
thing to note is that the type counts are recalculated by the "finish"
function of the `curve_type` attribute, so they don't need to be copied
explicitly. Also, the mutable attribute accessor cannot be an reference
if we want to give it an rvalue, which is convenient in this case.
2022-07-20 16:40:05 -05:00
fe108d85b4 Cleanup: Remove unused function 2022-07-20 14:30:44 -05:00
d34f8ac3d9 Cleanup: Remove unnecessary handling of normals for fluid colliders
The normals are transformed, but not used. It looks like this logic was
just copied from below where the mesh is transformed for creating
emitters, which do use vertex normals.
2022-07-20 13:18:03 -05:00
5d4574ea0e Fix T99340: Image.frame_duration returning wrong value when image not loaded
The logic here was broken in d5f1b9c, it should load the image first.
2022-07-20 18:23:03 +02:00
c4d8e28aa7 UI: Remove redundant view reference in view items
The new view item base class already holds a reference to the view, no
need to have one in the derived class as well.
2022-07-20 17:16:15 +02:00
0c6ae51d9f Fix missing registration of grid view items in the view 2022-07-20 17:16:15 +02:00
712960cefd Cleanup: use BLI_strncpy instead of strcpy
Using `strcpy` resulted in `stringop-truncation` warnings for me.
2022-07-20 16:08:02 +02:00
3ea91cecc9 Cleanup: remove unused get_cage_mesh parameter
All callers passed `false` for this parameter, making it more confusing
than useful. If this functionality is needed again in the future, a separate
function should be added.

Differential Revision: https://developer.blender.org/D15401
2022-07-20 15:57:16 +02:00
Wannes Malfait
7561183830 Fix T99667: regression in Delete Geometry node
Differential Revision: https://developer.blender.org/D15445
2022-07-20 15:49:50 +02:00
29c68e2523 Fix T99869: Edge crease no longer working
Missed in d14c2d549b
2022-07-20 10:28:23 -03:00
a814c7091b Fix T99847: Dragging image from Image Editor to Node Editor broken
Oversight in b0da080c2c. The `session_uuid` operator property wouldn't
be checked by the invoke callback, and if neither the `filepath` nor the
`name` property were set, the File Browser would open.
2022-07-20 14:54:32 +02:00
7f8d05131a IDManagement: Speedup ID unique name assignment by tracking used names/basenames/suffixes
An implementation of T73412, roughly as outlined there:

Track the names that are in use, as well as base names (before
numeric suffix) plus a bit map for each base name, indicating which
numeric suffixes are already used. This is done per-Main/Library,
per-object-type.

Timings (Windows, VS2022 Release build, AMD Ryzen 5950X):

- Scene with 10k cubes, Shift+D to duplicate them all: 8.7s -> 1.9s.
  Name map memory usage for resulting 20k objects: 4.3MB.
- Importing a 2.5GB .obj file of exported Blender 3.0 splash scene
  (24k objects), using the new C++ importer: 34.2s-> 22.0s. Name map
  memory usage for resulting scene: 8.6MB.
- Importing Disney Moana USD scene (almost half a million objects):
  56min -> 10min. Name map usage: ~100MB. Blender crashes later on
  when trying to render it, in the same place in both cases, but
  that's for another day.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D14162
2022-07-20 14:27:14 +03:00
8d69c6c4e7 Constraints: add checks to specially handle the custom space target.
- The custom space target never needs B-Bone data (used by depsgraph).
- When drawing the relationship lines use the space matrix directly.
- Don't use the custom target to control the target space type dropdown.

Differential Revision: https://developer.blender.org/D9732
2022-07-20 14:18:17 +03:00
e6855507a5 Constraints: add missing calls to initialize custom space.
Add calls to a few locations that look like they may need to
initialize the Custom Space matrix, i.e. generally any place
that computes target matrices.

Differential Revision: https://developer.blender.org/D9732
2022-07-20 14:18:17 +03:00
054a169be0 Use appropriate context for the DopeSheet Action Custom Properties panel.
Refactor D14646 to use context.active_action for the Action
Custom Properties panel, matching the already existing Action panel.

This has the advantage that it allows access to the properties of
any actions with channels visible in the Dope Sheet, e.g. Shape Keys,
Materials etc; while using just the active object is limited to just
the object animation.

Also move both panels from Item to the Action tab.

Differential Revision: https://developer.blender.org/D15288
2022-07-20 14:18:17 +03:00
ae49e0e8be Cleanup: unused parameter in own recent commit rB92ca920c52b9. 2022-07-20 11:09:16 +02:00
Damien Picard
c48dc61749 I18n: fixes to add-on message extraction
This commit fixes several issues in add-ons UI messages extraction code:

- In multi-file modules, the script would crash because it tried to write to
  the dir instead of a `translations.py` file;
- The add-on message extraction works by enabling the add-on, getting all
  messages; disabling the add-on, getting all messages; then comparing the
  two message sets. But often a bug happens where a class gets a
  description from somewhere else in memory. I couldn’t debug that, so a
  workaround is to check that the message isn’t a corrupted one before
  removing it;
- `printf()` doesn't exist in Python and would crash the script;
- `self.src[self.settings.PARSER_PY_ID]` can be replaced by `self.py_file`
  in class `I18n`, since a property exists to do that;
- At one point a generator was printed instead of its values, so let's
  unpack the generator to get the values. Maybe the print could be
  deleted entirely;
- Use SPDX license identifier instead of GPL license block, to be more in
  line with other scripts from the codebase.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15474
2022-07-20 11:05:07 +02:00
Bastien Montagne
92ca920c52 Add a 'Apply and Delete All' operation to shapekeys.
Adds a new option to the 'Delete ShpaKeys' operator, which first applies
the current mix to the object data, before removing all shapekeys.

Request from @JulienKaspar from Blender studio.

Reviewed By: JulienKaspar

Differential Revision: https://developer.blender.org/D15443
2022-07-20 10:55:08 +02:00
ecf4f4a71f Curves: fix uninitialized curve type when adding new curves 2022-07-20 10:47:23 +02:00
c3b9a4e001 Cleanup: Access attributes with new API instead of geometry components
Remove the boilerplate of using a local geometry component just to use
the attribute API that was necessary before b876ce2a4a.
2022-07-19 22:34:32 -05:00
215f805ce6 Curves: Remove use of CurveEval in sculpt brushes
This commit removes the use of PolySpline for resampling curves and
replaces it with the length parameterization utility for that purpose.
I didn't test performance, but I would expect the shrinking to be
slightly faster because I reused some arrays to avoid allocating
them for every curve. I noted some potential improvements in
the "add curves" function.

Differential Revision: https://developer.blender.org/D15342
2022-07-19 21:48:32 -05:00
2551cf9087 Curves: Port fillet node to the new data-block
This commit ports the fillet curves node to the new curves data-block,
and moves the fillet node implementation to the geometry module to help
separate the implementation from the node.

The changes are similar to the subdivide node or resample node. I've
resused common utilities where it makes sense, though some things like
the iteration over attributes can be generalized further. The node
is now multi-threaded per-curve and inside each curve, and some buffers
are reused per curve to avoid many allocations.

The code is more explicit now, and though there is more boilerplate to
pass around many spans, the more complex logic should be more readable.

Differential Revision: https://developer.blender.org/D15346
2022-07-19 18:50:27 -05:00
5d6e4822d8 Cleanup: Combine geometry null checks in if statements
Testing if components or virtual arrays are null in the same line they
are retrieved can make this boilerplate code a bit easier to read.
2022-07-19 18:29:23 -05:00
40ffb94ab4 Cleanup: Use generic utility for copying compressed attribute
In the future, `materialize_compressed_to_uninitialized_threaded`
could be moved somewhere else and reused.
2022-07-19 18:16:12 -05:00
410a6efb74 Point Cloud: Remove redundant custom data pointers
Similar to e9f82d3dc7, but for point clouds instead.

Differential Revision: https://developer.blender.org/D15487
2022-07-19 18:06:56 -05:00
e9f82d3dc7 Curves: Remove redundant custom data pointers
These mutable pointers present problems with ownership in relation to
proper copy-on-write for attributes. The simplest solution is to just
remove them and retrieve the layers from  `CustomData` when they are
needed. This also removes the complexity and redundancy of having to
update the pointers as the curves change. A similar change will apply
to meshes and point clouds.

One downside of this change is that it makes random access with RNA
slower. However, it's simple to just use the RNA attribute API instead,
which is unaffected. In this patch I updated Cycles to do that. With
the future attribute CoW changes, this generic approach makes sense
because Cycles can just request ownership of the existing arrays.

Differential Revision: https://developer.blender.org/D15486
2022-07-19 18:01:04 -05:00
Pratik Borhade
28985ccc05 Fix T99583: Missing update for option in particle edit mode
Missing Ui refresh when property is accessed through shortcut.
Use RNA_def_property_update to solve this.

Differential Revision: https://developer.blender.org/D15431
2022-07-19 14:20:44 -05:00
43d04c7eeb UI Code Quality: Move eyedropper files to own folder
Part of T98518
2022-07-19 19:33:38 +02:00
Tomek Gubala
3b7ac10d62 UV: add Snap Cursor to Origin
Similar to snapping to the world origin in the 3D viewport. This can be found
in the Shift+S pie menu and UV > Snap menu.

Differential Revision: https://developer.blender.org/D15055
2022-07-19 19:29:03 +02:00
75e62df429 Cleanup: compiler warning 2022-07-19 19:22:13 +02:00
cd478fbfb3 Fix error printed in console when running Shade Flat operator
Only the Shade Smooth operator has autosmooth settings.
2022-07-19 19:22:13 +02:00
edc89c7f46 Fix build error when not using unity build 2022-07-19 19:22:13 +02:00
d14c2d549b Fix T99643: Vertex Crease fails with symmetry
Create a transform conversion type that only considers the Vertex
Custom Data.

This reduces the complexity of converting Meshes and slightly
optimizes the transformation.
2022-07-19 14:13:00 -03:00
597955d0a8 Cleanup: Remove compile option for curves object
After becb1530b1 the new curves object type isn't hidden
behind an experimental flag anymore, and other areas depend on this,
so disabling curves at compile time doesn't make sense anymore.
2022-07-19 12:10:45 -05:00
16b145bc62 Cleanup: Improve API and documentation of interface_view.cc
File documentation was outdated and could use general improvement.
Function names didn't really reflect the level they are operating on.
2022-07-19 18:04:03 +02:00
fb9dc810f1 UI Code Quality: Move view related files to own folder
Part of T98518.
2022-07-19 18:04:03 +02:00
Amélie Fondevilla
801513efa0 Fix T99732: Crash on F3 in the dopesheet
Adding the `FCURVESONLY` filter in the filter function of the Grease
Pencil dopesheet prevents calls to F-curves related functions to grease
pencil channels, thereby fixing the crash.

Reviewed By: antoniov, sybren

Maniphest Tasks: T99732

Differential Revision: https://developer.blender.org/D15490
2022-07-19 17:49:10 +02:00
87ae10a050 Curves: Hide snapping menu in curves sculpt mode
The menu/popover doesn't affect anything in the mode, and precision
operations that would use snapping are meant for edit mode anyway.
2022-07-19 10:45:01 -05:00
35b4e3a350 RNA: Don't allocate empty char pointer properties
Instead of allocating a single 0 char, set the `char *` DNA pointer to
null. This avoids the overhead of allocating and copying single-bytes.

rBeed45b655c9f didn't do this for safety reasons, but I checked the
existing uses of this behavior in DNA/RNA. Out of 43 total `char *`
members, this change only affects 7 recently added properties.
For a complete list, see the patch description.

Differential Revision: https://developer.blender.org/D14779
2022-07-19 10:30:19 -05:00
c771dd5e9c Depsgraph: Make animated properties API receive const ID
Semantically it is more correct as the cache does not modify the ID.

There is need to do couple of const casts since the BKE (which is in C)
does not easily allow to iterate into f-curves of const ID.

Should be no functional changes.
2022-07-19 17:22:53 +02:00
6a1ab4747b Geometry Nodes: Copy parameters when copying a curves data-block
Previously, things like materials, symmetry, and selection options
stored on `Curves` weren't copied to the result in nodes like the
subdivide and resample nodes. Now they are, which fixes some
unexpected behavior and allows visualization of the sculpt mode
selection.

In the realize instances and join nodes the behavior is the same as
for meshes, the parameters are taken from the first (top) input.

I also refactored some functions to return a `CurvesGeometry` by-value,
which makes it the responsibility of the node to copy the parameters.
That should make the algorithms more reusable in other situations.

Differential Revision: https://developer.blender.org/D15408
2022-07-19 10:16:30 -05:00
9246ff373a Metal: Add license header to new files 2022-07-19 17:14:39 +02:00
Jason Fielder
9835d5e58b Metal: MTLUniformBuffer module implementation
Initial implementation.

Authored by Apple: Michael Parkin-White
Ref T96261

Reviewed By: fclem
Differential Revision: https://developer.blender.org/D15357
2022-07-19 17:12:39 +02:00
Jason Fielder
6bba4d864e Metal: MTLQueryPool implementation adding support for occlusion queries.
When a query begins, the current visibility result buffer needs to be
associated with the currently active Render Pass. The MTLContext and
MTLCommandBuffer are responsible for ensuring new render pass objects are
created if the visibility state changes.

Authored by Apple: Michael Parkin-White
Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15356
2022-07-19 17:02:15 +02:00
3370c1a8a7 Cleanup: Add comment for geometry nodes lazyness 2022-07-19 09:54:20 -05:00
ad5e3d30a2 Nishita sky: Increase elevation range
The Nishita sky texture currently only allows moving the sun to the zenith.
The problem is if you want to animate the passing of a full night-day-night
cycle. Currently it's not easy to do due to this limitation.

The patch makes it so users can easily animate the sun moving from sunrise
to sunset by expanding the max sun elevation to go 360° instead of 90°.

Reviewed By: fclem
Differential Revision: https://developer.blender.org/D13724
2022-07-19 16:36:57 +02:00
2e3fb58128 Cleanup: Apply clang-format 2022-07-19 16:33:09 +02:00
5bee991132 UI: Port view item features to base class, merge view item button types
No user visible changes expected.

Merges the tree row and grid tile button types, which were mostly doing
the same things. The idea is that there is a button type for
highlighting, as well as supporting general view item features (e.g.
renaming, drag/drop, etc.). So instead there is a view item button type
now. Also ports view item features like renaming, custom context menus,
drag controllers and drop controllers to `ui::AbstractViewItem` (the new
base class for all view items).

This should be quite an improvement because:
- Merges code that was duplicated over view items.
- Mentioned features (renaming, drag & drop, ...) are much easier to
  implement in new view types now. Most of it comes "for free".
- Further features will immediately become availalbe to all views (e.g.
  selection).
- Simplifies APIs, there don't have to be functions for individual view
  item types anymore.
- View item classes are split and thus less overwhelming visually.
- View item buttons now share all code (drawing, handling, etc.)
- We're soon running out of available button types, this commit merges
  two into one.

I was hoping I could do this in multiple smaller commits, but things
were quite intertwined so that would've taken quite some effort.
2022-07-19 16:31:23 +02:00
348ec37f52 UI: Add AbstractViewItem base class
No user visible changes expected.

Similar to rBc355be6faeac, but for view items now instead of the view.
Not much of the item code is ported to use it yet, it's actually a bit
tricky for the most part. But just introducing the base class already
allows me to start unifying the view item buttons (`uiButTreeRow` and
`uiButGridTile`). This would be a nice improvement.
2022-07-19 16:31:23 +02:00
Colin Basnett
2f834bfc14 Fix T97559: Undoing of NLA strip duplication requires two undo steps
Fix the issue where undoing a "duplicate NLA strip" operation would
require two undo steps.

The cause of this was that the operator was not using the operator macro
system to combine both the duplication and the translate operators into
one. Instead, the old code was simply manually invoking invoking the
translate operator after the duplicate operator had completed.

This patch requires the default keymap to be modified to include the two
new macro operators, `NLA_OT_duplicate_move` and
`NLA_OT_duplicate_linked_move` in favour of the old keymap that simply
called `NLA_OT_duplicate` and passed along a `linked` argument.

`duplicate_move` and `duplicate_move_linked` are two different enough
operations to justify having their own operators from user's
point-of-view, especially since we cannot yet have different tool-tips
based on an operator's settings.

Reviewed By: sybren, mont29

Differential Revision: https://developer.blender.org/D15086
2022-07-19 16:07:30 +02:00
Colin Basnett
4812eda3c5 Animation RNA: Add clear() method to FCurveKeyframePoints
Add `FCurveKeyframePoints.clear()` method to delete all keyframe points
from an FCurve.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15283
2022-07-19 15:58:37 +02:00
2232855b50 Curves: align surface and curves object in Empty Hair operator
Without this, symmetry does not work by default when the surface
object was not at the same location as the 3d cursor.
2022-07-19 15:49:45 +02:00
95fd7c3679 Depsgraph: Cleanup, Make variable less ambiguous and more clear 2022-07-19 15:27:20 +02:00
bc6b612d8b Depsgraph: Make variable naming more clear
Disambiguate from nodes visibility flags.
2022-07-19 15:25:49 +02:00
Ethan-Hall
44f1495b57 EEVEE: use mipmaps of compressed textures (DDS)
Currently Blender generates mipmaps that override the existing ones.
This patch disables generating new mipmaps for compressed textures.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D14459
2022-07-19 15:20:53 +02:00
e8465f941c Depsgraph: Cleanup, use nested namespace definition 2022-07-19 14:44:07 +02:00
835203fde8 Depsgraph: Localize synchronization component visibility handling
Move it from generic visibility handling to the synchronization
component node implementation. Should be no functional changes.
2022-07-19 14:36:36 +02:00
73f8a7ca0a Depsgraph: Cleanup, comments wrapping and spacing between lines
Should make it easier to read. No functional changes expected.
2022-07-19 14:25:02 +02:00
6d2100f7de Depsgraph: Introduce operation code for visibility operation
No functional changes, just makes code more semantically clear.
2022-07-19 13:00:19 +02:00
99faebfca6 Depsgraph: Cleanup, don't mic static function and anonymous namespace 2022-07-19 12:51:24 +02:00
2280a71f90 Depsgraph: Refactor evaluation into smaller reusable functions
Should be no functional changes.
2022-07-19 12:41:47 +02:00
9b2b61a07b Depsgraph: Cleanup, use nested namespace definition 2022-07-19 11:40:18 +02:00
d3c063188e Depsgraph: Make name and name tag optional in component node
Matches the builder API, making some code less verbose.
2022-07-19 11:31:44 +02:00
ff98b5eaa8 Depsgraph: Clarify comment in the component node 2022-07-19 11:29:00 +02:00
e00a027c1e Depsgraph: Use single task pool during evaluation
Not sure why multiple pools were created: the pool should be able to
handle two sets of tasks.

Perhaps non-measurable improvement in terms of performance but this
change simplifies code a bit.
2022-07-19 11:18:30 +02:00
533a5a6a8c Fix T99785: Make Principled Hair IOR input behave like other IOR sliders
Was accidental regression in rBed9b21098dd27bf9364397357f89b4c2648f40c2

Remove the input slider's PROP_FACTOR subtype in favor of the default to
align with other IOR sliders. This provides much better control when
dragging the value with the mouse.

Differential Revision: https://developer.blender.org/D15477
2022-07-18 20:38:19 -07:00
bbf87c4f75 Fix T99737: Dropping files fails with Wayland
Drop events ignored the cursor coordinates, under the assumption that
cursor motion events would also be sent to update the cursor location.

This depended on the behavior of the compositor, it failed for Sway
but worked for Gnome-shell & River.

Resolve by making use of the drop events cursor coordinates.
2022-07-19 13:33:02 +10:00
7ebd1f4b79 Cleanup: quiet compiler warnings 2022-07-19 13:32:53 +10:00
37922eab90 Fix T99794: regression from uv unwrap selected
Restore only_selected_faces flag inadvertently changed by c0e4532331

Differential Revision: https://developer.blender.org/D15480
2022-07-19 13:26:24 +12:00
135e530356 Fix T99781: uv minimize stretch now unflips flipped faces
Add a small gradient to flipped faces proportional to length of edges.

Differential Revision: https://developer.blender.org/D15475
2022-07-19 10:26:28 +12:00
Henrik Dick
d175eb6c30 Fix Text Editor highlight of assert and async
Due to the ordering of the checks, assert and async were not highlighted
in the editor, even though they were in the list of keywords.

Differential Revision: http://developer.blender.org/D15483
2022-07-18 23:33:30 +02:00
8358cc7963 Fix wrong alpha for scene linear byte images during texture painting
Make the update logic consistent with the case where the initial texture is
created. Also fixes a wrong assert.

Thanks Clément for spotting this.
2022-07-18 17:40:48 +02:00
cd21022b78 Context: implement an active_action property that returns a single action.
Although e.g. in the dopesheet there is no specific concept of
active action, displaying panels requires singling out one action
reference. It is more efficient and clearer to implement this
natively in the context rather than using selected_visible_actions[0].

- In the Action Editor the action is taken from the header.
- In the Dope Sheet the first selected action is chosen, because
  there is no concept of an active channel or keyframe.
- In the Graph Editor the action associated with the active curve
  is used, which should also be associated with the active vertex.
  This case may be different from selected_visible_actions[0].

Differential Revision: https://developer.blender.org/D15412
2022-07-18 17:44:46 +03:00
935b7a6f65 Context: implement indexing for list properties in path_resolve.
The real RNA path_resolve method supports indexing lists,
but the python version on the Context object does not. This
patch adds the missing feature for completeness.

Differential Revision: https://developer.blender.org/D15413
2022-07-18 17:38:00 +03:00
1f8567ac68 Fix T99750: crash with file output node, after image colorspace saving changes 2022-07-18 15:50:39 +02:00
757041560f Build: update Embree to 3.13.4, enable Neon2x on Arm
* Allows Apple Silicon machines to use 8-wide BVH, which the release notes
  mention give an 8% performance boost.
* An update to this version is also required for OpenPGL.

This patch includes contributions from Jason Fielder and Sebastian Herholz.

Ref D15286, T98555

Differential Revision: https://developer.blender.org/D15482
2022-07-18 15:36:34 +02:00
3407ed5f9b Cleanup: change internal Cycles compact BVH default to match UI 2022-07-18 15:34:13 +02:00
Damien Picard
dec8854bf3 I18n: translate add node operator tooltips
The tooltips from the Add Node menu were extracted, but not translated.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15467
2022-07-18 15:10:08 +02:00
Jun Mizutani
47f3b53756 Fix T99742: crash when generating rigify rigs, after recent changes
Differential Revision: https://developer.blender.org/D15473
2022-07-18 14:47:48 +02:00
c7f788b877 Subdiv: remove unused GPU device choice, fix crash with libepoxy on init
openSubdiv_init() would detect available evaluators before any OpenGL context
exists, causing a crash with libepoxy. This test however is redundant as we
already check the requirements on the Blender side through the GPU API.

To simplify things, completely remove the device detection in the opensubdiv
module and reduce the evaluators to just CPU and GPU. The plan here is to move
to the GPU module abstraction over OpenGL/Metal/Vulkan and so all these
different backends no longer make sense.

This also removes the user preference for OpenSubdiv compute device, which was
not used for the new GPU subdivision implementation.

Ref D15291

Differential Revision: https://developer.blender.org/D15470
2022-07-18 13:59:08 +02:00
3c016fbfd0 Fix error indenting new-lines in generated RST API docs
New-lines in RNA type descriptions caused invalid RST indentation.

This resolve the error noted by @nutti in D15481.
2022-07-18 20:00:21 +10:00
cd1e4ae448 Fix T99644: Anchored brush mode fails for negative brushes
The stroke code now supports raycasting the original mesh.
This fixes anchored mode not working for negative brushes,
which might move the mesh out of the initial mouse cursor
position.
2022-07-16 17:27:25 -07:00
9a14887905 Sculpt: Fix scene spacing mode (phase 1)
The scene spacing code was failing to
check if a raycast failed, which can happen
when sculpting the edges of objects in negative
mode.

Note I removed what I suspect was a hack put
in to fix this, spacing was clamped
to 0.001 scene units.

Scene spacing mode is actually quite broken,
so it will be fixed in a series of phases.
2022-07-16 16:45:41 -07:00
d136a996ca Audaspace: minor formatting fix for last commit. 2022-07-16 22:20:08 +02:00
Colin Basnett
1e4c557d82 Fix T99039: bpy.ops.sound.mixdown returns indecipherable error
Fix for {T99039}.

The problem was that `AUD_mixdown` and `AUD_mixdown_per_channel` were returning pointers to freed memory.

Two key changes are made:
1. The return value of those functions now simply return a bool as to whether the operation succeeded, instead of an optional error string pointer.
2. The error string buffer is now passed into the function to be filled in case an error occurs. In this way, the onus of memory ownership is unamibiguously on the caller.

Differential Revision: https://developer.blender.org/D15260
2022-07-16 22:14:19 +02:00
0a8d21e0c9 PyAPI: re-enable the "bgl" module for headless builds
Instead of removing the `bgl` module, set all it's functions to stubs
so importing `bgl` or any of it's members doesn't raise an error.

This avoids problems for scripts that import bgl but don't call it's
functions when running in background mode.
2022-07-16 17:30:17 +10:00
49babc7caa Cleanup: early exit MEM_lockfree_freeN when called with NULL pointer
Simplify logic for freeing a NULL pointer. While no null-pointer
de-reference was performed, this wasn't as so obvious as the pointer
was passed to MEM_lockfree_allocN_len before checking for NULL.

NOTE: T99744 claimed the a NULL pointer free was a vulnerability,
while I can't see evidence for this - exiting early makes it clearer
the memory isn't accessed.

*Details*

- Add MEMHEAD_LEN macro, avoids redundant NULL check.
- Use "UNLIKELY(..)" hint's for error cases
  (freeing NULL pointer and checking if `leak_detector_has_run`).
2022-07-16 17:23:42 +10:00
f76b537d48 Fix T99744: NULL pointer free with corrupt zSTD reading 2022-07-16 16:32:36 +10:00
bf49e6040c Fix error in assertion after 92a99c1496 2022-07-16 16:12:48 +10:00
b985437283 Fix workbench background render broken after recent changes from D15463
For Eevee the light baking can initialize OpenGL earlier, but for workbench we
can't assume the backend exists here already.
2022-07-15 20:10:42 +02:00
92a99c1496 Fix Eevee backround render crash after recent changes from D15463
Backend initialization needs to be delayed until after the OpenGL context
is created. This worked fine in foreground mode because the OpenGL context
already exists for the window at the point GPU_backend_init_once was called,
but not for background mode.

Create the backend just in time in GPU_context_create as before, and
automatically free it when the last context id discarded. But check if any
GPU backend is supported before creating the OpenGL context.

Ref D15463, D15465
2022-07-15 19:11:07 +02:00
5152c7c152 Cycles: refactor rays to have start and end distance, fix precision issues
For transparency, volume and light intersection rays, adjust these distances
rather than the ray start position. This way we increment the start distance
by the smallest possible float increment to avoid self intersections, and be
sure it works as the distance compared to be will be exactly the same as
before, due to the ray start position and direction remaining the same.

Fix T98764, T96537, hair ray tracing precision issues.

Differential Revision: https://developer.blender.org/D15455
2022-07-15 18:46:24 +02:00
bb376da6df Fix Cycles MetalRT error after recent specialization changes 2022-07-15 18:28:13 +02:00
03aeef64d5 Cleanup: compiler warnings 2022-07-15 16:57:04 +02:00
c505f19efe Fix compiler error in debug builds after 1cf465bbc3 2022-07-15 16:52:01 +02:00
1cf465bbc3 Fix GPU backend deleting resources without an active context
This causes an assert with libepoxy, but was wrong already regardless.

Refactor logic to work as follows:
* GPU_exit() deletes backend resources
* Destroy UI GPU resources with the context active
* Call GPU_backend_exit() after deleting the context

Ref D15291

Differential Revision: https://developer.blender.org/D15465
2022-07-15 16:31:28 +02:00
5e1229f253 Fix overly noisy surface deform warning message
An increased number of vertices is not a stopper for the surface
deform modifier anymore. It might still be useful to expose the
message in the UI, but printing error message to the console on
every modifier evaluation makes real errors to become almost
invisible.

Differential Revision: https://developer.blender.org/D15468
2022-07-15 16:30:11 +02:00
82f65d8971 Cleanup: VSE waveform drawing
No functional changes.
2022-07-15 15:52:37 +02:00
011d3c75a7 Cleanup: compiler warning 2022-07-15 15:20:53 +02:00
00dc747702 Fix T99706: Crash rendering with headless builds
When rendering with headless builds, show an error instead of crashing.

Previously GPU_backend_init was called indirectly from
DRW_opengl_context_create, a new function is now called from the window
manager (GPU_backend_init_once), so it's possible to check if the GPU
has a back-end.

This also disables the `bgl` Python module when building WITH_HEADLESS.

Reviewed By: fclem

Ref D15463
2022-07-15 22:16:44 +10:00
Damien Picard
180db0f752 UI: make many modifier strings translatable
This includes:
- new modifier names

It mostly uses `N_` because the strings are actually translated elsewhere.
The goal is simply to export them to .po files.

Most of the new translations were reported in T43295#1105335.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15418
2022-07-15 14:15:40 +02:00
914617f8fd Fix (unreported) LibOverride: invalid behaviors when creating (partial) overrides.
The outliner would tagg all existing local IDs (for remap from linked
reference data to newly created overrides) when creating a new override.
This would become critical issue in case there is several existing
copies of the same override hierarchy (leading to several hierarchies
using the same override).

Further more, BKE override creation code would not systematically
properly remapp linked usages to new overrides one whithin the affected
override hierarchy, leading to potential undesired remaining usages of
linked data.
2022-07-15 14:15:40 +02:00
523bbf7065 Cycles: generalize shader sorting / locality heuristic to all GPU devices
This was added for Metal, but also gives good results with CUDA and OptiX.
Also enable it for future Apple GPUs instead of only M1 and M2, since this has
been shown to help across multiple GPUs so the better bet seems to enable
rather than disable it.

Also moves some of the logic outside of the Metal device code, and always
enables the code in the kernel since other devices don't do dynamic compile.

Time per sample with OptiX + RTX A6000:
                                         new                  old
barbershop_interior                      0.0730s              0.0727s
bmw27                                    0.0047s              0.0053s
classroom                                0.0428s              0.0464s
fishy_cat                                0.0102s              0.0108s
junkshop                                 0.0366s              0.0395s
koro                                     0.0567s              0.0578s
monster                                  0.0206s              0.0223s
pabellon                                 0.0158s              0.0174s
sponza                                   0.0088s              0.0100s
spring                                   0.1267s              0.1280s
victor                                   0.0524s              0.0531s
wdas_cloud                               0.0817s              0.0816s

Ref D15331, T87836
2022-07-15 13:42:47 +02:00
da4ef05e4d Cycles: Apple Silicon optimization to specialize intersection kernels
The Metal backend now compiles and caches a second set of kernels which are
optimized for scene contents, enabled for Apple Silicon.

The implementation supports doing this both for intersection and shading
kernels. However this is currently only enabled for intersection kernels that
are quick to compile, and already give a good speedup. Enabling this for
shading kernels would be faster still, however this also causes a long wait
times and would need a good user interface to control this.

M1 Max samples per minute (macOS 13.0):

                    PSO_GENERIC  PSO_SPECIALIZED_INTERSECT  PSO_SPECIALIZED_SHADE

barbershop_interior       83.4	            89.5                   93.7
bmw27                   1486.1	          1671.0                 1825.8
classroom                175.2	           196.8                  206.3
fishy_cat                674.2	           704.3                  719.3
junkshop                 205.4	           212.0                  257.7
koro                     310.1	           336.1                  342.8
monster                  376.7	           418.6                  424.1
pabellon                 273.5	           325.4                  339.8
sponza                   830.6	           929.6                 1142.4
victor                    86.7              96.4                   96.3
wdas_cloud               111.8	           112.7                  183.1

Code contributed by Jason Fielder, Morteza Mostajabodaveh and Michael Jones

Differential Revision: https://developer.blender.org/D14645
2022-07-15 13:40:04 +02:00
5653c5fcdd Cycles: keep track of SVM nodes used in kernels
To be used for specialization in Metal, to automatically leave out unused nodes
from the kernel.

Ref D14645
2022-07-15 13:40:04 +02:00
79da7f2a8f Cycles: refactor to move part of KernelData definition to template header
To be used for specialization on Metal in a following commit, turning these
members into compile time constants.

Ref D14645
2022-07-15 13:40:04 +02:00
Damien Picard
2e70d5cb98 Render: camera depth of field support for armature bone targets
This is useful when using an armature as a camera rig, to avoid creating and
targetting an empty object.

Differential Revision: https://developer.blender.org/D7012
2022-07-15 13:40:04 +02:00
5ddbc14bb2 Render: improve render border operator in image editor
* Snap border to pixels just outside the drawn border, to more easily select
  specific pixels by drawing a border inside them.
* Support cropped border renders.
2022-07-15 13:40:04 +02:00
9ea1b88f0f Cleanup: add utlity function to compute render resolution
Instead of duplicating logic many times.
2022-07-15 13:40:04 +02:00
b8ffd43bd2 Cleanup: make format 2022-07-15 13:40:04 +02:00
4d7c990180 Fix T98061: uv resize with individual origins could break constrain to bounds
Fix unreported: Resize with Constrain To Bounds will now limit one shared scale
value for both U and V instead of calculating separate scale values for each.

To fix T98061, the individual origins (transdata->center) is now used when
that mode is active.

See also: 0e9367fc29

Differential Revision: https://developer.blender.org/D15420
2022-07-15 23:18:13 +12:00
e69c4482f1 I18n: Add suport for labels from modifiers' subpanels.
Was a bit oif a struggle since those functions take a first string which
is not our label, but should work fine now.

Reported/detected as part of D15418.
2022-07-15 11:42:58 +02:00
Martijn Versteegh
8e1323f633 Fix: Move DRW_shgroup_add_material_resources(grp, mat) to after the null-check for grp.
Reviewed By: fclem

Maniphest Tasks: T99646

Differential Revision: https://developer.blender.org/D15436
2022-07-15 11:23:26 +02:00
f4d7ea2cf6 Fix T99606: Regression: TexCoordinate losing precision far away from origin
Same root cause as T99128. The fix also needed to be done in another place.
2022-07-15 11:16:14 +02:00
98f688ac42 GPU: Fix shader builder on hardware that does not have all features 2022-07-15 11:16:14 +02:00
862170c0b1 Cleanup: GPU: Replace NULL by nullptr from C++ files 2022-07-15 11:16:14 +02:00
ca1daf4cda Fix an increasing bottleneck when key press operator is too slow
The goal of this change is to fix an increasing bottleneck of the event
queue handling when there is an operator bound to a key press event and
is taking longer to finish than a key-repeat speed on the system.

Practical example of when it happens is the marker tracking operator in
a single-frame track mode. Quite often artists will hold down Alt-arrow
to track a segment of footage which seems trivial to track. The issue
arises when the Alt-arrow is released: prior to this change it is was
possible that more frames will be tracked. It also seems that redraws
are less smooth.

It is a bit hard to make easily shareable computer-independent test
case. Instead, a synthetic case can be reproduced by adding a 50 ms
sleep in the `text_move_exec()`. In such synthetic case open a long
text in the text editor and hold left/right arrow button to navigate
the cursor. The observed behavior is that seemingly redraws happen
less and less often and cursor travels longer and longer distances
between redraws. The cursor will also keep moving after the buttons
has been released.

The proposed solution is to ignore sequential key-press events from
being added to the event queue. This seems to be the least intrusive
and the most safe approach:

- If the operator is fast enough there will be no multiple press events
  in the queue in both prior and after of this change.

- If the operator is slow enough, clicking the button multiple times
  (i.e. clicking arrow button 3 times in a heavy shot will change the
  scene frame by exactly 3 frames because no events are ignored in
  this case).

- Only do it for key press events, keeping mouse and tabled behavior
  unchanged which is crucial for the paint mode.

Note that this is a bit different from the key repeat tracking and
filtering which is already implemented for keymaps as here we only want
to avoid the event queue build-up and do want to ignore all repeat
events. In other words: we do want to handle as many key presses as the
operator performance allows it without clogging anything.

A possible extension to this change could be a key press counter, so
that instead of ignoring the event we merge it into the last event in
the queue, incrementing some counter. This way if some operator really
needs to know exact number of key repeats it can still access it.

Differential Revision: https://developer.blender.org/D15444
2022-07-15 11:03:00 +02:00
c2715dc416 GPU: Remove USD dependency from shader_builder.
Dependency was added as shader builder depended to blenkernel as an
umbrella, in stead of adding the actual dependencies it required.
2022-07-15 10:54:10 +02:00
63ea0f7581 BLI_bitmap: fix _BITMAP_NUM_BLOCKS to not over-count by one block
For bit counts that were exact multiple of block size, the macro was
computing one block too much.

Reviewed By: Campbell Barton, Bastien Montagne
Differential Revision: https://developer.blender.org/D15454
2022-07-15 10:21:27 +03:00
8fd2b79ca1 BLI_bitmap: ability to declare by-value, and function to find lowest unset bit
In preparation for a larger change (D14162), some BLI_bitmap
functionality that could be submitted separately:

- Ability to declare a fixed size bitmap by-value, without extra
  memory allocation: BLI_BITMAP_DECLARE
- Function to find the index of lowest unset bit:
  BLI_bitmap_find_first_unset
- Test coverage of the above.

Reviewed By: Campbell Barton, Bastien Montagne
Differential Revision: https://developer.blender.org/D15454
2022-07-15 10:20:04 +03:00
d8094f9212 GHOST/Wayland: partial support for updating the UI scale
Partial support for changing the UI scale while Blender is open.

The scale is set but issues with the window size not updating remain.
2022-07-15 15:42:24 +10:00
60f260eb6a GHOST/Wayland: fix error setting the cursor scale
Calculate a scale that's compatible with the cursor size.
Needed so the cursor is always a multiple of scale.
2022-07-15 15:36:21 +10:00
d14d570580 blend_render_info: add check for negative BHead length (corrupt file)
Without this check, corrupt files would raise a Python exception,
now early exit with a useful error.
2022-07-15 14:53:38 +10:00
c8e8f107bf Fix T99711: Eternal loop reading blend file thumbnail
Account for negative BHead length (already handled by blend file loading).
2022-07-15 14:53:38 +10:00
675f6ef089 Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData
Use const pointers to ImageSaveOptions and ImageFormatData for API
parameters where appropriate.

Differential Revision: https://developer.blender.org/D15400
2022-07-14 21:27:58 -07:00
178868cf42 Fix T79304: improve uv island calculation when in edge selection mode
Differential Revision: https://developer.blender.org/D15419
2022-07-15 14:19:48 +12:00
0e9367fc29 Cleanup: separate clipUVTransform into two different functions
No functional changes.

Prep for D15420 / T98061.
2022-07-15 10:44:11 +12:00
b1329d7eaa Fix T99705: fix integer overflow in thumbnail extractor
It was smart enough to check if the buffer had the right
size but neglected to cast to a 64 bit value so it
overflowed.

Differential Revision: https://developer.blender.org/D15457
Reviewed By: brecht
2022-07-14 12:18:35 -06:00
9fedcde750 Modifiers: fix mesh to volume modifier on non-volume objects 2022-07-14 20:05:23 +02:00
bdd0ac5bce Fix on_drag_start handler not getting ID when dragging from Outliner
We would first invoke the dragging, and then set the drag data (like the
ID or the dragged modifier), so the `wmDropBox.on_drag_start()` handler
wouldn't be able to access this. This broke dragging some IDs from the
Outliner, noticed in D15333.

It's now possible to first create/request drag data, extend it, and then
invoke the actual dragging. The normal function to start dragging
returns `void` now instead of `wmDrag *`, so the drag data can't easily
be modified after starting anymore.
2022-07-14 19:21:56 +02:00
1ef686bd26 UI: Tweak layout of File Browser Preferences
* Don't nest "Show Recent Locations" and "Show System Locations" under a
  "Defaults" heading. They are not just a default setting but completely
  hide panels from the UI.
* Use own "Show Locations" heading instead, and remove redundant words
  from labels.
* Move the options to the top of the panel, they are more general since
  they can't be toggled in a File Browser session, and thus have bigger
  impact.

We may want to remove these options in a future major release, I don't
think they are useful.

Agreed on with Pablo Vazquez.
2022-07-14 19:21:22 +02:00
b6de6da59a I18n: Fix regex for messages from BKE_modifier_set_error.
Signature of this function changed at some point, regex to extract
messages from it was no longer working.

Reported/detected as part of D15418.
2022-07-14 18:50:16 +02:00
3b15467e97 Fix T99702: Gpencil Flip strokes did not support multiframe edit
This was a missing feature and this commit solves this.
2022-07-14 16:42:26 +02:00
Olivier Maury
1b5db02a02 Fix Cycles MNEE wrong results with area light spread
When the solve is successful, the light sample needs to be updated since the
effective shading point is now on the last refractive interface. Spread was
not taken into account, creating false caustics.

Differential Revision: https://developer.blender.org/D15449
2022-07-14 16:36:38 +02:00
28c3739a9b Cleanup: replace state flow macros in the kernel with functions 2022-07-14 16:36:38 +02:00
5539fb3121 Cycles: add presets to the Performance panel
With choices Default, Lower Memory and Faster Render. For convenience, and
to help communicate what the various settings do.

Differential Revision: https://developer.blender.org/D15446
2022-07-14 16:36:38 +02:00
02ce29c6ee Improve Tool tip for Add-on search
Differential Revision: https://developer.blender.org/D15411
2022-07-14 16:33:04 +02:00
4b1d315017 Cycles: Improve cache usage on Apple GPUs by chunking active indices
This patch partitions the active indices into chunks prior to sorting by material in order to tradeoff some material coherence for better locality. On Apple Silicon GPUs (particularly higher end M1-family GPUs), we observe overall render time speedups of up to 15%. The partitioning is implemented by repeating the range of `shader_sort_key` for each partition, and encoding a "locator" key which distributes the indices into sorted chunks.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15331
2022-07-14 14:26:18 +01:00
47d4ce498e Cleanup: minor changes to camera frame fitting
Use const vars & make order of min/max checks consistent.
2022-07-14 22:08:30 +10:00
2d04012e57 Cleanup: spelling in comments
Also remove duplicate comments in bmesh_log.h, caused by automated
comment relocation in [0].

[0]: c4e041da23
2022-07-14 22:02:52 +10:00
9dfabc1de3 Cleanup: remove redundant event->val check for 3D text insertion 2022-07-14 22:01:43 +10:00
93f74299f0 Cleanup: clang-tidy changes to GHOST_SystemX11
Also remove redundant check.
2022-07-14 21:55:46 +10:00
cdd8b96e3b GHOST: remove redundant ascii argument to GHOST_EventKey
Now only the utf8 buffer is used there is no reason to pass both.
2022-07-14 21:54:28 +10:00
eb3e56a36e Fix: Wrong output types for some compositor nodes
The Difference Matte and RGB To BW nodes have a wrong output type. They
should be floats but are of type color.

This is a regression that was introduced during the migration to the
socket builder API in D13266.

Reviewed By: Blendify, fclem

Differential Revision: https://developer.blender.org/D15232
2022-07-14 13:52:44 +02:00
db80cf6ad7 GHOST/X11: avoid redundant utf8 text lookups for release events
The text representation of release events is never used,
so only calculate this for press events.
2022-07-14 21:10:22 +10:00
64e196422e GHOST/X11: Quiet warning about key-release events having their utf8 set
Quiet warning from [0], no functional change as the this information
was always ignored.

Key release events shouldn't have associated text, this was cleared
for wmEvent's, so there is no reason to pass it from GHOST.

[0]: d6fef73ef1
2022-07-14 21:04:16 +10:00
7fa7722350 Cleanup: format, unused argument 2022-07-14 20:53:20 +10:00
6cd30d5ff0 IDManagement: add more ID naming tests
As part of a larger change (https://developer.blender.org/D14162),
adding more test coverage for existing functionality separately.

New tests:
- ids_sorted_by_default
- ids_sorted_by_default_with_libraries
- name_too_long_handling
- create_equivalent_numeric_suffixes
- zero_suffix_is_never_assigned
- remove_after_dup_get_original_name
- name_number_suffix_assignment
- renames_with_duplicates
- names_are_unique_per_id_type
2022-07-14 13:41:43 +03:00
9024ac31be Fix curve drawing crash after changing geometry nodes output.
Using geometry nodes with attributes on a curve object and changing the
output is crashing. This is because the `render_mutex` in the curve
drawing cache is cleared after changes in `curves_batch_cache_init` and
set to null. The cache isn't actually needed currently because all draw
updates are single-threaded, but the new `drw_attributes_merge` function
still tries to access it (this seems to be tolerated on Linux platforms
but crashes on Windows).

Make sure the render_mutex is always initialized after (re-)initializing
the cache.
2022-07-14 11:17:59 +01:00
cb62095c1c Correct error with IME from d6fef73ef1 2022-07-14 20:07:06 +10:00
96cc603037 Geometry Nodes: update curve type counts after realizing instances
The type counts have to be updated eagerly. This was missing from
the realize-instances code before, leading to bugs further down
the line.
2022-07-14 11:49:28 +02:00
c8a07ef663 BLI: fix finding indices from virtual array
The sorting of index vectors assumed that all vectors have
at least one element. Now this is checked for more explicitely.
2022-07-14 11:32:01 +02:00
bcdce4ffd8 Geometry Nodes: fix face corner to edge boolean interpolation
This is a follow up for rB44e530e1b107fd0d91f472f9a58642ab59fd5422
which did not fix the function that interpolates boolean attributes.
2022-07-14 10:47:26 +02:00
44e530e1b1 Geometry Nodes: fix face corner to edge attribute interpolation
Looks like this was wrong all the time.. Luckily, this conversion
is not very common.

Found when testing D15274.
2022-07-14 10:35:59 +02:00
Damien Picard
9d73bbd966 UI: translate tooltips coming from menu descriptions
Many menus get their labels exported to the .po file, but then are not actually translated in the UI.

Before:
{F13283752}

After:
{F13283750}

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15417
2022-07-14 10:29:10 +02:00
Colin Basnett
8e3879ab52 Cleanup: Rename & refactor several F-curve functions
Rename and refactor several F-curve key manipulation functions, and move
them from `editors` to `blenkernel`.

The functions formerly known as `delete_fcurve_key`,
`delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from
`ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according
to hierarchical naming rules.

Below is a table of the naming changes.

| From | To |
| -- | -- |
| `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, index)` |
| `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` |
| `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` |
| `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` |
| `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` |

The function formerly known as `delete_fcurve_key` no longer takes a
`do_fast` parameter, which determined whether or not to call
`calchandles_fcurve`. Now, the responsibility is on the caller to run
the new `BKE_fcurve_handles_recalc` function if they have want to
recalculate the handles.

In addition, there is now a new static private function called
`fcurve_bezt_free` which sets the key count to zero and frees the key
array. This function is now used in couple of instances of functionally
equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a
wrapper around `fcurve_bezt_free`.

This change was initially spurred by the fact that `delete_fcurve_keys`
was improperly named; this was a good opportunity to fix the location
and naming of a few of these functions.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15282
2022-07-14 10:24:32 +02:00
Iliay Katueshenock
77df9d788a Fix T99239: weird behavior in Field on Domain node 2022-07-14 10:05:24 +02:00
Damien Picard
f48fadc953 UI: translate quick favorites menu operator names
Some operator titles were not translated in the quick favorites menu.

Before:
{F13283724}

After:
{F13283725}

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15416
2022-07-14 10:01:09 +02:00
Damien Picard
1571ee66b5 I18N: Allow translating newly added GP data names, and a missing Surface one. 2022-07-14 10:01:09 +02:00
3935bf255e Fix T99677: crash when convex hull node is used on empty mesh
Fundamental issue is that the attribute api returns none, because
the custom data api returns null for a layer when the size of 0.
This should be improved separately.
2022-07-14 09:57:08 +02:00
411bcf1fe7 Cleanup: simplify 3D text insert, remove checks for ascii escape codes
3D text included checks for escape codes such as \n\r\b which have not
been included in wmEvent.ascii since [0] (2009).

Remove these and use more straightforward logic for overriding the
events text input.

[0] 66437a62a7
2022-07-14 17:04:22 +10:00
b35e33317d Cleanup: update & correct comments for event handling
- Remove references to `ISTEXTINPUT` as any keyboard event with it's
  utf8_buf set can be handled as text input.

- Update references to the key repeat flag.
2022-07-14 16:10:13 +10:00
d6fef73ef1 WM: Remove ASCII members from wmEvent & GHOST_TEventKeyData
The `ascii` member was only kept for historic reason as some platforms
didn't support utf8 when it was first introduced.

Remove the `ascii` struct members since many checks used this as a
fall-back for utf8_buf not being set which isn't needed.
There are a few cases where it's convenient to access the ASCII value
of an event (or nil) so a function has been added to do that.

*Details*

- WM_event_utf8_to_ascii() has been added for the few cases an events
  ASCII value needs to be accessed, this just avoids having to do
  multi-byte character checks in-line.

- RNA Event.ascii remains, using utf8_buf[0] for single byte characters.

- GHOST_TEventKeyData.ascii has been removed.

- To avoid regressions non-ASCII Latin1 characters from GHOST are
  converted into multi-byte UTF8, when building X11 without
  XInput & X_HAVE_UTF8_STRING it seems like could still occur.
2022-07-14 15:59:19 +10:00
816a73891b GHOST/SDL: pass in utf8 buffer for keyboard events
While GHOST/SDL doesn't support non-ASCII text input,
use the UTF8 buffer to be consistent with all other back-ends.

Move the conversion from SDL_KeyboardEvent to ASCII into a function.

Also only lookup this value on key press (not release).
2022-07-14 15:58:46 +10:00
d3374e5337 Fix build and warnings from previous commit. 2022-07-14 16:19:21 +12:00
931779197a Fix T99684: Upgrade Averages Island Scale with options Scale UV and Shear
Differential Revision: https://developer.blender.org/D15421
2022-07-14 15:42:08 +12:00
09a74ff8b6 GHOST/SDL: add support for the key repeat flag
Now all ghost back-ends support the key repeat flag
(accessed as WM_EVENT_IS_REPEAT from wmEvent.flag).
2022-07-14 09:46:58 +10:00
50d832634e Docs: Fix out of order parameters
Fixes T99672
2022-07-13 16:25:57 -04:00
144d9f2b2e Cleanup: Do not use spaces in default data names.
Using white spaces in data names should not be encouraged in general,
better not give wrong example here.

Originally part of D15441.
2022-07-13 17:40:35 +02:00
88fbf0a8fc Fix (studio-reported) bad remapping of libraries.
New remapper code would also fail in some cases when remapping
libraries, similar to the issue yesterday, because ID_LI type had no
mask value.

That would fail to remap `parent` member of a library to NULL when
deleting that parent, leading to a crash e.g. in Outliner tree building
code.

Reported by @JulienKaspar from Blender studio.
2022-07-13 16:11:59 +02:00
ccdf189d3c Documentation: Update Docs for Gizmo
This patch updates the documentation for arguments regarding the `Gizmo`
type.

- Corrected `select_id` doc for draw_preset_ functions. `-1` indicates
  that no selection ID is to be written, but previous docs incorrectly
  specified `0` instead.
- Added missing doc for `target` argument for `target_set_handler`
  function.

Reviewed by: Aaron Carlisle (Blendify)

Differential Revision: https://developer.blender.org/D14834
2022-07-13 08:43:57 -04:00
441dd08dba Expose option for fallback tools keymap in GizmoGroup type
This patch allows new GizmoGroup classes to support tool fallback keymap.

With this patch, when new gizmo groups add `'TOOL_FALLBACK_KEYMAP'` to
its `bl_options`, the fallback tools are added to the group. This
allows a `WorkSpaceTool` (for example) to have selection be a fallback
tool if the user LeftMouse drags away from other gizmos in the group.

Reviewed by: Campbell Barton (campbellbarton)

Differential Revision: https://developer.blender.org/D15154
2022-07-13 08:30:40 -04:00
c484599687 Expose snap options in transform operators
This commit exposes snap options in transform operators. These options
are needed for Python tools to control snapping without requiring the
tool settings to be adjusted.

The newly exposed options are:

- `snap_elements` for choosing which element(s) of target the source
  geometry should snap to (ex: Face Raycast).
- `use_snap_self`, `use_snap_edit`, `use_snap_nonedit`,
  `use_snap_selectable_only` for controlling target selection.
- `use_snap_project` for controlling Face Raycast snapping.
- `use_snap_to_same_target` and `snap_face_nearest_steps` for
  controlling Face Nearest snapping.

Reviewed by: Campbell Barton (campbellbarton)

Differential Revision: https://developer.blender.org/D15398
2022-07-13 07:10:09 -04:00
c8be3d3b27 Fix T99654: Applying Mirror modifier breaks the erase tool
The problem was the new generated strokes were copied from original and the location was offset to mirror, but the internal geometry data was not updated and the collision check done by brushes was not working.

Now, the internal geometry data is recalculated when the modifier is applied.
2022-07-13 12:56:48 +02:00
74888cdbfd Fix (studio-reported) issue in remapping code.
Not clearing runtime remapping data for the new ID as well as the old
one can lead to false stale data there, wichi could e.g. make indirectly
linked data be tagged as directly linked.

This would generate an error report on file write when hapening on
ShapeKey ID, since that type is not allowed to be directly linked.
2022-07-13 11:15:19 +02:00
a084839605 Cleanup: logical order of axis defines, assign variables for readability 2022-07-13 16:42:06 +10:00
b3913d7551 Cleanup: use defines for camera axes for view frame fitting
The values used for axes weren't in any meaningful order, use defines
to improve readability.
2022-07-13 16:18:16 +10:00
9422627155 Fix T99653: "Align Active Camera to Selected" fails with ortho camera
There were two bugs, a regression in [0] and the object-data wasn't
tagged for depsgraph updating.

[0]: 19df0e3cfd
2022-07-13 16:18:14 +10:00
8f543a73ab Fix T99659: Improve UV Island calculation with hidden faces.
Simplify interface, regularize implementation and some light cleanup.

See also: T79304 and D15419.
2022-07-13 11:42:42 +12:00
d0a552b5c6 Fix: set dangling pointer to null
The data has been moved somewhere else, the span should not
keep a pointer to it.
2022-07-12 18:47:51 +02:00
5f09440d5a Cycles: Make not-compact BVH the default for embree
Measurements shown on average a 1.08x speedup for a 1.04x increase in
memory usage which is an acceptable trade off for a default setting,
although discoverability of such settings influencing memory usage could
be improved.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15429
2022-07-12 18:40:14 +02:00
9f153949f9 Enable "copy to selected" for new Curves modifiers
The operator bpy.ops.object.modifier_copy_to_selected()
does not work for the new Curves objects.
This is because it isn't added to BKE_object_supports_modifiers.

Differential Revision: https://developer.blender.org/D15439
2022-07-12 18:31:33 +02:00
1c382a4940 Curves: improve error checking in deform curves on surface node 2022-07-12 17:10:23 +02:00
02aefa7659 Fix: wrong node name in menu 2022-07-12 17:10:23 +02:00
b767628173 Fix: Memory leaks in indexer code
Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D15376
2022-07-12 16:58:04 +02:00
Khoi Dau
93253d5dcc Fix T99103: crash when displaying or rendering Grease Pencil object
On some hardware/systems, blender may crash when adding, rendering or displaying Grease Pencil objects.

In `/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl`, line 35:
```
gpMaterialFlag gp_flag = floatBitsToInt(gp_mat._flag);
```
`gpMaterialFlag` is of type `uint`. This is a mismatched-type assignment that can cause crashes on some hardware/systems with GLSL that do not support implicit type casting.

So use `floatBitsToUint` for type conversion.

Differential Revision: https://developer.blender.org/D15433
2022-07-12 11:34:41 -03:00
d58072caf4 Fix: missing geometry copy before modifying it
A geometry component may reference read-only geometry.
In this case it has to be copied before making changes to it.

This was caused by rBb876ce2a4a4638142.
2022-07-12 16:27:06 +02:00
47dd42485e Cycles: fix and enable JIT oneAPI CentOS7 builds for drivers 23570+
The current specific CentOS7 workaround we have for AoT, which is to
disable __FAST_MATH__ by using -fhonor-nans, now also fixes the
compilation issue for JIT as well since at least driver 23570.
2022-07-12 15:55:32 +02:00
4a445c8dc0 LibOverride: Fix some issues from.revealed by recent previous commit.
rB57097e9a8515 did not properly consider case where you have more than
one override for a same reference linked ID.

Also adds more security checks around shapekeys, since match between
override and its linked reference is never ensured either way (fixes a
crash reported by @Rik from Blender studio).
2022-07-12 15:34:40 +02:00
f72cedffb6 Cleanup: Use interpf instead of repeating the logic
This makes the code clearer.
2022-07-12 10:20:01 -03:00
2d1fe736fa Fix T96238: shrinking to zero doesn't actually scales the radius to zero
Probably to prevent the radius of a point from being stuck at zero,
the `Shrink/Fatten` curve operator sets a minimum value of `0.001`
for all points being transformed.

This is an inconvenience as these points may have been purposely set
to zero on the panel.

And it also doesn't follow the convention seen in other operators
(which keep the value zero).

So remove this limitation.
2022-07-12 10:11:05 -03:00
57097e9a85 Fix T99261: partial LibOverride creation would not properly remap all needed data.
When creating partial overrides, there may also be need to reamap usage
of linked data towards already existing overrides, in newly created
overrides.
2022-07-12 14:39:08 +02:00
RedMser
4344b2bf19 Markers: Make delete confirmation depend on key used
Add a 'Delete Confirmation' operator property to the 'Delete Marker'
operator. This determines whether the user is asked to confirm the
deletion or not.

Defaults so that only {key X} ({key Backspace} for industry compatible
keymap) prompts for deletion, whereas {key Del} does not show the
confirmation popup.

This also makes the default keymap for marker deletion consistent with
the common delete operators (such as objects and keyframes).

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D13818
2022-07-12 13:00:56 +02:00
52b7f2b089 UV: Box and lasso selection for partially intersecting edges
In UV edge mode, box and lasso selections allow edge selections only
when the entire edge is contained within the selection area. This
doesn't consider any edges that partially overlap with the selection
area.

This is  now fixed by adding a second pass, similar to how these
operators work for edit-mesh selections. Now if both operators are
unable to find any edges contained within the selection area, then
they will perform a second pass which checks for edges that partially
intersect with the selection area.

Now edge selection in the UV editor matches edit-mesh edge-selection
when drawing wire-frame.

Resolves T99443.

Ref D15362
2022-07-12 19:50:40 +10:00
bb3a538843 Fix: Incorrect coordinates used in BLI_rct*_isect_segment functions
Ref D15330.
2022-07-12 19:28:26 +10:00
8bd32019ca Fix threading crash due to conflict in mesh wrapper type
A mesh wrapper might be being accessed for read-only from one thread
while another thread converts the wrapper type to something else.

The proposes solution is to defer assignment of the mesh wrapper
type until the wrapper is fully converted. The good thing about this
approach is that it does not introduce extra synchronization (and,
potentially, evaluation pipeline stalls). The downside is that it
might not work with all possible wrapper types in the future. If a
wrapper type which does not clear data separation is ever added in
the future we will re-consider the threading safety then.

Unfortunately, some changes outside of the mesh wrapper file are
to be made to allow "incremental" construction of the mesh prior
changing its wrapper type.

Unfortunately, there is no simplified file which demonstrates the
issue. It was investigated using Heist production file checked at
the revision 1228: `pro/lib/char/einar/einar.shading.blend`. The
repro case is simple: tab into edit mode, possibly few times.

The gist is that there several surface deform and shrinkwrap
modifiers which uses the same target. While one of them is building
BVH tree (which changes wrapper type) the other one accesses it for
read-only via `BKE_mesh_wrapper_vert_coords_copy_with_mat4()`.

Differential Revision: https://developer.blender.org/D15424
2022-07-12 10:26:52 +02:00
6e6da22eb0 Fix: crash when iterating over all attributes 2022-07-12 09:42:19 +02:00
b8d1e576bc Cleanup: use array for internal _bpy methods 2022-07-12 16:11:19 +10:00
ae6a4fcc7a Tests: add test to ensure restricted py-driver execution is working
Add internal function (only used for testing at the moment)
`_bpy._driver_secure_code_test`.

Add test `script_pyapi_bpy_driver_secure_eval` to serves two purposes:

- Ensure expressions that should be insecure remain so when upgrading
  Python or making any changes in this area.

- Ensure new versions of Python don't introduce new byte-codes that
  prevent existing expressions from being executed
  (happened when upgrading from 3.7, see [0]).

[0]: dfa5201763
2022-07-12 16:11:19 +10:00
00c7e760b3 Python: add opcodes for safe py-drivers
The following opcodes have been added, see [0] for details:

- LIST_TO_TUPLE: convert a list to a tuple,
  use for constructing lists/tuples in some cases.

- LIST_EXTEND: use for constructing lists with unpacking.

- SET_UPDATE: use for constructing sets with unpacking.

- CONTAINS_OP: check if `a in b` generally useful.

When writing tests these op-codes where needed for basic operations
and can be safely supported.

Add note why dictionary manipulation op-codes have been left out.

Also restrict namsepace access to anything with an underscore prefix
since these may be undocumented.

[0]: https://docs.python.org/3.10/library/dis.html
2022-07-12 16:05:13 +10:00
2a1d12d7a0 Fix (studio-reported) crash in ID remapping code on rare cases.
Some ID types did not have a filter value, even though they would be
used in remapping code, leading to missing remappings. In that specific
case, shape keys would actually never be properly remapped.

Reproducible in r1230 of
`Heist/pro/animation_test/einar/einar_new_expression_shapes2.blend`,
2022-07-11 19:16:04 +02:00
995c904d00 Fix (unreported) crash in liboverride code on rare cases.
When dealing with 'embedded' IDs (and the like, e.g. shape keys),
liboverride code could fail in case the reference linked data (e.g. a
mesh) would not have a shapekey anymore, while the override mesh would
still have one.

Found while investigating another issue in Heist production file
`Heist/pro/animation_test/einar/einar_new_expression_shapes2.blend`,
r1230.
2022-07-11 19:16:04 +02:00
8ca09e6c5e GPU: add BUIDTIME to WITH_GPU_SHADER_BUILDER
Adds a better name that describes when it is used.
The GPU_SHADER_BUILDER is a buildtime tool for developers
to pre-validate GLSL (and in the overseen future pre-compile to
SpirV). We don't see that this needs to become a required
step in the future so WITH_GPU_BUILDTIME_SHADER_BUILDER
is more descriptive name.
2022-07-11 16:45:07 +02:00
Jeroen Bakker
76d8614236 GPU: Do not allow GPU Shader builder when USD is enabled.
Linking GPU shader builder requires stubs for many functions of the USD library.
We don't want to rely on other modules to update the stubs for a tool that
is only used by GPU developers.

This patch raises an error when both WITH_GPU_SHADER_BUILDER and WITH_USD are
enabled. This reduces the maintenance of updating the stubs when USD API changes.

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D15422
2022-07-11 16:12:36 +02:00
6e426259b4 Fix T99218: light group add button should be disabled when name is empty
Previously it was inactive but still clickable.

Ref D15316
2022-07-11 14:02:38 +02:00
6ca5ac2084 GPU: Update shader builder stubs.
Fixes workflow when using WITH_GPU_SHADER_BUILDER=On.
2022-07-11 13:36:29 +02:00
275419f6fd Fix/Cleanup UI messages. 2022-07-11 12:46:22 +02:00
1c4c904786 Deps Builder: Disable TermInfo and ncurses for DPC++
They are not strictly needed for compilation and disabling them makes
the compiler more portable without any special trickery.

This change aimed to solve problem which currently happens on the API
documentation build which does not have terminfo installed, but needs
to compile Cycles.

Note that the DPC++ is to be re-compiled.
2022-07-11 12:09:09 +02:00
da101118d4 Cleanup: Remove unused operator name storage in UI lists 2022-07-11 11:17:08 +02:00
7357176b57 Fix T99383: Wrong origdata type in color filter 2022-07-11 00:19:53 -07:00
cb39058f2f Fix T94633: Sculpt mode missing check for hidden active object
Note there is a bug in BKE_object_is_visible_in_viewport, it
returns false when the object is in local mode.

The transform operator poll should do a similar test.  That
would allow us to move the test from sculpt_brush_strok_invoke
to SCULPT_mode_poll (at the moment we cannot do this due to
the brush operator falling through to the translate keymap
item in global view3d keymap).
2022-07-10 23:39:45 -07:00
133d398120 PyAPI: add Matrix.is_identity read-only attribute
Add a convenient way of checking if the matrix is an identity matrix.
2022-07-11 12:45:00 +10:00
d51bc8215f GPencil: Dot-dash modifier rename segment bug fix.
This patch fixes naming and renaming issue with dot-dash modifier segment list.

Before: when double clicking and exiting it would append
number at the end regardless of name being changed or not.

Now it works like in other areas.

Authored by: Aleš Jelovčan (frogstomp)

Reviewed By: YimingWu (NicksBest)

Differential Revision: https://developer.blender.org/D15359
2022-07-11 10:13:07 +08:00
d4a4691c0c Cleanup: spelling in comments 2022-07-11 10:38:04 +10:00
a83502f05f Cleanup: remove unused GHOST function getAnyModifiedState.
Remove unused GHOST_WindowManager::getAnyModifiedState()
2022-07-11 10:38:02 +10:00
7f4ee97b9e Revert "Fix an assert trip in boolean tickled by D11272 example."
This reverts commit 6543290116.
It broke tests and I don't know why, so reverting this while
figuring that out.
2022-07-10 18:50:11 -04:00
6543290116 Fix an assert trip in boolean tickled by D11272 example.
The face merging code in exact boolean made an assumption that
the tesselated original face was manifold except at the boundaries.
This should be true but sometimes (e.g., if the input faces have
self-intersection, as happens in the example), it is not.
This commit makes face merging tolerant of such a situation.
It might leave some stray edges from triangulation, but it should
only happen if the input is malformed.
Note: the input may be malformed if there were previous booleans
in the stack, since snapping the exact result to float coordinates
is not guaranteed to leave the mesh without defects.
2022-07-10 14:50:17 -04:00
fad857f473 Fix T99532: New OBJ importer in some cases fails to import faces
The importer code was written under incorrect assumption that vertex
data (v, vn, vt commands etc.) are grouped by object, i.e. follow the
o command, and that each object has its own vertex data commands. This
is not the case -- all the vertex data in the whole OBJ file is
"global", with no relation to any objects/groups; it's just that the
faces belong to the object, and then they pull in any vertices they
like.

This patch fixes this incorrect assumption in the importer:

- Vertex data is now properly global; no need to track some sort of
  "offsets" per object like it was doing before.
- For each object, face definitions track the minimum & maximum vertex
  indices referenced by the object, and then all that vertex range is
  created in the final Blender object. Note: it might be (unusual, but
  possible) that an object does not reference a sequential range of
  vertices, e.g. just a single face with vertex indices 1, 10, 100 --
  the resulting Blender mesh will have all the 100 vertices (some
  "loose" without belonging to a face). It should be possible to track
  the used vertices exactly (e.g. with a vector set), but I haven't
  done that for performance reasons.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D15410
2022-07-10 20:09:29 +03:00
4114ace616 Fix T99536: new 3.2 OBJ importer fails with trailing space after wrapped lines
Address the issue by re-working line continuation handling: stop
trying to parse sequences like "backslash, newline" (which is the
bug: it should also handle "backslash, possible whitespace, newline")
during parsing. Instead, fixup line continuations after reading chunks
of input file data - turn backslash and the following newline into
spaces. The rest of parsing code does not have to be aware of them
at all then.

Makes the file attached to T99536 load correctly now. Also will extend
one of the test files in subversion tests repo to contain backslashes
followed by newlines.
2022-07-10 18:27:38 +03:00
443690604f Fix cursor display size with tablet input in GHOST/Wayland
The scale for tablet cursor surfaces was never set, making them display
larger. Now the outputs scale is set for mouse & tablet cursors.
2022-07-09 22:46:53 +10:00
1de14061cb Cleanup: split out wl_buffer creation into a utility function
Simplify logic for initializing the wl_buffer, ensure the cursors
custom data is never heft in a half initialized state.
Also remove the need for multiple calls to close when handling errors.
2022-07-09 22:27:30 +10:00
9a1d772339 Cleanup: remove buffer_t in GHOST/Wayland
This was allocated and only used to store the custom cursor data.
Use a pointer & size member instead for simplicity.
2022-07-09 22:27:28 +10:00
ef970b7756 Cleanup: split memfd_create into it's own function for Wayland
Avoid ifdef's in cursor loading by creating a memfd_create_sealed
utility function that works irrespective of memfd_create availability.
2022-07-09 22:27:27 +10:00
b5d22a8134 Fix resource leaks setting custom cursors in Wayland
- Memory from the prior cursor was never un-mapped.
- posix_fallocate failure left a file handle open..
2022-07-09 22:27:26 +10:00
80f8b7cbbb UI: renaming fIle browser thumbnail sizes
Rename the thumbnail size from Regular to Medium since it's the typical
way to refer to sizing in American English

Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D15305
2022-07-09 02:09:07 -06:00
e3801a2bd4 Weight & Vertex Paint: always respect edit mode hiding on faces.
In some cases it is mandatory to be able to hide parts of the mesh
in order to paint certain areas. The Mask modifier doesn't work in
weight paint, and edit mode hiding requires using selection, which
is not always convenient.

This makes the weight and vertex paint modes always respect edit mode
hiding like sculpt mode. The change in behavior affects drawing and
building paint PBVH. Thus it affects brushes, but not menu operators
like Smooth or Normalize.

In addition, this makes the Alt-H shortcut available even without
any selection enabled, and implements Hide for vertex selection.

Differential Revision: https://developer.blender.org/D14163
2022-07-09 10:39:53 +03:00
d9e00fbbf6 Cleanup: quiet class-memaccess warning 2022-07-09 15:08:23 +10:00
bc2121147f Cleanup: Remove unused variable 2022-07-08 18:47:31 -05:00
2ee6891728 Fix T99494: Transition effects not working correctly
This was caused by strip content length and start position being
incorrect. Previously this was set from strip boundary by update
function, but it was removed.

Add back code to set effect strip start and length.

Previously content length was always 1 for effects, but now it must
correspond to strip length. Because of this workaround for speed effect
to get this apparent content length was removed.
2022-07-08 18:07:07 +02:00
d8e980a4a6 Fix bug in recently added MutableVArraySpan move constructor 2022-07-08 16:27:47 +02:00
8159e0a666 Curves: use consistent default radius for Cycles, Eevee, Set Curve Radius node
To avoid Cycles not showing any hair by default, and to avoid very slow render
due to many overlaps with the previous 1 meter default in the node.

Fixes T97584, T99319

Differential Revision: https://developer.blender.org/D15405
2022-07-08 16:21:32 +02:00
f639b59a29 Cleanup: convert brush.c to C++
In preparation of refactoring for texture nodes.
2022-07-08 16:21:32 +02:00
b876ce2a4a Geometry Nodes: new geometry attribute API
Currently, there are two attribute API. The first, defined in `BKE_attribute.h` is
accessible from RNA and C code. The second is implemented with `GeometryComponent`
and is only accessible in C++ code. The second is widely used, but only being
accessible through the `GeometrySet` API makes it awkward to use, and even impossible
for types that don't correspond directly to a geometry component like `CurvesGeometry`.

This patch adds a new attribute API, designed to replace the `GeometryComponent`
attribute API now, and to eventually replace or be the basis of the other one.

The basic idea is that there is an `AttributeAccessor` class that allows code to
interact with a set of attributes owned by some geometry. The accessor itself has
no ownership. `AttributeAccessor` is a simple type that can be passed around by
value. That makes it easy to return it from functions and to store it in containers.

For const-correctness, there is also a `MutableAttributeAccessor` that allows
changing individual and can add or remove attributes.

Currently, `AttributeAccessor` is composed of two pointers. The first is a pointer
to the owner of the attribute data. The second is a pointer to a struct with
function pointers, that is similar to a virtual function table. The functions
know how to access attributes on the owner.

The actual attribute access for geometries is still implemented with the `AttributeProvider`
pattern, which makes it easy to support different sources of attributes on a
geometry and simplifies dealing with built-in attributes.

There are different ways to get an attribute accessor for a geometry:
* `GeometryComponent.attributes()`
* `CurvesGeometry.attributes()`
* `bke::mesh_attributes(const Mesh &)`
* `bke::pointcloud_attributes(const PointCloud &)`

All of these also have a `_for_write` variant that returns a `MutabelAttributeAccessor`.

Differential Revision: https://developer.blender.org/D15280
2022-07-08 16:16:56 +02:00
f391e8f316 Linux: Move Mesa software OpenGL libraries to sub-directory
Allows to put libraries which are always needed by Blender into the
lib/ folder and not worry about OpenGL libraries picked up from there.

Currently no functional changes as we do not yet have dynamic libraries
which we load at startup. It allows to use direct linking of oneAPI
Cycles device (see D15397), also it is something which would need to
happen to support USD/Hydra/TBB compiler as dynamic libraries in the
future.

Differential Revision: https://developer.blender.org/D15403
2022-07-08 15:44:06 +02:00
0f50ae131f Cycles: enable oneAPI in Linux release builds
with a very high min-driver version requirement, placeholder until JIT
CentOS runtime compilation issue gets fixed in a defined version.
min-driver version check can be worked around by setting
CYCLES_ONEAPI_ALL_DEVICES environment variable.
2022-07-08 15:39:13 +02:00
5723bf926d Fix T99191: Boolean modifier creates invalid material indices
Similar to 1a6d0ec71c which changed the mesh boolean node (and
also caused this bug), this commit changes the material mapping for the
exact mode of the boolean modifier. Now the result should contain any
material on the faces of the input objects (including materials linked
to objects and meshes). The improvement is possible because materials
can be changed during evaluation (as of 1a81d268a1).

Differential Revision: https://developer.blender.org/D15365
2022-07-08 08:32:32 -05:00
becb1530b1 Hair Curves: The new curves object is now available
This commit doesn't implement any new feature but makes the new curves
object type no longer experimental.

Documentation:

* https://docs.blender.org/manual/en/3.3/modeling/curves/primitives.html#empty-hair
* https://docs.blender.org/manual/en/3.3/sculpt_paint/curves_sculpting/introduction.html

Note: This also makes the Selection Paint tool available. This tool
should have been moved out of the "New Curves Tool" flag when we got the
selection drawing to work.

Differential Revision: https://developer.blender.org/D15402
2022-07-08 15:11:32 +02:00
2c55d8c1cf Cleanup: make format 2022-07-08 15:11:32 +02:00
05b38ecc78 Curves: support deforming curves on surface
Curves that are attached to a surface can now follow the surface when
it is modified using shape keys or modifiers (but not when the original
surface is deformed in edit or sculpt mode).

The surface is allowed to be changed in any way that keeps uv maps
intact. So deformation is allowed, but also some topology changes like
subdivision.

The following features are added:
* A new `Deform Curves on Surface` node, which deforms curves with
  attachment information based on the surface object and uv map set
  in the properties panel.
* A new `Add Rest Position` checkbox in the shape keys panel. When checked,
  a new `rest_position` vector attribute is added to the mesh before shape
  keys and modifiers are applied. This is necessary to support proper
  deformation of the curves, but can also be used for other purposes.
* The `Add > Curve > Empty Hair` operator now sets up a simple geometry
  nodes setup that deforms the hair. It also makes sure that the rest
  position attribute is added to the surface.
* A new `Object (Attach Curves to Surface)` operator in the `Set Parent To`
  (ctrl+P) menu, which attaches existing curves to the surface and sets the
  surface object as parent.

Limitations:
* Sculpting the procedurally deformed curves will be implemented separately.
* The `Deform Curves on Surface` node is not generic and can only be used
  for one specific purpose currently. We plan to generalize this more in the
  future by adding support by exposing more inputs and/or by turning it into
  a node group.

Differential Revision: https://developer.blender.org/D14864
2022-07-08 14:47:10 +02:00
aa78278ef6 Fix build error without unity build, after recent changes 2022-07-08 14:38:21 +02:00
155bb95353 Fix Crash: Reading canvas tool settings.
Blender would crash when a file was saved where the tool settings is
set to paint on a single image (3d texture painting).

Reason is that the selected image memory address wasn't updated
when the new address.
2022-07-08 14:05:11 +02:00
Jeroen Bakker
a8f7d41d38 Draw: Curve outline drawing in object mode.
This patch adds (selected/active) outline around a curve object in object mode.

{F13270680}

In the past the draw bounds option was enabled for any curve objects. With this
patch it isn't needed and will be disabled.

In the future the curve outline could also be enabled to improve GPU selection.

Reviewed By: dfelinto, HooglyBoogly, fclem

Maniphest Tasks: T95933

Differential Revision: https://developer.blender.org/D15308
2022-07-08 12:08:31 +02:00
Damien Picard
2c4dfe3453 Add a few missing UI strings to translation.
Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15392
2022-07-08 11:55:01 +02:00
754dae6c76 GHOST/Wayland: add logging for listener handlers
Add logging to all Wayland listener callbacks as it can be difficult
to detect the cause of problems.

Using break-points often isn't practical for debugging interactive
windowing / compositor issues

Logging needs to be enabled on the command line, e.g:

blender --log "ghost.wl.*" --log-level 2 --log-show-basename
2022-07-08 19:40:10 +10:00
47616992f8 GHOST: use ELEM/ARRAY_SIZE/UNPACK macros to avoid repetition
Also use UNLIKELY macro for checks for very unlikely scenarios.
2022-07-08 19:39:11 +10:00
418d82af28 GHOST: add GHOST_utildefines
Add macros from BLI_utildefines, mainly to avoid that avoid repetition
(ELEM, UNPACK*, CLAMP* & ARRAY_SIZE).

Also add macros LIKELY/UNLIKELY as there are quiet a lot of checks
for unlikely situations for GHOST/Wayland (not having a keyboard,
or mouse for e.g.).
2022-07-08 19:36:31 +10:00
c4b32f1b29 Cleanup: Move mesh legacy conversion to a separate file
It's helpful to make the separation of legacy data formats explicit,
because it declutters actively changed code and makes it clear which
areas do not follow Blender's current design. In this case I separated
the `MFace`/"tessface" conversion code into a separate blenkernel
.cc file and header. This also makes refactoring to remove these
functions simpler because they're easier to find.

In the future, conversions to the `MLoopUV` type and `MVert`
can be implemented here for the same reasons (see T95965).

Differential Revision: https://developer.blender.org/D15396
2022-07-07 22:33:57 -05:00
b98a937db6 Fix T99364: Unable to select bones when custom shape display is disabled
Regression in [0] which revealed an error in [1].
Logic for pose channel custom transform ignored ARM_NO_CUSTOM.

[0]: 3267c91b4d
[1]: c3fef001ee
2022-07-08 11:33:22 +10:00
03173d63c0 Cleanup: spelling in comments
Also move mis-placed doc-string.
2022-07-08 09:48:49 +10:00
9ef3736959 Cleanup: format 2022-07-08 09:10:24 +10:00
56bf92f0f6 Cleanup: Calm GCC Conversion Warning
Commit b9c0eed206 introduced a GCC conversion warning because of an
assignment of a long int value to an int.

Own Code
2022-07-07 14:29:37 -07:00
b9c0eed206 BLF: Add Support for Variable Fonts
Add support for Variable/Multiple Master font features. These are fonts
that contain a range of design variations along multiple axes. This
contains no client-facing options.

See D12977 for details and examples

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

Reviewed by Brecht Van Lommel
2022-07-07 12:59:16 -07:00
fc06b4c033 Fix T99332: resize video in image editor does not update correctly
Use the image user from the image editor to correctly get the frame in the
operators. Based on patch by Nicolas (john-g-h-doe) with changes by me.

Differential Revision: https://developer.blender.org/D15380
2022-07-07 21:01:30 +02:00
52fa0c4251 Cleanup: Remove unused variable 2022-07-07 13:43:13 -05:00
4e9e44ad28 Cleanup: improve asserts in generic span 2022-07-07 19:27:30 +02:00
ba62e20af6 BLI: make some spans default constructible
`GSpan` and spans based on virtual arrays were not default constructible
before, which made them hard to use sometimes. It's generally fine for
spans to be empty.

The main thing the keep in mind is that the type pointer in `GSpan` may
be null now. Generally, code receiving spans as input can assume that
the type is not-null, but sometimes that may be valid. The old #type() method
that returned a reference to the type still exists. It asserts when the
type is null.
2022-07-07 19:19:18 +02:00
7cfea48752 LibOverride: Make fully editable when creating an experimental user setting.
This is temporary to investigate which behavior should be kept when
creating an override hierarchy if there are no cherry-picked data
defined: make all overrides user-editable, or not.

This removes the 'make override - fully editable' menu entries.
2022-07-07 18:19:11 +02:00
b8605ee458 UI: Superimposed pin icon for workspace scene pinning in the scene switcher
Followup to the previous commit, to display a pin icon in the scene switcher.
This is a good indicator to have and such workspace-wide functionality should
be available in the topbar, close to what it belongs to (scene switching).
Downside is that it makes this already crowded region even more crowded. But
thanks to the use of superimposed icons, it's not too noisy visually.

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

Reviewed by: Campbell Barton
2022-07-07 18:14:05 +02:00
e0cc86978c Workspaces: Option to pin scene to a workspace
Adds a "Pin Scene" option to the workspace. When activated, the workspace will
remember the scene that was last activated in it, so that when switching back
to this workspace, the same scene will be reactivated. This is important for a
VSE workflow, so that users can switch between different workspaces displaying
a scene and thus a timeline for a specific task.

The option can be found in the Properties, Workspace tab. D11890 additionally
adds an icon for this to the scene switcher in the topbar.

The workspace data contains a pointer to the scene which is a UI to scene data
relation. When appending a workspace, the pointer is cleared.

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

Reviewed by: Brecht Van Lommel, Bastien Montagne (no final accept, but was fine
with the general design earlier)
2022-07-07 18:08:18 +02:00
f9a805164a Outliner, Library Overrides: List child objects under parents
Because children point to, or "use" their parent, the Library Overrides
Hierarchies mode in the Outliner would show parents contained in children, not
children contained in a parent. See D15339 for pictures.

In production files this would make the rig listed under all its children, so
it would appear many times in the tree. Now it appears once and the children
are collected under it.

Refactors the tree building, so instead of using
`BKE_library_foreach_ID_link()`, it now uses the ID relations mapping in
`MainIDRelations`.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15339
2022-07-07 17:19:59 +02:00
Bastien Montagne
fcf1a9ff71 Fix T99256: Regression: Meta balls segfaulting copy-to-selected.
Revealed by rB43167a2c251b, but actuall issue is the
`rna_MetaBall_update_data` function expecting a never-NULL `scene`
pointer, which is not guaranteed.

This lead to refactoring the duo
`rna_MetaBall_update_data`/`BKE_mball_properties_copy`, since it was
doing a very sub-optimal O(n^2) process, new code is O(2n) now
(n being the number of Objects).

Not sure why the objects were processed through the existing bases of
the existing scene in the first place, this could miss a lot of affected
objects (e.g. in case said objects are in an excluded collection, etc.).

Also noticed that both old and new implementation can fail to fully propagate
changes to all affected meta-balls in some specific corner cases, added
a comment about it in the code.

Reviewed By: sergey

Maniphest Tasks: T99256

Differential Revision: https://developer.blender.org/D15338
2022-07-07 16:25:34 +02:00
c76e1ecac6 Compositor: Pre-fill motion tracking fields
Extends current functionality which was only filling in
the active movie clip. Now we also pre-fill tracking object
name, as well as (plane)track name.
2022-07-07 16:15:44 +02:00
59e1009f10 Cleanup: Use std::move for geometry set
The only real improvement is avoiding some reference counting,
but the main for the change is consistency. Also don't move a
StringRef, since that doesn't own any data anyway.
2022-07-07 09:01:46 -05:00
85ef8e1945 Cleanup: Use C++ style of avoiding unused variable warnings
As documented in the best practices section of the style guide:
https://wiki.blender.org/wiki/Style_Guide/Best_Practice_C_Cpp
2022-07-07 08:55:36 -05:00
a91f9c2c01 Cleanup: Use generic index mask utility
This may lead to improved performance from multithreading as well.
2022-07-07 08:49:23 -05:00
f0ac55f519 Fix: Spreadsheet does not display original curves data
The spreadsheet ignored the component choice in the data set region
for curves and volume objects, and the original curves data-block wasn't
retrieved from the original object.
2022-07-07 08:35:47 -05:00
Amélie Fondevilla
a26038ff38 Fix T99505: NLA tweak mode crashes with GPencil data
Adding Grease Pencil keyframes in the dopesheet (rB92d7f9ac56e0) lead to
crashes from the NLA editor (T99505). This is now resolved, by removing
grease pencil keyframes from NLA editor (as it was in 3.2), and
filtering them out of all NLA-related operations.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15391
2022-07-07 15:31:06 +02:00
Pratik Borhade
3063d90cfc Fix T99453: Regression: Crash on calling menu search
Fix T99453.
Crash due to null pointer access.
So wrap the function call in simple `if` check

Reviewed By: sybren

Maniphest Tasks: T99453

Differential Revision: https://developer.blender.org/D15370
2022-07-07 15:24:17 +02:00
eb7218de8d Fix T99386: Driven modifiers are always re-evaluated during animation
Even if the driver is not dependent on time the modifiers were always
re-evaluated during playback. This is due to the legacy nature of the
check whether modifier depends on time or not: it was simply checking
for sub-string match for modifier in the F-Curve and drivers RNA paths.

Nowadays such dependencies are created by the dependency graph builder,
which allows to have more granular control over what depends on what.

The code is now simplified to only check for "static" dependency of the
modifier form time: for example, Wave modifier which always depends on
time (even without explicit animation involved).

This change also fixes missing relation from the animation component to
the shader_fx modifiers, fixing race condition.

Additional files used to verify relations:
- Geometry: F13257368
- Grease Pencil: F13257369
- Shader FX: F13257370

In these files different types of modifiers have an animated property,
and the purpose of the test is to verify that the modifiers do react
to the animation and that there is a relation between animation and
geometry components of the object. The latter one can only be checked
using the dependency graph relation visualization.

The drivers are not tested by these files. Those are not typically
depend on time, and if there were missing relation from driver to
the modifier we'd receive a bug report already. As well as if there
was a bug in missing time relation to a driver we'd also receive a
report.

Differential Revision: https://developer.blender.org/D15358
2022-07-07 15:22:21 +02:00
9a4927031d Cleanup: Remove redundant filtering of legacy normal attribute
This is already done inside of `attribute_search_add_items`.
2022-07-07 08:15:29 -05:00
ed7dc4282c Cleanup: Correct comment with spreadsheet enum type 2022-07-07 08:14:00 -05:00
5c3dc52536 Cleanup: Improve variable name
The new name makes more sense in non-node-related contexts.
2022-07-07 08:13:11 -05:00
e3ef56ef91 Curves: Add sculpt selection overlay
This commit adds visualization to the selection in curves sculpt mode.
Previously it was only possible to see the selection when it was
connected to a material.

In order to obstruct the users vision as little as possible, the
selected areas of the curve are left as is, but a dark overlay
is drawn over unselected areas.

To make it work, the overlay requests the selection attribute and then
ensures that the evaluation is complete for curves. Then it retrieves
the evaluated selection GPU texture and passes that to the shader.
This reuses the existing generic attribute extraction system because
there currently wouldn't be any benefits to dealing with selection
separately, and because it avoids duplication of the logic that
extracts attributes from curves and evaluates them if necessary.

Differential Revision: https://developer.blender.org/D15219
2022-07-07 08:06:30 -05:00
5d6e7df4a8 GHOST: initialize grab axis for windows
While this didn't cause any user visible bugs, ASAN would report
an error when passing it as an argument.
2022-07-07 21:44:48 +10:00
a27024e36d ID Management: Purge: Make outliner button use recursive purge.
This change the 'Purge' button of the Outliner 'Orphaned' view to use
recursive purge, i.e. it wil not only delete immediately unused IDs (as
listed in the view) anymore, but also all their unused dependencies.
2022-07-07 13:01:02 +02:00
97dd107070 Fix T98029: Support isolated islands of IDs when purging unused ones.
Cases were e.g. an object would use a material, and this material would
use this object (e.g. through a driver), even if both those data-blocks
are technically unused, they would remain forever since they were not
detected as such.

Now this is properly detected and purged as part of the 'recursive
purge' operation.
2022-07-07 13:01:02 +02:00
051a341cf0 Fix T99491: Crash when opening modifiers panel
This crashed because in `get_active_fcurve_channel`, the filter did not
filter out channels with no fcurve.

The fix adds the filter `ANIMFILTER_FCURVESONLY`.

See rB92d7f9ac56e0ff1e65c364487542dfb7c32a0a67 for the new filter.

Maniphest Tasks: T99491

Differential Revision: https://developer.blender.org/D15386
2022-07-07 11:51:38 +02:00
14980c9b3a Fix: Save modified images during file close
Regressed in the following commit due to an inverted conditional:
{rB1159b63a07fd2cbc7fc48e162d57721c9c85b3f6}

Differential Revision: https://developer.blender.org/D15389
2022-07-07 02:36:54 -07:00
f256201876 Fix T99388: Obey relative path option when saving UDIMs
Ensure that the Image maintains the proper file path after saving all
the individual tiles.

The image_save_post function is unaware that the filepath it receives
is only for a single tile, not the entire Image, and happily keeps
setting ima->filepath to the concrete filepath for each tile.

There were 2 problems with the code that attempted to correct the
Image filepath back to the UDIM virtual form:
- It would trample the "relative" directory that might have been set
- It would do the wrong thing if no tiles could be saved at all

The design is now as follows: Example of trying to save to a new PathB
|                                  | all tiles ok     | any tile not ok|
| -------------------------------- | ---------------- | ---------------|
| ima->filepath is currently empty | set to new PathB | keep empty     |
| ima->filepath is currently PathA | set to new PathB | keep PathA     |

Differential Revision: https://developer.blender.org/D15384
2022-07-07 02:12:36 -07:00
50f9c1c09c OBJ: more robust .mtl texture offset/scale parsing (T89421)
As pointed out in a comment on T89421, if a MTL file contained
something like: `map_Ka -o 1 2.png` then it was parsed as having
offset `1 2` and the texture filename just a `.png`. Make it so that
mtl option numbers are parsed in a way where the number is only
accepted only if it's followed by whitespace.

Differential Revision: https://developer.blender.org/D15385
2022-07-07 11:34:13 +03:00
bddcb89cda OBJ: always set eevee blend mode when material "d" is below 1.0
Fixes T97743: the import code was setting EEVEE blending mode whenever
a transparency texture was present (map_d), or when the materials
illum was saying "yo, transparency!". But if only the material's d
was below 1.0, it was not setting the blend mode, which is different
to user expectations.

Differential Revision: https://developer.blender.org/D15383
2022-07-07 11:34:13 +03:00
28105caaa3 Fix T99342: GPencil multiframe falloff is scaling wrongly in rotation
The falloff was applied to scale by error. Now, the falloff is only applied to the rotation.

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

.
2022-07-07 09:47:59 +02:00
843ad51d18 Cleanup: use arguments for internal wayland cursor grabbing
Pass in arguments for internal grab logic instead of accessing
some values from the window and other values as arguments.
While more verbose it's simpler to reason about.
2022-07-07 16:36:46 +10:00
34c701abbd Fix T99270: bones using empties as custom shapes can't be selected
Regression in [0] which didn't account for the bounds of empty objects.
Add support support calculating bounds from empty draw-type to use in
pose-bone culling.

[0]: 3267c91b4d
2022-07-07 15:24:48 +10:00
3f657e7ef1 Python: show additional context for PyDriver errors in the stderr
Showing the expression alone may not be enough to track down an error
evaluating a py-driver. Show information about the target ID & property
in the error message as well.
2022-07-07 12:30:47 +10:00
83c0f6ac37 Python: clear Py-driver variables on exit
These kinds of leaks are relatively harmless, it reduces the number of
un-freed data reported by valgrind on exit.
2022-07-07 12:30:45 +10:00
5c790fd52b Cleanup: use boolean types & early exit on failure for PyDriver
Also use __func__ for printing the funciton name.
2022-07-07 12:30:44 +10:00
709e620977 Cleanup: format 2022-07-07 12:30:42 +10:00
378f65f7d9 Fix Py-driver byte code access with Python 3.11
Error in [0] which assumed the struct member was renamed however
byte-code access from PyCodeObject now requires an API call.

Thanks to @music for pointing this out.

[0]: 780c0ea097
2022-07-07 12:30:40 +10:00
3354ec3fb3 Fix T99334: Ignore edit-related snap options in Object mode
When in Object Mode, any of the active- and edit-related snapping
options (Include Active, Include Edited, Include Non-Edited) should be
ignored when in Object Mode, otherwise snapping could be effectively
disabled.

This commit forces snap code to ignore the active- and edit-related
options when in Object Mode.

Reviewed By: Germano Cavalcante (mano-wii)

Differential Revision: https://developer.blender.org/D15366
2022-07-06 16:21:56 -04:00
2a60b979cc UI: Adjust and fix shader node descriptions
The tooltips added for shader nodes in D15309 are very helpful already.
This commit makes a few tweaks to make them more consistent, concise,
and includes some fixes. Note that this might move some descriptions
further away from the wording in the manual.

* Make wording more concise
  * Start fewer new sentences
  * Use "For Example" slightly less
  * Avoid repeating the node's name unnecessarily
* Spelling/grammar fixes
  * Don't capitalize some words
  * Use consistent verb conjugation
  * Use ASCII characters/more common quote symbols
* Corrections to information
  * Plural/singular corrections
  * "smoke domains" -> "volume grids"
  * Fix tooltip for separate and combine color nodes
  * Refer to color sockets as colors rather than "images"
* Avoid "advice" in a few places, which should be left for the manual
* Remove information for sockets and could be in their tooltips
* Avoid referring to the locations of a property in the UI
* Avoid manual newlines (mostly reserve for "Note:")
  * Leave UI code in control of wrapping, which is more consistent
* Add some information
  * That the UV map and color attribute nodes use a default
  * That Voronoi is "based on the distance to random points"
  * Add "(Deprecated)" to old color combine and separate nodes

Differential Revision: https://developer.blender.org/D15381
2022-07-06 15:03:21 -05:00
2d041fc468 Object: Speed up duplication of large selections by doing fewer collection syncs
Previous code was doing N collection syncs when duplicating N objects.
New code avoids all the intermediate syncs by using
BKE_layer_collection_resync_forbid and
BKE_layer_collection_resync_allow, and then does one
BKE_main_collection_sync + BKE_main_collection_sync_remap for the
whole operation. There is some complexity involved where the Base
things of newly duplicated objects can't be found yet, without the
sync, so some work on them (marking them selected, active, ...) has
to be deferred until after the sync.

Timings: scene with 10k cubes, each with unique mesh (Windows, VS2022
Release build, AMD Ryzen 5950X):

- Shift+D duplicate: 13.6s -> 9.2s
- Alt+D duplicate: 4.76s -> 1.53s

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D14150
2022-07-06 21:30:50 +03:00
190ad73590 Cycles oneAPI: Remove direct dependency on Level-Zero
We used it only to access device id for explicitly allowing Arc GPUs.
It made the backend require ze_loader.dll which could be problematic if
we end up using direct linking.
I've replaced filtering based on PCI device id by using other HW properties
instead (EUs, threads per EU), that are now available through Level-Zero.
2022-07-06 18:55:38 +02:00
debb233787 Cleanup: fix comments in oneAPI kernel.cpp 2022-07-06 18:55:38 +02:00
fae68ec651 Fix T99464: Curves sculpt add 3D brush symmetry broken
The brush transform was not applied to the view direction.
2022-07-06 11:53:18 -05:00
8ea5a5259d Icons: Add each icon to a named group
The objects making up each icon are placed in a group named after the icon
coordinates in the grid. This change has no impact on the current pipeline used
to include icons in a Blender build, but lays the foundation to explore other
workflows to do that, and tidies up the file.

Differential Revision: https://developer.blender.org/D15251
2022-07-06 18:21:20 +02:00
82fc8786ea Fix T99343: Missing RNA_def_property_update for show overlays in UV editor
Reviewed By: jbakker

Maniphest Tasks: T99343

Differential Revision: https://developer.blender.org/D15354
2022-07-06 21:14:34 +05:30
0df574b55e Cycles: Improve an occupancy for Intel GPUs
Initially oneAPI implementation have waited after each memory
operation, even if there was no need for this. Now, the implementation
will wait only if it is really necessary - it have improved
performance noticeble for some scenes and a bit for the rest of them.
2022-07-06 17:26:23 +02:00
6636edbb00 BLI: improve reverse uv sample in edge cases
Allow for a small epsilon to improve handling of uvs that are on edges.
Generally, when using reverse uv sampling, we expect that the sampling
is supposed to succeed.
2022-07-06 15:20:38 +02:00
9d0777e514 Fix T99368: Annotation lines doesn't start where clicked
Caused by [0] which made accessing the drag-start require a function
instead of being the value written into the event cursor coordinates.

[0]: b8960267dd
2022-07-06 21:07:29 +10:00
da85245704 Compositor: Pre-fill active scene movie clip in more nodes
Pre-fills movie clip from the scene to the following nodes:
- Keying Screen
- Plane Track Deform
- Track Position

The rest of tracking related nodes were already doing so.

Differential Revision: https://developer.blender.org/D15377
2022-07-06 12:40:39 +02:00
94323bb427 IO: speed up import of large Alembic/USD/OBJ scenes by optimizing material assignment
The importer parts that were doing assignment of materials to the
imported objects/meshes were essentially having a quadratic complexity
in terms of scene object count. For each material assigned to each
object, they were scanning the whole scene, checking which other
Objects use the same Mesh data, in order to resize their material
arrays to match the size.

Performance details (Windows, Ryzen 5950X):

- Import OBJ Blender 3.0 splash scene (24k objects): 43.0s -> 32.9s
- Import USD Disney Moana scene (260k objects): saves two hours
  (~7400s). Note that later on this crashes when trying to render the
  imported result; crashes in the same way/place both in master and
  this patch.

Implementation details:

The importers were doing "scan the world" basically twice for each
object, for each material: once when creating a new material slot
(assigns an empty material), and then again when assigning the
material.

However, all these importers (USD, Alembic, OBJ) always create one
Object for one Mesh. So that whole quadratic complexity resulting
from "scan the world for possible other users of this obdata" is
completely not needed; it just never finds anything. So add a new
dedicated function BKE_object_material_assign_single_obdata that skips
the expensive part, but should only be used when the caller knows that
the obdata has exactly one user (the passed object).

Reviewed By: Bastien Montagne, Michael Kowalski
Differential Revision: https://developer.blender.org/D15145
2022-07-06 13:30:15 +03:00
4b0e7fe511 Fix T99462: Deleting Missing Libraries Crashes Blender.
Usual same issue with outliner operations, where you apply it on one
item, and then try to apply it again on same item listed somewhere else
in the tree...

Fixed by using the 'multi-tagged deletion' code we now have for IDs,
that way tree-walking function just tags IDs for deletion, and they all
get deleted at once at the end.
2022-07-06 10:53:22 +02:00
26f721b516 OBJ: extend test coverage for parsing MTL scale/offsets (T89421)
The new OBJ/MTL importer was already handling case T89421
correctly, but there was no test coverage to prove it. Extend
the tests to parse various forms of "-o" and "-s" (one, two, three
numbers).
2022-07-06 09:05:20 +03:00
e58e023e1a GHOST/Wayland: support dynamic loading libraries for Wayland
Add intern/wayland_dynload which is used when WITH_GHOST_WAYLAND_DYNLOAD
is enabled (off by default). When enabled, systems without Wayland
installed will fall back to X11.

This allows Blender to dynamically load:
- libwayland-client
- libwayland-cursor
- libwayland-egl
- libdecor-0 (when WITH_GHOST_WAYLAND_LIBDECOR is enabled).
2022-07-06 15:30:47 +10:00
d9505831a4 Cleanup: declare local variables static 2022-07-06 15:28:54 +10:00
db9e08a0d1 Cleanup: spelling in comments 2022-07-06 15:28:54 +10:00
Loren Osborn
1f0048cc2d Cleanup: Fix compiler warnings
Use consistent class/struct declaration in forward declarations.

Differential Revision: https://developer.blender.org/D15382
2022-07-06 00:06:16 -05:00
faac25fefe Fix T99284: Undefined values output from UV nodes
When committing D14389 I assumed that the output arrays didn't need
to be initialized, but the UV parameterizer uses the intial values of UVs.
2022-07-05 18:01:08 -05:00
Iliay Katueshenock
1a820680a1 Fix: Tests: Incorrect curve construction
The offsets were filled with the same value,
but they must be the total accumulated point count.

Differential Revision: https://developer.blender.org/D15374
2022-07-05 17:50:59 -05:00
9435ee8c65 Curves: Port subdivide node to the new data-block
This commit moves the subdivide curve node implementation to the
geometry module, changes it to work on the new curves data-block,
and adds support for Catmull Rom curves. Internally I also added
support for a curve domain selection. That isn't used, but it's
nice to have the option anyway.

Users should notice better performance as well, since we can avoid
many small allocations, and there is no conversion to and from the
old curve type.

The code uses a similar structure to the resample node (60a6fbf5b5)
and the set type node (9e393fc2f1). The resample curves node can be
restructured to be more similar to this soon though.

Differential Revision: https://developer.blender.org/D15334
2022-07-05 16:08:37 -05:00
7688f0ace7 Curves: Move type conversion to the geometry module
This helps to separate concerns, and makes the functionality
available for edit mode.
2022-07-05 15:51:12 -05:00
c52a18abf8 UI: Curves Sculpting - Remove duplicated entry for Curve Length 2022-07-05 17:50:27 +02:00
883d8ea16c Fix: Memleak in sequencer drag and drop code 2022-07-05 16:32:20 +02:00
329efa23d0 Cleanup: Unused headers in generic compositor nodes header
Move headers to node files which actually need those.
There is no need for all nodes to have all those headers
included indirectly.
2022-07-05 15:58:04 +02:00
31f0845b7e Fix tracking header not being self-sufficient
It used size_t type without including any header to define it.
2022-07-05 15:58:04 +02:00
8f0907b797 BLI: add float3x3 * float3 operator overload 2022-07-05 15:38:30 +02:00
d4099465cd Cleanup: extract function to snap curves to surface
This makes it possible to use this function without having
to call an operator. This is currently used by D14864.
2022-07-05 15:37:34 +02:00
b98d116257 BLI: use a slightly less trivial reverse uv sampler
This approach is still far from ideal, but at least it has linear
complexity in the common case instead of quadratic.
2022-07-05 15:36:00 +02:00
7ff054c6d1 Cleanup: use curves surface transform utility in operators 2022-07-05 15:06:31 +02:00
c46d4d9fad Curves: move curves surface transforms to blenkernel
This utility struct is useful outside of sculpting code as well.
2022-07-05 15:06:31 +02:00
7f24d90f11 Fix T99272: Regression: location override ignored when used in a shadertree.
This is not strictly speaking a regression, this worked before partial
resync was introduced purely because the whole override hierarchy was
systematically re-built.

But support for material pointers in obdata (meshes etc.) was simply not
implemented.

NOTE: This commit also greatly improves general support of materials in
liboverrides, although there is still more work needed in that area to
consider it properly supported.
2022-07-05 12:52:21 +02:00
ce1d023667 Fix (unreported) liboverride: incomplete hierarchy when root is not object/collection.
We do not (currently) consider other ID types as 'end points' justifying
to create an override hierarchy, however if the 'root' ID (i.e. the ID
the user selected as base to create the override) is not an object or
collection, we still want to check all of its dependencies.

This fixes e.g. if a material depends on another Empty object, and user
tries to hierarchy-override that material, its Empty dependency not
being overridden.
2022-07-05 12:52:20 +02:00
598a26fd8a NLA: update description of frame_end_ui RNA property
The description incorrectly mentioned it changes the start frame as well,
but it changes the strip's repeats or the action's end frame.
2022-07-05 12:20:59 +02:00
935ef06fd1 NLA: fix punctuation of tooltips 2022-07-05 12:18:20 +02:00
fdb854b932 Cleanup: NLA, reformatting code
No functional changes.
2022-07-05 11:34:40 +02:00
Thibault de Villèle
bd00324c26 NLA: change behavior of 'Frame Start' / 'End' sliders
Change the behavior of the "Frame start" and [Frame] "End" fields of an
NLA Strip in the NLA editor.

Frame Start now behaves like translating with {key G} and moving the
mouse. It also updates the Frame End to ensure the strip remains the
same length.

Frame End changes the length of the strip, based on the Repeat property.
If there are no repeats (i.e. number of repeats = 1) the underlying
Action will change length, such that more or less of its keyframes will
be part of the NLA strip. If there are repeats (i.e. number of repeats
smaller or larger than 1), the number of repeats will change. Either
way, the effective end frame off the strip will be the one set in the
Frame End slider.

The old behavior of stretching time has been removed. It is still
possible to stretch time of a strip, but this no longer automatically
happens when manipulating the Frame Start and Frame End sliders.

**Technical details:** new RNA properties `frame_start_ui` and
`frame_end_ui` have been added. Changing those values (for example via
the sliders, but also via Python) trigger the above behavior. The
behavior of the already-existing `frame_start` and `frame_end`
properties has been simplified, such that these can be set from Python
without many side-effects, simplifying import of data into the NLA.

Reviewed By: sybren, RiggingDojo

Differential Revision: https://developer.blender.org/D14658
2022-07-05 10:51:43 +02:00
322abb2e4b Geometry Nodes: Use alphabetical order for UV nodes in add menu 2022-07-04 23:54:06 -05:00
8c33a53b17 Cleanup: format 2022-07-05 14:34:09 +10:00
9145a4d08f GPU: add missing license header 2022-07-05 13:58:52 +10:00
780c0ea097 Python: support v3.11 (beta) with changes to PyFrameObject & opcodes
- Use API calls to access frame-data as PyFrameObject is now opaque.
- Update opcodes allowed for safe driver evaluation.

**Details**

Some opcodes have been added for safe-driver evaluation.
Python 3.11 removes many opcodes - the number of accepted opcodes in
Blender's listing dropped from 65 to 43) however some new opcodes
also needed to be added. As this relates to security details about newly
added opcodes have been noted below (see [0] for full documentation).

Newly added opcodes:

- CACHE:
  Used to control caching instructions.

- RESUME:
  A no-op. Performs internal checks.

- BINARY_OP:
  Implements the binary and in-place operators,
  replacing specific binary operations.

- CALL, PRECALL, KW_NAMES:
  Used for calling functions, replacing some existing opcodes.

- POP_JUMP_{FORWARD/BACKWARD}_IF_{TRUE/FALSE/NONE/NOT_NONE}.
  Manipulate the byte-code counter.

- SWAP, PUSH_NULL.
  Stack manipulation.

Resolves T99277.

[0]: https://docs.python.org/3.11/library/dis.html
2022-07-05 13:41:55 +10:00
dfa5201763 Python: add opcodes for safe py-drivers
New opcodes added since 3.7 meant some actions such as `len()`
were disabled in safe py-driver execution.

The following opcodes have been added, see [0] for details:

- ROT_FOUR: similar to existing ROT_* opcodes, added v3.8.

- ROT_N: similar to existing ROT_* opcodes, added v3.10.

- GET_LEN: Push len(TOS) onto the stack, added v3.10.

- IS_OP: for ternary operator, added v3.9.

- BUILD_SLICE: access `slice` built-in, doesn't expose new
  functionality beyond existing `__getitem__` access.

[0]: https://docs.python.org/3.10/library/dis.html
2022-07-05 13:41:53 +10:00
7537369498 Python: remove invalid Py_TPFLAGS_HAVE_GC usage
Blender wouldn't start with Python 3.11 because of an error in
Py_TPFLAGS_HAVE_GC usage for `bpy.app.handlers.persistent`.
Remove this flag as it's not necessary.

Part of fix for T99277.
2022-07-05 13:41:49 +10:00
6e879c3998 BLI: Use simpler sliced generic virtual arrays when possible
This is just a theoretical improvement currently, I won't try to justify
it with some microbenchmark, but it should be better to use the
specialized single and span virtual arrays when slicing a `GVArray`,
since any use of `GVArrayImpl_For_SlicedGVArray` has extra overhead.

Differential Revision: https://developer.blender.org/D15361
2022-07-04 15:30:42 -05:00
242bfd28ce METAL: Add license header to new files 2022-07-04 20:11:06 +02:00
dccdc6213e Curves: Expose function to calculate vector handles 2022-07-04 11:51:10 -05:00
8fb8a6529f OBJ: remove "experimental" from C++ based importer/exporter, mark Python legacy
By now I'm not aware of any serious regressions or missing functionality
in the C++ based OBJ importer/exporter. They have more features (vertex colors
support), and are way faster than the Python based importer/exporter.

Reviewed By: Thomas Dinges, Howard Trickey
Differential Revision: https://developer.blender.org/D15360
2022-07-04 19:12:35 +03:00
c63569c0e0 Cleanup: Correct UI view comments 2022-07-04 16:50:46 +02:00
abbc8333ac Fix curves sculpting Selection Paint missing refresh
This was reported as part of D15219 but it is a problem in master, not
in the patch.

EEVEE is drawing with a cheap sampling when navigating or painting, but
we need to clear the painting flag when we are done painting.

For a rainy day: DRW_state_is_navigating() should be renamed to indicate
that it also checks for the painting flag.
2022-07-04 16:08:29 +02:00
af6f3a4020 Cleanup: Remove unused function 2022-07-04 08:50:33 -05:00
1c38bfdc6f Cleanup: Clarify relation name for time relation to modifier 2022-07-04 12:27:45 +02:00
004913dd95 Fix T99381: GPencil Unable to Sculpt last point using Subdivide Modifier
The problem was the last point had the original point, but the previous one not, so the loop ends before checking last point.

The solution is avoid the loop exist if the function is checking the previous point before last one.
2022-07-04 10:58:53 +02:00
3f5073a8e2 Fix T98884: Fix edge case crashes in gpu subdiv cache code 2022-07-04 01:34:54 -07:00
7be07a9d6e Cleanup: use local variable in smear code instead of ss->cache->bstrength 2022-07-04 01:19:14 -07:00
a720a4aabb Fix T98698: Division by zero in smear code when strength is zero 2022-07-04 01:17:19 -07:00
c5d3846b10 Fix use-after-free error when handling events that close windows
Regression in [0] caused operations such as file-load or file-new
from any window besides the first to write into the freed:
`wmWindow.eventstate`.

Resolve by copying the event instead of restoring the region relative
cursor position after modifying it.

[0]: 789b1617f7
2022-07-04 16:24:04 +10:00
cbb897070d Cleanup: remove unused WM_event_is_last_mousemove
This was part of walk-mode logic that implemented it's own cursor-grab,
now this has been moved to use GHOST's cursor grabbing,
it's no longer needed.
2022-07-04 16:04:34 +10:00
148dcb3954 Cleanup: spelling in comments 2022-07-04 15:26:57 +10:00
faa97de208 Cleanup: correct function signature for UI_block_add_view for grid_view 2022-07-04 15:07:02 +10:00
9dd27a2c87 UV: Improve UV Straighten operator
Improves UV Straighten in several ways:
- Operate on entire selection.
- One straighten for each selected island.
- Prefers pins to anchor the endpoints of the resulting line.

Differential Revision: D15121
Resolves: T78553
2022-07-04 13:45:48 +12:00
929811df63 Cleanup(UV): Refactor UV Align and UV Straighten (No user visible changes)
Move functionality into uvedit_uv_align_weld and uvedit_uv_straighten.

Prep for D15121
2022-07-04 13:45:48 +12:00
f4a9a3767e Cleanup: Rename curve segment count function
`curve_segment_num` -> `segments_num`.
The "curve" prefix is reduntant for a function in the curve namespace.
2022-07-03 20:44:56 -05:00
e86c2f7288 UI: Move rename buffer management to new view base class
Renaming is a nice example of a feature that shouldn't need a specific
implementation for a specific view type (e.g. grid or tree view). So it's
something that can be supported in the general view code. Individual views can
use it "for free" then. This ports the view level part of the renaming code,
the view item level part of it can be ported once we have a common base class
for the view items.
2022-07-03 01:55:38 +02:00
c355be6fae UI: Add AbstractView base class for views, unify reconstruction in there
No user visible changes expected.

There's plenty of duplicated code in the grid and the tree view, and I expect
this to become more. This starts the process of unifying these parts, which
should also make it easier to add new views. Complexity in the view classes is
reduced, and some type shenanigans for C compatibility and general view
management can be removed, since there is now a common base type.

For the start this ports some of the view reconstruction, where the view and
its items are compared to the version of itself in the previous redraw, so that
state (highlighted, active, renaming, collapsed, ...) can be preserved.
Notifier listening is also ported.
2022-07-03 01:55:38 +02:00
Iliay Katueshenock
4ffee9a48d Fix T99316: Crash with no font in String to Curves node
If you remove the default font from the project, the node will not
have the selected font. In this case, there is no check that the font
does not exist. This suggestion adds an error message if the font
is not specified.

Differential Revision: https://developer.blender.org/D15337
2022-07-02 18:37:32 -05:00
ab444a80a2 BLI: refactor length parameterization
This refactor had two main goals:
* Simplify the sampling code by using an algorithm with fewer special cases.
* Generalize the sampling to support non-sorted samples.

The `SampleSegmentHint` optimization was inspired by `ValueAccessor` from
OpenVDB and improves performance 2x in my test cases.

Differential Revision: https://developer.blender.org/D15348
2022-07-02 21:51:58 +02:00
69ee9ca90e Fix: Build error with unity builds off after recent cleanup
Mistake in df8d96ab66
2022-07-02 13:04:55 -05:00
01d7dedd74 Revert "Start of Bevel V2, as being worked on with task T98674."
This reverts commit 9bb2afb55e.
Oops, did not intend to commit this to master.
2022-07-02 10:14:26 -04:00
9bb2afb55e Start of Bevel V2, as being worked on with task T98674.
This is the start of a geometry node to do edge, vertex, and face
bevels.

It doesn't yet do anything but analyze the "Vertex cap" around
selected vertices for vertex bevel.
2022-07-02 10:09:18 -04:00
5d9ade27de BLI: improve span access to virtual arrays
* Make the class names more consistent.
* Implement missing move-constructors and assignment-operators.
2022-07-02 11:45:57 +02:00
3c60d62dba BKE: fix wrong recently added assert 2022-07-02 11:40:36 +02:00
d0e3388848 Cleanup: Simplify logic building in length parameterization
We can construct an IndexRange directly rather than retrieving it.
2022-07-01 09:46:27 -05:00
da00d62c49 Fix crash with window decorations (libdecor) in Wayland
Surfaces from window decorations were passed into GHOST's listeners
since libdecor & GHOST share a connection.

This error introduced by recent changes that assumed surfaces passed to
GHOST's handler functions were owned by GHOST.

Tag GHOST surfaces & outputs to ensure GHOST only attempts to access
data it created.
2022-07-01 22:50:58 +10:00
56b218296c Fix T99268: LineArt better handling for dense overlappings.
Two main fixes:
- Split tiles only when we are more sure that it will improve distribution.
- Discard edges and chains that are not gonna be used afterwards before chaining.

This speeds up the whole process and also eliminates unnecessary tile splitting.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D15335
2022-07-01 20:46:17 +08:00
b683a37824 Fix T99301: RNA_boolean_get warning when saving a file for the first time
Caused by [0], RNA_struct_property_is_set also functioned to check if
the property existed.

[0]: 6a2c42a0d5
2022-07-01 20:54:47 +10:00
5e5fe217ca Cleanup: rename internal cursor grabbing function
This function was named as if it was part of GHOST's API but was
in fact an internal utility.
2022-07-01 20:35:11 +10:00
41c10ac84a Cycles: fix support for multiple Intel GPUs
Identical Intel GPUs ended up with the same id.
Added PCI BDF to the id to make it unique.
2022-07-01 11:20:00 +02:00
e7a21275c0 IO: print import & export times of Alembic & USD
Many existing importers/exporters do log the time it takes to system
console (some others log more information too). In particular, OBJ
(C++ & python), STL (C++ & python), PLY, glTF2 all log the time it
takes. However, neither USD nor Alembic do. And also it's harder to
know the time it takes there from a profiler, since all the work
normally is done on a background job and is split between several
threads (so you can't just find some top-level function and see how
much time it took).

This change:

- Adds import/export time logging to USD & Alembic importer/exporter,
- In the time utility class (also used by OBJ & STL), improve the
  output formatting: 1) print only one decimal digit, 2) for long
  times, print seconds and also produce a hours:minutes:seconds form.

Reviewed By: Michael Kowalski, Kévin Dietrich
Differential Revision: https://developer.blender.org/D15170
2022-07-01 12:17:50 +03:00
Jason Fielder
4527dd1ce4 Metal: MTLMemoryManager implementation includes functions which manage allocation of MTLBuffer resources.
The memory manager includes both a GPUContext-local manager which allocates per-context resources such as Circular Scratch Buffers for temporary data such as uniform updates and resource staging, and a GPUContext-global memory manager which features a pooled memory allocator for efficient re-use of resources, to reduce CPU-overhead of frequent memory allocations.

These Memory Managers act as a simple interface for use by other Metal backend modules and to coordinate the lifetime of buffers, to ensure that GPU-resident resources are correctly tracked and freed when no longer in use.

Note: This also contains dependent DIFF changes from D15027, though these will be removed once D15027 lands.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15277
2022-07-01 10:31:57 +02:00
3ffc558341 Sculpt Curves: UI tweaks and shortcut
* Minimum Distance -> Distance Mix
* Max Count -> Count Max
* Shift + A for selection grow

This follows better the names we have in geometry nodes in the Distribute Points
node when using the Poisson Disk method (Distance Min, Distance Max).

The shortcut for the selection grow is the same we use in mesh sculpt
for the Expand Mask operator (which behaves a bit similar).
2022-07-01 10:23:58 +02:00
0554537c3c Cleanup: add missing license headers in Cycles oneAPI implementation 2022-07-01 10:13:07 +02:00
bb8953ab49 GHOST/Wayland: map additional cursors from GHOST_TStandardCursor 2022-07-01 18:11:19 +10:00
5b7e7d67a5 Cleanup: GPUCodegen: Remove unused variables 2022-07-01 10:10:58 +02:00
4cba209edd GPUMaterial: Remove the max attribute check
This is needed to make the GPU_attribute used as generic input mechanism.
2022-07-01 10:10:58 +02:00
ccbf9ee482 Fix un-grab cursor positioning failing for Wayland
UI elements such as sliders & color picker set an un-grab location
which GHOST/Wayland didn't implement.
2022-07-01 18:06:20 +10:00
eff62ea8ab Geometry Nodes: remove warning in Points node
Generating no points in some frames is a perfectly valid use case.
2022-07-01 10:04:35 +02:00
5d57d9f899 Cleanup: remove unused variable 2022-07-01 09:55:20 +02:00
e4bf58e285 Tracking: Image from Plane Marker operators
There are two operators added, which are available via a special
content menu next to the plane track image selector:

- New Image from Plane Marker
- Update Image from Plane Marker

The former one creates an image from pixels which the active plane
track marker "sees" at the current frame and sets it as the plane
track's image.

The latter one instead of creating the new image data-block updates
the image in-place.

This allows to create unwarped texture from a billboard from footage.
The intent is to allow this image to be touched up and re-projected
back to the footage with an updated content.

Available from a plane track image context menu, as well as from the
Track menu.

{F13243219}

The demo of the feature from Sebastian Koenig: https://www.youtube.com/watch?v=PDphO-w2SsA

Differential Revision: https://developer.blender.org/D15312
2022-07-01 09:44:07 +02:00
72b9e07cf2 Add helper function to replace buffer of a single-frame image
Very similar to BKE_image_add_from_imbuf with the exception that no
new image data-block is created, but instead the given one is modified.
2022-07-01 09:44:07 +02:00
dfa5bd689e Fix possible wrong image color space when it is created from image buffer
From quick look it doesn't seem to be leading to real issues yet as the
image buffers are created with the default roles, but valid color space
is needed to be ensured for an upcoming development.
2022-07-01 09:44:07 +02:00
c922b9e2c1 Fix image-from-imbuf resulting in invalid image configuration
The image which source is set to file is not expected to have empty
file path. If it happens it becomes very tricky to save the image on
exit using the standard quit dialog.

This change makes it so if the image buffer does not have file path
then the new image is set to the "generated" source and it behaves
as if the image was created like so and was fully painted on.

Additionally, mark image as dirty, so that quitting Blender after
such image was added will warn about possible data loss.
2022-07-01 09:44:07 +02:00
b872ad037a Fix T99315: Unit plane track deform compositor node leads to unnecessary blur 2022-07-01 09:42:48 +02:00
16264aebe6 Fix sequencer transform test failing.
Issue was caused by using function `SEQ_render_give_stripelem` to obtain
first `StripElem`, but this function now takes retiming into account.

Since first element was meant to be obtained, point to it directly by
using `seq->strip->stripdata`.
2022-07-01 09:02:07 +02:00
b1d3b14711 Fix crash when creating an off-screen context fails in Wayland
This is very unlikely to happen but better not to crash.
2022-07-01 15:33:51 +10:00
650a15fb9b Fix accessing windows from surfaces in Wayland
This is a follow up to [0], where it was assumed flushing the output
would run the appropriate leave handlers & clear the keyboard & pointer
surfaces. While that's mostly true it's not guaranteed.

Resolve this by clearing the pointers when closing windows and add NULL
checks before accessing the windows.

Tested with Gnome, KDE & River compositors.

[0]: 58ccd8338e
2022-07-01 15:16:45 +10:00
bd7b181e10 Cleanup: Remove outdated comments
Point clouds always use geometry_set_eval, and so do volumes.
2022-06-30 21:52:04 -05:00
df8d96ab66 Cleanup: Remove unnecessary includes from geometry nodes header 2022-06-30 21:51:13 -05:00
276e419671 Curves: Avoid initializing offsets when first allocated
The offsets array that encodes the sizes of each curve must be filled
anyway, or the curves will be in an invalid state. Calloc is unnecessary
here. To make that situation clearer, fill the offsets with -1 in debug
builds. Always set the first offset to zero though, since that can save
some boilerplate in other areas.
2022-06-30 21:42:09 -05:00
7e55ff15b0 Fix: Incorrectly sized curves created in set conversion node
The number of points in the source curve was needed, but the offset
(just zero) was passed instead. It's unclear how this worked before.
A mistake in the recent commit 9e393fc2f1.

Also use a common utility for retrieving the sizes of curves
in ranges instead of reimplementing it for this file.
2022-06-30 21:33:11 -05:00
3d3ba9ca8e Cleanup: group public utility functions for Wayland System/Window
GHOST methods were mixed in with Wayland specific utility functions,
making it difficult to navigate or know where to add new functions.
2022-07-01 11:19:01 +10:00
cf64a1d73e Cleanup: spelling in comments 2022-07-01 11:18:58 +10:00
90f4b35bc2 Cleanup: remove unused argument 2022-07-01 11:18:56 +10:00
c15ae2e87b Fix: Correct attribute names in resample curves code 2022-06-30 19:30:06 -05:00
4206b30275 Curves: Adjust "for each curve by type" utility
The first change is reusing the same vector for all types. While we don't
generally optimize for the multi-type case, it doesn't hurt here. The
second change is avoiding calling the corresponding function if there
are no curves of a certain type. This avoids creating attributes for
types that aren't used, for example.
2022-06-30 19:29:32 -05:00
32e9c9802e Cleanup: Add assert for customdata realloc size
This gives a more clear error than finding the error with the signed
to unsigned conversion for size_t.
2022-06-30 19:27:41 -05:00
6161ce6e5d Cleanup: Add assert for unsupported legacy curve type 2022-06-30 19:26:51 -05:00
982d6589a8 Cleanup: Remove duplicate include 2022-06-30 19:25:44 -05:00
a69e5c2348 Cleanup: Avoid assigning constructed VArray to reference
This is clearer about what is actually happening (VArray is small
enough to be a by-value type and is constructed on demand, while
only the generic virtual array is stored).
2022-06-30 19:17:32 -05:00
95055af668 Fix T99309: Duplicate elements deletes instance attributes
The node had incorrect handling of instance attributes. For the instance
component, instead of using the instance domain over the point domain,
it just looked through instances recursively when retrieving attributes.
We never want to do that, since we only work on one geometry at a time.
Instead, just switch out the instance domain for the point domain like
the set position node.
2022-06-30 19:01:02 -05:00
Gaia Clary
106d937a4e COLLADA: Support for alpha color in vertex data.
Many thanks to the original Author of this patch: Christian Aguilera

The COLLADA importer was silently ignoring the alpha component in the
vertex data.

The `stride` variable holds the component count (3 for RGB; 4 for RGBA),
and can be used for honouring the alpha channel in the vertex data.

Test plan:
- Open Blender.
- Clear the scene.
- Add a plane.
- Enter **Vertex Paint** mode.
- Switch to the **Erase Alpha** blending mode.
- Select a tone of gray.
- Turn strength down to less than 1
- Paint [some of] the vertices of the plane.
- Export project as a COLLADA file (`.dae`).
- Clear the scene.
- Re-import the COLLADA file again.
- Export the project again (with different name).

**Without** this patch, the second exported project will have lost the
alpha component in their vertex data:

```lang=xml, counterexample
<float_array id="Plane-mesh-colors-Col-array" count="24">1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</float_array>
```

**With** the patch, the first and the second exported projects retain
the alpha values painted previously:

```lang=xml
<float_array id="Plane-mesh-colors-Col-array" count="24">1 1 1 1 1 1 1 0.5490196 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.5490196</float_array>
```

Reviewed By: cristian64, SonnyCampbell_Unity
Authored by: Christian Aguilera

Differential Revision: https://developer.blender.org/D14246
2022-06-30 23:13:37 +02:00
f18067aa03 EEVEE-Next: Add Film and RenderBuffers module
This modules handles renderpasses allocation and filling. Also handles
blitting to viewport framebuffer and render result reading.

Changes against the old implementation:
- the filling of the renderpasses happens all at once requiring
  only 1 geometry pass.
- The filtering is optimized with weights precomputed on CPU and
  reuse of neighboor pixels.
- Only one accumulation buffer for renderpasses (no ping-pong).
- Accumulation happens in one pass for every passes using a single
  dispatch or fullscreen triangle pass.

TAA and history reprojection is not yet implemented.
AOVs support is present but with a 16 AOV limit for now.
Cryptomatte is not yet implemented.
2022-06-30 22:45:42 +02:00
a9696f04a0 Fix T90964: Strip can't be deleted if cursor is at bottom of timeline
Caused by hard-coded width of markers region causing operator to pass
through.

Execute operator if there are no markers.
2022-06-30 20:45:37 +02:00
fbcc00d10d Fix broken Cycles performance benchmark after recent logging changes
Ensure full render report is printed with default verbosity.
2022-06-30 19:51:50 +02:00
c9795102c2 Fix build error with Alembic after 65166e145b 2022-06-30 19:47:21 +02:00
e7c58941b1 Fix pointer to pointer passed where single pointer is expected (VSE versioning) 2022-06-30 18:42:22 +02:00
65166e145b Cleanup: Remove scene frame macros (CFRA et al.)
Removes the following macros for scene/render frame values:
- `CFRA`
- `SUBFRA`
- `SFRA`
- `EFRA`

These macros don't add much, other than saving a few characters when typing.
It's not immediately clear what they refer to, they just hide what they
actually access. Just be explicit and clear about that.
Plus these macros gave read and write access to the variables, so eyesores like
this would be done (eyesore because it looks like assigning to a constant):
```
CFRA = some_frame_nbr;
```

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D15311
2022-06-30 18:38:44 +02:00
66de653784 Fix incorrect strip position if pitch was animated
Commit 302b04a5a3 introduced new retiming system, that unified sound
pitch animation with strip speed control. Because sound playback is
handled in different way, this did not work as expected and old files
were broken. In addition animation was not copied to new property.

Revert length position and offset handling for sound strips so their
position does not change and remap fcurves to new `speed_factor`
property.
2022-06-30 18:33:34 +02:00
Patrick Huang
79fe27b976 Fix T96429: outliner tooltip inconsistent with behavior when linking collections
Previously, it would show "Link inside collection" but move between collections
instead in some cases. Additionally there was no tooltip for the "Link before/
after/between collections" case.

Behavior and tooltip should now be consistent in all cases.

Differential Revision: https://developer.blender.org/D15237
2022-06-30 17:19:48 +02:00
34e04ccde2 Cleanup: fix compiler warnings
"override" should be used either for all methods or none, otherwise Clang gives
warnings. Adding it for all platforms is a bigger change.
2022-06-30 17:17:25 +02:00
ef268c7893 Build: Fix build of library dependencies on Linux aarch64
rBb9c37608a9e959a896f5358d4ab3d3d001a70833 moved evaluation of
`versions.cmake` before `options.cmake`, as a result of which
`BLENDER_PLATFORM_ARM` was no longer defined in `versions.cmake`,
causing it to choose the wrong OpenSSL version for aarch64. This
reverts that. Also fixes a compiler crash when building flex with some
glibc versions.

Differential Revision: https://developer.blender.org/D15319
2022-06-30 16:49:42 +02:00
Andrii Symkin
f00d9e80ae Cycles: add more math functions for float4
Add more math functions for float4 to make them on par with float3 ones. It
makes it possible to change the types of float3 variables to float4 without
additional work.

Differential Revision: https://developer.blender.org/D15318
2022-06-30 16:25:21 +02:00
6bb703a9ee Fix T99266: Crash when dragging file to VSE from file browser
Crash happened because sequencer data was not initialized. Ensure data
is initialized before adding strip.
2022-06-30 15:56:08 +02:00
8bf9d482da Cleanup: colon after params, move text into public doc-strings, spelling 2022-06-30 23:48:22 +10:00
58ccd8338e GHOST/Wayland: clarify window access from surfaces
It wasn't obvious when direct access or lookups should be used.

Add class methods for direct lookups as well as searching from known
windows when windows are accessed outside Wayland's handlers.

This avoids having to check if the window has been removed in some cases.
2022-06-30 23:46:57 +10:00
7c98632289 GHOST/Wayland: use flush instead of roundtrip
Using flush avoids handling new events which complicates logic here.
2022-06-30 23:46:57 +10:00
cfd087673d Fix key/dnd event handling accessing freed memory under Wayland
Closing a window could leave danging pointers which Wayland
callbacks are responsible for clearing.

However, any calls Blender makes that don't originate from Wayland's
handlers don't have that assurance (key-repeat in this case).

Resolve by using a window lookup on each key-repeat event.
2022-06-30 23:46:57 +10:00
1cf64434ed Fix accessing cursor position for GHOST/Wayland
GHOST_GetCursorPosition wasn't working properly under Wayland because
the last focused window didn't necessarily match the window used to call
wm_cursor_position_get(..).

Now the window passed into wm_cursor_position_get is passed to GHOST
so that window is used to access cursor coordinates.
2022-06-30 23:46:57 +10:00
6bd2c6789b GHOST: get/set cursor position now uses client instead of screen coords
Use client (window) relative coordinates for cursor position access,
this only moves the conversion from window-manager into GHOST,
(no functional changes).

This is needed for fix a bug in GHOST/Wayland which doesn't support
accessing absolute cursor coordinates & the window is needed to properly
access the cursor coordinates.

As it happens every caller to GHOST_GetCursorPosition was already making
the values window-relative, so there is little benefit in attempting to
workaround the problem on the Wayland side.

If needed the screen-space versions of functions can be exposed again.
2022-06-30 23:46:57 +10:00
df40e9d0aa Fix memory leak with off-screen buffers under Wayland
Each off-screen buffer created a surface and EGL window which was
only freed when Blender exited.

Resolve by freeing the associated data when disposing the off-screen
context.
2022-06-30 23:46:57 +10:00
e190b70946 Cleanup: declare GHOST/Wayland methods const
Needed when called by functions that are const too.
2022-06-30 23:46:57 +10:00
e75f3e3feb Cleanup: use "use_" prefix for boolean property 2022-06-30 23:46:57 +10:00
90ccb71969 Fix missing argument, avoid instancing function call in macro 2022-06-30 23:44:13 +10:00
547efb6b1e Fix T99133:animating multiply factor on video strips crashes blender
Crash caused by `effect_seq->len` being 0, so frame map was not built.

Get length in timeline using handle positions.
2022-06-30 15:31:58 +02:00
Amélie Fondevilla
92d7f9ac56 Animation: Add GP layers in regular Dopesheet
Grease Pencil animation channels are now also shown in the Dopesheet
mode of the Dopesheet editor and in the Timeline.

Grease pencil related events are now listened not only by container
`SACTCONT_GPENCIL` (Grease Pencil Dopesheet), but also
`SACTCONT_DOPESHEET` (main Dopesheet), and `SACTCONT_TIMELINE`
(timeline).

A new Animation Filter flag was added: `ANIMFILTER_FCURVESONLY`. For now
this only filters out Grease Pencil Layer channels.

**Implemented:**

- Preview range set: now only considers selected Grease Pencil keyframes
  when `onlySel` parameter is true. Not only this allows the operator to
  work with grease pencil keyframes in main dopesheet, but it also fixes
  the operator in the Grease Pencil dopesheet.
- Translation: allocation (and freeing) of specific memory for
  translation of Grease Pencil keyframes.
- Copy/Paste: call to both Fcurve and GPencil operators, to allow for
  mixed selection. Errors are only reported when both the FCurve and
  GPencil functions fail to paste anything.
- Keyframe Type change and Insert Keyframe: removed some code here to
  unify Grease Pencil dopesheet and main dopesheet code.

- Jump, Snap, Mirror, Select all/box/lasso/circle, Select left/right,
  Clickselect: account for Grease Pencil channels within the channels
  loop, no need for `ANIMFILTER_FCURVESONLY` there.

**Not Implemented:**

- Graph-related operators. The filter `ANIMFILTER_FCURVESONLY` is
  naively added to all graph-related operators, meaning more-or-less all
  operators that used `ANIMFILTER_CURVE_VISIBLE`.
- Select linked: is for F-curves channel only
- Select more/less: not yet implemented for grease pencil layers.
- Clean Keys, Sample, Extrapolation, Interpolation, Easing, and Handle
  type change: work on Fcurve-channels only, so the
  `ANIMFILTER_FCURVESONLY` filter is activated

Graying out these operators (when no fcurve keyframe is selected) can be
done with custom poll functions BUT may affect performance. This is NOT
done in this patch.

**Dopesheet Summary Selection:**

The main summary of the dopesheet now also takes into account Grease
Pencil keyframes, using some nasty copy/pasting of code, as explained
[on devtalk](https://devtalk.blender.org/t/gpencil-layers-integration-in-main-dopesheet-selection-issue/24527).
It works, but may be improved, providing some deeper changes.

Reviewed By: mendio, pepeland, sybren

Maniphest Tasks: T97477

Differential Revision: https://developer.blender.org/D15003
2022-06-30 15:20:18 +02:00
416aef4e13 Curves: New tools for curves sculpt mode.
This commit contains various new features for curves sculpt mode
that have been developed in parallel.

* Selection:
  * Operator to select points/curves randomly.
  * Operator to select endpoints of curves.
  * Operator to grow/shrink an existing selection.
* New Brushes:
  * Pinch: Moves points towards the brush center.
  * Smooth: Makes individual curves straight without changing the root
    or tip position.
  * Puff: Makes curves stand up, aligning them with the surface normal.
  * Density: Add or remove curves to achieve a certain density defined
    by a minimum distance value.
  * Slide: Move root points on the surface.

Differential Revision: https://developer.blender.org/D15134
2022-06-30 15:09:13 +02:00
Nate Rupsis
0f22b5599a Normalize Weights: use valid default Subset for current context
For the Normalize Weights operator, dynamically set the default 'Subset'
parameter so that it is applicable to the current context.

When the user's last use of Normalize Weights was set to "Deform Pose
Bones", and then tries to use the operator on a mesh without armature,
Blender would try to use the previous opertor properties and show an
error message. This is resolved by switching to `WT_VGROUP_ACTIVE` in
such cases.

Reviewed By: zanqdo, sybren

Maniphest Tasks: T95038

Differential Revision: https://developer.blender.org/D14961
2022-06-30 12:54:27 +02:00
4a7e1c9209 Constraints: rename and refactor custom space initialization.
Rename and simplify the function for initializing the custom space,
avoiding the need for the calling code to be aware of the internals
of bConstraintOb. This patch should not change any behavior.

This was split off from D9732.

Differential Revision: https://developer.blender.org/D15252
2022-06-30 12:51:26 +03:00
c64d1b23df Fix numerical issues with plane track compositor node with empty input
No changes in the interface, but avoids spam in the console about
inability to find a solution for homography transform from singularity.
2022-06-30 11:10:19 +02:00
b544225202 Fix (unreported) liboverride resync creating garbage data in some cases.
Regression caused by the introduction of partial resync in February 2022
(rB1695d38989fd482d3c). Code was missing adding some existing overrides
to the mapping in some specific cases, causing resync to create 'new'
ones instead of re-using existing ones.

This commit also adds a basic resync testcase that illustrates this
issue.
2022-06-30 10:33:44 +02:00
acdc043c30 Revert "Revert "LibOverride: Handle dependencies in both directions in partial override cases.""
This reverts commit rB31d80ddeaad, and fixes issue introduced in rBf0b4aa5d59e3
by not doing the 'reversed dependency check' in resync case.

Rational here are:
* Supporting reversed dependency in a reliable, coinsistent way in
  resync is likely to be a nightmare, if even possible at all.
* Needs for such reversed dependency in resync should be close to 0% of
  cases, as long as users remain reasonable with their organization of
  their assets (it could only become a problem in extreme bad practice
  and corner cases, like a geometry object being added as a child of a
  rig in a completely new, otherwise un-overridden collection, in
  partial override context).

This decision may need to be re-evaluated later in case we go more
towards a very highly partial-override  workflow, but even then I would
expect current solution to work fine in all reasonable use cases.
2022-06-30 10:33:09 +02:00
edbf04ff37 Fix T99290: Wrong color management of plane track image preview
Always consider images as "View as Render" for the plane track image drawing.
2022-06-30 10:24:33 +02:00
Iyad Ahmed
5c726dd4ef Fix C++ STL importer unused function result warning
Fix unused function result warnings for usages of `fread` in the C++
.stl importer, by actually using the returned error code.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15189
2022-06-30 10:14:08 +02:00
c39e932631 Fix T99196: sculpt_update_object calls paint updates for nonpaint tools
Specifically BKE_texpaint_slots_refresh_object was being called, which
causes cycles to reset at strange times (like moving the mouse cursor
in pose, boundary and various other tools).

This (along with some code that checks if the pbvh pixels need
to be rebuilt) is only run if is_paint_mode (which used to be
needs_colors) is true.
2022-06-29 23:31:08 -07:00
2185943235 Sculpt: Fix a few bugs revealed by SCULPT_TOOL_NEEDS_COLOR name change
* Color attributes are no longer auto-created when painting an image.
* Workbench shading type is no longer automatically changed to
  Attribute for image paint.
2022-06-29 23:22:06 -07:00
f7c6d3705d Cleanup: Renamed SCULPT_TOOL_NEEDS_COLOR to SCULPT_tool_is_paint
Old name is confusing since SCULPT_TOOL_PAINT can paint
on images too, and it's planned for smear to as well.
2022-06-29 23:11:24 -07:00
3cefa13770 Fix T98886: PBVH_GRIDS ignores face smooth flag on first gpu build 2022-06-29 21:05:21 -07:00
feeb8310c8 Cleanup: format 2022-06-30 12:14:23 +10:00
b6c28002ac Cleanup: spelling in comments 2022-06-30 12:14:22 +10:00
209f2b85d7 Cleanup: quiet warning, remove punctuation in description 2022-06-30 12:14:20 +10:00
011327224e Transform Snap: nearest face snap mode, snapping options, refactoring.
This commit adds a new face nearest snapping mode, adds new snapping
options, and (lightly) refactors code around snapping.

The new face nearest snapping mode will snap transformed geometry to the
nearest surface in world space. In contrast, the original face snapping
mode uses projection (raycasting) to snap source to target geometry.
Face snapping therefore only works with what is visible, while nearest
face snapping can snap geometry to occluded parts of the scene. This new
mode is critical for retopology work, where some of the target mesh
might be occluded (ex: sliding an edge loop that wraps around the
backside of target mesh).

The nearest face snapping mode has two options: "Snap to Same Target"
and "Face Nearest Steps". When the Snap to Same Object option is
enabled, the selected source geometry will stay near the target that it
is nearest before editing started, which prevents the source geometry
from snapping to other targets. The Face Nearest Steps divides the
overall transformation for each vertex into n smaller transformations,
then applies those n transformations with surface snapping interlacing
each step. This steps option handles transformations that cross U-shaped
targets better.

The new snapping options allow the artist to better control which target
objects (objects to which the edited geometry is snapped) are considered
when snapping. In particular, the only option for filtering target
objects was a "Project onto Self", which allowed the currently edited
mesh to be considered as a target. Now, the artist can choose any
combination of the following to be considered as a target: the active
object, any edited object that isn't active (see note below), any non-
edited object. Additionally, the artist has another snapping option to
exclude objects that are not selectable as potential targets.

The Snapping Options dropdown has been lightly reorganized to allow for
the additional options.

Included in this patch:

- Snap target selection is more controllable for artist with additional
  snapping options.
- Renamed a few of the snap-related functions to better reflect what
  they actually do now. For example, `applySnapping` implies that this
  handles the snapping, while `applyProject` implies something entirely
  different is done there. However, better names would be
  `applySnappingAsGroup` and `applySnappingIndividual`, respectively,
  where `applySnappingIndividual` previously only does Face snapping.
- Added an initial coordinate parameter to snapping functions so that
  the nearest target before transforming can be determined(for "Snap to
  Same Object"), and so the transformation can be broken into smaller
  steps (for "Face Nearest Steps").
- Separated the BVH Tree getter code from mesh/edit mesh to its own
  function to reduce code duplication.
- Added icon for nearest face snapping.
- The original "Project onto Self" was actually not correct! This option
  should be called "Project onto Active" instead, but that only matters
  when editing multiple meshes at the same time. This patch makes this
  change in the UI.

Reviewed By: Campbell Barton, Germano Cavalcante

Differential Revision: https://developer.blender.org/D14591
2022-06-29 20:52:00 -04:00
0ea282f746 Geometry Nodes: Only calculate mesh to volume bounds when necessary
In "size" voxel resolution mode, calculating the bounds of the mesh to
volume node's input mesh isn't necessary. For high poly this can take
a few milliseconds, so this commit skips the calculation unless we need
it for the "Amount" mode.

Differential Revision: https://developer.blender.org/D15324
2022-06-29 12:28:08 -05:00
Aleksi Juvani
4593fb52cf Geometry Nodes: UV Unwrap and Pack Islands Nodes
This commit adds new Unwrap and Pack Islands nodes, with equivalent
functionality to the existing Unwrap and Pack Islands operators. The
Unwrap node uses generic boolean attributes to determine seams instead
of looking at the seam flags in the mesh geometry.

Unlike the Unwrap operator, the Unwrap node doesn't perform aspect
ratio correction, because this is trivial for the user to implement
with a Vector Math node if it is desired.

The Unwrap node implicitly performs a Pack Islands operation upon
completion, because the results may not be generally useful otherwise.
This matches the behaviour of the Unwrap operator.

The nodes use the existing Vector socket type, and do not introduce a
new 2D Vector type (see T92765).

Differential Revision: https://developer.blender.org/D14389
2022-06-29 12:25:46 -05:00
Martijn Versteegh
d23818fcd9 Attributes: Use attribute renaming function for generic mesh layers
The RNA API in rna_mesh.c has a function to rename generic customdata
layers. However for customdata layers which are attributes (i.e. not
specialized types) the attribute renaming function needs to be used,
as that can ensure unique names across domains.

Differential Revision: https://developer.blender.org/D15310
2022-06-29 11:36:46 -05:00
95964444c6 Cleanup: Clang tidy, unused variable warning 2022-06-29 10:57:28 -05:00
1516f7dcde Geometry Nodes: Add Mesh To Volume Node
This adds a Mesh To Volume Node T86838 based on the existing modifier.
The mesh to volume conversion is implemented in the geometry module,
and shared between the node and the modifier.

Currently the node outputs a grid with the name "density". This may
change in the future depending on the decisions made in T91668.

The original patch was by Kris (@Metricity), further implementation
by Geramy Loveless (@GeramyLoveless), then finished by Erik Abrahamsson
(@erik85).

Differential Revision: https://developer.blender.org/D10895
2022-06-29 10:56:17 -05:00
6b508eb012 Spreadsheet: display byte colors as scene linear floats
The compression as sRGB is mostly an implementation detail and showing the
integers does not make it clear what the actual values are that will be used
for computations in geometry nodes. This follows the general convention that
colors in Blender are displayed and edited in scene linear floats.

The raw sRGB bytes can still be viewed as a tooltip.

Ref T99205

Differential Revision: https://developer.blender.org/D15322
2022-06-29 17:08:50 +02:00
6dd8ceef2a LineArt: Shadow and related functionalities.
This patch includes the full shadow functionality for LineArt:

- Light contour and cast shadow lines.
- Lit/shaded region selection.
- Enclosed light/shadow shape calculation.
- Silhouette/anti-silhouette selection.
- Intersection priority based on shadow edge identifier.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D15109
2022-06-29 22:54:29 +08:00
Arye Ramaty
2ac5b55289 UI: add tooltips for nodes to the shader node add menu
These are based on the descriptions from the manual, with various changes.

Differential Revision: https://developer.blender.org/D15309
2022-06-29 16:19:24 +02:00
b708f45922 Fix T99248: GPencil Sculpt Grab/Push don't work with one point
There were two problems:

1) The checking of the collision was not working with one point only.
2) For one point, the masking was checked always and if the masking was not activated, the stroke was skipped.
2022-06-29 16:07:13 +02:00
a5ac0375b0 Fix T98697: EEVEE: Regression: Missing custom property from volumetrics
The resource binding were missing from the shading group
(`shgroup->uniform_attrs`), leading to no custom property UBO creation
(`drw_uniform_attrs_pool_update`) when issuing the drawcall,
resulting in a missing UBO bind.

The fix make sure to no duplicate the bindings by creating a simple
shader bind instead of a `GPUMaterial` bind.

Candidate for 3.2.1 corrective release.
2022-06-29 14:12:03 +02:00
45fb7a1db5 Fix T98825: EEVEE: Regression: Buffer overflow in sample name buffer
This happened because of the false assumption that `std::array<char, 32>`
would be treated as a container and not relocate their content if the
`Vector` would grow. Replacing with actual object allocation fixes the
issue.

Candidate for 3.2.1 corrective release.
2022-06-29 14:12:03 +02:00
4a9f60ecd2 Fix T99104: EEVEE: Regression: Crash when using Light Output in Materials
Using Light output is supported in Cycles. This patch adds support for it
and remove the crash in `ntree_shader_weight_tree_invert()` by treating
it as any other outputs.

Candidate for 3.2.1 corrective release.
2022-06-29 14:12:03 +02:00
40f40e9931 Fix T99128: EEVEE: Regression: Pixelated Environment Texture
Use view position to retreive world space direction to retain float
precision.

Candidate for 3.2.1 corrective release.
2022-06-29 14:12:03 +02:00
70c6beeafb Fix T99138: EEVEE: Regression: World volume shader incorrect texture coords
The ORCO property was not being properly initialized in this case.

Candidate for 3.2.1 corrective release.
2022-06-29 14:12:03 +02:00
087e95d0fe Cleanup: correct type for sequencer SWAP macro 2022-06-29 22:02:04 +10:00
a02992f131 Cycles: Add support for rendering on Intel GPUs using oneAPI
This patch adds a new Cycles device with similar functionality to the
existing GPU devices.  Kernel compilation and runtime interaction happen
via oneAPI DPC++ compiler and SYCL API.

This implementation is primarly focusing on Intel® Arc™ GPUs and other
future Intel GPUs.  The first supported drivers are 101.1660 on Windows
and 22.10.22597 on Linux.

The necessary tools for compilation are:
- A SYCL compiler such as oneAPI DPC++ compiler or
  https://github.com/intel/llvm
- Intel® oneAPI Level Zero which is used for low level device queries:
  https://github.com/oneapi-src/level-zero
- To optionally generate prebuilt graphics binaries: Intel® Graphics
  Compiler All are included in Linux precompiled libraries on svn:
  https://svn.blender.org/svnroot/bf-blender/trunk/lib The same goes for
  Windows precompiled binaries but for the graphics compiler, available
  as "Intel® Graphics Offline Compiler for OpenCL™ Code" from
  https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html,
  for which path can be set as OCLOC_INSTALL_DIR.

Being based on the open SYCL standard, this implementation could also be
extended to run on other compatible non-Intel hardware in the future.

Reviewed By: sergey, brecht

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

Co-authored-by: Nikita Sirgienko <nikita.sirgienko@intel.com>
Co-authored-by: Stefan Werner <stefan.werner@intel.com>
2022-06-29 12:58:04 +02:00
302b04a5a3 VSE: Improved Retiming system
Patch implements better way to control playback speed than it is
possible to do with speed effect. Speed factor property can be set in
Time panel.

There are 2 layers of control:

Option to retime movie to match scene FPS rate.
Custom speed factor to control playback rate.
Since playback rate is strip property, it is now possible to manipulate
strip as normal one even if it is retimed.

To facilitate manipulation, some functions need to consider speed factor
and apply necessary corrections to strip offset or strip start. These
corrections may need to be float numbers, so start and offsets must be
float as well.

Sound strips now use speed factor instead of pitch. This means, that
strips will change length to match usable length. In addition, it is
possible to group movie and sound strip and change speed of meta strip.
2022-06-29 12:48:34 +02:00
c51b8ec863 BLI: add Vector.append_and_get_index with rvalue parameter
This makes it possible to use this method with `std::unique_ptr`.
2022-06-29 12:07:02 +02:00
43b65150ed Fix uninitialized memory use in key-down events on window activation 2022-06-29 18:21:36 +10:00
930398d5b1 GHOST/Wayland: quiet warning with empty title with libdecor
Set the title before showing the window.
2022-06-29 17:34:43 +10:00
6b2dd3e314 GHOST/Wayland: support older output manager (for Weston support)
Support zxdg_output_manager_v1 v2, as weston only supports this.

Even though it's a reference implementation it can be useful for testing.
2022-06-29 17:34:41 +10:00
b1163d2198 Mantaflow: disable call to MANTA::terminateMantaflow
Effectively revert [0] as it ran when freeing individual modifiers,
causing a crash on exit in one of the cycles_volume_cpu tests.

[0]: 6777c420db
2022-06-29 17:34:39 +10:00
Jeroen Bakker
66f826ae85 Benchmark: Add eevee viewport playback tests.
This commit adds the ability to test Eevee viewport playback performance tests.

Tests should be placed in `lib/benchmarks/eevee/*/*.blend`. {rBL62962} added
initial test files. See https://wiki.blender.org/wiki/Tools/Tests/Performance how
to set it up.

To record the playback performance the test start the viewport playback, and adds
a post frame change handler.

This handler will go over the next steps:

* Ensures the viewport is set to rendered mode.
* Wait for shaders to be compiled. Utilizes `bpy.app.is_job_running` function when
  available (v3.3) to wait for shader compilation to finish. When not available will wait
  for one minute.
* Draw several warmup frames
* Record for 10 seconds tracking the number of frames drawn and performance counters.
* When ready print the result to the console. The results will be extracted when the
  benchmark has run.

## Example report
```
                                         master               v3.0                 v3.1                 v3.2
T88219                                   0.0860s              0.0744s              0.0744s              0.0851s
blender290-fox                           1.3056s              0.8744s              0.7994s              1.2809s
```

{F13232387}

Reviewed By: brecht, fclem

Maniphest Tasks: T99136

Differential Revision: https://developer.blender.org/D15302
2022-06-29 07:55:51 +02:00
eaec01cad5 Sculpt: Fix backwards normals in PBVH_GRIDS raycasting
Winding order of grid quads was backwards.
2022-06-28 22:30:28 -07:00
2d0877ed7e Fix T99231: Wrong anchored mode test for smear brush 2022-06-28 21:35:55 -07:00
3283bc6367 Cleanup(UV): Remove unused parameter (no functional changes)
Prep for D15263
2022-06-29 13:14:39 +12:00
f32d7dd0c8 Cleanup(UV): Store nboundaries on pchart (no functional changes)
Prep for D15263
2022-06-29 12:31:16 +12:00
68d037190f Cleanup: format 2022-06-29 10:19:02 +10:00
e1dc54c8fc Cleanup: Fix mul_v2_v2_ccw for repeated arguments (no functional changes)
Prep for D15263
2022-06-29 12:14:35 +12:00
6777c420db Mantaflow: call MANTA::terminateMantaflow on exit
terminateMantaflow was never called, this leak is more of a technicality
since it's only called on exit.

Also make Py_Initialize/Py_Finalize optional in Pd:setup/finalize
as it caused Blender to crash, finalizing Python twice.

Add a patch to extern/mantaflow to keep track of changes in Blender
from up-stream.
2022-06-29 10:11:01 +10:00
d94d7a5d8f Cleanup: update curve_fit_nd (no functional changes) 2022-06-29 09:55:44 +10:00
45645936e9 Cleanup: spelling in comments 2022-06-29 09:40:16 +10:00
c0e4532331 Fix T78394: In UV Editor, UV Unwrap respects selection
Differential Revision: D14945
2022-06-29 10:57:41 +12:00
2d18dd9309 Fix: Use distance unit for points node radius input 2022-06-28 16:03:04 -05:00
1c61db5346 Fix: Flush mode to evaluated object when exiting curves sculpt mode
Tagging the object for copy on write in order to change the mode on the
evaluated object was already done when entering sculpt mode, it should
happen when exiting sculpt mode as well.

Also use the message system to tag updates of the mode property.
This is commonly done for other "mode switch" operators. It's
best to be consistent here, though I don't know that lacking that
caused any issues.
2022-06-28 15:57:22 -05:00
Siddhartha Jejurkar
33be9c0885 Fix T98924: Skip saving selection properties for UV edge ring operator
Oversight in rB7724251af81f. Skip saving selection properties
for UV edge ring operator as it allows the operator to re-use
the value that was previously set using the key-map.

Reviewed By: campbellbarton

Maniphest Tasks: T98924

Differential Revision: https://developer.blender.org/D15214
2022-06-29 01:18:22 +05:30
c257443192 Fix Cycles assert with mix weights outside of 0..1 range
This could result in wrong skipping of SVM nodes in the graph. Now make the
logic consistent with the clamping in the OSL implementation and constant
folding.

Thanks to Christophe Hery for finding the problem and providing the fix.
2022-06-28 19:13:57 +02:00
814f360c83 UI: Unhide the world mist panel if the mist pass is not enabled
This makes no sense to hide it since we can nowadays preview it inside the
viewport even if the render pass is not enabled.
2022-06-28 18:48:39 +02:00
e127182065 DRW: Curve: Fix wrong UBO alignment
This was preventing correct attribute rendering with multiple attributes.
Since the `CurveInfos` struct is used for data sharing between C++ and
GLSL and inside a UBO it needs to obey the `std140` alignment rules which
states that arrays of scalars are padded to the size of `vec4` for each
array entry.
2022-06-28 18:48:39 +02:00
75ad435ceb Cleanup: GPUShader: Fix missing space in debug message 2022-06-28 18:48:38 +02:00
fde7d39051 Cleanup: DRW: Fix misnamed argument and add more info in a function doc 2022-06-28 18:48:38 +02:00
Sayak Biswas
abfa09752f Cycles: enable Vega GPU/APU support
Enables Vega and Vega II GPUs as well as Vega APU, using changes in HIP code
to support 64-bit waves and a new HIP SDK version.

Tested with Radeon WX9100, Radeon VII GPUs and Ryzen 7 PRO 5850U with Radeon
Graphics APU.

Ref T96740, T91571

Differential Revision: https://developer.blender.org/D15242
2022-06-28 18:35:43 +02:00
270ed1c716 Fix T98882: Regression: Gradient colors in a Grease Pencil material change depending on the visibility of other objects
The material ID was being wrongly passed in the shader.
2022-06-28 13:13:48 -03:00
b8064e3312 Build: add HIP version to buildbot configuration 2022-06-28 16:54:45 +02:00
Christian Rauch
bd6912930f Build: when using Wayland, always enable EGL and disable system GLEW
GLEW does not support GLX and EGL at the same time, and the distribution version
is likely to have GLX.

This also refactors the code so all OpenGL related CMake options are together.

Differential Revision: https://developer.blender.org/D12034
2022-06-28 16:54:45 +02:00
614aa9d8ec Py API Doc: add runtime changelog generation to sphinx_doc_gen.py.
Optionally use `sphinx_changelog_gen.py` to dump current version of the
API in a JSON file, and use closest previous one listed in given index
file to create a changelog RST page for Sphinx.

Part of {T97663}.
2022-06-28 16:53:12 +02:00
f9f73473d6 Py API Doc: refactor changelog generation script.
Main change is to make it use JSON format for its dump files, instead of
some Python code.

It also introduces an index for those API dump files, mapping a blender
version to the relevant file path.

This is then used to automatically the most recent (version-number wise)
previous API dump to compare against current one, when generating the
change log RST file.

Part of {T97663}.
2022-06-28 16:52:46 +02:00
b585872450 Fix frame_final_start/end strip property not setting handle position
This was a mistake in 17a773cdce - I did not notice existing set
function and assumed, that property set DNA directly.

Both get and set functions are now available and readonly flag is
removed.
2022-06-28 15:58:08 +02:00
d5dcbabdd2 Build: remove GLEW version checking from install_deps.sh
Latest OpenSubdiv builds without GLEW by default, which is also what we do
for precompiled libraries. So there is no need for compatibility checking
with system GLEW.

Additionally WITH_SYSTEM_GLEW is turned off by default for Blender, and this
logic was presumably added when it was still on by default a few years ago.

Also remove outdated mention of glew-mx, we use intern/glew-mx and no
external library for this.

Differential Revision: https://developer.blender.org/D15281
2022-06-28 15:57:06 +02:00
luzpaz
4d982cbb5d Cleanup: fix various typos
Differential Revision: https://developer.blender.org/D15304
2022-06-28 15:56:16 +02:00
0124de9d0e Install_deps: Fix several issues with TBB.
* TBB MEX version is now 2021, since this versin introduces 'oneTBB'
  which brings a lot of incompatibilities with previous versions.
* Fix several typos and mistakes in OSD, Embree and OIDN build code that
  prevented proper usage of a local TBB build.
2022-06-28 15:47:41 +02:00
c96f2778f0 Fix: sampling points on mesh surface generates too many points 2022-06-28 13:13:41 +02:00
dfea5e24ad BLI: add kdtree range search method that accepts c++ lambda
This is easier to use in C++ code compared to passing a function
and user-data separately.
2022-06-28 13:13:41 +02:00
c1ffea157c Mask editor: Always use smooth drawing
The mask is expected to be always be displayed smooth, and the
option mainly existed for some legacy drivers. IF smooth drawing
causes issues it should be fixed in the drawing code, not as an
option in the interface.

Differential Revision: https://developer.blender.org/D15266
2022-06-28 10:55:45 +02:00
f9076f3869 Cleanup: Remove redundant theme versioning code
Since we reset the default theme for the 3.0 release, we don't need to
keep these version patches around anymore.

Ref D13131
2022-06-28 16:07:30 +10:00
33fc230ba2 Fix T98799: camera unselectable in camera view below a certain scale
The camera frame (used for selection) was drawn outside the near
clipping plane in those cases.

This has been an issue before as seen in the following commits:
- rB6e7e6832e87
- rB33d322873e6
- rB4f9451c0442

Remaining issue was that the code which ensure the frame isn't behind
the near clipping plane was not taking into account the camera could be
scaled (in Z).
A caller of `BKE_camera_view_frame_ex` (namely
`OVERLAY_camera_cache_populate`) applies scale (also on the depth) which
does not play well with the way `BKE_camera_view_frame_ex` did it.

Now take Z scale into account.

Ref D15178
2022-06-28 15:54:02 +10:00
Red Mser
e6d50cdd43 Fix textview selection rendering in front of text
Selection of Python Console renders in front of the text.
Since the default theme uses a low opacity selection color,
it isn't obvious, but increasing alpha to 100% shows it clearly.

Ref D13111
2022-06-28 15:20:06 +10:00
ca9e1f6391 Cleanup: replace magic number with define for scan-code/key-code offset 2022-06-28 14:43:37 +10:00
dd95deadf3 GHOST/Wayland: avoid creating a keyboard-state each key press/release
Instead, create keyboard two states when the keyboard layout is set
(one with & one without num-lock pressed).
This avoids key-press lookups having to check if num-lock exists and
setting the keyboard state for key press & release events.

No functional changes.
2022-06-28 14:35:14 +10:00
fd7c070861 Fix T96170: keys mis-mapped with NeoQwertz layout under Wayland
Accessing the symbols for keys with no modifiers & num-lock enabled
has unintended consequences for some keyboard layouts that use this
to switch layers.

Resolve by restricting num-locked lookups to keys typically toggled
with num-lock (key-pad home, page up/down ... etc).
2022-06-28 13:48:05 +10:00
40cd041f74 Cleanup: group wayland event codes in their own doxy section
Also don't pass typedef'd ints as references.
2022-06-28 12:01:29 +10:00
b8cc181808 Fix T99202: AccentGrave key doesn't work with Wayland
Implement scan-code fallback when the scan-code used for AccentGrave
on US keyboards doesn't map to a key known to GHOST.

Without this, shortcuts that use AccentGrave are inaccessible and the
key does nothing.

This matches functionality from X11, see [0].

[0]: f3427cbc98
2022-06-28 11:31:12 +10:00
Keith Boshoff
b910114384 UI: add Custom properties panel to collections
Show a custom properties panel in the collections tab,
matching other data-blocks which already support this.

Reviewed by: HooglyBoogly, campbellbarton

Ref D12598
2022-06-28 10:52:31 +10:00
381fe684e2 GHOST: only use GHOST_PRINT when WITH_GHOST_DEBUG is enabled
Revert part of [0] so only assert behavior is changed.

[0]: 9b5dda3b07
2022-06-28 10:16:28 +10:00
65f4f50640 Cleanup: compiler warnings, remove unused functions 2022-06-28 10:13:24 +10:00
7a44f62bdb Fix T99156: UV parameterizer respects both Pins and Seams
Rgression from: e6e9f1ac5a

Reviewed By: Brecht Van Lommel

Differential Revision: D15292
2022-06-28 10:46:10 +12:00
317dfc1735 Fix T96776: Assets dropped upside down when looking through camera
In perspective mode the snap point direction needs to be taken into
account to define which side of the face is being looked at.

If there is no face under the mouse cursor, there is no direction
adjustment and the element normal will be used.
2022-06-27 19:00:24 -03:00
17a773cdce Fix T99216: RNA startdisp and enddisp return unreliable values
Since 7afcfe111a `startdisp` and `enddisp` fields are used as runtime
position storage for effect strips exclusively.

Use getter functon to return handle position and make properties read
only.
2022-06-27 22:22:18 +02:00
36348bf4fc Fix error in previous commit - missed include 2022-06-27 22:17:59 +02:00
8eef98710b Fix meta strip has incorrect range when created
Caused by using `startdisp` and `enddisp` to initialize range.
Use handle position instead.
2022-06-27 22:06:07 +02:00
Germano Cavalcante
67e23b4b29 Fix T84369: Fluid: Missing cache invalidation when properties on non-domain objects change
The `DEG_OB_COMP_TRANSFORM` and `DEG_OB_COMP_GEOMETRY` relations between
the **Domain** object and the **Flow**, **Effector** and **Force Field** objects
are added in the `updateDepsgraph` callback of the Fluid modifier, more
specifically in `DEG_add_collision_relations`.

The node linked to these components is the `POINT_CACHE` whose assigned
function is `BKE_ptcache_object_reset`.

So include the `eModifierType_Fluid` modifier in outdated cache checks.

Reviewed By: sergey, zeddb

Maniphest Tasks: T84369

Differential Revision: https://developer.blender.org/D15210
2022-06-27 16:54:23 -03:00
a571c74e10 Sculpt: Fix backwards normals in PBVH_GRIDS raycasting
Winding order of grid quads was backwards.
2022-06-27 11:16:05 -07:00
31ebe8982e BLI: Math: Add ceil_to_multiple_u()
Standalone version of a function added to `BLI_math_vector.hh`.
2022-06-27 20:06:32 +02:00
Félix
6b35d9e6fb VSE: Add API function to select displayed meta strip
Use function `sequence_editor.display_stack(meta_strip)` to set
displayed timeline content.

To view top-level timeline, that does not belong to any meta strip, pass
`None` as argument.

Differential Revision: https://developer.blender.org/D12048
2022-06-27 19:44:16 +02:00
a2b9b9d3c4 Fix broken build on macOS after recent changes 2022-06-27 17:29:24 +02:00
f0a3d2beb2 FFmpeg: Add VFR media support
Variable frame rate (VFR) files have been difficult to work with.
This is because during sequential decoding, spacing between frames is
not always equal, but it was assumed to be equal. This can result in
movie getting out of sync with sound and difference between preview and
rendered image. A way to resolve these issues was to build and use
timecodes which is quite lengthy and resource intensive process. Such
issues are also difficult to communicate through UI because it is not
possible to predict if timecode usage would be needed.

With this patch, double buffer is used to keep previously decoded frame.
If current frame has PTS greater than what we are looking for, it is not
time to display it yet, and previous frame is displayed instead.

Each `AVFrame` has information about it's duration, so in theory double
buffering would not be needed, but in practice this information is
unreliable.

To ensure double buffer is always used, function
`ffmpeg_decode_video_frame_scan` is used for sequential decoding, even
if no scanning is expected.

This approach is similar to D6392, but this implementation does not
require seeking so it is much faster. Currently `AVFrame` is only
referenced, so no data is copied and therefore no overhead is added.

Note: There is one known issue where seeking fails even with double
buffering: Some files may seek too far in stream and miss requested
PTS. These require preseeking or greater negative subframe offset

Fixes: T86361, T72347

Reviewed By: zeddb, sergey

Differential Revision: https://developer.blender.org/D13583
2022-06-27 16:58:07 +02:00
6f7171525b File Browser UI: Use "Widget" font style instead of "Widget Label"
It didn't make much sense to use the "Widget Label" font style here,
since this is just regular text, not labels for widgets. Checked with
@pablovazquez and we agreed on using the "Widget" font style instead.

Also fixes a mismatch where we used the "Widget Label" font style for
drawing, but the "Widget" font style for string width calculations.
Fixes T99207.
2022-06-27 16:18:57 +02:00
Sonny Campbell
64a3a11e19 Fix T98055: Library Filters do not work in Source Files
The fix is to ensure the filter for id type is run when displaying
assets from an Asset Library.

In the current implementation the id_type filter does not run if a blend
file is opened that also happens to be in an Asset Library directory. If
we have opened a blend file that is in an Asset Library directory, we
now use the same filtering check as for the "Current File" asset
library.

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

Reviewed by: Julian Eisel
2022-06-27 16:09:38 +02:00
6243972319 UI: Scrollbar Behavior Changes
Changes to scrollbars so that they are always visible, but thin and
dim, and widen and become more visible as your mouse approaches.

See D6505 for details and examples.

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

Reviewed by Campbell Barton
2022-06-27 06:46:29 -07:00
Pratik Borhade
279e7dac7d Fix T99070: Apply transform fails to clear delta transform values
Clear delta transform value after applying transform.
Include delta location while applying transform.
Use `copy_v3_fl` for resetting object scale

Reviewed By: mano-wii

Maniphest Tasks: T99070

Differential Revision: https://developer.blender.org/D15270
2022-06-27 10:38:34 -03:00
83c2cbb880 Cleanup: Use assert instead of early exit for asset dragging internals
Instead of failing silently, throw a failed assert in debug builds.
2022-06-27 15:36:25 +02:00
36f5967b99 Fix T93650: Asset drag into catalogs broken, Industry Compatible keymap
Issue was that the Industry Compatible keymap wouldn't select files on a
mouse press, and since the dragged items are determined by the
selection, nothing would be considered as dragged.

Selecting items on mouse press happens since c606044157. I haven't
heard of that issue happening in the Industry Compatible keymap. But if
it did happen, it should be fixed too now.
2022-06-27 15:36:25 +02:00
228d79b789 Revert 6de0f29950: BLF: Support for Variable Fonts
Reverting for now, breaks on GCC
2022-06-27 06:32:30 -07:00
6de0f29950 BLF: Add Support for Variable Fonts
Add support for Variable/Multiple Master font features. These are fonts
that contain a range of design variations along multiple axes. This
contains no client-facing options.

See D12977 for details and examples

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

Reviewed by Brecht Van Lommel
2022-06-27 06:07:55 -07:00
151fc2fcd8 Fix T99171: Crash in mesh vertices positions RNA update function
Solution found by Philipp Oeser (@lichtwerk), thanks.
2022-06-27 08:01:54 -05:00
6a2c42a0d5 Cleanup: remove redundant RNA_struct_property_is_set check
This dates back to [0] from before PROP_SKIP_SAVE existed.
While harmless it's confusing why only one option uses this check.

[0]: ff83a98a07
2022-06-27 21:35:32 +10:00
2b806cb955 Cleanup: DRW: Remove drw_view renaming MACROS 2022-06-27 12:46:47 +02:00
ddc6b86a5b Fix color attribute interpolation with GPU subdivision
Handling of 16-bits compression was missing, which gave values that were
way off.
2022-06-27 12:39:39 +02:00
a617929683 Cleanup: rename misleading/inconsistent GHOST types
Remove mask suffix from:
- GHOST_TButtonMask
- GHOST_TModifierKeyMask
.. neither are used as bit-masks.

Remove 'Grab' from:
- GHOST_kGrabAxisNone
- GHOST_kGrabAxisY
.. matching the existing GHOST_TAxisFlag & GHOST_kAxisX.
2022-06-27 20:36:40 +10:00
3cf6516e7b Cleanup: format 2022-06-27 20:27:34 +10:00
Jason Fielder
9130a60d3d MTLCommandBufferState for coordinating GPU workload submission and render pass coordination.
MTLFrameBuffer has been implemented to support creation of RenderCommandEncoders, along with supporting functionality in the Metal Context.

Optimisation stubs for GPU_framebuffer_bind_ext has been added, which enables specific assignment of attachment load-store ops at the bind level, rather than on a framebuffer object as a whole.

Begin and end frame markers are used to encapsulate frame boundaries for explicit workload submission. This is required for explicit APIs where implicit flushing of work does not occur.

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15027
2022-06-27 11:45:49 +02:00
7b6b740ace Cleanup: spelling in comments 2022-06-27 17:29:57 +10:00
e1c0d18598 Cleanup: remove redundant has key checks 2022-06-27 17:25:07 +10:00
1cf05f17eb UI: define category for the dope-sheet properties panel
Caused warning on startup, missing from [0].

[0]: 57816a6435
2022-06-27 17:25:07 +10:00
10a2c50733 Fix T99178: Console warning using search (F3) in grease pencil draw mode
The preview data was not available in this context and need to be checked to avoid the warning.
2022-06-27 09:13:40 +02:00
3a8fa77c1f GHOST/Wayland: Add a build time option for DBUS, disable by default
Add WITH_GHOST_WAYLAND_DBUS option, so Blender can be built without
DBUS support. Currently it's only used to access the cursor theme.
Without this the "default" cursors are used instead.

Disabling this since it adds an additional dependency for a minor gain
in functionality, with the benefit of removing a library requirement.

There is also a problem where Blender hangs on startup for ~5 seconds
when DBUS isn't running. Eventually it would be good to be able to avoid
this problem without a build option.
2022-06-27 16:49:21 +10:00
2b6c633b63 GHOST/Wayland: set the minimum window size with libdecor 2022-06-27 16:09:23 +10:00
0e88c2fc59 GHOST/Wayland: split pointer/tablet state into separate structs
For Wayland the mouse & tablet are separate devices with their
own location, button-pressed state and focused window.
Split internal state storage so they're separate.

Also track mouse button press/release state without needing focused
windows.
2022-06-27 15:58:07 +10:00
30273b86c7 Fix T98673: Color attribute fill API didn't support editmode 2022-06-26 17:11:03 -07:00
4c3b984b3d Fix T99100: Undo/redo bugs with paint and gravity
You can now push multiple sculpt undo nodes
of different types.  This is necassary to handle
paint tools that have gravity enabled.
2022-06-26 16:15:40 -07:00
77f10fceb2 Cleanup (UV): Remove unused variable do_aspect 2022-06-27 11:13:06 +12:00
81c5b759d6 Fix T99182: Hard code screen_scale for circle drawing in 3D 2022-06-27 10:59:29 +12:00
a646a4b47e Curves: Port string to curves node to the new data-block
Use the conversion implemented in 5606942c63.
2022-06-25 19:09:57 -05:00
be692cc4fe Cleanup: Clang tidy 2022-06-25 19:05:31 -05:00
ef8bb8c0d5 Functions: improve span buffer reuse in procedure execution
This potentially overallocates buffers so that they are usable
for more data types, which allows buffers to be reused more
easily. That leads to fewer separate allocations and improved
cache usage (in one of my test files the number of separate
allocations went down from 1826 to 1555).
2022-06-25 19:41:44 +02:00
22fc0cbd69 BLI: improve support for trivial virtual arrays
This commits reduces the number of function calls through function
pointers in `blender::Any` when the stored type is trivial.

Furthermore, this implements marks some classes as trivial, which
we know are trivial but the compiler does not (the standard currently
says that any class with a virtual destructor is non-trivial). Under some
circumstances we know that final child classes are trivial though.
This allows for some optimizations.

Also see https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1077r0.html.
2022-06-25 19:27:33 +02:00
3237c6dbe8 Fix: crash when converting zero legacy curves
The issue was that the "radius" lookup below fails, because there is no
curve data. Arguably, it should be possible to add attributes even when
there is no data. However, the rules for that are a bit loose currently.
A simple fix is to just not run the conversion code when there is nothing
to convert.
2022-06-25 19:17:08 +02:00
b513c89e84 Functions: avoid using Map for small values
This leads to a 5-10% performance improvement in my benchmark
that runs a procedure many times on a single element.
2022-06-25 18:53:26 +02:00
ba1e97f1c6 Geometry Nodes: Field on Domain Node
As described in T98943, this commit adds a node that can
evaluate a field on a separate domain in a larger field context.
This is potentially useful in many cases, to avoid relying on
a separate capture attribute node, which can make it easier
to build reusable fields that don't need geometry inputs.

Internally, the node just evaluates the input field in the larger
field context and then uses the generic domain interpolation,
so the code is simple. One future optimization might be using
the input selection to only evaluate part of the input field, but
then the selection has to be interpolated as well, and that might
not always be worth it.

Differential Revision: https://developer.blender.org/D15289
2022-06-25 11:23:19 -05:00
5606942c63 Curves: Skip CurveEval in legacy curve conversion
Currently when converting from the legacy curve type to the new type,
which happens during evaluation of every legacy curve object, the
`CurveEval` type is used as an intermediate step. This involves
copying all data twice, and allocating a bunch of temporary arrays.
It's also another use of `CurveEval` that has to be removed before
we remove the type.

The main user difference besides the subtlety described below
will be improved performance.

**Invalid Handles and Types**
One important note is that there are two cases (that I know of)
where handles and handle types can be invalid in the old curve
type. The first is animation, where animated handle positions don't
necessary respect the types. The second is control points with a
single aligned handle that didn't necessarily align with the other.

In master (partially on purpose) the code corrects the first situation
(which caused T98965). But it doesn't correct the second situation.
It's trivial to correct for the second case with this patch (because of the
eager calculation decided on in D14464), but this patch makes the choice
not to correct for //either//.

Though not correcting the handle types puts curves in an invalid state,
it also adds flexibility by allowing that option. Users must understand
that any deformation may correct invalid handles.

Fixes T98965

Differential Revision: https://developer.blender.org/D15290
2022-06-25 11:11:59 -05:00
2967726a29 Cleanup: add missing override 2022-06-25 18:10:22 +02:00
2a8afc142f BLI: improve check for common virtual array implementations
This reduces the amount of code, and improves performance a bit by
doing more with less virtual method calls.

Differential Revision: https://developer.blender.org/D15293
2022-06-25 17:28:49 +02:00
9a0a4b0c0d Geometry Nodes: Add Points Node
This node takes a point count,a vector field, and float field and creates
a pointcloud with n points at the positions indicated in the vector
field with the radii specified in the float field.The node is placed in
the "Point" menu.

Differential Revision: https://developer.blender.org/D13920
Maniphest Task: https://developer.blender.org/T93044
2022-06-25 08:47:31 -05:00
12bde317f4 Fix T98949: Deleting vertex group in geometry nodes affects others
The vertex group indices stored in the weights need to be accounted for
when the vertex group list on the mesh changes.
2022-06-24 16:39:58 -05:00
35d2a22846 Cleanup: Remove unused argument 2022-06-24 16:16:43 -05:00
fca94c5e0d Fix: Incorrect dirty normal tag after mesh translation
Mistake in 54182e4925. The dirty flag was always cleared,
but we only want to clear it after translating a mesh if it normals
were already non-dirty.
2022-06-24 15:48:48 -05:00
f6290cd2a4 Cleanup: Remove unnecessary includes 2022-06-24 15:47:24 -05:00
35da733e6b Fix T99058: geometry nodes ignore if subdivision surface modifier is disabled
It was looking up the last modifier in the stack, ignoring visibility, instead
of mesh->runtime.subsurf_runtime_data set by the modifier evaluation and used by
the drawing code.
2022-06-24 19:57:28 +02:00
9b6e86ace1 Cycles: stop Metal rendering on command buffer error
If there is an error we should stop rendering, instead of finishing with a
wrong render result or reporting a wrong benchmark time.

Ref T96519

Differential Revision: https://developer.blender.org/D15287
2022-06-24 16:51:56 +02:00
Christian Rauch
29755e1df8 GHOST/Wayland: support client-side window decorations
This implements client-side window decorations for moving and resizing
windows and HiDPI support.

This functionality depends on the external project 'libdecor' that is
currently a build option: WITH_GHOST_WAYLAND_LIBDECOR.

Reviewed by: brecht, campbellbarton

Ref D7989
2022-06-25 00:10:39 +10:00
f1d191120f Fix T99130: Spline factor gets messed up if one hair is too short
In the cases where length is zero, we simply equally distribute the
value based on the control point/curve index.

Differential Revision: https://developer.blender.org/D15285
2022-06-24 15:36:31 +02:00
ad8add5f0c Fix T98427: Crash adding quick effects smoke from Python
Manta flow used the `__main__` namespace which it was executed in,
this caused a bug when calculating fluid from Python, which clears
it's `__main__` name-space after execution.
This caused Manta-flows name space to be cleared too.

Resolve this by creating a separate name-space for manta-flow.

Reviewed by: SonnyCampbell_Unity

Ref D15269
2022-06-24 23:28:55 +10:00
2580d2bab5 PyAPI: Expose event.type_prev, value_prev
Before [0] mouse-motion events left the 'event.value' un-changed,
so a mouse-move would be set to PRESS/RELEASE based on previous events.

Support accessing the previous event value directly
to address feedback from T99102.

Note that the previous cursor location is already exposed.

[0]: 52af3b20d4
2022-06-24 23:19:44 +10:00
77eadbede4 Fix T99037: bpy.ops.transform.rotate fails in background mode
This reverts commit c503c5f756,
alternate fix for T82244.

Scripts that run in background mode expected rotation to be usable,
defaulting to the 3D viewport when there is no active windowing data.

Also resolves T88610.
2022-06-24 22:16:47 +10:00
585d81ba2b Workbench: Increase render tests fail threshold for hair.
When running the render test cases on MacOS/Intel the hair render
test fail. Most likely due to the dense geometry and the low
resolution of the test image.

This patch increases the fail threshold so these tests will pass.
Note that I haven't been able to test whether this is also the case
for Linux/Windows. If that is the case we should remove the platform
specific test.
2022-06-24 14:09:15 +02:00
Jeroen Bakker
f748a81f25 Test/Eevee: Increase failure threshold for image tests.
Makes the current test cases pass on NVIDIA 1080Ti/515.
The tests still fail on other platforms (AMD, Intel). Some are actual failures.
Other require platform specific reference images.

Original patch provided by Brecht van Lommel.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15264
2022-06-24 13:45:29 +02:00
7927ac2fbe Fix T99129: Eevee Hair Info Length not working (old particle hair).
When using the old particle hair with the hair info length it wasn't
working with AMD GPUs. The reason was that the drw_curves uniform buffer
wasn't initialized what made the shader select the incorrect length.
2022-06-24 13:03:29 +02:00
79973494ec Cleanup: Fix building warnings on gcc 9.4.0
Solution by Jacques Lucke
2022-06-24 11:25:12 +02:00
e08c932482 Fix T98925: Editor panels are broken
Commit 277fa2f441 added channels region to unintended editors if sequencer was
used in area. This caused issues with some editors having 2 tool regions and
non functioning side panel.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D15253
2022-06-24 10:23:31 +02:00
3323cd9c9a GHOST/Wayland: support for cursor warp with hidden/wrapped grab enabled
As grab already uses it's own virtual coordinates, cursor warping can
be used when grab is enabled.

Currently nothing depends on this however it could be useful in future.
2022-06-24 14:38:17 +10:00
11f38f59e2 Cleanup: remove unused function WM_cursor_compatible_xy 2022-06-24 14:00:36 +10:00
4c4e8cc926 Fix T99021: Walk-mode doesn't work in Wayland
Walk mode implemented it's own grab which relied on WM_cursor_warp
to work (which isn't implemented for wayland).

Resolve this by using WM_cursor_grab_{enable/disable}.

Besides fixing Wayland this removes the need for workarounds:

- Ensure the event received were after the event generated from warping.
- Alternate logic that reset the "center" when using tablets.
- Checking the cursor location was scaled by native-pixels on macOS.

There is a minor change in behavior: on completion the cursor is left
at the location walk-mode began instead of the center of the region.
2022-06-24 13:58:21 +10:00
70648683a2 Cleanup: add C++ compatible WL_ARRAY_FOR_EACH macro 2022-06-24 10:22:46 +10:00
cc09661c4e Cleanup: remove unused cursor struct members in GHOST/Wayland 2022-06-24 09:59:37 +10:00
b3a713fffa Cleanup: use const arguments for GHOST/Wayland 2022-06-24 09:58:27 +10:00
9b5dda3b07 GHOST: use GHOST_ASSERT for non-release builds
GHOST_ASSERT now matches BLI_assert, which is only ignored for release
builds. Otherwise it prints or asserts when WITH_ASSERT_ABORT is enabled.
2022-06-24 09:00:19 +10:00
93de6b912f Docs: correct GHOST_TimerProcPtr time doc-string 2022-06-24 08:46:18 +10:00
4919403c29 Fix outdated pressure/tilt for tablet motions events under GHOST/Wayland
Accumulate tablet data before generating an event using the 'frame'
callback.
2022-06-24 08:19:08 +10:00
41a0411d79 Fix T99083: audio bad in command-line video player (blender -a)
There was a wrong sample size computation in PulseAudioDevice.
The sample format is switched to float32 for the command-line player.
2022-06-23 21:32:34 +02:00
b0fe0e6a30 Cleanup: Make function static 2022-06-23 13:03:31 -05:00
0473462241 Geometry Nodes: Speed up Separate color node in RGB mode
This applies the same optimization as b8bd304bd4 to the separate
color node. I observed about a 50% improvement with 10 million values
when only extracting one channel-- from about 17ms to 11ms.
2022-06-23 12:34:31 -05:00
a5ff46e0fc Cleanup: make format 2022-06-23 19:28:39 +02:00
dc64673f6e Fix T97691: undefined behavior sanitizer warning for alignment in RNA functions
Thanks Loren Osborn for investigating this and proposing solutions.

Ref D14798
2022-06-23 19:22:50 +02:00
Max Edge
56435b3268 Fix T94621: Missing selection indication for virtual node sockets
A small regression as a result of adding a custom outline to the empty
virtual socket, which ended up overriding the colors when selected with
Shift+LMB.

Differential Revision: https://developer.blender.org/D15103
2022-06-23 12:22:23 -05:00
Angel Bueno
792bf82f11 Spreadsheet: Support operations for filtering colors
Support choosing an operation when filtering colors,
like the other types.

Differential Revision: https://developer.blender.org/D15191
2022-06-23 12:16:18 -05:00
9b775ebad7 Cleanup: Remove unused array in vertex paint code
Unused since 4f616c93f7
2022-06-23 12:10:12 -05:00
6dde88c536 Vertex paint mode tried to do a "fast update" by trying to avoid tagging
the mesh ID for a full update. The conditions it uses are troublesome:
 1. There must be an evaluated mesh
 2. The evaluated mesh's active byte color layer must equal the original's

This logic doesn't make sense for a few reasons. First of all, the
`mloopcol` pointer doesn't make sense in the context of color
attributes (rather than the old vertex colors), since it only points
to byte color attribute on face corners. Second, just because the
layer pointers are equal doesn't mean something doesn't depend
on the attribute's values.

I think the best solution currently is to remove this "fast update"
case and instead work on optimizing the general case.

Also, T95842 suggests removing these pointers, and this is one
of the last remaining uses of `Mesh.mloopcol`.

Differential Revision: https://developer.blender.org/D15275
2022-06-23 12:05:48 -05:00
54182e4925 Mesh: Add an explicit "positions changed" function
We store various lazily calculated caches on meshes, some of which
depend on the vertex positions staying the same. The current API to
invalidate these caches is a bit confusing. With an explicit set of
functions modeled after the functions in `BKE_node_tree_update.h`,
it becomes clear which function to call. This may become more
important if more lazy caches are added in the future.

Differential Revision: https://developer.blender.org/D14760
2022-06-23 12:00:25 -05:00
3e5a4d1412 Geometry Nodes: Optimize selection for virtual array input
This makes calculation of selected indices slightly faster when the
input is a virtual array (the direct output of various nodes like
Face Area, etc). The utility can be helpful for other areas that
need to find selected indices besides field evaluation.

With the face area node used as a selection with 4 million faces,
the speedup is 3.51 ms to 3.39 ms, just a slight speedup.

Differential Revision: https://developer.blender.org/D15127
2022-06-23 11:51:33 -05:00
633c2f07da Cyles: switch primitive.h inline hints to forceinline
This change helps decrease Intel GPU binaries compile time by 5-10
minutes without impacting other backends.

Reviewed By: sergey, brecht

Differential Revision: http://developer.blender.org/D15273
2022-06-23 18:36:48 +02:00
2eba15d3e8 Fix T98975: Broken vertex paint mode operators
All of the operators in vertex paint mode didn't work properly with
the new color attribute system. They only worked on byte color type
attributes on the face corner domain.

Since there are four possible combinations of domains and types now,
it mostly ended up being simpler to convert the code to C++ and use
the geometry component API for retrieving attributes, interpolating
between domains, etc. The code changes ended up being fairly large,
but the result should be simpler now.

Differential Revision: https://developer.blender.org/D15261
2022-06-23 11:33:11 -05:00
5c6ffd07e0 Fix T99110: Crash after running view_all operator in VSE
Crash caused by NULL dereference, when `Editing` is not initialized.

Check if data is initialized in poll function.
2022-06-23 18:20:02 +02:00
d1ea39aac7 Fix T99091: Freeze when changing strip source with thumbnails enabled
When input file is changed, `orig_height` and `orig_width` fields are
reset, which causes thumbnail dimensions to be incorrectly calculated.

Only draw thumbnails if both mentioned fields are non 0.
2022-06-23 17:49:26 +02:00
1c83354c63 Fix T99028: crash deleting file output node with color management override
One case of copying image formats was not properly using BKE_image_format_copy.
To fix this for existing .blend file we need to do versioning, ensuring the curve
mapping is properly copied.
2022-06-23 16:35:11 +02:00
Andrii Symkin
c2a2f3553a Cycles: unify math functions names
This patch unifies the names of math functions for different data types and uses
overloading instead. The goal is to make it possible to swap out all the float3
variables containing RGB data with something else, with as few as possible
changes to the code. It's a requirement for future spectral rendering patches.

Differential Revision: https://developer.blender.org/D15276
2022-06-23 15:02:53 +02:00
b8403b065e Fix T99027: Touch typing in text fields results in dropped key presses
Fix by always testing unhandled double-click events as press events,
irrespective of the previous event type.

**Details**

Handling double-click events only ran when the previously pressed-key
matched the current pressed-key.

Originally when double-click support was added the previous type was
compared (ignoring it's press/release value) and while not necessary
it was harmless as it matched the check for double-click events being
generated.

As of [0] the logic for click/drag detection changed to ignore release
events as release this could interrupt dragging.
This made it possible to generate double-click events that failed the
`event->prev_press_type == event->type` comparison.
In these cases it was possible to generate double-click
events that would not fall-back to a 'press' value when unhandled.

[0]: 102644cb8c
2022-06-23 22:25:13 +10:00
e63799e791 Cleanup: fix typo that deactivated clang-format in rna_brush.c 2022-06-23 13:10:26 +02:00
b830263186 Fix T98871: Drivers not updated when joining an armature
If the some driver had been flagged as "invalid", the flag would not be
cleared when joining armatures which could lead to now valid drivers
still being flagged as invalid.

Now we clear this invalid flag on all drivers to force a recheck after
joining the armatures.
2022-06-23 11:47:37 +02:00
Colin Basnett
091100bfd7 Animation: Add function to remove all FCurves from an Action
Add a `BKE_action_fcurves_clear(action)` function, which removes all the
Action's FCurves, and expose it as `ActionFCurves.clear()` in RNA.

This is more ergonomic than calling `remove` on f-curves until the list
is empty.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14660
2022-06-23 11:45:53 +02:00
Colin Basnett
2ae4397ec9 Armature: Add poll message explaining bone groups need pose mode
Add a poll message to the bone group operators, to explain they only
work in pose mode. Before, the buttons would be greyed out with no
explanation.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15119
2022-06-23 11:37:23 +02:00
Colin Basnett
57816a6435 Dopesheet: Add Custom Properties panel
Adds a custom property panel for the active `Action` to the Dopesheet
editor. There was previously no way to edit these properties outside of
the Python API.

This panel will show up when
`context.active_object.animation_data.action` is set.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14646
2022-06-23 11:12:42 +02:00
Michael Jones
d8e9647ae2 Cycles: Add diagnostic tracing of MTLLibrary compilation time
Reviewed By: sergey

Differential Revision: https://developer.blender.org/D15268
2022-06-23 10:06:20 +01:00
d20bad914e Fix key repeat continuing after a window loses focus for GHOST/Wayland
Also remove NULL checks in keyboard enter/leave handlers,
as they didn't serve any purpose.
2022-06-23 15:38:43 +10:00
e4f51b3a6e LineArt: Cleanup minor warnings from variable type changes. 2022-06-23 13:22:56 +08:00
743a027862 Fix key repeat behavior for GHOST/Wayland
- Respect modifier keys (Shift press/release didn't change the case).

- Changing modifiers resets the timer instead of canceling key-repeat.

- Releasing keys (besides the key being repeated) resets the timer
  instead of canceling key repeat.

This makes key-repeat behave the same way as GTK & WIN32 text input.
2022-06-23 15:14:18 +10:00
1160a3a3f8 Cleanup: Clang tidy
Mainly duplicate includes and else after return.
2022-06-22 18:58:25 -05:00
d2a3b99ff7 Cleanup: Use const arguments
Also use Curves as an argument instead of Object,
since it's more specific to this situation.
2022-06-22 16:58:22 -05:00
Michael Jones
532b33973b Cycles: Tidy of KernelData patchup code
Reviewed By: sergey

Differential Revision: https://developer.blender.org/D15267
2022-06-22 22:38:00 +01:00
Michael Jones
328a911379 Cycles: Distinguish Apple GPUs by core count
This patch suffixes Apple GPU device names with `(GPU - # cores)` so that variant GPUs with the same chipset can be distinguished. Currently benchmark scores for these M1 family GPUs are being incorrectly merged:

- M1: 7 or 8 cores
- M1 Pro: 14 or 16 cores
- M1 Max: 24 or 32 cores
- M1 Ultra: 48 or 64 cores

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D15257
2022-06-22 22:32:56 +01:00
5c0d18f682 Cleanup: remove unused sculpt texture cache generation
This has not been used since 5505697ac in 2010.
2022-06-22 19:52:55 +02:00
Ramil Roosileht
b6a76243cd D14974: Tip roundness - match square and round brush radius
Oneliner for T97961.  Square sculpt brushes no longer fit
inside the radius circle, they now use the radius for
the square size.

{F13082514}

Note: original patch was modified to scale PBVH
      search radius to avoid artifacts.

Differential Revision: https://developer.blender.org/D14974
Reviewed By: Joseph Eagar & Julien Kaspar
Ref: D14974
2022-06-22 10:03:27 -07:00
1cde1562e8 Cleanup: simplify macOS make deps instructions 2022-06-22 18:17:47 +02:00
Patrick Huang
9f4ec73101 Fix T97675: slow zoom in node editor with Continue zoom method
Speed increased by 10x, making it visually similar to other editors.

Differential Revision: https://developer.blender.org/D15209
2022-06-22 16:56:20 +02:00
6c3965c027 Fix T98773: GPU Subdivision breaks auto selection in UV edit mode
When GPU subdivision is used, and the modifier is not set to be applied
on the cage, UV selection is not synced with the face selection in the
viewport.

This happens because the extraction, despite being in edit mode, is set
to `MESH` instead of `BMESH` (or `MAPPED` in some cases) like for CPU
subdivision, and since the mesh is not always synchrnised with the BMesh
the edit mode flags are not always updated.

With GPU subdivision, when creating the `MeshRenderData`, the condition
`has_mdata && do_final && editmesh_eval_final != editmesh_eval_cage` is
true which forces the `MESH` extraction. Following comment in D14485,
this replace the `has_mdata` in the condition with `use_mapped` which
solves the issue.

Differential Revision: https://developer.blender.org/D15248
2022-06-22 16:45:20 +02:00
cebc5531e9 Fix T98956: Crash removing some builtin attributes
For example, the "id" attribute is stored as a named attribute.
If it doesn't exist already, `layer_index` was uninitialized, causing
issues with `CustomData_free_layer`. The fix is to use the generic
function to free a named layer in that case. Eventually the other
case will go away as T95965 is finished.
2022-06-22 09:06:29 -05:00
785931fc3c Fix: Memory leak writing to builtin attribute with wrong type
The store named attribute node creates a new buffer to evaluate
the field into. When creating the attribute with that buffer fails,
if must be freed.
2022-06-22 09:03:27 -05:00
a3d0f77ded Cleanup: Remove unused function arguments
Solves the corresponding compiler warning.
2022-06-22 10:55:08 +02:00
a7b91fc8bc Cleanup: clang-format 2022-06-22 10:55:08 +02:00
31d80ddeaa Revert "LibOverride: Handle dependencies in both directions in partial override cases."
This reverts commit f0b4aa5d59.

This commit was making files to get bigger and bigger every time they
were saved and re-opened.

In the orphaned data in the outliner new collections would show up
there, even after continuously purging it. This would lead to a massive
file which get also very slow.

This problem will fix itself after a few re-open/re-saves of the files.
For anyone also experimenting this you can fix this faster by purging
the unused data multiple times in the file.

Example of file from the Project Heist (rev. 1014):
heist/pro/shots/010_opening/010_0050/010_0050.anim.blend
2022-06-22 10:48:59 +02:00
Simon Lenz
df2ab4e758 Mask Editor: Add toggle for mask spline drawing
Adds an overlay option to show/hide the spline points & lines of masks in the Mask Editor.

It also moves the "smooth" option up (its position left of the selection dropdown was missleading).

{F11847272}

This emerged from a discussion in https://developer.blender.org/D12776

Differential Revision: https://developer.blender.org/D13314
2022-06-22 10:45:18 +02:00
Ramil Roosileht
5946ea938a D14975: Voxel Remesh Size Edit - Constant Size by default
This patch makes constant size a default for size edit operator of voxel remesh.
In turn, pressing CTRL now enables relative scale, the old default.

Patch also changes workspace status text entry with new additions. Note that it is a simple text and not an array of keymaps (for that further changes are needed)

{F13082567}

Reviewed By: Julien Kaspar & Joseph Eagar
Differential Revision: https://developer.blender.org/D14975
Ref D14975
2022-06-22 01:36:13 -07:00
f4d8382c86 Rigid body physics: Move effector force update into substep loop.
The substep loop for rigid bodies causes unequal effects of force fields depedending on the substep setting, larger
substep counts cause a diminishing effect of force fields.
This is because the force to apply on a body is reset in Bullet after each step and needs to be recomputed. Without this
the body will just coast with constant velocity after the first substep. Since the per-step impulse with larger substep
counts is smaller, the effect is that more substeps cause a smaller total impulse.

The fix is to move external force calculation into the substep loop and update forces for each substep.

Note that this may be considered a breaking change, because the breaking commit rB1aa54d4921c2 has been in master for
a long time and after this fix force fields will generally have a much larger effect on rigid bodies (10x for the
default setting of 10 substeps).

Differential Revision: https://developer.blender.org/D15173
2022-06-22 06:37:45 +01:00
75f0aaab3d Cleanup: remove redundant GPU headers 2022-06-22 14:59:42 +10:00
b8289eb1b9 Cleanup: replace BLF defines with enum, formatting 2022-06-22 14:50:22 +10:00
8fab580949 Fix T99078: Crash closing the file selector in Wayland
Ensure wayland handlers run that clear the window immediately after
the window has been removed so dangling pointers to the window
aren't left set.
2022-06-22 13:11:32 +10:00
c08fda3a6b Cleanup: Grammar in comments 2022-06-21 15:47:25 -05:00
256cb68d33 Cleanup: Remove unused argument 2022-06-21 14:17:24 -05:00
d901f8b75b Fix T98960: Baking to active color attribute uses wrong layer
Baking assumed that color attributes could only have two configurations:
float color data type on vertices, or byte color type on face corners.
In reality the options can be combined to make four total options.
This commit handles the four cases explicitly with a somewhat
more scaleable approach (though this should really be C++ code).

This commit also changes some related error messages, tooltips,
and an enum name, in order to make the functionality more obvious.

Differential Revision: https://developer.blender.org/D15244
2022-06-21 14:15:18 -05:00
7140016838 GPencil: Move New Layer option to menu top
The new layer option must be the first in the menu.

Differential Revision: https://developer.blender.org/D15255
2022-06-21 17:04:30 +02:00
d2f47017b9 Fix crash editing anisotropic filter preference from background mode 2022-06-21 16:00:56 +02:00
9622dace3e Cleanup: removed unused Blender Internal bump/normal mapping texture code
The TexResult.nor output does not appear to be used anywhere.
2022-06-21 16:00:56 +02:00
Colin Basnett
d90b320444 Fix T97533: Extrapolation of NLA strips outside current view are not rendered
Do a more thorough search for strips that are not visible themselves,
but still influence the viewed time range.

The problem before was that tracks not immediately visible would not be
drawn at all. The strategy for fixing this was to simply include strips
that are visible only because of their extrapolation mode.

To do this, there is now a new function `get_visible_nla_strips` which
gives a first and last `NlaTrack` that needs to  be drawn.

Tagging along with this is the removal of the strip index indicator from
the name on meta tracks. Because of the new structure of the code, it
would incur a performance penalty to restore the previous behavior
(requiring a linear search for the index). Since this number is of
virtually no utility to the user anyways (it has the look & feel of
developer debugging information), this is something I think we can
safely remove without regret.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14738
2022-06-21 15:40:45 +02:00
7f3af2aaee NLA: when searching for active track/strip, shortcut when none is active
In the `update_active_track()` function, add a shortcut that just sets
`NULL`, instead of searching for `NULL` pointers. Should give a tiny
speedup.
2022-06-21 15:28:11 +02:00
15bc3d260d Fix 2 for T98700: Crash when recursively nesting NLA meta strips
When searching for the active NLA strip, avoid overwriting the found strip
pointer with NULL if it was already found in a previous iteration.

The active strip is searched for while looping over the NLA tracks. If the
active strip was found on a previous track, and not on the current track,
this would effectively set `actstrip = NULL`. This is now avoided.

Another benefit is that the search for the active strip is stopped as soon
as it's found, which should increase performance a tiny bit.
2022-06-21 15:28:11 +02:00
d373206c3f NLA: update comment to reflect the current implementation
No functional changes.
2022-06-21 15:28:11 +02:00
3bb34fb7ee NLA: add BLI_assert_msg() to check for assumption
`find_active_strip_from_listbase()` expects two lists of strips with an
equal number of items. This is now not only documented, but also checked
for in an assertion.
2022-06-21 15:22:52 +02:00
1778 changed files with 78775 additions and 43242 deletions

View File

@@ -265,6 +265,7 @@ ForEachMacros:
- SET_SLOT_PROBING_BEGIN
- MAP_SLOT_PROBING_BEGIN
- VECTOR_SET_SLOT_PROBING_BEGIN
- WL_ARRAY_FOR_EACH
StatementMacros:
- PyObject_HEAD

View File

@@ -222,6 +222,17 @@ if(UNIX AND NOT (APPLE OR HAIKU))
option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF)
mark_as_advanced(WITH_GHOST_WAYLAND)
if (WITH_GHOST_WAYLAND)
option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" OFF)
mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR)
option(WITH_GHOST_WAYLAND_DBUS "Optionally build with DBUS support (used for Cursor themes). May hang on startup systems where DBUS is not used." OFF)
mark_as_advanced(WITH_GHOST_WAYLAND_DBUS)
option(WITH_GHOST_WAYLAND_DYNLOAD "Enable runtime dynamic WAYLAND libraries loading" OFF)
mark_as_advanced(WITH_GHOST_WAYLAND_DYNLOAD)
endif()
endif()
if(WITH_GHOST_X11)
@@ -255,19 +266,11 @@ if(WITH_GHOST_X11)
endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
option(WITH_SYSTEM_FREETYPE "Use the freetype library provided by the operating system" OFF)
else()
# not an option for other OS's
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
set(WITH_SYSTEM_FREETYPE OFF)
endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
else()
set(WITH_SYSTEM_FREETYPE OFF)
set(WITH_SYSTEM_EIGEN3 OFF)
endif()
@@ -444,7 +447,7 @@ endif()
if(NOT APPLE)
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
set(CYCLES_HIP_BINARIES_ARCH gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 CACHE STRING "AMD HIP architectures to build binaries for")
set(CYCLES_HIP_BINARIES_ARCH gfx900 gfx906 gfx90c gfx902 gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 CACHE STRING "AMD HIP architectures to build binaries for")
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
endif()
@@ -454,6 +457,21 @@ if(APPLE)
option(WITH_CYCLES_DEVICE_METAL "Enable Cycles Apple Metal compute support" ON)
endif()
# oneAPI
if(NOT APPLE)
option(WITH_CYCLES_DEVICE_ONEAPI "Enable Cycles oneAPI compute support" OFF)
option(WITH_CYCLES_ONEAPI_BINARIES "Enable Ahead-Of-Time compilation for Cycles oneAPI device" OFF)
option(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED "Enable use of SYCL host (CPU) device execution by oneAPI implementation. This option is for debugging purposes and impacts GPU execution." OFF)
# https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html
SET (CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU architectures to build binaries for")
SET (CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI targets to build AOT binaries for")
mark_as_advanced(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED)
mark_as_advanced(CYCLES_ONEAPI_SPIR64_GEN_DEVICES)
mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGETS)
endif()
# Draw Manager
option(WITH_DRAW_DEBUG "Add extra debug capabilities to Draw Manager" OFF)
mark_as_advanced(WITH_DRAW_DEBUG)
@@ -518,20 +536,48 @@ endif()
# OpenGL
# Experimental EGL option.
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, GLX or WGL)" OFF)
mark_as_advanced(WITH_GL_EGL)
if(WITH_GHOST_WAYLAND)
# Wayland can only use EGL to create OpenGL contexts, not GLX.
set(WITH_GL_EGL ON)
endif()
if(UNIX AND NOT APPLE)
if(WITH_GL_EGL)
# GLEW can only be built with either GLX or EGL support. Most binary distributions are
# built with GLX support and we have no automated way to detect this. So always build
# GLEW from source to be sure it has EGL support.
set(WITH_SYSTEM_GLEW OFF)
else()
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
endif()
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
else()
# System GLEW and GLES not an option on other platforms.
set(WITH_SYSTEM_GLEW OFF)
set(WITH_SYSTEM_GLES OFF)
endif()
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
option(WITH_GPU_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF)
option(WITH_GPU_BUILDTIME_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF)
mark_as_advanced(
WITH_OPENGL
WITH_GLEW_ES
WITH_GL_EGL
WITH_GL_PROFILE_ES20
WITH_GPU_SHADER_BUILDER
WITH_GPU_BUILDTIME_SHADER_BUILDER
)
if(WITH_HEADLESS)
set(WITH_OPENGL OFF)
endif()
# Metal
if (APPLE)

View File

@@ -29,10 +29,12 @@ cmake_minimum_required(VERSION 3.5)
include(ExternalProject)
include(cmake/check_software.cmake)
include(cmake/versions.cmake)
include(cmake/options.cmake)
# versions.cmake needs to be included after options.cmake due to the BLENDER_PLATFORM_ARM variable being needed.
include(cmake/versions.cmake)
include(cmake/boost_build_options.cmake)
include(cmake/download.cmake)
include(cmake/macros.cmake)
if(ENABLE_MINGW64)
include(cmake/setup_mingw64.cmake)
@@ -96,6 +98,15 @@ include(cmake/fmt.cmake)
include(cmake/robinmap.cmake)
if(NOT APPLE)
include(cmake/xr_openxr.cmake)
if(NOT WIN32 OR BUILD_MODE STREQUAL Release)
include(cmake/dpcpp.cmake)
include(cmake/dpcpp_deps.cmake)
endif()
if(NOT WIN32)
include(cmake/igc.cmake)
include(cmake/gmmlib.cmake)
include(cmake/ocloc.cmake)
endif()
endif()
# OpenColorIO and dependencies.
@@ -128,6 +139,7 @@ if(NOT WIN32 OR ENABLE_MINGW64)
include(cmake/vpx.cmake)
include(cmake/x264.cmake)
include(cmake/xvidcore.cmake)
include(cmake/aom.cmake)
include(cmake/ffmpeg.cmake)
include(cmake/fftw.cmake)
include(cmake/sndfile.cmake)

View File

@@ -42,4 +42,5 @@ endif()
add_dependencies(
external_alembic
external_openexr
external_imath
)

View File

@@ -0,0 +1,45 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
# The default generator on windows is msbuild, which we do not
# want to use for this dep, as needs to build with mingw
set(AOM_GENERATOR "Ninja")
# The default flags are full of MSVC options given this will be
# building with mingw, it'll have an unhappy time with that and
# we need to clear them out.
set(AOM_CMAKE_FLAGS )
# CMake will correctly identify phreads being available, however
# we do not want to use them, as that gains a dependency on
# libpthreadswin.dll which we do not want. when pthreads is not
# available oam will use a pthreads emulation layer using win32 threads
set(AOM_EXTRA_ARGS_WIN32 -DCMAKE_HAVE_PTHREAD_H=OFF)
else()
set(AOM_GENERATOR "Unix Makefiles")
set(AOM_CMAKE_FLAGS ${DEFAULT_CMAKE_FLAGS})
endif()
set(AOM_EXTRA_ARGS
-DENABLE_TESTDATA=OFF
-DENABLE_TESTS=OFF
-DENABLE_TOOLS=OFF
-DENABLE_EXAMPLES=OFF
${AOM_EXTRA_ARGS_WIN32}
)
# This is slightly different from all other deps in the way that
# aom uses cmake as a build system, but still needs the environment setup
# to include perl so we manually setup the environment and call
# cmake directly for the configure, build and install commands.
ExternalProject_Add(external_aom
URL file://${PACKAGE_DIR}/${AOM_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${AOM_HASH_TYPE}=${AOM_HASH}
PREFIX ${BUILD_DIR}/aom
CONFIGURE_COMMAND ${CONFIGURE_ENV} &&
cd ${BUILD_DIR}/aom/src/external_aom-build/ &&
${CMAKE_COMMAND} -G "${AOM_GENERATOR}" -DCMAKE_INSTALL_PREFIX=${LIBDIR}/aom ${AOM_CMAKE_FLAGS} ${AOM_EXTRA_ARGS} ${BUILD_DIR}/aom/src/external_aom/
BUILD_COMMAND ${CMAKE_COMMAND} --build .
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install
INSTALL_DIR ${LIBDIR}/aom
)

View File

@@ -56,10 +56,7 @@ if(UNIX)
"On Debian and Ubuntu:\n"
" apt install autoconf automake libtool yasm tcl ninja-build meson python3-mako\n"
"\n"
"On macOS Intel (with homebrew):\n"
" brew install autoconf automake bison libtool pkg-config yasm\n"
"\n"
"On macOS ARM (with homebrew):\n"
"On macOS (with homebrew):\n"
" brew install autoconf automake bison flex libtool pkg-config yasm\n"
"\n"
"Other platforms:\n"

View File

@@ -101,3 +101,19 @@ download_source(ROBINMAP)
download_source(IMATH)
download_source(PYSTRING)
download_source(LEVEL_ZERO)
download_source(DPCPP)
download_source(VCINTRINSICS)
download_source(OPENCLHEADERS)
download_source(ICDLOADER)
download_source(MP11)
download_source(SPIRV_HEADERS)
download_source(IGC)
download_source(IGC_LLVM)
download_source(IGC_OPENCL_CLANG)
download_source(IGC_VCINTRINSICS)
download_source(IGC_SPIRV_HEADERS)
download_source(IGC_SPIRV_TOOLS)
download_source(IGC_SPIRV_TRANSLATOR)
download_source(GMMLIB)
download_source(OCLOC)
download_source(AOM)

View File

@@ -0,0 +1,109 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
set(LLVM_GENERATOR "Ninja")
else()
set(LLVM_GENERATOR "Unix Makefiles")
endif()
set(DPCPP_CONFIGURE_ARGS
# When external deps dpcpp needs are not found it will automatically
# download the during the configure stage using FetchContent. Given
# we need to keep an archive of all source used during build for compliance
# reasons it CANNOT download anything we do not know about. By setting
# this property to ON, all downloads are disabled, and we will have to
# provide the missing deps some other way, a build error beats a compliance
# violation
--cmake-opt FETCHCONTENT_FULLY_DISCONNECTED=ON
)
set(DPCPP_SOURCE_ROOT ${BUILD_DIR}/dpcpp/src/external_dpcpp/)
set(DPCPP_EXTRA_ARGS
# When external deps dpcpp needs are not found it will automatically
# download the during the configure stage using FetchContent. Given
# we need to keep an archive of all source used during build for compliance
# reasons it CANNOT download anything we do not know about. By setting
# this property to ON, all downloads are disabled, and we will have to
# provide the missing deps some other way, a build or configure error
# beats a compliance violation
-DFETCHCONTENT_FULLY_DISCONNECTED=ON
-DLLVMGenXIntrinsics_SOURCE_DIR=${BUILD_DIR}/vcintrinsics/src/external_vcintrinsics/
-DOpenCL_HEADERS=file://${PACKAGE_DIR}/${OPENCLHEADERS_FILE}
-DOpenCL_LIBRARY_SRC=file://${PACKAGE_DIR}/${ICDLOADER_FILE}
-DBOOST_MP11_SOURCE_DIR=${BUILD_DIR}/mp11/src/external_mp11/
-DLEVEL_ZERO_LIBRARY=${LIBDIR}/level-zero/lib/${LIBPREFIX}ze_loader${SHAREDLIBEXT}
-DLEVEL_ZERO_INCLUDE_DIR=${LIBDIR}/level-zero/include
-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${BUILD_DIR}/spirvheaders/src/external_spirvheaders/
# Below here is copied from an invocation of buildbot/config.py
-DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_EXTERNAL_PROJECTS=sycl^^llvm-spirv^^opencl^^libdevice^^xpti^^xptifw
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/sycl
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/llvm-spirv
-DLLVM_EXTERNAL_XPTI_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/xpti
-DXPTI_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/xpti
-DLLVM_EXTERNAL_XPTIFW_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/xptifw
-DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR=${DPCPP_SOURCE_ROOT}/libdevice
-DLLVM_ENABLE_PROJECTS=clang^^sycl^^llvm-spirv^^opencl^^libdevice^^xpti^^xptifw
-DLIBCLC_TARGETS_TO_BUILD=
-DLIBCLC_GENERATE_REMANGLED_VARIANTS=OFF
-DSYCL_BUILD_PI_HIP_PLATFORM=AMD
-DLLVM_BUILD_TOOLS=ON
-DSYCL_ENABLE_WERROR=OFF
-DSYCL_INCLUDE_TESTS=ON
-DLLVM_ENABLE_DOXYGEN=OFF
-DLLVM_ENABLE_SPHINX=OFF
-DBUILD_SHARED_LIBS=OFF
-DSYCL_ENABLE_XPTI_TRACING=ON
-DLLVM_ENABLE_LLD=OFF
-DXPTI_ENABLE_WERROR=OFF
-DSYCL_CLANG_EXTRA_FLAGS=
-DSYCL_ENABLE_PLUGINS=level_zero
-DCMAKE_INSTALL_RPATH=\$ORIGIN
-DPython3_ROOT_DIR=${LIBDIR}/python/
-DPython3_EXECUTABLE=${PYTHON_BINARY}
-DPYTHON_EXECUTABLE=${PYTHON_BINARY}
-DLLDB_ENABLE_CURSES=OFF
-DLLVM_ENABLE_TERMINFO=OFF
)
if(WIN32)
list(APPEND DPCPP_EXTRA_ARGS -DPython3_FIND_REGISTRY=NEVER)
endif()
ExternalProject_Add(external_dpcpp
URL file://${PACKAGE_DIR}/${DPCPP_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${DPCPP_HASH_TYPE}=${DPCPP_HASH}
PREFIX ${BUILD_DIR}/dpcpp
CMAKE_GENERATOR ${LLVM_GENERATOR}
SOURCE_SUBDIR llvm
LIST_SEPARATOR ^^
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp ${DEFAULT_CMAKE_FLAGS} ${DPCPP_EXTRA_ARGS}
#CONFIGURE_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/configure.py ${DPCPP_CONFIGURE_ARGS}
#BUILD_COMMAND echo "." #${PYTHON_BINARY} ${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/compile.py
INSTALL_COMMAND ${CMAKE_COMMAND} --build . -- deploy-sycl-toolchain
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/dpcpp/src/external_dpcpp < ${PATCH_DIR}/dpcpp.diff
INSTALL_DIR ${LIBDIR}/dpcpp
)
add_dependencies(
external_dpcpp
external_python
external_python_site_packages
external_vcintrinsics
external_openclheaders
external_icdloader
external_mp11
external_level-zero
external_spirvheaders
)
if(BUILD_MODE STREQUAL Release AND WIN32)
ExternalProject_Add_Step(external_dpcpp after_install
COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/dpcpp/bin/clang-cl.exe
COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/dpcpp/bin/clang-cpp.exe
COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/dpcpp/bin/clang.exe
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/dpcpp ${HARVEST_TARGET}/dpcpp
)
endif()

View File

@@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# These are build time requirements for dpcpp
# We only have to unpack these dpcpp will build
# them.
ExternalProject_Add(external_vcintrinsics
URL file://${PACKAGE_DIR}/${VCINTRINSICS_FILE}
URL_HASH ${VCINTRINSICS_HASH_TYPE}=${VCINTRINSICS_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/vcintrinsics
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)
# opencl headers do not have to be unpacked, dpcpp will do it
# but it wouldn't hurt to do it anyway as an opertunity to validate
# the hash is correct.
ExternalProject_Add(external_openclheaders
URL file://${PACKAGE_DIR}/${OPENCLHEADERS_FILE}
URL_HASH ${OPENCLHEADERS_HASH_TYPE}=${OPENCLHEADERS_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/openclheaders
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)
# icdloader does not have to be unpacked, dpcpp will do it
# but it wouldn't hurt to do it anyway as an opertunity to validate
# the hash is correct.
ExternalProject_Add(external_icdloader
URL file://${PACKAGE_DIR}/${ICDLOADER_FILE}
URL_HASH ${ICDLOADER_HASH_TYPE}=${ICDLOADER_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/icdloader
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)
ExternalProject_Add(external_mp11
URL file://${PACKAGE_DIR}/${MP11_FILE}
URL_HASH ${MP11_HASH_TYPE}=${MP11_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/mp11
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)
ExternalProject_Add(external_spirvheaders
URL file://${PACKAGE_DIR}/${SPIRV_HEADERS_FILE}
URL_HASH ${SPIRV_HEADERS_HASH_TYPE}=${SPIRV_HEADERS_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/spirvheaders
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)

View File

@@ -10,18 +10,12 @@ set(EMBREE_EXTRA_ARGS
-DEMBREE_RAY_MASK=ON
-DEMBREE_FILTER_FUNCTION=ON
-DEMBREE_BACKFACE_CULLING=OFF
-DEMBREE_MAX_ISA=AVX2
-DEMBREE_TASKING_SYSTEM=TBB
-DEMBREE_TBB_ROOT=${LIBDIR}/tbb
-DTBB_ROOT=${LIBDIR}/tbb
-DTBB_STATIC_LIB=${TBB_STATIC_LIBRARY}
)
if(BLENDER_PLATFORM_ARM)
set(EMBREE_EXTRA_ARGS
${EMBREE_EXTRA_ARGS}
-DEMBREE_MAX_ISA=NEON)
else()
if (NOT BLENDER_PLATFORM_ARM)
set(EMBREE_EXTRA_ARGS
${EMBREE_EXTRA_ARGS}
-DEMBREE_MAX_ISA=AVX2)
@@ -30,23 +24,10 @@ endif()
if(TBB_STATIC_LIBRARY)
set(EMBREE_EXTRA_ARGS
${EMBREE_EXTRA_ARGS}
-DEMBREE_TBB_LIBRARY_NAME=tbb_static
-DEMBREE_TBBMALLOC_LIBRARY_NAME=tbbmalloc_static
-DEMBREE_TBB_COMPONENT=tbb_static
)
endif()
if(WIN32)
set(EMBREE_BUILD_DIR ${BUILD_MODE}/)
if(BUILD_MODE STREQUAL Debug)
list(APPEND EMBREE_EXTRA_ARGS
-DEMBREE_TBBMALLOC_LIBRARY_NAME=tbbmalloc_debug
-DEMBREE_TBB_LIBRARY_NAME=tbb_debug
)
endif()
else()
set(EMBREE_BUILD_DIR)
endif()
ExternalProject_Add(external_embree
URL file://${PACKAGE_DIR}/${EMBREE_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}

View File

@@ -1,9 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/opus/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/zlib/include")
set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/opus/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/zlib/lib")
set(FFMPEG_CFLAGS "-I${mingw_LIBDIR}/lame/include -I${mingw_LIBDIR}/openjpeg/include/ -I${mingw_LIBDIR}/ogg/include -I${mingw_LIBDIR}/vorbis/include -I${mingw_LIBDIR}/theora/include -I${mingw_LIBDIR}/opus/include -I${mingw_LIBDIR}/vpx/include -I${mingw_LIBDIR}/x264/include -I${mingw_LIBDIR}/xvidcore/include -I${mingw_LIBDIR}/zlib/include -I${mingw_LIBDIR}/aom/include")
set(FFMPEG_LDFLAGS "-L${mingw_LIBDIR}/lame/lib -L${mingw_LIBDIR}/openjpeg/lib -L${mingw_LIBDIR}/ogg/lib -L${mingw_LIBDIR}/vorbis/lib -L${mingw_LIBDIR}/theora/lib -L${mingw_LIBDIR}/opus/lib -L${mingw_LIBDIR}/vpx/lib -L${mingw_LIBDIR}/x264/lib -L${mingw_LIBDIR}/xvidcore/lib -L${mingw_LIBDIR}/zlib/lib -L${mingw_LIBDIR}/aom/lib")
set(FFMPEG_EXTRA_FLAGS --pkg-config-flags=--static --extra-cflags=${FFMPEG_CFLAGS} --extra-ldflags=${FFMPEG_LDFLAGS})
set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}:${mingw_LIBDIR}/vpx/lib/pkgconfig:${mingw_LIBDIR}/theora/lib/pkgconfig:${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:)
set(FFMPEG_ENV PKG_CONFIG_PATH=${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/x264/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}:${mingw_LIBDIR}/vpx/lib/pkgconfig:${mingw_LIBDIR}/theora/lib/pkgconfig:${mingw_LIBDIR}/openjpeg/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:${mingw_LIBDIR}/aom/lib/pkgconfig:)
if(WIN32)
set(FFMPEG_ENV set ${FFMPEG_ENV} &&)
@@ -79,6 +79,7 @@ ExternalProject_Add(external_ffmpeg
--disable-librtmp
--enable-libx264
--enable-libxvid
--enable-libaom
--disable-libopencore-amrnb
--disable-libopencore-amrwb
--disable-libdc1394
@@ -125,6 +126,7 @@ add_dependencies(
external_vorbis
external_ogg
external_lame
external_aom
)
if(WIN32)
add_dependencies(

View File

@@ -0,0 +1,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(GMMLIB_EXTRA_ARGS
)
ExternalProject_Add(external_gmmlib
URL file://${PACKAGE_DIR}/${GMMLIB_FILE}
URL_HASH ${GMMLIB_HASH_TYPE}=${GMMLIB_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/gmmlib
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmmlib ${DEFAULT_CMAKE_FLAGS} ${GMMLIB_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/gmmlib
)

View File

@@ -25,9 +25,6 @@ if(BUILD_MODE STREQUAL Release)
# glew-> opengl
${CMAKE_COMMAND} -E copy ${LIBDIR}/glew/lib/libglew32.lib ${HARVEST_TARGET}/opengl/lib/glew.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/glew/include/ ${HARVEST_TARGET}/opengl/include/ &&
# tiff
${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/
DEPENDS
)
endif()
@@ -177,6 +174,7 @@ harvest(opus/lib ffmpeg/lib "*.a")
harvest(vpx/lib ffmpeg/lib "*.a")
harvest(x264/lib ffmpeg/lib "*.a")
harvest(xvidcore/lib ffmpeg/lib "*.a")
harvest(aom/lib ffmpeg/lib "*.a")
harvest(webp/lib webp/lib "*.a")
harvest(webp/include webp/include "*.h")
harvest(usd/include usd/include "*.h")
@@ -192,6 +190,10 @@ harvest(zstd/lib zstd/lib "*.a")
if(UNIX AND NOT APPLE)
harvest(libglu/lib mesa/lib "*.so*")
harvest(mesa/lib64 mesa/lib "*.so*")
endif()
harvest(dpcpp dpcpp "*")
harvest(igc dpcpp/lib/igc "*")
harvest(ocloc dpcpp/lib/ocloc "*")
endif()
endif()

View File

@@ -0,0 +1,126 @@
# SPDX-License-Identifier: GPL-2.0-or-later
unpack_only(igc_vcintrinsics)
unpack_only(igc_spirv_headers)
unpack_only(igc_spirv_tools)
#
# igc_opencl_clang contains patches that need to be applied
# to external_igc_llvm and igc_spirv_translator, we unpack
# igc_opencl_clang first, then have the patch stages of
# external_igc_llvm and igc_spirv_translator apply them.
#
ExternalProject_Add(external_igc_opencl_clang
URL file://${PACKAGE_DIR}/${IGC_OPENCL_CLANG_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${IGC_OPENCL_CLANG_HASH_TYPE}=${IGC_OPENCL_CLANG_HASH}
PREFIX ${BUILD_DIR}/igc_opencl_clang
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ < ${PATCH_DIR}/igc_opencl_clang.diff
)
set(IGC_OPENCL_CLANG_PATCH_DIR ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/patches)
set(IGC_LLVM_SOURCE_DIR ${BUILD_DIR}/igc_llvm/src/external_igc_llvm)
set(IGC_SPIRV_TRANSLATOR_SOURCE_DIR ${BUILD_DIR}/igc_spirv_translator/src/external_igc_spirv_translator)
ExternalProject_Add(external_igc_llvm
URL file://${PACKAGE_DIR}/${IGC_LLVM_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${IGC_LLVM_HASH_TYPE}=${IGC_LLVM_HASH}
PREFIX ${BUILD_DIR}/igc_llvm
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0001-OpenCL-3.0-support.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0002-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0003-Avoid-calling-ParseCommandLineOptions-in-BackendUtil.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0004-OpenCL-support-cl_ext_float_atomics.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0005-OpenCL-Add-cl_khr_integer_dot_product.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/llvm/0001-Memory-leak-fix-for-Managed-Static-Mutex.patch &&
${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/llvm/0002-Remove-repo-name-in-LLVM-IR.patch
)
add_dependencies(
external_igc_llvm
external_igc_opencl_clang
)
ExternalProject_Add(external_igc_spirv_translator
URL file://${PACKAGE_DIR}/${IGC_SPIRV_TRANSLATOR_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${IGC_SPIRV_TRANSLATOR_HASH_TYPE}=${IGC_SPIRV_TRANSLATOR_HASH}
PREFIX ${BUILD_DIR}/igc_spirv_translator
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${IGC_SPIRV_TRANSLATOR_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/spirv/0001-update-SPIR-V-headers-for-SPV_INTEL_split_barrier.patch &&
${PATCH_CMD} -p 1 -d ${IGC_SPIRV_TRANSLATOR_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/spirv/0002-Add-support-for-split-barriers-extension-SPV_INTEL_s.patch &&
${PATCH_CMD} -p 1 -d ${IGC_SPIRV_TRANSLATOR_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/spirv/0003-Support-cl_bf16_conversions.patch
)
add_dependencies(
external_igc_spirv_translator
external_igc_opencl_clang
)
if(WIN32)
set(IGC_GENERATOR "Ninja")
set(IGC_TARGET Windows64)
else()
set(IGC_GENERATOR "Unix Makefiles")
set(IGC_TARGET Linux64)
endif()
set(IGC_EXTRA_ARGS
-DIGC_OPTION__ARCHITECTURE_TARGET=${IGC_TARGET}
-DIGC_OPTION__ARCHITECTURE_HOST=${IGC_TARGET}
)
if(UNIX AND NOT APPLE)
list(APPEND IGC_EXTRA_ARGS
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
-DFLEX_INCLUDE_DIR=${LIBDIR}/flex/include
)
endif()
ExternalProject_Add(external_igc
URL file://${PACKAGE_DIR}/${IGC_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${IGC_HASH_TYPE}=${IGC_HASH}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/igc ${DEFAULT_CMAKE_FLAGS} ${IGC_EXTRA_ARGS}
# IGC is pretty set in its way where sub projects ought to live, for some it offers
# hooks to supply alternatives folders, other are just hardocded with no way to configure
# we symlink everything here, since it's less work than trying to convince the cmake
# scripts to accept alternative locations.
#
PATCH_COMMAND ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_llvm/src/external_igc_llvm/ ${BUILD_DIR}/igc/src/llvm-project &&
${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/opencl-clang &&
${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_translator/src/external_igc_spirv_translator/ ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/llvm-spirv &&
${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_tools/src/external_igc_spirv_tools/ ${BUILD_DIR}/igc/src/SPIRV-Tools &&
${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_headers/src/external_igc_spirv_headers/ ${BUILD_DIR}/igc/src/SPIRV-Headers &&
${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_vcintrinsics/src/external_igc_vcintrinsics/ ${BUILD_DIR}/igc/src/vc-intrinsics
PREFIX ${BUILD_DIR}/igc
INSTALL_DIR ${LIBDIR}/igc
INSTALL_COMMAND ${CMAKE_COMMAND} --install . --strip
CMAKE_GENERATOR ${IGC_GENERATOR}
)
add_dependencies(
external_igc
external_igc_vcintrinsics
external_igc_llvm
external_igc_opencl_clang
external_igc_vcintrinsics
external_igc_spirv_headers
external_igc_spirv_tools
external_igc_spirv_translator
)
if(UNIX AND NOT APPLE)
add_dependencies(
external_igc
external_flex
)
endif()

View File

@@ -28,7 +28,7 @@ elseif(UNIX)
set(ISPC_EXTRA_ARGS_UNIX
-DCMAKE_C_COMPILER=${LIBDIR}/llvm/bin/clang
-DCMAKE_CXX_COMPILER=${LIBDIR}/llvm/bin/clang++
-DARM_ENABLED=Off
-DARM_ENABLED=${BLENDER_PLATFORM_ARM}
-DFLEX_EXECUTABLE=${LIBDIR}/flex/bin/flex
)
endif()

View File

@@ -82,4 +82,3 @@ add_dependencies(
ll
external_python
)

View File

@@ -0,0 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# shorthand to only unpack a certain dependency
macro(unpack_only name)
string(TOUPPER ${name} UPPER_NAME)
set(TARGET_FILE ${${UPPER_NAME}_FILE})
set(TARGET_HASH_TYPE ${${UPPER_NAME}_HASH_TYPE})
set(TARGET_HASH ${${UPPER_NAME}_HASH})
ExternalProject_Add(external_${name}
URL file://${PACKAGE_DIR}/${TARGET_FILE}
URL_HASH ${TARGET_HASH_TYPE}=${TARGET_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/${name}
CONFIGURE_COMMAND echo .
BUILD_COMMAND echo .
INSTALL_COMMAND echo .
)
endmacro()

View File

@@ -0,0 +1,24 @@
# SPDX-License-Identifier: GPL-2.0-or-later
set(OCLOC_EXTRA_ARGS
-DNEO_SKIP_UNIT_TESTS=1
-DNEO_BUILD_WITH_OCL=0
-DBUILD_WITH_L0=0
-DIGC_DIR=${LIBDIR}/igc
-DGMM_DIR=${LIBDIR}/gmmlib
)
ExternalProject_Add(external_ocloc
URL file://${PACKAGE_DIR}/${OCLOC_FILE}
URL_HASH ${OCLOC_HASH_TYPE}=${OCLOC_HASH}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
PREFIX ${BUILD_DIR}/ocloc
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ocloc ${DEFAULT_CMAKE_FLAGS} ${OCLOC_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/ocloc
)
add_dependencies(
external_ocloc
external_igc
external_gmmlib
)

View File

@@ -18,9 +18,15 @@ if(WIN32)
set(PNG_LIBNAME libpng16_static${LIBEXT})
set(OIIO_SIMD_FLAGS -DUSE_SIMD=sse2)
set(OPENJPEG_POSTFIX _msvc)
if(BUILD_MODE STREQUAL Debug)
set(TIFF_POSTFIX d)
else()
set(TIFF_POSTFIX)
endif()
else()
set(PNG_LIBNAME libpng${LIBEXT})
set(OIIO_SIMD_FLAGS)
set(TIFF_POSTFIX)
endif()
if(MSVC)
@@ -65,7 +71,7 @@ set(OPENIMAGEIO_EXTRA_ARGS
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
-DPNG_LIBRARY=${LIBDIR}/png/lib/${PNG_LIBNAME}
-DPNG_PNG_INCLUDE_DIR=${LIBDIR}/png/include
-DTIFF_LIBRARY=${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${LIBEXT}
-DTIFF_LIBRARY=${LIBDIR}/tiff/lib/${LIBPREFIX}tiff${TIFF_POSTFIX}${LIBEXT}
-DTIFF_INCLUDE_DIR=${LIBDIR}/tiff/include
-DJPEG_LIBRARY=${LIBDIR}/jpeg/lib/${JPEG_LIBRARY}
-DJPEG_INCLUDE_DIR=${LIBDIR}/jpeg/include

View File

@@ -38,6 +38,7 @@ message("BUILD_DIR = ${BUILD_DIR}")
if(WIN32)
set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe)
set(LIBEXT ".lib")
set(SHAREDLIBEXT ".lib")
set(LIBPREFIX "")
# For OIIO and OSL
@@ -96,6 +97,7 @@ if(WIN32)
else()
set(PATCH_CMD patch)
set(LIBEXT ".a")
set(SHAREDLIBEXT ".so")
set(LIBPREFIX "lib")
if(APPLE)

View File

@@ -3,6 +3,8 @@
set(TIFF_EXTRA_ARGS
-DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY}
-DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include
-DJPEG_LIBRARY=${LIBDIR}/jpeg/lib/${JPEG_LIBRARY}
-DJPEG_INCLUDE_DIR=${LIBDIR}/jpeg/include
-DPNG_STATIC=ON
-DBUILD_SHARED_LIBS=OFF
-Dlzma=OFF
@@ -24,10 +26,12 @@ add_dependencies(
external_tiff
external_zlib
)
if(WIN32 AND BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_tiff after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiffd${LIBEXT} ${LIBDIR}/tiff/lib/tiff${LIBEXT}
DEPENDEES install
)
if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_tiff after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/
DEPENDEES install
)
endif()
endif()

View File

@@ -45,15 +45,15 @@ set(PTHREADS_HASH f3bf81bb395840b3446197bcf4ecd653)
set(PTHREADS_HASH_TYPE MD5)
set(PTHREADS_FILE pthreads4w-code-${PTHREADS_VERSION}.zip)
set(OPENEXR_VERSION 3.1.4)
set(OPENEXR_VERSION 3.1.5)
set(OPENEXR_URI https://github.com/AcademySoftwareFoundation/openexr/archive/v${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_HASH e990be1ff765797bc2d93a8060e1c1f2)
set(OPENEXR_HASH a92f38eedd43e56c0af56d4852506886)
set(OPENEXR_HASH_TYPE MD5)
set(OPENEXR_FILE openexr-${OPENEXR_VERSION}.tar.gz)
set(IMATH_VERSION 3.1.4)
set(IMATH_VERSION 3.1.5)
set(IMATH_URI https://github.com/AcademySoftwareFoundation/Imath/archive/v${OPENEXR_VERSION}.tar.gz)
set(IMATH_HASH fddf14ec73e12c34e74c3c175e311a3f)
set(IMATH_HASH dd375574276c54872b7b3d54053baff0)
set(IMATH_HASH_TYPE MD5)
set(IMATH_FILE imath-${IMATH_VERSION}.tar.gz)
@@ -147,7 +147,7 @@ set(OPENIMAGEIO_HASH de45fb38501c4581062b522b53b6141c)
set(OPENIMAGEIO_HASH_TYPE MD5)
set(OPENIMAGEIO_FILE OpenImageIO-${OPENIMAGEIO_VERSION}.tar.gz)
# 8.0.0 is currently oiio's preferred vesion although never versions may be available.
# 8.0.0 is currently oiio's preferred version although never versions may be available.
# the preferred version can be found in oiio's externalpackages.cmake
set(FMT_VERSION 8.0.0)
set(FMT_URI https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.tar.gz)
@@ -155,7 +155,7 @@ set(FMT_HASH 7bce0e9e022e586b178b150002e7c2339994e3c2bbe44027e9abb0d60f9cce83)
set(FMT_HASH_TYPE SHA256)
set(FMT_FILE fmt-${FMT_VERSION}.tar.gz)
# 0.6.2 is currently oiio's preferred vesion although never versions may be available.
# 0.6.2 is currently oiio's preferred version although never versions may be available.
# the preferred version can be found in oiio's externalpackages.cmake
set(ROBINMAP_VERSION v0.6.2)
set(ROBINMAP_URI https://github.com/Tessil/robin-map/archive/refs/tags/${ROBINMAP_VERSION}.tar.gz)
@@ -163,9 +163,9 @@ set(ROBINMAP_HASH c08ec4b1bf1c85eb0d6432244a6a89862229da1cb834f3f90fba8dc35d8c8e
set(ROBINMAP_HASH_TYPE SHA256)
set(ROBINMAP_FILE robinmap-${ROBINMAP_VERSION}.tar.gz)
set(TIFF_VERSION 4.3.0)
set(TIFF_VERSION 4.4.0)
set(TIFF_URI http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz)
set(TIFF_HASH 0a2e4744d1426a8fc8211c0cdbc3a1b3)
set(TIFF_HASH 376f17f189e9d02280dfe709b2b2bbea)
set(TIFF_HASH_TYPE MD5)
set(TIFF_FILE tiff-${TIFF_VERSION}.tar.gz)
@@ -410,9 +410,9 @@ set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7)
set(SQLITE_HASH_TYPE SHA1)
set(SQLITE_FILE sqlite-src-3240000.zip)
set(EMBREE_VERSION 3.13.3)
set(EMBREE_VERSION 3.13.4)
set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
set(EMBREE_HASH f62766ba54e48a2f327c3a22596e7133)
set(EMBREE_HASH 52d0be294d6c88ba7a6c9e046796e7be)
set(EMBREE_HASH_TYPE MD5)
set(EMBREE_FILE embree-v${EMBREE_VERSION}.zip)
@@ -502,3 +502,140 @@ set(LEVEL_ZERO_URI https://github.com/oneapi-src/level-zero/archive/refs/tags/${
set(LEVEL_ZERO_HASH c39bb05a8e5898aa6c444e1704105b93d3f1888b9c333f8e7e73825ffbfb2617)
set(LEVEL_ZERO_HASH_TYPE SHA256)
set(LEVEL_ZERO_FILE level-zero-${LEVEL_ZERO_VERSION}.tar.gz)
set(DPCPP_VERSION 20220620)
set(DPCPP_URI https://github.com/intel/llvm/archive/refs/tags/sycl-nightly/${DPCPP_VERSION}.tar.gz)
set(DPCPP_HASH a5f41abd5229d28afa92cbd8a5d8d786ee698bf239f722929fd686276bad692c)
set(DPCPP_HASH_TYPE SHA256)
set(DPCPP_FILE DPCPP-${DPCPP_VERSION}.tar.gz)
########################
### DPCPP DEPS BEGIN ###
########################
# The following deps are build time requirements for dpcpp, when possible
# the source in the dpcpp source tree for the version chosen is documented
# by each dep, these will only have to be downloaded and unpacked, dpcpp
# will take care of building them, unpack is being done in dpcpp_deps.cmake
# Source llvm/lib/SYCLLowerIR/CMakeLists.txt
set(VCINTRINSICS_VERSION 984bb27baacce6ee5c716c2e64845f2a1928025b)
set(VCINTRINSICS_URI https://github.com/intel/vc-intrinsics/archive/${VCINTRINSICS_VERSION}.tar.gz)
set(VCINTRINSICS_HASH abea415a15a0dd11fdc94dee8fb462910f2548311b787e02f42509789e1b0d7b)
set(VCINTRINSICS_HASH_TYPE SHA256)
set(VCINTRINSICS_FILE vc-intrinsics-${VCINTRINSICS_VERSION}.tar.gz)
# Source opencl/CMakeLists.txt
set(OPENCLHEADERS_VERSION dcd5bede6859d26833cd85f0d6bbcee7382dc9b3)
set(OPENCLHEADERS_URI https://github.com/KhronosGroup/OpenCL-Headers/archive/${OPENCLHEADERS_VERSION}.tar.gz)
set(OPENCLHEADERS_HASH ca8090359654e94f2c41e946b7e9d826253d795ae809ce7c83a7d3c859624693)
set(OPENCLHEADERS_HASH_TYPE SHA256)
set(OPENCLHEADERS_FILE opencl_headers-${OPENCLHEADERS_VERSION}.tar.gz)
# Source opencl/CMakeLists.txt
set(ICDLOADER_VERSION aec3952654832211636fc4af613710f80e203b0a)
set(ICDLOADER_URI https://github.com/KhronosGroup/OpenCL-ICD-Loader/archive/${ICDLOADER_VERSION}.tar.gz)
set(ICDLOADER_HASH e1880551d67bd8dc31d13de63b94bbfd6b1f315b6145dad1ffcd159b89bda93c)
set(ICDLOADER_HASH_TYPE SHA256)
set(ICDLOADER_FILE icdloader-${ICDLOADER_VERSION}.tar.gz)
# Source sycl/cmake/modules/AddBoostMp11Headers.cmake
# Using external MP11 here, getting AddBoostMp11Headers.cmake to recognize
# our copy in boost directly was more trouble than it was worth.
set(MP11_VERSION 7bc4e1ae9b36ec8ee635c3629b59ec525bbe82b9)
set(MP11_URI https://github.com/boostorg/mp11/archive/${MP11_VERSION}.tar.gz)
set(MP11_HASH 071ee2bd3952ec89882edb3af25dd1816f6b61723f66e42eea32f4d02ceef426)
set(MP11_HASH_TYPE SHA256)
set(MP11_FILE mp11-${MP11_VERSION}.tar.gz)
# Source llvm-spirv/CMakeLists.txt (repo)
# Source llvm-spirv/spirv-headers-tag.conf (hash)
set(SPIRV_HEADERS_VERSION 36c0c1596225e728bd49abb7ef56a3953e7ed468)
set(SPIRV_HEADERS_URI https://github.com/KhronosGroup/SPIRV-Headers/archive/${SPIRV_HEADERS_VERSION}.tar.gz)
set(SPIRV_HEADERS_HASH 7a5c89633f8740456fe8adee052033e134476d267411d1336c0cb1e587a9229a)
set(SPIRV_HEADERS_HASH_TYPE SHA256)
set(SPIRV_HEADERS_FILE SPIR-V-Headers-${SPIRV_HEADERS_VERSION}.tar.gz)
######################
### DPCPP DEPS END ###
######################
##########################################
### Intel Graphics Compiler DEPS BEGIN ###
##########################################
# The following deps are build time requirements for the intel graphics
# compiler, the versions used are taken from the following location
# https://github.com/intel/intel-graphics-compiler/releases
set(IGC_VERSION 1.0.11222)
set(IGC_URI https://github.com/intel/intel-graphics-compiler/archive/refs/tags/igc-${IGC_VERSION}.tar.gz)
set(IGC_HASH d92f0608dcbb52690855685f9447282e5c09c0ba98ae35fabf114fcf8b1e9fcf)
set(IGC_HASH_TYPE SHA256)
set(IGC_FILE igc-${IGC_VERSION}.tar.gz)
set(IGC_LLVM_VERSION llvmorg-11.1.0)
set(IGC_LLVM_URI https://github.com/llvm/llvm-project/archive/refs/tags/${IGC_LLVM_VERSION}.tar.gz)
set(IGC_LLVM_HASH 53a0719f3f4b0388013cfffd7b10c7d5682eece1929a9553c722348d1f866e79)
set(IGC_LLVM_HASH_TYPE SHA256)
set(IGC_LLVM_FILE ${IGC_LLVM_VERSION}.tar.gz)
# WARNING WARNING WARNING
#
# IGC_OPENCL_CLANG contains patches for some of its dependencies.
#
# Whenever IGC_OPENCL_CLANG_VERSION changes, one *MUST* inspect
# IGC_OPENCL_CLANG's patches folder and update igc.cmake to account for
# any added or removed patches.
#
# WARNING WARNING WARNING
set(IGC_OPENCL_CLANG_VERSION bbdd1587f577397a105c900be114b56755d1f7dc)
set(IGC_OPENCL_CLANG_URI https://github.com/intel/opencl-clang/archive/${IGC_OPENCL_CLANG_VERSION}.tar.gz)
set(IGC_OPENCL_CLANG_HASH d08315f1b0d8a6fef33de2b3e6aa7356534c324910634962c72523d970773efc)
set(IGC_OPENCL_CLANG_HASH_TYPE SHA256)
set(IGC_OPENCL_CLANG_FILE opencl-clang-${IGC_OPENCL_CLANG_VERSION}.tar.gz)
set(IGC_VCINTRINSICS_VERSION v0.4.0)
set(IGC_VCINTRINSICS_URI https://github.com/intel/vc-intrinsics/archive/refs/tags/${IGC_VCINTRINSICS_VERSION}.tar.gz)
set(IGC_VCINTRINSICS_HASH c8b92682ad5031cf9d5b82a40e7d5c0e763cd9278660adbcaa69aab988e4b589)
set(IGC_VCINTRINSICS_HASH_TYPE SHA256)
set(IGC_VCINTRINSICS_FILE vc-intrinsics-${IGC_VCINTRINSICS_VERSION}.tar.gz)
set(IGC_SPIRV_HEADERS_VERSION sdk-1.3.204.1)
set(IGC_SPIRV_HEADERS_URI https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags/${IGC_SPIRV_HEADERS_VERSION}.tar.gz)
set(IGC_SPIRV_HEADERS_HASH 262864053968c217d45b24b89044a7736a32361894743dd6cfe788df258c746c)
set(IGC_SPIRV_HEADERS_HASH_TYPE SHA256)
set(IGC_SPIRV_HEADERS_FILE SPIR-V-Headers-${IGC_SPIRV_HEADERS_VERSION}.tar.gz)
set(IGC_SPIRV_TOOLS_VERSION sdk-1.3.204.1)
set(IGC_SPIRV_TOOLS_URI https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/${IGC_SPIRV_TOOLS_VERSION}.tar.gz)
set(IGC_SPIRV_TOOLS_HASH 6e19900e948944243024aedd0a201baf3854b377b9cc7a386553bc103b087335)
set(IGC_SPIRV_TOOLS_HASH_TYPE SHA256)
set(IGC_SPIRV_TOOLS_FILE SPIR-V-Tools-${IGC_SPIRV_TOOLS_VERSION}.tar.gz)
set(IGC_SPIRV_TRANSLATOR_VERSION 99420daab98998a7e36858befac9c5ed109d4920)
set(IGC_SPIRV_TRANSLATOR_URI https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/${IGC_SPIRV_TRANSLATOR_VERSION}.tar.gz)
set(IGC_SPIRV_TRANSLATOR_HASH 77dfb4ddb6bfb993535562c02ddea23f0a0d1c5a0258c1afe7e27c894ff783a8)
set(IGC_SPIRV_TRANSLATOR_HASH_TYPE SHA256)
set(IGC_SPIRV_TRANSLATOR_FILE SPIR-V-Translator-${IGC_SPIRV_TRANSLATOR_VERSION}.tar.gz)
########################################
### Intel Graphics Compiler DEPS END ###
########################################
set(GMMLIB_VERSION intel-gmmlib-22.1.2)
set(GMMLIB_URI https://github.com/intel/gmmlib/archive/refs/tags/${GMMLIB_VERSION}.tar.gz)
set(GMMLIB_HASH 3b9a6d5e7e3f5748b3d0a2fb0e980ae943907fece0980bd9c0508e71c838e334)
set(GMMLIB_HASH_TYPE SHA256)
set(GMMLIB_FILE ${GMMLIB_VERSION}.tar.gz)
set(OCLOC_VERSION 22.20.23198)
set(OCLOC_URI https://github.com/intel/compute-runtime/archive/refs/tags/${OCLOC_VERSION}.tar.gz)
set(OCLOC_HASH ab22b8bf2560a57fdd3def0e35a62ca75991406f959c0263abb00cd6cd9ae998)
set(OCLOC_HASH_TYPE SHA256)
set(OCLOC_FILE ocloc-${OCLOC_VERSION}.tar.gz)
set(AOM_VERSION 3.4.0)
set(AOM_URI https://storage.googleapis.com/aom-releases/libaom-${AOM_VERSION}.tar.gz)
set(AOM_HASH bd754b58c3fa69f3ffd29da77de591bd9c26970e3b18537951336d6c0252e354)
set(AOM_HASH_TYPE SHA256)
set(AOM_FILE libaom-${AOM_VERSION}.tar.gz)

View File

@@ -1,11 +1,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc --disable-multithread)
else()
set(VPX_EXTRA_FLAGS --target=x86-win32-gcc --disable-multithread)
endif()
# VPX is determined to use pthreads which it will tell ffmpeg to dynamically
# link, which is not something we're super into distribution wise. However
# if it cannot find pthread.h it'll happily provide a pthread emulation
# layer using win32 threads. So all this patch does is make it not find
# pthead.h
set(VPX_PATCH ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/vpx/src/external_vpx < ${PATCH_DIR}/vpx_windows.diff)
set(VPX_EXTRA_FLAGS --target=x86_64-win64-gcc )
else()
if(APPLE)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
@@ -18,6 +20,16 @@ else()
endif()
endif()
if(NOT BLENDER_PLATFORM_ARM)
list(APPEND VPX_EXTRA_FLAGS
--enable-sse4_1
--enable-sse3
--enable-ssse3
--enable-avx
--enable-avx2
)
endif()
ExternalProject_Add(external_vpx
URL file://${PACKAGE_DIR}/${VPX_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
@@ -30,11 +42,6 @@ ExternalProject_Add(external_vpx
--enable-static
--disable-install-bins
--disable-install-srcs
--disable-sse4_1
--disable-sse3
--disable-ssse3
--disable-avx
--disable-avx2
--disable-unit-tests
--disable-examples
--enable-vp8
@@ -42,6 +49,7 @@ ExternalProject_Add(external_vpx
${VPX_EXTRA_FLAGS}
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make install
PATCH_COMMAND ${VPX_PATCH}
INSTALL_DIR ${LIBDIR}/vpx
)

View File

@@ -465,7 +465,7 @@ TBB_VERSION="2020"
TBB_VERSION_SHORT="2020"
TBB_VERSION_UPDATE="_U3" # Used for source packages...
TBB_VERSION_MIN="2018"
TBB_VERSION_MEX="2022"
TBB_VERSION_MEX="2021" # 2021 introduces 'oneTBB', which has lots of compatibility breakage with previous versions
TBB_FORCE_BUILD=false
TBB_FORCE_REBUILD=false
TBB_SKIP=false
@@ -478,7 +478,7 @@ OCIO_FORCE_BUILD=false
OCIO_FORCE_REBUILD=false
OCIO_SKIP=false
IMATH_VERSION="3.1.4"
IMATH_VERSION="3.1.5"
IMATH_VERSION_SHORT="3.1"
IMATH_VERSION_MIN="3.0"
IMATH_VERSION_MEX="4.0"
@@ -487,7 +487,7 @@ IMATH_FORCE_REBUILD=false
IMATH_SKIP=false
_with_built_imath=false
OPENEXR_VERSION="3.1.4"
OPENEXR_VERSION="3.1.5"
OPENEXR_VERSION_SHORT="3.1"
OPENEXR_VERSION_MIN="3.0"
OPENEXR_VERSION_MEX="4.0"
@@ -567,7 +567,7 @@ OPENCOLLADA_FORCE_BUILD=false
OPENCOLLADA_FORCE_REBUILD=false
OPENCOLLADA_SKIP=false
EMBREE_VERSION="3.13.3"
EMBREE_VERSION="3.13.4"
EMBREE_VERSION_SHORT="3.13"
EMBREE_VERSION_MIN="3.13"
EMBREE_VERSION_MEX="4.0"
@@ -627,6 +627,9 @@ WEBP_DEV=""
VPX_USE=false
VPX_VERSION_MIN=0.9.7
VPX_DEV=""
AOM_USE=false
AOM_VERSION_MIN=3.3.0
AOM_DEV=""
OPUS_USE=false
OPUS_VERSION_MIN=1.1.1
OPUS_DEV=""
@@ -635,9 +638,6 @@ MP3LAME_DEV=""
OPENJPEG_USE=false
OPENJPEG_DEV=""
# Whether to use system GLEW or not (OpenSubDiv needs recent glew to work).
NO_SYSTEM_GLEW=false
# Switch to english language, else some things (like check_package_DEB()) won't work!
LANG_BACK=$LANG
LANG=""
@@ -1193,7 +1193,7 @@ Those libraries should be available as packages in all recent distributions (opt
* libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed).
* libwayland-client0, libwayland-cursor0, libwayland-egl1, libxkbcommon0, libdbus-1-3, libegl1 (Wayland)
* libsqlite3, libzstd, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp, flex.
* libsdl2, libglew, libpugixml, libpotrace, [libgmp], [libglewmx], fontconfig, [libharu/libhpdf].\""
* libsdl2, libglew, libpugixml, libpotrace, [libgmp], fontconfig, [libharu/libhpdf].\""
DEPS_SPECIFIC_INFO="\"BUILDABLE DEPENDENCIES:
@@ -1212,7 +1212,7 @@ You may also want to build them yourself (optional ones are [between brackets]):
** [NumPy $PYTHON_NUMPY_VERSION] (use pip).
* Boost $BOOST_VERSION (from $BOOST_SOURCE, modules: $BOOST_BUILD_MODULES).
* TBB $TBB_VERSION (from $TBB_SOURCE).
* [FFMpeg $FFMPEG_VERSION (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, libwebp, ...)] (from $FFMPEG_SOURCE).
* [FFMpeg $FFMPEG_VERSION (needs libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, libaom, libwebp, ...)] (from $FFMPEG_SOURCE).
* [OpenColorIO $OCIO_VERSION] (from $OCIO_SOURCE).
* Imath $IMATH_VERSION (from $IMATH_SOURCE).
* OpenEXR $OPENEXR_VERSION (from $OPENEXR_SOURCE).
@@ -1687,7 +1687,7 @@ compile_TBB() {
fi
# To be changed each time we make edits that would modify the compiled result!
tbb_magic=0
tbb_magic=1
_init_tbb
# Force having own builds for the dependencies.
@@ -2696,14 +2696,13 @@ compile_OSD() {
mkdir build
cd build
if [ -d $INST/tbb ]; then
cmake_d="$cmake_d $cmake_d -D TBB_LOCATION=$INST/tbb"
fi
cmake_d="-D CMAKE_BUILD_TYPE=Release"
if [ -d $INST/tbb ]; then
cmake_d="$cmake_d -D TBB_LOCATION=$INST/tbb"
fi
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
# ptex is only needed when nicholas bishop is ready
cmake_d="$cmake_d -D NO_PTEX=1"
cmake_d="$cmake_d -D NO_CLEW=1 -D NO_CUDA=1 -D NO_OPENCL=1"
cmake_d="$cmake_d -D NO_CLEW=1 -D NO_CUDA=1 -D NO_OPENCL=1 -D NO_GLEW=1"
# maya plugin, docs, tutorials, regression tests and examples are not needed
cmake_d="$cmake_d -D NO_MAYA=1 -D NO_DOC=1 -D NO_TUTORIALS=1 -D NO_REGRESSION=1 -DNO_EXAMPLES=1"
@@ -3004,7 +3003,7 @@ compile_ALEMBIC() {
fi
# To be changed each time we make edits that would modify the compiled result!
alembic_magic=2
alembic_magic=3
_init_alembic
# Force having own builds for the dependencies.
@@ -3052,7 +3051,7 @@ compile_ALEMBIC() {
fi
if [ "$_with_built_openexr" = true ]; then
cmake_d="$cmake_d -D USE_ARNOLD=OFF"
cmake_d="$cmake_d -D USE_BINARIES=OFF"
cmake_d="$cmake_d -D USE_BINARIES=ON" # Tests use some Alembic binaries...
cmake_d="$cmake_d -D USE_EXAMPLES=OFF"
cmake_d="$cmake_d -D USE_HDF5=OFF"
cmake_d="$cmake_d -D USE_MAYA=OFF"
@@ -3326,7 +3325,7 @@ compile_Embree() {
fi
# To be changed each time we make edits that would modify the compiled results!
embree_magic=10
embree_magic=11
_init_embree
# Force having own builds for the dependencies.
@@ -3386,7 +3385,7 @@ compile_Embree() {
cmake_d="$cmake_d -D EMBREE_TASKING_SYSTEM=TBB"
if [ -d $INST/tbb ]; then
make_d="$make_d EMBREE_TBB_ROOT=$INST/tbb"
cmake_d="$cmake_d -D EMBREE_TBB_ROOT=$INST/tbb"
fi
cmake $cmake_d ../
@@ -3525,7 +3524,7 @@ compile_OIDN() {
install_ISPC
# To be changed each time we make edits that would modify the compiled results!
oidn_magic=9
oidn_magic=10
_init_oidn
# Force having own builds for the dependencies.
@@ -3581,7 +3580,7 @@ compile_OIDN() {
cmake_d="$cmake_d -D ISPC_DIR_HINT=$_ispc_path_bin"
if [ -d $INST/tbb ]; then
make_d="$make_d TBB_ROOT=$INST/tbb"
cmake_d="$cmake_d -D TBB_ROOT=$INST/tbb"
fi
cmake $cmake_d ../
@@ -3638,7 +3637,7 @@ compile_FFmpeg() {
fi
# To be changed each time we make edits that would modify the compiled result!
ffmpeg_magic=5
ffmpeg_magic=6
_init_ffmpeg
# Force having own builds for the dependencies.
@@ -3691,6 +3690,10 @@ compile_FFmpeg() {
extra="$extra --enable-libvpx"
fi
if [ "$AOM_USE" = true ]; then
extra="$extra --enable-libaom"
fi
if [ "$WEBP_USE" = true ]; then
extra="$extra --enable-libwebp"
fi
@@ -4062,7 +4065,6 @@ install_DEB() {
libopenal-dev libglew-dev yasm \
libsdl2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev libjemalloc-dev \
libgmp-dev libpugixml-dev libpotrace-dev libhpdf-dev libzstd-dev libpystring-dev"
# libglewmx-dev (broken in deb testing currently...)
VORBIS_USE=true
OGG_USE=true
@@ -4145,33 +4147,37 @@ install_DEB() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
XVID_DEV="libxvidcore-dev"
check_package_DEB $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
MP3LAME_DEV="libmp3lame-dev"
check_package_DEB $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
VPX_DEV="libvpx-dev"
check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
OPUS_DEV="libopus-dev"
check_package_version_ge_DEB $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
XVID_DEV="libxvidcore-dev"
check_package_DEB $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
# Check cmake/glew versions and disable features for older distros.
MP3LAME_DEV="libmp3lame-dev"
check_package_DEB $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
VPX_DEV="libvpx-dev"
check_package_version_ge_DEB $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
AOM_DEV="libaom-dev"
check_package_version_ge_DEB $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="libopus-dev"
check_package_version_ge_DEB $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
# Check cmake version and disable features for older distros.
# This is so Blender can at least compile.
PRINT ""
_cmake=`get_package_version_DEB cmake`
@@ -4188,28 +4194,6 @@ install_DEB() {
fi
fi
PRINT ""
_glew=`get_package_version_DEB libglew-dev`
if [ -z $_glew ]; then
# Stupid virtual package in Ubuntu 12.04 doesn't show version number...
_glew=`apt-cache showpkg libglew-dev|tail -n1|awk '{print $2}'|sed 's/-.*//'`
fi
version_ge $_glew "1.9.0"
if [ $? -eq 1 ]; then
version_ge $_glew "1.7.0"
if [ $? -eq 1 ]; then
WARNING "OpenSubdiv disabled because GLEW-$_glew is not enough"
WARNING "Blender will not use system GLEW library"
OSD_SKIP=true
NO_SYSTEM_GLEW=true
else
WARNING "OpenSubdiv will compile with GLEW-$_glew but with limited capability"
WARNING "Blender will not use system GLEW library"
NO_SYSTEM_GLEW=true
fi
fi
PRINT ""
_do_compile_python=false
if [ "$PYTHON_SKIP" = true ]; then
@@ -4573,6 +4557,9 @@ install_DEB() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
@@ -4873,21 +4860,27 @@ install_RPM() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
VPX_DEV="libvpx-devel"
check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
VPX_DEV="libvpx-devel"
check_package_version_ge_RPM $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
AOM_DEV="libaom-devel"
check_package_version_ge_RPM $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="libopus-devel"
check_package_version_ge_RPM $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
if [ "$WITH_ALL" = true ]; then
PRINT ""
install_packages_RPM libspnav-devel
OPUS_DEV="libopus-devel"
check_package_version_ge_RPM $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
fi
PRINT ""
@@ -5272,6 +5265,9 @@ install_RPM() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
@@ -5461,30 +5457,34 @@ install_ARCH() {
WEBP_USE=true
fi
if [ "$WITH_ALL" = true ]; then
XVID_DEV="xvidcore"
check_package_ARCH $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
XVID_DEV="xvidcore"
check_package_ARCH $XVID_DEV
if [ $? -eq 0 ]; then
XVID_USE=true
fi
MP3LAME_DEV="lame"
check_package_ARCH $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
MP3LAME_DEV="lame"
check_package_ARCH $MP3LAME_DEV
if [ $? -eq 0 ]; then
MP3LAME_USE=true
fi
VPX_DEV="libvpx"
check_package_version_ge_ARCH $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
VPX_DEV="libvpx"
check_package_version_ge_ARCH $VPX_DEV $VPX_VERSION_MIN
if [ $? -eq 0 ]; then
VPX_USE=true
fi
OPUS_DEV="opus"
check_package_version_ge_ARCH $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
AOM_DEV="libaom"
check_package_version_ge_ARCH $AOM_DEV $AOM_VERSION_MIN
if [ $? -eq 0 ]; then
AOM_USE=true
fi
OPUS_DEV="opus"
check_package_version_ge_ARCH $OPUS_DEV $OPUS_VERSION_MIN
if [ $? -eq 0 ]; then
OPUS_USE=true
fi
@@ -5862,6 +5862,9 @@ install_ARCH() {
if [ "$VPX_USE" = true ]; then
_packages="$_packages $VPX_DEV"
fi
if [ "$AOM_USE" = true ]; then
_packages="$_packages $AOM_DEV"
fi
if [ "$OPUS_USE" = true ]; then
_packages="$_packages $OPUS_DEV"
fi
@@ -6290,12 +6293,6 @@ print_info() {
fi
fi
if [ "$NO_SYSTEM_GLEW" = true ]; then
_1="-D WITH_SYSTEM_GLEW=OFF"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
if [ "$FFMPEG_SKIP" = false ]; then
_1="-D WITH_CODEC_FFMPEG=ON"
PRINT " $_1"

View File

@@ -0,0 +1,54 @@
diff -Naur external_dpcpp.orig/sycl/source/CMakeLists.txt external_dpcpp/sycl/source/CMakeLists.txt
--- external_dpcpp.orig/sycl/source/CMakeLists.txt 2022-05-20 04:19:45.067771362 +0000
+++ external_dpcpp/sycl/source/CMakeLists.txt 2022-05-20 04:21:49.708025048 +0000
@@ -66,10 +66,10 @@
target_compile_options(${LIB_OBJ_NAME} PUBLIC
-fvisibility=hidden -fvisibility-inlines-hidden)
set(linker_script "${CMAKE_CURRENT_SOURCE_DIR}/ld-version-script.txt")
- set(abi_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/abi_replacements_linux.txt")
- target_link_libraries(
- ${LIB_NAME} PRIVATE "-Wl,${abi_linker_script}")
- set_target_properties(${LIB_NAME} PROPERTIES LINK_DEPENDS ${abi_linker_script})
+# set(abi_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/abi_replacements_linux.txt")
+# target_link_libraries(
+# ${LIB_NAME} PRIVATE "-Wl,${abi_linker_script}")
+# set_target_properties(${LIB_NAME} PROPERTIES LINK_DEPENDS ${abi_linker_script})
target_link_libraries(
${LIB_NAME} PRIVATE "-Wl,--version-script=${linker_script}")
set_target_properties(${LIB_NAME} PROPERTIES LINK_DEPENDS ${linker_script})
diff -Naur llvm-sycl-nightly-20220501.orig\opencl/CMakeLists.txt llvm-sycl-nightly-20220501\opencl/CMakeLists.txt
--- llvm-sycl-nightly-20220501.orig/opencl/CMakeLists.txt 2022-04-29 13:47:11 -0600
+++ llvm-sycl-nightly-20220501/opencl/CMakeLists.txt 2022-05-21 15:25:06 -0600
@@ -11,6 +11,11 @@
)
endif()
+# Blender code below is determined to use FetchContent_Declare
+# temporarily allow it (but feed it our downloaded tarball
+# in the OpenCL_HEADERS variable
+set(FETCHCONTENT_FULLY_DISCONNECTED OFF)
+
# Repo URLs
set(OCL_HEADERS_REPO
@@ -77,5 +82,6 @@
FetchContent_MakeAvailable(ocl-icd)
add_library(OpenCL-ICD ALIAS OpenCL)
+set(FETCHCONTENT_FULLY_DISCONNECTED ON)
add_subdirectory(opencl-aot)
diff -Naur llvm-sycl-nightly-20220208.orig/libdevice/cmake/modules/SYCLLibdevice.cmake llvm-sycl-nightly-20220208/libdevice/cmake/modules/SYCLLibdevice.cmake
--- llvm-sycl-nightly-20220208.orig/libdevice/cmake/modules/SYCLLibdevice.cmake 2022-02-08 09:17:24 -0700
+++ llvm-sycl-nightly-20220208/libdevice/cmake/modules/SYCLLibdevice.cmake 2022-05-24 11:35:51 -0600
@@ -36,7 +36,9 @@
add_custom_target(libsycldevice-obj)
add_custom_target(libsycldevice-spv)
-add_custom_target(libsycldevice DEPENDS
+# Blender: add ALL here otherwise this target will not build
+# and cause an error due to missing files during the install phase.
+add_custom_target(libsycldevice ALL DEPENDS
libsycldevice-obj
libsycldevice-spv)

View File

@@ -1,30 +1,37 @@
diff -Naur orig/common/sys/platform.h external_embree/common/sys/platform.h
--- orig/common/sys/platform.h 2020-05-13 23:08:53 -0600
+++ external_embree/common/sys/platform.h 2020-06-13 17:40:26 -0600
@@ -84,8 +84,8 @@
////////////////////////////////////////////////////////////////////////////////
diff -Naur org/kernels/rtcore_config.h.in embree-3.13.4/kernels/rtcore_config.h.in
--- org/kernels/rtcore_config.h.in 2022-06-14 22:13:52 -0600
+++ embree-3.13.4/kernels/rtcore_config.h.in 2022-06-24 15:20:12 -0600
@@ -14,6 +14,7 @@
#cmakedefine01 EMBREE_MIN_WIDTH
#define RTC_MIN_WIDTH EMBREE_MIN_WIDTH
+#cmakedefine EMBREE_STATIC_LIB
#cmakedefine EMBREE_API_NAMESPACE
#if defined(EMBREE_API_NAMESPACE)
diff --git a/kernels/CMakeLists.txt b/kernels/CMakeLists.txt
index 7c2f43d..106b1d5 100644
--- a/kernels/CMakeLists.txt
+++ b/kernels/CMakeLists.txt
@@ -201,6 +201,12 @@ embree_files(EMBREE_LIBRARY_FILES_AVX512 ${AVX512})
#message("AVX2: ${EMBREE_LIBRARY_FILES_AVX2}")
#message("AVX512: ${EMBREE_LIBRARY_FILES_AVX512}")
#ifdef __WIN32__
-#define dll_export __declspec(dllexport)
-#define dll_import __declspec(dllimport)
+#define dll_export
+#define dll_import
#else
#define dll_export __attribute__ ((visibility ("default")))
#define dll_import
diff --git orig/common/tasking/CMakeLists.txt external_embree/common/tasking/CMakeLists.txt
--- orig/common/tasking/CMakeLists.txt
+++ external_embree/common/tasking/CMakeLists.txt
@@ -27,7 +27,11 @@
else()
# If not found try getting older TBB via module (FindTBB.cmake)
unset(TBB_DIR CACHE)
- find_package(TBB 4.1 REQUIRED tbb)
+ if (TBB_STATIC_LIB)
+ find_package(TBB 4.1 REQUIRED tbb_static)
+ else()
+ find_package(TBB 4.1 REQUIRED tbb)
+ endif()
if (TBB_FOUND)
TARGET_LINK_LIBRARIES(tasking PUBLIC TBB)
TARGET_INCLUDE_DIRECTORIES(tasking PUBLIC "${TBB_INCLUDE_DIRS}")
+# Bundle Neon2x into the main static library.
+IF(EMBREE_ISA_NEON2X AND EMBREE_STATIC_LIB)
+ LIST(APPEND EMBREE_LIBRARY_FILES ${EMBREE_LIBRARY_FILES_AVX2})
+ LIST(REMOVE_DUPLICATES EMBREE_LIBRARY_FILES)
+ENDIF()
+
# replaces all .cpp files with a dummy file that includes that .cpp file
# this is to work around an ICC name mangling issue related to lambda functions under windows
MACRO (CreateISADummyFiles list isa)
@@ -277,7 +283,7 @@ IF (EMBREE_ISA_AVX AND EMBREE_LIBRARY_FILES_AVX)
ENDIF()
ENDIF()
-IF (EMBREE_ISA_AVX2 AND EMBREE_LIBRARY_FILES_AVX2)
+IF (EMBREE_ISA_AVX2 AND EMBREE_LIBRARY_FILES_AVX2 AND NOT (EMBREE_ISA_NEON2X AND EMBREE_STATIC_LIB))
DISABLE_STACK_PROTECTOR_FOR_INTERSECTORS(${EMBREE_LIBRARY_FILES_AVX2})
ADD_LIBRARY(embree_avx2 STATIC ${EMBREE_LIBRARY_FILES_AVX2})
TARGET_LINK_LIBRARIES(embree_avx2 PRIVATE tasking)

View File

@@ -0,0 +1,44 @@
diff -Naur external_igc_opencl_clang.orig/CMakeLists.txt external_igc_opencl_clang/CMakeLists.txt
--- external_igc_opencl_clang.orig/CMakeLists.txt 2022-03-16 05:51:10 -0600
+++ external_igc_opencl_clang/CMakeLists.txt 2022-05-23 10:40:09 -0600
@@ -126,22 +126,24 @@
)
endif()
-
- set(SPIRV_BASE_REVISION llvm_release_110)
- set(TARGET_BRANCH "ocl-open-110")
- get_filename_component(LLVM_MONOREPO_DIR ${LLVM_SOURCE_DIR} DIRECTORY)
- set(LLVM_PATCHES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
- ${CMAKE_CURRENT_SOURCE_DIR}/patches/clang)
- apply_patches(${LLVM_MONOREPO_DIR}
- "${LLVM_PATCHES_DIRS}"
- ${LLVM_BASE_REVISION}
- ${TARGET_BRANCH}
- ret)
- apply_patches(${SPIRV_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/patches/spirv
- ${SPIRV_BASE_REVISION}
- ${TARGET_BRANCH}
- ret)
+ #
+ # Blender: Why apply these manually in igc.cmake
+ #
+ #set(SPIRV_BASE_REVISION llvm_release_110)
+ #set(TARGET_BRANCH "ocl-open-110")
+ #get_filename_component(LLVM_MONOREPO_DIR ${LLVM_SOURCE_DIR} DIRECTORY)
+ #set(LLVM_PATCHES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/patches/llvm
+ # ${CMAKE_CURRENT_SOURCE_DIR}/patches/clang)
+ #apply_patches(${LLVM_MONOREPO_DIR}
+ # "${LLVM_PATCHES_DIRS}"
+ # ${LLVM_BASE_REVISION}
+ # ${TARGET_BRANCH}
+ # ret)
+ #apply_patches(${SPIRV_SOURCE_DIR}
+ # ${CMAKE_CURRENT_SOURCE_DIR}/patches/spirv
+ # ${SPIRV_BASE_REVISION}
+ # ${TARGET_BRANCH}
+ # ret)
endif(NOT USE_PREBUILT_LLVM)
#

View File

@@ -0,0 +1,11 @@
diff -Naur orig/configure external_vpx/configure
--- orig/configure 2022-07-06 09:22:04 -0600
+++ external_vpx/configure 2022-07-06 09:24:12 -0600
@@ -270,7 +270,6 @@
HAVE_LIST="
${ARCH_EXT_LIST}
vpx_ports
- pthread_h
unistd_h
"
EXPERIMENT_LIST="

View File

@@ -0,0 +1,56 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2021-2022 Intel Corporation
# - Find Level Zero library
# Find Level Zero headers and libraries needed by oneAPI implementation
# This module defines
# LEVEL_ZERO_LIBRARY, libraries to link against in order to use L0.
# LEVEL_ZERO_INCLUDE_DIR, directories where L0 headers can be found.
# LEVEL_ZERO_ROOT_DIR, The base directory to search for L0 files.
# This can also be an environment variable.
# LEVEL_ZERO_FOUND, If false, then don't try to use L0.
IF(NOT LEVEL_ZERO_ROOT_DIR AND NOT $ENV{LEVEL_ZERO_ROOT_DIR} STREQUAL "")
SET(LEVEL_ZERO_ROOT_DIR $ENV{LEVEL_ZERO_ROOT_DIR})
ENDIF()
SET(_level_zero_search_dirs
${LEVEL_ZERO_ROOT_DIR}
/usr/lib
/usr/local/lib
)
FIND_LIBRARY(_LEVEL_ZERO_LIBRARY
NAMES
ze_loader
HINTS
${_level_zero_search_dirs}
PATH_SUFFIXES
lib64 lib
)
FIND_PATH(_LEVEL_ZERO_INCLUDE_DIR
NAMES
level_zero/ze_api.h
HINTS
${_level_zero_search_dirs}
PATH_SUFFIXES
include
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LevelZero DEFAULT_MSG _LEVEL_ZERO_LIBRARY _LEVEL_ZERO_INCLUDE_DIR)
IF(LevelZero_FOUND)
SET(LEVEL_ZERO_LIBRARY ${_LEVEL_ZERO_LIBRARY})
SET(LEVEL_ZERO_INCLUDE_DIR ${_LEVEL_ZERO_INCLUDE_DIR} ${_LEVEL_ZERO_INCLUDE_PARENT_DIR})
SET(LEVEL_ZERO_FOUND TRUE)
ELSE()
SET(LEVEL_ZERO_FOUND FALSE)
ENDIF()
MARK_AS_ADVANCED(
LEVEL_ZERO_LIBRARY
LEVEL_ZERO_INCLUDE_DIR
)

View File

@@ -0,0 +1,88 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2021-2022 Intel Corporation
# - Find SYCL library
# Find the native SYCL header and libraries needed by oneAPI implementation
# This module defines
# SYCL_COMPILER, compiler which will be used for compilation of SYCL code
# SYCL_LIBRARY, libraries to link against in order to use SYCL.
# SYCL_INCLUDE_DIR, directories where SYCL headers can be found
# SYCL_ROOT_DIR, The base directory to search for SYCL files.
# This can also be an environment variable.
# SYCL_FOUND, If false, then don't try to use SYCL.
IF(NOT SYCL_ROOT_DIR AND NOT $ENV{SYCL_ROOT_DIR} STREQUAL "")
SET(SYCL_ROOT_DIR $ENV{SYCL_ROOT_DIR})
ENDIF()
SET(_sycl_search_dirs
${SYCL_ROOT_DIR}
/usr/lib
/usr/local/lib
/opt/intel/oneapi/compiler/latest/linux/
C:/Program\ Files\ \(x86\)/Intel/oneAPI/compiler/latest/windows
)
# Find DPC++ compiler.
# Since the compiler name is possibly conflicting with the system-wide
# CLang start with looking for either dpcpp or clang binary in the given
# list of search paths only. If that fails, try to look for a system-wide
# dpcpp binary.
FIND_PROGRAM(SYCL_COMPILER
NAMES
dpcpp
clang++
HINTS
${_sycl_search_dirs}
PATH_SUFFIXES
bin
NO_CMAKE_FIND_ROOT_PATH
NAMES_PER_DIR
)
# NOTE: No clang++ here so that we do not pick up a system-wide CLang
# compiler.
if(NOT SYCL_COMPILER)
FIND_PROGRAM(SYCL_COMPILER
NAMES
dpcpp
HINTS
${_sycl_search_dirs}
PATH_SUFFIXES
bin
)
endif()
FIND_LIBRARY(SYCL_LIBRARY
NAMES
sycl
HINTS
${_sycl_search_dirs}
PATH_SUFFIXES
lib64 lib
)
FIND_PATH(SYCL_INCLUDE_DIR
NAMES
CL/sycl.hpp
HINTS
${_sycl_search_dirs}
PATH_SUFFIXES
include
include/sycl
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SYCL DEFAULT_MSG SYCL_LIBRARY SYCL_INCLUDE_DIR)
IF(SYCL_FOUND)
get_filename_component(_SYCL_INCLUDE_PARENT_DIR ${SYCL_INCLUDE_DIR} DIRECTORY)
SET(SYCL_INCLUDE_DIR ${SYCL_INCLUDE_DIR} ${_SYCL_INCLUDE_PARENT_DIR})
ELSE()
SET(SYCL_SYCL_FOUND FALSE)
ENDIF()
MARK_AS_ADVANCED(
_SYCL_INCLUDE_PARENT_DIR
)

View File

@@ -70,7 +70,7 @@ if(NOT WIN32)
set(WITH_JACK ON CACHE BOOL "" FORCE)
endif()
if(WIN32)
set(WITH_WASAPI ON CACHE BOOL "" FORCE)
set(WITH_WASAPI ON CACHE BOOL "" FORCE)
endif()
if(UNIX AND NOT APPLE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
@@ -86,4 +86,8 @@ if(NOT APPLE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUBIN_COMPILER OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_HIP_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_ONEAPI ON CACHE BOOL "" FORCE)
# Disable AoT kernels compilations until buildbot can deliver them in a reasonable time.
set(WITH_CYCLES_ONEAPI_BINARIES OFF CACHE BOOL "" FORCE)
endif()

View File

@@ -162,6 +162,9 @@ if(WITH_CODEC_FFMPEG)
mp3lame ogg opus swresample swscale
theora theoradec theoraenc vorbis vorbisenc
vorbisfile vpx x264 xvidcore)
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
list(APPEND FFMPEG_FIND_COMPONENTS aom)
endif()
find_package(FFmpeg)
endif()
@@ -467,8 +470,9 @@ string(APPEND CMAKE_CXX_FLAGS " -ftemplate-depth=1024")
# Avoid conflicts with Luxrender, and other plug-ins that may use the same
# libraries as Blender with a different version or build options.
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_apple.map)
string(APPEND PLATFORM_LINKFLAGS
" -Wl,-unexported_symbols_list,'${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map'"
" -Wl,-unexported_symbols_list,'${PLATFORM_SYMBOLS_MAP}'"
)
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")

View File

@@ -38,9 +38,15 @@ if(EXISTS ${LIBDIR})
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
# Ignore Mesa software OpenGL libraries, they are not intended to be
# linked against but to optionally override at runtime.
list(REMOVE_ITEM LIB_SUBDIRS ${LIBDIR}/mesa)
# Ignore DPC++ as it contains its own copy of LLVM/CLang which we do
# not need to be ever discovered for the Blender linking.
list(REMOVE_ITEM LIB_SUBDIRS ${LIBDIR}/dpcpp)
# NOTE: Make sure "proper" compiled zlib comes first before the one
# which is a part of OpenCollada. They have different ABI, and we
# do need to use the official one.
@@ -196,6 +202,9 @@ if(WITH_CODEC_FFMPEG)
vpx
x264
xvidcore)
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
list(APPEND FFMPEG_FIND_COMPONENTS aom)
endif()
elseif(FFMPEG)
# Old cache variable used for root dir, convert to new standard.
set(FFMPEG_ROOT_DIR ${FFMPEG})
@@ -271,6 +280,18 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL)
endif()
endif()
if(WITH_CYCLES_DEVICE_ONEAPI)
set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation")
if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR)
set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
endif()
set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to DPC++ and SYCL installation")
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
endif()
endif()
if(WITH_OPENVDB)
find_package_wrapper(OpenVDB)
find_package_wrapper(Blosc)
@@ -613,17 +634,42 @@ if(WITH_GHOST_WAYLAND)
pkg_check_modules(wayland-scanner REQUIRED wayland-scanner)
pkg_check_modules(xkbcommon REQUIRED xkbcommon)
pkg_check_modules(wayland-cursor REQUIRED wayland-cursor)
pkg_check_modules(dbus REQUIRED dbus-1)
set(WITH_GL_EGL ON)
if(WITH_GHOST_WAYLAND_DBUS)
pkg_check_modules(dbus REQUIRED dbus-1)
endif()
if(WITH_GHOST_WAYLAND_LIBDECOR)
pkg_check_modules(libdecor REQUIRED libdecor-0>=0.1)
endif()
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LINK_LIBRARIES}
${wayland-egl_LINK_LIBRARIES}
${xkbcommon_LINK_LIBRARIES}
${wayland-cursor_LINK_LIBRARIES}
${dbus_LINK_LIBRARIES}
)
if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LINK_LIBRARIES}
${wayland-egl_LINK_LIBRARIES}
${wayland-cursor_LINK_LIBRARIES}
)
endif()
if(WITH_GHOST_WAYLAND_DBUS)
list(APPEND PLATFORM_LINKLIBS
${dbus_LINK_LIBRARIES}
)
add_definitions(-DWITH_GHOST_WAYLAND_DBUS)
endif()
if(WITH_GHOST_WAYLAND_LIBDECOR)
if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
list(APPEND PLATFORM_LINKLIBS
${libdecor_LIBRARIES}
)
endif()
add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
endif()
endif()
if(WITH_GHOST_X11)
@@ -842,8 +888,9 @@ unset(_IS_LINKER_DEFAULT)
# Avoid conflicts with Mesa llvmpipe, Luxrender, and other plug-ins that may
# use the same libraries as Blender with a different version or build options.
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_unix.map)
set(PLATFORM_LINKFLAGS
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'"
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${PLATFORM_SYMBOLS_MAP}'"
)
# Don't use position independent executable for portable install since file

View File

@@ -950,3 +950,6 @@ endif()
set(ZSTD_INCLUDE_DIRS ${LIBDIR}/zstd/include)
set(ZSTD_LIBRARIES ${LIBDIR}/zstd/lib/zstd_static.lib)
set(LEVEL_ZERO_ROOT_DIR ${LIBDIR}/level_zero)
set(SYCL_ROOT_DIR ${LIBDIR}/dpcpp)

View File

@@ -54,6 +54,8 @@ buildbot:
version: '10.1.243'
cuda11:
version: '11.4.1'
hip:
version: '5.2.21440'
optix:
version: '7.3.0'
cmake:

View File

@@ -38,7 +38,7 @@ PROJECT_NAME = Blender
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = V3.3
PROJECT_NUMBER = V3.4
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@@ -1,59 +1,111 @@
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Dump the python API into a text file so we can generate changelogs.
---------------
output from this tool should be added into "doc/python_api/rst/change_log.rst"
Dump the python API into a JSON file, or generate changelogs from those JSON API dumps.
# dump api blender_version.py in CWD
blender --background --python doc/python_api/sphinx_changelog_gen.py -- --dump
Typically, changelog output from this tool should be added into "doc/python_api/rst/change_log.rst"
# create changelog
API dump files are saved together with the generated API doc on the server, with a general index file.
This way the changelog generation simply needs to re-download the previous version's dump for the diffing process.
---------------
# Dump api blender_version.json in CWD:
blender --background --factory-startup --python doc/python_api/sphinx_changelog_gen.py -- \
--indexpath="path/to/api/docs/api_dump_index.json" \
dump --filepath-out="path/to/api/docs/<version>/api_dump.json"
# Create changelog:
blender --background --factory-startup --python doc/python_api/sphinx_changelog_gen.py -- \
--api_from blender_2_63_0.py \
--api_to blender_2_64_0.py \
--api_out changes.rst
--indexpath="path/to/api/docs/api_dump_index.json" \
changelog --filepath-out doc/python_api/rst/change_log.rst
# Api comparison can also run without blender
# Api comparison can also run without blender,
# will by default generate changeloig between the last two available versions listed in the index,
# unless input files are provided explicitely:
python doc/python_api/sphinx_changelog_gen.py -- \
--api_from blender_api_2_63_0.py \
--api_to blender_api_2_64_0.py \
--api_out changes.rst
--indexpath="path/to/api/docs/api_dump_index.json" \
changelog --filepath-in-from blender_api_2_63_0.json \
--filepath-in-to blender_api_2_64_0.json \
--filepath-out changes.rst
# Save the latest API dump in this folder, renaming it with its revision.
# This way the next person updating it doesn't need to build an old Blender only for that
--------------
API dump index format:
{[version_main, version_sub]: "<version>/api_dump.json", ...
}
API dump format:
[
[version_main, vserion_sub, version_path],
{"module.name":
{"parent.class":
{"basic_type", "member_name":
["Name", type, range, length, default, descr, f_args, f_arg_types, f_ret_types]}, ...
}, ...
}
]
"""
# format
'''
{"module.name":
{"parent.class":
{"basic_type", "member_name":
("Name", type, range, length, default, descr, f_args, f_arg_types, f_ret_types)}, ...
}, ...
}
'''
import json
import os
api_names = "basic_type" "name", "type", "range", "length", "default", "descr", "f_args", "f_arg_types", "f_ret_types"
API_BASIC_TYPE = 0
API_F_ARGS = 7
def api_dunp_fname():
import bpy
return "blender_api_%s.py" % "_".join([str(i) for i in bpy.app.version])
def api_version():
try:
import bpy
except:
return None, None
version = tuple(bpy.app.version[:2])
version_key = "%d.%d" % (version[0], version[1])
return version, version_key
def api_dump():
dump = {}
dump_module = dump["bpy.types"] = {}
def api_version_previous_in_index(index, version):
print("Searching for previous version to %s in %r" % (version, index))
version_prev = (version[0], version[1])
while True:
version_prev = (version_prev[0], version_prev[1] - 1)
if version_prev[1] < 0:
version_prev = (version_prev[0] - 1, 99)
if version_prev[0] < 0:
return None, None
version_prev_key = "%d.%d" % (version_prev[0], version_prev[1])
if version_prev_key in index:
print("Found previous version %s: %r" % (version_prev, index[version_prev_key]))
return version_prev, version_prev_key
class JSONEncoderAPIDump(json.JSONEncoder):
def default(self, o):
if o is ...:
return "..."
if isinstance(o, set):
return tuple(o)
return json.JSONEncoder.default(self, o)
def api_dump(args):
import rna_info
import inspect
version, version_key = api_version()
if version is None:
raise(ValueError("API dumps can only be generated from within Blender."))
dump = {}
dump_module = dump["bpy.types"] = {}
struct = rna_info.BuildRNAInfo()[0]
for struct_id, struct_info in sorted(struct.items()):
@@ -155,17 +207,25 @@ def api_dump():
)
del funcs
import pprint
filepath_out = args.filepath_out
with open(filepath_out, 'w', encoding='utf-8') as file_handle:
json.dump((version, dump), file_handle, cls=JSONEncoderAPIDump)
filename = api_dunp_fname()
filehandle = open(filename, 'w', encoding='utf-8')
tot = filehandle.write(pprint.pformat(dump, width=1))
filehandle.close()
print("%s, %d bytes written" % (filename, tot))
indexpath = args.indexpath
rootpath = os.path.dirname(indexpath)
if os.path.exists(indexpath):
with open(indexpath, 'r', encoding='utf-8') as file_handle:
index = json.load(file_handle)
else:
index = {}
index[version_key] = os.path.relpath(filepath_out, rootpath)
with open(indexpath, 'w', encoding='utf-8') as file_handle:
json.dump(index, file_handle)
print("API version %s dumped into %r, and index %r has been updated" % (version_key, filepath_out, indexpath))
def compare_props(a, b, fuzz=0.75):
# must be same basic_type, function != property
if a[0] != b[0]:
return False
@@ -180,15 +240,44 @@ def compare_props(a, b, fuzz=0.75):
return ((tot / totlen) >= fuzz)
def api_changelog(api_from, api_to, api_out):
def api_changelog(args):
indexpath = args.indexpath
filepath_in_from = args.filepath_in_from
filepath_in_to = args.filepath_in_to
filepath_out = args.filepath_out
file_handle = open(api_from, 'r', encoding='utf-8')
dict_from = eval(file_handle.read())
file_handle.close()
rootpath = os.path.dirname(indexpath)
file_handle = open(api_to, 'r', encoding='utf-8')
dict_to = eval(file_handle.read())
file_handle.close()
version, version_key = api_version()
if version is None and (filepath_in_from is None or filepath_in_to is None):
raise(ValueError("API dumps files must be given when ran outside of Blender."))
with open(indexpath, 'r', encoding='utf-8') as file_handle:
index = json.load(file_handle)
if filepath_in_to is None:
filepath_in_to = index.get(version_key, None)
if filepath_in_to is None:
raise(ValueError("Cannot find API dump file for Blender version " + str(version) + " in index file."))
print("Found to file: %r" % filepath_in_to)
if filepath_in_from is None:
version_from, version_from_key = api_version_previous_in_index(index, version)
if version_from is None:
raise(ValueError("No previous version of Blender could be found in the index."))
filepath_in_from = index.get(version_from_key, None)
if filepath_in_from is None:
raise(ValueError("Cannot find API dump file for previous Blender version " + str(version_from) + " in index file."))
print("Found from file: %r" % filepath_in_from)
with open(os.path.join(rootpath, filepath_in_from), 'r', encoding='utf-8') as file_handle:
_, dict_from = json.load(file_handle)
with open(os.path.join(rootpath, filepath_in_to), 'r', encoding='utf-8') as file_handle:
dump_version, dict_to = json.load(file_handle)
assert(tuple(dump_version) == version)
api_changes = []
@@ -249,63 +338,66 @@ def api_changelog(api_from, api_to, api_out):
# also document function argument changes
fout = open(api_out, 'w', encoding='utf-8')
fw = fout.write
# print(api_changes)
with open(filepath_out, 'w', encoding='utf-8') as fout:
fw = fout.write
# :class:`bpy_struct.id_data`
# Write header.
fw(""
":tocdepth: 2\n"
"\n"
"Blender API Change Log\n"
"**********************\n"
"\n"
".. note, this document is auto generated by sphinx_changelog_gen.py\n"
"\n"
"\n"
"%s to %s\n"
"============\n"
"\n" % (version_from_key, version_key))
def write_title(title, title_char):
fw("%s\n%s\n\n" % (title, title_char * len(title)))
def write_title(title, title_char):
fw("%s\n%s\n\n" % (title, title_char * len(title)))
for mod_id, class_id, props_moved, props_new, props_old, func_args in api_changes:
class_name = class_id.split(".")[-1]
title = mod_id + "." + class_name
write_title(title, "-")
for mod_id, class_id, props_moved, props_new, props_old, func_args in api_changes:
class_name = class_id.split(".")[-1]
title = mod_id + "." + class_name
write_title(title, "-")
if props_new:
write_title("Added", "^")
for prop_id in props_new:
fw("* :class:`%s.%s.%s`\n" % (mod_id, class_name, prop_id))
fw("\n")
if props_new:
write_title("Added", "^")
for prop_id in props_new:
fw("* :class:`%s.%s.%s`\n" % (mod_id, class_name, prop_id))
fw("\n")
if props_old:
write_title("Removed", "^")
for prop_id in props_old:
fw("* **%s**\n" % prop_id) # can't link to removed docs
fw("\n")
if props_old:
write_title("Removed", "^")
for prop_id in props_old:
fw("* **%s**\n" % prop_id) # can't link to removed docs
fw("\n")
if props_moved:
write_title("Renamed", "^")
for prop_id_old, prop_id in props_moved:
fw("* **%s** -> :class:`%s.%s.%s`\n" % (prop_id_old, mod_id, class_name, prop_id))
fw("\n")
if props_moved:
write_title("Renamed", "^")
for prop_id_old, prop_id in props_moved:
fw("* **%s** -> :class:`%s.%s.%s`\n" % (prop_id_old, mod_id, class_name, prop_id))
fw("\n")
if func_args:
write_title("Function Arguments", "^")
for func_id, args_old, args_new in func_args:
args_new = ", ".join(args_new)
args_old = ", ".join(args_old)
fw("* :class:`%s.%s.%s` (%s), *was (%s)*\n" % (mod_id, class_name, func_id, args_new, args_old))
fw("\n")
if func_args:
write_title("Function Arguments", "^")
for func_id, args_old, args_new in func_args:
args_new = ", ".join(args_new)
args_old = ", ".join(args_old)
fw("* :class:`%s.%s.%s` (%s), *was (%s)*\n" % (mod_id, class_name, func_id, args_new, args_old))
fw("\n")
fout.close()
print("Written: %r" % api_out)
print("Written: %r" % filepath_out)
def main():
def main(argv=None):
import sys
import os
import argparse
try:
import argparse
except ImportError:
print("Old Blender, just dumping")
api_dump()
return
argv = sys.argv
if argv is None:
argv = sys.argv
if "--" not in argv:
argv = [] # as if no args are passed
@@ -316,42 +408,42 @@ def main():
usage_text = "Run blender in background mode with this script: "
"blender --background --factory-startup --python %s -- [options]" % os.path.basename(__file__)
epilog = "Run this before releases"
parser = argparse.ArgumentParser(description=usage_text, epilog=epilog)
parser = argparse.ArgumentParser(description=usage_text,
epilog=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
"--dump", dest="dump", action='store_true',
help="When set the api will be dumped into blender_version.py")
"--indexpath", dest="indexpath", metavar='FILE', required=True,
help="Path of the JSON file containing the index of all available API dumps.")
parser.add_argument(
"--api_from", dest="api_from", metavar='FILE',
help="File to compare from (previous version)")
parser.add_argument(
"--api_to", dest="api_to", metavar='FILE',
help="File to compare from (current)")
parser.add_argument(
"--api_out", dest="api_out", metavar='FILE',
help="Output sphinx changelog")
parser_commands = parser.add_subparsers(required=True)
args = parser.parse_args(argv) # In this example we won't use the args
parser_dump = parser_commands.add_parser('dump', help="Dump the current Blender Python API into a JSON file.")
parser_dump.add_argument(
"--filepath-out", dest="filepath_out", metavar='FILE', required=True,
help="Path of the JSON file containing the dump of the API.")
parser_dump.set_defaults(func=api_dump)
if not argv:
print("No args given!")
parser.print_help()
return
parser_changelog = parser_commands.add_parser(
'changelog',
help="Generate the RST changelog page based on two Blender Python API JSON dumps.",
)
if args.dump:
api_dump()
else:
if args.api_from and args.api_to and args.api_out:
api_changelog(args.api_from, args.api_to, args.api_out)
else:
print("Error: --api_from/api_to/api_out args needed")
parser.print_help()
return
parser_changelog.add_argument(
"--filepath-in-from", dest="filepath_in_from", metavar='FILE', default=None,
help="JSON dump file to compare from (typically, previous version). "
"If not given, will be automatically determined from current Blender version and index file.")
parser_changelog.add_argument(
"--filepath-in-to", dest="filepath_in_to", metavar='FILE', default=None,
help="JSON dump file to compare to (typically, current version). "
"If not given, will be automatically determined from current Blender version and index file.")
parser_changelog.add_argument(
"--filepath-out", dest="filepath_out", metavar='FILE', required=True,
help="Output sphinx changelog RST file.")
parser_changelog.set_defaults(func=api_changelog)
print("batch job finished, exiting")
args = parser.parse_args(argv)
args.func(args)
if __name__ == "__main__":

View File

@@ -141,6 +141,26 @@ def handle_args():
required=False,
)
parser.add_argument(
"--api-changelog-generate",
dest="changelog",
default=False,
action='store_true',
help="Generate the API changelog RST file "
"(default=False, requires `--api-dump-index-path` parameter)",
required=False,
)
parser.add_argument(
"--api-dump-index-path",
dest="api_dump_index_path",
metavar='FILE',
default=None,
help="Path to the API dump index JSON file "
"(required when `--api-changelog-generate` is True)",
required=False,
)
parser.add_argument(
"-o", "--output",
dest="output_dir",
@@ -514,6 +534,42 @@ if ARGS.sphinx_build_pdf:
sphinx_make_pdf_log = os.path.join(ARGS.output_dir, ".latex_make.log")
SPHINX_MAKE_PDF_STDOUT = open(sphinx_make_pdf_log, "w", encoding="utf-8")
# --------------------------------CHANGELOG GENERATION--------------------------------------
def generate_changelog():
import importlib.util
spec = importlib.util.spec_from_file_location(
"sphinx_changelog_gen",
os.path.abspath(os.path.join(SCRIPT_DIR, "sphinx_changelog_gen.py")),
)
sphinx_changelog_gen = importlib.util.module_from_spec(spec)
spec.loader.exec_module(sphinx_changelog_gen)
API_DUMP_INDEX_FILEPATH = ARGS.api_dump_index_path
API_DUMP_ROOT = os.path.dirname(API_DUMP_INDEX_FILEPATH)
API_DUMP_FILEPATH = os.path.abspath(os.path.join(API_DUMP_ROOT, BLENDER_VERSION_DOTS, "api_dump.json"))
API_CHANGELOG_FILEPATH = os.path.abspath(os.path.join(SPHINX_IN_TMP, "change_log.rst"))
sphinx_changelog_gen.main((
"--",
"--indexpath",
API_DUMP_INDEX_FILEPATH,
"dump",
"--filepath-out",
API_DUMP_FILEPATH,
))
sphinx_changelog_gen.main((
"--",
"--indexpath",
API_DUMP_INDEX_FILEPATH,
"changelog",
"--filepath-out",
API_CHANGELOG_FILEPATH,
))
# --------------------------------API DUMP--------------------------------------
# Lame, python won't give some access.
@@ -1075,6 +1131,7 @@ def pymodule2sphinx(basepath, module_name, module, title, module_all_extra):
# Changes In Blender will force errors here.
context_type_map = {
# context_member: (RNA type, is_collection)
"active_action": ("Action", False),
"active_annotation_layer": ("GPencilLayer", False),
"active_bone": ("EditBone", False),
"active_file": ("FileSelectEntry", False),
@@ -1473,7 +1530,8 @@ def pyrna2sphinx(basepath):
else:
fw(".. class:: %s\n\n" % struct_id)
fw(" %s\n\n" % struct.description)
write_indented_lines(" ", fw, struct.description, False)
fw("\n")
# Properties sorted in alphabetical order.
sorted_struct_properties = struct.properties[:]
@@ -2473,6 +2531,9 @@ def main():
rna2sphinx(SPHINX_IN_TMP)
if ARGS.changelog:
generate_changelog()
if ARGS.full_rebuild:
# Only for full updates.
shutil.rmtree(SPHINX_IN, True)

View File

@@ -270,7 +270,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int sampl
return length;
}
AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data)
AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data, char* error, size_t errorsize)
{
try
{
@@ -282,15 +282,20 @@ AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned i
std::shared_ptr<IWriter> writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast<Container>(format), static_cast<Codec>(codec), bitrate);
FileWriter::writeReader(reader, writer, length, buffersize, callback, data);
return nullptr;
return true;
}
catch(Exception& e)
{
return e.getMessage().c_str();
if(error && errorsize)
{
std::strncpy(error, e.getMessage().c_str(), errorsize);
error[errorsize - 1] = '\0';
}
return false;
}
}
AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data)
AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data, char* error, size_t errorsize)
{
try
{
@@ -328,11 +333,16 @@ AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start
reader->seek(start);
FileWriter::writeReader(reader, writers, length, buffersize, callback, data);
return nullptr;
return true;
}
catch(Exception& e)
{
return e.getMessage().c_str();
if(error && errorsize)
{
std::strncpy(error, e.getMessage().c_str(), errorsize);
error[errorsize - 1] = '\0';
}
return false;
}
}

View File

@@ -70,13 +70,15 @@ extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, in
* \param bitrate The bitrate for encoding.
* \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL.
* \param data Pass through parameter that is passed to the callback.
* \return An error message or NULL in case of success.
* \param error String buffer to copy the error message to in case of failure.
* \param errorsize The size of the error buffer.
* \return Whether or not the operation succeeded.
*/
extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
extern AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate,
void(*callback)(float, void*), void* data);
void(*callback)(float, void*), void* data, char* error, size_t errorsize);
/**
* Mixes a sound down into multiple files.
@@ -91,13 +93,15 @@ extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, uns
* \param bitrate The bitrate for encoding.
* \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL.
* \param data Pass through parameter that is passed to the callback.
* \return An error message or NULL in case of success.
* \param error String buffer to copy the error message to in case of failure.
* \param errorsize The size of the error buffer.
* \return Whether or not the operation succeeded.
*/
extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
extern AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length,
unsigned int buffersize, const char* filename,
AUD_DeviceSpecs specs, AUD_Container format,
AUD_Codec codec, unsigned int bitrate,
void(*callback)(float, void*), void* data);
void(*callback)(float, void*), void* data, char* error, size_t errorsize);
/**
* Opens a read device and prepares it for mixdown of the sound scene.

View File

@@ -41,7 +41,7 @@ double PulseAudioDevice::PulseAudioSynchronizer::getPosition(std::shared_ptr<IHa
void PulseAudioDevice::updateRingBuffer()
{
unsigned int samplesize = AUD_SAMPLE_SIZE(m_specs);
unsigned int samplesize = AUD_DEVICE_SAMPLE_SIZE(m_specs);
std::unique_lock<std::mutex> lock(m_mixingLock);

View File

@@ -1,5 +1,5 @@
Project: Curve-Fit-nD
URL: https://github.com/ideasman42/curve-fit-nd
License: BSD 3-Clause
Upstream version: ddcd5bd (Last Release)
Upstream version: ae32da9de264c3ed399673e2bc1bc09003799416 (Last Release)
Local modifications: None

View File

@@ -39,7 +39,7 @@
* Takes a flat array of points and evaluates that to calculate a bezier spline.
*
* \param points, points_len: The array of points to calculate a cubics from.
* \param dims: The number of dimensions for for each element in \a points.
* \param dims: The number of dimensions for each element in \a points.
* \param error_threshold: the error threshold to allow for,
* the curve will be within this distance from \a points.
* \param corners, corners_len: indices for points which will not have aligned tangents (optional).
@@ -47,10 +47,10 @@
* to evaluate a line to detect corner indices.
*
* \param r_cubic_array, r_cubic_array_len: Resulting array of tangents and knots, formatted as follows:
* ``r_cubic_array[r_cubic_array_len][3][dims]``,
* `r_cubic_array[r_cubic_array_len][3][dims]`,
* where each point has 0 and 2 for the tangents and the middle index 1 for the knot.
* The size of the *flat* array will be ``r_cubic_array_len * 3 * dims``.
* \param r_corner_index_array, r_corner_index_len: Corner indices in in \a r_cubic_array (optional).
* The size of the *flat* array will be `r_cubic_array_len * 3 * dims`.
* \param r_corner_index_array, r_corner_index_len: Corner indices in \a r_cubic_array (optional).
* This allows you to access corners on the resulting curve.
*
* \returns zero on success, nonzero is reserved for error values.
@@ -85,7 +85,7 @@ int curve_fit_cubic_to_points_fl(
* Takes a flat array of points and evaluates that to calculate handle lengths.
*
* \param points, points_len: The array of points to calculate a cubics from.
* \param dims: The number of dimensions for for each element in \a points.
* \param dims: The number of dimensions for each element in \a points.
* \param points_length_cache: Optional pre-calculated lengths between points.
* \param error_threshold: the error threshold to allow for,
* \param tan_l, tan_r: Normalized tangents the handles will be aligned to.
@@ -166,7 +166,7 @@ int curve_fit_cubic_to_points_refit_fl(
* A helper function that takes a line and outputs its corner indices.
*
* \param points, points_len: Curve to evaluate.
* \param dims: The number of dimensions for for each element in \a points.
* \param dims: The number of dimensions for each element in \a points.
* \param radius_min: Corners on the curve between points below this radius are ignored.
* \param radius_max: Corners on the curve above this radius are ignored.
* \param samples_max: Prevent testing corners beyond this many points

View File

@@ -43,20 +43,24 @@
#include "../curve_fit_nd.h"
/* Take curvature into account when calculating the least square solution isn't usable. */
/** Take curvature into account when calculating the least square solution isn't usable. */
#define USE_CIRCULAR_FALLBACK
/* Use the maximum distance of any points from the direct line between 2 points
/**
* Use the maximum distance of any points from the direct line between 2 points
* to calculate how long the handles need to be.
* Can do a 'perfect' reversal of subdivision when for curve has symmetrical handles and doesn't change direction
* (as with an 'S' shape). */
* (as with an 'S' shape).
*/
#define USE_OFFSET_FALLBACK
/* avoid re-calculating lengths multiple times */
/** Avoid re-calculating lengths multiple times. */
#define USE_LENGTH_CACHE
/* store the indices in the cubic data so we can return the original indices,
* useful when the caller has data associated with the curve. */
/**
* Store the indices in the cubic data so we can return the original indices,
* useful when the caller has data associated with the curve.
*/
#define USE_ORIG_INDEX_DATA
typedef unsigned int uint;
@@ -95,13 +99,15 @@ typedef unsigned int uint;
* \{ */
typedef struct Cubic {
/* single linked lists */
/** Single linked lists. */
struct Cubic *next;
#ifdef USE_ORIG_INDEX_DATA
uint orig_span;
#endif
/* 0: point_0, 1: handle_0, 2: handle_1, 3: point_1,
* each one is offset by 'dims' */
/**
* 0: point_0, 1: handle_0, 2: handle_1, 3: point_1,
* each one is offset by 'dims'.
*/
double pt_data[0];
} Cubic;
@@ -195,7 +201,7 @@ static double *cubic_list_as_array(
bool use_orig_index = (r_orig_index != NULL);
#endif
/* fill the array backwards */
/* Fill the array backwards. */
const size_t array_chunk = 3 * dims;
double *array_iter = array + array_flat_len;
for (Cubic *citer = clist->items; citer; citer = citer->next) {
@@ -221,15 +227,15 @@ static double *cubic_list_as_array(
}
#endif
/* flip tangent for first and last (we could leave at zero, but set to something useful) */
/* Flip tangent for first and last (we could leave at zero, but set to something useful). */
/* first */
/* First. */
array_iter -= array_chunk;
memcpy(&array_iter[dims], handle_prev, sizeof(double) * 2 * dims);
flip_vn_vnvn(&array_iter[0 * dims], &array_iter[1 * dims], &array_iter[2 * dims], dims);
assert(array == array_iter);
/* last */
/* Last. */
array_iter += array_flat_len - (3 * dims);
flip_vn_vnvn(&array_iter[2 * dims], &array_iter[1 * dims], &array_iter[0 * dims], dims);
@@ -455,7 +461,7 @@ static double points_calc_circumference_factor(
const double dot = dot_vnvn(tan_l, tan_r, dims);
const double len_tangent = dot < 0.0 ? len_vnvn(tan_l, tan_r, dims) : len_negated_vnvn(tan_l, tan_r, dims);
if (len_tangent > DBL_EPSILON) {
/* only clamp to avoid precision error */
/* Only clamp to avoid precision error. */
double angle = acos(max(-fabs(dot), -1.0));
/* Angle may be less than the length when the tangents define >180 degrees of the circle,
* (tangents that point away from each other).
@@ -466,7 +472,7 @@ static double points_calc_circumference_factor(
return factor;
}
else {
/* tangents are exactly aligned (think two opposite sides of a circle). */
/* Tangents are exactly aligned (think two opposite sides of a circle). */
return (M_PI / 2);
}
}
@@ -485,18 +491,18 @@ static double points_calc_circle_tangent_factor(
const double eps = 1e-8;
const double tan_dot = dot_vnvn(tan_l, tan_r, dims);
if (tan_dot > 1.0 - eps) {
/* no angle difference (use fallback, length wont make any difference) */
/* No angle difference (use fallback, length won't make any difference). */
return (1.0 / 3.0) * 0.75;
}
else if (tan_dot < -1.0 + eps) {
/* parallel tangents (half-circle) */
/* Parallel tangents (half-circle). */
return (1.0 / 2.0);
}
else {
/* non-aligned tangents, calculate handle length */
/* Non-aligned tangents, calculate handle length. */
const double angle = acos(tan_dot) / 2.0;
/* could also use 'angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0' */
/* Could also use `angle_sin = len_vnvn(tan_l, tan_r, dims) / 2.0`. */
const double angle_sin = sin(angle);
const double angle_cos = cos(angle);
return ((1.0 - angle_cos) / (angle_sin * 2.0)) / angle_sin;
@@ -516,15 +522,15 @@ static double points_calc_cubic_scale(
const double len_direct = len_vnvn(v_l, v_r, dims);
const double len_circle_factor = points_calc_circle_tangent_factor(tan_l, tan_r, dims);
/* if this curve is a circle, this value doesn't need modification */
/* If this curve is a circle, this value doesn't need modification. */
const double len_circle_handle = (len_direct * (len_circle_factor / 0.75));
/* scale by the difference from the circumference distance */
/* Scale by the difference from the circumference distance. */
const double len_circle = len_direct * points_calc_circumference_factor(tan_l, tan_r, dims);
double scale_handle = (coords_length / len_circle);
/* Could investigate an accurate calculation here,
* though this gives close results */
* though this gives close results. */
scale_handle = ((scale_handle - 1.0) * 1.75) + 1.0;
return len_circle_handle * scale_handle;
@@ -554,9 +560,8 @@ static void cubic_from_points_fallback(
r_cubic->orig_span = (points_offset_len - 1);
#endif
/* p1 = p0 - (tan_l * alpha);
* p2 = p3 + (tan_r * alpha);
*/
/* `p1 = p0 - (tan_l * alpha);`
* `p2 = p3 + (tan_r * alpha);` */
msub_vn_vnvn_fl(p1, p0, tan_l, alpha, dims);
madd_vn_vnvn_fl(p2, p3, tan_r, alpha, dims);
}
@@ -594,7 +599,7 @@ static void cubic_from_points_offset_fallback(
project_plane_vn_vnvn_normalized(a[0], tan_l, dir_unit, dims);
project_plane_vn_vnvn_normalized(a[1], tan_r, dir_unit, dims);
/* only for better accuracy, not essential */
/* Only for better accuracy, not essential. */
normalize_vn(a[0], dims);
normalize_vn(a[1], dims);
@@ -620,7 +625,7 @@ static void cubic_from_points_offset_fallback(
*
* The 'dists[..] + dir_dirs' limit is just a rough approximation.
* While a more exact value could be calculated,
* in this case the error values approach divide by zero (inf)
* in this case the error values approach divide by zero (infinite)
* so there is no need to be too precise when checking if limits have been exceeded. */
double alpha_l = (dists[0] / 0.75) / fabs(dot_vnvn(tan_l, a[0], dims));
@@ -644,9 +649,8 @@ static void cubic_from_points_offset_fallback(
r_cubic->orig_span = (points_offset_len - 1);
#endif
/* p1 = p0 - (tan_l * alpha_l);
* p2 = p3 + (tan_r * alpha_r);
*/
/* `p1 = p0 - (tan_l * alpha_l);`
* `p2 = p3 + (tan_r * alpha_r);` */
msub_vn_vnvn_fl(p1, p0, tan_l, alpha_l, dims);
madd_vn_vnvn_fl(p2, p3, tan_r, alpha_r, dims);
}
@@ -674,7 +678,7 @@ static void cubic_from_points(
const double *p0 = &points_offset[0];
const double *p3 = &points_offset[(points_offset_len - 1) * dims];
/* Point Pairs */
/* Point Pairs. */
double alpha_l, alpha_r;
#ifdef USE_VLA
double a[2][dims];
@@ -696,7 +700,7 @@ static void cubic_from_points(
const double b0_plus_b1 = B0plusB1(u_prime[i]);
const double b2_plus_b3 = B2plusB3(u_prime[i]);
/* inline dot product */
/* Inline dot product. */
for (uint j = 0; j < dims; j++) {
const double tmp = (pt[j] - (p0[j] * b0_plus_b1)) + (p3[j] * b2_plus_b3);
@@ -719,7 +723,7 @@ static void cubic_from_points(
det_C0_C1 = c[0][0] * c[1][1] * 10e-12;
}
/* may still divide-by-zero, check below will catch nan values */
/* May still divide-by-zero, check below will catch NAN values. */
alpha_l = det_X_C1 / det_C0_C1;
alpha_r = det_C_0X / det_C0_C1;
}
@@ -736,7 +740,7 @@ static void cubic_from_points(
bool use_clamp = true;
/* flip check to catch nan values */
/* Flip check to catch NAN values. */
if (!(alpha_l >= 0.0) ||
!(alpha_r >= 0.0))
{
@@ -750,7 +754,7 @@ static void cubic_from_points(
alpha_l = alpha_r = len_vnvn(p0, p3, dims) / 3.0;
#endif
/* skip clamping when we're using default handles */
/* Skip clamping when we're using default handles. */
use_clamp = false;
}
@@ -764,9 +768,8 @@ static void cubic_from_points(
r_cubic->orig_span = (points_offset_len - 1);
#endif
/* p1 = p0 - (tan_l * alpha_l);
* p2 = p3 + (tan_r * alpha_r);
*/
/* `p1 = p0 - (tan_l * alpha_l);`
* `p2 = p3 + (tan_r * alpha_r);` */
msub_vn_vnvn_fl(p1, p0, tan_l, alpha_l, dims);
madd_vn_vnvn_fl(p2, p3, tan_r, alpha_r, dims);
@@ -781,7 +784,7 @@ static void cubic_from_points(
#endif
points_calc_center_weighted(points_offset, points_offset_len, dims, center);
const double clamp_scale = 3.0; /* clamp to 3x */
const double clamp_scale = 3.0; /* Clamp to 3x. */
double dist_sq_max = 0.0;
{
@@ -790,7 +793,7 @@ static void cubic_from_points(
#if 0
double dist_sq_test = sq(len_vnvn(center, pt, dims) * clamp_scale);
#else
/* do inline */
/* Do inline. */
double dist_sq_test = 0.0;
for (uint j = 0; j < dims; j++) {
dist_sq_test += sq((pt[j] - center[j]) * clamp_scale);
@@ -816,10 +819,8 @@ static void cubic_from_points(
alpha_l = alpha_r = len_vnvn(p0, p3, dims) / 3.0;
#endif
/*
* p1 = p0 - (tan_l * alpha_l);
* p2 = p3 + (tan_r * alpha_r);
*/
/* `p1 = p0 - (tan_l * alpha_l);`
* `p2 = p3 + (tan_r * alpha_r);` */
for (uint j = 0; j < dims; j++) {
p1[j] = p0[j] - (tan_l[j] * alpha_l);
p2[j] = p3[j] + (tan_r[j] * alpha_r);
@@ -829,7 +830,7 @@ static void cubic_from_points(
p2_dist_sq = len_squared_vnvn(center, p2, dims);
}
/* clamp within the 3x radius */
/* Clamp within the 3x radius. */
if (p1_dist_sq > dist_sq_max) {
isub_vnvn(p1, center, dims);
imul_vn_fl(p1, sqrt(dist_sq_max) / sqrt(p1_dist_sq), dims);
@@ -841,7 +842,7 @@ static void cubic_from_points(
iadd_vnvn(p2, center, dims);
}
}
/* end clamping */
/* End clamping. */
}
#ifdef USE_LENGTH_CACHE
@@ -917,7 +918,7 @@ static double cubic_find_root(
const uint dims)
{
/* Newton-Raphson Method. */
/* all vectors */
/* All vectors. */
#ifdef USE_VLA
double q0_u[dims];
double q1_u[dims];
@@ -932,8 +933,8 @@ static double cubic_find_root(
cubic_calc_speed(cubic, u, dims, q1_u);
cubic_calc_acceleration(cubic, u, dims, q2_u);
/* may divide-by-zero, caller must check for that case */
/* u - ((q0_u - p) * q1_u) / (q1_u.length_squared() + (q0_u - p) * q2_u) */
/* May divide-by-zero, caller must check for that case. */
/* `u - ((q0_u - p) * q1_u) / (q1_u.length_squared() + (q0_u - p) * q2_u)` */
isub_vnvn(q0_u, p, dims);
return u - dot_vnvn(q0_u, q1_u, dims) /
(len_squared_vn(q1_u, dims) + dot_vnvn(q0_u, q2_u, dims));
@@ -1032,7 +1033,7 @@ static bool fit_cubic_to_points(
double error_max_sq;
uint split_index;
/* Parameterize points, and attempt to fit curve */
/* Parameterize points, and attempt to fit curve. */
cubic_from_points(
points_offset, points_offset_len,
#ifdef USE_CIRCULAR_FALLBACK
@@ -1040,7 +1041,7 @@ static bool fit_cubic_to_points(
#endif
u, tan_l, tan_r, dims, r_cubic);
/* Find max deviation of points to fitted curve */
/* Find max deviation of points to fitted curve. */
error_max_sq = cubic_calc_error(
r_cubic, points_offset, points_offset_len, u, dims,
&split_index);
@@ -1062,7 +1063,7 @@ static bool fit_cubic_to_points(
cubic_test, points_offset, points_offset_len, u, dims,
&split_index);
/* intentionally use the newly calculated 'split_index',
/* Intentionally use the newly calculated 'split_index',
* even if the 'error_max_sq_test' is worse. */
if (error_max_sq > error_max_sq_test) {
error_max_sq = error_max_sq_test;
@@ -1071,7 +1072,7 @@ static bool fit_cubic_to_points(
}
#endif
/* Test the offset fallback */
/* Test the offset fallback. */
#ifdef USE_OFFSET_FALLBACK
if (!(error_max_sq < error_threshold_sq)) {
/* Using the offset from the curve to calculate cubic handle length may give better results
@@ -1095,7 +1096,7 @@ static bool fit_cubic_to_points(
if (!(error_max_sq < error_threshold_sq)) {
cubic_copy(cubic_test, r_cubic, dims);
/* If error not too large, try some reparameterization and iteration */
/* If error not too large, try some re-parameterization and iteration. */
double *u_prime = malloc(sizeof(double) * points_offset_len);
for (uint iter = 0; iter < iteration_max; iter++) {
if (!cubic_reparameterize(
@@ -1123,7 +1124,7 @@ static bool fit_cubic_to_points(
}
if (!(error_max_sq < error_threshold_sq)) {
/* continue */
/* Continue. */
}
else {
assert((error_max_sq < error_threshold_sq));
@@ -1156,7 +1157,7 @@ static void fit_cubic_to_points_recursive(
const double error_threshold_sq,
const uint calc_flag,
const uint dims,
/* fill in the list */
/* Fill in the list. */
CubicList *clist)
{
Cubic *cubic = cubic_alloc(dims);
@@ -1180,7 +1181,7 @@ static void fit_cubic_to_points_recursive(
cubic_free(cubic);
/* Fitting failed -- split at max error point and fit recursively */
/* Fitting failed -- split at max error point and fit recursively. */
/* Check splinePoint is not an endpoint?
*
@@ -1212,7 +1213,7 @@ static void fit_cubic_to_points_recursive(
#endif
const double *pt = &points_offset[split_index * dims];
/* tan_center = ((pt_a - pt).normalized() + (pt - pt_b).normalized()).normalized() */
/* `tan_center = ((pt_a - pt).normalized() + (pt - pt_b).normalized()).normalized()`. */
normalize_vn_vnvn(tan_center_a, pt_a, pt, dims);
normalize_vn_vnvn(tan_center_b, pt, pt_b, dims);
add_vn_vnvn(tan_center, tan_center_a, tan_center_b, dims);
@@ -1306,9 +1307,8 @@ int curve_fit_cubic_to_points_db(
const double *pt_l_next = pt_l + dims;
const double *pt_r_prev = pt_r - dims;
/* tan_l = (pt_l - pt_l_next).normalized()
* tan_r = (pt_r_prev - pt_r).normalized()
*/
/* `tan_l = (pt_l - pt_l_next).normalized();`
* `tan_r = (pt_r_prev - pt_r).normalized();` */
normalize_vn_vnvn(tan_l, pt_l, pt_l_next, dims);
normalize_vn_vnvn(tan_r, pt_r_prev, pt_r, dims);
@@ -1362,7 +1362,7 @@ int curve_fit_cubic_to_points_db(
*r_cubic_orig_index = NULL;
#endif
/* allocate a contiguous array and free the linked list */
/* Allocate a contiguous array and free the linked list. */
*r_cubic_array = cubic_list_as_array(
&clist
#ifdef USE_ORIG_INDEX_DATA
@@ -1454,7 +1454,7 @@ int curve_fit_cubic_to_points_single_db(
{
Cubic *cubic = alloca(cubic_alloc_size(dims));
/* in this instance theres no advantage in using length cache,
/* In this instance there are no advantage in using length cache,
* since we're not recursively calculating values. */
#ifdef USE_LENGTH_CACHE
double *points_length_cache_alloc = NULL;

View File

@@ -1490,3 +1490,4 @@ int curve_fit_cubic_to_points_refit_fl(
return result;
}

View File

@@ -37,7 +37,7 @@
* - #TPOOL_STRUCT: Name for pool struct name.
* - #TPOOL_CHUNK_SIZE: Chunk size (optional), use 64kb when not defined.
*
* \note #TPOOL_ALLOC_TYPE must be at least ``sizeof(void *)``.
* \note #TPOOL_ALLOC_TYPE must be at least `sizeof(void *)`.
*
* Defines the API, uses #TPOOL_IMPL_PREFIX to prefix each function.
*

View File

@@ -305,5 +305,3 @@ void *HEAP_node_ptr(HeapNode *node)
{
return node->ptr;
}
/** \} */

View File

@@ -1,6 +1,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2016 Blender Foundation. All rights reserved.
# Too noisy for code we don't maintain.
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "8.0")
add_cxx_flag("-Wno-cast-function-type")
endif()
endif()
set(INC
src
src/gflags

View File

@@ -2,4 +2,5 @@ Project: Mantaflow
URL: http://mantaflow.com/
License: Apache 2.0
Upstream version: 0.13
Local modifications: None
Local modifications:
* ./patches/local_namespace.diff to support loading MANTA variables into an isolated __main__ name-space.

View File

@@ -115,7 +115,7 @@ class WrapperRegistry {
void construct(const std::string &scriptname, const vector<string> &args);
void cleanup();
void renameObjects();
void runPreInit();
void runPreInit(PyObject *name_space);
PyObject *initModule();
ClassData *lookup(const std::string &name);
bool canConvert(ClassData *from, ClassData *to);
@@ -505,7 +505,7 @@ void WrapperRegistry::addConstants(PyObject *module)
}
}
void WrapperRegistry::runPreInit()
void WrapperRegistry::runPreInit(PyObject *name_space)
{
// add python directories to path
PyObject *sys_path = PySys_GetObject((char *)"path");
@@ -518,7 +518,15 @@ void WrapperRegistry::runPreInit()
}
if (!mCode.empty()) {
mCode = "from manta import *\n" + mCode;
PyRun_SimpleString(mCode.c_str());
PyObject *return_value = PyRun_String(mCode.c_str(), Py_file_input, name_space, name_space);
if (return_value == nullptr) {
if (PyErr_Occurred()) {
PyErr_Print();
}
}
else {
Py_DECREF(return_value);
}
}
}
@@ -698,16 +706,23 @@ PyObject *WrapperRegistry::initModule()
//******************************************************
// Register members and exposed functions
void setup(const std::string &filename, const std::vector<std::string> &args)
void setup(const bool python_lifecycle,
const std::string &filename,
const std::vector<std::string> &args,
PyObject *name_space)
{
WrapperRegistry::instance().construct(filename, args);
Py_Initialize();
WrapperRegistry::instance().runPreInit();
if (python_lifecycle) {
Py_Initialize();
}
WrapperRegistry::instance().runPreInit(name_space);
}
void finalize()
void finalize(const bool python_lifecycle)
{
Py_Finalize();
if (python_lifecycle) {
Py_Finalize();
}
WrapperRegistry::instance().cleanup();
}

View File

@@ -48,8 +48,11 @@ template<class T> struct Namify {
namespace Pb {
// internal registry access
void setup(const std::string &filename, const std::vector<std::string> &args);
void finalize();
void setup(bool python_lifecycle,
const std::string &filename,
const std::vector<std::string> &args,
PyObject *name_space);
void finalize(bool python_lifecycle);
bool canConvert(PyObject *obj, const std::string &to);
Manta::PbClass *objFromPy(PyObject *obj);
Manta::PbClass *createPy(const std::string &classname,

View File

@@ -0,0 +1,86 @@
diff --git a/extern/mantaflow/helper/pwrapper/registry.cpp b/extern/mantaflow/helper/pwrapper/registry.cpp
index 5196c0409f8..b4206a41dea 100644
--- a/extern/mantaflow/helper/pwrapper/registry.cpp
+++ b/extern/mantaflow/helper/pwrapper/registry.cpp
@@ -115,7 +115,7 @@ class WrapperRegistry {
void construct(const std::string &scriptname, const vector<string> &args);
void cleanup();
void renameObjects();
- void runPreInit();
+ void runPreInit(PyObject *name_space);
PyObject *initModule();
ClassData *lookup(const std::string &name);
bool canConvert(ClassData *from, ClassData *to);
@@ -505,7 +505,7 @@ void WrapperRegistry::addConstants(PyObject *module)
}
}
-void WrapperRegistry::runPreInit()
+void WrapperRegistry::runPreInit(PyObject *name_space)
{
// add python directories to path
PyObject *sys_path = PySys_GetObject((char *)"path");
@@ -518,7 +518,15 @@ void WrapperRegistry::runPreInit()
}
if (!mCode.empty()) {
mCode = "from manta import *\n" + mCode;
- PyRun_SimpleString(mCode.c_str());
+ PyObject *return_value = PyRun_String(mCode.c_str(), Py_file_input, name_space, name_space);
+ if (return_value == nullptr) {
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
+ }
+ else {
+ Py_DECREF(return_value);
+ }
}
}
@@ -698,16 +706,23 @@ PyObject *WrapperRegistry::initModule()
//******************************************************
// Register members and exposed functions
-void setup(const std::string &filename, const std::vector<std::string> &args)
+void setup(const bool python_lifecycle,
+ const std::string &filename,
+ const std::vector<std::string> &args,
+ PyObject *name_space)
{
WrapperRegistry::instance().construct(filename, args);
- Py_Initialize();
- WrapperRegistry::instance().runPreInit();
+ if (python_lifecycle) {
+ Py_Initialize();
+ }
+ WrapperRegistry::instance().runPreInit(name_space);
}
-void finalize()
+void finalize(const bool python_lifecycle)
{
- Py_Finalize();
+ if (python_lifecycle) {
+ Py_Finalize();
+ }
WrapperRegistry::instance().cleanup();
}
diff --git a/extern/mantaflow/helper/pwrapper/registry.h b/extern/mantaflow/helper/pwrapper/registry.h
index d9d2bbb624b..2273d0b9bb1 100644
--- a/extern/mantaflow/helper/pwrapper/registry.h
+++ b/extern/mantaflow/helper/pwrapper/registry.h
@@ -48,8 +48,11 @@ template<class T> struct Namify {
namespace Pb {
// internal registry access
-void setup(const std::string &filename, const std::vector<std::string> &args);
-void finalize();
+void setup(bool python_lifecycle,
+ const std::string &filename,
+ const std::vector<std::string> &args,
+ PyObject *name_space);
+void finalize(bool python_lifecycle);
bool canConvert(PyObject *obj, const std::string &to);
Manta::PbClass *objFromPy(PyObject *obj);
Manta::PbClass *createPy(const std::string &classname,

View File

@@ -67,3 +67,10 @@ endif()
if(UNIX AND NOT APPLE)
add_subdirectory(libc_compat)
endif()
if(UNIX AND NOT APPLE)
# Important this comes after "ghost" as it uses includes defined by GHOST's CMake.
if(WITH_GHOST_WAYLAND AND WITH_GHOST_WAYLAND_DYNLOAD)
add_subdirectory(wayland_dynload)
endif()
endif()

View File

@@ -36,8 +36,13 @@ if(WITH_CYCLES_NATIVE_ONLY)
)
if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -march=native")
set(CYCLES_KERNEL_FLAGS "-march=native")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_march_native "-march=native")
if(_has_march_native)
set(CYCLES_KERNEL_FLAGS "-march=native")
else()
set(CYCLES_KERNEL_FLAGS "")
endif()
unset(_has_march_native)
else()
if(NOT MSVC_NATIVE_ARCH_FLAGS)
TRY_RUN(
@@ -263,6 +268,10 @@ if(WITH_CYCLES_DEVICE_OPTIX)
endif()
endif()
if (WITH_CYCLES_DEVICE_ONEAPI)
add_definitions(-DWITH_ONEAPI)
endif()
if(WITH_CYCLES_EMBREE)
add_definitions(-DWITH_EMBREE)
include_directories(

View File

@@ -128,10 +128,6 @@ if(WITH_OPENIMAGEDENOISE)
)
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_NEW_CURVES_TYPE)
endif()
blender_add_lib(bf_intern_cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_dependencies(bf_intern_cycles bf_rna)

View File

@@ -84,10 +84,36 @@ class AddPresetViewportSampling(AddPresetBase, Operator):
preset_subdir = "cycles/viewport_sampling"
class AddPresetPerformance(AddPresetBase, Operator):
'''Add an Performance Preset'''
bl_idname = "render.cycles_performance_preset_add"
bl_label = "Add Performance Preset"
preset_menu = "CYCLES_PT_performance_presets"
preset_defines = [
"render = bpy.context.scene.render"
"cycles = bpy.context.scene.cycles"
]
preset_values = [
"render.threads_mode",
"render.use_persistent_data",
"cycles.debug_use_spatial_splits",
"cycles.debug_use_compact_bvh",
"cycles.debug_use_hair_bvh",
"cycles.debug_bvh_time_steps",
"cycles.use_auto_tile",
"cycles.tile_size",
]
preset_subdir = "cycles/performance"
classes = (
AddPresetIntegrator,
AddPresetSampling,
AddPresetViewportSampling,
AddPresetPerformance,
)

View File

@@ -118,7 +118,8 @@ enum_device_type = (
('CUDA', "CUDA", "CUDA", 1),
('OPTIX', "OptiX", "OptiX", 3),
('HIP', "HIP", "HIP", 4),
('METAL', "Metal", "Metal", 5)
('METAL', "Metal", "Metal", 5),
('ONEAPI', "oneAPI", "oneAPI", 6)
)
enum_texture_limit = (
@@ -692,7 +693,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
debug_use_compact_bvh: BoolProperty(
name="Use Compact BVH",
description="Use compact BVH structure (uses less ram but renders slower)",
default=True,
default=False,
)
debug_bvh_time_steps: IntProperty(
name="BVH Time Steps",
@@ -1397,7 +1398,8 @@ class CyclesPreferences(bpy.types.AddonPreferences):
def get_device_types(self, context):
import _cycles
has_cuda, has_optix, has_hip, has_metal = _cycles.get_device_types()
has_cuda, has_optix, has_hip, has_metal, has_oneapi = _cycles.get_device_types()
list = [('NONE', "None", "Don't use compute device", 0)]
if has_cuda:
list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1))
@@ -1407,6 +1409,8 @@ class CyclesPreferences(bpy.types.AddonPreferences):
list.append(('HIP', "HIP", "Use HIP for GPU acceleration", 4))
if has_metal:
list.append(('METAL', "Metal", "Use Metal for GPU acceleration", 5))
if has_oneapi:
list.append(('ONEAPI', "oneAPI", "Use oneAPI for GPU acceleration", 6))
return list
@@ -1438,7 +1442,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
def update_device_entries(self, device_list):
for device in device_list:
if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP', 'METAL'}:
if not device[1] in {'CUDA', 'OPTIX', 'CPU', 'HIP', 'METAL', 'ONEAPI'}:
continue
# Try to find existing Device entry
entry = self.find_existing_device_entry(device)
@@ -1482,7 +1486,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
import _cycles
# Ensure `self.devices` is not re-allocated when the second call to
# get_devices_for_type is made, freeing items from the first list.
for device_type in ('CUDA', 'OPTIX', 'HIP', 'METAL'):
for device_type in ('CUDA', 'OPTIX', 'HIP', 'METAL', 'ONEAPI'):
self.update_device_entries(_cycles.available_devices(device_type))
# Deprecated: use refresh_devices instead.
@@ -1545,18 +1549,31 @@ class CyclesPreferences(bpy.types.AddonPreferences):
elif device_type == 'HIP':
import sys
if sys.platform[:3] == "win":
col.label(text="Requires discrete AMD GPU with RDNA architecture", icon='BLANK1')
col.label(text="Requires AMD GPU with Vega or RDNA architecture", icon='BLANK1')
col.label(text="and AMD Radeon Pro 21.Q4 driver or newer", icon='BLANK1')
elif sys.platform.startswith("linux"):
col.label(text="Requires discrete AMD GPU with RDNA architecture", icon='BLANK1')
col.label(text="Requires AMD GPU with Vega or RDNA architecture", icon='BLANK1')
col.label(text="and AMD driver version 22.10 or newer", icon='BLANK1')
elif device_type == 'ONEAPI':
import sys
col.label(text="Requires Intel GPU with Xe-HPG architecture", icon='BLANK1')
if sys.platform.startswith("win"):
col.label(text="and Windows driver version 101.1660 or newer", icon='BLANK1')
elif sys.platform.startswith("linux"):
col.label(text="and Linux driver version xx.xx.23570 or newer", icon='BLANK1')
elif device_type == 'METAL':
col.label(text="Requires Apple Silicon with macOS 12.2 or newer", icon='BLANK1')
col.label(text="or AMD with macOS 12.3 or newer", icon='BLANK1')
return
for device in devices:
box.prop(device, "use", text=device.name)
import unicodedata
box.prop(
device, "use", text=device.name
.replace('(TM)', unicodedata.lookup('TRADE MARK SIGN'))
.replace('(R)', unicodedata.lookup('REGISTERED SIGN'))
.replace('(C)', unicodedata.lookup('COPYRIGHT SIGN'))
)
def draw_impl(self, layout, context):
row = layout.row()

View File

@@ -43,6 +43,12 @@ class CYCLES_PT_integrator_presets(CyclesPresetPanel):
preset_add_operator = "render.cycles_integrator_preset_add"
class CYCLES_PT_performance_presets(CyclesPresetPanel):
bl_label = "Performance Presets"
preset_subdir = "cycles/performance"
preset_add_operator = "render.cycles_performance_preset_add"
class CyclesButtonsPanel:
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
@@ -111,6 +117,12 @@ def use_optix(context):
return (get_device_type(context) == 'OPTIX' and cscene.device == 'GPU')
def use_oneapi(context):
cscene = context.scene.cycles
return (get_device_type(context) == 'ONEAPI' and cscene.device == 'GPU')
def use_multi_device(context):
cscene = context.scene.cycles
if cscene.device != 'GPU':
@@ -618,6 +630,9 @@ class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, Panel):
bl_label = "Performance"
bl_options = {'DEFAULT_CLOSED'}
def draw_header_preset(self, context):
CYCLES_PT_performance_presets.draw_panel_header(self.layout)
def draw(self, context):
pass
@@ -937,6 +952,8 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel):
col = split.column()
col.prop(dof, "focus_object", text="Focus Object")
if dof.focus_object and dof.focus_object.type == 'ARMATURE':
col.prop_search(dof, "focus_subtarget", dof.focus_object.data, "bones", text="Focus Bone")
sub = col.row()
sub.active = dof.focus_object is None
@@ -1196,7 +1213,7 @@ class CYCLES_OBJECT_PT_lightgroup(CyclesButtonsPanel, Panel):
sub.prop_search(ob, "lightgroup", view_layer, "lightgroups", text="Light Group", results_are_suggestions=True)
sub = row.column(align=True)
sub.active = bool(ob.lightgroup) and not any(lg.name == ob.lightgroup for lg in view_layer.lightgroups)
sub.enabled = bool(ob.lightgroup) and not any(lg.name == ob.lightgroup for lg in view_layer.lightgroups)
sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = ob.lightgroup
@@ -1634,7 +1651,7 @@ class CYCLES_WORLD_PT_settings_light_group(CyclesButtonsPanel, Panel):
)
sub = row.column(align=True)
sub.active = bool(world.lightgroup) and not any(lg.name == world.lightgroup for lg in view_layer.lightgroups)
sub.enabled = bool(world.lightgroup) and not any(lg.name == world.lightgroup for lg in view_layer.lightgroups)
sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="").name = world.lightgroup
@@ -2263,6 +2280,7 @@ classes = (
CYCLES_PT_sampling_presets,
CYCLES_PT_viewport_sampling_presets,
CYCLES_PT_integrator_presets,
CYCLES_PT_performance_presets,
CYCLES_RENDER_PT_sampling,
CYCLES_RENDER_PT_sampling_viewport,
CYCLES_RENDER_PT_sampling_viewport_denoise,

View File

@@ -143,11 +143,20 @@ static float blender_camera_focal_distance(BL::RenderEngine &b_engine,
if (!b_dof_object)
return b_camera.dof().focus_distance();
Transform dofmat = get_transform(b_dof_object.matrix_world());
string focus_subtarget = b_camera.dof().focus_subtarget();
if (b_dof_object.pose() && !focus_subtarget.empty()) {
BL::PoseBone b_bone = b_dof_object.pose().bones[focus_subtarget];
if (b_bone) {
dofmat = dofmat * get_transform(b_bone.matrix());
}
}
/* for dof object, return distance along camera Z direction */
BL::Array<float, 16> b_ob_matrix;
b_engine.camera_model_matrix(b_ob, bcam->use_spherical_stereo, b_ob_matrix);
Transform obmat = transform_clear_scale(get_transform(b_ob_matrix));
Transform dofmat = get_transform(b_dof_object.matrix_world());
float3 view_dir = normalize(transform_get_column(&obmat, 2));
float3 dof_dir = transform_get_column(&obmat, 3) - transform_get_column(&dofmat, 3);
return fabsf(dot(view_dir, dof_dir));

View File

@@ -55,7 +55,7 @@ static bool ObtainCacheParticleData(
return false;
Transform tfm = get_transform(b_ob->matrix_world());
Transform itfm = transform_quick_inverse(tfm);
Transform itfm = transform_inverse(tfm);
for (BL::Modifier &b_mod : b_ob->modifiers) {
if ((b_mod.type() == b_mod.type_PARTICLE_SYSTEM) &&
@@ -613,8 +613,6 @@ void BlenderSync::sync_particle_hair(
}
}
#ifdef WITH_NEW_CURVES_TYPE
static std::optional<BL::FloatAttribute> find_curves_radius_attribute(BL::Curves b_curves)
{
for (BL::Attribute &b_attribute : b_curves.attributes) {
@@ -632,6 +630,25 @@ static std::optional<BL::FloatAttribute> find_curves_radius_attribute(BL::Curves
return std::nullopt;
}
static BL::FloatVectorAttribute find_curves_position_attribute(BL::Curves b_curves)
{
for (BL::Attribute &b_attribute : b_curves.attributes) {
if (b_attribute.name() != "position") {
continue;
}
if (b_attribute.domain() != BL::Attribute::domain_POINT) {
continue;
}
if (b_attribute.data_type() != BL::Attribute::data_type_FLOAT_VECTOR) {
continue;
}
return BL::FloatVectorAttribute{b_attribute};
}
/* The position attribute must exist. */
assert(false);
return BL::FloatVectorAttribute{b_curves.attributes[0]};
}
template<typename TypeInCycles, typename GetValueAtIndex>
static void fill_generic_attribute(BL::Curves &b_curves,
TypeInCycles *data,
@@ -795,16 +812,16 @@ static void attr_create_generic(Scene *scene,
}
}
static float4 hair_point_as_float4(BL::Curves b_curves,
static float4 hair_point_as_float4(BL::FloatVectorAttribute b_attr_position,
std::optional<BL::FloatAttribute> b_attr_radius,
const int index)
{
float4 mP = float3_to_float4(get_float3(b_curves.position_data[index].vector()));
float4 mP = float3_to_float4(get_float3(b_attr_position.data[index].vector()));
mP.w = b_attr_radius ? b_attr_radius->data[index].value() : 0.0f;
return mP;
}
static float4 interpolate_hair_points(BL::Curves b_curves,
static float4 interpolate_hair_points(BL::FloatVectorAttribute b_attr_position,
std::optional<BL::FloatAttribute> b_attr_radius,
const int first_point_index,
const int num_points,
@@ -814,8 +831,8 @@ static float4 interpolate_hair_points(BL::Curves b_curves,
const int point_a = clamp((int)curve_t, 0, num_points - 1);
const int point_b = min(point_a + 1, num_points - 1);
const float t = curve_t - (float)point_a;
return lerp(hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_a),
hair_point_as_float4(b_curves, b_attr_radius, first_point_index + point_b),
return lerp(hair_point_as_float4(b_attr_position, b_attr_radius, first_point_index + point_a),
hair_point_as_float4(b_attr_position, b_attr_radius, first_point_index + point_b),
t);
}
@@ -848,6 +865,7 @@ static void export_hair_curves(Scene *scene,
hair->reserve_curves(num_curves, num_keys);
BL::FloatVectorAttribute b_attr_position = find_curves_position_attribute(b_curves);
std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_curves);
/* Export curves and points. */
@@ -866,9 +884,9 @@ static void export_hair_curves(Scene *scene,
/* Position and radius. */
for (int i = 0; i < num_points; i++) {
const float3 co = get_float3(b_curves.position_data[first_point_index + i].vector());
const float3 co = get_float3(b_attr_position.data[first_point_index + i].vector());
const float radius = b_attr_radius ? b_attr_radius->data[first_point_index + i].value() :
0.0f;
0.005f;
hair->add_curve_key(co, radius);
if (attr_intercept) {
@@ -923,6 +941,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Curves b_curves, int motio
int num_motion_keys = 0;
int curve_index = 0;
BL::FloatVectorAttribute b_attr_position = find_curves_position_attribute(b_curves);
std::optional<BL::FloatAttribute> b_attr_radius = find_curves_radius_attribute(b_curves);
for (int i = 0; i < num_curves; i++) {
@@ -938,7 +957,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Curves b_curves, int motio
int point_index = first_point_index + i;
if (point_index < num_keys) {
mP[num_motion_keys] = hair_point_as_float4(b_curves, b_attr_radius, point_index);
mP[num_motion_keys] = hair_point_as_float4(b_attr_position, b_attr_radius, point_index);
num_motion_keys++;
if (!have_motion) {
@@ -958,7 +977,7 @@ static void export_hair_curves_motion(Hair *hair, BL::Curves b_curves, int motio
for (int i = 0; i < curve.num_keys; i++) {
const float step = i * step_size;
mP[num_motion_keys] = interpolate_hair_points(
b_curves, b_attr_radius, first_point_index, num_points, step);
b_attr_position, b_attr_radius, first_point_index, num_points, step);
num_motion_keys++;
}
have_motion = true;
@@ -990,15 +1009,6 @@ void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int
export_hair_curves(scene, hair, b_curves, need_motion, motion_scale);
}
}
#else
void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, int motion_step)
{
(void)hair;
(void)b_ob_info;
(void)motion;
(void)motion_step;
}
#endif
void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Hair *hair)
{
@@ -1010,14 +1020,11 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, H
new_hair.set_used_shaders(used_shaders);
if (view_layer.use_hair) {
#ifdef WITH_NEW_CURVES_TYPE
if (b_ob_info.object_data.is_a(&RNA_Curves)) {
/* Hair object. */
sync_hair(&new_hair, b_ob_info, false);
}
else
#endif
{
else {
/* Particle hair. */
bool need_undeformed = new_hair.need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(
@@ -1064,15 +1071,12 @@ void BlenderSync::sync_hair_motion(BL::Depsgraph b_depsgraph,
/* Export deformed coordinates. */
if (ccl::BKE_object_is_deform_modified(b_ob_info, b_scene, preview)) {
#ifdef WITH_NEW_CURVES_TYPE
if (b_ob_info.object_data.is_a(&RNA_Curves)) {
/* Hair object. */
sync_hair(hair, b_ob_info, true, motion_step);
return;
}
else
#endif
{
else {
/* Particle hair. */
BL::Mesh b_mesh = object_to_mesh(
b_data, b_ob_info, b_depsgraph, false, Mesh::SUBDIVISION_NONE);

View File

@@ -15,6 +15,7 @@ enum ComputeDevice {
COMPUTE_DEVICE_OPTIX = 3,
COMPUTE_DEVICE_HIP = 4,
COMPUTE_DEVICE_METAL = 5,
COMPUTE_DEVICE_ONEAPI = 6,
COMPUTE_DEVICE_NUM
};
@@ -76,6 +77,9 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences, BL::Scene &b_scen
else if (compute_device == COMPUTE_DEVICE_METAL) {
mask |= DEVICE_MASK_METAL;
}
else if (compute_device == COMPUTE_DEVICE_ONEAPI) {
mask |= DEVICE_MASK_ONEAPI;
}
vector<DeviceInfo> devices = Device::available_devices(mask);
/* Match device preferences and available devices. */

View File

@@ -18,11 +18,7 @@ CCL_NAMESPACE_BEGIN
static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair)
{
#ifdef WITH_NEW_CURVES_TYPE
if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
return Geometry::HAIR;
}
@@ -217,11 +213,7 @@ void BlenderSync::sync_geometry_motion(BL::Depsgraph &b_depsgraph,
if (progress.get_cancel())
return;
#ifdef WITH_NEW_CURVES_TYPE
if (b_ob_info.object_data.is_a(&RNA_Curves) || use_particle_hair) {
#else
if (use_particle_hair) {
#endif
Hair *hair = static_cast<Hair *>(geom);
sync_hair_motion(b_depsgraph, b_ob_info, hair, motion_step);
}

View File

@@ -1,8 +1,10 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include "scene/pointcloud.h"
#include <optional>
#include "scene/attribute.h"
#include "scene/pointcloud.h"
#include "scene/scene.h"
#include "blender/sync.h"
@@ -138,6 +140,36 @@ static void copy_attributes(PointCloud *pointcloud,
}
}
static std::optional<BL::FloatAttribute> find_radius_attribute(BL::PointCloud b_pointcloud)
{
for (BL::Attribute &b_attribute : b_pointcloud.attributes) {
if (b_attribute.name() != "radius") {
continue;
}
if (b_attribute.data_type() != BL::Attribute::data_type_FLOAT) {
continue;
}
return BL::FloatAttribute{b_attribute};
}
return std::nullopt;
}
static BL::FloatVectorAttribute find_position_attribute(BL::PointCloud b_pointcloud)
{
for (BL::Attribute &b_attribute : b_pointcloud.attributes) {
if (b_attribute.name() != "position") {
continue;
}
if (b_attribute.data_type() != BL::Attribute::data_type_FLOAT_VECTOR) {
continue;
}
return BL::FloatVectorAttribute{b_attribute};
}
/* The position attribute must exist. */
assert(false);
return BL::FloatVectorAttribute{b_pointcloud.attributes[0]};
}
static void export_pointcloud(Scene *scene,
PointCloud *pointcloud,
BL::PointCloud b_pointcloud,
@@ -156,18 +188,18 @@ static void export_pointcloud(Scene *scene,
const int num_points = b_pointcloud.points.length();
pointcloud->reserve(num_points);
BL::FloatVectorAttribute b_attr_position = find_position_attribute(b_pointcloud);
std::optional<BL::FloatAttribute> b_attr_radius = find_radius_attribute(b_pointcloud);
/* Export points. */
BL::PointCloud::points_iterator b_point_iter;
for (b_pointcloud.points.begin(b_point_iter); b_point_iter != b_pointcloud.points.end();
++b_point_iter) {
BL::Point b_point = *b_point_iter;
const float3 co = get_float3(b_point.co());
const float radius = b_point.radius();
for (int i = 0; i < num_points; i++) {
const float3 co = get_float3(b_attr_position.data[i].vector());
const float radius = b_attr_radius ? b_attr_radius->data[i].value() : 0.0f;
pointcloud->add_point(co, radius);
/* Random number per point. */
if (attr_random != NULL) {
attr_random->add(hash_uint2_to_float(b_point.index(), 0));
attr_random->add(hash_uint2_to_float(i, 0));
}
}
@@ -195,14 +227,15 @@ static void export_pointcloud_motion(PointCloud *pointcloud,
int num_motion_points = 0;
const array<float3> &pointcloud_points = pointcloud->get_points();
BL::PointCloud::points_iterator b_point_iter;
for (b_pointcloud.points.begin(b_point_iter); b_point_iter != b_pointcloud.points.end();
++b_point_iter) {
BL::Point b_point = *b_point_iter;
BL::FloatVectorAttribute b_attr_position = find_position_attribute(b_pointcloud);
std::optional<BL::FloatAttribute> b_attr_radius = find_radius_attribute(b_pointcloud);
for (int i = 0; i < num_points; i++) {
if (num_motion_points < num_points) {
float3 P = get_float3(b_point.co());
P.w = b_point.radius();
const float3 co = get_float3(b_attr_position.data[i].vector());
const float radius = b_attr_radius ? b_attr_radius->data[i].value() : 0.0f;
float3 P = co;
P.w = radius;
mP[num_motion_points] = P;
have_motion = have_motion || (P != pointcloud_points[num_motion_points]);
num_motion_points++;

View File

@@ -871,18 +871,20 @@ static PyObject *enable_print_stats_func(PyObject * /*self*/, PyObject * /*args*
static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
{
vector<DeviceType> device_types = Device::available_types();
bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false;
bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false, has_oneapi = false;
foreach (DeviceType device_type, device_types) {
has_cuda |= (device_type == DEVICE_CUDA);
has_optix |= (device_type == DEVICE_OPTIX);
has_hip |= (device_type == DEVICE_HIP);
has_metal |= (device_type == DEVICE_METAL);
has_oneapi |= (device_type == DEVICE_ONEAPI);
}
PyObject *list = PyTuple_New(4);
PyObject *list = PyTuple_New(5);
PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda));
PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_optix));
PyTuple_SET_ITEM(list, 2, PyBool_FromLong(has_hip));
PyTuple_SET_ITEM(list, 3, PyBool_FromLong(has_metal));
PyTuple_SET_ITEM(list, 4, PyBool_FromLong(has_oneapi));
return list;
}
@@ -914,6 +916,9 @@ static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg)
else if (override == "METAL") {
BlenderSession::device_override = DEVICE_MASK_METAL;
}
else if (override == "ONEAPI") {
BlenderSession::device_override = DEVICE_MASK_ONEAPI;
}
else {
printf("\nError: %s is not a valid Cycles device.\n", override.c_str());
Py_RETURN_FALSE;

View File

@@ -928,8 +928,22 @@ static ShaderNode *add_node(Scene *scene,
sky->set_sun_disc(b_sky_node.sun_disc());
sky->set_sun_size(b_sky_node.sun_size());
sky->set_sun_intensity(b_sky_node.sun_intensity());
sky->set_sun_elevation(b_sky_node.sun_elevation());
sky->set_sun_rotation(b_sky_node.sun_rotation());
/* Patch sun position to be able to animate daylight cycle while keeping the shading code
* simple. */
float sun_rotation = b_sky_node.sun_rotation();
/* Wrap into [-2PI..2PI] range. */
float sun_elevation = fmodf(b_sky_node.sun_elevation(), M_2PI_F);
/* Wrap into [-PI..PI] range. */
if (fabsf(sun_elevation) >= M_PI_F) {
sun_elevation -= copysignf(2.0f, sun_elevation) * M_PI_F;
}
/* Wrap into [-PI/2..PI/2] range while keeping the same absolute position. */
if (sun_elevation >= M_PI_2_F || sun_elevation <= -M_PI_2_F) {
sun_elevation = copysignf(M_PI_F, sun_elevation) - sun_elevation;
sun_rotation += M_PI_F;
}
sky->set_sun_elevation(sun_elevation);
sky->set_sun_rotation(sun_rotation);
sky->set_altitude(b_sky_node.altitude());
sky->set_air_density(b_sky_node.air_density());
sky->set_dust_density(b_sky_node.dust_density());

View File

@@ -7,6 +7,7 @@
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
#include "RNA_blender_cpp.h"
#include "RNA_path.h"
#include "RNA_types.h"
#include "blender/id_map.h"

View File

@@ -21,13 +21,9 @@
# include "bvh/embree.h"
/* Kernel includes are necessary so that the filter function for Embree can access the packed BVH.
*/
# include "kernel/bvh/embree.h"
# include "kernel/bvh/util.h"
# include "kernel/device/cpu/bvh.h"
# include "kernel/device/cpu/compat.h"
# include "kernel/device/cpu/globals.h"
# include "kernel/sample/lcg.h"
# include "scene/hair.h"
# include "scene/mesh.h"
@@ -46,265 +42,6 @@ static_assert(Object::MAX_MOTION_STEPS <= RTC_MAX_TIME_STEP_COUNT,
static_assert(Object::MAX_MOTION_STEPS == Geometry::MAX_MOTION_STEPS,
"Object and Geometry max motion steps inconsistent");
# define IS_HAIR(x) (x & 1)
/* This gets called by Embree at every valid ray/object intersection.
* Things like recording subsurface or shadow hits for later evaluation
* as well as filtering for volume objects happen here.
* Cycles' own BVH does that directly inside the traversal calls.
*/
static void rtc_filter_intersection_func(const RTCFilterFunctionNArguments *args)
{
/* Current implementation in Cycles assumes only single-ray intersection queries. */
assert(args->N == 1);
RTCHit *hit = (RTCHit *)args->hit;
CCLIntersectContext *ctx = ((IntersectContext *)args->context)->userRayExt;
const KernelGlobalsCPU *kg = ctx->kg;
const Ray *cray = ctx->ray;
if (kernel_embree_is_self_intersection(kg, hit, cray)) {
*args->valid = 0;
}
}
/* This gets called by Embree at every valid ray/object intersection.
* Things like recording subsurface or shadow hits for later evaluation
* as well as filtering for volume objects happen here.
* Cycles' own BVH does that directly inside the traversal calls.
*/
static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
{
/* Current implementation in Cycles assumes only single-ray intersection queries. */
assert(args->N == 1);
const RTCRay *ray = (RTCRay *)args->ray;
RTCHit *hit = (RTCHit *)args->hit;
CCLIntersectContext *ctx = ((IntersectContext *)args->context)->userRayExt;
const KernelGlobalsCPU *kg = ctx->kg;
const Ray *cray = ctx->ray;
switch (ctx->type) {
case CCLIntersectContext::RAY_SHADOW_ALL: {
Intersection current_isect;
kernel_embree_convert_hit(kg, ray, hit, &current_isect);
if (intersection_skip_self_shadow(cray->self, current_isect.object, current_isect.prim)) {
*args->valid = 0;
return;
}
/* If no transparent shadows or max number of hits exceeded, all light is blocked. */
const int flags = intersection_get_shader_flags(kg, current_isect.prim, current_isect.type);
if (!(flags & (SD_HAS_TRANSPARENT_SHADOW)) || ctx->num_hits >= ctx->max_hits) {
ctx->opaque_hit = true;
return;
}
++ctx->num_hits;
/* Always use baked shadow transparency for curves. */
if (current_isect.type & PRIMITIVE_CURVE) {
ctx->throughput *= intersection_curve_shadow_transparency(
kg, current_isect.object, current_isect.prim, current_isect.u);
if (ctx->throughput < CURVE_SHADOW_TRANSPARENCY_CUTOFF) {
ctx->opaque_hit = true;
return;
}
else {
*args->valid = 0;
return;
}
}
/* Test if we need to record this transparent intersection. */
const uint max_record_hits = min(ctx->max_hits, INTEGRATOR_SHADOW_ISECT_SIZE);
if (ctx->num_recorded_hits < max_record_hits || ray->tfar < ctx->max_t) {
/* If maximum number of hits was reached, replace the intersection with the
* highest distance. We want to find the N closest intersections. */
const uint num_recorded_hits = min(ctx->num_recorded_hits, max_record_hits);
uint isect_index = num_recorded_hits;
if (num_recorded_hits + 1 >= max_record_hits) {
float max_t = ctx->isect_s[0].t;
uint max_recorded_hit = 0;
for (uint i = 1; i < num_recorded_hits; ++i) {
if (ctx->isect_s[i].t > max_t) {
max_recorded_hit = i;
max_t = ctx->isect_s[i].t;
}
}
if (num_recorded_hits >= max_record_hits) {
isect_index = max_recorded_hit;
}
/* Limit the ray distance and stop counting hits beyond this.
* TODO: is there some way we can tell Embree to stop intersecting beyond
* this distance when max number of hits is reached?. Or maybe it will
* become irrelevant if we make max_hits a very high number on the CPU. */
ctx->max_t = max(current_isect.t, max_t);
}
ctx->isect_s[isect_index] = current_isect;
}
/* Always increase the number of recorded hits, even beyond the maximum,
* so that we can detect this and trace another ray if needed. */
++ctx->num_recorded_hits;
/* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}
case CCLIntersectContext::RAY_LOCAL:
case CCLIntersectContext::RAY_SSS: {
/* Check if it's hitting the correct object. */
Intersection current_isect;
if (ctx->type == CCLIntersectContext::RAY_SSS) {
kernel_embree_convert_sss_hit(kg, ray, hit, &current_isect, ctx->local_object_id);
}
else {
kernel_embree_convert_hit(kg, ray, hit, &current_isect);
if (ctx->local_object_id != current_isect.object) {
/* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}
}
if (intersection_skip_self_local(cray->self, current_isect.prim)) {
*args->valid = 0;
return;
}
/* No intersection information requested, just return a hit. */
if (ctx->max_hits == 0) {
break;
}
/* Ignore curves. */
if (IS_HAIR(hit->geomID)) {
/* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}
LocalIntersection *local_isect = ctx->local_isect;
int hit_idx = 0;
if (ctx->lcg_state) {
/* See triangle_intersect_subsurface() for the native equivalent. */
for (int i = min((int)ctx->max_hits, local_isect->num_hits) - 1; i >= 0; --i) {
if (local_isect->hits[i].t == ray->tfar) {
/* This tells Embree to continue tracing. */
*args->valid = 0;
return;
}
}
local_isect->num_hits++;
if (local_isect->num_hits <= ctx->max_hits) {
hit_idx = local_isect->num_hits - 1;
}
else {
/* reservoir sampling: if we are at the maximum number of
* hits, randomly replace element or skip it */
hit_idx = lcg_step_uint(ctx->lcg_state) % local_isect->num_hits;
if (hit_idx >= ctx->max_hits) {
/* This tells Embree to continue tracing. */
*args->valid = 0;
return;
}
}
}
else {
/* Record closest intersection only. */
if (local_isect->num_hits && current_isect.t > local_isect->hits[0].t) {
*args->valid = 0;
return;
}
local_isect->num_hits = 1;
}
/* record intersection */
local_isect->hits[hit_idx] = current_isect;
local_isect->Ng[hit_idx] = normalize(make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z));
/* This tells Embree to continue tracing. */
*args->valid = 0;
break;
}
case CCLIntersectContext::RAY_VOLUME_ALL: {
/* Append the intersection to the end of the array. */
if (ctx->num_hits < ctx->max_hits) {
Intersection current_isect;
kernel_embree_convert_hit(kg, ray, hit, &current_isect);
if (intersection_skip_self(cray->self, current_isect.object, current_isect.prim)) {
*args->valid = 0;
return;
}
Intersection *isect = &ctx->isect_s[ctx->num_hits];
++ctx->num_hits;
*isect = current_isect;
/* Only primitives from volume object. */
uint tri_object = isect->object;
int object_flag = kernel_data_fetch(object_flag, tri_object);
if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
--ctx->num_hits;
}
/* This tells Embree to continue tracing. */
*args->valid = 0;
}
break;
}
case CCLIntersectContext::RAY_REGULAR:
default:
if (kernel_embree_is_self_intersection(kg, hit, cray)) {
*args->valid = 0;
return;
}
break;
}
}
static void rtc_filter_func_backface_cull(const RTCFilterFunctionNArguments *args)
{
const RTCRay *ray = (RTCRay *)args->ray;
RTCHit *hit = (RTCHit *)args->hit;
/* Always ignore back-facing intersections. */
if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z),
make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) {
*args->valid = 0;
return;
}
CCLIntersectContext *ctx = ((IntersectContext *)args->context)->userRayExt;
const KernelGlobalsCPU *kg = ctx->kg;
const Ray *cray = ctx->ray;
if (kernel_embree_is_self_intersection(kg, hit, cray)) {
*args->valid = 0;
}
}
static void rtc_filter_occluded_func_backface_cull(const RTCFilterFunctionNArguments *args)
{
const RTCRay *ray = (RTCRay *)args->ray;
RTCHit *hit = (RTCHit *)args->hit;
/* Always ignore back-facing intersections. */
if (dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z),
make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) {
*args->valid = 0;
return;
}
rtc_filter_occluded_func(args);
}
static size_t unaccounted_mem = 0;
static bool rtc_memory_monitor_func(void *userPtr, const ssize_t bytes, const bool)
@@ -535,8 +272,8 @@ void BVHEmbree::add_triangles(const Object *ob, const Mesh *mesh, int i)
set_tri_vertex_buffer(geom_id, mesh, false);
rtcSetGeometryUserData(geom_id, (void *)prim_offset);
rtcSetGeometryOccludedFilterFunction(geom_id, rtc_filter_occluded_func);
rtcSetGeometryIntersectFilterFunction(geom_id, rtc_filter_intersection_func);
rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func);
rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_intersection_func);
rtcSetGeometryMask(geom_id, ob->visibility_for_tracing());
rtcCommitGeometry(geom_id);
@@ -739,8 +476,8 @@ void BVHEmbree::add_points(const Object *ob, const PointCloud *pointcloud, int i
set_point_vertex_buffer(geom_id, pointcloud, false);
rtcSetGeometryUserData(geom_id, (void *)prim_offset);
rtcSetGeometryIntersectFilterFunction(geom_id, rtc_filter_func_backface_cull);
rtcSetGeometryOccludedFilterFunction(geom_id, rtc_filter_occluded_func_backface_cull);
rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_func_backface_cull);
rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func_backface_cull);
rtcSetGeometryMask(geom_id, ob->visibility_for_tracing());
rtcCommitGeometry(geom_id);
@@ -799,12 +536,13 @@ void BVHEmbree::add_curves(const Object *ob, const Hair *hair, int i)
rtcSetGeometryUserData(geom_id, (void *)prim_offset);
if (hair->curve_shape == CURVE_RIBBON) {
rtcSetGeometryIntersectFilterFunction(geom_id, rtc_filter_intersection_func);
rtcSetGeometryOccludedFilterFunction(geom_id, rtc_filter_occluded_func);
rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_intersection_func);
rtcSetGeometryOccludedFilterFunction(geom_id, kernel_embree_filter_occluded_func);
}
else {
rtcSetGeometryIntersectFilterFunction(geom_id, rtc_filter_func_backface_cull);
rtcSetGeometryOccludedFilterFunction(geom_id, rtc_filter_occluded_func_backface_cull);
rtcSetGeometryIntersectFilterFunction(geom_id, kernel_embree_filter_func_backface_cull);
rtcSetGeometryOccludedFilterFunction(geom_id,
kernel_embree_filter_occluded_func_backface_cull);
}
rtcSetGeometryMask(geom_id, ob->visibility_for_tracing());

View File

@@ -129,7 +129,7 @@ class BVHParams {
top_level = false;
bvh_layout = BVH_LAYOUT_BVH2;
use_compact_structure = true;
use_compact_structure = false;
use_unaligned_nodes = false;
num_motion_curve_steps = 0;

View File

@@ -91,6 +91,8 @@ if(CYCLES_STANDALONE_REPOSITORY)
_set_default(USD_ROOT_DIR "${_cycles_lib_dir}/usd")
_set_default(WEBP_ROOT_DIR "${_cycles_lib_dir}/webp")
_set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib")
_set_default(LEVEL_ZERO_ROOT_DIR "${_cycles_lib_dir}/level-zero")
_set_default(SYCL_ROOT_DIR "${_cycles_lib_dir}/dpcpp")
# Ignore system libraries
set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
@@ -647,3 +649,22 @@ if(WITH_CYCLES_DEVICE_METAL)
message(STATUS "Found Metal: ${METAL_LIBRARY}")
endif()
endif()
###########################################################################
# oneAPI
###########################################################################
if (WITH_CYCLES_DEVICE_ONEAPI)
find_package(SYCL)
find_package(LevelZero)
if (SYCL_FOUND AND LEVEL_ZERO_FOUND)
message(STATUS "Found oneAPI: ${SYCL_LIBRARY}")
message(STATUS "Found Level Zero: ${LEVEL_ZERO_LIBRARY}")
else()
message(STATUS "oneAPI or Level Zero not found, disabling oneAPI device from Cycles")
set(WITH_CYCLES_DEVICE_ONEAPI OFF)
endif()
endif()
unset(_cycles_lib_dir)

View File

@@ -82,6 +82,15 @@ set(SRC_HIP
hip/util.h
)
set(SRC_ONEAPI
oneapi/device_impl.cpp
oneapi/device_impl.h
oneapi/device.cpp
oneapi/device.h
oneapi/queue.cpp
oneapi/queue.h
)
set(SRC_DUMMY
dummy/device.cpp
dummy/device.h
@@ -134,6 +143,7 @@ set(SRC
${SRC_DUMMY}
${SRC_MULTI}
${SRC_OPTIX}
${SRC_ONEAPI}
${SRC_HEADERS}
)
@@ -181,6 +191,9 @@ if(WITH_CYCLES_DEVICE_METAL)
${SRC_METAL}
)
endif()
if (WITH_CYCLES_DEVICE_ONEAPI)
add_definitions(-DWITH_ONEAPI)
endif()
if(WITH_OPENIMAGEDENOISE)
list(APPEND LIB
@@ -193,6 +206,11 @@ include_directories(SYSTEM ${INC_SYS})
cycles_add_library(cycles_device "${LIB}" ${SRC})
if(WITH_CYCLES_DEVICE_ONEAPI)
# Need to have proper rebuilding in case of changes in cycles_kernel_oneapi due external project behaviour
add_dependencies(cycles_device cycles_kernel_oneapi)
endif()
source_group("cpu" FILES ${SRC_CPU})
source_group("cuda" FILES ${SRC_CUDA})
source_group("dummy" FILES ${SRC_DUMMY})
@@ -200,4 +218,5 @@ source_group("hip" FILES ${SRC_HIP})
source_group("multi" FILES ${SRC_MULTI})
source_group("metal" FILES ${SRC_METAL})
source_group("optix" FILES ${SRC_OPTIX})
source_group("oneapi" FILES ${SRC_ONEAPI})
source_group("common" FILES ${SRC_BASE} ${SRC_HEADERS})

View File

@@ -197,7 +197,7 @@ void CPUDevice::const_copy_to(const char *name, void *host, size_t size)
// Update scene handle (since it is different for each device on multi devices)
KernelData *const data = (KernelData *)host;
data->bvh.scene = embree_scene;
data->device_bvh = embree_scene;
}
#endif
kernel_const_copy(&kernel_globals, name, host, size);

View File

@@ -16,6 +16,7 @@
#include "device/hip/device.h"
#include "device/metal/device.h"
#include "device/multi/device.h"
#include "device/oneapi/device.h"
#include "device/optix/device.h"
#include "util/foreach.h"
@@ -39,6 +40,7 @@ vector<DeviceInfo> Device::optix_devices;
vector<DeviceInfo> Device::cpu_devices;
vector<DeviceInfo> Device::hip_devices;
vector<DeviceInfo> Device::metal_devices;
vector<DeviceInfo> Device::oneapi_devices;
uint Device::devices_initialized_mask = 0;
/* Device */
@@ -101,6 +103,13 @@ Device *Device::create(const DeviceInfo &info, Stats &stats, Profiler &profiler)
device = device_metal_create(info, stats, profiler);
break;
#endif
#ifdef WITH_ONEAPI
case DEVICE_ONEAPI:
device = device_oneapi_create(info, stats, profiler);
break;
#endif
default:
break;
}
@@ -126,6 +135,8 @@ DeviceType Device::type_from_string(const char *name)
return DEVICE_HIP;
else if (strcmp(name, "METAL") == 0)
return DEVICE_METAL;
else if (strcmp(name, "ONEAPI") == 0)
return DEVICE_ONEAPI;
return DEVICE_NONE;
}
@@ -144,6 +155,8 @@ string Device::string_from_type(DeviceType type)
return "HIP";
else if (type == DEVICE_METAL)
return "METAL";
else if (type == DEVICE_ONEAPI)
return "ONEAPI";
return "";
}
@@ -163,6 +176,9 @@ vector<DeviceType> Device::available_types()
#endif
#ifdef WITH_METAL
types.push_back(DEVICE_METAL);
#endif
#ifdef WITH_ONEAPI
types.push_back(DEVICE_ONEAPI);
#endif
return types;
}
@@ -219,6 +235,20 @@ vector<DeviceInfo> Device::available_devices(uint mask)
}
#endif
#ifdef WITH_ONEAPI
if (mask & DEVICE_MASK_ONEAPI) {
if (!(devices_initialized_mask & DEVICE_MASK_ONEAPI)) {
if (device_oneapi_init()) {
device_oneapi_info(oneapi_devices);
}
devices_initialized_mask |= DEVICE_MASK_ONEAPI;
}
foreach (DeviceInfo &info, oneapi_devices) {
devices.push_back(info);
}
}
#endif
if (mask & DEVICE_MASK_CPU) {
if (!(devices_initialized_mask & DEVICE_MASK_CPU)) {
device_cpu_info(cpu_devices);
@@ -282,6 +312,15 @@ string Device::device_capabilities(uint mask)
}
#endif
#ifdef WITH_ONEAPI
if (mask & DEVICE_MASK_ONEAPI) {
if (device_oneapi_init()) {
capabilities += "\noneAPI device capabilities:\n";
capabilities += device_oneapi_capabilities();
}
}
#endif
#ifdef WITH_METAL
if (mask & DEVICE_MASK_METAL) {
if (device_metal_init()) {
@@ -380,6 +419,7 @@ void Device::free_memory()
cuda_devices.free_memory();
optix_devices.free_memory();
hip_devices.free_memory();
oneapi_devices.free_memory();
cpu_devices.free_memory();
metal_devices.free_memory();
}

View File

@@ -29,6 +29,7 @@ class DeviceQueue;
class Progress;
class CPUKernels;
class CPUKernelThreadGlobals;
class Scene;
/* Device Types */
@@ -40,6 +41,7 @@ enum DeviceType {
DEVICE_OPTIX,
DEVICE_HIP,
DEVICE_METAL,
DEVICE_ONEAPI,
DEVICE_DUMMY,
};
@@ -49,6 +51,7 @@ enum DeviceTypeMask {
DEVICE_MASK_OPTIX = (1 << DEVICE_OPTIX),
DEVICE_MASK_HIP = (1 << DEVICE_HIP),
DEVICE_MASK_METAL = (1 << DEVICE_METAL),
DEVICE_MASK_ONEAPI = (1 << DEVICE_ONEAPI),
DEVICE_MASK_ALL = ~0
};
@@ -184,6 +187,11 @@ class Device {
return 0;
}
/* Called after kernel texture setup, and prior to integrator state setup. */
virtual void optimize_for_scene(Scene * /*scene*/)
{
}
virtual bool is_resident(device_ptr /*key*/, Device *sub_device)
{
/* Memory is always resident if this is not a multi device, regardless of whether the pointer
@@ -273,6 +281,7 @@ class Device {
static vector<DeviceInfo> cpu_devices;
static vector<DeviceInfo> hip_devices;
static vector<DeviceInfo> metal_devices;
static vector<DeviceInfo> oneapi_devices;
static uint devices_initialized_mask;
};

View File

@@ -51,7 +51,7 @@ static inline bool hipSupportsDevice(const int hipDevId)
hipDeviceGetAttribute(&major, hipDeviceAttributeComputeCapabilityMajor, hipDevId);
hipDeviceGetAttribute(&minor, hipDeviceAttributeComputeCapabilityMinor, hipDevId);
return (major > 10) || (major == 10 && minor >= 1);
return (major >= 9);
}
CCL_NAMESPACE_END

View File

@@ -34,7 +34,8 @@ void device_metal_info(vector<DeviceInfo> &devices)
int device_index = 0;
for (id<MTLDevice> &device : usable_devices) {
/* Compute unique ID for persistent user preferences. */
string device_name = [device.name UTF8String];
string device_name = MetalInfo::get_device_name(device);
string id = string("METAL_") + device_name;
/* Hardware ID might not be unique, add device number in that case. */
@@ -48,12 +49,6 @@ void device_metal_info(vector<DeviceInfo> &devices)
info.type = DEVICE_METAL;
info.description = string_remove_trademark(string(device_name));
/* Ensure unique naming on Apple Silicon / SoC devices which return the same string for CPU and
* GPU */
if (info.description == system_cpu_brand_string()) {
info.description += " (GPU)";
}
info.num = device_index;
/* We don't know if it's used for display, but assume it is. */
info.display_device = true;
@@ -69,14 +64,15 @@ string device_metal_capabilities()
{
string result = "";
auto allDevices = MTLCopyAllDevices();
uint32_t num_devices = allDevices.count;
uint32_t num_devices = (uint32_t)allDevices.count;
if (num_devices == 0) {
return "No Metal devices found\n";
}
result += string_printf("Number of devices: %u\n", num_devices);
for (id<MTLDevice> device in allDevices) {
result += string_printf("\t\tDevice: %s\n", [device.name UTF8String]);
string device_name = MetalInfo::get_device_name(device);
result += string_printf("\t\tDevice: %s\n", device_name.c_str());
}
return result;

View File

@@ -42,7 +42,6 @@ class MetalDevice : public Device {
nil; /* encoder used for fetching device pointers from MTLAccelerationStructure */
/*---------------------------------------------------*/
string device_name;
MetalGPUVendor device_vendor;
uint kernel_features;
@@ -76,7 +75,8 @@ class MetalDevice : public Device {
std::vector<id<MTLTexture>> texture_slot_map;
bool use_metalrt = false;
bool use_function_specialisation = false;
MetalPipelineType kernel_specialization_level = PSO_GENERIC;
std::atomic_bool async_compile_and_load = false;
virtual BVHLayoutMask get_bvh_layout_mask() const override;
@@ -92,9 +92,7 @@ class MetalDevice : public Device {
bool use_adaptive_compilation();
string get_source(const uint kernel_features);
string compile_kernel(const uint kernel_features, const char *name);
void make_source(MetalPipelineType pso_type, const uint kernel_features);
virtual bool load_kernels(const uint kernel_features) override;
@@ -112,7 +110,9 @@ class MetalDevice : public Device {
virtual void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
id<MTLLibrary> compile(string const &source);
virtual void optimize_for_scene(Scene *scene) override;
bool compile_and_load(MetalPipelineType pso_type);
/* ------------------------------------------------------------------ */
/* low-level memory management */

View File

@@ -6,9 +6,12 @@
# include "device/metal/device_impl.h"
# include "device/metal/device.h"
# include "scene/scene.h"
# include "util/debug.h"
# include "util/md5.h"
# include "util/path.h"
# include "util/time.h"
CCL_NAMESPACE_BEGIN
@@ -43,10 +46,9 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
auto usable_devices = MetalInfo::get_usable_devices();
assert(mtlDevId < usable_devices.size());
mtlDevice = usable_devices[mtlDevId];
device_name = [mtlDevice.name UTF8String];
device_vendor = MetalInfo::get_vendor_from_device_name(device_name);
device_vendor = MetalInfo::get_device_vendor(mtlDevice);
assert(device_vendor != METAL_GPU_UNKNOWN);
metal_printf("Creating new Cycles device for Metal: %s\n", device_name.c_str());
metal_printf("Creating new Cycles device for Metal: %s\n", info.description.c_str());
/* determine default storage mode based on whether UMA is supported */
@@ -78,6 +80,10 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
case METAL_GPU_APPLE: {
max_threads_per_threadgroup = 512;
use_metalrt = info.use_metalrt;
/* Specialize the intersection kernels on Apple GPUs by default as these can be built very
* quickly. */
kernel_specialization_level = PSO_SPECIALIZED_INTERSECT;
break;
}
}
@@ -90,6 +96,13 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
capture_enabled = true;
}
if (auto envstr = getenv("CYCLES_METAL_SPECIALIZATION_LEVEL")) {
kernel_specialization_level = (MetalPipelineType)atoi(envstr);
}
metal_printf("kernel_specialization_level = %s\n",
kernel_type_as_string(
(MetalPipelineType)min((int)kernel_specialization_level, (int)PSO_NUM - 1)));
MTLArgumentDescriptor *arg_desc_params = [[MTLArgumentDescriptor alloc] init];
arg_desc_params.dataType = MTLDataTypePointer;
arg_desc_params.access = MTLArgumentAccessReadOnly;
@@ -209,61 +222,86 @@ bool MetalDevice::use_adaptive_compilation()
return DebugFlags().metal.adaptive_compile;
}
string MetalDevice::get_source(const uint kernel_features)
void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_features)
{
string build_options;
string global_defines;
if (use_adaptive_compilation()) {
build_options += " -D__KERNEL_FEATURES__=" + to_string(kernel_features);
global_defines += "#define __KERNEL_FEATURES__ " + to_string(kernel_features) + "\n";
}
if (use_metalrt) {
build_options += "-D__METALRT__ ";
global_defines += "#define __METALRT__\n";
if (motion_blur) {
build_options += "-D__METALRT_MOTION__ ";
global_defines += "#define __METALRT_MOTION__\n";
}
}
# ifdef WITH_CYCLES_DEBUG
build_options += "-D__KERNEL_DEBUG__ ";
global_defines += "#define __KERNEL_DEBUG__\n";
# endif
switch (device_vendor) {
default:
break;
case METAL_GPU_INTEL:
build_options += "-D__KERNEL_METAL_INTEL__ ";
global_defines += "#define __KERNEL_METAL_INTEL__\n";
break;
case METAL_GPU_AMD:
build_options += "-D__KERNEL_METAL_AMD__ ";
global_defines += "#define __KERNEL_METAL_AMD__\n";
break;
case METAL_GPU_APPLE:
build_options += "-D__KERNEL_METAL_APPLE__ ";
global_defines += "#define __KERNEL_METAL_APPLE__\n";
break;
}
/* reformat -D defines list into compilable form */
vector<string> components;
string_replace(build_options, "-D", "");
string_split(components, build_options, " ");
string globalDefines;
for (const string &component : components) {
vector<string> assignments;
string_split(assignments, component, "=");
if (assignments.size() == 2)
globalDefines += string_printf(
"#define %s %s\n", assignments[0].c_str(), assignments[1].c_str());
else
globalDefines += string_printf("#define %s\n", assignments[0].c_str());
}
string source = globalDefines + "\n#include \"kernel/device/metal/kernel.metal\"\n";
string &source = this->source[pso_type];
source = "\n#include \"kernel/device/metal/kernel.metal\"\n";
source = path_source_replace_includes(source, path_get("source"));
metal_printf("Global defines:\n%s\n", globalDefines.c_str());
/* Perform any required specialization on the source.
* With Metal function constants we can generate a single variant of the kernel source which can
* be repeatedly respecialized.
*/
string baked_constants;
return source;
/* Replace specific KernelData "dot" dereferences with a Metal function_constant identifier of
* the same character length. Build a string of all active constant values which is then hashed
* in order to identify the PSO.
*/
if (pso_type != PSO_GENERIC) {
const double starttime = time_dt();
# define KERNEL_STRUCT_BEGIN(name, parent) \
string_replace_same_length(source, "kernel_data." #parent ".", "kernel_data_" #parent "_");
/* Add constants to md5 so that 'get_best_pipeline' is able to return a suitable match. */
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
baked_constants += string(#parent "." #name "=") + \
to_string(_type(launch_params.data.parent.name)) + "\n";
# include "kernel/data_template.h"
/* Opt in to all of available specializations. This can be made more granular for the
* PSO_SPECIALIZED_INTERSECT case in order to minimize the number of specialization requests,
* but the overhead should be negligible as these are very quick to (re)build and aren't
* serialized to disk via MTLBinaryArchives.
*/
global_defines += "#define __KERNEL_USE_DATA_CONSTANTS__\n";
metal_printf("KernelData patching took %.1f ms\n", (time_dt() - starttime) * 1000.0);
}
source = global_defines + source;
metal_printf("================\n%s================\n\%s================\n",
global_defines.c_str(),
baked_constants.c_str());
/* Generate an MD5 from the source and include any baked constants. This is used when caching
* PSOs. */
MD5Hash md5;
md5.append(baked_constants);
md5.append(source);
source_md5[pso_type] = md5.get_hex();
}
bool MetalDevice::load_kernels(const uint _kernel_features)
@@ -279,24 +317,22 @@ bool MetalDevice::load_kernels(const uint _kernel_features)
* active, but may still need to be rendered without motion blur if that isn't active as well. */
motion_blur = kernel_features & KERNEL_FEATURE_OBJECT_MOTION;
source[PSO_GENERIC] = get_source(kernel_features);
mtlLibrary[PSO_GENERIC] = compile(source[PSO_GENERIC]);
MD5Hash md5;
md5.append(source[PSO_GENERIC]);
source_md5[PSO_GENERIC] = md5.get_hex();
metal_printf("Front-end compilation finished (generic)\n");
bool result = MetalDeviceKernels::load(this, false);
bool result = compile_and_load(PSO_GENERIC);
reserve_local_memory(kernel_features);
return result;
}
id<MTLLibrary> MetalDevice::compile(string const &source)
bool MetalDevice::compile_and_load(MetalPipelineType pso_type)
{
make_source(pso_type, kernel_features);
if (!MetalDeviceKernels::should_load_kernels(this, pso_type)) {
/* We already have a full set of matching pipelines which are cached or queued. */
metal_printf("%s kernels already requested\n", kernel_type_as_string(pso_type));
return true;
}
MTLCompileOptions *options = [[MTLCompileOptions alloc] init];
options.fastMathEnabled = YES;
@@ -304,19 +340,30 @@ id<MTLLibrary> MetalDevice::compile(string const &source)
options.languageVersion = MTLLanguageVersion2_4;
}
NSError *error = NULL;
id<MTLLibrary> mtlLibrary = [mtlDevice newLibraryWithSource:@(source.c_str())
options:options
error:&error];
if (getenv("CYCLES_METAL_PROFILING") || getenv("CYCLES_METAL_DEBUG")) {
path_write_text(path_cache_get(string_printf("%s.metal", kernel_type_as_string(pso_type))),
source[pso_type]);
}
if (!mtlLibrary) {
const double starttime = time_dt();
NSError *error = NULL;
mtlLibrary[pso_type] = [mtlDevice newLibraryWithSource:@(source[pso_type].c_str())
options:options
error:&error];
if (!mtlLibrary[pso_type]) {
NSString *err = [error localizedDescription];
set_error(string_printf("Failed to compile library:\n%s", [err UTF8String]));
}
metal_printf("Front-end compilation finished in %.1f seconds (%s)\n",
time_dt() - starttime,
kernel_type_as_string(pso_type));
[options release];
return mtlLibrary;
return MetalDeviceKernels::load(this, pso_type);
}
void MetalDevice::reserve_local_memory(const uint kernel_features)
@@ -623,11 +670,63 @@ device_ptr MetalDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, siz
return 0;
}
void MetalDevice::optimize_for_scene(Scene *scene)
{
MetalPipelineType specialization_level = kernel_specialization_level;
if (specialization_level < PSO_SPECIALIZED_INTERSECT) {
return;
}
/* PSO_SPECIALIZED_INTERSECT kernels are fast to specialize, so we always load them
* synchronously. */
compile_and_load(PSO_SPECIALIZED_INTERSECT);
if (specialization_level < PSO_SPECIALIZED_SHADE) {
return;
}
if (!scene->params.background) {
/* Don't load PSO_SPECIALIZED_SHADE kernels during viewport rendering as they are slower to
* build. */
return;
}
/* PSO_SPECIALIZED_SHADE kernels are slower to specialize, so we load them asynchronously, and
* only if there isn't an existing load in flight.
*/
auto specialize_shade_fn = ^() {
compile_and_load(PSO_SPECIALIZED_SHADE);
async_compile_and_load = false;
};
bool async_specialize_shade = true;
/* Block if a per-kernel profiling is enabled (ensure steady rendering rate). */
if (getenv("CYCLES_METAL_PROFILING") != nullptr) {
async_specialize_shade = false;
}
if (async_specialize_shade) {
if (!async_compile_and_load) {
async_compile_and_load = true;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
specialize_shade_fn);
}
else {
metal_printf(
"Async PSO_SPECIALIZED_SHADE load request already in progress - dropping request\n");
}
}
else {
specialize_shade_fn();
}
}
void MetalDevice::const_copy_to(const char *name, void *host, size_t size)
{
if (strcmp(name, "data") == 0) {
assert(size == sizeof(KernelData));
memcpy((uint8_t *)&launch_params + offsetof(KernelParamsMetal, data), host, size);
memcpy((uint8_t *)&launch_params.data, host, sizeof(KernelData));
return;
}
@@ -648,7 +747,7 @@ void MetalDevice::const_copy_to(const char *name, void *host, size_t size)
/* Update data storage pointers in launch parameters. */
if (strcmp(name, "integrator_state") == 0) {
/* IntegratorStateGPU is contiguous pointers */
const size_t pointer_block_size = sizeof(IntegratorStateGPU);
const size_t pointer_block_size = offsetof(IntegratorStateGPU, sort_partition_divisor);
update_launch_pointers(
offsetof(KernelParamsMetal, integrator_state), host, size, pointer_block_size);
}

View File

@@ -31,7 +31,7 @@ enum {
enum { METALRT_TABLE_DEFAULT, METALRT_TABLE_SHADOW, METALRT_TABLE_LOCAL, METALRT_TABLE_NUM };
/* Pipeline State Object types */
enum {
enum MetalPipelineType {
/* A kernel that can be used with all scenes, supporting all features.
* It is slow to compile, but only needs to be compiled once and is then
* cached for future render sessions. This allows a render to get underway
@@ -39,28 +39,33 @@ enum {
*/
PSO_GENERIC,
/* A kernel that is relatively quick to compile, but is specialized for the
* scene being rendered. It only contains the functionality and even baked in
* constants for values that means it needs to be recompiled whenever a
* dependent setting is changed. The render performance of this kernel is
* significantly faster though, and justifies the extra compile time.
/* A intersection kernel that is very quick to specialize and results in faster intersection
* kernel performance. It uses Metal function constants to replace several KernelData variables
* with fixed constants.
*/
/* METAL_WIP: This isn't used and will require more changes to enable. */
PSO_SPECIALISED,
PSO_SPECIALIZED_INTERSECT,
/* A shading kernel that is slow to specialize, but results in faster shading kernel performance
* rendered. It uses Metal function constants to replace several KernelData variables with fixed
* constants and short-circuit all unused SVM node case handlers.
*/
PSO_SPECIALIZED_SHADE,
PSO_NUM
};
const char *kernel_type_as_string(int kernel_type);
const char *kernel_type_as_string(MetalPipelineType pso_type);
struct MetalKernelPipeline {
void compile();
id<MTLLibrary> mtlLibrary = nil;
bool scene_specialized;
MetalPipelineType pso_type;
string source_md5;
size_t usage_count = 0;
KernelData kernel_data_;
bool use_metalrt;
bool metalrt_hair;
bool metalrt_hair_thick;
@@ -75,6 +80,8 @@ struct MetalKernelPipeline {
id<MTLComputePipelineState> pipeline = nil;
int num_threads_per_block = 0;
bool should_use_binary_archive() const;
string error_str;
API_AVAILABLE(macos(11.0))
@@ -85,7 +92,8 @@ struct MetalKernelPipeline {
/* Cache of Metal kernels for each DeviceKernel. */
namespace MetalDeviceKernels {
bool load(MetalDevice *device, bool scene_specialized);
bool should_load_kernels(MetalDevice *device, MetalPipelineType pso_type);
bool load(MetalDevice *device, MetalPipelineType pso_type);
const MetalKernelPipeline *get_best_pipeline(const MetalDevice *device, DeviceKernel kernel);
} /* namespace MetalDeviceKernels */

View File

@@ -5,6 +5,7 @@
# include "device/metal/kernel.h"
# include "device/metal/device_impl.h"
# include "kernel/device/metal/function_constants.h"
# include "util/md5.h"
# include "util/path.h"
# include "util/tbb.h"
@@ -16,13 +17,15 @@ CCL_NAMESPACE_BEGIN
/* limit to 2 MTLCompiler instances */
int max_mtlcompiler_threads = 2;
const char *kernel_type_as_string(int kernel_type)
const char *kernel_type_as_string(MetalPipelineType pso_type)
{
switch (kernel_type) {
switch (pso_type) {
case PSO_GENERIC:
return "PSO_GENERIC";
case PSO_SPECIALISED:
return "PSO_SPECIALISED";
case PSO_SPECIALIZED_INTERSECT:
return "PSO_SPECIALIZED_INTERSECT";
case PSO_SPECIALIZED_SHADE:
return "PSO_SPECIALIZED_SHADE";
default:
assert(0);
}
@@ -50,7 +53,11 @@ struct ShaderCache {
/* Non-blocking request for a kernel, optionally specialized to the scene being rendered by
* device. */
void load_kernel(DeviceKernel kernel, MetalDevice *device, bool scene_specialized);
void load_kernel(DeviceKernel kernel, MetalDevice *device, MetalPipelineType pso_type);
bool should_load_kernel(DeviceKernel device_kernel,
MetalDevice *device,
MetalPipelineType pso_type);
void wait_for_all();
@@ -139,9 +146,53 @@ void ShaderCache::compile_thread_func(int thread_index)
}
}
bool ShaderCache::should_load_kernel(DeviceKernel device_kernel,
MetalDevice *device,
MetalPipelineType pso_type)
{
if (device_kernel == DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) {
/* Skip megakernel. */
return false;
}
if (device_kernel == DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE) {
if ((device->kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) == 0) {
/* Skip shade_surface_raytrace kernel if the scene doesn't require it. */
return false;
}
}
if (pso_type != PSO_GENERIC) {
/* Only specialize kernels where it can make an impact. */
if (device_kernel < DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST ||
device_kernel > DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) {
return false;
}
/* Only specialize shading / intersection kernels as requested. */
bool is_shade_kernel = (device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND);
bool is_shade_pso = (pso_type == PSO_SPECIALIZED_SHADE);
if (is_shade_pso != is_shade_kernel) {
return false;
}
}
{
/* check whether the kernel has already been requested / cached */
thread_scoped_lock lock(cache_mutex);
for (auto &pipeline : pipelines[device_kernel]) {
if (pipeline->source_md5 == device->source_md5[pso_type]) {
return false;
}
}
}
return true;
}
void ShaderCache::load_kernel(DeviceKernel device_kernel,
MetalDevice *device,
bool scene_specialized)
MetalPipelineType pso_type)
{
{
/* create compiler threads on first run */
@@ -154,52 +205,21 @@ void ShaderCache::load_kernel(DeviceKernel device_kernel,
}
}
if (device_kernel == DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) {
/* skip megakernel */
if (!should_load_kernel(device_kernel, device, pso_type)) {
return;
}
if (scene_specialized) {
/* Only specialize kernels where it can make an impact. */
if (device_kernel < DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST ||
device_kernel > DEVICE_KERNEL_INTEGRATOR_MEGAKERNEL) {
return;
}
}
{
/* check whether the kernel has already been requested / cached */
thread_scoped_lock lock(cache_mutex);
for (auto &pipeline : pipelines[device_kernel]) {
if (scene_specialized) {
if (pipeline->source_md5 == device->source_md5[PSO_SPECIALISED]) {
/* we already requested a pipeline that is specialized for this kernel data */
metal_printf("Specialized kernel already requested (%s)\n",
device_kernel_as_string(device_kernel));
return;
}
}
else {
if (pipeline->source_md5 == device->source_md5[PSO_GENERIC]) {
/* we already requested a generic pipeline for this kernel */
metal_printf("Generic kernel already requested (%s)\n",
device_kernel_as_string(device_kernel));
return;
}
}
}
}
incomplete_requests++;
PipelineRequest request;
request.pipeline = new MetalKernelPipeline;
request.pipeline->scene_specialized = scene_specialized;
memcpy(&request.pipeline->kernel_data_,
&device->launch_params.data,
sizeof(request.pipeline->kernel_data_));
request.pipeline->pso_type = pso_type;
request.pipeline->mtlDevice = mtlDevice;
request.pipeline->source_md5 =
device->source_md5[scene_specialized ? PSO_SPECIALISED : PSO_GENERIC];
request.pipeline->mtlLibrary =
device->mtlLibrary[scene_specialized ? PSO_SPECIALISED : PSO_GENERIC];
request.pipeline->source_md5 = device->source_md5[pso_type];
request.pipeline->mtlLibrary = device->mtlLibrary[pso_type];
request.pipeline->device_kernel = device_kernel;
request.pipeline->threads_per_threadgroup = device->max_threads_per_threadgroup;
@@ -214,7 +234,24 @@ void ShaderCache::load_kernel(DeviceKernel device_kernel,
{
thread_scoped_lock lock(cache_mutex);
pipelines[device_kernel].push_back(unique_ptr<MetalKernelPipeline>(request.pipeline));
auto &collection = pipelines[device_kernel];
/* Cache up to 3 kernel variants with the same pso_type, purging oldest first. */
int max_entries_of_same_pso_type = 3;
for (int i = (int)collection.size() - 1; i >= 0; i--) {
if (collection[i]->pso_type == pso_type) {
max_entries_of_same_pso_type -= 1;
if (max_entries_of_same_pso_type == 0) {
metal_printf("Purging oldest %s:%s kernel from ShaderCache\n",
kernel_type_as_string(pso_type),
device_kernel_as_string(device_kernel));
collection.erase(collection.begin() + i);
break;
}
}
}
collection.push_back(unique_ptr<MetalKernelPipeline>(request.pipeline));
request_queue.push_back(request);
}
cond_var.notify_one();
@@ -248,8 +285,9 @@ MetalKernelPipeline *ShaderCache::get_best_pipeline(DeviceKernel kernel, const M
continue;
}
if (pipeline->scene_specialized) {
if (pipeline->source_md5 == device->source_md5[PSO_SPECIALISED]) {
if (pipeline->pso_type != PSO_GENERIC) {
if (pipeline->source_md5 == device->source_md5[PSO_SPECIALIZED_INTERSECT] ||
pipeline->source_md5 == device->source_md5[PSO_SPECIALIZED_SHADE]) {
best_pipeline = pipeline.get();
}
}
@@ -258,13 +296,65 @@ MetalKernelPipeline *ShaderCache::get_best_pipeline(DeviceKernel kernel, const M
}
}
if (best_pipeline->usage_count == 0 && best_pipeline->pso_type != PSO_GENERIC) {
metal_printf("Swapping in %s version of %s\n",
kernel_type_as_string(best_pipeline->pso_type),
device_kernel_as_string(kernel));
}
best_pipeline->usage_count += 1;
return best_pipeline;
}
bool MetalKernelPipeline::should_use_binary_archive() const
{
if (auto str = getenv("CYCLES_METAL_DISABLE_BINARY_ARCHIVES")) {
if (atoi(str) != 0) {
/* Don't archive if we have opted out by env var. */
return false;
}
}
if (pso_type == PSO_GENERIC) {
/* Archive the generic kernels. */
return true;
}
if (device_kernel >= DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND &&
device_kernel <= DEVICE_KERNEL_INTEGRATOR_SHADE_SHADOW) {
/* Archive all shade kernels - they take a long time to compile. */
return true;
}
/* The remaining kernels are all fast to compile. They may get cached by the system shader cache,
* but will be quick to regenerate if not. */
return false;
}
static MTLFunctionConstantValues *GetConstantValues(KernelData const *data = nullptr)
{
MTLFunctionConstantValues *constant_values = [MTLFunctionConstantValues new];
MTLDataType MTLDataType_int = MTLDataTypeInt;
MTLDataType MTLDataType_float = MTLDataTypeFloat;
MTLDataType MTLDataType_float4 = MTLDataTypeFloat4;
KernelData zero_data = {0};
if (!data) {
data = &zero_data;
}
# define KERNEL_STRUCT_MEMBER(parent, _type, name) \
[constant_values setConstantValue:&data->parent.name \
type:MTLDataType_##_type \
atIndex:KernelData_##parent##_##name];
# include "kernel/data_template.h"
return constant_values;
}
void MetalKernelPipeline::compile()
{
int pso_type = scene_specialized ? PSO_SPECIALISED : PSO_GENERIC;
const std::string function_name = std::string("cycles_metal_") +
device_kernel_as_string(device_kernel);
@@ -281,6 +371,17 @@ void MetalKernelPipeline::compile()
if (@available(macOS 11.0, *)) {
MTLFunctionDescriptor *func_desc = [MTLIntersectionFunctionDescriptor functionDescriptor];
func_desc.name = entryPoint;
if (pso_type == PSO_SPECIALIZED_SHADE) {
func_desc.constantValues = GetConstantValues(&kernel_data_);
}
else if (pso_type == PSO_SPECIALIZED_INTERSECT) {
func_desc.constantValues = GetConstantValues(&kernel_data_);
}
else {
func_desc.constantValues = GetConstantValues();
}
function = [mtlLibrary newFunctionWithDescriptor:func_desc error:&error];
}
@@ -427,10 +528,7 @@ void MetalKernelPipeline::compile()
MTLPipelineOption pipelineOptions = MTLPipelineOptionNone;
bool use_binary_archive = true;
if (auto str = getenv("CYCLES_METAL_DISABLE_BINARY_ARCHIVES")) {
use_binary_archive = (atoi(str) == 0);
}
bool use_binary_archive = should_use_binary_archive();
id<MTLBinaryArchive> archive = nil;
string metalbin_path;
@@ -608,17 +706,30 @@ void MetalKernelPipeline::compile()
}
}
bool MetalDeviceKernels::load(MetalDevice *device, bool scene_specialized)
bool MetalDeviceKernels::load(MetalDevice *device, MetalPipelineType pso_type)
{
const double starttime = time_dt();
auto shader_cache = get_shader_cache(device->mtlDevice);
for (int i = 0; i < DEVICE_KERNEL_NUM; i++) {
shader_cache->load_kernel((DeviceKernel)i, device, pso_type);
}
shader_cache->wait_for_all();
metal_printf("Back-end compilation finished in %.1f seconds (%s)\n",
time_dt() - starttime,
kernel_type_as_string(pso_type));
return true;
}
bool MetalDeviceKernels::should_load_kernels(MetalDevice *device, MetalPipelineType pso_type)
{
auto shader_cache = get_shader_cache(device->mtlDevice);
for (int i = 0; i < DEVICE_KERNEL_NUM; i++) {
shader_cache->load_kernel((DeviceKernel)i, device, scene_specialized);
if (shader_cache->should_load_kernel((DeviceKernel)i, device, pso_type)) {
return true;
}
}
if (!scene_specialized || getenv("CYCLES_METAL_PROFILING")) {
shader_cache->wait_for_all();
}
return true;
return false;
}
const MetalKernelPipeline *MetalDeviceKernels::get_best_pipeline(const MetalDevice *device,

View File

@@ -24,6 +24,7 @@ class MetalDeviceQueue : public DeviceQueue {
virtual int num_concurrent_states(const size_t) const override;
virtual int num_concurrent_busy_states() const override;
virtual int num_sort_partition_elements() const override;
virtual void init_execution() override;

View File

@@ -293,6 +293,11 @@ int MetalDeviceQueue::num_concurrent_busy_states() const
return result;
}
int MetalDeviceQueue::num_sort_partition_elements() const
{
return MetalInfo::optimal_sort_partition_elements(metal_device_->mtlDevice);
}
void MetalDeviceQueue::init_execution()
{
/* Synchronize all textures and memory copies before executing task. */
@@ -359,7 +364,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
/* Prepare any non-pointer (i.e. plain-old-data) KernelParamsMetal data */
/* The plain-old-data is contiguous, continuing to the end of KernelParamsMetal */
size_t plain_old_launch_data_offset = offsetof(KernelParamsMetal, integrator_state) +
sizeof(IntegratorStateGPU);
offsetof(IntegratorStateGPU, sort_partition_divisor);
size_t plain_old_launch_data_size = sizeof(KernelParamsMetal) - plain_old_launch_data_offset;
memcpy(init_arg_buffer + globals_offsets + plain_old_launch_data_offset,
(uint8_t *)&metal_device_->launch_params + plain_old_launch_data_offset,
@@ -416,7 +421,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
/* this relies on IntegratorStateGPU layout being contiguous device_ptrs */
const size_t pointer_block_end = offsetof(KernelParamsMetal, integrator_state) +
sizeof(IntegratorStateGPU);
offsetof(IntegratorStateGPU, sort_partition_divisor);
for (size_t offset = 0; offset < pointer_block_end; offset += sizeof(device_ptr)) {
int pointer_index = int(offset / sizeof(device_ptr));
MetalDevice::MetalMem *mmem = *(
@@ -550,7 +555,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
/* Enhanced command buffer errors are only available in 11.0+ */
if (@available(macos 11.0, *)) {
if (command_buffer.status == MTLCommandBufferStatusError && command_buffer.error != nil) {
printf("CommandBuffer Failed: %s\n", [kernel_name UTF8String]);
metal_device_->set_error(string("CommandBuffer Failed: ") + [kernel_name UTF8String]);
NSArray<id<MTLCommandBufferEncoderInfo>> *encoderInfos = [command_buffer.error.userInfo
valueForKey:MTLCommandBufferEncoderInfoErrorKey];
if (encoderInfos != nil) {
@@ -564,7 +569,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
}
}
else if (command_buffer.error) {
printf("CommandBuffer Failed: %s\n", [kernel_name UTF8String]);
metal_device_->set_error(string("CommandBuffer Failed: ") + [kernel_name UTF8String]);
}
}
}];

View File

@@ -25,10 +25,20 @@ enum MetalGPUVendor {
METAL_GPU_INTEL = 3,
};
enum AppleGPUArchitecture {
APPLE_UNKNOWN,
APPLE_M1,
APPLE_M2,
};
/* Contains static Metal helper functions. */
struct MetalInfo {
static vector<id<MTLDevice>> const &get_usable_devices();
static MetalGPUVendor get_vendor_from_device_name(string const &device_name);
static int get_apple_gpu_core_count(id<MTLDevice> device);
static MetalGPUVendor get_device_vendor(id<MTLDevice> device);
static AppleGPUArchitecture get_apple_gpu_architecture(id<MTLDevice> device);
static int optimal_sort_partition_elements(id<MTLDevice> device);
static string get_device_name(id<MTLDevice> device);
};
/* Pool of MTLBuffers whose lifetime is linked to a single MTLCommandBuffer */

View File

@@ -10,26 +10,83 @@
# include "util/string.h"
# include "util/time.h"
# include <IOKit/IOKitLib.h>
# include <pwd.h>
# include <sys/shm.h>
# include <time.h>
CCL_NAMESPACE_BEGIN
MetalGPUVendor MetalInfo::get_vendor_from_device_name(string const &device_name)
string MetalInfo::get_device_name(id<MTLDevice> device)
{
if (device_name.find("Intel") != string::npos) {
string device_name = [device.name UTF8String];
if (get_device_vendor(device) == METAL_GPU_APPLE) {
/* Append the GPU core count so we can distinguish between GPU variants in benchmarks. */
int gpu_core_count = get_apple_gpu_core_count(device);
device_name += string_printf(gpu_core_count ? " (GPU - %d cores)" : " (GPU)", gpu_core_count);
}
return device_name;
}
int MetalInfo::get_apple_gpu_core_count(id<MTLDevice> device)
{
int core_count = 0;
if (@available(macos 12.0, *)) {
io_service_t gpu_service = IOServiceGetMatchingService(
kIOMainPortDefault, IORegistryEntryIDMatching(device.registryID));
if (CFNumberRef numberRef = (CFNumberRef)IORegistryEntryCreateCFProperty(
gpu_service, CFSTR("gpu-core-count"), 0, 0)) {
if (CFGetTypeID(numberRef) == CFNumberGetTypeID()) {
CFNumberGetValue(numberRef, kCFNumberSInt32Type, &core_count);
}
CFRelease(numberRef);
}
}
return core_count;
}
AppleGPUArchitecture MetalInfo::get_apple_gpu_architecture(id<MTLDevice> device)
{
const char *device_name = [device.name UTF8String];
if (strstr(device_name, "M1")) {
return APPLE_M1;
}
else if (strstr(device_name, "M2")) {
return APPLE_M2;
}
return APPLE_UNKNOWN;
}
MetalGPUVendor MetalInfo::get_device_vendor(id<MTLDevice> device)
{
const char *device_name = [device.name UTF8String];
if (strstr(device_name, "Intel")) {
return METAL_GPU_INTEL;
}
else if (device_name.find("AMD") != string::npos) {
else if (strstr(device_name, "AMD")) {
return METAL_GPU_AMD;
}
else if (device_name.find("Apple") != string::npos) {
else if (strstr(device_name, "Apple")) {
return METAL_GPU_APPLE;
}
return METAL_GPU_UNKNOWN;
}
int MetalInfo::optimal_sort_partition_elements(id<MTLDevice> device)
{
if (auto str = getenv("CYCLES_METAL_SORT_PARTITION_ELEMENTS")) {
return atoi(str);
}
/* On M1 and M2 GPUs, we see better cache utilization if we partition the active indices before
* sorting each partition by material. Partitioning into chunks of 65536 elements results in an
* overall render time speedup of up to 15%. */
if (get_device_vendor(device) == METAL_GPU_APPLE) {
return 65536;
}
return 0;
}
vector<id<MTLDevice>> const &MetalInfo::get_usable_devices()
{
static vector<id<MTLDevice>> usable_devices;
@@ -41,9 +98,8 @@ vector<id<MTLDevice>> const &MetalInfo::get_usable_devices()
metal_printf("Usable Metal devices:\n");
for (id<MTLDevice> device in MTLCopyAllDevices()) {
const char *device_name = [device.name UTF8String];
MetalGPUVendor vendor = get_vendor_from_device_name(device_name);
string device_name = get_device_name(device);
MetalGPUVendor vendor = get_device_vendor(device);
bool usable = false;
if (@available(macos 12.2, *)) {
@@ -55,12 +111,12 @@ vector<id<MTLDevice>> const &MetalInfo::get_usable_devices()
}
if (usable) {
metal_printf("- %s\n", device_name);
metal_printf("- %s\n", device_name.c_str());
[device retain];
usable_devices.push_back(device);
}
else {
metal_printf(" (skipping \"%s\")\n", device_name);
metal_printf(" (skipping \"%s\")\n", device_name.c_str());
}
}
if (usable_devices.empty()) {

View File

@@ -0,0 +1,185 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Intel Corporation */
#include "device/oneapi/device.h"
#include "util/log.h"
#ifdef WITH_ONEAPI
# include "device/device.h"
# include "device/oneapi/device_impl.h"
# include "util/path.h"
# include "util/string.h"
# ifdef __linux__
# include <dlfcn.h>
# endif
#endif /* WITH_ONEAPI */
CCL_NAMESPACE_BEGIN
#ifdef WITH_ONEAPI
static OneAPIDLLInterface oneapi_dll;
#endif
#ifdef _WIN32
# define LOAD_ONEAPI_SHARED_LIBRARY(path) (void *)(LoadLibrary(path))
# define FREE_SHARED_LIBRARY(handle) FreeLibrary((HMODULE)handle)
# define GET_SHARED_LIBRARY_SYMBOL(handle, name) GetProcAddress((HMODULE)handle, name)
#elif __linux__
# define LOAD_ONEAPI_SHARED_LIBRARY(path) dlopen(path, RTLD_NOW)
# define FREE_SHARED_LIBRARY(handle) dlclose(handle)
# define GET_SHARED_LIBRARY_SYMBOL(handle, name) dlsym(handle, name)
#endif
bool device_oneapi_init()
{
#if !defined(WITH_ONEAPI)
return false;
#else
string lib_path = path_get("lib");
# ifdef _WIN32
lib_path = path_join(lib_path, "cycles_kernel_oneapi.dll");
# else
lib_path = path_join(lib_path, "cycles_kernel_oneapi.so");
# endif
void *lib_handle = LOAD_ONEAPI_SHARED_LIBRARY(lib_path.c_str());
/* This shouldn't happen, but it still makes sense to have a branch for this. */
if (lib_handle == NULL) {
LOG(ERROR) << "oneAPI kernel shared library cannot be loaded for some reason. This should not "
"happen, however, it occurs hence oneAPI rendering will be disabled";
return false;
}
# define DLL_INTERFACE_CALL(function, return_type, ...) \
(oneapi_dll.function) = reinterpret_cast<decltype(oneapi_dll.function)>( \
GET_SHARED_LIBRARY_SYMBOL(lib_handle, #function)); \
if (oneapi_dll.function == NULL) { \
LOG(ERROR) << "oneAPI shared library function \"" << #function \
<< "\" has not been loaded from kernel shared - disable oneAPI " \
"library disable oneAPI implementation due to this"; \
FREE_SHARED_LIBRARY(lib_handle); \
return false; \
}
# include "kernel/device/oneapi/dll_interface_template.h"
# undef DLL_INTERFACE_CALL
VLOG_INFO << "oneAPI kernel shared library has been loaded successfully";
/* We need to have this oneapi kernel shared library during all life-span of the Blender.
* So it is not unloaded because of this.
* FREE_SHARED_LIBRARY(lib_handle); */
/* NOTE(@nsirgien): we need to enable JIT cache from here and
* right now this cache policy is controlled by env. variables. */
/* NOTE(hallade) we also disable use of copy engine as it
* improves stability as of intel/LLVM SYCL-nightly/20220529.
* All these env variable can be set beforehand by end-users and
* will in that case -not- be overwritten. */
# ifdef _WIN32
if (getenv("SYCL_CACHE_PERSISTENT") == nullptr) {
_putenv_s("SYCL_CACHE_PERSISTENT", "1");
}
if (getenv("SYCL_CACHE_TRESHOLD") == nullptr) {
_putenv_s("SYCL_CACHE_THRESHOLD", "0");
}
if (getenv("SYCL_DEVICE_FILTER") == nullptr) {
_putenv_s("SYCL_DEVICE_FILTER", "host,level_zero");
}
if (getenv("SYCL_ENABLE_PCI") == nullptr) {
_putenv_s("SYCL_ENABLE_PCI", "1");
}
if (getenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE") == nullptr) {
_putenv_s("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE", "0");
}
# elif __linux__
setenv("SYCL_CACHE_PERSISTENT", "1", false);
setenv("SYCL_CACHE_THRESHOLD", "0", false);
setenv("SYCL_DEVICE_FILTER", "host,level_zero", false);
setenv("SYCL_ENABLE_PCI", "1", false);
setenv("SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE", "0", false);
# endif
return true;
#endif
}
#if defined(_WIN32) || defined(__linux__)
# undef LOAD_SYCL_SHARED_LIBRARY
# undef LOAD_ONEAPI_SHARED_LIBRARY
# undef FREE_SHARED_LIBRARY
# undef GET_SHARED_LIBRARY_SYMBOL
#endif
Device *device_oneapi_create(const DeviceInfo &info, Stats &stats, Profiler &profiler)
{
#ifdef WITH_ONEAPI
return new OneapiDevice(info, oneapi_dll, stats, profiler);
#else
(void)info;
(void)stats;
(void)profiler;
LOG(FATAL) << "Requested to create oneAPI device while not enabled for this build.";
return nullptr;
#endif
}
#ifdef WITH_ONEAPI
static void device_iterator_cb(const char *id, const char *name, int num, void *user_ptr)
{
vector<DeviceInfo> *devices = (vector<DeviceInfo> *)user_ptr;
DeviceInfo info;
info.type = DEVICE_ONEAPI;
info.description = name;
info.num = num;
/* NOTE(@nsirgien): Should be unique at least on proper oneapi installation. */
info.id = id;
info.has_nanovdb = true;
info.denoisers = 0;
info.has_gpu_queue = true;
/* NOTE(@nsirgien): oneAPI right now is focused on one device usage. In future it maybe will
* change, but right now peer access from one device to another device is not supported. */
info.has_peer_memory = false;
/* NOTE(@nsirgien): Seems not possible to know from SYCL/oneAPI or Level0. */
info.display_device = false;
devices->push_back(info);
VLOG_INFO << "Added device \"" << name << "\" with id \"" << info.id << "\".";
}
#endif
void device_oneapi_info(vector<DeviceInfo> &devices)
{
#ifdef WITH_ONEAPI
(oneapi_dll.oneapi_iterate_devices)(device_iterator_cb, &devices);
#else /* WITH_ONEAPI */
(void)devices;
#endif /* WITH_ONEAPI */
}
string device_oneapi_capabilities()
{
string capabilities;
#ifdef WITH_ONEAPI
char *c_capabilities = (oneapi_dll.oneapi_device_capabilities)();
if (c_capabilities) {
capabilities = c_capabilities;
(oneapi_dll.oneapi_free)(c_capabilities);
}
#endif
return capabilities;
}
CCL_NAMESPACE_END

View File

@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#pragma once
#include "util/string.h"
#include "util/vector.h"
CCL_NAMESPACE_BEGIN
class Device;
class DeviceInfo;
class Profiler;
class Stats;
bool device_oneapi_init();
Device *device_oneapi_create(const DeviceInfo &info, Stats &stats, Profiler &profiler);
void device_oneapi_info(vector<DeviceInfo> &devices);
string device_oneapi_capabilities();
CCL_NAMESPACE_END

View File

@@ -0,0 +1,438 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Intel Corporation */
#ifdef WITH_ONEAPI
# include "device/oneapi/device_impl.h"
# include "util/debug.h"
# include "util/log.h"
# include "kernel/device/oneapi/kernel.h"
CCL_NAMESPACE_BEGIN
static void queue_error_cb(const char *message, void *user_ptr)
{
if (user_ptr) {
*reinterpret_cast<std::string *>(user_ptr) = message;
}
}
OneapiDevice::OneapiDevice(const DeviceInfo &info,
OneAPIDLLInterface &oneapi_dll_object,
Stats &stats,
Profiler &profiler)
: Device(info, stats, profiler),
device_queue_(nullptr),
texture_info_(this, "texture_info", MEM_GLOBAL),
kg_memory_(nullptr),
kg_memory_device_(nullptr),
kg_memory_size_(0),
oneapi_dll_(oneapi_dll_object)
{
need_texture_info_ = false;
oneapi_dll_.oneapi_set_error_cb(queue_error_cb, &oneapi_error_string_);
/* OneAPI calls should be initialized on this moment. */
assert(oneapi_dll_.oneapi_create_queue != nullptr);
bool is_finished_ok = oneapi_dll_.oneapi_create_queue(device_queue_, info.num);
if (is_finished_ok == false) {
set_error("oneAPI queue initialization error: got runtime exception \"" +
oneapi_error_string_ + "\"");
}
else {
VLOG_DEBUG << "oneAPI queue has been successfully created for the device \""
<< info.description << "\"";
assert(device_queue_);
}
size_t globals_segment_size;
is_finished_ok = oneapi_dll_.oneapi_kernel_globals_size(device_queue_, globals_segment_size);
if (is_finished_ok == false) {
set_error("oneAPI constant memory initialization got runtime exception \"" +
oneapi_error_string_ + "\"");
}
else {
VLOG_DEBUG << "Successfully created global/constant memory segment (kernel globals object)";
}
kg_memory_ = oneapi_dll_.oneapi_usm_aligned_alloc_host(device_queue_, globals_segment_size, 16);
oneapi_dll_.oneapi_usm_memset(device_queue_, kg_memory_, 0, globals_segment_size);
kg_memory_device_ = oneapi_dll_.oneapi_usm_alloc_device(device_queue_, globals_segment_size);
kg_memory_size_ = globals_segment_size;
}
OneapiDevice::~OneapiDevice()
{
texture_info_.free();
oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_);
oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_device_);
for (ConstMemMap::iterator mt = const_mem_map_.begin(); mt != const_mem_map_.end(); mt++)
delete mt->second;
if (device_queue_)
oneapi_dll_.oneapi_free_queue(device_queue_);
}
bool OneapiDevice::check_peer_access(Device * /*peer_device*/)
{
return false;
}
BVHLayoutMask OneapiDevice::get_bvh_layout_mask() const
{
return BVH_LAYOUT_BVH2;
}
bool OneapiDevice::load_kernels(const uint requested_features)
{
assert(device_queue_);
/* NOTE(@nsirgien): oneAPI can support compilation of kernel code with certain feature set
* with specialization constants, but it hasn't been implemented yet. */
(void)requested_features;
bool is_finished_ok = oneapi_dll_.oneapi_run_test_kernel(device_queue_);
if (is_finished_ok == false) {
set_error("oneAPI kernel load: got runtime exception \"" + oneapi_error_string_ + "\"");
}
else {
VLOG_INFO << "Runtime compilation done for \"" << info.description << "\"";
assert(device_queue_);
}
return is_finished_ok;
}
void OneapiDevice::load_texture_info()
{
if (need_texture_info_) {
need_texture_info_ = false;
texture_info_.copy_to_device();
}
}
void OneapiDevice::generic_alloc(device_memory &mem)
{
size_t memory_size = mem.memory_size();
/* TODO(@nsirgien): In future, if scene doesn't fit into device memory, then
* we can use USM host memory.
* Because of the expected performance impact, implementation of this has had a low priority
* and is not implemented yet. */
assert(device_queue_);
/* NOTE(@nsirgien): There are three types of Unified Shared Memory (USM) in oneAPI: host, device
* and shared. For new project it maybe more beneficial to use USM shared memory, because it
* provides automatic migration mechanism in order to allow to use the same pointer on host and
* on device, without need to worry about explicit memory transfer operations. But for
* Blender/Cycles this type of memory is not very suitable in current application architecture,
* because Cycles already uses two different pointer for host activity and device activity, and
* also has to perform all needed memory transfer operations. So, USM device memory
* type has been used for oneAPI device in order to better fit in Cycles architecture. */
void *device_pointer = oneapi_dll_.oneapi_usm_alloc_device(device_queue_, memory_size);
if (device_pointer == nullptr) {
size_t max_memory_on_device = oneapi_dll_.oneapi_get_memcapacity(device_queue_);
set_error("oneAPI kernel - device memory allocation error for " +
string_human_readable_size(mem.memory_size()) +
", possibly caused by lack of available memory space on the device: " +
string_human_readable_size(stats.mem_used) + " of " +
string_human_readable_size(max_memory_on_device) + " is already allocated");
return;
}
assert(device_pointer);
mem.device_pointer = reinterpret_cast<ccl::device_ptr>(device_pointer);
mem.device_size = memory_size;
stats.mem_alloc(memory_size);
}
void OneapiDevice::generic_copy_to(device_memory &mem)
{
size_t memory_size = mem.memory_size();
/* Copy operation from host shouldn't be requested if there is no memory allocated on host. */
assert(mem.host_pointer);
assert(device_queue_);
oneapi_dll_.oneapi_usm_memcpy(
device_queue_, (void *)mem.device_pointer, (void *)mem.host_pointer, memory_size);
}
/* TODO: Make sycl::queue part of OneapiQueue and avoid using pointers to sycl::queue. */
SyclQueue *OneapiDevice::sycl_queue()
{
return device_queue_;
}
string OneapiDevice::oneapi_error_message()
{
return string(oneapi_error_string_);
}
OneAPIDLLInterface OneapiDevice::oneapi_dll_object()
{
return oneapi_dll_;
}
void *OneapiDevice::kernel_globals_device_pointer()
{
return kg_memory_device_;
}
void OneapiDevice::generic_free(device_memory &mem)
{
assert(mem.device_pointer);
stats.mem_free(mem.device_size);
mem.device_size = 0;
assert(device_queue_);
oneapi_dll_.oneapi_usm_free(device_queue_, (void *)mem.device_pointer);
mem.device_pointer = 0;
}
void OneapiDevice::mem_alloc(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
assert(!"mem_alloc not supported for textures.");
}
else if (mem.type == MEM_GLOBAL) {
assert(!"mem_alloc not supported for global memory.");
}
else {
if (mem.name) {
VLOG_DEBUG << "OneapiDevice::mem_alloc: \"" << mem.name << "\", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
}
generic_alloc(mem);
}
}
void OneapiDevice::mem_copy_to(device_memory &mem)
{
if (mem.name) {
VLOG_DEBUG << "OneapiDevice::mem_copy_to: \"" << mem.name << "\", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
}
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else {
if (!mem.device_pointer)
mem_alloc(mem);
generic_copy_to(mem);
}
}
void OneapiDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem)
{
if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
}
else if (mem.host_pointer) {
const size_t size = (w > 0 || h > 0 || elem > 0) ? (elem * w * h) : mem.memory_size();
const size_t offset = elem * y * w;
if (mem.name) {
VLOG_DEBUG << "OneapiDevice::mem_copy_from: \"" << mem.name << "\" object of "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ") from offset " << offset
<< " data " << size << " bytes";
}
assert(device_queue_);
assert(size != 0);
assert(mem.device_pointer);
char *shifted_host = reinterpret_cast<char *>(mem.host_pointer) + offset;
char *shifted_device = reinterpret_cast<char *>(mem.device_pointer) + offset;
bool is_finished_ok = oneapi_dll_.oneapi_usm_memcpy(
device_queue_, shifted_host, shifted_device, size);
if (is_finished_ok == false) {
set_error("oneAPI memory operation error: got runtime exception \"" + oneapi_error_string_ +
"\"");
}
}
}
void OneapiDevice::mem_zero(device_memory &mem)
{
if (mem.name) {
VLOG_DEBUG << "OneapiDevice::mem_zero: \"" << mem.name << "\", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")\n";
}
if (!mem.device_pointer) {
mem_alloc(mem);
}
if (!mem.device_pointer) {
return;
}
assert(device_queue_);
bool is_finished_ok = oneapi_dll_.oneapi_usm_memset(
device_queue_, (void *)mem.device_pointer, 0, mem.memory_size());
if (is_finished_ok == false) {
set_error("oneAPI memory operation error: got runtime exception \"" + oneapi_error_string_ +
"\"");
}
}
void OneapiDevice::mem_free(device_memory &mem)
{
if (mem.name) {
VLOG_DEBUG << "OneapiDevice::mem_free: \"" << mem.name << "\", "
<< string_human_readable_number(mem.device_size) << " bytes. ("
<< string_human_readable_size(mem.device_size) << ")\n";
}
if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
}
else {
generic_free(mem);
}
}
device_ptr OneapiDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/)
{
return reinterpret_cast<device_ptr>(reinterpret_cast<char *>(mem.device_pointer) +
mem.memory_elements_size(offset));
}
void OneapiDevice::const_copy_to(const char *name, void *host, size_t size)
{
assert(name);
VLOG_DEBUG << "OneapiDevice::const_copy_to \"" << name << "\" object "
<< string_human_readable_number(size) << " bytes. ("
<< string_human_readable_size(size) << ")";
ConstMemMap::iterator i = const_mem_map_.find(name);
device_vector<uchar> *data;
if (i == const_mem_map_.end()) {
data = new device_vector<uchar>(this, name, MEM_READ_ONLY);
data->alloc(size);
const_mem_map_.insert(ConstMemMap::value_type(name, data));
}
else {
data = i->second;
}
assert(data->memory_size() <= size);
memcpy(data->data(), host, size);
data->copy_to_device();
oneapi_dll_.oneapi_set_global_memory(
device_queue_, kg_memory_, name, (void *)data->device_pointer);
oneapi_dll_.oneapi_usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
}
void OneapiDevice::global_alloc(device_memory &mem)
{
assert(mem.name);
size_t size = mem.memory_size();
VLOG_DEBUG << "OneapiDevice::global_alloc \"" << mem.name << "\" object "
<< string_human_readable_number(size) << " bytes. ("
<< string_human_readable_size(size) << ")";
generic_alloc(mem);
generic_copy_to(mem);
oneapi_dll_.oneapi_set_global_memory(
device_queue_, kg_memory_, mem.name, (void *)mem.device_pointer);
oneapi_dll_.oneapi_usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
}
void OneapiDevice::global_free(device_memory &mem)
{
if (mem.device_pointer) {
generic_free(mem);
}
}
void OneapiDevice::tex_alloc(device_texture &mem)
{
generic_alloc(mem);
generic_copy_to(mem);
/* Resize if needed. Also, in case of resize - allocate in advance for future allocs. */
const uint slot = mem.slot;
if (slot >= texture_info_.size()) {
texture_info_.resize(slot + 128);
}
texture_info_[slot] = mem.info;
need_texture_info_ = true;
texture_info_[slot].data = (uint64_t)mem.device_pointer;
}
void OneapiDevice::tex_free(device_texture &mem)
{
/* There is no texture memory in SYCL. */
if (mem.device_pointer) {
generic_free(mem);
}
}
unique_ptr<DeviceQueue> OneapiDevice::gpu_queue_create()
{
return make_unique<OneapiDeviceQueue>(this);
}
int OneapiDevice::get_num_multiprocessors()
{
assert(device_queue_);
return oneapi_dll_.oneapi_get_num_multiprocessors(device_queue_);
}
int OneapiDevice::get_max_num_threads_per_multiprocessor()
{
assert(device_queue_);
return oneapi_dll_.oneapi_get_max_num_threads_per_multiprocessor(device_queue_);
}
bool OneapiDevice::should_use_graphics_interop()
{
/* NOTE(@nsirgien): oneAPI doesn't yet support direct writing into graphics API objects, so
* return false. */
return false;
}
void *OneapiDevice::usm_aligned_alloc_host(size_t memory_size, size_t alignment)
{
assert(device_queue_);
return oneapi_dll_.oneapi_usm_aligned_alloc_host(device_queue_, memory_size, alignment);
}
void OneapiDevice::usm_free(void *usm_ptr)
{
assert(device_queue_);
return oneapi_dll_.oneapi_usm_free(device_queue_, usm_ptr);
}
CCL_NAMESPACE_END
#endif

View File

@@ -0,0 +1,103 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Intel Corporation */
#ifdef WITH_ONEAPI
# include "device/device.h"
# include "device/oneapi/device.h"
# include "device/oneapi/queue.h"
# include "util/map.h"
CCL_NAMESPACE_BEGIN
class DeviceQueue;
class OneapiDevice : public Device {
private:
SyclQueue *device_queue_;
using ConstMemMap = map<string, device_vector<uchar> *>;
ConstMemMap const_mem_map_;
device_vector<TextureInfo> texture_info_;
bool need_texture_info_;
void *kg_memory_;
void *kg_memory_device_;
size_t kg_memory_size_ = (size_t)0;
OneAPIDLLInterface oneapi_dll_;
std::string oneapi_error_string_;
public:
virtual BVHLayoutMask get_bvh_layout_mask() const override;
OneapiDevice(const DeviceInfo &info,
OneAPIDLLInterface &oneapi_dll_object,
Stats &stats,
Profiler &profiler);
virtual ~OneapiDevice();
bool check_peer_access(Device *peer_device) override;
bool load_kernels(const uint requested_features) override;
void load_texture_info();
void generic_alloc(device_memory &mem);
void generic_copy_to(device_memory &mem);
void generic_free(device_memory &mem);
SyclQueue *sycl_queue();
string oneapi_error_message();
OneAPIDLLInterface oneapi_dll_object();
void *kernel_globals_device_pointer();
void mem_alloc(device_memory &mem) override;
void mem_copy_to(device_memory &mem) override;
void mem_copy_from(device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
void mem_copy_from(device_memory &mem)
{
mem_copy_from(mem, 0, 0, 0, 0);
}
void mem_zero(device_memory &mem) override;
void mem_free(device_memory &mem) override;
device_ptr mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_t /*size*/) override;
virtual void const_copy_to(const char *name, void *host, size_t size) override;
void global_alloc(device_memory &mem);
void global_free(device_memory &mem);
void tex_alloc(device_texture &mem);
void tex_free(device_texture &mem);
/* Graphics resources interoperability. */
virtual bool should_use_graphics_interop() override;
virtual unique_ptr<DeviceQueue> gpu_queue_create() override;
int get_num_multiprocessors();
int get_max_num_threads_per_multiprocessor();
/* NOTE(@nsirgien): Create this methods to avoid some compilation problems on Windows with host
* side compilation (MSVC). */
void *usm_aligned_alloc_host(size_t memory_size, size_t alignment);
void usm_free(void *usm_ptr);
};
CCL_NAMESPACE_END
#endif

View File

@@ -0,0 +1,17 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#pragma once
/* Include kernel header to get access to SYCL-specific types, like SyclQueue and
* OneAPIDeviceIteratorCallback. */
#include "kernel/device/oneapi/kernel.h"
#ifdef WITH_ONEAPI
struct OneAPIDLLInterface {
# define DLL_INTERFACE_CALL(function, return_type, ...) \
return_type (*function)(__VA_ARGS__) = nullptr;
# include "kernel/device/oneapi/dll_interface_template.h"
# undef DLL_INTERFACE_CALL
};
#endif

View File

@@ -0,0 +1,136 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Intel Corporation */
#ifdef WITH_ONEAPI
# include "device/oneapi/queue.h"
# include "device/oneapi/device_impl.h"
# include "util/log.h"
# include "util/time.h"
# include <iomanip>
# include <vector>
# include "kernel/device/oneapi/kernel.h"
CCL_NAMESPACE_BEGIN
struct KernelExecutionInfo {
double elapsed_summary = 0.0;
int enqueue_count = 0;
};
/* OneapiDeviceQueue */
OneapiDeviceQueue::OneapiDeviceQueue(OneapiDevice *device)
: DeviceQueue(device),
oneapi_device_(device),
oneapi_dll_(device->oneapi_dll_object()),
kernel_context_(nullptr)
{
}
OneapiDeviceQueue::~OneapiDeviceQueue()
{
delete kernel_context_;
}
int OneapiDeviceQueue::num_concurrent_states(const size_t state_size) const
{
const int max_num_threads = oneapi_device_->get_num_multiprocessors() *
oneapi_device_->get_max_num_threads_per_multiprocessor();
int num_states = max(8 * max_num_threads, 65536) * 16;
VLOG_DEVICE_STATS << "GPU queue concurrent states: " << num_states << ", using up to "
<< string_human_readable_size(num_states * state_size);
return num_states;
}
int OneapiDeviceQueue::num_concurrent_busy_states() const
{
const int max_num_threads = oneapi_device_->get_num_multiprocessors() *
oneapi_device_->get_max_num_threads_per_multiprocessor();
return 4 * max(8 * max_num_threads, 65536);
}
void OneapiDeviceQueue::init_execution()
{
oneapi_device_->load_texture_info();
SyclQueue *device_queue = oneapi_device_->sycl_queue();
void *kg_dptr = (void *)oneapi_device_->kernel_globals_device_pointer();
assert(device_queue);
assert(kg_dptr);
kernel_context_ = new KernelContext{device_queue, kg_dptr};
debug_init_execution();
}
bool OneapiDeviceQueue::enqueue(DeviceKernel kernel,
const int signed_kernel_work_size,
DeviceKernelArguments const &_args)
{
if (oneapi_device_->have_error()) {
return false;
}
void **args = const_cast<void **>(_args.values);
debug_enqueue(kernel, signed_kernel_work_size);
assert(signed_kernel_work_size >= 0);
size_t kernel_work_size = (size_t)signed_kernel_work_size;
size_t kernel_local_size = oneapi_dll_.oneapi_kernel_preferred_local_size(
kernel_context_->queue, (::DeviceKernel)kernel, kernel_work_size);
size_t uniformed_kernel_work_size = round_up(kernel_work_size, kernel_local_size);
assert(kernel_context_);
/* Call the oneAPI kernel DLL to launch the requested kernel. */
bool is_finished_ok = oneapi_dll_.oneapi_enqueue_kernel(
kernel_context_, kernel, uniformed_kernel_work_size, args);
if (is_finished_ok == false) {
oneapi_device_->set_error("oneAPI kernel \"" + std::string(device_kernel_as_string(kernel)) +
"\" execution error: got runtime exception \"" +
oneapi_device_->oneapi_error_message() + "\"");
}
return is_finished_ok;
}
bool OneapiDeviceQueue::synchronize()
{
if (oneapi_device_->have_error()) {
return false;
}
bool is_finished_ok = oneapi_dll_.oneapi_queue_synchronize(oneapi_device_->sycl_queue());
if (is_finished_ok == false)
oneapi_device_->set_error("oneAPI unknown kernel execution error: got runtime exception \"" +
oneapi_device_->oneapi_error_message() + "\"");
debug_synchronize();
return !(oneapi_device_->have_error());
}
void OneapiDeviceQueue::zero_to_device(device_memory &mem)
{
oneapi_device_->mem_zero(mem);
}
void OneapiDeviceQueue::copy_to_device(device_memory &mem)
{
oneapi_device_->mem_copy_to(mem);
}
void OneapiDeviceQueue::copy_from_device(device_memory &mem)
{
oneapi_device_->mem_copy_from(mem);
}
CCL_NAMESPACE_END
#endif /* WITH_ONEAPI */

View File

@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Intel Corporation */
#pragma once
#ifdef WITH_ONEAPI
# include "device/kernel.h"
# include "device/memory.h"
# include "device/queue.h"
# include "device/oneapi/device.h"
# include "device/oneapi/dll_interface.h"
CCL_NAMESPACE_BEGIN
class OneapiDevice;
class device_memory;
/* Base class for OneAPI queues. */
class OneapiDeviceQueue : public DeviceQueue {
public:
explicit OneapiDeviceQueue(OneapiDevice *device);
~OneapiDeviceQueue();
virtual int num_concurrent_states(const size_t state_size) const override;
virtual int num_concurrent_busy_states() const override;
virtual void init_execution() override;
virtual bool enqueue(DeviceKernel kernel,
const int kernel_work_size,
DeviceKernelArguments const &args) override;
virtual bool synchronize() override;
virtual void zero_to_device(device_memory &mem) override;
virtual void copy_to_device(device_memory &mem) override;
virtual void copy_from_device(device_memory &mem) override;
protected:
OneapiDevice *oneapi_device_;
OneAPIDLLInterface oneapi_dll_;
KernelContext *kernel_context_;
bool with_kernel_statistics_;
};
CCL_NAMESPACE_END
#endif /* WITH_ONEAPI */

View File

@@ -26,7 +26,6 @@
# include "util/task.h"
# include "util/time.h"
# undef __KERNEL_CPU__
# define __KERNEL_OPTIX__
# include "kernel/device/optix/globals.h"
@@ -2047,7 +2046,7 @@ void OptiXDevice::const_copy_to(const char *name, void *host, size_t size)
/* Update traversable handle (since it is different for each device on multi devices). */
KernelData *const data = (KernelData *)host;
*(OptixTraversableHandle *)&data->bvh.scene = tlas_handle;
*(OptixTraversableHandle *)&data->device_bvh = tlas_handle;
update_launch_params(offsetof(KernelParamsOptiX, data), host, size);
return;

View File

@@ -8,7 +8,6 @@
# include "util/time.h"
# undef __KERNEL_CPU__
# define __KERNEL_OPTIX__
# include "kernel/device/optix/globals.h"

View File

@@ -105,6 +105,13 @@ class DeviceQueue {
* value. */
virtual int num_concurrent_busy_states() const = 0;
/* Number of elements in a partition of sorted shaders, that improves memory locality of
* integrator state fetch at the cost of decreased coherence for shader kernel execution. */
virtual int num_sort_partition_elements() const
{
return 65536;
}
/* Initialize execution of kernels on this queue.
*
* Will, for example, load all data required by the kernels from Device to global or path state.

View File

@@ -373,7 +373,7 @@ void PathTrace::path_trace(RenderWork &render_work)
work_balance_infos_[i].time_spent += work_time;
work_balance_infos_[i].occupancy = statistics.occupancy;
VLOG_WORK << "Rendered " << num_samples << " samples in " << work_time << " seconds ("
VLOG_INFO << "Rendered " << num_samples << " samples in " << work_time << " seconds ("
<< work_time / num_samples
<< " seconds per sample), occupancy: " << statistics.occupancy;
});
@@ -1103,6 +1103,8 @@ static const char *device_type_for_description(const DeviceType type)
return "OptiX";
case DEVICE_HIP:
return "HIP";
case DEVICE_ONEAPI:
return "oneAPI";
case DEVICE_DUMMY:
return "Dummy";
case DEVICE_MULTI:

View File

@@ -181,27 +181,45 @@ void PathTraceWorkGPU::alloc_integrator_queue()
void PathTraceWorkGPU::alloc_integrator_sorting()
{
/* Compute sort partitions, to balance between memory locality and coherence.
* Sort partitioning becomes less effective when more shaders are in the wavefront. In lieu of a
* more sophisticated heuristic we simply disable sort partitioning if the shader count is high.
*/
num_sort_partitions_ = 1;
if (device_scene_->data.max_shaders < 300) {
const int num_elements = queue_->num_sort_partition_elements();
if (num_elements) {
num_sort_partitions_ = max(max_num_paths_ / num_elements, 1);
}
}
integrator_state_gpu_.sort_partition_divisor = (int)divide_up(max_num_paths_,
num_sort_partitions_);
/* Allocate arrays for shader sorting. */
const int max_shaders = device_scene_->data.max_shaders;
if (integrator_shader_sort_counter_.size() < max_shaders) {
integrator_shader_sort_counter_.alloc(max_shaders);
const int sort_buckets = device_scene_->data.max_shaders * num_sort_partitions_;
if (integrator_shader_sort_counter_.size() < sort_buckets) {
integrator_shader_sort_counter_.alloc(sort_buckets);
integrator_shader_sort_counter_.zero_to_device();
integrator_shader_raytrace_sort_counter_.alloc(max_shaders);
integrator_shader_raytrace_sort_counter_.zero_to_device();
integrator_shader_mnee_sort_counter_.alloc(max_shaders);
integrator_shader_mnee_sort_counter_.zero_to_device();
integrator_shader_sort_prefix_sum_.alloc(max_shaders);
integrator_shader_sort_prefix_sum_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE] =
(int *)integrator_shader_sort_counter_.device_pointer;
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE] =
(int *)integrator_shader_raytrace_sort_counter_.device_pointer;
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE] =
(int *)integrator_shader_mnee_sort_counter_.device_pointer;
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
integrator_shader_raytrace_sort_counter_.alloc(sort_buckets);
integrator_shader_raytrace_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE] =
(int *)integrator_shader_raytrace_sort_counter_.device_pointer;
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
integrator_shader_mnee_sort_counter_.alloc(sort_buckets);
integrator_shader_mnee_sort_counter_.zero_to_device();
integrator_state_gpu_.sort_key_counter[DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE] =
(int *)integrator_shader_mnee_sort_counter_.device_pointer;
}
integrator_shader_sort_prefix_sum_.alloc(sort_buckets);
integrator_shader_sort_prefix_sum_.zero_to_device();
}
}
@@ -333,8 +351,12 @@ void PathTraceWorkGPU::enqueue_reset()
queue_->enqueue(DEVICE_KERNEL_INTEGRATOR_RESET, max_num_paths_, args);
queue_->zero_to_device(integrator_queue_counter_);
queue_->zero_to_device(integrator_shader_sort_counter_);
queue_->zero_to_device(integrator_shader_raytrace_sort_counter_);
queue_->zero_to_device(integrator_shader_mnee_sort_counter_);
if (device_scene_->data.kernel_features & KERNEL_FEATURE_NODE_RAYTRACE) {
queue_->zero_to_device(integrator_shader_raytrace_sort_counter_);
}
if (device_scene_->data.kernel_features & KERNEL_FEATURE_MNEE) {
queue_->zero_to_device(integrator_shader_mnee_sort_counter_);
}
/* Tiles enqueue need to know number of active paths, which is based on this counter. Zero the
* counter on the host side because `zero_to_device()` is not doing it. */
@@ -486,9 +508,9 @@ void PathTraceWorkGPU::compute_sorted_queued_paths(DeviceKernel kernel,
/* Compute prefix sum of number of active paths with each shader. */
{
const int work_size = 1;
int max_shaders = device_scene_->data.max_shaders;
int sort_buckets = device_scene_->data.max_shaders * num_sort_partitions_;
DeviceKernelArguments args(&d_counter, &d_prefix_sum, &max_shaders);
DeviceKernelArguments args(&d_counter, &d_prefix_sum, &sort_buckets);
queue_->enqueue(DEVICE_KERNEL_PREFIX_SUM, work_size, args);
}

View File

@@ -156,6 +156,9 @@ class PathTraceWorkGPU : public PathTraceWork {
bool interop_use_checked_ = false;
bool interop_use_ = false;
/* Number of partitions to sort state indices into prior to material sort. */
int num_sort_partitions_;
/* Maximum number of concurrent integrator states. */
int max_num_paths_;

View File

@@ -37,7 +37,12 @@ set(SRC_KERNEL_DEVICE_OPTIX
device/optix/kernel_shader_raytrace.cu
)
set(SRC_KERNEL_DEVICE_ONEAPI
device/oneapi/kernel.cpp
)
set(SRC_KERNEL_DEVICE_CPU_HEADERS
device/cpu/bvh.h
device/cpu/compat.h
device/cpu/image.h
device/cpu/globals.h
@@ -67,17 +72,30 @@ set(SRC_KERNEL_DEVICE_HIP_HEADERS
)
set(SRC_KERNEL_DEVICE_OPTIX_HEADERS
device/optix/bvh.h
device/optix/compat.h
device/optix/globals.h
)
set(SRC_KERNEL_DEVICE_METAL_HEADERS
device/metal/bvh.h
device/metal/compat.h
device/metal/context_begin.h
device/metal/context_end.h
device/metal/function_constants.h
device/metal/globals.h
)
set(SRC_KERNEL_DEVICE_ONEAPI_HEADERS
device/oneapi/compat.h
device/oneapi/context_begin.h
device/oneapi/context_end.h
device/oneapi/globals.h
device/oneapi/image.h
device/oneapi/kernel.h
device/oneapi/kernel_templates.h
)
set(SRC_KERNEL_CLOSURE_HEADERS
closure/alloc.h
closure/bsdf.h
@@ -140,6 +158,7 @@ set(SRC_KERNEL_SVM_HEADERS
svm/math_util.h
svm/mix.h
svm/musgrave.h
svm/node_types_template.h
svm/noise.h
svm/noisetex.h
svm/normal.h
@@ -198,8 +217,6 @@ set(SRC_KERNEL_BVH_HEADERS
bvh/util.h
bvh/volume.h
bvh/volume_all.h
bvh/embree.h
bvh/metal.h
)
set(SRC_KERNEL_CAMERA_HEADERS
@@ -268,6 +285,7 @@ set(SRC_KERNEL_UTIL_HEADERS
set(SRC_KERNEL_TYPES_HEADERS
data_arrays.h
data_template.h
tables.h
types.h
)
@@ -299,6 +317,7 @@ set(SRC_UTIL_HEADERS
../util/math_float2.h
../util/math_float3.h
../util/math_float4.h
../util/math_float8.h
../util/math_int2.h
../util/math_int3.h
../util/math_int4.h
@@ -336,8 +355,6 @@ set(SRC_UTIL_HEADERS
../util/types_uint4.h
../util/types_uint4_impl.h
../util/types_ushort4.h
../util/types_vector3.h
../util/types_vector3_impl.h
)
set(LIB
@@ -687,6 +704,209 @@ if(WITH_CYCLES_DEVICE_OPTIX AND WITH_CYCLES_CUDA_BINARIES)
cycles_set_solution_folder(cycles_kernel_optix)
endif()
if(WITH_CYCLES_DEVICE_ONEAPI)
if(WIN32)
set(cycles_kernel_oneapi_lib ${CMAKE_CURRENT_BINARY_DIR}/cycles_kernel_oneapi.dll)
else()
set(cycles_kernel_oneapi_lib ${CMAKE_CURRENT_BINARY_DIR}/cycles_kernel_oneapi.so)
endif()
set(cycles_oneapi_kernel_sources
${SRC_KERNEL_DEVICE_ONEAPI}
${SRC_KERNEL_HEADERS}
${SRC_KERNEL_DEVICE_GPU_HEADERS}
${SRC_KERNEL_DEVICE_ONEAPI_HEADERS}
${SRC_UTIL_HEADERS}
)
# SYCL_CPP_FLAGS is a variable that the user can set to pass extra compiler options
set(sycl_compiler_flags
${CMAKE_CURRENT_SOURCE_DIR}/${SRC_KERNEL_DEVICE_ONEAPI}
-fsycl
-fsycl-unnamed-lambda
-fdelayed-template-parsing
-mllvm -inlinedefault-threshold=300
-mllvm -inlinehint-threshold=400
-shared
-DWITH_ONEAPI
-ffast-math
-DNDEBUG
-O2
-o ${cycles_kernel_oneapi_lib}
-I${CMAKE_CURRENT_SOURCE_DIR}/..
${SYCL_CPP_FLAGS}
)
if (WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED)
list(APPEND sycl_compiler_flags -DWITH_ONEAPI_SYCL_HOST_ENABLED)
endif()
# Set defaults for spir64 and spir64_gen options
if (NOT DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_spir64)
set(CYCLES_ONEAPI_SYCL_OPTIONS_spir64 "-options '-ze-opt-large-register-file -ze-opt-regular-grf-kernel integrator_intersect'")
endif()
if (NOT DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen)
SET (CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen "${CYCLES_ONEAPI_SYCL_OPTIONS_spir64}" CACHE STRING "Extra build options for spir64_gen target")
endif()
# enabling zebin (graphics binary format with improved compatibility) on Windows only while support on Linux isn't available yet
if(WIN32)
string(PREPEND CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen "--format zebin ")
endif()
string(PREPEND CYCLES_ONEAPI_SYCL_OPTIONS_spir64_gen "-device ${CYCLES_ONEAPI_SPIR64_GEN_DEVICES} ")
if (WITH_CYCLES_ONEAPI_BINARIES)
# Iterate over all targest and their options
list (JOIN CYCLES_ONEAPI_SYCL_TARGETS "," targets_string)
list (APPEND sycl_compiler_flags -fsycl-targets=${targets_string})
foreach(target ${CYCLES_ONEAPI_SYCL_TARGETS})
if(DEFINED CYCLES_ONEAPI_SYCL_OPTIONS_${target})
list (APPEND sycl_compiler_flags -Xsycl-target-backend=${target} "${CYCLES_ONEAPI_SYCL_OPTIONS_${target}}")
endif()
endforeach()
else()
# If AOT is disabled, build for spir64
list(APPEND sycl_compiler_flags
-fsycl-targets=spir64
-Xsycl-target-backend=spir64 "${CYCLES_ONEAPI_SYCL_OPTIONS_spir64}")
endif()
if(WITH_NANOVDB)
list(APPEND sycl_compiler_flags
-DWITH_NANOVDB
-I"${NANOVDB_INCLUDE_DIR}")
endif()
if(WITH_CYCLES_DEBUG)
list(APPEND sycl_compiler_flags -DWITH_CYCLES_DEBUG)
endif()
get_filename_component(sycl_compiler_root ${SYCL_COMPILER} DIRECTORY)
get_filename_component(sycl_compiler_compiler_name ${SYCL_COMPILER} NAME_WE)
if(NOT OCLOC_INSTALL_DIR)
get_filename_component(OCLOC_INSTALL_DIR "${sycl_compiler_root}/../lib/ocloc" ABSOLUTE)
endif()
if(WITH_CYCLES_ONEAPI_BINARIES AND NOT EXISTS ${OCLOC_INSTALL_DIR})
message(FATAL_ERROR "WITH_CYCLES_ONEAPI_BINARIES requires ocloc but ${OCLOC_INSTALL_DIR} directory doesn't exist."
" A different ocloc directory can be set using OCLOC_INSTALL_DIR cmake variable.")
endif()
if(UNIX AND NOT APPLE)
if(NOT WITH_CXX11_ABI)
check_library_exists(sycl
_ZN2cl4sycl7handler22verifyUsedKernelBundleERKSs ${sycl_compiler_root}/../lib SYCL_NO_CXX11_ABI)
if(SYCL_NO_CXX11_ABI)
list(APPEND sycl_compiler_flags -D_GLIBCXX_USE_CXX11_ABI=0)
endif()
endif()
endif()
if(WIN32)
list(APPEND sycl_compiler_flags
-fms-extensions
-fms-compatibility
-D_WINDLL
-D_MBCS
-DWIN32
-D_WINDOWS
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
-DONEAPI_EXPORT)
if(sycl_compiler_compiler_name MATCHES "dpcpp")
# The oneAPI distribution calls the compiler "dpcpp" and comes with a script that sets environment variables.
add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib}
COMMAND "${sycl_compiler_root}/../../env/vars.bat"
COMMAND ${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags}
DEPENDS ${cycles_oneapi_kernel_sources})
else()
# The open source SYCL compiler just goes by clang++ and does not have such a script.
# Set the variables manually.
string(REPLACE /Redist/ /Tools/ MSVC_TOOLS_DIR ${MSVC_REDIST_DIR})
if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) # case for Ninja on Windows
get_filename_component(cmake_mt_dir ${CMAKE_MT} DIRECTORY)
string(REPLACE /bin/ /Lib/ WINDOWS_KIT_DIR ${cmake_mt_dir})
get_filename_component(WINDOWS_KIT_DIR "${WINDOWS_KIT_DIR}/../" ABSOLUTE)
else()
set(WINDOWS_KIT_DIR ${WINDOWS_KITS_DIR}/Lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
endif()
list(APPEND sycl_compiler_flags
-L "${MSVC_TOOLS_DIR}/lib/x64"
-L "${WINDOWS_KIT_DIR}/um/x64"
-L "${WINDOWS_KIT_DIR}/ucrt/x64")
add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib}
COMMAND ${CMAKE_COMMAND} -E env
"LIB=${sycl_compiler_root}/../lib" # for compiler to find sycl.lib
"PATH=${OCLOC_INSTALL_DIR};${sycl_compiler_root}"
${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags}
DEPENDS ${cycles_oneapi_kernel_sources})
endif()
else()
list(APPEND sycl_compiler_flags -fPIC)
# We avoid getting __FAST_MATH__ to be defined when building on CentOS 7 until the compilation crash
# it triggers at either AoT or JIT stages gets fixed.
list(APPEND sycl_compiler_flags -fhonor-nans)
# add $ORIGIN to cycles_kernel_oneapi.so rpath so libsycl.so and
# libpi_level_zero.so can be placed next to it and get found.
list(APPEND sycl_compiler_flags -Wl,-rpath,'$$ORIGIN')
# The oneAPI distribution calls the compiler "dpcpp" and comes with a script that sets environment variables.
if(sycl_compiler_compiler_name MATCHES "dpcpp")
add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib}
COMMAND bash -c \"source ${sycl_compiler_root}/../../env/vars.sh&&${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags}\"
DEPENDS ${cycles_oneapi_kernel_sources})
else()
# The open source SYCL compiler just goes by clang++ and does not have such a script.
# Set the variables manually.
if(NOT IGC_INSTALL_DIR)
get_filename_component(IGC_INSTALL_DIR "${sycl_compiler_root}/../lib/igc" ABSOLUTE)
endif()
add_custom_command(
OUTPUT ${cycles_kernel_oneapi_lib}
COMMAND ${CMAKE_COMMAND} -E env
"LD_LIBRARY_PATH=${sycl_compiler_root}/../lib:${OCLOC_INSTALL_DIR}/lib:${IGC_INSTALL_DIR}/lib"
"PATH=${OCLOC_INSTALL_DIR}/bin:${sycl_compiler_root}:$ENV{PATH}" # env PATH is for compiler to find ld
${SYCL_COMPILER} $<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g> ${sycl_compiler_flags}
DEPENDS ${cycles_oneapi_kernel_sources})
endif()
endif()
# install dynamic libraries required at runtime
if(WIN32)
set(SYCL_RUNTIME_DEPENDENCIES
sycl.dll
pi_level_zero.dll
)
if(NOT WITH_BLENDER)
# For the Cycles standalone put libraries next to the Cycles application.
delayed_install("${sycl_compiler_root}" "${SYCL_RUNTIME_DEPENDENCIES}" ${CYCLES_INSTALL_PATH})
else()
# For Blender put the libraries next to the Blender executable.
#
# Note that the installation path in the delayed_install is relative to the versioned folder,
# which means we need to go one level up.
delayed_install("${sycl_compiler_root}" "${SYCL_RUNTIME_DEPENDENCIES}" "../")
endif()
elseif(UNIX AND NOT APPLE)
file(GLOB SYCL_RUNTIME_DEPENDENCIES
${sycl_compiler_root}/../lib/libsycl.so
${sycl_compiler_root}/../lib/libsycl.so.[0-9]
${sycl_compiler_root}/../lib/libsycl.so.[0-9].[0-9].[0-9]-[0-9]
)
list(APPEND SYCL_RUNTIME_DEPENDENCIES ${sycl_compiler_root}/../lib/libpi_level_zero.so)
delayed_install("" "${SYCL_RUNTIME_DEPENDENCIES}" ${CYCLES_INSTALL_PATH}/lib)
endif()
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cycles_kernel_oneapi_lib}" ${CYCLES_INSTALL_PATH}/lib)
add_custom_target(cycles_kernel_oneapi ALL DEPENDS ${cycles_kernel_oneapi_lib})
endif()
# OSL module
if(WITH_CYCLES_OSL)
@@ -752,6 +972,7 @@ cycles_add_library(cycles_kernel "${LIB}"
${SRC_KERNEL_DEVICE_HIP_HEADERS}
${SRC_KERNEL_DEVICE_OPTIX_HEADERS}
${SRC_KERNEL_DEVICE_METAL_HEADERS}
${SRC_KERNEL_DEVICE_ONEAPI_HEADERS}
)
source_group("bake" FILES ${SRC_KERNEL_BAKE_HEADERS})
@@ -764,6 +985,7 @@ source_group("device\\gpu" FILES ${SRC_KERNEL_DEVICE_GPU_HEADERS})
source_group("device\\hip" FILES ${SRC_KERNEL_DEVICE_HIP} ${SRC_KERNEL_DEVICE_HIP_HEADERS})
source_group("device\\optix" FILES ${SRC_KERNEL_DEVICE_OPTIX} ${SRC_KERNEL_DEVICE_OPTIX_HEADERS})
source_group("device\\metal" FILES ${SRC_KERNEL_DEVICE_METAL} ${SRC_KERNEL_DEVICE_METAL_HEADERS})
source_group("device\\oneapi" FILES ${SRC_KERNEL_DEVICE_ONEAPI} ${SRC_KERNEL_DEVICE_ONEAPI_HEADERS})
source_group("film" FILES ${SRC_KERNEL_FILM_HEADERS})
source_group("geom" FILES ${SRC_KERNEL_GEOM_HEADERS})
source_group("integrator" FILES ${SRC_KERNEL_INTEGRATOR_HEADERS})
@@ -782,6 +1004,9 @@ endif()
if(WITH_CYCLES_HIP)
add_dependencies(cycles_kernel cycles_kernel_hip)
endif()
if(WITH_CYCLES_DEVICE_ONEAPI)
add_dependencies(cycles_kernel cycles_kernel_oneapi)
endif()
# Install kernel source for runtime compilation

View File

@@ -29,14 +29,14 @@ ccl_device void kernel_displace_evaluate(KernelGlobals kg,
object_inverse_dir_transform(kg, &sd, &D);
#ifdef __KERNEL_DEBUG_NAN__
if (!isfinite3_safe(D)) {
if (!isfinite_safe(D)) {
kernel_assert(!"Cycles displacement with non-finite value detected");
}
#endif
/* Ensure finite displacement, preventing BVH from becoming degenerate and avoiding possible
* traversal issues caused by non-finite math. */
D = ensure_finite3(D);
D = ensure_finite(D);
/* Write output. */
output[offset * 3 + 0] += D.x;
@@ -68,13 +68,13 @@ ccl_device void kernel_background_evaluate(KernelGlobals kg,
float3 color = shader_background_eval(&sd);
#ifdef __KERNEL_DEBUG_NAN__
if (!isfinite3_safe(color)) {
if (!isfinite_safe(color)) {
kernel_assert(!"Cycles background with non-finite value detected");
}
#endif
/* Ensure finite color, avoiding possible numerical instabilities in the path tracing kernels. */
color = ensure_finite3(color);
color = ensure_finite(color);
/* Write output. */
output[offset * 3 + 0] += color.x;

View File

@@ -1,40 +1,47 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
/* BVH
*
* Bounding volume hierarchy for ray tracing. We compile different variations
* of the same BVH traversal function for faster rendering when some types of
* primitives are not needed, using #includes to work around the lack of
* C++ templates in OpenCL.
*
* Originally based on "Understanding the Efficiency of Ray Traversal on GPUs",
* the code has been extended and modified to support more primitives and work
* with CPU/CUDA/OpenCL. */
#pragma once
#ifdef __EMBREE__
# include "kernel/bvh/embree.h"
#endif
#ifdef __METALRT__
# include "kernel/bvh/metal.h"
#endif
#include "kernel/bvh/types.h"
#include "kernel/bvh/util.h"
#include "kernel/integrator/state_util.h"
/* Device specific acceleration structures for ray tracing. */
#if defined(__EMBREE__)
# include "kernel/device/cpu/bvh.h"
# define __BVH2__
#elif defined(__METALRT__)
# include "kernel/device/metal/bvh.h"
#elif defined(__KERNEL_OPTIX__)
# include "kernel/device/optix/bvh.h"
#else
# define __BVH2__
#endif
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_GPU_RAYTRACING__)
#ifdef __BVH2__
/* Regular BVH traversal */
/* BVH2
*
* Bounding volume hierarchy for ray tracing, when no native acceleration
* structure is available for the device.
* We compile different variations of the same BVH traversal function for
* faster rendering when some types of primitives are not needed, using #includes
* to work around the lack of C++ templates in OpenCL.
*
* Originally based on "Understanding the Efficiency of Ray Traversal on GPUs",
* the code has been extended and modified to support more primitives and work
* with CPU and various GPU kernel languages. */
# include "kernel/bvh/nodes.h"
/* Regular BVH traversal */
# define BVH_FUNCTION_NAME bvh_intersect
# define BVH_FUNCTION_FEATURES BVH_POINTCLOUD
# include "kernel/bvh/traversal.h"
@@ -57,9 +64,46 @@ CCL_NAMESPACE_BEGIN
# include "kernel/bvh/traversal.h"
# endif
/* Subsurface scattering BVH traversal */
ccl_device_intersect bool scene_intersect(KernelGlobals kg,
ccl_private const Ray *ray,
const uint visibility,
ccl_private Intersection *isect)
{
if (!intersection_ray_valid(ray)) {
return false;
}
# ifdef __EMBREE__
if (kernel_data.device_bvh) {
return kernel_embree_intersect(kg, ray, visibility, isect);
}
# endif
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
# ifdef __HAIR__
if (kernel_data.bvh.have_curves) {
return bvh_intersect_hair_motion(kg, ray, isect, visibility);
}
# endif /* __HAIR__ */
return bvh_intersect_motion(kg, ray, isect, visibility);
}
# endif /* __OBJECT_MOTION__ */
# ifdef __HAIR__
if (kernel_data.bvh.have_curves) {
return bvh_intersect_hair(kg, ray, isect, visibility);
}
# endif /* __HAIR__ */
return bvh_intersect(kg, ray, isect, visibility);
}
/* Single object BVH traversal, for SSS/AO/bevel. */
# ifdef __BVH_LOCAL__
# if defined(__BVH_LOCAL__)
# define BVH_FUNCTION_NAME bvh_intersect_local
# define BVH_FUNCTION_FEATURES BVH_HAIR
# include "kernel/bvh/local.h"
@@ -69,25 +113,40 @@ CCL_NAMESPACE_BEGIN
# define BVH_FUNCTION_FEATURES BVH_MOTION | BVH_HAIR
# include "kernel/bvh/local.h"
# endif
# endif /* __BVH_LOCAL__ */
/* Volume BVH traversal */
ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
ccl_private const Ray *ray,
ccl_private LocalIntersection *local_isect,
int local_object,
ccl_private uint *lcg_state,
int max_hits)
{
if (!intersection_ray_valid(ray)) {
if (local_isect) {
local_isect->num_hits = 0;
}
return false;
}
# if defined(__VOLUME__)
# define BVH_FUNCTION_NAME bvh_intersect_volume
# define BVH_FUNCTION_FEATURES BVH_HAIR
# include "kernel/bvh/volume.h"
# if defined(__OBJECT_MOTION__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_motion
# define BVH_FUNCTION_FEATURES BVH_MOTION | BVH_HAIR
# include "kernel/bvh/volume.h"
# ifdef __EMBREE__
if (kernel_data.device_bvh) {
return kernel_embree_intersect_local(kg, ray, local_isect, local_object, lcg_state, max_hits);
}
# endif
# endif /* __VOLUME__ */
/* Record all intersections - Shadow BVH traversal */
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
return bvh_intersect_local_motion(kg, ray, local_isect, local_object, lcg_state, max_hits);
}
# endif /* __OBJECT_MOTION__ */
return bvh_intersect_local(kg, ray, local_isect, local_object, lcg_state, max_hits);
}
# endif
/* Transparent shadow BVH traversal, recording multiple intersections. */
# ifdef __SHADOW_RECORD_ALL__
# if defined(__SHADOW_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_shadow_all
# define BVH_FUNCTION_FEATURES BVH_POINTCLOUD
# include "kernel/bvh/shadow_all.h"
@@ -110,412 +169,6 @@ CCL_NAMESPACE_BEGIN
# include "kernel/bvh/shadow_all.h"
# endif
# endif /* __SHADOW_RECORD_ALL__ */
/* Record all intersections - Volume BVH traversal. */
# if defined(__VOLUME_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all
# define BVH_FUNCTION_FEATURES BVH_HAIR
# include "kernel/bvh/volume_all.h"
# if defined(__OBJECT_MOTION__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all_motion
# define BVH_FUNCTION_FEATURES BVH_MOTION | BVH_HAIR
# include "kernel/bvh/volume_all.h"
# endif
# endif /* __VOLUME_RECORD_ALL__ */
# undef BVH_FEATURE
# undef BVH_NAME_JOIN
# undef BVH_NAME_EVAL
# undef BVH_FUNCTION_FULL_NAME
#endif /* !defined(__KERNEL_GPU_RAYTRACING__) */
ccl_device_inline bool scene_intersect_valid(ccl_private const Ray *ray)
{
/* NOTE: Due to some vectorization code non-finite origin point might
* cause lots of false-positive intersections which will overflow traversal
* stack.
* This code is a quick way to perform early output, to avoid crashes in
* such cases.
* From production scenes so far it seems it's enough to test first element
* only.
* Scene intersection may also called with empty rays for conditional trace
* calls that evaluate to false, so filter those out.
*/
return isfinite_safe(ray->P.x) && isfinite_safe(ray->D.x) && len_squared(ray->D) != 0.0f;
}
ccl_device_intersect bool scene_intersect(KernelGlobals kg,
ccl_private const Ray *ray,
const uint visibility,
ccl_private Intersection *isect)
{
#ifdef __KERNEL_OPTIX__
uint p0 = 0;
uint p1 = 0;
uint p2 = 0;
uint p3 = 0;
uint p4 = visibility;
uint p5 = PRIMITIVE_NONE;
uint p6 = ((uint64_t)ray) & 0xFFFFFFFF;
uint p7 = (((uint64_t)ray) >> 32) & 0xFFFFFFFF;
uint ray_mask = visibility & 0xFF;
uint ray_flags = OPTIX_RAY_FLAG_ENFORCE_ANYHIT;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
}
else if (visibility & PATH_RAY_SHADOW_OPAQUE) {
ray_flags |= OPTIX_RAY_FLAG_TERMINATE_ON_FIRST_HIT;
}
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
ray->P,
ray->D,
0.0f,
ray->t,
ray->time,
ray_mask,
ray_flags,
0, /* SBT offset for PG_HITD */
0,
0,
p0,
p1,
p2,
p3,
p4,
p5,
p6,
p7);
isect->t = __uint_as_float(p0);
isect->u = __uint_as_float(p1);
isect->v = __uint_as_float(p2);
isect->prim = p3;
isect->object = p4;
isect->type = p5;
return p5 != PRIMITIVE_NONE;
#elif defined(__METALRT__)
if (!scene_intersect_valid(ray)) {
isect->t = ray->t;
isect->type = PRIMITIVE_NONE;
return false;
}
# if defined(__KERNEL_DEBUG__)
if (is_null_instance_acceleration_structure(metal_ancillaries->accel_struct)) {
isect->t = ray->t;
isect->type = PRIMITIVE_NONE;
kernel_assert(!"Invalid metal_ancillaries->accel_struct pointer");
return false;
}
if (is_null_intersection_function_table(metal_ancillaries->ift_default)) {
isect->t = ray->t;
isect->type = PRIMITIVE_NONE;
kernel_assert(!"Invalid ift_default");
return false;
}
# endif
metal::raytracing::ray r(ray->P, ray->D, 0.0f, ray->t);
metalrt_intersector_type metalrt_intersect;
if (!kernel_data.bvh.have_curves) {
metalrt_intersect.assume_geometry_type(metal::raytracing::geometry_type::triangle);
}
MetalRTIntersectionPayload payload;
payload.self = ray->self;
payload.u = 0.0f;
payload.v = 0.0f;
payload.visibility = visibility;
typename metalrt_intersector_type::result_type intersection;
uint ray_mask = visibility & 0xFF;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
/* No further intersector setup required: Default MetalRT behavior is any-hit. */
}
else if (visibility & PATH_RAY_SHADOW_OPAQUE) {
/* No further intersector setup required: Shadow ray early termination is controlled by the
* intersection handler */
}
# if defined(__METALRT_MOTION__)
payload.time = ray->time;
intersection = metalrt_intersect.intersect(r,
metal_ancillaries->accel_struct,
ray_mask,
ray->time,
metal_ancillaries->ift_default,
payload);
# else
intersection = metalrt_intersect.intersect(
r, metal_ancillaries->accel_struct, ray_mask, metal_ancillaries->ift_default, payload);
# endif
if (intersection.type == intersection_type::none) {
isect->t = ray->t;
isect->type = PRIMITIVE_NONE;
return false;
}
isect->t = intersection.distance;
isect->prim = payload.prim;
isect->type = payload.type;
isect->object = intersection.user_instance_id;
isect->t = intersection.distance;
if (intersection.type == intersection_type::triangle) {
isect->u = 1.0f - intersection.triangle_barycentric_coord.y -
intersection.triangle_barycentric_coord.x;
isect->v = intersection.triangle_barycentric_coord.x;
}
else {
isect->u = payload.u;
isect->v = payload.v;
}
return isect->type != PRIMITIVE_NONE;
#else
if (!scene_intersect_valid(ray)) {
return false;
}
# ifdef __EMBREE__
if (kernel_data.bvh.scene) {
isect->t = ray->t;
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_REGULAR);
IntersectContext rtc_ctx(&ctx);
RTCRayHit ray_hit;
ctx.ray = ray;
kernel_embree_setup_rayhit(*ray, ray_hit, visibility);
rtcIntersect1(kernel_data.bvh.scene, &rtc_ctx.context, &ray_hit);
if (ray_hit.hit.geomID != RTC_INVALID_GEOMETRY_ID &&
ray_hit.hit.primID != RTC_INVALID_GEOMETRY_ID) {
kernel_embree_convert_hit(kg, &ray_hit.ray, &ray_hit.hit, isect);
return true;
}
return false;
}
# endif /* __EMBREE__ */
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
# ifdef __HAIR__
if (kernel_data.bvh.have_curves) {
return bvh_intersect_hair_motion(kg, ray, isect, visibility);
}
# endif /* __HAIR__ */
return bvh_intersect_motion(kg, ray, isect, visibility);
}
# endif /* __OBJECT_MOTION__ */
# ifdef __HAIR__
if (kernel_data.bvh.have_curves) {
return bvh_intersect_hair(kg, ray, isect, visibility);
}
# endif /* __HAIR__ */
return bvh_intersect(kg, ray, isect, visibility);
#endif /* __KERNEL_OPTIX__ */
}
#ifdef __BVH_LOCAL__
ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
ccl_private const Ray *ray,
ccl_private LocalIntersection *local_isect,
int local_object,
ccl_private uint *lcg_state,
int max_hits)
{
# ifdef __KERNEL_OPTIX__
uint p0 = pointer_pack_to_uint_0(lcg_state);
uint p1 = pointer_pack_to_uint_1(lcg_state);
uint p2 = pointer_pack_to_uint_0(local_isect);
uint p3 = pointer_pack_to_uint_1(local_isect);
uint p4 = local_object;
uint p6 = ((uint64_t)ray) & 0xFFFFFFFF;
uint p7 = (((uint64_t)ray) >> 32) & 0xFFFFFFFF;
/* Is set to zero on miss or if ray is aborted, so can be used as return value. */
uint p5 = max_hits;
if (local_isect) {
local_isect->num_hits = 0; /* Initialize hit count to zero. */
}
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
ray->P,
ray->D,
0.0f,
ray->t,
ray->time,
0xFF,
/* Need to always call into __anyhit__kernel_optix_local_hit. */
OPTIX_RAY_FLAG_ENFORCE_ANYHIT,
2, /* SBT offset for PG_HITL */
0,
0,
p0,
p1,
p2,
p3,
p4,
p5,
p6,
p7);
return p5;
# elif defined(__METALRT__)
if (!scene_intersect_valid(ray)) {
if (local_isect) {
local_isect->num_hits = 0;
}
return false;
}
# if defined(__KERNEL_DEBUG__)
if (is_null_instance_acceleration_structure(metal_ancillaries->accel_struct)) {
if (local_isect) {
local_isect->num_hits = 0;
}
kernel_assert(!"Invalid metal_ancillaries->accel_struct pointer");
return false;
}
if (is_null_intersection_function_table(metal_ancillaries->ift_local)) {
if (local_isect) {
local_isect->num_hits = 0;
}
kernel_assert(!"Invalid ift_local");
return false;
}
# endif
metal::raytracing::ray r(ray->P, ray->D, 0.0f, ray->t);
metalrt_intersector_type metalrt_intersect;
metalrt_intersect.force_opacity(metal::raytracing::forced_opacity::non_opaque);
if (!kernel_data.bvh.have_curves) {
metalrt_intersect.assume_geometry_type(metal::raytracing::geometry_type::triangle);
}
MetalRTIntersectionLocalPayload payload;
payload.self = ray->self;
payload.local_object = local_object;
payload.max_hits = max_hits;
payload.local_isect.num_hits = 0;
if (lcg_state) {
payload.has_lcg_state = true;
payload.lcg_state = *lcg_state;
}
payload.result = false;
typename metalrt_intersector_type::result_type intersection;
# if defined(__METALRT_MOTION__)
intersection = metalrt_intersect.intersect(
r, metal_ancillaries->accel_struct, 0xFF, ray->time, metal_ancillaries->ift_local, payload);
# else
intersection = metalrt_intersect.intersect(
r, metal_ancillaries->accel_struct, 0xFF, metal_ancillaries->ift_local, payload);
# endif
if (lcg_state) {
*lcg_state = payload.lcg_state;
}
*local_isect = payload.local_isect;
return payload.result;
# else
if (!scene_intersect_valid(ray)) {
if (local_isect) {
local_isect->num_hits = 0;
}
return false;
}
# ifdef __EMBREE__
if (kernel_data.bvh.scene) {
const bool has_bvh = !(kernel_data_fetch(object_flag, local_object) &
SD_OBJECT_TRANSFORM_APPLIED);
CCLIntersectContext ctx(
kg, has_bvh ? CCLIntersectContext::RAY_SSS : CCLIntersectContext::RAY_LOCAL);
ctx.lcg_state = lcg_state;
ctx.max_hits = max_hits;
ctx.ray = ray;
ctx.local_isect = local_isect;
if (local_isect) {
local_isect->num_hits = 0;
}
ctx.local_object_id = local_object;
IntersectContext rtc_ctx(&ctx);
RTCRay rtc_ray;
kernel_embree_setup_ray(*ray, rtc_ray, PATH_RAY_ALL_VISIBILITY);
/* If this object has its own BVH, use it. */
if (has_bvh) {
RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2);
if (geom) {
float3 P = ray->P;
float3 dir = ray->D;
float3 idir = ray->D;
Transform ob_itfm;
rtc_ray.tfar = ray->t *
bvh_instance_motion_push(kg, local_object, ray, &P, &dir, &idir, &ob_itfm);
/* bvh_instance_motion_push() returns the inverse transform but
* it's not needed here. */
(void)ob_itfm;
rtc_ray.org_x = P.x;
rtc_ray.org_y = P.y;
rtc_ray.org_z = P.z;
rtc_ray.dir_x = dir.x;
rtc_ray.dir_y = dir.y;
rtc_ray.dir_z = dir.z;
RTCScene scene = (RTCScene)rtcGetGeometryUserData(geom);
kernel_assert(scene);
if (scene) {
rtcOccluded1(scene, &rtc_ctx.context, &rtc_ray);
}
}
}
else {
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
}
/* rtcOccluded1 sets tfar to -inf if a hit was found. */
return (local_isect && local_isect->num_hits > 0) || (rtc_ray.tfar < 0);
;
}
# endif /* __EMBREE__ */
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
return bvh_intersect_local_motion(kg, ray, local_isect, local_object, lcg_state, max_hits);
}
# endif /* __OBJECT_MOTION__ */
return bvh_intersect_local(kg, ray, local_isect, local_object, lcg_state, max_hits);
# endif /* __KERNEL_OPTIX__ */
}
#endif
#ifdef __SHADOW_RECORD_ALL__
ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
IntegratorShadowState state,
ccl_private const Ray *ray,
@@ -524,131 +177,18 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
ccl_private uint *num_recorded_hits,
ccl_private float *throughput)
{
# ifdef __KERNEL_OPTIX__
uint p0 = state;
uint p1 = __float_as_uint(1.0f); /* Throughput. */
uint p2 = 0; /* Number of hits. */
uint p3 = max_hits;
uint p4 = visibility;
uint p5 = false;
uint p6 = ((uint64_t)ray) & 0xFFFFFFFF;
uint p7 = (((uint64_t)ray) >> 32) & 0xFFFFFFFF;
uint ray_mask = visibility & 0xFF;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
}
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
ray->P,
ray->D,
0.0f,
ray->t,
ray->time,
ray_mask,
/* Need to always call into __anyhit__kernel_optix_shadow_all_hit. */
OPTIX_RAY_FLAG_ENFORCE_ANYHIT,
1, /* SBT offset for PG_HITS */
0,
0,
p0,
p1,
p2,
p3,
p4,
p5,
p6,
p7);
*num_recorded_hits = uint16_unpack_from_uint_0(p2);
*throughput = __uint_as_float(p1);
return p5;
# elif defined(__METALRT__)
if (!scene_intersect_valid(ray)) {
return false;
}
# if defined(__KERNEL_DEBUG__)
if (is_null_instance_acceleration_structure(metal_ancillaries->accel_struct)) {
kernel_assert(!"Invalid metal_ancillaries->accel_struct pointer");
return false;
}
if (is_null_intersection_function_table(metal_ancillaries->ift_shadow)) {
kernel_assert(!"Invalid ift_shadow");
return false;
}
# endif
metal::raytracing::ray r(ray->P, ray->D, 0.0f, ray->t);
metalrt_intersector_type metalrt_intersect;
metalrt_intersect.force_opacity(metal::raytracing::forced_opacity::non_opaque);
if (!kernel_data.bvh.have_curves) {
metalrt_intersect.assume_geometry_type(metal::raytracing::geometry_type::triangle);
}
MetalRTIntersectionShadowPayload payload;
payload.self = ray->self;
payload.visibility = visibility;
payload.max_hits = max_hits;
payload.num_hits = 0;
payload.num_recorded_hits = 0;
payload.throughput = 1.0f;
payload.result = false;
payload.state = state;
uint ray_mask = visibility & 0xFF;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
}
typename metalrt_intersector_type::result_type intersection;
# if defined(__METALRT_MOTION__)
payload.time = ray->time;
intersection = metalrt_intersect.intersect(r,
metal_ancillaries->accel_struct,
ray_mask,
ray->time,
metal_ancillaries->ift_shadow,
payload);
# else
intersection = metalrt_intersect.intersect(
r, metal_ancillaries->accel_struct, ray_mask, metal_ancillaries->ift_shadow, payload);
# endif
*num_recorded_hits = payload.num_recorded_hits;
*throughput = payload.throughput;
return payload.result;
# else
if (!scene_intersect_valid(ray)) {
if (!intersection_ray_valid(ray)) {
*num_recorded_hits = 0;
*throughput = 1.0f;
return false;
}
# ifdef __EMBREE__
if (kernel_data.bvh.scene) {
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SHADOW_ALL);
Intersection *isect_array = (Intersection *)state->shadow_isect;
ctx.isect_s = isect_array;
ctx.max_hits = max_hits;
ctx.ray = ray;
IntersectContext rtc_ctx(&ctx);
RTCRay rtc_ray;
kernel_embree_setup_ray(*ray, rtc_ray, visibility);
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
*num_recorded_hits = ctx.num_recorded_hits;
*throughput = ctx.throughput;
return ctx.opaque_hit;
if (kernel_data.device_bvh) {
return kernel_embree_intersect_shadow_all(
kg, state, ray, visibility, max_hits, num_recorded_hits, throughput);
}
# endif /* __EMBREE__ */
# endif
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
@@ -662,7 +202,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
return bvh_intersect_shadow_all_motion(
kg, ray, state, visibility, max_hits, num_recorded_hits, throughput);
}
# endif /* __OBJECT_MOTION__ */
# endif /* __OBJECT_MOTION__ */
# ifdef __HAIR__
if (kernel_data.bvh.have_curves) {
@@ -673,132 +213,29 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
return bvh_intersect_shadow_all(
kg, ray, state, visibility, max_hits, num_recorded_hits, throughput);
# endif /* __KERNEL_OPTIX__ */
}
#endif /* __SHADOW_RECORD_ALL__ */
# endif /* __SHADOW_RECORD_ALL__ */
/* Volume BVH traversal, for initializing or updating the volume stack. */
# if defined(__VOLUME__) && !defined(__VOLUME_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_volume
# define BVH_FUNCTION_FEATURES BVH_HAIR
# include "kernel/bvh/volume.h"
# if defined(__OBJECT_MOTION__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_motion
# define BVH_FUNCTION_FEATURES BVH_MOTION | BVH_HAIR
# include "kernel/bvh/volume.h"
# endif
#ifdef __VOLUME__
ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg,
ccl_private const Ray *ray,
ccl_private Intersection *isect,
const uint visibility)
{
# ifdef __KERNEL_OPTIX__
uint p0 = 0;
uint p1 = 0;
uint p2 = 0;
uint p3 = 0;
uint p4 = visibility;
uint p5 = PRIMITIVE_NONE;
uint p6 = ((uint64_t)ray) & 0xFFFFFFFF;
uint p7 = (((uint64_t)ray) >> 32) & 0xFFFFFFFF;
uint ray_mask = visibility & 0xFF;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
}
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
ray->P,
ray->D,
0.0f,
ray->t,
ray->time,
ray_mask,
/* Need to always call into __anyhit__kernel_optix_volume_test. */
OPTIX_RAY_FLAG_ENFORCE_ANYHIT,
3, /* SBT offset for PG_HITV */
0,
0,
p0,
p1,
p2,
p3,
p4,
p5,
p6,
p7);
isect->t = __uint_as_float(p0);
isect->u = __uint_as_float(p1);
isect->v = __uint_as_float(p2);
isect->prim = p3;
isect->object = p4;
isect->type = p5;
return p5 != PRIMITIVE_NONE;
# elif defined(__METALRT__)
if (!scene_intersect_valid(ray)) {
return false;
}
# if defined(__KERNEL_DEBUG__)
if (is_null_instance_acceleration_structure(metal_ancillaries->accel_struct)) {
kernel_assert(!"Invalid metal_ancillaries->accel_struct pointer");
return false;
}
if (is_null_intersection_function_table(metal_ancillaries->ift_default)) {
kernel_assert(!"Invalid ift_default");
return false;
}
# endif
metal::raytracing::ray r(ray->P, ray->D, 0.0f, ray->t);
metalrt_intersector_type metalrt_intersect;
metalrt_intersect.force_opacity(metal::raytracing::forced_opacity::non_opaque);
if (!kernel_data.bvh.have_curves) {
metalrt_intersect.assume_geometry_type(metal::raytracing::geometry_type::triangle);
}
MetalRTIntersectionPayload payload;
payload.self = ray->self;
payload.visibility = visibility;
typename metalrt_intersector_type::result_type intersection;
uint ray_mask = visibility & 0xFF;
if (0 == ray_mask && (visibility & ~0xFF) != 0) {
ray_mask = 0xFF;
}
# if defined(__METALRT_MOTION__)
payload.time = ray->time;
intersection = metalrt_intersect.intersect(r,
metal_ancillaries->accel_struct,
ray_mask,
ray->time,
metal_ancillaries->ift_default,
payload);
# else
intersection = metalrt_intersect.intersect(
r, metal_ancillaries->accel_struct, ray_mask, metal_ancillaries->ift_default, payload);
# endif
if (intersection.type == intersection_type::none) {
return false;
}
isect->prim = payload.prim;
isect->type = payload.type;
isect->object = intersection.user_instance_id;
isect->t = intersection.distance;
if (intersection.type == intersection_type::triangle) {
isect->u = 1.0f - intersection.triangle_barycentric_coord.y -
intersection.triangle_barycentric_coord.x;
isect->v = intersection.triangle_barycentric_coord.x;
}
else {
isect->u = payload.u;
isect->v = payload.v;
}
return isect->type != PRIMITIVE_NONE;
# else
if (!scene_intersect_valid(ray)) {
if (!intersection_ray_valid(ray)) {
return false;
}
@@ -809,44 +246,56 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg,
# endif /* __OBJECT_MOTION__ */
return bvh_intersect_volume(kg, ray, isect, visibility);
# endif /* __KERNEL_OPTIX__ */
}
#endif /* __VOLUME__ */
# endif /* defined(__VOLUME__) && !defined(__VOLUME_RECORD_ALL__) */
#ifdef __VOLUME_RECORD_ALL__
ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals kg,
ccl_private const Ray *ray,
ccl_private Intersection *isect,
const uint max_hits,
const uint visibility)
/* Volume BVH traversal, for initializing or updating the volume stack.
* Variation that records multiple intersections at once. */
# if defined(__VOLUME__) && defined(__VOLUME_RECORD_ALL__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all
# define BVH_FUNCTION_FEATURES BVH_HAIR
# include "kernel/bvh/volume_all.h"
# if defined(__OBJECT_MOTION__)
# define BVH_FUNCTION_NAME bvh_intersect_volume_all_motion
# define BVH_FUNCTION_FEATURES BVH_MOTION | BVH_HAIR
# include "kernel/bvh/volume_all.h"
# endif
ccl_device_intersect uint scene_intersect_volume(KernelGlobals kg,
ccl_private const Ray *ray,
ccl_private Intersection *isect,
const uint max_hits,
const uint visibility)
{
if (!scene_intersect_valid(ray)) {
if (!intersection_ray_valid(ray)) {
return false;
}
# ifdef __EMBREE__
if (kernel_data.bvh.scene) {
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_VOLUME_ALL);
ctx.isect_s = isect;
ctx.max_hits = max_hits;
ctx.num_hits = 0;
ctx.ray = ray;
IntersectContext rtc_ctx(&ctx);
RTCRay rtc_ray;
kernel_embree_setup_ray(*ray, rtc_ray, visibility);
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
return ctx.num_hits;
# ifdef __EMBREE__
if (kernel_data.device_bvh) {
return kernel_embree_intersect_volume(kg, ray, isect, max_hits, visibility);
}
# endif /* __EMBREE__ */
# endif
# ifdef __OBJECT_MOTION__
# ifdef __OBJECT_MOTION__
if (kernel_data.bvh.have_motion) {
return bvh_intersect_volume_all_motion(kg, ray, isect, max_hits, visibility);
}
# endif /* __OBJECT_MOTION__ */
# endif /* __OBJECT_MOTION__ */
return bvh_intersect_volume_all(kg, ray, isect, max_hits, visibility);
}
#endif /* __VOLUME_RECORD_ALL__ */
# endif /* defined(__VOLUME__) && defined(__VOLUME_RECORD_ALL__) */
# undef BVH_FEATURE
# undef BVH_NAME_JOIN
# undef BVH_NAME_EVAL
# undef BVH_FUNCTION_FULL_NAME
#endif /* __BVH2__ */
CCL_NAMESPACE_END

View File

@@ -1,176 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2018-2022 Blender Foundation. */
#pragma once
#include <embree3/rtcore_ray.h>
#include <embree3/rtcore_scene.h>
#include "kernel/device/cpu/compat.h"
#include "kernel/device/cpu/globals.h"
#include "kernel/bvh/util.h"
#include "util/vector.h"
CCL_NAMESPACE_BEGIN
struct CCLIntersectContext {
typedef enum {
RAY_REGULAR = 0,
RAY_SHADOW_ALL = 1,
RAY_LOCAL = 2,
RAY_SSS = 3,
RAY_VOLUME_ALL = 4,
} RayType;
KernelGlobals kg;
RayType type;
/* For avoiding self intersections */
const Ray *ray;
/* for shadow rays */
Intersection *isect_s;
uint max_hits;
uint num_hits;
uint num_recorded_hits;
float throughput;
float max_t;
bool opaque_hit;
/* for SSS Rays: */
LocalIntersection *local_isect;
int local_object_id;
uint *lcg_state;
CCLIntersectContext(KernelGlobals kg_, RayType type_)
{
kg = kg_;
type = type_;
ray = NULL;
max_hits = 1;
num_hits = 0;
num_recorded_hits = 0;
throughput = 1.0f;
max_t = FLT_MAX;
opaque_hit = false;
isect_s = NULL;
local_isect = NULL;
local_object_id = -1;
lcg_state = NULL;
}
};
class IntersectContext {
public:
IntersectContext(CCLIntersectContext *ctx)
{
rtcInitIntersectContext(&context);
userRayExt = ctx;
}
RTCIntersectContext context;
CCLIntersectContext *userRayExt;
};
ccl_device_inline void kernel_embree_setup_ray(const Ray &ray,
RTCRay &rtc_ray,
const uint visibility)
{
rtc_ray.org_x = ray.P.x;
rtc_ray.org_y = ray.P.y;
rtc_ray.org_z = ray.P.z;
rtc_ray.dir_x = ray.D.x;
rtc_ray.dir_y = ray.D.y;
rtc_ray.dir_z = ray.D.z;
rtc_ray.tnear = 0.0f;
rtc_ray.tfar = ray.t;
rtc_ray.time = ray.time;
rtc_ray.mask = visibility;
}
ccl_device_inline void kernel_embree_setup_rayhit(const Ray &ray,
RTCRayHit &rayhit,
const uint visibility)
{
kernel_embree_setup_ray(ray, rayhit.ray, visibility);
rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID;
rayhit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
}
ccl_device_inline bool kernel_embree_is_self_intersection(const KernelGlobals kg,
const RTCHit *hit,
const Ray *ray)
{
bool status = false;
if (hit->instID[0] != RTC_INVALID_GEOMETRY_ID) {
const int oID = hit->instID[0] / 2;
if ((ray->self.object == oID) || (ray->self.light_object == oID)) {
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
rtcGetGeometry(kernel_data.bvh.scene, hit->instID[0]));
const int pID = hit->primID +
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
status = intersection_skip_self_shadow(ray->self, oID, pID);
}
}
else {
const int oID = hit->geomID / 2;
if ((ray->self.object == oID) || (ray->self.light_object == oID)) {
const int pID = hit->primID + (intptr_t)rtcGetGeometryUserData(
rtcGetGeometry(kernel_data.bvh.scene, hit->geomID));
status = intersection_skip_self_shadow(ray->self, oID, pID);
}
}
return status;
}
ccl_device_inline void kernel_embree_convert_hit(KernelGlobals kg,
const RTCRay *ray,
const RTCHit *hit,
Intersection *isect)
{
isect->t = ray->tfar;
if (hit->instID[0] != RTC_INVALID_GEOMETRY_ID) {
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
rtcGetGeometry(kernel_data.bvh.scene, hit->instID[0]));
isect->prim = hit->primID +
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
isect->object = hit->instID[0] / 2;
}
else {
isect->prim = hit->primID + (intptr_t)rtcGetGeometryUserData(
rtcGetGeometry(kernel_data.bvh.scene, hit->geomID));
isect->object = hit->geomID / 2;
}
const bool is_hair = hit->geomID & 1;
if (is_hair) {
const KernelCurveSegment segment = kernel_data_fetch(curve_segments, isect->prim);
isect->type = segment.type;
isect->prim = segment.prim;
isect->u = hit->u;
isect->v = hit->v;
}
else {
isect->type = kernel_data_fetch(objects, isect->object).primitive_type;
isect->u = 1.0f - hit->v - hit->u;
isect->v = hit->u;
}
}
ccl_device_inline void kernel_embree_convert_sss_hit(
KernelGlobals kg, const RTCRay *ray, const RTCHit *hit, Intersection *isect, int object)
{
isect->u = 1.0f - hit->v - hit->u;
isect->v = hit->u;
isect->t = ray->tfar;
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
rtcGetGeometry(kernel_data.bvh.scene, object * 2));
isect->prim = hit->primID +
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
isect->object = object;
isect->type = kernel_data_fetch(objects, object).primitive_type;
}
CCL_NAMESPACE_END

Some files were not shown because too many files have changed in this diff Show More