1
1

Compare commits

...

1416 Commits

Author SHA1 Message Date
8aa3b1c2be Improve performance. 2022-10-14 21:26:14 +02:00
61e7026e27 Added method to link multiple objects to a
collection. Refactored the findptr method to
use a gset to check whether the object is already
in the collection.
2022-10-14 11:07:57 +02:00
057e99d6df Cycles: use one instance of oneAPI gpu compiler by default
This change removes CMake code for automatic calculation of the number
of offline device compiler instances, to hand over control to developers
instead as it incurs a rather large memory usage with around 8GB per
instance at peak.
Use SYCL_OFFLINE_COMPILER_PARALLEL_JOBS CMake variable to configure it.
2022-10-13 10:49:30 +02:00
Werner, Stefan
c32a455605 Cleanup: Fixed some warnings
Some unused parameters were left after changing the oneAPI device code
to be a direclty linked shared library.
2022-10-13 09:45:53 +02:00
fabf4ee33d Fix T100699: Older preferences from 2.93 wont load
Even though this was intentionally removed in [0], loading data from
older startup files is supported. So show them when available.

[0]: 45439dfe4c
2022-10-13 17:36:30 +11:00
c67e5628d2 Cleanup: Use std::mutex for mesh runtime mutexes
Instead of allocating three separate ThreadMutex pointers,
just embed std::mutex into the struct directly.
2022-10-12 22:31:50 -05:00
375dafe3ef Build: use bash for build environment script
- Prefer bash over sh to so it's unambiguous which features can be used.
- Use array syntax to specify main package list, allowing to comment
  why packages are required and making git-blame easier to track down
  commits that add/remove packages.
- Add license header.
2022-10-13 13:20:58 +11:00
c34c6d3e25 Mesh: Move runtime data out of DNA
This commit replaces the `Mesh_Runtime` struct embedded in `Mesh`
with `blender::bke::MeshRuntime`. This has quite a few benefits:
- It's possible to use C++ types like `std::mutex`, `Array`,
  `BitVector`, etc. more easily
- Meshes saved in files are slightly smaller
- Copying and writing meshes is a bit more obvious without
  clearing of runtime data, etc.

The first is by far the most important. It will allows us to avoid a
bunch of manual memory management boilerplate that is error-prone and
annoying. It should also simplify future CoW improvements for runtime
data.

This patch doesn't change anything besides changing `mesh.runtime.data`
to `mesh.runtime->data`. The cleanups above will happen separately.

Differential Revision: https://developer.blender.org/D16180
2022-10-12 20:55:57 -05:00
b3e6a2888a Point Cloud: Support applying modifiers
The geometry nodes modifier can now be applied on point cloud objects.
This is basically a copy of the logic from 96bdd65e74
and 538da79c6d.
2022-10-12 19:16:37 -05:00
99f88281df Fix T101776: wrong logic for GLX setSwapInterval
Regression in 93e4b15767.
2022-10-13 10:27:22 +11:00
3980af7453 Fix T101779: Incorrect app_id on Wayland
Using the title as the app_id prevented the proper icon being used
under KDE-Plasma.
2022-10-13 10:10:26 +11:00
a481eb5576 Cleanup: Use correct blenkernel namespace for mesh functions 2022-10-12 17:41:35 -05:00
6c4210b97b Draw: Add missing TBB define to draw module
Allows improving performance with BLI_task.hh in draw extraction code.
Threading added in c15a63d21e improved performance by 3-4x
for me, but didn't make a difference until now.
2022-10-12 16:51:29 -05:00
7f921032c2 Cleanup: Remove deprecated socket variables
Last used in 62421470ee.
2022-10-12 16:10:06 -05:00
bcc56253e2 Fix T95683: FFmpeg seeking is broken
According to information I gathered, ffmpeg seeks internally using DTS
values instead of PTS. In some files DTS and PTS values are offset and
ffmpeg fails to seek correctly to keyframe located before requested PTS.

This issue become evident after hardcoded preseek of 25 frames was
removed and effort went into more precise seeking to improve
performance. It was thought, that this is bug in ffmpeg code, but
after reading some discussions, I don't think it is considered as such
by their developers, see below:
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-March/226354.html
https://trac.ffmpeg.org/ticket/1189

Best solution seems to be to add small preseek value possibly at
detriment of performance, so 3 frames of preseek are applied. Number 3
was chosen experimentally.

Performance impact seems to be insignificant with this change.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D15847
2022-10-12 20:10:15 +02:00
a1bc05b200 Nodes: Add "Legacy" to legacy node UI names, skip in search
Currently there is no way to tell that these node types are deprecated
in the UI. This commit adds "(Legacy)" to the end of the names.
It also makes it simple to skip these in the various node searches
more automatically than before.

Fixes T101700

Differential Revision: https://developer.blender.org/D16223
2022-10-12 12:31:38 -05:00
0d25169dc5 Fix T101711: Curve to points node sometimes skips initializing radius
Don't add the radius attribute to point clouds by default, since not
having a radius attribute should be a valid state. The radius is only
set when a radius attribute also exists on curves.
2022-10-12 12:29:25 -05:00
a6db2c22b1 Cycles: Use 0.01m as default point cloud radius
Currently Cycles uses zero as a default radius when no "radius"
attribute exists. This is more confusing than helpful. Instead,
use the same default radius as EEVEE and Workbench.
2022-10-12 12:23:23 -05:00
605f87256e Cleanup: Decrease variable scope in UI region popup code 2022-10-12 12:19:28 -05:00
ba67a383fa Cycles: Enable MNEE on Metal (macOS >= 13)
This patch enables MNEE on macOS >= 13. There was an inefficiency in the calculation of spill requirements, fixed as of macOS 13. This patch also adds a temporary inlining workaround for a Metal compiler bug which causes `mnee_compute_constraint_derivatives` to behave incorrectly.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16235
2022-10-12 17:06:50 +01:00
d586f8962d Cleanup: EEVEE-Next: Add precision to comment 2022-10-12 17:39:23 +02:00
0610fc38b9 DRW: View: Expose matrices through interface 2022-10-12 17:39:23 +02:00
7a9a83f4a0 DRW: Wrappers: Add TextureRef to wrap around GPUTexture pointers
This adds the possibility to use the C++ API for other GPUTexture.
2022-10-12 17:39:23 +02:00
b249b3658c DRW: Fix gl error related to incorrect uniform size 2022-10-12 17:39:23 +02:00
4552924dcc Cleanup: DRW: Improve state_stencil documentation 2022-10-12 17:39:23 +02:00
aa5ce2fcc1 Cleanup: Use const vertex pointer argument 2022-10-12 10:08:10 -05:00
e38377d690 Cleanup: Reduce variable scope in vertex group mirror operator
Combined with the previous cleanup, this would have prevented T101773.
2022-10-12 10:04:54 -05:00
7e4786503c Cleanup: Remove macro usage in vertex group mirror operator
Avoiding a few lines of duplication is not worth the
confusion and worse debugging experience of macros.
2022-10-12 09:52:06 -05:00
a35d5378ad Fix T101773: Mirror Vertex Weights operator broken 2022-10-12 09:48:07 -05:00
a379fce14b Fix T101679: Duplicate objects are created when 'Make' override is called on existing override in 3DView
When the active selected object in the 3DView is already a local
liboverride, only perform the 'clear system flag' process on selected
objects, there is no point in trying to create an override out of it.
2022-10-12 11:45:25 +02:00
872a45f42b ImageEngine: Clamp image data to fit half float range.
When image data exceeds half float ranges values are set to +/-
infinity that could lead to artifacts later on in the pipeline.
Color management for example.

This patch adds a utility function `IMB_gpu_clamp_half_float`
that clamps full float values to fit within the range of
half floats.

This fixes T98575 and T101601.
2022-10-12 08:56:14 +02:00
78634b1fd1 Cleanup: minor edits to recent wayland/libdecor
Remove asserts committed by accident & simplify preprocessor checks.
2022-10-12 17:23:51 +11:00
f0e1089a33 GHOST/Wayland: only require libdecor when running in gnome-shell
- Support switching between libdecor and xdg_shell at run-time.

- Require libdecor when using gnome-shell, otherwise use xdg_shell.

- Gnome-shell detection checks for a gtk_shell* interface which
  isn't ideal however it's not possible to check server-side-decorations
  are supported without first creating a window.

- Unload Wayland libraries when Wayland fails to load.
2022-10-12 17:01:52 +11:00
0f60872461 Cleanup: Simplify node insert after drag code
- Give functions and variables more descriptive names
- Use references for arguments
- Use tree topology cache to avoid iterating over all links
- Group related code together
2022-10-11 20:33:31 -05:00
b9e4d930b3 Cleanup: use 'u' prefixed unsigned types 2022-10-12 10:39:12 +11:00
3f64b88684 Cleanup: use function style casts for C++, format & spelling 2022-10-12 10:39:12 +11:00
984b279ef1 Cleanup: use commented arguments for unused args in C++ 2022-10-12 10:39:12 +11:00
89bd261d9e Cleanup: Convert two nodes files to C++ 2022-10-11 18:17:37 -05:00
a80b1adc10 Cleanup: Comment formatting in BMesh operator 2022-10-11 18:17:37 -05:00
f5e6d4e4b0 Cleanup: Remove link drag search operations for socket templates
Besides texture nodes, which aren't supported anyway, we don't have any
builtin nodes that still use the socket template system, so this can be
removed.
2022-10-11 18:17:37 -05:00
37d83f0095 Cleanup: Reduce indentation in node attach operator 2022-10-11 18:17:37 -05:00
b7decab07e UV: add grid shape source to the uv editor, and add new "pixel" option
This change is part of a wider set of changes to implement Grid and Pixel
snapping in the UV Editor. This particular change adds a new third option,
`pixel grid`, to the previous grid options, `dynamic grid` and `fixed grid`.

Maniphest Tasks : T78391

Differential Revision: https://developer.blender.org/D16197
2022-10-12 11:27:41 +13:00
c2256bf7f7 Fix T90782: add uv pack option to specify margin as a fraction
A refactor of the margin calculation of UV packing, in anticipation
of multiple packing methods soon becoming available.

Three margin scaling methods are now available:

* "Add", Simple method, just add the margin. [0]
    (The default margin scale from Blender 2.8 and earlier.)
* "Scaled", Use scale of existing UVs to multiply margin.
    (The default from Blender 3.3+)
* "Fraction", a new (slow) method to precisely specify
    a fraction of the UV unit square for margin. [1]

The "fraction" code path implements a novel combined search / secant
root finding method which exploits domain knowledge to accelerate
convergence while remaining robust against bad input.

[0]: Resolves T85978
[1]: Resolves T90782

Differential Revision: https://developer.blender.org/D16121
2022-10-12 11:05:34 +13:00
a376c4c3c3 Nodes: Change Mix node link drag weighting
This lowers the search weight for color-specific
mix functions on non-color sockets.

Reported in blender.chat by simonthommes

Differential Revision: https://developer.blender.org/D16228
2022-10-11 22:59:22 +01:00
7636fc06ea Cleanup: Move draw_cache_impl_volume.c to C++ 2022-10-11 13:01:13 -05:00
48fd4a01ef Sculpt: Fix mask from cavity not redrawing viewport with modifiers 2022-10-11 10:11:16 -07:00
7119582b66 Sculpt: Fix T101595: sculpt_attribute_update_refs called in wrong place
Needs to go after the assignment to ob->sculpt->pbvh, not before.
2022-10-11 09:58:43 -07:00
188786f0b0 Sculpt: Fix T101718: Automasking crash with new texture paint
* 'Original coordinates' mode can't be used in image paint mode
(it does nothing in this case anyway).
* SCULPT_automasking_factor_get now returns 1.0 if
  a PBVH_REF_NONE vertex reference is passed in.
2022-10-11 09:58:41 -07:00
65b42d8c57 Fix T101709: Proportional editing being disabled in NLA Editor redo panel
Do not save the "use_proportional_edit" property if it is not supported.
This prevents it from being automatically disabled.

And hide "use_proportional_edit" in `SPACE_NLA`
2022-10-11 12:47:50 -03:00
4fc4005f6b deps_builder: add missing openpgl config file
harvesting openpgl_Exports-debug.cmake was missing for
windows in the build script, and we manually added it
to svn when openpgl landed when we realized it was
missing.

This fixes the issue at the root of the problem, so
the file will not be missing for future updates.
2022-10-11 09:14:10 -06:00
Alaska
0048820df8 Fix T101601: Compositor/Set cryptomatte alpha to 1.
Cryptomatte uses alpha node, which was altered to by default
apply the alpha. This patch changes it back to replacing the
alpha.

Reviewed By: jbakker

Maniphest Tasks: T101601

Differential Revision: https://developer.blender.org/D16165
2022-10-11 16:59:37 +02:00
009acfa477 Cleanup: Add missing include for parallel reduction
The parallel reduction file didn't include its own header, which can
yield "no previous declaration" warnings. This patch includes the header
to fix the warning.
2022-10-11 16:22:14 +02:00
37461b8bdd Cleanup: Remove unused spreadsheet geometry cache item 2022-10-11 08:52:18 -05:00
be44fd9401 Fix SVG tests: Add missing file 2022-10-11 15:13:30 +02:00
223ba59cb0 Beginning of automated SVG regression test
This commit contains the CTest integration.

Starting with the very simple tests for the recent fixes in the
io_corve_svg addon which were related on closing path.

The idea is to use same framework as what we use for render tests
to make it easily visible what aspect of SVG changed or broke.

In order to achieve this both .blend and .svg files are used.
The .svg file defines the exact subject of test, and the .blend
file defines camera, and possibly material.

The longer term idea is to have a number of atomic tests for a
specific SVG features to help isolating problematic areas, as
well as a more comprehensive tests to perform QA.
2022-10-11 15:03:09 +02:00
c425599216 Fix linker order of X11 and Wayland libs
For some compiler and linker configurations, linking would fail as the
wayland libs were linked at a high level and not at the actual code
where they were needed.

After talking to Campbell, we decided to clean up this part and now
only link both the X11 and Wayland libs where they are used.
2022-10-11 14:52:35 +02:00
50943f5dc7 Realtime Compositor: Implement variable size bokeh blur
This patch implements the variable size blur option in the Bokeh Blur
node. The implementation is different from the CPU one in that it also
takes the Bounding Box input into account, which is ignored for some
reason for the CPU. Additionally, this implementation does not do the
optimization where the search radius is limited relative to the maximum
value in the size texture. That's because the cost of computing the
maximum is not worth it for most use cases.

The reference implementation does three unexpected things that are
replicated here nonetheless. First, the center bokeh weight is always
ignored and assumed to be 1. Second the size of the center pixel is
taken into account. Third, a unidimensional distance is used instead of
a 2D euclidean one. Those need to be considered independently.

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

Reviewed By: Clement Foucault
2022-10-11 13:40:48 +02:00
0037411f55 Realtime Compositor: Implement parallel reduction
This patch implements generic parallel reduction for the realtime
compositor and implements the Levels operation as an example. This patch
also introduces the notion of a "Compositor Algorithm", which is a
reusable operation that can be used to construct other operations.

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

Reviewed By: Clement Foucault
2022-10-11 13:22:52 +02:00
f6a6992031 GPencil: Fix unreported Close Stroke operator did not select new points
When use the close stroke, the new created points were not addedd to the
selection.
2022-10-11 12:04:16 +02:00
Pratik Borhade
9a6dc39d4b Sculpt: Fix T101694: Change operator for unhide face sets
In 22c3db72ca `SHOW_ALL` has been removed from
`face_set_change_visibility`. Instead `SCULPT_OT_reveal_all` is now used
for unhiding all face sets.

Reviewed By: Joseph Eagar & Julian Kaspar
Differential Revision: https://developer.blender.org/D16199
Ref D16199
2022-10-11 02:49:45 -07:00
be27159527 Cleanup: rename base_index to ob_index in knife logic
This indexes the "objects" array, so rename 'b' and 'base_index'
to 'ob_index'.
2022-10-11 20:30:31 +11:00
2590626e77 Fix T101741: GPencil Outline modifier removes unexpectedly strokes
The stroke could be tagged before modifier and was removed due  the tag.

Now, the tag is reset before to avoid this problem.
2022-10-11 11:20:48 +02:00
2bacf1cb26 Fix T101721: Knife project crashes
The crash was caused by [0] however knife-project functionality has been
incorrect since [1] which would loop over each edit-mode object and run
the knife project function which operated on all edit-mode objects too.

- Resolve the crash by postponing face-tessellation recalculation
  until the knife tool has cut all objects

- Objects occluding each other is now supported
  (an old TODO and something that was never supported).

[0]: 690ecaae20
[1]: 6e77afe6ec
2022-10-11 20:19:13 +11:00
70ef334f08 GHOST/Wayland: correct the library path for libwayland-egl
Systems without `libwayland-egl.so` (Fedora 37 beta) failed to start,
as the name `libwayland-egl.so.0` wasn't correct.
2022-10-11 17:08:18 +11:00
9cd99684b0 Py Docs: Update to sphinx 5.2.3
Notable change is the improvements made to search.
2022-10-10 23:17:23 -04:00
b51d337adc GHOST/Wayland: print all dynamic loading failure when using Wayland
Previously only failure to dynamically load libdecor would report a
warning. Now report failure to load all Wayland libraries.

This was done because Wayland libraries (besides libdecor) are likely to
be installed on systems running Wayland. However it makes it difficult
to troubleshoot failure to load Wayland on systems with libdecor.

Only silence Wayland dynamic loading warnings when Wayland isn't running.
2022-10-11 11:14:40 +11:00
f495939e6e Correct argument type for BKE_pbvh_node_get_bm_orco_data, format 2022-10-11 11:06:32 +11:00
7f133b7a38 Sculpt: Clean up Dyntopo's original triangle api
Cleaned up Dyntopo original triangle API (which is deprecated):

* BMVerts for original triangles are now stored.
* BKE_pbvh_bmesh_update_topology now handles original triangle
* data properly.
* BKE_pbvh_bmesh_node_save_orig can now initialize the original
  coordinates from the current BMLogEntry.
* Ray casting of original data now returns active vertex.
  Should fix various random crashes.

Hopefully this will fix a number of bugs.
2022-10-10 14:45:48 -07:00
dc1418e5d9 Sculpt: Fix T101674: Passing null to GPU_batch_elembuf_set 2022-10-10 14:08:02 -07:00
da25006bc4 Sculpt: T101699: Face set change visibility crashes on no face sets
Cleaned up sculpt_face_sets_change_visibility_exec some more:

* SCULPT_UNDO_HIDDEN is now pushed instead of SCULPT_UNDO_FACE_SETS
  (since face sets no longer encode visibility).
* Added branches for if face sets do not exist.
* Cleaned up independent if statements into a switch.
2022-10-10 13:34:37 -07:00
473df37134 Sculpt: Fix T101729: Automasking crash in elastic deform brush
Was missing a call to SCULPT_automasking_node_update.
2022-10-10 13:05:43 -07:00
9b8be81eef deps_builder: Add support for cve-bin-tool
This change adds support for intels cve-bin-tool [1]
in the deps builder. This adds 2 new targets to the
builder that do not build automatically but can be
build on demand when required.

`make cve_check` will output to the console.
`make cve_check_html` will output a html file that
can be shared with other people.

Requirements:

- A working installation of cve-bin-tool on the system

Not required but higly recommended:

- Obtaining a key from the nvd [2] to speed up the
  database download. you can pass the key to cmake
  using `-DCVE_CHECK_NVD_KEY=your_api_key`

[1] https://github.com/intel/cve-bin-tool
[2] https://nvd.nist.gov/developers/request-an-api-key

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16160
2022-10-10 11:48:05 -06:00
03fd2f7a5a Fix building WITH_HEADLESS
An earlier commit removed the '#ifdef' check for the function call but not for
the function declaration.
2022-10-10 18:16:29 +02:00
9a8746dff1 Cleanup: clang-format 2022-10-10 17:57:25 +02:00
95aac5df73 Fix T101651: Cycles crashes when failing to initialize render device
The issue here was that PathTraceWork was set up before checking if
any error occurred, and it didn't account for the dummy device so
it called a non-implemented function.

This fix therefore avoids creating PathTraceWork for dummy devices
and checks for device creation errors earlier in the process.
2022-10-10 17:55:08 +02:00
Damien Picard
7d7318f6c5 I18n: disambiguate message "World"
The confusion is about World as an ID type, and the World coordinates.

Use no context for the latter, and either `BLT_I18NCONTEXT_ID_WORLD`,
or other more fine-grained contexts when needed as part of enums for the
former.

The message from the custom HDRI installation operator cannot be
disambiguated right now, because Python enums don't support contexts.

Ref T43295

Reviewed By: mont29

Maniphest Tasks: T43295

Differential Revision: https://developer.blender.org/D16194
2022-10-10 17:37:32 +02:00
Thibault de Villèle
962b647690 Cleanup: NLA transforms, simplify recalcData_nla()
Refactor the `recalcData_nla()` function, which takes data from the
transform system and updates NLA strips, such that the actual logic to
change the strip is moved into its own function.

This also moves some generic code (find prev/next strip) from that
function to BKE.

This is to make the code easier to adjust when different transform
operations need to perform different modifications of the strip (i.e. to
fix T101130).

Manifest Task: T101130

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16181
2022-10-10 17:28:35 +02:00
82a5790d2a Cycles: oneAPI: Trigger compilation of used kernels only
JIT compilation of oneAPI kernels now happens during load stage
and proper message gets shown in the GUI during compilation.
Also, this implementation skips kernels that aren't needed for
the used scene, reducing overall (re)compilation time.
2022-10-10 16:38:11 +02:00
bb8dba8609 Fix missing view layer update when iterating a collection from Python.
The previous fix ignored the most fundamental access operation.

Follow up to 4a60c4746d fixing 68589a31eb.
2022-10-10 17:13:06 +03:00
Charlie Jolly
f5e1a2119d Node: Add blend modes to Mix node link drag search
Allows searching for Mix blend modes
e.g. Overlay when using link drag search

Requested by @simonthommes in GN chat

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D16209
2022-10-10 14:36:44 +01:00
25b745ae85 IO: support Presets in Alembic, Collada, OBJ, STL, USD importers
The exporters already had Preset functionality, but the importers
did not.
2022-10-10 16:01:18 +03:00
499af28a35 IO: remove BKE_layer_collection_resync_forbid & allow
Part of T101073: after the view layer sync was made lazy (D15885), the
BKE_layer_collection_resync_forbid and BKE_layer_collection_resync_allow
in Alembic/USD/OBJ importers is no longer needed, as long as they do
view layer dependent operations (selecting new objects) in a separate
loop after creating all the objects.

Verified that this does not regress import times for 26k objects OBJ
scene (Blender 3.0 splash) and 250k objects USD scene (Moana).
2022-10-10 14:06:54 +03:00
Damien Picard
b099cf73ae I18n: disambiguate or extract a few messages
Disambiguate:
- "Active Only" (GPencil copy material and layer, add NLA modifier)
- "Clip" (movie clip, image extension mode)
- "Emission" (particles)
- "New" (scene)
- "Tracking" (movie clip)

Extract:
- "ViewLayer", the default view layer name when creating new scene

Ref T43295

Reviewed By: mont29

Maniphest Tasks: T43295

Differential Revision: https://developer.blender.org/D16196
2022-10-10 13:03:26 +02:00
Damien Picard
9b2d682394 I18n: fix popup menus context
When calling `wm.call_menu_pie` and `wm.call_menu`, the menu context
was ignored when showing its name in the header or pie menu center.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D16195
2022-10-10 13:01:18 +02:00
9df9397ae8 EEVEE-Next: Fix surface deferred shader compilation in debug mode 2022-10-10 11:09:29 +02:00
f77eadc203 GHOST/Wayland: warn when falling back to X11 because of missing libdecor
X11 is used as a fallback when libdecor isn't found on the users system.

Now print a warning when Blender falls back to X11 and a missing
libdecor is the only reason wayland could not be used.

Only print this warning when using Wayland so this warning doesn't show
on X11 systems which have Wayland libraries installed.

Addresses T101715.
2022-10-10 19:50:33 +11:00
d855f5fdcd Fix typos & co in UI messages. 2022-10-10 10:36:15 +02:00
42b1a7d4c6 OBJ: add global scale factor import setting
Requested in D16095 proposal - also USD & Alembic have import scale
option; OBJ has an export scale object but the import scale
was not there for some reason.
2022-10-10 10:10:46 +03:00
a24f11e0ec UI: show the windowing environment in the "About" splash
Show the windowing environment on non MS-Windows/Apple systems,
since X11/WAYLAND are selected startup there was no convenient way
for users to know which back-end was being used.

Include the windowing environment in the About splash & system-info.txt
since it will be useful for handling bug reports.

This commit adds a private API call not intended for general use
as I would like to be able to remove this later and it's only needed
in the specific case of testing if Blender is using WAYLAND or X11
(which maybe be used via XWayland).

Python scripts can already inspect the system to check which windowing
environment used, the API call is mainly useful for troubleshooting.
2022-10-10 11:22:41 +11:00
210f4db81c Cleanup: spelling in comments 2022-10-10 11:22:41 +11:00
e0ad4712f6 Cleanup: quiet warnings, format 2022-10-10 11:22:41 +11:00
aaa731a782 Partially fix T101702: OSL Shaders with boolean inputs crash
OSL (like Cycles) has no internal boolean type, instead an integer
input can be flagged to be shown as a boolean in the UI.
Cycles reacts to this by creating a boolean socket on the Blender
side, but as a result incorrectly called the boolean overload of the
set function even though the internal type is an integer.

There's another unrelated crash in the GPU viewport shader code that
appears to apply to every OSL node that outputs a shader, and the file
in T101702 triggers both, so this is only a partial fix for the report.
2022-10-10 01:03:12 +02:00
bd2f002e71 Fix T101685: OBJ importer does not assign proper material if "usemtl" is before "o"
The importer logic was wrongly resetting "current material name"
upon encountering a new object ("o" command). However as per OBJ
specification, this is incorrect:

> Specifies the material name for the element following it. Once a
> material is assigned, it cannot be turned off; it can only be
> changed.

Fixes T101685. Test coverage for this was added in svn tests repo.
2022-10-09 21:21:31 +03:00
c2fb85282d OBJ: extend importer tests to test imported material expectations
Previously "which material got assigned to an object in the end"
was not covered by tests. This is preparation for fixing T101685.
2022-10-09 20:52:23 +03:00
af34c13da4 Cleanup: Remove data duplication from large array in eevee_camera.hh
Use `inline constexpr` instead of `static const` to prevent these
variables from being duplicated in each translation unit that includes
the eevee_camera.hh header (was included into 17 different object files
with MSVC).

Differential Revision: https://developer.blender.org/D16200
2022-10-09 00:34:59 -07:00
cee6c07f9e Set operator poll message when vertex group is locked
Differential Revision: https://developer.blender.org/D16190
2022-10-08 11:43:38 -07:00
f61ff22967 Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.

Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.

Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.

In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.

The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.

Differential Revision: https://developer.blender.org/D15941
2022-10-08 16:43:18 +03:00
a716e69658 Cleanup: Use helper function for previous mesh loop 2022-10-07 22:46:52 -05:00
577a79b485 Cleanup: Fix outdated mesh data comments 2022-10-07 22:46:52 -05:00
f9ab2214ae Linux: enable WAYLAND by default
Enable the following CMake options:

- WITH_GHOST_WAYLAND
  Enable Wayland which is now included as part the bundled dependencies.
  When the pre-compiled libraries aren't used, only X11 will be enabled.

- WITH_GHOST_WAYLAND_DYNLOAD
  So systems without libwayland can fall back to X11.

- WITH_GHOST_WAYLAND_LIBDECOR
  To draw window frames on WAYLAND compositors such as gnome-shell which
  expect client-side decorations (without this the Blender window is
  borderless).

  Unfortunately there doesn't seem to be a reliable way to know if the
  compositors handles server-side decorations, so libdecor is required
  for Wayland to be used even with KDE and tiling compositors where it's
  not needed. Although this is an area that could use some further
  investigation - possibly bundling libdecor or handling client-side
  decorations in Blender.

The final part of D16091.
2022-10-08 13:26:33 +11:00
18c045a35f Build: show X11 & Wayland options on first run 2022-10-08 13:16:11 +11:00
Iliya Katueshenock
3d209d1619 Mesh: Multithread some boolean domain interpolation logic
This can improve performance by 3-10x in some simple test cases,
when reading a boolean attribute on a different domain from the
one it's stored on.

Differential Revision: https://developer.blender.org/D16054
2022-10-07 17:54:24 -05:00
af288a09a5 Viewport: Enable draw_debug.cc code when WITH_DRAW_DEBUG is on 2022-10-07 15:40:41 -07:00
Laurynas Duburas
f3f0ea8dc2 Curve: Retain active NURBS curve after point deletion
Before, the active spline index and the active point index were always
cleared. Now the active index is only cleared when the curve/surface is
deleted. This was accomplished by making the surface patch delete
function handle that correctly. The spline deletion already handled it.

This fixes only vertex deletion mode.
Fixes problem mentioned in T101160.

Differential Revision: https://developer.blender.org/D16133
2022-10-07 16:33:50 -05:00
d779792977 Build: reference bundled wayland and libdecor headers
When using pre-compiled libs, reference the bundled wayland headers,
needed so the headers from the bundled wayland-scanner are compatible.

Part of D16091.
2022-10-08 08:00:17 +11:00
66f184d981 Deps: add libdecor for Wayland window frames
Include libdecor, note that this only bundles a header file
as Blender dynamically loads on the system at run-time.

Part of D16091.
2022-10-08 08:00:08 +11:00
b083755c20 Deps: harvest Wayland headers, build Wayland libraries
The headers on centOS7 (Wayland 1.15) aren't compatible with the headers
generated by wayland-scanner 1.20.

Include the headers to support building Wayland on systems with
older Wayland installed.

Using these headers will be part of a separate commit.

Part of D16091.
2022-10-08 08:00:04 +11:00
f63179cc9f Fix T101424: Empty group node added to node add search
The group node type polls true, but adding an empty group node isn't
useful, so just skip it.
2022-10-07 12:32:23 -05:00
Nate Rupsis
f96b729d7b FIX T101275: Regression in NLA causes Actions to be ignored by Context menu (I.e influence, etc)
Reviewed By: sybren

Differential Revision: http://developer.blender.org/D16154
2022-10-07 11:03:24 -05:00
9cf2b413c2 Fix small errors in tool tips for path guiding
Contributed by Alaska.

Differential Revision: https://developer.blender.org/D16166
2022-10-07 17:59:22 +02:00
349091ce00 Cleanup: Move editmesh_undo.c to C++
To allow moving mesh runtime data to C++ (D16180).
2022-10-07 10:41:19 -05:00
1a5c57cdec Fix: One-API build issue on windows.
Flags were not properly passed to the
compiler.
2022-10-07 09:16:29 -06:00
bf85074148 GPencil: New Fill Extend lines adjust with MMB
The actual length of extension lines can be adjusted using wheel mouse 
but this is very inconvenient for tablet users.

Now, the extension can be adjusted using MMB of the pen.

There was a similar request in Right-Click Select

Reviewed By: Matias Mendiola, Daniel Martinez Lara

Differential Revision: https://developer.blender.org/D16128
2022-10-07 16:18:56 +02:00
3714d3c3ce Cycles: link oneAPI backend with debug version of sycl when in Debug
It fixes SYCL runtime issues in Debug builds that were due to mixing
Release and Debug MSVC runtimes.
This commit also removes specific handling of dpcpp compiler executable
to simplify the CMake implementation. Using it like clang++ works and
clang++ executable is also available from Intel oneAPI DPC++ compiler in
case it doesn't.
2022-10-07 16:14:50 +02:00
331f850056 Cleanup: redundant parenthesis 2022-10-07 22:55:03 +11:00
11abeae99f Cleanup: use function style casts for C++ 2022-10-07 22:55:03 +11:00
9dec9eee0d Cleanup: DRW: Rename ViewInfos to ViewMatrices
This makes sense now that the struct only contains matrices.
2022-10-07 13:15:22 +02:00
bae22ac7b4 DRW: Remove mouse_pixel and is_inverted from ViewInfos
This is part of the effor to simplify the View struct in order to implement
multiview rendering.

`mouse_pixel` is only use for debug purpose and will be reintroduced later.
`is_inverted` is moved to `draw::View`.
2022-10-07 13:13:23 +02:00
6fd557e2c2 DRW: Remove viewport_size from DRWView
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
f8384485fc EEVEE-Next: Use global viewport size instead of DRWView one
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
7b9ce3af98 GPencil: Use global viewport size instead of DRWView one
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
f11b3ed9b0 Basic: Use global viewport size instead of DRWView one
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
70b35c7ad0 Overlay: Use global viewport size instead of DRWView one
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
126d485b83 DRW: Remove screen_vecs
These were only a normalized copy of the XY axes of the inverse viewmat.
But since the viewmatrix is always normalized we can use it directly.
2022-10-07 12:43:10 +02:00
a945cf4d0f DRW: Move clipping planes to their own UBO
This is part of the effor to simplify the View struct in order to implement
multiview rendering.
2022-10-07 12:43:10 +02:00
223f970407 EEVEE: Move reflection clip plane to local storage
This avoid dependency with the draw view.
2022-10-07 12:43:09 +02:00
a775e42dee DRW: Use view_clipping_distances instead of world_clip_planes_set_clip_distance
No functional change. `view_clipping_distances` is prefered as it is
auto masked.
2022-10-07 12:43:09 +02:00
8f96d0f732 DRW: Remove view vectors
This is part of the effor to simplify the View struct in order to implement
multiview rendering.

The viewvecs can easilly be replace by projection matrix operation.
Even if slightly more complex, there is no performance impact.
2022-10-07 12:43:09 +02:00
03a7f1d7b1 DRW: Move CameraTexCoFactors to engine specific storage
This is part of the effor to simplify the View struct in order to implement
multiview rendering.

The CameraTexCoFactors being only valid for a single view, and being only
used in very few places, it make sense to move it to the engine side.
2022-10-07 12:43:09 +02:00
055680a89e DRW: Split ViewCullingData out of ViewInfos
This is in order to reduce the size of ViewInfos and support multi view
rendering.
2022-10-07 12:43:09 +02:00
f43c2d9abe Armature Modifier: skip non-deforming vertices in Multi-Modifier mode.
The modifier already contained a check to skip complex processing of
vertices that won't produce any deformation due to the vertex group
mask, but this only works for the non-Multi Modifier case. This adds
a similar check for the Multi Modifier mode.

Differential Revision: https://developer.blender.org/D16152
2022-10-07 13:11:44 +03:00
f7a781d45f Fix T101547: Add update notifiers in dopesheet and timeline selection operators
Updates the function checking if a container can have grease pencil layer keyframes, to account for dopesheet in main mode, and timeline.

Reviewed By: Sybren A. Stüvel

Differential Revision: http://developer.blender.org/D16132
2022-10-07 11:44:27 +02:00
87ef423e6e Fix missing header include when using timeit feature. 2022-10-07 11:32:13 +02:00
412d670e9c Refactor: adding function to check if an animation container has grease pencil layer keyframes.
Used in action_select to refactor the selection operators.

No functional changes.

Reviewed By: Sybren A. Stüvel

Differential Revision: http://developer.blender.org/D16168
2022-10-07 11:07:02 +02:00
7eeeaec6da Cycles: use direct linking for oneAPI backend
This is a minimal set of changes, allowing a lot of cleanup that can
happen afterward as it allows sycl method and objects to be used outside
of kernel.cpp.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D15397
2022-10-07 09:50:05 +02:00
fc0b1627eb Fix T100953: Zooming with NDOF is inverted in the camera view
Use convention for applying zoom in other 2D views.
2022-10-07 17:46:25 +11:00
3522c6e59c Cleanup: replace static variables with arguments
Functions in vfontdata_freetype.c used static variables instead of
argument parsing. This originates from initial freetype support [0].

This didn't cause problems as callers use a global lock, however it
makes the code more difficult to follow means we can more easily remove
the lock in the future.

[0]: d4f9678b39
2022-10-07 16:44:13 +11:00
0d16625d35 Cleanup: use doxy sections
Also use doxy syntax for some comments.
2022-10-07 16:05:39 +11:00
650beef4b6 GHOST/Wayland: silence warnings for modifier key handling in GNOME
GNOME (mutter) intentionally doesn't follow the Wayland spec for the
keyboard_enter events (held keys are always an empty array).

This means we can't know which keys are held on window activation,
making the result of getModifierKeys invalid (in that we don't know
which modifiers are held).

Detect this situation and suppress warnings as the issue has been
reported and it doesn't help for users to see noisy warnings for
a known problem.
2022-10-07 15:53:47 +11:00
a0af1e3971 GHOST/Wayland: improve logging messages for keyboard events 2022-10-07 15:53:46 +11:00
cafd204af6 Cleanup: remove redundant 'using'
clang-tidy converts C-style typedefs to this style,
but the "using ..." isn't needed.
2022-10-07 14:36:35 +11:00
47d3e76567 3D View: depth sort candidates in the selection menu
Objects/bones in the selection menu weren't ordered usefully,
worse, the closest items could be left out of the menu since items
would stop being added once the menu-size limit was reached.

Resolve this by sorting the menu items by depth, removing the most
distant when the number of items exceeds the limit.

When Ctrl is held, order by the distance to the object center
instead of depth.
2022-10-07 13:26:43 +11:00
3b77d60b6c Cleanup: share factory reset properties 2022-10-07 13:19:13 +11:00
db2b889618 Cleanup: quiet compiler shadowed variable warning 2022-10-07 13:19:12 +11:00
104fd82f74 Fix for T101481: Improved VFont Loading
Remove redundancy in the testing and loading of VFont fonts. Includes
improved setting of character map for using Wingding and Symbol fonts.

See D16174 for more details.

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

Reviewed by Campbell Barton
2022-10-06 18:02:40 -07:00
781d03efe4 Preferences: support loading factory settings only for app-templates
When app-templates are enabled, support resetting defaults only for the
app-templates.

Without this, it's not possible to reset app-template preferences
without also resetting the default preferences for all settings the
app-template does not override (used when there is no application
template loaded, and other app-templates).

These additional menu items are shown in menus when an app-template has
been loaded.

Address issue raised by T96427.

Reviewed By: mont29, brecht

Ref D16150
2022-10-07 10:50:17 +11:00
4eb3e7ff86 Cleanup: compiler warning 2022-10-07 10:42:56 +11:00
ecc404ea1a Cleanup: spelling in comments 2022-10-07 10:42:56 +11:00
b04b87b322 Cleanup: Avoid inconsistent naming in mesh topology API
Mesh corners are called "loops" in the code currently. Avoid diverging
naming and just use that convention in some newly added code.
2022-10-06 17:35:02 -05:00
79b1e267ef Cleanup: Move subdiv_ccg.c to C++
In preparation for moving mesh runtime data to C++
2022-10-06 17:24:16 -05:00
406a98aff8 Cleanup: Move eight modifier files to C++
In preparation for moving mesh runtime data to C++.
2022-10-06 16:08:07 -05:00
53d937a170 Sculpt: Raise pbvh->leaf_limit to 400 for dyntopo
Setting pbvh->leaf_limit (the max triangles per node)
too low results in lots of distinct GPU meshes, which
can be slow for even moderately sized sculpt meshes
(starts to be a problem around 100-150k triangles).
2022-10-06 14:06:16 -07:00
dfa0eb298e Sculpt: Fix T101502: GPU tris miscounted for dyntopo
Dyntopo PBVH draw was miscounting the number of triangles.
2022-10-06 14:04:12 -07:00
eae3fa8730 Cleanup: Move subdiv_modifier.c to C++
In preparation for moving mesh runtime data to a C++ type
2022-10-06 15:48:02 -05:00
d4f77c2266 Cleanup: Move shrinkwrap.c to C++ 2022-10-06 15:48:02 -05:00
f58b524669 Sculpt: Fix bug in sculpt attribute api
SculptAttribute.domain wasn't being set
when creating from an existing CustomData
attribute.
2022-10-06 13:19:35 -07:00
65c8c83679 Fix: Properly free non-trivial node editor runtime type 2022-10-06 15:07:09 -05:00
14de57713d Cleanup: Remove unnecessary MOD_nodes.h includes 2022-10-06 15:07:09 -05:00
0d0e2dc0a8 DRW: fix use of potentially uninitialized variable
Bug introduced in rB6774cae3f25b.

This causes undefined behavior in `DRW_state_draw_support()` making
overlay depth drawing unpredictable.
2022-10-06 16:04:11 -03:00
be8ee05dcb Fix for T53332: BFont 43 Inaccessible Glyphs
Preloading of BFont (default for 3D Text Objects) glyphs will not load
any with a character code greater than 256, resulting in 43 characters
that are inaccessible. This patch corrects that preloading code.

See D16122 for more details

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

Reviewed by Campbell Barton
2022-10-06 10:36:57 -07:00
c592bff047 Animation: Expose "mute" for drivers in their properties UI
In the driver editor and the "edit driver" popover, add a checkbox that
can mute the driver. This is the same functionality as the checkbox in
the driver editor's channel list, but then exposed in a different place
in the UI.

This is for convenience, such that a driver can now be muted by
right-clicking on the driven property, choosing "Edit Driver", then
muting it there. The same checkbox was added to the regular driver
editor's header for consistency.

Reviewed By: Severin

Maniphest Tasks: T101592

Differential Revision: https://developer.blender.org/D16173
2022-10-06 19:07:33 +02:00
46c40d7fa1 Fix: Use after free in geometry node group logger
The name of the node group in the geometry nodes logger is created
in `GeoModifierLog::get_local_tree_logger`, where it references the
compute context. However, the compute context is a local variable
that doesn't live as long as the log. Therefore the log needs to own
the node group name.

Removing the ownership from `NodeGroupComputeContext` may be
possible as well, but seems less obviously correct. This can be a
temporary solution until we can completely avoid storing strings
in the logger (see D15775).

Fixes T101599
2022-10-06 11:58:11 -05:00
26df25caef UI: remove extraneous inversion of "inverted" button state
Fix an issue where a `UI_BTYPE_CHECKBOX_N` button couldn't be toggled.

When toggling the value of a property, the `UI_BTYPE_TOGGLE_N`,
`UI_BTYPE_ICON_TOGGLE_N`, and `UI_BTYPE_CHECKBOX_N` types shouldn't
matter. These determine the inverted display of the value, but toggles
of that value should still happen once.

For these button types, the toggle happened twice, effectively making it
a no-op. The code for individual values is now also consistent with the
code for handling bit-flags.

Actually found & over-the-shoulder-reviewed by @Severin
2022-10-06 18:54:36 +02:00
bd77cdde58 Build Environment: Update Ubuntu instructions to include bison
Ubuntu also requires bison (just like macOS seems to do).
2022-10-06 18:09:29 +02:00
0f224ceedb Cleanup: Move multires.c to C++ 2022-10-06 10:49:24 -05:00
dc93235797 GPencil: Use new icons for Envelope and Outline modifiers
Before both modifiers were using Skin icon.
2022-10-06 17:25:38 +02:00
6942f05848 UI: New modifier Icons Envelope and Outline
Task: T101155

Designed by: Matias Mendiola
Reviewed by : Pablo Vazquez
2022-10-06 17:16:56 +02:00
29e1cd75fa Linux CentOS 7 setup script
Add a script to set up a Linux CentOS 7 machine so that it can be used
to build the precompiled libraries for Linux.

Reviewed By: sergey, brecht

Differential Revision: https://developer.blender.org/D16171
2022-10-06 16:59:07 +02:00
Sebastian Herholz
e1a3348755 Fix T101458: Changing volume density when pg is enabled causes crash
Changing volume parameters during rendering could cause a crash
when guiding was enabled. It was due to an unintialized state paramter
at the beginning of the path tracing process.

In addition guiding is disabled when dealing with almost delta volumes
(i.e., g close to 1.0 or -1.0).
2022-10-06 14:39:51 +02:00
423c1366b0 Fix T101618: Freeze when reloading a library in certain situation
Freeze happened when reloading a library while having an Object property
with a custom getter function defined in Python.

Just piggybacking on rB62eb21e3ce87, this just applies the same fix (use
the BPy_BEGIN/END_ALLOW_THREADS macros) to relading from RNA/py.

All credit goes to @brecht and @mont29.

Maniphest Tasks: T101618

Differential Revision: https://developer.blender.org/D16167
2022-10-06 14:18:02 +02:00
a01ab2b4e0 Fix T101492: UV stitch crash (more than 32 objects selected)
Crash happened when adjusting operator props in Adjust Last Operation
panel.

When there are more than 32 objects selected in muti-object-editmode, we
are running into RNA array limit (`objects_selection_count` is defined as
an RNA array (which can only hold 32 entries, see
`RNA_MAX_ARRAY_LENGTH`), leading to reading random memory errors.

While there might be ways to make this work with more than 32 selected
objects (e.g. by instead using a collection, or investigate supporting
dynamic sized arrays for run-time RNA), this patch only cancels the
operator with a report message (instead of crashing).

Maniphest Tasks: T101492

Differential Revision: https://developer.blender.org/D16115
2022-10-06 14:11:02 +02:00
25533ac22d Fix T101517: GPencil strokes snap to origin in a Scale value is on 0
The problem was the conversion to object space converted the
points to zero.

Now, the new function `zero_axis_bias_m4` is used in order to add
a small bias in the inverse matrix and avoid the zero points.

A known math issue is the stroke can be offsetted if the scale is set to 1 
again. In this case apply the scale to reset to 1.

Differential Revision: https://developer.blender.org/D16162
2022-10-06 13:30:09 +02:00
7163a83450 Fix addons submodule ref
Was downgraded to a version from 2019 by mistake
2022-10-06 12:53:19 +02:00
Damien Picard
8b485e7226 I18n: ignore user-installed add-ons when extracting bl_info
Since add-on info was made translatable in D15747, user-installed
add-ons could also get their info extracted. This led to having
different messages depending on the environment of the Blender doing
the I18n messages update.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15963
2022-10-06 10:28:18 +02:00
247af8cf5b UI Translations: Add context to 'New' menu entries for files.
Aftermath of rBf5d67f3fdf2d and rBa096248d1253, from D16159 (did not
apply direclty).
2022-10-06 10:16:09 +02:00
0484b6bb18 Fix T101591: mathutils.geometry.intersect_line_line 2D vector error
Uninitialized stack memory was used when intersecting 2D vectors.
2022-10-06 17:33:50 +11:00
707c7de21f Fix T101628: Correct frame node intersection in add reroute operator
Fix reroute nodes added via the cut link gesture being parented to the
wrong frame node.

The frame's bounds that are used for the intersection test with the
newly added reroute are in view space, but the reroute's location was
given in the node tree's coordinate space, when the add reroute
operator was recently refactored (56193eccf6).

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16163
2022-10-06 07:35:35 +02:00
c2c31afa92 Cleanup: split BLF glyph rendering into a function
This makes the drawing loop easier to follow.
2022-10-06 16:28:12 +11:00
RedMser
6fac4bb8b0 Curve: increase max of order U/V
Uses soft and hard max of the resolution properties.

Range for order U/V was 2-6, but after testing higher max values with
NURB splines and surfaces with many control points, no problems were
found.

Reviewed By: campbellbarton

Ref D13918
2022-10-06 13:17:21 +11:00
63ed9550e9 Fix exception in bpy_extras.object_utils.object_data_add(..)
Adding object-data that doesn't support edit-mode would raise an
exception when the "Enter Edit Mode" preferences was enabled.

Other changes:

- Don't attempt to enter edit-mode for library-data.
- Support entering edit-mode for grease-pencil objects.

Alternate fix for the issue raised by D15999.
2022-10-06 13:07:16 +11:00
68ea6c85ab Fix: File context menu broken after recent commit
layout.menu does not have a text_context argument.
f5d67f3fdf
2022-10-06 12:49:22 +11:00
86352364a6 3D View: use float for ED_view3d_project_base & minor changes
Using 'short' was historic (as the value was stored in the Base).
Prefer floats which allow sub-pixel distances to be differentiated.

Also remove IS_CLIPPED assignment as this only made sense when the
values were stored in the Base, without any other ways to check
if projection failed.
2022-10-06 12:35:28 +11:00
87d737cd79 Cleanup: spelling in code comments 2022-10-06 12:13:00 +11:00
51bd26d0fa New math function to add small bias to zero axis
In some situations the zero axis can produce problems and need to add a small bias.

This function adds a small bias using the orthogonal result of the others valid axis.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D16158
6d
2022-10-05 22:11:08 +02:00
1ff51f30ad GPencil: Use stroke function for convert points
The stroke function is faster because the matrix 
is inverted only once.
2022-10-05 22:11:08 +02:00
bfeb64d620 Cleanup: make format 2022-10-05 21:40:58 +02:00
9d40b1cc3e Sculpt: Fix crash in face set init 2022-10-05 12:38:26 -07:00
38af785dba Sculpt: Fix crash in dyntopo draw 2022-10-05 12:38:26 -07:00
a096248d12 Fix: File menu broken after recent commit
layout.menu does not have a text_context argument.
f5d67f3fdf
2022-10-05 13:48:01 -05:00
548a2cbe06 Cleanup: Clang tidy
Also remove unnecessary struct keywords in C++ files.
2022-10-05 13:48:01 -05:00
6306d747b7 DRW: Split ViewProjectionMatrix in order to increase precision
This also removes the need to compute the persmat and saves some memory
from the `ViewInfos` struct. This is needed to allow multiview support.

Initial testing found no major performance regression during vertex
heavy workload.

Test file: {F13610017}

Results:
| Platform | Master | Split Matrix|
| Linux + Mesa + AMD W6600 | 48 fps | 47 fps |
| Macbook Pro M1 | 50 fps | 51 fps |
| Linux + NVidia 1080Ti | 51 fps | 52 fps |
| Linux + Radeon Vega 64 | 25.6 fps | 26.7 fps |

Increased precision when far from origin:
{F13610024}

{F13610025}

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D16125
2022-10-05 20:29:12 +02:00
74ff0aeea0 deps_builder: harden the package download process
During the 3.3 release some packages were missing
in SVN during the release and it ended up building
the release tarball without issues when re-running
the `make source_archive_complete` command after it
failed initially. The tarball however had 0 byte files
for the missing packages.... not good.

This diff hardens the download process by :

1) Validating all required variables are set. This
catches the erroneously attempt at downloading the
nanovdb package even though we have removed it
from versions.cmake but neglected to remove it
from download.cmake

2) When a download fails (due to either a missing
package, or bad download URL) FILE Download will
warn about a hash mismatch but will carry on
happily, you then have to go into the file system
go delete the 0 byte file to retry the download.
We know for a fact the file is bad when it is 0
bytes, just delete it.

3) When we are using the blender repository
(and likely building a source archive) explicitly
validate the hash of all packages. Normally the
build process does this, however when building
a source archive the build does not actually
run for a dep. So preform this check during the
configuration stage.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16124
2022-10-05 12:05:26 -06:00
Iliya Katueshenock
e89b2b1221 Mesh: Skip some domain interpolations for single values
Completely skip the work of interpolating domains for single values
for many to and from combinations. Similar to 535f50e5a6,
but slightly more complex because of the possibility of loose elements
on some mesh domains.

From D16054, with added comments.
2022-10-05 12:42:46 -05:00
124df79e78 Fix T101523: Cycles path guiding debug settings not affecting final render 2022-10-05 19:33:36 +02:00
Iliya Katueshenock
829569dccf Cleanup: Use generic array for mesh domain interpolation result
Instead of declaring a typed array inside the static type block.
This generates slightly less code and should have the same performance.

From D16054
2022-10-05 12:03:07 -05:00
9a633b967a Revert "Geometry Nodes: Add index input to Edge Vertices node"
Unfortunately this commit changed behavior in a fundamental way that
can't be addressed without larger changes. Previously the position
outputs were evaluated on the edge domain and then interpolated to the
context domain, which could be useful for some rudimentary mesh smoothing.
After the commit they were just evaluated at the specified index, which
looks practically random when evaluated on a different domain. We may need
a new node that doesn't have the implicit behavior in the future.

This reverts commit 4ddc5a936e.
2022-10-05 11:38:53 -05:00
424df9ea87 Fix T101610: UV Sphere missing from geometry nodes menu
Caused by 837144b457
2022-10-05 11:02:45 -05:00
Damien Picard
fd48f1b505 I18n: improve unit extraction regex
There were two issues with the unit extraction regex:
- it didn't take the inches, feet, arcminutes and arcseconds symbols
into accounts, which aren’t letters but ' and ";
- some units have more than one B_UNIT_DEF_* flag.

This allows extracting feet, inches, square millimeters, cubic
millimeters, arcminutes, and arcseconds.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D16144
2022-10-05 17:58:50 +02:00
Damien Picard
f5d67f3fdf I18n: disambiguate a few messages
- Active Track (NLA vs movie clip)
- New (file)
- Object Index (loop cut)
- Object Index (render pass)
- Proxy Storage (sequence)
- Rim (Solidify modifier)
- Roughness (particle children)
- Spaces (text whitespace)
- Out (sequencer wipe transition)

Also make new asset tag name translatable.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D16067
2022-10-05 17:53:37 +02:00
Damien Picard
860a539fb5 I18n: extract dynamic enum items
These item names and descriptions never got extracted because they're
not in the RNA until the proper context occurs, and so the extraction
script never even knew about them.

The properties are mostly located in the fluids UI.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15994
2022-10-05 17:47:54 +02:00
195bcea0d0 install_deps: Fix typo in previous commit.
Typo from rB7fa0080c4ffa.
2022-10-05 17:19:16 +02:00
6dd2e193e1 Fix T101405: Deleting a baked action results in an error.
RNA code to create new actions did not properly remove the extra user
set by default, as done in other `new` callbacks of other ID types.

NOTE: Mask ID had the same issue, also fixed in this commit.

NOTE: At some point this needs to be properly fixed, default super-low
level ID creation code should simply not add a 'default' user, this is
extremely bad design and forces higher-level code to do all kind of
extra work to get rid of it half of the time, in very unclear and
confusing ways and places.
2022-10-05 15:59:25 +02:00
Bastien Montagne
b47a234f98 BKE_Main: Add clear separation between 'temp' mains and global main.
Blender is using more and more temporary Main data-base (historically
for reading linked data, but also now when resyncing liboverrides, for
temp data in asset code, etc.).

This commit aims at making this a bit more formal and defined, by:
* Adding a dedicated flag in Main struct to mark a Main as global.
* Adding some API to replace, or temporarily swap the current global
  Main (`G_MAIN`) by another one.

NOTE: Having to temporarily replace `G_MAIN` is a workaround for the
limitation of current RNA, ideally this should be fixed in RNA itself,
but for now at least having an API helps tracking those cases (since
this is potentially risky operation).

This work is also a preparation for more usages of temp mains in the near
future (Asset Brushes and its presets system e.g. will most likely use
temp mains too).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15977
2022-10-05 14:26:45 +02:00
31a4fb42d4 Fix T101613: Muted Mix node wrongly connects to Factor socket
T101613: Muting/ctrl+x deleting the new mix node in Float mode
passes through the wrong input.

Fix by setting no_muted_links() on Factor sockets.
2022-10-05 13:19:54 +01:00
634e4a49d6 Fix T101334: Paint Texture Slots appear greyed out
To the user, this looks like a disfunctional thing (usually greying out
is used for props having no effect).

The greying out is caused by
{rB8b7cd1ed2a17e40661101eea4adae99e8e3d02e9}.
Above commit disabled the direct renaming of images in the
`TEXTURE_UL_texpaintslots` UIList (and instead displays the texture slot
directly as a prop -- which has its `PROP_EDITABLE` flag cleared)
(from the commit message):
> A limitation of this patch is that is isn't possible anymore to rename
images directly from
> the selection panel. This is currently allowed in master. But as
CustomDataLayers
> aren't ID fields and not owned by the material supporting this wouldn't
be easy.

To work around the UI confusion (but still keep the non-editable nature
of the property), now just display this as a label.

Maniphest Tasks: T101334

Differential Revision: https://developer.blender.org/D16138
2022-10-05 13:41:59 +02:00
cfa765845b Fix T101306: crash when calling Delete command for Library Override
Was not passing user_data to id_override_library_delete_hierarchy_fn.

Also correct a wrong assert.

Greenlit by @mont29 in T101306.
Should also go into 3.3 LTS.
2022-10-05 12:47:13 +02:00
6d879601b7 LineArt: Fix "No intersection" flicker.
The flicker was caused by the failure for checking both triangles for
flags. Now fixed.
2022-10-05 18:11:43 +08:00
7fa0080c4f Install_deps: Add building of OpenPGL.
Ref. T101403.
2022-10-05 12:08:05 +02:00
e3bcb203a9 Fix order of include-guard & C++ extern block 2022-10-05 20:27:45 +11:00
1a485a3aa6 Fix error in 6b76381e0a
Missed flipping arguments for caller.
2022-10-05 16:56:10 +11:00
b9cbb229b1 Fix app-template settings being used for non-template preferences
Saving non app-template preferences would use add-ons and other
app-template settings to write the default preferences if there was no
existing user preferences file saved.
2022-10-05 15:34:02 +11:00
79774aa68c App Template: quiet warning when existing preferences don't exist
Suppress warning when saving app-template preferences.

Check if the preferences exist before attempting to read them,
while harmless it looked as if something went wrong.
2022-10-05 15:34:02 +11:00
5dc798f2e4 Docs: improve doc-strings for blend file IO
- Document the behavior of app-template IO for preferences.
- Add doxy-sections for each kind of blend file IO.
- Clarify BKE_blender_userdef_app_template_data_swap doc-string.
2022-10-05 15:30:42 +11:00
6be8c6b3b1 Cleanup: Remove unused includes 2022-10-04 22:17:59 -05:00
fbbd7f0d5c Fix: Crash when reininitializing empty generic array
Noticed this while developing new code that used GArray.
2022-10-04 22:17:59 -05:00
b804f925c7 Fix T101185: New Mikktspace crashes on meshes without valid triangles
The code already had a check for meshes with zero triangles, but it
didn't catch the case where all triangles are flagged as degenerate.
A simple way to reproduce this is to take a mesh and scale it to zero.

After checking the code, it turns out that in this case it's supposed
to just set all tangents to zero, so the fix simply is to detect this
case and skip the computation.
2022-10-05 02:42:43 +02:00
f9a10e7ed0 Geometry Nodes: Add soft min for points node radius input
Also remove an unnecessary cast.
2022-10-04 17:45:58 -05:00
41281cc0e7 Build: fix missing xml2 build time dependency for wayland
Also prepend the existing 'PKG_CONFIG_PATH' instead of overwriting it
as this prevents 'devtoolset-9' libraries being used in the release
environment.
2022-10-05 08:48:32 +11:00
82de17c801 Cleanup: VSE: Rename val to timeline_frame 2022-10-04 21:24:09 +02:00
6309f67718 Cleanup: Add docstrings to SEQ_time.h 2022-10-04 21:24:09 +02:00
76043bc3d6 Cleanup: VSE code readability
Add function `SEQ_time_content_end_frame_get` to get content end frame.
New function is shorthand for
`SEQ_time_start_frame_get() + SEQ_time_strip_length_get()`.
2022-10-04 21:24:09 +02:00
d981418c8c Fix: Crash versioning transfer node with animation data
This versioning needs to be done after linking in order to affect
animation  data which might not be loaded in the regular "do_versions"
loop. Animation data is removed in `nodeRemoveNode`.

Fixes T101439
2022-10-04 13:27:24 -05:00
ea95d04245 Build: integrate OpenPGL into platform files like other libraries
To avoid issues with install_deps. If we more generally switch to using
CMake configs then perhaps this code can be deduplicated again or at
least simplified.
2022-10-04 20:24:27 +02:00
6167a065a5 Build: also list Cycles build options on first cmake config 2022-10-04 20:13:58 +02:00
3353fc60c2 Cleanup: remove unused members from RenderResult 2022-10-04 20:13:54 +02:00
9f8b0b83a9 UI: Avoid unnecessary label in set curve normal node
"Mode" is obvious and isn't worth cutting off the text.
2022-10-04 12:36:06 -05:00
31e89ee5b9 Fix: Bump subversion after forward compatibility breakage
c3b6e37254 change node ID names. Bump the subversion and the
min file subversion so older versions get warnings opening newer files.
2022-10-04 12:33:09 -05:00
8102510482 Fix T101583: Issues applying modifier to mesh with shape keys
The wrong mesh was used to read the position attribute. Also, there was
always a warning about missing shape keys when that wasn't the case.
2022-10-04 12:10:10 -05:00
bc00666683 Fix: UI: Warning for description with period at end
The last period is added automatically, for better or worse.
2022-10-04 12:10:10 -05:00
3e2d7403f9 Cycles: refine inlining thresholds for oneAPI backend
New thresholds give a few percent improvement in average.
2022-10-04 18:34:54 +02:00
df29211eeb Cycles: Speed up oneAPI GPU binaries compilation by using parallel instances
This change speeds up the compilation at the cost of higher memory usage.
CMake implementation checks the amount of available memory to spawn a
reasonable number of parallel compiler jobs.
2022-10-04 18:19:37 +02:00
d2f0cb6745 BLI: Unroll vector loops for better performance on GCC
On GCC, the loops created by `BLI_VEC_OP_IMPL` were not always
unrolled, leading to branching. For `attribute_math::mix4<float3>`,
this lead to a significant performance regression compared to its
older `interp_v3_v3v3v3v3` counterpart.

Instead of a using macros to create the for loops, use variadic
templates to manually unroll them. The compiler might do it anyway
(I didn't observe any effect on Clang in my tests), but there should
be no reason not to unroll these small loops, and making it explicit
and removing use of macros seems better.

On a Ryzen 3700x, this commits doubles the performance of Catmull
Rom curve position evaluation (from 18-19ms to around 9-10ms).

Differential Revision: https://developer.blender.org/D16136
2022-10-04 11:16:25 -05:00
4d9588ee45 Revert "install_deps: update OpenVDB for Blender 3.4."
This update has been moved back to Blender 3.5.

This reverts commit ded4604d71.
2022-10-04 17:35:21 +02:00
25d162f864 Revert "install_deps: update OIIO/Boost/Python/NumPy versions."
These updates have been moved back to Blender 3.5.

This reverts commit 1e1e9014cf.
2022-10-04 17:35:21 +02:00
4186b0ebe4 Fix T101233: Crash on deleting the object in outliner due to null pointer access
After rB188f7585a183 deleting the object results in crash due
to null pointer access if collections are filtered out

Reviewed by: mont29

Differential Revision: https://developer.blender.org/D16031
2022-10-04 20:49:34 +05:30
dd4a40f42d Always initialize MaterialPass (Fixes a crash in mscv)
Differential Revision: https://developer.blender.org/D16134
2022-10-04 16:16:46 +02:00
957cb173f2 Fix T101447: Hold split not working correctly
Caused by incorrect conflict resolution in commit 302b04a5a3.
2022-10-04 16:11:34 +02:00
0458b24a23 Fix T101499: Do not allow unlinking objects from linked collections. 2022-10-04 14:59:06 +02:00
38170cd295 Cleanup: Remove commented out code in ssr_lib.glsl. 2022-10-04 13:33:41 +02:00
Miguel Pozo
6c2c3ed2c9 Fix T101438: Wrong LOD selection after clamping the mip value (Nvidia)
Fix for T101438

Clamping the mip seems to always set it to 9.0.
I couldn't find an alternative way to avoid triggering the error (ie. min(mip, 9.0)).

In any case, the results with this patch applied look the same to the (correct) ones on AMD.
And, since clamping the max mip to a hardcoded value could result in resolution-depended behavior, I guess disabling the clamp should be ok anyway.

Reviewed By: fclem

Maniphest Tasks: T101438

Differential Revision: https://developer.blender.org/D16129
2022-10-04 13:32:15 +02:00
James
da6d6f99a8 Animation: Update tooltips to be more readable
Change some wording of tooltips for readability, in animation-related
areas (drivers, keying sets, animation channel visibility).

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16131
2022-10-04 12:30:30 +02:00
c3003b4346 Fix T101559: Rain Test Animation demo crashes Blender 3.3
Update to liboverride creation code to add support of keeping active
object forgot to consider case when there is no known/given view layer.

NOTE: due to differences in code, fix for 3.3 will be a bit different.
2022-10-04 10:56:49 +02:00
501fff40e8 New viewlayer deferred resync code: add utils to ensure resync of whole Scene and Main.
Similar to existing `BKE_main_collection_sync` and `BKE_scene_collection_sync`,
in some cases code does not have access to a specific view layer,
and/or does not know exactly which view layer needs to be in sync,
or just need the full data to be up to date.
2022-10-04 10:53:05 +02:00
6b76381e0a Cleanup: rename BKE_appdir_folder_id_version, improve doc-strings
Rename BKE_appdir_folder_id_version to
BKE_appdir_resource_path_id_with_version because BKE_appdir_folder_id
and BKE_appdir_folder_id_version didn't accept compatible arguments.

Also add notes to GHOST_getSystemDir & GHOST_getUserDir that
BKE_appdir_resource_path_id(..) should be used instead (in most cases).
2022-10-04 16:52:10 +11:00
bf4926b30c Support environment variables to override USER & SYSTEM resource paths
Even though individual USER/SYSTEM paths could be set using environment variables,
it wasn't possible to override the USER or SYSTEM paths.

This meant the result of `bpy.utils.resource_path('USER')` &
`bpy.utils.resource_path('SYSTEM')` could still be used by scripts,
making the Blender session potentially the default USER directory
(even when `BLENDER_USER_CONFIG`, `BLENDER_USER_SCRIPTS` &
`BLENDER_USER_DATAFILES` all point elsewhere).

Resolve by adding environment variables:

- BLENDER_USER_RESOURCES
- BLENDER_SYSTEM_RESOURCES

These will be used for `bpy.utils.resource_path('USER')` &
`bpy.utils.resource_path('SYSTEM')`, as well as a basis for user &
system directories, unless those environment variables are
set (`BLENDER_USER_*` or `BLENDER_SYSTEM_*`).

Resolves issue raised by T101389.

Example usage & output:

{P3225}

Reviewed By: brecht

Ref D16111
2022-10-04 13:54:09 +11:00
868ef9ec37 Cleanup: remove unnecessary includes from sculpt_paint 2022-10-04 13:54:04 +11:00
5c51bf2ffe Cleanup: format 2022-10-04 13:54:02 +11:00
a9918e9c0e Cleanup: undeclared function warning 2022-10-04 13:54:01 +11:00
1d629a4403 Cleanup: correct argument size for plane in planeProjection 2022-10-04 13:53:59 +11:00
22c3db72ca Sculpt: Visibility bugfixes
* Unhide all is no longer part of face_set_change_visibility.
* Implemented a few visibility API methods for PBVH_BMESH
* Fixed bug with unhide all not freeing all multires grid_hidden
  bitmaps.
2022-10-03 17:19:50 -07:00
2cf21604c9 Sculpt: implement Reveal All for PBVH_BMESH 2022-10-03 17:19:50 -07:00
d42f882343 Cleanup: Fix sign conversion warning in BMesh log 2022-10-03 17:43:21 -05:00
97746129d5 Cleanup: replace UNUSED macro with commented args in C++ code
This is the conventional way of dealing with unused arguments in C++,
since it works on all compilers.

Regex find and replace: `UNUSED\((\w+)\)` -> `/*$1*/`
2022-10-03 17:38:16 -05:00
ed7f5713f8 Sculpt: Fix T101430: Blank stroke undo steps corrupt dyntopo
Blank brush strokes never have an oppurtunity to initialize
a sculpt undo step, which results in blank global undo steps.
These confuse DynTopo's internal BMLog undo stack.

Note: I tried having the stroke operator return OPERATOR_CANCELLED,
but this didn't prevent the undo push (which is done automatically
due to the presence of OPTYPE_UNDO in the operator flags).
I might investigate removing the flag, but that might cause other
problems.
2022-10-03 15:37:23 -07:00
416d1d0393 Sculpt: Add debug code to print sculpt undo stack. 2022-10-03 15:37:23 -07:00
4ddc5a936e Geometry Nodes: Add index input to Edge Vertices node
Previously the edge index was always determined by the field context,
and the node didn't work when the context was in any other domain.
Adding an index input makes it work much more nicely with the other
topology nodes. It's now in the topology submenu too.

I also reimplemented the edge positions input to use the field at index
node internally. That will probably make it slower for now, but we need
to optimize that to do nothing in some special cases anyway.

Differential Revision: https://developer.blender.org/D16105
2022-10-03 16:54:23 -05:00
99cbaced3b Fix: Incorrect field status in offset point in curve node
The input supports fields, the outputs are fields only if either of the
inputs are fields. Also, .hide_value() is redundant for implicit fields.
2022-10-03 16:44:09 -05:00
c3b6e37254 Geometry Nodes: Rename Control Point Neighbors Node
Rename the node to "Offset Point in Curve"

Since this was committed, more mesh and curve topology nodes have been
committed with a different naming scheme (482d431bb6). Change
the name of this node to match "Offset Corner in Face". Because the
node was only added recently, it's a full rename, including the ID,
so forward compatibility is broken.
2022-10-03 16:41:58 -05:00
248def7e48 Geometry Nodes: Change order of outputs in topology nodes
It's a bit more natural if the "Total" output come second, and it's
also consistent with the Accumulate Field node.
2022-10-03 16:27:09 -05:00
748fda32ed Geometry Nodes: Set Curve Normal
This node allows for curves to have their evaluated normal mode changed
between MINIMUM_TWIST and Z_UP. A selection input allows for choosing
which spline in the curves object will be affected.

Differential Revision: D16118
2022-10-03 15:50:21 -05:00
Phoenix Katsch
b475506cfb Cycles: add option to bake specular from active camera viewpoint
Previously it would bake viewed from above the surface. The new option can be
useful when the baked result is meant to be viewed from a fixed viewpoint or
with limited camera motion.

Some effort is made to give a continuous reflection on parts of the surface
invisible to the camera, but this is necessarily only a rough approximation.

Differential Revision: https://developer.blender.org/D15921
2022-10-03 21:59:31 +02:00
af51e4b41c Cleanup: fix source comment/documentation typos
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D16071
2022-10-03 21:59:31 +02:00
e2572bd89f Fix OpenEXR saving still outputting alpha when using RGB instead of RGBA mode
Contributed by linhsu0723.

Differential Revision: https://developer.blender.org/D15979
2022-10-03 21:59:31 +02:00
42f40657f1 Images: remove option to choose between BW/RGB/RGBA for multilayer EXR save
This was not properly respected, and in general with multiple passes and layers
it's unclear what this should do exactly without breaking some render passes.
Better to keep this image format for raw unmodified render results.
2022-10-03 21:59:20 +02:00
9b7c84f293 Image: improve Save As Render tooltip, hide option when saving render result 2022-10-03 21:00:55 +02:00
0c7458604d Cleanup: rename IMA_CHAN_FLAG_ALPHA to IMA_CHAN_FLAG_RGBA to match meaning 2022-10-03 20:45:06 +02:00
72ceb7dec1 Fix: crash when linked geometry node group is missing 2022-10-03 19:15:06 +02:00
13b3c408e3 Fix T101510: Incorrect context for running data unlink from template ID
There was already a fix for this, but it got broken again with c973d333da.
2022-10-03 18:20:59 +02:00
d20be55c1a Cleanup: in Cycles force inline transform_inverse_impl
We expect this to always happen.

Ref T100891
2022-10-03 17:58:34 +02:00
2f7234d3e1 Attribute Node: access geometry node instance attributes.
The Instancer mode of the node is intended for varying material
behavior between instances. Since Geometry Nodes support arbitrary
named instance attributes, this mode should include them in lookup.

To implement this it is sufficient to store references to Geometry
Node data in DupliObject, and check it during dupli attribute lookup.

In order to reduce the memory usage of DupliObject, only 4 array
entries are allocated, even though the current dupli recursion stack
limit is 8. This assumes that not every entry would be associated with
a GeometrySet instance. Hopefully, soon the whole system will be
rewritten to remove the hard limits altogether.

Differential Revision: https://developer.blender.org/D16114
2022-10-03 18:02:24 +03:00
a6083cdeef Cleanup: remove unnecessary braces 2022-10-03 16:28:21 +02:00
e65598b4fa Geometry Nodes: new Sample UV Surface node
This node allows sampling an attribute on a mesh surface based
on a UV coordinate. Internally, this has to do a "reverse uv lookup",
i.e. the node has to find the polygon that corresponds to the uv
coordinate. Therefore, the uv map of the mesh should not have
overlapping faces.

Differential Revision: https://developer.blender.org/D15440
2022-10-03 16:06:29 +02:00
31ae3a5012 Geometry Nodes: set viewer overlay opacity default to 1
This value worked better for artists.
2022-10-03 12:34:48 +02:00
83ebf6a811 Fix T101564: GPencil: Selecting imprecise if transforms are animated
The check was doing with the original point and
must be the evaluated point.
2022-10-03 11:18:08 +02:00
035c237d69 Fix T101548: GPencil new lines in Multiframe editing appear as Onion
The problem was the eval data update only occurs for the 
actual frame and in this case must be for all frames.
2022-10-03 10:38:00 +02:00
7029f11439 Fix T101487: New OBJ importer handles UVs incorrectly when some faces of an object don't have UVs
The UV data filling logic was incorrectly just skipping over loop
entries that don't have a UV coordinate, instead of assigning
the default zero UV for them. This was a problem only for meshes
where some faces did have UVs, but some other faces did not (T101487).
2022-10-03 11:07:50 +03:00
cbfd2aaeb7 Cleanup: sort cmake file lists 2022-10-03 12:13:01 +11:00
b1a672f541 CMake: add missing headers 2022-10-03 12:13:01 +11:00
7afee060d0 Cleanup: add license header 2022-10-03 12:04:41 +11:00
d4d40f3b69 DNA: reduce size of Base struct
Re-order members and remove pad members,
reducing it's size by 24 bytes on 64 bit systems.
2022-10-03 11:19:15 +11:00
d3ba8826b0 Cleanup: remove 2D region-relative coordinates from Base
Historically, caching these values may have had some advantages,
simplifying drawing object centers and selecting by object center.

Now the only uses of these values would calculate the projection
before use, so there is no reason to store run-time projection in DNA.

This also quiets a `-Wstring-overflow` warning.
2022-10-03 11:07:17 +11:00
ea2c41c730 Cleanup: spelling in comments
Also replace "dm" for evaluated mesh in some comments.
2022-10-03 11:03:46 +11:00
55387197a7 Cleanup: use function style casts for C++ 2022-10-03 11:03:46 +11:00
d762132a72 Cleanup: quiet undeclared function warning 2022-10-03 10:24:05 +11:00
15e6673ccd Cleanup: Move three modifier files to C++ 2022-10-02 11:17:40 -05:00
ed6764dede Fix: build issue with MSVC
Issue introduced by rB208b3a0472b3
which fixed a build issue on linux.

This fix is a band-aid at best but
reverting rB208b3a0472b3 is not
really an option since that would
break linux again.
2022-10-02 10:17:05 -06:00
5a982b0695 GPUTexture: Add GPU_texture_create_single_layer_view
This allows the creation of texture arrays from 1D/2D/Cube texture.
This is useful when the shader expect a texture array but the original
texture isn't.
2022-10-02 15:18:42 +02:00
208b3a0472 Fix build error on Linux after font thumbnail changes 2022-10-02 15:06:34 +02:00
9d30adb7eb Cleanup: Rename function gpencil_point_to_parent_space
gpencil_point_to_parent_space -> gpencil_point_to_world_space

The old name was not clear because it looked it was moving into
the object space, but really is doing the opposite.
2022-10-02 13:40:42 +02:00
8f1d3e14d9 Cleanup: Rename functions
gpencil_apply_parent->gpencil_world_to_object_space
gpencil_apply_parent_point->gpencil_world_to_object_space_point

The old name was not descriptive enough.
2022-10-02 13:40:42 +02:00
e0a261c653 Cleanup: Move more files using mesh runtime data to C++
In preparation for moving mesh runtime data out of DNA.
2022-10-01 22:13:19 -05:00
b14ad9114f Fix: Mix node did not set clamp result correctly in versioning code
Files were incorrectly loaded without the Clamp Result option set.

Reported in BA by CarlG
2022-10-02 00:04:30 +01:00
Jason Fielder
0fdb9cd650 GPU: Fix issue with GPU render boundaries being opened while a GPUBackend does not exist.
Fixes regression introduced by rBe8bcca4bdc94 (D15900)

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D16085
2022-10-02 00:08:52 +02:00
Pratik Borhade
ffd8390af7 Fix T101504: Crash when repeat value is zero
Crash triggers due to division by zero
fix is to increase minimum limit for `seg_repeat` to 1

Reviewed By: antoniov, frogstomp

Maniphest Tasks: T101504

Differential Revision: https://developer.blender.org/D16120
2022-10-01 16:28:29 +02:00
e5ccbfab09 Cleanup: simplify uv packing for non-square materials 2022-10-01 17:29:14 +13:00
206dead860 Sculpt: Fix T101467: Improper vertex count in pbvh draw 2022-09-30 15:40:50 -07:00
81f15a51aa Sculpt: Fix sculpt face set undo creating duplicate face set layers 2022-09-30 15:35:11 -07:00
991a35b844 Sculpt: fix crash in relax face sets brush 2022-09-30 15:32:01 -07:00
6b9f45c1d1 Sculpt: Fix T101430: Dyntopo undo crash 2022-09-30 15:28:26 -07:00
5b0485fd77 Sculpt: Upload white for color attributes in multires in sculpt
Even if multires in sculpt mode doesn't yet support color
attributes, we should at least upload white color to avoid
making everything black.

Also fixed a bug where multires PBVHs didn't have access to
their CustomData attribute layout, which PBVH draw needs.
2022-09-30 15:19:10 -07:00
1eba76d8ed Sculpt: Fix T101503: Memory corruption in multires faceset drawing 2022-09-30 15:02:50 -07:00
4cbafba04b Sculpt: Fix T101430: Curve shown improperly in mask from cavity redo 2022-09-30 14:56:06 -07:00
554afabf75 Attribute Node: refactor lookup to remove duplication between engines.
Currently lookup of Object and Instancer attributes is completely
duplicated between Cycles, Eevee and Eevee Next. This is bad design,
so this patch aims to deduplicate it by introducing a common API
in blenkernel.

In case of Cycles this requires certain hacks, but according to
Brecht it is planned to be rewritten later for more direct access
to internal Blender data anyway.

Differential Revision: https://developer.blender.org/D16117
2022-09-30 20:01:57 +03:00
42eda155df Cleanup: Move draw_manager_data.cc to C++
This will help with moving mesh runtime data to C++
2022-09-30 09:38:02 -05:00
8ba508d70b Fix missing Outliner updates when adding nodetrees
When e.g. grouping nodes into nodegroups, these would not show up
immediately in the Outliner (Blender File / Data API view).

Now send (unique combination, not used elsewhere) notifiers (and listen
for these in the Outliner).

Differential Revision: https://developer.blender.org/D16093
2022-09-30 11:53:03 +02:00
2004827bc9 Fix T101347: Curve draw fails to project to cursor depth in ortho views
ED_view3d_win_to_3d_on_plane with do_clip enabled wasn't working in
non-camera orthographic views as it didn't take into account the ray
origin being centered to the view.

Resolve by testing viewport clipping after the ray has been projected.
2022-09-30 18:29:26 +10:00
68ac737d48 Cleanup: format 2022-09-30 10:28:11 +02:00
6865aab133 Cleanup: quiet unused parameter warning in lambda function
Copy-paste error in rB039429faeb41.
2022-09-30 10:27:48 +02:00
dbc097d6b8 Fix error in blf_get_sample_text returning a pointer to stack memory
Copy-by-value was used when iterating over unicode_samples which
then referenced an array from the value.

Resolve by referencing a const pointer to the unicode_sample array.
2022-09-30 15:03:18 +10:00
8bdd4b4685 Cleanup: use function style casts for C++ 2022-09-30 14:51:49 +10:00
1c1dc5f844 Cleanup: Move files that use mesh runtime data to C++
In preparation for moving the mesh runtime struct out of DNA.
2022-09-29 18:32:44 -05:00
7db79feecd Cleanup: Move object_update.c to C++ 2022-09-29 17:11:20 -05:00
0ff485b6ba Cleanup: Move modifier.c to C++ 2022-09-29 16:43:09 -05:00
3059c0998a Fix T101118, T101471: Crash with bevel weight in solidify modifier
Just a missing null check for the original edge weight.
2022-09-29 16:40:13 -05:00
688c4f7e51 Sculpt: fix stroke-only attributes not being freed at stroke end 2022-09-29 13:45:17 -07:00
b063cfa9cf Sculpt: fix T101465, crash in cloth filter with new automasking modes 2022-09-29 13:38:16 -07:00
6a9b45995d Sculpt: Fix T101464: Crash in mask from cavity 2022-09-29 13:14:42 -07:00
f998fa2732 Sculpt: Fix T101463: Don't initialize automask to zero in
factor mode if topology or boundary modes are inactive

Factors mode (precomputing the automask) should initialize the
mask to 1.0 if no additive automasking modes are enabled, instead
of zero.
2022-09-29 13:06:55 -07:00
c938447ee2 Cleanup: Naming in edge vertices node
- Use `enum class`
- Use shorter names for field input classes for better line wrapping
- Use "Vert" instead of "Vertex"
2022-09-29 15:01:10 -05:00
912a1e2820 Fix: Order of node mixins in custom nodes python template
See T101259. This order makes the poll not work, even when called from
Python. The bundled template shouldn't be a source of errors for node
addons.
2022-09-29 11:59:02 -05:00
c007e84e9e Fix: Viewer node overlay alpha broken on NVidia GPUs
On NVidia GPUs, when the blue channel was between 0 and 0.1,
the overlay's alpha would increase, making it invisible.

With the `overlay_line_fb` frame buffer bound in `overlay_engine.cc`
there are two outputs to write to: the color and the line output, which
is used for making smooth antialiased lines. The overlay is in its
current position in the order of overlays so that it draws on top of
curve wire lines. Not writing to that second output is undefined
behavior, so fix it by writing zeros. In the future, the overlay
could be smoothed on curves using that second texture.

Thanks to Clément for the explanation of the issue!
2022-09-29 11:28:48 -05:00
520d111eca Cleanup: Simplify code and remove duplications
This commit simplify the previous fix for T101455

f6c2f1c65e
2022-09-29 15:03:23 +02:00
d2e576f34c GPencil: Remove Fill use_collide_only option
After a lot of testing, this option is not required and
now this is managed by stroke_collsion.

If the stroke_collision is enabled, only collide strokes 
are used.
2022-09-29 14:58:29 +02:00
10f1972ff7 GPencil: Fix missing Fill stroke cross detection
If the cross point was in the extreme of the stroke the
collision was not detected because it could be
outside of the bbox.

Removed the bbox check because now it is
not necessary.
2022-09-29 13:51:58 +02:00
f6c2f1c65e Fix T101455: GPencil Gizmo in wrong location when using Active Element
The gizmo was not set when this option was selected.

By design, in grease pencil the active element option uses
the object origin as pivot point.
2022-09-29 13:38:31 +02:00
b70b02ee42 Fix: Spline Parameter node produces NaN when curve is a single point
Issue found in file from T101256.
2022-09-29 13:32:03 +02:00
ffccdf069b Nodes: fix missing update when input of muted node changes 2022-09-29 13:09:00 +02:00
6757f81fab Viewport: Remove unnecassary assert 2022-09-29 04:05:03 -07:00
db0ef8b00d Fix T101410: ignore dangling reroute inputs
For consistency with other node systems in Blender and older
versions of geometry nodes, dangling reroute inputs should
not affect the output. When an input socket is linked to dangling
reroutes, its own value should be used instead.
2022-09-29 13:03:15 +02:00
5ffbabb24c Nodes: fix missing updates with muted nodes and reroutes
Muted nodes and reroutes can potentially affect the output when
they are linked to an input socket and don't have any inputs on
their own.

The issues was that previously "logically linked sockets" where used
which hide reroutes and muted nodes away. The solution is to work
with the directly linked sockets instead and handle reroutes etc
explicitly.
2022-09-29 12:43:43 +02:00
1494a22a90 Sculpt: Reset automask cache on non-color non-mask undo steps 2022-09-29 02:33:59 -07:00
f1990bd900 UI: Nodes typo in "distribute points in volume" node
Distribute Points In Volume →  Distribute Points in Volume.
2022-09-29 11:16:47 +02:00
fae975dd54 UI: Nodes re-organize the nodes in alphabetical order
This was a regression introduced after the 3.3 release.

This fix T101452
2022-09-29 11:13:27 +02:00
2fc136427d Fix T101451: curve attribute overlay disappears when origin is out of view
The core issue seems to be that `BKE_curve_minmax` does not create the
correct bounding box for `Curve` data passed to the render engine.
That's because this `Curve` object does not contain the legacy curve
data structure.

Fixing this will likely require some more consideration, so this fix just
avoids the culling check for now, which is actually also done in
`OVERLAY_extra_wire` using the same approach.
2022-09-29 11:12:05 +02:00
6d3da28676 Sculpt: fix draw face sets not updating on first stroke 2022-09-29 01:47:40 -07:00
Andrew Oates
4bdba62cb9 Fix T94441: fix crash parenting object to a bone
This crash occurs when the bone is newly created.  In certain
circumstances the depsgraph data for the armature is not updated,
causing `pchan_eval` to be NULL when the parent is updated.  This causes
a segfault in `ED_object_parent_set` when the flags are updated.

This change fixes the underlying depsgraph bug, and also adds both an
assertion and NULL pointer check to `ED_object_parent_set` to better
handle this scenario if it recurs via another path.

Maniphest Tasks: T94441

Differential Revision: https://developer.blender.org/D16065
2022-09-29 10:35:18 +02:00
039429faeb Sculpt: fix missing nullptr check in pbvh draw
This time it was face sets.
2022-09-29 01:25:47 -07:00
9be99bcb45 Cleanup: Address format-security warning 2022-09-29 10:02:04 +02:00
5dd48c50f0 Cleanup: Set but unused variable 2022-09-29 09:52:00 +02:00
46e0512d1e Cleanup; Warning about missing override for virtual function 2022-09-29 09:51:32 +02:00
eeb81c4a63 Cleanup: quiet warnings (unused arg & trailing fullstop) 2022-09-29 17:31:55 +10:00
a56da7b045 Fix bpy.utils.script_paths() ignoring environment variables
When check_all=True was passed,

- `os.path.join(bpy.utils.resource_path('USER'), "scripts")`
  was used instead of BLENDER_USER_SCRIPTS.
- `os.path.join(bpy.utils.resource_path('SYSTEM'), "scripts")`
  was used instead of BLENDER_SYSTEM_SCRIPTS.

Other minor changes:

- Simplify collecting paths.
- Don't add user-directories multiple times when check_all=True.
- Normalize paths before before checking duplicates to reduce the
  change the same path is added multiple times.

Found these issues while investigating T101389.
2022-09-29 17:31:55 +10:00
a66e584294 Cleanup: correct API usage for script access
In practice this didn't cause problems, but accessing scripts via
bpy.utils.resource_path('USER') ignores the BLENDER_USER_SCRIPTS
environment variable.
2022-09-29 17:22:32 +10:00
46076e4876 Cleanup: run clang-format in sculpt code 2022-09-28 23:41:53 -07:00
eab69d4930 Cleanup: Use c++-style unused paramter form in automasking code.
Also renamed shadowed variable in sculpt_filter_mesh.c
2022-09-28 23:38:48 -07:00
0de9081e89 Sculpt: fix missing nullptr check in pbvh draw
Check for nullptr when building mask vbos.
2022-09-28 23:33:02 -07:00
bbc69563d0 Sculpt: Normal-based automasking modes
Two new normal-based automasking modes.

The first mode, "brush", compares vertex normals with the initial
normal at the beginning of the brush stroke.

The second, "view", compares vertex normals with the view normal.
If "occlusion" is on then rays will be shot from each vertex to test
if it is occluded by other geometry (note: this can be very slow).\
Only geometry inside the sculpt mesh is considered.

Each mode has an associated angular limit and a falloff.

Reviewed by: Julien Kaspar and Jeroen Bakker
Differential Revision: https://developer.blender.org/D15297
Ref D15297
2022-09-28 23:21:56 -07:00
a4ff106c58 Cleanup: Remove more unused CustomData API functions
Due to increased usage of typed arrays in C++ and name/offset based
access for BMesh, these are unlikely to be used again, and haven't been
used in many years.
2022-09-28 23:13:58 -05:00
ff353842bd Cleanup: Deduplicate logic in CustomData access functions
Also remove comments that just restated what the next line
was doing, often incorrectly.
2022-09-28 23:13:58 -05:00
57620af33c Cleanup: Remove unused BMesh function 2022-09-28 23:13:58 -05:00
0c282c068f Cleanup: cmake indentation 2022-09-29 13:32:16 +10:00
f96020fb9a Cleanup: remove '.' from the end of descriptions
Quiet warnings at startup & build time.
2022-09-29 13:32:16 +10:00
91db47e914 Cleanup: simplify storage when uv island packing
Refactor ahead of upcoming packing changes.

Differential Revision: https://developer.blender.org/D16096
2022-09-29 15:48:53 +13:00
e2df195844 Fix wrong version bump to 3.4.1, we are still on 3.4.0
The patch levels are reserved for bugfix releases.
2022-09-29 03:57:30 +02:00
c64d3a692d Cleanup: use doxy-sections in anim_channels_edit.c 2022-09-29 10:28:56 +10:00
c1548938a4 Cleanup: spelling in comments 2022-09-29 10:28:39 +10:00
d459219307 Cleanup: quiet deprecated copy warning 2022-09-29 10:28:11 +10:00
ec8118a59e Cleanup: replace UNUSED() with commented arguments
This is the conventional way of dealing with unused arguments in C++.

Also quiet enum conversion warnings.
2022-09-29 10:26:10 +10:00
9cfa8b945a Cleanup: format 2022-09-29 10:11:42 +10:00
c087d09c16 Cleanup: fix unused variable warnings in draw_pbvh.cc 2022-09-28 16:39:21 -07:00
0156a677c7 Sculpt: New Cavity Automasking Mode
Add new cavity automasking mode based on local mesh
curvature.  Cavity masking is a great way to quickly add
detail in crevices and the like.  It's meant to be used
with the Paint brush in color attribute mode.  It does
work with other brushes but the results can be unpredictable.

{F13131497}

The old "dirty mask" operator has been replace with a new
"mask from cavity" operator that shares the same code with
cavity automasking.

Differences from the sculpt-dev implementation:
    * It uses the word "cavity."  When I first implemented
this I wasn't aware
      this feature existed in other software (and other
paint modes in Blender),
      and for reasons that escape me today I initially
decided to call it a concave or
      concavity mask.
    * The cavity factor works a bit differently.  It's
      no longer non-linear and functions as a simple
      scale around 0.5f.
    * Supports custom curves.
    * Supports blurring.

Reviewed By: Julian Kaspar, Jeroen Bakker and Campbell Barton
Differential Revision: https://developer.blender.org/D15122
Ref D15122
2022-09-28 16:22:34 -07:00
53ac3192ba Cleanup: remove duplicate declaration
Also got rid of ATTR_NO_OPT macro.
2022-09-28 15:50:09 -07:00
65900d88a8 Sculpt: Rewrite PBVH draw
Rewrite PBVH draw to allocate attributes into individual VBOs.
The old system tried to create a single VBO that could feed
every open viewport.  This required uploading every color and
UV attribute  to the viewport whether needed or not, often exceeding
the VBO limit.

This new system creates one VBO per attribute.  Each attribute layout is
given its own GPU batch which is cached inside the owning PBVH node.

Notes:

* This is a full C++ rewrite.  The old code is still there; ripping it out
can happen later.
* PBVH nodes now have a collection of batches, PBVHBatches, that keeps
track of all the batches inside the node.
* Batches are built exclusively from a list of attributes.
* Each attribute has its own VBO.
* Overlays, workbench and EEVEE can all have different attribute
  layouts, each of which will get its own batch.

Reviewed by: Clement Foucault
Differential Revision: https://developer.blender.org/D15428
Ref D15428
2022-09-28 14:51:23 -07:00
a790873d2a Cleanup: Typo in forward declaration 2022-09-28 16:32:59 -05:00
482d431bb6 Geometry Nodes: Curve and mesh topology access nodes
This patch contains an initial set of nodes to access basic
mesh topology information, as explored in T100020.

The nodes allow six direct topology mappings for meshes:
- **Corner -> Face** The face a corner is in, the index in the face
- **Vertex -> Edge** Choose an edge attached to the vertex
- **Vertex -> Corner** Choose a corner attached to the vertex
- **Corner -> Edge** The next and previous edge at each face corner
- **Corner -> Vertex** The vertex associated with a corner
- **Corner -> Corner** Offset a corner index within a face

And two new topology mappings for curves:
- **Curve -> Points** Choose a point within a curve
- **Point -> Curve** The curve a point is in, the index in the curve

The idea is that some of the 16 possible mesh mappings are more
important, and that this is a useful set of nodes to start exploring
this area. For mappings with an arbitrary number of connections, we
must sort them and use an index to choose a single element, because
geometry nodes does not support list fields. Note that the sort
index has repeating behavior as it goes over the "Total" number of
connections, and negative sort indices choose from the end.

Currently which of the "start" elements is used is determined by the
field context, so the "Field at Index" and "Interpolate Domain" nodes
will be quite important. Also, currently the "Sort Index" inputs are
clamped to the number of connections.

One important feature that isn't implemented here is using the winding
order for the output elements. This can be a separate mode for some
of these nodes. It will be optional because of the performance impact.

There are several todos for separate commits after this:
- Rename "Control Point Neighbors" to be consistent with this naming
- Version away the "Vertex Neighbors" node which is fully redundant now
- Implement a special case for when no weights are used for performance
- De-duplicating some of the sorting logic between the nodes
- Improve performance and memory use of topology mappings
- Look into caching some of the mappings on meshes

Differential Revision: https://developer.blender.org/D16029
2022-09-28 14:38:27 -05:00
25533dbe21 Mesh: Add C++ implementaiton of topology mappings
Because they are friendlier to use in C++ code than the existing mesh
mapping API, these mappings from one domain to another were often
reimplemented in separate files. This commit moves some basic
implementations to a `mesh_topology` namespace in the existing
mesh mapping header file. These is plenty of room for performance
improvement here, particularly by not using an array of Vectors, but
that can come later.

Split from D16029
2022-09-28 14:31:32 -05:00
878dea4e0f GPencil: Avoid infinite loop in Fill debug mode
If the internal flag is set to debug and the Ctrl key is used
the program keeps running endless.
2022-09-28 20:29:41 +02:00
6e9320d237 GPencil: Disable Fill visual aids if use Inverted
When the inverted mode is used, the visual aids must
not be displayed.
2022-09-28 20:23:49 +02:00
19955ef88e GPencil: Extend Fill lines when visual aids are disabled
When the visual aids are disabled, but the extend factor
is > 0, the lines must be extended, but not displayed.

Also, some variables renamed to clarify.
2022-09-28 20:07:20 +02:00
36096fe480 GPencil: Change property text for Fill Visual Aids 2022-09-28 19:42:03 +02:00
ad789c74df GPencil: Fix unreported memory leak in Fill inverse
There was a memory leak when use inverted fill.
2022-09-28 19:36:31 +02:00
c55d38f00b Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.

**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
  makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
  is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
  its active or not.

**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
  When pinned, the spreadsheet still references the viewer node even
  when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
  the active viewer.

**Attribute**
* When a field is linked to the second input of the viewer node it is
  displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
  automatically. This does not work in all cases. It falls back to the
  face corner domain on meshes and the point domain on curves. When
  necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
  that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.

**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
  setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
  by disabling the "Viewer Node" option in the "View" menu.

**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
  is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
  field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
  attribute.
* The ground truth for the active viewer node is stored in the workspace
  now. Node editors, spreadsheets and viewports retrieve the active
  viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
  the viewed geometry of the corresponding object is part of the iterator
  instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
  to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
  existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
  "preferred domain" for every field input. If there is not exactly one
  preferred domain, the fallback is used.

Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
  added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
  the values might have to be normalized or some should be drawn as arrays.
  For now, we encourage users to build node groups that generate appropriate
  viewer-geometry. We might include some of that functionality in future versions.
  Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
  nvidia gpus, to be investigated.

Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
2312915b96 Cleanup: Rename variables 2022-09-28 17:42:32 +02:00
8c95ab235f GPencil: Fix unreported bug for fill closing strokes
The extend lines were included in render by error
when the only collide option was ON.
2022-09-28 17:42:32 +02:00
1f493125e3 MSVC: promote C4033 to an error
C4033 'function' must return a value

is a MSVC level-1 warning, clang and GCC
treat this as an error however, this
change promotes it to an error as well
for MSVC to mimic the GCC behaviour.
2022-09-28 08:32:56 -06:00
3f55121a18 GPencil: Fix compiler warning 2022-09-28 16:10:54 +02:00
bb4e09ddc5 Fix compiler warnings with clang
This attribute only works on functions in clang, not function pointers.
2022-09-28 16:03:39 +02:00
fe19de5fcc GPencil: Fill Tool - Check if extensions collide with real strokes
This commit is an improvement in the previous fill tool
changes in order to improve how the extended strokes
are managed.

* Now, the algorithm checks if the extend cross a standard stroke, not only extend strokes.

* Option to enable or disable the stroke cross checking
because this can be slow in very complex scenes.

* Added `D` key to toggle stroke cross option.

* Option to use only collide strokes to be used as fill limit.

If the option to use only collide strokes is enabled, the
open extensions are in different color.

* Status text now shows mode and the actual extend factor.

This commits also contains a refactor of the loops
to use arrays as much as possible.

Reviewed By: mendio, pepeland

Differential Revision: https://developer.blender.org/D16052
2022-09-28 15:44:20 +02:00
e191cf89b2 Fix macOS cmake warning about missing OpenAL, after Python module changes 2022-09-28 14:39:25 +02:00
050b6498d3 Bump submodule versions 2022-09-28 13:45:22 +02:00
808b03da43 Cleanup: decentralize .blend I/O for space types
This adds callbacks to `SpaceType` to make each editor responsible to
manage their own .blend I/O, and moves relevant code from `screen.c`
to the editors files.

Differential Revision: D11069
2022-09-28 11:52:22 +02:00
5270ac5ed8 Fix GC tracking error for instances of mathutils types
Mathutils types were always GC tracked even when it wasn't intended.
Not having to track objects speeds up Python execution.

In an isolated benchmark created to stress test the GC
creating 4-million vectors (re-assigning them 100 times), this gives
an overall ~2.5x speedup, see: P3221.

Details:

Since [0] (which added support for sub-classed mathutils types)
tp_alloc was called which defaults to PyType_GenericAlloc which always
GC tracked the resulting object when Py_TPFLAGS_HAVE_GC was set.

Avoid using PyType_GenericAlloc unless the type is sub-classed,
in that case the object is un-tracked.

Add asserts that the tracked state is as expected before tracking &
un-tracking, to ensure changes to object creation don't cause objects
to be tracked unintentionally.

Also assign the PyTypeObject.tp_is_gc callback so types optionally GC
track objects only do so when an object is referenced.

[0]: fbd9364944
2022-09-28 17:53:30 +10:00
ada2b9f6e4 Fix T101341: make nodegroups active input/output non-animatable
Active UI list index is usually not animatable.
Here specifically, the active list index is oly used for operators acting
on a specific (active) socket.

Note other props here were already made non-animatable in
rB1d3b92bdeabc.

Maniphest Tasks: T101341

Differential Revision: https://developer.blender.org/D16077
2022-09-28 08:47:08 +02:00
788f3d72cf Fix Python module test failing with macOS + address sanitizer
Based on patch by Ankit Meel.

Ref D10877
2022-09-28 03:01:47 +02:00
5beaecb33e Fix T101414: in 3d viewport, smart uv project failed to pack
Regression from https://developer.blender.org/rBa5c696a0c2b9
2022-09-28 12:42:49 +13:00
6d1d1bf2b1 Cleanup: spelling in comments
Also add missing task ID.
2022-09-28 09:41:31 +10:00
72a7f107d8 Cleanup: format 2022-09-28 09:41:28 +10:00
6f9b84c5ce Cleanup: compiler warnings 2022-09-28 09:41:28 +10:00
552561d46e Correct sign conversion errors in convexhull_2d.c 2022-09-28 09:36:15 +10:00
5c93c37678 Cleanup: improve 2D convex hull
Improve correctness, API, comments, memory usage and performance
of the 2D convex hull calculation.

Pre-requisite for UV packing improvements.

Differential Revision: https://developer.blender.org/D16055
2022-09-28 12:24:16 +13:00
2ead05d738 Cycles: Add optional per-kernel performance statistics
When verbose level 4 is enabled, Blender prints kernel performance
data for Cycles on GPU backends (except Metal that doesn't use
debug_enqueue_* methods) for groups of kernels.
These changes introduce a new CYCLES_DEBUG_PER_KERNEL_PERFORMANCE
environment variable to allow getting timings for each kernels
separately and not grouped with others. This is done by adding
explicit synchronization after each kernel execution.

Differential Revision: https://developer.blender.org/D15971
2022-09-27 22:15:00 +02:00
b145cc9d36 Cleanup: Unused variable warning with path guiding turned off 2022-09-27 15:00:37 -05:00
f2bad0e49f Fix T101348: Sculpt smooth brush artifacts with hidden faces
The brush mixed up the vert and poly hide layers.
2022-09-27 14:50:07 -05:00
aa58f58e46 Fix: Assert in legacy mesh conversion
When setting the old face set custom data type, do it in the
"layers to write" vector instead of the mesh's poly custom
data layers, which weren't "prepared" yet. Otherwise this
could make the mesh's custom data typemap invalid.
2022-09-27 14:50:07 -05:00
2f0c40c7a2 Cleanup: Use signed integers for mesh vertex indices 2022-09-27 14:50:07 -05:00
b6ee599d92 Cleanup: Use variable and const for sculpt mesh vertex to poly maps 2022-09-27 14:50:07 -05:00
Pablo Vazquez
f69aaf71f8 WM: Support opening backup .blend files via drag-drop
Add support for opening Blender backup `.blend` files (`.blend1`, `.blend2`, etc) by dropping them into the window, just like regular .blend files.

{F13393482, size=full}

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D15700
2022-09-27 19:19:29 +02:00
447368b472 Fix: OpenPGL related build error on windows
Debug and Release libs are different libs on
Windows and will give linker errors when you
try to mix and match them.

This changes retrieves both libs and fills the
OPENPGL_LIBRARIES variable appropriately resolving
the linker error.
2022-09-27 10:48:09 -06:00
Michael Jones
2b88ee50fb Cycles: Tweak inlining policy on Metal
This patch optimises the Metal inlining policy. It gives a small speedup (2-3% on M1 Max) with no notable compilation slowdown vs what is already in master. Previously noted compilation slowdowns (as reported in T100102) were caused by forcing inlining for `ccl_device`, but we get better rendering perf by relying on compiler heuristics in these cases.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16081
2022-09-27 17:01:28 +01:00
fc604a0be3 Cycles: Disable binary archives on macOS < 13.0
An bug with binary archives was fixed in macOS 13.0 which stops some spurious kernel recompilations. In older macOS versions, falling back on the system shader cache will prevent recompilations in most instances (this is the same behaviour as in Blender 3.1.x and 3.2.x).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16082
2022-09-27 16:58:21 +01:00
Aleš Jelovčan
b0d70a9c80 Gpencil: Time Offset modifier new Chain mode
This patch adds 5th mode to Time offset modifier, which should allow 
to create time segments list.

This will allow users to chain together multiple time ranges in 4 modes:

- Forward
- Backwards
- Pingpong
- Reverse  Pingpong

It also comes with additional Repeat parameter which specifies number 
of times particular segment should run.

The mechanic of it is transforming initial parameters into array of frames which 
are mapped to existing cfra (current frame) value.
Prototype : https://jsfiddle.net/ha2sjw8p/3/

This is also closely aligned to community request: 
https://blender.community/c/rightclickselect/Txhbbc/

This should allow creation of complex animations like dancing, 
which consists of repeating loops and transitions to the next.
One important side effect of this is dramatically reduced 
file sizes, as user no longer needs to copy paste keyframes.

Reviewed By: antoniov, mendio, pepeland

Differential Revision: https://developer.blender.org/D15052
2022-09-27 17:55:43 +02:00
12fdf9069a BLF: Editing Text with Combining Characters
Corrections for caret insertion & movement and deletion for text
strings that include non-precomposed diacritical marks (Unicode
combining characters).

See D15659 for more details and examples.

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

Reviewed by Campbell Barton
2022-09-27 08:40:36 -07:00
697e86a761 View3D: move view3d_draw.c to c++ 2022-09-27 17:38:23 +02:00
5f7259a001 GPencil: New Outline modifier
This modifier converts any stroke (no fill strokes) into perimeter
from camera view.  Also, it's possible to define an alternative 
material for the outline.

There is an option to include a target object to manipulate the start 
point of the strokes. The start point will be the nearest point 
to the target object.

Reviewed By: mendio, frogstomp

Maniphest Tasks: T100826

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

Note: Icon will be updated in T101155
2022-09-27 16:43:20 +02:00
Sebastian Herhoz
75a6d3abf7 Cycles: add Path Guiding on CPU through Intel OpenPGL
This adds path guiding features into Cycles by integrating Intel's Open Path
Guiding Library. It can be enabled in the Sampling > Path Guiding panel in the
render properties.

This feature helps reduce noise in scenes where finding a path to light is
difficult for regular path tracing.

The current implementation supports guiding directional sampling decisions on
surfaces, when the material contains a least one diffuse component, and in
volumes with isotropic and anisotropic Henyey-Greenstein phase functions.

On surfaces, the guided sampling decision is proportional to the product of
the incident radiance and the normal-oriented cosine lobe and in volumes it
is proportional to the product of the incident radiance and the phase function.

The incident radiance field of a scene is learned and updated during rendering
after each per-frame rendering iteration/progression.

At the moment, path guiding is only supported by the CPU backend. Support for
GPU backends will be added in future versions of OpenPGL.

Ref T92571

Differential Revision: https://developer.blender.org/D15286
2022-09-27 15:56:32 +02:00
6d19da0b2d Cycles: BSDF eval refactor to remove separate reflection/refraction methods
Simplifies code overall to do it inside the eval function, most of the BSDFs
already compute the dot product.

The refactoring in bsdf_principled_hair_eval() was needed to avoid a HIP
compiler bug. Cause is unclear, just changing the implementation enough
is meant to sidestep it.

Ref T92571, D15286
2022-09-27 15:56:28 +02:00
Sebastian Herhoz
bd249eb4f3 Cycles: BSDF changes in preparation of path guiding
* Return roughness and IOR for BSDF sampling
* Add functions to query IOR and label for given BSDF
* Default IOR to 1.0 instead of 0.0 for BSDFs that don't use it
* Ensure pdf >= 0.0 in case of numerical precision issues

Ref T92571, D15286
2022-09-27 15:47:03 +02:00
Germano Cavalcante
715c86d9e5 Fix T101231: Console flooded with warnings when fluid type is Domain
Although rB67e23b4b2967 turned the problem more recurrent, the warning
messages in the console always appear when `BKE_fluid_cache_free_all`
is called.

This is because of a bug in `BLI_filelist_dir_contents` as this function
calls `BLI_strdupcat` instead of `BLI_join_dirfile`

NOTE: Other places in Blender avoid this problem by making sure to add
a `SEP_STR` to the end of the directory.

Differential Revision: https://developer.blender.org/D16043
2022-09-27 10:17:29 -03:00
f3a46e2fd9 Deps: fix builing wayland-scanner
- fix the source package download URL
- patch the `meson.build` file to allow the CentOS 7 meson version to be
  used
- only build what we need (`wayland-scanner`), and not the libraries,
  documentation, and tests.

Ref: D16074

This also reverts commit f6664217b3
"Build: temporarily disable wayland dependency".
2022-09-27 15:11:57 +02:00
0084b8635f Fix T101398: Transfer Attribute node still defined in menu
Removing this item was missed in 837144b457.
2022-09-27 07:49:21 -05:00
ed28ba4e99 Fix T101393: Vertex Crease operator does not create vertex crease layer
Typo in rBa8a454287a27 (created layer on edge data instead of vertex
data).

Maniphest Tasks: T101393

Differential Revision: https://developer.blender.org/D16079
2022-09-27 14:38:48 +02:00
f6664217b3 Build: temporarily disable wayland dependency
This caused problems on centos7, see D16074 for details.
2022-09-27 22:28:55 +10:00
1cbfe04638 Fix: GPencil animated layer transforms evaluate wrong when identity
Due to (optimization) checks in in `BKE_gpencil_prepare_eval_data` &
`BKE_gpencil_update_layer_transforms`, updates were skipped if animation
reached exact identity transforms.

Now check if the matrix has changed additionally to gain proper updates.
Unsure if this is the cheapest way to check for the animated state of
layer transforms tbh, but I see similar checks elsewhere.

Fixes T101164.

Maniphest Tasks: T101164

Differential Revision: https://developer.blender.org/D16018
2022-09-27 12:29:07 +02:00
30113e54d2 Fix curves sculpting in deformed space when using Subdivide node
Needs a call to remember_deformed_curve_positions_if_necessary, missed
in rB1f94b56d7744.

Thx @JacquesLucke for the solution!

Differential Revision: https://developer.blender.org/D16078
2022-09-27 11:59:56 +02:00
4a60c4746d Fix T101272: Missing view layer updates handling collections via python.
Fixed by ensuring the view layer is up to date.
2022-09-27 11:57:34 +02:00
cbab734445 Build: add wayland to deps build
This is needed to ensure and up to date "wayland-scanner" is used,
as versions before 1.20.0 generate headers incompatible with
dynamic linking (WITH_GHOST_WAYLAND_DYNLOAD).

As the centos7 version of wayland is 1.15 so make this part of Blender's
dependencies on Linux.

We intend to enable Wayland for Blender 3.4 release, this is needed for
the build-bot.

Reviewed By: brecht

Ref D16074
2022-09-27 19:22:07 +10:00
5f6d66c1c5 Cleanup: Fix brace-scalar-init warning 2022-09-27 10:19:12 +02:00
b6a7541f87 GHOST: exit with an error when GHOST cannot be initialized
When the GHOST back-end Blender was built with isn't supported,
Blender would crash on startup without any useful information.
This could happen when building X11 only, then running on Wayland.

Now show a list of the GHOST back-ends that were attempted and exit
with an error code instead of crashing.
2022-09-27 17:14:32 +10:00
78952518e7 Cleanup: format 2022-09-27 16:36:27 +10:00
Iyad Ahmed
cd7ec0dac6 WM: batch rename action clips
Batch rename for action clips works in outliner and 3d view.

Reviewed By: campbellbarton

Ref D15819
2022-09-27 12:13:08 +10:00
2edb8ab739 Revert "Cleanup: remove redundant WITH_GHOST_WAYLAND check"
This reverts commit 7fa7c7ceda.

The check was not redundant, it accounted for wayland not being found.
2022-09-27 11:53:12 +10:00
4e1d32107b Build: add missing include for opencolorio
OpenColorIO failed to build on Linux+GCC-12.2 because of strlen() use.
2022-09-27 11:21:35 +10:00
7fa7c7ceda Cleanup: remove redundant WITH_GHOST_WAYLAND check 2022-09-27 09:14:24 +10:00
Iliya Katueshenock
8da253cfb6 Fix T101361: Collapsed multi-input sockets not collapsing noodles
Caused by 40d815dff6, which removed the check for "hidden" nodes.

Differential Revision: https://developer.blender.org/D16061
2022-09-26 18:10:27 -05:00
dcd909122f Scew Modifier: Remove eager normal calculation
The screw modifier calculated normals eagerly (whether or not the
next modifier actually used them). However, this was incorrect and
set invalid normals. It isn't necessary because they can be calculated
later anyway. The potential performance improvement isn't worth the
complexity or maintenance burden.

Fixes T101075

Differential Revision: https://developer.blender.org/D16073
2022-09-26 17:59:44 -05:00
722b850c38 GPU: Fix crash when rendering with compositor using CLI
The backend gets used before it is initialized again.

This is just a workaround for now as production schedule needs ir.
2022-09-27 00:53:56 +02:00
408a8edf89 Cleanup: remove unnecessary argument to else() in CMake
We have moved away from duplicating arguments in else() and endif()
commands.
2022-09-27 08:49:51 +10:00
b77ad0c82d Cleanup: correct indentation of harvest.cmake 2022-09-27 08:48:28 +10:00
cd1caa5853 GPU: Revert part of D16017 that was accidentally commited
This code slipped through the final review step surely caused by a faulty
merge.

Fixes T101372 Regression: World shader setup crashes Blender in rendered view

Regression introduced by rB697b447c2069bbbbaa9929aab0ea1f66ef8bf4d0
2022-09-27 00:00:28 +02:00
Sebastian Herhoz
66a863e301 Build: add OpenPGL as to deps builds
Ref T92571, D15286
2022-09-26 23:40:33 +02:00
bcb7b119ae Cleanup: remove workarounds and version checks for unsupported compilers
Match minimum supported versions from the WIKI [0] by raising them to:

- GCC 9.3.1
- CLANG 8.0
- MVCS 2019 (16.9.16 / 1928)

Details:

- Add CMake checks that ensure supported compiler versions early on.
- Previously GCC per-processor version checks served to exclude
  `__clang__`, in some cases this has been replaced by explicitly
  excluding `__clang__`. This was needed as CLANG treated some of these
  flags differently to GCC, causing the build to fail.
- Remove USE_APPLE_OMP_FIX GCC-4.2 OpenMP workaround.
- Remove linking error workaround for old MSVC versions.

[0]: https://wiki.blender.org/wiki/Building_Blender

Reviewed by: brecht, LazyDodo

Ref D16068
2022-09-27 07:05:13 +10:00
cd7e9a1ad5 Cleanup: use the system-handle arg for GHOST_SetMultitouchGestures
There was an unused argument warning, quiet by using the argument.
2022-09-27 07:05:13 +10:00
84ddb8b3cc UI: add preference to disable touchpad multitouch gestures
Available on Windows and macOS, where such gestures are supported.
For Windows, disabling this option restores touchpad behavior to
match Blender 3.2.

Ref T97925

Differential Revision: https://developer.blender.org/D16005
2022-09-26 22:59:35 +02:00
57ea827bfb Fix: Incorrect handling for crease layers
First, there can only be one crease layer, so remove the "default name",
since apparently that's how CustomData tests for that
(see `CustomData_layertype_is_singleton`).

Second, always propagate crease data because it can be used in arbitrary
situations by geometry nodes. That also has to be done for all generic
attribute layers.

Fixes T101340, T101373
2022-09-26 15:42:29 -05:00
8d49a4f36e Fix T101365: saving second view layer as (non-Multilayer) OpenEXR does not work 2022-09-26 22:24:39 +02:00
d4fc451b90 Fix T101354: Cycles crash with baking and adaptive sampling 2022-09-26 22:16:01 +02:00
ddf6f70049 Fix build errors and warnings after recent changes, when not using Unity build 2022-09-26 21:12:25 +02:00
c15a761524 Geometry Nodes: Miscellaneous changes in control point neighbors node
- Use const and whitespace more consistently
- Fix "Offset Valid" output only working on point domain
- Use the smallest output array that can contain the result.
- Consistent include ordering
- Use "data-block" term instead of "object" in tooltip
- Remove unnecessary call to set default output values
2022-09-26 13:23:07 -05:00
837144b457 Nodes: Use plain menus for geometry nodes add menu
At the cost of slightly more boilerplate code, we can avoid the `NodeItem`
and `NodeCategory` abstractions used to build the node add menu.
This makes the menus more flexible and more obvious, which will
make them easier to extend with assets.

The identifiers for the new menu types are inconsistent with regular
class naming for backwards compatibility with the old "category"
menu naming.

Also adds an item for the "Self Object" node missed in dd5131bd70.

Differential Revision: https://developer.blender.org/D15973
2022-09-26 13:10:42 -05:00
8a6dc0fac7 Geometry Nodes: Control Point Neighbors Node
This node allows access to the indices of neighboring control points
within a curve via an offset. This includes taking into consideration
curves that are cyclic.

Differential Revision: D13373
2022-09-26 13:03:28 -05:00
46cfd345e4 Fix typo and and incorrect property initialization
Error in rB236fda7faf58
2022-09-26 14:23:11 -03:00
236fda7faf Fix T101343: useless Snapping menu in transform operators
Changes:
- Use the "snap_elements" property only for operators that support snapping to geometry.
- Remove unused properties:
  - "use_snap_to_same_target",
  - "snap_face_nearest_steps").
- Fix property with wrong name "use_snap_selectable_only" -> "use_snap_selectable"
- Fix use of dependent property flags.
- Remove redundant initialization of variables
- Simplify `poll_propety`. Only the "use_snap_project" is not hidden.

>>! In rBc484599687ba it's said:
>  These options are needed for Python tools to control snapping without requiring the tool settings to be adjusted.
If that's the case, there doesn't seem to be any need to display them in the redo panel.  Therefore:
- Hide snapping properties in redo panel.

Many properties have been added that can be independent of ToolSettings. Therefore:
- Save snapping properties in the operator itself. For Redo.
2022-09-26 14:18:39 -03:00
125ac1f914 Cycles: increase min-supported driver version for Intel GPUs
Windows drivers 101.3430 fix an important GUI-related crash and it's
best to prevent users from running into it.
Linux drivers weren't affected but still had relevant gpu binary
compatibility fixes, so it makes sense to keep the min-supported version
aligned across OSes.
2022-09-26 07:41:47 -07:00
Angus Stanton
2522ca03d2 Asset Browser: Add slider UI to pose blending
Add the Slider UI to pose blending. This adds a slider with percentages,
and controls for precision control and incremental control.

Reviewed By: sybren

Maniphest Tasks: T90182

Differential Revision: https://developer.blender.org/D14984
2022-09-26 16:21:00 +02:00
2356afc7af Cleanup: format, ensure trailing newlines 2022-09-26 21:52:40 +10:00
03eac69c61 Cleanup: restore parenthesis removed in recent commit
Partial revert [0], removed by accident because the -fpermissive
flag was enabled with collada.

[0]: 34477bbfcd
2022-09-26 21:51:43 +10:00
b211540783 Fix: bump subversion to avoid corrupted files
Replacing the transfer node breaks forward compatibility, so a version
bump is necessary to get a warning in older versions.
2022-09-26 12:06:54 +02:00
fa1c214c5b Fix crash in Solidify modifier with Inner Crease
Since a8a454287a the simple case would crash:

- Add place
- Add Solidify modifier
- Set Inner Crease to something non-zero

Seems to be a mistake in the logic which was trying to access
existing custom data layer on a clean result while it is more
logical to create the layer.

Was initially reported by the studio who could not open
production files after the change.
2022-09-26 11:55:34 +02:00
530b9841ee Fix T101370: GPencil Grab Sculpt crash after bake transform animation
The problem was the duplicated strokes had wrong pointers 
to the original stroke.
2022-09-26 11:09:49 +02:00
333e41eac6 Cleanup: replace C-style casts with functional casts for numeric types
Use function style casts in C++ headers & source.
2022-09-26 17:58:36 +10:00
0210c4df17 GPU: Disable SSBO support from commandline.
In heavy scenes containing many hairs/curves and volumetrics
using SSBO can overwrite the binding information of the volumetric
resolve shader. This has been detected during project Heist and is
only reproducable on NVIDIA platform.

This patch adds an debug option to disable SSBOs from the command
line to replace the --debug-gpu-force-workarounds that has been
used as a workaround on the render farm. Reason is that
force workarounds will also add other limitations as well (number
of texture binds for example)
2022-09-26 09:41:50 +02:00
6075b04cf9 System info: Added GPU device type and feature support.
Adds more information to System info to help triaging/debugging.
2022-09-26 08:36:05 +02:00
267aee514a Python: Add platform feature support methods to gpu.capabilities module.
Depending on the actual platform, Blender will disable features that are
known to have a faulty implementation. Add-on developers or users don't
have the ability to check what is actually enabled.

This patch will add the ability to check for

* Compute shader support `gpu.capabilities.compute_shader_support_get()`.
* SSBO support `gpu.capabilities.shader_storage_buffer_objects_support_get()`.
* Image load/store `gpu.capabilities.shader_image_load_store_support_get()`.
2022-09-26 08:19:44 +02:00
b4605f6158 Console: Add gpu python module to list of internal modules.
The python GPU module was not mentioned in the list of internal
modules. Adding the GPU module to the list allows curious users
to find it.
2022-09-26 08:18:17 +02:00
34477bbfcd Cleanup: remove redundant parenthesis 2022-09-26 14:23:52 +10:00
6275541df7 Cleanup: use ELEM/STR_ELEM/STREQ macros 2022-09-26 14:12:38 +10:00
96d88e5614 CMake: remove workaround for GCC 4.5 as 9.3.1 is the minimum version
The -fpermissive flag is best avoided as it suppresses some important
warnings/errors.
2022-09-26 11:52:21 +10:00
20276191e5 Cleanup: fix warning in recent parenthesis removal
Regression in [0], this slipped through due to "-fpermissive"
being added to GCC flags, suppressing the error.

[0]: c9e35c2ced
2022-09-26 11:39:24 +10:00
3961d3493b Cleanup: use 'u' prefixed integer types for brevity in C code
This also simplifies using function style casts when moving to C++.
2022-09-26 11:33:22 +10:00
3a7dc572dc Cleanup: use 'u' prefixed unsigned types for GHOST 2022-09-26 10:52:52 +10:00
5b320e5a24 Fix undefined 'uint' for macOS/WIN32 2022-09-26 10:42:47 +10:00
8a68f4f808 Cleanup: replace unsigned with uint, use function style casts for C++ 2022-09-26 10:09:15 +10:00
15f3cf7f8f Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb0.
2022-09-26 09:53:49 +10:00
e746999aa9 Fix T101309: crash when executing geometry nodes without logger 2022-09-25 23:07:29 +02:00
b3714b1e85 BLF: Refactor of blf_font_boundbox_foreach_glyph
Refactor of `BLF_boundbox_foreach_glyph` and simplification of its
usage by only passing translated glyph bounds to callbacks.

See D15765 for more details.

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

Reviewed by Campbell Barton
2022-09-25 11:25:31 -07:00
c8ee70c962 Geometry Nodes: decentralize implicit input definitions
Previously, all implicit inputs where stored in a centralized place.
Now the information which nodes have which implicit inputs is
stored in the nodes directly.
2022-09-25 19:16:53 +02:00
2fd63efd0e BLI: simplify removing elements from containers with predicate
Previously removing elements based on a predicate was a bit cumbersome,
especially for hash tables. Now there is a new `remove_if` method in some
data structures which is similar to `std::erase_if`. We could consider adding
`blender::erase_if` in the future to more closely mimic the standard library,
but for now this is using the api design of the surrounding code is used.
2022-09-25 17:57:49 +02:00
c6e70e7bac Cleanup: follow C++ type cast style guide in some files
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast

This was discussed in https://devtalk.blender.org/t/rfc-style-guide-for-type-casts-in-c-code/25907.
2022-09-25 17:39:45 +02:00
0419ee871f Cleanup: remove redundant parenthesis (especially with macros) 2022-09-25 22:41:22 +10:00
21d77a417e Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb0.
2022-09-25 22:31:31 +10:00
d35a10134c Cleanup: Remove commented lines 2022-09-25 12:31:05 +02:00
b6adca3280 Fix T101317: GPencil separate Active layer freezes blender
The error occurs only when the layer is empty.
2022-09-25 12:26:59 +02:00
f68cfd6bb0 Cleanup: replace C-style casts with functional casts for numeric types 2022-09-25 20:17:08 +10:00
c7b247a118 Cleanup: replace static_casts with functional casts for numeric types 2022-09-25 18:31:10 +10:00
891949cbb4 Cleanup: use 'u' prefixed integer types for brevity & cast style
To use function style cast '(unsigned char)x' can't be replaced by
'unsigned char(x)'.
2022-09-25 18:26:27 +10:00
c9e35c2ced Cleanup: remove redundant double parenthesis 2022-09-25 15:34:32 +10:00
865894481c Cleanup: quiet compiler warning 2022-09-25 15:26:30 +10:00
26f330ea4c Cleanup: format, spelling in comments 2022-09-25 15:24:37 +10:00
4e7983e073 UI: Improved Font Thumbnails
Thumbnails of fonts that better show design, shapes, contents, intent,
and intended language. Previews almost every known language - living
and dead - and symbol, specialty fonts, etc.

See D12032 for more details and samples.

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

Reviewed by Campbell Barton
2022-09-24 10:57:34 -07:00
2ff5d42cd3 Sculpt: Fix bug with allocating duplicate attribute layers
Sculpt attribute API was incorrectly allocating duplicate
attribute layers.
2022-09-24 10:04:28 -07:00
72933ebe96 BLF: Correctly Set Default Font Size
Commit cd1631b17d fails to scale the global_font_size by UI scale in
BLF_set_default. Generally used for simple text output like statistics.

See D16053 for more details.

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

Own Code
2022-09-24 08:23:36 -07:00
1b46d57f67 Fix: Invalid CustomData type map created for legacy mesh conversion
Caused by 060a534141.
2022-09-24 09:37:30 -05:00
535f50e5a6 Curves: Use early out when apapting domain of single value
When adapting the domain of a single value virtual array, skip
allocating an array for the result and just return another single
value. Among other cases, this can help when everything is selected
in sculpt mode, moving domain interpolation from 5% of perf samples
to 0% when sculpting.
2022-09-24 09:31:15 -05:00
c25df02ac3 Cleanup: simplify accessing mesh looptris 2022-09-24 11:41:08 +02:00
8422da13c9 GPencil: Exist early from loop for Fill extensions
It does not need follow in the loop if a collision was found.
2022-09-24 11:18:39 +02:00
f416a76bcd Cleanup: typo in static node type 2022-09-24 10:33:17 +02:00
cd1631b17d BLF: Refactor of DPI
Correction of U.dpi to hold actual monitor DPI. Simplify font sizing by
omitting DPI as API argument, always using 72 internally.

See D15961 for more details.

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

Reviewed by Campbell Barton
2022-09-23 17:36:49 -07:00
88a602bc64 Fix build error in blenloader on macOS after recent changes 2022-09-24 01:21:26 +02:00
ff27b68f41 Fix T101295: Allow Large Windows Thumbnails
Allow our Windows Thumbnail Handler to supply thumbnails up to the
maximum 256x256 size.

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

Reviewed by Ray Molenkamp
2022-09-23 14:49:36 -07:00
ce63fea080 Cleanup: Remove unused data transfer function 2022-09-23 16:30:25 -05:00
1b5c94630e GPU: Disable static compilation for geometry shaders workaround
These shaders are only supported by the Metal backed.
Regression introduced by 1514e1a5b7
2022-09-23 23:27:42 +02:00
fd2668a368 Overlay: Fix overlay image shaders
Regression introduced in 18b45aabf9.
Caused by a bad merge.
2022-09-23 23:27:42 +02:00
c2a21dfb77 Sculpt: fix memory corruption in new attribute api 2022-09-23 14:16:11 -07:00
7e980f2b8c Fix T101249: Node groups don't show in node search
bdb5754147 neglected to add search items for node groups.
Luckily adding them is quite simple. However, if the node group is also
an asset, it will show up duplicated in the list. To resolve this we
avoid adding node groups to the list if they have already been
added as assets.
2022-09-23 14:25:25 -05:00
dedc679eca Geometry Nodes: Split transfer attribute node
This patch replaces the existing transfer attribute node with three
nodes, "Sample Nearest Surface", "Sample Index", and "Sample Nearest".
This follows the design in T100010, allowing for new nodes like UV
sampling in the future. There is versioning so the new nodes replace
the old ones and are relinked as necessary.

The "Sample Nearest Surface" node is meant for the more complex
sampling algorithms that only work on meshes and interpolate
values inside of faces.

The new "Sample Index" just retrieves attributes from a geometry at
specific indices. It doesn't have implicit behavior like the old
transfer mode, which should make it more predictable. In order to not
change the behavior from existing files, the node has a has a "Clamp",
which is off by default for consistency with the "Field at Index" node.

The "Sample Nearest" node returns the index of the nearest element
on a geometry. It can be combined with the "Sample Index" node for
the same functionality as the old transfer node. This node can support
curves in the future.

Backwards compatibility is handled by versioning, but old versions can
not understand these nodes. The warning from 680fa8a523 should make
this explicit in 3.3 and earlier.

Differential Revision: https://developer.blender.org/D15909
2022-09-23 13:56:35 -05:00
d5554cdc7c Fix T100741: Update FFMPEG Dimensions
Update the animation's dimensions within ffmpeg_fetchibuf in case it
has changed because of dynamic resolution (possible with WebM).

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

Reviewed by Richard Antalik
2022-09-23 10:50:05 -07:00
d12f0d3f70 Fix: Crash with empty vertex group in mask modifier
The C++ vertex group data accessor returned a span with null data that
wasn't empty. Instead of adding a null check as well as the size check,
just return an empty span when there is no vertex group data.
2022-09-23 12:32:08 -05:00
392855ce50 GPencil: Improve Fill Tool Extend lines
* Improve how the extend lines collision is calculated.
* Added `S` key to switch between modes.
*  Now extend factor does not disable visual aids (thi sis done with checkbox).
* Reduce the use of linked list and now memory array is used.
* Refactor Radius functions.
* Fixed bug of Radius mode when object is rotated.
* Cleanup code.

Differential Revision: https://developer.blender.org/D16022
2022-09-23 19:29:02 +02:00
2d8eadacf9 Fix: Missing DNA rename for recent mesh refactor
12becbf0df changed to `flag_legacy` but didn't use a rename.
2022-09-23 12:13:25 -05:00
67308d73a4 Node Editor: Adjust node link curving
Clamp node link curving when the link is close to horizontal to prevent
overshooting at the ends.

Reviewed By: Pablo Vazquez, Hans Goudey

Differential Revision: http://developer.blender.org/D16041
2022-09-23 18:13:45 +02:00
2438f76d6f Fix: Assert calculating mesh triangulation
The condition from 0d7d8c73cf was reversed.
2022-09-23 10:45:07 -05:00
12becbf0df Mesh: Move selection flags to generic attributes
Using the attribute name semantics from T97452, this patch moves the
selection status of mesh elements from the `SELECT` of vertices, and
edges, and the `ME_FACE_SEL` of faces to generic boolean attribute
Storing this data as generic attributes can significantly simplify and
improve code, as described in T95965.

The attributes are called `.select_vert`, `.select_edge`, and
`.select_poly`. The `.` prefix means they are "UI attributes",so they
still contain original data edited by users, but they aren't meant to
be accessed procedurally by the user in arbitrary situations. They are
also be hidden in the spreadsheet and the attribute list.

Until 4.0, the attributes are still written to and read from the mesh
in the old way, so neither forward nor backward compatibility are
affected. This means memory requirements will be increased by one byte
per element when selection is used. When the flags are removed
completely, requirements will decrease.

Further notes:
* The `MVert` flag is empty at runtime now, so it can be ignored.
* `BMesh` is unchanged, otherwise the change would be much larger.
* Many tests have slightly different results, since the selection
  attribute uses more generic propagation. Previously you couldn't
  really rely on edit mode selections being propagated procedurally.
  Now it mostly works as expected.

Similar to 2480b55f21
Ref T95965

Differential Revision: https://developer.blender.org/D15795
2022-09-23 10:45:07 -05:00
e345686cb7 View3d: move space_view3d.c to c++ 2022-09-23 16:51:29 +02:00
63bdd89108 Cleanup: use depsgraph iterator settings in rna
Somehow missed this as part of rBb197cd5821f1dfaa5168d31984dd8014f5252456.
2022-09-23 16:12:59 +02:00
a8a454287a Mesh: Move edge crease out of MEdge
This is very similar to D14077. There are two differences though.
First is that vertex creases are already stored in a separate layer,
and second is that we can now completely remove use of `Mesh.cd_flag`,
since that information is now inherent to whether the layers exist.

There are two functional differences here:
 * Operators are used to add and remove layers instead of a property.
 * The "crease" attribute can be created and removed by geometry nodes.

The second change should make various geometry nodes slightly faster,
since the "crease" attribute was always processed before. Creases are
now interpolated generically in the CustomData API too, which should
help maintain the values across edits better.

Meshes get an `edge_creases` RNA property like the existing vertex
property, to provide more efficient access to the data in Cycles.

One test failure is expected, where different rounding between float
the old char storage means that 5 additional points are scattered in
a geometry nodes test.

Differential Revision: https://developer.blender.org/D15927
2022-09-23 09:02:28 -05:00
b197cd5821 Cleanup: use depsgraph iterator settings in rna
This was missing in rBe5d4afd5bac71e29ba71ecf091feaa0d70b70260.
2022-09-23 15:49:12 +02:00
0d7d8c73cf Mesh: Use cached looptris in draw cache extraction
The mesh's triangulation cache is often created for other operations
besides the drawing code, but during the mesh draw cache extraction
it is recalculated on every single time. It is simpler and faster to use
the existing MLoopTri array. It can also save memory if the cache
already exists by avoiding allocating a duplicate array. For a 4 million
face quad mesh, that is already 128 MB.

Also use face normals for mesh triangulation if they aren't dirty,
which should provide a general speedup when they're both necessary.

Recently 54182e4925 made this more reliable, since the triangulation
cache is invalidated properly when the mesh is deformed.

Fixes T98073

Differential Revision: https://developer.blender.org/D15550
2022-09-23 08:23:35 -05:00
060a534141 Mesh: Move sculpt face sets to a generic attribute
Similar to the other refactors from T95965, this commit moves sculpt
face sets to use a generic integer attribute named `".sculpt_face_set"`.
This makes face sets accessible in the Python API.

The attribute is not visible in the attributes list or the spreadsheet
because it is meant for internal use, though that could be an option
in the future along with other similar attributes. Currently the change
is small, but in the future this could simplify code by allowing use
of more generic attribute APIs.

Differential Revision: https://developer.blender.org/D16045
2022-09-23 08:19:40 -05:00
35375380d7 Cleanup: Grammar fix in lazy function 2022-09-23 08:05:44 -05:00
998fc4f8f6 Cleanup: fix compiler errors 2022-09-23 14:45:25 +02:00
f2b5fd0a0e Cleanup: give anonymous enum a name 2022-09-23 12:48:22 +02:00
e5d4afd5ba Depsgraph: generalize passing parameters to depsgraph object iterator
This makes it easier to pass more parameters to the iterator in the future.

Differential Revision: https://developer.blender.org/D16047
2022-09-23 12:41:22 +02:00
eb54502d9d Fix T101109: Animation on nodes problems when dealing with Node Groups
Whenever animation on nodes was transfered to/from nodegroups (grouping/
ungrouping/separating) via BKE_animdata_transfer_by_basepath, it was
possible to create new nodes with the same name (in the formerly same
path -- see report for an example of this) and animation from the
original node was still performed on them. Issue went away after save/
reload.

In order to fully update the action, a depsgraph is now performed on the
action (similar to what is done when renaming for example).

Maniphest Tasks: T101109

Differential Revision: https://developer.blender.org/D15987
2022-09-23 12:06:32 +02:00
c350d97a2f Fix T101046: missing DEG update changing bone layers in editmode
Following {T54811} (and {rBbb92edd1c802}), DEG updates have been added
to the various operators. This has also been done for the layers
operators (see {rBf998bad211ae}, `ARMATURE_OT_bone_layers` has been
marked done in T54811). However, instead of `ARMATURE_OT_bone_layers`,
the update tagging actually happened for `POSE_OT_bone_layers`.

Now do this for `ARMATURE_OT_bone_layers` as well (keep it for
`POSE_OT_bone_layers`, dont think this is wrong there either).

Maniphest Tasks: T101046

Differential Revision: https://developer.blender.org/D15969
2022-09-23 12:06:02 +02:00
fbd78a8d78 Cleanup: use ELEM macro 2022-09-23 15:29:21 +10:00
c655bdfa31 Cleanup: add string utility macros to GHOST/Wayland
Use STREQ for readability.
2022-09-23 15:28:48 +10:00
77ed4651ee Cleanup: float literals 2022-09-23 15:28:48 +10:00
0f6d5c9a9d Docs: minor improvements to info_advanced_blender_as_bpy wording 2022-09-23 15:04:02 +10:00
c172522060 Fix T100141: Header Alignment of New Editors
Revert part of [0] which changed logic for scaling 2D regions
when the window resize. This re-introduces T72392 which can be
fixed separately.

[0]: 6243972319
2022-09-23 14:33:51 +10:00
0e94d24080 Cleanup: replace int return value with bool 2022-09-23 14:33:47 +10:00
187d8ba362 Cleanup: avoid unnecessary access to context.space_data 2022-09-23 14:33:46 +10:00
998ace3463 Cleanup: use lowercase function calls & macros in for CMake
This is already the case for most CMake usage.
Although some find modules are an exception to this, as they were
originally maintained externally they use some different conventions.

Also corrected bad indentation in: intern/cycles/CMakeLists.txt
2022-09-23 14:33:44 +10:00
add1b6ab3c Cleanup: spelling in comments 2022-09-23 14:33:43 +10:00
3edd87f009 Cleanup: format 2022-09-23 14:33:42 +10:00
cda2dc721d Cleanup: compiler warnings 2022-09-23 14:33:40 +10:00
e9344d329f Fix: Add missing drag link search item for store named attribute node
The search didn't add an item for the geometry output socket.
2022-09-22 16:54:23 -05:00
319ee296fd Curves editmode: show point selection
Points cannot be selected atm in editmode, this patch just shows the
selection from sculptmode in editmode.

Since the selection in sculptmode is a float, a point is considered
selected as soon as the float selection is above 0.0f.

Implementation: this piggy-back on the existing drawing via
overlay_edit_curve_point.glsl which requires a "data" VBO which holds
flags for selection (next to others such as "active" - which we also
have to take care of later).

Differential Revision: https://developer.blender.org/D16021
2022-09-22 20:23:13 +02:00
Charlie Jolly
680fa8a523 Fix T100846: Bump blender file min version for forward compatibility warning
Also reported in blender.chat.

Corrupted files were reported after opening files with the new Mix node (rBbfa0ee13d539).

Files saved in 3.4 will not be compatible with older versions of Blender.

Opening these files in previous versions will exhibit a red undefined node.

Reviewed By: HooglyBoogly, brecht

Differential Revision: https://developer.blender.org/D16025
2022-09-22 17:08:50 +01:00
Jason Fielder
e8bcca4bdc GPU: Ensure rendering operations occur within GPU render boundaries.
This is required by the Metal backend to perform flushing of temporary objective-C resources. This is implemented as a global autoreleasepool, and is to ensure consistency such that all rendering operations, whether called via events, or via main loop will be within an autoreleasepool.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15900
2022-09-22 18:05:59 +02:00
Jason Fielder
18b45aabf9 Metal: GLSL shader compatibility changes for global uniform and interface name collision.
For the Metal shader translation support for shader-global uniforms are remapped via macro's, and in such cases where a uniform name matches a vertex attribute name, compilation errors will occur due to this injected syntax being incompatible with the immediate code.

Also adding source-level function interface alternatives where sized arrays are passed in. These are not supported directly in Metal shading language and are instead handled as pointers. These pointers require explicit address-space qualifiers in some cases, if device/constant address space memory is passed into the function.

Ref T96261

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15898
2022-09-22 17:53:56 +02:00
Jason Fielder
1514e1a5b7 Metal: First set of Geometry Shader alternative implementations using SSBO vertex shader fetch.
These implementations remove dependency on the Geometry pass by instead invoking one vertex shader instance for each expected output vertex, matching what a geometry shader would emit. Each vertex shader instance is then responsible for calculating the same output position based on its vertex_id as the logic would in the geometry shader version.

SSBO Vertex fetch enables full random-access into a vertex buffer by binding it as a read-only SSBO. This enables each instance to read neighbouring vertex data to perform contextual calculations as a geometry shader would, for cases where attribute Multiload is not supported.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15901
2022-09-22 17:43:04 +02:00
Thomas Dinges
697b447c20 Metal: MTLContext implementation and immediate mode rendering support.
MTLContext provides functionality for command encoding, binding management and graphics device management. MTLImmediate provides simple draw enablement with dynamically encoded data. These draws utilise temporary scratch buffer memory to provide minimal bandwidth overhead during workload submission.

This patch also contains empty placeholders for MTLBatch and MTLDrawList to enable testing of first pixels on-screen without failure.

The Metal API also requires access to the GHOST_Context to ensure the same pre-initialized Metal GPU device is used by the viewport. Given the explicit nature of Metal, explicit control is also needed over presentation, to ensure correct work scheduling and rendering pipeline state.

Authored by Apple: Michael Parkin-White

Ref T96261

(The diff is based on 043f59cb3b)

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15953
2022-09-22 17:32:43 +02:00
Thomas Dinges
bb63b98d1f Metal: MTLVertBuf implementation and support for texture creation from vertex buffers.
Metal: MTLVertBuf implementation and support for texture creation from vertex buffers.

Authored by Apple: Michael Parkin-White

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15452
2022-09-22 17:16:22 +02:00
dd5131bd70 Geometry Nodes: Add Self Object Node
From the nodes' description: "Retrieve the object that contains
the geometry nodes modifier currently being executed". This was
discussed in the most recent geometry nodes module meeting.

Because the node allows you to retrieve the position of the modifier
object, it has to add a depsgraph relation to object transform.
Expect that modifiers will be reevaluated when moving the object.
In the future, better static analysis of node trees could make this
check smarter.

Differential Revision: https://developer.blender.org/D16037
2022-09-22 08:15:03 -05:00
dc06bf2cb6 Fix crash loading fonts that fail to be read
Null pointer dereference since [0] when font's can't be read.

[0]: d39abb74a0
2022-09-22 22:11:09 +10:00
Werner, Stefan
0c824837ab Cycles: Cleanup in oneAPI math includes and definitions
Now explicitly including math.h first before #defining funcitons.
This avoids undefined behavior and improves compatibility with
different SYCL compilers and backends.
2022-09-22 11:33:57 +02:00
75d984a712 Refactor: const-correctness in bmesh conversion assert 2022-09-22 10:33:12 +02:00
c50335b359 UV: add toggle to show the grid over the image
In UV editor, previously unable to see grid and image at same time.

Maniphest Tasks: T78391

Differential Revision: https://developer.blender.org/D16038
2022-09-22 17:20:11 +12:00
3185c3bc74 Cleanup: use an array of modifier keys for GHOST/Wayland
Support iterating over modifiers, instead of using macros.
2022-09-22 13:47:17 +10:00
ef06375159 GHOST: assert when unknown keys are passed to the ModifierKeys API 2022-09-22 13:47:17 +10:00
7ce09ef48f Cleanup: remove unused modifier state checks from getModifierKeys
Also remove unused numpad & caplock key index storage.
2022-09-22 13:47:17 +10:00
967fe75bb6 Cleanup: remove redundant includes from GHOST_SystemPathsUnix 2022-09-22 13:47:17 +10:00
62ffbc7d7f PyGPU: Allow single bool in 'GPUShader.uniform_bool' method
As with the other uniform methods, a single value is expected.
2022-09-21 22:30:57 -03:00
20dc839319 Fix T101262: Crash in spreadsheet selection filter with empty domain
The BMesh selection virtual array was empty. There are a few different
places we could add an "empty" check here, but at the top of the
function is the simplest for now.
2022-09-21 17:34:30 -05:00
77dcfac8a3 Fix: Use correct node group for add node search
Similar to e5a7470638, the tree currently being edited should be
used for polling and other tests, rather than the node tree at the root
of the node editor's path.
2022-09-21 17:12:53 -05:00
3676d6b88d Cleanup: Use const arguments for node group poll function
Also make the disabled hint argument optional.
2022-09-21 17:12:53 -05:00
f42569bb71 Fix EEVEE: Screen Space Refraction Artefacts caused by viewport aspect ratio
This was caused by the vertical/horizontal clasification being done in
NDC space which wasn't respecting the Aspect ratio.

Multiplying the test vector by the target size fixes the issue.
2022-09-21 21:48:23 +02:00
91dd29fd45 Attributes: Allow calling "finish" on empty accessors
This removes some boilerplate when creating many optional attributes.
2022-09-21 13:17:05 -05:00
600c069e0e Attributes: Correct implementation of typed "write_only" method
The typed "lookup_or_add_for_write_only" function is meant to do the
same thing as the non-typed version of the function. Instead, it still
initialized values of new attribute arrays, which isn't meant to happen.

Missed in 4c91c24bc7.

I also had to correct one place that used the "write_only"
function but didn't intialize all values.
2022-09-21 13:10:03 -05:00
a82e52102b Mesh: Avoid uninitialized values when converting BMesh to Mesh
I didn't observe this issue in practice, but since the write_only
version of the attribute API isn't meant to initialize trivial types,
theoretically this could be a problem if the attribute is created
halfway through converting the BMesh to a Mesh.
2022-09-21 12:06:53 -05:00
c1f622e63e Cleanup: Miscellaneous cleanup in distribute points in volume node
- Fix unused variable warning
- Change whitespace
- Use standard variable names
- Use standard method to remove non-pointcloud components
2022-09-21 11:24:37 -05:00
a2966f6477 Fix race condition in memory freeing in edit mesh wrapper to mesh
The BM_mesh_bm_to_me_for_eval() cal be called on the same BMesh
from multiple threads. This adds a restriction that this function
should not modify the BMesh. This started to be violated quite
madly during the generic attributes changes.

This change makes it so that the BMesh is not modified.
The code looks less functional-like, but it solves the threading
conflict.

Ideally the BMesh will be const in the function but doing it now
is a bit tricky due to the other APIs.

The repro case for the crash is a bit tricky to reproduce from
scratch. For those who has access to the Heis production repo
/pro/lib/char/pack_bot/pack_bot.blend file can be used. Simply
add loop to "GEO-leg.R" object and use bevel operator on the
new loop.

There is still some write of the element indices happening in
this function. In theory those could be removed (together with
the dirty index tag clear) but it leads to obscure crashes in
area far away from this one. I've left it unchanged for now as
on 64bit platforms those assignments should not be causing real
issues.

Differential Revision: https://developer.blender.org/D16023
2022-09-21 17:36:42 +02:00
8bffadcdc4 Refactor: Simplify transfer of tags in the depsgraph builder
Base it in an existing building blocks rather than having dedicated
structure for it.

No functional changes is expected, just preparing to make the code
more reusable.
2022-09-21 16:48:48 +02:00
cd3a19f20c Fix inconsistent node name handling in dependency graph
The ID nodes will use the provided component name to maintain
the map-based storage, while the component node itself could
override the empty name with a type name.

This lead to situations when it is not possible to lookup
the operation from its owner parameters.
2022-09-21 16:48:48 +02:00
0ca9b637c5 Refactor: More const-correctness in node builder
Make it so find type of methods receive const pointers and do not
modify graph topology.

The latter was violated in the find_operation() which could have
created an empty component. This is not intended behavior.

No functional changes is expected.
2022-09-21 16:48:48 +02:00
f948ffaa9f Refactor: Move depsgraph node keys to own file
They are not specific to the relations builder and could be
used outside of it.
2022-09-21 16:48:48 +02:00
78b7a1c3a8 PyAPI: disable IMB color management methods for stand-alone mathutils
Allow building a standalone mathutils without including imbuf.
2022-09-21 23:53:38 +10:00
1b95784aad Fix compile error on (designated initializers in C++) 2022-09-21 14:36:55 +02:00
efa6525bf1 Cleanup: Move file browser history handing to own file
Was placed in filelist.cc, which didn't make much sense since they deal
with quite different things.
2022-09-21 14:32:08 +02:00
cd84d3f3da Refactor: Move file browser filelist.c to C++
I'm adding some asset APIs/types in C++ that the file-listing code would
use. I prefer porting this code to C++ over adding a C-API for the asset
code.

Includes some minor cleanups that shouldn't change behavior, like using
`MEM_new()`/`MEM_cnew()`, C++ style C-library includes,
`LISTBASE_FOREACH()`, removing unnecessary typedefs, etc.
2022-09-21 12:39:26 +02:00
Alaska
6adb481fb5 Add oneAPI to the 'cycles_device' command line argument help text
Differential Revision: https://developer.blender.org/D16027
2022-09-21 12:04:27 +02:00
78bfaf1a4f File Browser: Manual auto-increase name support for output filepaths
This functionality was present until Blender 2.80.  Basically it adds back the
"+" and "-" buttons in the file browser when it stores an output filepath.

This is useful for someone rendering multiple versions of an animation (or a
composition) to compare.

At the moment this is used for the render output, and the File Output node in
the compositor.

Differential Revision: https://developer.blender.org/D15968
2022-09-21 11:06:44 +02:00
15593299f3 Revert "Cleanup: Fix warning unused variable 'mode' when doing make lite"
Sorry, this was working before I rebased. I believe the warning was
fixed and the rebase still applied.

The commit as it was introduced building problems

This reverts commit ae21319d7f.
2022-09-21 11:05:35 +02:00
ae21319d7f Cleanup: Fix warning unused variable 'mode' when doing make lite 2022-09-21 10:57:11 +02:00
bc88f2006d Cleanup: remove vector adaptor data structure
This was used in early node based particle system development
but is not used anymore. The code also didn't match the standards
of other data structures in blenlib.
2022-09-21 10:39:07 +02:00
ea79dab062 Docs: add notes about wmWindow.eventstate & modifier key checks
There were undocumented limitations in the current modifier handling
that came to my attention while investigating related issues.
2022-09-21 16:46:41 +10:00
f97728248e Fix module search path for Python on initialization
Initializing the sys.path on startup attempted to add subdirectories
of {BLENDER_SYSTEM_SCRIPTS}:

- ./modules/modules
- ./modules/startup

As the directories aren't expected to exist there is no need to add them.

Also improved comments for path searching logic.
2022-09-21 12:01:49 +10:00
5517c848bd Cleanup: spelling in comments 2022-09-21 12:00:01 +10:00
e9bdf8ebc3 Cleanup: unused variable warning 2022-09-21 11:55:56 +10:00
6f15141f27 Fix T101188: Fluid modifier doesn't work
05952aa94d modified this area incorrectly, transforming
vertices outside of the mesh. That would have been fine, but the mesh
is used to retrieve the bounding box. Instead just avoid duplicating the
positions and normals completely, and avoid using referenced layers
just to be extra safe.
2022-09-20 18:38:20 -05:00
cbbed90486 Cleanup: Remove BKE_ prefix for local functions 2022-09-20 18:38:20 -05:00
7f284f5134 Fix T101138: remove console spam when hovering over toolbar in uv editor
Reviewers: Campbell Barton <ideasman42>, Ryan Inch <Imaginer>

Differential Revision: https://developer.blender.org/D16015
2022-09-21 09:44:59 +12:00
1df58ec540 Fix T101220: UV proportional editing not working correctly with UV Sync Selection
Regression introduced in rb2ba1cf4b40fc.

The `MLOOPUV_VERTSEL` flag only indicates UV selection without sync.
2022-09-20 17:29:44 -03:00
90999a0694 Fix T101208: Missing original index handling in extrude node
The extrude node must set the original indices for new faces to "None"
in edge mode as well. Same for new edges in vertex mode.
2022-09-20 14:36:20 -05:00
01ed08690a Fix: BMesh to Mesh conversion does not create all necessary layers
Even meshes without any faces must have MPoly and MLoop layers, etc.
This caused a crash in the extrude node when the edit mesh had no faces
(see T101208). Issue with f94130c94b.
2022-09-20 14:34:12 -05:00
9df0d20957 Cycles: don't allow negative BSDF weights
This doesn't work with path guiding, and likely other features.
2022-09-20 21:07:29 +02:00
ed6c8d82b8 Fix T101196: constraint plane failing in side orthographic views
Caused due to an inaccuracy when the values of `in` and `out` are too
close.

The solution is to project the value of `in` directly onto the plane.
2022-09-20 14:29:37 -03:00
1b4cf3af4b Cleanup: Improve consistency when nodes run without OpenVDB
Use a consistent order of expressions and formatting.
Also use consistent error message text.
2022-09-20 12:27:36 -05:00
Miguel Porces
01a4d38606 Fix: Group input and output always show in node add menu
In D10241, both NodeItems for NodeGroupInput and NodeGroupOutput in the
were moved from their categories into the 'node_group_items' generator.

As the NodeItem.poll() is called by the NodeCategory class and not by
the NodeItem class, the poll functions associated with those NodeItems
were never called. This should correct that.

Differential Revision: https://developer.blender.org/D16013
2022-09-20 12:07:59 -05:00
32b766223a Sculpt: Fix T100479: Boundary expand crash
Face sets were not being initialized.  I had also
forgotten to remove a dead struct member from
SculptBoundary which was being accessed.
2022-09-20 10:03:28 -07:00
bf14757709 Sculpt: Fix memory corruption with reading masks from PBVH_BMESH
Feeding -1 to BM_ELEM_CD_GET_VOID_P will not return NULL.
2022-09-20 10:03:27 -07:00
5c33704ffa GPencil: Add offset parameter to reproject operator Redo Panel
Now it's possible to set an offset in the surface reprojection.
Before, this was only possible while drawing, but not in the
reproject operator.

Differential Revision: https://developer.blender.org/D15610
2022-09-20 17:32:09 +02:00
afe91903af Cleanup: Strict compiler warning
Resolves -Wunneeded-internal-declaration warning generated by Clang.
2022-09-20 15:39:29 +02:00
RedMser
3132d2751e Animation: Fix operator properties for redo panel
After the redo panel is added to animation editors in D14960, many
operators have now been 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-09-20 14:57:00 +02:00
RedMser
1f828a5a06 Animation: Add redo panel to Dopesheet and NLA
Add the Redo panel to the dopesheet & NLA editors. This also implicitly
adds it to 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.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14960
2022-09-20 14:37:16 +02:00
9396437417 Move workspace.c to C++
Differential Revision: https://developer.blender.org/D16020
2022-09-20 13:22:55 +02:00
2b4cb893e7 Fix T101214: hidden link can cause cycle in node tree
Links that are linked to unavailable sockets should be ignored.
2022-09-20 13:21:16 +02:00
22efaa2e7b Fix T101201: Missing filter from outliner header
This was missing in Blender File & Orphan Data view.

Typo in rBb5fc8f611e39.

Maniphest Tasks: T101201

Differential Revision: https://developer.blender.org/D16016
2022-09-20 12:20:14 +02:00
5c81d3bd46 Geometry Nodes: improve evaluator with lazy threading
In large node setup the threading overhead was sometimes very significant.
That's especially true when most nodes do very little work.

This commit improves the scheduling by not using multi-threading in many
cases unless it's likely that it will be worth it. For more details see the comments
in `BLI_lazy_threading.hh`.

Differential Revision: https://developer.blender.org/D15976
2022-09-20 11:08:05 +02:00
7a239812ca Fix misleading operator name in the dope-sheet and action editor
The operator did not set the any extrapolation mode of the individual
keyframes, it sets it for the whole f-curve. Change the operator name to
reflect that.
2022-09-20 10:52:35 +02:00
c8a18fd239 Cleanup: add hint that typedef is used as compiler bug workaround
https://developercommunity.visualstudio.com/t/Alias-template-inside-fold-expression-fa/10040507
2022-09-20 10:42:25 +02:00
41935b9285 Cleanup: quite compiler warning
Warning: P3204.
2022-09-20 10:37:46 +02:00
22b69ed08f Fix T101001: crash setting texture node active in certain cases
Code from {rBb0cb0a785475} assumed a texture node `node->id` would
always be an image.
That is not true though:
 - could be an object (as reported here with the Point Density node)
 - could be a textblock (as in the IES Texture node)

Acting on these would crash when doing `BKE_image_signal` on them.

Now check node id is an image and do nothing otherwise.
Also check if an image is actually set in these nodes (if none is, the
Image Editor is now also untouched, previously the image in the Image
Editor was "cleared" here [set to NULL] -- which does not seems very
beneficial)

Maniphest Tasks: T101001

Differential Revision: https://developer.blender.org/D15943
2022-09-20 09:19:49 +02:00
e00f76c6a8 ViewLayer: fix missing sync in object APIs (fixes T101128, T101204)
Since D15885, most (all?) python based importers are failing with an
error like RuntimeError: Error: Object 'Cube' can't be selected
because it is not in View Layer, whenever they try to mark
just-created objects selected via obj.select_set(True). Happens at
least in FBX and (legacy) OBJ importers -- effectively they end up
creating just the first imported object before failing with this
exception.

Looks like BKE_view_layer_synced_ensure calls were missing before
BKE_view_layer_base_find in rna_object_api.c.

Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D16004
2022-09-20 09:45:27 +03:00
b950a8fb79 Painting: Don't calculate rake rotation when texture is not set.
Currently the rake rotation is calculated when the angle mode is set. Even when the texture isn't valid.
This change will only calculate the rake rotation when the texture is valid and the angle mode is set.
2022-09-20 08:28:35 +02:00
c279a0d931 GHOST/Wayland: refactor modifier handling on window activation
GHOST_SystemWayland::getModifierKeys() now returns the correct
modifier keys held instead of guessing that both left/right modifiers
were held.
2022-09-20 16:02:34 +10:00
09308c4b6a CMake: fail to build with unsupported versions of wayland-scanner
When WITH_GHOST_WAYLAND_DYNLOAD is enabled.
2022-09-20 12:53:06 +10:00
9c35f103c0 Cleanup: quiet warning 2022-09-20 12:53:05 +10:00
710b8b7929 GNUmakefile: fix error showing final message with the 'dash' shell
The bpy module check wasn't working with dash,
use posix compliant check for empty string.
2022-09-20 12:53:03 +10:00
3d5e0c8b9d Cleanup: Move mesh_mapping.c to C++ 2022-09-19 18:45:11 -05:00
a24fc6bbc1 UV: extend custom grid sizes to set each axis separately
For example, allows a custom UV grid size of 4 x 12.

TODO: Fix snapping with custom UV grid sizes.

Manifest Tasks: T78391

Differential Revision: https://developer.blender.org/D16000
2022-09-20 10:00:41 +12:00
7a67d69ca4 Cleanup: spelling 2022-09-20 09:20:55 +12:00
bdb5754147 Nodes: Add node group assets to search menus
Currently node group assets are supported, but using them by dragging
from the asset browser is cumbersome. This patch adds all node group
assets from user asset libraries and the current file libraries to the
add node search menu and the link drag search menu.

Node groups added through the search will have their "options" hidden,
meaning the data-block selector is displayed. This helps keep the UI
clean, and the selector shouldn't be necessary anyway.

To make that possible, metadata like the node tree type and its inputs
and outputs has to be saved in the file. This requires re-saving the
files that contain the assets with the patch applied.

The node add search operator is moved from Python to C++ to ease
development and allow more flexibility. It supports a tooltip that
gives the description of assets.

Currently the node groups are added with the asset system's existing
"Append & Reuse" behavior. It's likely that linking should be possible
in the future too, but for now the idea is to use the more foolproof
option that doesn't create dependencies between files.

Because loading assets can potentially take a long time, the search
menu refreshes its items as new assets are loaded. However, changing
the search field is necessary to see the update.

Differential Revision: https://developer.blender.org/D15568
2022-09-19 11:57:10 -05:00
862de9187f Cleanup: Move versioning_300.c to C++ 2022-09-19 11:06:21 -05:00
Iyad Ahmed
b6e26a410c Geometry Nodes: Distribute Points in Volume
This commit adds a node to distribute points inside of volume grids.
The "Random" mode usese OpenVDB's "point scatter" implementation, and
there is also a "Grid" mode for uniform distributions. Both methods
operate on all of the float grids in the volume, using every voxel with
a value higher than the threshold. The random method is not stable as
the input volume deforms.

Based on a patch by Angus Stanton (@abstanton), which was based on a
patch by Kenzie (@kenziemac130).

Differential Revision: https://developer.blender.org/D15375
2022-09-19 10:14:08 -05:00
0e6a8df6df GPencil: Make format
Missing in previous commit
2022-09-19 16:31:00 +02:00
5c13c7cd30 GPencil: Cut Extended lines in Fill tool when collide
Before, the lines could be extended endless, but this added too noise. 
Now, the lines are not extended more if collide.

Before:

{F13504186}

After:

{F13504187}

Reviewed By: mendio, frogstomp

Differential Revision: https://developer.blender.org/D15992
2022-09-19 16:03:53 +02:00
be863506b8 Cleanup: Improve comment for curve component legacy curves 2022-09-19 08:46:28 -05:00
2ce8b01c59 PyGPU: call 'GPU_shader_bind' in 'GPUShader.uniform_' methods
This simplifies python code.

When we call a method like shader.uniform_float("color", (1,1,1,1)),
we expect the shader's uniform to be updated regardless of whether the
shader is bound or not.

And `batch.draw()` already calls `GPU_shader_bind` inside.

Differential Revision: https://developer.blender.org/D15929
2022-09-19 09:40:20 -03:00
2fffd7d7a8 Move overlay engine to C++
This just makes the minimum changes to make the files compile.
2022-09-19 14:29:58 +02:00
327802b86f DNA: Remove unnecessary studio light & light probe struct paddings 2022-09-19 12:16:30 +02:00
2c407cfb8f GHOST/Wayland: correct flag for checking pressed keys
Check modifier keys using XKB_STATE_MODS_DEPRESSED which is used
to check if modifiers are physically held. In practice it's unlikely
this would have caused an error for key-maps in common use.
2022-09-19 16:29:29 +10:00
ea35c237fc Fix T101180: console HOME key doesn't work
Regression in [0], re-order the key-map so the home key
can be used for cursor motion.

[0]: 82fc52ffc8
2022-09-19 15:52:21 +10:00
6b8b2c8e7f Cleanup: use doxy sections 2022-09-19 14:52:27 +10:00
6424fbca94 Cleanup: spelling 2022-09-19 14:52:27 +10:00
4baa6e57bd Cleanup: prefer 'arg' over 'params' for sphinx documentation
While both are supported, 'arg' is in more common use so prefer it.
2022-09-19 14:24:31 +10:00
Wannes Malfait
8a9f6a2e0a Fix T101137: Crash with Transform Node
In `BKE_mesh_tag_coords_changed_uniformly` the checks for dirty vertex
and dirty poly normals were swapped around, causing an assert to be
triggered.

Differential Revision: https://developer.blender.org/D16002
2022-09-18 22:58:51 -05:00
a45b408422 Cleanup: Fix grammar in IndexRange header
Also make it more clear by avoiding repeating the name of the function.
2022-09-18 22:57:46 -05:00
ecf3435362 Curves: Remove CurveEval and old Spline types
`CurveEval` was added for the first iteration of geometry nodes curve
support. Since then, it has been replaced by the new `Curves` type
which is designed to be much faster for many curves and better
integrated with the rest of Blender. Now that all curve nodes have
been moved to use `Curves` (T95443), the type can be removed,
along with the corresponding geometry component.
2022-09-18 15:10:04 -05:00
7536abbe16 Curves: Port Curve to Points node to the new data-block
This is the last node to use the `CurveEval` type. Since the curve to
points node is basically the same as the resample node, now it just
reuses the resample code and moves the curve point `CustomData` to a
new point cloud at the end. I had to add support for sampling tangents
and normals to the resampling.

There is one behavior change: If the radius attribute doesn't exist,
the node won't set the radius to 1 for the output point cloud anymore.
Instead, the default radius for point clouds will be used.
That issue was similar to T99814.

Differential Revision: https://developer.blender.org/D16008
2022-09-18 14:56:24 -05:00
cf56b8be37 Fix T101166: crash when creating group input socket
The issue was that not all Group Input nodes were updated when
the node group interface changed.
2022-09-18 21:07:23 +02:00
53c92efd5a Fix: Prevent clipping of node drop shadow
Fix clipping artifacts of node drop shadows that could occur
on hidden nodes, when using higher UI scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16007
2022-09-18 20:39:14 +02:00
998ffcbf09 Fix: Make node position consistent when added through link drag search
The node position is specified in the coordinate space of the node
editor. The cursor position has to be divided by `UI_DPI_FAC` since it's
in view space but the offset is independent of any ui scaling.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D16006
2022-09-18 20:18:50 +02:00
fd1bc90679 Cycles: sync changes from standalone repository
* Windows build fixes
* Workaround for Hydra + OpenColorIO link issue
* Bump version
2022-09-18 17:34:23 +02:00
0ffd288fab Build: fix gtest build flags affecting actual library
Switch to target_ functions to avoid this.
2022-09-18 11:26:34 +02:00
6bf5cc62e0 Build: limit Py_ENABLE_SHARED to modules using Python headers
And remove Python flags from nodes, no longer needed.
2022-09-18 11:26:33 +02:00
892a5f8176 Build: disable gtests entirely for Python module
To avoid test failure on Windows.
2022-09-18 11:26:23 +02:00
Wannes Malfait
3ff15a9e23 Geometry Nodes: New Face Set Boundaries node
With the recent addition of the UV unwrapping node, there is a need to
be able to create seams easily. This node does that by outputting a
selection of the boundaries between different input face sets. In the
context of UV mapping, one inputs the "patches" you want, and the node
gives you the seams needed to make those patches.

Differential Revision: https://developer.blender.org/D15423
2022-09-17 22:18:52 -05:00
Mattias Fredriksson
ce54f48556 BLI: Add generic utlity for gathering values with indices
Add new functions to `array_utils` namespace called `gather(..)`.
Versions of `GVArray::materialize_compressed_to_uninitialized(..)` with
threading have been reimplemented locally in multiple geometry node
contexts. The purpose of this patch is therefore to:
 * Assemble these implementations in a single file.
 * Provide a naming convention that is easier to recognize.

Differential Revision: https://developer.blender.org/D15786
2022-09-17 22:12:02 -05:00
Mattias Fredriksson
095516403c Curves: Correct and improve Catmull Rom interpolation
Correct interpolation of integer POD types for Catmull Rom
interpolation as implemented in eaf416693d.

**Problem description**
`attribute_math::DefaultMixer<T>::mix_in()` assumes/asserts positive
weights but the basis function for Catmull-Rom splines generates
negative weights (see image in revision). Passing negative weights will
yield correct result as sum(weights) = 1 (after multiplication by 0.5)
but the assert is still triggered in debug builds. This patch adjusts
the behavior by extending the mix functions with mix4(). The benefit
of using mix#() over a DefaultMixer is that the result no longer needs
to be divided by the weight sum, instead utilizing that the basis weight
sum is constant (see plot).

**Changes**
 * Added mix4() and updated catmull_rom::interpolate() to use it.
 * Removed TODOs from catmull_rom functions.
 * Moved mix definitions to be ordered as 2, 3, 4 in the header.

**Implementation specifics**
`catmull_rom::interpolate()` uses a constexpr to differentiate between
POD types which multiplies the result with 0.5 after weighting the
values, this reduces the number of multiplications for 1D, 2D, 3D
vectors (https://godbolt.org/z/8M1z9Pxx6). While this could be
considered unnecessary, I didn't want to change the original behavior
as it could influence performance (did not measure performance here
as this should ensure the logic is ~identical for FP types).

Differential Revision: https://developer.blender.org/D15997
2022-09-17 21:53:58 -05:00
641bbc820f Curves: Don't allow resolutions less than 1
While this worked, the result for curves with a resolution of zero was
just a single evaluated point, which isn't useful or intuitive. Using
the attribute validation from 8934f00ac5, make sure users
can't set values 0 or less.
2022-09-17 21:12:25 -05:00
0bdb5239c1 LineArt: Force intersection option.
This option allows easier setup of intersection overrides on more
complex scene structures. Setting force intersection would allow objects
to always produce intersection lines even against no-intersection ones.

Reviewed By: Aleš Jelovčan (frogstomp) Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D15978
2022-09-18 09:46:21 +08:00
4f284873d0 Fix: Crash after recent attributes commit
Fixes test failures from 8934f00ac5.
2022-09-17 20:27:50 -05:00
8c878ddd34 Fix OS-key events repeating on GHOST/Win32
Holding the OS (Windows) key on Win32 used key-repeat behavior.
While as far as I know it didn't cause user visible errors - sending
repeated modifier events isn't expected behavior and doesn't happen
on other platforms (or for other modifier keys).
2022-09-18 11:16:24 +10:00
0950e6fae6 GHOST: support left/right OS-key
Handling the OS key now match other modifiers in GHOST which detect
each key separately, making the behavior simpler to reason about since
mapping a single key to a modifier state is simpler, avoiding handling
that only applied to the OS-Key.

This means simulating key up/down events can use the correct modifier.

In the window-manager this is still only accessed accessed via KM_OSKEY.
2022-09-18 10:31:14 +10:00
8934f00ac5 Attributes: Validate some builtin attributes for untrusted inputs
We expect some builtin attributes to have positive values or values
within a certain range, but currently there some cases where users
can set attributes to arbitrary values: the store named attribute node,
and the output attributes of the geometry nodes modifier. The set
material index node also needs validation.

This patch adds an `AttributeValidator` to the attribute API, which
can be used to correct values from these untrusted inputs if necessary.
As an alternative to D15548, this approach makes it much easier to
understand when validation is being applied, without the need to add
arguments to every attribute API method or complicate the virtual
array system.

Currently validation is provided with a multi-function. That integrates
well with the field evaluations that set these values now, but it could
be wrapped to be friendlier to other areas of Blender in the future.

The Python API is not handled here either. Currently I would prefer to
wait until we can integrate the C++ and C attribute APIs better before
addressing that.

Fixes T100952

Differential Revision: https://developer.blender.org/D15990
2022-09-17 14:38:30 -05:00
6069cab442 Mikktspace: Fix triangle reordering predicate
This only affected meshes containing degenerate triangles.
2022-09-17 21:18:12 +02:00
114815816b Fix: lite build on windows
writefile.cc includes BLI_winstuff.h which
includes Windows.h which supplies definitions
of min/max that conflict with the c++ headers

previously windows.h was only included when TBB was
enabled, the inclusion of BLI_winstuff.h now
makes this define mandatory for all configurations
2022-09-17 09:36:14 -06:00
44272fdd23 WM: send a modifier press when activating a window with modifier held
Previously the a simulated event was sent for releasing modifiers
on activation but pressing only set the eventstate flag.

Prefer the simulated events since press/release events are used in some
modal key-maps.
2022-09-18 00:39:13 +10:00
d74c16ba81 WM: refactor modifier hold/release logic when activating a window
Initial support for matching left/right modifier keys for simulated
events - no functional changes.
2022-09-18 00:39:13 +10:00
57e4b6aefb PyDoc: correct parameter doc-strings & exception message 2022-09-18 00:39:13 +10:00
f8a3ec48e4 Fix T100330: Remove Render Slot not working for first slot
This bug was caused by the weird ownership logic for render results.
Basically, the most recent render result is owned by the Render, while
all others are owned by the RenderSlots.
When a new render is started, the previous Render is handed over to its
slot, and the new slot is cleared. So far, so good.

However, when a slot is removed and happens to be the one with the most
recent render, this causes a complication.
The code handles this by making another slot the most recent one, along
with moving its result back to the Render, as if that had always been
the most recent one.

That works, unless there is no most recent render because you haven't
rendered anything yet. Unfortunately, there is no way to store "there
hasn't been a render yet", so the code still tries to perform this
handover but can't.
Previously, the code handled that case by just refusing to delete the
slot. However, this blocks users from deleting this slot.

But of course, if there hasn't been a render yet, the slots will not
contain anything yet, so this entire maneuver is pointless.
Therefore, the fix for the bug is to just skip it altogether if there
is no Render instead of failing the operation.

Technically, there is a weird corner case remaining, because Renders
are per-scene. Therefore, if a user renders images in one scene,
switches to a different scene, deletes a slot there and then switches
back, in some situations the result in the deleted slot might end up
in the next slot.
Unfortunately this is just a limitation of the weird split ownership
logic and can't just be worked around. The proper fix for this
probably would be to hand over ownership of the result from the Render
to the RenderSlot once the render is done, but this is quite complex.

Also fixes a crash when iuser->scene is NULL.
2022-09-17 16:21:44 +02:00
bdbf24772a GPencil: Remove Leak Size
This value was used to close gaps, but now with the new system is not needed.

Internally, still we need to keep a small leak size, but after doing a lot of test a 
value of 3 is perfect, so it's harcoded.
2022-09-17 12:30:13 +02:00
742268c50b GPencil: Move Gap Closure option to separated subpanel
Also removed leak size
2022-09-17 12:30:13 +02:00
0621d162f0 GPencil: Change prop text to Closure Mode 2022-09-17 12:30:13 +02:00
dd0ef74887 GPencil: Hide the help Circles for gaps when gap is closed
To avoid too much noise, the help circles are only visible if the
the gap is still open. When the gap is closed, the circles are hidden.

Hiding the circles makes it easier to focus on what is problematic.
instead, to see many circles that are already resolved.
2022-09-17 12:30:13 +02:00
172b0ebe6a GPencil: Rename Fill closure methods
The new names are:

* Radius
* Extend

The mode Radius + Extend has been removed.

Also, some code cleanup and format.
2022-09-17 12:30:13 +02:00
Dave Pagurek
468f2ccc0e GPencil: Add more types of stroke extensions when filling
The motivation for this change: while working on an animation recently, I found that there are some gaps that won't close easily via stroke extension or leak size checking. In D14698, I attempted to address this by changing the algorithm of the raster-space flood fill. This patch attempts to address the same issue in vector space by adding two new cases where stroke extensions are added, as suggested by @frogstomp:

  # **Points of high curvature:** when the curvature at a point is high enough that it's hard to visually distinguish between it and an endpoint, add a stroke extension out along the normal (pointing in the opposite direction of the stroke's acceleration.) This addresses cases where technically the endpoint points up, but there's a sharp corner right below it that should extend to connect.

  # **Stroke endpoints within a radius**: when two endpoints are close together, regardless of the angle they make, connect them if they are within a radius. This addresses cases like where the two endpoints have effectively parallel tangents, so extensions won't close the gap.

Reviewed By: antoniov, mendio, frogstomp

Differential Revision: https://developer.blender.org/D14809
2022-09-17 12:30:13 +02:00
a4027658ee IndexRange: Add new intersect method
Returns a new range, that contains the intersection of the current one
with the given range.

This is helpful to select a portion of a range without having to deal with
all the asserts of other functions. The resulting range being always a
valid subrange, it can be used to iterate or copy a part of a vector.
2022-09-17 12:27:00 +02:00
9dcce5be90 DRW: Debug: Fix row / column counters not being reset on init
This fixes the issues with CPU debug print not being in the right order.
2022-09-17 12:27:00 +02:00
a1aafddcbe DRW: GPU wrapper: Add new StorageVectorBuffer
Same as `StorageArrayBuffer` but has a length counter and act like a
`blender::Vector` you can clear and append to.
2022-09-17 12:27:00 +02:00
7549e0c5ae Geometry Nodes: use stringref instead of string in logger
This reduces logging overhead. The performance difference is only
significant when there are many fast nodes. In my test file with many
math nodes, the performance improved from 720ms to 630ms.
2022-09-17 12:08:57 +02:00
1810b1e4c8 GL: Framebuffer: Add support for empty framebuffer (no attachments)
This allows to reduce the memory footprint of very large framebuffers if
there is no need for any attachment.
2022-09-17 10:17:47 +02:00
b37954d03c Cleanup: format 2022-09-17 15:12:56 +10:00
34a6952067 Cleanup: compiler warnings 2022-09-17 15:12:42 +10:00
d9930d5fd0 Cleanup: spelling, punctuation & repeated words in comments 2022-09-17 15:08:40 +10:00
5f6f2e106c Cleanup: Use dedicated function to offset VSE strip handles 2022-09-17 05:23:34 +02:00
d4a763d363 Fix T101098: Moving meta strip can change its length
Caused by clamping handle translation to strip bounds in functions
`SEQ_time_*_handle_frame_set()` to prevent strip ending in invalid
state. Issue happens when meta strip is moved so quickly, such that
immediate offset is greater than strip length.

Currently meta strip bounds are updated when any contained strip changes
its position, but this update always preserves meta strip position.
Transforming meta strip is not possible directly and all contained
strips are moved instead. Therefore this is 2-step process and fix needs
to be applied on update function and on translation function.

Inline offset handling without clamping in function
`SEQ_time_update_meta_strip_range()`.
Add new function `seq_time_translate_handles()` to move both handles at
once in `SEQ_transform_translate_sequence()`.
2022-09-17 04:21:56 +02:00
e108d67635 Sculpt: add .sculpt to allow_procedural_attribute_access
Also cleaned up a comment.
2022-09-16 13:05:04 -07:00
9c35a5a524 Sculpt: Improve performance when initializing face sets
Avoid conversion to `BMesh` for basic topology operations and data access.
Instead use a mesh map to retrieve the faces connected to each edge.
I observed performance improvements of 5x (600ms to 100ms) to 10x
(15s to 1s), with bigger changes for large meshes with more data layers
Switching to `std::queue` over Blender's `GSQueue` gave another
25% improvement.

Differential Revision: https://developer.blender.org/D15988
2022-09-16 14:31:30 -05:00
8fdaf2bddc Fix: Missing updates for multires sculpting
Caused by ee23f0f3fb, which removed the update tag when entering
sculpt mode, and by b5f7af31d6, which made these layers lazily
created, so they weren't always available at the start of a stroke. Now
update the evaluated mesh/multires CCG as necessary. Some updates
could potentially avoided when switching modes in the future, but for
now do it all the time.

Fixes T101116
Also fixes a crash when painting multires mask for the first time
2022-09-16 14:31:30 -05:00
02575bcbd0 Sculpt: New attribute API
New unified attribute API for sculpt code.

= Basic Design =

The sculpt attribute API can create temporary or permanent attributes (only supported in `PBVH_FACES` mode).  Attributes are created via `BKE_sculpt_attribute_ensure.`

Attributes can be explicit CustomData attributes or simple array-based pseudo-attributes (this is useful for PBVH_GRIDS and PBVH_BMESH).

== `SculptAttributePointers` ==

There is a structure in `SculptSession` for convenience attribute pointers, `ss->attrs`.  Standard attributes should assign these; the attribute API will automatically clear them when the associated attributes are released.  For example, the automasking code stores its factor attribute layer in `ss->attrs.automasking_factor`.

== Naming ==

Temporary attributes should use the SCULPT_ATTRIBUTE_NAME macro for naming, it takes an entry in `SculptAttributePointers` and builds a layer name.

== `SculptAttribute` ==

Attributes are referenced by a special `SculptAttribute` structure, which holds
all the info needed to look up elements of an attribute at run time.

All of these structures live in a preallocated flat array in `SculptSession`, `ss->temp_attributes`.  This is extremely important.  Since any change to the `CustomData` layout can in principle invalidate every extant `SculptAttribute`, having them all in one block of memory whose location doesn't change allows us to update them transparently.

This makes for much simpler code and eliminates bugs.  To see why this is tricky to get right, imagine we want to create three attributes in PBVH_BMESH mode and we provide our own `SculptAttribute` structs for the API to fill in.  Each new layer will invalidate the `CustomData` block offsets in the prior one, leading to memory corruption.

Reviewed by: Brecht Van Lommel
Differential Revision: https://developer.blender.org/D15496
Ref D15496
2022-09-16 12:20:28 -07:00
4cea4f4c5f Fix: Geometry nodes crash with undefined node
The new evaluator crashes for multi-input sockets coming from undefined
nodes. The multi-input socket lazy node tries to retrieve the default
value since the undefined node never created output values. But there
is no default value stored because the socket is linked.

Differential Revision: https://developer.blender.org/D15980
2022-09-16 12:54:46 -05:00
3d93525069 Cleanup: Remove unused member variable in lazy function graph 2022-09-16 12:53:18 -05:00
9ca1abe042 Fix T101100: missing smooth shading with linked subdivision surface in editmode
Smooth flag should come from the evaluated mesh, only selection and hidding
state should be mapped to the original bmesh.

Pre-existing issue revealed by refactor in b247588dc0.
2022-09-16 16:50:43 +02:00
4d67a995d9 Fix: crash when evaluating geometry nodes after deleting an unlinked node
This was essentially a use-after-free issue. When a geometry nodes
group changes it has to be preprocessed again before it can be evaluated.
This part was working, the issue was that parent node groups have to be
preprocessed as well, which was missing. The lazy-function graph cached
on the parent node group was still referencing data that was freed when
the child group changed.

Now the depsgraph makes sure that all relevant geometry node groups are
preprocessed again after a change.

This issue was found by Simon Thommes.
2022-09-16 16:03:50 +02:00
7042f4e4b2 Fix Linux bpy wheel failing to install due to wrong ABI flags 2022-09-16 15:53:37 +02:00
c8b9ede4b1 Sculpt: Move sculpt_face_set.c to C++ 2022-09-16 08:17:54 -05:00
Lukas Stockner
44aaa9893b Eevee: Add support for Nishita sky texture
Sun Disc is currently not supported because it'll need special handling - on the one hand, I'm not sure if Eevee would handle a 1e6 coming out of a background shader without issues, and on the other hand it won't actually cast sharp shadows anyways.
I guess we'd want to internally add a sun to the lamps if Sun Disc is enabled, but getting that right is tricky since the user could e.g. swap RGB channels in the node tree and the lamp wouldn't match that.
Anyways, that can be handled later, the sky itself is already a start.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D13522
2022-09-16 15:10:09 +02:00
2eb19eeb19 Fix 101000: color picker colors drift above 1 for some OCIO configurations
Increase threshold to avoid float precision issues.
2022-09-16 15:00:39 +02:00
bf05b998b6 Revert "EEVEE: Fix volumetric resolve in large scenes."
This reverts commit 34051fcc12.
Although for normal use this doesn't make a difference. But when working with
huge scenes and volumetrics + NVIDIA it made a work-around not possible anymore.

For the heist production we added a fix on the render-farm (enable GPU workarounds).
{rB34051fcc12f388375697dcfc6da53e9909058fe1} made another work-around not
accessible anymore and it and was requested to revert this change.
2022-09-16 14:55:04 +02:00
Germano Cavalcante
4b326d5a78 Fix T101040: Blender Crashes When snap roll a bone in armature
The modes that don't support individual projection shouldn't support
FACE_NEAREST either.

Differential Revision: https://developer.blender.org/D15970
2022-09-16 09:05:33 -03:00
13c4af66fc Cleanup: format 2022-09-16 18:14:33 +10:00
95f05a6a4b Cleanup: spelling in comments 2022-09-16 18:14:33 +10:00
48d7ff68f0 Make File Select dialog update operator's file & path properties
When an operator is attached to a file select dialog, the update
callback function for the operator's directory, filename and filepath
properties will be called as the user navigates through the dialog.

This will allow add-on authors to make more interactive import
operators.

Differential Revision: https://developer.blender.org/D15543
2022-09-16 00:27:59 -07:00
8bf0714d50 make_source_archive: exclude hidden git files 2022-09-16 15:34:53 +10:00
ac76da2944 Revert "UI: Use full word for face set operator name, tweak description"
This reverts commit 15d85c54c3.
Included a separate change/new file by mistake. Sorry for the noise.
2022-09-15 23:06:04 -05:00
15d85c54c3 UI: Use full word for face set operator name, tweak description
"Init" shouldn't be used in the UI, and avoid repeating the operator
name in its description.
2022-09-15 23:04:55 -05:00
a231637fae Sculpt: Respect hiding when creating face sets from loose parts
Different areas of the mesh can be "loose parts" visually when separated
by hidden areas. This is consistent with other areas of sculpt mode that
also treat hidden areas differently.
2022-09-15 22:54:51 -05:00
72253f427d Docs: Update sphinx 2022-09-15 22:30:47 -04:00
d255c8e9f7 Cleanup: format 2022-09-16 11:53:40 +10:00
a8eeec7b35 Cleanup: typos in 427d669f62 2022-09-16 11:39:48 +10:00
427d669f62 make_bpy_wheel: various minor improvements
- Add doc-string with example usage shown in the --help message.
- Add help text for command line arguments.
- Only search for the CMakeCache.txt file when the `--build-dir`
  is omitted.
- Write fatal errors to the stderr.
2022-09-16 11:27:13 +10:00
8342564796 Cleanup: suppress type warnings for make_bpy_wheel & make_utils
'make check_mypy' now runs without warnings.
2022-09-16 10:52:20 +10:00
d5df23d758 Cleanup: Rename attribute required functions
Avoid "customdata" in the name, since that's an implementation detail
in this context.
2022-09-15 13:14:31 -05:00
0945ae338b Fix: Merging mesh and non-empty BMesh creates "flag" attributes
We need to use the custom data copy function that skips mesh-only
attributes like the hide status attributes, the generic material index
attribute, etc. Otherwise the BMesh has those attributes which
conflict with their builtin counterparts.
2022-09-15 12:52:18 -05:00
8b26349d57 BLO: move blenloader to C++
Differential Revision: https://developer.blender.org/D15965
2022-09-15 19:13:13 +02:00
Brecht Van Lommel
9f76d0c8e6 Python: script for packing bpy module as wheel
The buildbot will call this script to create a binary .whl file that can be
easily installed through pip.

This wheel will only work with the same Python version used for Blender.
Other minimum system requirements are the same as regular Blender builds.

Includes contributions by Campbell Barton.

Differential Revision: https://developer.blender.org/D15957
2022-09-15 18:27:03 +02:00
f70fac6382 Python: fix failing bpy build with full release config on Windows
* Fix issue with different build and install paths.
* Fix issue with oneAPI kernel build.

Ref D15957
2022-09-15 18:27:02 +02:00
5228b0b74f Python: fix failing tests when building bpy module
* Use Python executable from lib folder since it's not installed.
* Make bpy module test work for portable install.
* Disable gtests which don't work with different Python link flags
  and shared library locations.

Ref D15957
2022-09-15 18:27:01 +02:00
335a6c0c87 Cleanup: move Blender version parsing to make_utils.py
Ref D15957
2022-09-15 18:27:00 +02:00
5b216aae8b Fix T101065: wrong denoising depth after ray precision improvements 2022-09-15 16:04:24 +02:00
fbc74c9d93 Fix warning-as-errors in older GCC's, take 2.
rBf4e6616b835e did not work for `some reason`, this one has been
verified with gcc 10!
2022-09-15 15:58:21 +02:00
f4e6616b83 Fix warning-as-errors in older GCC's.
Recent compilers (at least gcc 11 and 12) do not report any issue, but
gcc 10 does.
2022-09-15 15:46:47 +02:00
c41249d436 PointCloud: add BKE_pointcloud_nomain_to_pointcloud
This adds a utility function to copy the data from a PointCloud
outside of the main database to one that is in the database. This
is similar to `BKE_mesh_nomain_to_mesh`.

Ref D11592
2022-09-15 15:21:25 +02:00
Damien Picard
a869fcd686 I18n: disambiguate and extract a few messages
Disambiguate:
- Lower / Upper (case)
- Spray (ocean modifier)
- Keep Original (clip, grease pencil, object)
- Screen [space] (inside some enum items, mostly)
- Cast Shadow ("shadow that is cast", not "to cast a shadow")

Extract:
- Line Art Light Reference Near and Far
- Mesh vertex attribute domain: Vertex

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15938
2022-09-15 11:38:45 +02:00
903709c4eb GPencil: Add frame number to Trace operator
The default trace can only trace an image or a sequence, but
it was not possible to trace only selected frames in a sequence. 
This new parameter allows to define what frame trace.

If the value is 0, the trace is done as before.

The parameter is not exposed in the UI because this is logic
if it is managed by a python API, but it has no sense in the UI.

This feature was included after receiving feedback from Studios
which need to trace videos only for some frames using custom
python scripts.
2022-09-15 11:19:30 +02:00
Nate Rupsis
2310daed3a NLA: draw track bg based on strip's extrapolation type
In the NLA, draw the track background based on the strip's extrapolation
setting. Previously, this had no visual indicator; "Hold", "Hold
Forward", and "Nothing"  were visually indistinguishable. Now "Nothing"
actually shows nothing, "Hold Forward" shows a dimly colored background
from the strip to its right, and "Hold" shows that in both directions.

Reviewed By: RiggingDojo, sybren

Maniphest Tasks: T97572

Differential Revision: https://developer.blender.org/D14836
2022-09-15 10:47:02 +02:00
3eae1bfe35 Cleanup: quiet sign-conversion warning in OFFSETOF_STRUCT_AFTER
BLI_strict_flags.h raised a build error when this macro was used.
2022-09-15 18:02:53 +10:00
5c4295ee6f Workaround for msvc compiler bug
This is the same issue as in rB2e8089b6bf50.
2022-09-15 09:34:20 +02:00
5d69958442 Correct over allocation in 0e172e9732 2022-09-15 17:10:39 +10:00
718d545ff8 Cleanup: minor improvement to boundary check
Use a byte flag instead of counting polys using edges
(technically a fix for edges with USHRT_MAX+2 users).
2022-09-15 16:57:14 +10:00
0e172e9732 Fix T95649: Corrective Smooth can cause vertices to jump
Calculate a tangent per loop, apply the transformation in multiple
spaces and accumulate the result weighting by the loop-angle.

Note that previously only the tangents Z axis (normal)
was properly accumulated, the X and Y axes only contained the values
from a single loop (the last one written to), meaning only two edges
contributed to the result. Now the transformation from all loops are
taken into account.

In practice the difference between both methods is minimal,
only for more extreme bending it can be noticed which is often when the
previous method didn't work as well.
2022-09-15 16:17:17 +10:00
2c53970bbf Cleanup: use doxy sections, remove outdated comment 2022-09-15 15:27:21 +10:00
27e17fed28 PyDoc: hide overly long titles from the side-bar
The side-bar included both title and description for documentation
pages including quickstart, tips & tricks .. etc.

Titles often wrapped and took up a lot of vertical space in the side-bar.

Now these pages are linked on the main page, with the side-bar
used for top-level Python modules.
2022-09-15 14:34:23 +10:00
4bbb043bc5 Cleanup: spelling in comments, comment blocks 2022-09-15 10:03:46 +10:00
5cd08e373b CMake: exclude '.github' from addons in the install target
This file is only used for the github mirror
and doesn't need to be installed.
2022-09-15 09:48:32 +10:00
f404dd0b3c Fix Unreported: VSE and NLA handle position text is not drawn
When moving strip, or it's handle, text with frame number near handle
should be drawn. This feature was broken by 8d53ead69b, because
function `UI_view2d_text_cache_add` sets all fields of `v2s->rect` to 0.
This case was checked in function `UI_view2d_text_cache_draw`, but it
was not quite obvious.

This commit reverts 8d53ead69b, makes condition for 0 size rectangle
more obvious and adds comment for clarity.

function `UI_view2d_text_cache_add` is only used in NLA and VSE, and
this new condition fits existing use-cases. Status of T97500 is not
affected by this change.
2022-09-15 01:12:16 +02:00
b5115ed80f UV: rename "Pixel Snap Mode" to "Pixel Round Mode"
Maniphest Tasks: T78391

Differential Revision: https://developer.blender.org/D15952
2022-09-15 10:36:13 +12:00
530f203e27 Fix: Build error after previous cleanup commit
The prototype didn't match the definition anymore.
2022-09-14 15:12:15 -05:00
42fe0b6dfc Attributes: add color_srgb property to FloatColorAttributeValue and ByteColorAttributeValue
This patch adds color_srgb property to FloatColorAttributeValue and
ByteColorAttributeValue, so Python code can do
`layer.data.foreach_get("color_srgb", ...)` to fetch the data
efficiently, if it needs it in sRGB color space.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D15966
2022-09-14 22:51:00 +03:00
6d4d74172b Cleanup: Remove unused argument from modifier data mask callback
This isn't likely to be helpful in the future with the move to generic
attributes
2022-09-14 14:49:40 -05:00
e22198b8d1 Cleanup: Make format 2022-09-14 14:45:36 -05:00
ee23f0f3fb Sculpt: Separate hide status from face sets, use generic attribute
Whether faces are hidden and face sets are orthogonal concepts, but
currently sculpt mode stores them together in the face set array.
This means that if anything is hidden, there must be face sets,
and if there are face sets, we have to keep track of what is hidden.
In other words, it adds a bunch of redundant work and state tracking.

On the user level it's nice that face sets and hiding are consistent,
but we don't need to store them together to accomplish that.

This commit uses the `".hide_poly"` attribute from rB2480b55f216c to
read and change hiding in sculpt mode. Face sets don't need to be
negative anymore, and a bunch of "face set <-> hide status" conversion
can be removed. Plus some other benefits:
 - We don't need to allocate either array quite as much.
 - The hide status can be read from 1/4 the memory as face sets.
 - Updates when entering or exiting sculpt mode can be removed.
 - More opportunities for early-outs when nothing is hidden.
 - Separating concerns makes sculpt code more obvious.
 - It will be easier to convert face sets into a generic int attribute.

 Differential Revision: https://developer.blender.org/D15950
2022-09-14 14:37:18 -05:00
Monique Dewanchand
68589a31eb ViewLayer: Lazy sync of scene data.
When a change happens which invalidates view layers the syncing will be postponed until the first usage.
This will improve importing or adding many objects in a single operation/script.

`BKE_view_layer_need_resync_tag` is used to tag the view layer to be out of sync. Before accessing
`BKE_view_layer_active_base_get`, `BKE_view_layer_active_object_get`, `BKE_view_layer_active_collection`
or `BKE_view_layer_object_bases` the caller should call `BKE_view_layer_synced_ensure`.

Having two functions ensures that partial syncing could be added as smaller patches in the future. Tagging a
view layer out of sync could be replaced with a partial sync. Eventually the number of full resyncs could be
reduced. After all tagging has been replaced with partial syncs the ensure_sync could be phased out.

This patch has been added to discuss the details and consequences of the current approach. For clarity
the call to BKE_view_layer_ensure_sync is placed close to the getters.
In the future this could be placed in more strategical places to reduce the number of calls or improve
performance. Finding those strategical places isn't that clear. When multiple operations are grouped
in a single script you might want to always check for resync.

Some areas found that can be improved. This list isn't complete.
These areas aren't addressed by this patch as these changes would be hard to detect to the reviewer.
The idea is to add changes to these areas as a separate patch. It might be that the initial commit would reduce
performance compared to master, but will be fixed by the additional patches.

**Object duplication**
During object duplication the syncing is temporarily disabled. With this patch this isn't useful as when disabled
the view_layer is accessed to locate bases. This can be improved by first locating the source bases, then duplicate
and sync and locate the new bases. Will be solved in a separate patch for clarity reasons ({D15886}).

**Object add**
`BKE_object_add` not only adds a new object, but also selects and activates the new base. This requires the
view_layer to be resynced. Some callers reverse the selection and activation (See `get_new_constraint_target`).
We should make the selection and activation optional. This would make it possible to add multiple objects
without having to resync per object.

**Postpone Activate Base**
Setting the basact is done in many locations. They follow a rule as after an action find the base and set
the basact. Finding the base could require a resync. The idea is to store in the view_layer the object which
base will be set in the basact during the next sync, reducing the times resyncing needs to happen.

Reviewed By: mont29

Maniphest Tasks: T73411

Differential Revision: https://developer.blender.org/D15885
2022-09-14 21:34:38 +02:00
Monique Dewanchand
23276bcc37 Adding const Scene* parameter in many areas.
Related to {D15885} that requires scene parameter
to be added in many places. To speed up the review process
the adding of the scene parameter was added in a separate
patch.

Reviewed By: mont29

Maniphest Tasks: T73411

Differential Revision: https://developer.blender.org/D15930
2022-09-14 21:30:56 +02:00
1a48548980 BLF: Incorrect Define Used
Replace incorrect usage of GLYPH_ASCII_TABLE_SIZE with correct
KERNING_CACHE_TABLE_SIZE

See D15815 for more details.

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

Own Code.
2022-09-14 09:57:54 -07:00
5f4db28c24 Fix T100899: Drag and Drop failing depending on window position
Regression introduced in rBbbf87c4f7509, which now relies on OS coordinates for Drag and Drop.

These coordinates did not match on different OSs.
2022-09-14 13:54:51 -03:00
818c9e524d Fix: Mesh SoA format conversion skips versioning
Converting to the SoA format (T95965) immediately when reading meshes
means that none of the changes from versioning would be applied first.
This means important fixes like f14995aba7 aren't properly applied,
so modifications could be done to invalid CustomData. To fix this, move
the SoA changes into versioning code, in a new versioning_400.cc file.

Differential Revision: https://developer.blender.org/D15919
2022-09-14 11:33:35 -05:00
460fe4a10c Curves: Improve sculpting performance by reducing allocations
The snake hook and grow/shrink brushes need some arrays for input
to the length paramterization code. These were allocated and freed
for every curve. Instead, use a local buffer for each task execution.

Differential Revision: https://developer.blender.org/D15964
2022-09-14 11:18:20 -05:00
390320a151 Mesh: Fix quadratic cost for accessing normals with RNA
Same as eb3a561a7f, but for the mesh normal arrays
introduced in b7fe27314b.
2022-09-14 11:12:27 -05:00
eb3a561a7f Curves/PointCloud: Avoid quadratic cost for retrieving positions
A "lookup_int" callback needs to be provided for RNA collections
that aren't backed by DNA directly. Otherwise they will iterate from
the start of the array for every access.
2022-09-14 10:55:18 -05:00
21ed3b3258 Fix T101025: Cycles motion blur crash with changing point cloud size
Caused by 410a6efb74 which didn't properly use the
smallest size between the Cycles and Blender point clouds.
2022-09-14 09:51:27 -05:00
643e94c032 Cleanup: Add missing licence headers
Missed in eaf416693d
2022-09-14 08:54:04 -05:00
56fb2a5ed0 Cleanup: use proper bool variables in Main, instead of char. 2022-09-14 15:48:49 +02:00
Myron Carey
22bf5ba4d1 Fix T49814: Collada Import Ignores Vertex Normals
We now import and apply custom normals using a similar strategy
to the STL importer. We store custom normal data for each loop
as we read each MPoly and then apply it to the mesh after
`BKE_mesh_calc_edges()` is called.

The new behavior is optional and may be disabled in the Collada import
UI. When disabled, we use the old behavior of only using normals
to determine whether or not to smooth shade an MPoly.

----

Patch as requested in {T49814}.

The Collada import UI now has an additional checkbox, similar to the glTF and FBX import UIs:

{F13428264}

Here is a test Collada file with a simple test cube with flipped custom normals:

{F13428260}

{F13428282}

And a sphere where the two halves are disconnected geometry, but has custom normals that make the halves appear to be connected:

{F13436363}

{F13436368}

I've tested it on a number of my own meshes, and the custom normals appear to be imported
correctly. I'm not too sure about how I've plumbed the option down, though, or whether this
is the most proper way to apply custom normals.

Reviewed By: gaiaclary

Differential Revision: https://developer.blender.org/D15804
2022-09-14 15:26:11 +02:00
Joseph Micheli
8aca0da952 Fix T100684: Correct descriptions in Python API
The descriptions for view_layer_eval and scene_eval incorrectly duplicate the descriptions for view_layer and scene:

  - https://docs.blender.org/api/current/bpy.types.Depsgraph.html?highlight=depsgraph#bpy.types.Depsgraph.view_layer_eval
  - https://docs.blender.org/api/current/bpy.types.Depsgraph.html?highlight=depsgraph#bpy.types.Depsgraph.scene_eval

This patch fixes this by changing "Original" to "Evaluated."

Reviewed By: jbakker

Maniphest Tasks: T100684

Differential Revision: https://developer.blender.org/D15931
2022-09-14 15:20:53 +02:00
Germano Cavalcante
4e4daa6417 Fix T100959: Memory leak when moving node with Alt
The memory leak happens because `ED_node_link_insert` (called after the
transform operation) overwrites the pre-existing `snode->runtime->iofsd`,
losing the reference without freeing the memory.

So to "move" the reference from `snode->runtime->iofsd` to
`op->customdata`, so that each operator works with its own data.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D15948
2022-09-14 09:13:12 -03:00
10a3bfa5ee Cleanup: quiet warnings 2022-09-14 12:07:40 +02:00
a9250cb1f1 Cleanup: remove unused fields + add override 2022-09-14 12:02:27 +02:00
e4b925b9e2 Added missing license headers. 2022-09-14 11:49:48 +02:00
38a77c1400 Fix T100977: Wrong native Ukrainian language name in UI. 2022-09-14 11:37:59 +02:00
Erik Abrahamsson
609171d8b7 Optimization: Exit early when resizing material slots.
When assigning a huge number of materials, like when importing thousands of
objects, the function `BKE_objects_materials_test_all` uses quite a lot of
resources because of the way it loops through all objects to resize the
mat-array.

By counting the amount of processed objects and comparing to the number
of users of the obdata ID, we can exit early and avoid looping through
all objects every time.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15740
2022-09-14 11:00:37 +02:00
39c341bf4a Cleanup: remove redundant braces from assert & raise
autopep8 v1.7 added a space after assert & raise,
remove the braces as they aren't needed.
2022-09-14 16:18:59 +10:00
260b75a952 PyDoc: add an "Advanced" section to document WITH_PYTHON_MODULE
Document the use cases, usage and limitations
of using Blender as a Python module.
2022-09-14 15:17:51 +10:00
d26220d97a Fix reports printing twice when called from Python in background-mode
Calling operators in background-mode always printed with the
assumption that output should never be hidden.
However operators called from `bpy.ops` were also printing reports to
the `stdout` (needed for the Python console and generally useful).

Resolve by adding a flag to signal that the owner of the ReportList
is responsible for printing to the `stdout`.
2022-09-14 14:06:44 +10:00
7bd60d40ef CMake: warn when "bpy" installs into the site-packages from LIBDIR
Using "../lib" as a target is unlikely to be useful,
add a warning & suggest alternatives.
2022-09-14 14:06:41 +10:00
f74fa63b5a Cleanup: skip argument freeing when built as a Python module 2022-09-14 14:06:39 +10:00
Charlie Jolly
e1a9c16176 UI: Add Mix Node to color section of add node menu
This adds back the new mix node to the Color sections
of the add node menu.

The add menu now contains two entries for the mix node.

One under Utilites/Converter which defaults for float.

One under Color which defaults to color with `Mix Color` label.

This was moved as part of D13749.

The issue was reported on BlenderArtists.

Differential Revision: https://developer.blender.org/D15887
2022-09-13 23:06:40 +01:00
7518d30f2a Fix T100771: Incorrect strip length when timecodes are used
Some files have 2 different framerates stored in metadata. Use function
`av_guess_frame_rate` to get media FPS, because it provides more
consistent / correct values across multiple files.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D15839
2022-09-13 20:29:12 +02:00
3302b7e6a3 Fix T100998: Speed effect not rendering scene strip subframes
After change in 19bff8eb51, subframe must be calculated for function
`RE_RenderFrame` in order to render subframes.
2022-09-13 20:25:50 +02:00
08a8de739d Fix: Resolve deprecation warning when copying polygon struct
`MPoly` is used and copied in many places. To avoid the need to use a
special function for copying MPoly, or the need to add a copy
constructor, just rename the `mat_nr` field to include "legacy" in the
name. This keeps the original purpose of notifying developers that
the field shouldn't be used without any further complexity.
Apply the same fix to `bweight`.

Differential Revision: https://developer.blender.org/D15841
2022-09-13 11:43:34 -05:00
Mattias Fredriksson
eaf416693d Geometry Nodes: Port the trim curve node to the new data-block
The trim functionality is implemented in the geometry module, and
generalized a bit to be potentially useful for bisecting in the future.
The implementation is based on a helper type called `IndexRangeCyclic`
which allows iteration over all control points between two points on a
curve.

Catmull Rom curves are now supported-- trimmed without resampling first.
However, maintaining the exact shape is not possible. NURBS splines are
still converted to polylines using the evaluated curve concept.

Performance is equivalent or faster then a 3.1 build with regards to
node timings. Compared to 3.3 and 3.2, it's easy to observe test cases
where the node is at least 3 or 4 times faster.

Differential Revision: https://developer.blender.org/D14481
2022-09-13 11:36:14 -05:00
d88811aed3 Fix T100980: Missing deg update when duplicating a geometry nodetree in node editor.
Tagging depsgraph for relation rebuild does not replace tagging IDs for update.
2022-09-13 16:42:34 +02:00
109cc14dba Revert hidden object optimization in depsgraph
The internal state tracking is not fully suited for such kind
of optimization yet.

It is probably not that much work to make them work, but the
issue caused by the changes is serious enough for the studio
so it feels better to revert changes for now and have a closer
look into remaining issues without pressure.
2022-09-13 16:05:16 +02:00
8442b0ffc1 Fix T101027: Sculpt tools don't respect visibility after recent commit
Caused by b5f7af31d6, which exposed the fact that the PBVH wasn't
retrieving the updated hide status attributes if they were allocated in
sculpt mode. Previously the attributes were always allocated when
entering sculpt mode.
2022-09-13 08:35:58 -05:00
Nate Rupsis
b6ebd5591c NLA: Remove Edited Action tab from NLA panel
Removes the "Edited Action" tab for selected Action strips in the NLA
editor. It is still available in the Action editor, where it is actually
suitable/usable. Having it in the NLA got in the way of the actual NLA
strip properties.

Reviewed By: sybren, RiggingDojo

Differential Revision: https://developer.blender.org/D14964
2022-09-13 15:09:06 +02:00
34051fcc12 EEVEE: Fix volumetric resolve in large scenes.
On NVIDIA volumetric resolve failed for large production scenes.
The result would remove most color from the final render. The cause
seems to be a faulty driver.

This change ported the fragment shader to a compute shader which
would select a different compiler branch and didn't show the error.
2022-09-13 15:05:17 +02:00
Wayde Moss
b404548972 Fix: set ipo/easing in dope ignores hidden channels
Animators were not able to set channel interpolation or easing type for
channels visible in the dopesheet but hidden in the graph editor.

Bug seemed to be due to typo.
No official report, but there was a RCS on this
https://blender.community/c/rightclickselect/yWgbbc/

Reviewed By: sybren, RiggingDojo

Differential Revision: https://developer.blender.org/D10228
2022-09-13 15:03:24 +02:00
92a92fdca5 Fix T101031: Crash with Initialize Face Sets operator 2022-09-13 07:48:41 -05:00
a99a62231e obj: implement support for PBR .mtl extensions
Implement import & export support for "PBR extensions" in .mtl files
(T101029, also fixes T86736).

Newly supported parameters:
- Roughness (Pr, map_Pr)
- Metallic (Pm, map_Pm)
- Sheen (Ps, map_Ps)
- Clearcoat thickness (Pc) and roughness (Pcr)
- Anisotropy (aniso) and rotation (anisor)
- Transmittance (Tf / Kt)

Exporter has an option to enable these additional PBR parameters
export; defaults to off since not all software understands that.

Exporter UI tweaked and all material-related options were put into
their own separate box.

Added/extended test files in Subversion repository for test coverage.
2022-09-13 15:01:29 +03:00
3839a4dd84 Fix broken Cycles Metal build after recent changes
It was unable to find the Metal framework, thanks to Alaska for tracking
this down.
2022-09-13 13:52:14 +02:00
62cee24003 Fix: crash when changing to viewer context in spreadsheet 2022-09-13 13:14:29 +02:00
3c2c296130 Fix compilation error on Windows after recent change 2022-09-13 11:52:11 +02:00
Jeroen Bakker
8068b89a68 EEVEE-Next: Cryptomatte render passes.
This change adds cryptomatte render passes to EEVEE-Next. Due to the upcoming viewport
compositor we also improved cryptomatte so it will be real-time. This also allows viewing
the cryptomatte passes in the viewport directly.

{F13482749}

A surface shader would store any active cryptomatte layer to a texture. Object hash is stored
as R, Asset hash as G and Material hash as B. Hashes are only calculated when the cryptomatte
layer is active to reduce any unneeded work.

During film accumulation the hashes are separated and stored in a texture array that matches
the cryptomatte standard. For the real-time use case sorting is skipped. For final rendering
the samples are sorted and normalized.

NOTE: Eventually we should also do sample normalization in the viewport in order to extract the correct
mask when using the viewport compositor.

Reviewed By: fclem

Maniphest Tasks: T99390

Differential Revision: https://developer.blender.org/D15753
2022-09-13 11:07:38 +02:00
bb3a021427 Fix T101004: Crash when invisible object becomes visible
A regression since ac20970bc2

The issue was caused by depsgraph clearing all id->recalc flags
wrongly assuming that all IDs are fully evaluated.

This change makes it so the depsgraph becomes aware of possibly
incompletely evaluated IDs.

Differential Revision: https://developer.blender.org/D15946
2022-09-13 11:00:37 +02:00
a45c36efae Cycles: Make OSL implementation independent from SVM
Cleans up the file structure to be more similar to that of the SVM
and also makes it possible to build kernels with OSL support, but
without having to include SVM support.

This patch was split from D15902.

Differential Revision: https://developer.blender.org/D15949
2022-09-13 10:59:28 +02:00
8e03df9bbc Fix oneAPI compilation on modern Linux and CentOS 7 libraries 2022-09-13 10:55:36 +02:00
602cca671e Cycles: Include reason the oneAPI library could not be loaded
Additionally, just stick to a pure error stating. Such messages
are aimed for developers and it is rather implied that oneAPI
rendering will be disabled.
2022-09-13 10:52:18 +02:00
cca416cfe6 Fix compilation on Linux, glibc 2.34, and CentOS libraries
A continuation of previous fix for malloc hooks which got removed
from the new glibc library.

The pre-compiled jemalloc has definitions which interpose hooks
in glibc leading to linking errors with multiple hook definitions.

A simple fix is to skip doing the workaround when using jemalloc
from pre-compiled libraries.

This will likely be revisited in the future, but for now it is
important to fix compilation errors for developers.
2022-09-13 10:38:42 +02:00
146e67b2bd CMake: exclude BLI_args when building as a Python module 2022-09-13 18:03:29 +10:00
d92e14af1f Cleanup: typo in variable name 2022-09-13 18:03:09 +10:00
f78219c9a8 Cleanup: spelling in comments 2022-09-13 18:03:09 +10:00
4130f1e674 Geometry Nodes: new evaluation system
This refactors the geometry nodes evaluation system. No changes for the
user are expected. At a high level the goals are:
* Support using geometry nodes outside of the geometry nodes modifier.
* Support using the evaluator infrastructure for other purposes like field evaluation.
* Support more nodes, especially when many of them are disabled behind switch nodes.
* Support doing preprocessing on node groups.

For more details see T98492.

There are fairly detailed comments in the code, but here is a high level overview
for how it works now:
* There is a new "lazy-function" system. It is similar in spirit to the multi-function
  system but with different goals. Instead of optimizing throughput for highly
  parallelizable work, this system is designed to compute only the data that is actually
  necessary. What data is necessary can be determined dynamically during evaluation.
  Many lazy-functions can be composed in a graph to form a new lazy-function, which can
  again be used in a graph etc.
* Each geometry node group is converted into a lazy-function graph prior to evaluation.
  To evaluate geometry nodes, one then just has to evaluate that graph. Node groups are
  no longer inlined into their parents.

Next steps for the evaluation system is to reduce the use of threads in some situations
to avoid overhead. Many small node groups don't benefit from multi-threading at all.
This is much easier to do now because not everything has to be inlined in one huge
node tree anymore.

Differential Revision: https://developer.blender.org/D15914
2022-09-13 08:44:32 +02:00
4d69b6f525 Cleanup: use u-prefixed integer types (for brevity) 2022-09-13 16:29:06 +10:00
75f9b691e2 Docs: improve explanation for why CLG_exit shouldn't be called early 2022-09-13 16:01:39 +10:00
5ffa829a0e Cleanup: improve titles for CMake sections, line length
Also use same convention for comments as (space after #).
2022-09-13 13:50:21 +10:00
060da0858b CMake: omit WITH_INSTALL_PORTABLE from bpy_module.cmake
Since this was added, Linux libraries have been included in `../lib/`.
This made `make bpy` on Linux install the `bpy` module into the bundled
SVN libraries which isn't very useful.

Now leave WITH_INSTALL_PORTABLE unset (defaulting to ON).
Python developers may reference their systems Python and disable the
option if they wish for a system-wide module installation.
2022-09-13 13:30:06 +10:00
41212c1d44 CMake: omit WITH_INSTALL_PORTABLE from the 'lite' configuration
As portable is already the default, setting it meant using the lite
configuration would always reset the value if was intentionally changed.

This was also inconsistent as other configurations left this unset.
2022-09-13 13:30:06 +10:00
9189260880 Python: update defaults for "make bpy"
This was a kind of "lite" target, disabling options such as FFMPEG and
ALEMBIC which may be useful to read/write data from the Python module.

Now fewer options have been changed.
The following options are now disabled:

- Audio support (to prevent audio devices being initialized on startup).
- Input device support such as NDOF and IME as there is no GUI.
- Blender thumbnail extraction as it's not installed as part of
  the Python module.

Instead of attempting to predict what is useful to enable when building
as a Python module, developers can mix combine options e.g.
"make bpy release" or "make bpy lite".
2022-09-13 13:28:22 +10:00
03885fe120 Makefile: support 'make bpy lite' / 'make bpy release'
Re-order configuration loading so 'bpy' is loaded after others.
Needed as `bpy` disables options other configurations enable.
2022-09-13 13:28:22 +10:00
90fb212a93 Docs: improve BKE_object_defgroup_flip_map doc-string 2022-09-13 13:24:45 +10:00
1a08a26388 Cleanup: spelling in comments 2022-09-13 13:24:44 +10:00
c05ff54795 Cleanup: remove unused function 2022-09-13 13:24:42 +10:00
400151833d Nodes: Avoid unnecessary sorting when selecting or moving nodes
Previously the nodes were sorted wven when there was no change.
This is a fixed version of e3ef6a6660, which was reverted by
dc937c5aee.
2022-09-12 21:47:01 -05:00
50913d719c Cleanup: Use attribute API for curves functions 2022-09-12 21:47:01 -05:00
ddfce277e0 NLA: actionclip_add now fails on invoke if no NLA track is selected
This makes the NLA_OT_actionclip_add operation (Shift+A while mousing
over the NLA strips area) fail on invocation if no tracks are active.

This stops the annoyance of using the Shift+A menu to select an action
to add, but only getting the error after you select an action.

Differential Revision: https://developer.blender.org/D15737
2022-09-12 18:11:00 -07:00
b3e9ef1924 Fix building WITH_GHOST_WAYLAND, WITH_OPENXR (without X11)
The pre-processor blocks contained un-balanced braces, causing a syntax
error when building with WAYLAND but not X11.

Use the same number of opening & closing braces in each pre-processor
block so changes aren't as likely to break other platforms.

Also assert when unexpected states are reached.
2022-09-13 10:41:36 +10:00
ebcf004ecf Cleanup: quiet missing-variable-declarations warning 2022-09-13 10:41:36 +10:00
2c73175100 Cleanup: missing declaration warning 2022-09-13 10:41:36 +10:00
28c9b33870 IMBUF: Fix WebP Build Error and Warnings
Fix error and warnings introduced in commit 8851790dd7. Include
unistd.h for close() on Non-Windows OSs. Calm warnings about unused
argument. Return full size of image file to caller.

Own Code.
2022-09-12 17:28:19 -07:00
c8b6062d6c Update RNA to User manual mappings 2022-09-12 19:09:32 -04:00
8851790dd7 IMBUF: Improved Thumbnailing of WebP Images
Thumbnail WebP images quicker while using much less RAM.

See D15908 for more details.

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

Reviewed by Brecht Van Lommel
2022-09-12 15:42:51 -07:00
ad245f1970 Fix T101013: Reordering materials broken with only one assigned
When there was only a single material assigned to the mesh, the material
index attribute didn't necessarily exist. Changing the oder of the slots
wouldn't change the first material index as necessary.
2022-09-12 17:17:11 -05:00
ea474dda62 Fix: Node edge pan and remove on cancel doesn't work
Caused by 4a71765f9a which used an operator that didn't have the
properties it expected.
2022-09-12 16:43:54 -05:00
5bad311f4c Fix: Multires crash after recent face set refactor
Missing null check when retrieving face sets for multires automasking.
Caused by b5f7af31d6.
2022-09-12 16:12:18 -05:00
752a9b743e USD IO: fixed compiler warnings 2022-09-12 15:47:45 -04:00
bc15c83afa Fix T100886: error saving side-by-side stereo EXR image of depth pass
The stereo saving code that combines two image buffers into one did not work
correctly when the number of channels is not equal to 4.
2022-09-12 20:21:13 +02:00
100fe61f7c Sculpt: Fix T100941: Draw cache invalidation loop
PBVH draw was invalidating the draw cache even
when disabled (e.g. if modifiers exist).
2022-09-12 11:10:07 -07:00
8af59cdb16 Cleanup: obj: rename MTLMaterial & MTLTexMapType members
The members were named after .mtl file syntax ("d") instead of their
meaning ("alpha"). In preparation for extending OBJ code for more
PBR parameters support, rename them for clarity. No functionality
changes, just a pure rename.
2022-09-12 21:05:57 +03:00
8f6a07bc75 Cleanup: Comment formatting
Also include a small cleanup to the previous commit missed from review.
2022-09-12 12:54:44 -05:00
2c1650ae8f Sculpt: Fix T100608: SCULPT_UNDO_FACE_SETS broken for redo
Always swap values when restoring sculpt undo data.
2022-09-12 10:51:53 -07:00
b5f7af31d6 When these features aren't used, there is no sense in storing the
corresponding data layers and using their values for computations.
Avoiding that should increase performance in many operations that
would otherwise have to read, write, or propagate these values.
It also means decreased memory usage-- not just for sculpt mode
but for any mesh that was in sculpt mode. Previously the mask, face set,
and hide status layers were *always* allocated by sculpt mode.

Here are a few basic tests when masking and face sets are not used:

| Test | Before | After |
| Subsurf Modifier | 148 ms | 126 ms |
| Sculpt Overlay Extraction | 24 ms every redraw | 0 ms |
| Memory usage | 252 MB | 236 MB |

I wouldn't expect any difference when they are used though.

The code changes are mostly just making sculpt features safe for when
the layers aren't stored, and some changes to the conversion to and
from the hide layers. Use of the ".hide_poly" attribute replaces testing
whether face sets are negative in many places.

Differential Revision: https://developer.blender.org/D15937
2022-09-12 12:48:42 -05:00
3d3c34f345 Sculpt: Fix T101008: Missing CD_MDISPS layer
sculpt_update_object now auto-creates a CD_MDISPS layer
if missing.  Note that it is possible for the depsgraph
to provide a multires ccg context without a CD_MDISPS.
This causes a PBVH_GRIDS pbvh to be built instead of
falling back to PBVH_FACES, which is why this bug happens
(of course falling back to PBVH_FACES would still be a bug).
2022-09-12 10:33:47 -07:00
9951464571 Fix T100956: Cycles GPU context assert after recent changes
We don't need to be on the main thread to destroy the context.
2022-09-12 19:00:07 +02:00
54571003dc Fix T100016: Memory leak in USD importer.
These changes were implemented by Sonny Campbell.

Fixed the first issue by freeing the operator customdata when the import
is cancelled.

Fixed the second issue by using a character array instead of allocating
new memory for the prim_path_mask.

Differential Revision: https://developer.blender.org/D15781
2022-09-12 12:46:27 -04:00
9088a1f476 Geometry: Avoid unnecessary initialization when resizing data arrays
When resizing mesh and curves attribute storage, avoid initializing the
new memory for basic types. Also, avoid skipping "no free" layers; all
layers should be reallocated to the new size since they may be accessed.

The semantics introduced in 25237d2625 are essential for this
change, because otherwise we don't have a way to construct non-trivial
types in the new memory.

In a basic test of the extrude node, I observed a performance
improvement of about 30%, from 55ms to 42ms.

Differential Revision: https://developer.blender.org/D15818
2022-09-12 11:35:33 -05:00
225b5a3491 BLI: Add utility functions to generic spans
Generally we don't want to do per-element operations on these spans
because of the overhead of the runtime type system, but these operations
on the whole span avoid ugly pointer arithmetic in other areas.
2022-09-12 11:04:52 -05:00
e37f3388b1 Attributes: Add function to retrieve span without adding attribute
Previously, the only versions of attribute access that gave a span would
also add the attribute when it doesn't exist, which isn't always wanted.
2022-09-12 11:04:52 -05:00
ce07bc3628 Merge remote-tracking branch 'origin/blender-v3.3-release' 2022-09-12 17:13:25 +02:00
Thibault de Villèle
7c33d7b4b5 Fix T100918: change min value for NLAStrip start
The bug was contained in BKE/intern/nla.c, where the wrong macro was
used as the minimum frame value. Instead of `MINAFRAMEF`, `MINFRAMEF`
was used (the former is around -10k, the latter is 0, both fp32).

Differential Revision: https://developer.blender.org/D15940
2022-09-12 17:08:06 +02:00
038a19ce6c Fix macOS incomplete Python install after recent changes
After 2c23b4e0bf the meaning of PYTHON_LIBPATH changed.
2022-09-12 15:48:09 +02:00
16af35054d GLibC Compat: Add deprecated memory hooks symbols removed from 2.34.
Starting from GLibC 2.34, deprecated `__malloc_hook` & co. have been
removed from headers, while still present in the shared library itself.

This means that it is no more possible to build Blender with USD 22.03
on recent linux systems.

While USD 22.08 has a fix to this issue, it is unlikely to be upgraded
for Blender 3.4, and definitely not for Blender 3.3.

This commit ensures Blender can build with USD 22.03 and glibc >= 2.34.

Ref.: T99618,
https://devtalk.blender.org/t/building-blender-on-linux-using-glibc-2-34-raises-linking-errors-from-the-usd-library/24185

Patch by @brecht, many thanks.
2022-09-12 15:23:42 +02:00
ec2e866aee UI: Cleanup/Fixes of some UI messages. 2022-09-12 14:18:17 +02:00
2d069b609b Fix T100999: GPencil Copy paste stroke(s) does not respect autokeying
The operator was not checking the status of the 
Autokey button.
2022-09-12 12:13:07 +02:00
33abb68cf2 UI: add a Custom Properties panel to the View Layer tab of properties.
Although view layers aren't ID, they do support custom properties,
so not providing the UI to access them seems to be a simple oversight.
2022-09-12 10:31:53 +03:00
6d0f8d5a19 Fix T100851: Sync markers does not work for numinput
special_aftertrans_update would always use TransInfo values (not
the values_final -- we need the final values to follow numinput, snapping,
etc).

Maniphest Tasks: T100851

Differential Revision: https://developer.blender.org/D15893
2022-09-12 09:11:29 +02:00
ebc385de5f Cleanup: Remove unused DerivedMesh functions 2022-09-11 21:42:41 -05:00
94e211ced9 Fix T100874: improve uv unwrap of degenerate geometry
Provide reasonable defaults for UV unwrap for triangles with zero area:

* Three vertices are arranged in a line.
* Two vertices are at the same 3D location.
* All three vertices are at the same 3D location.

Change fixes quads / ngons which have triangulations with zero area.

Change fixes both "Angle Based" method and "Conformal" method.

Differential Revision: https://developer.blender.org/D15922
2022-09-12 14:23:22 +12:00
c9a8380426 Cleanup: remove unused ImBuf.next/prev pointers 2022-09-12 11:20:22 +10:00
f884a34cae Cleanup: replace BLI_snprintf with BLI_path_join
Also use a larger buffer to account for the unlikely case of the
buffer not being big enough for the appended directories.
2022-09-12 11:02:25 +10:00
cf9c0a4b50 Tests: add tests for leading (relative) slashes for BLI_path_join
Also note that leading slashes are kept in the doc-string.
2022-09-12 11:02:25 +10:00
caf6225a3d UV: support uv seams when computing uv islands
An edge can be marked BM_ELEM_SEAM, which means the UV co-ordinates
on either side of the edge are actually independent, even if they
happen to currently have the same value.

This commit optionally add support for UV Seams when computing islands.

Affects UV sculpt tools, individual origins, UV stitch and changing
UV selection modes etc.

Required for upcoming packing refactor which requires seam support
when computing islands.

Differential Revision: https://developer.blender.org/D15875
2022-09-12 12:27:14 +12:00
1f4dc51d09 Fix T100974: Remesh operators reset mesh properties
Caused by 21f2bacad9 which copies a few more values to
the original meshes from the "nomain" meshes. The "nomain" meshes
created from the originals need to copy some values as well.
2022-09-10 18:06:54 -05:00
8b612c6496 GPencil: Add new Set Start Point operator to context menu 2022-09-10 16:12:18 +02:00
98c4e1e590 GPencil: New Set Start point operator
This operator allows to set the start point for any cyclic stroke.

This is very handy to fit interpolation issues or
use thickness modifier.

Note: There is small change in this commit to fix
a typo error in the name of the operator.

Reviewed By: mendio, frogstomp

Maniphest Tasks: T100827

Differential Revision: https://developer.blender.org/D15881
2022-09-10 15:43:20 +02:00
2c23b4e0bf Python: on macOS, stop requiring framework for building bpy module
Build against Python from precompiled libraries by default, instead of
requiring framework from python.org package install. The resulting bpy module
can still be used with any Python install of the same version.

Use the same CMake find module as Linux. This simplifies code, and makes it
possible to manually set PYTHON_* variables in CMake configuration.

Remove WITH_PYTHON_FRAMEWORK option for regular Blender build, as this doesn't
work well due to missing required Python packages. Advanced users can still
set PYTHON_ROOT_DIR=/Library/Frameworks/Python.framework/Versions/3.10 for
the same result.
2022-09-10 13:47:48 +02:00
325eee2261 Cleanup: cycles OSL compiler warnings 2022-09-10 13:47:48 +02:00
8cb3b49e51 Cleanup: replace strncpy with BLI_strncpy
Also replace strncpy+strcat with BLI_string_join
2022-09-10 16:54:21 +10:00
489cb7fd7e Cleanup: remove unnecessary strcat use 2022-09-10 16:19:23 +10:00
c90fbbf75a WM: update comment for wm_autosave_location auto-save fallback 2022-09-10 16:19:23 +10:00
66fab6828c BKE_appdir: add function attributes 2022-09-10 15:50:49 +10:00
c34b4d35ab Fix possible NULL pointer dereference in bookmark operators
Although unlikely, the result of BKE_appdir_folder_id_create may be NULL.
Check this for bookmark operators & move writing bookmarks into a shared
utility function.
2022-09-10 15:38:51 +10:00
9877d9e145 Cleanup: remove redundant NULL checks
Checking if a property exists only makes sense for generic callbacks
that apply to multiple operators.
2022-09-10 14:54:02 +10:00
5a0447ca88 Cleanup: spelling in comments 2022-09-10 14:19:34 +10:00
eae081f8fd Cleanup: format, spelling 2022-09-10 14:17:32 +10:00
ef3c49de81 Cleanup: early return when directories can't be found
Also reduce variable scope and assert when an invalid argument
is passed to BKE_appdir_folder_id_create.
2022-09-10 14:13:07 +10:00
099ae99589 Fix: Missed return in ASSET_OT_bundle_install item enumerator
Discovered from inspection.

Differential Revision: https://developer.blender.org/D15699
2022-09-09 20:12:47 -07:00
352d55b1c8 Mesh: Avoid saving redundant generic material index attribute
This attribute is still read and written in the legacy format which
puts it inside of `MPoly`. Missed in f1c0249f34.
2022-09-09 17:58:13 -05:00
7966fb083e PyGPU: expose 'GPU_SHADER_3D_IMAGE_COLOR'
This shader is required by some addons that need to modulate the alpha of images.
2022-09-09 18:31:08 -03:00
ded4604d71 install_deps: update OpenVDB for Blender 3.4.
This has been a pain, newer OpenVDB forcefully trying to use more recent
system TBB (oneTBB) instead of the one built by this script.

Also include a few minor unrelated fixes.

Ref T99618.
2022-09-09 21:38:56 +02:00
1e1e9014cf install_deps: update OIIO/Boost/Python/NumPy versions.
OIIO: 2.3.18.0
Boost: 1.80.0
Python:3.10.6
NumPy: 1.23.2

Ref T99618.
2022-09-09 18:01:45 +02:00
8611c37f97 Cycles: Generate OSL closures using macros and a template file
This has the advantage of being able to use information about the
existing OSL closures in various places without code duplication. In
addition, the setup code for all closures was moved to standalone
functions to avoid usage of virtual function calls in preparation for GPU
support.

This patch was split from D15902.

Differential Revision: https://developer.blender.org/D15917
2022-09-09 15:47:37 +02:00
ef7c9e793e Cycles: Remove separate OSL attribute map and instead always use SVM attribute map
The SVM attribute map is always generated and uses a simple
linear search to lookup by an opaque ID, so can reuse that for OSL
as well and simply use the attribute name hash as ID instead of
generating a unique value separately. This works for both object
and geometry attributes since the SVM attribute map already
stores both. Simplifies code somewhat and reduces memory
usage slightly.

This patch was split from D15902.

Differential Revision: https://developer.blender.org/D15918
2022-09-09 15:35:44 +02:00
291c313f80 Mesh: Move bevel weight out of MVert and MEdge
As described in T95966, the goal is to move to a "struct of arrays"
approach rather than gathering an arbitrary set of data in hard-coded
structs. This has performance benefits, but also code complexity
benefits (this patch removes plenty of code, though the boilerplate
for the new operators outweighs that here).

To mirror the internal change, the options for storing mesh bevel
weights are converted into operators that add or remove the layer,
like for some other layers.

The most complex change is to the solidify modifier, where bevel
weights had special handling. Other than that, most changes are
removing clearing of the weights, boilerplate for the add/remove
operators, and removing the manual transfer of bevel weights
in bmesh - mesh conversion.

Eventually bevel weights can become a fully generic attribute,
but for now this patch aims to avoid most functional changes.

Bevel weights are still written and read from the mesh in the old way,
so neither forward nor backward compatibility are affected. As described
in T95965, writing in the old format will be done until 4.0.

Differential Revision: https://developer.blender.org/D14077
2022-09-09 08:29:47 -05:00
21f2bacad9 Cleanup: Simplify BKE_mesh_nomain_to_mesh
- Remove "take ownership" argument which was confusing and always true
  - The argument made ownership very confusing
  - Better to avoid boolean arguments that switch a function's purpose
- Remove "mask" argument which was basically wrong and not used properly
  - "EVERYTHING" was used because developers are wary of removing data
  - Instead use `CD_MASK_MESH` for its purpose of original mesh data
- Remove use of shallow copied temporary mesh, which is unnecessary now
- Split shape key processing into separate functions and use C++ types
- Copy fields explicitly rather than using memcpy for the whole struct
- Use higher level functions and avoid redundant code
  - The whole idea is pretty simple and can be built from standard logic
- Adjust `CustomData` logic to be consistent with "assign" expectations
  - Clear the layer data from the source, and moves the anonymous ID

Differential Revision: https://developer.blender.org/D15857
2022-09-09 08:29:46 -05:00
12c235a1c5 Subdiv: Avoid quadratic runtime for loose edges
Currently, when subdividing every single vertex on every loose edge,
Blender iterates over all other edges to find neighbors. This has
quadratic runtime and can be very slow. Instead, first create a
map of edges connected to each vertex.

With about 10000 edges, the performance goes from very slow to very
smooth in my tests. Because of the nature of quadratic runtime, the
improvement will depend massively on the number of elements.

The only downside to this is that the map will still be built when
there are only a couple loose edges, but that case is probably not
so common.

Differential Revision: https://developer.blender.org/D15923
2022-09-09 08:29:46 -05:00
cef1b9c30f Cleanup: remove BLI_make_file_string
This function did multiple things making it difficult to know
what was intended by the caller:

- Directory & file join.
- Expand relative '//' prefix to an optional directory.
- Expand drive letters on windows (guessing with fall-backs).
- Switch slashes to native direction.

This functionality wasn't needed as the full directory was always passed
in, so guessing the drive letter wasn't needed.

If functionality to add drive letters onto paths is needed in the future
a function that only does this can be added.
2022-09-09 23:21:00 +10:00
436f1b4dbe Correct error building on WIN32
Mistake in f7a4ede79f.
2022-09-09 23:21:00 +10:00
6039d15732 Fix Clang warning about braces around initialization 2022-09-09 15:03:36 +02:00
05f821b094 Cleanup: remove unnecessary use of BLI_make_file_string
Use BLI_join_dirfile instead, also reduce right-shift.
2022-09-09 22:43:34 +10:00
8f8ae06b51 Fix use-after-free error when exiting on WIN32
The logging API was freed before calling wm_autosave_delete that called
BKE_appdir_folder_id_create to get the auto-save location (when the
temporary directory wasn't found). Detecting BLENDER_USER_AUTOSAVE would
log details about the path, which would read data freed by CLG_exit.
Resolve by calling CLG_exit last.
2022-09-09 22:43:34 +10:00
f4e5a86544 Realtime Compositor: Implement bokeh blur node
This patch implements the bokeh blur node for the realtime compositor.
The patch is still missing the Variable Size option because it depends
on the Levels node, which is yet to be implemented. In particular, it
requires the computation of global texture properties like the maximum
color.

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

Reviewed By: Clement Foucault
2022-09-09 14:32:58 +02:00
03f33a6f23 Realtime Compositor: Allow inputs to skip realization
This patch adds support for the skip realization option of the input
descriptor. Inputs that request skip realization will not be realized on
the operation domain of the operation and will not contribute to its
computation, and consequently, they can't be a domain input.

An example is the bokeh input of the Bokeh Blur node, which is actually
a resource that is decoupled from the rest of the inputs and should not
affect or be affected by their domain.

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

Reviewed By: Clement Foucault
2022-09-09 14:22:03 +02:00
0fd39da3a9 Realtime Compositor: Implement scale node
This patch implements the Scale node for the realtime compositor.

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

Reviewed By: Clement Foucault
2022-09-09 14:11:43 +02:00
e254d8867d Outliner: Hide library overrdies context menu when no IDs are selected
The library overrides context menu operators only make sense when at
least one ID is selected in the Outliner. So don't show them unless
that's the case. This also means the menu items don't show up anymore
for things like RNA properties, or the overridden properties in the
Library Overrides Properties view.

Also see 7eda9d8dda and the previous commit.
2022-09-09 14:04:27 +02:00
860c3dce1b Outliner: Don't show asset context menu when no IDs are selected
The asset context menu operators only make sense when at least one ID is
selected in the Outliner. So don't show them unless that's the case.
This also means the menu items don't show up anymore for things like RNA
properties, or the overridden properties in the Library Overrides
Properties view.

Also see 7eda9d8dda.
2022-09-09 14:04:27 +02:00
04ae0fe46b Realtime Compositor: Implement blur node
This patch implements the blur node for the realtime compositor. The patch is
still missing the Variable Size option because it depends on the Erode/Dilate
node, which is yet to be implemented. Furthermore, there are a number of
optimizations that can be implemented, the most important of which is the IIR
implementation of the Fast Gaussian filter, as well as the use of hardware
filtering and thread local memory. The latter of which was attempted but was
not robust enough, so it will be submitted as separate patch.

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

Reviewed By: Clement Foucault
2022-09-09 13:58:54 +02:00
1339fec22a Nodes: fix memory leak 2022-09-09 13:35:21 +02:00
f15fecf0f7 Readfile: avoid confusion when debugging a memory leak 2022-09-09 13:16:28 +02:00
ac66a819c1 Realtime Compositor: Implement pixelate node
This patch implements the pixelate node for the realtime compositor.

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

Reviewed By: Clement Foucault
2022-09-09 13:15:01 +02:00
77a4bb02cc Fix T100697: Curve nodes change colors at identity settings
Shader and compositor curve nodes change their inputs even if they are
at identity settings.

That is because shader and compositor curve nodes evaluate their curve
map texture samplers at the normalized input directly, disregarding the
fact that the samplers are evaluated using linear interpolation. This
causes the output to be slightly different that it should be.

This patch remaps the evaluation parameters such that the texture
sampler is evaluated at the center of the pixels.

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

Reviewed By: Clement Foucault
2022-09-09 13:03:53 +02:00
fa0f18b37d Cleanup: readfile: use correct type 2022-09-09 12:37:02 +02:00
0817966f14 Cleanup: Remove unused attribute in draw manager.
There are no plans to use the object attribute anymore.
2022-09-09 12:24:51 +02:00
dc937c5aee Fix Auto-offset for nodes: Revert "Cleanup: Return early"
This "cleanup" commit broke Auto-offset for nodes.

This reverts commit e3ef6a6660.
2022-09-09 11:51:07 +02:00
58945b07f1 Cleanup: remove paranoid NULL checks 2022-09-09 17:46:43 +10:00
Loren Osborn
3baca31719 Fix error extracting arguments from project_source_info
Output of make encounters path names that are single-quoted. This
causes the path to be misinterpreted and fail validation.

Resolves error in "make check_cppcheck"

Ref D15801 (partially applied)
2022-09-09 17:18:11 +10:00
1e6a003860 Cleanup: move return arguments last, use r_ prefix
Also use '_num' suffix instead of '_tot'.
2022-09-09 16:20:32 +10:00
87a45db522 Edit mode normalize fails to respect locked groups
Add BKE_object_defgroup_flip_map_unlocked which excludes locked groups
from the flip-map.

Reviewed By: zanqdo, campbellbarton

Maniphest Tasks: T96787

Ref D15317
2022-09-09 16:03:02 +10:00
Nate Rupsis
43b1624eee Fix T96787: Edit mode normalize fails to respect locked groups
Add BKE_object_defgroup_flip_map_unlocked which excludes locked groups
from the flip-map.

Reviewed By: zanqdo, campbellbarton

Ref D15317
2022-09-09 15:58:49 +10:00
fb07bbb751 License headers: use SPDX identifiers 2022-09-09 15:44:03 +10:00
274dc024f6 Cleanup: format, trailing space 2022-09-09 15:38:27 +10:00
0c9749093b Cleanup: spelling in comments 2022-09-09 15:37:33 +10:00
f7a4ede79f Python: change bpy.app.binary_path behavior WITH_PYTHON_MODULE
The following changes have been made to this attribute with
WITH_PYTHON_MODULE is defined:

- Defaults to an empty string (instead of pointing to __init__.so).
- It's writable, so script authors can point to a valid Blender binary.

`where_am_i(..)` is no longer used by BKE_appdir_program_path_init,
there is now a separate code-path for setting the initial program
directory, calls after this can be used to set the binary path.
2022-09-09 14:01:41 +10:00
d455f1a0ba Cleanup: quiet conversion warning 2022-09-09 12:17:59 +10:00
ce5ad66330 GNUmakefile: change message to reference "bpy" when building as a module 2022-09-09 12:17:09 +10:00
3a01c23a84 Cleanup: cmake line length, wrapping 2022-09-09 11:52:14 +10:00
9e0c2f6867 CMake: exclude Python libs & batch scripts WITH_PYTHON_MODULE for WIN32 2022-09-09 11:33:43 +10:00
22b84424c7 Cleanup: check for Python module in BKE_appdir_program_path_init
Replace the argument with an in ifdef in BKE_appdir_program_path_init.
At the time `blenkernel` didn't define WITH_PYTHON_MODULE, since it does
now there is no need for an argument. With the minor benefit of fewer
preprocessor checks in the main() function.
2022-09-09 11:13:05 +10:00
fad7a30de3 Cleanup: comments, spelling, line length for creator's CMake file 2022-09-09 11:10:37 +10:00
81558783e4 Python: install "bpy" as a package WITH_PYTHON_MODULE
Building WITH_PYTHON_MODULE was creating a "bpy" module that required
Blenders data-files to be located in the module search path too.

This mean that a typical installation on Linux would create:

- `/usr/lib/python3.10/site-packages/bpy.so`
- `/usr/lib/python3.10/site-packages/3.4`
  (containing `scripts` & `datafiles`).

The new behavior creates:

- `/usr/lib/python3.10/site-packages/bpy/__init__.so`
- `/usr/lib/python3.10/site-packages/bpy/3.4`

With the advantage that the "bpy" directory is the self contained Python
module.

No changes are needed for the module loading logic as the mechanism to
swap in blend internal Python "bpy" module
(defined in `release/scripts/modules/bpy/__init__.py`)
works the same in both instances.

Thanks to Brecht for macOS support.

Reviewed by brecht

Ref D15911
2022-09-09 10:25:35 +10:00
Dominik Fill
4a71765f9a Fix T100521: Nodes added with link drag search not added to frame
Use macro NODE_OT_translate_attach for attaching node created through
link-drag-search to frame, as suggested by Leon Schittek (@lone_noel)
in D15888.

Differential Revision: https://developer.blender.org/D15920
2022-09-08 17:03:54 -05:00
ff8cd48418 Fix T100833: Cycles UDIM baking broken after recent changes 2022-09-08 20:24:32 +02:00
06a5741f42 Silence warnings/assert about invalid embedded IDs for older blendfiles.
there is no point in warning about files that are not supposed to be
'correct' in that regard.
2022-09-08 18:49:10 +02:00
e5a7470638 Fix: link drag search feature only works forgeometry nodes groups
The node tree used to detect if the tree was a node group wasn't the
last in the node editor's path like it should be, so the search thought
that all shader node groups weren't node groups.
2022-09-08 10:57:21 -05:00
ff7bba8dad Fix: Integer type in linear probing strategy
Probing strategies must iterate over every possible hash, but the linear
strategy only did 2^32 iterations, not 2^64. Updating this was missed
in 8cbbdedaf4. Also fix an unnecessary comma.

Differential Revision: https://developer.blender.org/D15913
2022-09-08 09:52:42 -05:00
17f37b43f1 Cleanup: Remove unused face customdata for merging meshes 2022-09-08 09:50:59 -05:00
b9727dae82 Cleanup: Remove redundant vertex duplication in extrude node
Now this is done by `Mesh::verts_for_write()`
2022-09-08 09:50:59 -05:00
59f6c60fb6 Cleanup: Remove unused variable in RNA path function
Caused by 462014b59b
2022-09-08 16:44:24 +02:00
7eda9d8dda Outliner: Hide "data operations" context menu entries unless supported
The context menu would always show a section with "Select", "Deselect",
"Hide", "Unhide" and "Select Linked" if there were no more specific
operators to show (e.g. modifier operations). For many tree elements
they did not make sense and simply would do nothing. Only show the
section for supported types.
2022-09-08 16:36:00 +02:00
8f6a38ed7e Cleanup: Simplify outliner context menu building queries
- Remove unnecessary calls to `get_element_operation_type()` (result
  wasn't used).
- Remove branches/checks for cases that couldn't possibly happen.
  (assert instead).
- Ensure all return arguments are set so caller can't make the mistake
  of forgetting that.
- Early exit instead of big `if` block.
- Use `const`.
2022-09-08 16:36:00 +02:00
406243c2fd IDManagement: change IDTypeInfo.owner_get to instead return address of the owner_id pointer.
Also rename the callback. That way, we can keep moving toward a more
generic handling of those embedded IDs (think e.g. about copy code).
2022-09-08 16:34:31 +02:00
462014b59b IDManagement: Add new BKE_id_owner_get accessor.
Essentially calls `IDTypeInfo->owner_get` for now, will make more sense
once the callback is changed to return the address of the pointer
instead.
2022-09-08 16:34:31 +02:00
4ac69c26db Fix Cycles wrong MIS logic in shade_light kernel after recent changes
Though end result was still correct. Thanks to Alaska for spotting this.
2022-09-08 15:23:21 +02:00
173d8edb0b Cleanup: make meaning of base visibility flags more clear
Rename, add comments, and use flag in the depsgraph to ensure the logic
matches.

Differential Revision: https://developer.blender.org/D15883
2022-09-08 15:23:21 +02:00
b5fc8f611e Outliner: Hide ID type filter for library overrides
a) There were two filter icons next to each other in the header which
isn't exactly professional, b) the filter was redundant since IDs are
now grouped under an ID type element ("Objects", "Collection", ...)
anyway.
In the hierarchies view it was already hidden (because the whole point
of it is to show relationships between IDs, you wouldn't want to have
any parts of the hierarchy hidden).
2022-09-08 14:19:59 +02:00
2a769e76a0 Outliner: Hide search options for library overrides hierarchies view
Searching isn't possible in the hierarchies view anymore, so the options
for it shouldn't be displayed either.
Followup to 21b92a5f31, forgot to remove these.
2022-09-08 14:10:58 +02:00
21b92a5f31 Outliner: Hide search button for library overrides hierarchies view
c9a9967903 added a workaround for performance issues in heavy
production scenes in the library overrides hierarchies view, reducing
the amounts of elements to be built. Searching for elements would still
have to build the entire tree, so Blender would essentially freeze when
searching in mentioned heavy scenes. Removing the search functionality
works around this issue for now.
2022-09-08 12:54:49 +02:00
d481fb10ef Nodes: fix handling cyclic node trees 2022-09-08 12:54:00 +02:00
5e2d139ee3 Fix Blender as a Python module for WIN32
BKE_appdir_program_path_init would override the module path extracted
from the Python module, replacing it with the Python executable.

This caused the data files not to be found and the module not to load.
2022-09-08 20:32:57 +10:00
82fc52ffc8 Console: Support page up/down and home keys for scrolling
- Page up/down scrolls up/down an entire page
- Home resets the scrolling back to the bottom.

The fact that these were missing was probably an oversight. Other
similar editors have them.

This works by including the "View2D Buttons List" keymap for the
console, which the other similar editors use as well.
2022-09-08 12:27:42 +02:00
129993c026 Fix T100887: Some C++ importers/exporters (e.g. OBJ) reset file dialog Sort By mode
A couple years ago D8598 made it so that C++ operators generally
should use "default" sort mode, which remembers previously used sort
setting. Back then all the places that needed it got changed to use
this "default" one, but since then some more IO code landed, where
seemingly by accident it used "sort by file name":

- USD importer,
- Grease Pencil exporter,
- OBJ importer & exporter,
- STL importer.

Reviewed By: Julian Eisel
Differential Revision: https://developer.blender.org/D15906
2022-09-08 13:07:31 +03:00
268e1eff8a Fix T96297: obj: improve layout of UI fields and axis validation
Implement ideas from T96297:
- Fix "invalid axis settings" (both forward & up along the same
  direction) validation: now similar to the Python based code, when
  invalid axis is applied, the other axis is changed to not conflict.
- Make axis enums be expanded inside the row, similar to Collada UI.
- Move "selected only" near the top, similar to how it's in Collada,
  USD, FBX and glTF export UIs.
- Move animation export options to the bottom.
2022-09-08 11:43:47 +03:00
ecf3287533 Fix T100822: Merging objects does not assign materials correctly
Caused by {rBf1c0249f34c4}

This is what (I think) went wrong in the above commit:
- `join_mesh_single` was writing material indices to the custom data /
attribute of the source mesh
- the `polyofs` of each mesh that was joined was not taken into account

Now, instead of using the AttributeWriter on a particular mesh, use the
CustomData (`pdata`) - that is constantly changed during joining -
directly for writing.
Otherwise we end up writing into customdata that has not been "extended"
yet (even if we use the destination mesh).
Also note that even on the destination mesh, CustomData would be freed
anyways after all calls to `join_mesh_single` took place, to be replaced
with the mentioned `pdata` which should be the single customdata to
write to here.

When doing this (writing to `pdata`), we also need to take into account
the poly offset of each contributing mesh.

Maniphest Tasks: T100822

Differential Revision: https://developer.blender.org/D15878
2022-09-08 09:06:50 +02:00
a3ddcc6b4d Cleanup: correct PyModuleDef.m_slots reference
Changed in Python 3.5, match Python's internal name.
2022-09-08 15:32:33 +10:00
8a9d1f19ab Python: ensure the runtime version is compatible WITH_PYTHON_MODULE
When Blender is built as a Python module, exit early if the major
and minor versions don't match. Without this, the error message can
be cryptic/unhelpful.
2022-09-08 14:58:16 +10:00
9f50bd20eb Fix: Spreadsheet row filters unimplemented for boolean type
This was lost in 474adc6f88
2022-09-07 23:31:46 -05:00
d593497421 Cleanup: Use C++ methods to retrieve attribute accessors
Replace `mesh_attributes`, `mesh_attributes_for_write` and the point
cloud versions with methods on the `Mesh` and `PointCloud` types.
This makes them friendlier to use and improves readability.

Differential Revision: https://developer.blender.org/D15907
2022-09-07 21:41:39 -05:00
17bc292530 Cleanup: remove ED_types.h & ACTIVE, DESELECT definitions
- ACTIVE flag is no longer in use.

- DESELECT was used in some places as an alias for false,
  even though this could arguably help readability, in practice this
  was often passed with a selection flag leading to confusing calls
  such as `select_beztriple(bezt, DESELECT, SELECT, HIDDEN)`.
  Replace SELECT/DESELECT with true/false in these cases.

- Remove ED_types.h. Add a 'SELECT' definition to DNA_anim_types.h,
  for fcurve_test, we could use a shared DNA header, or remove use of
  the define entirely in favor of typed enums.
2022-09-08 12:08:20 +10:00
c2c369ebe6 Cleanup: prefer terms verts/polys over vertices/polygons
Follows existing naming for the most part, also use "num" as a suffix
in some instances (following our naming conventions).
2022-09-08 11:34:02 +10:00
c36c403cdb Cleanup: Removed handling of unused flag in TimeMarkers
This removes the defunct handling of the ACTIVE flag in
TimeMarker::flags. It's not possible for that flag to be set though
normal operation.

Differential Revision: https://developer.blender.org/D15828
2022-09-07 18:13:05 -07:00
0a32f6b76a Fix T100863, T100875: Vertex group reading broken for recent files
This patch consists of two related fixes. The first is a simple fix for
forward compatibility, setting the Mesh.dvert pointer when writing a
file allows old Blender versions to read vertex groups from newly saved
files.

The second part is a bit uglier and more complex. Normally mesh vertex
group data is read in mesh_blend_read_data, for backward compatibility
with very old files. However, after 05952aa94d the mesh.dvert
pointer was not set, so the data was not read. Reading vertex group
layers when reading custom data is enough to fix that issue. We need to
read the data from *both* places, but BKE_defvert_blend_read cannot run
twice without memory leaks, so first try reading from custom data, then
read the pointer if that fails.

Differential Revision: https://developer.blender.org/D15905
2022-09-07 14:33:29 -05:00
e53405bf15 UI: Small Adjustments to Event Icons
Minor adjustments to event icons required after recent font changes.

See D15582 for more details and examples.

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

Reviewed by Brecht Van Lommel
2022-09-07 08:06:29 -07:00
67dcdebb3a Fix T100669: OBJ exporter does not properly export image sequence texture names
When exporting OBJ/MTL animation, texture file paths of image
sequences were not adjusted to contain the correct frame number.
Fixes T100669.

Also, the OBJ exporter was wrongly writing to the same .mtl file
for each exported frame, which is a regression compared to the
legacy Python exporter.
2022-09-07 17:56:21 +03:00
715d185dcd DRW: update test 'draw_pass_all_commands'
It was incorrectly updated in rBc226c480079fc07e3784f673b1bac4a774fe7937
2022-09-07 08:51:05 -03:00
da0c3cdbc9 DRW: fix 'bind_texture' being called in place of 'bind_image'
Error pointed out by tests.
2022-09-07 08:51:05 -03:00
967664d1ee BLI: new C++ BitVector data structure
This adds a new `blender::BitVector` data structure that was requested
a couple of times. It also replaces usages of `BLI_bitmap` in C++ code.

See the comment in `BLI_bit_vector.hh` for more details about the
advantages and disadvantages of using a bit-vector and how the new
data structure compares to `std::vector<bool>` and `BLI_bitmap`.

Differential Revision: https://developer.blender.org/D14006
2022-09-07 13:15:34 +02:00
13a7516f43 Cleanup: factor out "set default filepath" into a ED_fileselect_ensure_default_filepath
Follow up to D15904, a bunch of places had exact same logic for
"is filepath set? if not, set some default one", so factor all that out
into a separate ED_fileselect_ensure_default_filepath function.
2022-09-07 13:27:27 +03:00
97bd04d665 Fix T100797: C++ exporters do not remember the path on subsequent exports
Most/all C++ based IO code had a pattern of doing using
RNA_struct_property_is_set to check whether a default path needs to
be set. However, it returns false for properties restored from
"previous operator settings" (property restoration code sets
IDP_FLAG_GHOST flag on them, which "is set" sees and goes
"nope, not set").

The fix here is to apply similar logic as 10 years ago in the
T32855 fix (rBdb250a4): use RNA_struct_property_is_set_ex instead.

Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D15904
2022-09-07 12:57:34 +03:00
788952705c IDManagement: Add some assert to ensure lib consistency in embedded IDs.
From re-checking related code, it seems that we already always ensure
consistency of the `lib` pointer between embedded IDs and their owners.

This commit only adds some asserts in ambedded ID read code to
double-check this.
2022-09-07 11:26:11 +02:00
46642507ae Geometry Nodes: improve printing geometry set for debugging 2022-09-07 10:43:46 +02:00
ab5d0d2df3 Cleanup: Remove some references to proxies in comments/log messages.
Note that there are still some references to proxies left, in some cases
it's unclear if the code related to the comment is even still relevant,
this goes beyond mere cleanup to address then.
2022-09-07 10:27:20 +02:00
17d8028181 Nodes: add owner_tree method to nodes 2022-09-07 10:24:51 +02:00
2b43173fa9 Fix T100862: only leading deform modifiers used in weight/vertex paint.
It turns out upon close inspection that the 'deform only' mesh
only includes leading deform modifiers, rather than all of them
like crazyspace evaluation. This reduces the effect of the change
in rB9823a8f72be8 to using the fully evaluated mesh (all modifiers)
when the whole stack resulted in no topology change.
2022-09-07 11:10:41 +03:00
ddfd2b7644 Cleanup: comment unused INPUTCHANGE event 2022-09-07 16:34:44 +10:00
b5837bc948 WM: don't clear modifiers when the window is de-activated
Leave the modifiers as they were so comparing with previous modifiers
on window re-activation isn't detected as a state change.
2022-09-07 16:18:06 +10:00
8c8c102980 Fix T40059: Switching windows ignores held modifier keys
Re-enable workaround (USE_WIN_ACTIVATE) which should no longer cause
problems as of [0].

[0]: 37d835f0bc
2022-09-07 16:07:47 +10:00
857639559c CMake: add missing headers 2022-09-07 15:14:50 +10:00
3f5505b4cb Cleanup: de-duplicate bounding box center calculation 2022-09-07 15:14:50 +10:00
adb746415f Cleanup: add sections, use float literals 2022-09-07 15:14:50 +10:00
bd2b50dfa8 Cleanup: sort cmake file lists 2022-09-07 15:14:50 +10:00
7c52f18f15 Cleanup: format 2022-09-07 15:14:49 +10:00
124655547c Cleanup: GHOST/Win32 drop
- Reduce variable scope.
- Use snake-case for variables.
- Remove unnecessary counter when building file-list.
- Remove break after return.
- Use early return.
- Add missing braces.
2022-09-07 15:14:49 +10:00
be038b844c Cleanup: Tweak naming for recently added mesh accessors
Use `verts` instead of `vertices` and `polys` instead of `polygons`
in the API added in 05952aa94d. This aligns better with
existing naming where the shorter names are much more common.
2022-09-07 00:06:31 -05:00
20daaeffce UV: add new operator, uvcalc_align_rotation
Adds a new operator to automatically rotate UV Islands into alignment.

Modes:
* Auto (All edges)
* Geometry (V direction will point in geometry direction) [1]
* Edge (Rotate until selected edge is in V direction)

Also adds uv_sync_selection support to UV Randomize Transform.

Resolves: T78399
Differential Revision: https://developer.blender.org/D15820

[1] Listed as "World" in Task description.
2022-09-07 16:26:32 +12:00
18d1ef46f2 Cleanup: rename internal types for GHOST/Wayland
- Use pascel-case type names, instead of snake-case with `_t` suffix.
- Use `GWL_` prefix (short for GhostWayLand), to distinguish these
  types from ghost (`GHOST_*`) and wayland (`wl_*`) types.
- Rename `input` to `seat` (following wayland's own terminology).
- Use `wl_` prefix for wayland native variables which have locally
  defined equivalents so `GWL_Output *output` isn't confused with
  `struct wl_output *wl_output`. As the locally defined types are used
  more often this is less verbose overall.
2022-09-07 14:04:01 +10:00
ef46f5399b GHOST/Wayland: correct logging ID 2022-09-07 13:07:13 +10:00
da3d1e9165 Cleanup: spelling in comments, correct doxy slashes, replace '/w' 2022-09-07 13:04:44 +10:00
a5d65200c2 Cleanup: unused argument warning 2022-09-07 13:04:44 +10:00
ffc0e4d410 Fix building with MSVC
Correct error from [0] which built with GCC.

[0]: b8d9864518
2022-09-07 13:04:44 +10:00
b8d9864518 Cleanup: remove unused Main argument to RNA_path functions
Note that lib_override functions have kept the unused argument,
but this may be removed too. It impacts many lib_override functions
so this can be handled separately.
2022-09-07 11:07:44 +10:00
9c4c9a889d Cleanup: use 'continue' in customdata for loop, reduce right shift 2022-09-07 09:02:59 +10:00
Lukas Stockner
6951e8890a Mikktspace: Optimized port to C++
This commit is a big overhaul to the Mikktspace module, which is used
to compute tangents. I'm not calling it a rewrite since it's the
result of a lot of iterations on the original code, but pretty much
everything is reworked somehow.

Overall goal was to a) make it faster and b) make it maintainable.

Notable changes:
- Since the callbacks for requesting geometry data were a big
  bottleneck before, I've ported it to C++ and made it header-only,
  templating on the data source. That way, the compiler generates code
  specific to the caller, which allows it to inline the data source and
  specialize for some cases (e.g. subd vs. non-subd in Cycles).
- The one input parameter, an optional angle threshold, was not used
  anywhere. Turns out that removing it allows for considerable
  algorithmic simplification, removing a lot of the complexity in the
  later stages. Therefore, I've just removed the option in the new code.
- The code computes several outputs, but only one (the tangent itself)
  is ever used in Blender. Therefore, I've removed the others to
  simplify the code. They could easily be brought back if needed, none
  of the algorithmic simplifications are conflicting with them.
- The original code had fallback paths for many steps in case temporary
  memory allocation fails, but that never actually gets used anyways
  since malloc() doesn't really ever return NULL in practise, so I
  removed them.
- In general, I've restructured A LOT of the code to make the
  algorithms clearer and make use of some C++ features (vectors,
  std::array, booleans, classes), though there's still some of cleanup
  that could be done.
- Parallelized duplicate detection, neighbor detection, triangle
  tangent computation, degenerate triangle handling and tangent space
  accumulation.
- Replaced several algorithms with faster equivalents: Duplicate
  detection uses a (concurrent) hash set now, neighbor detection uses
  Radixsort and splits vertices by index pairs etc.

As for results, the exact speedup depends on the scene of course, but
let's consider the file from T97378:
- Blender 3.1 (before D14675): 6.07sec
- Blender 3.2 (with D14675): 4.62sec
- rBf0a36599007d (last nightly build): 4.42sec
- With this commit: 0.90sec

This speedup will mostly be noticed at the start of Cycles renders and,
even more importantly, in Eevee when doing something that changes the
geometry (e.g. animating) on a model using normal maps.

Differential Revision: https://developer.blender.org/D15589
2022-09-07 00:35:44 +02:00
Lukas Stockner
6b6428fcbc Cleanup: Move (edit)mesh_tangent.c to C++
This changes the two tangent-related files in BKE to C++ in preparation for the C++ Mikktspace port in D15589.
For now, they still use the original Mikktspace.

Differential Revision: https://developer.blender.org/D15636
2022-09-07 00:24:42 +02:00
043f59cb3b Fix weight paint smoothing with vertex selection.
Broken in rB2480b55f216c3137 by incorrectly converting a boolean
expression. There is also another suspect expression nearby.
2022-09-06 23:02:55 +03:00
2636f6fdee Fix T100760: No color attribute initialization when created by brush
Caused by 25237d2625.
2022-09-06 14:46:14 -05:00
f94130c94b Fix T100854, T100856: Invalid shape keys when exiting edit mode
The `mvert` pointer was passed to `bm_to_mesh_shape` and was never
reset to the beginning of the vertex array. Use spans instead to
eliminate this error completely. This also has the benefit of letting
the CustomData system handle allocation of mesh layers.
2022-09-06 14:25:48 -05:00
ced56dbc53 Fix: Restore fix for empty attributes after recent commit
3484c6d4f1 removed parts of 6e5eb46d73 by mistake,
returning no attribute when attribute data wasn't found. However, we
want that attributes can exist even on empty geometry. This commit
restores the fix and tries to make it more explicit to avoid the same
mistake again.

Differential Revision: https://developer.blender.org/D15899
2022-09-06 13:23:41 -05:00
Sonny Campbell
394c0b5ae4 Fix T99141: Crash with edit mode and copy location constraint
The constraint attempted to access mesh normals on a mesh with
wrapper type ME_WRAPPER_TYPE_BMESH. This commit reverses the if
statements so that If there is an editmesh then we use that as the
source of truth - otherwise use the evaluated mesh.

Differential Revision: https://developer.blender.org/D15809
2022-09-06 13:09:01 -05:00
e3ef6a6660 Cleanup: Return early 2022-09-06 12:14:04 -05:00
545fb528d5 Cleanup: Avoid using runtime node flag, use topology cache
It's easier to keep track of state in these algorithms if it's stored in
a central place like a set. Plus, using flags requires clearing them
beforehand. For the selected linked operators, using the topology
cache means we don't have to iterate over all links.
2022-09-06 12:14:04 -05:00
1d24586a90 Cleanup: Move select all nodes code to operator
This more specific high level functionality isn't needed
elsewhere. Move it to the operator and clean it up a bit.
2022-09-06 12:14:03 -05:00
2d38768f89 Cleanup: Use more specific function for deselecting all nodes 2022-09-06 12:14:03 -05:00
ff17131109 Fix T100841: Creating a frame node with shortcut doesn't sort nodes
Before 58c650a44c, the nodes span was rebuilt on every redraw. Now
that it's only rebuilt as necessary, we need to tag it dirty when nodes
are reordered. Relying on the order of the nodes at all isn't ideal, but
it's fairly fundamental in many areas at the moment.
2022-09-06 12:14:03 -05:00
6830ba12a8 Cleanup: Remove unnecessary node sorting, rename variables
Changing node colors shouldn't change the output of `node_sort`.
2022-09-06 12:14:03 -05:00
6d08ba8a50 Fix T100824: Cycles GPU render broken on macOS 13 Beta and Apple silicon
The recent revert of Apple silicon inlining changes to avoid long compile times
worked on macOS 12, but in macOS 13 Beta it results in render errors. This may
be a compiler bug and perhaps get fixed in time, but try to be on the safe side
and ensure Blender 3.3.0 works regardless.

This brings part of the inlining back, which brings improved performance but
also longer compiler times again. Compile time is around 2min now, where the
previous full inlining was about 5-7min.

Patch by Michael Jones.

Differential Revision: https://developer.blender.org/D15897
2022-09-06 19:11:52 +02:00
da9e685e26 Fix T100823: Do Not Load Non-Scalable Fonts
Do not allow the loading of old-style non-scalable fonts.

See D15884 for more details.

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

Reviewed by Brecht Van Lommel
2022-09-06 09:48:41 -07:00
0c242ff72b Cleanup: IDManagement: Simplify owner_get calllback of IDTypeInfo.
Now that all embedded IDs have a loopback pointer to their owner, we do
need anymore extra parameters for this accessor.
2022-09-06 18:21:16 +02:00
e46687c3aa Address to some extent issues with invalid embedded IDs in existing files.
Many existing .blend files (including startup ones) seem to have invalid
embedded IDs (they are not properly tagged with `LIB_EMBEDDED_DATA`).

We cannot `do_version` this so just fix it on the fly when detecting the
issue. User then need to re-save these files.

We also need to update some release files (default factory startup is
OK, but e.g. the VSE template one is not).

Keeping the assert is important here, as such missing flag is a critical
data corruption that can potentially have many serious consequences
throughout the ID management code.
2022-09-06 18:01:53 +02:00
e047b2618a BLI: Add new blender::Pool container
A `blender::Pool` can construct and destruct elements without reordering. Freed items memory
will be reused by next allocations.

Elements are allocated in chunks to reduce memory fragmentation and avoid reallocation.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D15894
2022-09-06 17:51:25 +02:00
0759f671ce Fix T100824: Cycles GPU render broken on macOS 13 Beta and Apple silicon
The recent revert of Apple silicon inlining changes to avoid long compile times
worked on macOS 12, but in macOS 13 Beta it results in render errors. This may
be a compiler bug and perhaps get fixed in time, but try to be on the safe side
and ensure Blender 3.3.0 works regardless.

This brings part of the inlining back, which brings improved performance but
also longer compiler times again. Compile time is around 2min now, where the
previous full inlining was about 5-7min.

Patch by Michael Jones.

Differential Revision: https://developer.blender.org/D15897
2022-09-06 17:39:08 +02:00
3484c6d4f1 Cleanup: Remove unused update custom data pointers in attribute API
Unused after 05952aa94d, 410a6efb74, and e9f82d3dc7.
2022-09-06 09:43:32 -05:00
64b10c43c4 Blender 3.3 release version bump.
Branch is frozen now and in Bcon5.
2022-09-06 16:34:45 +02:00
e3afead9aa Fix (unreported) bad handling of embedded IDs on owner copying.
Completely forgot in rBcd49fee74114 to handle the owner ID copying case
(this code now also needs to re-assign to `owner_id` pointer of the
newly copied embedded IDs to their rightful owner).
2022-09-06 16:23:06 +02:00
6f80c60ce6 Fix T100850: Regression: Gpencil: crash on material color and other properties change.
rBcd49fee74114 forgot to add proper support for calls to `ntreeAddTree`
with a NULL Main (which should generate `NO_MAIN` ntrees).
2022-09-06 16:23:06 +02:00
3dd9ab341a IDManagement: better debug checks in owner_get callbacks.
Simplify and make more efficients checks in collection one (missed
these in yesterday's commit rBcd49fee74114), add some to ShapeKey's one.
2022-09-06 16:23:06 +02:00
987c3a3e22 Merge branch 'blender-v3.3-release' 2022-09-06 16:17:34 +02:00
Josh Whelchel
74477149dd Fix T100845: wrong Cycles OptiX runtime compilation include path
Causing OptiX kernel build errors on Arch Linux.

Differential Revision: https://developer.blender.org/D15891
2022-09-06 16:11:12 +02:00
d9ea72291f Fix T100842: Display Texture Paint UVs option in UV editor not working
In 8cf52e8226 we assumed that the UV IBO's are only needed in edit mode,
however the UV lines also need to work in texture paint mode. So prefer to
use bmesh when available to fix the original bug, but don't assume the face
is hidden when there is no bmesh.

Differential Revision: https://developer.blender.org/D15895
2022-09-06 16:08:30 +02:00
e1fbb4ce89 Merge branch 'blender-v3.3-release' 2022-09-06 15:39:12 +02:00
8b11ed392c Cycles: Fix crashes in oneAPI backend for scenes not fitting in dGPU memory
Differential Revision: https://developer.blender.org/D15889
2022-09-06 15:38:15 +02:00
c226c48007 Update DRW tests
And remove retest of `GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR`.
2022-09-06 08:43:40 -03:00
b23fceff7d GPU/DRW: Fix test
Regression introduced in rB755e728a9840
2022-09-06 13:20:54 +02:00
dd41dda80e Merge branch 'blender-v3.3-release' 2022-09-06 11:53:44 +02:00
25c8d72e20 Fix T100747: Cannot add "String" attribute to mesh
Caused by {rB31365c6b9e4c}.

The new API `CustomDataAttributeProvider` just did not support
`CD_MASK_PROP_STRING`.

While strings dont perform nicely in their current form, still add
support back for the API.

Adding Strings to the supported types seems to survive just
fine, see attached example file.

Maniphest Tasks: T100747

Differential Revision: https://developer.blender.org/D15851
2022-09-06 11:44:07 +02:00
397e5c5526 GL: Require a minimum of 8 ssbo slot per shader stage
Otherwise we disable this feature. This is because some driver
does not support any vertex storage buffers but still support
8 ssbo in fragment shader.
2022-09-06 11:12:38 +02:00
d7a67e245d DRW: remove consistent debug buffer bind
This avoids the overhead of debug drawing when not debugging
anything or even not using the new draw manager.
2022-09-06 11:12:38 +02:00
6602f30225 Cleanup: early exit when the active layer disallows procedural access
Once the active layer index is reached, there is no need to keep
searching. Return early instead.
2022-09-06 17:16:04 +10:00
3ebf6a7f38 Cleanup: Remove use of designated initializers in C++ code
Does not compile on Windows.
2022-09-06 18:31:01 +12:00
6c6a53fad3 Cleanup: spelling in comments, formatting, move comments into headers 2022-09-06 16:25:20 +10:00
077ba5ac38 ShaderBuilder: Fix compilation error due to recent changes.
Added CustomData_get_layer to stub.
2022-09-06 08:18:04 +02:00
Jason Fielder
32d19f7317 MacOS: Resolve purple rendering artifacts in EEVEE materials by increasing sampler limit.
Enables a feature flag during OpenGL device initialisation on macOS, which increases the available number of texture samplers available for use within shaders. Enabling this flag removes purple rendering artifacts present in certain EEVEE materials, when the existing limit of 16 is exceeded.

This feature flag is supported on Apple Silicon and AMD GPUs, for devices supporting macOS 11.0+. Device initialisation first tests whether GL device creation with the flag is supported, if not, we fall back to standard initialisation.

Other solutions would not be trivial or incur additional performance overhead or feature limitations. Other workarounds, such as texture atlas's, could already be created by artists.

{F13245498}

{F13245497}

Reviewed By: jbakker

Maniphest Tasks: T57759, T63935

Differential Revision: https://developer.blender.org/D15336
2022-09-06 08:08:07 +02:00
d9db79dbe5 Cleanup: Move uvedit_islands to c++
Differential Revision: https://developer.blender.org/D15870
2022-09-06 15:52:26 +12:00
f0a3659900 GPU: remove 'GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR'
The only difference between `GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR`
and `GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR` is that in the vertex
shader the 2D version uses `vec4(pos, 0.0, 1.0)` and the 3D version
uses `vec4(pos, 1.0)`.

But VBOs with 2D attributes work perfectly in shaders that use 3D
attributes. Components not specified are filled with components from
`vec4(0.0, 0.0, 0.0, 1.0)`.

So there is no real benefit to having two different shader versions.
2022-09-05 19:01:02 -03:00
755e728a98 GPU: remove 'GPU_SHADER_3D_IMAGE_MODULATE_ALPHA'
`GPU_SHADER_3D_IMAGE_MODULATE_ALPHA` can be seamlessly replaced by
`GPU_SHADER_3D_IMAGE_COLOR` with no real harm done.
2022-09-05 18:11:35 -03:00
1fcc673230 Cleanup: Remove unused function
This had a specific use case relating to the `CurveEval` type
which shouldn't be necessary anymore.
2022-09-05 15:48:47 -05:00
5763918651 GPU: convert 'GPU_SHADER_2D_IMAGE_COLOR' to 3D
3D shaders work in both 2D and 3D viewports.

This shader is a good candidate to be exposed in Python.
2022-09-05 17:34:10 -03:00
4536de98d1 GPU: remove 'GPU_SHADER_2D_SMOOTH_COLOR'
The only real difference between `GPU_SHADER_2D_SMOOTH_COLOR` and
`GPU_SHADER_3D_SMOOTH_COLOR` is that in the vertex shader the 2D
version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses
`vec4(pos, 1.0)`.

But VBOs with 2D attributes work perfectly in shaders that use 3D
attributes. Components not specified are filled with components from
`vec4(0.0, 0.0, 0.0, 1.0)`.

So there is no real benefit to having two different shader versions.

This will simplify porting shaders to python as it will not be
necessary to use a 3D and a 2D version of the shaders.

In python the new name for '2D_SMOOTH_COLOR' and '3D_SMOOTH_COLOR'
is 'SMOOTH_COLOR', but the old names still work for backward
compatibility.
2022-09-05 16:34:05 -03:00
0c3953d545 GPU: remove 'GPU_SHADER_2D_IMAGE'
The only real difference between `GPU_SHADER_2D_IMAGE` and
`GPU_SHADER_3D_IMAGE` is that in the vertex shader the 2D
version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses
`vec4(pos, 1.0)`.

But VBOs with 2D attributes work perfectly in shaders that use 3D
attributes. Components not specified are filled with components from
`vec4(0.0, 0.0, 0.0, 1.0)`.

So there is no real benefit to having two different shader versions.

This will simplify porting shaders to python as it will not be
necessary to use a 3D and a 2D version of the shaders.

In python the new name for '2D_IMAGE' and '3D_IMAGE'
is 'IMAGE', but the old names still work for backward
compatibility.
2022-09-05 16:34:05 -03:00
baf2835ff7 GPU: remove 'GPU_SHADER_2D_FLAT_COLOR'
The only real difference between `GPU_SHADER_2D_FLAT_COLOR` and
`GPU_SHADER_3D_FLAT_COLOR` is that in the vertex shader the 2D
version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses
`vec4(pos, 1.0)`.

But VBOs with 2D attributes work perfectly in shaders that use 3D
attributes. Components not specified are filled with components from
`vec4(0.0, 0.0, 0.0, 1.0)`.

So there is no real benefit to having two different shader versions.

This will simplify porting shaders to python as it will not be
necessary to use a 3D and a 2D version of the shaders.

In python the new name for '2D_FLAT_COLOR'' and '3D_FLAT_COLOR'
is 'FLAT_COLOR', but the old names still work for backward
compatibility.
2022-09-05 16:34:05 -03:00
223665b994 GPU: remove 'GPU_SHADER_2D_UNIFORM_COLOR'
The only real difference between `GPU_SHADER_2D_UNIFORM_COLOR` and
`GPU_SHADER_3D_UNIFORM_COLOR` is that in the vertex shader the 2D
version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses
`vec4(pos, 1.0)`.

But VBOs with 2D attributes work perfectly in shaders that use 3D
attributes. Components not specified are filled with components from
`vec4(0.0, 0.0, 0.0, 1.0)`.

So there is no real benefit to having two different shader versions.

This will simplify porting shaders to python as it will not be
necessary to use a 3D and a 2D version of the shaders.

In python the new name for '2D_UNIFORM_COLOR'' and '3D_UNIFORM_COLOR'
is 'UNIFORM_COLOR', but the old names still work for backward
compatibility.

Differential Revision: https://developer.blender.org/D15836
2022-09-05 16:34:05 -03:00
cec67176b1 GPencil: Use correct index for start point and refactor update
The last commit offset the start point by 1.

Also, remove the update because is better to do this in each operator that need it.
2022-09-05 20:19:35 +02:00
d26a0be968 UI: Corrected Scaling of AREAMINX
Minimum horizontal area size should be scaled by UI resolution.

See D15865 for more details.

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

Reviewed by Brecht Van Lommel
2022-09-05 10:37:15 -07:00
258d385857 Cleanup: Unused variable, compiler warning 2022-09-05 12:02:21 -05:00
05952aa94d Mesh: Remove redundant custom data pointers
For copy-on-write, we want to share attribute arrays between meshes
where possible. Mutable pointers like `Mesh.mvert` make that difficult
by making ownership vague. They also make code more complex by adding
redundancy.

The simplest solution is just removing them and retrieving layers from
`CustomData` as needed. Similar changes have already been applied to
curves and point clouds (e9f82d3dc7, 410a6efb74). Removing use of
the pointers generally makes code more obvious and more reusable.

Mesh data is now accessed with a C++ API (`Mesh::edges()` or
`Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`).

The CoW changes this commit makes possible are described in T95845
and T95842, and started in D14139 and D14140. The change also simplifies
the ongoing mesh struct-of-array refactors from T95965.

**RNA/Python Access Performance**
Theoretically, accessing mesh elements with the RNA API may become
slower, since the layer needs to be found on every random access.
However, overhead is already high enough that this doesn't make a
noticible differenc, and performance is actually improved in some
cases. Random access can be up to 10% faster, but other situations
might be a bit slower. Generally using `foreach_get/set` are the best
way to improve performance. See the differential revision for more
discussion about Python performance.

Cycles has been updated to use raw pointers and the internal Blender
mesh types, mostly because there is no sense in having this overhead
when it's already compiled with Blender. In my tests this roughly
halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million
face grid).

Differential Revision: https://developer.blender.org/D15488
2022-09-05 11:56:34 -05:00
63cfc8f9f6 Cleanup: Fix unused variable warnings 2022-09-05 11:28:30 -05:00
70da5a1434 Cleanup: Remove unused code for VSE waveform drawing 2022-09-05 17:49:46 +02:00
7f70b99584 Fix VSE: accidentally commented out code
`DEG_id_tag_update` was commented out in `sequencer_meta_toggle_exec()`.
Tagging does not affect functionality now, but it should be done.
2022-09-05 17:49:46 +02:00
Germano Cavalcante
89abc14d6c Fix T81002: Images drawn with the Python gpu module no longer draw on top in the Image Editor
This reverts commit 32d4a67017 thus fixing T81002 again.

And in order not to break T81212 (again) a different fix was implemented.


Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15840
2022-09-05 12:35:42 -03:00
44619eaa32 Cleanup: make format 2022-09-05 17:25:05 +02:00
39a3d312c1 GPencil: Fix bug in set start api function
The point of the second stroke was duplicated.
2022-09-05 17:10:42 +02:00
191872a836 GPencil: Improve previous commit error checking
Better check if the strokes has more points. 

A 0 or 1 point stroke never need to set start point.
2022-09-05 17:08:23 +02:00
ffe4840c2b Cleanup: Add parameter auto_flip documentation 2022-09-05 17:04:23 +02:00
5b2720befc GPencil: Small code cleanup 2022-09-05 17:01:35 +02:00
Bastien Montagne
cd49fee741 IDMAnagement: Add owner ID pointer to embedded ones.
Add a dedicated `owner_id` pointer to ID types that can be embedded
(Collections and NodeTrees), and modify slightly come code to make
handling those more safe and consistent.

This implements first part of T69169.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15838
2022-09-05 16:12:54 +02:00
dd19d6456a EEVEE: Fix attributes node on Alpha Clip/Hashed materials
This was cause by a missing implementation of some post
processing attribute functions. Leading to unresolved reference.
2022-09-05 16:03:30 +02:00
Damien Picard
19b9ea72b0 I18n: extract keymap preferences
The per-keymap user preferences messages were not extracted. This goes
through the keymap preferences RNA, as well as Python files for UI.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15871
2022-09-05 15:37:09 +02:00
Damien Picard
dead26b577 I18n: translate untitled file names
When saving, the default file name is "untitled" regardless of
selected language. This can be translated, like many graphical
applications do.

This applies to:
- blend file
- alembic file
- collada file
- obj file
- usd file
- rendered image
- grease pencil export
- subtitles export
- other Python exports through ExportHelper

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15868
2022-09-05 15:29:20 +02:00
f70cf451ed Merge branch 'blender-v3.3-release' 2022-09-05 15:21:49 +02:00
141d5cac3a GPencil: Move Outline operator in menu
Reviewed by: Matias Mendiola
2022-09-05 15:20:20 +02:00
8000d52684 Fix T100796: wrong tangents on bezier splines with duplicate points and handles
Differential Revision: https://developer.blender.org/D15880
2022-09-05 15:20:18 +02:00
Damien Picard
a2a208d88d I18n: fix translation of status bar
- Use the proper context (Operator, since that is what the cursor
  keymap status uses)
- Add a few missing message extraction tags

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15867
2022-09-05 15:19:04 +02:00
fbf875a3da GPencil: Move Scale Thickness option in menu
The option is more logic in the Normalize group

Reviewed by: Matias Mendiola
2022-09-05 15:16:42 +02:00
404e75c165 Merge branch 'blender-v3.3-release' 2022-09-05 15:07:47 +02:00
1b216fc237 Fix T100814: Cycles wrong area light parametric texture coordinates
The fix from cefd6140f3 was for light intersection, but light sampling also
needs it.

Differential Revision: https://developer.blender.org/D15879
2022-09-05 13:25:50 +02:00
871347fd93 Fix Cycles not rendering hair without radius attributes
This was fixed in 8159e0a but accidentally reverted as part of 18b703d
2022-09-05 11:38:32 +02:00
38508f5110 GPencil: New BKE function to set stroke start point
This function allows to set the start point for cyclic strokes.

The function is required by a new modifier and operator
that are currently under development.
2022-09-05 11:03:12 +02:00
91b1ca5b7b Fix T100820: Crash renaming modifier with visibility driver 2022-09-05 10:41:15 +02:00
472d8f8e92 Merge branch 'blender-v3.3-release' 2022-09-05 10:06:31 +02:00
Clément Foucault
3ae996c293 Fix T100649: Regression: Environment texture is stretched when added to mesh
The new code was not using the correct default attribute. Add access to
`g_data.P` through `node_tex_coord_position()` to replace the old
`GPU_builtin(GPU_VIEW_POSITION)` which was used before.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15862
2022-09-05 09:21:02 +02:00
Clément Foucault
f0166bc168 Fix T100775: Regression: EEVEE world environment is stretched when using orthographic view
It was using normalized vector instead of `viewCameraVec` which account for
orthographic views.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15861
2022-09-05 09:18:44 +02:00
b0d9b6f6df Fix T100788 Regression: EEVEE wrong normal map on backfaces
This was caused by rB07cf3ce92fa2. It was missing a sign flip.
2022-09-05 09:12:12 +02:00
0ff920b777 Cleanup: Clarify multi-socket input sorting
The multi-socket input sorting was used for two purposes: moving links
to the proper positions when dragging a new link, and resetting the
multi-input indices on the links when removing a link. They are now
separated into two functions, and the sorting when making a group
node that didn't accomplish anything is removed (in that case a
proper implementation would copy the indices from the original
exterior sockets).
2022-09-03 23:25:06 -05:00
b978c1bc65 Cleanup: Replace recursive quadratic node link mute operation
The previous implementation iterated over all links multiple times
recursively. Instead, use the node tree topology cache, only iterate
over all links once, and use a stack to propagate the mute upsteam
and downstream.
2022-09-03 17:57:53 -05:00
b60850d395 Cleanup: Deduplicate node link intersection test 2022-09-03 14:52:27 -05:00
56193eccf6 Cleanup: Refactor node add reroute operator
Use C++ Map that supports the duplication natively. Use vectors instead
of linked lists, and adjust naming. Also remove combination of reroutes
for input sockets, which doesn't make sense since a reroute isn't
allowed to combine multiple input links into one output.
2022-09-03 14:19:09 -05:00
4b818b1513 Merge branch 'blender-v3.3-release' 2022-09-03 11:43:15 +02:00
a631dc5575 Fix T100731: Keymap Editor context menu crash
Caused by {rB3f3d82cfe9ce}

Since above commit, a `uiRNACollectionSearch` may contain a NULL
`search_prop`, crashing the menu entry for "Jump To Target"
(`ui_jump_to_target_button_poll`).

Now safeguard against this with a NULL check (getting search callbacks
to work for "Jump To Target" can be investigated in master).

Maniphest Tasks: T100731

Differential Revision: https://developer.blender.org/D15832
2022-09-03 11:36:57 +02:00
a50ca6a1cd Fix T100687: Geometry Attribute Convert crashes in sculpt mode
Since above commit, `BKE_id_attributes_active_get` would also return
"internal" attributes like ".hide_poly" or ".hide_vert".
As a consequence, a couple of poll functions dont return false anymore
(attribute remove, attribute convert), allowing these operators to
execute, but acting on this "internal" layers is just asking for
trouble.

In the UI, we dont see these attributes, because `MESH_UL_attributes`
checks `is_internal`, same thing we do now in
`BKE_id_attributes_active_get`.

Maniphest Tasks: T100687

Differential Revision: https://developer.blender.org/D15833
2022-09-03 11:30:51 +02:00
0348bc88e4 Cleanup: Return early 2022-09-02 19:06:12 -05:00
2d72fc0586 Cleanup: use more standard variable name for node sockets 2022-09-02 17:48:46 -05:00
4a4044ad9b Cleanup: Use separate variables for node socket locations
This will help if the locations are moved out of DNA
and require slightly more complicated access.
2022-09-02 17:46:38 -05:00
df40440d22 Cleanup: Avoid using node socket location
The location of a reroute node and its sockets should be the same,
only stored in different coordinate spaces. Because the node's location
is the ground truth, use that for finding whether the mouse is hovering.
2022-09-02 17:46:38 -05:00
cd10fb4826 Cleanup: Use references and const in node editor 2022-09-02 17:46:38 -05:00
aa08545a01 Cleanup: Use new node topology cache for sorting multi input sockets
Assuming the cost of building the cache is ammortized, this
may be be helpful because it removes some quadratic behavior.
2022-09-02 17:45:29 -05:00
a736ca33ab Cleanup: Return early 2022-09-02 16:20:01 -05:00
0b4b3abc0b Merge branch 'blender-v3.3-release' 2022-09-02 15:49:33 -05:00
831ed297d0 Fix T100767: Geometry nodes viewer node placed incorrectly
See explanation in comment.

Differential Revision: https://developer.blender.org/D15864
2022-09-02 15:48:41 -05:00
b903b74944 Cleanup: Deduplicate node link points evaluation functions 2022-09-02 15:44:05 -05:00
40d815dff6 Cleanup: Further split of node link Bezier calculation function
Now dragged handles are handled separately, and the function returns a
statically sized array by value. The functions are also renamed to be
more consistent with curve naming elsewhere in Blender.
2022-09-02 15:44:05 -05:00
21e235afc3 Fix: Ensure topology cache exists when drawing nodes
This was missed in 58c650a44c.
2022-09-02 15:44:05 -05:00
8d1e5334ec Cleanup: Split node link draw culling to separate function
This was only really used in one place, so better to just do it there
rather than requiring another argument for the handle calculation.
2022-09-02 15:44:05 -05:00
ab6702a40f Cleanup: Return early 2022-09-02 15:44:05 -05:00
4068880ffc Cleanup: Remove unnecessary struct keyword usage in node editor 2022-09-02 15:44:05 -05:00
0fb699b212 Cleanup: Remove unused struct
Unused after 217d0a1524
2022-09-02 15:44:05 -05:00
a1e01f4c02 UI: 3D Text Caret
Changes to the text caret (cursor) when editing Text objects in the
3D Viewport.

See D15797 for more details and examples.

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

Reviewed by Brecht Van Lommel
2022-09-02 13:18:09 -07:00
65a215b819 Cleanup: DRW: Fix warning in release mode 2022-09-02 21:16:42 +02:00
86e7aaead2 Cleanup: Use C++ vector types in node editor 2022-09-02 14:09:41 -05:00
58c650a44c Nodes: Use existing nodes span cache
Use cache from 25e307d725 rather
than creating a new vector on every redraw.
2022-09-02 14:09:41 -05:00
RaphaelBelmont
6f53af3a81 EEVEE: Fix Symbol error in SH_L2 Caculation
The caculation of 7th SH coefficient need a negative sign

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15635
2022-09-02 20:59:09 +02:00
2b7de49a2b EEVEE-Next: Port to new Draw Manager 2022-09-02 20:56:55 +02:00
99afbc40e7 Cleanup: Fix clang-tidy warnings: [bugprone-suspicious-memory-comparison] 2022-09-02 20:34:37 +02:00
06043c8313 Cleanup: Fix clang-tidy warnings: [modernize-redundant-void-arg] 2022-09-02 20:34:37 +02:00
73434f02c3 Cleanup: Fix clang-tidy warnings: [modernize-use-nullptr] 2022-09-02 20:34:37 +02:00
4e84fba547 Cleanup: Fix clang-tidy warnings: [modernize-use-using] 2022-09-02 20:34:37 +02:00
9c469321c5 Cleanup: Fix clang-tidy warnings: [readability-else-after-return] 2022-09-02 20:34:37 +02:00
ccf62df8b6 Cleanup: Fix clang-tidy warnings: [readability-inconsistent-declaration-parameter-name] 2022-09-02 20:34:37 +02:00
aa781f98bb Cleanup: Fix clang-tidy warnings: [bugprone-incorrect-roundings] 2022-09-02 20:34:37 +02:00
9ba04c4598 Cleanup: Fix clang-tidy warnings: [modernize-use-bool-literals] 2022-09-02 20:34:37 +02:00
361a2de6f1 Cleanup: Fix clang-tidy warnings: [modernize-deprecated-headers] 2022-09-02 20:34:37 +02:00
e0bdd171f3 Merge branch 'blender-v3.3-release' 2022-09-02 13:10:45 -05:00
d3242b772b obj: improve placement of shader nodes in imported materials
Previously for most materials (especially the ones without any
textures), the nodes were "off screen" way to the right, requiring
a view framing to even see them.

Also, as soon as multiple images were used, many nodes overlapped
one another and the connections were all a mess.

Simplify all that, and now each node type (coordinate, mapping, image,
normal map, bsdf etc.) is in it's own column, with BSDF at zero
coordinate. Each used image (along with any possible coordinate,
mapping, normal map) is it's own row. The resulting connections
are much cleaner.
2022-09-02 21:03:44 +03:00
1a641b449a BLF: Replacement of Hebrew Font
Replacement of our Hebrew font, which has bad variable weight default.

See D15846 for more details.

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

Reviewed by Brecht Van Lommel
2022-09-02 10:54:03 -07:00
e48a6fcc63 DRW-Next: Add uniform attributes (object attributes) support
This replaces the direct shader uniform layout declaration by a linear
search through a global buffer.

Each instance has an attribute offset inside the global buffer and an
attribute count.

This removes any padding and tighly pack all uniform attributes inside
a single buffer.

This would also remove the limit of 8 attribute but it is kept because of
compatibility with the old system that is still used by the old draw
manager.
2022-09-02 19:37:15 +02:00
356460f5cf Cleanup: EEVEE-Next: Use reference as suggested by MSVC 2022-09-02 19:05:48 +02:00
28d8076a2e Fix T100768: Reverse curves skips handles of middle Bezier points
Reversing Bezier handle types and positions would skip the middle point
of curves with an odd number of segments, which is still necessary to
swap in order to avoid changing the curve's shape.
2022-09-02 12:05:12 -05:00
da0bd86739 Cleanup: GPU: UniformAttribute: Improve const correctness
Removes a warning and tidy the API.
2022-09-02 19:01:12 +02:00
Clément Foucault
65ad36f5fd DRWManager: New implementation.
This is a new implementation of the draw manager using modern
rendering practices and GPU driven culling.

This only ports features that are not considered deprecated or to be
removed.

The old DRW API is kept working along side this new one, and does not
interfeer with it. However this needed some more hacking inside the
draw_view_lib.glsl. At least the create info are well separated.

The reviewer might start by looking at `draw_pass_test.cc` to see the
API in usage.

Important files are `draw_pass.hh`, `draw_command.hh`,
`draw_command_shared.hh`.

In a nutshell (for a developper used to old DRW API):
- `DRWShadingGroups` are replaced by `Pass<T>::Sub`.
- Contrary to DRWShadingGroups, all commands recorded inside a pass or
   sub-pass (even binds / push_constant / uniforms) will be executed in order.
- All memory is managed per object (except for Sub-Pass which are managed
   by their parent pass) and not from draw manager pools. So passes "can"
   potentially be recorded once and submitted multiple time (but this is
   not really encouraged for now). The only implicit link is between resource
   lifetime and `ResourceHandles`
- Sub passes can be any level deep.
- IMPORTANT: All state propagate from sub pass to subpass. There is no
   state stack concept anymore. Ensure the correct render state is set before
   drawing anything using `Pass::state_set()`.
- The drawcalls now needs a `ResourceHandle` instead of an `Object *`.
   This is to remove any implicit dependency between `Pass` and `Manager`.
   This was a huge problem in old implementation since the manager did not
   know what to pull from the object. Now it is explicitly requested by the
   engine.
- The pases need to be submitted to a `draw::Manager` instance which can
   be retrieved using `DRW_manager_get()` (for now).

Internally:
- All object data are stored in contiguous storage buffers. Removing a lot
   of complexity in the pass submission.
- Draw calls are sorted and visibility tested on GPU. Making more modern
   culling and better instancing usage possible in the future.
- Unit Tests have been added for regression testing and avoid most API
   breakage.
- `draw::View` now contains culling data for all objects in the scene
   allowing caching for multiple views.
- Bounding box and sphere final setup is moved to GPU.
- Some global resources locations have been hardcoded to reduce complexity.

What is missing:
- ~~Workaround for lack of gl_BaseInstanceARB.~~ Done
- ~~Object Uniform Attributes.~~ Done (Not in this patch)
- Workaround for hardware supporting a maximum of 8 SSBO.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15817
2022-09-02 18:45:14 +02:00
fd47fe4006 Cleanup: fix compiler warning 2022-09-02 18:33:10 +02:00
789936ea1b Merge branch 'blender-v3.3-release'
# Conflicts:
#	release/scripts/addons
2022-09-02 18:28:46 +02:00
Clément Foucault
e02e844f51 Fix T100163: Eevee: Regression: Displacement maps affected by rotation
This was an oversight as the matrix multiplication present in original
code was reversed.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15858
2022-09-02 18:21:24 +02:00
07cf3ce92f Fix T100377: EEVEE: Regression 3.2 normalmap node broken
This was caused by un-wanted normalization. This is a requirement of
the MikkTspace. The issue is that g_data.N is expected to be normalized
by many other functions and overriden by bump displacement.

Adding a new global variable containing the interpolated normal fixes the
issue AND make it match cycles behavior better (mix between bump and
interpolated normal).
2022-09-02 18:13:54 +02:00
719a0378ae Cleanup: Use NODE_STORAGE_FUNCS for compositor nodes
This patches replaces the custom node storage acessor functions from the
viewport compositor code and replaces it with NODE_STORAGE_FUNCS.
2022-09-02 18:12:31 +02:00
Clément Foucault
874e9cbab9 Fix T99528: EEVEE: Regression: Faulty shaders when using Volume Info node
Workaround the issue by adding an intermediate function. This is usually
the case when working with attributes.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15860
2022-09-02 18:11:11 +02:00
Nathan Vegdahl
49ca810bf3 Cycles: enable adaptive sampling for Sobol-Burley
This uses the same sample classification approach as used for PMJ,
because it turns out to also work equally well with Sobol-Burley.

This also implements a fallback (random classification) that should
work "okay" for other samplers, though there are no other samplers
at the moment.

Differential Revision: https://developer.blender.org/D15845
2022-09-02 17:36:58 +02:00
4bbbba5bc2 Fix Cycles scrambling distance incorrectly showing as enabled for Sobol-Burley
Contributed by Alaska.

Differential Revision: https://developer.blender.org/D15849
2022-09-02 17:36:58 +02:00
aa174f632e Cleanup: split surface/displacement/volume shader eval into separate files 2022-09-02 17:13:28 +02:00
b865339833 Cleanup: remove some unnecessary kernel feature defines
That are either unused or aren't useful for testing anymore without a
megakernel.
2022-09-02 17:13:28 +02:00
cf57624764 Cleanup: refactoring of kernel film function names and organization 2022-09-02 17:13:28 +02:00
e72b9ca556 Fix: Wrong enum used in Mix Node for factor mode
Wrong type of enum was used for factor mode in rna_nodetree.c

No functional change, thankfully the correct enum had the same value.
2022-09-02 15:42:52 +01:00
622470fbb2 Cleanup: Comments of ID's tags. 2022-09-02 16:18:43 +02:00
852995d084 Cleaunp: Reorder GPencil function parameters
It's better to keep stroke as first parameter.
2022-09-02 16:11:23 +02:00
426d6b4baa GPencil: Simplify Perimeter functions to not use RegionView3D
This makes the api more portable and not depend on 
any visual area for background tasks like future modifiers.
2022-09-02 16:07:37 +02:00
633117669b Realtime Compositor: Implement dilate erode node
This patch implements the dilate/erode node for the realtime compositor.

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

Reviewed By: Clement Foucault
2022-09-02 14:47:39 +02:00
8cfca8e1bd PyGPU: only use 3D shaders and rename string enums
Since rB6269d66da, creating formats no longer depends solely on the
shader, but now depends on the dimensions used to fill the VBOs.

This allows 3D shaders to work flawlessly when assigned dimensions are
2D.

So there's no real benefit to us having shaders that are limited to 2D
use anymore.

This limitation makes it difficult to implement other builtin shaders
as they indirectly require a 2D version.

So this commit removes the 2D versions of the builtin sahders used in
Python , renames the string enums but keeps the old enums working for
backward compatibility.

(This brings parts of the changes reviewed in D15836).
2022-09-02 09:39:09 -03:00
Clément Foucault
de818d81c3 Fix T98190: EEVEE: Very slow rendering on Intel HD Graphics 4400
This particular GPU driver does not constant fold all the way in order
to discard the unused branches.

To workaround that, we introduce a series of material flag that generates
defines that only keep used branches.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D15852
2022-09-02 13:51:43 +02:00
c8ac1280bb EEVEE-Next: Move weight layer indexes to shader shared.
Upcoming cryptomatte patch would need access to these defines. So moving
them from film_lib to shader shared. We cannot include the film_lib as
it requires images/textures to be bound that we don't need.

At the same time fixes incorrect casing (`lAYER` => `LAYER`).
2022-09-02 11:33:33 +02:00
0a85288462 Fix build error after recent Metal GPU commit
These definitions were in the patch but didn't make it to the commit.
2022-09-01 17:10:05 -05:00
af4e62a020 Cleanup: Remove duplicate declaration in GPU capabilities 2022-09-01 16:57:17 -05:00
Thomas Dinges
cc8ea6ac67 Metal: MTLShader and MTLShaderGenerator implementation.
Full support for translation and compilation of shaders in Metal, using
GPUShaderCreateInfo. Includes render pipeline state creation and management,
enabling all standard GPU viewport rendering features in Metal.

Authored by Apple: Michael Parkin-White, Marco Giordano

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15563
2022-09-01 22:28:40 +02:00
Jason Fielder
ac07fb38a1 Metal: Minimum per-vertex stride, 3D texture size + Transform feedback GPUCapabilities expansion.
- Adding in compatibility paths to support minimum per-vertex strides for vertex formats. OpenGL supports a minimum stride of 1 byte, in Metal, this minimum stride is 4 bytes. Meaing a vertex format must be atleast 4-bytes in size.

- Replacing transform feedback compile-time check to conditional look-up, given TF is supported on macOS with Metal.

- 3D texture size safety check added as a general capability, rather than being in the gl backend only. Also required for Metal.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D14510
2022-09-01 22:18:02 +02:00
Jason Fielder
5f4409b02e Metal: MTLIndexBuf class implementation.
Implementation also contains a number of optimisations and feature enablements specific to the Metal API and Apple Silicon GPUs.

Ref T96261

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D15369
2022-09-01 21:45:12 +02:00
9d59734ffd Fix build (missing include from fa40013009) 2022-09-01 21:57:42 +03:00
fa40013009 Cleanup: obj: simplify material node tree creation
As pointed out in D15827 comment, the unique_ptr usage in
ShaderNodetreeWrap related code does not sound very useful. Looking at
it, whole ShaderNodetreeWrap does not make much sense - it's only
ever created, and then immediately just one thing is fetched from it.
This very much sounds like "a function", so make it just that -
header file contains just a `create_mtl_node_tree` function, and the
whole implementation is hidden from the users. Which I've also
simplified into just a handful of freestanding functions.

No functionality or performance changes, but the code does get ~80
lines shorter.
2022-09-01 21:26:28 +03:00
16adfff1c6 Cleanup: make format 2022-09-01 19:59:55 +02:00
9a86255da8 Node Editor: Visual tweaks to node links
Several visual tweaks to node links to make them overall fit in
better with the look of the node editor:

- Change the link thickness with the zoom level to a certain degree.
- Remove the fuzziness of the node link and its shadow/outline.
- The link outline color can now be made transparent.
- Add circles at the end of dragged links when connecting to sockets.
- Improve the banding of the color interpolation along the link.
- Adjust the spacing of dashes along straight node links.

Reviewed By: Pablo Vazquez, Hans Goudey

Differential Revision: http://developer.blender.org/D15036
2022-09-01 19:48:35 +02:00
6ee3431914 Fix: Use of deprecated field in legacy MFace conversion
The material indices have been moved out of MPoly since f1c0249f34.
That conversion happens in file reading code currently, so the material
indices have to be accessed the new way everywhere.
2022-09-01 12:45:18 -05:00
08894ac929 Merge branch 'blender-v3.3-release' 2022-09-01 20:44:09 +03:00
f366d197db Fix T100737: OBJ/USD import: imported object has no active material, material has 2 users
Fixes issues in importers written in C++ (T100737):

- Materials had one reference count too much. Affected Collada,
  Alembic, USD, OBJ importers, looks like "since forever".
- Active material index was not properly set on imported meshes.
  Regression since 3.3 (D15145). Affected Alembic, USD, OBJ. Note:
  now it sets the first material as the active one, whereas
  previously the last one was set as active. First one sounds more
  "intuitive" to me.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D15831
2022-09-01 20:38:56 +03:00
82e3513a8d Merge branch 'blender-v3.3-release' 2022-09-01 17:48:06 +02:00
ad4dcfe227 Fix T100709: baking max ray distance wrong with older .blend files
Add versioning to compensate for bugfix from T97945.
2022-09-01 17:16:50 +02:00
3249853ebe Fix: Incorrect vertex group layer "construct" callback
The "set default" callback doesn't need to be defined since it falls
back to clearing the memory, but since "construct" is optional, it
needs to be defined. Mistake in 25237d2625.
2022-09-01 08:23:57 -05:00
00d2bda241 Py Docs: Document delayed setting of UI data
Blender may not apply certain UI data changes immediately when done via BPY.
This is a rather typical gotcha, better to have it documented.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D15614
2022-09-01 15:03:51 +02:00
06d2dc6be2 Cleanup: minor cleanups for sample pattern code 2022-09-01 14:57:39 +02:00
60119daef5 Cycles: remove old Sobol pattern, simplify sampling dimensions
The multi-dimensional Sobol pattern required us to carefully use as low
dimensions as possible, as quality goes down in higher dimensions. Now that we
have two sampling patterns that are at least as good, there is no need to keep
it around and the implementation can be simplified.

Differential Revision: https://developer.blender.org/D15788
2022-09-01 14:57:39 +02:00
Nathan Vegdahl
50df9caef0 Cycles: improve Progressive Multi-Jittered sampling
Fix two issues in the previous implementation:
* Only power-of-two prefixes were progressively stratified, not suffixes.
  This resulted in unnecessarily increased noise when using non-power-of-two
  sample counts.
* In order to try to get away with just a single sample pattern, the code
  used a combination of sample index shuffling and Cranley-Patterson rotation.
  Index shuffling is normally fine, but due to the sample patterns themselves
  not being quite right (as described above) this actually resulted in
  additional increased noise. Cranley-Patterson, on the other hand, always
  increases noise with randomized (t,s) nets like PMJ02, and should be avoided
  with these kinds of sequences.

Addressed with the following changes:
* Replace the sample pattern generation code with a much simpler algorithm
  recently published in the paper "Stochastic Generation of (t, s) Sample
  Sequences". This new implementation is easier to verify, produces fully
  progressively stratified PMJ02, and is *far* faster than the previous code,
  being O(N) in the number of samples generated.
* It keeps the sample index shuffling, which works correctly now due to the
  improved sample patterns. But it now uses a newer high-quality hash instead
  of the original Laine-Karras hash.
* The scrambling distance feature cannot (to my knowledge) be implemented with
  any decorrelation strategy other than Cranley-Patterson, so Cranley-Patterson
  is still used when that feature is enabled. But it is now disabled otherwise,
  since it increases noise.
* In place of Cranley-Patterson, multiple independent patterns are generated
  and randomly chosen for different pixels and dimensions as described in the
  original PMJ paper. In this patch, the pattern selection is done via
  hash-based shuffling to ensure there are no repeats within a single pixel
  until all patterns have been used.

The combination of these fixes brings the quality of Cycles' PMJ sampler in
line with the previously submitted Sobol-Burley sampler in D15679. They are
essentially indistinguishable in terms of quality/noise, which is expected
since they are both randomized (0,2) sequences.

Differential Revision: https://developer.blender.org/D15746
2022-09-01 14:57:39 +02:00
ba1bf87bd8 GPUMaterial: Make uniform attrib precompute hash and attribute safe name
This avoids redundant operation at draw time.
The per attrib hash is to be used with the future implementation.
2022-09-01 14:41:00 +02:00
06005b0870 Tweak cryptomatte channels naming to improve interoperability
Use lowercase rgba channel names which still by-passes lossy nature
of DWA compression and which also keeps external compositing tools
happy.

Thanks Steffen Dünner for testing this patch!

Differential Revision: https://developer.blender.org/D15834
2022-09-01 14:39:26 +02:00
Germano Cavalcante
cb771dbe76 PyDoc: update the shader creation examples with gpu module
The old way of creating shaders is being replaced by using
`GPUShaderCreateInfo` for more portability.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D14634
2022-09-01 08:31:56 -03:00
Germano Cavalcante
6269d66da2 PyGPU: GPUShader: implementation of 'attrs_info_get' method
With the new `attrs_info_get` method, we can get information about
the attributes used in a `GPUShader` and thus have more freedom in the
automatic creation of `GPUVertFormat`s

Reviewed By: fclem, campbellbarton

Differential Revision: https://developer.blender.org/D15764
2022-09-01 08:25:55 -03:00
05fe7ca5af Merge branch 'blender-v3.3-release' 2022-09-01 12:43:13 +02:00
df751516e1 Fix cryptomatte passes saved lossy into multilayer EXR
The DWA compression code in OpenEXR has hardcoded rules which decides
which channels are lossy or lossless. There is no control over these
rules via API.

This change makes it so channel names of xyzw is used for cryptomatte
passes in Cycles. This works around the hardcoded rules in the DWA code
making it so lossless compression is used. It is important to use lower
case y channel name as the upper case Y uses lossy compression.

The change in the channel naming also makes it so the write code uses
32bit for the cryptomatte even when saving half-float EXR.

Fixes T96933: Cryptomatte layers saved incorrectly with EXR DWA compression
Fixes T88049: Cryptomatte EXR Output Bit Depth should always be 32bit

Differential Revision: https://developer.blender.org/D15823
2022-09-01 10:37:39 +02:00
Monique Dewanchand
17501c146e Cleanup: Remove/replace View Layer macros.
This patch is a cleanup required before refactoring the view layer syncing
process {T73411}.

* Remove FIRSTBASE.
* Remove LASTBASE.
* Remove BASACT.
* Remove OBEDIT_FROM_WORKSPACE.
* Replace OBACT with BKE_view_layer_active_object.
* Replace OBEDIT_FROM_VIEW_LAYER with BKE_view_layer_edit_object.

Reviewed By: mont29

Maniphest Tasks: T73411

Differential Revision: https://developer.blender.org/D15799
2022-09-01 10:22:43 +02:00
f9c249917d Cleanup: use reference instead of copy 2022-09-01 09:57:24 +02:00
Bastien Montagne
414baf9780 Fix invalid memory handling in C++ OBJ MTL Importer.
An ID created with regualr ID management code should never ever be
directly freed directly.

For embedded nodetrees, there is a dedicated function.

Reviewed By: aras_p

Differential Revision: https://developer.blender.org/D15827
2022-09-01 09:17:02 +02:00
9806672e86 Fix: Build error in Cycles with OpenVDB turned off 2022-08-31 18:06:13 -05:00
3a605b23d0 Fix T100708: Cycles bake of diffuse/glossy color not outputting alpha 2022-08-31 20:51:50 +02:00
b9998541e1 Fix part of T100626: Cycles not using tiles for baking
Leading to excessive memory usage compared to Blender 2.93. There's still
some avoidable memory usage remaining, due to the full float buffer in the
new image editor drawing and not loading the cached EXR from disk in tiles.

Main difficulty was handling multi-image baking and disk caches, which is
solved by associating a unique layer name with each image so it can be
matched when reading back the image from the disk.

Also some minor header changes to be able to use RE_MAXNAME in RE_bake.h.
2022-08-31 20:04:14 +02:00
e665f0f497 Fix T100714: Cycles volume render artifacts with negative value grids
The volume bounds were not constructed correctly in this case.
2022-08-31 20:04:14 +02:00
d7b33cd8c8 Sculpt: Fix T100479: Memory corruption in sculpt_boundary_edit_data_init 2022-08-31 10:20:30 -07:00
70f1711324 Mesh: Remove unnecessary copy in modifier stack
These few lines making a copy of the final mesh were confusing.
The goal (I'm fairly certain) is to make sure the cage mesh and final
mesh aren't shared when applying the vertex coordinates to the final
mesh. This can be done more simply though, in a way that avoids
duplicating the final mesh if it already isn't shared.

This works well in some basic tests with different modifiers. Though
I doubt it was really a bottleneck anywhere, simplifying the modifier
stack internals is always nice.

Differential Revision: https://developer.blender.org/D15814
2022-08-31 12:12:09 -05:00
91d9f46aec Cleanup: Use const for node data in compositor
Push the const usage a bit further for compositor nodes, so that they
are more explicit about not modifying original nodes from the editor.

Differential Revision: https://developer.blender.org/D15822
2022-08-31 12:06:13 -05:00
fae955fdb1 Fix merge error. 2022-08-31 10:04:23 -07:00
ab8240fcff Fix submodule refs 2022-08-31 10:02:42 -07:00
373e69b94e Merge branch 'blender-v3.3-release' 2022-08-31 09:46:33 -07:00
cdc0be48c9 Cleanup: fix warnings from vcol limit commit 2022-08-31 09:43:52 -07:00
e6557785ed Fix: crash on undo due to missing node declaration
This was broken in {rB25e307d725d0b924fb0e87e4ffde84f915b74310}.
2022-08-31 18:35:07 +02:00
0a4249561c Fix compile error from merge. 2022-08-31 09:08:35 -07:00
2f729bc111 Fix T98525: depsgraph for indirectly referenced ID Properties in drivers.
If the RNA path of a Single Property variable goes through a pointer
to a different ID, the property should be attached to that ID using
the owner reference in the RNA pointer. This already happened when
building some, but not all of the relations and nodes.

This patch fixes the remaining cases.

Differential Revision: https://developer.blender.org/D15323
2022-08-31 19:00:38 +03:00
f987d9b758 Merge branch 'blender-v3.3-release' 2022-08-31 08:33:23 -07:00
30ec628d43 UI: Fix Geometry Nodes "Is Face Planar" name
Old name: "Face is Planar"
New name: "Is Face Planar"

This follows the current convention (Is Shade Smooth, Is Viewport, ...).
2022-08-31 17:31:04 +02:00
db98007c3a UI: Fix Geometry Nodes "Mesh to Volume" name (typo)
Old name: "Mesh To Volume"
New name: "Mesh to Volume"

This is consistent with what we do for the other nodes
(Mesh to Curve, Mesh to Points).
2022-08-31 17:30:39 +02:00
a6ba8e5f38 Core: Remove color attribute limit from CustomData API
Note: does not fix the limit in PBVH draw which is
caused by VBO limits not MAX_MCOL.
2022-08-31 08:29:16 -07:00
2a13ce1e61 Fix T100700: Compositor crashes when disabled then enabled
The viewport compositor crashes when it is disabled then enabled after
the compositor node tree is edited.

This happens because the compositor engine uses the view_update callback
of the draw engine type to detect changes in the node tree and reset its
state for future evaluation. However, the draw manager only calls the
view_update callback for enabled engines, so the compositor never
receives the needed updates to properly reset its state and then crashes
at draw time.

This patch call the view_update callback for all registered engines
regardless if they are enabled or not, that way, they always receive
the potentially important updated needed to maintain a correct state.

Aside from the compositor engine, this change affects the EEVEE and
Workbench engines because they are the only engines that utilizes this
callback. However, both of them only reset a flag that is checked at
draw time. So the change should have no side effects. For the EEVEE
engine, we just add a null check in case it was not instanced, while
Workbench already have the appropriate null check.

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

Reviewed By: Clement Foucault
2022-08-31 16:59:54 +02:00
370b17a8c6 Merge remote-tracking branch 'origin/blender-v3.3-release' 2022-08-31 16:30:57 +02:00
0864ab5248 UI: Fix order of Geometry Nodes in the Add Nodes Mesh menu 2022-08-31 16:29:13 +02:00
ae79bc490a GPencil: Apply Brush Size to Outline thickness while drawing
The new factor allows to apply the current brush size to the
external stroke perimeter conversion done in draw mode.
2022-08-31 16:18:08 +02:00
097ed6565e Merge branch 'blender-v3.3-release' 2022-08-31 16:10:59 +02:00
f1c0249f34 Mesh: Move material indices to a generic attribute
This patch moves material indices from the mesh `MPoly` struct to a
generic integer attribute. The builtin material index was already
exposed in geometry nodes, but this makes it a "proper" attribute
accessible with Python and visible in the "Attributes" panel.

The goals of the refactor are code simplification and memory and
performance improvements, mainly because the attribute doesn't have
to be stored and processed if there are no materials. However, until
4.0, material indices will still be read and written in the old
format, meaning there may be a temporary increase in memory usage.

Further notes:
* Completely removing the `MPoly.mat_nr` after 4.0 may require
  changes to DNA or introducing a new `MPoly` type.
* Geometry nodes regression tests didn't look at material indices,
  so the change reveals a bug in the realize instances node that I fixed.
* Access to material indices from the RNA `MeshPolygon` type is slower
  with this patch. The `material_index` attribute can be used instead.
* Cycles is changed to read from the attribute instead.
* BMesh isn't changed in this patch. Theoretically it could be though,
  to save 2 bytes per face when less than two materials are used.
* Eventually we could use a 16 bit integer attribute type instead.

Ref T95967

Differential Revision: https://developer.blender.org/D15675
2022-08-31 09:09:01 -05:00
d4d14df38c Release schedule: Blender 3.3 RC
The branch is now in Bcon4, critical bug fixes only.
2022-08-31 16:08:26 +02:00
3e73afb536 Merge branch 'blender-v3.3-release' 2022-08-31 15:34:44 +02:00
b1231e616a Cycles: Enforce Windows driver version requirements for sycl
sycl/L0 runtime reports compute-runtime version since Intel graphics
driver 101.3268 on Windows, when querying driver version from sycl.
Prior to this driver, it was 0. Now we can bump minimum requirement to
this one and filter-out devices returning 0.

Maniphest Tasks: T100648
2022-08-31 15:33:16 +02:00
310a43bcac Cleanup: Resolve unused-lambda-capture warning 2022-08-31 15:20:45 +02:00
ac20970bc2 Depsgraph: optimize out evaluation of hidden objects
This change makes it so that objects which are temporary hidden from
the viewport (the icon toggle in outliner) do not affect on the
performance of the viewport.

The attached file demonstrates the issue. Before this change hiding
the object does not change FPS, after this change FPS goes high when
the object is hidden.

F13435936

Changing the object temporary visibility is already expected to tag
scene for bases updates, which flushes down the stream to the object
visibility update. So the only remaining topic was to ensure the
graph does a special round of visibility update on such changes.

Differential Revision: https://developer.blender.org/D15813
2022-08-31 15:11:18 +02:00
5a1b733a67 Fix unnecessary modifier visibility re-evaluation
While it is hard to measure the performance impact accurately, there
is no need to perform per-modifier string lookup on every frame update.

Implemented as an exceptional case in the code which flushes updates to
the entire component. Sounds a bit suboptimal, but there are already
other exception cases handled in the function.

Differential Revision: https://developer.blender.org/D15812
2022-08-31 15:11:18 +02:00
c1e342136d UI: Add shift-click hint to library overrides button tooltip
This information was missing and made the feature hard to discover.
2022-08-31 15:04:43 +02:00
773241add9 Merge branch 'blender-v3.3-release' 2022-08-31 14:47:52 +02:00
24fe659224 LibOverride: Replace linked objects by their overrides when created from 3DView.
From the 3DView code has basically no knowledge of collection hierarchy,
so we can either not remap any local usage of linked objects that are
being overridden, or remap them in all their local collections.

The second behavior makes most sense in the vast majority of cases.

Note that this was only an issue when directly linking and overriding
objects, not when doing so through collections.
2022-08-31 14:44:55 +02:00
4b9d7b71e0 Fix: incorrect detection of used sockets 2022-08-31 14:41:57 +02:00
627e8ad682 Fix: missing vector clear
Otherwise, these vectors are never cleared, leading to crashes
down the line.
2022-08-31 13:57:08 +02:00
d3f07998ed Cleanup: simplify debugging
This makes it easy to set breakpoints where false is returned.
2022-08-31 13:57:08 +02:00
81d82427b5 Merge branch 'blender-v3.3-release' 2022-08-31 12:38:13 +02:00
d210ab90d4 Fix crash in liboverride operations from the Outliner.
Checks for 'invalid' selected IDs that need to be skipped were
incomplete, and one was missing the actual return statement.
2022-08-31 12:36:54 +02:00
25e307d725 Nodes: move NodeTreeRef functionality into node runtime data
The purpose of `NodeTreeRef` was to speed up various queries on a read-only
`bNodeTree`. Not that we have runtime data in nodes and sockets, we can also
store the result of some queries there. This has some benefits:
* No need for a read-only separate node tree data structure which increased
  complexity.
* Makes it easier to reuse cached queries in more parts of Blender that can
  benefit from it.

A downside is that we loose some type safety that we got by having different
types for input and output sockets, as well as internal and non-internal links.

This patch also refactors `DerivedNodeTree` so that it does not use
`NodeTreeRef` anymore, but uses `bNodeTree` directly instead.

To provide a convenient API (that is also close to what `NodeTreeRef` has), a
new approach is implemented: `bNodeTree`, `bNode`, `bNodeSocket` and `bNodeLink`
now have C++ methods declared in `DNA_node_types.h` which are implemented in
`BKE_node_runtime.hh`. To make this work, `makesdna` now skips c++ sections when
parsing dna header files.

No user visible changes are expected.

Differential Revision: https://developer.blender.org/D15491
2022-08-31 12:16:13 +02:00
5a60535a20 GPUCapabilities: Add GPU_shader_draw_parameters_support
This checks for the availability of `gl_BaseInstanceARB` or equivalent.

Disabling for any workaround that disables shader_image_load_store_support
as a preventive measure.
2022-08-31 11:35:18 +02:00
41f439a737 Merge branch 'blender-v3.3-release' 2022-08-31 10:29:35 +02:00
6177d9f0c8 Fix: reverse uv lookup fails due to floating point accuracy issues
The case when the query uv is almost on an edge but outside of any
triangle was handled before. Now the case where the query uv is
almost on an edge but inside more than one triangle is handled as well.
2022-08-31 10:28:35 +02:00
68f234b8ab Cleanup: obj: simplify import/export syntax handling code
I want to add support for PBR materials extension to OBJ, but the way
current I/O code syntax handling was done made it quite cumbersome
to extend the number of MTL textures/parameters.

Simplify all that by removing FormatHandler template on "syntax"
that gets routed through keyword enums, and instead just have
simple `write_obj_*` and `write_mtl_*` functions.

Simplify MTLMaterial to not contain a map of textures (that is always
fully filled with all possible textures), instead now there's
a simple array. Rename `tex_map_XX` to `MTLTexMap`.

All this does not affect behavior or performance, but it does result
in 170 fewer lines of code, and saves a couple kilobytes of executable
size.
2022-08-31 11:18:34 +03:00
caa352bc45 Merge branch 'blender-v3.3-release' 2022-08-31 09:44:15 +02:00
e2deee73ab Update freedesktop file.
Add new features for upcoming Blender 3.3 and also missing 3.2 notes, which were not merged to master.
2022-08-31 09:42:17 +02:00
60576fba11 Fix resource leak dropping files in GHOST/Win32
Early returns in error cases missed calling ReleaseStgMedium for
getDropDataAsFilenames, getDropDataAsString & getDropDataAsString.
2022-08-31 16:28:32 +10:00
a0ff2be199 Cleanup: remove pointless strcpy return value check 2022-08-31 16:12:24 +10:00
70035e6473 Cleanup: break before the default case in switch statements
While missing the break before a default that only breaks isn't
an error, it means adding new cases needs to remember to add the
break for an existing case, changing the default case will also
result in an unintended fall-through.

Also avoid `default:;` and add an explicit break.
2022-08-31 16:01:29 +10:00
ff651a08b5 Fix returning a freed context when initialization fails for GHOST/Win32 2022-08-31 14:55:47 +10:00
4df3cf020b Fix uninitialized variable use for ID3D11RenderTargetView
When 'm_render_target' was NULL, backbuffer_res would be used without
being assigned. While it seems likely this code-path is rarely used
(if at all), resolve the logical error.
2022-08-31 14:55:47 +10:00
065a1cd0b1 Cleanup: check GetKeyboardState succeeds before using it's values
Quiets compiler warning.
2022-08-31 14:55:39 +10:00
e9d4a20a59 Cleanup: tablet press could fall through to release on GHOST/Win32
Introduced in [0], checking the logic here, there seems to be no reason
a press event should ever run release logic, relocate break statement.

In practice this was unlikely to cause problems as peeking into press
events would need to fail, peeking into release would need to succeed.
Even so, better avoid accidental fall through in switch statements.

[0]: 6f158f834d
2022-08-31 14:36:44 +10:00
8bfb65e254 Cleanup: remove 'else' after return 2022-08-31 14:36:44 +10:00
c4a16389bc Cleanup: use bool for GHOST_SystemWin32::setConsoleWindowState return 2022-08-31 14:36:44 +10:00
0f8ebd21e3 Cleanup: reduce scope, quiet unused variable warnings
When building without thumbnails some variables weren't used,
reduce their scope as well as the BlPath sub-string.
2022-08-31 14:26:47 +10:00
876d1bfe4e Cleanup: quiet MSVC warning using flag flag operations on boolean
While harmless it wasn't clear if other bits might be set but ignored,
assign the value instead.
2022-08-31 14:26:46 +10:00
68d85ce208 Cleanup: format 2022-08-31 13:52:44 +10:00
cae50c83c6 Cleanup: split font datafile loading into a function
Also use more descriptive/conventional variable names.
2022-08-31 12:50:08 +10:00
657b92c888 BLF: use existing stat from 'direntry' for directory check 2022-08-31 12:42:41 +10:00
dc733cf17d Merge branch 'blender-v3.3-release' 2022-08-31 10:02:45 +08:00
fec90a5d58 GPencil: Fix sharp_threshold property in sample stroke operator
The property registration was missing in the operator, now fixed.
2022-08-31 10:02:09 +08:00
66fecfcda6 LineArt: Fix (unreported) wrong index in weight transfer
Line art now uses global index for vertices but needs to have
local index in order to do correct weight transfer.
2022-08-31 10:02:09 +08:00
Charlie Jolly
bfa0ee13d5 Node: Mix node
This patch is a response to T92588 and is implemented
as a Function/Shader node.

This node has support for Float, Vector and Color data types.

For Vector it supports uniform and non-uniform mixing.

For Color it now has the option to remove factor clamping.

It replaces the Mix RGB for Shader and Geometry node trees.

As discussed in T96219, this patch converts existing nodes
in .blend files. The old node is still available in the
Python API but hidden from the menus.

Reviewed By: HooglyBoogly, JacquesLucke, simonthommes, brecht

Maniphest Tasks: T92588

Differential Revision: https://developer.blender.org/D13749
2022-08-31 00:13:57 +01:00
0331a8c67c Cleanup: Remove redundant addition of attribute
The radius attribute is aleady added in `pointcloud_random`.
2022-08-30 17:03:04 -05:00
b5bc086864 Cleanup: Avoid using geometry component unnecessarily 2022-08-30 17:00:36 -05:00
7bfabc6444 Cleanup: Remove unused point cloud function
This can be done more intuitively with a "copy parameters" function
like `curves_copy_parameters` or `BKE_mesh_copy_parameters` anyway.
2022-08-30 16:52:30 -05:00
d94a11ed79 Curves: Avoid unnecessarily initializing new positions layer
When creating a curves data-block, one is expected to set the new
position values. We can slightly improve performance by avoiding
doing that redundantly.

Similar to cccc6d6905.
2022-08-30 16:49:24 -05:00
4c91c24bc7 Attributes: Avoid unnecessarily initializing new attributes
The "write_only" (i.e. no reading) API function expects the caller to
set values for all new attribute elements, so using calloc or setting
 the default value first is redundant. In theory this can improve
performance by avoiding an extra pass over the array. I observed a
6% improvement in a basic test with the mesh to points node:
from 47.9ms to 45ms on average.

See 25237d2625 for more info.
Similar to cccc6d6905.
2022-08-30 16:45:00 -05:00
cccc6d6905 Mesh: Avoid redundant custom data layer initialization
In all these cases, it was clear that the layer values were set right
after the layer was created anyway. So there's no point in using
calloc or setting the values to zero first.

See 25237d2625 for more info.
2022-08-30 16:27:43 -05:00
47d105f6ad Merge branch 'blender-v3.3-release' 2022-08-30 15:39:30 -05:00
d9c48d94e4 Fix: Potential name clash when adding rest position attribute
If a "rest_position" attribute already existed, potentiall with another
type, the next name "rest_position.001" would be used, which might
even conflict with a name on another domain. Use the C++ attribute
API instead, which has more standard/predictable behavior.
2022-08-30 15:38:38 -05:00
bcd671e565 Cleanup: Use C++ attribute API 2022-08-30 15:32:10 -05:00
3090edfecf Cleanup: Use standard variable name for curve points 2022-08-30 15:32:10 -05:00
4944167dee GPUBatch: Add multi_draw_indirect capability and indirect buffer offset
This is for completion and to be used by the new draw manager.
2022-08-30 22:26:11 +02:00
f5ea2a6434 GPUTexture: Add type correct GPU_SAMPLER_MAX constant for C++
This avoid having to cast when using it in `.cc` and `.hh` files.
2022-08-30 22:26:11 +02:00
36e74cc4f7 GPUMaterial: Expose debug name getter
This also makes it mandatory, but reduced length for release.
2022-08-30 22:26:11 +02:00
da03c1f96d GPUCodegen: Do not rely on auto resource location
This allows the render engine to expect non-overlapping resources in the
generated create info.
Textures are indexed from 0 and up.
Nodetree ubo is bound to slot 0.
Uniform attributes ubo is bound to slot 1.
2022-08-30 22:26:11 +02:00
b15f90bf85 GPUBatch: Add draw parameter getter
This is used to populate indirect draw commands in the draw manager.
2022-08-30 22:26:11 +02:00
fe195f51d1 GPUStorageBuf: Add read() function to readback buffer data to host
This is not expected to be fast. This is only for inspecting the content
of the buffer for debugging or validation purpose.
2022-08-30 22:26:11 +02:00
25237d2625 Attributes: Improve custom data initialization options
When allocating new `CustomData` layers, often we do redundant
initialization of arrays. For example, it's common that values are
allocated, set to their default value, and then set to some other
value. This is wasteful, and it negates the benefits of optimizations
to the allocator like D15082. There are two reasons for this. The
first is array-of-structs storage that makes it annoying to initialize
values manually, and the second is confusing options in the Custom Data
API. This patch addresses the latter.

The `CustomData` "alloc type" options are rearranged. Now, besides
the options that use existing layers, there are two remaining:
* `CD_SET_DEFAULT` sets the default value.
  * Usually zeroes, but for colors this is white (how it was before).
  * Should be used when you add the layer but don't set all values.
* `CD_CONSTRUCT` refers to the "default construct" C++ term.
  * Only necessary or defined for non-trivial types like vertex groups.
  * Doesn't do anything for trivial types like `int` or `float3`.
  * Should be used every other time, when all values will be set.

The attribute API's `AttributeInit` types are updated as well.
To update code, replace `CD_CALLOC` with `CD_SET_DEFAULT` and
`CD_DEFAULT` with `CD_CONSTRUCT`. This doesn't cause any functional
changes yet. Follow-up commits will change to avoid initializing
new layers where the correctness is clear.

Differential Revision: https://developer.blender.org/D15617
2022-08-30 14:56:05 -05:00
d81e947c59 BLF: Fallback Stack Error Handling
Properly handle invalid fonts.

See D15798 for more details

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

Reviewed by Brecht Van Lommel
2022-08-30 11:31:11 -07:00
627bd4c46a Merge branch 'blender-v3.3-release' 2022-08-30 20:21:09 +02:00
f20d0de3b7 Fix T93084: Area stretch overlay full red on large scale mesh
Issue arises when face areas are really large combined with small UV
areas (report has a mesh ~1.5 km), then precission of shorts is
insufficient.

Now use floats instead.
This also removes this negative signed version of the total area ratio
(since with floats it is no longer used).

Thx @brecht for a lot of hand-holding!

NOTE: this is an alternative to D15805 (and quick tests show this does
not introduce the tiny performance hit as D15805 did).

Maniphest Tasks: T93084

Differential Revision: https://developer.blender.org/D15810
2022-08-30 20:16:30 +02:00
6f52a118a0 Fix: Build error on windows 2022-08-30 13:06:09 -05:00
934b9277be Fix build error from missing include 2022-08-30 12:47:21 -05:00
82a46ea6f8 Geometry Nodes: Use separate field context for each geometry type
Using the same `GeometryComponentFieldContext` for all situations,
even when only one geometry type is supported is misleading, and mixes
too many different abstraction levels into code that could be simpler.
With the attribute API moved out of geometry components recently,
the "component" system is just getting in the way here.

This commit adds specific field contexts for geometry types: meshes,
curves, point clouds, and instances. There are also separate field input
helper classes, to help reduce boilerplate for fields that only support
specific geometry types.

Another benefit of this change is that it separates geometry components
from fields, which makes it easier to see the purpose of the two concepts,
and how they relate.

Because we want to be able to evaluate a field on just `CurvesGeometry`
rather than the full `Curves` data-block, the generic "geometry context"
had to be changed to avoid using `GeometryComponent`, since there is
no corresponding geometry component type. The resulting void pointer
is ugly, but only turns up in three places in practice. When Apple clang
supports `std::variant`, that could be used instead.

Differential Revision: https://developer.blender.org/D15519
2022-08-30 11:08:27 -05:00
4d107041ec Merge branch 'blender-v3.3-release' 2022-08-30 10:43:36 -05:00
3306b4a86b Fix T99253: Missing face center dots with deform modifier cage option
Before 8c25889bb6, subsurf face center tags were stored in each
vertex, so they were always copied to duplicate meshes. Now they are
stored in runtime data though, so they need to be copied explicitly.
The function name "reset_on_copy" is a bit awkward here, so the
tags are copied by the caller.
2022-08-30 10:41:26 -05:00
38cf0d7d13 GPencil: Improve Thickness handling for Outline operator
Actually, when you increase the thickness of the stroke in the outline conversion, the shape of the stroke changes and becomes thicker.

This commit includes a new algorithm to correct this problem. A new `Keep Shape`  parameter allows you to disable it because, for artist reasons, it may be good to keep the old algorithm and change the shape.
2022-08-30 17:12:03 +02:00
002f339aed Fix: Alphabetical order in duplicate data preferences panel 2022-08-30 08:22:31 -05:00
9cfa74087e Merge branch 'blender-v3.3-release' 2022-08-30 15:18:49 +02:00
afa4f8f3ce LibOverride: Minor resync optimization by removing unuecessary processing.
Not much to gain here, but can make resync faster by a few percents when
dealing with linked overrides and such.
2022-08-30 15:18:17 +02:00
34ff27025d Cleanup: Remove one level of indentation by early continue in a loop. 2022-08-30 15:18:17 +02:00
f3186389b0 Fix T100586: libOverride resync could remove too many data-blocks.
Do not delete 'orphaned' overrides when their reference is missing
because the library file itself is missing.
2022-08-30 15:18:17 +02:00
fdc332981e Cleanup: simplify comparison, clarify comment 2022-08-30 21:20:26 +10:00
e0ab4b29a9 Merge branch 'blender-v3.3-release' 2022-08-30 21:07:31 +10:00
524d9a3e2f Fix error in operator poll functions
- PALETTE_OT_color_add: crashed without a brush.
- SCREEN_OT_actionzone: crashed without a window.
- PREFERENCES_OT_studiolight_show: exception when opening prefs failed.
2022-08-30 21:06:17 +10:00
c7555372fe Merge branch 'blender-v3.3-release' 2022-08-30 12:51:12 +02:00
558a6a45b4 Cleanup: Avoid misleading Outliner tree element callback name
These functions used the term "find", which makes it sound like a lookup
callback, when in fact it would add elements to a set for further
processing. So use "collect" instead.
2022-08-30 12:24:17 +02:00
34e30baedf Fix T100673: crash when using slide brush without attachment info
The slide brush requires attachment information on the curves.
Now a warning is shown instead of crashing Blender. The attachment
information can be generated by executing the
`Curves > Snap to Nearest Surface` operator.
2022-08-30 12:20:37 +02:00
702f112e77 Merge branch 'blender-v3.3-release' 2022-08-30 19:46:44 +10:00
a97ae83a09 Fix T100703: Crash in file reading with ID's referenced from the WM
Don't decrement ID reference counts as any ID references from the
window-managers will have already been freed.

Reviewed By: mont29

Ref D15808
2022-08-30 19:41:48 +10:00
364f47c834 Merge branch 'blender-v3.3-release' 2022-08-30 11:24:58 +02:00
16938ab7d4 Update DPC++ to 20220812
This was already done in the libraries SVN, just the build system
changes got forgotten to be committed.
2022-08-30 11:23:35 +02:00
d2c0d86a38 EEVEE-Next: Register render passes for compositor.
EEVEE-Next passes were rendered to the render result, but didn't appear
in the compositor. Reasoning is that when a render engine has the update
render passes callback registered it would not register any default
render passes. This callback is used to update the Render Layer node.

This patch implements the callback for EEVEE-Next with the render passes
that are already available. In the future the callback should be
extended. Note that AO/SHADOW render passes have been disabled for now
as they need to be converted to color buffers.
2022-08-30 10:26:10 +02:00
a65676e6e9 GPencil: Rename in Outline operator mode with material_mode
The old name `mode` was confusing because there was also a `view_mode`.
2022-08-30 09:37:26 +02:00
e7f1c73a4e GPencil: Add thickness parameter to Outline operator
Instead to use always a value of 1, now the thickness of the stroke perimeter can be set.

This thickness is added to the original perimeter, so using a big number can increase the global thickness of the stroke.
2022-08-30 09:37:26 +02:00
c29d63aa5e Cleanup: spelling in comments 2022-08-30 16:22:49 +10:00
24b8ccaa94 Cleanup: format 2022-08-30 16:22:49 +10:00
26487530f2 Merge branch 'blender-v3.3-release' 2022-08-30 11:14:08 +10:00
e9fe4aa7d7 Fix Dirty Vertex Colors failure when no vertex colors existed 2022-08-30 11:12:55 +10:00
5ae3fa50e2 Cleanup: Remove misleading std::string reference binding
These functions that retrieve strings from assets return stringrefs.
Storing them as std::strings is unnecessary and relies on binding to
the const references.
2022-08-29 18:11:37 -05:00
6577d2df8c Cleanup: Use const for custom data layers 2022-08-29 17:00:46 -05:00
71b660571a Sculpt: Avoid creating mask and face set when remeshing
If these layers didn't exist on the original mesh, they would be created
from scratch and transferred anyway. That is inefficient because all the
work is pointless, and because creating these layers could slow down
subsequent sculpt operations.
2022-08-29 16:55:26 -05:00
dc92c5766f Merge branch 'blender-v3.3-release' 2022-08-29 14:55:04 -05:00
b814f64f4a Fix: Broken build with OpenVDB turned off
Problem with e3a6a2f412.
2022-08-29 14:50:26 -05:00
Tom Edwards
35df9f80b9 Fix T99576: Guard against empty names when removing attributes
It's possible for misbehaving scripts written before 3.3 to reach
this state and crash Blender. With this change, the error is reduced
to a Python exception.

Differential Revision: https://developer.blender.org/D15724
2022-08-29 14:45:55 -05:00
Pratik Borhade
68487cff95 Fix T98968: Node reroute tool doesn't add to frames
If reroute node lies in side the frame node boundaries then set
frame node as the parent of reroute.

Differential Revision: https://developer.blender.org/D15739
2022-08-29 14:45:01 -05:00
Pratik Borhade
50e5c78799 Fix T98968: Node reroute tool doesn't add to frames
If reroute node lies in side the frame node boundaries then set
frame node as the parent of reroute.

Differential Revision: https://developer.blender.org/D15739
2022-08-29 14:39:14 -05:00
7fbf72f148 Build: automatically disable WITH_GHOST_WAYLAND if missing libraries
Same as other build options, don't make it a hard requirement to have
Wayland libraries installed when it gets enabled by default.

Also fixes wayland-protocols not being found on the buildbot.
2022-08-29 19:51:07 +02:00
74caf77361 Cycles: add option to specify OptiX runtime root directory
This allows individual users or Linux distributions to specify a directory
Cycles will automatically look for the OptiX include folder, to compile kernels
at runtime.

It is still possible to override this with the OPTIX_ROOT_DIR environment
variable at runtime.

Based on patch by Sebastian Parborg.

Ref D15792
2022-08-29 19:50:20 +02:00
42cff95519 Cycles: disable Scrambling Distance UI when using Sobol Burley
Contributed by Alaska.

Differential Revision: https://developer.blender.org/D15794
2022-08-29 19:45:58 +02:00
21acfbe348 Cleanup: move Cycles display driver context handling to render module
This is highly coupled to Blender logic so doesn't belong in Cycles.
2022-08-29 19:45:58 +02:00
810e7c032c Cleanup: move part of render module to C++ 2022-08-29 19:45:58 +02:00
ff27457240 Allocator: add MEM_cnew_array
This is a more C++ friendly version MEM_calloc_arrayN, like MEM_cnew is for
MEM_callocN. For cases where data structures are still C and Vector or Array
don't work.
2022-08-29 19:45:58 +02:00
658ff994c5 Merge branch 'blender-v3.3-release' 2022-08-29 19:21:49 +02:00
805d1063a0 Cycles: Remove "return" and "assert" from oneAPI kernel code 2022-08-29 19:18:50 +02:00
dff15bb5bf Fix: Broken build with OpenVDB turned off
Problem with e3a6a2f412.
2022-08-29 12:12:16 -05:00
48e1a66af0 Merge branch 'blender-v3.3-release' 2022-08-29 18:21:56 +02:00
1cd8ca49f9 Cycles: Increased minimum supported driver for Windows in oneAPI 2022-08-29 18:10:56 +02:00
999c5c5c8d Fix (studio-reported) crash when linking/appending data in some cases.
Recent refactor (rB7be1c8bbae76f49f) removed a null check in WM code,
that is mandatory in some cases like e.g. liboverride apply code on
linked data.
2022-08-29 17:25:09 +02:00
1567dca657 Merge branch 'blender-v3.3-release' 2022-08-29 17:01:01 +02:00
e3a6a2f412 Fix T99004: scaling volume down results in crash
OpenVDB crashes when the determinant of the grid transformation is
too small. The solution is too detect when the determinant is too small
and to replace the grid with an empty one. If possible the translation
and rotation of the grid remains unchanged.

Differential Revision: https://developer.blender.org/D15806
2022-08-29 17:00:08 +02:00
Damien Picard
9120c86c3f I18n: disambiguate and make a few more strings translatable
Those strings were at least partly disambiguated:
- Area
  - Zone
  - Measurement
- Ease
  - BBone Ease In / Out
- Back
  - Camera BG image depth
  - GP interpolate sequence
- Edge Crease
  - Theme
- Jitter
  - Brush
  - GPencil
  - Lens distorsion compositing node
- Cineon color management
  - Black
  - Gamma
  - White

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15791
2022-08-29 16:04:03 +02:00
Damien Picard
0db582c41c Add missing RNA text for the MeshUVLoop struct
The structures in rna_mesh.c all had a UI text which showed up in the
animation editors, except for MeshUVLoop.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15803
2022-08-29 15:08:29 +02:00
Damien Picard
9bf5c37bee I18n: translate newly created node group sockets
Translate:
- new group socket names
  - default names Input and Output
  - on connecting a link from another node
- new geometry nodes input and output socket names

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15763
2022-08-29 14:26:10 +02:00
Damien Picard
73bfd8058f I18n: make add-ons' info translatable
The info provided by add-ons is very valuable to users, yet it wasn’t translatable yet.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15747
2022-08-29 14:12:21 +02:00
9823a8f72b Weight Paint: use coordinates from normal evaluated mesh if same topology.
Weight and Vertex paint don't change coordinates and thus don't need
crazyspace data, which allows using coordinates from normal evaluated
meshes.

Since painting uses original topology, the deform only mesh is used,
but if the fully evaluated mesh has the same topology, it is preferred.
This is useful because not only Geometry Nodes, but even simple weight
computation modifiers are excluded from the deform only mesh evaluation.

Differential Revision: https://developer.blender.org/D15501
2022-08-29 14:10:31 +03:00
e460050099 Merge branch 'blender-v3.3-release' 2022-08-29 12:45:14 +02:00
7bb08882ec I18n: Better wording for the skipped languages in language menu file. 2022-08-29 11:05:03 +02:00
613b6ad9e5 GPencil: New conversion to outline in draw mode
This new option converts the stroke to outline perimeter as soon as is drawn.

If no alternative material is set, the actual material is used.

The algorithm is similar to the new operator in D15664

Reviewed By: pepeland

Differential Revision: https://developer.blender.org/D15738
2022-08-29 09:47:08 +02:00
377b81ac07 Fix compilation issue in MTLQueryPool::allocate_buffer.
This compilation issue happened due to multiple patches being handled at the same
time one overwriting a correction of the other.
2022-08-29 08:34:47 +02:00
c4d9dca4a6 Cleanup: Add missing override keyword in mtl_backend. 2022-08-29 08:31:56 +02:00
91b88d3d94 Merge branch 'blender-v3.3-release' 2022-08-28 17:55:42 -04:00
7b56c74881 Update RNA to User manual mappings 2022-08-28 17:53:49 -04:00
e0414070d9 Cleanup: Slightly improve virtual array implementation consistency
Previously the base virtual array implementation optimized for
common cases where data is stored as spans or single values.
However, that didn't make sense when there are already
sub-classes that handle those cases specifically. Instead,
implement the faster materialize methods for each class.
Now, if the base class is reached, it means no optimizations
for avoiding virtual function call overhead are used.

Differential Revision: https://developer.blender.org/D15549
2022-08-28 14:40:49 -05:00
67f3259c54 Curves: Avoid creating types array when unnecessary
When the curve type attribute doesn't exist, there is no reason to
create an array for it only to fill the default value, which will add
overhead to subsequent "add" operations. I added a "get_if_single"
method to virtual array to simplify this check. Also use the existing
functions for filling curve types.

Differential Revision: https://developer.blender.org/D15560
2022-08-28 14:33:03 -05:00
28750bcf7e Cleanup: replace NULL with nullptr for C++ files 2022-08-28 20:52:28 +10:00
7269ee4dbb Cleanup: use const FontBLF arguments 2022-08-28 20:46:53 +10:00
206272621e Merge branch 'blender-v3.3-release' 2022-08-28 20:21:32 +10:00
4694d497b7 Merge branch 'blender-v3.3-release' 2022-08-28 20:19:02 +10:00
ff78f79abc Merge branch 'blender-v3.3-release' 2022-08-28 20:18:58 +10:00
7de290ea08 Fix crashes running operators in invalid contexts
Fix for running operators outside of expected contexts.

- UI_OT_view_drop (poll)
- UI_OT_view_item_rename (poll)
- OBJECT_OT_gpencil_modifier_move_to_index
- OBJECT_OT_modifier_move_to_index
- OBJECT_OT_geometry_nodes_input_attribute_toggle
- OBJECT_OT_geometry_node_tree_copy_assign
- OBJECT_OT_shaderfx_remove
- OBJECT_OT_shaderfx_copy
- POSE_OT_relax (& other pose slide operators).
2022-08-28 20:18:12 +10:00
219d109575 Fix crash in gpencil.brush_reset_all referencing freed memory
A reference to the active brush was kept even when it was freed.
2022-08-28 20:00:14 +10:00
1f9d0acfa9 Fix running transform without a region
Running transform in background mode or without a region would crash.
2022-08-28 19:55:52 +10:00
ff7a7a6f77 Merge branch 'blender-v3.3-release' 2022-08-27 09:12:14 +02:00
f7ce20e340 Cleanup: Remove two files committed by mistake.
Committed in rB3c7a6718ddc.
2022-08-27 09:09:41 +02:00
d527aa4dd5 UV: support constrain-to-bounds for uv rotation operator
Differential Revision: https://developer.blender.org/D15730
2022-08-27 17:01:55 +12:00
7459c0228e Cleanup: rename filename to filepath when used for full paths 2022-08-27 14:52:31 +10:00
d41acc23e1 CMake: include missing header files 2022-08-27 14:32:50 +10:00
bfca876c05 CMake: cleanup, rename INC_HD_CYCLES to SRC_HD_CYCLES_HEADERS
Our convention is to use `INC_*` for include directories,
this caused `make check_cmake` to incorrectly fail as it expected
these files to be include directories.
2022-08-27 14:32:50 +10:00
3cba80039d UV: bpy_extras.mesh_utils.mesh_linked_uv_islands raises error in edit mode
Maniphest Tasks: T86484

Differential Revision: https://developer.blender.org/D15778
2022-08-27 16:09:17 +12:00
f7027f2253 Cleanup: simplify key input handling for GHOST/Win32
- Don't create utf8 text for key release events.
- Reduce variable scope.
2022-08-27 13:47:17 +10:00
95162e7157 Cleanup: add missing braces for GHOST/Win32 2022-08-27 13:11:34 +10:00
de1a2d7988 Cleanup: pass notifiers as const 2022-08-27 12:54:26 +10:00
578dff7863 Fix assertion when notifiers weren't removed from the notifier queue set
Since [0] notifiers were cleared and left in the queue, while harmless
it meant the call to remove the notifier from the set was redundant.

Now set aside a category to tag notifiers as having been cleared and
skip them entirely.

[0]: 0aaff9a07d
2022-08-27 12:28:18 +10:00
955032ffb0 Cleanup: use C style comments for GHOST/Win32 text 2022-08-27 11:24:49 +10:00
37d835f0bc Fix T100582: Windows-10 Switching Desktops locks Ctrl Key
Regression in recent fix for T66088 [0]. caused by much older problem
introduced with [1] & [2].

Unlike other platforms, as of [1] GHOST/Win32 was keeping track of the
pressed modifier keys.

Since GHOST/Win32 cleared the modifier state on window activation [2]
and only changes to modifier state would generate key events, activating
the window and releasing the modifier would not send the release event.

Resolve this by removing the stored modifier state from GHOST/Win32,
always passing modifier press/release events through to Blender
(matching other GHOST back-ends).
Instead, use key-repeat detection to prevent repeated modifier keys
from being generated - an alternate solution to T26446.

[0]: 8bc76bf4b9
[1]: d6b43fed31
[2]: 6b987910e4
2022-08-27 07:36:00 +10:00
07ccb9b573 Cleanup: use 'len_v2'
Simplifies readability and avoids repeat casts.
2022-08-26 16:10:22 -03:00
6bea434c41 Cleanup: Move bmesh_query_uv.c to C++
Helpful for D14365.
2022-08-26 13:56:50 -05:00
6a9cf59ce1 Merge branch 'blender-v3.3-release' 2022-08-26 15:35:18 -03:00
e040aea7bf Transform: Use more general approach to node view update
With rBe6a557952ead, concerns were reported about missing updates when
the view is moved other than through the Edge Pan system.

Although the transform operator blocks navigation in general, it is
good to avoid these cases.
2022-08-26 15:34:38 -03:00
da022f3f48 Merge branch 'blender-v3.3-release' 2022-08-26 14:19:34 -03:00
0c8de0eb3b Fix T100632: Regression: Node border snap guide line not drawing properly
Caused by {rBd2271cf93926}.

Color values were being used without being initialized.
2022-08-26 14:18:11 -03:00
e6a557952e Fix T100633: Node Editor: Edge scrolling breaks node snapping
The view offset, calculated by the Edge Pan system, only affects the
position of the nodes, but forget to update:
- snapping data
- final value of transform
- values used for custom drawing

Therefore, to avoid having to update a lot of scattered data, the
`transformViewUpdate` utility has been implemented to recalculate input
values when the view changes.

This utility does more than is necessary to fix the bug, but with that,
it can work in any situation.
2022-08-26 14:17:55 -03:00
3c060b2216 Fix T100633: Node Editor: Edge scrolling breaks node snapping
The view offset, calculated by the Edge Pan system, only affects the
position of the nodes, but forget to update:
- snapping data
- final value of transform
- values used for custom drawing

Therefore, to avoid having to update a lot of scattered data, the
`transformViewUpdate` utility has been implemented to recalculate input
values when the view changes.

This utility does more than is necessary to fix the bug, but with that,
it can work in any situation.
2022-08-26 13:17:51 -03:00
cc9c4e2744 CustomData: Add function to get name of default layer
Used by D14365
2022-08-26 11:16:10 -05:00
167e2fda15 Merge branch 'blender-v3.3-release' 2022-08-26 18:09:05 +02:00
8181494ffe Fix assert in id remapper tests.
Was using uninitialized ID name, leading to unknown ID type.

Thanks at Ray molenkamp (@LazyDodo) for noting the issue.
2022-08-26 18:08:46 +02:00
aaea263be4 Cleanup: Fix const correctness in CustomData set name function
The function does modify the object since it changes the name of a layer
it owns. Ideally this wouldn't be possible, but raw pointers don't have
ownership semantics so this is a common problem with CustomData.
2022-08-26 10:57:43 -05:00
Luis Pereira
763cafc2b1 Fix T55284: error in Hybrid MultiFractal Musgrave texture
The calculation was revised to address two issues:
* Discontinuities occurring when detail was a non-integer greater than 2.
* Levels of detail in the interval [0,1) repeating the levels of detail in
  the interval [1,2).

This fixes Cycles, Eevee and geometry nodes.

Differential Revision: https://developer.blender.org/D15785
2022-08-26 17:27:43 +02:00
a1c8a17b4d IDManagement: fix missing WM name validation when using "keep current WM list" code path
The blendfile_liblink and blendfile_io python tests in debug fired an
assert that WMWinMan object was in Main database, but not in the ID
name map. This was caused by wm_window_match_do going into case 3
there: the new WM list is completely empty, the old list is not empty,
and it was directly using the old/current list (via
wm_window_match_keep_current_wm function), without actually
registering/validating the objects in it through the name map.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D15787
2022-08-26 12:15:12 +02:00
51178fd4da UV: improve consistency for scale parameter of uvcalc_randomize_transform 2022-08-26 21:19:46 +12:00
3e51ebaf54 IDManagement: fix missing WM name validation when using "keep current WM list" code path
The blendfile_liblink and blendfile_io python tests in debug fired an
assert that WMWinMan object was in Main database, but not in the ID
name map. This was caused by wm_window_match_do going into case 3
there: the new WM list is completely empty, the old list is not empty,
and it was directly using the old/current list (via
wm_window_match_keep_current_wm function), without actually
registering/validating the objects in it through the name map.

Reviewed By: Bastien Montagne
Differential Revision: https://developer.blender.org/D15787
2022-08-26 11:49:02 +03:00
e1f8136230 Merge branch 'blender-v3.3-release' 2022-08-26 09:16:46 +02:00
60420f6ea4 Fix T100602: Incoming Vector in world shader for Eevee is inverted
Regression from {rBf4d7ea2cf61} where the direction was flipped.

Maniphest Tasks: T100602

Differential Revision: https://developer.blender.org/D15779
2022-08-26 09:13:55 +02:00
054cec404b Cleanup: use booleans 2022-08-26 15:58:32 +10:00
6bf2c73249 Cleanup: quiet GCC array bounds warning 2022-08-26 15:06:33 +10:00
e77ac31799 makesrna: type check bool/int/float/enum get/set callbacks
While converting types from callbacks isn't a bug, it's unlikely
we ever want to do this on purpose and can hide mistakes such as
silently converting floating point values to ints as happened
with Sequencer.frame_start.
2022-08-26 14:43:16 +10:00
5bd4aea29c Cleanup: use matching function signatures for RNA callbacks
Use matching int/float/boo types for RNA callbacks.
2022-08-26 14:37:16 +10:00
4a0dd1d435 Merge branch 'blender-v3.3-release' 2022-08-26 14:26:55 +10:00
c9723d9464 Fix Sequence.frame_start being rounded to int when assigned 2022-08-26 14:22:58 +10:00
65cd265235 CMake: disable IME for lite configuration 2022-08-26 13:28:45 +10:00
6fc7b37583 Cleanup: reduce variable scope 2022-08-26 12:51:46 +10:00
a3e1a9e2aa Cleanup: spelling in comments, format 2022-08-26 12:47:21 +10:00
ef51825c06 Fix incorrect UI scaling after changing monitors DPI under Wayland
Add a GHOST_kEventWindowDPIHintChanged event to ensure the UI is
properly updated.
2022-08-26 12:37:08 +10:00
047d0e6c4a Merge branch 'blender-v3.3-release' 2022-08-25 17:26:58 +02:00
Bastien Montagne
500d815478 Fix T100255: Make RigidBodyWorld (and effector_weights) collections refcounted.
Those collections were so far mainly just tagged as fake user (even
though a few places in code already incremented usercount on them).

Since we now clear the fakeuser flag when linking/appending data, ensure
that these collections are preserved by making these usages regular ID
refcounting ones.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D15783
2022-08-25 17:21:39 +02:00
9b41ac6251 Revert "LibOverride: Preserve viewlayers when creating overrides of collecitons."
Commit is not working as expected in some cases, as revealed by
liboverride testcase entering infinite loop.

Code needs some more thinking.

This reverts commit ee7bd79b54.
2022-08-25 16:17:34 +02:00
093607423d Merge branch 'blender-v3.3-release' 2022-08-25 12:23:27 +02:00
b27856f12e Update liboverride operators to manual mapping. 2022-08-25 12:23:10 +02:00
ee7bd79b54 LibOverride: Preserve viewlayers when creating overrides of collecitons.
Usually, when overriding collections, the linked reference ones are
removed from the ViewLayer, and the overrides replace them.

This change to `layer_collection_sync` code makes it so that in case
there is a free viewlayer hierarchy matching the linked collection, it
gets re-used for the override one, instead of re-creating everything
from scratch.

To achieve this, resync process is split into two steps, first regular
collections are processed, then the override ones. This should ensure
an override does not steal the layers of its reference if the later is
still instantiated in the view layer.
2022-08-25 12:22:38 +02:00
d4764a385a Merge branch 'blender-v3.3-release' 2022-08-25 11:50:55 +02:00
9c2bc57cbd Fix Cycles oneAPI for a newer DPC++ compiler version 2022-08-25 11:50:22 +02:00
e50c7a244b Merge branch 'blender-v3.3-release' 2022-08-25 09:25:22 +02:00
714a3739da Fix T100599: dont reset parent inverse setting parent type the same
Since rBb100bdca25b1 the parent inverse was always reset in
ED_object_parent (also for just changing the parent type).

This does make sense (since there is no point keeping it when e.g
changing from "Bone" to "Object" or "Vertex" to "Object", for this to
really make sense it would have to be properly recalculated anyways
which does not happen afaict).

The reported issue was that setting the prop to the same value as it was
before (e.g. from "Object" to "Object") would still reset the parent
inverse which was really unexpected since from a user standpoint,
nothing has changed here.

So in case the value does not really change, we now just early out and
skip `ED_object_parent`.

Maniphest Tasks: T100599

Differential Revision: https://developer.blender.org/D15771
2022-08-25 09:22:55 +02:00
96d8367924 PyAPI: return faces instead of indices from bmesh_linked_uv_islands
Return faces instead of face indices from bmesh_linked_uv_islands
since BMesh indices aren't reliable when geometry is added/removed,
where the faces will still be valid.
2022-08-25 17:05:50 +10:00
012db9e820 Cleanup: replace dict with set for bmesh_utils.bmesh_linked_uv_islands
Also correct doc-string syntax.
2022-08-25 16:41:22 +10:00
de570dc87e Fix T78406: create uv randomize islands operator
Implement a new operator to randomize the scale, rotation and offset
of selected UV islands.
2022-08-25 18:09:32 +12:00
f36d8d59c2 Cleanup: remove redundant calculation in bmo_poke_exec
Mistake in [0] calculated the mean-face-center which wasn't used.

0: 23344bca6c
2022-08-25 15:14:34 +10:00
fcecbc5610 Cleanup: rename mat3_to_quat_is_ok to mat3_to_quat_legacy
Update comment, noting why this is kept.
2022-08-25 14:33:01 +10:00
be40f31d03 Keyframing: replace mat3_to_quat_is_ok with mat4_to_quat
Added [0] which notes in most cases results are the same but in some
cases the result seems better. While true at the time of writing since
then mat3_to_quat has been improved and used for nearly all matrix
to quaternion conversion.

0: 876cfc837e
2022-08-25 14:32:34 +10:00
a7650c6206 BLI_math: ensure non-negative matrices for mat3_to_quat calculations
Making the callers responsible for this isn't practical as matrices are
often passed indirectly to a functions such as mat3_to_axis_angle,
BKE_object_mat3_to_rot & BKE_pchan_mat3_to_rot.
Or the matrix is combined from other matrices which could be negative.

Given quaternions calculated from negative matrices are completely
invalid and checking only needs to negate matrices with a negative
determinant, move the check into mat3_to_quat and related functions.

Add mat3_normalized_to_quat_fast for cases no error checking on the
input matrix is needed such as blending rotations.
2022-08-25 13:48:31 +10:00
8593228a13 Cleanup: remove outdated, unhelpful comments 2022-08-25 13:36:54 +10:00
9f1c05d5cb Fix matrix/quaternion conversion with negative scaled cameras 2022-08-25 12:38:04 +10:00
a604ed0068 Fix accessing freed memory for GHOST/Wayland clipboard access 2022-08-25 10:52:36 +10:00
Mattias Fredriksson
87e8810dd0 Cleanup: Add asserts to curves data-block creation
Ref D14481
2022-08-24 18:22:39 -04:00
Mattias Fredriksson
1dae11ccb5 Cleanup: Improve comments
Add to comments in curves header, fix typo in attribute header.

Ref D14481
2022-08-24 18:22:29 -04:00
f593a560d3 Cleanup: Deduplicate RNA mesh element index retrieval
Reuse the subtraction, which simplifies adding assertions
and refactoring to remove the custom data pointers.
2022-08-24 15:41:55 -04:00
b19c51c7f4 Cleanup: Move outliner types to namespace, avoid C-style type definition
With C++ we should transition towards namespaces to avoid naming
collisions. Having the namespace in place is the first step for that
transition.

Plus, the `typedef` isn't necessary for struct/class/enum definitions
in C++, so avoid the verbosity it adds.
2022-08-24 20:10:15 +02:00
ce1f401b42 Merge branch 'blender-v3.3-release' 2022-08-24 19:17:14 +02:00
3a1ea04d46 Cleanup warning about missing pointer casting. 2022-08-24 19:16:18 +02:00
fc26e3fe19 Cleanup: Fix typo in comment
Added by mistake in 6718afdc8a.
2022-08-24 11:25:04 -04:00
5d4d5a2162 Merge branch 'blender-v3.3-release' 2022-08-24 17:12:01 +02:00
8b7293eb41 LibOverride: Fix (unreported) crashes in some cases, preserve active object on Clear, general cleanup.
Inconsistencies in update/tagging code between different code doing the
same 'Clear. liboverride operation lead to crashes in some cases.

Unify deg tagging and WM notifiers accross the three editor-level
codepaths performing the common Make/Reset/Clear operations.

Preserve if possible the active object accross Clear operation.

Several cleanup/rename/re-arangement of code to make it more consistent.
2022-08-24 17:11:36 +02:00
24dc84f156 Cleanup: rename new IDTemplate operator to create overrides to make.
Matches other operators' names and UI labels better.
2022-08-24 17:11:36 +02:00
61896947d4 Merge branch 'blender-v3.3-release' 2022-08-24 15:39:52 +02:00
e65f0337e9 Fix WITH_CYCLES_ONEAPI_BINARIES issues with make release
Fix typo in blender_release.cmake, and ensure that "make release" still works
when ocloc is not available. While a fatal error is useful for debugging, the
current convention is to disable features, especially in cases like this where
there is no simple way to make the feature work.

Differential Revision: https://developer.blender.org/D15774
2022-08-24 15:38:27 +02:00
be0a68f0d1 BLI_math: assert mat3_normalized_to_quat doesn't use a negative matrix
Add an assert to ensure callers don't pass in negative matrices as the
resulting quaternion is invalid.
2022-08-24 20:45:17 +10:00
489aeda034 Merge branch 'blender-v3.3-release' 2022-08-24 20:40:43 +10:00
8c38a994c6 Fix Quaternion.rotate(matrix) with negative matrices
Rotating a quaternion by a negative matrix gave an invalid result.

Follow up fix for T94231 which negated negative matrices too.
2022-08-24 18:59:04 +10:00
dc2d75d9bc Merge branch 'blender-v3.3-release' 2022-08-24 17:27:25 +10:00
62f764fad7 Fix T100606: Apply object transform fails with delta quaternion rotation
Apply transform failed to clear delta quaternion & axis-angle rotation.
2022-08-24 17:26:38 +10:00
02d13c2d2f Merge branch 'blender-v3.3-release' 2022-08-24 09:17:51 +02:00
62bd007646 Fix T100590: Crash when changing active image texture node
Mistake in own rBc76d7f7bde35.
Happened when no image was set in the Image Editor already (which is now
checked for).

Maniphest Tasks: T100590

Differential Revision: https://developer.blender.org/D15761
2022-08-24 09:15:14 +02:00
4fb64068a7 Cleanup: use determinant_m3(m) < 0 to implement is_negative_m3/m4
Use a more direct method of checking if a matrix is negative instead of
using cross & dot product.

Also replace some determinant_m3() < 0 checks with is_negative_m3.
2022-08-24 16:34:04 +10:00
f39c9d1596 Merge branch 'blender-v3.3-release' 2022-08-24 16:09:13 +10:00
10a4726a5b Fix T94231: Matrix.to_quaternion() returns invalid rotation
The result of mat3_normalized_to_quat isn't valid for negative matrices.

Isolate the fix to the Matrix.to_quaternion() instead of changing
mat3_normalized_to_quat to prevent unintended side effects elsewhere.
2022-08-24 16:07:56 +10:00
be81690b73 Merge branch 'blender-v3.3-release' 2022-08-24 10:20:52 +10:00
112a2c0627 Fix error from 21ea499558
Was not using the absolute index for comparison,
breaking the id_management test.
2022-08-24 10:20:05 +10:00
649807a8cd Cleanup: format 2022-08-24 09:22:26 +10:00
a6056b870b Fix T100494: Broken sculpt hide status undo/redo
Caused by 2480b55f21 using the undo step indices instead of the
indices of vertices in the mesh, causing the hide values to be swapped
around randomly in the mesh.
2022-08-23 14:09:46 -04:00
e36ced1dce Fix: Write hide status attributes for undo steps
We don't convert to the old mesh format when writing undo steps to
avoid overhead. So we can't skip writing the hide attributes then.
2022-08-23 13:50:47 -04:00
35c601269b Fix T100482: Face Set visibility reset after saving
The face hide attribute wasn't created in order to store the visiblity
from the face sets, it was only updated if it already existed.
2022-08-23 12:17:16 -04:00
486d27d32a Cleanup: Move paint.c to C++ 2022-08-23 12:01:37 -04:00
59aef1d717 Cleanup: Use utility to write palette color list 2022-08-23 11:19:07 -04:00
b649fc13ed Cleanup: Avoid using invalid attribute domain
The number of attribute domains isn't an attribute domain, so storing
ATTR_DOMAIN_NUM in a variable with an eAttrDomain type isn't correct.
In the cases it was used, the value wouldn't be accessed anyway.
2022-08-23 10:44:10 -04:00
c32bb58e5b Depsgraph: use more fine grained update tags for scenes
Ref D15710, this avoids unnecessary sequencer updates for some operations.
2022-08-23 15:27:16 +02:00
a87d3edb98 Build: add system for shipping with dynamic libraries on Linux and macOS
PLATFORM_BUNDLED_LIBRARIES gathers shared libraries that will be installed
to the lib/ folder. The Blender executable gets a relative rpath pointing to
this folder as part of the install step.

The build rpath is different and uses absolute paths, so that it works for
executables like tests that are in different locations, and to support the
case where the build and install folders are different.

The system is already used for the OpenMP library on macOS. But on Linux it
will only kick in once we start using shared libraries for dependencies.

This also removes Mesa libraries from the old location, as these would cause
Blender to start with software OpenGL.

Ref T99618
2022-08-23 15:27:16 +02:00
afb74149c1 Cleanup: consistent variable names for install target directories 2022-08-23 15:27:16 +02:00
ddad2f8672 Build: use package instead of git repo for sse2neon
More consistent with other libs and avoids issues where it would always be
rebuilt.
2022-08-23 15:27:16 +02:00
a77a1bcae7 Merge branch 'blender-v3.3-release' 2022-08-23 15:09:50 +02:00
efc9faef23 Fix T98954: Color management is very slow with sequencer sound
Function `rna_ColorManagement_update` tagged unnecesary updates.

Reviewed By: sergey, brecht

Differential Revision: https://developer.blender.org/D15710
2022-08-23 15:08:46 +02:00
21ea499558 Fix T100286: Crash accessing freed depsgraph object instances
Invalidate depsgraph.object_instances when freed, this resolves a crash
when accessing the object instances after iteration has finished.

Unlike most other collections, object_instances is only valid while the
iterator is in-memory.

The Python/RNA API needs to inline int/string collection lookups so the
Python instance can be created before the iterator ends.

Reviewed By: mont29, sergey

Ref D15755
2022-08-23 22:56:54 +10:00
ffb6cc263f Cleanup: format 2022-08-23 22:55:48 +10:00
Jeroen Bakker
37533cd6cb ImBuf: Optimize GPU memory by using 1 component format for grayscale images
This is done by checking the number of bitplanes from the image buffer.
We assume that for float buffer to use the same bitplanes as it was a
byte buffer.

Then, the data of the image buffer is packed at the start of the `rect` or
`float_rect` before upload.

**Statistics - einar.v004.blend **

Note that not all grayscale textures have been stored as BW images so the
amount of memory that can be reduced would be more.

Without patch
```
104 Textures - 3294.99 MB (3294.47 MB over 32x32), 37 RTs - 192.52 MB.
Avg. tex dimension: 2201.88x1253.51 (2283.53x2202.13 over 32x32)
464 Buffers - 25.01 MB total 1.24 MB IBs 23.50 MB VBs.
3512.52 MB - Grand total GPU buffer + texture load
```

Patch applied
```
104 Textures - 2917.66 MB (2917.14 MB over 32x32), 39 RTs - 215.45 MB.
Avg. tex dimension: 2221.38x1252.75 (2323.28x2253.47 over 32x32)
467 Buffers - 25.01 MB total 1.24 MB IBs 23.51 MB VBs.
3158.13 MB - Grand total GPU buffer + texture load.
```

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15484
2022-08-23 14:35:39 +02:00
13b2716e1c Merge branch 'blender-v3.3-release' 2022-08-23 14:25:18 +02:00
65870821da Fix: OBJ import unused parameter warning
Since {rB2542fda14d85}, `r_node` is an unused parameter.
Changed `load_texture_image` to reflect that.

Differential Revision: https://developer.blender.org/D15759
2022-08-23 14:22:23 +02:00
Philipp Oeser
0bc95b7b40 Compositor: handle NODE_DO_OUTPUT in RNA when setting a node active
Main motivation is from T54314 where there was no way to read from a
Viewer image datablock after setting another viewer node active.

Part of the problem was addressed in rB16d329da284c (where handlers for
the compositing background job were added so that you can act after the
compositor has run), however there was still the remaining issue that
setting another viewer node active would not properly tag the node
NODE_DO_OUTPUT. This forced users into a complicated workaround (using
switch nodes feeding into a single viewer node).

Now handle NODE_DO_OUTPUT properly in RNA, too, and do proper updates so
that behavior from RNA matches that of the Node Editor when setting a
viewer node active.

ref T54314.

Reviewed By: JacquesLucke

Maniphest Tasks: T54314

Differential Revision: https://developer.blender.org/D15203
2022-08-23 14:22:04 +02:00
60e2dfd1e8 Fix T99524: GPencil not updating when frame num is changed
When changing the frame_number of a grease pencil frame, the grease
pencil object is not updated correctly. The frame stays where it
previously was.

The fix adds a `property_update` callback to the `frame_number` RNA
property.

Maniphest Tasks: T99524

Reviewed By: antoniov

Differential Revision: https://developer.blender.org/D15394
2022-08-23 13:53:44 +02:00
511ff898da Merge branch 'blender-v3.3-release' 2022-08-23 12:40:58 +02:00
1663530408 Fix T100318: handle custom nodes in field inferencing more gracefully
Custom nodes are not supported, but it shouldn't crash here.
2022-08-23 12:40:26 +02:00
65c6886284 Merge branch 'blender-v3.3-release' 2022-08-23 11:55:57 +02:00
95464a842c Fix T99932: video in node group does not play 2022-08-23 11:54:51 +02:00
Damien Picard
4ac96a483b I18n: make workspaces translatable
This makes workspaces more translatable:
- New Workspace menu
  - header
  - preset menus
  - preset entries
- workspace names upon factory file template load
- new workspace name upon workspace addition

To properly translate those names, an extraction function for
workspace names from app templates was added as well.

(Do not do anything when loading a user-saved file!)

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15727
2022-08-23 11:54:34 +02:00
22fdb88be5 Merge branch 'blender-v3.3-release' 2022-08-23 11:19:08 +02:00
d269ad3535 Fix T100578: Surface Deform modifier displays wrong in editmode
This was the case when the "Show in Editmode" option was used and a
vertexgroup affected the areas.

Probably an oversight in {rBdeaff945d0b9}?, seems like deforming
modifiers always need to call `BKE_mesh_wrapper_ensure_mdata` in
`deformVertsEM` when a vertex group is used.

Maniphest Tasks: T100578

Differential Revision: https://developer.blender.org/D15756
2022-08-23 11:07:26 +02:00
c76d7f7bde Fix T99493: better syncing between Node Editor and Image Editor
Since {rBb0cb0a785475}, changing the active texture in the Node Editor
would also change the current image in the Image Editor.
While this was an overall improvement, this was not desired when the
image currently looked at was a `Render Result` or a `Viewer Node`
(artists usually want to keep focus on these).

With this patch, syncing the active texture change from the Node Editor
to the Image Editor will now only happen if the Image Editor's current
image is not a Render Result or a Viewer Node.

NOTE: Syncing the active paint slot to the Image Editor still happens
(even if the Image Editor's current image is not a Render Result or a
Viewer Node), behavior was not changed since this is a much more
explicit action while texture painting and probably desired in that
case.

Maniphest Tasks: T99493

Differential Revision: https://developer.blender.org/D15749
2022-08-23 11:07:08 +02:00
a3548667bc Merge branch 'blender-v3.3-release' 2022-08-23 10:58:00 +02:00
5d67b52441 Fix T100562: Realize Instances node crashes when there is an attribute name collision 2022-08-23 10:57:28 +02:00
56205e9f31 Fix T100579: internal links are drawn when sockets are hidden 2022-08-23 10:35:38 +02:00
6319dcb230 Fix: Missing compositor domain priority for filter nodes
Domain priorities were accidentally left out of the patches for the
filter nodes. This patch adds them appropriately.
2022-08-23 09:33:28 +02:00
655e9eabc3 Cleanup: Turn filter node methods into an Enum
This patch turns the filter node methods into an enum and renames the
members from FILT into FILTER for easier writing.
2022-08-23 09:24:25 +02:00
78061e6c3e Fix: Compositor results are fuzzy with bilinear filtering
The realtime compositor sometimes produces fuzzy results when the
interpolation is set to bilinear. This was due to the domain realization
shader, which incorrectly sampled the input image.

This patch fixes such fuzziness by introducing a 0.5 offset to evaluate
the sampler at the center of pixels. Additionally, it makes sure the
centring offset is an integer offset by taking its floor, retaining the
previous 0.5 offset even with the difference in size is odd.
2022-08-23 09:06:16 +02:00
35cc755366 Cleanup: simplify partition functions
- Assign return arguments last instead of manipulating them.
- Remove redundant NULL assignment of return arguments.
2022-08-23 12:48:06 +10:00
7694678025 Cleanup: remove unnecessary NULL check 2022-08-23 12:18:01 +10:00
ee60aa9d01 Cleanup: match names between functions & declarations 2022-08-23 11:05:50 +10:00
a65e4e6139 check_cppcheck: skip files that hang, minor improvements
- Skip text_format_pov.c & text_format_pov_ini.c which caused
  cppcheck to hang.
- Enable '--inconclusive' checks as they can be useful.
2022-08-23 11:01:02 +10:00
7f6cd405b9 Merge branch 'blender-v3.3-release' 2022-08-22 18:16:09 +02:00
4fecf652e2 Fix T100568: triangulate node resets vertices to rest position
The triangulate node is not supposed to take shape keys into account.
This was likely a mistake in rBabf30007abdac2a5bf3a1.
2022-08-22 18:15:33 +02:00
3345e8ed3c Merge branch 'blender-v3.3-release' 2022-08-22 16:31:53 +02:00
Iliya Katueshenock
5fff6c419c Fix T100258: wrong spline length used in Spline Parameter node
Differential Revision: https://developer.blender.org/D15705
2022-08-22 16:30:18 +02:00
de00b892a7 Merge branch 'blender-v3.3-release' 2022-08-22 16:13:30 +02:00
Sonny Campbell
8265d08e7f Fix T90706: crash when deleting fluid sim geometry
Differential Revision: https://developer.blender.org/D15299
2022-08-22 16:00:39 +02:00
500e4d540a Merge branch 'blender-v3.3-release'
Conflicts:
	release/scripts/startup/bl_ui/space_userpref.py
2022-08-22 15:44:44 +02:00
Damien Picard
0b2be4fbc3 I18n: Fix lighting preferences error messages
While the current situation sort of works, a proper translation cannot
be achieved in every language. Separate messages for each lighting
type.
2022-08-22 15:34:27 +02:00
4ad471d67f I18n: systematically tag all messages in RNA_ENUM_ITEM_HEADING.
Add missing labels, and also add tooltips.

Unfortunately there is no way currently to extract two messages from a
single 'function' call, so unless those type of macros become very
widely used, would keep it as manual tagging.

Also disambiguate `case` in text context, pretty sure English is one of
the very rare languages to use this word for character case too.
2022-08-22 15:24:21 +02:00
Damien Picard
ee985fa925 I18n: disambiguate a few translations
- Keying (keyframe insertion)
- Roughness (particle children)
- New image, collection, text (in menus)
- Parents (particles)
- Wrap (text)
- Light (add menu)
- Empty (volume add menu)
- Empty (empty add menu)
- Cycles (f-curve modifier)
- Drag (workspace tool type)
- Power (light intensity)
- Power (math nodes)

This last change also moves all math operations in nodes to the
ID_nodetree context. It's needed only for some operations, but we
can't be more granular here.

Also...

- Fix context extraction for interpolation mode headers in F-Curves
  and GPencil interpolation operator
- Enable new translation: "Slot %d" in image editor
- Fix an English message in the node editor:
  "Replace the input image's alpha channels by..." -> channel

Ref. T43295

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15694
2022-08-22 14:33:07 +02:00
ba74704c9a Merge branch 'blender-v3.3-release' 2022-08-22 12:16:11 +02:00
c973d333da Fix T100527: Right click in the attribute name field crashes blender.
`UI_context_active_but_prop_get_templateID` became much more widely used
with recent rBfec254364884, which revealed that it did not do any check
on actual type of data it accesses, resulting easily in undefined
behavior.

Now also check the callback function pointer, this should be safe
enough.

Patch by @Severin (Julian Eisel), many thanks!
2022-08-22 12:15:50 +02:00
ad577d3b69 Merge branch 'blender-v3.3-release' 2022-08-22 11:49:32 +02:00
f29f023017 Enable oneAPI AoT binaries on Windows 2022-08-22 11:49:00 +02:00
b72c658cfd Enable oneAPI AoT binaries on Windows 2022-08-22 11:47:18 +02:00
9e23ab9f37 Fix: Memory leak in realtime compositor
There was a memory leak in the GPU code generator for the compositor
output. It was just due to a missing free in the GPU code generator
destructor, so this patch makes sure it is freed.
2022-08-22 10:57:24 +02:00
79dfd2eb7b EEVEE-Next: Fix shader compilation error.
This fixes a compilation error in eevee_light_culling_debug shader.

Some compilers complained when accessing the same data twice. Unclear
why. We should investigate that this change doesn't harm the performance
of the shader.

Although the light is a local variable it might clutter available
registers. If so it will harm developers during debugging.
2022-08-22 10:44:46 +02:00
d966ce718b EEVEE-Next: Fix shader compilation error.
Due to a copy-paste error there was an out of bound read. Some drivers
didn't complain about it, others did. This patch fixes the compilation
error by accessing the array within bounds.
2022-08-22 10:36:38 +02:00
0aeae0d0b9 Revert "Fix T99259: Python API: ViewLayer.aovs.remove isn't available"
This reverts commit ae7909010f.
2022-08-22 08:40:36 +02:00
Mangal Kushwah
ae7909010f Fix T99259: Python API: ViewLayer.aovs.remove isn't available
Imeplemented **ViewLayer.aovs.remove** by Adding a new rna function to call the internal **BKE_view_layer_remove_aov**, removed assert from **BKE_view_layer_remove_aov**.

Reviewed By: jbakker

Maniphest Tasks: T99259

Differential Revision: https://developer.blender.org/D15341
2022-08-22 08:36:19 +02:00
9581be930b Cleanup: remove dead code 2022-08-22 12:42:23 +10:00
2a43c9bb08 Cleanup: move inline unit system search into a function
Improved readability and remove redundant NULL checks.
Also remove redundant assignment.
2022-08-22 12:42:23 +10:00
212a3a23df Merge branch 'blender-v3.3-release' 2022-08-22 12:14:09 +10:00
f3bf497c2c Merge branch 'blender-v3.3-release' 2022-08-22 12:14:06 +10:00
edfa67a8cc Merge branch 'blender-v3.3-release' 2022-08-22 12:14:02 +10:00
dc644677cb Merge branch 'blender-v3.3-release' 2022-08-22 12:13:58 +10:00
c9144f0cbb Fix potential undefined behavior printing a NULL pointer string
Improve messages when the font directory can't be detected or is missing.
2022-08-22 12:10:41 +10:00
ed070b1223 check_cppcheck: update 'glew' exclusion since it's removal 2022-08-22 11:36:27 +10:00
b04514da5d Cleanup: match names between functions & declarations
Mostly update the declarations, in some cases rename in the function
especially when the names used were inconstant with related functions.
2022-08-22 11:20:40 +10:00
5bd1d63115 Cleanup: move model authors from the doc-string to the implementation
There is no need for details like this in API doc-strings.
2022-08-22 10:58:02 +10:00
a0c28a8054 Fix T100430: Restore larger node socket snap hitbox
Restore old hitbox for connecting links to sockets.

Commit rBd9d97db018d2 improved the node socket snapping when nodes
are close together by decreasing the tolerance around the cursor when
checking for nodes in front, that might occlude the socket.
In doing so it also reduced the hitbox of the node socket itself that
extended outside of the node.

This commit restores the old node socket hitbox while keeping the
improved behavior when nodes are close together with the following
changes:
1) When looking for the socket under the cursor, iterate through the
nodes front to back, which prioritizes node sockets in the foreground.
2) Instead of checking for another node underneath the cursor it checks
if the socket is actually occluded by another node.

The way the occlusion test for sockets is tweaked you can now connect to
sockets that are only partially occluded, which is a bit more forgiving
than previously.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D15731
2022-08-21 10:12:50 +02:00
c9a9967903 Outliner: Workaround for big performance issue in Library Overrides mode
When displaying the Hierarchies view of the Library Overrides display
mode in a specific Heist production file, Blender would become
unresponsive for about 30 seconds and every redraw in the Outliner would
lag noticably. Issue is that the sum of hierarchy elements is multiple
thousands, and that really brings the Outliner to its knees. I've looked
into some improvents and committed a few minor ones already, but it
seems it's really the big sum of elements causing the issue. There
doesn't appear to be a single bottle-neck.

To work around this, "lazy build" children, so that children of
collapsed elements are not actually created. This brings the tree
building down to some tens of miliseconds, and redrawing becomes
rather lag-free again, even with big parts of the tree un-collapsed.

Problem: Searching still needs to build the entire tree, so it's
essentially unusable right now. Should we disallow searching
altogether?
2022-08-19 22:22:40 +02:00
c2a6c3a4e2 Outliner: Refactor how lazy-building of children is done
Makes the lazy-building (where children are only built when the parent
isn't collapsed) more generic, so more display modes can use it. So far
this was hardcoded for the "Data API" display mode.

This will be used to work around a big performance issue with the
Library Overrides Hierachies view in a complex production file, see
following commit.
2022-08-19 22:22:25 +02:00
3234 changed files with 115572 additions and 90093 deletions

View File

@@ -273,5 +273,5 @@ StatementMacros:
- PyObject_VAR_HEAD
- ccl_gpu_kernel_postfix
MacroBlockBegin: "^BSDF_CLOSURE_CLASS_BEGIN$"
MacroBlockEnd: "^BSDF_CLOSURE_CLASS_END$"
MacroBlockBegin: "^OSL_CLOSURE_STRUCT_BEGIN$"
MacroBlockEnd: "^OSL_CLOSURE_STRUCT_END$"

File diff suppressed because it is too large Load Diff

View File

@@ -162,6 +162,7 @@ CPU:=$(shell uname -m)
# Source and Build DIR's
BLENDER_DIR:=$(shell pwd -P)
BUILD_TYPE:=Release
BLENDER_IS_PYTHON_MODULE:=
# CMake arguments, assigned to local variable to make it mutable.
CMAKE_CONFIG_ARGS := $(BUILD_CMAKE_ARGS)
@@ -229,9 +230,18 @@ endif
# -----------------------------------------------------------------------------
# additional targets for the build configuration
# Additional targets for the build configuration
# support 'make debug'
# NOTE: These targets can be combined and are applied in reverse order listed here.
# So it's important that `bpy` comes before `release` (for example)
# `make bpy release` first loads `release` configuration, then `bpy`.
# This is important as `bpy` will turn off some settings enabled by release.
ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_bpy
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" $(CMAKE_CONFIG_ARGS)
BLENDER_IS_PYTHON_MODULE:=1
endif
ifneq "$(findstring debug, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_debug
BUILD_TYPE:=Debug
@@ -256,10 +266,6 @@ ifneq "$(findstring headless, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_headless
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/blender_headless.cmake" $(CMAKE_CONFIG_ARGS)
endif
ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
BUILD_DIR:=$(BUILD_DIR)_bpy
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" $(CMAKE_CONFIG_ARGS)
endif
ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
CMAKE_CONFIG_ARGS:=-C"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake" $(CMAKE_CONFIG_ARGS)
@@ -297,8 +303,10 @@ endif
# use the default build path can still use utility helpers.
ifeq ($(OS), Darwin)
BLENDER_BIN?="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
BLENDER_BIN_DIR?="$(BUILD_DIR)/bin/Blender.app/Contents/MacOS/Blender"
else
BLENDER_BIN?="$(BUILD_DIR)/bin/blender"
BLENDER_BIN_DIR?="$(BUILD_DIR)/bin"
endif
@@ -355,8 +363,12 @@ all: .FORCE
@echo Building Blender ...
$(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install
@echo
@echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
@echo Blender successfully built, run from: $(BLENDER_BIN)
@echo Edit build configuration with: \"$(BUILD_DIR)/CMakeCache.txt\" run make again to rebuild.
@if test -z "$(BLENDER_IS_PYTHON_MODULE)"; then \
echo Blender successfully built, run from: $(BLENDER_BIN); \
else \
echo Blender successfully built as a Python module, \"bpy\" can be imported from: $(BLENDER_BIN_DIR); \
fi
@echo
debug: all

View File

@@ -94,6 +94,7 @@ include(cmake/pugixml.cmake)
include(cmake/ispc.cmake)
include(cmake/openimagedenoise.cmake)
include(cmake/embree.cmake)
include(cmake/openpgl.cmake)
include(cmake/fmt.cmake)
include(cmake/robinmap.cmake)
if(NOT APPLE)
@@ -169,6 +170,10 @@ if(UNIX AND NOT APPLE)
include(cmake/libglu.cmake)
include(cmake/mesa.cmake)
include(cmake/wayland_protocols.cmake)
# Can be removed when the build-bot upgrades to v1.20.x or newer.
include(cmake/wayland.cmake)
include(cmake/wayland_libdecor.cmake)
endif()
include(cmake/harvest.cmake)
include(cmake/cve_check.cmake)

View File

@@ -46,7 +46,7 @@ if(UNIX)
" ${_software_missing}\n"
"\n"
"On Debian and Ubuntu:\n"
" apt install autoconf automake libtool yasm tcl ninja-build meson python3-mako\n"
" apt install autoconf automake bison libtool yasm tcl ninja-build meson python3-mako\n"
"\n"
"On macOS (with homebrew):\n"
" brew install autoconf automake bison flex libtool meson ninja pkg-config yasm\n"

View File

@@ -0,0 +1,73 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# CVE Check requirements
#
# - A working installation of intels cve-bin-tool [1] has to be available in
# your path
#
# - Not strictly required, but highly recommended is obtaining a NVD key from
# nist since it significantly speeds up downloading/updating the required
# databases one can request a key on the following website:
# https://nvd.nist.gov/developers/request-an-api-key
# Bill of Materials construction
#
# This constructs a CSV cve-bin-tool [1] can read and process. Sadly
# cve-bin-tool at this point does not take a list of CPE's and output a check
# based on that list. so we need to pick apart the CPE retrieve the vendor,
# product and version tokens and generate a CSV.
#
# [1] https://github.com/intel/cve-bin-tool
# Because not all deps are downloaded (ie python packages) but can still have a
# xxx_CPE declared loop over all variables and look for variables ending in CPE.
set(SBOMCONTENTS)
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
if(_variableName MATCHES "CPE$")
string(REPLACE ":" ";" CPE_LIST ${${_variableName}})
list(GET CPE_LIST 3 CPE_VENDOR)
list(GET CPE_LIST 4 CPE_NAME)
list(GET CPE_LIST 5 CPE_VERSION)
set(SBOMCONTENTS "${SBOMCONTENTS}${CPE_VENDOR},${CPE_NAME},${CPE_VERSION}\n")
endif()
endforeach()
configure_file(${CMAKE_SOURCE_DIR}/cmake/cve_check.csv.in ${CMAKE_CURRENT_BINARY_DIR}/cve_check.csv @ONLY)
# Custom Targets
#
# This defines two new custom targets one could run in the build folder
# `cve_check` which will output the report to the console, and `cve_check_html`
# which will write out blender_dependencies.html in the build folder that one
# could share with other people or be used to get more information on the
# reported CVE's.
#
# cve-bin-tool takes data from the nist nvd database which rate limits
# unauthenticated requests to 1 requests per 6 seconds making the database
# download take "quite a bit" of time.
#
# When adding -DCVE_CHECK_NVD_KEY=your_api_key_here to your cmake invocation
# this key will be passed on to cve-bin-tool speeding up the process.
#
if(DEFINED CVE_CHECK_NVD_KEY)
set(NVD_ARGS --nvd-api-key ${CVE_CHECK_NVD_KEY})
endif()
# This will just report to the console
add_custom_target(cve_check
COMMAND cve-bin-tool
${NVD_ARGS}
-i ${CMAKE_CURRENT_BINARY_DIR}/cve_check.csv
--affected-versions
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/cve_check.csv
)
# This will write out blender_dependencies.html
add_custom_target(cve_check_html
COMMAND cve-bin-tool
${NVD_ARGS}
-i ${CMAKE_CURRENT_BINARY_DIR}/cve_check.csv
-f html
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/cve_check.csv
)

View File

@@ -0,0 +1,2 @@
vendor,product,version
@SBOMCONTENTS@

View File

@@ -14,6 +14,20 @@ function(download_source dep)
else()
set(TARGET_URI https://svn.blender.org/svnroot/bf-blender/trunk/lib/packages/${TARGET_FILE})
endif()
# Validate all required variables are set and give an explicit error message
# rather than CMake erroring out later on with a more ambigious error.
if (NOT DEFINED TARGET_FILE)
message(FATAL_ERROR "${dep}_FILE variable not set")
endif()
if (NOT DEFINED TARGET_HASH)
message(FATAL_ERROR "${dep}_HASH variable not set")
endif()
if (NOT DEFINED TARGET_HASH_TYPE)
message(FATAL_ERROR "${dep}_HASH_TYPE variable not set")
endif()
if (NOT DEFINED TARGET_URI)
message(FATAL_ERROR "${dep}_URI variable not set")
endif()
set(TARGET_FILE ${PACKAGE_DIR}/${TARGET_FILE})
message("Checking source : ${dep} (${TARGET_FILE})")
if(NOT EXISTS ${TARGET_FILE})
@@ -25,6 +39,36 @@ function(download_source dep)
SHOW_PROGRESS
)
endif()
if(EXISTS ${TARGET_FILE})
# Sometimes the download fails, but that is not a
# fail condition for "file(DOWNLOAD" it will warn about
# a crc mismatch and just carry on, we need to explicitly
# catch this and remove the bogus 0 byte file so we can
# retry without having to go find the file and manually
# delete it.
file (SIZE ${TARGET_FILE} TARGET_SIZE)
if(${TARGET_SIZE} EQUAL 0)
file(REMOVE ${TARGET_FILE})
message(FATAL_ERROR "for ${TARGET_FILE} file size 0, download likely failed, deleted...")
endif()
# If we are using sources from the blender repo also
# validate that the hashes match, this takes a
# little more time, but protects us when we are
# building a release package and one of the packages
# is missing or incorrect.
#
# For regular platform maintenaince this is not needed
# since the actual build of the dep will notify the
# platform maintainer if there is a problem with the
# source package and refuse to build.
if(NOT PACKAGE_USE_UPSTREAM_SOURCES)
file(${TARGET_HASH_TYPE} ${TARGET_FILE} LOCAL_HASH)
if(NOT ${TARGET_HASH} STREQUAL ${LOCAL_HASH})
message(FATAL_ERROR "${TARGET_FILE} ${TARGET_HASH_TYPE} mismatch\nExpected\t: ${TARGET_HASH}\nActual\t: ${LOCAL_HASH}")
endif()
endif()
endif()
endfunction(download_source)
download_source(ZLIB)
@@ -51,7 +95,6 @@ download_source(OSL)
download_source(PYTHON)
download_source(TBB)
download_source(OPENVDB)
download_source(NANOVDB)
download_source(NUMPY)
download_source(LAME)
download_source(OGG)
@@ -89,17 +132,21 @@ download_source(MESA)
download_source(NASM)
download_source(XR_OPENXR_SDK)
download_source(WL_PROTOCOLS)
download_source(WAYLAND)
download_source(WAYLAND_LIBDECOR)
download_source(ISPC)
download_source(GMP)
download_source(POTRACE)
download_source(HARU)
download_source(ZSTD)
download_source(SSE2NEON)
download_source(FLEX)
download_source(BROTLI)
download_source(FMT)
download_source(ROBINMAP)
download_source(IMATH)
download_source(PYSTRING)
download_source(OPENPGL)
download_source(LEVEL_ZERO)
download_source(DPCPP)
download_source(VCINTRINSICS)

View File

@@ -68,7 +68,7 @@ set(DPCPP_EXTRA_ARGS
)
if(WIN32)
list(APPEND DPCPP_EXTRA_ARGS -DPython3_FIND_REGISTRY=NEVER)
list(APPEND DPCPP_EXTRA_ARGS -DPython3_FIND_REGISTRY=NEVER)
endif()
ExternalProject_Add(external_dpcpp

View File

@@ -11,188 +11,194 @@ message("HARVEST_TARGET = ${HARVEST_TARGET}")
if(WIN32)
if(BUILD_MODE STREQUAL Release)
add_custom_target(Harvest_Release_Results
COMMAND # jpeg rename libfile + copy include
${CMAKE_COMMAND} -E copy ${LIBDIR}/jpeg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpeg/include/ ${HARVEST_TARGET}/jpeg/include/ &&
# png
${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ &&
# freeglut-> opengl
${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
DEPENDS
)
endif()
else(WIN32)
function(harvest from to)
set(pattern "")
foreach(f ${ARGN})
set(pattern ${f})
endforeach()
if(pattern STREQUAL "")
get_filename_component(dirpath ${to} DIRECTORY)
get_filename_component(filename ${to} NAME)
install(
FILES ${LIBDIR}/${from}
DESTINATION ${HARVEST_TARGET}/${dirpath}
RENAME ${filename}
)
else()
install(
DIRECTORY ${LIBDIR}/${from}/
DESTINATION ${HARVEST_TARGET}/${to}
USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN ${pattern}
PATTERN "pkgconfig" EXCLUDE
PATTERN "cmake" EXCLUDE
PATTERN "__pycache__" EXCLUDE
PATTERN "tests" EXCLUDE
if(BUILD_MODE STREQUAL Release)
add_custom_target(Harvest_Release_Results
COMMAND # jpeg rename libfile + copy include
${CMAKE_COMMAND} -E copy ${LIBDIR}/jpeg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpeg/include/ ${HARVEST_TARGET}/jpeg/include/ &&
# png
${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ &&
# freeglut-> opengl
${CMAKE_COMMAND} -E copy ${LIBDIR}/freeglut/lib/freeglut_static.lib ${HARVEST_TARGET}/opengl/lib/freeglut_static.lib &&
${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freeglut/include/ ${HARVEST_TARGET}/opengl/include/ &&
DEPENDS
)
endif()
endfunction()
harvest(alembic/include alembic/include "*.h")
harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a)
harvest(alembic/bin alembic/bin "*")
harvest(brotli/include brotli/include "*.h")
harvest(brotli/lib brotli/lib "*.a")
harvest(boost/include boost/include "*")
harvest(boost/lib boost/lib "*.a")
harvest(imath/include imath/include "*.h")
harvest(imath/lib imath/lib "*.a")
harvest(ffmpeg/include ffmpeg/include "*.h")
harvest(ffmpeg/lib ffmpeg/lib "*.a")
harvest(fftw3/include fftw3/include "*.h")
harvest(fftw3/lib fftw3/lib "*.a")
harvest(flac/lib sndfile/lib "libFLAC.a")
harvest(freetype/include freetype/include "*.h")
harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
harvest(epoxy/include epoxy/include "*.h")
harvest(epoxy/lib epoxy/lib "*.a")
harvest(gmp/include gmp/include "*.h")
harvest(gmp/lib gmp/lib "*.a")
harvest(jemalloc/include jemalloc/include "*.h")
harvest(jemalloc/lib jemalloc/lib "*.a")
harvest(jpeg/include jpeg/include "*.h")
harvest(jpeg/lib jpeg/lib "libjpeg.a")
harvest(lame/lib ffmpeg/lib "*.a")
if(NOT APPLE)
harvest(level-zero/include/level_zero level-zero/include/level_zero "*.h")
harvest(level-zero/lib level-zero/lib "*.so*")
endif()
harvest(llvm/bin llvm/bin "clang-format")
if(BUILD_CLANG_TOOLS)
harvest(llvm/bin llvm/bin "clang-tidy")
harvest(llvm/share/clang llvm/share "run-clang-tidy.py")
endif()
harvest(llvm/include llvm/include "*")
harvest(llvm/bin llvm/bin "llvm-config")
harvest(llvm/lib llvm/lib "libLLVM*.a")
harvest(llvm/lib llvm/lib "libclang*.a")
harvest(llvm/lib/clang llvm/lib/clang "*.h")
if(APPLE)
harvest(openmp/lib openmp/lib "*")
harvest(openmp/include openmp/include "*.h")
endif()
if(BLENDER_PLATFORM_ARM)
harvest(sse2neon sse2neon "*.h")
endif()
harvest(ogg/lib ffmpeg/lib "*.a")
harvest(openal/include openal/include "*.h")
if(UNIX AND NOT APPLE)
harvest(openal/lib openal/lib "*.a")
harvest(blosc/include blosc/include "*.h")
harvest(blosc/lib blosc/lib "*.a")
harvest(zlib/include zlib/include "*.h")
harvest(zlib/lib zlib/lib "*.a")
harvest(xml2/include xml2/include "*.h")
harvest(xml2/lib xml2/lib "*.a")
harvest(wayland-protocols/share/wayland-protocols wayland-protocols/share/wayland-protocols/ "*.xml")
else()
harvest(blosc/lib openvdb/lib "*.a")
harvest(xml2/lib opencollada/lib "*.a")
endif()
harvest(opencollada/include/opencollada opencollada/include "*.h")
harvest(opencollada/lib/opencollada opencollada/lib "*.a")
harvest(opencolorio/include opencolorio/include "*.h")
harvest(opencolorio/lib opencolorio/lib "*.a")
harvest(opencolorio/lib/static opencolorio/lib "*.a")
harvest(openexr/include openexr/include "*.h")
harvest(openexr/lib openexr/lib "*.a")
harvest(openimageio/bin openimageio/bin "idiff")
harvest(openimageio/bin openimageio/bin "maketx")
harvest(openimageio/bin openimageio/bin "oiiotool")
harvest(openimageio/include openimageio/include "*")
harvest(openimageio/lib openimageio/lib "*.a")
harvest(openimagedenoise/include openimagedenoise/include "*")
harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
harvest(embree/include embree/include "*.h")
harvest(embree/lib embree/lib "*.a")
harvest(openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION} openjpeg/include "*.h")
harvest(openjpeg/lib openjpeg/lib "*.a")
harvest(opensubdiv/include opensubdiv/include "*.h")
harvest(opensubdiv/lib opensubdiv/lib "*.a")
harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
harvest(openvdb/include/nanovdb openvdb/include/nanovdb "*.h")
harvest(openvdb/lib openvdb/lib "*.a")
harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
harvest(xr_openxr_sdk/lib xr_openxr_sdk/lib "*.a")
harvest(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")
harvest(osl/share/OSL/shaders osl/share/OSL/shaders "*.h")
harvest(png/include png/include "*.h")
harvest(png/lib png/lib "*.a")
harvest(pugixml/include pugixml/include "*.hpp")
harvest(pugixml/lib pugixml/lib "*.a")
harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}")
harvest(python/include python/include "*h")
harvest(python/lib python/lib "*")
harvest(sdl/include/SDL2 sdl/include "*.h")
harvest(sdl/lib sdl/lib "libSDL2.a")
harvest(sndfile/include sndfile/include "*.h")
harvest(sndfile/lib sndfile/lib "*.a")
harvest(spnav/include spnav/include "*.h")
harvest(spnav/lib spnav/lib "*.a")
harvest(tbb/include tbb/include "*.h")
harvest(tbb/lib/libtbb_static.a tbb/lib/libtbb.a)
harvest(theora/lib ffmpeg/lib "*.a")
harvest(tiff/include tiff/include "*.h")
harvest(tiff/lib tiff/lib "*.a")
harvest(vorbis/lib ffmpeg/lib "*.a")
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")
harvest(usd/lib/usd usd/lib/usd "*")
harvest(usd/plugin usd/plugin "*")
harvest(potrace/include potrace/include "*.h")
harvest(potrace/lib potrace/lib "*.a")
harvest(haru/include haru/include "*.h")
harvest(haru/lib haru/lib "*.a")
harvest(zstd/include zstd/include "*.h")
harvest(zstd/lib zstd/lib "*.a")
if(UNIX AND NOT APPLE)
harvest(libglu/lib mesa/lib "*.so*")
harvest(mesa/lib64 mesa/lib "*.so*")
function(harvest from to)
set(pattern "")
foreach(f ${ARGN})
set(pattern ${f})
endforeach()
harvest(dpcpp dpcpp "*")
harvest(igc dpcpp/lib/igc "*")
harvest(ocloc dpcpp/lib/ocloc "*")
endif()
if(pattern STREQUAL "")
get_filename_component(dirpath ${to} DIRECTORY)
get_filename_component(filename ${to} NAME)
install(
FILES ${LIBDIR}/${from}
DESTINATION ${HARVEST_TARGET}/${dirpath}
RENAME ${filename}
)
else()
install(
DIRECTORY ${LIBDIR}/${from}/
DESTINATION ${HARVEST_TARGET}/${to}
USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN ${pattern}
PATTERN "pkgconfig" EXCLUDE
PATTERN "cmake" EXCLUDE
PATTERN "__pycache__" EXCLUDE
PATTERN "tests" EXCLUDE
)
endif()
endfunction()
harvest(alembic/include alembic/include "*.h")
harvest(alembic/lib/libAlembic.a alembic/lib/libAlembic.a)
harvest(alembic/bin alembic/bin "*")
harvest(brotli/include brotli/include "*.h")
harvest(brotli/lib brotli/lib "*.a")
harvest(boost/include boost/include "*")
harvest(boost/lib boost/lib "*.a")
harvest(imath/include imath/include "*.h")
harvest(imath/lib imath/lib "*.a")
harvest(ffmpeg/include ffmpeg/include "*.h")
harvest(ffmpeg/lib ffmpeg/lib "*.a")
harvest(fftw3/include fftw3/include "*.h")
harvest(fftw3/lib fftw3/lib "*.a")
harvest(flac/lib sndfile/lib "libFLAC.a")
harvest(freetype/include freetype/include "*.h")
harvest(freetype/lib/libfreetype2ST.a freetype/lib/libfreetype.a)
harvest(epoxy/include epoxy/include "*.h")
harvest(epoxy/lib epoxy/lib "*.a")
harvest(gmp/include gmp/include "*.h")
harvest(gmp/lib gmp/lib "*.a")
harvest(jemalloc/include jemalloc/include "*.h")
harvest(jemalloc/lib jemalloc/lib "*.a")
harvest(jpeg/include jpeg/include "*.h")
harvest(jpeg/lib jpeg/lib "libjpeg.a")
harvest(lame/lib ffmpeg/lib "*.a")
if(NOT APPLE)
harvest(level-zero/include/level_zero level-zero/include/level_zero "*.h")
harvest(level-zero/lib level-zero/lib "*.so*")
endif()
harvest(llvm/bin llvm/bin "clang-format")
if(BUILD_CLANG_TOOLS)
harvest(llvm/bin llvm/bin "clang-tidy")
harvest(llvm/share/clang llvm/share "run-clang-tidy.py")
endif()
harvest(llvm/include llvm/include "*")
harvest(llvm/bin llvm/bin "llvm-config")
harvest(llvm/lib llvm/lib "libLLVM*.a")
harvest(llvm/lib llvm/lib "libclang*.a")
harvest(llvm/lib/clang llvm/lib/clang "*.h")
if(APPLE)
harvest(openmp/lib openmp/lib "*")
harvest(openmp/include openmp/include "*.h")
endif()
if(BLENDER_PLATFORM_ARM)
harvest(sse2neon sse2neon "*.h")
endif()
harvest(ogg/lib ffmpeg/lib "*.a")
harvest(openal/include openal/include "*.h")
if(UNIX AND NOT APPLE)
harvest(openal/lib openal/lib "*.a")
harvest(blosc/include blosc/include "*.h")
harvest(blosc/lib blosc/lib "*.a")
harvest(zlib/include zlib/include "*.h")
harvest(zlib/lib zlib/lib "*.a")
harvest(xml2/include xml2/include "*.h")
harvest(xml2/lib xml2/lib "*.a")
harvest(wayland-protocols/share/wayland-protocols wayland-protocols/share/wayland-protocols/ "*.xml")
harvest(wayland/bin wayland/bin "wayland-scanner")
harvest(wayland/include wayland/include "*.h")
harvest(wayland_libdecor/include wayland_libdecor/include "*.h")
else()
harvest(blosc/lib openvdb/lib "*.a")
harvest(xml2/lib opencollada/lib "*.a")
endif()
harvest(opencollada/include/opencollada opencollada/include "*.h")
harvest(opencollada/lib/opencollada opencollada/lib "*.a")
harvest(opencolorio/include opencolorio/include "*.h")
harvest(opencolorio/lib opencolorio/lib "*.a")
harvest(opencolorio/lib/static opencolorio/lib "*.a")
harvest(openexr/include openexr/include "*.h")
harvest(openexr/lib openexr/lib "*.a")
harvest(openimageio/bin openimageio/bin "idiff")
harvest(openimageio/bin openimageio/bin "maketx")
harvest(openimageio/bin openimageio/bin "oiiotool")
harvest(openimageio/include openimageio/include "*")
harvest(openimageio/lib openimageio/lib "*.a")
harvest(openimagedenoise/include openimagedenoise/include "*")
harvest(openimagedenoise/lib openimagedenoise/lib "*.a")
harvest(embree/include embree/include "*.h")
harvest(embree/lib embree/lib "*.a")
harvest(openpgl/include openpgl/include "*.h")
harvest(openpgl/lib openpgl/lib "*.a")
harvest(openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION} openpgl/lib/cmake/openpgl "*.cmake")
harvest(openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION} openjpeg/include "*.h")
harvest(openjpeg/lib openjpeg/lib "*.a")
harvest(opensubdiv/include opensubdiv/include "*.h")
harvest(opensubdiv/lib opensubdiv/lib "*.a")
harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
harvest(openvdb/include/nanovdb openvdb/include/nanovdb "*.h")
harvest(openvdb/lib openvdb/lib "*.a")
harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
harvest(xr_openxr_sdk/lib xr_openxr_sdk/lib "*.a")
harvest(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")
harvest(osl/share/OSL/shaders osl/share/OSL/shaders "*.h")
harvest(png/include png/include "*.h")
harvest(png/lib png/lib "*.a")
harvest(pugixml/include pugixml/include "*.hpp")
harvest(pugixml/lib pugixml/lib "*.a")
harvest(python/bin python/bin "python${PYTHON_SHORT_VERSION}")
harvest(python/include python/include "*h")
harvest(python/lib python/lib "*")
harvest(sdl/include/SDL2 sdl/include "*.h")
harvest(sdl/lib sdl/lib "libSDL2.a")
harvest(sndfile/include sndfile/include "*.h")
harvest(sndfile/lib sndfile/lib "*.a")
harvest(spnav/include spnav/include "*.h")
harvest(spnav/lib spnav/lib "*.a")
harvest(tbb/include tbb/include "*.h")
harvest(tbb/lib/libtbb_static.a tbb/lib/libtbb.a)
harvest(theora/lib ffmpeg/lib "*.a")
harvest(tiff/include tiff/include "*.h")
harvest(tiff/lib tiff/lib "*.a")
harvest(vorbis/lib ffmpeg/lib "*.a")
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")
harvest(usd/lib/usd usd/lib/usd "*")
harvest(usd/plugin usd/plugin "*")
harvest(potrace/include potrace/include "*.h")
harvest(potrace/lib potrace/lib "*.a")
harvest(haru/include haru/include "*.h")
harvest(haru/lib haru/lib "*.a")
harvest(zstd/include zstd/include "*.h")
harvest(zstd/lib zstd/lib "*.a")
if(UNIX AND NOT APPLE)
harvest(libglu/lib mesa/lib "*.so*")
harvest(mesa/lib64 mesa/lib "*.so*")
harvest(dpcpp dpcpp "*")
harvest(igc dpcpp/lib/igc "*")
harvest(ocloc dpcpp/lib/ocloc "*")
endif()
endif()

View File

@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
if(WIN32)
# cmake for windows
# CMAKE for MS-Windows.
set(JPEG_EXTRA_ARGS
-DNASM=${NASM_PATH}
-DWITH_JPEG8=ON
@@ -33,8 +33,8 @@ if(WIN32)
)
endif()
else(WIN32)
# cmake for unix
else()
# CMAKE for UNIX.
set(JPEG_EXTRA_ARGS
-DWITH_JPEG8=ON
-DENABLE_STATIC=ON

View File

@@ -0,0 +1,50 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Note the utility apps may use png/tiff/gif system libraries, but the
# library itself does not depend on them, so should give no problems.
set(OPENPGL_EXTRA_ARGS
-DOPENPGL_BUILD_PYTHON=OFF
-DOPENPGL_BUILD_STATIC=ON
-DOPENPGL_TBB_ROOT=${LIBDIR}/tbb
-DTBB_ROOT=${LIBDIR}/tbb
-Dembree_DIR=${LIBDIR}/embree/lib/cmake/embree-${EMBREE_VERSION}
-DCMAKE_DEBUG_POSTFIX=_d
)
if(TBB_STATIC_LIBRARY)
set(OPENPGL_EXTRA_ARGS
${OPENPGL_EXTRA_ARGS}
-DOPENPGL_TBB_COMPONENT=tbb_static
)
endif()
ExternalProject_Add(external_openpgl
URL file://${PACKAGE_DIR}/${OPENPGL_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENPGL_HASH_TYPE}=${OPENPGL_HASH}
PREFIX ${BUILD_DIR}/openpgl
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openpgl ${DEFAULT_CMAKE_FLAGS} ${OPENPGL_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/openpgl
)
add_dependencies(
external_openpgl
external_tbb
external_embree
)
if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_openpgl after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openpgl ${HARVEST_TARGET}/openpgl
DEPENDEES install
)
else()
ExternalProject_Add_Step(external_openpgl after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openpgl/lib/openpgl_d.lib ${HARVEST_TARGET}/openpgl/lib/openpgl_d.lib
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake ${HARVEST_TARGET}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake
DEPENDEES install
)
endif()
endif()

View File

@@ -15,7 +15,7 @@ message("BuildMode = ${BUILD_MODE}")
if(BUILD_MODE STREQUAL "Debug")
set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Debug)
else(BUILD_MODE STREQUAL "Debug")
else()
set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Release)
endif()

View File

@@ -1,9 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
ExternalProject_Add(external_sse2neon
GIT_REPOSITORY ${SSE2NEON_GIT}
GIT_TAG ${SSE2NEON_GIT_HASH}
URL file://${PACKAGE_DIR}/${SSE2NEON_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${SSE2NEON_HASH_TYPE}=${SSE2NEON_HASH}
PREFIX ${BUILD_DIR}/sse2neon
CONFIGURE_COMMAND echo sse2neon - Nothing to configure
BUILD_COMMAND echo sse2neon - nothing to build

View File

@@ -1,10 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# CPE's are used to identify dependencies, for more information on what they
# are please see https://nvd.nist.gov/products/cpe
#
# We use them in combination with cve-bin-tool to scan for known security issues.
#
# Not all of our dependencies are currently in the nvd database so not all
# dependencies have one assigned.
set(ZLIB_VERSION 1.2.12)
set(ZLIB_URI https://zlib.net/zlib-${ZLIB_VERSION}.tar.gz)
set(ZLIB_HASH 5fc414a9726be31427b440b434d05f78)
set(ZLIB_HASH_TYPE MD5)
set(ZLIB_FILE zlib-${ZLIB_VERSION}.tar.gz)
set(ZLIB_CPE "cpe:2.3:a:zlib:zlib:${ZLIB_VERSION}:*:*:*:*:*:*:*")
set(OPENAL_VERSION 1.21.1)
set(OPENAL_URI http://openal-soft.org/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2)
@@ -17,12 +26,14 @@ set(PNG_URI http://prdownloads.sourceforge.net/libpng/libpng-${PNG_VERSION}.tar.
set(PNG_HASH 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca)
set(PNG_HASH_TYPE SHA256)
set(PNG_FILE libpng-${PNG_VERSION}.tar.xz)
set(PNG_CPE "cpe:2.3:a:libpng:libpng:${PNG_VERSION}:*:*:*:*:*:*:*")
set(JPEG_VERSION 2.1.3)
set(JPEG_URI https://github.com/libjpeg-turbo/libjpeg-turbo/archive/${JPEG_VERSION}.tar.gz)
set(JPEG_HASH 627b980fad0573e08e4c3b80b290fc91)
set(JPEG_HASH_TYPE MD5)
set(JPEG_FILE libjpeg-turbo-${JPEG_VERSION}.tar.gz)
set(JPEG_CPE "cpe:2.3:a:d.r.commander:libjpeg-turbo:${JPEG_VERSION}:*:*:*:*:*:*:*")
set(BOOST_VERSION 1.78.0)
set(BOOST_VERSION_SHORT 1.78)
@@ -32,12 +43,14 @@ set(BOOST_URI https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION
set(BOOST_HASH c2f6428ac52b0e5a3c9b2e1d8cc832b5)
set(BOOST_HASH_TYPE MD5)
set(BOOST_FILE boost_${BOOST_VERSION_NODOTS}.tar.gz)
set(BOOST_CPE "cpe:2.3:a:boost:boost:${BOOST_VERSION}:*:*:*:*:*:*:*")
set(BLOSC_VERSION 1.21.1)
set(BLOSC_URI https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.tar.gz)
set(BLOSC_HASH 134b55813b1dca57019d2a2dc1f7a923)
set(BLOSC_HASH_TYPE MD5)
set(BLOSC_FILE blosc-${BLOSC_VERSION}.tar.gz)
set(BLOSC_CPE "cpe:2.3:a:c-blosc2_project:c-blosc2:${BLOSC_VERSION}:*:*:*:*:*:*:*")
set(PTHREADS_VERSION 3.0.0)
set(PTHREADS_URI http://prdownloads.sourceforge.net/pthreads4w/pthreads4w-code-v${PTHREADS_VERSION}.zip)
@@ -50,6 +63,7 @@ set(OPENEXR_URI https://github.com/AcademySoftwareFoundation/openexr/archive/v${
set(OPENEXR_HASH a92f38eedd43e56c0af56d4852506886)
set(OPENEXR_HASH_TYPE MD5)
set(OPENEXR_FILE openexr-${OPENEXR_VERSION}.tar.gz)
set(OPENEXR_CPE "cpe:2.3:a:openexr:openexr:${OPENEXR_VERSION}:*:*:*:*:*:*:*")
set(IMATH_VERSION 3.1.5)
set(IMATH_URI https://github.com/AcademySoftwareFoundation/Imath/archive/v${OPENEXR_VERSION}.tar.gz)
@@ -79,6 +93,7 @@ set(FREETYPE_URI http://prdownloads.sourceforge.net/freetype/freetype-${FREETYPE
set(FREETYPE_HASH bd4e3b007474319909a6b79d50908e85)
set(FREETYPE_HASH_TYPE MD5)
set(FREETYPE_FILE freetype-${FREETYPE_VERSION}.tar.gz)
SET(FREETYPE_CPE "cpe:2.3:a:freetype:freetype:${FREETYPE_VERSION}:*:*:*:*:*:*:*")
set(EPOXY_VERSION 1.5.10)
set(EPOXY_URI https://github.com/anholt/libepoxy/archive/refs/tags/${EPOXY_VERSION}.tar.gz)
@@ -97,6 +112,7 @@ set(ALEMBIC_URI https://github.com/alembic/alembic/archive/${ALEMBIC_VERSION}.ta
set(ALEMBIC_HASH 2cd8d6e5a3ac4a014e24a4b04f4fadf9)
set(ALEMBIC_HASH_TYPE MD5)
set(ALEMBIC_FILE alembic-${ALEMBIC_VERSION}.tar.gz)
SET(FREETYPE_CPE "cpe:2.3:a:freetype:freetype:${FREETYPE_VERSION}:*:*:*:*:*:*:*")
set(OPENSUBDIV_VERSION v3_4_4)
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
@@ -109,6 +125,7 @@ set(SDL_URI https://www.libsdl.org/release/SDL2-${SDL_VERSION}.tar.gz)
set(SDL_HASH a53acc02e1cca98c4123229069b67c9e)
set(SDL_HASH_TYPE MD5)
set(SDL_FILE SDL2-${SDL_VERSION}.tar.gz)
set(SDL_CPE "cpe:2.3:a:libsdl:sdl:${SDL_VERSION}:*:*:*:*:*:*:*")
set(OPENCOLLADA_VERSION v1.6.68)
set(OPENCOLLADA_URI https://github.com/KhronosGroup/OpenCOLLADA/archive/${OPENCOLLADA_VERSION}.tar.gz)
@@ -127,6 +144,7 @@ set(LLVM_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${LL
set(LLVM_HASH 5a4fab4d7fc84aefffb118ac2c8a4fc0)
set(LLVM_HASH_TYPE MD5)
set(LLVM_FILE llvm-project-${LLVM_VERSION}.src.tar.xz)
set(LLVM_CPE "cpe:2.3:a:llvm:compiler:${LLVM_VERSION}:*:*:*:*:*:*:*")
if(APPLE)
# Cloth physics test is crashing due to this bug:
@@ -154,6 +172,7 @@ set(FMT_URI https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.tar.g
set(FMT_HASH 7bce0e9e022e586b178b150002e7c2339994e3c2bbe44027e9abb0d60f9cce83)
set(FMT_HASH_TYPE SHA256)
set(FMT_FILE fmt-${FMT_VERSION}.tar.gz)
set(FMT_CPE "cpe:2.3:a:fmt:fmt:${FMT_VERSION}:*:*:*:*:*:*:*")
# 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
@@ -168,6 +187,7 @@ set(TIFF_URI http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz)
set(TIFF_HASH 376f17f189e9d02280dfe709b2b2bbea)
set(TIFF_HASH_TYPE MD5)
set(TIFF_FILE tiff-${TIFF_VERSION}.tar.gz)
set(TIFF_CPE "cpe:2.3:a:libtiff:libtiff:${TIFF_VERSION}:*:*:*:*:*:*:*")
set(OSL_VERSION 1.11.17.0)
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
@@ -182,12 +202,15 @@ set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTH
set(PYTHON_HASH 14e8c22458ed7779a1957b26cde01db9)
set(PYTHON_HASH_TYPE MD5)
set(PYTHON_FILE Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_CPE "cpe:2.3:a:python:python:${PYTHON_VERSION}:-:*:*:*:*:*:*")
set(TBB_VERSION 2020_U3)
set(TBB_YEAR 2020)
set(TBB_VERSION ${TBB_YEAR}_U3)
set(TBB_URI https://github.com/oneapi-src/oneTBB/archive/${TBB_VERSION}.tar.gz)
set(TBB_HASH 55ec8df6eae5ed6364a47f0e671e460c)
set(TBB_HASH_TYPE MD5)
set(TBB_FILE oneTBB-${TBB_VERSION}.tar.gz)
set(TBB_CPE "cpe:2.3:a:intel:threading_building_blocks:${TBB_YEAR}:*:*:*:*:*:*:*")
set(OPENVDB_VERSION 9.0.0)
set(OPENVDB_URI https://github.com/AcademySoftwareFoundation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz)
@@ -198,6 +221,7 @@ set(OPENVDB_FILE openvdb-${OPENVDB_VERSION}.tar.gz)
set(IDNA_VERSION 3.3)
set(CHARSET_NORMALIZER_VERSION 2.0.10)
set(URLLIB3_VERSION 1.26.8)
set(URLLIB3_CPE "cpe:2.3:a:urllib3:urllib3:${URLLIB3_VERSION}:*:*:*:*:*:*:*")
set(CERTIFI_VERSION 2021.10.8)
set(REQUESTS_VERSION 2.27.1)
set(CYTHON_VERSION 0.29.26)
@@ -214,12 +238,14 @@ set(NUMPY_URI https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}
set(NUMPY_HASH 252de134862a27bd66705d29622edbfe)
set(NUMPY_HASH_TYPE MD5)
set(NUMPY_FILE numpy-${NUMPY_VERSION}.zip)
set(NUMPY_CPE "cpe:2.3:a:numpy:numpy:${NUMPY_VERSION}:*:*:*:*:*:*:*")
set(LAME_VERSION 3.100)
set(LAME_URI http://downloads.sourceforge.net/project/lame/lame/3.100/lame-${LAME_VERSION}.tar.gz)
set(LAME_HASH 83e260acbe4389b54fe08e0bdbf7cddb)
set(LAME_HASH_TYPE MD5)
set(LAME_FILE lame-${LAME_VERSION}.tar.gz)
set(LAME_CPE "cpe:2.3:a:lame_project:lame:${LAME_VERSION}:*:*:*:*:*:*:*")
set(OGG_VERSION 1.3.5)
set(OGG_URI http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz)
@@ -232,6 +258,7 @@ set(VORBIS_URI http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERS
set(VORBIS_HASH 0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab)
set(VORBIS_HASH_TYPE SHA256)
set(VORBIS_FILE libvorbis-${VORBIS_VERSION}.tar.gz)
set(VORBIS_CPE "cpe:2.3:a:xiph.org:libvorbis:${VORBIS_VERSION}:*:*:*:*:*:*:*")
set(THEORA_VERSION 1.1.1)
set(THEORA_URI http://downloads.xiph.org/releases/theora/libtheora-${THEORA_VERSION}.tar.bz2)
@@ -244,12 +271,14 @@ set(FLAC_URI http://downloads.xiph.org/releases/flac/flac-${FLAC_VERSION}.tar.xz
set(FLAC_HASH 8ff0607e75a322dd7cd6ec48f4f225471404ae2730d0ea945127b1355155e737 )
set(FLAC_HASH_TYPE SHA256)
set(FLAC_FILE flac-${FLAC_VERSION}.tar.xz)
set(FLAC_CPE "cpe:2.3:a:flac_project:flac:${FLAC_VERSION}:*:*:*:*:*:*:*")
set(VPX_VERSION 1.11.0)
set(VPX_URI https://github.com/webmproject/libvpx/archive/v${VPX_VERSION}/libvpx-v${VPX_VERSION}.tar.gz)
set(VPX_HASH 965e51c91ad9851e2337aebcc0f517440c637c506f3a03948062e3d5ea129a83)
set(VPX_HASH_TYPE SHA256)
set(VPX_FILE libvpx-v${VPX_VERSION}.tar.gz)
set(VPX_CPE "cpe:2.3:a:webmproject:libvpx:${VPX_VERSION}:*:*:*:*:*:*:*")
set(OPUS_VERSION 1.3.1)
set(OPUS_URI https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz)
@@ -275,12 +304,14 @@ set(OPENJPEG_URI https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSI
set(OPENJPEG_HASH 8702ba68b442657f11aaeb2b338443ca8d5fb95b0d845757968a7be31ef7f16d)
set(OPENJPEG_HASH_TYPE SHA256)
set(OPENJPEG_FILE openjpeg-v${OPENJPEG_VERSION}.tar.gz)
set(OPENJPEG_CPE "cpe:2.3:a:uclouvain:openjpeg:${OPENJPEG_VERSION}:*:*:*:*:*:*:*")
set(FFMPEG_VERSION 5.0)
set(FFMPEG_URI http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2)
set(FFMPEG_HASH c0130b8db2c763430fd1c6905288d61bc44ee0548ad5fcd2dfd650b88432bed9)
set(FFMPEG_HASH_TYPE SHA256)
set(FFMPEG_FILE ffmpeg-${FFMPEG_VERSION}.tar.bz2)
set(FFMPEG_CPE "cpe:2.3:a:ffmpeg:ffmpeg:${FFMPEG_VERSION}:*:*:*:*:*:*:*")
set(FFTW_VERSION 3.3.10)
set(FFTW_URI http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz)
@@ -299,12 +330,14 @@ set(SNDFILE_URI http://www.mega-nerd.com/libsndfile/files/libsndfile-${SNDFILE_V
set(SNDFILE_HASH 646b5f98ce89ac60cdb060fcd398247c)
set(SNDFILE_HASH_TYPE MD5)
set(SNDFILE_FILE libsndfile-${SNDFILE_VERSION}.tar.gz)
set(SNDFILE_CPE "cpe:2.3:a:libsndfile_project:libsndfile:${SNDFILE_VERSION}:*:*:*:*:*:*:*")
set(WEBP_VERSION 1.2.2)
set(WEBP_URI https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VERSION}.tar.gz)
set(WEBP_HASH b5e2e414a8adee4c25fe56b18dd9c549)
set(WEBP_HASH_TYPE MD5)
set(WEBP_FILE libwebp-${WEBP_VERSION}.tar.gz)
set(WEBP_CPE "cpe:2.3:a:webmproject:libwebp:${WEBP_VERSION}:*:*:*:*:*:*:*")
set(SPNAV_VERSION 0.2.3)
set(SPNAV_URI http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%20${SPNAV_VERSION}/libspnav-${SPNAV_VERSION}.tar.gz)
@@ -323,6 +356,7 @@ set(XML2_URI http://xmlsoft.org/sources/libxml2-${XML2_VERSION}.tar.gz)
set(XML2_HASH 10942a1dc23137a8aa07f0639cbfece5)
set(XML2_HASH_TYPE MD5)
set(XML2_FILE libxml2-${XML2_VERSION}.tar.gz)
set(XML2_CPE "cpe:2.3:a:xmlsoft:libxml2:${XML2_VERSION}:*:*:*:*:*:*:*")
set(TINYXML_VERSION 2_6_2)
set(TINYXML_VERSION_DOTS 2.6.2)
@@ -330,12 +364,14 @@ set(TINYXML_URI https://nchc.dl.sourceforge.net/project/tinyxml/tinyxml/${TINYXM
set(TINYXML_HASH c1b864c96804a10526540c664ade67f0)
set(TINYXML_HASH_TYPE MD5)
set(TINYXML_FILE tinyxml_${TINYXML_VERSION}.tar.gz)
set(TINYXML_CPE "cpe:2.3:a:tinyxml_project:tinyxml:${TINYXML_VERSION_DOTS}:*:*:*:*:*:*:*")
set(YAMLCPP_VERSION 0.6.3)
set(YAMLCPP_URI https://codeload.github.com/jbeder/yaml-cpp/tar.gz/yaml-cpp-${YAMLCPP_VERSION})
set(YAMLCPP_HASH b45bf1089a382e81f6b661062c10d0c2)
set(YAMLCPP_HASH_TYPE MD5)
set(YAMLCPP_FILE yaml-cpp-${YAMLCPP_VERSION}.tar.gz)
set(YAMLCPP "cpe:2.3:a:yaml-cpp_project:yaml-cpp:${YAMLCPP_VERSION}:*:*:*:*:*:*:*")
set(PYSTRING_VERSION v1.1.3)
set(PYSTRING_URI https://codeload.github.com/imageworks/pystring/tar.gz/refs/tags/${PYSTRING_VERSION})
@@ -344,16 +380,19 @@ set(PYSTRING_HASH_TYPE MD5)
set(PYSTRING_FILE pystring-${PYSTRING_VERSION}.tar.gz)
set(EXPAT_VERSION 2_4_4)
set(EXPAT_VERSION_DOTS 2.4.4)
set(EXPAT_URI https://github.com/libexpat/libexpat/archive/R_${EXPAT_VERSION}.tar.gz)
set(EXPAT_HASH 2d3e81dee94b452369dc6394ff0f8f98)
set(EXPAT_HASH_TYPE MD5)
set(EXPAT_FILE libexpat-${EXPAT_VERSION}.tar.gz)
set(EXPAT_CPE "cpe:2.3:a:libexpat_project:libexpat:${EXPAT_VERSION_DOTS}:*:*:*:*:*:*:*")
set(PUGIXML_VERSION 1.10)
set(PUGIXML_URI https://github.com/zeux/pugixml/archive/v${PUGIXML_VERSION}.tar.gz)
set(PUGIXML_HASH 0c208b0664c7fb822bf1b49ad035e8fd)
set(PUGIXML_HASH_TYPE MD5)
set(PUGIXML_FILE pugixml-${PUGIXML_VERSION}.tar.gz)
set(PUGIXML_CPE "cpe:2.3:a:pugixml_project:pugixml:${PUGIXML_VERSION}:*:*:*:*:*:*:*")
set(FLEXBISON_VERSION 2.5.24)
set(FLEXBISON_URI http://prdownloads.sourceforge.net/winflexbison/win_flex_bison-${FLEXBISON_VERSION}.zip)
@@ -376,12 +415,14 @@ set(BZIP2_URI http://http.debian.net/debian/pool/main/b/bzip2/bzip2_${BZIP2_VERS
set(BZIP2_HASH ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269)
set(BZIP2_HASH_TYPE SHA256)
set(BZIP2_FILE bzip2_${BZIP2_VERSION}.orig.tar.gz)
set(BZIP2_CPE "cpe:2.3:a:bzip:bzip2:${BZIP2_VERSION}:*:*:*:*:*:*:*")
set(FFI_VERSION 3.3)
set(FFI_URI https://sourceware.org/pub/libffi/libffi-${FFI_VERSION}.tar.gz)
set(FFI_HASH 72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056)
set(FFI_HASH_TYPE SHA256)
set(FFI_FILE libffi-${FFI_VERSION}.tar.gz)
set(FFI_CPE "cpe:2.3:a:libffi_project:libffi:${FFI_VERSION}:*:*:*:*:*:*:*")
set(LZMA_VERSION 5.2.5)
set(LZMA_URI https://tukaani.org/xz/xz-${LZMA_VERSION}.tar.bz2)
@@ -403,12 +444,14 @@ else()
set(SSL_HASH_TYPE SHA256)
set(SSL_FILE openssl-${SSL_VERSION}.tar.gz)
endif()
set(SSL_CPE "cpe:2.3:a:openssl:openssl:${SSL_VERSION}:*:*:*:*:*:*:*")
set(SQLITE_VERSION 3.31.1)
set(SQLITE_URI https://www.sqlite.org/2018/sqlite-src-3240000.zip)
set(SQLITE_HASH fb558c49ee21a837713c4f1e7e413309aabdd9c7)
set(SQLITE_HASH_TYPE SHA1)
set(SQLITE_FILE sqlite-src-3240000.zip)
set(SQLITE_CPE "cpe:2.3:a:sqlite:sqlite:${SQLITE_VERSION}:*:*:*:*:*:*:*")
set(EMBREE_VERSION 3.13.4)
set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip)
@@ -439,12 +482,14 @@ set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa/mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH 022c7293074aeeced2278c872db4fa693147c70f8595b076cf3f1ef81520766d)
set(MESA_HASH_TYPE SHA256)
set(MESA_FILE mesa-${MESA_VERSION}.tar.xz)
set(MESA_CPE "cpe:2.3:a:mesa3d:mesa:${MESA_VERSION}:*:*:*:*:*:*:*")
set(NASM_VERSION 2.15.02)
set(NASM_URI https://github.com/netwide-assembler/nasm/archive/nasm-${NASM_VERSION}.tar.gz)
set(NASM_HASH aded8b796c996a486a56e0515c83e414116decc3b184d88043480b32eb0a8589)
set(NASM_HASH_TYPE SHA256)
set(NASM_FILE nasm-${NASM_VERSION}.tar.gz)
set(NASM_PCE "cpe:2.3:a:nasm:nasm:${NASM_VERSION}:*:*:*:*:*:*:*")
set(XR_OPENXR_SDK_VERSION 1.0.22)
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
@@ -458,6 +503,18 @@ set(WL_PROTOCOLS_URI https://gitlab.freedesktop.org/wayland/wayland-protocols/-/
set(WL_PROTOCOLS_HASH af5ca07e13517cdbab33504492cef54a)
set(WL_PROTOCOLS_HASH_TYPE MD5)
set(WAYLAND_VERSION 1.21.0)
set(WAYLAND_FILE wayland-${WAYLAND_VERSION}.tar.xz)
set(WAYLAND_URI https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.21.0/downloads/wayland-${WAYLAND_VERSION}.tar.xz)
set(WAYLAND_HASH f2653a2293bcd882d756c6a83d278903)
set(WAYLAND_HASH_TYPE MD5)
set(WAYLAND_LIBDECOR_VERSION 0.1.0)
set(WAYLAND_LIBDECOR_FILE libdecor-${WAYLAND_LIBDECOR_VERSION}.tar.xz)
set(WAYLAND_LIBDECOR_URI https://gitlab.gnome.org/jadahl/libdecor/uploads/81adf91d27620e20bcc5f6b9b312d768/libdecor-${WAYLAND_LIBDECOR_VERSION}.tar.xz )
set(WAYLAND_LIBDECOR_HASH 47b59eba76faa3787f0878bf8700e912)
set(WAYLAND_LIBDECOR_HASH_TYPE MD5)
set(ISPC_VERSION v1.17.0)
set(ISPC_URI https://github.com/ispc/ispc/archive/${ISPC_VERSION}.tar.gz)
set(ISPC_HASH 4f476a3109332a77fe839a9014c60ca9)
@@ -469,12 +526,14 @@ set(GMP_URI https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz)
set(GMP_HASH 0b82665c4a92fd2ade7440c13fcaa42b)
set(GMP_HASH_TYPE MD5)
set(GMP_FILE gmp-${GMP_VERSION}.tar.xz)
set(GMP_CPE "cpe:2.3:a:gmplib:gmp:${GMP_VERSION}:*:*:*:*:*:*:*")
set(POTRACE_VERSION 1.16)
set(POTRACE_URI http://potrace.sourceforge.net/download/${POTRACE_VERSION}/potrace-${POTRACE_VERSION}.tar.gz)
set(POTRACE_HASH 5f0bd87ddd9a620b0c4e65652ef93d69)
set(POTRACE_HASH_TYPE MD5)
set(POTRACE_FILE potrace-${POTRACE_VERSION}.tar.gz)
set(POTRACE_CPE "cpe:2.3:a:icoasoft:potrace:${POTRACE_VERSION}:*:*:*:*:*:*:*")
set(HARU_VERSION 2_3_0)
set(HARU_URI https://github.com/libharu/libharu/archive/RELEASE_${HARU_VERSION}.tar.gz)
@@ -487,15 +546,27 @@ set(ZSTD_URI https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}
set(ZSTD_HASH 5194fbfa781fcf45b98c5e849651aa7b3b0a008c6b72d4a0db760f3002291e94)
set(ZSTD_HASH_TYPE SHA256)
set(ZSTD_FILE zstd-${ZSTD_VERSION}.tar.gz)
set(ZSTD_CPE "cpe:2.3:a:facebook:zstandard:${ZSTD_VERSION}:*:*:*:*:*:*:*")
set(SSE2NEON_GIT https://github.com/DLTcollab/sse2neon.git)
set(SSE2NEON_GIT_HASH fe5ff00bb8d19b327714a3c290f3e2ce81ba3525)
set(SSE2NEON_VERSION fe5ff00bb8d19b327714a3c290f3e2ce81ba3525)
set(SSE2NEON_URI https://github.com/DLTcollab/sse2neon/archive/${SSE2NEON_VERSION}.tar.gz)
set(SSE2NEON_HASH 0780253525d299c31775ef95853698d03db9c7739942af8570000f4a25a5d605)
set(SSE2NEON_HASH_TYPE SHA256)
set(SSE2NEON_FILE sse2neon-${SSE2NEON_VERSION}.tar.gz)
set(BROTLI_VERSION v1.0.9)
set(BROTLI_URI https://github.com/google/brotli/archive/refs/tags/${BROTLI_VERSION}.tar.gz)
set(BROTLI_VERSION 1.0.9)
set(BROTLI_URI https://github.com/google/brotli/archive/refs/tags/v${BROTLI_VERSION}.tar.gz)
set(BROTLI_HASH f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46)
set(BROTLI_HASH_TYPE SHA256)
set(BROTLI_FILE brotli-${BROTLI_VERSION}.tar.gz)
set(BROTLI_FILE brotli-v${BROTLI_VERSION}.tar.gz)
set(BROTLI_CPE "cpe:2.3:a:google:brotli:${BROTLI_VERSION}:*:*:*:*:*:*:*")
set(OPENPGL_VERSION v0.3.1-beta)
set(OPENPGL_SHORT_VERSION 0.3.1)
set(OPENPGL_URI https://github.com/OpenPathGuidingLibrary/openpgl/archive/refs/tags/${OPENPGL_VERSION}.tar.gz)
set(OPENPGL_HASH 3830098c485c962018932766199527aab453a8029528dbbc04d4454d82431e2c)
set(OPENPGL_HASH_TYPE SHA256)
set(OPENPGL_FILE openpgl-${OPENPGL_VERSION}.tar.gz)
set(LEVEL_ZERO_VERSION v1.7.15)
set(LEVEL_ZERO_URI https://github.com/oneapi-src/level-zero/archive/refs/tags/${LEVEL_ZERO_VERSION}.tar.gz)
@@ -503,9 +574,9 @@ set(LEVEL_ZERO_HASH c39bb05a8e5898aa6c444e1704105b93d3f1888b9c333f8e7e73825ffbfb
set(LEVEL_ZERO_HASH_TYPE SHA256)
set(LEVEL_ZERO_FILE level-zero-${LEVEL_ZERO_VERSION}.tar.gz)
set(DPCPP_VERSION 20220620)
set(DPCPP_VERSION 20220812)
set(DPCPP_URI https://github.com/intel/llvm/archive/refs/tags/sycl-nightly/${DPCPP_VERSION}.tar.gz)
set(DPCPP_HASH a5f41abd5229d28afa92cbd8a5d8d786ee698bf239f722929fd686276bad692c)
set(DPCPP_HASH 0e3c95346c295f5cf80f3a42d80b1c49481955898530242636ddc002627248d6)
set(DPCPP_HASH_TYPE SHA256)
set(DPCPP_FILE DPCPP-${DPCPP_VERSION}.tar.gz)

View File

@@ -0,0 +1,23 @@
# SPDX-License-Identifier: GPL-2.0-or-later
ExternalProject_Add(external_wayland
URL file://${PACKAGE_DIR}/${WAYLAND_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${WAYLAND_HASH_TYPE}=${WAYLAND_HASH}
PREFIX ${BUILD_DIR}/wayland
PATCH_COMMAND ${PATCH_CMD} -d ${BUILD_DIR}/wayland/src/external_wayland < ${PATCH_DIR}/wayland.diff
# Use `-E` so the `PKG_CONFIG_PATH` can be defined to link against our own LIBEXPAT & LIBXML2.
# Note that passing link args "ffi/lib" should not be needed, but
# `pkgconfig` would incorrectly look in "ffi/lib/../lib64" otherwise.
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${LIBDIR}/expat/lib/pkgconfig:${LIBDIR}/xml2/lib/pkgconfig:${LIBDIR}/ffi/lib/pkgconfig:$PKG_CONFIG_PATH
meson --prefix ${LIBDIR}/wayland -Ddocumentation=false -Dtests=false -Dc_link_args=-L${LIBDIR}/ffi/lib . ../external_wayland
BUILD_COMMAND ninja
INSTALL_COMMAND ninja install
)
add_dependencies(
external_wayland
external_expat
external_xml2
external_ffi
)

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# NOTE: currently only the header file is extracted, no compilation is needed
# as the library is dynamically loaded when found on the system.
ExternalProject_Add(external_wayland_libdecor
URL file://${PACKAGE_DIR}/${WAYLAND_LIBDECOR_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${WAYLAND_LIBDECOR_HASH_TYPE}=${WAYLAND_LIBDECOR_HASH}
PREFIX ${BUILD_DIR}/wayland_libdecor
BUILD_COMMAND echo .
CONFIGURE_COMMAND echo .
INSTALL_COMMAND cp ../external_wayland_libdecor/src/libdecor.h ${LIBDIR}/wayland_libdecor/include/libdecor-0/libdecor.h
INSTALL_DIR ${LIBDIR}/wayland_libdecor/include/libdecor-0
)

View File

@@ -40,15 +40,15 @@ ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,ver-xr-openxr:,ver-
force-all,force-python,force-boost,force-tbb,\
force-ocio,force-imath,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
force-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-usd,\
force-xr-openxr,force-level-zero,\
force-xr-openxr,force-level-zero, force-openpgl,\
build-all,build-python,build-boost,build-tbb,\
build-ocio,build-imath,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
build-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-usd,\
build-xr-openxr,build-level-zero,\
build-xr-openxr,build-level-zero, build-openpgl,\
skip-python,skip-boost,skip-tbb,\
skip-ocio,skip-imath,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd,\
skip-xr-openxr,skip-level-zero \
skip-xr-openxr,skip-level-zero, skip-openpgl \
-- "$@" \
)
@@ -232,6 +232,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--build-level-zero=<ver>
Force the build of OneAPI Level Zero library.
--build-openpgl
Force the build of OpenPGL library.
Note about the --build-foo options:
* They force the script to prefer building dependencies rather than using available packages.
This may make things simpler and allow working around some distribution bugs, but on the other hand it will
@@ -302,6 +305,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-level-zero=<ver>
Force the rebuild of OneAPI Level Zero library.
--force-openpgl
Force the rebuild of OpenPGL library.
Note about the --force-foo options:
* They obviously only have an effect if those libraries are built by this script
(i.e. if there is no available and satisfactory package)!
@@ -363,7 +369,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
Unconditionally skip OpenXR-SDK installation/building.
--skip-level-zero=<ver>
Unconditionally skip OneAPI Level Zero installation/building.\""
Unconditionally skip OneAPI Level Zero installation/building.
--skip-openpgl
Unconditionally skip OpenPGL installation/building.\""
# ----------------------------------------------------------------------------
# Main Vars
@@ -593,6 +602,14 @@ LEVEL_ZERO_FORCE_BUILD=false
LEVEL_ZERO_FORCE_REBUILD=false
LEVEL_ZERO_SKIP=false
OPENPGL_VERSION="0.3.1"
OPENPGL_VERSION_SHORT="0.3"
OPENPGL_VERSION_MIN="0.3.1"
OPENPGL_VERSION_MEX="0.3.2"
OPENPGL_FORCE_BUILD=false
OPENPGL_FORCE_REBUILD=false
OPENPGL_SKIP=false
XR_OPENXR_VERSION="1.0.22"
XR_OPENXR_VERSION_SHORT="1.0"
XR_OPENXR_VERSION_MIN="1.0.8"
@@ -827,6 +844,7 @@ while true; do
USD_FORCE_BUILD=true
XR_OPENXR_FORCE_BUILD=true
LEVEL_ZERO_FORCE_BUILD=true
OPENPGL_FORCE_BUILD=true
shift; continue
;;
--build-python)
@@ -887,6 +905,9 @@ while true; do
--build-level-zero)
LEVEL_ZERO_FORCE_BUILD=true; shift; continue
;;
--build-openpgl)
OPENPGL_FORCE_BUILD=true; shift; continue
;;
--force-all)
PYTHON_FORCE_REBUILD=true
BOOST_FORCE_REBUILD=true
@@ -907,6 +928,7 @@ while true; do
USD_FORCE_REBUILD=true
XR_OPENXR_FORCE_REBUILD=true
LEVEL_ZERO_FORCE_REBUILD=true
OPENPGL_FORCE_REBUILD=true
shift; continue
;;
--force-python)
@@ -967,6 +989,9 @@ while true; do
--force-level-zero)
LEVEL_ZERO_FORCE_REBUILD=true; shift; continue
;;
--force-openpgl)
OPENPGL_FORCE_REBUILD=true; shift; continue
;;
--skip-python)
PYTHON_SKIP=true; shift; continue
;;
@@ -1024,6 +1049,9 @@ while true; do
--skip-level-zero)
LEVEL_ZERO_SKIP=true; shift; continue
;;
--skip-openpgl)
OPENPGL_SKIP=true; shift; continue
;;
--)
# no more arguments to parse
break
@@ -1173,6 +1201,9 @@ XR_OPENXR_REPO_BRANCH="master"
LEVEL_ZERO_SOURCE=("https://github.com/oneapi-src/level-zero/archive/refs/tags/v${LEVEL_ZERO_VERSION}.tar.gz")
OPENPGL_USE_REPO=false
OPENPGL_SOURCE=( "https://github.com/OpenPathGuidingLibrary/openpgl/archive/refs/tags/v${OPENPGL_VERSION}-beta.tar.gz" )
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
# C++11 is required now
@@ -1227,7 +1258,8 @@ You may also want to build them yourself (optional ones are [between brackets]):
* [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).
* [Universal Scene Description $USD_VERSION] (from $USD_SOURCE).
* [OpenXR-SDK $XR_OPENXR_VERSION] (from $XR_OPENXR_SOURCE).
* [OneAPI Level Zero $LEVEL_ZERO_VERSION] (from $LEVEL_ZERO_SOURCE).\""
* [OneAPI Level Zero $LEVEL_ZERO_VERSION] (from $LEVEL_ZERO_SOURCE).
* [OpenPGL $OPENPGL_VERSION] (from $OPENPGL_SOURCE).\""
if [ "$DO_SHOW_DEPS" = true ]; then
PRINT ""
@@ -1661,6 +1693,7 @@ _update_deps_tbb() {
USD_FORCE_BUILD=true
EMBREE_FORCE_BUILD=true
OIDN_FORCE_BUILD=true
OPENPGL_FORCE_BUILD=true
fi
if [ "$2" = true ]; then
OSD_FORCE_REBUILD=true
@@ -1668,6 +1701,7 @@ _update_deps_tbb() {
USD_FORCE_REBUILD=true
EMBREE_FORCE_REBUILD=true
OIDN_FORCE_REBUILD=true
OPENPGL_FORCE_REBUILD=true
fi
}
@@ -3306,7 +3340,12 @@ _init_embree() {
}
_update_deps_embree() {
:
if [ "$1" = true ]; then
OPENPGL_FORCE_BUILD=true
fi
if [ "$2" = true ]; then
OPENPGL_FORCE_REBUILD=true
fi
}
clean_Embree() {
@@ -3325,7 +3364,7 @@ compile_Embree() {
fi
# To be changed each time we make edits that would modify the compiled results!
embree_magic=11
embree_magic=12
_init_embree
# Force having own builds for the dependencies.
@@ -3962,6 +4001,112 @@ compile_Level_Zero() {
}
# ----------------------------------------------------------------------------
# Build OpenPGL
_init_openpgl() {
_src=$SRC/openpgl-$OPENPGL_VERSION
_git=false
_inst=$INST/openpgl-$OPENPGL_VERSION_SHORT
_inst_shortcut=$INST/openpgl
}
_update_deps_openpgl() {
:
}
clean_OpenPGL() {
_init_openpgl
if [ -d $_inst ]; then
# Force rebuilding the dependencies if needed.
_update_deps_openpgl false true
fi
_clean
}
compile_OpenPGL() {
if [ "$NO_BUILD" = true ]; then
WARNING "--no-build enabled, OpenPGL will not be compiled!"
return
fi
# To be changed each time we make edits that would modify the compiled results!
openpgl_magic=1
_init_openpgl
# Force having own builds for the dependencies.
_update_deps_openpgl true false
# Clean install if needed!
magic_compile_check openpgl-$OPENPGL_VERSION $openpgl_magic
if [ $? -eq 1 -o "$OPENPGL_FORCE_REBUILD" = true ]; then
clean_OpenPGL
fi
if [ ! -d $_inst ]; then
INFO "Building OpenPGL-$OPENPGL_VERSION"
# Force rebuilding the dependencies.
_update_deps_openpgl true true
prepare_inst
if [ ! -d $_src ]; then
mkdir -p $SRC
download OPENPGL_SOURCE[@] "$_src.tar.gz"
INFO "Unpacking OpenPGL-$OPENPGL_VERSION"
tar -C $SRC --transform "s,(.*/?)openpgl-$OPENPGL_VERSION-beta[^/]*(.*),\1openpgl-$OPENPGL_VERSION\2,x" \
-xf $_src.tar.gz
fi
cd $_src
INFO "$_src"
# Always refresh the whole build!
if [ -d build ]; then
rm -rf build
fi
mkdir build
cd build
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D OPENPGL_BUILD_STATIC=OFF"
cmake_d="$cmake_d -D OPENPGL_BUILD_PYTHON=OFF"
cmake_d="$cmake_d -D EMBREE_ISPC_SUPPORT=OFF"
if [ -d $INST/tbb ]; then
cmake_d="$cmake_d -D OPENPGL_TBB_ROOT=$INST/tbb"
cmake_d="$cmake_d -D TBB_ROOT=$INST/tbb"
fi
cmake $cmake_d ../
make -j$THREADS && make install
make clean
if [ ! -d $_inst ]; then
ERROR "OpenPGL-$OPENPGL_VERSION failed to compile, exiting"
exit 1
fi
magic_compile_set openpgl-$OPENPGL_VERSION $openpgl_magic
cd $CWD
INFO "Done compiling OpenPGL-$OPENPGL_VERSION!"
else
INFO "Own OpenPGL-$OPENPGL_VERSION is up to date, nothing to do!"
INFO "If you want to force rebuild of this lib, use the --force-openpgl option."
fi
if [ -d $_inst ]; then
_create_inst_shortcut
fi
run_ldconfig "openpgl"
}
# ----------------------------------------------------------------------------
# Install on DEB-like
@@ -4064,7 +4209,8 @@ install_DEB() {
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev \
libopenal-dev libepoxy-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"
libgmp-dev libpugixml-dev libpotrace-dev libhpdf-dev libzstd-dev libpystring-dev \
libglfw3-dev"
VORBIS_USE=true
OGG_USE=true
@@ -4594,6 +4740,18 @@ install_DEB() {
PRINT ""
compile_Level_Zero
fi
PRINT ""
if [ "$OPENPGL_SKIP" = true ]; then
WARNING "Skipping OpenPGL installation, as requested..."
elif [ "$OPENPGL_FORCE_BUILD" = true ]; then
INFO "Forced OpenPGL building, as requested..."
compile_OpenPGL
else
# No package currently!
PRINT ""
compile_OpenPGL
fi
}
@@ -5301,6 +5459,18 @@ install_RPM() {
PRINT ""
compile_Level_Zero
fi
PRINT ""
if [ "$OPENPGL_SKIP" = true ]; then
WARNING "Skipping OpenPGL installation, as requested..."
elif [ "$OPENPGL_FORCE_BUILD" = true ]; then
INFO "Forced OpenPGL building, as requested..."
compile_OpenPGL
else
# No package currently!
PRINT ""
compile_OpenPGL
fi
}
@@ -5897,6 +6067,18 @@ install_ARCH() {
PRINT ""
compile_Level_Zero
fi
PRINT ""
if [ "$OPENPGL_SKIP" = true ]; then
WARNING "Skipping OpenPGL installation, as requested..."
elif [ "$OPENPGL_FORCE_BUILD" = true ]; then
INFO "Forced OpenPGL building, as requested..."
compile_OpenPGL
else
# No package currently!
PRINT ""
compile_OpenPGL
fi
}
@@ -6079,6 +6261,14 @@ install_OTHER() {
INFO "Forced Level Zero building, as requested..."
compile_Level_Zero
fi
PRINT ""
if [ "$OPENPGL_SKIP" = true ]; then
WARNING "Skipping OpenPGL installation, as requested..."
elif [ "$OPENPGL_FORCE_BUILD" = true ]; then
INFO "Forced OpenPGL building, as requested..."
compile_OpenPGL
fi
}
# ----------------------------------------------------------------------------
@@ -6096,7 +6286,7 @@ print_info() {
_buildargs="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB*"
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CLANG* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *BLOSC* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD*"
_buildargs="$_buildargs -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR*"
_buildargs="$_buildargs -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR* -U *OPENPGL*"
_1="-D WITH_CODEC_SNDFILE=ON"
PRINT " $_1"
@@ -6327,6 +6517,16 @@ print_info() {
#~ fi
#~ fi
if [ "$OPENPGL_SKIP" = false ]; then
if [ -d $INST/openpgl ]; then
_1="-D openpgl_DIR=$INST/openpgl/lib/cmake/openpgl-$OPENPGL_VERSION"
_2="-D WITH_CYCLES_PATH_GUIDING=ON"
PRINT " $_1"
PRINT " $_2"
_buildargs="$_buildargs $_1 $_2"
fi
fi
PRINT ""
PRINT "Or even simpler, just run (in your blender-source dir):"
PRINT " make -j$THREADS BUILD_CMAKE_ARGS=\"$_buildargs\""

View File

@@ -0,0 +1,101 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
# This script is part of the official build environment, see WIKI page for details.
# https://wiki.blender.org/wiki/Building_Blender/Other/CentOS7ReleaseEnvironment
set -e
if [ `id -u` -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
# yum-config-manager does not come in the default minimal install,
# so make sure it is installed and available.
yum -y update
yum -y install yum-utils
# Install all the packages needed for a new toolchain.
#
# NOTE: Keep this separate from the packages install, since otherwise
# older toolchain will be installed.
yum -y update
yum -y install epel-release
yum -y install centos-release-scl
yum -y install devtoolset-9
# Install packages needed for Blender's dependencies.
PACKAGES=(
git
subversion
bzip2
tar
cmake3
patch
make
autoconf
automake
libtool
meson
ninja-build
libXrandr-devel
libXinerama-devel
libXcursor-devel
libXi-devel
libX11-devel libXt-devel
mesa-libEGL-devel
mesa-libGL-devel
mesa-libGLU-devel
zlib-devel
rubygem-asciidoctor
wget
tcl
yasm
python36
python-setuptools
bison
flex
ncurses-devel
wayland-devel
libwayland-client
libwayland-server
)
yum -y install -y ${PACKAGES[@]}
# Dependencies for Mesa
yum -y install expat-devel
python3 -m pip install mako
# Dependencies for pip (needed for buildbot-worker).
yum -y install python36-pip python36-devel
# Dependencies for asound.
yum -y install -y \
alsa-lib-devel pulseaudio-libs-devel
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \
--family cmake
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake

View File

@@ -1,21 +1,3 @@
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

View File

@@ -14,3 +14,15 @@ index 7b894a45..92618215 100644
)
if(CMAKE_TOOLCHAIN_FILE)
set(pystring_CMAKE_ARGS
--- a/src/OpenColorIO/FileRules.cpp
+++ b/src/OpenColorIO/FileRules.cpp
@@ -7,6 +7,9 @@
#include <regex>
#include <sstream>
+/* NOTE: this has been applied up-stream, this edit can be removed after upgrading OpenColorIO. */
+#include <cstring>
+
#include <OpenColorIO/OpenColorIO.h>
#include "CustomKeys.h"

View File

@@ -0,0 +1,11 @@
--- meson.build.orig 2022-06-30 22:59:11.000000000 +0100
+++ meson.build 2022-09-27 13:21:26.428517668 +0100
@@ -2,7 +2,7 @@
'wayland', 'c',
version: '1.21.0',
license: 'MIT',
- meson_version: '>= 0.56.0',
+ meson_version: '>= 0.55.1',
default_options: [
'warning_level=2',
'buildtype=debugoptimized',

View File

@@ -34,11 +34,17 @@ SET(PYTHON_VERSION 3.10 CACHE STRING "Python Version (major and minor only)")
MARK_AS_ADVANCED(PYTHON_VERSION)
# See: http://docs.python.org/extending/embedding.html#linking-requirements
# for why this is needed
SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic" CACHE STRING "Linker flags for python")
MARK_AS_ADVANCED(PYTHON_LINKFLAGS)
if(APPLE)
if(WITH_PYTHON_MODULE)
set(PYTHON_LINKFLAGS "-undefined dynamic_lookup")
else()
set(PYTHON_LINKFLAGS)
endif()
else()
# See: http://docs.python.org/extending/embedding.html#linking-requirements
SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic" CACHE STRING "Linker flags for python")
MARK_AS_ADVANCED(PYTHON_LINKFLAGS)
endif()
# if the user passes these defines as args, we don't want to overwrite
SET(_IS_INC_DEF OFF)

View File

@@ -44,7 +44,7 @@ FIND_PROGRAM(SYCL_COMPILER
# compiler.
if(NOT SYCL_COMPILER)
FIND_PROGRAM(SYCL_COMPILER
NAMES
NAMES
dpcpp
HINTS
${_sycl_search_dirs}
@@ -62,6 +62,13 @@ FIND_LIBRARY(SYCL_LIBRARY
lib64 lib
)
if(WIN32)
string(REPLACE ".lib" "d.lib" SYCL_LIBRARY_DEBUG ${SYCL_LIBRARY})
set(SYCL_LIBRARY_DEBUG ${SYCL_LIBRARY_DEBUG} CACHE FILEPATH "Path to SYCL debug library")
else()
set(SYCL_LIBRARY_DEBUG ${SYCL_LIBRARY} CACHE FILEPATH "Path to SYCL debug library")
endif()
FIND_PATH(SYCL_INCLUDE_DIR
NAMES
CL/sycl.hpp
@@ -85,4 +92,5 @@ ENDIF()
MARK_AS_ADVANCED(
_SYCL_INCLUDE_PARENT_DIR
SYCL_LIBRARY_DEBUG
)

View File

@@ -268,7 +268,8 @@ same as the Google Test name (i.e. ``suite.testcase``); see also
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
#------------------------------------------------------------------------------
# -----------------------------------------------------------------------------
function(gtest_add_tests)
if(ARGC LESS 1)

View File

@@ -40,12 +40,10 @@ macro(BLENDER_SRC_GTEST_EX)
set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest")
endif()
add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
add_definitions(${GFLAGS_DEFINES})
add_definitions(${GLOG_DEFINES})
add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST})
setup_platform_linker_flags(${TARGET_NAME})
target_compile_definitions(${TARGET_NAME} PRIVATE ${GFLAGS_DEFINES})
target_compile_definitions(${TARGET_NAME} PRIVATE ${GLOG_DEFINES})
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
target_link_libraries(${TARGET_NAME} ${ARG_EXTRA_LIBS} ${PLATFORM_LINKLIBS})

View File

@@ -150,10 +150,10 @@ endif()
# BUILD_PLATFORM is taken from CMake
# but BUILD_DATE and BUILD_TIME are platform dependent
if(NOT BUILD_DATE)
STRING(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
string(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
endif()
if(NOT BUILD_TIME)
STRING(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC)
string(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC)
endif()
# Write a file with the BUILD_HASH define

View File

@@ -10,40 +10,77 @@ import tempfile
from typing import (
Any,
List,
Tuple,
)
USE_VERBOSE = (os.environ.get("VERBOSE", None) is not None)
# Could make configurable.
USE_VERBOSE_PROGRESS = True
USE_QUIET = (os.environ.get("QUIET", None) is not None)
CHECKER_BIN = "cppcheck"
CHECKER_IGNORE_PREFIX = [
"extern",
]
CHECKER_BIN = "cppcheck"
CHECKER_EXCLUDE_SOURCE_FILES = set(os.path.join(*f.split("/")) for f in (
# These files hang (taking longer than 5min with v2.8.2 at time of writing).
# All other files process in under around 10seconds.
"source/blender/editors/space_text/text_format_pov.c",
"source/blender/editors/space_text/text_format_pov_ini.c",
))
CHECKER_ARGS = [
# not sure why this is needed, but it is.
"-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
"--suppress=*:%s/extern/glew/include/GL/glew.h:241" % project_source_info.SOURCE_DIR,
"--max-configs=1", # speeds up execution
# "--check-config", # when includes are missing
"--enable=all", # if you want sixty hundred pedantic suggestions
# Speed up execution.
# As Blender has many defines, the total number of configurations is large making execution unreasonably slow.
# This could be increased but do so with care.
"--max-configs=1",
# Enable this when includes are missing.
# "--check-config",
# Shows many pedantic issues, some are quite useful.
"--enable=all",
# Also shows useful messages, even if some are false-positives.
"--inconclusive",
# Quiet output, otherwise all defines/includes are printed (overly verbose).
# Only enable this for troubleshooting (if defines are not set as expected for example).
"--quiet",
*(() if USE_VERBOSE else ("--quiet",))
# NOTE: `--cppcheck-build-dir=<dir>` is added later as a temporary directory.
]
if USE_QUIET:
CHECKER_ARGS.append("--quiet")
def source_info_filter(
source_info: List[Tuple[str, List[str], List[str]]],
) -> List[Tuple[str, List[str], List[str]]]:
source_dir = project_source_info.SOURCE_DIR
if not source_dir.endswith(os.sep):
source_dir += os.sep
source_info_result = []
for i, item in enumerate(source_info):
c = item[0]
if c.startswith(source_dir):
c_relative = c[len(source_dir):]
if c_relative in CHECKER_EXCLUDE_SOURCE_FILES:
CHECKER_EXCLUDE_SOURCE_FILES.remove(c_relative)
continue
source_info_result.append(item)
if CHECKER_EXCLUDE_SOURCE_FILES:
sys.stderr.write("Error: exclude file(s) are missing: %r\n" % list(sorted(CHECKER_EXCLUDE_SOURCE_FILES)))
sys.exit(1)
return source_info_result
def cppcheck() -> None:
source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
source_defines = project_source_info.build_defines_as_args()
# Apply exclusion.
source_info = source_info_filter(source_info)
check_commands = []
for c, inc_dirs, defs in source_info:
cmd = (
@@ -60,7 +97,7 @@ def cppcheck() -> None:
process_functions = []
def my_process(i: int, c: str, cmd: List[str]) -> subprocess.Popen[Any]:
if not USE_QUIET:
if USE_VERBOSE_PROGRESS:
percent = 100.0 * (i / len(check_commands))
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"

View File

@@ -17,6 +17,7 @@ set(WITH_COMPOSITOR_CPU ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)

View File

@@ -7,8 +7,6 @@
# cmake -C../blender/build_files/cmake/config/blender_lite.cmake ../blender
#
set(WITH_INSTALL_PORTABLE ON CACHE BOOL "" FORCE)
set(WITH_ALEMBIC OFF CACHE BOOL "" FORCE)
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_BLENDER_THUMBNAILER OFF CACHE BOOL "" FORCE)
@@ -35,6 +33,7 @@ set(WITH_IMAGE_OPENEXR OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENJPEG OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_TIFF OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_WEBP OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_IME OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)
set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)
set(WITH_IO_STL OFF CACHE BOOL "" FORCE)

View File

@@ -18,6 +18,7 @@ set(WITH_COMPOSITOR_CPU ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
@@ -71,8 +72,6 @@ if(NOT WIN32)
endif()
if(WIN32)
set(WITH_WASAPI ON CACHE BOOL "" FORCE)
# Disabled until the buildbot environment is configured.
set(WITH_CYCLES_ONEAPI_BINARIES OFF CACHE BOOL "" FORCE)
endif()
if(UNIX AND NOT APPLE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
@@ -80,7 +79,6 @@ if(UNIX AND NOT APPLE)
set(WITH_PULSEAUDIO ON CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_ONEAPI_BINARIES OM CACHE BOOL "" FORCE)
endif()
if(NOT APPLE)
set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
@@ -90,4 +88,5 @@ if(NOT APPLE)
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)
set(WITH_CYCLES_ONEAPI_BINARIES ON CACHE BOOL "" FORCE)
endif()

View File

@@ -8,41 +8,81 @@
set(WITH_PYTHON_MODULE ON CACHE BOOL "" FORCE)
# install into the systems python dir
set(WITH_INSTALL_PORTABLE OFF CACHE BOOL "" FORCE)
# no point int copying python into python
# -----------------------------------------------------------------------------
# Installation Configuration.
#
# NOTE: `WITH_INSTALL_PORTABLE` always defaults to ON when building as a Python module and
# isn't set here as it makes changing the setting impractical.
# Python-developers could prefer either ON/OFF depending on their usage:
#
# - When using the system's Python, disabling will install into their `site-packages`,
# allowing them to run Python from any directory and `import bpy`.
# - When using Blender's bundled Python in `./../lib/` it will install there
# which isn't especially useful as it requires running Python from this directory too.
#
# So default `WITH_INSTALL_PORTABLE` to ON, and developers who don't use Python from `./../lib/`
# can disable it if they wish to install into their systems Python.
# There is no point in copying python into Python.
set(WITH_PYTHON_INSTALL OFF CACHE BOOL "" FORCE)
# disable audio, its possible some devs may want this but for now disable
# so the python module doesn't hold the audio device and loads quickly.
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
set(WITH_WASAPI OFF CACHE BOOL "" FORCE)
# other features which are not especially useful as a python module
set(WITH_ALEMBIC OFF CACHE BOOL "" FORCE)
set(WITH_BULLET OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)
set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)
set(WITH_NANOVDB OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
set(WITH_OPENVDB OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
# Depends on Python install, do this to quiet warning.
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
# Jemalloc does not work with dlopen() of Python modules:
# https://github.com/jemalloc/jemalloc/issues/1237
set(WITH_MEM_JEMALLOC OFF CACHE BOOL "" FORCE)
if(WIN32)
set(WITH_WINDOWS_BUNDLE_CRT OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Library Compatibility.
# JEMALLOC does not work with `dlopen()` of Python modules:
# https://github.com/jemalloc/jemalloc/issues/1237
set(WITH_MEM_JEMALLOC OFF CACHE BOOL "" FORCE)
# -----------------------------------------------------------------------------
# Application Support.
# Not useful to include with the Python module.
# Although a way to extract this from Python could be handle,
# this would be better exposed directly via the Python API.
set(WITH_BLENDER_THUMBNAILER OFF CACHE BOOL "" FORCE)
# -----------------------------------------------------------------------------
# Audio Support.
# Disable audio, its possible some developers may want this but for now disable
# so the Python module doesn't hold the audio device and loads quickly.
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_SDL OFF CACHE BOOL "" FORCE)
if(UNIX AND NOT APPLE)
set(WITH_PULSEAUDIO OFF CACHE BOOL "" FORCE)
endif()
if(WIN32)
set(WITH_WASAPI OFF CACHE BOOL "" FORCE)
endif()
if(APPLE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Input Device Support.
# Other features which are not especially useful as a python module.
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)
if(WIN32 OR APPLE)
set(WITH_INPUT_IME OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Language Support.
set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)

View File

@@ -134,12 +134,11 @@ endfunction()
# Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
# use it instead of include_directories()
function(blender_include_dirs
includes
)
function(absolute_include_dirs
includes_absolute)
set(_ALL_INCS "")
foreach(_INC ${ARGV})
foreach(_INC ${ARGN})
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
list(APPEND _ALL_INCS ${_ABS_INC})
# for checking for invalid includes, disable for regular use
@@ -147,22 +146,24 @@ function(blender_include_dirs
# message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
# endif()
endforeach()
include_directories(${_ALL_INCS})
set(${includes_absolute} ${_ALL_INCS} PARENT_SCOPE)
endfunction()
function(blender_include_dirs_sys
includes
function(blender_target_include_dirs
name
)
set(_ALL_INCS "")
foreach(_INC ${ARGV})
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
list(APPEND _ALL_INCS ${_ABS_INC})
# if(NOT EXISTS "${_ABS_INC}/")
# message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
# endif()
endforeach()
include_directories(SYSTEM ${_ALL_INCS})
absolute_include_dirs(_ALL_INCS ${ARGN})
target_include_directories(${name} PRIVATE ${_ALL_INCS})
endfunction()
function(blender_target_include_dirs_sys
name
)
absolute_include_dirs(_ALL_INCS ${ARGN})
target_include_directories(${name} SYSTEM PRIVATE ${_ALL_INCS})
endfunction()
# Set include paths for header files included with "*.h" syntax.
@@ -268,13 +269,11 @@ function(blender_add_lib__impl
# message(STATUS "Configuring library ${name}")
# include_directories(${includes})
# include_directories(SYSTEM ${includes_sys})
blender_include_dirs("${includes}")
blender_include_dirs_sys("${includes_sys}")
add_library(${name} ${sources})
blender_target_include_dirs(${name} ${includes})
blender_target_include_dirs_sys(${name} ${includes_sys})
# On Windows certain libraries have two sets of binaries: one for debug builds and one for
# release builds. The root of this requirement goes into ABI, I believe, but that's outside
# of a scope of this comment.
@@ -382,7 +381,7 @@ function(blender_add_test_suite)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Figure out the release dir, as some tests need files from there.
GET_BLENDER_TEST_INSTALL_DIR(TEST_INSTALL_DIR)
get_blender_test_install_dir(TEST_INSTALL_DIR)
if(APPLE)
set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION})
else()
@@ -425,21 +424,21 @@ function(blender_add_test_lib
# This duplicates logic that's also in GTestTesting.cmake, macro BLENDER_SRC_GTEST_EX.
# TODO(Sybren): deduplicate after the general approach in D7649 has been approved.
LIST(APPEND includes
list(APPEND includes
${CMAKE_SOURCE_DIR}/tests/gtests
)
LIST(APPEND includes_sys
list(APPEND includes_sys
${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/extern/gtest/include
${CMAKE_SOURCE_DIR}/extern/gmock/include
)
add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
add_definitions(${GFLAGS_DEFINES})
add_definitions(${GLOG_DEFINES})
blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}")
target_compile_definitions(${name} PRIVATE ${GFLAGS_DEFINES})
target_compile_definitions(${name} PRIVATE ${GLOG_DEFINES})
set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name})
blender_add_test_suite(
@@ -469,16 +468,16 @@ function(blender_add_test_executable
## Otherwise external projects will produce warnings that we cannot fix.
remove_strict_flags()
include_directories(${includes})
include_directories(${includes_sys})
BLENDER_SRC_GTEST_EX(
blender_src_gtest_ex(
NAME ${name}
SRC "${sources}"
EXTRA_LIBS "${library_deps}"
SKIP_ADD_TEST
)
blender_target_include_dirs(${name}_test ${includes})
blender_target_include_dirs_sys(${name}_test ${includes_sys})
blender_add_test_suite(
TARGET ${name}_test
SUITE_NAME ${name}
@@ -513,6 +512,11 @@ function(setup_platform_linker_flags
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${PLATFORM_LINKFLAGS}")
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " ${PLATFORM_LINKFLAGS_RELEASE}")
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG " ${PLATFORM_LINKFLAGS_DEBUG}")
get_target_property(target_type ${target} TYPE)
if (target_type STREQUAL "EXECUTABLE")
set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${PLATFORM_LINKFLAGS_EXECUTABLE}")
endif()
endfunction()
# Platform specific libraries for targets.
@@ -760,7 +764,7 @@ function(ADD_CHECK_C_COMPILER_FLAG
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
check_c_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CFLAG: ${_FLAG}")
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
@@ -777,7 +781,7 @@ function(ADD_CHECK_CXX_COMPILER_FLAG
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
check_cxx_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CXXFLAG: ${_FLAG}")
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
@@ -795,9 +799,11 @@ function(get_blender_version)
# - BLENDER_VERSION_PATCH
# - BLENDER_VERSION_CYCLE (alpha, beta, rc, release)
# So cmake depends on BKE_blender.h, beware of inf-loops!
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done)
# So CMAKE depends on `BKE_blender.h`, beware of infinite-loops!
configure_file(
${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done
)
file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h _contents REGEX "^#define[ \t]+BLENDER_.*$")
@@ -1184,8 +1190,6 @@ macro(openmp_delayload
if(WITH_OPENMP)
if(MSVC_CLANG)
set(OPENMP_DLL_NAME "libomp")
elseif(MSVC_VERSION EQUAL 1800)
set(OPENMP_DLL_NAME "vcomp120")
else()
set(OPENMP_DLL_NAME "vcomp140")
endif()
@@ -1208,16 +1212,8 @@ endmacro()
macro(without_system_libs_begin)
set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
if(APPLE)
# Avoid searching for headers in frameworks (like Mono), and libraries in LIBDIR.
set(CMAKE_FIND_FRAMEWORK NEVER)
endif()
endmacro()
macro(without_system_libs_end)
unset(CMAKE_IGNORE_PATH)
if(APPLE)
# FIRST is the default.
set(CMAKE_FIND_FRAMEWORK FIRST)
endif()
endmacro()

View File

@@ -17,9 +17,9 @@ set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
SET(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
# Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.
@@ -48,7 +48,7 @@ if(MSVC)
else()
set(PACKAGE_ARCH windows32)
endif()
else(MSVC)
else()
set(PACKAGE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()

View File

@@ -21,6 +21,18 @@ function(print_found_status
endif()
endfunction()
# Utility to install precompiled shared libraries.
macro(add_bundled_libraries library)
if(EXISTS ${LIBDIR})
set(_library_dir ${LIBDIR}/${library}/lib)
file(GLOB _all_library_versions ${_library_dir}/*\.dylib*)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions})
list(APPEND PLATFORM_BUNDLED_LIBRARY_DIRS ${_library_dir})
unset(_all_library_versions)
unset(_library_dir)
endif()
endmacro()
# ------------------------------------------------------------------------
# Find system provided libraries.
@@ -63,6 +75,15 @@ if(NOT EXISTS "${LIBDIR}/")
message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'")
endif()
# Avoid searching for headers since this would otherwise override our lib
# directory as well as PYTHON_ROOT_DIR.
set(CMAKE_FIND_FRAMEWORK NEVER)
# Optionally use system Python if PYTHON_ROOT_DIR is specified.
if(WITH_PYTHON AND (WITH_PYTHON_MODULE AND PYTHON_ROOT_DIR))
find_package(PythonLibsUnix REQUIRED)
endif()
# Prefer lib directory paths
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
@@ -111,34 +132,8 @@ if(WITH_CODEC_SNDFILE)
unset(_sndfile_VORBISENC_LIBRARY)
endif()
if(WITH_PYTHON)
# Use precompiled libraries by default.
set(PYTHON_VERSION 3.10)
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
# Normally cached but not since we include them with blender.
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}")
set(PYTHON_LIBRARY ${LIBDIR}/python/lib/libpython${PYTHON_VERSION}.a)
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
else()
# Module must be compiled against Python framework.
set(_py_framework "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}")
set(PYTHON_INCLUDE_DIR "${_py_framework}/include/python${PYTHON_VERSION}")
set(PYTHON_EXECUTABLE "${_py_framework}/bin/python${PYTHON_VERSION}")
set(PYTHON_LIBPATH "${_py_framework}/lib/python${PYTHON_VERSION}")
unset(_py_framework)
endif()
# uncached vars
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
# needed for Audaspace, numpy is installed into python site-packages
set(PYTHON_NUMPY_INCLUDE_DIRS "${PYTHON_LIBPATH}/site-packages/numpy/core/include")
if(NOT EXISTS "${PYTHON_EXECUTABLE}")
message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}")
endif()
if(WITH_PYTHON AND NOT (WITH_PYTHON_MODULE AND PYTHON_ROOT_DIR))
find_package(PythonLibsUnix REQUIRED)
endif()
if(WITH_FFTW3)
@@ -201,11 +196,6 @@ if(WITH_JACK)
string(APPEND PLATFORM_LINKFLAGS " -F/Library/Frameworks -weak_framework jackmp")
endif()
if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
# force cmake to link right framework
string(APPEND PLATFORM_LINKFLAGS " /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")
endif()
if(WITH_OPENCOLLADA)
find_package(OpenCOLLADA)
find_library(PCRE_LIBRARIES NAMES pcre HINTS ${LIBDIR}/opencollada/lib)
@@ -334,7 +324,7 @@ if(WITH_LLVM)
if(WITH_CLANG)
find_package(Clang)
if(NOT CLANG_FOUND)
message(FATAL_ERROR "Clang not found.")
message(FATAL_ERROR "Clang not found.")
endif()
endif()
@@ -362,10 +352,6 @@ endif()
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)
# Increase stack size for Embree, only works for executables.
if(NOT WITH_PYTHON_MODULE)
string(APPEND PLATFORM_LINKFLAGS " -Wl,-stack_size,0x100000")
endif()
# Embree static library linking can mix up SSE and AVX symbols, causing
# crashes on macOS systems with older CPUs that don't have AVX. Using
@@ -415,6 +401,7 @@ if(WITH_OPENMP)
set(OpenMP_LIBRARY_DIR "${LIBDIR}/openmp/lib/")
set(OpenMP_LINKER_FLAGS "-L'${OpenMP_LIBRARY_DIR}' -lomp")
set(OpenMP_LIBRARY "${OpenMP_LIBRARY_DIR}/libomp.dylib")
add_bundled_libraries(openmp)
endif()
endif()
@@ -442,6 +429,18 @@ if(WITH_HARU)
endif()
endif()
if(WITH_CYCLES_PATH_GUIDING)
find_package(openpgl QUIET)
if(openpgl_FOUND)
get_target_property(OPENPGL_LIBRARIES openpgl::openpgl LOCATION)
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found OpenPGL: ${OPENPGL_LIBRARIES}")
else()
set(WITH_CYCLES_PATH_GUIDING OFF)
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
endif()
endif()
set(ZSTD_ROOT_DIR ${LIBDIR}/zstd)
find_package(Zstd REQUIRED)
@@ -449,6 +448,9 @@ if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
# Restore to default.
set(CMAKE_FIND_FRAMEWORK FIRST)
# ---------------------------------------------------------------------
# Set compiler and linker flags.
@@ -481,6 +483,9 @@ string(APPEND PLATFORM_LINKFLAGS
string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")
string(APPEND PLATFORM_LINKFLAGS " -stdlib=libc++")
# Make stack size more similar to Embree, required for Embree.
string(APPEND PLATFORM_LINKFLAGS_EXECUTABLE " -Wl,-stack_size,0x100000")
# Suppress ranlib "has no symbols" warnings (workaround for T48250)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
@@ -504,17 +509,27 @@ if(WITH_COMPILER_CCACHE)
endif()
endif()
# For binaries that are built but not installed (also not distributed) (datatoc,
# makesdna, tests, etc.), we add an rpath to the OpenMP library dir through
# CMAKE_BUILD_RPATH. This avoids having to make many copies of the dylib next to each binary.
#
# For the installed Python module and installed Blender executable, CMAKE_INSTALL_RPATH
# is modified to find the dylib in an adjacent folder. Install step puts the libraries there.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH "${OpenMP_LIBRARY_DIR}")
if(WITH_COMPILER_ASAN)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${COMPILER_ASAN_LIBRARY})
endif()
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/${BLENDER_VERSION}/lib")
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the
# rpath to the location where install step will copy the shared libraries.
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
if(WITH_PYTHON_MODULE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/lib")
else()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/lib")
endif()
# For binaries that are built but not installed (like makesdan or tests), we add
# the original directory of all shared libraries to the rpath. This is needed because
# these can be in different folders, and because the build and install folder may be
# different.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH ${PLATFORM_BUNDLED_LIBRARY_DIRS})
endif()
# Same as `CFBundleIdentifier` in Info.plist.
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.blenderfoundation.blender")

View File

@@ -16,13 +16,15 @@ if(NOT DEFINED LIBDIR)
# Choose the best suitable libraries.
if(EXISTS ${LIBDIR_NATIVE_ABI})
set(LIBDIR ${LIBDIR_NATIVE_ABI})
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True)
elseif(EXISTS ${LIBDIR_CENTOS7_ABI})
set(LIBDIR ${LIBDIR_CENTOS7_ABI})
set(WITH_CXX11_ABI OFF)
if(CMAKE_COMPILER_IS_GNUCC AND
CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3)
message(FATAL_ERROR "GCC version must be at least 9.3 for precompiled libraries, found ${CMAKE_C_COMPILER_VERSION}")
if(WITH_MEM_JEMALLOC)
# jemalloc provides malloc hooks.
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND False)
else()
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND True)
endif()
endif()
@@ -81,6 +83,15 @@ macro(find_package_wrapper)
endif()
endmacro()
# Utility to install precompiled shared libraries.
macro(add_bundled_libraries library)
if(EXISTS ${LIBDIR})
file(GLOB _all_library_versions ${LIBDIR}/${library}/lib/*\.so*)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_all_library_versions})
unset(_all_library_versions)
endif()
endmacro()
# ----------------------------------------------------------------------------
# Precompiled Libraries
#
@@ -127,14 +138,38 @@ if(NOT WITH_SYSTEM_FREETYPE)
endif()
if(WITH_PYTHON)
# No way to set py35, remove for now.
# find_package(PythonLibs)
# This could be used, see: D14954 for details.
# `find_package(PythonLibs)`
# Use our own instead, since without py is such a rare case,
# require this package
# XXX Linking errors with debian static python :/
# find_package_wrapper(PythonLibsUnix REQUIRED)
# Use our own instead, since without Python is such a rare case,
# require this package.
# XXX: Linking errors with Debian static Python (sigh).
# find_package_wrapper(PythonLibsUnix REQUIRED)
find_package(PythonLibsUnix REQUIRED)
if(WITH_PYTHON_MODULE AND NOT WITH_INSTALL_PORTABLE)
# Installing into `site-packages`, warn when installing into `./../lib/`
# which script authors almost certainly don't want.
if(EXISTS ${LIBDIR})
cmake_path(IS_PREFIX LIBDIR "${PYTHON_SITE_PACKAGES}" NORMALIZE _is_prefix)
if(_is_prefix)
message(WARNING "
Building Blender with the following configuration:
- WITH_PYTHON_MODULE=ON
- WITH_INSTALL_PORTABLE=OFF
- LIBDIR=\"${LIBDIR}\"
- PYTHON_SITE_PACKAGES=\"${PYTHON_SITE_PACKAGES}\"
In this case you may want to either:
- Use the system Python's site-packages, see:
python -c \"import site; print(site.getsitepackages()[0])\"
- Set WITH_INSTALL_PORTABLE=ON to create a stand-alone \"bpy\" module
which you will need to ensure is in Python's module search path.
Proceeding with PYTHON_SITE_PACKAGES install target, you have been warned!"
)
endif()
unset(_is_prefix)
endif()
endif()
endif()
if(WITH_IMAGE_OPENEXR)
@@ -300,10 +335,18 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
endif()
set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to DPC++ and SYCL installation")
set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to oneAPI DPC++ compiler")
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
endif()
file(GLOB _sycl_runtime_libraries
${SYCL_ROOT_DIR}/lib/libsycl.so
${SYCL_ROOT_DIR}/lib/libsycl.so.[0-9]
${SYCL_ROOT_DIR}/lib/libsycl.so.[0-9].[0-9].[0-9]-[0-9]
${SYCL_ROOT_DIR}/lib/libpi_level_zero.so
)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_sycl_runtime_libraries})
unset(_sycl_runtime_libraries)
endif()
if(WITH_OPENVDB)
@@ -549,6 +592,18 @@ if(WITH_HARU)
endif()
endif()
if(WITH_CYCLES_PATH_GUIDING)
find_package_wrapper(openpgl)
if(openpgl_FOUND)
get_target_property(OPENPGL_LIBRARIES openpgl::openpgl LOCATION)
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found OpenPGL: ${OPENPGL_LIBRARIES}")
else()
set(WITH_CYCLES_PATH_GUIDING OFF)
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
endif()
endif()
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
@@ -644,47 +699,134 @@ endif()
if(WITH_GHOST_WAYLAND)
find_package(PkgConfig)
pkg_check_modules(wayland-client REQUIRED wayland-client>=1.12)
pkg_check_modules(wayland-egl REQUIRED wayland-egl)
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(xkbcommon xkbcommon)
if(WITH_GHOST_WAYLAND_DBUS)
pkg_check_modules(dbus REQUIRED dbus-1)
# When dynamically linked WAYLAND is used and `${LIBDIR}/wayland` is present,
# there is no need to search for the libraries as they are not needed for building.
# Only the headers are needed which can reference the known paths.
if(EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD)
set(_use_system_wayland OFF)
else()
set(_use_system_wayland ON)
endif()
if(WITH_GHOST_WAYLAND_LIBDECOR)
pkg_check_modules(libdecor REQUIRED libdecor-0>=0.1)
endif()
list(APPEND PLATFORM_LINKLIBS
${xkbcommon_LINK_LIBRARIES}
)
if(NOT WITH_GHOST_WAYLAND_DYNLOAD)
list(APPEND PLATFORM_LINKLIBS
${wayland-client_LINK_LIBRARIES}
${wayland-egl_LINK_LIBRARIES}
${wayland-cursor_LINK_LIBRARIES}
if(_use_system_wayland)
pkg_check_modules(wayland-client wayland-client>=1.12)
pkg_check_modules(wayland-egl wayland-egl)
pkg_check_modules(wayland-scanner wayland-scanner)
pkg_check_modules(wayland-cursor wayland-cursor)
pkg_check_modules(wayland-protocols wayland-protocols>=1.15)
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
else()
# CentOS 7 packages have too old a version, a newer version exist in the
# precompiled libraries.
find_path(WAYLAND_PROTOCOLS_DIR
NAMES unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
PATH_SUFFIXES share/wayland-protocols
PATHS ${LIBDIR}/wayland-protocols
)
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}
)
if(EXISTS ${WAYLAND_PROTOCOLS_DIR})
set(wayland-protocols_FOUND ON)
endif()
add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
set(wayland-client_INCLUDE_DIRS "${LIBDIR}/wayland/include")
set(wayland-egl_INCLUDE_DIRS "${LIBDIR}/wayland/include")
set(wayland-cursor_INCLUDE_DIRS "${LIBDIR}/wayland/include")
set(wayland-client_FOUND ON)
set(wayland-egl_FOUND ON)
set(wayland-scanner_FOUND ON)
set(wayland-cursor_FOUND ON)
endif()
if (NOT ${wayland-client_FOUND})
message(STATUS "wayland-client not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if (NOT ${wayland-egl_FOUND})
message(STATUS "wayland-egl not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if (NOT ${wayland-scanner_FOUND})
message(STATUS "wayland-scanner not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if (NOT ${wayland-cursor_FOUND})
message(STATUS "wayland-cursor not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if (NOT ${wayland-protocols_FOUND})
message(STATUS "wayland-protocols not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if (NOT ${xkbcommon_FOUND})
message(STATUS "xkbcommon not found, disabling WITH_GHOST_WAYLAND")
set(WITH_GHOST_WAYLAND OFF)
endif()
if(WITH_GHOST_WAYLAND)
if(WITH_GHOST_WAYLAND_DBUS)
pkg_check_modules(dbus REQUIRED dbus-1)
endif()
if(WITH_GHOST_WAYLAND_LIBDECOR)
if(_use_system_wayland)
pkg_check_modules(libdecor REQUIRED libdecor-0>=0.1)
else()
set(libdecor_INCLUDE_DIRS "${LIBDIR}/wayland_libdecor/include/libdecor-0")
endif()
endif()
if(WITH_GHOST_WAYLAND_DBUS)
add_definitions(-DWITH_GHOST_WAYLAND_DBUS)
endif()
if(WITH_GHOST_WAYLAND_LIBDECOR)
add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
endif()
if(EXISTS "${LIBDIR}/wayland/bin/wayland-scanner")
set(WAYLAND_SCANNER "${LIBDIR}/wayland/bin/wayland-scanner")
else()
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
endif()
# When using dynamic loading, headers generated
# from older versions of `wayland-scanner` aren't compatible.
if(WITH_GHOST_WAYLAND_DYNLOAD)
execute_process(
COMMAND ${WAYLAND_SCANNER} --version
# The version is written to the `stderr`.
ERROR_VARIABLE _wayland_scanner_out
ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT "${_wayland_scanner_out}" STREQUAL "")
string(
REGEX REPLACE
"^wayland-scanner[ \t]+([0-9]+)\.([0-9]+).*"
"\\1.\\2"
_wayland_scanner_ver
"${_wayland_scanner_out}"
)
if("${_wayland_scanner_ver}" VERSION_LESS "1.20")
message(
FATAL_ERROR
"Found ${WAYLAND_SCANNER} version \"${_wayland_scanner_ver}\", "
"the minimum version is 1.20!"
)
endif()
unset(_wayland_scanner_ver)
else()
message(WARNING "Unable to access the version from ${WAYLAND_SCANNER}, continuing.")
endif()
unset(_wayland_scanner_out)
endif()
# End wayland-scanner version check.
endif()
unset(_use_system_wayland)
endif()
if(WITH_GHOST_X11)
@@ -693,12 +835,8 @@ if(WITH_GHOST_X11)
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
if(WITH_X11_XINPUT)
if(X11_Xinput_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
else()
if(NOT X11_Xinput_LIB)
message(FATAL_ERROR "LibXi not found. Disable WITH_X11_XINPUT if you
want to build without tablet support")
endif()
@@ -708,18 +846,14 @@ if(WITH_GHOST_X11)
# XXX, why doesn't cmake make this available?
find_library(X11_Xxf86vmode_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xxf86vmode_LIB)
if(X11_Xxf86vmode_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
else()
if(NOT X11_Xxf86vmode_LIB)
message(FATAL_ERROR "libXxf86vm not found. Disable WITH_X11_XF86VMODE if you
want to build without")
endif()
endif()
if(WITH_X11_XFIXES)
if(X11_Xfixes_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
else()
if(NOT X11_Xfixes_LIB)
message(FATAL_ERROR "libXfixes not found. Disable WITH_X11_XFIXES if you
want to build without")
endif()
@@ -728,9 +862,7 @@ if(WITH_GHOST_X11)
if(WITH_X11_ALPHA)
find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xrender_LIB)
if(X11_Xrender_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
else()
if(NOT X11_Xrender_LIB)
message(FATAL_ERROR "libXrender not found. Disable WITH_X11_ALPHA if you
want to build without")
endif()
@@ -970,4 +1102,17 @@ function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
endif()
endfunction()
CONFIGURE_ATOMIC_LIB_IF_NEEDED()
configure_atomic_lib_if_needed()
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the
# rpath to the relative path where the install step will copy the shared libraries.
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
list(APPEND CMAKE_INSTALL_RPATH $ORIGIN/lib)
# For executables that are built but not installed (mainly tests) we set an absolute
# rpath to the lib folder. This is needed because these can be in different folders,
# and because the build and install folder may be different.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH $ORIGIN/lib ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib)
endif()

View File

@@ -26,7 +26,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OPENMP_FOUND ON)
set(OpenMP_C_FLAGS "/clang:-fopenmp")
set(OpenMP_CXX_FLAGS "/clang:-fopenmp")
GET_FILENAME_COMPONENT(LLVMROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\LLVM\\LLVM;]" ABSOLUTE CACHE)
get_filename_component(LLVMROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\LLVM\\LLVM;]" ABSOLUTE CACHE)
set(CLANG_OPENMP_DLL "${LLVMROOT}/bin/libomp.dll")
set(CLANG_OPENMP_LIB "${LLVMROOT}/lib/libomp.lib")
if(NOT EXISTS "${CLANG_OPENMP_DLL}")
@@ -74,27 +74,6 @@ add_definitions(-DWIN32)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# Minimum MSVC Version
if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
if(MSVC_VERSION EQUAL 1800)
set(_min_ver "18.0.31101")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver})
message(FATAL_ERROR
"Visual Studio 2013 (Update 4, ${_min_ver}) required, "
"found (${CMAKE_CXX_COMPILER_VERSION})")
endif()
endif()
if(MSVC_VERSION EQUAL 1900)
set(_min_ver "19.0.24210")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver})
message(FATAL_ERROR
"Visual Studio 2015 (Update 3, ${_min_ver}) required, "
"found (${CMAKE_CXX_COMPILER_VERSION})")
endif()
endif()
endif()
unset(_min_ver)
# needed for some MSVC installations
# 4099 : PDB 'filename' was not found with 'object/library'
string(APPEND CMAKE_EXE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099")
@@ -158,7 +137,7 @@ endif()
# C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up
if(MSVC_VERSION GREATER 1911 AND NOT MSVC_CLANG)
if(NOT MSVC_CLANG)
string(APPEND CMAKE_CXX_FLAGS " /permissive-")
# Two-phase name lookup does not place nicely with OpenMP yet, so disable for now
string(APPEND CMAKE_CXX_FLAGS " /Zc:twoPhase-")
@@ -218,7 +197,7 @@ unset(SYMBOL_FORMAT)
unset(SYMBOL_FORMAT_RELEASE)
# JMC is available on msvc 15.8 (1915) and up
if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG)
if(NOT MSVC_CLANG)
string(APPEND CMAKE_CXX_FLAGS_DEBUG " /JMC")
endif()
@@ -251,9 +230,6 @@ if(NOT DEFINED LIBDIR)
elseif(MSVC_VERSION GREATER 1919)
message(STATUS "Visual Studio 2019 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
elseif(MSVC_VERSION GREATER 1909)
message(STATUS "Visual Studio 2017 detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15)
endif()
else()
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
@@ -264,10 +240,8 @@ endif()
include(platform_old_libs_update)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND # Only supported in the VS IDE
MSVC_VERSION GREATER_EQUAL 1924 AND # Supported for 16.4+
WITH_CLANG_TIDY # And Clang Tidy needs to be on
)
# Only supported in the VS IDE & Clang Tidy needs to be on.
if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND WITH_CLANG_TIDY)
set(CMAKE_VS_GLOBALS
"RunCodeAnalysis=false"
"EnableMicrosoftCodeAnalysis=false"
@@ -278,8 +252,7 @@ endif()
# Mark libdir as system headers with a lower warn level, to resolve some warnings
# that we have very little control over
if(MSVC_VERSION GREATER_EQUAL 1914 AND # Available with 15.7+
NOT MSVC_CLANG AND # But not for clang
if(NOT MSVC_CLANG AND # Available with MSVC 15.7+ but not for CLANG.
NOT WITH_WINDOWS_SCCACHE AND # And not when sccache is enabled
NOT VS_CLANG_TIDY) # Clang-tidy does not like these options
add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0)
@@ -504,12 +477,16 @@ if(WITH_JACK)
endif()
if(WITH_PYTHON)
set(PYTHON_VERSION 3.10) # CACHE STRING)
# Cache version for make_bpy_wheel.py to detect.
unset(PYTHON_VERSION CACHE)
set(PYTHON_VERSION "3.10" CACHE STRING "Python version")
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
set(PYTHON_LIBRARY ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}.lib)
set(PYTHON_LIBRARY_DEBUG ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}_d.lib)
set(PYTHON_EXECUTABLE ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/bin/python$<$<CONFIG:Debug>:_d>.exe)
set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/include)
set(PYTHON_NUMPY_INCLUDE_DIRS ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/lib/site-packages/numpy/core/include)
set(NUMPY_FOUND ON)
@@ -763,7 +740,7 @@ if(WITH_TBB)
endif()
# used in many places so include globally, like OpenGL
blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
include_directories(SYSTEM "${PTHREADS_INCLUDE_DIRS}")
set(WINTAB_INC ${LIBDIR}/wintab/include)
@@ -870,8 +847,8 @@ endif()
if(WINDOWS_PYTHON_DEBUG)
# Include the system scripts in the blender_python_system_scripts project.
FILE(GLOB_RECURSE inFiles "${CMAKE_SOURCE_DIR}/release/scripts/*.*" )
ADD_CUSTOM_TARGET(blender_python_system_scripts SOURCES ${inFiles})
file(GLOB_RECURSE inFiles "${CMAKE_SOURCE_DIR}/release/scripts/*.*" )
add_custom_target(blender_python_system_scripts SOURCES ${inFiles})
foreach(_source IN ITEMS ${inFiles})
get_filename_component(_source_path "${_source}" PATH)
string(REPLACE "${CMAKE_SOURCE_DIR}/release/scripts/" "" _source_path "${_source_path}")
@@ -891,8 +868,8 @@ if(WINDOWS_PYTHON_DEBUG)
endif()
file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT)
FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles})
file(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" )
add_custom_target(blender_python_user_scripts SOURCES ${inFiles})
foreach(_source IN ITEMS ${inFiles})
get_filename_component(_source_path "${_source}" PATH)
string(REPLACE "${USER_SCRIPTS_ROOT}" "" _source_path "${_source_path}")
@@ -959,8 +936,39 @@ if(WITH_HARU)
endif()
endif()
if(WITH_CYCLES_PATH_GUIDING)
find_package(openpgl QUIET)
if(openpgl_FOUND)
get_target_property(OPENPGL_LIBRARIES_RELEASE openpgl::openpgl LOCATION_RELEASE)
get_target_property(OPENPGL_LIBRARIES_DEBUG openpgl::openpgl LOCATION_DEBUG)
set(OPENPGL_LIBRARIES optimized ${OPENPGL_LIBRARIES_RELEASE} debug ${OPENPGL_LIBRARIES_DEBUG})
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
else()
set(WITH_CYCLES_PATH_GUIDING OFF)
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
endif()
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)
if(WITH_CYCLES_DEVICE_ONEAPI)
set(LEVEL_ZERO_ROOT_DIR ${LIBDIR}/level_zero)
set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to oneAPI DPC++ compiler")
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
endif()
file(GLOB _sycl_runtime_libraries_glob
${SYCL_ROOT_DIR}/bin/sycl.dll
${SYCL_ROOT_DIR}/bin/sycl[0-9].dll
)
foreach(sycl_runtime_library IN LISTS _sycl_runtime_libraries_glob)
string(REPLACE ".dll" "$<$<CONFIG:Debug>:d>.dll" sycl_runtime_library ${sycl_runtime_library})
list(APPEND _sycl_runtime_libraries ${sycl_runtime_library})
endforeach()
unset(_sycl_runtime_libraries_glob)
list(APPEND _sycl_runtime_libraries ${SYCL_ROOT_DIR}/bin/pi_level_zero.dll)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_sycl_runtime_libraries})
unset(_sycl_runtime_libraries)
endif()

View File

@@ -3,20 +3,22 @@
# First generate the manifest for tests since it will not need the dependency on the CRT.
configure_file(${CMAKE_SOURCE_DIR}/release/windows/manifest/blender.exe.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/tests.exe.manifest @ONLY)
# Always detect system libraries, since they are also used by oneAPI.
# But don't always install them, only for WITH_WINDOWS_BUNDLE_CRT=ON.
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
# This sometimes can change when updates are installed and the compiler version
# changes, so test if it exists and if not, give InstallRequiredSystemLibraries
# another chance to figure out the path.
if(MSVC_REDIST_DIR AND NOT EXISTS "${MSVC_REDIST_DIR}")
unset(MSVC_REDIST_DIR CACHE)
endif()
include(InstallRequiredSystemLibraries)
if(WITH_WINDOWS_BUNDLE_CRT)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
# This sometimes can change when updates are installed and the compiler version
# changes, so test if it exists and if not, give InstallRequiredSystemLibraries
# another chance to figure out the path.
if(MSVC_REDIST_DIR AND NOT EXISTS "${MSVC_REDIST_DIR}")
unset(MSVC_REDIST_DIR CACHE)
endif()
include(InstallRequiredSystemLibraries)
# ucrtbase(d).dll cannot be in the manifest, due to the way windows 10 handles
# redirects for this dll, for details see T88813.
foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS})

View File

@@ -30,6 +30,8 @@ from typing import (
cast,
)
import shlex
SOURCE_DIR = join(dirname(__file__), "..", "..")
SOURCE_DIR = normpath(SOURCE_DIR)
@@ -160,7 +162,7 @@ def build_info(
for c in compilers:
args = args.replace(c, fake_compiler)
args = args.split()
args = shlex.split(args)
# end
# remove compiler

View File

@@ -0,0 +1,222 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Make Python wheel package (`*.whl`) file from Blender built with 'WITH_PYTHON_MODULE' enabled.
Example
=======
If the "bpy" module was build on Linux using the command:
make bpy lite
The command to package it as a wheel is:
./build_files/utils/make_bpy_wheel.py ../build_linux_bpy_lite/bin --output-dir=./
This will create a `*.whl` file in the current directory.
"""
import argparse
import make_utils
import os
import re
import platform
import string
import setuptools # type: ignore
import sys
from typing import (
Generator,
List,
Optional,
Sequence,
Tuple,
)
# ------------------------------------------------------------------------------
# Generic Functions
def find_dominating_file(
path: str,
search: Sequence[str],
) -> str:
while True:
for d in search:
if os.path.exists(os.path.join(path, d)):
return os.path.join(path, d)
path_next = os.path.normpath(os.path.join(path, ".."))
if path == path_next:
break
path = path_next
return ""
# ------------------------------------------------------------------------------
# CMake Cache Access
def cmake_cache_var_iter(filepath_cmake_cache: str) -> Generator[Tuple[str, str, str], None, None]:
import re
re_cache = re.compile(r"([A-Za-z0-9_\-]+)?:?([A-Za-z0-9_\-]+)?=(.*)$")
with open(filepath_cmake_cache, "r", encoding="utf-8") as cache_file:
for l in cache_file:
match = re_cache.match(l.strip())
if match is not None:
var, type_, val = match.groups()
yield (var, type_ or "", val)
def cmake_cache_var(filepath_cmake_cache: str, var: str) -> Optional[str]:
for var_iter, type_iter, value_iter in cmake_cache_var_iter(filepath_cmake_cache):
if var == var_iter:
return value_iter
return None
def cmake_cache_var_or_exit(filepath_cmake_cache: str, var: str) -> str:
value = cmake_cache_var(filepath_cmake_cache, var)
if value is None:
sys.stderr.write("Unable to find %r in %r, abort!\n" % (var, filepath_cmake_cache))
sys.exit(1)
return value
# ------------------------------------------------------------------------------
# Argument Parser
def argparse_create() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"install_dir",
metavar='INSTALL_DIR',
type=str,
help="The installation directory containing the \"bpy\" package.",
)
parser.add_argument(
"--build-dir",
metavar='BUILD_DIR',
default=None,
help="The build directory containing 'CMakeCache.txt' (search parent directories of INSTALL_DIR when omitted).",
required=False,
)
parser.add_argument(
"--output-dir",
metavar='OUTPUT_DIR',
default=None,
help="The destination directory for the '*.whl' file (use INSTALL_DIR when omitted).",
required=False,
)
return parser
# ------------------------------------------------------------------------------
# Main Function
def main() -> None:
# Parse arguments.
args = argparse_create().parse_args()
install_dir = os.path.abspath(args.install_dir)
output_dir = os.path.abspath(args.output_dir) if args.output_dir else install_dir
if args.build_dir:
build_dir = os.path.abspath(args.build_dir)
filepath_cmake_cache = os.path.join(build_dir, "CMakeCache.txt")
del build_dir
if not os.path.exists(filepath_cmake_cache):
sys.stderr.write("File not found %r, abort!\n" % filepath_cmake_cache)
sys.exit(1)
else:
filepath_cmake_cache = find_dominating_file(install_dir, ("CMakeCache.txt",))
if not filepath_cmake_cache:
# Should never fail.
sys.stderr.write("Unable to find CMakeCache.txt in or above %r, abort!\n" % install_dir)
sys.exit(1)
# Get the major and minor Python version.
python_version = cmake_cache_var_or_exit(filepath_cmake_cache, "PYTHON_VERSION")
python_version_number = (
tuple(int("".join(c for c in digit if c in string.digits)) for digit in python_version.split(".")) +
# Support version without a minor version "3" (add zero).
tuple((0, 0, 0))
)
python_version_str = "%d.%d" % python_version_number[:2]
# Get Blender version.
blender_version_str = str(make_utils.parse_blender_version())
# Set platform tag following conventions.
if sys.platform == "darwin":
target = cmake_cache_var_or_exit(filepath_cmake_cache, "CMAKE_OSX_DEPLOYMENT_TARGET").split(".")
machine = cmake_cache_var_or_exit(filepath_cmake_cache, "CMAKE_OSX_ARCHITECTURES")
platform_tag = "macosx_%d_%d_%s" % (int(target[0]), int(target[1]), machine)
elif sys.platform == "win32":
platform_tag = "win_%s" % (platform.machine().lower())
elif sys.platform == "linux":
glibc = os.confstr("CS_GNU_LIBC_VERSION")
if glibc is None:
sys.stderr.write("Unable to find \"CS_GNU_LIBC_VERSION\", abort!\n")
sys.exit(1)
glibc = "%s_%s" % tuple(glibc.split()[1].split(".")[:2])
platform_tag = "manylinux_%s_%s" % (glibc, platform.machine().lower())
else:
sys.stderr.write("Unsupported platform: %s, abort!\n" % (sys.platform))
sys.exit(1)
os.chdir(install_dir)
# Include all files recursively.
def package_files(root_dir: str) -> List[str]:
paths = []
for path, dirs, files in os.walk(root_dir):
paths += [os.path.join("..", path, f) for f in files]
return paths
# Ensure this wheel is marked platform specific.
class BinaryDistribution(setuptools.dist.Distribution): # type: ignore
def has_ext_modules(self) -> bool:
return True
# Build wheel.
sys.argv = [sys.argv[0], "bdist_wheel"]
setuptools.setup(
name="bpy",
version=blender_version_str,
install_requires=["cython", "numpy", "requests", "zstandard"],
python_requires="==%d.%d.*" % (python_version_number[0], python_version_number[1]),
packages=["bpy"],
package_data={"": package_files("bpy")},
distclass=BinaryDistribution,
options={"bdist_wheel": {"plat_name": platform_tag}},
description="Blender as a Python module",
license="GPL-3.0",
author="Blender Foundation",
author_email="bf-committers@blender.org",
url="https://www.blender.org"
)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Move wheel to output directory.
dist_dir = os.path.join(install_dir, "dist")
for f in os.listdir(dist_dir):
if f.endswith(".whl"):
# No apparent way to override this ABI version with setuptools, so rename.
sys_py = "cp%d%d" % (sys.version_info.major, sys.version_info.minor)
sys_py_abi = sys_py + sys.abiflags
blender_py = "cp%d%d" % (python_version_number[0], python_version_number[1])
renamed_f = f.replace(sys_py_abi, blender_py).replace(sys_py, blender_py)
os.rename(os.path.join(dist_dir, f), os.path.join(output_dir, renamed_f))
if __name__ == "__main__":
main()

View File

@@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import argparse
import dataclasses
import make_utils
import os
import re
import subprocess
@@ -19,6 +19,8 @@ from typing import Iterable, TextIO, Optional, Any, Union
SKIP_NAMES = {
".gitignore",
".gitmodules",
".gitattributes",
".git-blame-ignore-revs",
".arcconfig",
".svn",
}
@@ -50,7 +52,7 @@ def main() -> None:
print(f"Output dir: {curdir}")
version = parse_blender_version(blender_srcdir)
version = make_utils.parse_blender_version()
tarball = tarball_path(curdir, version, cli_args)
manifest = manifest_path(tarball)
packages_dir = packages_path(curdir, cli_args)
@@ -62,53 +64,7 @@ def main() -> None:
print("Done!")
@dataclasses.dataclass
class BlenderVersion:
version: int # 293 for 2.93.1
patch: int # 1 for 2.93.1
cycle: str # 'alpha', 'beta', 'release', maybe others.
@property
def is_release(self) -> bool:
return self.cycle == "release"
def __str__(self) -> str:
"""Convert to version string.
>>> str(BlenderVersion(293, 1, "alpha"))
'2.93.1-alpha'
>>> str(BlenderVersion(327, 0, "release"))
'3.27.0'
"""
version_major = self.version // 100
version_minor = self.version % 100
as_string = f"{version_major}.{version_minor}.{self.patch}"
if self.is_release:
return as_string
return f"{as_string}-{self.cycle}"
def parse_blender_version(blender_srcdir: Path) -> BlenderVersion:
version_path = blender_srcdir / "source/blender/blenkernel/BKE_blender_version.h"
version_info = {}
line_re = re.compile(r"^#define (BLENDER_VERSION[A-Z_]*)\s+([0-9a-z]+)$")
with version_path.open(encoding="utf-8") as version_file:
for line in version_file:
match = line_re.match(line.strip())
if not match:
continue
version_info[match.group(1)] = match.group(2)
return BlenderVersion(
int(version_info["BLENDER_VERSION"]),
int(version_info["BLENDER_VERSION_PATCH"]),
version_info["BLENDER_VERSION_CYCLE"],
)
def tarball_path(output_dir: Path, version: BlenderVersion, cli_args: Any) -> Path:
def tarball_path(output_dir: Path, version: make_utils.BlenderVersion, cli_args: Any) -> Path:
extra = ""
if cli_args.include_packages:
extra = "-with-libraries"
@@ -148,7 +104,7 @@ def packages_path(current_directory: Path, cli_args: Any) -> Optional[Path]:
def create_manifest(
version: BlenderVersion,
version: make_utils.BlenderVersion,
outpath: Path,
blender_srcdir: Path,
packages_dir: Optional[Path],
@@ -170,9 +126,9 @@ def main_files_to_manifest(blender_srcdir: Path, outfile: TextIO) -> None:
def submodules_to_manifest(
blender_srcdir: Path, version: BlenderVersion, outfile: TextIO
blender_srcdir: Path, version: make_utils.BlenderVersion, outfile: TextIO
) -> None:
skip_addon_contrib = version.is_release
skip_addon_contrib = version.is_release()
assert not blender_srcdir.is_absolute()
for line in git_command("-C", blender_srcdir, "submodule"):
@@ -200,7 +156,11 @@ def packages_to_manifest(outfile: TextIO, packages_dir: Path) -> None:
def create_tarball(
version: BlenderVersion, tarball: Path, manifest: Path, blender_srcdir: Path, packages_dir: Optional[Path]
version: make_utils.BlenderVersion,
tarball: Path,
manifest: Path,
blender_srcdir: Path,
packages_dir: Optional[Path],
) -> None:
print(f'Creating archive: "{tarball}" ...', end="", flush=True)
command = ["tar"]

View File

@@ -9,9 +9,15 @@ import re
import shutil
import subprocess
import sys
from pathlib import Path
from typing import (
Sequence,
Optional,
)
def call(cmd, exit_on_error=True, silent=False):
def call(cmd: Sequence[str], exit_on_error: bool = True, silent: bool = False) -> int:
if not silent:
print(" ".join(cmd))
@@ -29,7 +35,7 @@ def call(cmd, exit_on_error=True, silent=False):
return retcode
def check_output(cmd, exit_on_error=True):
def check_output(cmd: Sequence[str], exit_on_error: bool = True) -> str:
# Flush to ensure correct order output on Windows.
sys.stdout.flush()
sys.stderr.flush()
@@ -46,14 +52,14 @@ def check_output(cmd, exit_on_error=True):
return output.strip()
def git_branch_exists(git_command, branch):
def git_branch_exists(git_command: str, branch: str) -> bool:
return (
call([git_command, "rev-parse", "--verify", branch], exit_on_error=False, silent=True) == 0 or
call([git_command, "rev-parse", "--verify", "remotes/origin/" + branch], exit_on_error=False, silent=True) == 0
)
def git_branch(git_command):
def git_branch(git_command: str) -> str:
# Get current branch name.
try:
branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
@@ -64,7 +70,7 @@ def git_branch(git_command):
return branch.strip().decode('utf8')
def git_tag(git_command):
def git_tag(git_command: str) -> Optional[str]:
# Get current tag name.
try:
tag = subprocess.check_output([git_command, "describe", "--exact-match"], stderr=subprocess.STDOUT)
@@ -74,18 +80,19 @@ def git_tag(git_command):
return tag.strip().decode('utf8')
def git_branch_release_version(branch, tag):
release_version = re.search("^blender-v(.*)-release$", branch)
if release_version:
release_version = release_version.group(1)
def git_branch_release_version(branch: str, tag: str) -> Optional[str]:
re_match = re.search("^blender-v(.*)-release$", branch)
release_version = None
if re_match:
release_version = re_match.group(1)
elif tag:
release_version = re.search(r"^v([0-9]*\.[0-9]*).*", tag)
if release_version:
release_version = release_version.group(1)
re_match = re.search(r"^v([0-9]*\.[0-9]*).*", tag)
if re_match:
release_version = re_match.group(1)
return release_version
def svn_libraries_base_url(release_version, branch=None):
def svn_libraries_base_url(release_version: Optional[str], branch: Optional[str] = None) -> str:
if release_version:
svn_branch = "tags/blender-" + release_version + "-release"
elif branch:
@@ -95,9 +102,58 @@ def svn_libraries_base_url(release_version, branch=None):
return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"
def command_missing(command):
def command_missing(command: str) -> bool:
# Support running with Python 2 for macOS
if sys.version_info >= (3, 0):
return shutil.which(command) is None
else:
return False
class BlenderVersion:
def __init__(self, version: int, patch: int, cycle: str):
# 293 for 2.93.1
self.version = version
# 1 for 2.93.1
self.patch = patch
# 'alpha', 'beta', 'release', maybe others.
self.cycle = cycle
def is_release(self) -> bool:
return self.cycle == "release"
def __str__(self) -> str:
"""Convert to version string.
>>> str(BlenderVersion(293, 1, "alpha"))
'2.93.1-alpha'
>>> str(BlenderVersion(327, 0, "release"))
'3.27.0'
"""
version_major = self.version // 100
version_minor = self.version % 100
as_string = f"{version_major}.{version_minor}.{self.patch}"
if self.is_release():
return as_string
return f"{as_string}-{self.cycle}"
def parse_blender_version() -> BlenderVersion:
blender_srcdir = Path(__file__).absolute().parent.parent.parent
version_path = blender_srcdir / "source/blender/blenkernel/BKE_blender_version.h"
version_info = {}
line_re = re.compile(r"^#define (BLENDER_VERSION[A-Z_]*)\s+([0-9a-z]+)$")
with version_path.open(encoding="utf-8") as version_file:
for line in version_file:
match = line_re.match(line.strip())
if not match:
continue
version_info[match.group(1)] = match.group(2)
return BlenderVersion(
int(version_info["BLENDER_VERSION"]),
int(version_info["BLENDER_VERSION_PATCH"]),
version_info["BLENDER_VERSION_CYCLE"],
)

View File

@@ -139,7 +139,7 @@ https://www.blender.org''')
l = lines.pop(0)
if l:
assert(l.startswith('\t'))
assert l.startswith('\t')
l = l[1:] # Remove first white-space (tab).
fh.write('%s\n' % man_format(l))

View File

@@ -1,4 +1,6 @@
"""
.. _modal_operator:
Modal Execution
+++++++++++++++

View File

@@ -134,7 +134,6 @@ batch = batch_for_shader(shader, 'LINES', {"pos": coords})
def draw():
shader.bind()
shader.uniform_float("color", (1, 1, 0, 1))
batch.draw(shader)

View File

@@ -14,33 +14,36 @@ from random import random
from mathutils import Vector
from gpu_extras.batch import batch_for_shader
vertex_shader = '''
uniform mat4 u_ViewProjectionMatrix;
vert_out = gpu.types.GPUStageInterfaceInfo("my_interface")
vert_out.smooth('FLOAT', "v_ArcLength")
in vec3 position;
in float arcLength;
shader_info = gpu.types.GPUShaderCreateInfo()
shader_info.push_constant('MAT4', "u_ViewProjectionMatrix")
shader_info.push_constant('FLOAT', "u_Scale")
shader_info.vertex_in(0, 'VEC3', "position")
shader_info.vertex_in(1, 'FLOAT', "arcLength")
shader_info.vertex_out(vert_out)
shader_info.fragment_out(0, 'VEC4', "FragColor")
out float v_ArcLength;
shader_info.vertex_source(
"void main()"
"{"
" v_ArcLength = arcLength;"
" gl_Position = u_ViewProjectionMatrix * vec4(position, 1.0f);"
"}"
)
void main()
{
v_ArcLength = arcLength;
gl_Position = u_ViewProjectionMatrix * vec4(position, 1.0f);
}
'''
shader_info.fragment_source(
"void main()"
"{"
" if (step(sin(v_ArcLength * u_Scale), 0.5) == 1) discard;"
" FragColor = vec4(1.0);"
"}"
)
fragment_shader = '''
uniform float u_Scale;
in float v_ArcLength;
out vec4 FragColor;
void main()
{
if (step(sin(v_ArcLength * u_Scale), 0.5) == 1) discard;
FragColor = vec4(1.0);
}
'''
shader = gpu.shader.create_from_info(shader_info)
del vert_out
del shader_info
coords = [Vector((random(), random(), random())) * 5 for _ in range(5)]
@@ -48,7 +51,6 @@ arc_lengths = [0]
for a, b in zip(coords[:-1], coords[1:]):
arc_lengths.append(arc_lengths[-1] + (a - b).length)
shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
batch = batch_for_shader(
shader, 'LINE_STRIP',
{"position": coords, "arcLength": arc_lengths},
@@ -56,7 +58,6 @@ batch = batch_for_shader(
def draw():
shader.bind()
matrix = bpy.context.region_data.perspective_matrix
shader.uniform_float("u_ViewProjectionMatrix", matrix)
shader.uniform_float("u_Scale", 10)

View File

@@ -6,38 +6,41 @@ import bpy
import gpu
from gpu_extras.batch import batch_for_shader
vertex_shader = '''
uniform mat4 viewProjectionMatrix;
in vec3 position;
out vec3 pos;
vert_out = gpu.types.GPUStageInterfaceInfo("my_interface")
vert_out.smooth('VEC3', "pos")
void main()
{
pos = position;
gl_Position = viewProjectionMatrix * vec4(position, 1.0f);
}
'''
shader_info = gpu.types.GPUShaderCreateInfo()
shader_info.push_constant('MAT4', "viewProjectionMatrix")
shader_info.push_constant('FLOAT', "brightness")
shader_info.vertex_in(0, 'VEC3', "position")
shader_info.vertex_out(vert_out)
shader_info.fragment_out(0, 'VEC4', "FragColor")
fragment_shader = '''
uniform float brightness;
shader_info.vertex_source(
"void main()"
"{"
" pos = position;"
" gl_Position = viewProjectionMatrix * vec4(position, 1.0f);"
"}"
)
in vec3 pos;
out vec4 FragColor;
shader_info.fragment_source(
"void main()"
"{"
" FragColor = vec4(pos * brightness, 1.0);"
"}"
)
void main()
{
FragColor = vec4(pos * brightness, 1.0);
}
'''
shader = gpu.shader.create_from_info(shader_info)
del vert_out
del shader_info
coords = [(1, 1, 1), (2, 0, 0), (-2, -1, 3)]
shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
batch = batch_for_shader(shader, 'TRIS', {"position": coords})
def draw():
shader.bind()
matrix = bpy.context.region_data.perspective_matrix
shader.uniform_float("viewProjectionMatrix", matrix)
shader.uniform_float("brightness", 0.5)

View File

@@ -22,7 +22,6 @@ batch = batch_for_shader(shader, 'LINES', {"pos": coords}, indices=indices)
def draw():
shader.bind()
shader.uniform_float("color", (1, 0, 0, 1))
batch.draw(shader)

View File

@@ -18,7 +18,6 @@ batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices)
def draw():
shader.bind()
shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
batch.draw(shader)

View File

@@ -56,7 +56,6 @@ batch = batch_for_shader(
def draw():
shader.bind()
shader.uniform_sampler("image", texture)
batch.draw(shader)

View File

@@ -35,35 +35,37 @@ with offscreen.bind():
# Drawing the generated texture in 3D space
#############################################
vertex_shader = '''
uniform mat4 modelMatrix;
uniform mat4 viewProjectionMatrix;
vert_out = gpu.types.GPUStageInterfaceInfo("my_interface")
vert_out.smooth('VEC2', "uvInterp")
in vec2 position;
in vec2 uv;
shader_info = gpu.types.GPUShaderCreateInfo()
shader_info.push_constant('MAT4', "viewProjectionMatrix")
shader_info.push_constant('MAT4', "modelMatrix")
shader_info.sampler(0, 'FLOAT_2D', "image")
shader_info.vertex_in(0, 'VEC2', "position")
shader_info.vertex_in(1, 'VEC2', "uv")
shader_info.vertex_out(vert_out)
shader_info.fragment_out(0, 'VEC4', "FragColor")
out vec2 uvInterp;
shader_info.vertex_source(
"void main()"
"{"
" uvInterp = uv;"
" gl_Position = viewProjectionMatrix * modelMatrix * vec4(position, 0.0, 1.0);"
"}"
)
void main()
{
uvInterp = uv;
gl_Position = viewProjectionMatrix * modelMatrix * vec4(position, 0.0, 1.0);
}
'''
shader_info.fragment_source(
"void main()"
"{"
" FragColor = texture(image, uvInterp);"
"}"
)
fragment_shader = '''
uniform sampler2D image;
shader = gpu.shader.create_from_info(shader_info)
del vert_out
del shader_info
in vec2 uvInterp;
out vec4 FragColor;
void main()
{
FragColor = texture(image, uvInterp);
}
'''
shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
batch = batch_for_shader(
shader, 'TRI_FAN',
{
@@ -74,7 +76,6 @@ batch = batch_for_shader(
def draw():
shader.bind()
shader.uniform_float("modelMatrix", Matrix.Translation((1, 2, 3)) @ Matrix.Scale(3, 4))
shader.uniform_float("viewProjectionMatrix", bpy.context.region_data.perspective_matrix)
shader.uniform_sampler("image", offscreen.texture_color)

View File

@@ -1,12 +1,12 @@
sphinx==5.0.1
sphinx==5.2.3
# Sphinx dependencies that are important
Jinja2==3.1.2
Pygments==2.12.0
Pygments==2.13.0
docutils==0.17.1
snowballstemmer==2.2.0
babel==2.10.1
requests==2.27.1
babel==2.10.3
requests==2.28.1
# Only needed to match the theme used for the official documentation.
# Without this theme, the default theme will be used.

View File

@@ -1,7 +1,9 @@
:tocdepth: 2
Blender API Change Log
**********************
Change Log
**********
Changes in Blender's Python API between releases.
.. note, this document is auto generated by sphinx_changelog_gen.py

View File

@@ -0,0 +1,15 @@
.. _info_advanced-index:
********
Advanced
********
This chapter covers advanced use (topics which may not be required for typical usage).
.. NOTE(@campbellbarton): Blender-as-a-Python-module is too obscure a topic to list directly on the main-page,
so opt for an "Advanced" page which can be expanded on as needed.
.. toctree::
:maxdepth: 1
info_advanced_blender_as_bpy.rst

View File

@@ -0,0 +1,126 @@
**************************
Blender as a Python Module
**************************
Blender supports being built as a Python module,
allowing ``import bpy`` to be added to any Python script, providing access to Blender's features.
.. note::
At time of writing official builds are not available,
using this requires compiling Blender yourself see
`build instructions <https://wiki.blender.org/w/index.php?title=Building_Blender/Other/BlenderAsPyModule>`__.
Use Cases
=========
Python developers may wish to integrate Blender scripts which don't center around Blender.
Possible uses include:
- Visualizing data by rendering images and animations.
- Image processing using Blender's compositor.
- Video editing (using Blender's sequencer).
- 3D file conversion.
- Development, accessing ``bpy`` from Python IDE's and debugging tools for example.
- Automation.
Usage
=====
For the most part using Blender as a Python module is equivalent to running a script in background-mode
(passing the command-line arguments ``--background`` or ``-b``),
however there are some differences to be aware of.
.. Sorted alphabetically as there isn't an especially a logical order to show them.
Blender's Executable Access
The attribute :class:`bpy.app.binary_path` defaults to an empty string.
If you wish to point this to the location of a known executable you may set the value.
This example searches for the binary, setting it when found:
.. code-block:: python
import bpy
import shutil
blender_bin = shutil.which("blender")
if blender_bin:
print("Found:", blender_bin)
bpy.app.binary_path = blender_bin
else:
print("Unable to find blender!")
Blender's Internal Modules
There are many modules included with Blender such as :mod:`gpu` and :mod:`mathuils`.
It's important that these are imported after ``bpy`` or they will not be found.
Command Line Arguments Unsupported
Functionality controlled by command line arguments (shown by calling ``blender --help`` aren't accessible).
Typically this isn't such a limitation although there are some command line arguments that don't have
equivalents in Blender's Python API (``--threads`` and ``--log`` for example).
.. note::
Access to these settings may be added in the future as needed.
Resource Sharing (GPU)
It's possible other Python modules make use of the GPU in a way that prevents Blender/Cycles from accessing the GPU.
Signal Handlers
Blender's typical signal handlers are not initialized, so there is no special handling for ``Control-C``
to cancel a render and a crash log is not written in the event of a crash.
Startup and Preferences
When the ``bpy`` module loads it contains the default startup scene
(instead of an "empty" blend-file as you might expect), so there is a default cube, camera and light.
If you wish to start from an empty file use: ``bpy.ops.wm.read_factory_settings(use_empty=True)``.
The users startup and preferences are ignored to prevent your local configuration from impacting scripts behavior.
The Python module behaves as if ``--factory-startup`` was passed as a command line argument.
The users preferences and startup can be loaded using operators:
.. code-block:: python
import bpy
bpy.ops.wm.read_userpref()
bpy.ops.wm.read_homefile()
Limitations
===========
Most constraints of Blender as an application still apply:
Reloading Unsupported
Reloading the ``bpy`` module via ``importlib.reload`` will raise an exception
instead of reloading and resetting the module.
Instead, the operator ``bpy.ops.wm.read_factory_settings()`` can be used to reset the internal state.
Single Blend File Restriction
Only a single ``.blend`` file can be edited at a time.
.. hint::
As with the application it's possible to start multiple instances,
each with their own ``bpy`` and therefor Blender state.
Python provides the ``multiprocessing`` module to make communicating with sub-processes more convenient.
In some cases the library API may be an alternative to starting separate processes,
although this API operates on reading and writing ID data-blocks and isn't
a complete substitute for loading ``.blend`` files, see:
- :meth:`bpy.types.BlendDataLibraries.load`
- :meth:`bpy.types.BlendDataLibraries.write`
- :meth:`bpy.types.BlendData.temp_data`
supports a temporary data-context to avoid manipulating the current ``.blend`` file.

View File

@@ -1,6 +1,6 @@
*******************
Reference API Usage
API Reference Usage
*******************
Blender has many interlinking data types which have an auto-generated reference API which often has the information

View File

@@ -86,7 +86,8 @@ No updates after setting values
Sometimes you want to modify values from Python and immediately access the updated values, e.g:
Once changing the objects :class:`bpy.types.Object.location`
you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`,
but this doesn't work as you might expect.
but this doesn't work as you might expect. There are similar issues with changes to the UI, that
are covered in the next section.
Consider the calculations that might contribute to the object's final transformation, this includes:
@@ -110,6 +111,35 @@ Now all dependent data (child objects, modifiers, drivers, etc.)
have been recalculated and are available to the script within the active view layer.
No updates after changing UI context
------------------------------------
Similar to the previous issue, some changes to the UI may also not have an immediate effect. For example, setting
:class:`bpy.types.Window.workspace` doesn't seem to cause an observable effect in the immediately following code
(:class:`bpy.types.Window.workspace` is still the same), but the UI will in fact reflect the change. Some of the
properties that behave that way are:
- :class:`bpy.types.Window.workspace`
- :class:`bpy.types.Window.screen`
- :class:`bpy.types.Window.scene`
- :class:`bpy.types.Area.type`
- :class:`bpy.types.Area.uitype`
Such changes impact the UI, and with that the context (:class:`bpy.context`) quite drastically. This can break
Blender's context management. So Blender delays this change until after operators have run and just before the UI is
redrawn, making sure that context can be changed safely.
If you rely on executing code with an updated context this can be worked around by executing the code in a delayed
fashion as well. Possible options include:
- :ref:`Modal Operator <modal_operator>`.
- :class:`bpy.app.handlers`.
- :class:`bpy.app.timer`.
It's also possible to depend on drawing callbacks although these should generally be avoided as failure to draw a
hidden panel, region, cursor, etc. could cause your script to be unreliable
Can I redraw during script execution?
-------------------------------------

View File

@@ -1,8 +1,8 @@
.. _info_overview:
*******************
Python API Overview
*******************
************
API Overview
************
The purpose of this document is to explain how Python and Blender fit together,
covering some of the functionality that may not be obvious from reading the API references

View File

@@ -241,9 +241,9 @@ def main():
comment_washed = []
comment = [] if comment is None else comment
for i, l in enumerate(comment):
assert((l.strip() == "") or
(l in {"/*", " *"}) or
(l.startswith(("/* ", " * "))))
assert ((l.strip() == "") or
(l in {"/*", " *"}) or
(l.startswith(("/* ", " * "))))
l = l[3:]
if i == 0 and not l.strip():
@@ -270,7 +270,7 @@ def main():
tp_sub = None
else:
print(arg)
assert(0)
assert 0
tp_str = ""
@@ -315,7 +315,7 @@ def main():
tp_str += " or any sequence of 3 floats"
elif tp == BMO_OP_SLOT_PTR:
tp_str = "dict"
assert(tp_sub is not None)
assert tp_sub is not None
if tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_BMESH:
tp_str = ":class:`bmesh.types.BMesh`"
elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_SCENE:
@@ -330,10 +330,10 @@ def main():
tp_str = ":class:`bpy.types.bpy_struct`"
else:
print("Can't find", vars_dict_reverse[tp_sub])
assert(0)
assert 0
elif tp == BMO_OP_SLOT_ELEMENT_BUF:
assert(tp_sub is not None)
assert tp_sub is not None
ls = []
if tp_sub & BM_VERT:
@@ -342,7 +342,7 @@ def main():
ls.append(":class:`bmesh.types.BMEdge`")
if tp_sub & BM_FACE:
ls.append(":class:`bmesh.types.BMFace`")
assert(ls) # must be at least one
assert ls # Must be at least one.
if tp_sub & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE:
tp_str = "/".join(ls)
@@ -367,10 +367,10 @@ def main():
tp_str += "unknown internal data, not compatible with python"
else:
print("Can't find", vars_dict_reverse[tp_sub])
assert(0)
assert 0
else:
print("Can't find", vars_dict_reverse[tp])
assert(0)
assert 0
args_wash.append((name, tp_str, comment))
return args_wash
@@ -394,7 +394,7 @@ def main():
fw(" :return:\n\n")
for (name, tp, comment) in args_out_wash:
assert(name.endswith(".out"))
assert name.endswith(".out")
name = name[:-4]
fw(" - ``%s``: %s\n\n" % (name, comment))
fw(" **type** %s\n" % tp)

View File

@@ -101,7 +101,7 @@ def api_dump(args):
version, version_key = api_version()
if version is None:
raise(ValueError("API dumps can only be generated from within Blender."))
raise ValueError("API dumps can only be generated from within Blender.")
dump = {}
dump_module = dump["bpy.types"] = {}
@@ -250,7 +250,7 @@ def api_changelog(args):
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."))
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)
@@ -258,17 +258,21 @@ def api_changelog(args):
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."))
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."))
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."))
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)
@@ -277,7 +281,7 @@ def api_changelog(args):
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)
assert tuple(dump_version) == version
api_changes = []
@@ -345,8 +349,10 @@ def api_changelog(args):
fw(""
":tocdepth: 2\n"
"\n"
"Blender API Change Log\n"
"**********************\n"
"Change Log\n"
"**********\n"
"\n"
"Changes in Blender's Python API between releases.\n"
"\n"
".. note, this document is auto generated by sphinx_changelog_gen.py\n"
"\n"

View File

@@ -387,23 +387,35 @@ EXAMPLE_SET_USED = set()
# RST files directory.
RST_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, "rst"))
# extra info, not api reference docs
# stored in ./rst/info_*
# Extra info, not api reference docs stored in `./rst/info_*`.
# Pairs of (file, description), the title makes from the RST files are displayed before the description.
INFO_DOCS = (
("info_quickstart.rst",
"Quickstart: New to Blender or scripting and want to get your feet wet?"),
"New to Blender or scripting and want to get your feet wet?"),
("info_overview.rst",
"API Overview: A more complete explanation of Python integration"),
"A more complete explanation of Python integration."),
("info_api_reference.rst",
"API Reference Usage: examples of how to use the API reference docs"),
"Examples of how to use the API reference docs."),
("info_best_practice.rst",
"Best Practice: Conventions to follow for writing good scripts"),
"Conventions to follow for writing good scripts."),
("info_tips_and_tricks.rst",
"Tips and Tricks: Hints to help you while writing scripts for Blender"),
"Hints to help you while writing scripts for Blender."),
("info_gotcha.rst",
"Gotcha's: Some of the problems you may encounter when writing scripts"),
("change_log.rst", "Change Log: List of changes since last Blender release"),
"Some of the problems you may encounter when writing scripts."),
("info_advanced.rst",
"Topics which may not be required for typical usage."),
("change_log.rst",
"List of changes since last Blender release"),
)
# Referenced indirectly.
INFO_DOCS_OTHER = (
# Included by: `info_advanced.rst`.
"info_advanced_blender_as_bpy.rst",
)
# Hide the actual TOC, use a separate list that links to the items.
# This is done so a short description can be included with each link.
USE_INFO_DOCS_FANCY_INDEX = True
# only support for properties atm.
RNA_BLACKLIST = {
@@ -1470,7 +1482,7 @@ def pyrna2sphinx(basepath):
struct_module_name = struct.module_name
if USE_ONLY_BUILTIN_RNA_TYPES:
assert(struct_module_name == "bpy.types")
assert struct_module_name == "bpy.types"
filepath = os.path.join(basepath, "%s.%s.rst" % (struct_module_name, struct.identifier))
file = open(filepath, "w", encoding="utf-8")
fw = file.write
@@ -1904,7 +1916,7 @@ except ModuleNotFoundError:
# fw(" 'collapse_navigation': True,\n")
fw(" 'sticky_navigation': False,\n")
fw(" 'navigation_depth': 1,\n")
# fw(" 'includehidden': True,\n")
fw(" 'includehidden': False,\n")
# fw(" 'titles_only': False\n")
fw(" }\n\n")
@@ -1976,12 +1988,21 @@ def write_rst_index(basepath):
if not EXCLUDE_INFO_DOCS:
fw(".. toctree::\n")
if USE_INFO_DOCS_FANCY_INDEX:
fw(" :hidden:\n")
fw(" :maxdepth: 1\n")
fw(" :caption: Documentation\n\n")
for info, info_desc in INFO_DOCS:
fw(" %s <%s>\n" % (info_desc, info))
fw(" %s\n" % info)
fw("\n")
if USE_INFO_DOCS_FANCY_INDEX:
# Show a fake TOC, allowing for an extra description to be shown as well as the title.
fw(title_string("Documentation", "="))
for info, info_desc in INFO_DOCS:
fw("- :doc:`%s`: %s\n" % (info.removesuffix(".rst"), info_desc))
fw("\n")
fw(".. toctree::\n")
fw(" :maxdepth: 1\n")
fw(" :caption: Application Modules\n\n")
@@ -2314,6 +2335,8 @@ def copy_handwritten_rsts(basepath):
if not EXCLUDE_INFO_DOCS:
for info, _info_desc in INFO_DOCS:
shutil.copy2(os.path.join(RST_DIR, info), basepath)
for info in INFO_DOCS_OTHER:
shutil.copy2(os.path.join(RST_DIR, info), basepath)
# TODO: put this docs in Blender's code and use import as per modules above.
handwritten_modules = [

View File

@@ -3,9 +3,7 @@
# 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()
add_cxx_flag("-Wno-cast-function-type")
endif()
set(INC

View File

@@ -106,8 +106,7 @@
/* Copied from BLI_utils... */
/* C++ can't use _Static_assert, expects static_assert() but c++0x only,
* Coverity also errors out. */
#if (!defined(__cplusplus)) && (!defined(__COVERITY__)) && \
(defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) /* gcc4.6+ only */
#if (!defined(__cplusplus)) && (!defined(__COVERITY__)) && (defined(__GNUC__)) /* GCC only. */
# define ATOMIC_STATIC_ASSERT(a, msg) __extension__ _Static_assert(a, msg);
#else
/* Code adapted from http://www.pixelbeat.org/programming/gcc/static_assert.html */

View File

@@ -6,12 +6,8 @@
#include "testing/testing.h"
#ifdef __GNUC__
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 /* gcc4.6+ only */
# pragma GCC diagnostic error "-Wsign-compare"
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
# pragma GCC diagnostic error "-Wsign-conversion"
# endif
# pragma GCC diagnostic error "-Wsign-compare"
# pragma GCC diagnostic error "-Wsign-conversion"
#endif
/* -------------------------------------------------------------------- */

View File

@@ -36,7 +36,7 @@ if(WITH_CYCLES_NATIVE_ONLY)
)
if(NOT MSVC)
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_march_native "-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()
@@ -45,18 +45,18 @@ if(WITH_CYCLES_NATIVE_ONLY)
unset(_has_march_native)
else()
if(NOT MSVC_NATIVE_ARCH_FLAGS)
TRY_RUN(
arch_run_result
arch_compile_result
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/cmake/msvc_arch_flags.c
COMPILE_OUTPUT_VARIABLE arch_compile_output
RUN_OUTPUT_VARIABLE arch_run_output
)
if(arch_compile_result AND "${arch_run_result}" EQUAL "0")
string(STRIP ${arch_run_output} arch_run_output)
set(MSVC_NATIVE_ARCH_FLAGS ${arch_run_output} CACHE STRING "MSVC Native architecture flags")
endif()
try_run(
arch_run_result
arch_compile_result
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/cmake/msvc_arch_flags.c
COMPILE_OUTPUT_VARIABLE arch_compile_output
RUN_OUTPUT_VARIABLE arch_run_output
)
if(arch_compile_result AND "${arch_run_result}" EQUAL "0")
string(STRIP ${arch_run_output} arch_run_output)
set(MSVC_NATIVE_ARCH_FLAGS ${arch_run_output} CACHE STRING "MSVC Native architecture flags")
endif()
endif()
set(CYCLES_KERNEL_FLAGS "${MSVC_NATIVE_ARCH_FLAGS}")
endif()
@@ -347,6 +347,24 @@ if(WITH_OPENCOLORIO)
)
endif()
if(WITH_CYCLES_PATH_GUIDING)
add_definitions(-DWITH_PATH_GUIDING)
# The level of the guiding integration.
# Different levels can be selected to measure the overhead of different stages.
# 1 = recording the path segments
# 2 = 1 + generating (not storing) sample data from the segments
# 3 = 2 + storing the generates sample data
# 4 = 3 + training the guiding fields
# 5 = 4 + querying the trained guiding for sampling (full path guiding)
add_definitions(-DPATH_GUIDING_LEVEL=5)
include_directories(
SYSTEM
${OPENPGL_INCLUDE_DIR}
)
endif()
# NaN debugging
if(WITH_CYCLES_DEBUG_NAN)
add_definitions(-DWITH_CYCLES_DEBUG_NAN)
@@ -364,7 +382,7 @@ endif()
# Warnings
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")
add_check_cxx_compiler_flag(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")
unset(_has_no_error_unused_macros)
endif()

View File

@@ -7,8 +7,10 @@ set(INC
../../mikktspace
../../../source/blender/makesdna
../../../source/blender/makesrna
../../../source/blender/blenkernel
../../../source/blender/blenlib
../../../source/blender/gpu
../../../source/blender/render
${CMAKE_BINARY_DIR}/source/blender/makesrna/intern
)
@@ -64,6 +66,8 @@ set(LIB
cycles_subd
cycles_util
bf_intern_mikktspace
${Epoxy_LIBRARIES}
${PYTHON_LINKFLAGS}
${PYTHON_LIBRARIES}
@@ -100,6 +104,10 @@ if(WITH_MOD_FLUID)
add_definitions(-DWITH_FLUID)
endif()
if(WITH_TBB)
add_definitions(-DWITH_TBB)
endif()
if(WITH_OPENVDB)
add_definitions(-DWITH_OPENVDB ${OPENVDB_DEFINITIONS})
list(APPEND INC_SYS

View File

@@ -13,7 +13,7 @@ def _configure_argument_parser():
action='store_true')
parser.add_argument("--cycles-device",
help="Set the device to use for Cycles, overriding user preferences and the scene setting."
"Valid options are 'CPU', 'CUDA', 'OPTIX', 'HIP' or 'METAL'."
"Valid options are 'CPU', 'CUDA', 'OPTIX', 'HIP', 'ONEAPI', or 'METAL'."
"Additionally, you can append '+CPU' to any GPU type for hybrid rendering.",
default=None)
return parser
@@ -156,6 +156,11 @@ def with_osl():
return _cycles.with_osl
def with_path_guiding():
import _cycles
return _cycles.with_path_guiding
def system_info():
import _cycles
return _cycles.system_info()

View File

@@ -81,9 +81,8 @@ enum_use_layer_samples = (
)
enum_sampling_pattern = (
('SOBOL', "Sobol", "Use Sobol random sampling pattern", 0),
('SOBOL', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 0),
('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1),
('SOBOL_BURLEY', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 2),
)
enum_volume_sampling = (
@@ -180,6 +179,12 @@ enum_view3d_shading_render_pass = (
('SAMPLE_COUNT', "Sample Count", "Per-pixel number of samples"),
)
enum_guiding_distribution = (
('PARALLAX_AWARE_VMM', "Parallax-Aware VMM", "Use Parallax-aware von Mises-Fisher models as directional distribution", 0),
('DIRECTIONAL_QUAD_TREE', "Directional Quad Tree", "Use Directional Quad Trees as directional distribution", 1),
('VMM', "VMM", "Use von Mises-Fisher models as directional distribution", 2),
)
def enum_openimagedenoise_denoiser(self, context):
import _cycles
@@ -359,7 +364,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
preview_samples: IntProperty(
name="Viewport Samples",
description="Number of samples to render in the viewport, unlimited if 0",
min=0, max=(1 << 24),
min=0,
soft_min=1,
max=(1 << 24),
default=1024,
)
@@ -382,7 +389,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
sampling_pattern: EnumProperty(
name="Sampling Pattern",
description="Random sampling pattern used by the integrator. When adaptive sampling is enabled, Progressive Multi-Jitter is always used instead of Sobol",
description="Random sampling pattern used by the integrator. When adaptive sampling is enabled, Progressive Multi-Jitter is always used instead of Sobol-Burley",
items=enum_sampling_pattern,
default='PROGRESSIVE_MULTI_JITTER',
)
@@ -508,6 +515,78 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=1.0,
)
use_guiding: BoolProperty(
name="Guiding",
description="Use path guiding for sampling paths. Path guiding incrementally "
"learns the light distribution of the scene and guides path into directions "
"with high direct and indirect light contributions",
default=False,
)
use_deterministic_guiding: BoolProperty(
name="Deterministic",
description="Makes path guiding deterministic which means renderings will be "
"reproducible with the same pixel values every time. This feature slows down "
"training",
default=True,
)
guiding_distribution_type: EnumProperty(
name="Guiding Distribution Type",
description="Type of representation for the guiding distribution",
items=enum_guiding_distribution,
default='PARALLAX_AWARE_VMM',
)
use_surface_guiding: BoolProperty(
name="Surface Guiding",
description="Use guiding when sampling directions on a surface",
default=True,
)
surface_guiding_probability: FloatProperty(
name="Surface Guiding Probability",
description="The probability of guiding a direction on a surface",
min=0.0, max=1.0,
default=0.5,
)
use_volume_guiding: BoolProperty(
name="Volume Guiding",
description="Use guiding when sampling directions inside a volume",
default=True,
)
guiding_training_samples: IntProperty(
name="Training Samples",
description="The maximum number of samples used for training path guiding. "
"Higher samples lead to more accurate guiding, however may also unnecessarily slow "
"down rendering once guiding is accurate enough. "
"A value of 0 will continue training until the last sample",
min=0,
soft_min=1,
default=128,
)
volume_guiding_probability: FloatProperty(
name="Volume Guiding Probability",
description="The probability of guiding a direction inside a volume",
min=0.0, max=1.0,
default=0.5,
)
use_guiding_direct_light: BoolProperty(
name="Guide Direct Light",
description="Consider the contribution of directly visible light sources during guiding",
default=True,
)
use_guiding_mis_weights: BoolProperty(
name="Use MIS Weights",
description="Use the MIS weight to weight the contribution of directly visible light sources during guiding",
default=True,
)
max_bounces: IntProperty(
name="Max Bounces",
description="Total maximum number of bounces",
@@ -1559,9 +1638,9 @@ class CyclesPreferences(bpy.types.AddonPreferences):
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')
col.label(text="and Windows driver version 101.3430 or newer", icon='BLANK1')
elif sys.platform.startswith("linux"):
col.label(text="and Linux driver version xx.xx.23570 or newer", icon='BLANK1')
col.label(text="and Linux driver version xx.xx.23904 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')

View File

@@ -278,6 +278,63 @@ class CYCLES_RENDER_PT_sampling_render_denoise(CyclesButtonsPanel, Panel):
col.prop(cscene, "denoising_prefilter", text="Prefilter")
class CYCLES_RENDER_PT_sampling_path_guiding(CyclesButtonsPanel, Panel):
bl_label = "Path Guiding"
bl_parent_id = "CYCLES_RENDER_PT_sampling"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
from . import engine
return use_cpu(context) and engine.with_path_guiding()
def draw_header(self, context):
scene = context.scene
cscene = scene.cycles
self.layout.prop(cscene, "use_guiding", text="")
def draw(self, context):
scene = context.scene
cscene = scene.cycles
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
layout.active = cscene.use_guiding
col = layout.column(align=True)
col.prop(cscene, "use_surface_guiding")
col.prop(cscene, "use_volume_guiding")
col.prop(cscene, "guiding_training_samples")
class CYCLES_RENDER_PT_sampling_path_guiding_debug(CyclesDebugButtonsPanel, Panel):
bl_label = "Debug"
bl_parent_id = "CYCLES_RENDER_PT_sampling_path_guiding"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
scene = context.scene
cscene = scene.cycles
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
layout.active = cscene.use_guiding
layout.prop(cscene, "guiding_distribution_type", text="Distribution Type")
col = layout.column(align=True)
col.prop(cscene, "surface_guiding_probability")
col.prop(cscene, "volume_guiding_probability")
col = layout.column(align=True)
col.prop(cscene, "use_deterministic_guiding")
col.prop(cscene, "use_guiding_direct_light")
col.prop(cscene, "use_guiding_mis_weights")
class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "CYCLES_RENDER_PT_sampling"
@@ -296,7 +353,6 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
row.prop(cscene, "use_animated_seed", text="", icon='TIME')
col = layout.column(align=True)
col.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
col.prop(cscene, "sampling_pattern", text="Pattern")
col = layout.column(align=True)
@@ -305,6 +361,7 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
layout.separator()
heading = layout.column(align=True, heading="Scrambling Distance")
heading.active = cscene.sampling_pattern != 'SOBOL'
heading.prop(cscene, "auto_scrambling_distance", text="Automatic")
heading.prop(cscene, "preview_scrambling_distance", text="Viewport")
heading.prop(cscene, "scrambling_distance", text="Multiplier")
@@ -1823,6 +1880,12 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
layout.prop(rd, "use_bake_multires")
layout.prop(cscene, "bake_type")
if not rd.use_bake_multires and cscene.bake_type not in {
"AO", "POSITION", "NORMAL", "UV", "ROUGHNESS", "ENVIRONMENT"}:
row = layout.row()
row.prop(cbk, "view_from")
row.active = scene.camera is not None
class CYCLES_RENDER_PT_bake_influence(CyclesButtonsPanel, Panel):
bl_label = "Influence"
@@ -2286,6 +2349,8 @@ classes = (
CYCLES_RENDER_PT_sampling_viewport_denoise,
CYCLES_RENDER_PT_sampling_render,
CYCLES_RENDER_PT_sampling_render_denoise,
CYCLES_RENDER_PT_sampling_path_guiding,
CYCLES_RENDER_PT_sampling_path_guiding_debug,
CYCLES_RENDER_PT_sampling_advanced,
CYCLES_RENDER_PT_light_paths,
CYCLES_RENDER_PT_light_paths_max_bounces,

View File

@@ -2,6 +2,7 @@
* Copyright 2011-2022 Blender Foundation */
#include "scene/camera.h"
#include "scene/bake.h"
#include "scene/scene.h"
#include "blender/sync.h"
@@ -592,6 +593,11 @@ void BlenderSync::sync_camera(BL::RenderSettings &b_render,
blender_camera_from_object(&bcam, b_engine, b_ob);
b_engine.camera_model_matrix(b_ob, bcam.use_spherical_stereo, b_ob_matrix);
bcam.matrix = get_transform(b_ob_matrix);
scene->bake_manager->set_use_camera(b_render.bake().view_from() ==
BL::BakeSettings::view_from_ACTIVE_CAMERA);
}
else {
scene->bake_manager->set_use_camera(false);
}
/* sync */

View File

@@ -843,7 +843,7 @@ static float4 hair_point_as_float4(BL::FloatVectorAttribute b_attr_position,
const int index)
{
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;
mP.w = b_attr_radius ? b_attr_radius->data[index].value() : 0.005f;
return mP;
}
@@ -910,7 +910,7 @@ static void export_hair_curves(Scene *scene,
for (int j = 0; j < num_points; j++) {
const int point_offset = first_point_index + j;
const float3 co = get_float3(b_attr_position.data[point_offset].vector());
const float radius = b_attr_radius ? b_attr_radius->data[point_offset].value() : 0.0f;
const float radius = b_attr_radius ? b_attr_radius->data[point_offset].value() : 0.005f;
curve_keys[point_offset] = co;
curve_radius[point_offset] = radius;

View File

@@ -9,21 +9,7 @@
#include "GPU_platform.h"
extern "C" {
struct RenderEngine;
bool RE_engine_has_render_context(struct RenderEngine *engine);
void RE_engine_render_context_enable(struct RenderEngine *engine);
void RE_engine_render_context_disable(struct RenderEngine *engine);
bool DRW_opengl_context_release();
void DRW_opengl_context_activate(bool drw_state);
void *WM_opengl_context_create();
void WM_opengl_context_activate(void *gl_context);
void WM_opengl_context_dispose(void *gl_context);
void WM_opengl_context_release(void *context);
}
#include "RE_engine.h"
CCL_NAMESPACE_BEGIN
@@ -559,18 +545,21 @@ struct BlenderDisplayDriver::Tiles {
}
};
BlenderDisplayDriver::BlenderDisplayDriver(BL::RenderEngine &b_engine, BL::Scene &b_scene)
BlenderDisplayDriver::BlenderDisplayDriver(BL::RenderEngine &b_engine,
BL::Scene &b_scene,
const bool background)
: b_engine_(b_engine),
background_(background),
display_shader_(BlenderDisplayShader::create(b_engine, b_scene)),
tiles_(make_unique<Tiles>())
{
/* Create context while on the main thread. */
gl_context_create();
gpu_context_create();
}
BlenderDisplayDriver::~BlenderDisplayDriver()
{
gl_resources_destroy();
gpu_resources_destroy();
}
/* --------------------------------------------------------------------
@@ -601,12 +590,12 @@ bool BlenderDisplayDriver::update_begin(const Params &params,
/* Note that it's the responsibility of BlenderDisplayDriver to ensure updating and drawing
* the texture does not happen at the same time. This is achieved indirectly.
*
* When enabling the OpenGL context, it uses an internal mutex lock DST.gl_context_lock.
* When enabling the OpenGL context, it uses an internal mutex lock DST.gpu_context_lock.
* This same lock is also held when do_draw() is called, which together ensure mutual
* exclusion.
*
* This locking is not performed on the Cycles side, because that would cause lock inversion. */
if (!gl_context_enable()) {
if (!gpu_context_enable()) {
return false;
}
@@ -627,13 +616,13 @@ bool BlenderDisplayDriver::update_begin(const Params &params,
if (!tiles_->gl_resources_ensure()) {
tiles_->gl_resources_destroy();
gl_context_disable();
gpu_context_disable();
return false;
}
if (!tiles_->current_tile.gl_resources_ensure()) {
tiles_->current_tile.gl_resources_destroy();
gl_context_disable();
gpu_context_disable();
return false;
}
@@ -712,7 +701,7 @@ void BlenderDisplayDriver::update_end()
* On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
* renders while Blender is drawing. As a workaround update texture during draw, under assumption
* that there is no graphics interop on macOS and viewport render has a single tile. */
if (use_gl_context_ &&
if (!background_ &&
GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY)) {
tiles_->current_tile.need_update_texture_pixels = true;
}
@@ -723,7 +712,7 @@ void BlenderDisplayDriver::update_end()
gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
gl_context_disable();
gpu_context_disable();
}
/* --------------------------------------------------------------------
@@ -771,12 +760,12 @@ BlenderDisplayDriver::GraphicsInterop BlenderDisplayDriver::graphics_interop_get
void BlenderDisplayDriver::graphics_interop_activate()
{
gl_context_enable();
gpu_context_enable();
}
void BlenderDisplayDriver::graphics_interop_deactivate()
{
gl_context_disable();
gpu_context_disable();
}
/* --------------------------------------------------------------------
@@ -910,7 +899,7 @@ void BlenderDisplayDriver::flush()
* If we don't do this, the NVIDIA driver hangs for a few seconds for when ending 3D viewport
* rendering, for unknown reasons. This was found with NVIDIA driver version 470.73 and a Quadro
* RTX 6000 on Linux. */
if (!gl_context_enable()) {
if (!gpu_context_enable()) {
return;
}
@@ -922,15 +911,12 @@ void BlenderDisplayDriver::flush()
glWaitSync((GLsync)gl_render_sync_, 0, GL_TIMEOUT_IGNORED);
}
gl_context_disable();
gpu_context_disable();
}
void BlenderDisplayDriver::draw(const Params &params)
{
/* See do_update_begin() for why no locking is required here. */
if (use_gl_context_) {
gl_context_mutex_.lock();
}
gpu_context_lock();
if (need_clear_) {
/* Texture is requested to be cleared and was not yet cleared.
@@ -938,9 +924,7 @@ void BlenderDisplayDriver::draw(const Params &params)
* Do early return which should be equivalent of drawing all-zero texture.
* Watch out for the lock though so that the clear happening during update is properly
* synchronized here. */
if (use_gl_context_) {
gl_context_mutex_.unlock();
}
gpu_context_unlock();
return;
}
@@ -996,94 +980,55 @@ void BlenderDisplayDriver::draw(const Params &params)
gl_render_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
gpu_context_unlock();
VLOG_DEVICE_STATS << "Display driver number of textures: " << GLTexture::num_used;
VLOG_DEVICE_STATS << "Display driver number of PBOs: " << GLPixelBufferObject::num_used;
}
if (use_gl_context_) {
gl_context_mutex_.unlock();
void BlenderDisplayDriver::gpu_context_create()
{
if (!RE_engine_gpu_context_create(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data))) {
LOG(ERROR) << "Error creating OpenGL context.";
}
}
void BlenderDisplayDriver::gl_context_create()
bool BlenderDisplayDriver::gpu_context_enable()
{
/* When rendering in viewport there is no render context available via engine.
* Check whether own context is to be created here.
*
* NOTE: If the `b_engine_`'s context is not available, we are expected to be on a main thread
* here. */
use_gl_context_ = !RE_engine_has_render_context(
reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
if (use_gl_context_) {
const bool drw_state = DRW_opengl_context_release();
gl_context_ = WM_opengl_context_create();
if (gl_context_) {
/* On Windows an old context is restored after creation, and subsequent release of context
* generates a Win32 error. Harmless for users, but annoying to have possible misleading
* error prints in the console. */
#ifndef _WIN32
WM_opengl_context_release(gl_context_);
#endif
}
else {
LOG(ERROR) << "Error creating OpenGL context.";
}
DRW_opengl_context_activate(drw_state);
}
return RE_engine_gpu_context_enable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
}
bool BlenderDisplayDriver::gl_context_enable()
void BlenderDisplayDriver::gpu_context_disable()
{
if (use_gl_context_) {
if (!gl_context_) {
return false;
}
gl_context_mutex_.lock();
WM_opengl_context_activate(gl_context_);
return true;
}
RE_engine_render_context_enable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
return true;
RE_engine_gpu_context_disable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
}
void BlenderDisplayDriver::gl_context_disable()
void BlenderDisplayDriver::gpu_context_destroy()
{
if (use_gl_context_) {
if (gl_context_) {
WM_opengl_context_release(gl_context_);
gl_context_mutex_.unlock();
}
return;
}
RE_engine_render_context_disable(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
RE_engine_gpu_context_destroy(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
}
void BlenderDisplayDriver::gl_context_dispose()
void BlenderDisplayDriver::gpu_context_lock()
{
if (gl_context_) {
const bool drw_state = DRW_opengl_context_release();
WM_opengl_context_activate(gl_context_);
WM_opengl_context_dispose(gl_context_);
DRW_opengl_context_activate(drw_state);
}
RE_engine_gpu_context_lock(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
}
void BlenderDisplayDriver::gl_resources_destroy()
void BlenderDisplayDriver::gpu_context_unlock()
{
gl_context_enable();
RE_engine_gpu_context_unlock(reinterpret_cast<RenderEngine *>(b_engine_.ptr.data));
}
void BlenderDisplayDriver::gpu_resources_destroy()
{
gpu_context_enable();
tiles_->current_tile.gl_resources_destroy();
tiles_->finished_tiles.gl_resources_destroy_and_clear();
tiles_->gl_resources_destroy();
gl_context_disable();
gpu_context_disable();
gl_context_dispose();
gpu_context_destroy();
}
CCL_NAMESPACE_END

View File

@@ -89,7 +89,7 @@ class BlenderDisplaySpaceShader : public BlenderDisplayShader {
/* Display driver implementation which is specific for Blender viewport integration. */
class BlenderDisplayDriver : public DisplayDriver {
public:
BlenderDisplayDriver(BL::RenderEngine &b_engine, BL::Scene &b_scene);
BlenderDisplayDriver(BL::RenderEngine &b_engine, BL::Scene &b_scene, const bool background);
~BlenderDisplayDriver();
virtual void graphics_interop_activate() override;
@@ -115,23 +115,18 @@ class BlenderDisplayDriver : public DisplayDriver {
virtual void flush() override;
/* Helper function which allocates new GPU context. */
void gl_context_create();
bool gl_context_enable();
void gl_context_disable();
void gl_context_dispose();
void gpu_context_create();
bool gpu_context_enable();
void gpu_context_disable();
void gpu_context_destroy();
void gpu_context_lock();
void gpu_context_unlock();
/* Destroy all GPU resources which are being used by this object. */
void gl_resources_destroy();
void gpu_resources_destroy();
BL::RenderEngine b_engine_;
/* OpenGL context which is used the render engine doesn't have its own. */
void *gl_context_ = nullptr;
/* The when Blender RenderEngine side context is not available and the DisplayDriver is to create
* its own context. */
bool use_gl_context_ = false;
/* Mutex used to guard the `gl_context_`. */
thread_mutex gl_context_mutex_;
bool background_;
/* Content of the display is to be filled with zeroes. */
std::atomic<bool> need_clear_ = true;

View File

@@ -20,7 +20,7 @@ CCL_NAMESPACE_BEGIN
* Utility class to map between Blender datablocks and Cycles data structures,
* and keep track of recalc tags from the dependency graph. */
template<typename K, typename T> class id_map {
template<typename K, typename T, typename Flags = uint> class id_map {
public:
id_map(Scene *scene_) : scene(scene_)
{
@@ -63,6 +63,11 @@ template<typename K, typename T> class id_map {
b_recalc.insert(id_ptr);
}
bool check_recalc(const BL::ID &id)
{
return id.ptr.data && b_recalc.find(id.ptr.data) != b_recalc.end();
}
bool has_recalc()
{
return !(b_recalc.empty());
@@ -154,6 +159,7 @@ template<typename K, typename T> class id_map {
TMapPair &pair = *jt;
if (do_delete && used_set.find(pair.second) == used_set.end()) {
flags.erase(pair.second);
scene->delete_node(pair.second);
}
else {
@@ -171,9 +177,33 @@ template<typename K, typename T> class id_map {
return b_map;
}
bool test_flag(T *data, Flags val)
{
typename map<T *, uint>::iterator it = flags.find(data);
return it != flags.end() && (it->second & (1 << val)) != 0;
}
void set_flag(T *data, Flags val)
{
flags[data] |= (1 << val);
}
void clear_flag(T *data, Flags val)
{
typename map<T *, uint>::iterator it = flags.find(data);
if (it != flags.end()) {
it->second &= ~(1 << val);
if (it->second == 0) {
flags.erase(it);
}
}
}
protected:
map<K, T *> b_map;
set<T *> used_set;
map<T *, uint> flags;
set<void *> b_recalc;
Scene *scene;
};

View File

@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include <optional>
#include "blender/session.h"
#include "blender/sync.h"
#include "blender/util.h"
@@ -22,22 +24,23 @@
#include "util/log.h"
#include "util/math.h"
#include "mikktspace.h"
#include "mikktspace.hh"
#include "DNA_meshdata_types.h"
CCL_NAMESPACE_BEGIN
/* Tangent Space */
struct MikkUserData {
MikkUserData(const BL::Mesh &b_mesh,
const char *layer_name,
const Mesh *mesh,
float3 *tangent,
float *tangent_sign)
template<bool is_subd> struct MikkMeshWrapper {
MikkMeshWrapper(const BL::Mesh &b_mesh,
const char *layer_name,
const Mesh *mesh,
float3 *tangent,
float *tangent_sign)
: mesh(mesh), texface(NULL), orco(NULL), tangent(tangent), tangent_sign(tangent_sign)
{
const AttributeSet &attributes = (mesh->get_num_subd_faces()) ? mesh->subd_attributes :
mesh->attributes;
const AttributeSet &attributes = is_subd ? mesh->subd_attributes : mesh->attributes;
Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
vertex_normal = attr_vN->data_float3();
@@ -47,7 +50,9 @@ struct MikkUserData {
if (attr_orco) {
orco = attr_orco->data_float3();
float3 orco_size;
mesh_texture_space(*(BL::Mesh *)&b_mesh, orco_loc, orco_size);
inv_orco_size = 1.0f / orco_size;
}
}
else {
@@ -58,160 +63,126 @@ struct MikkUserData {
}
}
int GetNumFaces()
{
if constexpr (is_subd) {
return mesh->get_num_subd_faces();
}
else {
return mesh->num_triangles();
}
}
int GetNumVerticesOfFace(const int face_num)
{
if constexpr (is_subd) {
return mesh->get_subd_num_corners()[face_num];
}
else {
return 3;
}
}
int CornerIndex(const int face_num, const int vert_num)
{
if constexpr (is_subd) {
const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
return face.start_corner + vert_num;
}
else {
return face_num * 3 + vert_num;
}
}
int VertexIndex(const int face_num, const int vert_num)
{
int corner = CornerIndex(face_num, vert_num);
if constexpr (is_subd) {
return mesh->get_subd_face_corners()[corner];
}
else {
return mesh->get_triangles()[corner];
}
}
mikk::float3 GetPosition(const int face_num, const int vert_num)
{
const float3 vP = mesh->get_verts()[VertexIndex(face_num, vert_num)];
return mikk::float3(vP.x, vP.y, vP.z);
}
mikk::float3 GetTexCoord(const int face_num, const int vert_num)
{
/* TODO: Check whether introducing a template boolean in order to
* turn this into a constexpr is worth it. */
if (texface != NULL) {
const int corner_index = CornerIndex(face_num, vert_num);
float2 tfuv = texface[corner_index];
return mikk::float3(tfuv.x, tfuv.y, 1.0f);
}
else if (orco != NULL) {
const int vertex_index = VertexIndex(face_num, vert_num);
const float2 uv = map_to_sphere((orco[vertex_index] + orco_loc) * inv_orco_size);
return mikk::float3(uv.x, uv.y, 1.0f);
}
else {
return mikk::float3(0.0f, 0.0f, 1.0f);
}
}
mikk::float3 GetNormal(const int face_num, const int vert_num)
{
float3 vN;
if (is_subd) {
const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
if (face.smooth) {
const int vertex_index = VertexIndex(face_num, vert_num);
vN = vertex_normal[vertex_index];
}
else {
vN = face.normal(mesh);
}
}
else {
if (mesh->get_smooth()[face_num]) {
const int vertex_index = VertexIndex(face_num, vert_num);
vN = vertex_normal[vertex_index];
}
else {
const Mesh::Triangle tri = mesh->get_triangle(face_num);
vN = tri.compute_normal(&mesh->get_verts()[0]);
}
}
return mikk::float3(vN.x, vN.y, vN.z);
}
void SetTangentSpace(const int face_num, const int vert_num, mikk::float3 T, bool orientation)
{
const int corner_index = CornerIndex(face_num, vert_num);
tangent[corner_index] = make_float3(T.x, T.y, T.z);
if (tangent_sign != NULL) {
tangent_sign[corner_index] = orientation ? 1.0f : -1.0f;
}
}
const Mesh *mesh;
int num_faces;
float3 *vertex_normal;
float2 *texface;
float3 *orco;
float3 orco_loc, orco_size;
float3 orco_loc, inv_orco_size;
float3 *tangent;
float *tangent_sign;
};
static int mikk_get_num_faces(const SMikkTSpaceContext *context)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
if (userdata->mesh->get_num_subd_faces()) {
return userdata->mesh->get_num_subd_faces();
}
else {
return userdata->mesh->num_triangles();
}
}
static int mikk_get_num_verts_of_face(const SMikkTSpaceContext *context, const int face_num)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
if (userdata->mesh->get_num_subd_faces()) {
const Mesh *mesh = userdata->mesh;
return mesh->get_subd_num_corners()[face_num];
}
else {
return 3;
}
}
static int mikk_vertex_index(const Mesh *mesh, const int face_num, const int vert_num)
{
if (mesh->get_num_subd_faces()) {
const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
return mesh->get_subd_face_corners()[face.start_corner + vert_num];
}
else {
return mesh->get_triangles()[face_num * 3 + vert_num];
}
}
static int mikk_corner_index(const Mesh *mesh, const int face_num, const int vert_num)
{
if (mesh->get_num_subd_faces()) {
const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
return face.start_corner + vert_num;
}
else {
return face_num * 3 + vert_num;
}
}
static void mikk_get_position(const SMikkTSpaceContext *context,
float P[3],
const int face_num,
const int vert_num)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
const float3 vP = mesh->get_verts()[vertex_index];
P[0] = vP.x;
P[1] = vP.y;
P[2] = vP.z;
}
static void mikk_get_texture_coordinate(const SMikkTSpaceContext *context,
float uv[2],
const int face_num,
const int vert_num)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
if (userdata->texface != NULL) {
const int corner_index = mikk_corner_index(mesh, face_num, vert_num);
float2 tfuv = userdata->texface[corner_index];
uv[0] = tfuv.x;
uv[1] = tfuv.y;
}
else if (userdata->orco != NULL) {
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
const float3 orco_loc = userdata->orco_loc;
const float3 orco_size = userdata->orco_size;
const float3 orco = (userdata->orco[vertex_index] + orco_loc) / orco_size;
const float2 tmp = map_to_sphere(orco);
uv[0] = tmp.x;
uv[1] = tmp.y;
}
else {
uv[0] = 0.0f;
uv[1] = 0.0f;
}
}
static void mikk_get_normal(const SMikkTSpaceContext *context,
float N[3],
const int face_num,
const int vert_num)
{
const MikkUserData *userdata = (const MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
float3 vN;
if (mesh->get_num_subd_faces()) {
const Mesh::SubdFace &face = mesh->get_subd_face(face_num);
if (face.smooth) {
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
vN = userdata->vertex_normal[vertex_index];
}
else {
vN = face.normal(mesh);
}
}
else {
if (mesh->get_smooth()[face_num]) {
const int vertex_index = mikk_vertex_index(mesh, face_num, vert_num);
vN = userdata->vertex_normal[vertex_index];
}
else {
const Mesh::Triangle tri = mesh->get_triangle(face_num);
vN = tri.compute_normal(&mesh->get_verts()[0]);
}
}
N[0] = vN.x;
N[1] = vN.y;
N[2] = vN.z;
}
static void mikk_set_tangent_space(const SMikkTSpaceContext *context,
const float T[],
const float sign,
const int face_num,
const int vert_num)
{
MikkUserData *userdata = (MikkUserData *)context->m_pUserData;
const Mesh *mesh = userdata->mesh;
const int corner_index = mikk_corner_index(mesh, face_num, vert_num);
userdata->tangent[corner_index] = make_float3(T[0], T[1], T[2]);
if (userdata->tangent_sign != NULL) {
userdata->tangent_sign[corner_index] = sign;
}
}
static void mikk_compute_tangents(
const BL::Mesh &b_mesh, const char *layer_name, Mesh *mesh, bool need_sign, bool active_render)
{
/* Create tangent attributes. */
AttributeSet &attributes = (mesh->get_num_subd_faces()) ? mesh->subd_attributes :
mesh->attributes;
const bool is_subd = mesh->get_num_subd_faces();
AttributeSet &attributes = is_subd ? mesh->subd_attributes : mesh->attributes;
Attribute *attr;
ustring name;
if (layer_name != NULL) {
@@ -247,24 +218,18 @@ static void mikk_compute_tangents(
}
tangent_sign = attr_sign->data_float();
}
/* Setup userdata. */
MikkUserData userdata(b_mesh, layer_name, mesh, tangent, tangent_sign);
/* Setup interface. */
SMikkTSpaceInterface sm_interface;
memset(&sm_interface, 0, sizeof(sm_interface));
sm_interface.m_getNumFaces = mikk_get_num_faces;
sm_interface.m_getNumVerticesOfFace = mikk_get_num_verts_of_face;
sm_interface.m_getPosition = mikk_get_position;
sm_interface.m_getTexCoord = mikk_get_texture_coordinate;
sm_interface.m_getNormal = mikk_get_normal;
sm_interface.m_setTSpaceBasic = mikk_set_tangent_space;
/* Setup context. */
SMikkTSpaceContext context;
memset(&context, 0, sizeof(context));
context.m_pUserData = &userdata;
context.m_pInterface = &sm_interface;
/* Compute tangents. */
genTangSpaceDefault(&context);
if (is_subd) {
MikkMeshWrapper<true> userdata(b_mesh, layer_name, mesh, tangent, tangent_sign);
/* Compute tangents. */
mikk::Mikktspace(userdata).genTangSpace();
}
else {
MikkMeshWrapper<false> userdata(b_mesh, layer_name, mesh, tangent, tangent_sign);
/* Compute tangents. */
mikk::Mikktspace(userdata).genTangSpace();
}
}
template<typename TypeInCycles, typename GetValueAtIndex>
@@ -277,10 +242,15 @@ static void fill_generic_attribute(BL::Mesh &b_mesh,
switch (b_domain) {
case BL::Attribute::domain_CORNER: {
if (subdivision) {
for (BL::MeshPolygon &p : b_mesh.polygons) {
int n = p.loop_total();
for (int i = 0; i < n; i++) {
*data = get_value_at_index(p.loop_start() + i);
const int polys_num = b_mesh.polygons.length();
if (polys_num == 0) {
return;
}
const MPoly *polys = static_cast<const MPoly *>(b_mesh.polygons[0].ptr.data);
for (int i = 0; i < polys_num; i++) {
const MPoly &b_poly = polys[i];
for (int j = 0; j < b_poly.totloop; j++) {
*data = get_value_at_index(b_poly.loopstart + j);
data++;
}
}
@@ -297,27 +267,32 @@ static void fill_generic_attribute(BL::Mesh &b_mesh,
break;
}
case BL::Attribute::domain_EDGE: {
const size_t edges_num = b_mesh.edges.length();
if (edges_num == 0) {
return;
}
if constexpr (std::is_same_v<TypeInCycles, uchar4>) {
/* uchar4 edge attributes do not exist, and averaging in place
* would not work. */
assert(0);
}
else {
const MEdge *edges = static_cast<const MEdge *>(b_mesh.edges[0].ptr.data);
const size_t verts_num = b_mesh.vertices.length();
vector<int> count(verts_num, 0);
/* Average edge attributes at vertices. */
const size_t num_verts = b_mesh.vertices.length();
vector<int> count(num_verts, 0);
for (int i = 0; i < edges_num; i++) {
TypeInCycles value = get_value_at_index(i);
for (BL::MeshEdge &e : b_mesh.edges) {
BL::Array<int, 2> vertices = e.vertices();
TypeInCycles value = get_value_at_index(e.index());
data[vertices[0]] += value;
data[vertices[1]] += value;
count[vertices[0]]++;
count[vertices[1]]++;
const MEdge &b_edge = edges[i];
data[b_edge.v1] += value;
data[b_edge.v2] += value;
count[b_edge.v1]++;
count[b_edge.v2]++;
}
for (size_t i = 0; i < num_verts; i++) {
for (size_t i = 0; i < verts_num; i++) {
if (count[i] > 1) {
data[i] /= (float)count[i];
}
@@ -601,6 +576,12 @@ static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh)
static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, bool subdivide_uvs)
{
const int polys_num = b_mesh.polygons.length();
if (polys_num == 0) {
return;
}
const MPoly *polys = static_cast<const MPoly *>(b_mesh.polygons[0].ptr.data);
if (!b_mesh.uv_layers.empty()) {
BL::Mesh::uv_layers_iterator l;
int i = 0;
@@ -634,10 +615,10 @@ static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh,
float2 *fdata = uv_attr->data_float2();
for (BL::MeshPolygon &p : b_mesh.polygons) {
int n = p.loop_total();
for (int j = 0; j < n; j++) {
*(fdata++) = get_float2(l->data[p.loop_start() + j].uv());
for (int i = 0; i < polys_num; i++) {
const MPoly &b_poly = polys[i];
for (int j = 0; j < b_poly.totloop; j++) {
*(fdata++) = get_float2(l->data[b_poly.loopstart + j].uv());
}
}
}
@@ -700,6 +681,8 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
if (num_verts == 0) {
return;
}
const MVert *verts = static_cast<const MVert *>(b_mesh.vertices[0].ptr.data);
/* STEP 1: Find out duplicated vertices and point duplicates to a single
* original vertex.
*/
@@ -752,10 +735,12 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
*/
vector<float3> vert_normal(num_verts, zero_float3());
/* First we accumulate all vertex normals in the original index. */
const float(*b_vert_normals)[3] = static_cast<const float(*)[3]>(
b_mesh.vertex_normals[0].ptr.data);
for (int vert_index = 0; vert_index < num_verts; ++vert_index) {
const float3 normal = get_float3(b_mesh.vertices[vert_index].normal());
const float *b_vert_normal = b_vert_normals[vert_index];
const int orig_index = vert_orig_index[vert_index];
vert_normal[orig_index] += normal;
vert_normal[orig_index] += make_float3(b_vert_normal[0], b_vert_normal[1], b_vert_normal[2]);
}
/* Then we normalize the accumulated result and flush it to all duplicates
* as well.
@@ -768,18 +753,24 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
vector<int> counter(num_verts, 0);
vector<float> raw_data(num_verts, 0.0f);
vector<float3> edge_accum(num_verts, zero_float3());
BL::Mesh::edges_iterator e;
EdgeMap visited_edges;
int edge_index = 0;
memset(&counter[0], 0, sizeof(int) * counter.size());
for (b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++edge_index) {
const int v0 = vert_orig_index[b_mesh.edges[edge_index].vertices()[0]],
v1 = vert_orig_index[b_mesh.edges[edge_index].vertices()[1]];
const MEdge *edges = static_cast<MEdge *>(b_mesh.edges[0].ptr.data);
const int edges_num = b_mesh.edges.length();
for (int i = 0; i < edges_num; i++) {
const MEdge &b_edge = edges[i];
const int v0 = vert_orig_index[b_edge.v1];
const int v1 = vert_orig_index[b_edge.v2];
if (visited_edges.exists(v0, v1)) {
continue;
}
visited_edges.insert(v0, v1);
float3 co0 = get_float3(b_mesh.vertices[v0].co()), co1 = get_float3(b_mesh.vertices[v1].co());
const MVert &b_vert_0 = verts[v0];
const MVert &b_vert_1 = verts[v1];
float3 co0 = make_float3(b_vert_0.co[0], b_vert_0.co[1], b_vert_0.co[2]);
float3 co1 = make_float3(b_vert_1.co[0], b_vert_1.co[1], b_vert_1.co[2]);
float3 edge = normalize(co1 - co0);
edge_accum[v0] += edge;
edge_accum[v1] += -edge;
@@ -807,11 +798,11 @@ static void attr_create_pointiness(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, b
float *data = attr->data_float();
memcpy(data, &raw_data[0], sizeof(float) * raw_data.size());
memset(&counter[0], 0, sizeof(int) * counter.size());
edge_index = 0;
visited_edges.clear();
for (b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++edge_index) {
const int v0 = vert_orig_index[b_mesh.edges[edge_index].vertices()[0]],
v1 = vert_orig_index[b_mesh.edges[edge_index].vertices()[1]];
for (int i = 0; i < edges_num; i++) {
const MEdge &b_edge = edges[i];
const int v0 = vert_orig_index[b_edge.v1];
const int v1 = vert_orig_index[b_edge.v2];
if (visited_edges.exists(v0, v1)) {
continue;
}
@@ -850,6 +841,7 @@ static void attr_create_random_per_island(Scene *scene,
return;
}
const int polys_num = b_mesh.polygons.length();
int number_of_vertices = b_mesh.vertices.length();
if (number_of_vertices == 0) {
return;
@@ -857,8 +849,11 @@ static void attr_create_random_per_island(Scene *scene,
DisjointSet vertices_sets(number_of_vertices);
for (BL::MeshEdge &e : b_mesh.edges) {
vertices_sets.join(e.vertices()[0], e.vertices()[1]);
const MEdge *edges = static_cast<MEdge *>(b_mesh.edges[0].ptr.data);
const int edges_num = b_mesh.edges.length();
for (int i = 0; i < edges_num; i++) {
vertices_sets.join(edges[i].v1, edges[i].v2);
}
AttributeSet &attributes = (subdivision) ? mesh->subd_attributes : mesh->attributes;
@@ -871,14 +866,37 @@ static void attr_create_random_per_island(Scene *scene,
}
}
else {
for (BL::MeshPolygon &p : b_mesh.polygons) {
data[p.index()] = hash_uint_to_float(vertices_sets.find(p.vertices()[0]));
if (polys_num != 0) {
const MPoly *polys = static_cast<const MPoly *>(b_mesh.polygons[0].ptr.data);
const MLoop *loops = static_cast<const MLoop *>(b_mesh.loops[0].ptr.data);
for (int i = 0; i < polys_num; i++) {
const MPoly &b_poly = polys[i];
const MLoop &b_loop = loops[b_poly.loopstart];
data[i] = hash_uint_to_float(vertices_sets.find(b_loop.v));
}
}
}
}
/* Create Mesh */
static std::optional<BL::IntAttribute> find_material_index_attribute(BL::Mesh b_mesh)
{
for (BL::Attribute &b_attribute : b_mesh.attributes) {
if (b_attribute.domain() != BL::Attribute::domain_FACE) {
continue;
}
if (b_attribute.data_type() != BL::Attribute::data_type_INT) {
continue;
}
if (b_attribute.name() != "material_index") {
continue;
}
return BL::IntAttribute{b_attribute};
}
return std::nullopt;
}
static void create_mesh(Scene *scene,
Mesh *mesh,
BL::Mesh &b_mesh,
@@ -890,6 +908,7 @@ static void create_mesh(Scene *scene,
{
/* count vertices and faces */
int numverts = b_mesh.vertices.length();
const int polys_num = b_mesh.polygons.length();
int numfaces = (!subdivision) ? b_mesh.loop_triangles.length() : b_mesh.polygons.length();
int numtris = 0;
int numcorners = 0;
@@ -902,13 +921,17 @@ static void create_mesh(Scene *scene,
return;
}
const MVert *verts = static_cast<const MVert *>(b_mesh.vertices[0].ptr.data);
if (!subdivision) {
numtris = numfaces;
}
else {
for (BL::MeshPolygon &p : b_mesh.polygons) {
numngons += (p.loop_total() == 4) ? 0 : 1;
numcorners += p.loop_total();
const MPoly *polys = static_cast<const MPoly *>(b_mesh.polygons[0].ptr.data);
for (int i = 0; i < polys_num; i++) {
const MPoly &b_poly = polys[i];
numngons += (b_poly.totloop == 4) ? 0 : 1;
numcorners += b_poly.totloop;
}
}
@@ -920,17 +943,23 @@ static void create_mesh(Scene *scene,
mesh->reserve_mesh(numverts, numtris);
/* create vertex coordinates and normals */
BL::Mesh::vertices_iterator v;
for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
mesh->add_vertex(get_float3(v->co()));
for (int i = 0; i < numverts; i++) {
const MVert &b_vert = verts[i];
mesh->add_vertex(make_float3(b_vert.co[0], b_vert.co[1], b_vert.co[2]));
}
AttributeSet &attributes = (subdivision) ? mesh->subd_attributes : mesh->attributes;
Attribute *attr_N = attributes.add(ATTR_STD_VERTEX_NORMAL);
float3 *N = attr_N->data_float3();
for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N)
*N = get_float3(v->normal());
N = attr_N->data_float3();
if (subdivision || !use_loop_normals) {
const float(*b_vert_normals)[3] = static_cast<const float(*)[3]>(
b_mesh.vertex_normals[0].ptr.data);
for (int i = 0; i < numverts; i++) {
const float *b_vert_normal = b_vert_normals[i];
N[i] = make_float3(b_vert_normal[0], b_vert_normal[1], b_vert_normal[2]);
}
}
/* create generated coordinates from undeformed coordinates */
const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.empty()) &&
@@ -945,19 +974,30 @@ static void create_mesh(Scene *scene,
float3 *generated = attr->data_float3();
size_t i = 0;
BL::Mesh::vertices_iterator v;
for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v) {
generated[i++] = get_float3(v->undeformed_co()) * size - loc;
}
}
std::optional<BL::IntAttribute> material_indices = find_material_index_attribute(b_mesh);
auto get_material_index = [&](const int poly_index) -> int {
if (material_indices) {
return clamp(material_indices->data[poly_index].value(), 0, used_shaders.size() - 1);
}
return 0;
};
/* create faces */
const MPoly *polys = static_cast<const MPoly *>(b_mesh.polygons[0].ptr.data);
if (!subdivision) {
for (BL::MeshLoopTriangle &t : b_mesh.loop_triangles) {
BL::MeshPolygon p = b_mesh.polygons[t.polygon_index()];
const int poly_index = t.polygon_index();
const MPoly &b_poly = polys[poly_index];
int3 vi = get_int3(t.vertices());
int shader = clamp(p.material_index(), 0, used_shaders.size() - 1);
bool smooth = p.use_smooth() || use_loop_normals;
int shader = get_material_index(poly_index);
bool smooth = (b_poly.flag & ME_SMOOTH) || use_loop_normals;
if (use_loop_normals) {
BL::Array<float, 9> loop_normals = t.split_normals();
@@ -977,15 +1017,19 @@ static void create_mesh(Scene *scene,
else {
vector<int> vi;
for (BL::MeshPolygon &p : b_mesh.polygons) {
int n = p.loop_total();
int shader = clamp(p.material_index(), 0, used_shaders.size() - 1);
bool smooth = p.use_smooth() || use_loop_normals;
const MLoop *loops = static_cast<const MLoop *>(b_mesh.loops[0].ptr.data);
for (int i = 0; i < numfaces; i++) {
const MPoly &b_poly = polys[i];
int n = b_poly.totloop;
int shader = get_material_index(i);
bool smooth = (b_poly.flag & ME_SMOOTH) || use_loop_normals;
vi.resize(n);
for (int i = 0; i < n; i++) {
/* NOTE: Autosmooth is already taken care about. */
vi[i] = b_mesh.loops[p.loop_start() + i].vertex_index();
vi[i] = loops[b_poly.loopstart + i].v;
}
/* create subd faces */
@@ -1038,27 +1082,33 @@ static void create_subd_mesh(Scene *scene,
create_mesh(scene, mesh, b_mesh, used_shaders, need_motion, motion_scale, true, subdivide_uvs);
/* export creases */
size_t num_creases = 0;
const int edges_num = b_mesh.edges.length();
for (BL::MeshEdge &e : b_mesh.edges) {
if (e.crease() != 0.0f) {
num_creases++;
if (edges_num != 0 && b_mesh.edge_creases.length() > 0) {
size_t num_creases = 0;
const float *creases = static_cast<float *>(b_mesh.edge_creases[0].ptr.data);
for (int i = 0; i < edges_num; i++) {
if (creases[i] != 0.0f) {
num_creases++;
}
}
}
mesh->reserve_subd_creases(num_creases);
mesh->reserve_subd_creases(num_creases);
for (BL::MeshEdge &e : b_mesh.edges) {
if (e.crease() != 0.0f) {
mesh->add_edge_crease(e.vertices()[0], e.vertices()[1], e.crease());
const MEdge *edges = static_cast<MEdge *>(b_mesh.edges[0].ptr.data);
for (int i = 0; i < edges_num; i++) {
if (creases[i] != 0.0f) {
const MEdge &b_edge = edges[i];
mesh->add_edge_crease(b_edge.v1, b_edge.v2, creases[i]);
}
}
}
for (BL::MeshVertexCreaseLayer &c : b_mesh.vertex_creases) {
for (int i = 0; i < c.data.length(); ++i) {
if (c.data[i].value() != 0.0f) {
mesh->add_vertex_crease(i, c.data[i].value());
for (BL::MeshVertexCreaseLayer &c : b_mesh.vertex_creases) {
for (int i = 0; i < c.data.length(); ++i) {
if (c.data[i].value() != 0.0f) {
mesh->add_vertex_crease(i, c.data[i].value());
}
}
}
}
@@ -1179,6 +1229,12 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
/* TODO(sergey): Perform preliminary check for number of vertices. */
if (b_mesh) {
const int b_verts_num = b_mesh.vertices.length();
if (b_verts_num == 0) {
free_object_to_mesh(b_data, b_ob_info, b_mesh);
return;
}
/* Export deformed coordinates. */
/* Find attributes. */
Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
@@ -1196,22 +1252,30 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
/* Load vertex data from mesh. */
float3 *mP = attr_mP->data_float3() + motion_step * numverts;
float3 *mN = (attr_mN) ? attr_mN->data_float3() + motion_step * numverts : NULL;
const MVert *verts = static_cast<const MVert *>(b_mesh.vertices[0].ptr.data);
/* NOTE: We don't copy more that existing amount of vertices to prevent
* possible memory corruption.
*/
BL::Mesh::vertices_iterator v;
int i = 0;
for (b_mesh.vertices.begin(v); v != b_mesh.vertices.end() && i < numverts; ++v, ++i) {
mP[i] = get_float3(v->co());
if (mN)
mN[i] = get_float3(v->normal());
for (int i = 0; i < std::min<size_t>(b_verts_num, numverts); i++) {
const MVert &b_vert = verts[i];
mP[i] = make_float3(b_vert.co[0], b_vert.co[1], b_vert.co[2]);
}
if (mN) {
const float(*b_vert_normals)[3] = static_cast<const float(*)[3]>(
b_mesh.vertex_normals[0].ptr.data);
for (int i = 0; i < std::min<size_t>(b_verts_num, numverts); i++) {
const float *b_vert_normal = b_vert_normals[i];
mN[i] = make_float3(b_vert_normal[0], b_vert_normal[1], b_vert_normal[2]);
}
}
if (new_attribute) {
/* In case of new attribute, we verify if there really was any motion. */
if (b_mesh.vertices.length() != numverts ||
if (b_verts_num != numverts ||
memcmp(mP, &mesh->get_verts()[0], sizeof(float3) * numverts) == 0) {
/* no motion, remove attributes again */
if (b_mesh.vertices.length() != numverts) {
if (b_verts_num != numverts) {
VLOG_WARNING << "Topology differs, disabling motion blur for object " << ob_name;
}
else {
@@ -1235,7 +1299,7 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph,
}
}
else {
if (b_mesh.vertices.length() != numverts) {
if (b_verts_num != numverts) {
VLOG_WARNING << "Topology differs, discarding motion blur for object " << ob_name
<< " at time " << motion_step;
memcpy(mP, &mesh->get_verts()[0], sizeof(float3) * numverts);

View File

@@ -23,6 +23,8 @@
#include "util/log.h"
#include "util/task.h"
#include "BKE_duplilist.h"
CCL_NAMESPACE_BEGIN
/* Utilities */
@@ -94,6 +96,13 @@ bool BlenderSync::object_is_light(BL::Object &b_ob)
return (b_ob_data && b_ob_data.is_a(&RNA_Light));
}
bool BlenderSync::object_is_camera(BL::Object &b_ob)
{
BL::ID b_ob_data = b_ob.data();
return (b_ob_data && b_ob_data.is_a(&RNA_Camera));
}
void BlenderSync::sync_object_motion_init(BL::Object &b_parent, BL::Object &b_ob, Object *object)
{
/* Initialize motion blur for object, detecting if it's enabled and creating motion
@@ -353,79 +362,26 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
return object;
}
/* This function mirrors drw_uniform_property_lookup in draw_instance_data.cpp */
static bool lookup_property(BL::ID b_id, const string &name, float4 *r_value)
{
PointerRNA ptr;
PropertyRNA *prop;
extern "C" DupliObject *rna_hack_DepsgraphObjectInstance_dupli_object_get(PointerRNA *ptr);
if (!RNA_path_resolve(&b_id.ptr, name.c_str(), &ptr, &prop)) {
return false;
}
if (prop == NULL) {
return false;
}
PropertyType type = RNA_property_type(prop);
int arraylen = RNA_property_array_length(&ptr, prop);
if (arraylen == 0) {
float value;
if (type == PROP_FLOAT)
value = RNA_property_float_get(&ptr, prop);
else if (type == PROP_INT)
value = static_cast<float>(RNA_property_int_get(&ptr, prop));
else
return false;
*r_value = make_float4(value, value, value, 1.0f);
return true;
}
else if (type == PROP_FLOAT && arraylen <= 4) {
*r_value = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
RNA_property_float_get_array(&ptr, prop, &r_value->x);
return true;
}
return false;
}
/* This function mirrors drw_uniform_attribute_lookup in draw_instance_data.cpp */
static float4 lookup_instance_property(BL::DepsgraphObjectInstance &b_instance,
const string &name,
bool use_instancer)
{
string idprop_name = string_printf("[\"%s\"]", name.c_str());
float4 value;
::Object *ob = (::Object *)b_instance.object().ptr.data;
::DupliObject *dupli = nullptr;
::Object *dupli_parent = nullptr;
/* If requesting instance data, check the parent particle system and object. */
if (use_instancer && b_instance.is_instance()) {
BL::ParticleSystem b_psys = b_instance.particle_system();
if (b_psys) {
if (lookup_property(b_psys.settings(), idprop_name, &value) ||
lookup_property(b_psys.settings(), name, &value)) {
return value;
}
}
if (lookup_property(b_instance.parent(), idprop_name, &value) ||
lookup_property(b_instance.parent(), name, &value)) {
return value;
}
dupli = rna_hack_DepsgraphObjectInstance_dupli_object_get(&b_instance.ptr);
dupli_parent = (::Object *)b_instance.parent().ptr.data;
}
/* Check the object and mesh. */
BL::Object b_ob = b_instance.object();
BL::ID b_data = b_ob.data();
float4 value;
BKE_object_dupli_find_rgba_attribute(ob, dupli, dupli_parent, name.c_str(), &value.x);
if (lookup_property(b_ob, idprop_name, &value) || lookup_property(b_ob, name, &value) ||
lookup_property(b_data, idprop_name, &value) || lookup_property(b_data, name, &value)) {
return value;
}
return zero_float4();
return value;
}
bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object)
@@ -451,7 +407,8 @@ bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance
std::string real_name;
BlenderAttributeType type = blender_attribute_name_split_type(name, &real_name);
if (type != BL::ShaderNodeAttribute::attribute_type_GEOMETRY) {
if (type == BL::ShaderNodeAttribute::attribute_type_OBJECT ||
type == BL::ShaderNodeAttribute::attribute_type_INSTANCER) {
bool use_instancer = (type == BL::ShaderNodeAttribute::attribute_type_INSTANCER);
float4 value = lookup_instance_property(b_instance, real_name, use_instancer);

View File

@@ -194,7 +194,7 @@ static void export_pointcloud(Scene *scene,
/* Export points. */
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;
const float radius = b_attr_radius ? b_attr_radius->data[i].value() : 0.01f;
pointcloud->add_point(co, radius);
/* Random number per point. */
@@ -224,27 +224,24 @@ static void export_pointcloud_motion(PointCloud *pointcloud,
const int num_points = pointcloud->num_points();
float3 *mP = attr_mP->data_float3() + motion_step * num_points;
bool have_motion = false;
int num_motion_points = 0;
const array<float3> &pointcloud_points = pointcloud->get_points();
const int b_points_num = b_pointcloud.points.length();
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) {
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++;
}
for (int i = 0; i < std::min(num_points, b_points_num); 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;
float3 P = co;
P.w = radius;
mP[i] = P;
have_motion = have_motion || (P != pointcloud_points[i]);
}
/* In case of new attribute, we verify if there really was any motion. */
if (new_attribute) {
if (num_motion_points != num_points || !have_motion) {
if (b_points_num != num_points || !have_motion) {
pointcloud->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
}
else if (motion_step > 0) {

View File

@@ -15,6 +15,7 @@
#include "util/debug.h"
#include "util/foreach.h"
#include "util/guiding.h"
#include "util/log.h"
#include "util/md5.h"
#include "util/opengl.h"
@@ -534,7 +535,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
socket_type = "NodeSocketBool";
data_type = BL::NodeSocket::type_BOOLEAN;
if (param->validdefault) {
default_boolean = (bool)param->idefault[0];
default_boolean = bool(param->idefault[0]);
}
}
else {
@@ -1008,6 +1009,15 @@ void *CCL_python_module_init()
PyModule_AddStringConstant(mod, "osl_version_string", "unknown");
#endif
if (ccl::guiding_supported()) {
PyModule_AddObject(mod, "with_path_guiding", Py_True);
Py_INCREF(Py_True);
}
else {
PyModule_AddObject(mod, "with_path_guiding", Py_False);
Py_INCREF(Py_False);
}
#ifdef WITH_EMBREE
PyModule_AddObject(mod, "with_embree", Py_True);
Py_INCREF(Py_True);

View File

@@ -60,7 +60,8 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
height(0),
preview_osl(preview_osl),
python_thread_state(NULL),
use_developer_ui(false)
use_developer_ui(b_userpref.experimental().use_cycles_debug() &&
b_userpref.view().show_developer_ui())
{
/* offline render */
background = true;
@@ -659,6 +660,7 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
session->set_display_driver(nullptr);
session->set_output_driver(make_unique<BlenderOutputDriver>(b_engine));
session->full_buffer_written_cb = [&](string_view filename) { full_buffer_written(filename); };
/* Sync scene. */
BL::Object b_camera_override(b_engine.camera_override());
@@ -700,6 +702,10 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
BufferParams buffer_params;
buffer_params.width = bake_width;
buffer_params.height = bake_height;
buffer_params.window_width = bake_width;
buffer_params.window_height = bake_height;
/* Unique layer name for multi-image baking. */
buffer_params.layer = string_printf("bake_%d\n", bake_id++);
/* Update session. */
session->reset(session_params, buffer_params);
@@ -713,8 +719,6 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
session->start();
session->wait();
}
session->set_output_driver(nullptr);
}
void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_)
@@ -1059,8 +1063,8 @@ void BlenderSession::ensure_display_driver_if_needed()
return;
}
unique_ptr<BlenderDisplayDriver> display_driver = make_unique<BlenderDisplayDriver>(b_engine,
b_scene);
unique_ptr<BlenderDisplayDriver> display_driver = make_unique<BlenderDisplayDriver>(
b_engine, b_scene, background);
display_driver_ = display_driver.get();
session->set_display_driver(move(display_driver));
}

View File

@@ -146,6 +146,8 @@ class BlenderSession {
BlenderDisplayDriver *display_driver_ = nullptr;
vector<string> full_buffer_files_;
int bake_id = 0;
};
CCL_NAMESPACE_END

View File

@@ -22,6 +22,8 @@
#include "util/string.h"
#include "util/task.h"
#include "BKE_duplilist.h"
CCL_NAMESPACE_BEGIN
typedef map<void *, ShaderInput *> PtrInputMap;
@@ -103,6 +105,7 @@ static ImageAlphaType get_image_alpha_type(BL::Image &b_image)
static const string_view object_attr_prefix("\x01object:");
static const string_view instancer_attr_prefix("\x01instancer:");
static const string_view view_layer_attr_prefix("\x01layer:");
static ustring blender_attribute_name_add_type(const string &name, BlenderAttributeType type)
{
@@ -111,6 +114,8 @@ static ustring blender_attribute_name_add_type(const string &name, BlenderAttrib
return ustring::concat(object_attr_prefix, name);
case BL::ShaderNodeAttribute::attribute_type_INSTANCER:
return ustring::concat(instancer_attr_prefix, name);
case BL::ShaderNodeAttribute::attribute_type_VIEW_LAYER:
return ustring::concat(view_layer_attr_prefix, name);
default:
return ustring(name);
}
@@ -130,6 +135,11 @@ BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_r
return BL::ShaderNodeAttribute::attribute_type_INSTANCER;
}
if (sname.substr(0, view_layer_attr_prefix.size()) == view_layer_attr_prefix) {
*r_real_name = sname.substr(view_layer_attr_prefix.size());
return BL::ShaderNodeAttribute::attribute_type_VIEW_LAYER;
}
return BL::ShaderNodeAttribute::attribute_type_GEOMETRY;
}
@@ -205,7 +215,9 @@ static void set_default_value(ShaderInput *input,
}
case SocketType::INT: {
if (b_sock.type() == BL::NodeSocket::type_BOOLEAN) {
node->set(socket, get_boolean(b_sock.ptr, "default_value"));
/* Make sure to call the int overload of set() since this is an integer socket as far as
* Cycles is concerned. */
node->set(socket, get_boolean(b_sock.ptr, "default_value") ? 1 : 0);
}
else {
node->set(socket, get_int(b_sock.ptr, "default_value"));
@@ -350,6 +362,33 @@ static ShaderNode *add_node(Scene *scene,
mix->set_use_clamp(b_mix_node.use_clamp());
node = mix;
}
else if (b_node.is_a(&RNA_ShaderNodeMix)) {
BL::ShaderNodeMix b_mix_node(b_node);
if (b_mix_node.data_type() == BL::ShaderNodeMix::data_type_VECTOR) {
if (b_mix_node.factor_mode() == BL::ShaderNodeMix::factor_mode_UNIFORM) {
MixVectorNode *mix_node = graph->create_node<MixVectorNode>();
mix_node->set_use_clamp(b_mix_node.clamp_factor());
node = mix_node;
}
else {
MixVectorNonUniformNode *mix_node = graph->create_node<MixVectorNonUniformNode>();
mix_node->set_use_clamp(b_mix_node.clamp_factor());
node = mix_node;
}
}
else if (b_mix_node.data_type() == BL::ShaderNodeMix::data_type_RGBA) {
MixColorNode *mix_node = graph->create_node<MixColorNode>();
mix_node->set_blend_type((NodeMix)b_mix_node.blend_type());
mix_node->set_use_clamp(b_mix_node.clamp_factor());
mix_node->set_use_clamp_result(b_mix_node.clamp_result());
node = mix_node;
}
else {
MixFloatNode *mix_node = graph->create_node<MixFloatNode>();
mix_node->set_use_clamp(b_mix_node.clamp_factor());
node = mix_node;
}
}
else if (b_node.is_a(&RNA_ShaderNodeSeparateRGB)) {
node = graph->create_node<SeparateRGBNode>();
}
@@ -1072,7 +1111,9 @@ static bool node_use_modified_socket_name(ShaderNode *node)
return true;
}
static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
static ShaderInput *node_find_input_by_name(BL::Node b_node,
ShaderNode *node,
BL::NodeSocket &b_socket)
{
string name = b_socket.identifier();
ShaderInput *input = node->input(name.c_str());
@@ -1082,6 +1123,35 @@ static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_
if (string_startswith(name, "Shader")) {
string_replace(name, "Shader", "Closure");
}
/* Map mix node internal name for shader. */
if (b_node.is_a(&RNA_ShaderNodeMix)) {
if (string_endswith(name, "Factor_Float")) {
string_replace(name, "Factor_Float", "Factor");
}
else if (string_endswith(name, "Factor_Vector")) {
string_replace(name, "Factor_Vector", "Factor");
}
else if (string_endswith(name, "A_Float")) {
string_replace(name, "A_Float", "A");
}
else if (string_endswith(name, "B_Float")) {
string_replace(name, "B_Float", "B");
}
else if (string_endswith(name, "A_Color")) {
string_replace(name, "A_Color", "A");
}
else if (string_endswith(name, "B_Color")) {
string_replace(name, "B_Color", "B");
}
else if (string_endswith(name, "A_Vector")) {
string_replace(name, "A_Vector", "A");
}
else if (string_endswith(name, "B_Vector")) {
string_replace(name, "B_Vector", "B");
}
}
input = node->input(name.c_str());
if (!input) {
@@ -1111,7 +1181,9 @@ static ShaderInput *node_find_input_by_name(ShaderNode *node, BL::NodeSocket &b_
return input;
}
static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::NodeSocket &b_socket)
static ShaderOutput *node_find_output_by_name(BL::Node b_node,
ShaderNode *node,
BL::NodeSocket &b_socket)
{
string name = b_socket.identifier();
ShaderOutput *output = node->output(name.c_str());
@@ -1122,6 +1194,21 @@ static ShaderOutput *node_find_output_by_name(ShaderNode *node, BL::NodeSocket &
name = "Closure";
output = node->output(name.c_str());
}
/* Map internal name for shader. */
if (b_node.is_a(&RNA_ShaderNodeMix)) {
if (string_endswith(name, "Result_Float")) {
string_replace(name, "Result_Float", "Result");
output = node->output(name.c_str());
}
else if (string_endswith(name, "Result_Color")) {
string_replace(name, "Result_Color", "Result");
output = node->output(name.c_str());
}
else if (string_endswith(name, "Result_Vector")) {
string_replace(name, "Result_Vector", "Result");
output = node->output(name.c_str());
}
}
}
return output;
@@ -1267,7 +1354,11 @@ static void add_nodes(Scene *scene,
if (node) {
/* map node sockets for linking */
for (BL::NodeSocket &b_input : b_node.inputs) {
ShaderInput *input = node_find_input_by_name(node, b_input);
if (b_input.is_unavailable()) {
/* Skip unavailable sockets. */
continue;
}
ShaderInput *input = node_find_input_by_name(b_node, node, b_input);
if (!input) {
/* XXX should not happen, report error? */
continue;
@@ -1277,7 +1368,11 @@ static void add_nodes(Scene *scene,
set_default_value(input, b_input, b_data, b_ntree);
}
for (BL::NodeSocket &b_output : b_node.outputs) {
ShaderOutput *output = node_find_output_by_name(node, b_output);
if (b_output.is_unavailable()) {
/* Skip unavailable sockets. */
continue;
}
ShaderOutput *output = node_find_output_by_name(b_node, node, b_output);
if (!output) {
/* XXX should not happen, report error? */
continue;
@@ -1337,6 +1432,89 @@ static void add_nodes(Scene *scene,
empty_proxy_map);
}
/* Look up and constant fold all references to View Layer attributes. */
void BlenderSync::resolve_view_layer_attributes(Shader *shader,
ShaderGraph *graph,
BL::Depsgraph &b_depsgraph)
{
bool updated = false;
foreach (ShaderNode *node, graph->nodes) {
if (node->is_a(AttributeNode::node_type)) {
AttributeNode *attr_node = static_cast<AttributeNode *>(node);
std::string real_name;
BlenderAttributeType type = blender_attribute_name_split_type(attr_node->get_attribute(),
&real_name);
if (type == BL::ShaderNodeAttribute::attribute_type_VIEW_LAYER) {
/* Look up the value. */
BL::ViewLayer b_layer = b_depsgraph.view_layer_eval();
BL::Scene b_scene = b_depsgraph.scene_eval();
float4 value;
BKE_view_layer_find_rgba_attribute((::Scene *)b_scene.ptr.data,
(::ViewLayer *)b_layer.ptr.data,
real_name.c_str(),
&value.x);
/* Replace all outgoing links, using appropriate output types. */
float val_avg = (value.x + value.y + value.z) / 3.0f;
foreach (ShaderOutput *output, node->outputs) {
float val_float;
float3 val_float3;
if (output->type() == SocketType::FLOAT) {
val_float = (output->name() == "Alpha") ? value.w : val_avg;
val_float3 = make_float3(val_float);
}
else {
val_float = val_avg;
val_float3 = float4_to_float3(value);
}
foreach (ShaderInput *sock, output->links) {
if (sock->type() == SocketType::FLOAT) {
sock->set(val_float);
}
else if (SocketType::is_float3(sock->type())) {
sock->set(val_float3);
}
sock->constant_folded_in = true;
}
graph->disconnect(output);
}
/* Clear the attribute name to avoid further attempts to look up. */
attr_node->set_attribute(ustring());
updated = true;
}
}
}
if (updated) {
shader_map.set_flag(shader, SHADER_WITH_LAYER_ATTRS);
}
else {
shader_map.clear_flag(shader, SHADER_WITH_LAYER_ATTRS);
}
}
bool BlenderSync::scene_attr_needs_recalc(Shader *shader, BL::Depsgraph &b_depsgraph)
{
if (shader && shader_map.test_flag(shader, SHADER_WITH_LAYER_ATTRS)) {
BL::Scene scene = b_depsgraph.scene_eval();
return shader_map.check_recalc(scene) || shader_map.check_recalc(scene.world()) ||
shader_map.check_recalc(scene.camera());
}
return false;
}
/* Sync Materials */
void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
@@ -1355,7 +1533,8 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
Shader *shader;
/* test if we need to sync */
if (shader_map.add_or_update(&shader, b_mat) || update_all) {
if (shader_map.add_or_update(&shader, b_mat) || update_all ||
scene_attr_needs_recalc(shader, b_depsgraph)) {
ShaderGraph *graph = new ShaderGraph();
shader->name = b_mat.name().c_str();
@@ -1376,6 +1555,8 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
graph->connect(diffuse->output("BSDF"), out->input("Surface"));
}
resolve_view_layer_attributes(shader, graph, b_depsgraph);
/* settings */
PointerRNA cmat = RNA_pointer_get(&b_mat.ptr, "cycles");
shader->set_use_mis(get_boolean(cmat, "sample_as_light"));
@@ -1432,9 +1613,11 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
BlenderViewportParameters new_viewport_parameters(b_v3d, use_developer_ui);
Shader *shader = scene->default_background;
if (world_recalc || update_all || b_world.ptr.data != world_map ||
viewport_parameters.shader_modified(new_viewport_parameters)) {
Shader *shader = scene->default_background;
viewport_parameters.shader_modified(new_viewport_parameters) ||
scene_attr_needs_recalc(shader, b_depsgraph)) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
@@ -1532,6 +1715,8 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
background->set_visibility(visibility);
}
resolve_view_layer_attributes(shader, graph, b_depsgraph);
shader->set_graph(graph);
shader->tag_update(scene);
}
@@ -1598,7 +1783,8 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all)
Shader *shader;
/* test if we need to sync */
if (shader_map.add_or_update(&shader, b_light) || update_all) {
if (shader_map.add_or_update(&shader, b_light) || update_all ||
scene_attr_needs_recalc(shader, b_depsgraph)) {
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
@@ -1619,6 +1805,8 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all)
graph->connect(emission->output("Emission"), out->input("Surface"));
}
resolve_view_layer_attributes(shader, graph, b_depsgraph);
shader->set_graph(graph);
shader->tag_update(scene);
}

View File

@@ -206,6 +206,9 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
}
}
}
else if (object_is_camera(b_ob)) {
shader_map.set_recalc(b_ob);
}
}
/* Mesh */
else if (b_id.is_a(&RNA_Mesh)) {
@@ -218,6 +221,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
if (world_map == b_world.ptr.data) {
world_recalc = true;
}
shader_map.set_recalc(b_world);
}
/* World */
else if (b_id.is_a(&RNA_Scene)) {
shader_map.set_recalc(b_id);
}
/* Volume */
else if (b_id.is_a(&RNA_Volume)) {
@@ -343,7 +351,7 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold"));
SamplingPattern sampling_pattern = (SamplingPattern)get_enum(
cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_PMJ);
integrator->set_sampling_pattern(sampling_pattern);
int samples = 1;
@@ -385,7 +393,8 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
/* Only use scrambling distance in the viewport if user wants to. */
bool preview_scrambling_distance = get_boolean(cscene, "preview_scrambling_distance");
if (preview && !preview_scrambling_distance) {
if ((preview && !preview_scrambling_distance) ||
sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) {
scrambling_distance = 1.0f;
}
@@ -412,6 +421,22 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
integrator->set_direct_light_sampling_type(direct_light_sampling_type);
#endif
integrator->set_use_guiding(get_boolean(cscene, "use_guiding"));
integrator->set_use_surface_guiding(get_boolean(cscene, "use_surface_guiding"));
integrator->set_use_volume_guiding(get_boolean(cscene, "use_volume_guiding"));
integrator->set_guiding_training_samples(get_int(cscene, "guiding_training_samples"));
if (use_developer_ui) {
integrator->set_deterministic_guiding(get_boolean(cscene, "use_deterministic_guiding"));
integrator->set_surface_guiding_probability(get_float(cscene, "surface_guiding_probability"));
integrator->set_volume_guiding_probability(get_float(cscene, "volume_guiding_probability"));
integrator->set_use_guiding_direct_light(get_boolean(cscene, "use_guiding_direct_light"));
integrator->set_use_guiding_mis_weights(get_boolean(cscene, "use_guiding_mis_weights"));
GuidingDistributionType guiding_distribution_type = (GuidingDistributionType)get_enum(
cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PARALLAX_AWARE_VMM);
integrator->set_guiding_distribution_type(guiding_distribution_type);
}
DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
/* No denoising support for vertex color baking, vertices packed into image
@@ -679,14 +704,18 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
}
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
* User facing parameter is the number of pairs. */
* User facing parameter is the number of pairs.
*
* NOTE: Name channels lowercase RGBA so that compression rules check in OpenEXR DWA code uses
* lossless compression. Reportedly this naming is the only one which works good from the
* interoperability point of view. Using XYZW naming is not portable. */
int crypto_depth = divide_up(min(16, b_view_layer.pass_cryptomatte_depth()), 2);
scene->film->set_cryptomatte_depth(crypto_depth);
CryptomatteType cryptomatte_passes = CRYPT_NONE;
if (b_view_layer.use_pass_cryptomatte_object()) {
for (int i = 0; i < crypto_depth; i++) {
string passname = cryptomatte_prefix + string_printf("Object%02d", i);
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
}
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
@@ -694,7 +723,7 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
if (b_view_layer.use_pass_cryptomatte_material()) {
for (int i = 0; i < crypto_depth; i++) {
string passname = cryptomatte_prefix + string_printf("Material%02d", i);
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
}
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
@@ -702,7 +731,7 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
if (b_view_layer.use_pass_cryptomatte_asset()) {
for (int i = 0; i < crypto_depth; i++) {
string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
b_engine.add_pass(passname.c_str(), 4, "rgba", b_view_layer.name().c_str());
pass_add(scene, PASS_CRYPTOMATTE, passname.c_str());
}
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
@@ -732,6 +761,17 @@ void BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_v
pass_add(scene, PASS_DENOISING_DEPTH, "Denoising Depth", PassMode::NOISY);
}
#ifdef WITH_CYCLES_DEBUG
b_engine.add_pass("Guiding Color", 3, "RGB", b_view_layer.name().c_str());
pass_add(scene, PASS_GUIDING_COLOR, "Guiding Color", PassMode::NOISY);
b_engine.add_pass("Guiding Probability", 1, "X", b_view_layer.name().c_str());
pass_add(scene, PASS_GUIDING_PROBABILITY, "Guiding Probability", PassMode::NOISY);
b_engine.add_pass("Guiding Average Roughness", 1, "X", b_view_layer.name().c_str());
pass_add(scene, PASS_GUIDING_AVG_ROUGHNESS, "Guiding Average Roughness", PassMode::NOISY);
#endif
/* Custom AOV passes. */
BL::ViewLayer::aovs_iterator b_aov_iter;
for (b_view_layer.aovs.begin(b_aov_iter); b_aov_iter != b_view_layer.aovs.end(); ++b_aov_iter) {

View File

@@ -120,6 +120,11 @@ class BlenderSync {
void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
void sync_nodes(Shader *shader, BL::ShaderNodeTree &b_ntree);
bool scene_attr_needs_recalc(Shader *shader, BL::Depsgraph &b_depsgraph);
void resolve_view_layer_attributes(Shader *shader,
ShaderGraph *graph,
BL::Depsgraph &b_depsgraph);
/* Object */
Object *sync_object(BL::Depsgraph &b_depsgraph,
BL::ViewLayer &b_view_layer,
@@ -207,13 +212,16 @@ class BlenderSync {
bool object_is_geometry(BObjectInfo &b_ob_info);
bool object_can_have_geometry(BL::Object &b_ob);
bool object_is_light(BL::Object &b_ob);
bool object_is_camera(BL::Object &b_ob);
/* variables */
BL::RenderEngine b_engine;
BL::BlendData b_data;
BL::Scene b_scene;
id_map<void *, Shader> shader_map;
enum ShaderFlags { SHADER_WITH_LAYER_ATTRS };
id_map<void *, Shader, ShaderFlags> shader_map;
id_map<ObjectKey, Object> object_map;
id_map<void *, Procedural> procedural_map;
id_map<GeometryKey, Geometry> geometry_map;

View File

@@ -515,7 +515,7 @@ void BVHSpatialSplit::split_reference(const BVHBuild &builder,
int dim,
float pos)
{
/* initialize boundboxes */
/* Initialize bounding-boxes. */
BoundBox left_bounds = BoundBox::empty;
BoundBox right_bounds = BoundBox::empty;

View File

@@ -69,6 +69,7 @@ if(CYCLES_STANDALONE_REPOSITORY)
_set_default(BOOST_ROOT "${_cycles_lib_dir}/boost")
_set_default(BLOSC_ROOT_DIR "${_cycles_lib_dir}/blosc")
_set_default(EMBREE_ROOT_DIR "${_cycles_lib_dir}/embree")
_set_default(EPOXY_ROOT_DIR "${_cycles_lib_dir}/epoxy")
_set_default(IMATH_ROOT_DIR "${_cycles_lib_dir}/imath")
_set_default(GLEW_ROOT_DIR "${_cycles_lib_dir}/glew")
_set_default(JPEG_ROOT "${_cycles_lib_dir}/jpeg")
@@ -91,7 +92,11 @@ 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")
if(WIN32)
set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level_zero)
else()
set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level-zero)
endif()
_set_default(SYCL_ROOT_DIR "${_cycles_lib_dir}/dpcpp")
# Ignore system libraries
@@ -197,17 +202,17 @@ endif()
if(CYCLES_STANDALONE_REPOSITORY)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(OPENEXR_INCLUDE_DIR ${OPENEXR_ROOT_DIR}/include)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_ROOT_DIR}/include/OpenEXR)
set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_ROOT_DIR}/include/OpenEXR ${IMATH_ROOT_DIR}/include ${IMATH_ROOT_DIR}/include/Imath)
set(OPENEXR_LIBRARIES
optimized ${OPENEXR_ROOT_DIR}/lib/OpenEXR_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/OpenEXRCore_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/Iex_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/Half_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/IlmImf_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/Imath_s.lib
optimized ${IMATH_ROOT_DIR}/lib/Imath_s.lib
optimized ${OPENEXR_ROOT_DIR}/lib/IlmThread_s.lib
debug ${OPENEXR_ROOT_DIR}/lib/OpenEXR_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/OpenEXRCore_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/Iex_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/Half_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/IlmImf_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/Imath_s_d.lib
debug ${IMATH_ROOT_DIR}/lib/Imath_s_d.lib
debug ${OPENEXR_ROOT_DIR}/lib/IlmThread_s_d.lib
)
else()
@@ -264,6 +269,31 @@ if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OSL)
endif()
endif()
###########################################################################
# OpenPGL
###########################################################################
if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_PATH_GUIDING)
if(NOT openpgl_DIR AND EXISTS ${_cycles_lib_dir})
set(openpgl_DIR ${_cycles_lib_dir}/openpgl/lib/cmake/openpgl)
endif()
find_package(openpgl QUIET)
if(openpgl_FOUND)
if(WIN32)
get_target_property(OPENPGL_LIBRARIES_RELEASE openpgl::openpgl LOCATION_RELEASE)
get_target_property(OPENPGL_LIBRARIES_DEBUG openpgl::openpgl LOCATION_DEBUG)
set(OPENPGL_LIBRARIES optimized ${OPENPGL_LIBRARIES_RELEASE} debug ${OPENPGL_LIBRARIES_DEBUG})
else()
get_target_property(OPENPGL_LIBRARIES openpgl::openpgl LOCATION)
endif()
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
else()
set(WITH_CYCLES_PATH_GUIDING OFF)
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
endif()
endif()
###########################################################################
# OpenColorIO
###########################################################################
@@ -319,8 +349,8 @@ if(CYCLES_STANDALONE_REPOSITORY)
if(NOT BOOST_VERSION)
message(FATAL_ERROR "Unable to determine Boost version")
endif()
set(BOOST_POSTFIX "vc141-mt-x64-${BOOST_VERSION}.lib")
set(BOOST_DEBUG_POSTFIX "vc141-mt-gd-x64-${BOOST_VERSION}.lib")
set(BOOST_POSTFIX "vc142-mt-x64-${BOOST_VERSION}.lib")
set(BOOST_DEBUG_POSTFIX "vc142-mt-gd-x64-${BOOST_VERSION}.lib")
set(BOOST_LIBRARIES
optimized ${BOOST_ROOT}/lib/libboost_date_time-${BOOST_POSTFIX}
optimized ${BOOST_ROOT}/lib/libboost_iostreams-${BOOST_POSTFIX}
@@ -459,6 +489,7 @@ if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_NANOVDB)
if(MSVC AND EXISTS ${_cycles_lib_dir})
set(NANOVDB_INCLUDE_DIR ${NANOVDB_ROOT_DIR}/include)
set(NANOVDB_INCLUDE_DIRS ${NANOVDB_INCLUDE_DIR})
else()
find_package(NanoVDB REQUIRED)
endif()
@@ -628,15 +659,29 @@ endif()
# oneAPI
###########################################################################
if (WITH_CYCLES_DEVICE_ONEAPI)
if(WITH_CYCLES_DEVICE_ONEAPI)
find_package(SYCL)
find_package(LevelZero)
if (SYCL_FOUND AND LEVEL_ZERO_FOUND)
if(SYCL_FOUND AND LEVEL_ZERO_FOUND)
message(STATUS "Found oneAPI: ${SYCL_LIBRARY}")
message(STATUS "Found Level Zero: ${LEVEL_ZERO_LIBRARY}")
if(WITH_CYCLES_ONEAPI_BINARIES)
if(NOT OCLOC_INSTALL_DIR)
get_filename_component(_sycl_compiler_root ${SYCL_COMPILER} DIRECTORY)
get_filename_component(OCLOC_INSTALL_DIR "${_sycl_compiler_root}/../lib/ocloc" ABSOLUTE)
unset(_sycl_compiler_root)
endif()
if(NOT EXISTS ${OCLOC_INSTALL_DIR})
message(STATUS "oneAPI ocloc not found in ${OCLOC_INSTALL_DIR}, disabling WITH_CYCLES_ONEAPI_BINARIES."
" A different ocloc directory can be set using OCLOC_INSTALL_DIR cmake variable.")
set(WITH_CYCLES_ONEAPI_BINARIES OFF)
endif()
endif()
else()
message(STATUS "oneAPI or Level Zero not found, disabling oneAPI device from Cycles")
message(STATUS "oneAPI or Level Zero not found, disabling WITH_CYCLES_DEVICE_ONEAPI")
set(WITH_CYCLES_DEVICE_ONEAPI OFF)
endif()
endif()

View File

@@ -118,6 +118,9 @@ macro(cycles_external_libraries_append libraries)
if(WITH_ALEMBIC)
list(APPEND ${libraries} ${ALEMBIC_LIBRARIES})
endif()
if(WITH_PATH_GUIDING)
target_link_libraries(${target} ${OPENPGL_LIBRARIES})
endif()
list(APPEND ${libraries}
${OPENIMAGEIO_LIBRARIES}
@@ -169,13 +172,13 @@ macro(cycles_install_libraries target)
FILES
${TBB_ROOT_DIR}/bin/tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX}
${OPENVDB_ROOT_DIR}/bin/openvdb_d${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION $<TARGET_FILE_DIR:${target}>)
DESTINATION ${CMAKE_INSTALL_PREFIX})
else()
install(
FILES
${TBB_ROOT_DIR}/bin/tbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${OPENVDB_ROOT_DIR}/bin/openvdb${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION $<TARGET_FILE_DIR:${target}>)
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endif()
endmacro()

View File

@@ -19,6 +19,8 @@ if(WITH_CYCLES_DEVICE_OPTIX OR WITH_CYCLES_DEVICE_CUDA)
)
add_definitions(-DCYCLES_CUDA_NVCC_EXECUTABLE="${CUDA_NVCC_EXECUTABLE}")
endif()
add_definitions(-DCYCLES_RUNTIME_OPTIX_ROOT_DIR="${CYCLES_RUNTIME_OPTIX_ROOT_DIR}")
endif()
if(WITH_CYCLES_DEVICE_HIP AND WITH_HIP_DYNLOAD)
@@ -140,7 +142,6 @@ set(SRC
${SRC_DUMMY}
${SRC_MULTI}
${SRC_OPTIX}
${SRC_ONEAPI}
${SRC_HEADERS}
)
@@ -186,7 +187,25 @@ if(WITH_CYCLES_DEVICE_METAL)
)
endif()
if (WITH_CYCLES_DEVICE_ONEAPI)
if(WIN32)
set(cycles_kernel_oneapi_lib ${CMAKE_CURRENT_BINARY_DIR}/../kernel/cycles_kernel_oneapi.lib)
else()
set(cycles_kernel_oneapi_lib ${CMAKE_CURRENT_BINARY_DIR}/../kernel/libcycles_kernel_oneapi.so)
endif()
list(APPEND LIB
${cycles_kernel_oneapi_lib}
"$<$<CONFIG:Debug>:${SYCL_LIBRARY_DEBUG}>"
"$<$<CONFIG:Release>:${SYCL_LIBRARY}>"
"$<$<CONFIG:RelWithDebInfo>:${SYCL_LIBRARY}>"
"$<$<CONFIG:MinSizeRel>:${SYCL_LIBRARY}>"
)
add_definitions(-DWITH_ONEAPI)
list(APPEND SRC
${SRC_ONEAPI}
)
list(APPEND INC_SYS
${SYCL_INCLUDE_DIR}
)
endif()
if(WITH_OPENIMAGEDENOISE)

View File

@@ -7,6 +7,7 @@
/* Used for `info.denoisers`. */
/* TODO(sergey): The denoisers are probably to be moved completely out of the device into their
* own class. But until then keep API consistent with how it used to work before. */
#include "util/guiding.h"
#include "util/openimagedenoise.h"
CCL_NAMESPACE_BEGIN
@@ -27,6 +28,12 @@ void device_cpu_info(vector<DeviceInfo> &devices)
info.has_osl = true;
info.has_nanovdb = true;
info.has_profiling = true;
if (guiding_supported()) {
info.has_guiding = true;
}
else {
info.has_guiding = false;
}
if (openimagedenoise_supported()) {
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
}

View File

@@ -28,7 +28,6 @@
#include "kernel/device/cpu/kernel.h"
#include "kernel/types.h"
#include "kernel/osl/shader.h"
#include "kernel/osl/globals.h"
// clang-format on
@@ -39,6 +38,7 @@
#include "util/debug.h"
#include "util/foreach.h"
#include "util/function.h"
#include "util/guiding.h"
#include "util/log.h"
#include "util/map.h"
#include "util/openimagedenoise.h"
@@ -279,6 +279,23 @@ void CPUDevice::build_bvh(BVH *bvh, Progress &progress, bool refit)
Device::build_bvh(bvh, progress, refit);
}
void *CPUDevice::get_guiding_device() const
{
#ifdef WITH_PATH_GUIDING
if (!guiding_device) {
if (guiding_device_type() == 8) {
guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_8);
}
else if (guiding_device_type() == 4) {
guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_4);
}
}
return guiding_device.get();
#else
return nullptr;
#endif
}
void CPUDevice::get_cpu_kernel_thread_globals(
vector<CPUKernelThreadGlobals> &kernel_thread_globals)
{

View File

@@ -23,10 +23,12 @@
#include "kernel/device/cpu/kernel.h"
#include "kernel/device/cpu/globals.h"
#include "kernel/osl/shader.h"
#include "kernel/osl/globals.h"
// clang-format on
#include "util/guiding.h"
#include "util/unique_ptr.h"
CCL_NAMESPACE_BEGIN
class CPUDevice : public Device {
@@ -43,6 +45,9 @@ class CPUDevice : public Device {
RTCScene embree_scene = NULL;
RTCDevice embree_device;
#endif
#ifdef WITH_PATH_GUIDING
mutable unique_ptr<openpgl::cpp::Device> guiding_device;
#endif
CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_);
~CPUDevice();
@@ -73,6 +78,8 @@ class CPUDevice : public Device {
void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
void *get_guiding_device() const override;
virtual void get_cpu_kernel_thread_globals(
vector<CPUKernelThreadGlobals> &kernel_thread_globals) override;
virtual void *get_cpu_osl_memory() override;

View File

@@ -3,10 +3,7 @@
#include "device/cpu/kernel_thread_globals.h"
// clang-format off
#include "kernel/osl/shader.h"
#include "kernel/osl/globals.h"
// clang-format on
#include "util/profiling.h"
@@ -17,25 +14,35 @@ CPUKernelThreadGlobals::CPUKernelThreadGlobals(const KernelGlobalsCPU &kernel_gl
Profiler &cpu_profiler)
: KernelGlobalsCPU(kernel_globals), cpu_profiler_(cpu_profiler)
{
reset_runtime_memory();
clear_runtime_pointers();
#ifdef WITH_OSL
OSLShader::thread_init(this, reinterpret_cast<OSLGlobals *>(osl_globals_memory));
OSLGlobals::thread_init(this, static_cast<OSLGlobals *>(osl_globals_memory));
#else
(void)osl_globals_memory;
#endif
#ifdef WITH_PATH_GUIDING
opgl_path_segment_storage = new openpgl::cpp::PathSegmentStorage();
#endif
}
CPUKernelThreadGlobals::CPUKernelThreadGlobals(CPUKernelThreadGlobals &&other) noexcept
: KernelGlobalsCPU(std::move(other)), cpu_profiler_(other.cpu_profiler_)
{
other.reset_runtime_memory();
other.clear_runtime_pointers();
}
CPUKernelThreadGlobals::~CPUKernelThreadGlobals()
{
#ifdef WITH_OSL
OSLShader::thread_free(this);
OSLGlobals::thread_free(this);
#endif
#ifdef WITH_PATH_GUIDING
delete opgl_path_segment_storage;
delete opgl_surface_sampling_distribution;
delete opgl_volume_sampling_distribution;
#endif
}
@@ -47,16 +54,25 @@ CPUKernelThreadGlobals &CPUKernelThreadGlobals::operator=(CPUKernelThreadGlobals
*static_cast<KernelGlobalsCPU *>(this) = *static_cast<KernelGlobalsCPU *>(&other);
other.reset_runtime_memory();
other.clear_runtime_pointers();
return *this;
}
void CPUKernelThreadGlobals::reset_runtime_memory()
void CPUKernelThreadGlobals::clear_runtime_pointers()
{
#ifdef WITH_OSL
osl = nullptr;
#endif
#ifdef WITH_PATH_GUIDING
opgl_sample_data_storage = nullptr;
opgl_guiding_field = nullptr;
opgl_path_segment_storage = nullptr;
opgl_surface_sampling_distribution = nullptr;
opgl_volume_sampling_distribution = nullptr;
#endif
}
void CPUKernelThreadGlobals::start_profiling()

View File

@@ -36,7 +36,7 @@ class CPUKernelThreadGlobals : public KernelGlobalsCPU {
void stop_profiling();
protected:
void reset_runtime_memory();
void clear_runtime_pointers();
Profiler &cpu_profiler_;
};

View File

@@ -79,7 +79,7 @@ bool CUDADeviceQueue::enqueue(DeviceKernel kernel,
return false;
}
debug_enqueue(kernel, work_size);
debug_enqueue_begin(kernel, work_size);
const CUDAContextScope scope(cuda_device_);
const CUDADeviceKernel &cuda_kernel = cuda_device_->kernels.get(kernel);
@@ -121,6 +121,8 @@ bool CUDADeviceQueue::enqueue(DeviceKernel kernel,
0),
"enqueue");
debug_enqueue_end();
return !(cuda_device_->have_error());
}

View File

@@ -352,6 +352,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
info.has_nanovdb = true;
info.has_osl = true;
info.has_guiding = true;
info.has_profiling = true;
info.has_peer_memory = false;
info.use_metalrt = false;
@@ -399,6 +400,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
/* Accumulate device info. */
info.has_nanovdb &= device.has_nanovdb;
info.has_osl &= device.has_osl;
info.has_guiding &= device.has_guiding;
info.has_profiling &= device.has_profiling;
info.has_peer_memory |= device.has_peer_memory;
info.use_metalrt |= device.use_metalrt;

View File

@@ -66,6 +66,7 @@ class DeviceInfo {
bool display_device; /* GPU is used as a display device. */
bool has_nanovdb; /* Support NanoVDB volumes. */
bool has_osl; /* Support Open Shading Language. */
bool has_guiding; /* Support path guiding. */
bool has_profiling; /* Supports runtime collection of profiling info. */
bool has_peer_memory; /* GPU has P2P access to memory of another GPU. */
bool has_gpu_queue; /* Device supports GPU queue. */
@@ -84,6 +85,7 @@ class DeviceInfo {
display_device = false;
has_nanovdb = false;
has_osl = false;
has_guiding = false;
has_profiling = false;
has_peer_memory = false;
has_gpu_queue = false;
@@ -217,6 +219,15 @@ class Device {
return false;
}
/* Guiding */
/* Returns path guiding device handle. */
virtual void *get_guiding_device() const
{
LOG(ERROR) << "Request guiding field from a device which does not support it.";
return nullptr;
}
/* Buffer denoising. */
/* Returns true if task is fully handled. */

View File

@@ -79,7 +79,7 @@ bool HIPDeviceQueue::enqueue(DeviceKernel kernel,
return false;
}
debug_enqueue(kernel, work_size);
debug_enqueue_begin(kernel, work_size);
const HIPContextScope scope(hip_device_);
const HIPDeviceKernel &hip_kernel = hip_device_->kernels.get(kernel);
@@ -120,6 +120,8 @@ bool HIPDeviceQueue::enqueue(DeviceKernel kernel,
0),
"enqueue");
debug_enqueue_end();
return !(hip_device_->have_error());
}

View File

@@ -254,6 +254,10 @@ void MetalDevice::make_source(MetalPipelineType pso_type, const uint kernel_feat
break;
}
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSOperatingSystemVersion macos_ver = [processInfo operatingSystemVersion];
global_defines += "#define __KERNEL_METAL_MACOS__ " + to_string(macos_ver.majorVersion) + "\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"));

View File

@@ -308,26 +308,29 @@ MetalKernelPipeline *ShaderCache::get_best_pipeline(DeviceKernel kernel, const M
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;
/* Issues with binary archives in older macOS versions. */
if (@available(macOS 13.0, *)) {
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 (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;
}
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. */
/* 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;
}

View File

@@ -19,60 +19,12 @@
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
@@ -107,17 +59,10 @@ bool device_oneapi_init()
#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);
return new OneapiDevice(info, stats, profiler);
#else
(void)info;
(void)stats;
@@ -163,7 +108,7 @@ static void device_iterator_cb(const char *id, const char *name, int num, void *
void device_oneapi_info(vector<DeviceInfo> &devices)
{
#ifdef WITH_ONEAPI
(oneapi_dll.oneapi_iterate_devices)(device_iterator_cb, &devices);
OneapiDevice::iterate_devices(device_iterator_cb, &devices);
#else /* WITH_ONEAPI */
(void)devices;
#endif /* WITH_ONEAPI */
@@ -173,10 +118,10 @@ string device_oneapi_capabilities()
{
string capabilities;
#ifdef WITH_ONEAPI
char *c_capabilities = (oneapi_dll.oneapi_device_capabilities)();
char *c_capabilities = OneapiDevice::device_capabilities();
if (c_capabilities) {
capabilities = c_capabilities;
(oneapi_dll.oneapi_free)(c_capabilities);
free(c_capabilities);
}
#endif
return capabilities;

View File

@@ -8,7 +8,7 @@
# include "util/debug.h"
# include "util/log.h"
# include "kernel/device/oneapi/kernel.h"
# include "kernel/device/oneapi/globals.h"
CCL_NAMESPACE_BEGIN
@@ -19,26 +19,19 @@ static void queue_error_cb(const char *message, void *user_ptr)
}
}
OneapiDevice::OneapiDevice(const DeviceInfo &info,
OneAPIDLLInterface &oneapi_dll_object,
Stats &stats,
Profiler &profiler)
OneapiDevice::OneapiDevice(const DeviceInfo &info, 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)
kg_memory_size_(0)
{
need_texture_info_ = false;
oneapi_dll_.oneapi_set_error_cb(queue_error_cb, &oneapi_error_string_);
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);
bool is_finished_ok = create_queue(device_queue_, info.num);
if (is_finished_ok == false) {
set_error("oneAPI queue initialization error: got runtime exception \"" +
oneapi_error_string_ + "\"");
@@ -50,7 +43,7 @@ OneapiDevice::OneapiDevice(const DeviceInfo &info,
}
size_t globals_segment_size;
is_finished_ok = oneapi_dll_.oneapi_kernel_globals_size(device_queue_, globals_segment_size);
is_finished_ok = kernel_globals_size(globals_segment_size);
if (is_finished_ok == false) {
set_error("oneAPI constant memory initialization got runtime exception \"" +
oneapi_error_string_ + "\"");
@@ -59,25 +52,27 @@ OneapiDevice::OneapiDevice(const DeviceInfo &info,
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_ = usm_aligned_alloc_host(device_queue_, globals_segment_size, 16);
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_device_ = usm_alloc_device(device_queue_, globals_segment_size);
kg_memory_size_ = globals_segment_size;
max_memory_on_device_ = get_memcapacity();
}
OneapiDevice::~OneapiDevice()
{
texture_info_.free();
oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_);
oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_device_);
usm_free(device_queue_, kg_memory_);
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_);
free_queue(device_queue_);
}
bool OneapiDevice::check_peer_access(Device * /*peer_device*/)
@@ -93,18 +88,26 @@ BVHLayoutMask OneapiDevice::get_bvh_layout_mask() const
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_);
bool is_finished_ok = oneapi_run_test_kernel(device_queue_);
if (is_finished_ok == false) {
set_error("oneAPI kernel load: got runtime exception \"" + oneapi_error_string_ + "\"");
set_error("oneAPI test kernel execution: got a runtime exception \"" + oneapi_error_string_ +
"\"");
return false;
}
else {
VLOG_INFO << "Runtime compilation done for \"" << info.description << "\"";
VLOG_INFO << "Test kernel has been executed successfully for \"" << info.description << "\"";
assert(device_queue_);
}
is_finished_ok = oneapi_load_kernels(device_queue_, (const unsigned int)requested_features);
if (is_finished_ok == false) {
set_error("oneAPI kernels loading: got a runtime exception \"" + oneapi_error_string_ + "\"");
}
else {
VLOG_INFO << "Kernels loading (compilation) has been done for \"" << info.description << "\"";
}
return is_finished_ok;
}
@@ -134,17 +137,16 @@ void OneapiDevice::generic_alloc(device_memory &mem)
* 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);
void *device_pointer = nullptr;
if (mem.memory_size() + stats.mem_used < max_memory_on_device_)
device_pointer = 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;
string_human_readable_size(max_memory_on_device_) + " is already allocated");
}
assert(device_pointer);
mem.device_pointer = reinterpret_cast<ccl::device_ptr>(device_pointer);
mem.device_size = memory_size;
@@ -154,13 +156,15 @@ void OneapiDevice::generic_alloc(device_memory &mem)
void OneapiDevice::generic_copy_to(device_memory &mem)
{
if (!mem.device_pointer) {
return;
}
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);
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. */
@@ -174,11 +178,6 @@ 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_;
@@ -186,12 +185,15 @@ void *OneapiDevice::kernel_globals_device_pointer()
void OneapiDevice::generic_free(device_memory &mem)
{
assert(mem.device_pointer);
if (!mem.device_pointer) {
return;
}
stats.mem_free(mem.device_size);
mem.device_size = 0;
assert(device_queue_);
oneapi_dll_.oneapi_usm_free(device_queue_, (void *)mem.device_pointer);
usm_free(device_queue_, (void *)mem.device_pointer);
mem.device_pointer = 0;
}
@@ -256,14 +258,14 @@ void OneapiDevice::mem_copy_from(device_memory &mem, size_t y, size_t w, size_t
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_ +
"\"");
if (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 = 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_ + "\"");
}
}
}
}
@@ -284,7 +286,7 @@ void OneapiDevice::mem_zero(device_memory &mem)
}
assert(device_queue_);
bool is_finished_ok = oneapi_dll_.oneapi_usm_memset(
bool is_finished_ok = 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_ +
@@ -341,10 +343,9 @@ void OneapiDevice::const_copy_to(const char *name, void *host, size_t 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);
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_);
usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
}
void OneapiDevice::global_alloc(device_memory &mem)
@@ -359,10 +360,9 @@ void OneapiDevice::global_alloc(device_memory &mem)
generic_alloc(mem);
generic_copy_to(mem);
oneapi_dll_.oneapi_set_global_memory(
device_queue_, kg_memory_, mem.name, (void *)mem.device_pointer);
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_);
usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
}
void OneapiDevice::global_free(device_memory &mem)
@@ -402,18 +402,6 @@ 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
@@ -424,13 +412,465 @@ bool OneapiDevice::should_use_graphics_interop()
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);
return 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);
return usm_free(device_queue_, usm_ptr);
}
void OneapiDevice::check_usm(SyclQueue *queue_, const void *usm_ptr, bool allow_host = false)
{
# ifdef _DEBUG
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
sycl::info::device_type device_type =
queue->get_device().get_info<sycl::info::device::device_type>();
sycl::usm::alloc usm_type = get_pointer_type(usm_ptr, queue->get_context());
(void)usm_type;
assert(usm_type == sycl::usm::alloc::device ||
((device_type == sycl::info::device_type::host ||
device_type == sycl::info::device_type::cpu || allow_host) &&
usm_type == sycl::usm::alloc::host));
# else
/* Silence warning about unused arguments. */
(void)queue_;
(void)usm_ptr;
(void)allow_host;
# endif
}
bool OneapiDevice::create_queue(SyclQueue *&external_queue, int device_index)
{
bool finished_correct = true;
try {
std::vector<sycl::device> devices = OneapiDevice::available_devices();
if (device_index < 0 || device_index >= devices.size()) {
return false;
}
sycl::queue *created_queue = new sycl::queue(devices[device_index],
sycl::property::queue::in_order());
external_queue = reinterpret_cast<SyclQueue *>(created_queue);
}
catch (sycl::exception const &e) {
finished_correct = false;
oneapi_error_string_ = e.what();
}
return finished_correct;
}
void OneapiDevice::free_queue(SyclQueue *queue_)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
delete queue;
}
void *OneapiDevice::usm_aligned_alloc_host(SyclQueue *queue_, size_t memory_size, size_t alignment)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
return sycl::aligned_alloc_host(alignment, memory_size, *queue);
}
void *OneapiDevice::usm_alloc_device(SyclQueue *queue_, size_t memory_size)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
return sycl::malloc_device(memory_size, *queue);
}
void OneapiDevice::usm_free(SyclQueue *queue_, void *usm_ptr)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
OneapiDevice::check_usm(queue_, usm_ptr, true);
sycl::free(usm_ptr, *queue);
}
bool OneapiDevice::usm_memcpy(SyclQueue *queue_, void *dest, void *src, size_t num_bytes)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
OneapiDevice::check_usm(queue_, dest, true);
OneapiDevice::check_usm(queue_, src, true);
sycl::event mem_event = queue->memcpy(dest, src, num_bytes);
# ifdef WITH_CYCLES_DEBUG
try {
/* NOTE(@nsirgien) Waiting on memory operation may give more precise error
* messages. Due to impact on occupancy, it makes sense to enable it only during Cycles debug.
*/
mem_event.wait_and_throw();
return true;
}
catch (sycl::exception const &e) {
oneapi_error_string_ = e.what();
return false;
}
# else
sycl::usm::alloc dest_type = get_pointer_type(dest, queue->get_context());
sycl::usm::alloc src_type = get_pointer_type(src, queue->get_context());
bool from_device_to_host = dest_type == sycl::usm::alloc::host &&
src_type == sycl::usm::alloc::device;
bool host_or_device_memop_with_offset = dest_type == sycl::usm::alloc::unknown ||
src_type == sycl::usm::alloc::unknown;
/* NOTE(@sirgienko) Host-side blocking wait on this operation is mandatory, otherwise the host
* may not wait until the end of the transfer before using the memory.
*/
if (from_device_to_host || host_or_device_memop_with_offset)
mem_event.wait();
return true;
# endif
}
bool OneapiDevice::usm_memset(SyclQueue *queue_,
void *usm_ptr,
unsigned char value,
size_t num_bytes)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
OneapiDevice::check_usm(queue_, usm_ptr, true);
sycl::event mem_event = queue->memset(usm_ptr, value, num_bytes);
# ifdef WITH_CYCLES_DEBUG
try {
/* NOTE(@nsirgien) Waiting on memory operation may give more precise error
* messages. Due to impact on occupancy, it makes sense to enable it only during Cycles debug.
*/
mem_event.wait_and_throw();
return true;
}
catch (sycl::exception const &e) {
oneapi_error_string_ = e.what();
return false;
}
# else
(void)mem_event;
return true;
# endif
}
bool OneapiDevice::queue_synchronize(SyclQueue *queue_)
{
assert(queue_);
sycl::queue *queue = reinterpret_cast<sycl::queue *>(queue_);
try {
queue->wait_and_throw();
return true;
}
catch (sycl::exception const &e) {
oneapi_error_string_ = e.what();
return false;
}
}
bool OneapiDevice::kernel_globals_size(size_t &kernel_global_size)
{
kernel_global_size = sizeof(KernelGlobalsGPU);
return true;
}
void OneapiDevice::set_global_memory(SyclQueue *queue_,
void *kernel_globals,
const char *memory_name,
void *memory_device_pointer)
{
assert(queue_);
assert(kernel_globals);
assert(memory_name);
assert(memory_device_pointer);
KernelGlobalsGPU *globals = (KernelGlobalsGPU *)kernel_globals;
OneapiDevice::check_usm(queue_, memory_device_pointer);
OneapiDevice::check_usm(queue_, kernel_globals, true);
std::string matched_name(memory_name);
/* This macro will change global ptr of KernelGlobals via name matching. */
# define KERNEL_DATA_ARRAY(type, name) \
else if (#name == matched_name) \
{ \
globals->__##name = (type *)memory_device_pointer; \
return; \
}
if (false) {
}
else if ("integrator_state" == matched_name) {
globals->integrator_state = (IntegratorStateGPU *)memory_device_pointer;
return;
}
KERNEL_DATA_ARRAY(KernelData, data)
# include "kernel/data_arrays.h"
else
{
std::cerr << "Can't found global/constant memory with name \"" << matched_name << "\"!"
<< std::endl;
assert(false);
}
# undef KERNEL_DATA_ARRAY
}
bool OneapiDevice::enqueue_kernel(KernelContext *kernel_context,
int kernel,
size_t global_size,
void **args)
{
return oneapi_enqueue_kernel(kernel_context, kernel, global_size, args);
}
/* Compute-runtime (ie. NEO) version is what gets returned by sycl/L0 on Windows
* since Windows driver 101.3268. */
/* The same min compute-runtime version is currently required across Windows and Linux.
* For Windows driver 101.3430, compute-runtime version is 23904. */
static const int lowest_supported_driver_version_win = 1013430;
static const int lowest_supported_driver_version_neo = 23904;
int OneapiDevice::parse_driver_build_version(const sycl::device &device)
{
const std::string &driver_version = device.get_info<sycl::info::device::driver_version>();
int driver_build_version = 0;
size_t second_dot_position = driver_version.find('.', driver_version.find('.') + 1);
if (second_dot_position == std::string::npos) {
std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
<< "\" does not match xx.xx.xxxxx (Linux), x.x.xxxx (L0),"
<< " xx.xx.xxx.xxxx (Windows) for device \""
<< device.get_info<sycl::info::device::name>() << "\"." << std::endl;
}
else {
try {
size_t third_dot_position = driver_version.find('.', second_dot_position + 1);
if (third_dot_position != std::string::npos) {
const std::string &third_number_substr = driver_version.substr(
second_dot_position + 1, third_dot_position - second_dot_position - 1);
const std::string &forth_number_substr = driver_version.substr(third_dot_position + 1);
if (third_number_substr.length() == 3 && forth_number_substr.length() == 4)
driver_build_version = std::stoi(third_number_substr) * 10000 +
std::stoi(forth_number_substr);
}
else {
const std::string &third_number_substr = driver_version.substr(second_dot_position + 1);
driver_build_version = std::stoi(third_number_substr);
}
}
catch (std::invalid_argument &) {
std::cerr << "Unable to parse unknown Intel GPU driver version \"" << driver_version
<< "\" does not match xx.xx.xxxxx (Linux), x.x.xxxx (L0),"
<< " xx.xx.xxx.xxxx (Windows) for device \""
<< device.get_info<sycl::info::device::name>() << "\"." << std::endl;
}
}
return driver_build_version;
}
std::vector<sycl::device> OneapiDevice::available_devices()
{
bool allow_all_devices = false;
if (getenv("CYCLES_ONEAPI_ALL_DEVICES") != nullptr)
allow_all_devices = true;
/* Host device is useful only for debugging at the moment
* so we hide this device with default build settings. */
# ifdef WITH_ONEAPI_SYCL_HOST_ENABLED
bool allow_host = true;
# else
bool allow_host = false;
# endif
const std::vector<sycl::platform> &oneapi_platforms = sycl::platform::get_platforms();
std::vector<sycl::device> available_devices;
for (const sycl::platform &platform : oneapi_platforms) {
/* ignore OpenCL platforms to avoid using the same devices through both Level-Zero and OpenCL.
*/
if (platform.get_backend() == sycl::backend::opencl) {
continue;
}
const std::vector<sycl::device> &oneapi_devices =
(allow_all_devices || allow_host) ? platform.get_devices(sycl::info::device_type::all) :
platform.get_devices(sycl::info::device_type::gpu);
for (const sycl::device &device : oneapi_devices) {
if (allow_all_devices) {
/* still filter out host device if build doesn't support it. */
if (allow_host || !device.is_host()) {
available_devices.push_back(device);
}
}
else {
bool filter_out = false;
/* For now we support all Intel(R) Arc(TM) devices and likely any future GPU,
* assuming they have either more than 96 Execution Units or not 7 threads per EU.
* Official support can be broaden to older and smaller GPUs once ready. */
if (device.is_gpu() && platform.get_backend() == sycl::backend::ext_oneapi_level_zero) {
/* Filtered-out defaults in-case these values aren't available through too old L0
* runtime. */
int number_of_eus = 96;
int threads_per_eu = 7;
if (device.has(sycl::aspect::ext_intel_gpu_eu_count)) {
number_of_eus = device.get_info<sycl::info::device::ext_intel_gpu_eu_count>();
}
if (device.has(sycl::aspect::ext_intel_gpu_hw_threads_per_eu)) {
threads_per_eu =
device.get_info<sycl::info::device::ext_intel_gpu_hw_threads_per_eu>();
}
/* This filters out all Level-Zero supported GPUs from older generation than Arc. */
if (number_of_eus <= 96 && threads_per_eu == 7) {
filter_out = true;
}
/* if not already filtered out, check driver version. */
if (!filter_out) {
int driver_build_version = parse_driver_build_version(device);
if ((driver_build_version > 100000 &&
driver_build_version < lowest_supported_driver_version_win) ||
driver_build_version < lowest_supported_driver_version_neo) {
filter_out = true;
}
}
}
else if (!allow_host && device.is_host()) {
filter_out = true;
}
else if (!allow_all_devices) {
filter_out = true;
}
if (!filter_out) {
available_devices.push_back(device);
}
}
}
}
return available_devices;
}
char *OneapiDevice::device_capabilities()
{
std::stringstream capabilities;
const std::vector<sycl::device> &oneapi_devices = available_devices();
for (const sycl::device &device : oneapi_devices) {
const std::string &name = device.get_info<sycl::info::device::name>();
capabilities << std::string("\t") << name << "\n";
# define WRITE_ATTR(attribute_name, attribute_variable) \
capabilities << "\t\tsycl::info::device::" #attribute_name "\t\t\t" << attribute_variable \
<< "\n";
# define GET_NUM_ATTR(attribute) \
{ \
size_t attribute = (size_t)device.get_info<sycl::info::device ::attribute>(); \
capabilities << "\t\tsycl::info::device::" #attribute "\t\t\t" << attribute << "\n"; \
}
GET_NUM_ATTR(vendor_id)
GET_NUM_ATTR(max_compute_units)
GET_NUM_ATTR(max_work_item_dimensions)
sycl::id<3> max_work_item_sizes =
device.get_info<sycl::info::device::max_work_item_sizes<3>>();
WRITE_ATTR("max_work_item_sizes_dim0", ((size_t)max_work_item_sizes.get(0)))
WRITE_ATTR("max_work_item_sizes_dim1", ((size_t)max_work_item_sizes.get(1)))
WRITE_ATTR("max_work_item_sizes_dim2", ((size_t)max_work_item_sizes.get(2)))
GET_NUM_ATTR(max_work_group_size)
GET_NUM_ATTR(max_num_sub_groups)
GET_NUM_ATTR(sub_group_independent_forward_progress)
GET_NUM_ATTR(preferred_vector_width_char)
GET_NUM_ATTR(preferred_vector_width_short)
GET_NUM_ATTR(preferred_vector_width_int)
GET_NUM_ATTR(preferred_vector_width_long)
GET_NUM_ATTR(preferred_vector_width_float)
GET_NUM_ATTR(preferred_vector_width_double)
GET_NUM_ATTR(preferred_vector_width_half)
GET_NUM_ATTR(native_vector_width_char)
GET_NUM_ATTR(native_vector_width_short)
GET_NUM_ATTR(native_vector_width_int)
GET_NUM_ATTR(native_vector_width_long)
GET_NUM_ATTR(native_vector_width_float)
GET_NUM_ATTR(native_vector_width_double)
GET_NUM_ATTR(native_vector_width_half)
size_t max_clock_frequency =
(size_t)(device.is_host() ? (size_t)0 :
device.get_info<sycl::info::device::max_clock_frequency>());
WRITE_ATTR("max_clock_frequency", max_clock_frequency)
GET_NUM_ATTR(address_bits)
GET_NUM_ATTR(max_mem_alloc_size)
/* NOTE(@nsirgien): Implementation doesn't use image support as bindless images aren't
* supported so we always return false, even if device supports HW texture usage acceleration.
*/
bool image_support = false;
WRITE_ATTR("image_support", (size_t)image_support)
GET_NUM_ATTR(max_parameter_size)
GET_NUM_ATTR(mem_base_addr_align)
GET_NUM_ATTR(global_mem_size)
GET_NUM_ATTR(local_mem_size)
GET_NUM_ATTR(error_correction_support)
GET_NUM_ATTR(profiling_timer_resolution)
GET_NUM_ATTR(is_available)
# undef GET_NUM_ATTR
# undef WRITE_ATTR
capabilities << "\n";
}
return ::strdup(capabilities.str().c_str());
}
void OneapiDevice::iterate_devices(OneAPIDeviceIteratorCallback cb, void *user_ptr)
{
int num = 0;
std::vector<sycl::device> devices = OneapiDevice::available_devices();
for (sycl::device &device : devices) {
const std::string &platform_name =
device.get_platform().get_info<sycl::info::platform::name>();
std::string name = device.get_info<sycl::info::device::name>();
std::string id = "ONEAPI_" + platform_name + "_" + name;
if (device.has(sycl::aspect::ext_intel_pci_address)) {
id.append("_" + device.get_info<sycl::info::device::ext_intel_pci_address>());
}
(cb)(id.c_str(), name.c_str(), num, user_ptr);
num++;
}
}
size_t OneapiDevice::get_memcapacity()
{
return reinterpret_cast<sycl::queue *>(device_queue_)
->get_device()
.get_info<sycl::info::device::global_mem_size>();
}
int OneapiDevice::get_num_multiprocessors()
{
const sycl::device &device = reinterpret_cast<sycl::queue *>(device_queue_)->get_device();
if (device.has(sycl::aspect::ext_intel_gpu_eu_count)) {
return device.get_info<sycl::info::device::ext_intel_gpu_eu_count>();
}
else
return 0;
}
int OneapiDevice::get_max_num_threads_per_multiprocessor()
{
const sycl::device &device = reinterpret_cast<sycl::queue *>(device_queue_)->get_device();
if (device.has(sycl::aspect::ext_intel_gpu_eu_simd_width) &&
device.has(sycl::aspect::ext_intel_gpu_hw_threads_per_eu)) {
return device.get_info<sycl::info::device::ext_intel_gpu_eu_simd_width>() *
device.get_info<sycl::info::device::ext_intel_gpu_hw_threads_per_eu>();
}
else
return 0;
}
CCL_NAMESPACE_END

Some files were not shown because too many files have changed in this diff Show More