1
1

Compare commits

...

1124 Commits

Author SHA1 Message Date
f4dab64487 EEVEE: Move Closure definitions to gpu_shader_codegen_lib.glsl
This way they can be used as inputs to the closure eval functions.
2022-03-23 14:15:12 +01:00
6a7f603e70 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/intern/DRW_gpu_wrapper.hh
#	source/blender/draw/intern/draw_manager_exec.c
#	source/blender/gpu/GPU_storage_buffer.h
#	source/blender/gpu/intern/gpu_storage_buffer.cc
#	source/blender/gpu/intern/gpu_storage_buffer_private.hh
#	source/blender/gpu/opengl/gl_storage_buffer.cc
#	source/blender/gpu/opengl/gl_storage_buffer.hh
2022-03-18 21:13:33 +01:00
2297db5c49 DRW: gpu wrappers: Fix compilation in release mode 2022-03-18 20:59:48 +01:00
16dd382f06 GPUTexture: Add Cube view as 2D array
This is useful to read/write to the textures directly using compute
shaders and imageLoad/Store.
2022-03-18 20:59:44 +01:00
c509a12fd8 DRW: Expose stencil view in gpu_wrapper 2022-03-18 20:59:40 +01:00
daa26ac0f5 Cleanup: DRW: Fix comments in DRW_gpu_wrapper 2022-03-18 20:59:37 +01:00
e5c2bfb341 DRW: Add support for compute indirect command.
This just expose the GPU API through DRW.
2022-03-18 20:59:33 +01:00
d7df0dcccb GPU: Add indirect dispatch support.
This uses a StorageBuf as the source of indirect dispatch argument.
The user needs to make sure the parameters are in the right order.

There is no support for argument offset for the moment as there is no
need for it. But this might be added in the future.

Note that the indirect buffer is synchronized at the backend level. This is
done for practical reasons and because this feature is almost always used
for GPU driven pipeline.
2022-03-18 20:59:27 +01:00
7ee816e32f GPU: StorageBuf: Add method to clear the buffer in place.
This is a faster way to clear a buffer instead of reuploading new data.
It is equivalent to `memset` and runs directly on the GPU.

This is better to clear huge buffers and to avoid the sync cost of data upload.
2022-03-18 20:59:20 +01:00
5bd38f3be8 Cleanup: GPUStorageBuf: Fix header license 2022-03-18 20:57:15 +01:00
33b4e21820 Cleanup: SSBO: Rename ubo to ssbo in arguments. 2022-03-18 20:54:58 +01:00
93bf17d952 GPU: Add support for stencil buffer texturing mode.
This adds the possibility to read the stencil buffer inside shaders.
This is only available on GL 4.3 so use it accordingly.
2022-03-18 20:54:42 +01:00
054957659f GL: Check texture framebuffer feedback only if not using compute pipeline.
This was getting in the way in multiple instances. Compute shaders dispatch
are still made in the presence of the last bound framebuffer even if they
do not interact with it.
2022-03-18 20:54:27 +01:00
935136f844 GPUTexture: Fix bug in texture view creation
The switch case was based on an uninitialized value.
2022-03-18 20:54:18 +01:00
081255671a GL: Add missing format in image layout conversion 2022-03-18 20:54:02 +01:00
3f484c502f GPUShaderCreateInfo: Add explicit early_fragment_test 2022-03-18 20:53:52 +01:00
0f08453ea9 DRW: Add simple texture view wrappers to draw::Texture 2022-03-18 20:53:41 +01:00
3b75ca2f60 GPUTexture: Expose layer & mip count 2022-03-18 20:53:17 +01:00
374cb32d4a GLShader: Fix two small issues with compute shader generated code 2022-03-18 20:53:04 +01:00
2580869901 DRW: Add support for GPUStorageBuf in wrappers
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_light.cc
#	source/blender/draw/engines/eevee/eevee_shadow.cc
2022-03-18 20:50:25 +01:00
8c93f8c6cc DRW: Add support for GPUStorageBuf 2022-03-18 20:49:45 +01:00
bacfd55a0e GPU/GL: Add StorageBuf implementation
Almost 1:1 identical to UniformBuf implementation.
2022-03-18 20:49:41 +01:00
4544761a2d GPUShader: Fix crash when compilation error is a linking error 2022-03-18 20:49:22 +01:00
59f53f5802 EEVEE: Add new experimental "EEVEE Next" option
This is supposed to hold the latest improvement from the EEVEE rewrite branch.
Note that a restart is necessary in order for the engine to appear.

The registration code is a bit convoluted as it needs to be after the WM_init.
2022-03-18 20:49:09 +01:00
Christoph Lendenfeld
37b93b5df8 Animation: Blend To Default Implementation
Add a new operator to the Graph Editor that blends selected keyframes
to their default value.
The operator can be accessed from
Key>Slider Operators>Blend To Default Value

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D9376
Ref: D9367
2022-03-18 20:07:16 +01:00
a65d9e22cd Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/engines/eevee/shaders/lookdev_world_frag.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_object_info.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_tex_environment.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl
2022-03-18 20:00:11 +01:00
63f9cb5a0b Fix T96608: GPencil Simplify must check general Simplify switch
As the grease pencil simplify is a subotion of general simplify, if the general switch is disabled, the grease pencil simplify must be disabled too.

This patch also disable the UI panel.
2022-03-18 19:50:38 +01:00
77b52bf9cf EEVEE: Add new experimental "EEVEE Next" option
This is supposed to hold the latest improvement from the EEVEE rewrite branch.
Note that a restart is necessary in order for the engine to appear.

The registration code is a bit convoluted as it needs to be after the WM_init.
2022-03-18 19:04:10 +01:00
298d8a7b4a Curves: Port reverse curves node to the new data-block
Create a function on CurvesGeometry that can also be used for an edit
mode operator in the future. Dealing with CustomData directly means the
code is a bit more verbose than would be ideal, but this would be a
simple thing to clean up in the future if we get an attribute API here.

Also change the reverse node to first work on a read-only geometry
component, and only get write access if there is a curve selected.

Differential Revision: https://developer.blender.org/D14375
2022-03-18 12:24:05 -05:00
d2726e4626 Cleanup: Remove unnecessary namespace usage, use const 2022-03-18 12:21:13 -05:00
b2cb99d3fd Curves: Port fill curve node to the new data-block
This will mostly just remove the overhead of converting
to and from the old curves type, though it also does open
some opportunities for multi-threading in the future.
2022-03-18 12:18:19 -05:00
8146c996eb Fix: Curves last evaluated segment is empty
A mistake in 8538c69921. The offsets include the segment at the
corresponding index, but the evaluated offset calculation was adjusting
the offset for the second to last segment.
2022-03-18 12:05:14 -05:00
5d7f4f2cab Curves: Port transform node to new data-block
Make the new curves' translate and transform functions also affect
the handle position attributes.

Differential Revision: https://developer.blender.org/D14372
2022-03-18 10:30:27 -05:00
fe9e7036b0 Fix UV's not aligning with image.
This reverts a part of {rB33409f9f1cd42e899f2706fe7878e5e89b50d617}.
2022-03-18 14:17:19 +01:00
65b8b38787 Cleanup: Redundant parenthesis 2022-03-18 14:16:16 +01:00
c3ecfdf40b Cleanup: Compilation warnings
Mainly -Wset-but-unused-variable.
Makes default compilation on macOS way less noisy.

Differential Revision: https://developer.blender.org/D14357
2022-03-18 12:07:08 +01:00
3aac5c92bb EEVEE: Raytracing: Add back denoising step
Still work in progress.
2022-03-18 11:29:52 +01:00
2252bc6a55 BLI: move CPPType to blenlib
For more detail about `CPPType`, see `BLI_cpp_type.hh` and D14367.

Differential Revision: https://developer.blender.org/D14367
2022-03-18 10:57:45 +01:00
7509a74116 Fix T96278: missing update after alpha socket connection
Differential Revision: https://developer.blender.org/D14299
2022-03-18 10:49:54 +01:00
c7954d5904 Cleanup: Remove unused function 2022-03-18 10:34:06 +01:00
578c2f117a Curves: Port handle type selection node to new data-block
The node's structure isn't changed, it basically still works the
same way. The use of virtual arrays could be optimized in the
future if necessary.
2022-03-18 00:16:54 -05:00
389807624d Curves: Port Bezier Segment node to the new data-block
Ref T95443
2022-03-17 22:47:56 -05:00
0eb394af74 Fix resizing nodes not respecting the drag-start
Resizing nodes used the cursor location when the event was triggered
instead of the drag-start, harmless but means the drag location isn't
under the cursor especially with a high drag threshold.

Noticed when investigating other drag issues,
unrelated to recent changes to drag behavior.
2022-03-18 13:20:11 +11:00
5035fbdd23 License headers: use SPDX identifiers in intern/itasc
Added license headers based on the original LGPL files from:
gitlab.kuleuven.be/rob-itasc
2022-03-18 10:27:01 +11:00
a0e2373b7e Docs: add license text file for LGPL2.1 2022-03-18 10:27:01 +11:00
89ab3cdc56 Fix wrong documentation/UI text for NodeLink
`RNA_def_struct_ui_text(srna, ...)` was reused for `is_valid` and `is_muted`
which would set the documentation to theirs (actually to that of the last
call).

`RNA_def_property_ui_text(prop, ...)` should be used for the properties.
2022-03-17 23:57:06 +01:00
a67c7693a7 Fix typo in smooth brush tooltip 2022-03-17 23:56:55 +01:00
8407c0b64e Cleanup: unused class members. 2022-03-17 23:56:18 +01:00
d4bd9f6a27 Curves: Port convex hull node to new data-block
This uses the evaluated positions calculations from 8538c69921.
2022-03-17 17:45:37 -05:00
7bdba5f1e0 Cleanup: Remove unused includes 2022-03-17 17:16:53 -05:00
0835996cc9 Cleanup: Rename "spline" variables to "curve"
Ref T95355
2022-03-17 17:08:36 -05:00
ee2d39b3a7 Cleanup: Reorganize duplicate elements file
Use sections to keep all the code for a specific mode together,
rather than keeping the attribute duplication separate.
2022-03-17 16:46:58 -05:00
663bd38ed6 Curves: Port duplicate elements node to new data-block
Remove the conversion to and from `CurveEval` by supporting the
new Curves data-block in the node. This allows for some simplifications
to the code, as well as a fix for transfering curve domain attributes
when duplicating the curve domain.

The performance improvements (obverved through the timings overlay)
can be relatively massive with many curves. When duplicating 10000
4-point curves to become 2 million curves, I observed an approximate
150x improvement, from about 3 seconds to about 20ms.
2022-03-17 16:36:43 -05:00
6d97a5f93c Cleanup: Miscellaneous improvements to duplicate geometry node
- Pass less redundant information in function arguments.
- Use `IndexRange` more instead of direct offset calculations.
- Use specific geometry component types for specialized functions.
- Use const arguments.
- Declare variables closer to where they are created or used.
- Remove some redundant logic.
- Simplify the description for the output geometry.
2022-03-17 16:23:58 -05:00
3bc270327d DRW: gpu wrappers: Fix compilation in release mode 2022-03-17 22:18:52 +01:00
4e3148a547 GPUMaterial: Fix missing thickness output link 2022-03-17 22:18:12 +01:00
43529aaff3 GPUMaterial: Fix compilation error when shader use bump nodes 2022-03-17 22:17:36 +01:00
8e7e51bc2f GPUCodegen: Fix missing dependency of some nodes to object infos 2022-03-17 22:16:57 +01:00
7fed4c06c2 Fix keying-set selector broken
The menu for Timeline > Keying > Active Keying Set wouldn't show up.

Caused by d8e3bcf770. The function to attach search menu data to the button
would be called twice with different arguments for the same button now.
Shouldn't be an issue in general, but the first call now had the unexpected
side effect that the button would get disabled. Make sure it's re-enabled when
the second call sets the proper search data now.
2022-03-17 17:52:50 +01:00
17906794f5 Fix T96330: Three times slower 'relink to new id' process in 3.1.
Caused by rB43bc494892c3, moving this 'new id' relink to generic
remapping code added the over-head of proper, generic post-processing,
compared to the special-cases previous code was only designed to handle.

Fortunately with recent 'multi-remapping' work we can easily rewrite
that new id relink code to use the multi-remapping approach too.

No behavioral change is expected from this commit, besides the improved
performances (essentially restored to what they where before
rB43bc494892c3).
2022-03-17 17:23:57 +01:00
007d4c9e0f EEVEE: Use compute shaders for lightprobe related filtering
This reduces the complexity and avoid framebuffer setup costs.

This also "remove" the prefiltering of the glossy cubemaps in favor
of a simple bilinear filtering of the mipchain.
2022-03-17 15:56:17 +01:00
36e355e1ad EEVEE: Fix race condition in HiZ downsample shader 2022-03-17 14:40:23 +01:00
ab3f66d7c8 GPUTexture: Add Cube view as 2D array
This is useful to read/write to the textures directly using compute
shaders and imageLoad/Store.
2022-03-17 14:39:03 +01:00
Henrik Dick
236ef11a07 GPencil: Fix cyclic flag cleared by simplify modifier
Change the sample mode to don't duplicate the last vertex of the
stroke and instead use the cyclic flag to close previously cyclic
strokes. This is necessary for the following modifiers.

Reviewed By: NicksBest

Differential Revision: http://developer.blender.org/D14359
2022-03-17 14:09:29 +01:00
d0968a9c52 BLI: add probabilistic rounding utility 2022-03-17 12:48:41 +01:00
8f68cff01b Cleanup: name enums 2022-03-17 12:42:01 +01:00
dd483215e5 Hair: Sculpt Mode Icons
From hair particle mode:
* Add
* Comb
* Cut
* Grow

New:
* Delete

Only comb and delete are used at the moment (by the new tools which are
under experimental).
2022-03-17 12:12:53 +01:00
b6702aa604 Curves: separate sculpt brushes into separate files
This makes it easier to work on these brushes in parallel.
2022-03-17 10:04:02 +01:00
884b167f74 View 3D: scale object center selection penalty by the pixel size
All screen-space UI thresholds should scale by the interface scale.
2022-03-17 20:02:37 +11:00
e0a8f9b78e Fix unintended de-selection when selecting the object center
Selecting an object that was already active & selected would de-select
it when the cursor was over the objects center.

This was caused by [0] that added a check which assumed more than one
hits from GPU_select meant there were multiple objects to select from.
This is not necessarily the case since bones, camera tracks or the
objects own center can add additional hits.

Resolve by keeping track of the best hit with & without the
active-selected object, only using the non-active-selected if it's found.

[0] 1550573360
2022-03-17 18:21:47 +11:00
bb735bd518 Tweak Tool: supports select & tweak on LMB (with RMB-select key-map)
Support for differentiating the tweak tool from the 3D cursor when
select is set to RMB.

This is currently an experimental preference:
Tweak Tool: Left Mouse Select & Drag

When enabled the tweak tool can now tweak the existing selection
without de-selecting first, a single click can be used to replace
the selection.
This matches selection in the graph & node editors.

This preferences is only available with "Developer Extras" enabled.

Ref T96544.
2022-03-17 16:47:14 +11:00
3017585ebf View 3D: the select operator now uses the cancel flag on failure
Needed so mapping selection to click doesn't pass the click event
through to setting the 3D cursor for e.g.

While this doesn't happen with the default key-map, setting selection
to LMB-click would set the 3D cursor as well (when the selection
fell through to nothing).
2022-03-17 16:22:33 +11:00
859c062a2a View 3D: multi-object pose selection no longer de-selects objects
De-selecting objects meant that selecting a bone would de-select
all the other pose objects - making exiting & entering pose-mode
loose the current set of pose objects.

Match edit-mode behavior: avoid de-selecting objects in the current mode
(unless the action is explicitly performed in the outliner for e.g.).
2022-03-17 14:39:38 +11:00
ba6d59a85a Cleanup: simplify logic for skipping object selection
Previously setting the 'basact' to NULL was done, but this wasn't
so simple to use with deselect_all which needs to check if there was
anything found at the cursor.

Add a 'handled' variable to differentiate this case, when set
don't attempt object selection.
2022-03-17 14:38:38 +11:00
42f430e9a2 Cleanup: minor clarifications to comments & use const variables 2022-03-17 14:37:23 +11:00
83fd242546 Fix 3D view movie-clip track selection
While basic single track selection worked,
toggling and de-selection has been broken since at least 2.83.

Support SelectPick_Params with the exception of deselect_all
which doesn't make sense for tracks as de-selecting all objects
is expected in that case.
2022-03-17 14:37:22 +11:00
7bc6a04767 Cleanup: split movie clip track selection into it's own function
This was an involved operation to include inline,
making ed_object_select_pick more difficult to follow.

Prepare for track selection to properly support SelectPick_Params.
2022-03-17 14:37:21 +11:00
1d88aeb95f View 3D: support for select passthrough when picking selected items
Currently this isn't used in the key-map, it will eventually
allow the 3D viewports tweak tool to match the behavior of other
editors that support tweaking a selection without first de-selecting
all other elements.
2022-03-17 14:37:20 +11:00
ea0c86e961 Cleanup: spelling in comments
Use <pre>..</pre> for pseudo-code.
2022-03-17 10:08:41 +11:00
27388f7f46 Cleanup: include argument names for drop-box callbacks
Indicates typical names for callbacks and allows them to be documented.
2022-03-17 10:08:41 +11:00
Habib Gahbiche
33409f9f1c Compositor: Support backdrop offset for the Viewer node
This is only part of the experimental "Full Frame" mode (disabled
by default). See T88150.

Currently the viewer node uses buffer paddings to display image offset
in the backdrop as a temporal solution implemented for {D12466}.
This solution is inefficient memory and performance-wise. Another
issue is that the paddings are part the image when saved.

This patch instead sets the offset in the Viewer node image
as variables and makes the backdrop take it into account
when drawing the image or any related gizmo.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D12750
2022-03-16 23:28:36 +01:00
22de21bef1 Fix: Compiler error on windows and mac
The previous fix including `<algorithm>` was an improvement
but not the actual error, which appears to be that `int64_t` is
long long int on one platform but just long int on another.
The fix includes the template argument directly.
2022-03-16 16:49:31 -05:00
7a4af7a01b Fix: Build error after curve evaluation commit 2022-03-16 16:29:24 -05:00
8538c69921 Curves: Initial evaluation for curves data-block
This patch adds evaluation for NURBS, Bezier, and Catmull Rom
curves for the new `Curves` data-block. The main difference from
the code in `BKE_spline.hh` is that the functionality is not
encapsulated in classes. Instead, each function has arguments
for all of the information it needs. This makes the code more
reusable and removes a bunch of unnecessary complications
for keeping track of state.

NURBS and Bezier evaluation works the same way as existing code.
The Catmull Rom implementation is new, with the basis function
based on Cycles code. All three types have some basic tests.

For NURBS and Catmull Rom curves, evaluating positions is the
same as any generic attribute, so it's implemented by the generic
interpolation to evaluated points. Bezier curves are a bit special,
because the "handle" control points are stored in a separate attribute.
This patch doesn't include generic interpolation to evaluated points
for Bezier curves.

Ref T95942

Differential Revision: https://developer.blender.org/D14284
2022-03-16 15:47:00 -05:00
c50ba2f778 GPUCodegen: Add comment on the pass hash first check 2022-03-16 19:19:21 +01:00
6cc40796af EEVEE: Speedup: Add subsurface scattering bypass on principle BSDF
This is to avoid the cost of running another shading pass when not
needed.
2022-03-16 19:17:09 +01:00
9af791f873 Fix: Update icons for hair to curves rename
ddf189892c missed recreating the icons with the new names.
This commit runs `make icons` and replaces the names in CMake.
2022-03-16 12:48:00 -05:00
7dd40c8ae8 EEVEE: Material: Fix issue with DRWShadingGroup reuse.
With the deferred pipeline, the materials needs different shading groups
depending on their matflags.

Note that this is potentially slower because execution order of shaders
may now be random. This might be fixed in a later commit.
2022-03-16 18:43:46 +01:00
9e30590eab EEVEE: Refactor indirect lighting pipeline to use compute
This matches better what hardware raytracing will be doing. Performances
are also more predictable.
2022-03-16 18:43:23 +01:00
Bastien Montagne
7e06fc11b7 Add 'multiple' variant of ID relink function.
Similar to other changes to ID remapping, gives huge speedups in some
cases, like certain types of liboverride creation.

Case from {T96092} goes from 1725 seconds (almost 30 minutes) to 45
seconds to generate the liboverride, on my machine.

Reviewed By: jbakker

Maniphest Tasks: T96092

Differential Revision: https://developer.blender.org/D14240
2022-03-16 18:34:20 +01:00
2564d152d6 Cleanup: Remove unnecessary namespace specification
Ever since d5b72fb06c, shader nodes have been in the
`blender::nodes` namespace, so they don't need to use that to access
Blender's C++ types and functions.
2022-03-16 12:33:36 -05:00
263c5b33d6 Fix: Build error from missing build dependencies
Somehow exposed after 943b919fe8, linking could fail because
bf_nodes was not properly configured as a dependency of bf_nodes_shader.
Also add the dependency to the geometry nodes module.
2022-03-16 12:20:05 -05:00
390b9f1305 Fix Cycles HIP assuming warp size 32
In HIP these masks are 64 bit, while in CUDA only 32 bit.
2022-03-16 18:05:48 +01:00
076079454f Cleanup: remove some unused Cycles GPU code
To make porting to other architectures easier, clarifying that this does not
need to be supported. The unused parallel_reduce implementation assumed warp
size 32, but is easy to update if we ever need it in the future.
2022-03-16 18:05:08 +01:00
213d00607e Cleanup: Further removal for legacy geometry nodes
943b919fe8 missed removing the experimental
option and the nodes from the add menu.
2022-03-16 10:56:53 -05:00
79e74b1486 Fix T96518: Gpencil Fill freezes when use invert and click inside areas
When using inverted filling and click inside a closed area and not outside as is expected, the algorithm to detect the contour to fill is unable to find the filling shape and try to fill outside of the valid index.

The infinite loop was adding more memory for each loop and the process continued while there was system resources and finally crashed the system.

As the tool in negative mode is designed to fill all areas when you click outside of any shape, now the algorithm check if the outline is not working as expected and cancels the filling process.
2022-03-16 16:30:53 +01:00
943b919fe8 Geometry Nodes: Remove legacy node code
This commit removes the implementations of legacy nodes,
their type definitions, and related code that becomes unused.
Now that we have two releases that included the legacy nodes,
there is not much reason to include them still. Removing the
code means refactoring will be easier, and old code doesn't
have to be tested and maintained.

After this commit, the legacy nodes will be undefined in the UI,
so 3.0 or 3.1 should be used to convert files to the fields system.

The net change is 12184 lines removed!

The tooltip for legacy nodes mentioned that we would remove
them before 4.0, which was purposefully a bit vague to allow
us this flexibility. In a poll in a devtalk post showed that the
majority of people were okay with removing the nodes.
https://devtalk.blender.org/t/geometry-nodes-backward-compatibility-poll/20199

Differential Revision: https://developer.blender.org/D14353
2022-03-16 08:51:11 -05:00
cb267cec55 Fix T96512: Crash selecting an edge
Regression in 5e5285baf6.
2022-03-16 23:42:31 +11:00
31f31496af Document some flags controlling BKE_library_foreach_ID_link behavior. 2022-03-16 13:15:41 +01:00
42e13ea4bf Cleanup: Deprecated field access in outliner_duplicate
Solved by introducing introducing a variant of MEM_cnew which behaves
as a copy-constructor for a trivial types.

Alternative approach would be to surround DNA structs with clang/gcc
diagnostics push/modify/pop so that implicitly defined constructors
and copy operators are allowed to access deprecated fields.

The downside of the DNA approach is that it will require some way to
easily apply diagnostics modifications to many structs, which is not
possible currently.

The newly added MEM_cnew has other good usecases, so is easiest to
use this route, at least for now.

Differential Revision: https://developer.blender.org/D14356
2022-03-16 12:38:23 +01:00
ddc54a2a6b Cleanup: Remove use of deprecated std::iterator in Freestyle
Resolves a fair amount of noisy warnings with default build on macOS.

Tested using render_layer render test which includes Freestyle layer.

Differential Revision: https://developer.blender.org/D14355
2022-03-16 11:56:30 +01:00
fbc36c77b0 Fix error with pose & deselect_all with 5e5285baf6 2022-03-16 21:25:38 +11:00
79ae5f5014 Fix T96386: crash when changing shader to node group in properties
The previous code updated the wrong node tree. The result was that
the new group node did not have the socket that was supposed to
be linked.
2022-03-16 11:23:45 +01:00
a45108840e CMake: Extra flags to ignore for strict compiler
Solves warnings generated by default build on macOS.
2022-03-16 10:33:04 +01:00
2d42187395 View 3D: refactor edit-mode meta-element selection
Meta-element selection now follows conventions for other picking
functions (e.g. EDBM_select_pick).

- Split meta-element find-nearest into a separate function.

- Cycle the meta-element starting from the active & selected
  instead of comparing & setting a static variable.

- Order elements using depth (from front-to-back)
  when cycling multiple elements.
2022-03-16 20:09:55 +11:00
9df27e7f00 Fix object centers & geometry selecting meta-elements in edit-mode 2022-03-16 19:57:47 +11:00
ebd50e7f3a DRW: Expose stencil view in gpu_wrapper 2022-03-16 09:08:29 +01:00
0241227a06 Cleanup: DRW: Fix comments in DRW_gpu_wrapper 2022-03-16 09:07:57 +01:00
fd57ab3dd8 DRW: Add support for compute indirect command.
This just expose the GPU API through DRW.
2022-03-16 09:06:18 +01:00
91c5dd21a2 GPU: Add indirect dispatch support.
This uses a StorageBuf as the source of indirect dispatch argument.
The user needs to make sure the parameters are in the right order.

There is no support for argument offset for the moment as there is no
need for it. But this might be added in the future.

Note that the indirect buffer is synchronized at the backend level. This is
done for practical reasons and because this feature is almost always used
for GPU driven pipeline.
2022-03-16 09:01:36 +01:00
01118f0e53 GPU: StorageBuf: Add method to clear the buffer in place.
This is a faster way to clear a buffer instead of reuploading new data.
It is equivalent to `memset` and runs directly on the GPU.

This is better to clear huge buffers and to avoid the sync cost of data upload.
2022-03-16 08:42:12 +01:00
aa77d35cff Cleanup: SSBO: Rename ubo to ssbo in arguments. 2022-03-16 08:38:33 +01:00
2bcf75d6cc GPU: Add support for stencil buffer texturing mode.
This adds the possibility to read the stencil buffer inside shaders.
This is only available on GL 4.3 so use it accordingly.
2022-03-16 08:36:42 +01:00
00caf993f2 GL: Check texture framebuffer feedback only if not using compute pipeline.
This was getting in the way in multiple instances. Compute shaders dispatch
are still made in the presence of the last bound framebuffer even if they
do not interact with it.
2022-03-16 08:24:54 +01:00
4f37b548bd Cleanup: de-duplicate struct declaration
Also use boolean instead of int.
2022-03-16 15:55:10 +11:00
8cfdad99a0 Cleanup: incorrect comments, use C comments 2022-03-16 15:30:22 +11:00
24ada9c960 Cleanup: Remove volatile from RenderResult and related APIs
Volatile fields were introduced to the RenderResult struct years ago[1].

However, volatile is most likely not doing what it was intended to do
in this instance, and is problematic when moving files to c++ (see
discussion from D13962). There are complex rules around what happens to
these fields but none of them guarantee what the above commit alluded to.

This patch drops the volatile and cleans up the APIs surrounding it.

[1] rB7930c40051ef1b1a26140629cf1299aa89eed859

Passing on all platforms:
https://builder.blender.org/admin/#/builders/18/builds/338

Differential Revision: https://developer.blender.org/D14298
2022-03-15 21:12:49 -07:00
f1501ac060 Cleanup: rename variables in view3d_select_exec
- Rename 'location' to 'mval', typically used for region cursor coords.
- Rename 'retval' to 'changed', typically used for operators
  when their return value depends on a change being made.
2022-03-16 15:05:05 +11:00
5e5285baf6 View 3D: move picking arguments into a struct & minor refactor
- Add SelectPick_Params struct to make picking logic more
  straightforward and easier to extend.

- Use `eSelectOp` instead of booleans (extend, deselect, toggle)
  which were used to represent 4 states (which wasn't obvious).

- Handle deselect_all when pocking instead of view3d_select_exec,
  de-duplicate de-selection which was already needed in when replacing
  the selection in picking functions.

- Handle outliner update & notifiers in the picking functions
  instead of view3d_select_exec.

- Fix particle select deselect_all option which did nothing.
2022-03-16 14:48:25 +11:00
9a763d24f2 Fix missing update selecting 3D text-box 2022-03-16 13:40:16 +11:00
be7855591e Cleanup: rename cnt to count
Follow naming from T85728.
2022-03-16 11:58:22 +11:00
379bd6d50c Curves: Port count spline length output to new data-block
This fixes T96487 in a similar way to 5791835678,
and also removes the conversion to old curve type for the
"Point Count" output.
2022-03-15 16:22:36 -05:00
d8e3bcf770 Outliner: Display buttons to edit library override properties
As proposed in T95802, this adds buttons to a new column on the right to modify
the override in the Library Override display mode. Some further usability
improvements are planned. E.g. this does not yet expand collections (modifiers,
constraints, etc) nicely or group modified properties of a modifier together.
Vector properties with more than 3 items or matrices aren't displayed nicely
yet, they are just squeezed into the column. If this actually becomes a problem
there are some ideas to address this.

Differential Revision: https://developer.blender.org/D14268
2022-03-15 18:48:52 +01:00
7f77bd95d9 Fix T96381: Cycles GPU wrong render with camera inside multiple volumes 2022-03-15 18:42:08 +01:00
c2f9133b29 Fix Cycles kernel error on Metal after recent changes 2022-03-15 17:56:45 +01:00
630d2b6497 Cycles: allow Adaptive Sampling with Scrambling Distance
While the correlation may not work well with adaptive sampling, in practice
this appears to work ok in most cases

Automatic scrambling distance uses the minimum samples from adaptive sampling,
which provides a good default estimate to avoid artifacts.

Contributed by Alaska.

Differential Revision: https://developer.blender.org/D13325
2022-03-15 16:12:13 +01:00
f9d3632cde Cycles: change Scrambling Distance Multiplier to a soft limit
This allows users to type in values larger than 1, for use in conjunction
with automatic scrambling distance.

Contributed by Alaska.

Differential Revision: https://developer.blender.org/D13580
2022-03-15 16:12:13 +01:00
af51b0d8d8 Fix T96417: Cycles issue with multiscatter GGX and self intersection avoidance
When the light direction is not pointing away from the geometric normal and
there is a shadow terminator offset, self intersection is supposed to occur.
2022-03-15 16:12:13 +01:00
19bff8eb51 Fix T96263: command line rendering affected by current scene subframe 2022-03-15 16:12:13 +01:00
2613a2552d Fix some properties missing in the UI for new Curves object type
Missed some renames from HAIR to CURVES.
2022-03-15 16:12:13 +01:00
3bb4597b2d Disable GPU subdivision if the maximum number of SSBO binding is reached
Some old platforms and drivers have limited amount of SSBO binding per
compute shader. This disables GPU subdivision if we cannot possibly
bind all required buffers within this limit.

For now the maximum number of buffers used by the GPU code is hardcoded,
but will be programmatically detected when shader creation is automated.

Ref D14337
2022-03-15 16:07:32 +01:00
45b637e1e7 GPU capabilities: detect max SSBO bindings
This adds detection of the maximum number of shader storage buffer
bindings that is supported on the current platform. This can be
useful to turn off features that require compute shaders but use
more buffer bindings than available.

Differential Revision: https://developer.blender.org/D14337
2022-03-15 16:04:41 +01:00
e08180fdab Fix slow tracking of long sequences
The performance issue was noticeable when tracking a lot of tracks
which are using keyframe pattern matching. What was happening is that
at some cache gets filled in and the furthest away frame gets removed
from the cache: the frame at marker's keyframe gets removed and needs
to be re-read from disk on the next tracking step.

This change makes it so frames at markers' keyframes are not removed
from cache during tracking.

Steps to easily reproduce:
- Set cache size to 512 Mb.
- Open image sequence in clip editor
- Detect features
- Track all markers

Originally was reported by Rik, thanks!
2022-03-15 15:50:40 +01:00
2156841c8c Fix T96452: Armature corrupted after undoing 'Join' operation.
Modified source Armature ID in the join operation was not properly
tagged as such for the depsgraph (and therefore memfile undo)..

Issue caused/revealed by rBe648e388874a.

Should be backported to 3.1 should we make a corrective release.
2022-03-15 15:02:39 +01:00
256d36683b Cleanup: remove redundant 'extern StructRNA' declarations
After rB9b298cf3dbec, the `StructRNA` declarations can now be accessed via
`RNA prototypes.h`

Also, since all redundated declarations are now removed,
`_WM_MESSAGE_EXTERN_BEGIN` and `_WM_MESSAGE_EXTERN_END` are also no
longer needed.

Differential Revision: https://developer.blender.org/D14342
2022-03-15 09:14:38 -03:00
7ec2c5c10b Cleanup: Remove confusing double negation in RNA helper function
Much more readable that way.
2022-03-15 13:11:41 +01:00
46b35c6836 Cleanup: remove accidental shallow mesh copy 2022-03-15 12:32:18 +01:00
49fc4449e7 Fix T96357: Issue clicking on stem of arrow gizmos to scale on axis
Caused by 0cb5eae9d0 which restored
support for 3D depth when selecting gizmos - making it difficult
to select single lines drawn in front of other gizmos.
Previously the first hit was always used.

Resolve by using a margin around arrow stems when selecting
which was already done for 2D arrows.
2022-03-15 20:03:33 +11:00
a0a572ce8b Cleanup: correct unbalanced doxy sections 2022-03-15 17:29:54 +11:00
683c130b06 Docs: correct doc-string for BPY_driver_reset
Remove outdated reference to "pydrivers.py", also document BPY_DECREF.
2022-03-15 15:31:11 +11:00
8c60050d30 Cleanup: comments in bpy_driver.c, minor corrections 2022-03-15 15:20:38 +11:00
7c24804d62 Cleanup: de-duplicate Py_DECREF when evaluating PyDrivers 2022-03-15 15:06:25 +11:00
977c958242 Fix memory leak when there is an error evaluating a PyDriver
In practice users are unlikely to ever run into this error.
2022-03-15 15:03:27 +11:00
3cbf20228e Cleanup: use single back-ticks in regular comments
Double back-ticks are used for RST literals.
2022-03-15 14:53:49 +11:00
f410efbda0 UI: expose "Dolly View" in the menu
This is mainly to expose the shortcut to make Dolly discoverable.
2022-03-15 13:01:10 +11:00
Iyad Ahmed
fc259d4c30 Fix gpu.types.GPUTexture not passing data buffer to 3D textures
Missed in rB4430e8a00810ca8df2fa20029c4cb8078e8cdbe6

Reviewed By: mano-wii

Differential Revision: https://developer.blender.org/D14333
2022-03-14 16:06:32 -03:00
d4e46c13cc Geometry Nodes: Add named attribute nodes behind experimental flag
This commit adds three nodes:
- `Remove Attribute`: Removes an attribute with the given name
- `Named Attribute`: A field input node
- `Store Named Attribute`: Puts results of a field in a named attribute

They are added behind a new experimental feature flag, because further
development of attribute search and name dependency visualization will
happen as separate steps.

Ref T91742

Differential Revision: https://developer.blender.org/D12685
2022-03-14 11:48:11 -05:00
a5578351c3 Auto-generate RNA-structs declarations in RNA_prototypes.h
So far it was needed to declare a new RNA struct to `RNA_access.h` manually.
Since 9b298cf3db we generate a `RNA_prototypes.h` for RNA property
declarations. Now this also includes the RNA struct declarations, so they don't
have to be added manually anymore.

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

Reviewed by: brecht, campbellbarton
2022-03-14 17:08:46 +01:00
cc98b40f87 Cleanup: Clang tidy 2022-03-14 10:55:48 -05:00
9b298cf3db RNA: Generate property declerations header, solving msg-bus C++ incompatibility
Lets `makesrna` generate a `RNA_prototypes.h` header with declarations for all
RNA properties. This can be included in regular source files when needing to
reference RNA properties statically.

This solves an issue on MSVC with adding such declarations in functions, like
we used to do. See 800fc17367. Removes any such declarations and the related
FIXME comments.

Reviewed By: campbellbarton, LazyDodo, brecht

Differential Revision: https://developer.blender.org/D13837
2022-03-14 16:50:49 +01:00
cff6eb6580 Cleanup: Remove duplicate Bake modifier code
This patch remove all duplicate code for the same Bake modifier logic.

Still some modifiers need custom bake functions and cannot use this generic bake.
2022-03-14 16:13:59 +01:00
8c4ddd5dde Fix dead-lock in movie cache
Steps to reproduce:
- Add image sequence to movie clip editor.
- Set cache limit to a low value in the user preferences.
- Playback until old frames starts to be removed from cache.
- Jump to the beginning of the image sequence.

The reason of dead-lock comes from two factors:
- Due to global nature of the cache limiter calls needs to be
  guarded with locks.
- Image buffers stored in the cache can have their own cache
  (which is used for color management).

Didn't find a better solution than to use recursive lock.
Kind of makes sense since the thread-guardable resource is
recursive (moviecache can have nested moviecaches).

Differential Revision: https://developer.blender.org/D14331
2022-03-14 14:46:49 +01:00
e0241e0860 Convert moviecache to C++ 2022-03-14 14:46:22 +01:00
a5cd1799fc Cleanup: Deduplicate code in Multiply modifier 2022-03-14 11:35:26 +01:00
8eb189925e Cleanup: Make more obvious from the name that function is not public 2022-03-14 11:21:23 +01:00
7306417ae4 Revert "Animation: Sensible frame range for motion paths"
This reverts commit 1558b270e9.

An earlier commit (rB101fadcf6b93c) introduced some new functionality,
which was overlooked in reviewing this commit & got broken.

Will re-commit after the issue has been fixed.

Ref: D13687
2022-03-14 11:17:45 +01:00
Henrik Dick
4045b3d7b6 GPencil: Fix offset modifier negative scale thickness
If the scale in the offset modifier was set to a value lower than -1,
the object would get mirrored. The problem was, that the thickness
was set to 0 by that. This fix makes the thickness calculation only
use the absolute values.

Differential Revision: http://developer.blender.org/D14324
2022-03-14 11:11:22 +01:00
bf5e9ef2df Fix T96402: fix case when material output is contained in node group
For now just assume that a node group without output sockets is
an output node. Ideally, we would use run-time information stored
on the node group itself to determine if the group contains a
top-level output node (e.g. Material Output). That can be
implemented separately.

In the larger scheme of things, top-level outputs within node
groups seem to break the node group abstraction and reusability
a bit.
2022-03-14 10:49:35 +01:00
c6642f06ab Fix T96395: NDOF entries prevent loading of custom keymaps in 3.2
Even though the default key-map didn't use NDOF types some key-maps did.
2022-03-14 20:42:12 +11:00
82e7956f12 Fix T96396: cannot set active node group output with Python
This is essentially the same fix as in rB22a341d9d8d3d337f79df228ab2e4e0726f81430.
2022-03-14 10:21:47 +01:00
b3d0abd893 Fix T96378: B-Bone selection fails in pose-mode
Regression in 3267c91b4d.
2022-03-14 20:10:24 +11:00
d7dd7403a8 WM: avoid hard coded modifier key checks in object.hide_collection
These checks aren't always valid when there are multiple events
in the queue.
2022-03-14 15:50:06 +11:00
541ba68991 Cleanup: use size_t for BLF text API functions
Also minor cleanup to txt_sel_to_buf:

- Use memcpy instead of strncpy as the strings don't contain nil bytes.
- Replace while loops with for loops.
2022-03-14 14:25:33 +11:00
a5571fd0e8 Cleanup: spelling 2022-03-14 14:25:32 +11:00
6ea1455ce3 Fix mistake in 4c951bfa82
Removed WITH_SYSTEM_GLEW by mistake, thanks to @The_Orb for spotting.
2022-03-14 14:25:31 +11:00
b959f603da Fix T96267: Sidebar Tab Font Size Correction
Correction to the calculation of font size used for the tabs on the
Sidebar so that they are always the same size as other content on the
panel.

See D14322 for more details.

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

Reviewed by Brecht Van Lommel
2022-03-13 17:08:15 -07:00
4ec1c8bc9c Cleanup: Use helper variable, const argument 2022-03-13 16:53:48 -05:00
25b4e41875 Curve: Store NURBS basis cache as a single vector
Instead of allocating a vector of the basis weights cache for
each evaluated point, allocate a single vector for all of the
weights. This should reduce memory usage by avoiding the
overhead of storing many vectors. I noticed a small performance
improvement to evaluated position calculation with an order of 5,
which is larger than `Vector`'s default inline buffer capacity.

This change is possible because of previous commits that
made the basis cache for each evaluated point always have
the same "order" size.
2022-03-13 16:53:48 -05:00
3c8182409c Cleanup: Simplify NURBS basis cache arguments
Only pass a mutable span and a return argument to the calculation
function, so it's simpler and doesn't worry about where either are
stored.
2022-03-13 16:53:48 -05:00
29dc6fb1c1 Curve: Remove temporary buffer during NURBS evaluation
Currently a single buffer is used as working space for all evaluated
points. In order to make evaluations more independent, opening
options like multi-threading in the future, instead use a separate
array for each call. Using an inline buffer capacity higher than
the default allows a few percent performance improvement, and removes
allocations for every evaluated point.
2022-03-13 16:53:48 -05:00
34a61ceeaa Cleanup: Remove unnecessary NURBS optimization
The step after calculating the NURBS basis for a single evaluated
point trimmed extra zeroes from the weights. However, in practice
this rarely did anything, only for the first and last evaluated point
of certain knot configurations. Remove it in order to simplify code.

Also use a separate span for the result, to clarify its length.
2022-03-13 16:53:48 -05:00
Octave C
3b16530aa1 UI: Fix incoherent brush size in popover menu and brush settings
Previously, the popover menu in sculpt/texture paint mode did not
take into account the `UnifiedBrushSettings` for the unit.

To fix this,  the behavior of `class _draw_tool_settings_context_mode`  is matched
by checking the same conditions when setting up the UI of the right-click popover menu.

Fixes T81616

Reviewed By: #sculpt_paint_texture, pablodp606

Maniphest Tasks: T81616

Differential Revision: https://developer.blender.org/D9168
2022-03-13 17:45:35 -04:00
Yevgeny Makarov
301fac5ded UI: Fix Label alignment in top bar
Label alignment in top bar by using `ui_text_icon_width_ex` instead of `w_hint`

Old:

{F12733743}

New:

{F12733742}

Fixes T61558

Reviewed By: Severin

Maniphest Tasks: T61558

Differential Revision: https://developer.blender.org/D13552
2022-03-13 17:38:55 -04:00
Henrik Dick
a6b5d5bfe8 GPencil: Simplify modifier minimal vert count fix
Lower the minimal vert count for all simplify modes.

Differential Revision: http://developer.blender.org/D14319
2022-03-13 17:21:30 +01:00
Aras Pranckevicius
70720c42c2 Fix T96303: C++ OBJ exporter needs presets and skip modifiers.
This patch, D14303, from Aras Pranckevicius adds presets to the OBJ exporter,
and also adds a checkbox (default on) to apply modifiers before export.
2022-03-13 12:04:52 -04:00
91dbc28363 Cleanup: clang format 2022-03-13 00:49:41 -05:00
f6b7396610 Fix transform gizmo check for shift to constrain to a plane
The eventstate was checked instead of the current event being handled,
causing the check to be invalid in some cases.
2022-03-12 21:29:14 +11:00
a2bb3c4cad GPencil: Fix unreported select error in Normalize operator
The curve selection was wrongly checked.
2022-03-12 10:48:42 +01:00
8617ab153e Fix T96352: Gpencil crash using Normalize Thickness with Curves
The stroke curve data could be NULL.
2022-03-12 10:33:32 +01:00
Dilith Jayakody
39c070ed8f Fix T96229: GN Fillet Node unexpected limit radius behavior for 3 point splines
This commit fixes T96229.

The maximum possible radius was being used for 3 point
splines, regardless of the current radius.

Reviewed By: HooglyBoogly

Maniphest Tasks: T96229

Differential Revision: https://developer.blender.org/D14311
2022-03-12 10:19:26 +05:30
f19582ebf4 UI: Use property split in curves surface panel 2022-03-11 14:57:50 -06:00
db7c4d7a1c Cleanup: Use new enum for NURBS curve knots modes
Move the definition of the enum to `Curves` DNA, since the values
will be saved in files, and ongoing development needs to use this.
2022-03-11 14:55:42 -06:00
bd9f94e917 Fix T94692: Show Cached OneDrive Thumbnails
When OneDrive files are offline, show preexisting thumbnails.

See D13930 for details.

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

Reviewed by Julian Eisel
2022-03-11 10:05:16 -08:00
22807d2075 Curves: Move constructor/assignment
Add the ability to move `CurvesGeometry` without copying its attributes
and data. The benefit is more intuitive management of the data-block
copying, and less overhead for copying in some cases. The "moved-from"
source is left in an empty but valid state. A test file is added to test
the move constructor.
2022-03-11 11:34:03 -06:00
Ethan-Hall
3b28c785d4 Cycles: show viewport hair settings when using Cycles
Before this patch, users had to switch render engines just to change how the
hair should be displayed in solid and material preview viewport shading modes.

Differential Revision: https://developer.blender.org/D14290
2022-03-11 18:27:58 +01:00
Ethan-Hall
3902bebf18 Cycles: make smart interpolation fallback to cubic for GPU
Matching CPU and Eevee behavior.

Differential Revision: https://developer.blender.org/D14296
2022-03-11 18:27:58 +01:00
1842cef210 Fix wrong line width when using Show Lines in Histogram scope
By not resetting the line width, other scopes were using the
wrong line thickness.

Contributed by RedMser.

Differential Revision: https://developer.blender.org/D12030
2022-03-11 18:27:58 +01:00
Hallam Roberts
3da84d8b08 Cleanup: use M_PI_2 and M_PI_4 where possible
The constant M_PI_4 is added to GLSL to ensure it works there too.

Differential Revision: https://developer.blender.org/D14288
2022-03-11 18:27:58 +01:00
62a0984d72 Cleanup: fix source typos homogenous->homogeneous
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D14306
2022-03-11 18:27:58 +01:00
e1a1dc868b Cleanup: fix source comment typos
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D14307
2022-03-11 18:27:58 +01:00
dbd9472ef5 Fix: Assert in set spline type node after recent commit
My own error when committing 0602852860. It appears that
the "Endpoint" knots modes should be handled together, otherwise
out of bounds array access is possible.
2022-03-11 11:27:34 -06:00
ae3c8bc9f0 Fix T85689: Replace SHGetFileInfoW for Drive Name
Win32: Replace SHGetFileInfoW as means to get friendly display names
for volumes because it causes long pauses for disconnected remote
drives.

See D14305 for more details.

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

Reviewed by Brecht Van Lommel
2022-03-11 09:26:59 -08:00
5c86f0369c Fix: Deleting vertex group attribute can change original mesh
There was an error with the attribute API implementation for vertex
groups. If the vertex group layer referenced an original mesh, it wasn't
properly duplicated for writing.
2022-03-11 11:25:59 -06:00
28434dab0c Cleanup: Use helper variable
For a NURBS curve, the order is just the degree plus one.
So just pass around the degree instead of always subtracting one.
2022-03-11 10:46:48 -06:00
02f77cbf99 GPUTexture: Fix bug in texture view creation
The switch case was based on an uninitialized value.
2022-03-11 16:46:32 +01:00
9097c97767 Fix T96243: Workbench Curvature not rendering in background.
When rendering using the command line the curvature wasn't rendered. The reason
was that the ui_scale wasn't initialized and therefore the same pixels where
sampled to detect the curvature. This is fixed by setting the ui_scale to 1 for any
image render.
2022-03-11 13:52:12 +01:00
9bee8e46a1 Event System: limit early evaluation of drag actions to mouse buttons
Change early drag evaluation added in
1f1dcf41d5 to only apply to drag events
from mouse buttons. Otherwise pressing two keyboard keys at one would
create a drag event for the first pressed key. While this didn't cause
any bugs as far as I know, this behavior makes most sense for drags
that come from cursor input.
2022-03-11 23:06:45 +11:00
c87c12b2a4 Event System: only set press values in win->eventstate
Only set press events in the windows eventstate, not the current event
since it's not useful for these to be set current events press values.
This makes it possible for a press event to access values for the
previous press.
2022-03-11 23:04:11 +11:00
789b1617f7 Fix out of order event handling when calling operators from gizmos
Activating a gizmo used the windows eventstate which may have values
newer than the event used to activate the gizmo.

This meant transforms check for the key that activated transform
could be incorrect.

Support passing an event when calling operators to avoid this problem.
2022-03-11 22:49:47 +11:00
e20fe18706 Correct error in 1032f111d0
Thanks to Jacques Lucke for spotting.
2022-03-11 22:37:16 +11:00
f4c8b4eb3e Fix threading conflict with movie cache line
It was possible that a render thread will be freeing cache while the
interface is iterating over cache items to build cache line.

Found while looking into T94738. It might be a fix, but I am unable
to reproduce the original issue, so can not know for sure whether
there is something else going or or not.
2022-03-11 12:34:37 +01:00
f6564df351 Cleanup: remove duplicate compiler attribute 2022-03-11 15:29:11 +11:00
cf58648409 Correct error in d2222d5b2c 2022-03-11 15:27:34 +11:00
d2222d5b2c RNA: use a function to access the nurbs error message
It makes more sense to use a function in this case as this
creates an error message which is not data associated with
the NURBS curve.
2022-03-11 15:21:30 +11:00
8cc5483331 Text: use simplified logic for txt_to_buf
This function was copied from txt_sel_to_buf, including unnecessary
complexity to support selection as well as checks for the cursor
which don't make sense when copying the whole buffer.

Use a simple loop to copy all text into the destination buffer.
2022-03-11 15:14:14 +11:00
231eac160e PyAPI: use C/RNA API for Text.from_string/to_string
Use faster C code for getting the buffer from text.
2022-03-11 14:44:02 +11:00
1032f111d0 RNA: support functions returning allocated strings
Now it's possible for a C/RNA function to return a dynamic string,
The PROP_NEVER_NULL flag is also supported so a NULL string returns
None in Python.
2022-03-11 14:42:39 +11:00
f527d6582b Cleanup: remove unused variable 2022-03-11 12:38:34 +11:00
d73726dbbe Cleanup: use doxy sections for the outliner 2022-03-11 12:00:08 +11:00
0327a464ba Fix dragging items in the outliner
Regression in b8960267dd,
it's important for box-select to use the drag start to check
if the cursor is over an icon.
2022-03-11 11:46:23 +11:00
Laurynas Duburas
0602852860 Curve: Improve NURBS knot generation modes
This patch enables all 8 combinations of Nurbs modes: Cyclic,
Bezier and Endpoint. Also removes restriction on Bezier Nurbs order.

The most significant changes are mode combinations bringing new
meaning. In D13891 is a scheme showing NURBS with same control
points in a modes, and also further description of each possible case.

Differential Revision: https://developer.blender.org/D13891
2022-03-10 18:34:27 -06:00
27fb63381e Fix T94121: PyAPI: ID property group returns wrong type with iter()
Regression in 265d97556a.
Where iterating directly on a property group failed, e.g.:
`iter(group)`, tests missed this since only `group.keys()`
was checked.
2022-03-11 10:26:27 +11:00
4a8bd31825 Cleanup: use doxy sections in image.cc
Also minor improvements & clarifications to comments.
2022-03-11 09:41:48 +11:00
d449deec21 Cleanup: use enum for local versioning enum 2022-03-11 09:27:37 +11:00
Germano Cavalcante
e3de755ae3 Transform/UI: individualize the option to use snap per editor type
`3DView`'s `use_snap` option has little or nothing to do with using
snapping in `UV`, `Nodes` or `Sequencer`.
So there are no real advantages to keeping these options in sync.

Therefore, individualize the option to use snap for each "spacetype".

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D13310
2022-03-10 18:47:38 -03:00
edcb2ad7b3 Fix: Handle handles reset when realizing with other curve types
The result handle attributes for non-bezier types are zeroed.
By mistake though, the entire array was zeroed, not just the
area corresponding to that curves source.
2022-03-10 15:42:30 -06:00
fe3a9fcce1 Fix incorrect meta strip background color
When viewing meta strip, it had orange color. This was caused by
overflow because of hard-coded offset. Theme got darker, and background
was also set again further in code, but redundant drawing was removed in
f4492629ea.
2022-03-10 20:26:21 +01:00
3f91e7d779 Curves: actually delete curves with Delete brush
Previously, the position was just set to zero as part of the prototype.

Differential Revision: https://developer.blender.org/D14291
2022-03-10 18:06:43 +01:00
22a341d9d8 Fix T96292: unable to set active material output using Python
Differential Revision: https://developer.blender.org/D14301
2022-03-10 18:04:07 +01:00
338fe9e2b5 Cleanup: Reduce duplication in realize instances code
Realizing and copying attributes of meshes, curves, and points are very
similar processes, but currently the logic is duplicated three times in
the realize instances code. This commit combines the implementation
for copying generic attributes and creating the result id attribute.

The functions for threaded copying and filling should ideally be in
some file elsewhere, since they're not just useful here. But it's not
clear where they would go yet.

Differential Revision: https://developer.blender.org/D14294
2022-03-10 09:37:56 -06:00
8cdee3a6d4 Fix T93710: Artifacts denoising hi-res images using OPtiX
Caused by an integer overflow in the tiling utilities of OptiX SDK.

Seems for now it's easier to copy and modify code to our sources so
that we don't need to bump SDK version requirement (which might lead
to an increased driver requirement as well).

There are still some fixes needed from a newer driver to have such
denoising to work properly: Windows requires 511.79, Linux 510.54.

Thanks Patrick for investigation!

Differential Revision: https://developer.blender.org/D14300
2022-03-10 16:17:59 +01:00
Ethan-Hall
34d8ef8fa4 Fix: closest image texture interpolation inconsistent in geometry nodes
The `-0.5f` offset is inconsistent with shader nodes.
See D14235 for an example file.

Differential Revision: https://developer.blender.org/D14235
2022-03-10 11:38:08 +01:00
7b62203fc7 IK: make Ik chain length non-animatable
Mark the chain length of regular and spline IK constraints
non-animatable. Changing the IK chain length requires a rebuild of
depsgraph relations. This makes it unsuitable for animation. It's better
to simply avoid having this property animatable than to allow animation
but produce unstable results.

Ref: T96203
2022-03-10 11:34:51 +01:00
1f1dcf41d5 Event System: key-press while dragging now activates drag first
When dragging with a large threshold (using a tablet for example),
it's possible to press another key before the drag threshold is reached.

So tweaking then pressing X would show the delete popup instead of
transforming along the X-axis.

Now key presses while dragging cause the drag event to be evaluated
before the key press.

Note that to properly base the mouse-move event on the previous
state the last handled event is now stored in the window.
Without this the inserted mouse-move event may contain invalid values
from the next event (it's modifier state or other `prev_*` values).

Requested by @JulienKaspar.
2022-03-10 21:26:15 +11:00
ef6d108b75 Fix T96279: 'Emulate 3 button mouse' fails to emulate MMB
Regression in 08d8eee006 caused
emulate-middle mouse to work once, clearing the modifier key.

Now the modifier key from emulated mouse events is never stored
in the windows event-state.
2022-03-10 20:50:58 +11:00
b33d38ebd9 Cleanup: de-duplicate event customdata freeing logic 2022-03-10 16:44:47 +11:00
8c3aee2faf Cleanup: use SPDX license header 2022-03-10 16:27:18 +11:00
36dd3f42bc Cleanup: use 'WM_file_' prefix for file operations 2022-03-10 16:27:18 +11:00
1829232598 Cleanup: spelling in comments & some minor clarifications 2022-03-10 16:27:18 +11:00
0ef8a6179d Cleanup: Move image.c to c++
Passing on all platforms:
https://builder.blender.org/admin/#/builders/18/builds/329

Differential Revision: https://developer.blender.org/D13962
2022-03-09 21:03:02 -08:00
f379943734 Cleanup: Simplify/deduplicate curves built-in attribute access
Separate two templated functions that deal with custom data so that
each built-in attribute accessor doesn't need the same boilerplace and
logic.
2022-03-09 22:59:39 -06:00
24c543d4af Fix: Add missing break 2022-03-09 10:27:08 -06:00
115ff08fdb Fix: Use "construct" instead of "assign" for uninitialized memory
The realize instances code used "assign", but the attribute buffers on
the result aren't necessarily initialized. This doesn't make a difference
for trivial types like `int`, but it would with more complex types.
2022-03-09 10:23:17 -06:00
6c6f591f90 Curves: Port realize instances node to the new data-block
This commit replaces the temporary conversion to `CurveEval` with
use of the new curves data-block. The end result is that the
process looks more like the other components-- somewhere in between
meshes and point clouds in terms of complexity.

The final result is that the logic between meshes and curves is
very similar. There are a few different strategies to reduce
duplication here, so I'll investigate that separately.

There is some special behavior for the radius and handle position
attributes. I used the attribute API to store spans of these
attributes temporarily. Using access methods on `CurvesGeometry`
would be reasonable to, storing spans separately feels a bit more
predictable for now though.

There should be significant performance improvements in some cases,
I haven't tested that specifically though.

Differential Revision: https://developer.blender.org/D14247
2022-03-09 09:58:02 -06:00
39c50d8f31 Outliner: Ensure compiler error when passing wrong tree-element to macro
Passing a `TreeElement *` instead of its `TreeStoreElement *` to
`TSELEM_OPEN()` would seem to work but cause a bug. Add a type check
that will cause a compiler error if it fails.
2022-03-09 15:28:16 +01:00
8e3a58578a Outliner: Correct check for element culling
I don't see a reason to use 2x the element height for the "in-view"
checks. That seems incorrect (although shouldn't cause issues). So
remove that, I don't expect behavior changes.
2022-03-09 15:23:51 +01:00
c4d3d10401 Cleanup: Deduplicate Outliner item culling logic
For whatever reason the "in-view" check was using 2x the element height.
From what I can see this isn't needed, so I'll remove it in a follow-up
commit.
2022-03-09 15:23:51 +01:00
beaf2baeff Cleanup: fix wrong spelling of texture and indentation
Contributed by luzpaz.

Ref D14271, D14270
2022-03-09 15:07:38 +01:00
Ethan-Hall
ef3d76fbaa Fix wrong detection of alpha for grayscale images, after recent changes
Differential Revision: https://developer.blender.org/D14286
2022-03-09 14:53:07 +01:00
6be665926c LibOverride/Outliner: Restrict further operations over liboverrides.
Restrict a lot deletion/moving around of liboverride objects and
collections in the Outliner.

While some of those operations may be valid in some specific cases, in
the vast majority of cases they would just end up breaking override
hierarchies/relationships.

Part of T95708/T95707.
2022-03-09 12:50:04 +01:00
6a7066c2c1 LibOverride: Add a 'is hierarchy root' macro check. 2022-03-09 12:50:04 +01:00
4da282a161 Curves: rename initial brushes
The brushes that are still called "Test" still need to be changed
until they can get their correct name.

Ref T96259.
2022-03-09 11:33:33 +01:00
010ea688f1 Fix T96233: Crash with gpencil data with vertex groups
Blender crashes when a multi-user grease pencil object has vertex
groups and is modified by modifiers, layer transform or parenting.

The fix makes sure that we copy the vertex group names list.

Reviewed By: antoniov

Maniphest Tasks: T96233

Differential Revision: https://developer.blender.org/D14275
2022-03-09 11:22:51 +01:00
04e89c5b06 Fix T96165: Incorrect render of barcelone scene with BVH2
Fix T95462: Partly transparent objects appear to glow in the dark

The issue was caused by incorrect check for exceeded number
of transparent bounces: the same maximum distance was used
for picking up N closest intersections and counting overall
intersections count.

Now made it so intersection count is using ray distance which
matches the way how Embree and OptiX implementation works.

Benchmark result:
{F12907888}

There is no big time difference in the pabellon scene. The
Victor scene timing doesn't seem to be very reliable as the
variance in time across different benchmark runs is quite
high.

Differential Revision: https://developer.blender.org/D14280
2022-03-09 10:37:19 +01:00
801d7b4921 Fix T95738: wrong "Bottom" selection for cone without base
Original patch by @lone_noel with changes by me.

Differential Revision: https://developer.blender.org/D14102
2022-03-09 10:34:59 +01:00
1f9d85f56a Fix cursor drag failing to use click-start
Error in b8960267dd,
the flag was cleared before use.
2022-03-09 17:18:31 +11:00
9416004092 Cleanup: use doxygen comments & sections for animation files 2022-03-09 16:29:22 +11:00
136f0910ff Fix T96250: Invalid default for uv_relax_method
Correct the default & version existing files.
2022-03-09 16:10:19 +11:00
20f53f6984 Correct assert in 399ac1ff11
Pass NULL instead of an empty string.
2022-03-09 13:43:39 +11:00
399ac1ff11 Fix subtype & default for keying set operator properties
Error in 1a12c9edab,
also correct descriptions.
2022-03-09 13:23:00 +11:00
e55f4657f7 Fix T89560: Keymap editor no longer shows keying set dropdown
Include built-in keying sets when ANIM_keying_sets_enum_itemf is called
without a context to allow binding keys to built-in keying sets.
2022-03-09 13:02:29 +11:00
2146256563 Cleanup: use ELEM macro 2022-03-09 10:13:43 +11:00
626c844105 Cleanup: rename wmEvent.prev_click_* to prev_press_*
At the time of naming these members only some event types generated
click events so it made some sense to differentiate a click.

Now all buttons support click & drag it's more logical to use the
prefix "prev_press_" as any press event will set these values.

Also update doc-strings.
2022-03-09 09:25:14 +11:00
353376c783 Fix T92331: Duplicated Window Should Not Be Modal
Operator area_dupli_invoke should not create modal windows.

See D14253 for details.

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

Reviewed by Brecht Van Lommel
2022-03-08 13:57:35 -08:00
Aleksi Juvani
eb326c7b40 Attributes: Implement CustomData interpolation for boolean data type
This commit fixes an issue, where for instance, when merging vertices
with the "Merge by Distance" geometry node, the resulting vertices had
their boolean attributes set unpredictably.

Boolean attributes are implemented as custom data, and when welding
vertices, the custom data for the resulting vertices comes from
interpolating the custom data of the source vertices.

This commit implements the missing interpolation function for the
boolean custom data type. This interpolation function is implemented in
terms of the logical or operation, that is to say, if any of the source
vertices (with a weight greater than zero) have the boolean set, the
boolean will also be set on the resulting vertex.

This logic matches 95981c9876.

In geometry nodes, attribute interpolation generally does not use the
CustomData API for performance reasons, but other areas of Blender
still do.

Differential Revision: https://developer.blender.org/D14172
2022-03-08 15:51:53 -06:00
521d4190a0 Fix T96146: Subdivide curve node uninitialized dangling handles
Handles of non-cyclic bezier curves were not initialized.
Now properly copy the dangling handle positions and types
from the source curve.
2022-03-08 15:45:37 -06:00
b8960267dd Event System: drag events no longer default to the drag start location
This avoids transform jumping which is a problem when tweaking values a
small amount. A fix for T40549 was made box-select used the location
when the key was pressed.

While it's important for box-select or any operator where it's expected
the drag-start location is used, this is only needed in some cases.
Since the event stores the click location and the current location,
no longer overwrite the events real location. Operators that depend on
using the drag-start can use this location if they need.

In some cases the region relative cursor location (Event.mval) now needs
to be calculated based on the click location.

- Added `WM_event_drag_start_mval` for convenient access to the region
  relative drag-start location (for drag events).
- Added `WM_event_drag_start_xy` for window relative coordinates.
- Added Python property Event.mouse_prev_click_x/y

Resolves T93599.

Reviewed By: Severin

Ref D14213
2022-03-09 08:38:42 +11:00
Hallam Roberts
156e07232e Geometry Nodes: Tiny optimization to UV Sphere primitive
Prevents a few unneeded calls to `std::sin`, with an observed
performance improvement of about 1 percent.

Differential Revision: https://developer.blender.org/D14279
2022-03-08 14:39:58 -06:00
d09695b4dd Cleanup: Clang tidy 2022-03-08 13:28:22 -06:00
90c3147e05 Cleanup: Correct comment
Normals aren't stored in custom data anymore, nor are they stored in
MVert for comparisons.
2022-03-08 12:31:21 -06:00
c7ff99b100 Merge branch 'blender-v3.1-release' 2022-03-08 12:19:50 -06:00
c77597cd0e Fix T95843: Invalid mesh runtime data after sculpt undo
When the geometry of the sculpt mesh was replaced when restoring from
a full undo step, the runtime data was not cleared (including any
normals, triangulation data, or any other cached derived data).
In the report, only the invalid normals were observed.

The fix is to simply clear these caches. Later they will be reallocated
and recalculated if necessary. Since the whole mesh replaced here
anyway, this should be a safe fix.

Differential Revision: https://developer.blender.org/D14282
2022-03-08 12:16:42 -06:00
ffea47530d Merge branch 'blender-v3.1-release' 2022-03-08 18:46:23 +01:00
7add8163e4 Blender 3.1 - version bump -> release 2022-03-08 18:36:00 +01:00
b154b8c6f8 Merge branch 'blender-v3.1-release' 2022-03-08 18:34:09 +01:00
b217eb73f5 Licenses: Attribution document for Blender 3.1 2022-03-08 18:27:04 +01:00
50bd8bb175 Cleanup: Remove extra . at the end of RNA string
The strings must not end with point.
2022-03-08 16:55:29 +01:00
c305b88aac Docs: 3.1 release description for Linux appdata 2022-03-08 16:55:19 +01:00
944122d49f Cleanup: Use ELEM macro 2022-03-08 16:44:03 +01:00
62885637fb Cleanup: Make format 2022-03-08 16:41:30 +01:00
Marc Chéhab
e74838d0d0 GPencil: New "Additive" mode for build modifier
The new mode only builds the new strokes in each frame. 

The code is assuming somebody uses "additive" drawing, so that each frame is different only in its NEW strokes. Already existing strokes are skipped. 

I used a simple solution: Count the number of strokes in the previous frame and ignore this many strokes in the current frame.

Differential Revision: https://developer.blender.org/D14252
2022-03-08 16:40:27 +01:00
5791835678 Geometry Nodes: fix spline length node after recent refactor
Differential Revision: https://developer.blender.org/D14276
2022-03-08 16:09:44 +01:00
7bd3762b7c UI: Minor tweaks to IDTemplate operations. 2022-03-08 14:57:47 +01:00
bea7d2e22d LibOverride: Do not assert when root ID is not object/collection.
While uncommon, this is still a valid case...
2022-03-08 14:57:47 +01:00
178f4fa71e Cleanup: fix compiler warning 2022-03-08 13:58:50 +01:00
6f8e65cd7a Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-03-08 13:48:47 +01:00
d5e4cab76c Fix T96224: GPU subdiv crash with smooth normals and tangents
Tangents are computed from UVs on the CPU side when using GPU subdivision
and require that the normals are available there as well (at least for smooth
shading, flat normals can be computed on the fly). This simply adds the missing
normals update call for the `MeshRenderData` setup for the subdivision case.

Differential Revision: https://developer.blender.org/D14278
2022-03-08 13:47:14 +01:00
3a672fe6fb GPU: disable compute shader for problematic drivers
Some drivers for legacy platforms seem to have issues with compute
shaders, as revealed by T94936. This disables compute shader for the
known drivers where this issue is present. It is not clear if the issue
is Windows only or not, so this disable them for all operating systems.

See T94936 for a list of configurations where the issue is reproducible
or not.

Differential Revision: https://developer.blender.org/D14264
2022-03-08 13:39:18 +01:00
64a5fd7a1d Fix wrong edge crease validity check in the Cycles Alembic procedural 2022-03-08 13:38:21 +01:00
3cb3167278 Simplify sound property handling
Sound properties like volume, pitch and muting are handled in
`BKE_sound_add_scene_sound()`. This is unnecessary, because in
properties are then set to real values in `SEQ_edit_update_muting()` and
`seq_update_seq_cb()`.

Alternatively, it may be better to remove all other updates leave them
in `BKE_sound_add_scene_sound()`. But I want to add muting per channel,
whhich is easier and probably cleaner to do with function
`SEQ_edit_update_muting()`.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D14269
2022-03-08 13:16:36 +01:00
73dc8c24e4 PyAPI: optimize depsgraph use in PyDrivers
Avoid re-creating & freeing the depsgraph for every driver evaluation.

Now the depsgraph is kept in the name-space (matching self),
only re-created when the value changes.

In a contrived test-case with many drivers this gave ~15% overall
speedup for animation playback.
2022-03-08 22:15:12 +11:00
f76f48be23 Fix (unreported) liboverride rules from linked data disapearing.
Code cleaning up no-more-needed override data during diffing process
would systematically remove override data from linked IDs.

While this is not a critical issue in theory, it has bad consequences at
the very least on user UI/UX, and potentially can cause bugs in some
corner-cases scenarii.
2022-03-08 12:08:21 +01:00
0df8c22c8a LibOverrides: Tweak to ensure no overrides can be created on linked data.
Was already mostly the case, but from RNA API there was no proper check.
2022-03-08 11:02:22 +01:00
1c1efe3ac6 Fix memory leak evaluating PyDrivers
Missed decref in 686ab4c940 caused every
driver evaluation to create the BPy_StructRNA depsgraph without freeing
the previously allocated depsgraph.
2022-03-08 20:47:43 +11:00
10c11bb897 Curves: add initial comb, grow and shrink brush
The exact behavior of the brushes is still being iterated on, but it
helps having a base implementation that we can work upon.
All of that is still hidden behind an experimental feature flag anyway.

The brushes will get a name in the ui soon.

Differential Revision: https://developer.blender.org/D14241
2022-03-08 10:41:52 +01:00
Jeroen Bakker
1d902a6367 Fix T96213: Crash when texture painting across multiple materials.
Issue only happens in release builds on windows. That said it was an
actual error in the code. This class is compiled inline in release
builds. When updating multiple textures it would reuse the same memory
to collect the changes. When the previous loaded tilenumber was exactly the
same but from a different image the tile buffer wasn't loaded.

Reviewed By: sergey

Maniphest Tasks: T96213

Differential Revision: https://developer.blender.org/D14274
2022-03-08 10:38:38 +01:00
94d2470c41 Curves: increase default viewport resolution for curves object
This part has to be refactored soon anyway, because more types
curves have to be drawn for the new Curves object.

For now, 3 is a better default than 2, because that matches the
actual resolution of the curve currently.
2022-03-08 10:36:46 +01:00
4b598739c5 Curves: disable stroke spacing for curve sculpt brushes
This makes the brushes more smooth, because the brush has an
effect after every mouse move, instead of only every x pixels.

For this to work well, the brushes have to look at the stroke
segments instead of at the mouse positions separately.

A more fine grained check might be added in the future.
2022-03-08 10:33:51 +01:00
b588c09eee Fix: add missing case in switch statement for curves 2022-03-08 10:23:38 +01:00
3d71a05a1d Merge branch 'blender-v3.1-release' 2022-03-08 09:52:47 +01:00
Pratik Borhade
2ddb53de54 Fix T96228: TypeError on use of Copy from Active Track operation
Issue was introduced after the python 3.10 switch
Explicit conversion to int will fix the issue.
Same issue is likely to happen with `MovieTrackingSettings.default_search_size`
So I did the same change over there.

Differential Revision: https://developer.blender.org/D14273
2022-03-08 09:52:17 +01:00
63ac1660c0 Fix T92861: Transform fails for multiple pose object sharing ob-data
Support transforming two pose objects at once even when they share
object data as this is per-object.
2022-03-08 15:13:53 +11:00
3c889fe2b0 Cleanup: pass const scene argument to UV selection functions 2022-03-08 14:45:33 +11:00
06d9c2c223 Cleanup: spelling in comments 2022-03-08 14:32:34 +11:00
c0c840cc31 Cleanup: prefer UNUSED_VARS_NDEBUG for debug only variables
Otherwise it's possible to accidentally use these variables
in debug builds, breaking release builds.
2022-03-08 14:15:34 +11:00
59c972b40a Event System: remove unused NDOF buttons
GHOST always converts NDOF keyboard buttons into keyboard events
so there is no need to expose their values for Blender event types.
2022-03-08 14:01:49 +11:00
88b2bbc649 Event System: support changing NDOF button shortcuts 2022-03-08 13:56:04 +11:00
b58e660828 Event System: click/click-drag support for NDOF buttons
Support this for completeness, as it's simpler to support click-drag
for all events types that support press/release instead of having to
document which kinds buttons support click-drag.
2022-03-08 13:48:40 +11:00
f052fb5646 Event System: add ISKEYBOARD_OR_BUTTON macro
This simplifies checking for event types that support press & release.
2022-03-08 13:48:34 +11:00
08d8eee006 Event System: refactor click detection into function
Also simplify modifier & keymodifier assignment.
2022-03-08 13:48:33 +11:00
08f88bba69 Event System: exclude cursor & NDOF motion from ISHOTKEY() macro
In practice this didn't cause a bug since assigning hot-keys was also
checking for "press" events (which NDOF_MOTION doesn't generate).

Add ISNDOF_BUTTON macro which is now used by ISHOTKEY to avoid
problems in the future.
2022-03-08 13:48:32 +11:00
7b66397664 Cleanup: spelling in comments, use C++ comments for disabled code 2022-03-08 13:48:31 +11:00
901a03725e Curves: Port mesh to curve node to new data-block
The main improvement is a code simplification, because attributes don't
have to be transferred separately for each curve, and all attributes can
be handled generically. Performance improves significantly when the
output contains many curves. Basic testing with a 2 million curve output
shows an approximate 10x performance improvement.
2022-03-07 19:06:40 -06:00
c238728105 Fix: Curves cyclic access function duplicates attribute
This was an oversight in 6594e802ab. First it must check if the
attribute exists before adding it.
2022-03-07 18:58:04 -06:00
b8f1ae5c38 Cleanup: Rename geometry set "curve" to "curves"
Similar to 245722866d, just another function I missed before.
2022-03-07 16:26:55 -06:00
dfd7832a0e Merge branch 'blender-v3.1-release' 2022-03-07 13:58:14 -06:00
2b3367cdf8 Fix T93573: Curve evaluated mesh selected in edit mode
This fixes the second part of T93573 that 8506f3d9fe didn't
properly address. Specifically, outlines of instances still had the
selected color in edit mode in wireframe view. This change is the
same as that commit, just in a different place.

Differential Revision: https://developer.blender.org/D14229
2022-03-07 13:54:49 -06:00
0597902bde Fix memory leak when reading ffmpeg video frames.
We had forgotten to unref packets after reading them.
This lead to a memory leak inside of ffmpeg.
2022-03-07 19:04:51 +01:00
Leon Schittek
1cb303242f UI: align labels of number fields and value sliders
Previously the labels and values in number fields and value sliders
used different padding for the text. This looks weird when they are
placed underneath each other in a column and, as noted by a comment
in the code of `widget_numslider`, they are actually meant to be
aligned.

This patch fixes that by using the same padding that is used for the
number field for the value slider, as well. This also has the benefit,
that the labels of the value sliders don't shift anymore when adjusting
the corner roundness.

Differential Revision: https://developer.blender.org/D14091
2022-03-07 18:32:47 +01:00
21d633f83b GPencil: Temporary fix to avoid crashes on startup
This quick fix will populate the runtime orig pointers to avoid
crashes when a grease pencil object uses layer transforms, parenting
or modifiers.
This will have to be revisited and fixed with a better solution.
2022-03-07 17:48:36 +01:00
Ethan-Hall
15186f4259 Shader Nodes: added alpha mode selector to Image Texture node
Enables image user nodes to display the file alpha mode, similar to the
colorspace setting.

Also removes image_has_alpha in favor of using BKE_image_has_alpha, because it
did not check if the image actually had an alpha channel, just if the file format
was capable of supporting an alpha channel.

Differential Revision: https://developer.blender.org/D14153
2022-03-07 17:39:27 +01:00
Ethan-Hall
5b4ab89663 Shader Nodes: add Alpha output to Object Info node
An alpha component can be specified for an object's color. This adds an alpha
socket to the object info shader node allowing for the alpha component of the
object's color to be accessed in the shader editor.

Differential Revision: https://developer.blender.org/D14141
2022-03-07 17:35:48 +01:00
76f9d83a19 Merge branch 'blender-v3.1-release' 2022-03-07 17:31:32 +01:00
Ethan-Hall
60481e4d99 Fix T96195: f-curve factorized polynomial generator broken UI
The polynomial parameters were not shown correctly.

Differential Revision: https://developer.blender.org/D14254
2022-03-07 17:30:30 +01:00
f130d4f211 Cleanup: fix various typos
Contributed by luzpaz.

Differential Revision: https://developer.blender.org/D14203
2022-03-07 17:28:39 +01:00
5bb2b4236d Cleanup: move asssertion-test-only variable into #ifndef NDEBUG block
Move `ToolSettings *ts` into an `#ifdef NDEBUG` block, as it's only used
for a `BLI_assert` call.
2022-03-07 17:10:13 +01:00
2d06b97d29 Fix T95256: Crash when creating off-screen pose asset
Fix crash when creating a pose asset for which the file list entry in
the asset browser is scrolled off-screen. Because of the
off-screen-ness, it wasn't loaded into memory, which eventually caused
an unexpected NULL pointer.

The solution was to use a different function (`filelist_file_find_id`)
that can reliably find the file list entry, after which the cache entry
can be created.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D14265
2022-03-07 17:07:20 +01:00
Leon Schittek
6b8dde93b0 Fix T95531: Draw y axis values in Driver Editor
When drawing the driver editor, only skip drawing the "scrubbing area"
and not the Y-axis values or the scroll bars.

The issue was introduced in rBb3431a88465db2433b46e1f6426c801125d0047d
to avoid drawing the playhead in the Driver Editor but also prevented
the text on the y axis from being drawn.

Reviewed by: Severin, sybren

Maniphest Tasks: T95531

Differential Revision: https://developer.blender.org/D14022
2022-03-07 17:07:20 +01:00
5dca3ee6a2 Fix T95256: Crash when creating off-screen pose asset
Fix crash when creating a pose asset for which the file list entry in
the asset browser is scrolled off-screen. Because of the
off-screen-ness, it wasn't loaded into memory, which eventually caused
an unexpected NULL pointer.

The solution was to use a different function (`filelist_file_find_id`)
that can reliably find the file list entry, after which the cache entry
can be created.

Reviewed by: Severin

Differential Revision: https://developer.blender.org/D14265
2022-03-07 17:04:10 +01:00
5ae26e410a Fix T94360: Assert on dragging keyframes
Fix an assert by commenting out the assert.

In normal situations all keyframes are sorted. However, while keys are
transformed, they may change order and then this assertion no longer
holds. The effect is that the drawing isn't perfect during the
transform; the "constant value" bars aren't updated until the
transformation is confirmed. Apart from that, the code runs fine, so it
seems like a workable workaround.
2022-03-07 16:48:44 +01:00
Leon Schittek
ea3b2e8736 Fix T95531: Draw y axis values in Driver Editor
When drawing the driver editor, only skip drawing the "scrubbing area"
and not the Y-axis values or the scroll bars.

The issue was introduced in rBb3431a88465db2433b46e1f6426c801125d0047d
to avoid drawing the playhead in the Driver Editor but also prevented
the text on the y axis from being drawn.

Reviewed by: Severin, sybren

Maniphest Tasks: T95531

Differential Revision: https://developer.blender.org/D14022
2022-03-07 16:24:17 +01:00
5b2d9c0cbe Merge branch 'blender-v3.1-release' 2022-03-07 15:19:05 +01:00
e908ebc094 Fix T96207: wrong default value of Principled BSDF specular tint
Contributed by MysteryPancake.

Differential Revision: https://developer.blender.org/D14256
2022-03-07 14:53:59 +01:00
7f57899823 Merge branch 'blender-v3.1-release' 2022-03-07 12:37:54 +01:00
00f6e4c990 Fix T96180: driver in node tree not updating in real time
Differential Revision: https://developer.blender.org/D14260
2022-03-07 12:37:13 +01:00
4ffe2fec16 Python: Add new annotation_pre & annotation_post handlers
Annotation tool is used as a general mark tool for many add-ons. To be able to detect when an annotation is done is very handy to integrate the annotation tool in add-ons and other studio workflows.

The  new callback names are:  `annotation_pre`  and `annotation_post`

Both callbacks are exposed via the Python module `bpy.app.handlers`

Example use:

```
import bpy

def annotation_starts(gpd):
    print("Annotation starts")

def annotation_done(gpd):
    print("Annotation done")

bpy.app.handlers.annotation_pre.clear()
bpy.app.handlers.annotation_pre.append(annotation_starts)
bpy.app.handlers.annotation_post.clear()
bpy.app.handlers.annotation_post.append(annotation_done)
```

Note: The handlers are called for any annotation tool, including eraser.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D14221
2022-03-07 12:36:47 +01:00
548eabbaa1 Revert "Revert "Fix Crash: Switching to wireframe mode.""
This reverts commit 25fc5876d3.

Committed this unintentionally, looking into an alternate fix.
2022-03-07 22:32:46 +11:00
638c0bd234 Merge branch 'blender-v3.1-release' 2022-03-07 21:52:24 +11:00
a61ee1dcae Cleanup: quiet warnings 2022-03-07 21:51:50 +11:00
0e51defcf4 Fix T95591: Crash on drawing with measure tool with tweak fallback tool
Using press to activate the Tweak tool doesn't work well when used a
fallback tool as the drag event is often used by the current tool -
making it impossible not to select when dragging (unless the fallback
tool is disabled entirely).
Resolve this by using CLICK events when the Tweak tool is used as a
fallback.

Even though this avoids the crash, check for null-pointer de-reference
since changes to the key-map shouldn't cause operators to crash.

Note that the ability for operators to access a gizmo before it's fully
initialized is a more general problem that should be addressed, but out
of scope for a bug-fix.

Reviewed By: zeddb, JulienKaspar, Severin

Maniphest Tasks: T95591

Ref D14231
2022-03-07 21:47:00 +11:00
Yann Lanthony
7ca13eef7c Improve multi-user gpencil data performance with modifiers
When a grease pencil data-block has multiple users and is subject
to modifiers, layer transforms or parenting, performance
(especially playback) is greatly affected.

This was caused by the grease pencil eval process which does per
instance full-copies of the original datablock in case those
kinds of transformations need to be applied.

This commit changes the behavior of the eval process to do shallow
copies (layers with empty frames) of the datablock instead
and duplicates only the visible strokes.

When we need to have a unique eval data
per instance, only copy the strokes of visible
frames to this copy.

Performance:
On a test file with 1350 frames 33k strokes and 480k points
in a single grease pencil object that was instanced 13 times:
 - master: 2.8 - 3.3 fps
 - patch: 42 - 52 fps

Co-authored by: @filedescriptor
This patch was contributed by The SPA Studios.

Reviewed By: #grease_pencil, pepeland

Differential Revision: https://developer.blender.org/D14238
2022-03-07 11:38:56 +01:00
57c5f2a503 Merge branch 'blender-v3.1-release' 2022-03-07 21:35:21 +11:00
72e20785e1 Fix T96205: Active shape key gets lost upon edit mode undo
Regression in d961adb866,
it's important that for the Mesh used for undo storage matches
the shape-key instead of using the coordinates of the Basis key.

Prior to bfdbc78466 a different method of
restoring the basis shape-key coordinates was used (restoring from the
input `Mesh.mvert` array). When undo wrote the edit-mesh into the mesh
this was always NULL so the basis shape keys coordinates were never
used.

Now a parameter has been added so undo can use the active shape for the
meshes vertex coordinates.

Reviewed By: sergey

Maniphest Tasks: T96205

Ref D14258
2022-03-07 21:31:48 +11:00
25fc5876d3 Revert "Fix Crash: Switching to wireframe mode."
This reverts commit cb986446e2.
2022-03-07 19:55:33 +11:00
Jeroen Bakker
073d2390f0 Fix T96163: Image editor doesn't refresh when undo/redo.
Undo would invalidate image owned GPU textures only. Textures
that are owned by the editor were not refreshed. This patch would
invalidate all the GPU textures by marking the whole image dirty.

This can be improved later as we could add partial updates of GPU
textures.

Reviewed By: mont29

Maniphest Tasks: T96163

Differential Revision: https://developer.blender.org/D14259
2022-03-07 08:43:50 +01:00
ad2948face Merge branch 'blender-v3.1-release' 2022-03-07 07:49:52 +01:00
4681987d92 Fix T96156: Snap to 3D cursor can't be undone
Caused by oversight in 2bcf93bbbe. Operator returns `OPERATOR_CANCELLED`
when it should return `OPERATOR_FINISHED`.

Reviewed By: mano-wii, campbellbarton

Differential Revision: https://developer.blender.org/D14243
2022-03-07 07:46:24 +01:00
Red Mser
8ec35c05b2 Curve: sync active material with selection
Changing active spline updates active material index.

Reviewed By: campbellbarton

Ref D14250
2022-03-07 12:06:33 +11:00
fae45a43fa Cleanup: use doxy-sections for pipeline, text_drag & effects
Also improve on the doc-string for RE_RenderFrame & RE_RenderAnim.
2022-03-07 10:51:22 +11:00
a5f972c018 Cleanup: use loops for key-map entries that map values to number keys
Also add __all__ referencing the only two members of the modules
that should be accessed externally.
2022-03-06 21:16:21 +11:00
887ccb8537 Fix T96152: Crash realizing curve instances
The "curve_type" was transferred to instances because it isn't a
built-in curve attribute. Then it was interpolated as a point
domain attribute from the instance domain in the realize
instances node.

The fix was just missing from 9ec12c26f1.
`curve_type` needs to be marked as a built-in attribute.
2022-03-04 22:28:57 -05:00
295d5c6ef5 Fix T96164: Crash with curve domain attributes
When converting from the new type to the old, the curve domain
attributes weren't properly resized, so their data was not properly
allocated.
2022-03-04 11:11:56 -05:00
45079b169d Fix T96160: freezing when using multiple Handle Type Selection nodes
Differential Revision: https://developer.blender.org/D14245
2022-03-04 15:21:18 +01:00
1763ffa0be Cleanup: Unused variable warnings 2022-03-04 07:59:07 -05:00
5eaeb9bd0d GPencil: Fix wrong parameters in gpencil_check_same_material_color
The stroke and fill parameters were flipped.
2022-03-04 08:44:23 +01:00
0212c423bf Cleanup: remove outdated references to tweak 2022-03-04 13:31:16 +11:00
0a4fdcbb5f Cleanup: unused Python variables & imports 2022-03-04 11:07:37 +11:00
6bca614fd8 Cleanup: use doxy-sections in outliner_draw.cc
Also remove outdated comment.
2022-03-04 10:53:06 +11:00
bfd43222c3 Cleanup: use doxy-sections for interface_dropboxes.cc 2022-03-04 10:35:22 +11:00
0a2d61f45c Sequencer: de-duplicate new-scene enum, include in generated docs 2022-03-04 10:31:11 +11:00
65e6bcdd9f Sequencer: disallow assigning scenes to non-seuencer strips 2022-03-04 10:31:11 +11:00
ccefcf46bf Cleanup: use doxy-sections in scene_edit.c 2022-03-04 10:31:11 +11:00
4837ea3ab6 Cleanup: warning & spelling from recent scene/sequencer operator
- Avoid the abbreviation "VSE" as the convention is to use "sequencer".
- Remove dead-code (second return statement).
- Remove unused argument.
2022-03-04 10:31:11 +11:00
8b06c524d2 Cleanup: spelling in comments, function name 2022-03-04 10:31:11 +11:00
Azeem Bande-Ali
fd2519e0b6 UI: Drag & Drop to Properties Materials Panel
Support drag/drop of materials to Properties Material Slots.

See D13549 for more details.

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

Reviewed by Julian Eisel
2022-03-03 15:28:48 -08:00
58e2ec18ae EEVEE: Deferred: Large refactor
This changes drastically the implementation to leverage arbitrary writes
in order to reduce complexity, memory usage and increase speed.

Since we are no longer dependent on the framebuffer requirement, we can
allocate bigger size texture that fits all views and avoid the extra.

Transparency, holdout and emissions are no longer deferred and are now
composited using dual source blending.

The indirect lighting and raytracing is still not functional but will
also gets a large refactor on its own
2022-03-03 21:16:54 +01:00
fbf4d8f8b5 GL: Add missing format in image layout conversion 2022-03-03 21:11:45 +01:00
d471c7d1c2 GPUShaderCreateInfo: Add explicit early_fragment_test 2022-03-03 21:10:55 +01:00
471f27d66b Curves: Port endpoint selection node to new data-block
The node should be faster than in 3.1, for a few reasons:
- It doesn't need to calculate and allocate the curve offsets.
- It doesn't need to de-reference a pointer for each curve.
- The inputs are accessed from the virual arrays fewer times.

On top of that, I added two other performance improvements:
- The node is multi-threaded when there are many curves.
- There are generated special cases for single value and span inputs.

**Performance**
With a set position node affecting 1 million splines with a selection
based on this node, on an Intel i5 8250U (times are approximate):
| Before | After | Speedup |
| 760 ms | 60 ms | 13x     |

Differential Revision: https://developer.blender.org/D14233
2022-03-03 11:55:31 -05:00
908ac7dce2 Merge branch 'blender-v3.1-release' 2022-03-03 17:47:34 +01:00
769ae5c866 Fix T96139: Cycles doesn't warn if the render is paused
Caused by 6ec83afb1d.

Technically, a regression since 3.0.

Differential Revision: https://developer.blender.org/D14239
2022-03-03 17:21:11 +01:00
d793d18413 BLI: Add functions to IndexRange to mirror Span
Adds functions for special cases of slicing and an `is_empty` method.
2022-03-03 11:14:44 -05:00
e8dc82311d Fix T96145: GPencil eval data not updated correctly
When removing a modifier, changing the layer transform or updating
 the parent of a grease pencil object that has a multi-user datablock
 and animation data, the eval data is not updated properly (after a
 frame change). This can also cause memory leaks.

 The fix makes sure that we free and reset any runtime copy
 (`ob->runtime.gpd_eval`) in `BKE_gpencil_prepare_eval_data`.

 Note: As far as we can tell, `ob->runtime.gpd_orig` is unused and could
 be removed. The assignment in `BKE_gpencil_prepare_eval_data`
 seemed to be unnecessary.

Co-authored-by: @yann-lty

Reviewed By: antoniov

Maniphest Tasks: T96145

Differential Revision: https://developer.blender.org/D14236
2022-03-03 16:01:23 +01:00
6e487228a5 File Browser UI: Allow dragging anywhere in a file preview tile to drag
Previously you'd have to be careful to drag the image itself. Dragging
anywhere else on the tile (e.g. between the preview and the text, or the
text itself) would trigger border select. This often conflicts with user
expectations and causes frustration when trying to work quick, I've seen
many people complain about this.

Note that the "hitbox" for dragging is a bit smaller than the tile, to
not make border select by dragging from in-between the tiles too hard.

Differential Revision: https://developer.blender.org/D14228
2022-03-03 15:17:23 +01:00
544bd0c353 Cleanup: Remove redundant drag image size parameters
Just use the image-buffer size and the already provided scale to
determine the size, not the button size (which would always have to
match the scaled image-buffer size or it would give unexpected results).
2022-03-03 15:04:45 +01:00
1b863041c9 i18n: Fix more potential contextual issues with "Back" UI label.
Add 'ID_ACTION' context to some animation curve interpolation enums.

Related to T95506/T43295.
2022-03-03 14:52:45 +01:00
0f77933031 Merge branch 'blender-v3.1-release' 2022-03-03 13:49:08 +01:00
9c2e385509 Fix Cycles hang in classroom scene with upcomping AMD driver version 22.10
This is a workaround until there is a fix in the HIP compiler or driver.

Differential Revision: https://developer.blender.org/D14232
2022-03-03 13:42:58 +01:00
ffaaa0bcbf UV: Edge selection support
This patch adds edge selection support for UV editing (refer T76545).
Developed as a part of GSoC 2021 project - UV Editor Improvements.

Previously, selections in the UV editor always flushed down to vertices
and this caused multiple issues such as T76343, T78757 and T26676.
This patch fixes that by adding edge selection support for all UV
operators and adding support for flushing selections between vertices
and edges. Updating UV select modes is now done using a separate
operator, which also handles select mode flushing and undo for UV
select modes. Drawing edges (in UV edge mode) is also updated to match
the edit-mesh display in the 3D viewport.

Notes on technical changes made with this patch:
* MLOOPUV_EDGESEL flag is restored (was removed in rB9fa29fe7652a).
* Support for flushing selection between vertices and edges.
* Restored the BMLoopUV.select_edge boolean in the Python API.
* New operator to update UV select modes and flushing.
* UV select mode is now part of editmesh undo.

TODOs added with this patch:
* Edge support for shortest path operator (currently uses vertex path logic).
* Change default theme color instead of reducing contrast with edge-select.
* Proper UV element selections for Reveal Hidden operator.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D12028
2022-03-03 17:59:09 +05:30
76879e3702 Outliner: Display respective data-block icon in library overrides mode
Just showing the library override icon for every item doesn't add much
information, it's just redundant. Displaying the data-block type icon on
the other hand can be useful.

Differential Revision: https://developer.blender.org/D14208
2022-03-03 13:18:23 +01:00
9b12889a1a Fix T96140: Crash on color button drag & drop
Use-after-free in context store, which wasn't cleared correctly after
setting and querying.
2022-03-03 12:51:44 +01:00
2d24ba0210 VSE: Allow to create scene in strip properties
This patch adds a button in the scene to add a new one, but this does not change to the new created scene because this breaks the storyboarding workflow.

This is a common request for Storyboarding artists.

Reviewed By: mendio, brecht, ISS

Differential Revision: https://developer.blender.org/D14148
2022-03-03 12:37:48 +01:00
ce0d4ea41c Merge branch 'blender-v3.1-release' 2022-03-03 20:47:07 +11:00
d961adb866 Fix T96135: Mesh coordinates are set to the last edited shape-key
When exiting edit-mode set the vertex coordinates to the basis-shape when editing non-basis keys.

Regression in bfdbc78466.

Reviewed By: sergey

Ref D14234
2022-03-03 20:42:30 +11:00
d66b047ca3 WM: use pass-through for cursor placement operator
This is needed since 4d0f846b93
however change in the operator instead of the event handler is correct,
as accepting a press event should suppress drag events unless
the pass-through flag is set.

This is how select & tweak already works.
2022-03-03 20:35:14 +11:00
ec09ded792 Fix missing i18n context variable in UI py script.
Mistake in own rBdb3f5ae48ac, thanks to Ethan-Hall (@Ethan1080) for the
heads up.
2022-03-03 08:57:06 +01:00
a8df292264 Cleanup: comments in wm_event_system.c 2022-03-03 16:45:40 +11:00
4d0f846b93 Event System: use more thoroughly tested logic for click-drag events
No functional changes, largely restoring old logic & removing the need
for workarounds.

Reverts:
- 13b6cec039.
- aa71414dfc (partially).
2022-03-03 16:07:18 +11:00
9d529407da UI: only wrap cursor motion horizontally when dragging markers
It's not useful to wrap vertical motion when dragging markers.
It was too easy to accidentally wrap the cursor to the top of a region,
as markers need to be dragged from the bottom edge of the region.
2022-03-03 15:48:41 +11:00
d764448f73 Cleanup: use doxygen sections for anim_markers.c 2022-03-03 15:46:26 +11:00
08da699faa Cleanup: rename misleading variable for marker selection cycling
"marker_selected" was the marker after the selected marker
and is used for cycling the selection.
2022-03-03 15:46:15 +11:00
61c288cee5 Fix timeline marker click-drag arbitrary deselection
The logic to cycle selected markers wasn't cycling back to the beginning
of the list.

The marker after the selected marker at the cursor frame was also used
to check if a selection existed, causing dragging to transform all
selected markers to de-select all when when dragging the last marker.
2022-03-03 15:25:02 +11:00
ef431a8705 Cleanup: remove references to key-map modifier values denoting order
This feature was never exposed to users.
2022-03-03 13:57:44 +11:00
3c175caaa3 Cleanup: Rename set handle type node internally to match UI
I've had trouble finding this node a few times now,
it's simpler if the file name matches the name in the UI.
2022-03-02 17:58:17 -05:00
ddf956fb58 Curves: Port set resolution node to the new data-block
The node unnecessarily converted to the old data structure to check if
there were any poly splines. Instead, that warning is just removed,
because the node now still sets resolution values in that case, they
just aren't used (before the values weren't set at all). Either way, it
wasn't clear that looping though all of the curve types was worth
the performance cost here.
2022-03-02 17:50:25 -05:00
2600806c2e Fix: BLI math clamp doesn't work
Return type was wrong, output of std::clamp wasn't used.
2022-03-02 17:09:17 -05:00
ecba8c1243 Fix mistake in seeking cleanup
In `ffmpeg_read_video_frame` fix assignment used as truth value.
In `ffmpeg_seek_recover_stream_position` loop while return value is
greater or equal to 0.
2022-03-02 22:25:43 +01:00
f531dff9b3 Cleanup: Use rectangle for file browser tile drawing
Passing around coordinates for drawing can be quite confusing, it's
often not clear what they represent and where they are currently.
Instead pass around the tile rectangle for drawing and let all code draw
based on that, it's way more clear that way.

Changes shouldn't be user visible.
2022-03-02 19:25:18 +01:00
Nikhil Shringarpurey
721b705499 UI: Comments Misspellings of Vertex/Vertices
Correct misspellings in code comments of "vertex" and "vertices".

See D13932 for more details.

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

Reviewed by Harley Acheson
2022-03-02 10:05:15 -08:00
ca0b728529 Fix T96101: "Remove" button failure on Grease Pencil layer's relation to bone
As the channel was not found, the relation data was not updated.

Now, if the bone is removed, the relation is set.
2022-03-02 17:48:35 +01:00
34267a868a Merge branch 'blender-v3.1-release'
and resolve merge error (version string).
2022-03-02 17:35:09 +01:00
9789a6c6d9 Search: take word order into account in string search
Differential Revision: https://developer.blender.org/D14223
2022-03-02 17:25:39 +01:00
8506f3d9fe Blender 3.1 bcon4 - change release cycle to release candidate
This is still a rolling release candidate with new builds every day
as a preparation to the final release.
2022-03-02 17:17:38 +01:00
ac45540a34 Curves: add brush to add curves on surface
This adds a prototype for the first brush that can add new curves by
painting on a surface. Note that this can only be used when the curves
object has a surface object set in the properties panel.

The brush can take minimum distance into account. This allows
distributing curves with a somewhat consistent density.

Differential Revision: https://developer.blender.org/D14207
2022-03-02 17:15:44 +01:00
037e1ad140 Merge branch 'blender-v3.1-release' 2022-03-02 17:13:57 +01:00
2fb31f34af Fix T95692: incorrect interpolated children particle hair
Differential Revision: https://developer.blender.org/D14227
2022-03-02 17:12:56 +01:00
d86f80f42a Merge branch 'blender-v3.1-release' 2022-03-02 10:55:21 -05:00
216a215ba5 Fix T93573: Remove outline from instances in edit mode
This commit removes the outline from instances generated from an object
when in edit mode. This takes the change in aa13c4b386 a bit further,
with the idea that instance outlines are more like regular outlines.

Because evaluated object data that doesn't match the original object
type is treated as an instance internally, this fixes the way evaluated
meshes for curves objects have an outline, for example.

See the differential revision for a visual comparison.

Differential Revision: https://developer.blender.org/D14226
2022-03-02 10:49:48 -05:00
7935d3668a Fix T95479: geometry nodes crash with cage display
Differential Revision: https://developer.blender.org/D14225
2022-03-02 16:10:42 +01:00
Ethan Hall
1e1d1f15e8 UI: Enable the outliner to use the correct icon for each curve subtype
This patch enables enables the outliner to use the correct icon for each
of the curve subtypes (Curve/Surface/Font).

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

Reviewed by: Julian Eisel
2022-03-02 15:52:17 +01:00
13b6cec039 Fix/Workaround T96120: Crash dropping from the file browser
Since removal of tweak events 4986f71848,
box-select is activating while dragging files.

As far as I can tell this used to work because of differences
int the order tweak / click-drag events are handled.

Apply a workaround since dragging files doesn't prevent other parts
of the UI from activated (it's possible to open menus for e.g),
this is something we will likely want to limit which would resolve
this bug too.
2022-03-03 01:36:14 +11:00
3a0df7d37b Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-03-02 15:22:19 +01:00
6883c47bb5 Fix T94729: GPU subdivision does not support meshes without polygons
There are two issues revealed in the bug report:
- the GPU subdivision does not support meshes with only loose geometry
- the loose geometry is not subdivided

For the first case, checks are added to ensure we still fill the
buffers with loose geometry even if no polygons are present.

For the second case, this adds
`BKE_subdiv_mesh_interpolate_position_on_edge` which encapsulates the
loose vertex interpolation mechanism previously found in
`subdiv_mesh_vertex_of_loose_edge`.

The subdivided loose geometry is stored in a new specific data structure
`DRWSubdivLooseGeom` so as to not pollute `MeshExtractLooseGeom`. These
structures store the corresponding coarse element data, which will be
used for filling GPU buffers appropriately.

Differential Revision: https://developer.blender.org/D14171
2022-03-02 15:19:55 +01:00
47396ea81e Fix T96123: Crash when click-dragging across the visibility icons
Partially revert aa71414dfc

This attempted have the click-drag event compatible with old tweak
events, but needs to be re-thought since it caused events to be handled
in unexpected situations.
2022-03-03 01:11:17 +11:00
4a95c3466f Fix T96085: repeated evaluation of geometry nodes when nothing changed
Differential Revision: https://developer.blender.org/D14216
2022-03-02 14:12:08 +01:00
c23ec04b4e BLI: add scoped-defer utility to add RAII-like behavior to C types
This utility is useful when using C types that own some resource in
a C++ file. It mainly helps in functions that have multiple return
statements, but also simplifies code by moving construction and
destruction closer together.

Differential Revision: https://developer.blender.org/D14215
2022-03-02 12:51:21 +01:00
721335553c Add Object Tool: use the drag-start location for initial placement 2022-03-02 22:29:40 +11:00
Henrik Dick
c2e8e68b65 Fix T95963: change thresholds in complex solidify
This fix contains two parts. There was one critical mistake where
order of two indices was wrong when removing constraint planes from
the array. The other changes are improvements to the used thresholds
to keep everything numerically stable.

Differential Revision: http://developer.blender.org/D14183
2022-03-02 12:14:22 +01:00
ccf4001458 Fix modal item open/close in the outliner since removing tweak events
Correct check for left-mouse event which assumed the alternative was
a tweak event.

Also remove print added by accident.
2022-03-02 22:04:39 +11:00
102644cb8c Fix releasing modifier keys suppressing drag events
Always use event.prev_click_type since this is never set on key-release,
which could still interrupt dragging (box selecting for example).
2022-03-02 21:47:49 +11:00
1747269ea5 Cleanup: misleading code from aa71414dfc
This branch was previously run when the action had been handled,
since action checks were removed it was running. This assignment
does nothing but shouldn't be kept.
2022-03-02 21:47:49 +11:00
51c5a4d85d Merge branch 'blender-v3.1-release' 2022-03-02 11:45:48 +01:00
Brecht Van Lommel
383a6ee78c Fix T94609: geometry nodes always re-evaluated with image texture nodes
previously_visible_components_mask was not preserved for Image ID nodes, which
meant it was always detected as newly visible and tagged to be updated, which
in turn caused the geometry nodes using it to be always updated also.

Reviewed By: sergey, JacquesLucke

Maniphest Tasks: T94609

Differential Revision: https://developer.blender.org/D14217
2022-03-02 11:45:17 +01:00
5086913b28 Fix T96116: Image editor not updated when adding new tile. 2022-03-02 11:42:23 +01:00
f8577db05d Docs: document the use_axis_view argumeht to view_roll_angle
Also remove event print left in by accident.
2022-03-02 18:28:15 +11:00
46a5a15d30 Cleanup: rename direction enum as it's part of the key-map item
Also improve doc-strings for key-map item constants.
2022-03-02 18:00:59 +11:00
7e4c031328 Cleanup: remove all tweak events from key-map presets 2022-03-02 17:29:27 +11:00
4986f71848 Event System: remove tweak events in favor of click-drag
Supporting two kinds of dragging is redundant, remove tweak events as
they only supported 3 mouse buttons and added complexity from using the
'value' to store directions.

Support only click-drag events (KM_CLICK_DRAG) which can be used with
any keyboard or mouse button.

Details:

- A "direction" member has been added to keymap items and events which
  can be used when the event value is set to KM_CLICK_DRAG.

- Keymap items are version patched.

- Loading older key-maps are also updated.

- Currently the key-maps stored in ./release/scripts/presets/keyconfig/
  still reference tweak events & need updating. For now they are updated
  on load.

Note that in general this wont impact add-ons as modal operators don't
receive tweak events.

Reviewed By: brecht

Ref D14214
2022-03-02 15:31:50 +11:00
426ff481a7 Event System: match click-drag & tweak event handling for transform 2022-03-02 14:53:15 +11:00
78372d8b9c Event System: support "Release Confirms" for click-drag events 2022-03-02 14:44:34 +11:00
aa71414dfc Fix click-drag events for dragging markers
Clicking and dragging markers accumulates flags from multiple operators
in a way that can't be interpreted when combine.

Follow tweak behavior for cancelling click-drag events.
2022-03-02 14:28:29 +11:00
cf428b2ebd Fix ignored click-drag events when operators pass-through & finished
Replacing tweak key-map items with click-drag caused selection
in the graph/sequencer/node editors to ignore drag events
(all uses of WM_generic_select_modal).

Operators that return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED
result in the event loop considering the event as being handled.

This stopped WM_CLICK_DRAG events from being generated which is not the
case for tweak events.

As click-drag is intended to be compatible with tweak events,
accept drag events when WM_HANDLER_BREAK isn't set or when
wm_action_not_handled returns true.
2022-03-02 12:25:12 +11:00
aa500c4fca Cleanup: use back-slash for doxygen commands, color after parameters 2022-03-02 12:11:08 +11:00
eabdcdcd44 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-03-02 00:59:03 +01:00
4932269ec3 Fix T94952: normals maps don't render correctly with GPU subdivision
A simple case of missing the tangent VBO. The tangents are computed from
the coarse mesh, and interpolated on the GPU for the final mesh. Code for
initializing the tangents, and the vertex format for the VBO was
factored out of the coarse extraction routine, to be shared with the
subdivision routine.
2022-03-02 00:58:40 +01:00
e03b9f555c Cmake: Re-enable Amaranth add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-03-01 17:45:45 -05:00
a75e9863fe Cmake: Re-enable Amaranth add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-03-01 17:45:13 -05:00
10405b15ec Cleanup: Refactor seeking code
Improve readability and reduce indentation levels. No functional changes.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D14075
2022-03-01 23:42:23 +01:00
4491c62260 Fix potential crash during proxy building
Last step of proxy building caused crash due to thread race contition
when acessing ed->seqbase.

Looking at code, it seems that calling IMB_close_anim_proxies on
original strips is unnecessary so this code was removed to resolve this
issue.

Locking seqbase data may be possible, but it's not very practical as
many functions access this data on demand which can easily cause
program to freeze.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D14210
2022-03-01 23:42:23 +01:00
bfe37b7255 Merge branch 'blender-v3.1-release' 2022-03-01 18:35:48 -03:00
9bd586a01e Fix T95608: Mac issues with drag drop on multi-monitor
Mousemove events are sent to windows.

In Windows OS, almost all mousemove events are sent to the window whose
mouse cursor is over.

On MacOS, the window with mousemove events is always the active window.
It doesn't matter if the mouse cursor is inside or outside the window.

So, in order for non-active windows to also have events,
`WM_window_find_under_cursor` is called to find those windows and send
the same events.

The problem is that to find the window, `WM_window_find_under_cursor`
only has the mouse coordinates available, it doesn't differentiate
which monitor these coordinates came from.

So the mouse on one monitor may incorrectly send events to a window on
another monitor.

The solution used is to use a native API on Mac to detect the window
under the cursor.

For Windows and Linux nothing has changed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D14197
2022-03-01 18:25:12 -03:00
e1ec2d0251 Merge branch 'blender-v3.1-release' 2022-03-01 16:31:18 -03:00
8e88af9934 Fix wrong object mode checking in snap code
The value of `OB_MODE_OBJECT` is 0, this makes it unsuitable as a bitflag.

Issue pointed out at https://pvs-studio.com/en/blog/posts/cpp/0922/

Thanks to Andrey Karpov
2022-03-01 16:30:30 -03:00
8322a4f6b7 Fix T92980: missing Cycles video texture update with persistent data 2022-03-01 19:51:30 +01:00
Henrik Dick
6498688e27 GPencil: Improve subdivision modifier
The subdivision modifier for Grease Pencil handles closed strokes
correctly now and does converge to the same shape as the mesh
subdivision surface.

Differential Revision: http://developer.blender.org/D14218
2022-03-01 19:32:02 +01:00
444d57d440 Geometry Nodes: Port most curve primitives to new data-block
Create `Curves` directly, instead of using the conversion from
`CurveEval`. This means that the `tilt` and `radius` attributes
don't need to be allocated. The old behavior is kept by using the
right defaults in the conversion to `CurveEval` later on.

The Bezier segment primitive isn't ported yet, because functions
to provide easy access to built-in attributes used for Bezier curves
haven't been added yet.

Differential Revision: https://developer.blender.org/D14212
2022-03-01 12:06:29 -05:00
f085c2bab5 Cmake: Re-enable tiny cad add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-03-01 11:58:27 -05:00
89bf5d8ba9 Cmake: Re-enable tiny cad add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-03-01 11:57:13 -05:00
f98d74c80d Curves: Move curves primitive to object add code
Currently, any time a Curves data-block is created, the `curves_random`
function runs, filling it with 500 random curves, also adding a radius
attribute. This is just left over from the prototype in the initial
commit that added the type.

This commit moves the code that creates the random data to the curve
editors module, like the other primitives are organized.

Differential Revision: https://developer.blender.org/D14211
2022-03-01 11:40:25 -05:00
952a613d38 Cycles: Hide MetalRT checkbox for AMD GPUs
This patch hides the MetalRT checkbox for AMD GPUs, pending fixes for MetalRT argument encoding on AMD.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D14175
2022-03-01 16:05:47 +00:00
143bc9f8d4 Merge branch 'blender-v3.1-release' 2022-03-01 23:11:46 +11:00
d681d82d41 Fix T96035: Some tool settings do not work
Oversight in 74611e3555 missed updating
property access to use the tool identifier to lookup the property group.
2022-03-01 23:09:56 +11:00
f493e2f23a Merge branch 'blender-v3.1-release' 2022-03-01 11:46:53 +01:00
629f22f161 Fix T95997: Crash when entering edit mode
The issue was uncovered by the 0f89bcdbeb, but the root cause goes
into a much earlier design violation happened in the code: the modifier
evaluation function is modifying input mesh, which is not something
what is ever expected.

Bring code closer to the older state where such modification is only
done for the object in edit mode.

---

From own tests works seems to work fine, but extra eyes and testing
is needed.

Differential Revision: https://developer.blender.org/D14191
2022-03-01 11:46:38 +01:00
90ec634135 Fix incorrect drag-event threshold when releasing modifiers early
db4313610c added support for modifier
keys to be released while dragging.

The key release events set wmEvent.prev_type which is used select the
drag threshold, causing the wrong threshold to be used.

Add wmEvent.prev_click_type which is only set when the drag begins.
2022-03-01 21:41:08 +11:00
cde5e12c0b Fix T96097: Image editor tile drawing not working.
The image engine is depth aware when using tile drawing the depth is
only updated for the central image what lead to showing the background
on top of other areas.

Also makes sure that switching the tile drawing would lead to an update
of the texture slots.
2022-03-01 11:37:18 +01:00
4b9c77a19a Merge branch 'blender-v3.1-release' 2022-03-01 11:36:46 +01:00
9216cf9cb5 Fix: dangling internal links after removing sockets
This is a follow up for rBd5e73fa13dd275fb9c76b1e41142ab086dd2e6be.
The issue was found with the file in T95997.
2022-03-01 11:34:36 +01:00
476fe7d164 Fix T95979: Bake doesn't update Image editor. 2022-03-01 11:20:54 +01:00
eec1c16200 Fix T96030: Update Image editor after reload. 2022-03-01 11:04:09 +01:00
a5214212cf Fix T96030: ImageEditor not updated for generated images. 2022-03-01 10:51:07 +01:00
d743ef91df Fix 3d texture painting artifacts.
When dimension of images aren't a multifold of 256 parts of the gpu
textures are not updated. This patch will calculate the correct part of
the image that needs to be reuploaded.
2022-03-01 10:45:19 +01:00
4a4701b43c Fix painting on none 256 aligned images.
Internally the update tiles are 256x256. Due to some miscalculations
tiles were not generated correctly if the dimension of the image wasn't
a multifold of 256.
2022-03-01 09:32:58 +01:00
34f6a99433 Fix crash triggered by an introduced assert. 2022-03-01 08:56:58 +01:00
ead84d2ba6 Fix building error in previous commit. 2022-03-01 08:53:23 +01:00
5e9c1feb8a Image Engine: Performance 8 byte images.
Previously we used to cache a float image representation of the image in
rect_float. This adds some incorrect behavior as many areas only expect
one of these buffers to be used.

This patch stores float buffers inside the image engine. This is done per
instance. In the future we should consider making a global cache.
2022-03-01 08:41:25 +01:00
f0bfceb96d Cleanup: remove unused code 2022-03-01 17:22:35 +11:00
9b114d6214 Merge branch 'blender-v3.1-release' 2022-02-28 23:47:43 -05:00
91de337dc5 Cmake: Re-enable tissue add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-02-28 23:45:59 -05:00
a4e8b3a9a9 Cleanup: remove check_deprecated.py
This was temporarily added back as the build-bot was running it.
2022-03-01 14:09:03 +11:00
8a8424021c Cleanup: move Event.is_repeat & is_direction_inverted to flags
Use a flag for events to avoid adding struct members every time a new
kind of tag is needed - so events remain small.

This also simplifies copying settings as flags can be copied at once
with a mask.
2022-03-01 12:21:27 +11:00
eb0f8317e2 Cleanup: ED_view3d_win_to_delta & ED_view3d_calc_zfac usage
- Rename ED_view3d_win_to_delta `mval` argument to `xy_delta` as it
  as it was misleading since this is an screen-space offset not a region
  relative cursor position (typical use of the name `mval`).
  Also rename the variable passed to this function which also used the
  term `mval` in many places.
- Re-order the output argument of ED_view3d_win_to_delta last.
  use an r_ prefix for return arguments.
- Document how the `zfac` argument is intended to be used.
- Split ED_view3d_calc_zfac into two functions as the `r_flip` argument
  was only used in some special cases.
2022-03-01 11:18:17 +11:00
Leon Schittek
ae6400cfb4 UI: Fix multi input socket outline and highlight
Small fixes to the drawing of multi input sockets:
 - Make the outline thickness consistent with normal node sockets,
   independent from the screen DPI.
 - Only highlight multi input sockets when they are actually selected.
 - Skip selected multi inputs when drawing normal selected sockets.

Differential Revision: https://developer.blender.org/D14192
2022-02-28 18:05:30 -05:00
5777bd719b Cleanup: use doxygen comments, correct spelling
Also move eDupli_ID_Flags doc-string to it's declaration.
2022-03-01 09:36:25 +11:00
94a4dddb1b Fix: Don't tag curves component cache dirty for radius
Changing the radius does not invalidate a cache on
`CurvesGeometry`.
2022-02-28 17:28:54 -05:00
9ebb65323e Fix: Use correct default in Curves to CurveEval conversion
Currently the code expects the radius attribuet to always exist on the
input Curves. This won't be true in the future though, so the correct
default value of one should be used when creating the data on CurveEval,
where the data is not optional.
2022-02-28 17:27:38 -05:00
6594e802ab Curves: Add method to access cyclic attribute
Avoids the need to use the attribute API to access this commonly
used builtin attribute.
2022-02-28 17:20:37 -05:00
4c407f20a6 Cleanup: Move object_add.c to C++
This patch was tested on the buildbot first, it builds on all platforms.
2022-02-28 16:20:55 -05:00
Leon Schittek
75bb99fa40 Nodes: Improve readability of selected node links
This commit improves the drawing of selected node links:
 - Highlight the entire link to make it easier to spot where the link
   is going/coming from.
 - Always draw selected links on top, so they are always clearly
   visible.
 - Don't fade selected node links when the sockets they are connected
   to are out out view.
 - Dragged node links still get a partial highlight when they are only
   attached to one socket.

Differential Revision: https://developer.blender.org/D11930
2022-02-28 15:52:00 -05:00
Wannes Malfait
eeb0279e89 Geometry Nodes: Use std::move in dual mesh node
Add a std::move in some places to prevent arrays from being copied.
These cases were potentially optimized by the compiler, but this makes
it more explicit.

Differential Revision: https://developer.blender.org/D14129
2022-02-28 15:16:01 -05:00
611157057b Cleanup: Use bool instead of int 2022-02-28 15:10:20 -05:00
7c3a5da04b Merge branch 'blender-v3.1-release' 2022-02-28 14:38:41 -05:00
59a133b61f Cmake: Re-enable real snow add-on
This add-on now conforms to the distribution requirements, see: T95442.
2022-02-28 14:38:13 -05:00
96492903aa Merge branch 'blender-v3.1-release' 2022-02-28 19:18:22 +01:00
44b0c70919 Fix T92288, T96041: instancing of shared mesh objects without modifiers broken
New code from the vertex normal refactor cfa53e0fbe combined with older code
from 592759e3d6 that disabled instancing for custom normals and autosmooth
meant that instancing was always disabled.

However we do not need to disable instancing for custom normals and autosmooth
at all, this can be shared between instances just fine.
2022-02-28 18:32:27 +01:00
Henrik Dick
8c932ab43c Fix T96032: add null check to constraint operators
The constraint operators for delete, apply, copy and copy to selected
were missing null checks and could crash blender when called wrongly
from the python api.

Differential Revision: http://developer.blender.org/D14195
2022-02-28 18:26:58 +01:00
245722866d Cleanup: Rename geometry set "curve" functions to "curves"
Ref T95355
2022-02-28 10:53:30 -05:00
9ec12c26f1 Geometry Nodes: Begin conversion to new curves
This commit changes `CurveComponent` to store the new curve
type by adding conversions to and from `CurveEval` in most nodes.
This will temporarily make performance of curves in geometry nodes
much worse, but as functionality is implemented for the new type
and it is used in more places, performance will become better than
before.

We still use `CurveEval` for drawing curves, because the new `Curves`
data-block has no evaluated points yet. So the `Curve` ID is still
generated for rendering in the same way as before. It's also still
needed for drawing curve object edit mode overlays.

The old curve component isn't removed yet, because it is still used
to implement the conversions to and from `CurveEval`.

A few more attributes are added to make this possible:
- `nurbs_weight`: The weight for each control point on NURBS curves.
- `nurbs_order`: The order of the NURBS curve
- `knots_mode`: Necessary for conversion, not defined yet.
- `handle_type_{left/right}`: An 8 bit integer attribute.

Differential Revision: https://developer.blender.org/D14145
2022-02-28 10:46:34 -05:00
37d2c774c1 Fix T96073: Don't remove links when inserting reroute nodes
This was an oversight in rB06ac5992618a75c453e495e06af7c5faf30499a7.
2022-02-28 16:42:15 +01:00
81bb86c750 Cleanup: Remove duplicated comment
Something went wrong here in 61776befc3.
2022-02-28 16:33:34 +01:00
579f42ae52 Cleanup: Move mesh_validate.c to C++
This patch was tested on the build bots on all platforms.
2022-02-28 10:08:26 -05:00
f5159e078e Merge branch 'blender-v3.1-release' 2022-02-28 15:03:17 +01:00
413e87b6b7 Fix T96048: Crash on appending with driver variables loop in shapekeys.
The usual 'shape keys snowflake' nightmare again...
2022-02-28 15:02:17 +01:00
db3f5ae48a Fix T95506: Separate strings for "Back" (operator).
Add a new `EDITOR_VIEW3D` context to those view orientations.
2022-02-28 14:37:07 +01:00
1e848281f9 18n: Add new EDITOR_VIEW3D translation context. 2022-02-28 14:37:07 +01:00
8e940f31fd WM: Allow drop-box polls to use context from UI
The UI context was only set for the operator polls, but not for the
drop-box polls. Initially I thought this wouldn't be needed since the
drop-boxes should leave up context polls to the operator, but in
practice that may not be what API users expect. Plus the tooltip for the
drop-boxes will likely have to access context anyway, so they should be
able to check it beforehand.
2022-02-28 13:14:46 +01:00
Colin Marmont
1558b270e9 Animation: Sensible frame range for motion paths
Motion paths can now be initialised to more sensible frame ranges,
rather than simply 1-250:

- Scene Frame Range
- Selected Keyframes
- All Keyframes

The Motion Paths operators are now also added to the Object context menu
and the Dopesheet context menu.

The scene range operator was removed, because the operators now
automatically find the range when baking the motion paths.

The clear operator now appears separated in "Selected Only" and "All",
because it was not clear for the user what the button was doing.

Reviewed By: sybren, looch

Maniphest Tasks: T93047

Differential Revision: https://developer.blender.org/D13687
2022-02-28 12:28:19 +01:00
6f23401e98 Merge branch 'blender-v3.1-release' 2022-02-28 10:57:12 +01:00
6bbf63f251 Fix T96054: Switching vertex group does not update display
Caused by 0f89bcdbeb and was not fully addressed by 6f9828289f:
tagging an ID with flag 0 is to be seen as an explicit tag for copy
on write.

Would be nice to either consolidate code paths of flag 0 and explicit
component tag, or get rid of tagging with 0 flag, but that is above of
what we can do for the upcoming release.
2022-02-28 10:54:07 +01:00
307d612404 Fix compilation warning. 2022-02-28 09:45:52 +01:00
cb736d2f03 Fix T95298: Multiview images not displaying correctly.
Image users have a multi_index that wasn't updated in case it is a normal
image.
2022-02-28 09:23:45 +01:00
540fd10b4f Fix T95992: Crash Ancored strokes 2d texture painting.
When using ancored stroked the diameter of the stroke can be 0 what
leads to a division by zero that on certain platforms wrap to a large
negative number that cannot be looked up. This fix will clamp the size
of the brush to 1.
2022-02-28 09:03:47 +01:00
2a644deaa7 Fix T95981: Remove implicit conversion in texture paint shader.
This fixes a crash on selected platforms.
2022-02-28 08:40:59 +01:00
db4313610c Event System: drag events now use modifier state on drag start
Now drag & tweak can have modifier keys to be released while dragging.
without this, modifier keys needs to be held which is more noticeable
for tablet input or whenever the drag threshold is set to a large value.

Resolves T89989.
2022-02-28 15:31:01 +11:00
63891f9dad Fix: Crash in Duplicate Element
Return early if a curve has a domain size of 0.
T96060
2022-02-27 15:16:45 -06:00
4f2f3114b7 Fix: Incorrect assert in curves code
The attribute data might be null if the number of curves is zero.
While that is not common, an empty curves data-block is valid.
2022-02-26 17:33:45 -05:00
ee160630c6 Merge branch 'blender-v3.1-release' 2022-02-26 17:57:37 -03:00
4ee4b61dd8 Ghost/Event System: Support mapping more keys
This fixes T93051, T76405 and maybe others.

Characters like '²', '<' are not recognized in Blender's shortcut keys.
And sometimes simple buttons like {key .} and {key /} on the Windows
keyboard, although the symbol is "known", Blender also doesn't
detect for shortcuts.

For Windows, some of the symbols represented by `VK_OEM_[1-8]` values,
depending on the language, are not mapped by Blender.

On Mac there is a fallback reading the "actual character value of the
'remappable' keys". But sometimes the character is not mapped either.

On Windows, the solution now mimics the Mac and tries to read the button's
character as a fallback.

For unmapped characters ('²', '<', '\''), now another value is chosen as a
substitute.

More "substitutes" may be added over time.

Differential Revision: https://developer.blender.org/D14149
2022-02-26 17:56:17 -03:00
576853661c UI: Use title case for labels 2022-02-25 23:34:08 -05:00
d6b3723b08 Cleanup: typos in comments. 2022-02-26 02:15:22 +01:00
ac3f4db719 Cleanup: Mesh normal calculation comments and logic
Some logic and comments in the vertex normal calculation were
left over from when normals were stored in MVert, before
cfa53e0fbe. Normals are never allocated and freed
locally anymore.
2022-02-25 17:47:42 -05:00
1598ab9639 Merge branch 'blender-v3.1-release' 2022-02-25 17:23:14 -05:00
7aa0be4b32 Fix: Failing OBJ export tests due to mesh normals commit
In some cases, the normal edit modifier calculated the normals on one
mesh with the "ensure" functions, then copied the mesh and retrieved
the layers "for write" on the copy. Since 59343ee162, normal
layers are never copied, and normals are allocated with malloc instead
of calloc, so the mutable memory was uninitialized.

Fix by calculating normals on the correct mesh, and also add a warning
to the "for write" functions in the header.
2022-02-25 17:18:07 -05:00
a911f075d7 Fix T93123: viewport lags with custom attributes
The check to see if newly requested attributes are not already in the
cache was not taking into account the possibility that we do not have
new requested attributes (`num_requests == 0`). In this case, if
`attr_used` already had attributes, but `attr_requested` is empty, we
would consider the cache as dirty, and needlessly rebuild the attribute
VBOs.
2022-02-25 22:04:10 +01:00
72a286760f Fix compile warning from earlier commit. 2022-02-25 22:01:17 +01:00
bdf4e1596d Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-25 21:36:09 +01:00
c8b4e0c0b5 Disable GPU subdivision if autosmooth or split normals are used
These features are complicated to support on GPU and hardly compatible
with subdivision in the first place. In the future, with T68891 and
T68893, subdivision and custom smooth shading will be separate workflows.
For now, and to better prepare for this future (although long term
plan), we should discourage workflows mixing subdivision and custom
smooth normals, and as such, this disables GPU subdivision when
autosmoothing or custom split normals are used.

This also adds a message in the modifier's UI to indicate that GPU
subdivision will be disabled if autosmooth or custom split normals are
used on the mesh.

Differential Revision: https://developer.blender.org/D14194
2022-02-25 21:28:13 +01:00
118a219e9d Fix different shading between CPU and GPU subdivision
Reuse the same vertex normals calculation as for the GPU code, by
weighing each vertex normals by the angle of the edges incident to the
vertex on the face.

Additionally, remove limit normals, as the CPU code does not use them
either, and would also cause different shading issues when limit surface
is used.

Fixes T95242: shade smooth artifacts with edge crease and limit surface
Fixes T94919: subdivision, different shading between CPU and GPU
2022-02-25 21:25:13 +01:00
4896e72a4d Fix T95977: Point Info node radius wrong under rotation 2022-02-25 20:51:22 +01:00
1a8db5b717 Fix: Only possible to create one 8 bit integer attribute
The custom data code checks for `LayerTypeInfo.defaultname` before
adding a second layer with a certain type. This was missed in
e7912dfa19. In practice, this default name
is not actually used.
2022-02-25 10:35:14 -05:00
0a6a74bac4 Fix T94396: USD errors opening saved scenes.
Added call to ensure that the USD plugins are registered
when opening a USD cache archive. This is to avoid USD
load errors due to missing USD file format plugins when
opening blender files that contain USD transform cache
constraints and mesh sequence cache modifilers.

Fixes T94396
2022-02-25 09:27:10 -05:00
688d2eb6e7 EEVEE: Simplify Hi-Z pass by porting it to a single pass compute shader 2022-02-25 15:14:01 +01:00
fd82cf7099 DRW: Add simple texture view wrappers to draw::Texture 2022-02-25 15:14:01 +01:00
06f5f29d17 Merge branch 'blender-v3.1-release' 2022-02-25 15:11:01 +01:00
e84b42bfcf Fix (unreported) Outliner 'liboverride create hierarchy' applied on several IDs.
This operation can only be applied on one ID at a time, so only apply it
to the active Outliner item, and not all the selected ones.

Also renamed `Make Library Override` menu entry to `Make Library Override
Single` to emphasis this is not the 'default expected' option for the
user.
2022-02-25 15:06:43 +01:00
6e11cfc56a Curves: add surface object pointer
Ref T95776.

Differential Revision: https://developer.blender.org/D14182
2022-02-25 13:22:42 +01:00
1a853a9e90 LibOverrides: fix handling of hierarchy root in complex cases.
This affects essentially the Outliner 'create hierarchy' tool currenlty.
Previously code did not handle properly hierarchy root in case overrides
where created from a non-root ID (e.g. an object inside of a linked
collection), and in case additional partial overrides were added to an
existing partially overrided hierarchy.

Also did some renaming on the go to avoid using 'reference' in override
context for anything else but the reference linked IDs.
2022-02-25 12:18:48 +01:00
5db32ab5fc Merge branch 'blender-v3.1-release' 2022-02-25 21:51:37 +11:00
0bac962fe5 CMake: exclude add-ons that don't confirm to key requirements
These add-ons don't have documentation on blender.org, see: T95442

These can be re-enabled once documentation has been relocated.
2022-02-25 21:50:00 +11:00
8ddeb71a55 Merge branch 'blender-v3.1-release' 2022-02-25 11:40:19 +01:00
66328db703 Fix T95636: Dragging Material from Asset Browser (Link mode) to Viewport empty space removes this material from all objects
Trust user count to actually delete or not the dragged ID when current
dragging is cancelled, since it may be already used by others.

NOTE: This is more a band-aid fix than anything else, cancelling drag
has a lot of other issues here (like never deleting any indirectly
linked/appended data, etc.). It needs a proper rethink in general.
2022-02-25 11:37:55 +01:00
4c9846eeae Cleanup: Modify comment 2022-02-25 11:24:45 +01:00
8f1ee85ff4 Merge branch 'blender-v3.1-release' 2022-02-25 11:22:17 +01:00
5186a28dec GPencil: Make Fill Dilate expand outside stroke
To keep consistency with the new contract option, the dilate now expand the shape beyond the internal closed area.

Note: This was committed only in master (3.2) by error.
2022-02-25 11:15:56 +01:00
5fd792c1f6 GPencil: Fill Dilate using negative values contract the fill area
This is requested by artist for some animation styles where is necessary to fill the area, but create a gap between fill and stroke.

Also some code cleanup and fix a bug in dilate for top area.

Reviewed By: pepeland, mendio

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

Note: This was committed only in master (3.2) by error.
2022-02-25 11:15:42 +01:00
ad0b3abf53 Cleanup: use flags for wmEvent modifier keys
Using flags makes checking multiple modifiers at once more convenient
and avoids macros/functions such as IS_EVENT_MOD & WM_event_modifier_flag
which have been removed. It also simplifies checking if modifier keys
have changed.
2022-02-25 17:58:22 +11:00
60af7a3496 Fix T95984: Use consistent shifting for persp and ortho cam.
Now always properly shifting camera for ortho and perspective.
2022-02-25 14:07:39 +08:00
e7cae51877 Fix T95984: Use consistent shifting for persp and ortho cam.
Now always properly shifting camera for ortho and perspective.
2022-02-25 13:57:27 +08:00
1304db6c52 GPUTexture: Expose layer & mip count 2022-02-25 01:05:09 +01:00
13a0aa8b2d Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_data.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/gpu/CMakeLists.txt
2022-02-24 22:53:59 +01:00
7d7dd66ba7 GPUTexture: Add support for texture view
This is an OpenGL 4.3 feature that enables creating a texture using a range
of the same data as another texture.
2022-02-24 22:51:19 +01:00
e59f754c16 GPUTexture: Use immutable storage
This means textures need to have the number of mipmap levels specified
upfront. It does not mean the data is immutable.

There is fallback code for OpenGL < 4.2.

Immutable storage will enables texture views in the future.
2022-02-24 22:51:19 +01:00
c23ee6d7b4 Cleanup: Simplify operating on multiple geometry components 2022-02-24 14:02:32 -05:00
5ccbbaed08 Cleanup: Sort include lines 2022-02-24 19:44:07 +01:00
3b3e519edd Nodes: Add include to avoid Windows compiler error
This line was added as request of @HooglyBoogly
2022-02-24 19:43:14 +01:00
9de720f31a Merge branch 'blender-v3.1-release' 2022-02-24 19:40:42 +01:00
8fb7c50aab Fix compiler error in Windows
In some compilers this file fails because the function `BKE_mesh_poly_normals_ensure`is not defined.
2022-02-24 19:38:16 +01:00
0781c22cee Fix T95969, T91856: bake AO to vertex color artifacts after ray offset removal
Without ray offsets intersections at neigbhoring triangles are found, as
the ray start is exactly at the vertex. There was a small offset towards
the center of the triangle, but not enough.

Now this offset computation is moved into Cycles and modified for better
results. It's still not perfect though like any offset approach, especially
with long thin triangles.

Additionaly, this uses the shadow terminate offset for AO rays now, which
helps remove some pre-existing artifacts.
2022-02-24 19:35:36 +01:00
6e396e21e6 Cleanup: remove unused ray offset function 2022-02-24 19:35:36 +01:00
4c66bd5da2 Curves: Use simpler "set" behavior for postion attribute
This is similar to f8fe0e831e, which made the change to the
handle position attributes. This commit removes the way that setting the
`position` attribute also changes the handle position attributes. Now,
the "Set Position" node still has this behavior, but changing the
attribute directly (with the modifier's output attributes) does not.

The previous behavior was a relic of the geometry nodes design
from before fields and the set position node existed.

This makes the transition to the new curves data structure simpler.
There is more room for optimizing the Bezier case of the set position
node in the future.
2022-02-24 12:22:26 -05:00
f4d80ecdfd Cleanup: Typo in comment 2022-02-24 12:01:22 -05:00
cc966c548d Merge branch 'blender-v3.1-release' 2022-02-24 11:57:53 -05:00
7b37d980b9 Fix: Crash switching between sculpt and edit mode
Also fix a couple other places where normals layers weren't properly
tagged dirty or reallocated when the mesh changes.

Caused by cfa53e0fbe. When the size of a mesh changes,
the normal layers need to be reallocated. There were a couple of places
that cleared other runtime data with `BKE_mesh_runtime_clear_geometry`
but didn't deal with normals properly. Clearing the runtime "geometry"
is different from clearing the normals, because sometimes the size of
the normal layers doesn't have to change, in which case simply tagging
them dirty is fine.
2022-02-24 11:56:32 -05:00
7c1b0dec00 Merge branch 'blender-v3.1-release' 2022-02-24 17:43:24 +01:00
f8507ca372 EEVEE: Fix crash when shadow caster count is reduced to 0.
The crash was catched by ASAN. It was caused by the buffer shrinking logic
being faulty.
2022-02-24 17:43:04 +01:00
17301a3163 Fix incorrect Outliner tree-display type returned
Reverts 6d97fdc37e. A function like this should not return a different
tree-display object than of the requested type. This may hide errors,
and leaves the Outliner in an undefined state (where the stored display
mode doesn't match the tree-display object). I rather don't hide the
fact that all display-modes should be handled here, and emit a clear
error if one isn't.
2022-02-24 17:10:19 +01:00
fc8aab755a Fix T96015: Calling wrong operator resulting in python error
Own mistake in rB86fc63c4ca9d36eae7512c5c3e640285d84415d1.
Forgot to change the call from `wm.url_open` to `wm.url_open_preset`.
2022-02-24 11:10:00 -05:00
8d83fc552a GPU: Fix compilation in debug mode
Fixes issue introduced in rB1685b1dba44e02ce1faace4a5de6d6cd0d98ef90
2022-02-24 15:55:22 +01:00
1685b1dba4 OCIO: Fix mip length in texture creation
Also add an assert to avoid reproducing the error in the future.
2022-02-24 15:48:54 +01:00
9be720d85e BLI: support accessing nth last element in Array/Span/Vector
This often helps to make the intend of code more clear compared
to computing the index manually in the caller.
2022-02-24 14:50:13 +01:00
7cab7eb3d6 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-24 14:34:15 +01:00
b7a954218b Fix T95976: on cage GPU subdivision breaks X-ray selection
When X-ray mode is active the selection is done using the mesh data to
select what is closest to the cursor. When GPU subdivision is active with
the "show on cage" modifier option, this fails as the mesh used for selection
is the unsubdivided one.

This creates a subdivision wrapper before running the selection routines to
ensure that subdivision is available on the CPU side as well.

Differential Revision: https://developer.blender.org/D14188
2022-02-24 14:33:48 +01:00
189c5bd9af Merge branch 'blender-v3.1-release' 2022-02-24 12:45:27 +01:00
17e0634902 Fix T95985: crash when assigning a name for an output attribute
This was a double free error which happened because `BM_mesh_bm_from_me`
was taking ownership of arrays that were still owned by the Mesh. Note that
this only happens when the mesh is empty but some custom data layers still
have a non-null data pointer. While usually the data pointer should be null in
this case for performance reasons, other functions should still be able to
handle this situation.

Differential Revision: https://developer.blender.org/D14181
2022-02-24 12:44:02 +01:00
d48e595c78 Fix wrong asset library displayed/loaded in asset view templates
Sometimes when switching asset libraries in the asset view templates
(like the pose library sidebar UI), the wrong library would end up being
shown.
2022-02-24 12:40:40 +01:00
b0eed6fb9a Merge branch 'blender-v3.1-release' 2022-02-24 18:01:53 +11:00
41d607976c Keymap: use 90 degree roll for NDOF roll shortcuts
3Dconnexion documentation states these buttons should roll 90 degrees.
2022-02-24 18:00:18 +11:00
13efaa8a09 3D View: keep the orthographic view when rolling 90 degrees
Support for maintaining orthographic view for view3d.view_roll for an
angle of 90/-90 degrees.
2022-02-24 18:00:17 +11:00
87c2b1988d Keymap: correct NDOF button roll assignment
NDOF ROLL CCW was used for both left & right roll.
2022-02-24 18:00:17 +11:00
e767a2d98b Keymap: correct NDOF button roll assignment
NDOF ROLL CCW was used for both left & right roll.
2022-02-24 17:51:19 +11:00
81df323df4 Tests: disable file output for bl_keymap_validate.py
Left on by accident but should only be used when debugging output.
2022-02-24 17:43:36 +11:00
fe4b53311a Merge branch 'blender-v3.1-release' 2022-02-24 15:25:38 +11:00
f80f7afbf0 Fix 2D view NDOF panning requiring both axes to be non-zero
Possible fix for T86592.
2022-02-24 15:24:09 +11:00
1a6b35157c Cleanup: code comments in vfont_to_curve 2022-02-24 13:20:33 +11:00
b45a3e8747 Cleanup: remove dead code in vfont_to_curve
Also replaces numbers with character literals for tab/space.
2022-02-24 13:14:33 +11:00
24450fa142 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-24 03:01:44 +01:00
d59f45fb15 Cleanup: remove dead code from text wrapping logic
Error from original commit in 2005,
97df61a7e5.
2022-02-24 12:53:11 +11:00
e83e7d49b6 Cleanup: use continue instead of goto for 3D text wrapping logic 2022-02-24 12:53:09 +11:00
ba274d20b4 Fix T95959: crash when exporting subdivision to Alembic
When exporting generated coordinates, the subdivision export code was
using the schema for the non-subdivision case, which is invalid as
non-initialized. This typo existed since the initial commit for the
feature (rBf9567f6c63e75feaf701fa7b78669b9a436f13dd).
2022-02-24 02:46:33 +01:00
affed12bb9 Merge branch 'blender-v3.1-release' 2022-02-24 12:19:17 +11:00
c9582b2752 Fix T95116: Scale to fit fails with a single word & non-zero Y-size
The scale-to-fit option did nothing for single words when
the text box had a height. This happened because it was expected that
text would be wrapped however single words never wrap.

Now the same behavior for zero-height text boxes is used when text
can't be wrapped onto multiple lines.
2022-02-24 12:18:39 +11:00
f8fe0e831e Curves: Use simpler "set" behavior for handle position attributes
The handle position attributes `handle_left` and `handle_right` had
rather complex behavior to get expected behavior when aligned or auto/
vector handles were used. In order to simplify the attribtue API and
make the transition to the new curves data structure simpler, this
commit moves that behavior from the attribute to the "Set Handle
Positions" node. When that node is used, the behavior should be the
same as before. However, if the modifier's output attributes were used
to set handle positions, the behavior may be different. That situation
is expected to be very rare though.
2022-02-23 15:44:55 -05:00
756f7fb23e Geometry Nodes: Face is Planar Node
This adds a node with a boolean field output which returns true if all of the
points of the evaluated face are on the same plane. A float field input allows
for the threshold of the face/point comparison to be adjusted on a per face basis.

One clear use case is to only triangulate faces that are not planar.

Differential Revision: https://developer.blender.org/D13906
2022-02-23 14:19:54 -06:00
86fc63c4ca Cleanup: Simplify manual url version handling
Recently we changed the build pipeline to always create a version
number in the url and point 'dev' to the latest version rather than creating the version number url once we release.

This makes the check to `bpy.app.version_cycle` unnecessary.
2022-02-23 15:00:16 -05:00
6ca85a8cf1 Fix: Build issue on windows
tbb/enumerable_thread_specific.h drags in windows.h
which will define min/max macro's unless you politely
ask it not to.

it's bit of an eyesore, but it is what it is
2022-02-23 12:27:02 -07:00
88712453f6 Fix error with SPDX-License-Identifier 2022-02-23 14:16:46 -05:00
572acba5d1 Merge branch 'blender-v3.1-release' 2022-02-23 14:12:48 -05:00
80be63e2a5 Update RNA to user manual mapping file 2022-02-23 14:10:52 -05:00
b93d4faba8 Fix for last commit: Define for Node numbering 2022-02-23 13:04:46 -06:00
81e89a444e Merge branch 'blender-v3.1-release' 2022-02-23 14:01:20 -05:00
99a6392fb5 Fix OSL trace() not being fully updated for ray offsetting removal
This was the last place still using the ray_offset() function.
2022-02-23 20:01:03 +01:00
dbef66c32f Fix T95952: Uninitialized value used in Bezier Segment node
0fd72a98ac called functions to set bezier handle positions
that used uninitialized memory. The fix is to define the handle positions
explicitly, like before.
2022-02-23 13:57:04 -05:00
7518adc5bb Fix: Attempt to fix build error on windows
`index_mask.cc` ends up including this header, but not much else,
the `<algorithm>` include is necessary on Windows for `std::max`.
2022-02-23 13:02:06 -05:00
226f0c4fef Curves: initial brush implementations for curves sculpt mode
The main goal here is to add the boilerplate code to make it possible
to add the actual sculpt tools more easily. Both brush implementations
added by this patch are meant to be prototypes which will be removed
or refined in the coming weeks.

Ref T95773.

Differential Revision: https://developer.blender.org/D14180
2022-02-23 16:56:27 +01:00
120f16fa1f Geometry Nodes: Duplicate Elements Node
This adds a node which copies part of a geometry a dynamic number
of times.

Different parts of the geometry can be copied differing amounts
of times, controlled by the amount input field. Geometry can also
be ignored by use of the selection input.

The output geometry contains only the copies created by the node.
if the amount input is set to zero, the output geometry will be
empty. The duplicate index output is an integer index with the copy
number of each duplicate.

Differential Revision: https://developer.blender.org/D13701
2022-02-23 09:08:16 -06:00
e32b676baf Merge branch 'blender-v3.1-release' 2022-02-23 09:58:41 -05:00
398538b914 Fix T95987: Data transfer modifier custom normals crash
59343ee162 missed one case of normals being
retrieved from polygon custom data instead of the normals API.
The fix is simple.
2022-02-23 09:49:25 -05:00
1361c6e604 Curves: Add methods to retrieve range for points or curves 2022-02-23 08:54:35 -05:00
b9ce036d6b Merge branch 'blender-v3.1-release' 2022-02-23 14:33:53 +01:00
867e50b886 Fix T95183: Cage gizmo axis unreliable
`orient_matrix` was not initialized.

Reviewed By: lichtwerk

Differential Revision: https://developer.blender.org/D14167
2022-02-23 14:25:00 +01:00
391c3848b1 NDOF: make camera view/pan behavior optional
User request since adding this option in:
51975b89ed

When disabled, use the previous behavior when orbiting a camera view.
2022-02-23 21:25:46 +11:00
3429444905 BLI: add index mask utilities
Sometimes it is useful to get the index ranges that are in an index mask.
That is because some algorithms can process index ranges more efficiently
than generic index masks.

Extracting ranges from an index mask is relatively efficient, because it is
cheap to check if a span of indices contains a contiguous range.
2022-02-23 11:14:07 +01:00
66c0fe5b23 Cleanup: correction to repeated word removal & correct spelling 2022-02-23 20:47:14 +11:00
7393cc1db7 Cleanup: Remove repeated word in comments 2022-02-23 18:24:37 +11:00
Alaska
165b030b19 Cleanup: Remove repeated word in comment
Differential Revision: https://developer.blender.org/D14178
2022-02-23 11:07:04 +05:30
3c0fd287cb Merge branch 'blender-v3.1-release' 2022-02-23 16:29:51 +11:00
74611e3555 Fix T93331: Gizmo tool options reset when switching tools
Drag Action was constantly resetting itself to "move".

Solve this by storing the tool settings per tool and no longer clear
gizmo properties when activating a new tool.
2022-02-23 16:27:26 +11:00
06bc20f61a Fix: Errors in previous cleanup commit
f3ef0763b4 introduced a file by mistake, and didn't add
a new enum type to many switch cases. Sorry for the noise.
2022-02-22 22:15:03 -05:00
f3ef0763b4 Cleanup: Use new curves type enum for CurveEval
Though this is less aesthetically pleasing, it makes the transition to the
new curves type (T95941) a bit simpler, and it has to be done anyway.
2022-02-22 21:52:48 -05:00
c6df7266c7 CMake: move cmake_consistency_check.py into source/tools/ repo
This isn't needed for building Blender so move this along side
other source checking scripts.
2022-02-23 12:31:46 +11:00
e1c33698e6 GNUmakefile: prefer "check_" prefix instead of "test_"
- Reserve "test" for tests & testing frameworks.
- Add "check_mypy" to "make help" text.
- Output to the standard output instead of redirecting to log-files,
  leave redirecting output log-files to the user running the command.
2022-02-23 12:31:46 +11:00
4c423ccbd6 CMake: include missing files
Also use SRC_ prefix for source variables so cmake_consistency_check.py
detects these files as being known to CMake.
2022-02-23 12:31:46 +11:00
4addc1f31e Tests: temporarily add back tests/check_deprecated.py
The build-bot directly referenced this file and doesn't
have publically available configuration.

Add an empty file until this can be removed by the build scripts.
2022-02-23 12:30:54 +11:00
5b4732f81c Cleanup: Use new enum for CurveEval handle types
This will make the transition to the new curves data structure
a bit simple, since the handle types can be copied directly between
the two. The change to CurveEval is simple because it is runtime-only.
2022-02-22 17:37:58 -05:00
0b9cc6725c XR: Use #ifdef for Vive Focus 3 extension
Helps with building against different OpenXR SDK versions (i.e. for
downstream builds that require specific versions), as the extension was
only defined since OpenXR 1.0.22.
2022-02-23 06:56:08 +09:00
d228f05814 Merge branch 'blender-v3.1-release' 2022-02-22 14:40:20 -05:00
2746238dde Python API Docs: Hide version swtich
This still needs some fixes to be ready for release.
2022-02-22 14:39:51 -05:00
529f891878 GPencil: Make Fill Dilate expand outside stroke
To keep consistency with the new contract option, the dilate now expand the shape beyond the internal closed area.
2022-02-22 20:03:34 +01:00
ad3ee84f4e Cleanup: Remove unused mesh dirty flags
These were only set in two places. One was related to "tessellated loop
normal", and the other derived corner normals. The values were never
checked though, after 59343ee162. The handling of dirty face
corner normals is clearly problematic, but in the future it should be
handled like the normal layers on the other domains instead.

Ref D14154, T95839
2022-02-22 13:13:13 -05:00
c7a9f76149 Merge branch 'blender-v3.1-release' 2022-02-22 12:47:05 -05:00
59343ee162 Fix T95839: Data race when lazily creating mesh normal layers
Currently, when normals are calculated for a const mesh, a custom data
layer might be added if it doesn't already exist. Adding a custom data
layer to a mesh is not thread-safe, so this can be a problem in some
situations.

This commit moves derived mesh normals for polygons and
vertices out of `CustomData` to `Mesh_Runtime`. Most of the
hard work for this was already done by rBcfa53e0fbeed7178.
Some changes to logic elsewhere are necessary/helpful:
- No need to call both `BKE_mesh_runtime_clear_cache` and
  `BKE_mesh_normals_tag_dirty`, since the former also does the latter.
- Cleanup/simplify mesh conversion and copying since normals are
  handled with other runtime data.

Storing these normals like other runtime data clarifies their status
as derived data, meaning custom data moves more towards storing
original/editable data. This means normals won't automatically benefit
from the planned copy-on-write refactor (T95845), so it will have to be
added manually like for the other runtime data.

Differential Revision: https://developer.blender.org/D14154
2022-02-22 12:44:15 -05:00
f3d97498c3 Merge branch 'blender-v3.1-release' 2022-02-22 18:03:27 +01:00
ee9949a85f Fix (unreported) LibOverride: missing copying flag member. 2022-02-22 18:01:52 +01:00
29696fb725 UI: ActionZone Swap Areas Between Windows
Allow SCREEN_OT_area_swap to operate between different Blender
windows, and other minor feedback improvements.

See D14135 for more details and demonstrations.

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

Reviewed by Campbell Barton
2022-02-22 08:58:42 -08:00
8ae77efe4e Merge branch 'blender-v3.1-release' 2022-02-22 17:34:07 +01:00
283a4cd40e Fix ffmpeg tests when using ffmpeg 5.0 2022-02-22 17:30:52 +01:00
2f951667c0 OCIO: Fix bool1 vs. bool comparison warning.
Fixes the following warning:
`'!=': unsafe mix of type 'bool1' and type 'bool' in operation`
2022-02-22 17:29:32 +01:00
353fe610ed Fix: Clear mesh runtime cache when adding elements
Currently the RNA functions to add mesh elements like vertices
don't clear the runtime cache of things like triangulation, BVH
trees, etc. This is important, since they might be accessed with
incorrect sizes. This is split from a fix for T95839.
2022-02-22 11:14:50 -05:00
8073c95fe9 Cleanup: Deduplicate logic in RNA_property_editable & co.
Fairly straight-forward, now all the logic for all those 'is editable'
complex checks is gathered into a single util function.
2022-02-22 16:38:04 +01:00
51c7193405 Cycles: Removed numaapi from standalone 2022-02-22 16:34:52 +01:00
faf5333f0f EEVEE: Fix no shadow option 2022-02-22 16:21:04 +01:00
b861d3e4c1 Merge branch 'blender-v3.1-release' 2022-02-22 16:08:38 +01:00
7de7a1a5cf EEVEE: Shadow: Improve the case of directional shadowmaps in ortho view
This is still far from perfect but it is better than not working
correctly.

The view/casters intersection bounds are too big and rough to
compute a decent tilemap level that is near the desire shadow pixels
density.

The algorithm works relatively ok if the sun direction is almost
parallel to the ortho view direction.
2022-02-22 16:07:07 +01:00
ca991e3012 Fix compilation error on certain platforms
Atomic operations performed by the C++ standard library might require
libatomic on platforms which do not have hardware support for those
operations.

This change makes it that such configurations are automatically detected
and -latomic is added when needed.

Differential Revision: https://developer.blender.org/D14106
2022-02-22 15:47:43 +01:00
37fb69e020 Fix (unreported) RNA_property_editable_index.
NOTE: This function is currently unused. However, it does use a callback
defined by a few RNA properties through
`RNA_def_property_editable_array_func`, so don't think it should be
removed without further thinking.

This function had two main issues:
* It was doing bitwise AND on potentially three sources of property
  flag, when actually used `RNA_property_editable` just use one source
  ever.
* It was completely ignoring liboverride cases.

TODO: Deduplicate code between `RNA_property_editable`,
`RNA_property_editable_info` and `RNA_property_editable_index`.
2022-02-22 15:33:52 +01:00
f449b89688 Cleanup: Make RNA_property_editable logic clearer.
Split code in smaller bits with early returns, instead of a giant single
set of checks.

No behavioral change expected here.
2022-02-22 15:18:08 +01:00
472ddc6e27 Merge branch 'blender-v3.1-release' 2022-02-22 15:13:27 +01:00
1d4037645f Cleanup: quiet warnings for FFMPEG before 5.0
Even though 5.0 has been released newer distributions wont include it,
so quiet warnings.
2022-02-22 15:11:35 +01:00
9d8af55eb8 GNUmakefile: missed removing docs for test_deprecated when renaming 2022-02-23 00:05:34 +11:00
66f3545a0b Cleanup: compiler warning 2022-02-22 14:03:11 +01:00
85b39b6be0 Fix subdivision surface modifier doing unnnecessary work
There was accidentally some displacement related code running even when not
using displacement.

Differential Revision: https://developer.blender.org/D14169
2022-02-22 14:03:11 +01:00
6bb4c0e498 GNUmakefile: rename test_depracted to check_deprecated
Also move this utility into the source/tools repo.
2022-02-23 00:00:32 +11:00
4a7559bbcb Cleanup: quiet warnings for FFMPEG before 5.0
Even though 5.0 has been released newer distributions wont include it,
so quiet warnings.
2022-02-23 00:00:32 +11:00
64293a277f Merge branch 'blender-v3.1-release' 2022-02-22 13:57:05 +01:00
4e78a7360e Fix T93784: text and curve objects have no motion blur
Previously, objects and geometries were mapped between frames
using different hash tables in a way that is incompatible with
geometry instances. That is because the geometry mapping happened
without looking at the `persistent_id` of instances, which is not possible
anymore. Now, there is just one mapping that identifies the same
object at multiple points in time.

There are also two new caches for duplicated vbos and textures used for
motion blur. This data has to be duplicated, otherwise it would be freed
when another time step is evaluated. This caching existed before, but is
now a bit more explicit and works for geometry instances as well.

Differential Revision: https://developer.blender.org/D13497
2022-02-22 13:52:15 +01:00
0b4c56b010 Cleanup: Replace eTexPaintMode with classes.
For an upcoming prototype we would introduced a new eTexPaintMode
option. That would add more cases and if statements. This change migrate
the eTexPaintMode to 3 classes. AbstractPaintMode contains a shared interface.
ImagePaintMode for 2d painting and ProjectionPaintMode for 3d painting.
2022-02-22 13:42:44 +01:00
683a77256d Fix compilation issue under windows. 2022-02-22 10:30:02 +01:00
4ba894cbb8 Fix compilation error on certain platforms.
Seems this isn't an issue on newer compilers.
2022-02-22 10:00:03 +01:00
1d4ed6ba29 Convert paint_image to cc. 2022-02-22 10:00:03 +01:00
1ec02b8695 Cleanup: Renamed PaintOperation.custom_paint to stroke_handle. 2022-02-22 10:00:03 +01:00
0cfcb261b1 Merge branch 'blender-v3.1-release' 2022-02-22 19:59:31 +11:00
0ad4d2694b Python: change behavior for CONSOLE_OT_indent_or_autocomplete
Checking only the previous character broke import auto-completion.
2022-02-22 19:57:36 +11:00
7657358447 Cleanup: use doxygen sections 2022-02-22 19:39:55 +11:00
27427f3447 Cleanup: Use switch-statement for eTexPaintMode. 2022-02-22 09:02:52 +01:00
2cd33955be Merge branch 'blender-v3.1-release' 2022-02-22 16:43:23 +11:00
c5b66560de Fix T93629: Reset to defaults undoes all steps when applied twice
Reset Defaults left the undo stack in an invalid state,
with the active undo step left at the previous state then it should
have been.

Now the buttons own undo logic is used to perform undo pushes.
2022-02-22 16:40:07 +11:00
2234bfbcdb GPencil: Simplify sample modifier improvements.
1. Now handles cyclic strokes correctly.

2.  Added a sharp threshold value to allow preservation of sharp corners.

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

Ref D14044
2022-02-22 12:54:35 +08:00
0f2e0a25e1 LineArt: Consistent backface culling behavior
1. Now will remove lines if both adjacent faces are back face.

2. Added a check to respect material back face culling setting.

3. Changed label in the modifier to "Force Backface Culling" (which reflect more accurately with what the checkbox does).

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

Ref D14041
2022-02-22 12:51:49 +08:00
2fefdaae93 Merge branch 'blender-v3.1-release' 2022-02-21 21:54:59 -03:00
75be58c63d Fix errors in 'gpu.state' documentation
`blend_depth_test_get` --> `depth_test_get`
`depth_mask_set_get` --> `depth_mask_get`

Thanks to @SBCV for pointing out these inconsistencies.
2022-02-21 21:48:17 -03:00
18d3d283ec Fix wrong method name in gpu documentation
`use_program_point_size` --> `program_point_size_set`.
2022-02-21 21:48:02 -03:00
Germano Cavalcante
c73bacc364 Camera: Simplify View Frame code
- No need for `normal_tx` array if we normalize the planes in `plane_tx`.
- No need to calculate the distance squared to a plane (with `dist_signed_squared_to_plane_v3`) if the plane is normalized. `plane_point_side_v3` gets the real distance, accurately, efficiently and also signed.

So normalize the planes of the member `CameraViewFrameData::plane_tx`.
2022-02-21 21:47:46 -03:00
459d9c1e3d Fix (unreported): Issues with 'SNAP_NOT_SELECTED' for pose and edit modes
This is a regression partially introduced in rB0a6f428be7f0.

Bones being transformed into edit mode were snapping to themselves.

And the bones of the pose mode weren't even snapping.

(Curious that this was not reported).
2022-02-21 21:47:24 -03:00
fcda858e32 Cleanup: remove Python 3.9 annotation workarounds 2022-02-22 10:28:01 +11:00
ca12696257 Merge branch 'blender-v3.1-release' 2022-02-22 10:18:15 +11:00
ec5bbebf3e Python: bump minimum version to 3.10
Since Python 3.10 is now supported on all platform,
bump the minimum version to reduce the number of Python versions that
need to be supported simultaneously.

Reviewed By: LazyDodo, sybren, mont29, brecht

Ref D13943
2022-02-22 10:16:25 +11:00
b13bf8556b Cleanup: clang-format 2022-02-22 10:08:38 +11:00
55a4ebc701 Merge branch 'blender-v3.1-release' 2022-02-22 10:08:24 +11:00
6ec57f9083 Merge branch 'blender-v3.1-release' 2022-02-22 10:08:20 +11:00
2a5df72d9b Revert "Cleanup: quiet const cast warning"
This reverts commit 626fb290eb.

This was an intentional change for FFMPEG v5.0,
removing the cast should be done in a version check instead.
2022-02-22 10:07:05 +11:00
bfdbc78466 Fix T44415: Shape keys get out of sync when using undo in edit-mode
This is an alternate fix for T35170 since it caused T44415.
Having the undo system manipulate the key-block coordinates is error
prone as (in the case of T44415) there are situations when it's
important to apply the difference with the original shape key.

This reverts dab0bd9de6, and instead
avoids the problem by not using the data in `Mesh.key` as a reference
for updating shape-keys when exiting edit-mode.

The assumption that the `Mesh.key` in edit-mode won't be modified
until leaving edit-mode isn't always true. Leading to synchronization
errors. (details noted in code-comments).

Resolve this by using shape-key data stored in the BMesh.

Resolving both T35170 & T44415.

Details:

- Remove use of the original vertices when exiting edit mode.
- Remove use of the original shape-key coordinates when exiting
  edit-mode (except as a last resort).
- Move shape-key synchronization into a separate function:
  `bm_to_mesh_key`.
- Split the synchronization loop into two branches,
  depending on the existence of BMesh shape-key coordinates.
- Always write shape-key values back to the BMesh CD_SHAPEKEY layers.
  This was only done in some cases but is now necessary for all
  shape-keys as these are used to calculate offsets where the `Mesh.key`
  was previously used.
- Report a warning when the shape-key layer isn't found as this uses an
  imperfect method of restoring coordinates which should only be used as
  a last resort.

Reviewed By: mont29

Ref D14127
2022-02-22 09:57:07 +11:00
c3d36b7127 Cleanup: clang-format 2022-02-22 09:56:43 +11:00
dde5cc6670 Cleanup: Use curves wrapper 2022-02-21 17:06:17 -05:00
24ddb4b1ad Merge branch 'blender-v3.1-release' 2022-02-21 14:04:38 -05:00
284cef473f Fix T95919: Apply Pose as Rest Pose Operator crashes
A simple mistake with a null mesh in rBcfa53e0fbeed.
2022-02-21 13:59:18 -05:00
48abcc91ae Merge branch 'blender-v3.1-release' 2022-02-21 19:51:50 +01:00
49ae0b5b3c Fix T95923: GPencil Array modifier constant offset works even disabled
The problem was when the Object Offset was enabled because the Constant Offset flag was not checked and the offset always was added to the transformation matrix.
2022-02-21 19:48:11 +01:00
06487a4ba1 Merge branch 'master' into eevee-rewrite 2022-02-21 19:14:56 +01:00
9762dbe94e Merge branch 'blender-v3.1-release' 2022-02-21 13:07:14 -05:00
be6bcaa8c1 Fix T93873: Wrong limits for color socket exposed to modifier
Limit the min and max of the IDProperty for the node group input
from 0 to infinity, and the soft min and max between 0 and 1.

Thanks to @PratikPB2123 for investigation.
2022-02-21 13:01:37 -05:00
b7171d1b82 Cleanup: Use function to check if normals are dirty
This makes the fix for T95839 simpler.
Similar to 969c4a45ce.
2022-02-21 12:17:41 -05:00
a81cc5cbcb Fix: Avoid potential use of dirty normals
Instead of accessing the `CD_NORMAL` layer directly,
use the proper API for accessing mesh normals. Even if the
layer exists, the values might be incorrect due to a deformation.
Related to ef0e21f0ae, 969c4a45ce, and T95839.
2022-02-21 11:40:59 -05:00
869dd2e699 Fix T95154 Eevee AO node: the "only local" option applies "inside" instead
The `custom2` was not being used as a bitflag as it should.
2022-02-21 17:18:45 +01:00
68a2dc58de Weight Proximity: do flag split versioning both in 3.1 and 3.2
The flags overlapped ever since normalize was added, so this
requires versioning to copy the flag value. This needs to be
done both in Blender 3.1 and 3.2.

Differential Revision: https://developer.blender.org/D14165
2022-02-21 18:15:17 +03:00
1234a7ada0 Merge branch 'blender-v3.1-release' 2022-02-21 18:14:41 +03:00
82ff0fa586 Weight Proximity: fix value overlap between Normalize and Invert VGroup.
The flags overlapped ever since normalize was added, so this requires
versioning to copy the flag value.

Differential Revision: https://developer.blender.org/D14165
2022-02-21 18:08:53 +03:00
ed9f763034 Paint: pass operator to stroke update function
This allows accessing properties of the operator that the
stroke belongs to.
2022-02-21 16:07:59 +01:00
38ae311706 Weight Modifiers: use the correct flags for the mask invert property.
The code was using the same flag value for different modifiers,
resulting in matching the toggle to random overlapping flags.

Differential Revision: https://developer.blender.org/D14165
2022-02-21 18:07:08 +03:00
Henrik Dick
68586d2c18 Complex Solidify: improve constraints solver
The constraints solver is now able to handle more cases correctly.
Also the behavior of the boundary fixes is slightly changed if
the constraints thickness mode is used.

Differential Revision: https://developer.blender.org/D14143
2022-02-21 14:13:55 +01:00
fa715a158a Vertex Weight Mix: support Minimum and Maximum mix modes.
The modifier supports arithmetic operations, like Add or Multiply,
but for some reason omits Minimum and Maximum. They are similarly
simple and useful math functions and should be supported.

Differential Revision: https://developer.blender.org/D14164
2022-02-21 16:01:39 +03:00
0f242981ec Workbench: Fix missing world_data ubo during opaque prepass 2022-02-21 13:30:20 +01:00
5c11ca10c0 Merge branch 'blender-v3.1-release' 2022-02-21 23:15:50 +11:00
829812f180 Fix T92467: Path Selection broken when Drag is set to Tweak
When RMB-select uses "Select Tweak" as a fallback tool,
ignore all bindings mapped to the Control key as these are
used for path selection.

This was fixed in 2a2d873124
however that caused shift-select to fail (T93100).
2022-02-21 23:09:34 +11:00
d076e9468c Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-21 13:06:28 +01:00
132f9a2e31 Fix T95596: Crash in versioning of node animation
The node animation versioning code passes `nullptr` to the `oldName` and
`newName` parameters, but those weren't `NULL`-safe. I added an extra
check for this.

No functional changes, just a crash fix.
2022-02-21 13:02:23 +01:00
e2ffe88983 Curves: use paint cursor in curves sculpt mode
Also adds radius and strength control to the tool settings in the ui.
2022-02-21 12:49:36 +01:00
fcb84e32e0 Cleanup: use namespace and code sections 2022-02-21 12:01:30 +01:00
9e0a2386cf DRW: Debug: Print fix missing last argument and support function call 2022-02-21 12:00:11 +01:00
7f2beb79c6 Cleanup: move curves sculpt mode toggle operator to sculpt/paint module
This is necessary, because the operator will have to use functions that
are currently private within this module. E.g. `paint_cursor_start`.
2022-02-21 11:57:43 +01:00
141d5851d7 Paint: decouple op->customdata from PaintStroke
Previously, all operators using `PaintStroke` would have to store
the stroke in `op->customdata`. That made it impossible to store
other operator specific data in `op->customdata` that was unrelated
to the stroke.

This patch changes it so that the `PaintStroke` is passed to api
functions as a separate argument, which allows storing the stroke
as a subfield of some other struct in `op->customdata`.
2022-02-21 11:52:46 +01:00
5be74160c0 macOS/ blender_icons_update.py: prioritise environment variables
Also fix binary name for mac

Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D14161
2022-02-21 15:19:19 +05:30
5247b5aeda EEVEE: Fix build on MSVC 2022-02-21 10:05:30 +01:00
bce810f057 Fix T95871: Non-float textures report as float.
Althought the float buffers are only used as cache, current code paths
don't look at the flags to identify which kind of image it is. Actual
fix would be to check flags, but that wouldn't be something to add one
week before release.

This commit fixes it by removing the buffers after use in the image
engine.
2022-02-21 07:48:49 +01:00
9189191c5b Fix errors in 'gpu.state' documentation
`blend_depth_test_get` --> `depth_test_get`
`depth_mask_set_get` --> `depth_mask_get`

Thanks to @SBCV for pointing out these inconsistencies.
2022-02-20 23:31:08 -03:00
813895f713 Cleanup: use strict type checking for bl_keymap_validate 2022-02-21 12:21:47 +11:00
167c4c6962 Tests: add duplicate key-map test, also test multiple configurations
Duplicate key-map items (while harmless in most cases) may cause
unexpected behavior or point to mistakes in the key-map,
so best avoid these.
2022-02-21 12:03:56 +11:00
16da9c944c Cleanup: remove duplicate key-map items 2022-02-21 12:01:32 +11:00
1884f6e729 BLI_array: add BLI_array_trim utility to re-allocate the current size
Use this in BKE_view_layer_array_* functions.
2022-02-21 12:01:32 +11:00
7b11c71729 RNA: modify debug mode logic for setting invalid unset values
The previous behavior called RNA_enum_item_add a second time,
filled it's contents with invalid values then subtracted totitem,
this caused an unusual reallocation pattern where MEM_recallocN
would run in order to create the dummy item, then again when adding
another itme (reallocating an array of the same size).

Simply memset the array to 0xff instead.
2022-02-21 12:01:32 +11:00
2554ef986a readfile: free & reallocate arrays in oldnewmap_clear
Even though the size of the map was set back to DEFAULT_SIZE_EXP,
the underlying arrays were left unchained. In some cases this caused
further expansions to result in an unusual reallocation pattern
where MEM_reallocN would run expand the entries into an array
that was in fact the same size.
2022-02-21 12:01:32 +11:00
e93a8c4f74 Cleanup: avoid reallocating arrays at the same size 2022-02-21 12:01:32 +11:00
626fb290eb Cleanup: quiet const cast warning 2022-02-21 12:01:32 +11:00
35ebf6cf02 EEVEE: Shadow: Fix out of bound access in page_list stage 2022-02-20 23:52:42 +01:00
36d7adf85c Merge branch 'blender-v3.1-release' 2022-02-20 23:15:39 +01:00
24272c7780 EEVEE: Shadow: Add debug visual for the page cache 2022-02-20 23:10:59 +01:00
0451d556c2 EEVEE: Shadow: Fix defrag phase 2022-02-20 23:09:45 +01:00
1a0a22f95a Fix T95413: Blur node size input crash
Bug was introduced in D12167.

Reading input size from an input socket is not possible in tiled compositor before execution is initialized. A similar change was done for the base class, see BlurBaseOperation::init_data().

Reviewed by: Jeroen Bakker

Differential Revision: https://developer.blender.org/D14067
2022-02-20 23:00:44 +01:00
04b49d5678 EEVEE: Shadow: Use debug_view for debug pass 2022-02-20 21:38:06 +01:00
5d27a78917 EEVEE: Shadows: Fix 2 small imprecision 2022-02-20 21:37:27 +01:00
fbf0c0e02b EEVEE: Shadow: Improve debug 2022-02-20 21:37:00 +01:00
de886884c0 Fix T95470: LineArt GPU subdiv fix.
Use evaluated mesh instead of ob->data.

Reviewed by: Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D14040
2022-02-20 19:40:44 +08:00
2903c11c93 DRW: Debug print: add support for multithread printing
This is basic but each thread can now write one line without
overlapping with other threads.
2022-02-20 12:08:49 +01:00
5a20ef35b3 EEVEE: Shadow: Revisit the cache system
This allows removing the indirection for lods during shading since the
tile is not owner of the page unless it uses it.

The cache system is quite more complex but makes it easier to spot
errors since the pages are not scattered into the tile texture.

This also simplify allocation since the free heap is separated from the
cache.
2022-02-20 12:08:32 +01:00
Aaron Carlisle
1f79132287 UI: Do not include the text stating an enum item is the default
This adds maintence overhead and it is not that useful when we have reset to default.

If this is something that we want it should be added dynamically.

Reviewed By: HooglyBoogly, Severin, #user_interface

Differential Revision: https://developer.blender.org/D14151
2022-02-19 21:31:53 -05:00
70ec3d3a3e DRW: Add optional name to storage buffers 2022-02-19 21:04:41 +01:00
991781c8ea LineArt: GPU subdiv fix.
Use evaluated mesh instead of ob->data.

Reviewed by: Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D14040
2022-02-19 22:35:22 +08:00
385d9488e6 Fix incorrect copying of XR action paths
After using MEM_dupallocN() on the original item/binding, the
user/component path ListBase for the new item/binding needs to be
cleared and each path copied separately.
2022-02-19 15:23:34 +09:00
0503bbf989 Merge branch 'master' into eevee-rewrite 2022-02-18 22:48:56 +01:00
16d5658365 OCIO: Port shader creation logic to use GPUShaderCreateInfo
This commit should suffice to make the shader API agnostic now (given that
all users of it use the GPU API).

This makes the shaders not trigger a false positive error anymore since
the binding slots are now garanteed by the backend and not changed at
after compilation.

This also bundles all uniforms into UBOs. Making them extendable without
limitations of push constants. The generated uniforms from OCIO are not
densely packed in the UBO to avoid complexity. Another approach would be to
use GPU_uniformbuf_create_from_list but this requires converting uniforms
to GPUInputs which is too complex for what it is.

Reviewed by: brecht, jbakker

Differential Revision: https://developer.blender.org/D14123
2022-02-18 22:30:45 +01:00
e81dda4f38 Merge branch 'blender-v3.1-release'
# Conflicts:
#	intern/opencolorio/ocio_shader_shared.hh
2022-02-18 22:29:31 +01:00
93cc892470 Revert "OCIO: Port shader creation logic to use GPUShaderCreateInfo"
This reverts commit 7f7c614ecd.
2022-02-18 22:28:05 +01:00
32660382f5 Revert "OCIO: Fix gpu include file"
This reverts commit 3cebfadb27.
2022-02-18 22:28:01 +01:00
7f68185d34 Merge branch 'blender-v3.1-release' 2022-02-18 15:17:01 -06:00
3cebfadb27 OCIO: Fix gpu include file
Was the cause by ef0e21f0ae
2022-02-18 21:52:29 +01:00
eba3ffc31a GL: Fix possible shift by -1
This can happen when the attribute has been optimized out by the compiler.
2022-02-18 21:33:47 +01:00
7f7c614ecd OCIO: Port shader creation logic to use GPUShaderCreateInfo
This commit should suffice to make the shader API agnostic now (given that
all users of it use the GPU API).

This makes the shaders not trigger a false positive error anymore since
the binding slots are now garanteed by the backend and not changed at
after compilation.

This also bundles all uniforms into UBOs. Making them extendable without
limitations of push constants. The generated uniforms from OCIO are not
densely packed in the UBO to avoid complexity. Another approach would be to
use GPU_uniformbuf_create_from_list but this requires converting uniforms
to GPUInputs which is too complex for what it is.

Reviewed by: brecht, jbakker

Differential Revision: https://developer.blender.org/D14123
2022-02-18 21:33:47 +01:00
b75279e19b EEVEE: Shadow: Avoid loosing cached tiles updates in LOD levels 2022-02-18 21:29:49 +01:00
871c538509 EEVEE: Shadow: Avoid missing a load because of float imprecision 2022-02-18 21:28:31 +01:00
a082189c1d EEVEE: Improve shadow debug 2022-02-18 21:26:48 +01:00
e65f8c2579 EEVEE: Fix shader compilation 2022-02-18 21:24:37 +01:00
e3793186c0 EEVEE: Shadows: Compute max tile LOD visibility 2022-02-18 21:23:56 +01:00
471ea14ec1 EEVEE: Shadow: Add render page list to simplify the execution model 2022-02-18 21:14:27 +01:00
e32b3c95c5 Cleanup: EEVEE Remove NULL in .cc files 2022-02-18 21:08:57 +01:00
f0c75976d7 EEVEE: Fix use_scene_lights option 2022-02-18 21:07:10 +01:00
30bbd01fe0 DRW: Port draw_debug_lib to shader info 2022-02-18 21:05:05 +01:00
ef0e21f0ae Cleanup: Remove unused argument to mesh tessellation
This removes manual handling of normals that was hard-coded
to false in the one place the function was called. This change
will help to make a fix to T95839 simpler.
2022-02-18 13:39:16 -06:00
969c4a45ce Cleanup: Use functions for accessing mesh normal dirty state
It's better not to expose the details of where the dirty flags are
stored to every place that wants to know if the normals are dirty.
Some of these places are relics from before vertex normals were
computed lazily anyway, so this is more of an incrememtal cleanup.
This will make part of the fix for T95839 simpler.
2022-02-18 13:21:36 -06:00
eaa4aa8644 Fix part of T95848: missing updates editing light object nodes
Make relation match material and world nodes. Does not address the reported
issue regarding muted nodes, but another missing update found investigating.
2022-02-18 19:50:53 +01:00
b04d42022f Fix T95338: missing image editor refresh after render compositing
This was an old issue, but recent image partial update changes made this more
likely to happen in some cases. Now ensure that whenever the rendered scene
switches the image is updated.
2022-02-18 19:50:53 +01:00
Dominik Fill
d9d97db018 Fix T87829, T95331: Issues when nodes too close together
This patch aims to fix the issues presented in T87829 and T95331,
namely precision issues while connecting two nodes when being too
close together in the node editor editors, in a few cases even
resulting in the complete inability to connect nodes.

Sockets are found by intersecting a padded rect around the cursor
with the nodes' sockets' location. That creates ambiguities, as it's
possible for the padded rect to intersect with the wrong node,
as the distance between two nodes is smaller than the rect is padded.

The fix in this patch is checking against an unpadded rectangle in
visible_node().

Differential Revision: https://developer.blender.org/D14122
2022-02-18 12:22:51 -06:00
07fbf3108b Merge branch 'blender-v3.1-release' 2022-02-18 11:40:55 -06:00
Wannes Malfait
82fc68ed90 Fix T95542: Dual Mesh crashes with some non-manifold vertices
The problem was that the code for sorting polygons around a vertex
assumed that it was a manifold or boundary vertex. However in some cases
the vertex could still be nonmanifold causing the crash. The cases where
the sorting fails are now detected and these vertices are then marked as
nonmanifold.

Differential Revision: https://developer.blender.org/D14065
2022-02-18 11:35:08 -06:00
Leon Schittek
ddc52f2e1d Fix: Curve to Mesh node creates caps when curve is cyclic
The "Fill Caps" option on the Curve to Mesh node introduced in
rBbc2f4dd8b408ee makes it possible to fill the open ends of the sweep
to create a manifold mesh.

This patch fixes an edge case, where caps were created even when the
rail curve (the curve used in the "Curve" input socket) was cyclic
making the resulting mesh non-manifold.

Differential Revision: https://developer.blender.org/D14124
2022-02-18 11:27:28 -06:00
c2016feadc Merge branch 'blender-v3.1-release' 2022-02-18 18:25:31 +01:00
af6a1b08e3 VSE: Refactor our code to be compatible with ffmpeg 5.0
In ffmpeg 5.0, several variables were made const to try to prevent bad API usage.
Removed some dead code that wasn't used anymore as well.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D14063
2022-02-18 18:24:16 +01:00
16ab6111f7 UI: Speedup preview icon loading from hard drive
Significantly improves loading speed of preview images from disk, e.g. custom
previews loaded using `bpy.utils.previews.ImagePreviewCollection.load()`.

See D14144 for details & comparison videos.

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

Reviewed by: Bastien Montagne
2022-02-18 18:13:06 +01:00
1850a0b2ab Mesh: Avoid creating incorrect original index layers
Currently, whenever any BMesh is converted to a Mesh (except for edit
mode switching), original index (`CD_ORIGINDEX`) layers are added.
This is incorrect, because many operations just convert some Mesh into
a BMesh and then back, but they shouldn't make any assumption about
where their input mesh came from. It might even come from a primitive
in geometry nodes, where there are no original indices at all.

Conceptually, mesh original indices should be filled by the modifier
stack when first creating the evaluated mesh. So that's where they're
moved in this patch. A separate function now fills the indices with their
default (0,1,2,3...) values. The way the mesh wrapper system defers
the BMesh to Mesh conversion makes this a bit less obvious though.

The old behavior is incorrect, but it's also slower, because three
arrays the size of the mesh's vertices, edges, and faces had to be
allocated and filled during the BMesh to Mesh conversion, which just
ends up putting more pressure on the cache. In the many cases where
original indices aren't used, I measured an **8% speedup** for the
conversion (from 76.5ms to 70.7ms).

Generally there is an assumption that BMesh is "original" and Mesh is
"evaluated". After this patch, that assumption isn't quite as strong,
but it still exists for two reasons. First, original indices are added
whenever converting a BMesh "wrapper" to a Mesh. Second, original
indices are not added to the BMesh at the beginning of evaluation,
which assumes that every BMesh in the viewport is original and doesn't
need the mapping.

Differential Revision: https://developer.blender.org/D14018
2022-02-18 10:51:00 -06:00
a08c5c7149 Merge branch 'blender-v3.1-release' 2022-02-18 10:35:11 -06:00
82c3bef765 Fix T94495: Split edges node leads to a crash in edit mode
If original indices exist on the input mesh, also copy them to
the BMesh used for the edge split operation so they aren't lost.

Part of D14018
2022-02-18 10:34:00 -06:00
ddf189892c Cleanup: Rename original curve object type enum
This commit renames enums related the "Curve" object type and ID type
to add `_LEGACY` to the end. The idea is to make our aspirations clearer
in the code and to avoid ambiguities between `CURVE` and `CURVES`.

Ref T95355

To summarize for the record, the plans are:
- In the short/medium term, replace the `Curve` object data type with
 `Curves`
- In the longer term (no immediate plans), use a proper data block for
  3D text and surfaces.

Differential Revision: https://developer.blender.org/D14114
2022-02-18 09:50:29 -06:00
48b17da1d9 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-18 16:36:45 +01:00
1b47d07d76 Fix T95724: boundary error in BLI_str_unescape_ex
Fix boundary error in `BLI_str_unescape_ex`. The `dst_maxncpy` parameter
indicates the maximum buffer size, not the maximum number of characters.

As these are strings, the loop has to stop one byte early to allow space
for the trailing zero byte.

Thanks @mano-wii for the patch!
2022-02-18 16:34:00 +01:00
734c6a4405 Nodes: Update dependency graph when removing some nodes
When removing a node that has a dependence on an ID, like the object
info node, the dependency graph relations weren't updated. This can
cause unexpected performance issues if a complex node tree continues
to depend on an ID that it doesn't actually use anymore. To fix this case,
tag relations for an update if the node has a data-block socket.

Fixes part of T88332

Differential Revision: https://developer.blender.org/D14121
2022-02-18 09:25:13 -06:00
Sayed Amin
ceea3d0f80 Fix T95135: improve error filtering non-existant anim data
If there is no animation at all, or it's all hidden, the Euler Filter
operators poll now fails with a message that explains this a bit more,
instead of just the generic "context is wrong" error.

Reviewed By: sybren

Maniphest Tasks: T95135

Differential Revision: https://developer.blender.org/D13967
2022-02-18 16:24:48 +01:00
aab1561690 LibOverride: Fix resync sometimes deleting root ID of other liboverrides.
While this should not happen in theory, very bad/broken/dirty files can
lead to such situations.

So we need to re-ensure valid root IDs after resync (for now, done after
each 'library indirect level' pass of resync, this may not be 100%
bulletproof though, time will say).

Found while investigating Blender studio issues in Snow parkour short.
2022-02-18 16:08:43 +01:00
d9fe565c85 LibOverride: Fix potential broken cases re ShapeKeys when finding hierarchy root ID.
In some cases broken files could lead to selecting a shapekey as
hierarchy root ID, which is not allowed.

Found while investigating Blender studio issues in Snow parkour short.
2022-02-18 16:06:15 +01:00
303b566b10 Merge branch 'blender-v3.1-release' 2022-02-18 15:32:24 +01:00
e4b7d52fe4 Fix graphics interop resources leak in Cycles
When new display driver is given to the PathTrace ensure that there are
no GPU resources used from it by the work. This solves graphics interop
descriptors leak.

This aqlso fixes Invalid graphics context in cuGraphicsUnregisterResource
error when doing final render on the display GPU.

Fixes T95837: Regression: GPU memory accumulation in Cycles render
Fixes T95733: Cycles Cuda/Optix error message with multi GPU devices. (Invalid graphics context in cuGraphicsUnregisterResource)
Fixes T95651: GPU error (Invalid graphics context in cuGraphicsUnregisterResource)
Fixes T95631: VRAM is not being freed when rendering (Invalid graphics context in cuGraphicsUnregisterResource)
Fixes T89747: Cycles Render - Textures Disappear then Crashes the Render

Maniphest Tasks: T95837, T95733, T95651, T95631, T89747

Differential Revision: https://developer.blender.org/D14146
2022-02-18 15:26:15 +01:00
40cddcd917 Cleanup: Fix incompatible pointer types warnings 2022-02-18 23:21:53 +09:00
af308049bc Merge branch 'blender-v3.1-release' 2022-02-18 14:55:54 +01:00
02f4d63dcc Fix broken shapekeys: check for 'NULL' from pointer too.
Add check for `NULL` `from` pointer to `BLO_main_validate_shapekeys`,
and delete these shapekeys, as they are fully invalid and impossible to
recover.

Found in a studio production file (`animation
test/snow_parkour/shots/0040/0040.lighting.blend`, svn rev `1111`).
Would be nice to know how this was generated too...
2022-02-18 12:29:27 +01:00
5f16e24cc9 Curves: add initial edit mode support
This adds initial support for edit mode for the experimental new curves
object. For now we can only toggle in and out of the mode, no real
interraction is possible.

This patch also adds empty menus in edit mode. Those were added mainly
to quiet warnings as the menus are programmatically added to the edit
mode based on the object type and context.

Ref T95769

Reviewed By: JacquesLucke, HooglyBoogly

Maniphest Tasks: T95769

Differential Revision: https://developer.blender.org/D14136
2022-02-18 11:31:13 +01:00
8b4da9a191 Fix strict compilation warnings 2022-02-18 10:14:34 +01:00
61aaeb3745 Curves: initial brush system integration for curves sculpt mode
This adds the boilerplate code that is necessary to use the tool/brush/paint
systems in the new sculpt curves mode.

Two temporary dummy tools are part of this patch. They do nothing and
only serve to test the boilerplate. When the first actual tool is added,
those dummy tools will be removed.

Differential Revision: https://developer.blender.org/D14117
2022-02-18 09:14:54 +01:00
964d3a38fa XR: Enable Vive Focus 3 controller extension
Allows controller-specific action bindings for the HTC Vive Focus 3
controller. Currently not supported by any OpenXR runtimes (save for
the dedicated Focus 3 runtime in developer early-access:
https://forum.vive.com/topic/11354-openxr-support-for-focus-3-early-access-application-form),
but useful to have for the future.
2022-02-18 17:00:43 +09:00
4ad4d8a59c Cleanup: Use compact license header.
New file introduced in blender-v3.1-release branch.
2022-02-18 08:30:10 +01:00
5c6eefa850 Merge branch 'blender-v3.1-release' 2022-02-18 08:29:32 +01:00
fe26d18889 Fix T95809: Check color space changes to refresh image engine.
Previous commit fixed the compositor node, this commit is related to the
shader tree. Also checks if the color space or alpha mode have changed.
2022-02-18 08:22:18 +01:00
400e57b64a Fix T95809: Compositor Node not directly updated in image editor.
Image wasn't tagged to be dirty.
2022-02-18 08:11:51 +01:00
6efdfeb886 Image Engine: Store image usage to identity changes.
Previous implementation had a copy of the image user, which doesn't
contain all the data to identify changes. This patch introduces a new
struct to store the data and can be extended with other data as well
(color spaces, alpha settings).
2022-02-18 07:55:36 +01:00
ca1f879c02 Cleanup: simplify viewmove_apply
Check for a camera-view before checking if the view is locked
to the cursor/object since the camera-view takes priority,
it reads better to check that first.

Also reuse the event offset variable.
2022-02-18 17:24:10 +11:00
51975b89ed 3D View: Add camera view pan/zoom support for NDOF
NDOF navigation in a camera view now behaves like orthographic pan/zoom.

Note that NDOF orbiting out of the camera view has been disabled,
see code comment for details.

Resolves T93666.
2022-02-18 17:09:49 +11:00
f33e6e0d8c Cleanup: move camera-view pan/zoom into utility functions 2022-02-18 16:48:27 +11:00
ae9dd0cbf9 Merge branch 'blender-v3.1-release' 2022-02-17 23:44:47 -06:00
Pratik Borhade
1d0d810331 Fix T93526: Missing tooltip for attribute search button
For the attribute search button, the tooltip was missing
if the input socket type has attribute toggle activated.

Differential Revision: https://developer.blender.org/D14142
2022-02-17 23:44:16 -06:00
59aaf2036e Fix wrong method name in gpu documentation
`use_program_point_size` --> `program_point_size_set`.
2022-02-17 22:11:08 -03:00
9153bf24cb Merge branch 'blender-v3.1-release' 2022-02-17 20:30:45 +01:00
3cdbeb32d3 Fix build error on some compilers after recent bugfix 2022-02-17 20:30:19 +01:00
ad2577e0cd Merge branch 'blender-v3.1-release' 2022-02-17 19:52:46 +01:00
da6b534274 Fix T95368: wrong white point adaptation for Linear ACES color space
This affected loading of EXR files with set to Linear ACES colorspace, as
well as the sky texture for in some custom OpenColorIO configurations.

Use the builtin OpenColorIO transform from ACES AP0 to XYZ D65 to fix this.
2022-02-17 19:51:43 +01:00
48432c1c92 Fix: Debug build error with vector type division
The idea is to keep `is_any_zero` in the `blender::math` namespace,
so instead of trying to be clever, just move it there and expand the
function where it was used in the class.
2022-02-17 12:36:41 -06:00
b6fe1b0c65 Merge branch 'blender-v3.1-release' 2022-02-17 18:44:18 +01:00
a04300c436 Cleanup: Move more cmake library variables to be advanced
I noticed that there were a few variables that should not be visible per default.
It seems to me to simply be an oversight, so I went ahead and cleaned them up.

Reviewed By: Sybren, Ray molenkamp

Differential Revision: http://developer.blender.org/D14132
2022-02-17 18:42:06 +01:00
807624b602 Merge branch 'master' into eevee-rewrite 2022-02-17 18:16:36 +01:00
8355ac97b4 GPU: Remove runtime sampler texture slot assignment
This avoid potential shader recompilation and is more in line
with vulkan design.
2022-02-17 18:15:31 +01:00
37fa1bc254 OCIO: Port shader creation logic to use GPUShaderCreateInfo
This commit should suffice to make the shader API agnostic now (given that
all users of it use the GPU API).

This makes the shaders not trigger a false positive error anymore since
the binding slots are now garanteed by the backend and not changed at
after compilation.

This also bundles all uniforms into UBOs. Making them extendable without
limitations of push constants. The generated uniforms from OCIO are not
densely packed in the UBO to avoid complexity. Another approach would be to
use GPU_uniformbuf_create_from_list but this requires converting uniforms
to GPUInputs which is too complex for what it is.

Reviewed by: brecht, jbakker

Differential Revision: https://developer.blender.org/D14123
2022-02-17 18:15:31 +01:00
9281ba5812 Fix part of T95654: Cycles crash with text objects in excluded view layers
This is a bug on the Blender side, where the depsgraph does not have proper
relations for text object duplis and fails to include the required materials
in the dependency graph. But at least Cycles should not crash.
2022-02-17 17:30:40 +01:00
b5e3700b79 Cleanup: Replace direct id.lib pointer checks with ID_IS_LINKED macro usages. 2022-02-17 17:08:00 +01:00
c99d1d5d0d Fix build errors on Linux/clang after recent changes 2022-02-17 16:19:26 +01:00
114cc47b78 Fix: Memory leak in recently added curves copy function
Specify that the destination curve must be initialized, and free the
existing attributes (which `CustomData_copy` doesn't do).
2022-02-17 09:05:08 -06:00
Germano Cavalcante
e240c8c5db Camera: Simplify View Frame code
- No need for `normal_tx` array if we normalize the planes in `plane_tx`.
- No need to calculate the distance squared to a plane (with `dist_signed_squared_to_plane_v3`) if the plane is normalized. `plane_point_side_v3` gets the real distance, accurately, efficiently and also signed.

So normalize the planes of the member `CameraViewFrameData::plane_tx`.
2022-02-17 11:51:45 -03:00
a4c800ed02 Merge branch 'blender-v3.1-release' 2022-02-17 15:24:29 +01:00
e5100ca3ad Build: update CMake to support OpenImageIO 2.3.4
FindOpenImageIO was updated to link to separate OpenImageIO_Util for new
versions, where it is required. For older versions, we can not link to it
because there will be duplicated symbols.

Ref D14128
2022-02-17 15:21:09 +01:00
2c9931699e Build: update CMake to support OpenEXR 3
FindOpenEXR was updated to find new lib names and separate Imath. It's all
added to the list of OpenEXR include dirs and libs.

This keeps it compatible with both version 2 and 3 for now, and doesn't
require changes outside the find module.

Ref D14128
2022-02-17 15:21:09 +01:00
cd7550cfe7 Images: update code to support OpenEXR 3
Compatibility with OpenEXR 2 is preserved, since Blender releases and Linux
distribution packages can be on different versions.

Ref D14128
2022-02-17 15:21:09 +01:00
6a283b7a7f Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-17 15:16:31 +01:00
4541249360 Fix compile error on MSVC
`uint` is POSIX type, use `GLuint` like for the rest of the code.
2022-02-17 15:15:46 +01:00
68a09bf5fd Cleanup/fix comment. 2022-02-17 14:36:03 +01:00
433fad50d8 Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-17 13:14:47 +01:00
c5dcfb63d9 Fix T94881: GPU subdivision fails with high polycount coarse meshes
Coarse meshes with high polycount would show as corrupted when GPU
subdivision is used with AMD cards This was caused by the OpenSubdiv
library not taking `GL_MAX_COMPUTE_WORK_GROUP_COUNT` into account when
dispatching computes. AMD drivers tend to set the limit lower than
NVidia ones (2^16 for the former, and 2^32 for the latter, at least
on my machine).

This moves the `GLComputeEvaluator` from the OpenSubdiv library into
`intern/opensubdiv` and modifies it to compute a dispatch size in a
similar way as for the draw code: we split the dispatch size into a 2
dimensional value based on `GL_MAX_COMPUTE_WORK_GROUP_COUNT` and
manually compute an index in the shader.

We could have patched the OpenSubdiv library and sent the fix upstream
(which can still be done), however, moving it to our side allows us to
better control the `GLComputeEvaluator` and in the future remove some
redundant work that it does compared to Blender (see T94644) and
probably prepare the ground for Vulkan support. As a matter of fact,
this patch also removes the OpenGL initialization that OpenSubdiv would
do here. This removal is not related to the bug fix, but necessary to not
have to copy more files/code over.

Differential Revision: https://developer.blender.org/D14131
2022-02-17 13:14:19 +01:00
43b40f7bde Merge remote-tracking branch 'origin/blender-v3.1-release' 2022-02-17 08:41:01 +01:00
be3047c500 Fix T95827: vertex groups do not display correctly with GPU subdivision
Issue caused by 993839ce85 which modified
the coarse face flags update function, but forgot the case where we have
a mapped extraction with no BMesh.
2022-02-17 08:40:38 +01:00
401383f245 Fix vertex groups not rendering properly with GPU subdivision
This was missing the BMesh case. Issue found while investigating T95827.
2022-02-17 08:38:12 +01:00
6a8709ba13 XR: Allow variable count of action map subactions
Previously, the number of action map subactions was limited to two per
action (identified by user_path0, user_path1), however for devices with
more than two user paths (e.g. Vive Tracker) it will be useful to
support a variable amount instead.

For example, a single pose action could then be used to query the
positions of all connected trackers, with each tracker having its own
subaction tracking space.

NOTE: This introduces breaking changes for the XR Python API as follows:
- XrActionMapItem: The new `user_paths` collection property
replaces the `user_path0`/`user_path1` properties.
- XrActionMapBinding: The new `component_paths` collection property
replaces the `component_path0`/`component_path1` properties.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D13949
2022-02-17 15:51:16 +09:00
7d4d8a13ce Merge branch 'blender-v3.1-release' 2022-02-17 15:39:31 +09:00
dd6fd06c15 Fix T76082: VR Scene Inspection: It shows me only a pink screen
This fixes VR pink screen issues when using the DirectX backend, caused
by `wglDXRegisterObjectNV()` failing to register the shared
OpenGL-DirectX render buffer. The issue is mainly present on AMD
graphics, however, there have been reports on NVIDIA as well.

A limited workaround for the SteamVR runtime (AMD only) was provided
in rB82ab2c167844, however this patch provides a more complete solution
that should apply to all OpenXR runtimes. For example, with this patch,
the Windows Mixed Reality runtime that exclusively uses DirectX can now
be used with AMD graphics cards.

Implementation-wise, a `GL_TEXTURE_2D` render target is used as a
fallback for the shared OpenGL-DirectX resource in the case that
registering a render buffer (`GL_RENDERBUFFER`) fails. While using a
texture render target may be less optimal than a render buffer, it
enables proper display in VR using the OpenGL/DirectX interop (tested
on AMD Vega 64).

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D14100
2022-02-17 15:28:29 +09:00
8c8d84fbc5 Cleanup: compiler warning, typo in comment 2022-02-17 16:50:44 +11:00
bdde8c7207 License headers: use SPDX identifiers 2022-02-17 16:47:37 +11:00
Christoph Lendenfeld
b626edd751 fix: RNA property not set for Graph editor breakdown op
After running the breakdown operator for the graph editor,
the factor property in the redo panel didn't reflect the value you chose

to mitigate that issue down the line there is a
new helper function to get the factor value, and
store it at the same time

Reviewed by: Sybren A. Stüvel
Differential Revision: https://developer.blender.org/D14105
Ref: D14105
2022-02-16 21:55:42 +01:00
8c96ee8903 Cleanup: Deduplicate functions for creating attributes 2022-02-16 14:10:21 -06:00
6862caea5e macOS/bpy module: install text files correctly
Instead of Blender.app (despite building bpy), install license etc in
`Resources/text` of bpy install location. Part of D14111
2022-02-17 01:31:03 +05:30
71545e542c macOS/bpy module: install scripts relative to bpy.so
Brew's Python framework's site-packages is a symlink so the assumption
that Resources and site-packages would be in the same directory
doesn't hold. So install scripts etc relative to bpy.so. Part of D14111
2022-02-17 01:31:03 +05:30
57013e2a44 Merge branch 'blender-v3.1-release' 2022-02-16 19:51:58 +01:00
05697470ab Cleanup: Remove deprecated StringGrid from our openvdb code
StringGrid has been deprecated in openvdb 9.0.0 and will be removed soon

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D14133
2022-02-16 19:49:58 +01:00
f38c2fbef9 Merge branch 'blender-v3.1-release' 2022-02-16 19:03:00 +01:00
0622d2ec61 Fix T95815: missing null check when computing dupli dimensions
Some instances might be "empty" and therefore have no dimensions.
Those should be ignored here.
2022-02-16 18:58:01 +01:00
c324cf1539 Curves: Further implementation of new curves data structure
The general idea here is to wrap the `CurvesGeometry` DNA struct
with a C++ class that can do most of the heavy lifting for the curve
geometry. Using a C++ class allows easier ways to group methods, easier
const correctness, and code that's more readable and faster to write.
This way, it works much more like a version of `CurveEval` that uses
more efficient attribute storage.

This commit adds the structure of some yet-to-be-implemented code,
the largest thing being mutexes and vectors meant to hold lazily
calculated evaluated positions, tangents, and normals. That part might
change slightly, but it's helpful to be able to see the direction this
commit is aiming in. In particular, the inherently single-threaded
accumulated lengths and Bezier evaluated point offsets might be cached.

Ref T95355

Differential Revision: https://developer.blender.org/D14054
2022-02-16 11:32:37 -06:00
5b73017ddb BLI: Generalize short algorithm for finding bounds
Finding the greatest and/or smallest element in an array is a common
need. This commit refactors the point cloud bounds code added in
6d7dbdbb44 to a more general header in blenlib.
This will allow reusing the algorithm for curves without duplicating it.

Differential Revision: https://developer.blender.org/D14053
2022-02-16 10:53:58 -06:00
399168f3c1 BLI: Implement templated math functions for basic types
This is meant to complement the `blender::math` functions recently
added by D13791. It's sometimes desired to template an operation to work
on vector types, but also basic types like `float` and `int`. This patch
adds that ability with a new `BLI_math_base.hh` header.

The existing vector math header is changed to use the `vec_base` type
more explicitly, to allow the compiler's generic function overload resolution
to determine which implementation of each math function to use.
This is a relatively large change, but it also makes the file significantly
easier to understand by reducing the use of macros.

Differential Revision: https://developer.blender.org/D14113
2022-02-16 10:28:26 -06:00
47b72c8e67 EEVEE: Fix forward material not appearing. 2022-02-16 14:52:25 +01:00
39963ffba1 Merge branch 'master' into eevee-rewrite 2022-02-16 14:41:12 +01:00
1d322894a1 Cleanup: Fix warnings 2022-02-15 00:32:53 +01:00
1ee03bc7ef Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_bloom.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_data.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_lut_gen.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_mist.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_sampling.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cascade.c
#	source/blender/draw/engines/eevee/eevee_shadows_cube.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material_library.c
#	source/blender/gpu/opengl/gl_compute.cc
#	source/blender/makesrna/intern/rna_material.c
2022-02-15 00:32:40 +01:00
74bca81507 GLStorageBuf: Fix wrong enum for debug name 2022-02-15 00:12:15 +01:00
943315d16c EEVEE: Fix glossy filter 2022-02-14 23:55:12 +01:00
6c97a2eee8 EEVEE: Fix some GL errors and missing binds 2022-02-14 23:54:55 +01:00
b4b2af595e EEVEE: Fix shader compilation on Nvidia driver
There is some issues with referencing buffer variables in functions
when the buffer is not read & write.
2022-02-14 18:03:30 +01:00
b284b17844 Fix compilation in release mode 2022-02-14 18:01:37 +01:00
311f8ba794 DRW: Add null resource check instead of crashing 2022-02-09 11:34:54 +01:00
af82d0fec7 GPUCodegen: Fix attribute having GPU_NONE gputype 2022-02-09 11:34:54 +01:00
dc9e8a4075 EEVEE: Split directional light path
This should reduce VGPR now that the iterations are separated
2022-02-09 11:34:54 +01:00
da0a8e384e EEVEE: Fix shader not static 2022-02-09 11:34:54 +01:00
d73152b985 EEVEE: Disable raytracing 2022-02-09 11:34:54 +01:00
a9b0728bd4 EEVEE: Remove integer division 2022-02-09 11:34:54 +01:00
4bcc62a257 EEVEE: Fix light culling light count and padd culling tile buffer 2022-02-09 11:34:54 +01:00
89bef5adb2 GPUCodegen: Fix missing mat4 in function arguments 2022-02-09 11:34:54 +01:00
a02eee7e98 DRW: Add new draw_debug_print_lib.glsl
This lib allows any shader to use `print()` like functions for
logging and debugging shaders.

Usage is described in the comment at the top of the file.
2022-02-09 11:34:54 +01:00
4205629ea2 GLShader: Fix two small issues with compute shader generated code 2022-02-09 11:34:54 +01:00
dd6ee49d05 DRW: Add support for GPUStorageBuf in wrappers 2022-02-09 11:34:54 +01:00
9c36da1c34 DRW: Add support for GPUStorageBuf 2022-02-09 11:34:54 +01:00
4477ac7c8a GPU/GL: Add StorageBuf implementation
Almost 1:1 identical to UniformBuf implementation.
2022-02-08 23:17:31 +01:00
8a9f18d72c GPUShader: Fix crash when compilation error is a linking error 2022-02-08 23:15:52 +01:00
9d53e0cb07 EEVEE: Fix more float4x4 issues 2022-02-06 17:04:11 +01:00
e654975b1e EEVEE: Fix assert caused by division by 0 2022-02-06 17:02:10 +01:00
74a0a85181 GLDebug: Wrap glDispatch function into our debug wrappers 2022-02-06 17:01:10 +01:00
d02a3b4aeb EEVEE: Fix uninitialized texture issue.
This was happending on amdgpu-pro driver. `mix(a,b,1)` does not
garantee `b`.
2022-02-06 16:39:30 +01:00
de6d0db833 Merge branch 'master' into eevee-rewrite 2022-02-06 13:51:44 +01:00
6ebe1652d6 Merge branch 'master' into eevee-rewrite 2022-02-06 01:41:18 +01:00
9d44753ab8 EEVEE: Fix missing gpu_Layer in probe filter 2022-02-06 01:23:37 +01:00
03be5c4140 EEVEE: Fix dependencies to draw_view 2022-02-06 01:23:12 +01:00
f7cbd80bd9 EEVEE: Fix frustum_planes/corners references 2022-02-06 01:22:39 +01:00
3b812973fa GPUShaderCreateInfo: Add duplication error checking of dependency merging
As of now we do not allow additional infos duplication. We could in the future
but for now assert that this is not the case.
2022-02-06 01:21:07 +01:00
112c4345a3 DRW: Add preprocessor error if including common_view_lib.glsl without draw_view
This avoid making include mistake and potentially detect areas that do
not really need common_view_lib.glsl.
2022-02-06 01:18:56 +01:00
a3f79499b2 EEVEE: Fix float4x4 usage 2022-02-06 01:16:32 +01:00
26f413d1f8 BLI_float4x4: Add << operator and add ATTR_WARN_UNUSED_RESULT to identity() 2022-02-06 01:16:10 +01:00
ae024ca446 Merge branch 'master' into eevee-rewrite 2022-02-05 23:09:49 +01:00
6f531aba94 GPU: Debug: Avoid double printing of compilation issues
To avoid that, we simply filter using a debug group.
2022-02-05 23:07:53 +01:00
5c9ce9d066 DRW: Make use of shader shared header 2022-02-05 22:58:32 +01:00
29824c6ed3 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/gpu/CMakeLists.txt
2022-02-05 22:46:04 +01:00
e3027906d7 Merge branch 'master' into eevee-rewrite 2022-02-05 22:19:07 +01:00
ee6fafc615 GPUTexture: Fix missing cases in to_data_format() 2022-02-05 19:26:07 +01:00
94b35f9e9d GPU: Enable CLOG for gpu when --debug-gpu option is set
This is because all of the debug printing is done through CLog now. Without
it the is little point in this option.
2022-02-05 19:25:35 +01:00
ac9dd50384 GLShaderInterface: Fix missing in builtin SSBO support 2022-02-05 19:23:06 +01:00
a9fa50b6fb GL: Fix compute shader label error 2022-02-05 18:51:39 +01:00
b253532fa7 EEVEE: Fix missing resource binding 2022-02-05 18:51:11 +01:00
e58b397a2a EEVEE: Fix compilation on amdgpu-pro
Implementation only supports global scope shared variables and does not
like having the restrict qualifier on function inputs.
2022-02-05 18:48:28 +01:00
7dff6a074b Merge branch 'master' into eevee-rewrite 2022-02-05 14:00:04 +01:00
af49f0022a Codegen: Fix memory leak 2022-02-05 13:58:57 +01:00
9a31f13298 Merge branch 'master' into eevee-rewrite 2022-02-05 13:30:05 +01:00
b7e2e075c4 Cleanup: EEVEE: Remove unecessary internal C interface. 2022-02-05 13:27:53 +01:00
2f9a7d536d GLShaderInterface: Fix SSBO using the ubo mask
This might head lead to a crash when a shader uses both ubo and ssbo.
2022-02-05 13:22:30 +01:00
4717151495 EEVEE: Fix some broken renaming 2022-02-05 00:06:08 +01:00
031181a6b5 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/gpu/intern/gpu_shader_dependency.cc
2022-02-04 23:48:23 +01:00
df349a2214 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_manager_data.c
2022-02-04 19:41:36 +01:00
792e3fc6ed GPU: Rewrite the function library system
Instead of using a manual list of dependency, the new implementation
scans all shader files beginning by `gpu_shader_material_` and extract
all function declarations.

This way we can deduce the internal dependencies between theses files.

This new implementation is merged with the manual pragma dependency system
uses by other shader files. This way it is compatible with the shader
logging system and does not require any string duplication during shader
building.
2022-02-04 15:47:03 +01:00
86ef6da834 GPUCodegen: Remove use of gpu_data_type_to_string 2022-02-04 15:20:26 +01:00
314f5b20d5 EEVEE: Fix more shader dependencie issues 2022-02-04 15:18:16 +01:00
b2b1c0102c GPUShader: Add optionnal dependency display in
This introduce `DEBUG_DEPENDENCIES` (not a cmake flag but a local define)
 which when set to 1, will list all the original files included in this
shader while omitting the generated / non original code.
2022-02-04 15:16:10 +01:00
6f16ca39a2 GPUShader: Remove some non useful error lines from log 2022-02-04 15:02:30 +01:00
31133d22b6 GPUShader: Fix issue when error row is 0
It would display the whole file instead of only the line.
2022-02-04 15:01:50 +01:00
b2d3960dc1 GLShader: Fix warning about ARB_conservative_depth even if the GL version supports it 2022-02-04 15:00:43 +01:00
bcd635e549 GPUShader: Improve error logging to support source:row layout
This is the layout used by the amdgpu-pro GL implementation.
This also add some sanitizing of the parse output because the bespoke
implementation has bogus error when it comes to compute shaders.
2022-02-04 14:59:31 +01:00
8af5e2d246 EEVEE: Fix more shader issues 2022-02-03 18:29:55 +01:00
c785a8e166 GPUShader: Avoid double typedef source inclusion 2022-02-03 18:28:45 +01:00
f6d1ba8235 EEVEE: Fix missing weight socket on multiple nodes 2022-02-03 18:18:28 +01:00
78e9d829de EEVEE: Fix shader compilations issues, resource bindings & naming 2022-02-03 13:45:41 +01:00
45885eaea3 GPUShader: Add better error message in case of incorrect dependency name 2022-02-03 12:55:58 +01:00
249717f394 GPUShaderLog: Add filename before error to improve debugging
This displays the error source such as IDE can find identify them
as path and let the programmer follow the direct link instead of
manual string search.

This only works for shaders compiling from unaltered sources as
it uses the source `char*` as key for filename search.
2022-02-03 12:44:32 +01:00
5b02f1c031 Cleanup: GPUShader: Avoid casting 2022-02-03 12:42:13 +01:00
e3f475c17c GPUTexture: Fix missing cases in validate_data_format 2022-02-03 12:30:03 +01:00
bc2e5845de Cleanup: GPUShader: Remove shader source duplication 2022-02-03 00:58:00 +01:00
e5dcd91755 DRW: Fix heatmap_gradient function messing error line number
For some reason on some GL implementation (amdgpu) this particular
syntaxes shift the error lines.

Remove the context lines by default as they are not useful anymore.
2022-02-03 00:24:30 +01:00
0ef24bb0e2 Cleanup: EEVEE: Naming 2022-02-02 23:47:38 +01:00
1b2eeb9c64 Cleanup: GPUShader: Reduce copy paste 2022-02-02 23:33:50 +01:00
0f964142b9 GPUShaderCreateInfo: Add basic debug print support 2022-02-02 22:14:44 +01:00
a0c8c932fb Cleanup: common_hair_lib.glsl: deduplicate functions definitions 2022-02-02 22:12:45 +01:00
e167c1cb89 EEVEE: Add material shader tests in the form of unused createInfos
This adds basic variations check at compile time in debug mode.
2022-02-02 22:11:44 +01:00
e9fe318e8e EEVEE: Fix more shader compilation issues 2022-02-02 22:11:26 +01:00
8a20e3f229 GPUShaderCreateInfo: Add automatic resource location
Turning this option on will recreate the slot number making sure
no slot overlaps.
2022-02-02 22:08:02 +01:00
664d31d40a Cleanup: Remove void argument to functions 2022-02-02 22:07:01 +01:00
088fc410d9 EEVEE: Finish implementing GPUShaderCreateInfo and fix compilation 2022-02-02 19:01:37 +01:00
6f3a119464 DRW: Add draw_gpencil info for gpencil geom type 2022-02-02 18:40:40 +01:00
7073959d48 GLShader: Add array macro
This is to support different array syntax
2022-02-02 18:38:16 +01:00
76a4fb223e GPUShaderCreateInfo: Fix strange crash when using std::cerr 2022-02-02 18:37:35 +01:00
a9a045fd2d GLShader: Fix image declaration 2022-02-02 18:37:03 +01:00
f39acfc874 GPUCodegen: Port to use shader create info
We now use ShaderCreateInfo as a way to setup the custom material
implementation.
This is more versatile and flexible while not require parsing of
snippets of code.
2022-02-02 18:36:50 +01:00
484c97707f Fix clang-tidy 2022-02-02 18:32:19 +01:00
81502a99b5 EEVEE: Add back support of raytrace_resolve_lib.glsl 2022-02-02 17:53:08 +01:00
9c6ceb4503 fix merge 2022-02-01 19:49:51 +01:00
08439aebf1 EEVEE: Use GPUShaderCreateInfo 2022-02-01 19:49:45 +01:00
4fd26cdd37 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_diffuse_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_glossy_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_gtao_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_trace_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/intern/draw_manager_shader.c
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_shader_log.cc
#	source/blender/gpu/shaders/material/gpu_shader_material_diffuse.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
2022-02-01 19:38:54 +01:00
f7b03a7906 Merge branch 'master' into eevee-rewrite 2022-01-27 22:57:26 +01:00
39c7e19d43 Fix missing glsl file in cmake file 2022-01-27 22:55:15 +01:00
1f503d2ef5 Fix linker error on gpu_shader_builder.cc 2022-01-27 22:43:58 +01:00
9cc6d1dc32 Fix MainView constructor error on GCC < 9.4 2022-01-27 22:19:38 +01:00
8e7b535ce6 Fix NaN compilation error on MSVC 2022-01-27 21:39:42 +01:00
9b35b77716 Merge branch 'master' into eevee-rewrite 2022-01-27 21:38:05 +01:00
ea577c499f EEVEE: Make use of float4x4 instead of float[4][4] and rename vectors
This follows the type defined in `gpu_shader_shared_utils.h`.
2022-01-27 19:33:09 +01:00
0ea5f3fb5d Merge branch 'master' into eevee-rewrite 2022-01-27 18:46:38 +01:00
37cfceb7eb EEVEE: Make use of new DRW_gpu_wrapper.hh instead of eevee_wrapper.hh 2022-01-27 18:41:53 +01:00
c75f7143b6 Merge branch 'master' into eevee-rewrite 2022-01-27 17:05:11 +01:00
ea214f128e EEVEE: Fix compilation issues 2022-01-27 17:01:17 +01:00
848d35c57e EEVEE: Make use of DRW_gpu_wrappers 2022-01-27 17:00:58 +01:00
a3c416f864 Merge branch 'master' into eevee-rewrite 2022-01-27 16:21:02 +01:00
d0e86c1b78 Merge branch 'master' into eevee-rewrite
# Conflicts:
#	source/blender/draw/intern/draw_manager_exec.c
2022-01-27 15:53:38 +01:00
338c0e5f90 Merge branch 'master' into eevee-rewrite 2022-01-27 14:59:50 +01:00
1f2b3cdd73 Comment eevee_raytrace_resolve_lib out to avoid compilation errors for now 2022-01-27 14:56:10 +01:00
032baf06f3 Merge branch 'draw-viewport-data' into eevee-rewrite 2022-01-27 12:34:42 +01:00
0bdf574ea2 Merge branch 'master' into draw-viewport-data 2022-01-26 22:05:55 +01:00
4226c484bd Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	release/scripts/startup/bl_ui/properties_data_camera.py
#	source/blender/blenkernel/BKE_camera.h
#	source/blender/blenkernel/BKE_node.h
#	source/blender/blenkernel/intern/camera.c
#	source/blender/blenlib/BLI_float2.hh
#	source/blender/blenlib/BLI_float3.hh
#	source/blender/blenlib/BLI_float4.hh
#	source/blender/blenlib/BLI_math_geom.h
#	source/blender/blenlib/intern/math_geom.c
#	source/blender/draw/CMakeLists.txt
#	source/blender/draw/engines/basic/basic_engine.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightcache.h
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_sampling.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cube.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
#	source/blender/draw/engines/eevee/shaders/random_lib.glsl
#	source/blender/draw/engines/eevee/shaders/shadow_vert.glsl
#	source/blender/draw/engines/eevee/shaders/surface_lib.glsl
#	source/blender/draw/engines/eevee/shaders/surface_vert.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
#	source/blender/draw/engines/external/external_engine.c
#	source/blender/draw/engines/gpencil/gpencil_engine.c
#	source/blender/draw/engines/image/image_engine.c
#	source/blender/draw/engines/overlay/overlay_engine.c
#	source/blender/draw/engines/select/select_engine.c
#	source/blender/draw/engines/workbench/shaders/workbench_volume_frag.glsl
#	source/blender/draw/engines/workbench/shaders/workbench_volume_vert.glsl
#	source/blender/draw/engines/workbench/workbench_engine.c
#	source/blender/draw/engines/workbench/workbench_shader.c
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_debug.h
#	source/blender/draw/intern/draw_manager_data.c
#	source/blender/draw/intern/draw_manager_exec.c
#	source/blender/draw/intern/draw_view_data.h
#	source/blender/gpu/CMakeLists.txt
#	source/blender/gpu/GPU_material.h
#	source/blender/gpu/GPU_shader.h
#	source/blender/gpu/GPU_state.h
#	source/blender/gpu/GPU_vertex_buffer.h
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material.c
#	source/blender/gpu/intern/gpu_material_library.h
#	source/blender/gpu/intern/gpu_node_graph.c
#	source/blender/gpu/intern/gpu_texture_private.hh
#	source/blender/gpu/intern/gpu_vertex_buffer.cc
#	source/blender/gpu/opengl/gl_shader.cc
#	source/blender/gpu/shaders/gpu_shader_common_obinfos_lib.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl
#	source/blender/nodes/shader/node_shader_tree.cc
#	source/blender/nodes/shader/nodes/node_shader_background.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.c
#	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
#	source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc
#	source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc
#	source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc
#	source/blender/nodes/shader/nodes/node_shader_emission.cc
#	source/blender/nodes/shader/nodes/node_shader_holdout.cc
#	source/blender/nodes/shader/nodes/node_shader_output_material.cc
#	source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
#	source/blender/nodes/shader/nodes/node_shader_tex_coord.cc
#	source/blender/nodes/shader/nodes/node_shader_vector_transform.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_principled.cc
#	source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc
#	source/blender/render/RE_pipeline.h
#	source/blender/render/intern/initrender.c
2022-01-26 22:03:58 +01:00
af87b6d8cb Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine_types.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
#	source/blender/draw/intern/draw_manager_profiling.c
#	source/blender/draw/intern/draw_manager_text.h
#	source/blender/draw/intern/draw_texture_pool.cc
#	source/blender/draw/intern/draw_texture_pool.h
#	source/blender/draw/intern/draw_view_data.cc
#	source/blender/draw/intern/draw_view_data.h
#	source/blender/editors/space_view3d/view3d_draw.c
#	source/blender/gpu/GPU_texture.h
#	source/blender/gpu/GPU_viewport.h
#	source/blender/gpu/intern/gpu_shader_create_info_private.hh
#	source/blender/gpu/intern/gpu_viewport.c
2022-01-26 20:27:16 +01:00
55a6a8900a EEVEE: Shadow: Avoid double rendering
The update flag was not being cleared after the opaque pass, making the
updates of the forward pass re-render the same tiles.
2021-12-10 18:19:47 +01:00
36bec765e2 EEVEE: Shadow: Add defrag shader and page debug buffer generator
The defrag shader make sure the free heap is free of holes. Making
the allocation more straightforward.

Since we now only reference the pages using the tiles, we introduce
a debug shader that produces an image with page data in a visual way.
This replaces the debug 8 option.

This also fixes some bug that were still present in the pipeline.
2021-12-10 17:25:37 +01:00
0a7c4afd21 EEVEE: Shadow: Split LOD masking to its own shader
This fixes an issue with tile reuse causing corruption.
2021-12-09 16:27:48 +01:00
021bf5b171 EEVEE: Light: Separate directional lights iteration
This separate the handling of directional lights (sun) into their
own loops. This will help reduce register pressure and remove some
pollution of the local light culling.

All sun lights are packed at the start of the light array.
2021-12-08 21:51:13 +01:00
181bc60214 EEVEE: Shadow: Add depth scan for tile tagging
We now scan the depth buffer after the prepass to tag the needed
shadow tiles.

This is much more precise than the bound box tagging which is now
reserved for transparent objects.

This also:
- fix pixel radius size.
- add a dedicated info buffer to avoid having one unused tile.
2021-12-08 13:02:28 +01:00
b23d9519d0 EEVEE: Shadow: Make punctual LOD selection based on pixel density
Until now the LOD selection was based on distance from camera.

Now it is based on receiver distance ratio. We compute the world
size of one view pixel along with the world size of one shadow texel.
By knowing one point distance to the light or to the view, we can
compute the pixel density ratio and deduce the corresponding LOD.

We use this to compute the min LOD during the visibility selection phase
and the "mean" LOD for usage tagging by BBoxes.

The tagging LOD is a crude approximation as it only uses the BBox
center.
2021-12-05 23:08:46 +01:00
7303a453aa EEVEE: Shadow: Add LOD system for punctual shadows
This makes every shadow setup pass aware of the LOD chain of the tilemap
for each cubemap face.

In the free phase, we mask any LOD page that is completely covered by
higher LOD. This avoir commiting memory twice or more per area.

In the allocation phase, we check for the last valid LOD and set it
in the LOD 0 meta data. We also store the actual page location in LOD0 but
do not mark it as allocated as the LOD tile has the ownership of the page.
2021-12-05 01:28:36 +01:00
26335dfc57 EEVEE: Light: Merge ShadowData into LightData
This is because the light indices can now change because of the
culling. So the shadow data needs to follow.
2021-12-03 22:41:37 +01:00
1b00ca3575 EEVEE: Light: Port light culling to GPU
This removes the light count limit for the forward shaded object. This
also provides a more efficient way of computing the culling directly on
the GPU. Moreover, this avoids doing multiple lighting passes for high
light counts in the deferred pipeline, improving performance.
2021-12-03 22:41:37 +01:00
68b0195bf3 GL: Add support for all image resource types 2021-11-23 21:19:34 +01:00
68602f3d87 DRW: Add DRW_shgroup_vertex_buffer_ref 2021-11-23 21:19:11 +01:00
a8a4f5f805 EEVEE: Shadow: New virtual shadowmap sampling
This adds clipmap level selection and final page coordinate computation.

This also fixes some issues with tilemaps tagging.
2021-11-18 23:19:54 +01:00
9bd070fbc2 GPU: Add more barrier types 2021-11-16 21:39:26 +01:00
7664e1dd79 EEVEE: Shadows: Virtual shadowmap part 2
This continue the effort to implement virtual shadow mapping.

This includes:
- Spot cone culling of tile.
- Tile vs. view frustum tagging.
- Shadowmap Page allocation / freeing.
- Rendering to 4K buffer only tiles that needs it.
- Copying to shadow atlas.
2021-11-14 19:35:41 +01:00
55af3361bf DRWView: Add frustum infos to uniform buffer
This way it is possible to do some culling on GPU.
2021-11-14 14:43:38 +01:00
fbfbc9f15d DRW: Add debug line buffer
This debug buffer is automatically bound if a shader is including
`common_debug_lib.glsl`. One buffer is created for each shading group
using such a shader.

The shader can then use the functions from that file to draw debug
lines. There is a hardcoded limit of line one buffer can contain. Make
sure to only output lines for a few threads at most.

Under the hood this uses a vertex buffer bound as SSBO that contains
the number of verts and all the positions and colors packed into 1 vec4.
We render by just rendering the whole buffer.
All unused vertices are initialized with NaN positions and will not be
drawn.
2021-11-14 14:42:54 +01:00
bf42246984 GPUTexture: Fix support / validation for integer textures
Some types were missing in the switch cases in order to convert them to
correct values.
2021-11-14 14:29:53 +01:00
761ba97601 BLI: Add more operator to float4
Straightforward.
2021-11-14 14:28:54 +01:00
ebb2b1120c EEVEE: Shadow: Add Tilemap lod debug and fix clipmap end distance 2021-11-09 23:20:50 +01:00
2b61ca8f34 GPUVertexBuf: Mark dirty when using GPU_vertbuf_get_data
This way buffers with dynamic usage can also use this function
to update their content.
2021-11-09 20:13:17 +01:00
9db0734a1e GPU: Bump shader to version 430 and support other image uniforms
This is required for new EEVEE features
2021-11-09 14:47:35 +01:00
9c4cf35414 EEVEE: Shadow: Implement Virtual Shadowmapping
This is a total refactor of how shadows are handled.

We use Virtual shadow maps with different Level of details to
ensure a somewhat evenly distributed precision.

The shadow test is a really crude shadow test that will be
improved in further commit.

There is a pool of 4096 Tilemaps that are distributed between
shadowed ligths. These tilemaps are 16x16 each and reference
shadow map pages that are allocated in an atlas. Pages are only
allocated if needed (i.e: visible for rendering an object).

Page management is done on GPU using compute shaders to reduce
CPU task.

On CPU only one draw pass per updated tilemaps is issued.

This reduces the memory requirement of shadowmapping large scenes
with many lights.
2021-11-09 14:47:23 +01:00
c92b2d8bc4 EEVEE: Camera: fix fallback camera projection matrix 2021-11-05 16:55:06 +01:00
2a6a06fab7 EEVEE: Update / remove obsolete properties in the UI. 2021-11-05 16:55:06 +01:00
fc6a430d8e EEVEE: Raytracing: Add denoise and move raytrace passes to raytracing module.
Denoising make use of more memory to store and reproject the result of
previous frame to reduce noise. This only works for viewport.

There is a final bilateral filter for cleaning up noise even more.
2021-11-05 16:55:06 +01:00
c746eeae93 DRW: Shading Group: Add compute dispatch with size reference
This way we can reuse the same DRWPass using dispatch for multiple views.
2021-11-05 16:55:06 +01:00
e5fadd8c84 EEVEE: Texture: Make ensure function return true if allocation occured 2021-11-05 16:55:06 +01:00
682e1bea7e EEVEE: Forward: Support raytracing
Screen space Raytracing is supported by alpha blended surfaces.
However only opaque surfaces will be visible to the rays. This means
Alpha blended surfaces cannot reflect or refract themselves.

Denoising is not possible on alpha blended surfaces. Many samples
are needed for noise free results.

Since the cost of tracing can be very high, raytracing will only be
enabled on demand, on a per-material basis.
2021-11-05 16:55:06 +01:00
75db7522c6 EEVEE: Gbuffer: Split file 2021-11-05 16:55:06 +01:00
96d354a84d EEVEE: Subsurface: Small optimisation & fix comparison 2021-11-05 16:55:06 +01:00
5905b11c07 EEVEE: Raytrace: Add Diffuse surface raytracing
This simply reuse the reflection raytracing pipeline but with another
ray distribution. Only direct lighting, distant lighting and emissive
light are visible to diffuse rays.

Subsurface effect is not visible but transmittance effect is visible
to diffuse rays.

Indirect diffuse light is processed by the SSS filter.
2021-11-05 16:55:06 +01:00
a97234574d EEVEE: Deffered: Change normal packing for better negative normals
The spheremap encoding has a singularity issue for inverted normals
which are used by the translucent BSDF. This fixes the issue.
2021-11-05 16:55:06 +01:00
282a0c90d1 EEVEE: Subsurface: Fix issue cause by HiZ mipmaps
The mip level needs to be 0 to avoid sampling coarser level.
2021-11-05 16:55:06 +01:00
b8ab3f2f52 EEVEE: Principled BSDF: Fix refraction roughness when GGX single-scatter 2021-11-05 16:55:06 +01:00
92a92fc60f EEVEE: Cleanup: Rename uvcoordsvar to uv and explicit output location 2021-11-05 16:55:06 +01:00
52a81b8175 EEVEE: Raytracing: Add back screen space raytracing
The new pipeline is now cleaner and allows for deferred refraction.

The refractions are more accurate but are not denoised for now. More
research needs to be done in this area.

There is no feedback buffer for now, so reflections of metallic surfaces
will appear black.

The same restriction on refractive materials still holds true. They will
not appear in screen space tracing of other non refractive surfaces.

However, refractive surfaces (non-blended) can now reflect themselves
and the other surfaces with screen space reflections.

Half res tracing is not implemented back yet.
2021-11-05 16:55:06 +01:00
55a85af05d EEVEE: Add eevee_build: precomputation and codegen at compile time
This is to automate the generation of reuse sample tables and maybe more
in the future. This is not designed to make compilation way longer than
expected.
2021-10-24 16:15:38 +02:00
3db3006d4c EEVEE: Port back HiZbuffer
Pretty much identical.

Texture format is now always `GPU_R32F` to remove some workarounds.
2021-10-24 16:13:04 +02:00
008fb3eed9 EEVEE: Fix Crash with some geometry type 2021-10-08 17:58:45 +02:00
b304514bd5 EEVEE: Transmittance: Add back light transmittance
Same as SSS this has been rewritten to support varying SSS radius.

Instead of relying on shadowmap hack to improve the transmittance
artifact (previously called translucency) we exposed a min thickness
output that will reduce the maximum of light bleeding that can happen
at the shading point. This is far from perfect but at least it is
tweakable.

The effect is now cheaper and the option to enable it is now gone.
It can always be artificially disabled by making the thickness bigger
than the sss radius.

The effect is always enabled for all SSS surfaces and will even be
applied on forward shaded object (alpha blend mode).
2021-10-08 17:58:45 +02:00
b0da401292 EEVEE: Material: Add thickness output
This only adds the output but the output is not yet used.

This thickness output is meant to control the aspect of subsurface,
refraction, absorption and volume shaders.

The value expected is the mean thickness inside the object at the
shading point. The source can be a vertex color or a texture map baked
from a raytracer.
2021-10-08 17:58:45 +02:00
ee7deb09cf EEVEE: Subsurface Scattering: New implementation
This new implementation follows the technique described in
"Efficient screen space subsurface scattering Siggraph 2018".

Compared to the old implementation it fixes a lot of issues at
the cost of it being slower. This fixes:
- Light leaking between different objects.
- Light leaking between different surfaces with different depths.
- SSS radii are now "texturable" per pixel. No SSS surfaces limits.
- Noise should be lower.
- Precomputation is only done once for all SSS surfaces which lowers the
  per material storage and precomputation time.

Implementation is also simpler as it is only a one pass processing.

We differ from the reference presentation by not precomputing the
RGB weights per samples. We actually compute them on the fly in order
to support varying SSS radii.

Notes:
- SSS IOR and SSS anisotropy are not supported.
- Object level light leak prevention might not work for high number of
  objects in the scene (> 1024). In this case light leak might occur.
  Adding or deleting (hidding) objects in the scene might change which
  objects can leak.
2021-10-08 17:58:45 +02:00
9f85107fef EEVEE: Fix smooth transition when using render borders
The first sample buffer is fullscreen and needs to have its uvs
corrected to match the render border viewport.
2021-10-08 17:58:42 +02:00
bcd5bd6cd5 EEVEE: Fix double Stroke color in Panel
The stroke color was displayed in the side panel and this must be used only in 3D View.
2021-10-06 12:08:59 +02:00
42d2c96d4c Wrapped related global vars into struct. 2021-10-04 14:45:30 +02:00
941fdefdb3 Move index from DrawEngineType to DRWRegisteredDrawEngine. 2021-10-04 14:36:47 +02:00
a0df3c4d51 Fix incorrect merge: missing function DRW_view_get_active. 2021-10-04 11:21:38 +02:00
6f773e289b EEVEE: Fix shader compilation caused by latest merge 2021-09-29 18:10:06 +02:00
d5f91a68c0 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-09-29 18:06:17 +02:00
4984cba10d DRW: Fix implicit convertion warning on MSVC 2021-09-29 18:05:49 +02:00
e28ae32461 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-09-29 17:26:03 +02:00
59a0099b9f Merge branch 'master' into draw-viewport-data 2021-09-29 17:25:16 +02:00
225c1b0708 Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_minmaxz_frag.glsl
#	source/blender/draw/intern/DRW_render.h
#	source/blender/draw/intern/draw_cache.h
#	source/blender/gpu/GPU_material.h
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_material.c
#	source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_hair_info.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
#	source/blender/makesdna/DNA_gpencil_types.h
#	source/blender/makesdna/DNA_node_types.h
#	source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
#	source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
2021-09-29 17:24:30 +02:00
f8cfd7e288 Merge branch 'master' into draw-viewport-data
# Conflicts:
#	source/blender/draw/DRW_engine.h
#	source/blender/draw/intern/draw_manager.c
#	source/blender/draw/intern/draw_manager.h
2021-09-29 11:31:39 +02:00
dc0c074ac4 Cleanup: Remove compiler warning and fix some comments 2021-09-29 11:24:25 +02:00
2994b6dd98 EEVEE: Fix crash when destroying the Instance (in debug build)
This was caused by the StructArrayBuffer wrapper not being tagged as NonMovable.
The UBO was in fact being freed at creation time in debug build, but the
pointer was kept as valid in the copied wrapper.

Changing the higher level structure to not use the copy constructor to avoid this.
2021-09-29 11:14:34 +02:00
ab6a6ffed4 Cleanup: Remove compiler warnings 2021-09-29 11:14:34 +02:00
d3a825678a EEVEE: Film: Make smooth transition not rely on dtxl->color persistence
This is a needed change for the viewport compositor. The compositor
needs to draw to `dtxl->color` to have correct overlay / background
composition.

The solution here is to have a separate buffer that keeps the first
sample we blend from. This increases VRAM usage but it is the most
elegant option.
2021-09-15 17:15:40 +02:00
41c84bb08b EEVEE: More Windows 64bits changes
Missing in previous commit
2021-09-13 17:14:54 +02:00
9711cddbe0 EEVEE: Fix Windows 64bits error
Windows is different of Linux
2021-09-13 17:02:04 +02:00
85b6e6da4a EEVEE: Fix compiler errors in Windows 2021-09-12 19:37:59 +02:00
c51604e308 EEVEE: Use special depth shader to resolve the depth buffer
This was the cause of a bug on Intel Integrated GPU and might as well
impact other platforms.
2021-09-07 08:41:57 +02:00
9207920c1e EEVEE: LightGrid: Fix divide by zero leading to wrong world lighting
This integer divide by zero was evaluated to 0 on all platform but apple,
where it yields 1. The world lighting would then sample the 1 sample of the
first grid instead of its own sample.
2021-08-25 15:38:26 +02:00
f79788f767 EEVEE: Film: Fix undefined viewport color values after resizing
This was caused by the blend mode that was used even with full opacity.
This caused issues with the viewport was resized and the color of the
framebuffer becomes undefined, leading to undefined values in the blend
equation.

Another fix would be to clear the viewport color on resize inside the
GPUViewport.
2021-08-19 10:01:25 +02:00
c4287db151 EEVEE: Fix compilation on OSX platform
OSX driver does not support loose semicolon in code
2021-07-20 16:48:38 +02:00
62aa72dac8 Merge branch 'draw-viewport-data' into eevee-rewrite
# Conflicts:
#	source/blender/blenlib/BLI_assert.h
#	source/blender/blenloader/intern/versioning_290.c
#	source/blender/draw/engines/eevee/eevee_cryptomatte.c
#	source/blender/draw/engines/eevee/eevee_depth_of_field.c
#	source/blender/draw/engines/eevee/eevee_effects.c
#	source/blender/draw/engines/eevee/eevee_engine.c
#	source/blender/draw/engines/eevee/eevee_lightcache.c
#	source/blender/draw/engines/eevee/eevee_lightprobes.c
#	source/blender/draw/engines/eevee/eevee_lights.c
#	source/blender/draw/engines/eevee/eevee_lookdev.c
#	source/blender/draw/engines/eevee/eevee_materials.c
#	source/blender/draw/engines/eevee/eevee_mist.c
#	source/blender/draw/engines/eevee/eevee_motion_blur.c
#	source/blender/draw/engines/eevee/eevee_occlusion.c
#	source/blender/draw/engines/eevee/eevee_private.h
#	source/blender/draw/engines/eevee/eevee_render.c
#	source/blender/draw/engines/eevee/eevee_renderpasses.c
#	source/blender/draw/engines/eevee/eevee_screen_raytrace.c
#	source/blender/draw/engines/eevee/eevee_shaders.c
#	source/blender/draw/engines/eevee/eevee_shadows.c
#	source/blender/draw/engines/eevee/eevee_shadows_cascade.c
#	source/blender/draw/engines/eevee/eevee_subsurface.c
#	source/blender/draw/engines/eevee/eevee_temporal_sampling.c
#	source/blender/draw/engines/eevee/eevee_volumes.c
#	source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
#	source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
#	source/blender/draw/engines/eevee/shaders/btdf_lut_frag.glsl
#	source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
#	source/blender/draw/engines/eevee/shaders/closure_type_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
#	source/blender/draw/engines/eevee/shaders/common_utiltex_lib.glsl
#	source/blender/draw/engines/eevee/shaders/eevee_depth_of_field_tiles_flatten_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_bokeh_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_dilate_tiles_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_gather_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_lib.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_reduce_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_dof_setup_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_resolve_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_reflection_trace_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_subsurface_frag.glsl
#	source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl
#	source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl
#	source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
#	source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
#	source/blender/draw/engines/eevee/shaders/lights_lib.glsl
#	source/blender/draw/engines/eevee/shaders/random_lib.glsl
#	source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
#	source/blender/draw/engines/eevee/shaders/ssr_lib.glsl
#	source/blender/draw/engines/eevee/shaders/surface_lib.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_geom.glsl
#	source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
#	source/blender/draw/intern/draw_manager_shader.c
#	source/blender/draw/intern/shaders/common_math_lib.glsl
#	source/blender/gpu/CMakeLists.txt
#	source/blender/gpu/intern/gpu_codegen.c
#	source/blender/gpu/intern/gpu_shader.cc
#	source/blender/gpu/shaders/material/gpu_shader_material_geometry.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_subsurface_scattering.glsl
#	source/blender/gpu/shaders/material/gpu_shader_material_world_normals.glsl
#	source/blender/nodes/shader/nodes/node_shader_output_aov.c
2021-07-19 23:04:20 +02:00
0053d2fc81 DRW: Move buffer & temp textures & framebuffer management to DrawManager
This is a necessary step for EEVEE's new arch. This moves more data
to the draw manager. This makes it easier to have the render or draw
engines manage their own data.

This makes more sense and cleans-up what the GPUViewport holds

Also rewrites the Texture pool manager to be in C++.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.

Differential Revision: https://developer.blender.org/D11966
2021-07-19 19:47:55 +02:00
6206a30519 EEVEE: GBuffer: Change layout
This change the gbuffer layout to use more of the hardware to converting
data back and forth. Normals are encoded as two 16 bits components and
colors as R11G11B10F format.

This was motivated by the need of better quality normals. The issue is
that this increase the GBuffer size consequently. In order to balance
this we chose to merge the refraction and Diffuse/SSS data to use the
same buffer. This means we need to stochastically chose one of these
layers (so noise appear). Given that Glass BSDFs are rarely mixed
with Diffuse BSDFs, we think this is a good tradeoff.
2021-07-19 19:01:09 +02:00
e3ff83a4a8 GPUFramebuffer: Bump maximum color attachement to 8
This is needed for EEVEE's new deferred render pipeline.
2021-07-15 17:26:03 +02:00
80b92467f0 GPU: Shader: Add debug context line count
This gives more detail, when the error line is misleading.
2021-07-03 14:45:26 +02:00
169a2a54d7 EEVEE: Fix crash caused by transparent material without prepass 2021-07-03 14:44:23 +02:00
d8ec228a76 GPUMaterial: Fix issue with displacement tree and partial derivatives 2021-07-01 00:02:42 +02:00
27adad0b0d GPUNodeTree: Fix issue with weight tree inversion and displacement
Displacement tree was also being tagged for copy and caused issue.
2021-06-30 23:56:03 +02:00
c4a3ba6f83 EEVEE: Hair: Add back shaded hair support
Same implementation as before but it is less intrusive towards the
shading Node glsl code.

Hair shaders also now supports displacement.
2021-06-30 23:55:37 +02:00
e962002db2 DRW: Fix crash in deferred compilation 2021-06-23 15:39:55 +02:00
3ad7832a8d EEVEE: Add back refraction support for lightprobes
Screen Space Raytracing support is still to come.
Both forward and deferred pipelines are supported.
2021-06-20 18:45:38 +02:00
209ab8c424 EEVEE: Cleanup: Replace lighting evaluation macro by functions
The functions need to be declared before main as prototypes.
The appended libs will use the resources (textures, UBOs) defined at
global scope.

This removes a bit of code duplication and some long macros.
2021-06-20 01:28:30 +02:00
94f813db70 DRW: ShaderLib: Add support for requesting lib to be appended to shader
Instead of appending using `BLENDER_REQUIRE`, shaders can now ask for
libs to be added after the shader's `main()` by using the
`BLENDER_REQUIRE_POST` pragma.
2021-06-19 18:01:26 +02:00
c844497aee EEVEE: Film: Fix accumulator precision when zoomed out
Use viewspace instead of world space to compute pixel projection.
This fix issues when camera is far from origin and float precision would
produce artifacts.
2021-06-19 18:00:53 +02:00
a6ae942540 EEVEE: Port back barycentric coordinates.
Nothing changed appart from the style of the integration which is
now fully on EEVEE's side.
2021-06-15 22:35:54 +02:00
1f262a461c GPUCodegen: Fix crash when there is no output node 2021-06-15 22:31:40 +02:00
4c816924e7 EEVEE: GPencil: Fix missing strokes
And comment velocity not implemented yet
2021-06-08 22:54:12 +02:00
a1459e1fcf EEVEE: Shadows: Modify view matrix instead of projection for each face
This is the same reason we changed back for lightprobes rendering:
To much area assume -Z is camera direction.
2021-06-08 22:30:36 +02:00
4260823e1e EEVEE: GPencil: Finish geometry support
This port the facing "flat" normal trick used by the gpencil engine
to EEVEE as well as the thickness mode.

The objects parameters are passed via the objectInfos UBO to avoid
much boiler plate code. However if this UBO grows too much we might have
to split it.

The normal trick for planar surfaces is quite simple to port to the
vertex shader even if it is less efficient.
However to compute it we need the objects bounds. This is passed as a
scale only through the orco factors. This will needs a bit of cleaning
at some points, with boundbox computed at object level.
2021-06-08 22:09:57 +02:00
89a002c4e3 EEVEE: Material: Add back support for backfacing and transparency
Nothing much different compared to the previous implementation.

The transparent BSDF and principled BSDF now detects when the material
is potentially transparent to select the best way to render it.
2021-06-07 19:49:00 +02:00
6c1e7868c7 EEVEE: LookDev: Move rendering to view render.
This makes is possible to have AA and correct blending of the
forward rendered spheres.

However, to avoid distorded spheres we need to not support Lookdev
in panoramic projection mode.

Also remove support for LookDev when using render border for now.
2021-06-06 16:36:02 +02:00
9b153666e7 EEVEE: FowardPass: Fix closure sampling, add emission & fix transparency 2021-06-06 16:36:02 +02:00
93881a2a8e EEVEE: LookDev: Add back overlay support
This differs a bit from old implementation.
- Instead of manually adjusting the viewport we correctly place the
  sphere in the vertex shader.
- Rendering happens after TAA accumulation: This is because we now
  support panoramic cameras and TAA would distort the spheres.
2021-06-06 16:36:02 +02:00
04f053c6a4 EEVEE: ForwardPass: Add lightprobe support & fix pipeline selection 2021-06-06 00:37:55 +02:00
d66b98e9c8 EEVEE: Patch lightprobe and light modules to handle zero lights/probes
This expose the capability of having no light and no probe (except the
world one) for specific views / code path.

The caller just need to pass 0 as extent to the `set_view()` function.

This is usefull for lookdev.
2021-06-05 23:46:27 +02:00
ae529ed93e BLI: int2: add more float operator to avoid incorrect implicit cast 2021-06-05 23:45:13 +02:00
581cb48c9e BLI: float2: add more operator and fix a typo 2021-06-05 23:44:44 +02:00
dc64186d75 EEVEE: Nodes: Fix environment texture node default mapping and ...
... empty image behavior
2021-06-05 16:00:44 +02:00
308d42d072 Merge branch 'draw-viewport-data' into eevee-rewrite 2021-06-05 15:38:33 +02:00
e6d94b83ba DRW: Fix memory leak of GPUTextures
The textures needs to be released by iterating. Not by using the
free callback.
2021-06-05 15:36:47 +02:00
3caf7ba32d EEVEE: Lookdev: Add back lighting support
This does not include reference spheres rendering.

The approach is a bit different than before.
Now we use a `bNodeTree` to control the rendering of lookdev. This
generates a `GPUMaterial` that is stored per `Instance`. This way
rendering lookdev is just updating the temp light cache using this
material as world material. Removing the use of custom shader.

This introduces a small hack in order to bind the studiolight hdri after
the nodetree glsl parsing.

The background display however is still using a custom shader in order
to sample the world cubemap with different roughness.

The view space option of the studiolight is now faster by using a
transform before shading instead of rebaking the lightprobe constantly.
This should not have any particular impact on render time.
2021-06-05 15:29:00 +02:00
b3084d23bf EEVEE: Light: Fix culling in orthographic view 2021-06-04 21:05:32 +02:00
7f5d787952 EEVEE: LightCache: Fix broken visibility sampling 2021-06-04 20:29:48 +02:00
79a5322fa4 EEVEE: LightCache: Fix broken light bounce 2021-06-04 19:52:03 +02:00
92aedc5eda EEVEE: Fix world probe rendering objects
Was leftover of a test.
2021-06-04 18:22:37 +02:00
33ff463ea1 EEVEE: GBuffer: Fix undefined behavior
When evaluating surfaces, the deferred passes needs to sample the
depth buffer. But it also test against the stancil buffer.

Moreover the sampler needs to be a 2D sampler which is not the case
for cubemaps and texture2Darrays.

To overcome this we simply copy the gbuffer depth to another
temp texture using framebuffer blitting.
2021-06-04 02:34:32 +02:00
7d3f65a044 EEVEE: Remove light specular during baking & fix bounce light 2021-06-04 02:33:44 +02:00
6d3c7a8281 EEVEE: LightProbe: Fix grid display and deduplicate code 2021-06-03 16:53:38 +02:00
8e6deba985 EEVEE: LightProbe: Fix light cache display visibility without overlays 2021-06-03 16:35:55 +02:00
d31e74d3f8 EEVEE: LightProbe: Fix wrong shading on other cube faces
Use modified viewmat instead of modified winmat. Too much code
assume conventional winmat.
2021-06-03 16:34:48 +02:00
bdcf0ccead EEVEE: LightProbe: Fix level bias and visibility filtering 2021-06-03 16:34:16 +02:00
c8b40c5fd6 EEVEE: Fix irradiance baking sample order 2021-06-03 16:33:48 +02:00
2dc9db65d7 EEVEE: Fix irradiance smoothing wrong 2021-06-03 15:17:44 +02:00
ff00c1d6eb EEVEE: Fix background transparent
Alpha of main output is transparency and not opacity.
2021-06-03 15:15:06 +02:00
1f5c3c9d74 EEVEE: LightCache: Port back cache Display
Nothing significantly different appart from codestyle.
2021-06-03 15:15:06 +02:00
d87161e574 BLI: float3: add division operator between 2 float3 2021-06-03 15:15:06 +02:00
14df74ea8b EEVEE: LightCache: Port baking
Some things differs from old implementation.
- Object visibility is filtered correctly without using a visibility
  callback (which is to be removed).

The implementation is also more high level using less low level tricks.

A dedicated LightProbeView is created for each lightprobe cubeface to
render using all pipeline (deferred and forward).

There is still a few things not working.
2021-06-03 15:15:06 +02:00
060c462f3a EEVEE: LightProbe: Finish loading and rendering of lightcache
Starting to port lightcache.c to c++.
2021-05-31 14:25:03 +02:00
25dd16a8cd EEVEE: Fix crash cause by world material without attributes 2021-05-30 22:48:40 +02:00
0fb1621594 EEVEE: Lightprobe: Add back lightprobe rendering support for world.
Only world probe is supported for now.

The new implementation diverge from the original by randomly
selecting one lightprobe instead of sampling them all.
This speeds-up rendering a bit.
2021-05-30 22:48:40 +02:00
5fb1b27d17 EEVEE: Lightprobe: Port back lightprobe filtering
No much change appart from code organization and structure.
2021-05-30 22:48:40 +02:00
6376b575d9 DRW: Add DRW_view_frustum_bsphere_get 2021-05-30 22:48:40 +02:00
31963c8d86 DRW: Increase shader library max supported lib count 2021-05-29 16:59:15 +02:00
4495060185 DRW: Add DRW_view_get_active 2021-05-29 16:44:00 +02:00
f4dbdd7b52 EEVEE: Lightprobe: Add simple world probe rendering and downsampling 2021-05-28 01:07:12 +02:00
e19c028cc4 EEVEE: Add back world nodetree support
Only for background for now.

Support is now not using defines and just use the correct globals and
uniforms to keep the same values as before.
2021-05-28 00:51:04 +02:00
f04011dd87 World: Add static default world
This is a small convenience. This let the render engine use this
default world if scene has no world.

World is black to keep the same behavior as before.
2021-05-27 04:52:21 +02:00
1bc0a70d94 EEVEE: Fix ModelMatrix in nodetree and wrong bump map output 2021-05-26 02:23:32 +02:00
2b6c70a780 EEVEE: Rework multi material handling
Shading groups are now created by the material_array_get functions
instead of passing a reference to be filled later. This avoids having
to wait later to maybe create a sub shading group.
This also simplifies different geomety type handling.
2021-05-26 02:02:46 +02:00
113c16d7a9 EEVEE/GPU: Nodes: Fix some BSDF nodes
Fix glass, principled and eevee specular shaders.
2021-05-24 20:45:58 +02:00
06ca1818d0 EEVEE: GPencil: Add basic support for gpencil geometry
This adds support for rendering gpencil objects.

There is a lot of features to implement specially the ones requiring
per object uniforms.
2021-05-24 20:43:25 +02:00
6c0d8c4b75 EEVEE: Material: Fix shader uuid to material type conversion 2021-05-24 18:13:55 +02:00
44bb4be66c DRW: Shader: Fix deferred compilation abortion
The case where a shader was queued but then requested as non deferred
was not handled correctly.
2021-05-24 18:12:24 +02:00
f7f1ee9e99 EEVEE: Add back split sum BSDF approximation
This improves the surface appearance of most bsdf.
2021-05-23 02:42:46 +02:00
e91df656f5 EEVEE: Material: Use weight to random sample closure per types
This adds a new closure selection method.

- In a first pass, weights are accumulated per output type (diffuse,
  reflection, refraction).
- A random threshold is then generated before evaluating the BSDF nodes
  again.
- During the evaluation pass the random threshold is decremented until
  it reaches 0. At this moment the current BSDF is sampled.

For this to work, I splited the evaluation and the weighting in two
functions for all BSDF. The `*_eval` nodes are generated as dangling
nodes from the graph and only serialized after the rest of the graph.
2021-05-23 00:39:56 +02:00
10cf16270a GPUMaterial: Add recalc flag workaround
Recalc flag on Material ID being unavailable to render engine, this
adds a simple way to detect material update by detecting shader creation
or update.
2021-05-22 03:05:24 +02:00
7d36a00d14 GPUNodeTree: Add weight tree inversion
This constructs a "mirror" nodetree that feeds the closure "shader"
nodes with their respective final weight.

The tree is mirrored using simple math nodes. This is quite messy but
this is the only way to proceed without introducing special nodes.
The other issue with this method is that inputs are all uniforms even
for unplugged socket on temporary math nodes with add bloat to the
shader uniform buffer structure.

Only the part relevant to the weighting is duplicated. Other connexions
with the shading tree are reuse.

All shader nodes are updated to receive a `Weight` hidden parameter.

The original shader mixing tree is preserve to let the choice of using
either way to weight the output.

For now this is only done for the output nodes. This will need to be
extended to Closure to RGBA sub-tree.
2021-05-22 02:55:41 +02:00
9a857d83a6 GPUNodeTree: Move closure socket implicit cast to ntreeGPUMaterialNodes
This reduces complexity of weighting closure in further dev.
2021-05-21 17:28:18 +02:00
25806227e8 GPUNode: Remove ssr_id and sss_id
These are not useful anymore.
2021-05-21 17:25:55 +02:00
6dc49ec992 GPU/EEVEE: Refactor codegen and nodetree support
This is the first step towards the new evaluation scheme of EEVEE
closures.

This commit contains:
- Removal of GPU_SOURCE_BUILTIN type, prefering global instead. This
  avoid many boilerplate code since most of the old builtins are now
  datas that are always present (i.e: view matrices, normals).
- Rewritting of codegen in C++ to use `std::stringstream`.
- Added a callback to let engine decide what to do with codegen code.
  This remove a lot of needs for defines because of code order
  dependency. The engine can insert the nodetree code in custom ways
  to create advance effects (i.e: add displacement or vertex lighting).
  Engine now returns final shader strings.
- Closure nodes evaluation replacment is a placeholder for now.
2021-05-20 23:51:52 +02:00
0c71240f14 EEVEE: Material: Add basic material logic
This is a port of the old material grouping. This is a bit more
clean as we use containers for each passes and other structures.

Nodetree is generated without major error for simple materials but
it is not yet used as closures are not outputed.
2021-05-18 15:39:40 +02:00
f46661428b DRWShaderLib: Add better debug output from missing lib 2021-05-03 16:37:17 +02:00
4500a90cdc EEVEE: Implementation of volume rendering
This adds the transparency and volume handling in the deferred
render pipeline.

Implementation is still unfinished.

To have better naming convention, I renamed object shader to surface.
2021-05-03 16:35:36 +02:00
99a5d49a38 EEVEE: Initial implementation of deferred shading
This introduce a fat Gbuffer layout that groups closure data in groups
of similar BSDF. The goal is to have at least one sample for each
group to avoid too much code complexity and expected worse performance.

There is a lot of room for buffer reuse to reduce memory usage but it is
 not considered a priority for now.
2021-04-30 15:57:38 +02:00
c59156dac7 DRWTexture: Add missing integer render-targets format support. 2021-04-30 15:56:15 +02:00
c7fb0d5c7b EEVEE: Add specular layer to temporary default material 2021-04-27 13:45:20 +02:00
f1a5c5f6cb EEVEE: Film/Sampling: Add smooth transition
Add a smooth transition to avoid flickering of stochastic effects such
as soft shadows.

This use a simple blend method to progressively reveal the render
after some low sample count to avoid most of the flickering.

Parameters are hardcoded for now.
2021-04-27 13:42:43 +02:00
556478c20e EEVEE: Shadow: Add back soft shadows support
We use a new RNG to avoid correlation artifacts between Anti-Aliasing
and Shadow samples (see T68594).

The new sequence is a leap halton sequence. This makes it good with
low number of samples and yield less correlation issues.

Another change is that we directly jitter the projection matrix instead
of rotating the view matrix. This is improving convergence time and
avoid passing a second matrix to the shader.

However this case lead to discontinuity artifacts at face boders.
We might want to revert to the old rotation method for this
reason even if convergence is slower.
2021-04-27 03:15:15 +02:00
5df8d5af8a EEVEE: Shadow: Add back shadow caster tracking
Compared to previous implementation this does track dupli objects.

There is a few optimizations left like using bitfield instead of bool
arrays.
2021-04-26 15:17:59 +02:00
1d3de154e2 EEVEE: Shadow: Simplify the shadow module
Now the shadows are linked to a `Light` object. The `Light` object is
linked to an `ObjectKey` to ensure persistence and deletion tracking.

The Uniform data are packed so that there is 1 `ShadowPunctualData`
per light in a `LightBatch`. This means there is only a shadowmap
limit to the number of `Shadow` in a scene.
2021-04-26 01:44:52 +02:00
4090bac8c8 EEVEE: Use C++ vector types 2021-04-24 23:03:21 +02:00
0932d508c8 BLI: Add more operator to float2/3 and int2/3 2021-04-24 23:02:50 +02:00
0fdd8a64b4 BLI: add int2 and int3 C++ support
Simple addition based on float2/3.
2021-04-24 21:58:03 +02:00
9dddfe2ef6 DRW: Debug: Add DRW_debug_view 2021-04-23 17:32:12 +02:00
e808500ba1 EEVEE: Shadow: Add Point light shadows support back
Difference with previous implementation:
- Better texture space usage of cone and area light shadow.
- Shadows are packed in an atlas. Reducing requirements for future
  features.
- Sampling is simpler because shadow matrix does everything.
2021-04-23 17:27:02 +02:00
2fd359684d EEVEE: Fix use after free crash 2021-04-21 22:35:00 +02:00
da91f87764 EEVEE: Check updates using recalc flag only an object maps.
This avoids having to reset accumulation if nothing affecting
eevee changes.
2021-04-21 22:06:52 +02:00
610294205f EEVEE: Light: Add back LTC area lights and lighting function
I did a small optimization pass to avoid some division and
redundant computation.

Also cleans-up the Light vector usage.
2021-04-19 14:29:38 +02:00
5697f96608 EEVEE: Light: 2.5D Culling: Initial implementation
This follows closely the implementation of 2.5D tiled light
culling described in the presentation:
"Improved Culling for Tiled and Clustered Rendering"
from Michal Drobot
http://advances.realtimerendering.com/s2017/2017_Sig_Improved_Culling_final.pdf

I chose the tile + Z binning approach for its high depth range support
and low CPU overhead & low memory consumption compared to the cluster
based culling. The cons is that the culling is a bit less precise in
some aspect but it is quite balanced.

The culling is done by the `Culling` object which is templated to easily
be reused for light probes cullg.

The Z-binning process is described starting from slide 20 in the
reference pdf.

I also implemented a debug pass to visualize false negative (light
culled when they shouldn't) and light evaluation density.
This is useful to detect failure case and hotspot. This could be exposed
as a developper only render pass in the future.

Some optimization of the reference implementation requires extensions
not yet added to GPU module and will be added later.
2021-04-18 17:30:36 +02:00
93b774a661 GPUTexture: Fix missing cases for integer textures 2021-04-18 01:15:19 +02:00
bf0ca28494 DRW: Fix const correctness 2021-04-18 01:14:48 +02:00
89af2b0485 EEVE: Lights: Implement simple culling scheme.
This has the basis of clustered light culling but does not yet do
it. The lights are only culled by frustum.

Its the same as if there was only one Cell for the entire Viewport.
2021-04-16 02:16:15 +02:00
ddc1be5556 EEVEE: Split shading passes to eevee_shading.cc 2021-04-15 01:05:42 +02:00
23584ee52f EEVEE: Refactor: Split implementation to .cc file
This also wrap GPUFrameBuffer & GPUTexture inside eevee:Framebuffer
and eevee:Texture to improve managment.

Another cleanup was to put all members of `Instance` public to
avoid much complexity in accessing the data with modules
dependencies.

Also split velocity View related data to `class Velocity` and
rename previous `Velocity` to `VelocityModule`
2021-04-15 00:49:32 +02:00
520962b3d6 EEVEE: Lights: Support infinite light count
Support infinite light count by dividing rendering into chucks of
LIGHT_MAX. Forward passes are just rendered again and deferred passes
(not implemented yet) will just have to have multiple light evaluation
passes.
2021-04-14 16:46:48 +02:00
017e9d852e EEVEE: Lights: Initial Work in progress implementation
Only supports simple point lights for now
2021-04-14 13:21:49 +02:00
ab55a1b67b DRW: Make draw_debug.h C++ compatible 2021-04-14 13:20:25 +02:00
9bf6fa974d Cleanup: EEVEE: RenderPasses: Use iterator 2021-04-14 12:08:44 +02:00
431a662f4f EEVEE: Add back object update and view update detection. 2021-04-14 00:24:05 +02:00
9c74f9322d EEVEE: Motion Blur: Fix cdf inversion and a typo 2021-04-12 23:06:55 +02:00
a4ae2b91c9 EEVEE: Motion Blur: Add back post process motion blur
This is almost the same thing as old implementation.
Differences:
- We clamp the motion vectors to their maximum when sampling the velocity buffer.
- Velocity rendering (and data manager) is separated from motion blur. This allows
  outputing the motion vector render pass and in the future use motion vectors to
  reproject older frames.
- Vector render pass support (only if motion blur is disabled, just like cycles).
- Velocity tiles are computed in one pass (simpler code, less CPU overhead, less
  VRAM usage, maybe a bit slower but imperceivable (< 0.3ms)).
- Two velocity passes are outputed, one for motion blur fx (applied per shading view)
  and one for the vector pass. This could be optimized further in the future.
- No current support for deformation & hair (to come).
2021-04-12 21:34:08 +02:00
0cd4896037 EEVEE: Add wrapper to simplify ubo managment 2021-04-10 01:40:19 +02:00
e540c9c47a EEVEE: Motion Blur: Add back accumulation logic
Bonus addition, support for shutter curve.

Compared to the old implementation, the per time step sync function
is lighter and localized. Also it does not require a full engine
"reboot" in order to work.

Also modifies camera setup to be compatible with future camera motion
blur.
2021-04-09 21:42:56 +02:00
f9b15edbde EEVEE: Motion Blur: Add back accumulation logic
Bonus addition, support for shutter curve.

Compared to the old implementation, the per time step sync function
is lighter and localized. Also it does not require a full engine
"reboot" in order to work.
2021-04-09 21:42:49 +02:00
1857fa8bc9 EEVEE: Depth Of Field: Fix ortho factor
When will it end? Is there some UB somewhere in cycles?
2021-04-08 23:13:10 +02:00
ac6e2b0083 EEVEE: Sampling: Add UBO containing LDS random numbers
We have many dimensions to avoid correlation between effects.
2021-04-08 23:11:51 +02:00
d18e74d822 DRW: Fix debug print of error in shader lib dependency. 2021-04-08 16:22:57 +02:00
8c753a2c80 GPUTexture: Fix max FBO attachement in panoramic view + dof + eevee 2021-04-08 16:22:14 +02:00
2a7d9d4515 EEVEE: Depth Of Field: Add back post process depth of field.
Pretty much identical to the previous implementation. With the exception
of a temporary noise function and some simplification of the CoC
computation. This also fixes issues with the Ortho depth of field.

Most of the files were modified to comply to new shader codestyle.

This also adds partial support of panoramic cameras (bokeh and
anamorphic is still buggy).
2021-04-08 16:17:04 +02:00
89f2d3427e EEVEE: Depth Of Field: Port back jittered dof
This cleansup a lot of confusion / complexity in the setup code.

Setup is closer to what cycles does now.

Also duplicates some buggy behavior of Cycles for now until this
is fixed.
2021-04-05 17:38:41 +02:00
309b90c955 Cleanup: BLI: Fix some const conrectness 2021-04-05 17:34:33 +02:00
a766ee6d5d EEVEE: Shader: Add preprocessor to have better shared enum definition
This removes the use of very ugly macros. Now we preprocess
the .hh string at startup to change enum definitions to a more
GLSL friendly variant.
2021-04-04 21:56:55 +02:00
ebf455daba Cleanup: DRW: Const correctness 2021-04-04 19:17:50 +02:00
fe9ea5d5cb Cleanup: EEVEE: Use class instead of struct and remove typedefs 2021-04-04 00:12:25 +02:00
8a2f400cf3 EEVEE: Reorganize ShadingView initialisation
This move view resolution handling to the `Camera` class that will
in the future clip and trim each view in panoramic projection.

There is a new `CameraView` that contains the `DRWView` and subview.
This way each `ShadingView` is associated to a unique `CameraView`.

ShadingView` & `CameraView` are all allocated & defined at creation time
but only the one activated by `Camera` will be rendered.
2021-04-03 23:43:23 +02:00
448d10a31a Cleanup: DRW: More const correctness 2021-04-03 23:40:48 +02:00
e0e1dd73bb EEVEE: Film: Add option to use log encoding
This option will make accumulation happen in a pre exposed logarithm
color space. This reduces the importance of bright pixels in the pixel
filter which will result in less aliasing in theses areas.

There is a few cases where one might want to disable this option to
match cycles better.
2021-04-03 23:40:26 +02:00
fa88f5af4c EEVEE: Render: Add back render mode
Render mode is really close to what the viewport render does.

Film output is done by resolving the data to the next (double buffered)
framebuffer and read back.

This also includes a bit of cleaning about naming of init() and sync()
functions.
2021-04-03 00:51:37 +02:00
fcb85633ea DRWView: Add getter for camtexco 2021-04-03 00:50:49 +02:00
935da83e2c Cleanup: RenderPipeline: Fix const correctness 2021-04-03 00:50:02 +02:00
ef174ffcb3 Cleanup: EEVEE: Renaming
- Add eevee_ prefix to shaders to avoid name clashing.
- remove plural of eevee_shaders.
- rename eevee_shared.hh to eevee_shader_shared.hh.
2021-04-02 14:44:44 +02:00
ad23570fa2 EEVEE: Film: Filtered accumulation with panoramic projection support
This commit adds the Film class that handles accumulation of color and
non-color data using arbitrary projection and filter size.

A weighted accumulation (sum) is done into a data buffer with an
additional weight buffer. The sum being per pixel, it allows the input
textures that are not aligned with the output pixel grid.

Panoramic projection works by rendering a cubemap (6 views) of the scene
at the camera position. The Film filter pass then gather the pixels
using the correct Panoramic projection ensuring correct Anti-Aliasing.

For Non-color data (depth, normals) we only keep the closest value to
the target pixel center (simulating a filter size of 0).

Color data is accumulated in a log space to improve AntiAliasing output.
This is hardcoded for now.

Larger filters have poor performance but are very fast to converge.

Code Wise: This commit rename some modules to avoid possible confusion
and have better meaning. Use namespace instead of prefixes.

Added a new eevee_shared.hh file to share structure and enum definitions
between GLSL and C++.
2021-04-01 22:37:50 +02:00
8777497c4b DNA: Camera: Add panoramic types and parameters
These are direct copy of Cycles parameters. Cycles parameters
unification will be done separately.
2021-04-01 21:38:53 +02:00
25af8b801d EEVEE: New basic drawing
TODO describe overall implementation here
2021-03-28 16:53:31 +02:00
829e2e4a24 EEVEE: Add new engine managed per viewport data
This was engine(s) can have arbitrarily persistent resources and
are responsible for freeing it properly.
2021-03-25 14:30:47 +01:00
09e1f276ff EEVEE: Remove EEVEE
Starting clean!
2021-03-25 13:15:35 +01:00
81632de706 DRW: Move mempool datas to a DRW managed struct.
Same idea as previous commit. This cleans-up the interface and put all
viewport related data inside the `DRWData` struct.

The draw manager is responsible for freeing it. That is the main point
of this all. In the future, we can have custom freeing method for each
engine.

This also move the DefaultFramebuffer/TextureList and the engine related
data to a new `DRWViewData` struct. This struct manages the per view
(as in stereo view) engine data.

There is a bit of cleanup in the way the draw manager is setup.
We now use a temporary DRWData instead of creating a dummy viewport.
2021-03-25 01:03:10 +01:00
f7cb19956f DRW: Move GPUViewport texture pool to DRW module
This makes more sense and cleans-up what the GPUViewport holds.

Also rewrite it to be in C++.
2021-03-22 23:53:42 +01:00
1796 changed files with 62330 additions and 56799 deletions

View File

@@ -264,6 +264,9 @@ ForEachMacros:
- SET_SLOT_PROBING_BEGIN
- MAP_SLOT_PROBING_BEGIN
- VECTOR_SET_SLOT_PROBING_BEGIN
- LIGHT_FOREACH_BEGIN_DIRECTIONAL
- LIGHT_FOREACH_BEGIN_LOCAL
- LIGHT_FOREACH_BEGIN_LOCAL_NO_CULL
StatementMacros:
- PyObject_HEAD

View File

@@ -256,7 +256,7 @@ endif()
if(UNIX AND NOT APPLE)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
option(WITH_SYSTEM_FREETYPE "Use the freetype library provided by the operating system" OFF)
else()
# not an option for other OS's
@@ -502,7 +502,7 @@ else()
set(WITH_EXPERIMENTAL_FEATURES OFF)
endif()
# Unit testsing
# Unit testing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
option(WITH_OPENGL_RENDER_TESTS "Enable OpenGL render related unit testing (Experimental)" OFF)
option(WITH_OPENGL_DRAW_TESTS "Enable OpenGL UI drawing related unit testing (Experimental)" OFF)
@@ -866,7 +866,7 @@ if(WITH_CYCLES_DEVICE_HIP)
endif()
#-----------------------------------------------------------------------------
# Check check if submodules are cloned
# Check if submodules are cloned.
if(WITH_INTERNATIONAL)
file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
@@ -889,8 +889,8 @@ if(WITH_PYTHON)
# Do this before main 'platform_*' checks,
# because UNIX will search for the old Python paths which may not exist.
# giving errors about missing paths before this case is met.
if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.9")
message(FATAL_ERROR "At least Python 3.9 is required to build, but found Python ${PYTHON_VERSION}")
if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.10")
message(FATAL_ERROR "At least Python 3.10 is required to build, but found Python ${PYTHON_VERSION}")
endif()
file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons")
@@ -1668,6 +1668,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable)
ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
@@ -1886,7 +1888,6 @@ elseif(WITH_CYCLES_STANDALONE)
add_subdirectory(intern/glew-mx)
add_subdirectory(intern/guardedalloc)
add_subdirectory(intern/libc_compat)
add_subdirectory(intern/numaapi)
add_subdirectory(intern/sky)
add_subdirectory(intern/cycles)

View File

@@ -32,7 +32,7 @@ Other Convenience Targets
* config: Run cmake configuration tool to set build options.
* deps: Build library dependencies (intended only for platform maintainers).
The existance of locally build dependencies overrides the pre-built dependencies from subversion.
The existence of locally build dependencies overrides the pre-built dependencies from subversion.
These must be manually removed from '../lib/' to go back to using the pre-compiled libraries.
Project Files
@@ -51,20 +51,13 @@ Testing Targets
* test:
Run automated tests with ctest.
* test_cmake:
Runs our own cmake file checker
which detects errors in the cmake file list definitions
* test_pep8:
Checks all python script are pep8
which are tagged to use the stricter formatting
* test_deprecated:
Checks for deprecation tags in our code which may need to be removed
Static Source Code Checking
Not associated with building Blender.
* check_cppcheck: Run blender source through cppcheck (C & C++).
* check_clang_array: Run blender source through clang array checking script (C & C++).
* check_deprecated: Check if there is any deprecated code to remove.
* check_splint: Run blenders source through splint (C only).
* check_sparse: Run blenders source through sparse (C only).
* check_smatch: Run blenders source through smatch (C only).
@@ -73,6 +66,10 @@ Static Source Code Checking
using one of the accepted licenses in 'doc/license/SPDX-license-identifiers.txt'
Append with 'SHOW_HEADERS=1' to show all unique headers
which can be useful for spotting license irregularities.
* check_cmake: Runs our own cmake file checker which detects errors in the cmake file list definitions.
* check_pep8: Checks all Python script are pep8 which are tagged to use the stricter formatting.
* check_mypy: Checks all Python scripts using mypy,
see: source/tools/check_source/check_mypy_config.py scripts which are included.
Spell Checkers
This runs the spell checker from the developer tools repositor.
@@ -400,20 +397,6 @@ package_archive: .FORCE
test: .FORCE
@$(PYTHON) ./build_files/utils/make_test.py "$(BUILD_DIR)"
# run pep8 check check on scripts we distribute.
test_pep8: .FORCE
@$(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
@echo "written: test_pep8.log"
# run some checks on our CMAKE files.
test_cmake: .FORCE
@$(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
@echo "written: test_cmake_consistency.log"
# run deprecation tests, see if we have anything to remove.
test_deprecated: .FORCE
@$(PYTHON) tests/check_deprecated.py
# -----------------------------------------------------------------------------
# Project Files
@@ -491,11 +474,23 @@ check_descriptions: .FORCE
@$(BLENDER_BIN) --background -noaudio --factory-startup --python \
"$(BLENDER_DIR)/source/tools/check_source/check_descriptions.py"
check_deprecated: .FORCE
@PYTHONIOENCODING=utf_8 $(PYTHON) \
source/tools/check_source/check_deprecated.py
check_licenses: .FORCE
@PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_licenses.py" \
"--show-headers=$(SHOW_HEADERS)"
check_pep8: .FORCE
@PYTHONIOENCODING=utf_8 $(PYTHON) \
tests/python/pep8.py
check_cmake: .FORCE
@PYTHONIOENCODING=utf_8 $(PYTHON) \
source/tools/check_source/check_cmake_consistency.py
# -----------------------------------------------------------------------------
# Utilities

View File

@@ -366,7 +366,7 @@ CLANG_FORMAT_VERSION_MEX="14.0"
PYTHON_VERSION="3.10.2"
PYTHON_VERSION_SHORT="3.10"
PYTHON_VERSION_MIN="3.9"
PYTHON_VERSION_MIN="3.10"
PYTHON_VERSION_MEX="3.12"
PYTHON_VERSION_INSTALLED=$PYTHON_VERSION_SHORT
PYTHON_FORCE_BUILD=false

View File

@@ -79,4 +79,6 @@ mark_as_advanced(
unset(_ffmpeg_SEARCH_DIRS)
unset(_ffmpeg_LIBRARIES)
unset(_ffmpeg_INCLUDE_DIR)
# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
# find_path so we don't need to clear it from the cache here.
unset(_ffmpeg_INCLUDE_DIR CACHE)

View File

@@ -72,6 +72,7 @@ FIND_PATH(OSL_SHADER_DIR
/usr/include/OSL/
PATH_SUFFIXES
share/OSL/shaders
shaders
)
# handle the QUIETLY and REQUIRED arguments and set OSL_FOUND to TRUE if
@@ -95,6 +96,7 @@ ENDIF()
MARK_AS_ADVANCED(
OSL_INCLUDE_DIR
OSL_SHADER_DIR
)
FOREACH(COMPONENT ${_osl_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)

View File

@@ -83,12 +83,14 @@ ENDIF()
MARK_AS_ADVANCED(
OPENCOLORIO_INCLUDE_DIR
OPENCOLORIO_LIBRARY
OPENCOLORIO_OPENCOLORIO_LIBRARY
OPENCOLORIO_TINYXML_LIBRARY
OPENCOLORIO_YAML-CPP_LIBRARY
OPENCOLORIO_VERSION
)
FOREACH(COMPONENT ${_opencolorio_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
MARK_AS_ADVANCED(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY)
ENDFOREACH()
UNSET(COMPONENT)
UNSET(UPPERCOMPONENT)
UNSET(_opencolorio_FIND_COMPONENTS)

View File

@@ -29,14 +29,6 @@ ENDIF()
# Old versions (before 2.0?) do not have any version string, just assuming this should be fine though.
SET(_openexr_libs_ver_init "2.0")
SET(_openexr_FIND_COMPONENTS
Half
Iex
IlmImf
IlmThread
Imath
)
SET(_openexr_SEARCH_DIRS
${OPENEXR_ROOT_DIR}
/opt/lib/openexr
@@ -89,6 +81,24 @@ UNSET(_openexr_libs_ver_init)
STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
# Different library names in 3.0, and Imath and Half moved out.
IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
SET(_openexr_FIND_COMPONENTS
Iex
IlmThread
OpenEXR
OpenEXRCore
)
ELSE()
SET(_openexr_FIND_COMPONENTS
Half
Iex
IlmImf
IlmThread
Imath
)
ENDIF()
SET(_openexr_LIBRARIES)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
@@ -107,6 +117,57 @@ ENDFOREACH()
UNSET(_openexr_libs_ver)
IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
# For OpenEXR 3.x, we also need to find the now separate Imath library.
# For simplicity we add it to the OpenEXR includes and libraries, as we
# have no direct dependency on Imath and it's simpler to support both
# 2.x and 3.x this way.
# Find include directory
FIND_PATH(IMATH_INCLUDE_DIR
NAMES
Imath/ImathMath.h
HINTS
${_openexr_SEARCH_DIRS}
PATH_SUFFIXES
include
)
# Find version
FIND_FILE(_imath_config
NAMES
ImathConfig.h
PATHS
${IMATH_INCLUDE_DIR}/Imath
NO_DEFAULT_PATH
)
# Find line with version, extract string, and format for library suffix.
FILE(STRINGS "${_imath_config}" _imath_build_specification
REGEX "^[ \t]*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
STRING(REGEX REPLACE ".*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
"\\1" _imath_libs_ver ${_imath_build_specification})
STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _imath_libs_ver ${_imath_libs_ver})
# Find library, with or without version number.
FIND_LIBRARY(IMATH_LIBRARY
NAMES
Imath-${_imath_libs_ver} Imath
NAMES_PER_DIR
HINTS
${_openexr_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
LIST(APPEND _openexr_LIBRARIES "${IMATH_LIBRARY}")
# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
# FIND_FILE so we don't need to clear it from the cache here.
UNSET(_imath_config CACHE)
UNSET(_imath_libs_ver)
UNSET(_imath_build_specification)
ENDIF()
# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
@@ -115,13 +176,25 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG
IF(OPENEXR_FOUND)
SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES})
# Both include paths are needed because of dummy OSL headers mixing #include <OpenEXR/foo.h> and #include <foo.h> :(
SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR)
# Both include paths are needed because of dummy OSL headers mixing
# #include <OpenEXR/foo.h> and #include <foo.h>, as well as Alembic
# include <half.h> directly.
SET(OPENEXR_INCLUDE_DIRS
${OPENEXR_INCLUDE_DIR}
${OPENEXR_INCLUDE_DIR}/OpenEXR)
IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
LIST(APPEND OPENEXR_INCLUDE_DIRS
${IMATH_INCLUDE_DIR}
${IMATH_INCLUDE_DIR}/Imath)
ENDIF()
ENDIF()
MARK_AS_ADVANCED(
OPENEXR_INCLUDE_DIR
OPENEXR_VERSION
IMATH_INCLUDE_DIR
IMATH_LIBRARY
)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)

View File

@@ -106,6 +106,7 @@ ENDIF()
MARK_AS_ADVANCED(
OPENIMAGEDENOISE_INCLUDE_DIR
OPENIMAGEDENOISE_LIBRARY
)
FOREACH(COMPONENT ${_openimagedenoise_FIND_COMPONENTS})

View File

@@ -44,6 +44,8 @@ FIND_LIBRARY(OPENIMAGEIO_LIBRARY
lib64 lib
)
set(_openimageio_LIBRARIES ${OPENIMAGEIO_LIBRARY})
FIND_FILE(OPENIMAGEIO_IDIFF
NAMES
idiff
@@ -53,14 +55,47 @@ FIND_FILE(OPENIMAGEIO_IDIFF
bin
)
# Additionally find util library if needed. In old versions this library was
# included in libOpenImageIO and linking to both would duplicate symbols. In
# new versions we need to link to both.
FIND_FILE(_openimageio_export
NAMES
export.h
PATHS
${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO
NO_DEFAULT_PATH
)
# Use existence of OIIO_UTIL_API to check if it's a separate lib.
FILE(STRINGS "${_openimageio_export}" _openimageio_util_define
REGEX "^[ \t]*#[ \t]*define[ \t]+OIIO_UTIL_API.*$")
IF(_openimageio_util_define)
FIND_LIBRARY(OPENIMAGEIO_UTIL_LIBRARY
NAMES
OpenImageIO_Util
HINTS
${_openimageio_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
LIST(APPEND _openimageio_LIBRARIES ${OPENIMAGEIO_UTIL_LIBRARY})
ENDIF()
# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
# FIND_FILE so we don't need to clear it from the cache here.
UNSET(_openimageio_export CACHE)
UNSET(_openimageio_util_define)
# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
_openimageio_LIBRARIES OPENIMAGEIO_INCLUDE_DIR)
IF(OPENIMAGEIO_FOUND)
SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
SET(OPENIMAGEIO_LIBRARIES ${_openimageio_LIBRARIES})
SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
IF(EXISTS ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/pugixml.hpp)
SET(OPENIMAGEIO_PUGIXML_FOUND TRUE)
@@ -74,7 +109,9 @@ ENDIF()
MARK_AS_ADVANCED(
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARY
OPENIMAGEIO_UTIL_LIBRARY
OPENIMAGEIO_IDIFF
)
UNSET(_openimageio_SEARCH_DIRS)
UNSET(_openimageio_LIBRARIES)

View File

@@ -1,387 +0,0 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# <pep8 compliant>
# Note: this code should be cleaned up / refactored.
import sys
if sys.version_info.major < 3:
print("\nPython3.x needed, found %s.\nAborting!\n" %
sys.version.partition(" ")[0])
sys.exit(1)
import os
from os.path import (
dirname,
join,
normpath,
splitext,
)
from cmake_consistency_check_config import (
IGNORE_SOURCE,
IGNORE_SOURCE_MISSING,
IGNORE_CMAKE,
UTF8_CHECK,
SOURCE_DIR,
BUILD_DIR,
)
from typing import (
Callable,
Dict,
Generator,
Iterator,
List,
Optional,
Tuple,
)
global_h = set()
global_c = set()
global_refs: Dict[str, List[Tuple[str, int]]] = {}
# Flatten `IGNORE_SOURCE_MISSING` to avoid nested looping.
IGNORE_SOURCE_MISSING_FLAT = [
(k, ignore_path) for k, ig_list in IGNORE_SOURCE_MISSING
for ignore_path in ig_list
]
# Ignore cmake file, path pairs.
global_ignore_source_missing: Dict[str, List[str]] = {}
for k, v in IGNORE_SOURCE_MISSING_FLAT:
global_ignore_source_missing.setdefault(k, []).append(v)
del IGNORE_SOURCE_MISSING_FLAT
def replace_line(f: str, i: int, text: str, keep_indent: bool = True) -> None:
file_handle = open(f, 'r')
data = file_handle.readlines()
file_handle.close()
l = data[i]
ws = l[:len(l) - len(l.lstrip())]
data[i] = "%s%s\n" % (ws, text)
file_handle = open(f, 'w')
file_handle.writelines(data)
file_handle.close()
def source_list(
path: str,
filename_check: Optional[Callable[[str], bool]] = None,
) -> Generator[str, None, None]:
for dirpath, dirnames, filenames in os.walk(path):
# skip '.git'
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
for filename in filenames:
if filename_check is None or filename_check(filename):
yield os.path.join(dirpath, filename)
# extension checking
def is_cmake(filename: str) -> bool:
ext = splitext(filename)[1]
return (ext == ".cmake") or (filename == "CMakeLists.txt")
def is_c_header(filename: str) -> bool:
ext = splitext(filename)[1]
return (ext in {".h", ".hpp", ".hxx", ".hh"})
def is_c(filename: str) -> bool:
ext = splitext(filename)[1]
return (ext in {".c", ".cpp", ".cxx", ".m", ".mm", ".rc", ".cc", ".inl", ".metal"})
def is_c_any(filename: str) -> bool:
return is_c(filename) or is_c_header(filename)
def cmake_get_src(f: str) -> None:
sources_h = []
sources_c = []
filen = open(f, "r", encoding="utf8")
it: Optional[Iterator[str]] = iter(filen)
found = False
i = 0
# print(f)
def is_definition(l: str, f: str, i: int, name: str) -> bool:
if l.startswith("unset("):
return False
if ('set(%s' % name) in l or ('set(' in l and l.endswith(name)):
if len(l.split()) > 1:
raise Exception("strict formatting not kept 'set(%s*' %s:%d" % (name, f, i))
return True
if ("list(APPEND %s" % name) in l or ('list(APPEND ' in l and l.endswith(name)):
if l.endswith(")"):
raise Exception("strict formatting not kept 'list(APPEND %s...)' on 1 line %s:%d" % (name, f, i))
return True
return False
while it is not None:
context_name = ""
while it is not None:
i += 1
try:
l = next(it)
except StopIteration:
it = None
break
l = l.strip()
if not l.startswith("#"):
found = is_definition(l, f, i, "SRC")
if found:
context_name = "SRC"
break
found = is_definition(l, f, i, "INC")
if found:
context_name = "INC"
break
if found:
cmake_base = dirname(f)
cmake_base_bin = os.path.join(BUILD_DIR, os.path.relpath(cmake_base, SOURCE_DIR))
# Find known missing sources list (if we have one).
f_rel = os.path.relpath(f, SOURCE_DIR)
f_rel_key = f_rel
if os.sep != "/":
f_rel_key = f_rel_key.replace(os.sep, "/")
local_ignore_source_missing = global_ignore_source_missing.get(f_rel_key, [])
while it is not None:
i += 1
try:
l = next(it)
except StopIteration:
it = None
break
l = l.strip()
if not l.startswith("#"):
# Remove in-line comments.
l = l.split(" # ")[0].rstrip()
if ")" in l:
if l.strip() != ")":
raise Exception("strict formatting not kept '*)' %s:%d" % (f, i))
break
# replace dirs
l = l.replace("${CMAKE_SOURCE_DIR}", SOURCE_DIR)
l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
l = l.replace("${CMAKE_CURRENT_BINARY_DIR}", cmake_base_bin)
l = l.strip('"')
if not l:
pass
elif l in local_ignore_source_missing:
local_ignore_source_missing.remove(l)
elif l.startswith("$"):
if context_name == "SRC":
# assume if it ends with context_name we know about it
if not l.split("}")[0].endswith(context_name):
print("Can't use var '%s' %s:%d" % (l, f, i))
elif len(l.split()) > 1:
raise Exception("Multi-line define '%s' %s:%d" % (l, f, i))
else:
new_file = normpath(join(cmake_base, l))
if context_name == "SRC":
if is_c_header(new_file):
sources_h.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif is_c(new_file):
sources_c.append(new_file)
global_refs.setdefault(new_file, []).append((f, i))
elif l in {"PARENT_SCOPE", }:
# cmake var, ignore
pass
elif new_file.endswith(".list"):
pass
elif new_file.endswith(".def"):
pass
elif new_file.endswith(".cl"): # opencl
pass
elif new_file.endswith(".cu"): # cuda
pass
elif new_file.endswith(".osl"): # open shading language
pass
elif new_file.endswith(".glsl"):
pass
else:
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
elif context_name == "INC":
if new_file.startswith(BUILD_DIR):
# assume generated path
pass
elif os.path.isdir(new_file):
new_path_rel = os.path.relpath(new_file, cmake_base)
if new_path_rel != l:
print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel))
# # Save time. just replace the line
# replace_line(f, i - 1, new_path_rel)
else:
raise Exception("non existent include %s:%d -> %s" % (f, i, new_file))
# print(new_file)
global_h.update(set(sources_h))
global_c.update(set(sources_c))
'''
if not sources_h and not sources_c:
raise Exception("No sources %s" % f)
sources_h_fs = list(source_list(cmake_base, is_c_header))
sources_c_fs = list(source_list(cmake_base, is_c))
'''
# find missing C files:
'''
for ff in sources_c_fs:
if ff not in sources_c:
print(" missing: " + ff)
'''
# reset
del sources_h[:]
del sources_c[:]
filen.close()
def is_ignore_source(f: str, ignore_used: List[bool]) -> bool:
for index, ignore_path in enumerate(IGNORE_SOURCE):
if ignore_path in f:
ignore_used[index] = True
return True
return False
def is_ignore_cmake(f: str, ignore_used: List[bool]) -> bool:
for index, ignore_path in enumerate(IGNORE_CMAKE):
if ignore_path in f:
ignore_used[index] = True
return True
return False
def main() -> None:
print("Scanning:", SOURCE_DIR)
ignore_used_source = [False] * len(IGNORE_SOURCE)
ignore_used_cmake = [False] * len(IGNORE_CMAKE)
for cmake in source_list(SOURCE_DIR, is_cmake):
if not is_ignore_cmake(cmake, ignore_used_cmake):
cmake_get_src(cmake)
# First do stupid check, do these files exist?
print("\nChecking for missing references:")
is_err = False
errs = []
for f in (global_h | global_c):
if f.startswith(BUILD_DIR):
continue
if not os.path.exists(f):
refs = global_refs[f]
if refs:
for cf, i in refs:
errs.append((cf, i))
else:
raise Exception("CMake references missing, internal error, aborting!")
is_err = True
errs.sort()
errs.reverse()
for cf, i in errs:
print("%s:%d" % (cf, i))
# Write a 'sed' script, useful if we get a lot of these
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
if is_err:
raise Exception("CMake references missing files, aborting!")
del is_err
del errs
# now check on files not accounted for.
print("\nC/C++ Files CMake does not know about...")
for cf in sorted(source_list(SOURCE_DIR, is_c)):
if not is_ignore_source(cf, ignore_used_source):
if cf not in global_c:
print("missing_c: ", cf)
# Check if automake builds a corresponding .o file.
'''
if cf in global_c:
out1 = os.path.splitext(cf)[0] + ".o"
out2 = os.path.splitext(cf)[0] + ".Po"
out2_dir, out2_file = out2 = os.path.split(out2)
out2 = os.path.join(out2_dir, ".deps", out2_file)
if not os.path.exists(out1) and not os.path.exists(out2):
print("bad_c: ", cf)
'''
print("\nC/C++ Headers CMake does not know about...")
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
if not is_ignore_source(hf, ignore_used_source):
if hf not in global_h:
print("missing_h: ", hf)
if UTF8_CHECK:
# test encoding
import traceback
for files in (global_c, global_h):
for f in sorted(files):
if os.path.exists(f):
# ignore outside of our source tree
if "extern" not in f:
i = 1
try:
for _ in open(f, "r", encoding="utf8"):
i += 1
except UnicodeDecodeError:
print("Non utf8: %s:%d" % (f, i))
if i > 1:
traceback.print_exc()
# Check ignores aren't stale
print("\nCheck for unused 'IGNORE_SOURCE' paths...")
for index, ignore_path in enumerate(IGNORE_SOURCE):
if not ignore_used_source[index]:
print("unused ignore: %r" % ignore_path)
# Check ignores aren't stale
print("\nCheck for unused 'IGNORE_SOURCE_MISSING' paths...")
for k, v in sorted(global_ignore_source_missing.items()):
for ignore_path in v:
print("unused ignore: %r -> %r" % (ignore_path, k))
# Check ignores aren't stale
print("\nCheck for unused 'IGNORE_CMAKE' paths...")
for index, ignore_path in enumerate(IGNORE_CMAKE):
if not ignore_used_cmake[index]:
print("unused ignore: %r" % ignore_path)
if __name__ == "__main__":
main()

View File

@@ -1,64 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import os
IGNORE_SOURCE = (
"/test/",
"/tests/gtests/",
"/release/",
# specific source files
"extern/audaspace/",
# Use for `WIN32` only.
"source/creator/blender_launcher_win32.c",
# specific source files
"extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp",
"extern/bullet2/src/BulletCollision/CollisionShapes/btBox2dShape.cpp",
"extern/bullet2/src/BulletCollision/CollisionShapes/btConvex2dShape.cpp",
"extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.cpp",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp",
"doc/doxygen/doxygen.extern.h",
"doc/doxygen/doxygen.intern.h",
"doc/doxygen/doxygen.main.h",
"doc/doxygen/doxygen.source.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h",
"extern/bullet2/src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.h",
"extern/bullet2/src/BulletCollision/CollisionShapes/btBox2dShape.h",
"extern/bullet2/src/BulletCollision/CollisionShapes/btConvex2dShape.h",
"extern/bullet2/src/BulletDynamics/Character/btKinematicCharacterController.h",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btHinge2Constraint.h",
"extern/bullet2/src/BulletDynamics/ConstraintSolver/btUniversalConstraint.h",
)
# Ignore cmake file, path pairs.
IGNORE_SOURCE_MISSING = (
( # Use for cycles stand-alone.
"intern/cycles/util/CMakeLists.txt", (
"../../third_party/numaapi/include",
)),
( # Use for `WITH_NANOVDB`.
"intern/cycles/kernel/CMakeLists.txt", (
"nanovdb/util/CSampleFromVoxels.h",
"nanovdb/util/SampleFromVoxels.h",
"nanovdb/NanoVDB.h",
"nanovdb/CNanoVDB.h",
),
),
)
IGNORE_CMAKE = (
"extern/audaspace/CMakeLists.txt",
)
UTF8_CHECK = True
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))
# doesn't have to exist, just use as reference
BUILD_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(SOURCE_DIR, "..", "build"))))

View File

@@ -345,6 +345,7 @@ if(WITH_BOOST)
find_package(IcuLinux)
endif()
mark_as_advanced(Boost_DIR) # why doesn't boost do this?
mark_as_advanced(Boost_INCLUDE_DIR) # why doesn't boost do this?
endif()
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
@@ -848,3 +849,45 @@ if(WITH_COMPILER_CCACHE)
set(WITH_COMPILER_CCACHE OFF)
endif()
endif()
# On some platforms certain atomic operations are not possible with assembly and/or intrinsics and
# they are emulated in software with locks. For example, on armel there is no intrinsics to grant
# 64 bit atomic operations and STL library uses libatomic to offload software emulation of atomics
# to.
# This function will check whether libatomic is required and if so will configure linker flags.
# If atomic operations are possible without libatomic then linker flags are left as-is.
function(CONFIGURE_ATOMIC_LIB_IF_NEEDED)
# Source which is used to enforce situation when software emulation of atomics is required.
# Assume that using 64bit integer gives a definitive answer (as in, if 64bit atomic operations
# are possible using assembly/intrinsics 8, 16, and 32 bit operations will also be possible.
set(_source
"#include <atomic>
#include <cstdint>
int main(int argc, char **argv) {
std::atomic<uint64_t> uint64; uint64++;
return 0;
}")
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITHOUT_LIBATOMIC)
if(NOT ATOMIC_OPS_WITHOUT_LIBATOMIC)
# Compilation of the test program has failed.
# Try it again with -latomic to see if this is what is needed, or whether something else is
# going on.
set(CMAKE_REQUIRED_LIBRARIES atomic)
check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITH_LIBATOMIC)
if(ATOMIC_OPS_WITH_LIBATOMIC)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -latomic" PARENT_SCOPE)
else()
# Atomic operations are required part of Blender and it is not possible to process forward.
# We expect that either standard library or libatomic will make atomics to work. If both
# cases has failed something fishy o na bigger scope is going on.
message(FATAL_ERROR "Failed to detect required configuration for atomic operations")
endif()
endif()
endfunction()
CONFIGURE_ATOMIC_LIB_IF_NEEDED()

View File

@@ -5,7 +5,7 @@ for %%X in (ctest.exe) do (set CTEST=%%~$PATH:X)
for %%X in (git.exe) do (set GIT=%%~$PATH:X)
REM For python, default on 39 but if that does not exist also check
REM the 310,311 and 312 folders to see if those are there, it checks
REM this far ahead to ensure good lib folder compatiblity in the future.
REM this far ahead to ensure good lib folder compatibility in the future.
set PYTHON=%BLENDER_DIR%\..\lib\win64_vc15\python\39\bin\python.exe
if EXIST %PYTHON% (
goto detect_python_done

View File

@@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -5,5 +5,6 @@ BSD-2-Clause BSD-2-Clause-license.txt https://spdx.org/licenses/BS
BSD-3-Clause BSD-3-Clause-license.txt https://spdx.org/licenses/BSD-3-Clause.html
GPL-2.0-or-later GPL-license.txt https://spdx.org/licenses/GPL-2.0-or-later.html
GPL-3.0-or-later GPL3-license.txt https://spdx.org/licenses/GPL-3.0-or-later.html
LGPL-2.1-or-later LGPL2.1-license.txt https://spdx.org/licenses/LGPL-2.1-or-later.html
MIT MIT-license.txt https://spdx.org/licenses/MIT.html
Zlib Zlib-license.txt https://spdx.org/licenses/Zlib.html

View File

@@ -16,7 +16,6 @@ and <output-filename> is where to write the generated man page.
import argparse
import os
import subprocess
import sys
import time
from typing import (

View File

@@ -1,5 +1,6 @@
/* Override RTD theme */
.rst-versions {
display: none;
border-top: 0px;
overflow: visible;
}

View File

@@ -177,7 +177,7 @@ void FFMPEGReader::init(int stream)
// get a decoder and open it
#ifndef FFMPEG_OLD_CODE
AVCodec* aCodec = avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
const AVCodec* aCodec = avcodec_find_decoder(m_formatCtx->streams[m_stream]->codecpar->codec_id);
if(!aCodec)
AUD_THROW(FileException, "File couldn't be read, no decoder found with ffmpeg.");

View File

@@ -23,6 +23,7 @@
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avio.h>
#include <libavutil/channel_layout.h>
}
AUD_NAMESPACE_BEGIN
@@ -171,66 +172,66 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
if(avformat_alloc_output_context2(&m_formatCtx, nullptr, formats[format], filename.c_str()) < 0)
AUD_THROW(FileException, "File couldn't be written, format couldn't be found with ffmpeg.");
AVOutputFormat* outputFmt = m_formatCtx->oformat;
const AVOutputFormat* outputFmt = m_formatCtx->oformat;
if(!outputFmt) {
avformat_free_context(m_formatCtx);
AUD_THROW(FileException, "File couldn't be written, output format couldn't be found with ffmpeg.");
}
outputFmt->audio_codec = AV_CODEC_ID_NONE;
AVCodecID audio_codec = AV_CODEC_ID_NONE;
switch(codec)
{
case CODEC_AAC:
outputFmt->audio_codec = AV_CODEC_ID_AAC;
audio_codec = AV_CODEC_ID_AAC;
break;
case CODEC_AC3:
outputFmt->audio_codec = AV_CODEC_ID_AC3;
audio_codec = AV_CODEC_ID_AC3;
break;
case CODEC_FLAC:
outputFmt->audio_codec = AV_CODEC_ID_FLAC;
audio_codec = AV_CODEC_ID_FLAC;
break;
case CODEC_MP2:
outputFmt->audio_codec = AV_CODEC_ID_MP2;
audio_codec = AV_CODEC_ID_MP2;
break;
case CODEC_MP3:
outputFmt->audio_codec = AV_CODEC_ID_MP3;
audio_codec = AV_CODEC_ID_MP3;
break;
case CODEC_OPUS:
outputFmt->audio_codec = AV_CODEC_ID_OPUS;
audio_codec = AV_CODEC_ID_OPUS;
break;
case CODEC_PCM:
switch(specs.format)
{
case FORMAT_U8:
outputFmt->audio_codec = AV_CODEC_ID_PCM_U8;
audio_codec = AV_CODEC_ID_PCM_U8;
break;
case FORMAT_S16:
outputFmt->audio_codec = AV_CODEC_ID_PCM_S16LE;
audio_codec = AV_CODEC_ID_PCM_S16LE;
break;
case FORMAT_S24:
outputFmt->audio_codec = AV_CODEC_ID_PCM_S24LE;
audio_codec = AV_CODEC_ID_PCM_S24LE;
break;
case FORMAT_S32:
outputFmt->audio_codec = AV_CODEC_ID_PCM_S32LE;
audio_codec = AV_CODEC_ID_PCM_S32LE;
break;
case FORMAT_FLOAT32:
outputFmt->audio_codec = AV_CODEC_ID_PCM_F32LE;
audio_codec = AV_CODEC_ID_PCM_F32LE;
break;
case FORMAT_FLOAT64:
outputFmt->audio_codec = AV_CODEC_ID_PCM_F64LE;
audio_codec = AV_CODEC_ID_PCM_F64LE;
break;
default:
outputFmt->audio_codec = AV_CODEC_ID_NONE;
audio_codec = AV_CODEC_ID_NONE;
break;
}
break;
case CODEC_VORBIS:
outputFmt->audio_codec = AV_CODEC_ID_VORBIS;
audio_codec = AV_CODEC_ID_VORBIS;
break;
default:
outputFmt->audio_codec = AV_CODEC_ID_NONE;
audio_codec = AV_CODEC_ID_NONE;
break;
}
@@ -268,10 +269,10 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo
try
{
if(outputFmt->audio_codec == AV_CODEC_ID_NONE)
if(audio_codec == AV_CODEC_ID_NONE)
AUD_THROW(FileException, "File couldn't be written, audio codec not found with ffmpeg.");
AVCodec* codec = avcodec_find_encoder(outputFmt->audio_codec);
const AVCodec* codec = avcodec_find_encoder(audio_codec);
if(!codec)
AUD_THROW(FileException, "File couldn't be written, audio encoder couldn't be found with ffmpeg.");

View File

@@ -423,6 +423,7 @@ TEST(atomic, atomic_fetch_and_and_uint32)
/** \} */
/* -------------------------------------------------------------------- */
/** \name 32 bit signed int atomics
* \{ */
@@ -559,6 +560,7 @@ TEST(atomic, atomic_fetch_and_and_int32)
/** \} */
/* -------------------------------------------------------------------- */
/** \name 16 bit signed int atomics
* \{ */
@@ -592,6 +594,9 @@ TEST(atomic, atomic_fetch_and_and_int16)
}
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name 8 bit unsigned int atomics
* \{ */
@@ -638,6 +643,7 @@ TEST(atomic, atomic_fetch_and_and_int8)
/** \} */
/* -------------------------------------------------------------------- */
/** \name char aliases
* \{ */
@@ -661,6 +667,7 @@ TEST(atomic, atomic_fetch_and_and_char)
/** \} */
/* -------------------------------------------------------------------- */
/** \name size_t aliases
* \{ */
@@ -772,6 +779,7 @@ TEST(atomic, atomic_fetch_and_update_max_z)
/** \} */
/* -------------------------------------------------------------------- */
/** \name unsigned int aliases
* \{ */
@@ -867,6 +875,7 @@ TEST(atomic, atomic_cas_u)
/** \} */
/* -------------------------------------------------------------------- */
/** \name pointer aliases
* \{ */
@@ -885,6 +894,7 @@ TEST(atomic, atomic_cas_ptr)
/** \} */
/* -------------------------------------------------------------------- */
/** \name floating point atomics
* \{ */

View File

@@ -34,8 +34,14 @@ endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
add_definitions(${GL_DEFINITIONS})
list(APPEND INC_SYS ${GLEW_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
list(APPEND LIBRARIES ${CYCLES_GL_LIBRARIES} ${SDL2_LIBRARIES})
list(APPEND INC_SYS
${GLEW_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
)
list(APPEND LIBRARIES
${CYCLES_GL_LIBRARIES}
${SDL2_LIBRARIES}
)
endif()
# Common configuration.

View File

@@ -75,7 +75,7 @@ bool OpenGLDisplayDriver::update_begin(const Params &params, int texture_width,
/* Update PBO dimensions if needed.
*
* NOTE: Allocate the PBO for the the size which will fit the final render resolution (as in,
* NOTE: Allocate the PBO for the size which will fit the final render resolution (as in,
* at a resolution divider 1. This was we don't need to recreate graphics interoperability
* objects which are costly and which are tied to the specific underlying buffer size.
* The downside of this approach is that when graphics interoperability is not used we are

View File

@@ -216,7 +216,6 @@ enum_direct_light_sampling_type = (
)
def update_render_passes(self, context):
scene = context.scene
view_layer = context.view_layer
view_layer.update_render_passes()
@@ -349,8 +348,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
scrambling_distance: FloatProperty(
name="Scrambling Distance",
default=1.0,
min=0.0, max=1.0,
description="Reduce randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts if set too low. Only works when not using adaptive sampling",
min=0.0, soft_max=1.0,
description="Reduce randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts if set too low",
)
preview_scrambling_distance: BoolProperty(
name="Scrambling Distance viewport",
@@ -361,7 +360,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
auto_scrambling_distance: BoolProperty(
name="Automatic Scrambling Distance",
default=False,
description="Automatically reduce the randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts. Only works when not using adaptive sampling",
description="Automatically reduce the randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts",
)
use_layer_samples: EnumProperty(
@@ -1353,7 +1352,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
items=CyclesPreferences.get_device_types,
)
devices: bpy.props.CollectionProperty(type=CyclesDeviceSettings)
devices: CollectionProperty(type=CyclesDeviceSettings)
peer_memory: BoolProperty(
name="Distribute memory across devices",
@@ -1514,9 +1513,12 @@ class CyclesPreferences(bpy.types.AddonPreferences):
row.prop(self, "peer_memory")
if compute_device_type == 'METAL':
row = layout.row()
row.use_property_split = True
row.prop(self, "use_metalrt")
import platform
# MetalRT only works on Apple Silicon at present, pending argument encoding fixes on AMD
if platform.machine() == 'arm64':
row = layout.row()
row.use_property_split = True
row.prop(self, "use_metalrt")
def draw(self, context):

View File

@@ -11,6 +11,7 @@ from bl_ui.utils import PresetPanel
from bpy.types import Panel
from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel
from bl_ui.properties_render import draw_hair_settings
from bl_ui.properties_view_layer import ViewLayerCryptomattePanel, ViewLayerAOVPanel
class CyclesPresetPanel(PresetPanel, Panel):
@@ -288,11 +289,8 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
layout.separator()
heading = layout.column(align=True, heading="Scrambling Distance")
heading.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
heading.prop(cscene, "auto_scrambling_distance", text="Automatic")
sub = heading.row()
sub.active = not cscene.use_preview_adaptive_sampling
sub.prop(cscene, "preview_scrambling_distance", text="Viewport")
heading.prop(cscene, "preview_scrambling_distance", text="Viewport")
heading.prop(cscene, "scrambling_distance", text="Multiplier")
layout.separator()
@@ -355,6 +353,13 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
if ccscene.shape == 'RIBBONS':
col.prop(ccscene, "subdivisions", text="Curve Subdivisions")
class CYCLES_RENDER_PT_hair_viewport_display(CyclesButtonsPanel, Panel):
bl_label = "Viewport Display"
bl_parent_id = "CYCLES_RENDER_PT_hair"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
draw_hair_settings(self, context)
class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
bl_label = "Volumes"
@@ -1023,7 +1028,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
if CyclesButtonsPanel.poll(context) and ob:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'HAIR', 'POINTCLOUD'}:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'CURVES', 'POINTCLOUD'}:
return True
if ob.instance_type == 'COLLECTION' and ob.instance_collection:
return True
@@ -1062,7 +1067,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
def has_geometry_visibility(ob):
return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT', 'VOLUME', 'POINTCLOUD', 'HAIR'}) or
return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT', 'VOLUME', 'POINTCLOUD', 'CURVES'}) or
(ob.instance_type == 'COLLECTION' and ob.instance_collection))
@@ -2153,6 +2158,7 @@ classes = (
CYCLES_RENDER_PT_volumes,
CYCLES_RENDER_PT_subdivision,
CYCLES_RENDER_PT_hair,
CYCLES_RENDER_PT_hair_viewport_display,
CYCLES_RENDER_PT_simplify,
CYCLES_RENDER_PT_simplify_viewport,
CYCLES_RENDER_PT_simplify_render,

View File

@@ -5,7 +5,6 @@
from __future__ import annotations
import bpy
import math
from bpy.app.handlers import persistent

View File

@@ -319,7 +319,9 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
(object->get_geometry() && object->get_geometry()->is_modified())) {
object->name = b_ob.name().c_str();
object->set_pass_id(b_ob.pass_index());
object->set_color(get_float3(b_ob.color()));
const BL::Array<float, 4> object_color = b_ob.color();
object->set_color(get_float3(object_color));
object->set_alpha(object_color[3]);
object->set_tfm(tfm);
/* dupli texture coordinates and random_id */

View File

@@ -493,8 +493,13 @@ void BlenderSession::render_frame_finish()
session->set_output_driver(nullptr);
session->full_buffer_written_cb = function_null;
/* The display driver holds OpenGL resources which belong to an OpenGL context held by the render
* engine on Blender side. Force destruction of those resources. */
/* The display driver is the source of drawing context for both drawing and possible graphics
* interop objects in the path trace. Once the frame is finished the OpenGL context might be
* freed form Blender side. Need to ensure that all GPU resources are freed prior to that
* point.
* Ideally would only do this when OpenGL context is actually destroyed, but there is no way to
* know when this happens (at least in the code at the time when this comment was written).
* The penalty of re-creating resources on every frame is unlikely to be noticed. */
display_driver_ = nullptr;
session->set_display_driver(nullptr);

View File

@@ -32,7 +32,8 @@ typedef map<string, ConvertNode *> ProxyMap;
void BlenderSync::find_shader(BL::ID &id, array<Node *> &used_shaders, Shader *default_shader)
{
Shader *shader = (id) ? shader_map.find(id) : default_shader;
Shader *synced_shader = (id) ? shader_map.find(id) : nullptr;
Shader *shader = (synced_shader) ? synced_shader : default_shader;
used_shaders.push_back_slow(shader);
shader->tag_used(scene);
@@ -1573,18 +1574,13 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all)
}
}
void BlenderSync::sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
void BlenderSync::sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all)
{
/* for auto refresh images */
ImageManager *image_manager = scene->image_manager;
const int frame = b_scene.frame_current();
const bool auto_refresh_update = image_manager->set_animation_frame_update(frame);
shader_map.pre_sync();
sync_world(b_depsgraph, b_v3d, auto_refresh_update);
sync_lights(b_depsgraph, auto_refresh_update);
sync_materials(b_depsgraph, auto_refresh_update);
sync_world(b_depsgraph, b_v3d, update_all);
sync_lights(b_depsgraph, update_all);
sync_materials(b_depsgraph, update_all);
}
CCL_NAMESPACE_END

View File

@@ -246,7 +246,12 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
int height,
void **python_thread_state)
{
if (!has_updates_) {
/* For auto refresh images. */
ImageManager *image_manager = scene->image_manager;
const int frame = b_scene.frame_current();
const bool auto_refresh_update = image_manager->set_animation_frame_update(frame);
if (!has_updates_ && !auto_refresh_update) {
return;
}
@@ -261,7 +266,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
sync_view_layer(b_view_layer);
sync_integrator(b_view_layer, background);
sync_film(b_view_layer, b_v3d);
sync_shaders(b_depsgraph, b_v3d);
sync_shaders(b_depsgraph, b_v3d, auto_refresh_update);
sync_images();
geometry_synced.clear(); /* use for objects and motion sync */
@@ -341,31 +346,48 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
integrator->set_sampling_pattern(sampling_pattern);
int samples = 1;
bool use_adaptive_sampling = false;
if (preview) {
samples = get_int(cscene, "preview_samples");
use_adaptive_sampling = RNA_boolean_get(&cscene, "use_preview_adaptive_sampling");
integrator->set_use_adaptive_sampling(use_adaptive_sampling);
integrator->set_adaptive_threshold(get_float(cscene, "preview_adaptive_threshold"));
integrator->set_adaptive_min_samples(get_int(cscene, "preview_adaptive_min_samples"));
}
else {
samples = get_int(cscene, "samples");
use_adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
integrator->set_use_adaptive_sampling(use_adaptive_sampling);
integrator->set_adaptive_threshold(get_float(cscene, "adaptive_threshold"));
integrator->set_adaptive_min_samples(get_int(cscene, "adaptive_min_samples"));
}
int samples = get_int(cscene, "samples");
float scrambling_distance = get_float(cscene, "scrambling_distance");
bool auto_scrambling_distance = get_boolean(cscene, "auto_scrambling_distance");
if (auto_scrambling_distance) {
if (samples == 0) {
/* If samples is 0, then viewport rendering is set to render infinitely. In that case we
* override the samples value with 4096 so the Automatic Scrambling Distance algorithm
* picks a Scrambling Distance value with a good balance of performance and correlation
* artifacts when rendering to high sample counts. */
samples = 4096;
}
if (use_adaptive_sampling) {
/* If Adaptive Sampling is enabled, use "min_samples" in the Automatic Scrambling Distance
* algorithm to avoid artifacts common with Adaptive Sampling + Scrambling Distance. */
const AdaptiveSampling adaptive_sampling = integrator->get_adaptive_sampling();
samples = min(samples, adaptive_sampling.min_samples);
}
scrambling_distance *= 4.0f / sqrtf(samples);
}
/* only use scrambling distance in the viewport if user wants to and disable with AS */
/* 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) || use_adaptive_sampling)
if (preview && !preview_scrambling_distance) {
scrambling_distance = 1.0f;
}
if (scrambling_distance != 1.0f) {
VLOG(3) << "Using scrambling distance: " << scrambling_distance;

View File

@@ -114,7 +114,7 @@ class BlenderSync {
/* Shader */
array<Node *> find_used_shaders(BL::Object &b_ob);
void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
void sync_nodes(Shader *shader, BL::ShaderNodeTree &b_ntree);
/* Object */

View File

@@ -191,7 +191,7 @@ device_ptr CPUDevice::mem_alloc_sub_ptr(device_memory &mem, size_t offset, size_
void CPUDevice::const_copy_to(const char *name, void *host, size_t size)
{
#if WITH_EMBREE
#ifdef WITH_EMBREE
if (strcmp(name, "__data") == 0) {
assert(size <= sizeof(KernelData));

View File

@@ -77,11 +77,11 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
}
case METAL_GPU_APPLE: {
max_threads_per_threadgroup = 512;
use_metalrt = info.use_metalrt;
break;
}
}
use_metalrt = info.use_metalrt;
if (auto metalrt = getenv("CYCLES_METALRT")) {
use_metalrt = (atoi(metalrt) != 0);
}

View File

@@ -33,6 +33,191 @@
CCL_NAMESPACE_BEGIN
// A minimal copy of functionality `optix_denoiser_tiling.h` which allows to fix integer overflow
// issues without bumping SDK or driver requirement.
//
// The original code is Copyright NVIDIA Corporation, BSD-3-Clause.
namespace {
static OptixResult optixUtilDenoiserSplitImage(const OptixImage2D &input,
const OptixImage2D &output,
unsigned int overlapWindowSizeInPixels,
unsigned int tileWidth,
unsigned int tileHeight,
std::vector<OptixUtilDenoiserImageTile> &tiles)
{
if (tileWidth == 0 || tileHeight == 0)
return OPTIX_ERROR_INVALID_VALUE;
unsigned int inPixelStride = optixUtilGetPixelStride(input);
unsigned int outPixelStride = optixUtilGetPixelStride(output);
int inp_w = std::min(tileWidth + 2 * overlapWindowSizeInPixels, input.width);
int inp_h = std::min(tileHeight + 2 * overlapWindowSizeInPixels, input.height);
int inp_y = 0, copied_y = 0;
do {
int inputOffsetY = inp_y == 0 ? 0 :
std::max((int)overlapWindowSizeInPixels,
inp_h - ((int)input.height - inp_y));
int copy_y = inp_y == 0 ? std::min(input.height, tileHeight + overlapWindowSizeInPixels) :
std::min(tileHeight, input.height - copied_y);
int inp_x = 0, copied_x = 0;
do {
int inputOffsetX = inp_x == 0 ? 0 :
std::max((int)overlapWindowSizeInPixels,
inp_w - ((int)input.width - inp_x));
int copy_x = inp_x == 0 ? std::min(input.width, tileWidth + overlapWindowSizeInPixels) :
std::min(tileWidth, input.width - copied_x);
OptixUtilDenoiserImageTile tile;
tile.input.data = input.data + (size_t)(inp_y - inputOffsetY) * input.rowStrideInBytes +
+(size_t)(inp_x - inputOffsetX) * inPixelStride;
tile.input.width = inp_w;
tile.input.height = inp_h;
tile.input.rowStrideInBytes = input.rowStrideInBytes;
tile.input.pixelStrideInBytes = input.pixelStrideInBytes;
tile.input.format = input.format;
tile.output.data = output.data + (size_t)inp_y * output.rowStrideInBytes +
(size_t)inp_x * outPixelStride;
tile.output.width = copy_x;
tile.output.height = copy_y;
tile.output.rowStrideInBytes = output.rowStrideInBytes;
tile.output.pixelStrideInBytes = output.pixelStrideInBytes;
tile.output.format = output.format;
tile.inputOffsetX = inputOffsetX;
tile.inputOffsetY = inputOffsetY;
tiles.push_back(tile);
inp_x += inp_x == 0 ? tileWidth + overlapWindowSizeInPixels : tileWidth;
copied_x += copy_x;
} while (inp_x < static_cast<int>(input.width));
inp_y += inp_y == 0 ? tileHeight + overlapWindowSizeInPixels : tileHeight;
copied_y += copy_y;
} while (inp_y < static_cast<int>(input.height));
return OPTIX_SUCCESS;
}
static OptixResult optixUtilDenoiserInvokeTiled(OptixDenoiser denoiser,
CUstream stream,
const OptixDenoiserParams *params,
CUdeviceptr denoiserState,
size_t denoiserStateSizeInBytes,
const OptixDenoiserGuideLayer *guideLayer,
const OptixDenoiserLayer *layers,
unsigned int numLayers,
CUdeviceptr scratch,
size_t scratchSizeInBytes,
unsigned int overlapWindowSizeInPixels,
unsigned int tileWidth,
unsigned int tileHeight)
{
if (!guideLayer || !layers)
return OPTIX_ERROR_INVALID_VALUE;
std::vector<std::vector<OptixUtilDenoiserImageTile>> tiles(numLayers);
std::vector<std::vector<OptixUtilDenoiserImageTile>> prevTiles(numLayers);
for (unsigned int l = 0; l < numLayers; l++) {
if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(layers[l].input,
layers[l].output,
overlapWindowSizeInPixels,
tileWidth,
tileHeight,
tiles[l]))
return res;
if (layers[l].previousOutput.data) {
OptixImage2D dummyOutput = layers[l].previousOutput;
if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(layers[l].previousOutput,
dummyOutput,
overlapWindowSizeInPixels,
tileWidth,
tileHeight,
prevTiles[l]))
return res;
}
}
std::vector<OptixUtilDenoiserImageTile> albedoTiles;
if (guideLayer->albedo.data) {
OptixImage2D dummyOutput = guideLayer->albedo;
if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->albedo,
dummyOutput,
overlapWindowSizeInPixels,
tileWidth,
tileHeight,
albedoTiles))
return res;
}
std::vector<OptixUtilDenoiserImageTile> normalTiles;
if (guideLayer->normal.data) {
OptixImage2D dummyOutput = guideLayer->normal;
if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->normal,
dummyOutput,
overlapWindowSizeInPixels,
tileWidth,
tileHeight,
normalTiles))
return res;
}
std::vector<OptixUtilDenoiserImageTile> flowTiles;
if (guideLayer->flow.data) {
OptixImage2D dummyOutput = guideLayer->flow;
if (const OptixResult res = ccl::optixUtilDenoiserSplitImage(guideLayer->flow,
dummyOutput,
overlapWindowSizeInPixels,
tileWidth,
tileHeight,
flowTiles))
return res;
}
for (size_t t = 0; t < tiles[0].size(); t++) {
std::vector<OptixDenoiserLayer> tlayers;
for (unsigned int l = 0; l < numLayers; l++) {
OptixDenoiserLayer layer = {};
layer.input = (tiles[l])[t].input;
layer.output = (tiles[l])[t].output;
if (layers[l].previousOutput.data)
layer.previousOutput = (prevTiles[l])[t].input;
tlayers.push_back(layer);
}
OptixDenoiserGuideLayer gl = {};
if (guideLayer->albedo.data)
gl.albedo = albedoTiles[t].input;
if (guideLayer->normal.data)
gl.normal = normalTiles[t].input;
if (guideLayer->flow.data)
gl.flow = flowTiles[t].input;
if (const OptixResult res = optixDenoiserInvoke(denoiser,
stream,
params,
denoiserState,
denoiserStateSizeInBytes,
&gl,
&tlayers[0],
numLayers,
(tiles[0])[t].inputOffsetX,
(tiles[0])[t].inputOffsetY,
scratch,
scratchSizeInBytes))
return res;
}
return OPTIX_SUCCESS;
}
} // namespace
OptiXDevice::Denoiser::Denoiser(OptiXDevice *device)
: device(device), queue(device), state(device, "__denoiser_state", true)
{
@@ -1075,20 +1260,20 @@ bool OptiXDevice::denoise_run(DenoiseContext &context, const DenoisePass &pass)
/* Finally run denoising. */
OptixDenoiserParams params = {}; /* All parameters are disabled/zero. */
optix_assert(optixUtilDenoiserInvokeTiled(denoiser_.optix_denoiser,
denoiser_.queue.stream(),
&params,
denoiser_.state.device_pointer,
denoiser_.sizes.stateSizeInBytes,
&guide_layers,
&image_layers,
1,
denoiser_.state.device_pointer +
denoiser_.sizes.stateSizeInBytes,
denoiser_.sizes.withOverlapScratchSizeInBytes,
denoiser_.sizes.overlapWindowSizeInPixels,
denoiser_.configured_size.x,
denoiser_.configured_size.y));
optix_assert(ccl::optixUtilDenoiserInvokeTiled(denoiser_.optix_denoiser,
denoiser_.queue.stream(),
&params,
denoiser_.state.device_pointer,
denoiser_.sizes.stateSizeInBytes,
&guide_layers,
&image_layers,
1,
denoiser_.state.device_pointer +
denoiser_.sizes.stateSizeInBytes,
denoiser_.sizes.withOverlapScratchSizeInBytes,
denoiser_.sizes.overlapWindowSizeInPixels,
denoiser_.configured_size.x,
denoiser_.configured_size.y));
return true;
}

View File

@@ -100,7 +100,7 @@ class DeviceQueue {
* based on number of cores and/or available memory. */
virtual int num_concurrent_states(const size_t state_size) const = 0;
/* Number of states which keeps the device occupied with work without loosing performance.
/* Number of states which keeps the device occupied with work without losing performance.
* The renderer will add more work (when available) when number of active paths falls below this
* value. */
virtual int num_concurrent_busy_states() const = 0;

View File

@@ -80,7 +80,8 @@ static bool is_single_supported_device(Device *device, DenoiserType type)
if (!device->info.multi_devices.empty()) {
/* Some configurations will use multi_devices, but keep the type of an individual device.
* This does simplify checks for homogenous setups, but here we really need a single device. */
* This does simplify checks for homogeneous setups, but here we really need a single device.
*/
return false;
}

View File

@@ -54,14 +54,7 @@ PathTrace::PathTrace(Device *device,
PathTrace::~PathTrace()
{
/* Destroy any GPU resource which was used for graphics interop.
* Need to have access to the PathTraceDisplay as it is the only source of drawing context which
* is used for interop. */
if (display_) {
for (auto &&path_trace_work : path_trace_works_) {
path_trace_work->destroy_gpu_resources(display_.get());
}
}
destroy_gpu_resources();
}
void PathTrace::load_kernels()
@@ -473,7 +466,7 @@ void PathTrace::set_denoiser_params(const DenoiseParams &params)
denoiser_ = Denoiser::create(device_, params);
/* Only take into account the "immediate" cancel to have interactive rendering responding to
* navigation as quickly as possible, but allow to run denoiser after user hit Esc button while
* navigation as quickly as possible, but allow to run denoiser after user hit Escape key while
* doing offline rendering. */
denoiser_->is_cancelled_cb = [this]() { return render_cancel_.is_requested; };
}
@@ -559,6 +552,11 @@ void PathTrace::set_output_driver(unique_ptr<OutputDriver> driver)
void PathTrace::set_display_driver(unique_ptr<DisplayDriver> driver)
{
/* The display driver is the source of the drawing context which might be used by
* path trace works. Make sure there is no graphics interop using resources from
* the old display, as it might no longer be available after this call. */
destroy_gpu_resources();
if (driver) {
display_ = make_unique<PathTraceDisplay>(move(driver));
}
@@ -1075,6 +1073,18 @@ bool PathTrace::has_denoised_result() const
return render_state_.has_denoised_result;
}
void PathTrace::destroy_gpu_resources()
{
/* Destroy any GPU resource which was used for graphics interop.
* Need to have access to the PathTraceDisplay as it is the only source of drawing context which
* is used for interop. */
if (display_) {
for (auto &&path_trace_work : path_trace_works_) {
path_trace_work->destroy_gpu_resources(display_.get());
}
}
}
/* --------------------------------------------------------------------
* Report generation.
*/

View File

@@ -226,6 +226,9 @@ class PathTrace {
void progress_set_status(const string &status, const string &substatus = "");
/* Destroy GPU resources (such as graphics interop) used by work. */
void destroy_gpu_resources();
/* Pointer to a device which is configured to be used for path tracing. If multiple devices
* are configured this is a `MultiDevice`. */
Device *device_ = nullptr;

View File

@@ -244,7 +244,7 @@ void RenderScheduler::render_work_reschedule_on_cancel(RenderWork &render_work)
render_work.tile.write = tile_write;
render_work.full.write = full_write;
/* Do not write tile if it has zero samples it it, treat it similarly to all other tiles which
/* Do not write tile if it has zero samples in it, treat it similarly to all other tiles which
* got canceled. */
if (!state_.tile_result_was_written && has_rendered_samples) {
render_work.tile.write = true;

View File

@@ -124,7 +124,7 @@ class RenderScheduler {
/* Get sample up to which rendering has been done.
* This is an absolute 0-based value.
*
* For example, if start sample is 10 and and 5 samples were rendered, then this call will
* For example, if start sample is 10 and 5 samples were rendered, then this call will
* return 14.
*
* If there were no samples rendered, then the behavior is undefined. */
@@ -132,7 +132,7 @@ class RenderScheduler {
/* Get number of samples rendered within the current scheduling session.
*
* For example, if start sample is 10 and and 5 samples were rendered, then this call will
* For example, if start sample is 10 and 5 samples were rendered, then this call will
* return 5.
*
* Note that this is based on the scheduling information. In practice this means that if someone

View File

@@ -50,7 +50,6 @@ set(SRC_KERNEL_DEVICE_GPU_HEADERS
device/gpu/kernel.h
device/gpu/parallel_active_index.h
device/gpu/parallel_prefix_sum.h
device/gpu/parallel_reduce.h
device/gpu/parallel_sorted_index.h
device/gpu/work_stealing.h
)

View File

@@ -29,8 +29,8 @@ ccl_device_inline
IntegratorShadowState state,
const uint visibility,
const uint max_hits,
ccl_private uint *num_recorded_hits,
ccl_private float *throughput)
ccl_private uint *r_num_recorded_hits,
ccl_private float *r_throughput)
{
/* todo:
* - likely and unlikely for if() statements
@@ -60,15 +60,18 @@ ccl_device_inline
* recorded hits is exceeded and we no longer need to find hits beyond the max
* distance found. */
float t_max_world = ray->t;
/* Equal to t_max_world when traversing top level BVH, transformed into local
* space when entering instances. */
float t_max_current = t_max_world;
/* Current maximum distance to the intersection.
* Is calculated as a ray length, transformed to an object space when entering
* instance node. */
float t_max_current = ray->t;
/* Conversion from world to local space for the current instance if any, 1.0
* otherwise. */
float t_world_to_instance = 1.0f;
*num_recorded_hits = 0;
*throughput = 1.0f;
*r_num_recorded_hits = 0;
*r_throughput = 1.0f;
/* traversal loop */
do {
@@ -237,10 +240,10 @@ ccl_device_inline
/* Always use baked shadow transparency for curves. */
if (isect.type & PRIMITIVE_CURVE) {
*throughput *= intersection_curve_shadow_transparency(
*r_throughput *= intersection_curve_shadow_transparency(
kg, isect.object, isect.prim, isect.u);
if (*throughput < CURVE_SHADOW_TRANSPARENCY_CUTOFF) {
if (*r_throughput < CURVE_SHADOW_TRANSPARENCY_CUTOFF) {
return true;
}
else {
@@ -249,37 +252,39 @@ ccl_device_inline
}
if (record_intersection) {
/* Increase the number of hits, possibly beyond max_hits, we will
* simply not record those and only keep the max_hits closest. */
uint record_index = (*num_recorded_hits)++;
/* Test if we need to record this transparent intersection. */
const uint max_record_hits = min(max_hits, INTEGRATOR_SHADOW_ISECT_SIZE);
if (record_index >= max_record_hits - 1) {
/* If maximum number of hits reached, find the intersection with
* the largest distance to potentially replace when another hit
* is found. */
const int num_recorded_hits = min(max_record_hits, record_index);
float max_recorded_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, 0, t);
int max_recorded_hit = 0;
if (*r_num_recorded_hits < max_record_hits || isect.t < t_max_world) {
/* If maximum number of hits was reached, replace the intersection with the
* highest distance. We want to find the N closest intersections. */
const uint num_recorded_hits = min(*r_num_recorded_hits, max_record_hits);
uint isect_index = num_recorded_hits;
if (num_recorded_hits + 1 >= max_record_hits) {
float max_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, 0, t);
uint max_recorded_hit = 0;
for (int i = 1; i < num_recorded_hits; i++) {
const float isect_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, i, t);
if (isect_t > max_recorded_t) {
max_recorded_t = isect_t;
max_recorded_hit = i;
for (uint i = 1; i < num_recorded_hits; ++i) {
const float isect_t = INTEGRATOR_STATE_ARRAY(state, shadow_isect, i, t);
if (isect_t > max_t) {
max_recorded_hit = i;
max_t = isect_t;
}
}
if (num_recorded_hits >= max_record_hits) {
isect_index = max_recorded_hit;
}
/* Limit the ray distance and stop counting hits beyond this. */
t_max_world = max(isect.t, max_t);
}
if (record_index >= max_record_hits) {
record_index = max_recorded_hit;
}
/* Limit the ray distance and stop counting hits beyond this. */
t_max_world = max(max_recorded_t, isect.t);
t_max_current = t_max_world * t_world_to_instance;
integrator_state_write_shadow_isect(state, &isect, isect_index);
}
integrator_state_write_shadow_isect(state, &isect, record_index);
/* Always increase the number of recorded hits, even beyond the maximum,
* so that we can detect this and trace another ray if needed. */
++(*r_num_recorded_hits);
}
}
}
@@ -318,7 +323,7 @@ ccl_device_inline
#endif
/* Restore world space ray length. */
t_max_current = t_max_world;
t_max_current = ray->t;
object = OBJECT_NONE;
t_world_to_instance = 1.0f;

View File

@@ -5,27 +5,6 @@
CCL_NAMESPACE_BEGIN
/* Ray offset to avoid self intersection.
*
* This function should be used to compute a modified ray start position for
* rays leaving from a surface. This is from "A Fast and Robust Method for Avoiding
* Self-Intersection" see https://research.nvidia.com/publication/2019-03_A-Fast-and
*/
ccl_device_inline float3 ray_offset(float3 P, float3 Ng)
{
const float int_scale = 256.0f;
int3 of_i = make_int3((int)(int_scale * Ng.x), (int)(int_scale * Ng.y), (int)(int_scale * Ng.z));
float3 p_i = make_float3(__int_as_float(__float_as_int(P.x) + ((P.x < 0) ? -of_i.x : of_i.x)),
__int_as_float(__float_as_int(P.y) + ((P.y < 0) ? -of_i.y : of_i.y)),
__int_as_float(__float_as_int(P.z) + ((P.z < 0) ? -of_i.z : of_i.z)));
const float origin = 1.0f / 32.0f;
const float float_scale = 1.0f / 65536.0f;
return make_float3(fabsf(P.x) < origin ? P.x + float_scale * Ng.x : p_i.x,
fabsf(P.y) < origin ? P.y + float_scale * Ng.y : p_i.y,
fabsf(P.z) < origin ? P.z + float_scale * Ng.z : p_i.z);
}
#if defined(__KERNEL_CPU__)
ccl_device int intersections_compare(const void *a, const void *b)
{

View File

@@ -72,7 +72,6 @@ typedef unsigned long long uint64_t;
#define ccl_gpu_syncthreads() __syncthreads()
#define ccl_gpu_ballot(predicate) __ballot_sync(0xFFFFFFFF, predicate)
#define ccl_gpu_shfl_down_sync(mask, var, detla) __shfl_down_sync(mask, var, detla)
/* GPU texture objects */

View File

@@ -186,7 +186,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
const int texture_type = info.data_type;
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
if (info.interpolation == INTERPOLATION_CUBIC) {
if (info.interpolation == INTERPOLATION_CUBIC || info.interpolation == INTERPOLATION_SMART) {
return kernel_tex_image_interp_bicubic<float4>(info, x, y);
}
else {
@@ -198,7 +198,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, flo
else {
float f;
if (info.interpolation == INTERPOLATION_CUBIC) {
if (info.interpolation == INTERPOLATION_CUBIC || info.interpolation == INTERPOLATION_SMART) {
f = kernel_tex_image_interp_bicubic<float>(info, x, y);
}
else {
@@ -241,7 +241,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
#endif
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
if (interpolation == INTERPOLATION_CUBIC) {
if (interpolation == INTERPOLATION_CUBIC || interpolation == INTERPOLATION_SMART) {
return kernel_tex_image_interp_tricubic<float4>(info, x, y, z);
}
else {
@@ -252,7 +252,7 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg,
else {
float f;
if (interpolation == INTERPOLATION_CUBIC) {
if (interpolation == INTERPOLATION_CUBIC || interpolation == INTERPOLATION_SMART) {
f = kernel_tex_image_interp_tricubic<float>(info, x, y, z);
}
else {

View File

@@ -1,74 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2021-2022 Blender Foundation */
#pragma once
CCL_NAMESPACE_BEGIN
/* Parallel sum of array input_data with size n into output_sum.
*
* Adapted from "Optimizing Parallel Reduction in GPU", Mark Harris.
*
* This version adds multiple elements per thread sequentially. This reduces
* the overall cost of the algorithm while keeping the work complexity O(n) and
* the step complexity O(log n). (Brent's Theorem optimization) */
#ifdef __HIP__
# define GPU_PARALLEL_SUM_DEFAULT_BLOCK_SIZE 1024
#else
# define GPU_PARALLEL_SUM_DEFAULT_BLOCK_SIZE 512
#endif
template<uint blocksize, typename InputT, typename OutputT, typename ConvertOp>
__device__ void gpu_parallel_sum(
const InputT *input_data, const uint n, OutputT *output_sum, OutputT zero, ConvertOp convert)
{
extern ccl_gpu_shared OutputT shared_data[];
const uint tid = ccl_gpu_thread_idx_x;
const uint gridsize = blocksize * ccl_gpu_grid_dim_x();
OutputT sum = zero;
for (uint i = ccl_gpu_block_idx_x * blocksize + tid; i < n; i += gridsize) {
sum += convert(input_data[i]);
}
shared_data[tid] = sum;
ccl_gpu_syncthreads();
if (blocksize >= 512 && tid < 256) {
shared_data[tid] = sum = sum + shared_data[tid + 256];
}
ccl_gpu_syncthreads();
if (blocksize >= 256 && tid < 128) {
shared_data[tid] = sum = sum + shared_data[tid + 128];
}
ccl_gpu_syncthreads();
if (blocksize >= 128 && tid < 64) {
shared_data[tid] = sum = sum + shared_data[tid + 64];
}
ccl_gpu_syncthreads();
if (blocksize >= 64 && tid < 32) {
shared_data[tid] = sum = sum + shared_data[tid + 32];
}
ccl_gpu_syncthreads();
if (tid < 32) {
for (int offset = ccl_gpu_warp_size / 2; offset > 0; offset /= 2) {
sum += ccl_shfl_down_sync(0xFFFFFFFF, sum, offset);
}
}
if (tid == 0) {
output_sum[ccl_gpu_block_idx_x] = sum;
}
}
CCL_NAMESPACE_END

View File

@@ -62,7 +62,7 @@ typedef unsigned long long uint64_t;
#define ccl_gpu_block_idx_x (blockIdx.x)
#define ccl_gpu_grid_dim_x (gridDim.x)
#define ccl_gpu_warp_size (warpSize)
#define ccl_gpu_thread_mask(thread_warp) uint(0xFFFFFFFF >> (ccl_gpu_warp_size - thread_warp))
#define ccl_gpu_thread_mask(thread_warp) uint64_t(0xFFFFFFFFFFFFFFFF >> (64 - thread_warp))
#define ccl_gpu_global_id_x() (ccl_gpu_block_idx_x * ccl_gpu_block_dim_x + ccl_gpu_thread_idx_x)
#define ccl_gpu_global_size_x() (ccl_gpu_grid_dim_x * ccl_gpu_block_dim_x)
@@ -71,7 +71,6 @@ typedef unsigned long long uint64_t;
#define ccl_gpu_syncthreads() __syncthreads()
#define ccl_gpu_ballot(predicate) __ballot(predicate)
#define ccl_gpu_shfl_down_sync(mask, var, detla) __shfl_down(var, detla)
/* GPU texture objects */
typedef hipTextureObject_t ccl_gpu_tex_object;

View File

@@ -74,7 +74,6 @@ typedef unsigned long long uint64_t;
#define ccl_gpu_syncthreads() __syncthreads()
#define ccl_gpu_ballot(predicate) __ballot_sync(0xFFFFFFFF, predicate)
#define ccl_gpu_shfl_down_sync(mask, var, detla) __shfl_down_sync(mask, var, detla)
/* GPU texture objects */

View File

@@ -263,6 +263,16 @@ ccl_device_inline float3 object_color(KernelGlobals kg, int object)
return make_float3(kobject->color[0], kobject->color[1], kobject->color[2]);
}
/* Alpha of the object */
ccl_device_inline float object_alpha(KernelGlobals kg, int object)
{
if (object == OBJECT_NONE)
return 0.0f;
return kernel_tex_fetch(__objects, object).alpha;
}
/* Pass ID number of object */
ccl_device_inline float object_pass_id(KernelGlobals kg, int object)

View File

@@ -128,9 +128,10 @@ ccl_device float point_radius(KernelGlobals kg, ccl_private const ShaderData *sd
return r;
}
else {
float3 dir = make_float3(r, r, r);
const float normalized_r = r * (1.0f / M_SQRT3_F);
float3 dir = make_float3(normalized_r, normalized_r, normalized_r);
object_dir_transform(kg, sd, &dir);
return average(dir);
return len(dir);
}
}

View File

@@ -30,6 +30,50 @@ ccl_device_inline float bake_clamp_mirror_repeat(float u, float max)
return ((((int)fu) & 1) ? 1.0f - u : u) * max;
}
/* Offset towards center of triangle to avoid ray-tracing precision issues. */
ccl_device const float2 bake_offset_towards_center(KernelGlobals kg,
const int prim,
const float u,
const float v)
{
float3 tri_verts[3];
triangle_vertices(kg, prim, tri_verts);
/* Empirically determined values, by no means perfect. */
const float position_offset = 1e-4f;
const float uv_offset = 1e-5f;
/* Offset position towards center, amount relative to absolute size of position coordinates. */
const float3 P = u * tri_verts[0] + v * tri_verts[1] + (1.0f - u - v) * tri_verts[2];
const float3 center = (tri_verts[0] + tri_verts[1] + tri_verts[2]) / 3.0f;
const float3 to_center = center - P;
const float3 offset_P = P + normalize(to_center) *
min(len(to_center), max(max3(fabs(P)), 1.0f) * position_offset);
/* Compute barycentric coordinates at new position. */
const float3 v1 = tri_verts[1] - tri_verts[0];
const float3 v2 = tri_verts[2] - tri_verts[0];
const float3 vP = offset_P - tri_verts[0];
const float d11 = dot(v1, v1);
const float d12 = dot(v1, v2);
const float d22 = dot(v2, v2);
const float dP1 = dot(vP, v1);
const float dP2 = dot(vP, v2);
const float denom = d11 * d22 - d12 * d12;
if (denom == 0.0f) {
return make_float2(0.0f, 0.0f);
}
const float offset_v = clamp((d22 * dP1 - d12 * dP2) / denom, uv_offset, 1.0f - uv_offset);
const float offset_w = clamp((d11 * dP2 - d12 * dP1) / denom, uv_offset, 1.0f - uv_offset);
const float offset_u = clamp(1.0f - offset_v - offset_w, uv_offset, 1.0f - uv_offset);
return make_float2(offset_u, offset_v);
}
/* Return false to indicate that this pixel is finished.
* Used by CPU implementation to not attempt to sample pixel for multiple samples once its known
* that the pixel did converge. */
@@ -87,7 +131,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
/* Initialize path state for path integration. */
path_state_init_integrator(kg, state, sample, rng_hash);
/* Barycentric UV with sub-pixel offset. */
/* Barycentric UV. */
float u = primitive[2];
float v = primitive[3];
@@ -96,6 +140,14 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
float dvdx = differential[2];
float dvdy = differential[3];
/* Exactly at vertex? Nudge inwards to avoid self-intersection. */
if ((u == 0.0f || u == 1.0f) && (v == 0.0f || v == 1.0f)) {
const float2 uv = bake_offset_towards_center(kg, prim, u, v);
u = uv.x;
v = uv.y;
}
/* Sub-pixel offset. */
if (sample > 0) {
u = bake_clamp_mirror_repeat(u + dudx * (filter_x - 0.5f) + dudy * (filter_y - 0.5f), 1.0f);
v = bake_clamp_mirror_repeat(v + dvdx * (filter_x - 0.5f) + dvdy * (filter_y - 0.5f),

View File

@@ -59,6 +59,8 @@ ccl_device void integrator_volume_stack_update_for_subsurface(KernelGlobals kg,
/* Move ray forward. */
volume_ray.P = stack_sd->P;
volume_ray.self.object = isect.object;
volume_ray.self.prim = isect.prim;
if (volume_ray.t != FLT_MAX) {
volume_ray.D = normalize_len(to_P - volume_ray.P, &volume_ray.t);
}
@@ -198,6 +200,8 @@ ccl_device void integrator_volume_stack_init(KernelGlobals kg, IntegratorState s
/* Move ray forward. */
volume_ray.P = stack_sd->P;
volume_ray.self.object = isect.object;
volume_ray.self.prim = isect.prim;
++step;
}
#endif

View File

@@ -352,17 +352,15 @@ ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
float ao_pdf;
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
if (!(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f)) {
return;
}
bool skip_self = true;
Ray ray ccl_optional_struct_init;
ray.P = sd->P;
ray.P = shadow_ray_offset(kg, sd, ao_D, &skip_self);
ray.D = ao_D;
ray.t = kernel_data.integrator.ao_bounces_distance;
ray.time = sd->time;
ray.self.object = sd->object;
ray.self.prim = sd->prim;
ray.self.object = (skip_self) ? sd->object : OBJECT_NONE;
ray.self.prim = (skip_self) ? sd->prim : PRIM_NONE;
ray.self.light_object = OBJECT_NONE;
ray.self.light_prim = PRIM_NONE;
ray.dP = differential_zero_compact();

View File

@@ -381,11 +381,19 @@ ccl_device bool light_sample_from_distant_ray(KernelGlobals kg,
float costheta = dot(-lightD, ray_D);
float cosangle = klight->distant.cosangle;
/* Workaround to prevent a hang in the classroom scene with AMD HIP drivers 22.10,
* Remove when a compiler fix is available. */
#ifdef __HIP__
ls->shader = klight->shader_id;
#endif
if (costheta < cosangle)
return false;
ls->type = type;
#ifndef __HIP__
ls->shader = klight->shader_id;
#endif
ls->object = PRIM_NONE;
ls->prim = PRIM_NONE;
ls->lamp = lamp;

View File

@@ -180,11 +180,9 @@ ccl_device_inline float3 shadow_ray_smooth_surface_offset(
ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg,
ccl_private const ShaderData *ccl_restrict sd,
float3 L)
float3 L,
ccl_private bool *r_skip_self)
{
float NL = dot(sd->N, L);
bool transmit = (NL < 0.0f);
float3 Ng = (transmit ? -sd->Ng : sd->Ng);
float3 P = sd->P;
if ((sd->type & PRIMITIVE_TRIANGLE) && (sd->shader & SHADER_SMOOTH_NORMAL)) {
@@ -194,19 +192,25 @@ ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg,
* offset_cutoff = 0.1f means that 10-20% of rays will be affected. Also
* make a smooth transition near the threshold. */
if (offset_cutoff > 0.0f) {
float NgL = dot(Ng, L);
float offset_amount = 0.0f;
float NL = dot(sd->N, L);
const bool transmit = (NL < 0.0f);
if (NL < 0) {
NL = -NL;
}
if (NL < offset_cutoff) {
offset_amount = clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f);
}
else {
offset_amount = clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
}
const float3 Ng = (transmit ? -sd->Ng : sd->Ng);
const float NgL = dot(Ng, L);
const float offset_amount = (NL < offset_cutoff) ?
clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f) :
clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
if (offset_amount > 0.0f) {
P += shadow_ray_smooth_surface_offset(kg, sd, Ng) * offset_amount;
/* Only skip self intersections if light direction and geometric normal point in the same
* direction, otherwise we're meant to hit this surface. */
*r_skip_self = (NgL > 0.0f);
}
}
}
@@ -217,7 +221,8 @@ ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg,
ccl_device_inline void shadow_ray_setup(ccl_private const ShaderData *ccl_restrict sd,
ccl_private const LightSample *ccl_restrict ls,
const float3 P,
ccl_private Ray *ray)
ccl_private Ray *ray,
const bool skip_self)
{
if (ls->shader & SHADER_CAST_SHADOW) {
/* setup ray */
@@ -246,10 +251,10 @@ ccl_device_inline void shadow_ray_setup(ccl_private const ShaderData *ccl_restri
ray->time = sd->time;
/* Fill in intersection surface and light details. */
ray->self.prim = sd->prim;
ray->self.object = sd->object;
ray->self.light_prim = ls->prim;
ray->self.object = (skip_self) ? sd->object : OBJECT_NONE;
ray->self.prim = (skip_self) ? sd->prim : PRIM_NONE;
ray->self.light_object = ls->object;
ray->self.light_prim = ls->prim;
}
/* Create shadow ray towards light sample. */
@@ -259,8 +264,9 @@ ccl_device_inline void light_sample_to_surface_shadow_ray(
ccl_private const LightSample *ccl_restrict ls,
ccl_private Ray *ray)
{
const float3 P = shadow_ray_offset(kg, sd, ls->D);
shadow_ray_setup(sd, ls, P, ray);
bool skip_self = true;
const float3 P = shadow_ray_offset(kg, sd, ls->D, &skip_self);
shadow_ray_setup(sd, ls, P, ray, skip_self);
}
/* Create shadow ray towards light sample. */
@@ -271,7 +277,7 @@ ccl_device_inline void light_sample_to_volume_shadow_ray(
const float3 P,
ccl_private Ray *ray)
{
shadow_ray_setup(sd, ls, P, ray);
shadow_ray_setup(sd, ls, P, ray, false);
}
ccl_device_inline float light_sample_mis_weight_forward(KernelGlobals kg,

View File

@@ -76,6 +76,7 @@ ustring OSLRenderServices::u_raster("raster");
ustring OSLRenderServices::u_ndc("NDC");
ustring OSLRenderServices::u_object_location("object:location");
ustring OSLRenderServices::u_object_color("object:color");
ustring OSLRenderServices::u_object_alpha("object:alpha");
ustring OSLRenderServices::u_object_index("object:index");
ustring OSLRenderServices::u_geom_dupli_generated("geom:dupli_generated");
ustring OSLRenderServices::u_geom_dupli_uv("geom:dupli_uv");
@@ -873,6 +874,10 @@ bool OSLRenderServices::get_object_standard_attribute(const KernelGlobalsCPU *kg
float3 f = object_color(kg, sd->object);
return set_attribute_float3(f, type, derivatives, val);
}
else if (name == u_object_alpha) {
float f = object_alpha(kg, sd->object);
return set_attribute_float(f, type, derivatives, val);
}
else if (name == u_object_index) {
float f = object_pass_id(kg, sd->object);
return set_attribute_float(f, type, derivatives, val);
@@ -1638,12 +1643,16 @@ bool OSLRenderServices::trace(TraceOpt &options,
ray.D = TO_FLOAT3(R);
ray.t = (options.maxdist == 1.0e30f) ? FLT_MAX : options.maxdist - options.mindist;
ray.time = sd->time;
ray.self.object = OBJECT_NONE;
ray.self.prim = PRIM_NONE;
ray.self.light_object = OBJECT_NONE;
ray.self.light_prim = PRIM_NONE;
if (options.mindist == 0.0f) {
/* avoid self-intersections */
if (ray.P == sd->P) {
bool transmit = (dot(sd->Ng, ray.D) < 0.0f);
ray.P = ray_offset(sd->P, (transmit) ? -sd->Ng : sd->Ng);
ray.self.object = sd->object;
ray.self.prim = sd->prim;
}
}
else {

View File

@@ -259,6 +259,7 @@ class OSLRenderServices : public OSL::RendererServices {
static ustring u_ndc;
static ustring u_object_location;
static ustring u_object_color;
static ustring u_object_alpha;
static ustring u_object_index;
static ustring u_geom_dupli_generated;
static ustring u_geom_dupli_uv;

View File

@@ -5,12 +5,14 @@
shader node_object_info(output point Location = point(0.0, 0.0, 0.0),
output color Color = color(1.0, 1.0, 1.0),
output float Alpha = 1.0,
output float ObjectIndex = 0.0,
output float MaterialIndex = 0.0,
output float Random = 0.0)
{
getattribute("object:location", Location);
getattribute("object:color", Color);
getattribute("object:alpha", Alpha);
getattribute("object:index", ObjectIndex);
getattribute("material:index", MaterialIndex);
getattribute("object:random", Random);

View File

@@ -116,6 +116,9 @@ ccl_device_noinline void svm_node_object_info(KernelGlobals kg,
stack_store_float3(stack, out_offset, object_color(kg, sd->object));
return;
}
case NODE_INFO_OB_ALPHA:
data = object_alpha(kg, sd->object);
break;
case NODE_INFO_OB_INDEX:
data = object_pass_id(kg, sd->object);
break;

View File

@@ -58,8 +58,8 @@ ccl_device_noinline void svm_node_light_path(KernelGlobals kg,
info = (float)integrator_state_bounce(state, path_flag);
}
/* For background, light emission and shadow evaluation we from a
* surface or volume we are effective one bounce further. */
/* For background, light emission and shadow evaluation from a
* surface or volume we are effectively one bounce further. */
if (path_flag & (PATH_RAY_SHADOW | PATH_RAY_EMISSION)) {
info += 1.0f;
}

View File

@@ -142,6 +142,7 @@ typedef enum NodeGeometry {
typedef enum NodeObjectInfo {
NODE_INFO_OB_LOCATION,
NODE_INFO_OB_COLOR,
NODE_INFO_OB_ALPHA,
NODE_INFO_OB_INDEX,
NODE_INFO_MAT_INDEX,
NODE_INFO_OB_RANDOM

View File

@@ -1307,6 +1307,7 @@ typedef struct KernelObject {
float pass_id;
float random_number;
float color[3];
float alpha;
int particle_index;
float dupli_generated[3];
@@ -1330,6 +1331,7 @@ typedef struct KernelObject {
uint visibility;
int primitive_type;
int pad[2];
} KernelObject;
static_assert_align(KernelObject, 16);

View File

@@ -469,7 +469,7 @@ static void add_subd_edge_creases(CachedData &cached_data,
const SubDSchemaData &data,
chrono_t time)
{
if (!(data.crease_indices.valid() && data.crease_indices.valid() &&
if (!(data.crease_indices.valid() && data.crease_lengths.valid() &&
data.crease_sharpnesses.valid())) {
return;
}
@@ -543,7 +543,7 @@ static void read_subd_geometry(CachedData &cached_data, const SubDSchemaData &da
add_positions(data.positions.getValue(iss), time, cached_data);
if (data.topology_variance != kHomogenousTopology || cached_data.shader.size() == 0) {
if (data.topology_variance != kHomogeneousTopology || cached_data.shader.size() == 0) {
add_subd_polygons(cached_data, data, time);
add_subd_edge_creases(cached_data, data, time);
add_subd_vertex_creases(cached_data, data, time);
@@ -582,7 +582,7 @@ static void read_curves_data(CachedData &cached_data, const CurvesSchemaData &da
array<int> curve_first_key;
array<int> curve_shader;
const bool is_homogenous = data.topology_variance == kHomogenousTopology;
const bool is_homogeneous = data.topology_variance == kHomogeneousTopology;
curve_keys.reserve(position->size());
curve_radius.reserve(position->size());
@@ -605,7 +605,7 @@ static void read_curves_data(CachedData &cached_data, const CurvesSchemaData &da
curve_radius.push_back_slow(radius * data.radius_scale);
}
if (!is_homogenous || cached_data.curve_first_key.size() == 0) {
if (!is_homogeneous || cached_data.curve_first_key.size() == 0) {
curve_first_key.push_back_reserved(offset);
curve_shader.push_back_reserved(0);
}
@@ -616,7 +616,7 @@ static void read_curves_data(CachedData &cached_data, const CurvesSchemaData &da
cached_data.curve_keys.add_data(curve_keys, time);
cached_data.curve_radius.add_data(curve_radius, time);
if (!is_homogenous || cached_data.curve_first_key.size() == 0) {
if (!is_homogeneous || cached_data.curve_first_key.size() == 0) {
cached_data.curve_first_key.add_data(curve_first_key, time);
cached_data.curve_shader.add_data(curve_shader, time);
}

View File

@@ -68,7 +68,7 @@ void Mesh::Triangle::verts_for_step(const float3 *verts,
r_verts[2] = verts[v[2]];
}
else {
/* Center step not stored in the attribute array array. */
/* Center step not stored in the attribute array. */
if (step > center_step) {
step--;
}

View File

@@ -76,6 +76,7 @@ NODE_DEFINE(Object)
SOCKET_TRANSFORM(tfm, "Transform", transform_identity());
SOCKET_UINT(visibility, "Visibility", ~0);
SOCKET_COLOR(color, "Color", zero_float3());
SOCKET_FLOAT(alpha, "Alpha", 0.0f);
SOCKET_UINT(random_id, "Random ID", 0);
SOCKET_INT(pass_id, "Pass ID", 0);
SOCKET_BOOLEAN(use_holdout, "Use Holdout", false);
@@ -414,6 +415,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s
kobject.color[0] = color.x;
kobject.color[1] = color.y;
kobject.color[2] = color.z;
kobject.alpha = ob->alpha;
kobject.pass_id = pass_id;
kobject.random_number = random_number;
kobject.particle_index = particle_index;

View File

@@ -44,6 +44,7 @@ class Object : public Node {
NODE_SOCKET_API(uint, random_id)
NODE_SOCKET_API(int, pass_id)
NODE_SOCKET_API(float3, color)
NODE_SOCKET_API(float, alpha)
NODE_SOCKET_API(ustring, asset_name)
vector<ParamValue> attributes;
NODE_SOCKET_API(uint, visibility)

View File

@@ -817,28 +817,28 @@ void ShaderManager::init_xyz_transforms()
Transform xyz_to_rgb;
if (config->hasRole("aces_interchange")) {
/* Standard OpenColorIO role, defined as ACES2065-1. */
const Transform xyz_E_to_aces = make_transform(1.0498110175f,
0.0f,
-0.0000974845f,
0.0f,
-0.4959030231f,
1.3733130458f,
0.0982400361f,
0.0f,
0.0f,
0.0f,
0.9912520182f,
0.0f);
const Transform xyz_D65_to_E = make_transform(
1.0521111f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9184170f, 0.0f);
/* Standard OpenColorIO role, defined as ACES AP0 (ACES2065-1). */
Transform aces_to_rgb;
if (!to_scene_linear_transform(config, "aces_interchange", aces_to_rgb)) {
return;
}
xyz_to_rgb = aces_to_rgb * xyz_E_to_aces * xyz_D65_to_E;
/* This is the OpenColorIO builtin transform:
* UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */
const Transform ACES_AP0_to_xyz_D65 = make_transform(0.938280f,
-0.004451f,
0.016628f,
0.000000f,
0.337369f,
0.729522f,
-0.066890f,
0.000000f,
0.001174f,
-0.003711f,
1.091595f,
0.000000f);
const Transform xyz_to_aces = transform_inverse(ACES_AP0_to_xyz_D65);
xyz_to_rgb = aces_to_rgb * xyz_to_aces;
}
else if (config->hasRole("XYZ")) {
/* Custom role used before the standard existed. */

View File

@@ -4216,6 +4216,7 @@ NODE_DEFINE(ObjectInfoNode)
SOCKET_OUT_VECTOR(location, "Location");
SOCKET_OUT_COLOR(color, "Color");
SOCKET_OUT_FLOAT(alpha, "Alpha");
SOCKET_OUT_FLOAT(object_index, "Object Index");
SOCKET_OUT_FLOAT(material_index, "Material Index");
SOCKET_OUT_FLOAT(random, "Random");
@@ -4239,6 +4240,11 @@ void ObjectInfoNode::compile(SVMCompiler &compiler)
compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_COLOR, compiler.stack_assign(out));
}
out = output("Alpha");
if (!out->links.empty()) {
compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_ALPHA, compiler.stack_assign(out));
}
out = output("Object Index");
if (!out->links.empty()) {
compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_INDEX, compiler.stack_assign(out));

View File

@@ -110,11 +110,7 @@ void Session::start()
void Session::cancel(bool quick)
{
/* Check if session thread is rendering. */
bool rendering;
{
thread_scoped_lock session_thread_lock(session_thread_mutex_);
rendering = (session_thread_state_ == SESSION_THREAD_RENDER);
}
const bool rendering = is_session_thread_rendering();
if (rendering) {
/* Cancel path trace operations. */
@@ -275,6 +271,12 @@ void Session::thread_render()
progress.set_update();
}
bool Session::is_session_thread_rendering()
{
thread_scoped_lock session_thread_lock(session_thread_mutex_);
return (session_thread_state_ == SESSION_THREAD_RENDER);
}
RenderWork Session::run_update_for_next_iteration()
{
RenderWork render_work;
@@ -557,7 +559,7 @@ void Session::set_pause(bool pause)
}
}
if (session_thread_) {
if (is_session_thread_rendering()) {
if (notify) {
pause_cond_.notify_all();
}

View File

@@ -162,6 +162,10 @@ class Session {
void thread_run();
void thread_render();
/* Check whether the session thread is in `SESSION_THREAD_RENDER` state.
* Returns true if it is so. */
bool is_session_thread_rendering();
/* Update for the new iteration of the main loop in run implementation (run_cpu and run_gpu).
*
* Will take care of the following things:

View File

@@ -43,7 +43,6 @@ static std::vector<std::string> exr_channel_names_for_passes(const BufferParams
static const char *component_suffixes[] = {"R", "G", "B", "A"};
int pass_index = 0;
int num_channels = 0;
std::vector<std::string> channel_names;
for (const BufferPass &pass : buffer_params.passes) {
if (pass.offset == PASS_UNUSED) {
@@ -51,7 +50,6 @@ static std::vector<std::string> exr_channel_names_for_passes(const BufferParams
}
const PassInfo pass_info = pass.get_info();
num_channels += pass_info.num_components;
/* EXR canonically expects first part of channel names to be sorted alphabetically, which is
* not guaranteed to be the case with passes names. Assign a prefix based on the pass index

View File

@@ -67,6 +67,9 @@ CCL_NAMESPACE_BEGIN
#ifndef M_SQRT2_F
# define M_SQRT2_F (1.4142135623730950f) /* sqrt(2) */
#endif
#ifndef M_SQRT3_F
# define M_SQRT3_F (1.7320508075688772f) /* sqrt(3) */
#endif
#ifndef M_LN2_F
# define M_LN2_F (0.6931471805599453f) /* ln(2) */
#endif

View File

@@ -242,6 +242,10 @@ void Octree::printMemUsage()
dc_printf("Total allocated bytes on disk: %d \n", totalbytes);
dc_printf("Total leaf nodes: %d\n", totalLeafs);
/* Unused when not debuggining. */
(void)totalbytes;
(void)totalLeafs;
}
void Octree::resetMinimalEdges()

View File

@@ -4,12 +4,13 @@
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/log.h>
}
namespace {
bool test_vcodec(AVCodec *codec, AVPixelFormat pixelformat)
bool test_vcodec(const AVCodec *codec, AVPixelFormat pixelformat)
{
av_log_set_level(AV_LOG_QUIET);
bool result = false;
@@ -30,7 +31,7 @@ bool test_vcodec(AVCodec *codec, AVPixelFormat pixelformat)
}
return result;
}
bool test_acodec(AVCodec *codec, AVSampleFormat fmt)
bool test_acodec(const AVCodec *codec, AVSampleFormat fmt)
{
av_log_set_level(AV_LOG_QUIET);
bool result = false;
@@ -54,7 +55,7 @@ bool test_acodec(AVCodec *codec, AVSampleFormat fmt)
bool test_codec_video_by_codecid(AVCodecID codec_id, AVPixelFormat pixelformat)
{
bool result = false;
AVCodec *codec = avcodec_find_encoder(codec_id);
const AVCodec *codec = avcodec_find_encoder(codec_id);
if (codec)
result = test_vcodec(codec, pixelformat);
return result;
@@ -63,7 +64,7 @@ bool test_codec_video_by_codecid(AVCodecID codec_id, AVPixelFormat pixelformat)
bool test_codec_video_by_name(const char *codecname, AVPixelFormat pixelformat)
{
bool result = false;
AVCodec *codec = avcodec_find_encoder_by_name(codecname);
const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
if (codec)
result = test_vcodec(codec, pixelformat);
return result;
@@ -72,7 +73,7 @@ bool test_codec_video_by_name(const char *codecname, AVPixelFormat pixelformat)
bool test_codec_audio_by_codecid(AVCodecID codec_id, AVSampleFormat fmt)
{
bool result = false;
AVCodec *codec = avcodec_find_encoder(codec_id);
const AVCodec *codec = avcodec_find_encoder(codec_id);
if (codec)
result = test_acodec(codec, fmt);
return result;
@@ -81,7 +82,7 @@ bool test_codec_audio_by_codecid(AVCodecID codec_id, AVSampleFormat fmt)
bool test_codec_audio_by_name(const char *codecname, AVSampleFormat fmt)
{
bool result = false;
AVCodec *codec = avcodec_find_encoder_by_name(codecname);
const AVCodec *codec = avcodec_find_encoder_by_name(codecname);
if (codec)
result = test_acodec(codec, fmt);
return result;

View File

@@ -249,6 +249,16 @@ extern GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle);
*/
extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle);
/**
* Get the Window under the cursor.
* \param x: The x-coordinate of the cursor.
* \param y: The y-coordinate of the cursor.
* \return The window under the cursor or nullptr in none.
*/
extern GHOST_WindowHandle GHOST_GetWindowUnderCursor(GHOST_SystemHandle systemhandle,
int32_t x,
int32_t y);
/***************************************************************************************
* Event management functionality
***************************************************************************************/

View File

@@ -309,6 +309,14 @@ class GHOST_ISystem {
*/
virtual void useWindowFocus(const bool use_focus) = 0;
/**
* Get the Window under the cursor.
* \param x: The x-coordinate of the cursor.
* \param y: The y-coordinate of the cursor.
* \return The window under the cursor or nullptr if none.
*/
virtual GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y) = 0;
/***************************************************************************************
* Event management functionality
***************************************************************************************/

View File

@@ -233,6 +233,16 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
return (int)system->getFullScreen();
}
GHOST_WindowHandle GHOST_GetWindowUnderCursor(GHOST_SystemHandle systemhandle,
int32_t x,
int32_t y)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
GHOST_IWindow *window = system->getWindowUnderCursor(x, y);
return (GHOST_WindowHandle)window;
}
bool GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, bool waitForEvent)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;

View File

@@ -7,6 +7,12 @@
* Definition of GHOST_ContextCGL class.
*/
/* Don't generate OpenGL deprecation warning. This is a known thing, and is not something easily
* solvable in a short term. */
#ifdef __clang__
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
#include "GHOST_ContextCGL.h"
#include <Cocoa/Cocoa.h>

View File

@@ -110,9 +110,11 @@ class GHOST_SharedOpenGLResource {
struct SharedData {
HANDLE device;
GLuint fbo;
HANDLE render_buf{nullptr};
HANDLE render_target{nullptr};
} m_shared;
enum RenderTarget { TARGET_RENDERBUF, TARGET_TEX2D };
public:
GHOST_SharedOpenGLResource(ID3D11Device *device,
ID3D11DeviceContext *device_ctx,
@@ -179,37 +181,64 @@ class GHOST_SharedOpenGLResource {
}
if (m_is_initialized) {
if (m_shared.render_buf) {
wglDXUnregisterObjectNV(m_shared.device, m_shared.render_buf);
if (m_shared.render_target
#if 1
/* TODO: #wglDXUnregisterObjectNV() causes an access violation on AMD when the shared
* resource is a GL texture. Since there is currently no good alternative, just skip
* unregistering the shared resource. */
&& !m_use_gl_texture2d
#endif
) {
wglDXUnregisterObjectNV(m_shared.device, m_shared.render_target);
}
if (m_shared.device) {
wglDXCloseDeviceNV(m_shared.device);
}
glDeleteFramebuffers(1, &m_shared.fbo);
glDeleteRenderbuffers(1, &m_gl_render_buf);
if (m_use_gl_texture2d) {
glDeleteTextures(1, &m_gl_render_target);
}
else {
glDeleteRenderbuffers(1, &m_gl_render_target);
}
}
}
void reregisterSharedObject()
/* Returns true if the shared object was successfully registered, false otherwise. */
bool reregisterSharedObject(RenderTarget target)
{
if (m_shared.render_buf) {
wglDXUnregisterObjectNV(m_shared.device, m_shared.render_buf);
if (m_shared.render_target) {
wglDXUnregisterObjectNV(m_shared.device, m_shared.render_target);
}
if (!m_render_target_tex) {
return;
return false;
}
m_shared.render_buf = wglDXRegisterObjectNV(m_shared.device,
m_render_target_tex,
m_gl_render_buf,
GL_RENDERBUFFER,
WGL_ACCESS_READ_WRITE_NV);
if (target == TARGET_TEX2D) {
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
m_cur_width,
m_cur_height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
nullptr);
}
if (!m_shared.render_buf) {
m_shared.render_target = wglDXRegisterObjectNV(m_shared.device,
m_render_target_tex,
m_gl_render_target,
(target == TARGET_TEX2D) ? GL_TEXTURE_2D :
GL_RENDERBUFFER,
WGL_ACCESS_READ_WRITE_NV);
if (!m_shared.render_target) {
fprintf(stderr, "Error registering shared object using wglDXRegisterObjectNV()\n");
return;
return false;
}
return true;
}
GHOST_TSuccess initialize()
@@ -221,16 +250,33 @@ class GHOST_SharedOpenGLResource {
}
/* Build the renderbuffer. */
glGenRenderbuffers(1, &m_gl_render_buf);
glBindRenderbuffer(GL_RENDERBUFFER, m_gl_render_buf);
glGenRenderbuffers(1, &m_gl_render_target);
glBindRenderbuffer(GL_RENDERBUFFER, m_gl_render_target);
reregisterSharedObject();
if (!reregisterSharedObject(TARGET_RENDERBUF)) {
glBindRenderbuffer(GL_RENDERBUFFER, 0);
if (m_gl_render_target) {
glDeleteRenderbuffers(1, &m_gl_render_target);
}
/* Fall back to texture 2d. */
m_use_gl_texture2d = true;
glGenTextures(1, &m_gl_render_target);
glBindTexture(GL_TEXTURE_2D, m_gl_render_target);
reregisterSharedObject(TARGET_TEX2D);
}
/* Build the framebuffer */
glGenFramebuffers(1, &m_shared.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, m_shared.fbo);
glFramebufferRenderbuffer(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_gl_render_buf);
if (m_use_gl_texture2d) {
glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_gl_render_target, 0);
}
else {
glFramebufferRenderbuffer(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_gl_render_target);
}
m_is_initialized = true;
return GHOST_kSuccess;
@@ -245,7 +291,7 @@ class GHOST_SharedOpenGLResource {
if ((m_cur_width != width) || (m_cur_height != height)) {
m_cur_width = width;
m_cur_height = height;
reregisterSharedObject();
reregisterSharedObject(m_use_gl_texture2d ? TARGET_TEX2D : TARGET_RENDERBUF);
}
}
@@ -293,18 +339,19 @@ class GHOST_SharedOpenGLResource {
private:
void beginGLOnly()
{
wglDXLockObjectsNV(m_shared.device, 1, &m_shared.render_buf);
wglDXLockObjectsNV(m_shared.device, 1, &m_shared.render_target);
}
void endGLOnly()
{
wglDXUnlockObjectsNV(m_shared.device, 1, &m_shared.render_buf);
wglDXUnlockObjectsNV(m_shared.device, 1, &m_shared.render_target);
}
ID3D11Device *m_device;
ID3D11DeviceContext *m_device_ctx;
GLuint m_gl_render_buf;
GLuint m_gl_render_target;
unsigned int m_cur_width, m_cur_height;
bool m_is_initialized{false};
bool m_use_gl_texture2d{false};
};
GHOST_SharedOpenGLResource *GHOST_ContextD3D::createSharedOpenGLResource(

View File

@@ -189,6 +189,25 @@ bool GHOST_System::getFullScreen(void)
return fullScreen;
}
GHOST_IWindow *GHOST_System::getWindowUnderCursor(int32_t x, int32_t y)
{
/* TODO: This solution should follow the order of the activated windows (Z-order).
* It is imperfect but usable in most cases. */
for (GHOST_IWindow *iwindow : m_windowManager->getWindows()) {
if (iwindow->getState() == GHOST_kWindowStateMinimized) {
continue;
}
GHOST_Rect bounds;
iwindow->getClientBounds(bounds);
if (bounds.isInside(x, y)) {
return iwindow;
}
}
return NULL;
}
void GHOST_System::dispatchEvents()
{
#ifdef WITH_INPUT_NDOF

View File

@@ -157,6 +157,14 @@ class GHOST_System : public GHOST_ISystem {
void useWindowFocus(const bool use_focus);
bool m_windowFocus;
/**
* Get the Window under the cursor.
* \param x: The x-coordinate of the cursor.
* \param y: The y-coordinate of the cursor.
* \return The window under the cursor or nullptr if none.
*/
GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y);
/***************************************************************************************
* Event management functionality
***************************************************************************************/

View File

@@ -109,6 +109,14 @@ class GHOST_SystemCocoa : public GHOST_System {
*/
GHOST_TSuccess disposeContext(GHOST_IContext *context);
/**
* Get the Window under the cursor.
* \param x: The x-coordinate of the cursor.
* \param y: The y-coordinate of the cursor.
* \return The window under the cursor or nullptr if none.
*/
GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y);
/***************************************************************************************
* Event management functionality
***************************************************************************************/

View File

@@ -307,6 +307,7 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
case ']':
return GHOST_kKeyRightBracket;
case '`':
case '<': /* The position of '`' is equivalent to this symbol in the French layout. */
return GHOST_kKeyAccentGrave;
default:
return GHOST_kKeyUnknown;
@@ -771,6 +772,20 @@ GHOST_TSuccess GHOST_SystemCocoa::disposeContext(GHOST_IContext *context)
return GHOST_kSuccess;
}
GHOST_IWindow *GHOST_SystemCocoa::getWindowUnderCursor(int32_t x, int32_t y)
{
NSPoint scr_co = NSMakePoint(x, y);
int windowNumberAtPoint = [NSWindow windowNumberAtPoint:scr_co belowWindowWithWindowNumber:0];
NSWindow *nswindow = [NSApp windowWithWindowNumber:windowNumberAtPoint];
if (nswindow == nil) {
return nil;
}
return m_windowManager->getWindowAssociatedWithOSWindow((void *)nswindow);
}
/**
* \note : returns coordinates in Cocoa screen coordinates
*/
@@ -1035,8 +1050,6 @@ void GHOST_SystemCocoa::notifyExternalEventProcessed()
GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
GHOST_WindowCocoa *window)
{
NSArray *windowsList;
windowsList = [NSApp orderedWindows];
if (!validWindow(window)) {
return GHOST_kFailure;
}

View File

@@ -114,4 +114,9 @@ class GHOST_SystemNULL : public GHOST_System {
type,
((glSettings.flags & GHOST_glStereoVisual) != 0));
}
GHOST_IWindow *getWindowUnderCursor(int32_t x, int32_t y)
{
return NULL;
}
};

View File

@@ -53,9 +53,6 @@
#ifndef VK_COMMA
# define VK_COMMA 0xBC
#endif // VK_COMMA
#ifndef VK_QUOTE
# define VK_QUOTE 0xDE
#endif // VK_QUOTE
#ifndef VK_BACK_QUOTE
# define VK_BACK_QUOTE 0xC0
#endif // VK_BACK_QUOTE
@@ -635,14 +632,32 @@ GHOST_TKey GHOST_SystemWin32::hardKey(RAWINPUT const &raw,
GHOST_TKey GHOST_SystemWin32::processSpecialKey(short vKey, short scanCode) const
{
GHOST_TKey key = GHOST_kKeyUnknown;
switch (PRIMARYLANGID(m_langId)) {
case LANG_FRENCH:
if (vKey == VK_OEM_8)
key = GHOST_kKeyF13; // oem key; used purely for shortcuts .
char ch = (char)MapVirtualKeyA(vKey, MAPVK_VK_TO_CHAR);
switch (ch) {
case u'\"':
case u'\'':
key = GHOST_kKeyQuote;
break;
case LANG_ENGLISH:
if (SUBLANGID(m_langId) == SUBLANG_ENGLISH_UK && vKey == VK_OEM_8) // "`¬"
key = GHOST_kKeyAccentGrave;
case u'.':
key = GHOST_kKeyNumpadPeriod;
break;
case u'/':
key = GHOST_kKeySlash;
break;
case u'`':
case u'²':
key = GHOST_kKeyAccentGrave;
break;
default:
if (vKey == VK_OEM_7) {
key = GHOST_kKeyQuote;
}
else if (vKey == VK_OEM_8) {
if (PRIMARYLANGID(m_langId) == LANG_FRENCH) {
/* OEM key; used purely for shortcuts. */
key = GHOST_kKeyF13;
}
}
break;
}
@@ -777,9 +792,6 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
case VK_CLOSE_BRACKET:
key = GHOST_kKeyRightBracket;
break;
case VK_QUOTE:
key = GHOST_kKeyQuote;
break;
case VK_GR_LESS:
key = GHOST_kKeyGrLess;
break;
@@ -821,9 +833,6 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
case VK_CAPITAL:
key = GHOST_kKeyCapsLock;
break;
case VK_OEM_8:
key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode);
break;
case VK_MEDIA_PLAY_PAUSE:
key = GHOST_kKeyMediaPlay;
break;
@@ -836,8 +845,10 @@ GHOST_TKey GHOST_SystemWin32::convertKey(short vKey, short scanCode, short exten
case VK_MEDIA_NEXT_TRACK:
key = GHOST_kKeyMediaLast;
break;
case VK_OEM_7:
case VK_OEM_8:
default:
key = GHOST_kKeyUnknown;
key = ((GHOST_SystemWin32 *)getSystem())->processSpecialKey(vKey, scanCode);
break;
}
}

View File

@@ -326,7 +326,7 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
ORIENTATION ort = pkt.pkOrientation;
/* Convert raw fixed point data to radians. */
float altRad = (float)((fabs((float)ort.orAltitude) / (float)m_maxAltitude) * M_PI / 2.0);
float altRad = (float)((fabs((float)ort.orAltitude) / (float)m_maxAltitude) * M_PI_2);
float azmRad = (float)(((float)ort.orAzimuth / (float)m_maxAzimuth) * M_PI * 2.0);
/* Find length of the stylus' projected vector on the XY plane. */
@@ -334,7 +334,7 @@ void GHOST_Wintab::getInput(std::vector<GHOST_WintabInfoWin32> &outWintabInfo)
/* From there calculate X and Y components based on azimuth. */
out.tabletData.Xtilt = sin(azmRad) * vecLen;
out.tabletData.Ytilt = (float)(sin(M_PI / 2.0 - azmRad) * vecLen);
out.tabletData.Ytilt = (float)(sin(M_PI_2 - azmRad) * vecLen);
}
out.time = pkt.pkTime;

View File

@@ -412,6 +412,9 @@ void GHOST_XrContext::getExtensionsToEnable(
/* Interaction profile extensions. */
try_ext.push_back(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
try_ext.push_back(XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME);
#ifdef XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME
try_ext.push_back(XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME);
#endif
try_ext.push_back(XR_HUAWEI_CONTROLLER_INTERACTION_EXTENSION_NAME);
/* Controller model extension. */

View File

@@ -278,6 +278,24 @@ template<typename T> inline T *MEM_cnew(const char *allocation_name)
return static_cast<T *>(MEM_callocN(sizeof(T), allocation_name));
}
/**
* Allocate memory for an object of type #T and copy construct an object from `other`.
* Only applicable for a trivial types.
*
* This function works around problem of copy-constructing DNA structs which contains deprecated
* fields: some compilers will generate access deprecated field in implicitly defined copy
* constructors.
*
* This is a better alternative to #MEM_dupallocN.
*/
template<typename T> inline T *MEM_cnew(const char *allocation_name, const T &other)
{
static_assert(std::is_trivial_v<T>, "For non-trivial types, MEM_new should be used.");
T *new_object = static_cast<T *>(MEM_mallocN(sizeof(T), allocation_name));
memcpy(new_object, &other, sizeof(T));
return new_object;
}
/**
* Destructs and deallocates an object previously allocated with any `MEM_*` function.
* Passing in null does nothing.

View File

@@ -193,7 +193,7 @@ void IK_QJacobian::InvertSDLS()
// DLS. The SDLS damps individual singular values, instead of using a single
// damping term.
double max_angle_change = M_PI / 4.0;
double max_angle_change = M_PI_4;
double epsilon = 1e-10;
int i, j;

View File

@@ -1,12 +1,9 @@
/** \file itasc/Armature.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
/*
* Armature.cpp
*
* Created on: Feb 3, 2009
* Author: benoitbolsee
*/
#include "Armature.hpp"
#include <algorithm>

View File

@@ -1,8 +1,8 @@
/*
* Armature.hpp
*
* Created on: Feb 3, 2009
* Author: benoitbolsee
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
#ifndef ARMATURE_HPP_

View File

@@ -1,12 +1,10 @@
/** \file itasc/Cache.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
/*
* Cache.cpp
*
* Created on: Feb 24, 2009
* Author: benoit bolsee
*/
#include <string.h>
#include <assert.h>
#include <math.h>

View File

@@ -1,8 +1,8 @@
/*
* Cache.hpp
*
* Created on: Feb 24, 2009
* Author: benoit tbolsee
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
#ifndef CACHE_HPP_
@@ -17,7 +17,7 @@ namespace iTaSC {
#define CACHE_CHANNEL_EXTEND_SIZE 10
#define CACHE_MAX_ITEM_SIZE 0x3FFF0
/* macro to get the alignement gap after an item header */
/* macro to get the alignment gap after an item header */
#define CACHE_ITEM_GAPB(item) (unsigned int)(((size_t)item+sizeof(CacheItem))&(sizeof(void*)-1))
/* macro to get item data position, item=CacheItem pointer */
#define CACHE_ITEM_DATA_POINTER(item) (void*)((unsigned char*)item+sizeof(CacheItem)+CACHE_ITEM_GAPB(item))

View File

@@ -1,12 +1,9 @@
/** \file itasc/ConstraintSet.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Ruben Smits. */
/** \file
* \ingroup intern_itasc
*/
/*
* ConstraintSet.cpp
*
* Created on: Jan 5, 2009
* Author: rubensmits
*/
#include "ConstraintSet.hpp"
#include "kdl/utilities/svd_eigen_HH.hpp"

View File

@@ -1,8 +1,8 @@
/*
* ConstraintSet.hpp
*
* Created on: Jan 5, 2009
* Author: rubensmits
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Ruben Smits. */
/** \file
* \ingroup intern_itasc
*/
#ifndef CONSTRAINTSET_HPP_

View File

@@ -1,12 +1,9 @@
/** \file itasc/ControlledObject.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Ruben Smits. */
/** \file
* \ingroup intern_itasc
*/
/*
* ControlledObject.cpp
*
* Created on: Jan 5, 2009
* Author: rubensmits
*/
#include "ControlledObject.hpp"

View File

@@ -1,8 +1,8 @@
/*
* ControlledObject.hpp
*
* Created on: Jan 5, 2009
* Author: rubensmits
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Ruben Smits. */
/** \file
* \ingroup intern_itasc
*/
#ifndef CONTROLLEDOBJECT_HPP_

View File

@@ -1,12 +1,9 @@
/** \file itasc/CopyPose.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
/*
* CopyPose.cpp
*
* Created on: Mar 17, 2009
* Author: benoit bolsee
*/
#include "CopyPose.hpp"
#include "kdl/kinfam_io.hpp"

View File

@@ -1,8 +1,8 @@
/*
* CopyPose.h
*
* Created on: Mar 17, 2009
* Author: benoit bolsee
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Benoit Bolsee. */
/** \file
* \ingroup intern_itasc
*/
#ifndef COPYPOSE_H_

View File

@@ -1,12 +1,9 @@
/** \file itasc/Distance.cpp
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright 2009 Ruben Smits. */
/** \file
* \ingroup intern_itasc
*/
/*
* Distance.cpp
*
* Created on: Jan 30, 2009
* Author: rsmits
*/
#include "Distance.hpp"
#include "kdl/kinfam_io.hpp"

Some files were not shown because too many files have changed in this diff Show More