Compare commits

..

899 Commits

Author SHA1 Message Date
a640587e25 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-17 20:20:22 +01:00
892637f60a Merge branch 'master' into temp-openxr-blenderside 2020-03-17 20:19:58 +01:00
c333f57603 Ghost: Ghost-XR API to abstract away and access OpenXR functionality
Extends Ghost to include an abstraction for OpenXR, which I refer to as
Ghost-XR. Such an API is the base for the following commit, which introduces VR
support to Blender.

Main features:
* Simple and high-level interface for Blender specific code to call.
* Extensible for muliple graphics backends, currently OpenGL and a DirectX
  compatibility layer are supported.
* Carefully designed error handling strategy allowing Blender to handle errors
  gracefully and with useful error messages.
* OpenXR extension and API-layer management.
* OpenXR session management.
* Basic OpenXR event management.
* Debug utilities for Ghost-XR and OpenXR

For more information on this API, check
https://wiki.blender.org/wiki/Source/Interface/XR.

Reviewed by: Brecht Van Lommel

Differential Revision: https://developer.blender.org/D6188
2020-03-17 20:10:57 +01:00
e09f0caff3 GPencil: Fix crash joining objects
The weights array can be NULL.
2020-03-17 19:02:10 +01:00
blender
ba3d49225c make deps: Fixes to make OpenXR to work on CentOS Linux
- Harvest to a proper location.
- Disable STD's filesystem which is experimental and caused
  linking errors when OpenXR is usedi n Blender.
2020-03-17 18:35:29 +01:00
f1eb86c458 GPencil: Rename old color operators to material
The color was used in old version when palettes were used, but now all are materials
2020-03-17 18:29:34 +01:00
bf9c4af9bb Fix T74762: Mantaflow: Non emmiting flow source affects simulation 2020-03-17 18:21:01 +01:00
07d5b8b023 Fix T74322: Wrong object bundles with scaled camera
Camera scale was not handled correctly when drawing 3d bundles for
reconstructed objects (caused by normalization of the matrix).
2020-03-17 17:48:55 +01:00
6a0ddb4bb1 Cleanup: Remove unused function
Was introduced earlier today and did not turn out to be very useful
and clear.
2020-03-17 17:40:54 +01:00
f958560a99 Multires: Properly support virtual modifiers for Apply Base
The initial code from earlier from today didn't really work reliable
since it is not possible to apply virtual modifiers but not the real
multires one (in a situation like mesh with shapekeys and multires).

New code uses less memory and has better performance for the case
when there are actual modifiers leading the multires. The case when
there is only multires will not be as performant as possible at this
moment.
2020-03-17 17:40:54 +01:00
1504cb26b0 Cleanup: process colorspace conversion with a 1D pixel array
No need to assume it's 2D or 3D.
2020-03-17 17:33:08 +01:00
2518f60109 GPencil: Fix Parent layer not working
The parenting was using the old logic, but with new engine the draw is done using eval data.

Fixed the depsgraph relationship missing with bones to get an update when the bone is transformed.

Also fixed Snap cursor to Selected
2020-03-17 17:28:49 +01:00
964375e36a Cleanup: blenkernel proper header inclusion for BKE_ocean.h
BKE_ocean.h uses the bool type without including stdbool.h
counting on someone else including that before it.

With D6811 enabling automatic sorting of the includes
this can no longer be counted on. This changes includes
stdbool.h in BKE_ocean.h so it can build without being
depended on others including the right headers before it.
2020-03-17 10:12:47 -06:00
Robert Guetzkow
d374237d43 Fix T74838: fix dereferencing of NULL in sculpt_no_multires_poll when no active object exists
Fix crash when the operator search is used while no active object exists. The cause of the issue is an attempt to dereference `ob` when it is `NULL`. Therefore this patch checks the return value of `SCULPT_mode_poll()` first, to ensure that `ob` isn't `NULL`.

Reviewed By: pablodp606

Maniphest Tasks: T74838

Differential Revision: https://developer.blender.org/D7156
2020-03-17 16:46:55 +01:00
24e44143a1 Multires: Fix Apply Base when there are deform modifiers
Their effect was applied twice after hitting Apply Base since the
operator was also applying deformation caused by those modifiers.
2020-03-17 16:41:43 +01:00
628d799c85 Multires: Add utility to create deformed base mesh
The new function will use original object as a starting point
and apply all enabled deformation modifiers prior to the multires.
2020-03-17 16:41:43 +01:00
c76d390c92 Mesh: Fix applying deform modifier up to index
The code would have break the first (deform only) modifiers
once the index is reached, but it will not prevent second
loop (over remaining modifiers) from run.

This was applying deform modifier twice in some conditions:
having single deform modifier and calculating deformed mesh
up to the first modifier (index=0).
2020-03-17 16:41:43 +01:00
bf5151b2d2 Mesh: Add utility to calculate deform modifier up to index
Intention is to be used to create mesh at the state which is an input
to the multires modifier.
2020-03-17 16:41:43 +01:00
a45c34ae8e Multires: Cleanup, argument naming and order
Use full argument name.

Also order arguments in the generosity order: from depsgraph
(which has everything) to object (which contains multires)
specific multires modifier.
2020-03-17 16:41:43 +01:00
17abae45f1 Multires: Cleanup, remove redundant argument
Scene can be queried from the dependency graph.
2020-03-17 16:41:43 +01:00
99eb95337f Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-17 16:40:07 +01:00
5d30598e3b Make it obvious that the DRW context getters are not for general use 2020-03-17 16:28:29 +01:00
20456b52b4 Fluid: Fixes for new abort bake faster feature
In addition to previous commit that made it possible to abort bakes faster.
2020-03-17 16:12:46 +01:00
b852db57ba Add experimental global undo speedup.
The feature is hidden behind an experimental option, you'll have to
enable it in the preferences to try it.

This feature is not yet considered fully stable, crashes may happen, as
well as .blend file corruptions (very unlikely, but still possible).

In a nutshell, the ideas behind this code are to:
* Detect unchanged IDs across an undo step.
* Reuse as much as possible existing IDs memory, even when its content
  did change.
* Re-use existing depsgraphs instead of building new ones from scratch.
* Store accumulated recalc flags, to avoid needless re-compute of things
  that did not change, when the ID itself is detected as modified.

See T60695 and D6580 for more technical details.
2020-03-17 15:02:05 +01:00
Mateusz Grzeliński
9ce3890950 Cleanup: rename function
This function was missed in rBec471a9b1c1.

Differential Revision: https://developer.blender.org/D7155
2020-03-17 14:46:50 +01:00
8cb463f4ff OverlayEngine: crash when using hidden faces
Unreported Crash. When hidden faces are active (retopology) the depth
test could fail as the default framebuffers aren't set. This patch will
check if we are rendering a depth only and skip the clearing of the
buffer.
2020-03-17 13:56:25 +01:00
3c1433b6f3 Revert "Cleanup: use doxy sections"
This reverts commit 626b2bd071.

Sergey prefers not to use doxy sections for this code.

Revert pending a decision on T74845
2020-03-17 23:53:36 +11:00
b2851dbe78 Fluid: Abort baking jobs faster
With this change baking jobs will be aborted faster. The user will not have to wait for the current frame to finish baking. The bake job will exit early and discard the incomplete frame.
2020-03-17 13:49:57 +01:00
54c8770692 Fix error using CUDA in plug-ins on Linux/macOS, hide our CUDA symbols
Better solution will be to hide all symbols by default, but this works for now.
2020-03-17 12:23:36 +01:00
0b7841679e Multires: Cleanup, naming, make it more consistent
The coarse mesh is an input to generic Subdiv, and exact meaning is
ambiguous.

The input to Multires is a base mesh, which owns CD_MDISPS.
2020-03-17 12:23:02 +01:00
b02a25b7e1 Add accumulated recalc flags to IDs.
Those accumulated flags get cleared every time an undo step is written
to memfile.

Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 12:10:52 +01:00
055863d9c1 Cleanup: minor changes. 2020-03-17 12:10:52 +01:00
20d7c04305 Fluid: Re-dded Empty Space option in the UI
This option existed already and was just hidden in the UI. With the new fluids system though, it will only be used for rendering - and not to optimize the cache.
2020-03-17 11:57:04 +01:00
7f3e84deb5 Fluid: Updated manta pp files
Includes only a rename. The name PyInit_Main was a bit confusing as it just belongs to Manta.
2020-03-17 11:57:04 +01:00
2ba3e6a02e Depsgraph: Adds helpers to extract/restore despgraphs in a given Main.
Extract will steal all depsgraphs currently stored in given bmain, and
restore will put them back in place, using scene and viewlayers as keys.

Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 11:24:37 +01:00
90ce708ef0 BKE_lib_id: Add helper to swap full ID content and use proper naming.
Preliminary work for undo-speedup.

Part of T60695/D6580.
2020-03-17 11:13:14 +01:00
b87997f59b Cleanup: rename 'centre' to 'center' in View3D 2020-03-17 11:34:11 +11:00
ab430cfdfe Cleanup: sort DNA renaming 2020-03-17 11:29:54 +11:00
67307e72ea Cleanup: use more descriptive variable name for the data-mask
Make it explicit this data mask is added to the default mask.
2020-03-17 11:04:50 +11:00
47af235ba9 Revert "UI: Add 7 new community themes"
This reverts commit d89e5fcaef.

This was meant to be committed to the add-ons repo.
2020-03-17 10:41:40 +11:00
1a7135b12f Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-16 22:07:02 +01:00
ae14649583 Fix comment being printed to console in Windows batch file 2020-03-16 22:00:36 +01:00
120a38ccbe Nodes: Display bl_icon of custom nodes in node header
This is D1578 by Philipp Oeser with small modifications.
2020-03-16 18:25:23 +01:00
a75a79272e Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-16 18:15:10 +01:00
ddbbd9928e Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-16 18:14:24 +01:00
d2ef342b2a Merge branch 'master' into temp-openxr-ghostxr 2020-03-16 18:13:37 +01:00
e42f61dda8 Fix incorrect Face Sets when using mask extract
Mask extract modifies the topology when adding the boundary loop, so
previous face sets may not be correct in the new mesh. Remove the face
sets datalayer and let sculpt mode rebuild it when entering sculpt mode
in the new object.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7129
2020-03-16 17:53:03 +01:00
bab0fd1308 Fix visual artifacts with partially hidden meshes and mask extract
The previous behaivour didn't make sense as sculpt mode was still active
when switching to the new object, so it was rendering inconrrectly.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7130
2020-03-16 17:45:22 +01:00
e4077ea69d Fix T74626: Wrong Face Sets overlay rendering in smooth shading
The face set color variable needs to be declared inside of the loop in
order to reset it per iteration.

Reviewed By: jbakker

Maniphest Tasks: T74626

Differential Revision: https://developer.blender.org/D7096
2020-03-16 17:43:54 +01:00
7941ea02f8 Update viewport rotation origin when changing Face Set visibility
Small UX fix. When hidding everything but the active face set with H,
the last stroke lotation center can be in a part of the model that is
hidden, so viewport navigation becomes confusing until you start a new
stroke on the visible face set. Now the viewport navigation rotation
center is updated to the active vertex when using a visibility operation
that uses it, so it always rotates using the visible face set as the
origin.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7137
2020-03-16 17:42:52 +01:00
ba26adee0c Fix T61234 Mirroring Grease Pencil keyframes in the Dopesheet fails
`ANIM_animdata_update()` did not sort grease pencil frames. A
pre-existing comment stated this wouldn't be necessary as
`posttrans_gpd_clean()` already does this. However, this is only
applicable when the change is performed via the transform system. The
mirror operator doesn't call `posttrans_gpd_clean()`, invalidating the
assumption in the comment.

I moved the sorting code into `BKE_gpencil_layer_frames_sort()`, which
is now called from both `ANIM_animdata_update()` and
`posttrans_gpd_clean()`.
2020-03-16 16:23:12 +01:00
f0856b1fda Cycles: Fix bad escape character used for dot 2020-03-16 16:17:13 +01:00
215e474a99 Fix T74776: Cycles crash with missing image texture after recent changes 2020-03-16 16:02:06 +01:00
20f6700c88 UI: Show decorators for lights when using Cycles
This matches Eevee, and also the rest of Blender.
2020-03-16 14:32:09 +01:00
d89e5fcaef UI: Add 7 new community themes
This commit adds 7 themes submitted by the community on Devtalk. These themes both serve specific purposes, provide a greater variety in look & feel, and serve as welcoming homes for users coming on board from other packages. This is the initial commit, but these themes can be continuously updated over time to fix issues and keep them up to date with changes.

Thanks to all contributors, and in particular the makes of the picked themes: Pierre Schiller, Edward Agwi, Vojtěch Lacina, Michail Soluyanov, Jason van Gumster, Mr Wax Police & Jonathan Lampel.

An overview is here: https://developer.blender.org/T74360
2020-03-16 14:25:47 +01:00
37e7e1e77c Cleanup: Typo in comment 2020-03-16 12:43:05 +01:00
a69c364746 UI: fix backdrop and alignment in anim channels
This patch fixes various problems of alignment and element backdrops for
the animation channels drawing, mainly in the Graph editor but also for
grease pencil and mask layers in the Dope Sheet.

Reviewed By: billreynish, sybren

Differential Revision: https://developer.blender.org/D5204
2020-03-16 12:18:33 +01:00
5a664c6e98 Fix another implicit cast of boot to int
Use proper comparison to nullptr.

It is important to use nullptr since NULL is actually an integer,
which leads to another type of warnings.
2020-03-16 12:15:16 +01:00
35a29befb3 Fluid: Updated Manta pp files
Includes additional minmax check for Windows
2020-03-16 11:52:18 +01:00
7df435325b Fix implicit cast from bool to int in path tests 2020-03-16 10:53:46 +01:00
01377fd229 Workbench: Crash When Rendering With Stereo 2020-03-16 10:42:03 +01:00
868573451f Cleanup: use unsigned char for UI_view2d_text_cache_add
Avoids casts when used with other UI code
where the color is often unsigned.
2020-03-16 11:53:08 +11:00
f06a6e92bc Cleanup: misleading memset use
This call to memset relied on PassList having a single,
zero sized struct member.

Pass the passes array instead for readability.
2020-03-16 09:43:07 +11:00
Yevgeny Makarov
ac1dcdbf06 UI: Add an Outline to the Popover Arrows
Reviewed By: billreynish, fclem

Differential Revision: https://developer.blender.org/D5873
2020-03-15 23:19:01 +01:00
7a19a99675 Workbench: Fix default view not reset after drawing
This fix jitter of overlay and GPencil. But I'm not sure this should
be the responsibility of the subsequent draw engines or the responsibility
of the current engine to reset the view.
2020-03-15 22:50:07 +01:00
cebff2ff30 Fix a syntax error in test spec for BLI_delaunay_2d_test.
Test specs are read from strings, and there was a comma instead
of a decimal point, and then an extra decimal point in the Quad0 test.
This test has been flaky on Windows buildbot. Perhaps this is why.
2020-03-15 17:14:04 -04:00
7a7b392b54 GPencil: Reduce factor to 5 in previous commit
10 decimals is too high
2020-03-15 19:40:21 +01:00
22925d0dd3 GPencil: Remove Keep parameter from Select Vertex Color
Also changed range of threshold from 0 to 10
2020-03-15 19:22:33 +01:00
8022fc3220 Fix Blender building after recent 'cleanup'.
Caused by rB4be4c0667155. Please ensure at least affected code does
still build...
2020-03-15 16:11:35 +01:00
e53e17b8d6 Fix outliner edit-mode check 2020-03-15 22:04:08 +11:00
b435bd2f31 Fix potential draw manager assignment to negative index
While there is an assert here, the run-time code would perform the assignment.
2020-03-15 22:03:59 +11:00
59f5194265 Fix potential NULL pointer de-reference creating liquid geometry 2020-03-15 22:03:49 +11:00
b8feef59c8 Cleanup: add parens for clarity 2020-03-15 21:53:57 +11:00
5029b97d02 Cleanup: add NULL check for RNA filename argument
Currently some of the code supports a NULL filename,
add the NULL check so RNAProcessItem's with a NULL filename
don't crash in the future.
2020-03-15 21:53:20 +11:00
ecfb89280e Cleanup: use 'r_' prefix for return args 2020-03-15 21:51:22 +11:00
37419bb3f6 Cleanup: avoid setting float values by bit-pattern
Replace memset with copy_vn_fl, note that the exact values are slightly
different in this case. The value being set was close to FLT_MAX.
2020-03-15 21:51:02 +11:00
4be4c06671 Cleanup: redundant checks
In some cases moved the checks into asserts,
to ensure changes in the future don't cause
the checks to become necessary again.
2020-03-15 21:48:35 +11:00
80edc0e972 Cleanup: redundant assignments 2020-03-15 21:46:18 +11:00
aa60b9338a Cleanup: use 'const' style argument 2020-03-15 21:42:06 +11:00
b037816980 Cleanup: shadow warning, clang-format 2020-03-15 21:42:06 +11:00
4031d8bcb7 UI: Fix capitalization in the macOS app menu 2020-03-15 11:16:08 +01:00
a210b8297f UI: Larger Alert Icons
Adding a set of larger icons for use in informational dialogs.

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

Reviewed by Campbell Barton
2020-03-14 11:05:09 -07:00
a816a067ed GPencil: Change Select Vertex Color to similar selection
Now, instead to use the Brush color as selection patron, now it uses any previous selected color.
2020-03-14 16:26:56 +01:00
b7160f2f0a IC keymap: Fixes for GP
- Remove Shift for drawing poly-lines, just as in the default keymap
  - Use consistent hotkeys for size and strength radial controls
  - Fix some bugs/missing items from the GP merge
2020-03-14 14:00:28 +01:00
94bad2f30d GPencil: Fix missing context wheel color in Tint tool 2020-03-14 11:58:22 +01:00
cc53900baf GPencil: Add option to keep selected in Select Vertex Color 2020-03-14 11:07:35 +01:00
428e65256e GPencil: Use Linear color instead of sRGB for Select Vertex Color
The brush color is sRGB but the Vertex Color is linear.
2020-03-14 10:46:28 +01:00
b8211a4d7c GPencil: Add Select Vertex Color to menu
This option was missing
2020-03-14 10:45:23 +01:00
466171d0ef GPencil: Rename operator select_color to select_vertex_color 2020-03-14 10:33:33 +01:00
d50d410a70 GPencil: Rename operator color_select to select_material
The old name was related to the old palettes.
2020-03-14 10:30:59 +01:00
bb89cc51ec Fix T67446: UV Editor: support island select mode for box/circle/lasso
selections

Previously this was only supported in single click selections, doing an
island selection with box/circle/lasso would just select individual
vertices instead. Now selects islands properly.

This also unifys some logic between box/circle/lasso:
- use early selection test from lasso [makes things faster] in box/
circle
- circle wasnt checking visible face
2020-03-14 08:16:08 +01:00
f0b0524c5f Cleanup: spelling 2020-03-14 15:43:21 +11:00
117ccb56ad Cleanup: remove unused ARegion from bGPdata_Runtime 2020-03-14 15:39:59 +11:00
4b38eac4da CMake: use spaces instead of tabs for icon updating script 2020-03-14 15:39:59 +11:00
60e3f690cb Cleanup: sort file lists & struct declatations 2020-03-14 15:39:59 +11:00
626b2bd071 Cleanup: use doxy sections 2020-03-14 15:39:53 +11:00
acab745078 UI: Toolbar icons
- Add icons for Sculpt Cloth, Clay Thumb and Draw Face Sets, as well as GP Tint, Replace and Transform Fill tools
  - Tweak icons for Sculpt Rotate, Pinch, Multiplane Scrape, Inflate, Blob, Draw Sharp, based on feedback on Devtalk
2020-03-14 01:31:28 +01:00
5260aaf3b1 Fix T73921: Eevee volume render test memory leak in Mantaflow
Fixed memory leak that showed up after the original issue (crash) had been fixed in 93ac4709eb. The fix ensures that light cache bakes free up GPU smoke textures and the smoke domain list correctly.

This commit also removes the workaround (f3a33a9298) that disabled light cache bakes for fluid objects.
2020-03-14 00:30:55 +01:00
7d56c425f8 GPencil: Don'r Replace color if vertex color is empty
The replace tools only must work over previously vertex painted.
2020-03-13 21:54:54 +01:00
dc99c3532a Cleanup: USD, move some common code to an abstract superclass
The `check_is_animated()` function will be used by the upcoming Alembic
exporter as well. There is nothing USD-specific in the function.

No functional changes.
2020-03-13 18:17:51 +01:00
ebf3c87912 Fix T74699: File browser closing while loading crash.
Owner of filelisting job was changed, without proper update of all
access/usages of that owner to reach the job, leading to failure of
timer removal from the WM, and attempt to double-free the job...

Caused by rB2c4dfbb00246ff.
2020-03-13 17:34:21 +01:00
5ad16e6a11 Cleanup: BKE_mesh_nomain_to_mesh: Add assert that source mesh is indeed not in Main. 2020-03-13 17:17:26 +01:00
4e26afe0ae Cleanup: Comments of wmJobs callbacks. 2020-03-13 17:17:26 +01:00
110a35ef5a Fix T74397: Crash after undoing quadriflow remesh on duplicate with armature deform
The issue was that we were creating temporary mesh copies and storing
them in bmain and then later using BKE_mesh_nomain_to_mesh which would
add them to bmain once more (duplicates).

This would lead to crashes later as the custom data of the mesh could be
trashed quite easily.
2020-03-13 16:29:30 +01:00
de30fda04e Fix T74686: Loading btx file in multires modifier is not working
Was happening when object does not have CD_MDISPS allocated yet.
Need to make sure totdisp and level is specified on CD_MDISPS data
prior to loading (as the load expects them to be properly set).
2020-03-13 16:15:31 +01:00
67704cb8aa Multires: Fix loosing sculpt data when using external BTX file 2020-03-13 16:15:31 +01:00
6bcb6a0ea6 Fix stereoscopy reference image drawing in the viewport
Note: Without D6922 stereo is too broken to even test this patch.
With D6922 + this patch the fullscreen modes work (anaglyph/interlace not yet).
2020-03-13 16:07:19 +01:00
be76a37c91 GPencil: Fix UI typo 2020-03-13 15:50:26 +01:00
5593efec01 Fix stereoscopy drawing for camera background
Part of the fix was to get gputexture to use an array to accomodate each
eye. This takes care of viewports showing individual Left or Right
views.

For the combined view the fix was in overlay_image.c:camera_background_images_stereo_setup.

Note 1: Referece images are still not supporting stereo.

Note 2: For painting, and getting image bindcode I'm hardcording a
single-view experience.

Note 3: Without D6922 stereo is too broken to even test this patch.
With D6922 + this patch the fullscreen modes work (anaglyph/interlace
not yet).

Differential Revision: D7143
2020-03-13 15:40:20 +01:00
93ac4709eb Fluid: Potential fix for Eevee tests crashing with Mantaflow
Belongs to T73921. This commit fixes the crashes with light baking (disabled in f3a33a9298). There is still a memory leak to be fixed though.
2020-03-13 15:34:07 +01:00
525bd62557 Potential fix for T74609: File Selector Crashes Showing Thumbnails.
Existing code was definitively giving possibility to access freed
memory, although probably not on a super-common basis...
2020-03-13 14:37:28 +01:00
bc0a0cdf17 Multires: Fix Subdivide, Reshape and Apply Base
This change fixes artifacts produced by these operations.

On a technical aspect this is done by porting all of the operations
to the new subdivision surface implementation which ensures that
tangent space used to evaluate modifier and those operations is
exactly the same (before modifier will use new code and the operations
will still use an old one).

The next step is to get sculpting on a non-top level to work, and
that actually requires fixes in the undo system.
2020-03-13 14:14:56 +01:00
b0a1af4eb1 Multires: Increase default quality to 4
Makes it work better "out of the box" for irregular topology like
Suzanne mesh.

There might be some performance impact on non-regular meshes, but
those are not very common usecase for multires and for those its
always possible to lower the quality if needed.
2020-03-13 14:13:37 +01:00
f36d98bb1d Subdiv: Fix loose geometry callbacks in certain conditions
Loose vertices and vertices of loose edges callback was not working
correct if some of other callbacks were set to NULL.

Was caused by missing bitmask set in the callbacks which were set
to NULL.
2020-03-13 14:07:44 +01:00
8622372256 OpenSubdiv: Make non-full geometry less strict for sharpness
Allow to mark individual vertices as infinitely sharp even if there is
no full topology and no access to edges: infinite sharp vertices do not
need connectivity information.
2020-03-13 14:07:44 +01:00
48e0af52e6 GPencil: Fix typo error 2020-03-13 13:08:45 +01:00
4326d162ba GPencil: Enable Lights ON to default object in 2D template 2020-03-13 13:06:02 +01:00
Bogdan Nagirniak
9075ec8269 Python: add foreach_get and foreach_set methods to pyrna_prop_array
This allows fast access to various arrays in the Python API.
Most notably, `image.pixels` can be accessed much more efficiently now.

**Benchmark**

Below are the results of a benchmark that compares different ways to
set/get all pixel values. I do the tests on 2048x2048 rgba images.
The benchmark tests the following dimensions:
- Byte vs. float per color channel
- Python list vs. numpy array containing floats
- `foreach_set` (new) vs. `image.pixels = ...` (old)

```
Pixel amount: 2048 * 2048 = 4.194.304
Byte buffer size:  16.8 mb
Float buffer size: 67.1 mb

Set pixel colors:
    byte  - new - list:    271 ms
    byte  - new - buffer:   29 ms
    byte  - old - list:    350 ms
    byte  - old - buffer: 2900 ms

    float - new - list:    249 ms
    float - new - buffer:    8 ms
    float - old - list:    330 ms
    float - old - buffer: 2880 ms

Get pixel colors:
    byte - list:   128 ms
    byte - buffer:   9 ms
    float - list:  125 ms
    float - buffer:  8 ms
```

**Observations**

The best set and get speed can be achieved with buffers and a float image,
at the cost of higher memory consumption. Furthermore, using buffers when
using `pixels = ...` is incredibly slow, because it is not optimized.
Optimizing this is possible, but might not be trivial (there were multiple
attempts afaik).

Float images are faster due to overhead introduced by the api for byte images.
If I profiled it correctly, a lot of time is spend in the `[0, 1] -> {0, ..., 255}`
conversion. The functions doing that conversion is `unit_float_to_uchar_clamp`.
While I have an idea on how it can be optimized, I do not know if it can be done
without changing its functionality slightly. Performance wise the best solution
would be to not do this conversion at all and accept byte input from the api
user directly, but that seems to be a more involved task as well.

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

Reviewers: JacquesLucke, mont29
2020-03-13 12:59:36 +01:00
db4298c6be GPencil: Avoid segment fault when use Simplify modifier
The number of points of the evaluated stroke can be less than original or the original can use less points that evaluated.
2020-03-13 12:57:59 +01:00
cb19bb7f57 Cleanup: USD, removed unused export job data
The code was copied from the Alembic exporter, and some of the options are
no longer used.

Not updating the Alembic exporter itself, as this will be done in a much
larger rewrite.
2020-03-13 12:34:03 +01:00
cf9b3310c0 GPencil: Fix Noise modifier versioning
The versioning was setting the factor for all modes without checking flags.

Also cleanup some unused code.
2020-03-13 12:24:49 +01:00
91ca3c3c0b Fix T74696: Segment fault in Noise modifier using Vertex Groups 2020-03-13 12:07:36 +01:00
1ca582c651 Fix IDTypeInfo not having enough bits for ID filter flag 2020-03-13 12:06:29 +01:00
3652870483 GPencil: Cleanup unneeded check 2020-03-13 11:16:02 +01:00
de9c7bae7b GPencil: Join Tint and Vertex Color modifier
Both are doing almost the same and can be merged. This reduce complexity for user and less code to maintain.

Reviewed By: mendio, pepeland, fclem

Differential Revision: https://developer.blender.org/D7134
2020-03-13 10:28:59 +01:00
df032580c1 Fix info showing multi-line reports reversed (upside-down)
Also, only show the icon once per report.
2020-03-13 20:14:33 +11:00
Jeroen Bakker
54743dbf09 DeformMod: Performance by reusing buffers
The Deform modifiers was reallocating buffers that only fit the vertices
of the inner loop. This patch first counts the maximum needed buffer and
allocates one.

When using the daily dweebs animation file the playback performance went
from 0.66 fps to 0.93 fps.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D7132
2020-03-13 09:28:58 +01:00
1f0b21e713 Cleanup: pass const args (mostly Scene & RenderData) 2020-03-13 17:27:11 +11:00
fa823f0af8 Fix boundary edges detection ignoring Face Set visibility
If one of the faces connected to a vertex is hidden in the face sets, we
can assume that the vertex is part of a boundary edge, so it should be
cosidered like that in all automasking and edge detection functions.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7126
2020-03-12 20:47:31 +01:00
69eaa19340 Fix flood fill operation not taking into account hidden vertices
The idea of the visibility system is that tools should behave like
hidden vertices do not exist, so the flood fill operation should ignore
hidden vertices for all operators.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7125
2020-03-12 20:45:06 +01:00
b0271c6e40 Use golden ratio conjugate for Face Sets hue generation
The face set ID is sequential, so implementing this was straightforward.
Suggested by Jeroen Bakker

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7123
2020-03-12 20:43:38 +01:00
53c03d4679 Fix Face Set operators not modifying sigle poly Face Sets
The face_set_set function which sets a face sets given a vertex index
can ignore all modifications to hidden face sets, so we can skip all
vertex visibility checks outside that function. This makes the code
faster, simpler and fixes multiple bugs.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7122
2020-03-12 20:38:57 +01:00
9dcd6ba3eb Fix T74646: Pick a random face set to be rendered white when randomizing the colors
The previous solution was also working fine as the white face set has no
meaning, but now it is a little bit more random. Also, bigger face sets
have more chance of getting the white color.

Reviewed By: jbakker

Maniphest Tasks: T74646

Differential Revision: https://developer.blender.org/D7111
2020-03-12 20:37:49 +01:00
88fd2b1dd5 Fix T74648: Do not relax with 0 neighbors or no vertex normal
The mesh provided in the report has 0 area faces and overlapping
vertices, causing the relax code to fail when calculating the plane to
constraint the vertex movement. Now it works fine both in the brush and
in the mesh filter.

Reviewed By: jbakker

Maniphest Tasks: T74648

Differential Revision: https://developer.blender.org/D7109
2020-03-12 20:36:49 +01:00
088b92b92c Fix mesh shrinking when using the relax mesh filter.
If the relax mesh filter was used on a non manifold mesh with open
boundaries, all the vertices were relaxed and the mesh was shrinking.
This was an unintended behavior that was making the filter unusable with
these meshes.

The mesh filter is now initializing an automasking buffer using the same
boundary automasking function from the brush code. Now edges are
preserved and the relax filter works as it should.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7097
2020-03-12 20:35:52 +01:00
472534d16e Fix memory leak in recent Cycles image texture refactor 2020-03-12 20:30:49 +01:00
2050baa139 GPencil: Move Vertex Paint mode to topbar
It's more easy to find in the topbar
2020-03-12 20:29:04 +01:00
c1290a1d1f GPencil: Fix color management in Vertex Paint tools
The brush is using sRGB and need to be Linear
2020-03-12 19:39:10 +01:00
649fdc7938 Fix T73049: Drag & drop on overlapping panels behaves incorrectly
Reviewers: brecht, Severin

Differential Revision: https://developer.blender.org/D7024
2020-03-12 19:36:13 +01:00
11e4827738 Fix T74670: crash during copy paste of objects.
Embedded data should always be considered as outside of Main database
here.

Note that it's a bit of an edge case to decide whether those should
always have their `LIB_TAG_NOMAIN` set too, or not? For now, let's keep
things as they are here.
2020-03-12 18:08:11 +01:00
4669dfe2cc Expose 'is embedded data' ID flag to RNA.
Relevant currently for root node trees and master collections.
2020-03-12 18:08:11 +01:00
38ba022858 Fix T66505: Dope Sheet shows empty Grease Pencil/Annotation layers
The behaviour of GP layers is the same as annotation layers: they show
in the dope sheet regardless of whether they have frames or not. This is
easily resolved by adding some extra filtering.
2020-03-12 17:33:48 +01:00
741888ce08 Cleanup: simplified Grease Pencil animdata filter
Part of the function was following an "if-ok: do-this" pattern, and then
mid-function switched to a "if-bad: skip" pattern. The function now just
uses the latter.

No functional changes.
2020-03-12 17:33:48 +01:00
26bea849cf Cleanup: add device_texture for images, distinct from other global memory
There was too much image texture specific stuff in device_memory, and too
much code duplication between devices.
2020-03-12 17:28:55 +01:00
75be60a667 Fix build error with recent OpenImageIO versions 2020-03-12 17:19:57 +01:00
f130c5ddb6 EEVEE: Update Preview file with new lightcache 2020-03-12 17:03:58 +01:00
5c427f4b17 GPencil: Fix unreliable comparison 2020-03-12 16:34:05 +01:00
b86be9b214 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-12 15:58:03 +01:00
cb6cec904f Merge branch 'master' into temp-openxr-ghostxr 2020-03-12 15:55:48 +01:00
63ee3db961 Fix T73228: UI shows settings of wrong marker when movie clip is offset 2020-03-12 15:53:52 +01:00
5929dd7129 Fix T73212: Gizmo's are still interactive when behind nodes 2020-03-13 01:29:06 +11:00
85ea7dfc54 Cleanup: move gizmo handling into a function 2020-03-13 01:29:06 +11:00
fe5933a972 Fix T71961: Soft body behavior is incorrect when CTRL + F12 animation is rendered.
The softbody modifier was missing the transform depsgraph relation and
thus the object matrix would not get updated during animation render.
2020-03-12 15:29:50 +01:00
37a07f812b Cleanup: remove unused node tree user counting functions 2020-03-12 13:23:02 +01:00
16ed7aebf2 Bug report preset update (last worked version)
I updated the "Worked" field in the online form but forgot to do it for
the oeprator from within Blender.
2020-03-12 11:14:53 +01:00
6c707aad6a Fix T74605 Key Indicator for motion paths not updating for objects
This fixes a functional change in 4db2a08281,
which was marked as 'should have non-functional changes only'.
2020-03-12 11:08:45 +01:00
4ba6a00afc GPencil: Change Build modifier UI layout for Influence Filters
The layer filter was not following the standard layout
2020-03-12 10:39:41 +01:00
8363e10ccc Fix T74659: Seaching for operator crashes Blender
The poll function was not checking the paint pointer.
2020-03-12 10:17:48 +01:00
21f016f010 DrawManager: Pack Draw State Bits
Some draw state bits are mutual exclusive. This patch will free some
draw state bits by packing the mutual exclusive bits in a mask.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D7088
2020-03-12 09:35:27 +01:00
456595fd39 Fix T74392: HDRI preview spheres appear in render passes and reflections
Do not render HDRI Previews when a renderpass is active

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D7005
2020-03-12 09:27:28 +01:00
0c0895e3e6 Fix move-3D gizmo in use 2D spaces
This fixes node corner-pin and sun-beam gizmo's cursor offsets.
2020-03-12 19:17:39 +11:00
d4d9ded09b Cleanup: text view API
- Use typed enum for line_data callback.
- Pass in 'const' arguments where possible.
- Use 'r_' prefix for return arguments.
- Remove unused return value from line_get callback.
- Remove redundant casts.
2020-03-12 16:18:38 +11:00
Phil Stopford
6ce709dceb Ocean: add new spectra modes to the ocean modifier
This extends the ocean modifier to add new spectra
(Pierson-Moskowitz, Jonswap, TMA).

These models are very different to the Phillips spectrum.
They are intended for more established,
large area, oceans and/or shallow water situations.
2020-03-12 15:48:20 +11:00
1aebcdbb3a Cleanup: spelling, clang-format 2020-03-12 12:34:54 +11:00
74855969e7 Cleanup: use term suppress instead of repress
Also check MSVC instead of WIN32, for setting MSVC flags.
2020-03-12 12:13:41 +11:00
8751af6d19 EEVEE: Bump minimum probe level to make rough reflection more precise 2020-03-12 01:33:56 +01:00
27e0998a8a EEVEE: Hair: Fix wrong color when using color attribute without actual data 2020-03-12 00:43:09 +01:00
72461c09b4 Windows: Clean-up warnings originating from bullet
Bullet currently generates the majority of the warnings
on windows all of them are silly. This patch disables
all warns from bullet for now.

We should revisit this if/when we update bullet
to a newer version.

Reviewed By: sergey brecht

Differential Revision: https://developer.blender.org/D7118
2020-03-11 14:11:19 -06:00
372dcacbe4 Windows: Cleanup warning about non returning dtor
`google::LogMessageFatal::~LogMessageFatal` calls `abort`
which MSVC correctly identifies as 'not returning'
and warns about a potential memory leak.

Given this is intended behaviour and glog is not overly
concerned with shutting down the process nicely, we
can safely ignore this warning.
2020-03-11 14:07:47 -06:00
e6d0a438ab Fix T73626: crash scrubbing timeline with Cycles viewport and smoke/fire 2020-03-11 20:45:39 +01:00
6cf4861c3a Cleanup: refactor image loading to use abstract ImageLoader base class
Rather than passing around void pointers, various Blender image sources now
subclass this. OIIO is also just another type of image loader.

Also fixes T67718: Cycles viewport render crash editing point density settings
2020-03-11 20:45:39 +01:00
d8aa613d94 Cleanup: add ImageHandle to centralize image ownership logic 2020-03-11 20:35:38 +01:00
ec3eeee46b Cycles: add internal default volume shader, to be used for new volume object
This is mostly straightforward, but required some refactoring to ensure that
the default volume material does not always turn on the volume feature for GPU
rendering.
2020-03-11 20:35:38 +01:00
5a169ae2f3 Cleanup: remove foreach include from header, conflicts with OpenVDB 2020-03-11 20:35:38 +01:00
21821601f2 Fix Optix build error on Linux with some compilers 2020-03-11 20:35:38 +01:00
cbb854a98f Cleanup: Fix build warning on windows.
printf is called for a size_t (64 bit on x64) type
but the formatter is `%lu` (32 bit) leading to a
warning with MSVC.

`%zu` is the appropriate formatter.
2020-03-11 13:26:09 -06:00
33c6b269d1 EEVEE: Fix test crashing
Probe counting now needs to have proper gl capabilities initialised to run
correctly.
2020-03-11 18:52:16 +01:00
12e64e5ec1 Cleanup: Fix unused debug var warning. 2020-03-11 18:50:48 +01:00
366d951b0c GPencil: Change default hardeness for Airbrush 2020-03-11 18:02:05 +01:00
e9220d5cd0 Depsgraph: Fix crash deleting Viewer image from Outliner
Was happening when having compositor open with Viewer node attached
directly to Render Layers output.

There were two things involved here:

1. The code which was storing CoW-ed versions of IDs was checking all
   IDs for whether they are expanded or not. This was causing access
   of freed memory for deleted IDs which do not need CoW (such as IM).

   Simple fix: store ID type as a scalar and use early check before
   doing more elaborate check based on accessing fields of id_cow.

2. The code which was ensuring view layer pointer is doing CoW for
   scene. This isn't an issue on its own, but scene might have an
   embedded ID such as compositor which was actually traversed by the
   ID remap routines. This was causing remapping procedure to go into
   non-updated copy of compositor, accessing freed Viewer image ID.

   Solved by not recursing into embedded IDs for datablocks as those
   are supposed to have own copy-on-write operations which takes care
   of re-mapping.

Reported my Bastien, and also pair-coded with him.
2020-03-11 17:38:42 +01:00
Giovanni Remigi
19b46b2fca Fix Cycles crash in BVH8 build due to out of bounds memory access
Differential Revision: https://developer.blender.org/D7114
2020-03-11 17:35:11 +01:00
200695dd89 Windows: Clean-up linker warnings regarding MSVCRT.lib
For debug builds we link the against the release mode libs
for C based libraries, which are technically linked against
a different CRT, which the linker will implicitly try to link.

Which results in a linker warning about mixing the debug/release CRT.

This patch prevents the implicit linking of the release
CRT in debug configurations for sub projects that had issues
with it.
2020-03-11 10:33:12 -06:00
a9c0ad53e2 Cleanup: Typo in comments. 2020-03-11 17:29:20 +01:00
a54e17e52d LibQuery: Add option to NOT process embedded IDs.
Request from depsgraph department, which does basically consider those
embedded IDs as any other data-block (unlike any BKE ID management code).
2020-03-11 17:26:58 +01:00
7dd0be9554 EEVEE: Replace octahedron reflection probe by cubemap array
We implement cubemap array support for EEVEE's lightcache reflection probes.
This removes stretched texels and bottom hemisphere seams artifacts caused
by the octahedral projection previously used.

This introduce versioning code for the lightcache which will discard any
lightcache version that is not compatible.

Differential Revision: https://developer.blender.org/D7066
2020-03-11 17:12:16 +01:00
c476c36e40 Workbench Simplification Refactor
This patch is (almost) a complete rewrite of workbench engine.
The features remain unchanged but the code quality is greatly improved.
Hair shading is brighter but also more correct.

This also introduce the concept of `DRWShaderLibrary` to make a simple
include system inside the GLSL files.

Differential Revision: https://developer.blender.org/D7060
2020-03-11 17:12:16 +01:00
f01bc597a8 Cleanup: stop encoding image data type in slot index
This is legacy code from when we had a fixed number of textures.
2020-03-11 17:07:17 +01:00
9910803574 Fix Cycles link error with debug + asan after RTTI changes 2020-03-11 17:05:15 +01:00
9ef7759bf0 Fix (unreported) bad user refcounting of viewer image ID.
This is typical case where you do not want to use actual ID refcounting,
but only the shallow 'user real' (aka 'user one') system...
2020-03-11 16:51:53 +01:00
dd8ef89633 Remove leftover from merge conflict 2020-03-11 16:31:50 +01:00
5cca2f041d Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-11 16:28:43 +01:00
00f83ec125 Cleanup and correct wrong bpy.app.build_options usage 2020-03-11 16:27:48 +01:00
e1698e3750 Windows: Clean-up warning while building blendthumb
Casting a 64 bit pointer to a 32 bit DWORD gave 2 warnings.
Solved by storing the actual DWORD in the registry table.

Would have preferred to use a union, but C++ doesn't let you
initialize anything other than the first field, and C99 style
initializers are not supported until C++20, so this solution
will have to do until then.
2020-03-11 09:27:35 -06:00
6a632f11c8 GPencil: Add missing Layer buttons in Dopesheet header and remove unneeded options
Update Dopesheet header to include missing buttons, remove Scene Active only buttton and also removed duplicated search box.

The removed options come from old 2.7x version and they are not required now.

Reviewed By: mendio, pepeland

Differential Revision: https://developer.blender.org/D7107
2020-03-11 16:10:47 +01:00
a2d04deda7 Remove in-place call to create reports-popup
To be replaced by D7113.
2020-03-11 15:34:49 +01:00
b198cef89f Fix T74516: Armature Crash on Select Similar Group
Select Similar Group and Select Similar Shape had this issue since they
were added. Basically it assumes there is pose data which in some cases
it does not.
2020-03-11 15:32:21 +01:00
Brecht Van Lommel
b9f6d033be Eevee: internal support for arbitrary number of volume grids
This has no user visible impact yet since smoke volumes only support a fixed
set of attributes, but will become important with the new volume object.

For GPU shader compilation, volume grids are now handled separately from
image textures. They are somewhere between a vertex attribute and an image
texture, basically an attribute that is stored as a texture.

Differential Revision: https://developer.blender.org/D6952
2020-03-11 14:59:05 +01:00
e1e772a802 Cleanup: add comment explaining reason for volume texture swizzling 2020-03-11 14:52:55 +01:00
c4beb518de Cycles: disable RTTI only for OSL files, other libraries like OpenVDB need it
This is a bit weak since it's not entirely clear where the boundary is, but
tested to build and pass tests on all platforms.
2020-03-11 14:42:46 +01:00
Brecht Van Lommel
c8acb6dd6c Smoke: put density/color in separate textures, fixes for workbench shader
This is more in line with standard grids and means we don't have to make
many special exceptions in the upcoming change for arbitrary number of volume
grids support in Eevee.

The workbench shader was also changed to fix bugs where squared density was
used, and the smoke color would affect the density so that black smoke would
be invisible. This can change the look of smoke in workbench significantly.

When using the color grid when smoke has a constant color, the color grid
will no longer be premultiplied by the density. If the color is constant
we want to be able not to store a grid at all. This breaks one test for
Cycles and Eevee, but the setup in that test using a color without density
does not make sense. It suffers from artifacts since the unpremultiplied
color grid by itself will not have smooth boundaries.

Differential Revision: https://developer.blender.org/D6951
2020-03-11 14:42:46 +01:00
f3a33a9298 Fix/workaround Eevee tests crashing with Mantaflow
Skip light cache baking until T73921 is fixed. This should be fixed properly
but being able to run the tests at all is important now.
2020-03-11 14:42:46 +01:00
4bee1e1c8c Fix broken logic in lib_query that could lead to NULL id_owner pointer.
Issue revealed by own recent cleanup in rB8820ab4, and moticed by
@brecht, thanks.

Note that am not 100% sure whether we should allow call on lib_query
without a proper valid owner_id, for embedded data-blocks. But this can
be investifated later, so far things have been working like that.
2020-03-11 14:37:38 +01:00
836b99ce49 Fix T74296: Free depsgraph when view layer is removed
Reviewers: sergey

Differential Revision: https://developer.blender.org/D7110
2020-03-11 14:18:22 +01:00
8f327fb070 Cleanup: Add comments on GPU data and Ghost context usage 2020-03-11 14:14:27 +01:00
6eeaecdd67 Cloth: Copy point cache settings when copying cloth modifier
This fixes the issue mentioned in the comment in T74515.

Reviewers: mont29

Differential Revision: https://developer.blender.org/D7104
2020-03-11 13:43:58 +01:00
5cb2861420 Fix Cycles incorrect result when compressing some 8 bit log colorspace images
Don't clamp and do premultiply after color space conversion.
2020-03-11 12:59:29 +01:00
68c0d77b0c Cleanup: rename 'private' to 'embedded' for sub-data IDs.
'Private' can be a rather confusing term, especially when considering
its meaning in programming languages.

So now root node trees and master collections are 'embedded' IDs
instead.
2020-03-11 12:53:10 +01:00
8820ab41bd Cleanup in ID remapping code re owner_id vs. self_id.
The former is always a real, in-Main data-block, while the later, when
different, should be one of those embedded 'private' IDs (like root node
ree or master collection).
2020-03-11 12:53:10 +01:00
f8c3ccf398 Add more info to blender_oculus batch file 2020-03-11 12:35:18 +01:00
7c11e45f5f Cleanup: Address various review comments 2020-03-11 12:34:23 +01:00
8b2072868d Cleanup: spelling 2020-03-11 21:39:56 +11:00
792335cfab Cleanup: Run clang-format on all affected files 2020-03-11 11:26:42 +01:00
b381eba6c7 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-11 11:26:05 +01:00
796683db8e Cycles: add view layer setting to exclude volumes, like hair and surfaces 2020-03-11 11:25:57 +01:00
066d755e47 Cleanup: Clang-format 2020-03-11 11:25:49 +01:00
f2018ba492 Cleanup: Remove unused Ghost window function 2020-03-11 11:23:59 +01:00
b70a13fb66 UI: show more digits for adaptive sampling noise threshold 2020-03-11 10:54:28 +01:00
476c0eab4a Fix T74315: Cloth brush breaks orbit around selection
Reviewers: pablodp606

Differential Revision: https://developer.blender.org/D7095
2020-03-11 10:30:52 +01:00
e1b70e9f9c Fix T74635: GPencil RMB-menu brush settings not working in Sculpt and Weight Paint modes 2020-03-11 10:14:42 +01:00
f2c64517b5 Fix T74607: Modifier key click events ignore mouse wheel
Alt-Wheel would sent Alt-Click event, prompting to switch tools.
2020-03-11 20:09:37 +11:00
d195deef5c Cleanup: clang-format 2020-03-11 19:23:52 +11:00
Greg Neumiller
d0618570eb UI: edit modifier messages to clarify where auto-smooth is set 2020-03-11 19:19:29 +11:00
1c9829f351 GHOST: tests now build again
GLX gears work as expected, multitest_c only creates windows
but misses font drawing still.
2020-03-11 15:17:27 +11:00
15983243a4 Cleanup: remove bitmap font drawing ifdef from MultiTest.c 2020-03-11 15:01:14 +11:00
4184f890fd GPU: minor changes to support standalone GHOST builds
- Move gpuPush/Pop from GPU_draw.h into GPU_state.h
  as this is for pushing/popping state.
- Add 'GPU_STANDALONE' define, to bypass use of user-preferences
  for theme colors and pixelsize, as well as pbvh init/free functions.

Needed to get GHOST tests working again.
2020-03-11 14:52:57 +11:00
f9cca12886 Fix T74596: Gpencil invert button was not working for Sculpt brushes
The button was not checked, only the pen position or the control key.
2020-03-10 20:12:11 +01:00
8126e4ac14 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-10 18:23:46 +01:00
cfa4302570 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-10 18:23:32 +01:00
e7ceb041cf Merge branch 'master' into temp-openxr-ghostxr 2020-03-10 18:22:40 +01:00
9c5a120ba2 GPencil: Use high precision float buffer for final rendering
This avoid color drifting due to R11G11B10 buffers.
2020-03-10 18:17:42 +01:00
fa09b900c2 Fix T74625 GPencil: Airbrush doesn't paint anything 2020-03-10 18:11:25 +01:00
0f1f751785 Fix T74525: Fluid caches overwrite each other by default
Reviewers: sebbas

Differential Revision: https://developer.blender.org/D7093
2020-03-10 17:33:05 +01:00
a6d7280b8e Fix T74200: Alembic import crashes Blender
I've added a very minimal mesh validation before the Alembic mesh is actually
converted to a Blender mesh. This prevents a specific crash with an example
file attached to T74200.
2020-03-10 17:16:12 +01:00
7c027f9480 Cycles: Fixed Shadow and Mist passes with adaptive sampling.
This also fixes a side-effect where turning on UV pass but leaving
Shadow pass turned off destroyed the Combined pass.
2020-03-10 16:50:51 +01:00
Julian Eisel
c02ba3653a Color transforms were fixed in Windows MR -> disable our workaround 2020-03-10 16:48:18 +01:00
be20bf2fc0 Fix T74617: Gpencil Sculpt Strength brush gets wonky results
Changed how the strength is calculñated and reduce the factor to get a smoother result.
2020-03-10 16:45:51 +01:00
9abf5ba1d5 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-10 16:34:26 +01:00
1619a5d8e9 Fix rendering artifacts when changing Face Sets visibility
All sculpt operators and brushes need to use ID_RECALC_SHADING even when
PBVH rendering is not used.
2020-03-10 16:32:09 +01:00
1cc81d39c4 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-10 16:21:15 +01:00
dc8bb3f3a0 Cleanup: Clarify places to look for subversion bump 2020-03-10 16:17:49 +01:00
e38cd1741e Remove old files/changes, git keeps bringing them back... 2020-03-10 16:11:44 +01:00
27bc3388da Minor cleanup: Avoid forward declaration 2020-03-10 16:05:06 +01:00
8b8142c13a Remove obscure unique_oxr_ptr, implement alternative RAII for swapchain
Add an own class for the swapchain, through which we can ensure correct
RAII resource management.
2020-03-10 16:00:06 +01:00
b37482bc3d Fix T74613: Assign the default face set color in the versioning code
A default face set color was not being set in previously saved meshes,
so it will always render the default face set with a random color until
the colors were recalculated.

Bump subversion to 283.8

Reviewed By: dfelinto

Maniphest Tasks: T74613

Differential Revision: https://developer.blender.org/D7094
2020-03-10 15:55:50 +01:00
e06888cf89 Cleanup: Add comment explaining DPI influence on RNA pixel-properties
Good to be explicit about the fact that we may still use the pixel
property sub-type when DPI will be applied.
See comments in https://developer.blender.org/D7077.
2020-03-10 15:19:22 +01:00
d55231e5a1 UI: Clarify 3D View Grid Size Tooltip
The 3D view grid size property is a multiplier, not the size of the grid itself.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7085
2020-03-10 08:44:30 -05:00
a52f6d7a31 Fix T66269: Menu for Extrapolation Mode is disabled in Graph Editor
The Extrapolation Mode menu in the graph editor channel list was
incorrectly using the operator for the Action/Dopesheet editor. The
operator was even missing in the generic dopesheet hotkeys, so
{key Shift E} was listed as hotkey but didn't work. This is now all
fixed.
2020-03-10 14:18:19 +01:00
a801487ef5 Fix T65076: Missing EasingType implementation on the Dopesheet
EasingType was implemented rBdaccaa713b6e for the GraphEditor (but never
made it to the Dopesheet). If you can select Easing Mode in the
DopeSheet, then you should also be able to select the associated Easing
Type.

Thanks @lichtwerk for the initial implementation.

Maniphest Tasks: T65076

Differential Revision: https://developer.blender.org/D6094
2020-03-10 14:02:40 +01:00
ca717f0489 Fix T74425: Cannot texture paint an images sequence anymore
Caused by the introduction of UDIM (rBc30d6571bb47).

We need to make sure the tiles ImageUser is set up correctly [especially
the framenr], otherwise BKE_image_acquire_ibuf() and friends will fail
to find the correct ImBuf.

Also instead of initializing a minimal BKE_imageuser_default, now use
an appropriate ImageUser if avaliable and pass this around (instead of
just the tile_number). 2D painting can reuse the Image Editor ImageUser,
for 3D painting we still rely on a default ImageUser in most places, but
at least set the framenr correctly].

This also fixes crashes when doing image operations such as inverting or
resizing on images in a sequence in the Image Editor.

This also fixes color sampling (S) from the 3DView going wrong for image
sequences (would fallback to OpenGL sampling because an ImBuf could not
be found).

Maniphest Tasks: T74425

Differential Revision: https://developer.blender.org/D7022
2020-03-10 13:47:33 +01:00
212660f467 Fix T73369: corner pin & sun-beam nodes gizmos are too big
Note that dragging isn't working well,
however this was an issue in previous releases.
2020-03-10 23:30:59 +11:00
85cdf9a1b9 Fix T74612: file browser thumbnails not showing and using CPU continuously
This started happening after changing filter ID to 64 bit in rB2841b2be3949,
however there was a pre-existing error here in the comparison to detect updates
to filter flags.
2020-03-10 13:11:32 +01:00
Lucas Veber
915998111b Modifiers: Corrective Smooth modifier, new Scale parameter
When scaling the root bone of a rig to apply a global scale, the
corrective smooth modifier results in wrong deformation due to incorrect
scaling. The delta calculations are not taking into account any scale
value.

To fix it, a scale property is added to the modifier, allowing to set
manually the scale value for the deltas by simply multiplying the
vectors by this value. There is a similar implementation in Maya's Delta
Mush deformer. This property can be for example driven by the scale of
the root bone of the rig, to dynamically update when the animator scale
this bone.

Reviewed By: brecht, sybren

Differential Revision: https://developer.blender.org/D6622
2020-03-10 12:49:08 +01:00
982b498c22 OVERLAY: Viewport Background Color visible in Material Preview Mode
When user used a custom background color, this color was also visible in
material preview mode, when the world opacity was less than 1. This
patch will draw the theme color as it was used to.
2020-03-10 11:36:39 +01:00
dc3ff1db3f Fix T74585: Crash when scrolling viewport shading pop-up
Was dereferencing NULL pointer. Mistake from d5572eacc5.
2020-03-10 11:21:00 +01:00
9f48852ba4 Buildbot: Enable version character for development builds
Allows to have 2.82a as a beta version on buildbot.
2020-03-10 10:23:28 +01:00
1aa7c4c28a GPencil: Cleanup float indicator 2020-03-10 08:58:25 +01:00
Stefan Werner
811569dc11 Cycles: Using OpenCL popcount() in PMJ sampler. 2020-03-10 08:53:30 +01:00
7b8ac04d86 Fix T74601: Cut Particles to Shape fails for transformed object 2020-03-10 16:55:41 +11:00
5aa54207e1 Fix sequencer Slip tool skipping offset=0 case
The slip tool wasn't being applied when the offset was zero.

This caused modal operation to skip applying this offset while dragging.
2020-03-10 16:09:57 +11:00
5184328991 Cleanup: replace term 'terrible' from sequence slip
Joke from branch name, makes comments unclear.
2020-03-10 15:53:18 +11:00
94a5b7a2e2 Fix vertex slide deselecting faces
Regression from 9a5df92c1b
2020-03-10 15:15:52 +11:00
163e6b348f Cleanup: GPencil: Remove uneeded cast 2020-03-10 05:01:13 +01:00
71712d828d GPencil: Fix RNA range for uv_rotation 2020-03-10 04:47:37 +01:00
c971e812d5 Fix T74536: Grease pencil immediately crashes on macOS
It seems like OSX drivers are using standard attributes for passing
gl_VertexID and gl_InstanceID to the vertex shader, and count them in the
limit of MAX_VERTEX_ATTRIBS.

This patch make sure to never use more than 13 attributes by packing some
attributes together.
2020-03-10 04:47:37 +01:00
bf1b323b15 DRW: Fix wrong test condition
Fixes the warning: address of array 'cmd->draw.batch->inst' will
always evaluate to 'true'
2020-03-10 04:47:37 +01:00
ec9b836d3b Fix T74579: Filename with '\' causes assert when browsing files 2020-03-10 12:29:37 +11:00
fbe81db29a Fix IC keymap after recent GP merge
Just a simple fix here for now to keep the keymap working. Will revisit these areas to make them fit in properly with the keymap.
2020-03-09 23:23:06 +01:00
9c5522f7c8 Cleanup: compiler warnings 2020-03-09 21:58:55 +01:00
0133d66ada Fix error in grease pencil vertex paint levels operator 2020-03-09 21:58:55 +01:00
Pablo Dobarro
4652f23fa3 Fix T74354: Avoid division by 0 when calculating hardness
I could not reproduce the issue, but it looks like it was produced by
this division by 0. In any case, the code here was wrong.

Reviewed By: jbakker

Maniphest Tasks: T74354

Differential Revision: https://developer.blender.org/D6987
2020-03-09 21:19:55 +01:00
84b94f9e7b Sculpt: Edge Automasking
This automasking option protects the open boundary edges of the mesh from the brush deformation. This is needed to sculpt cloths and it works nicely with the cloth brush.
It has a Propagation Steps property that controls the falloff of the mask from the edge.

Limitations:
- The automask is recalculated at the beginning of each stroke, creating a little bit of lag in high poly meshes, but it is not necessary. This can be fixed in the future by caching the edge distances, increasing a little bit the complexity of the code.
- The boundary vertex detection in meshes is not ideal and it fails with triangulated geometry, but it is the same as in the smooth brush. After fixing this, we should refactor the smooth brush to use the API and let the automasking option manually control the affected vertices.
- It does not work in Multires (it needs to be implemented in the API). The smooth brush in Multires is also not making boundary vertices.
- The falloff has a visible line artifact on grid patterns. We can smooth the final automasking factors several iterations, but it will make the initialization much slower. This can also be added in the future if we decided to cache the distances.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6705
2020-03-09 21:16:02 +01:00
Yevgeny Makarov
04e9ba7169 UI: add menus for preferences editor
This only applies to the case where preferences are opened as an editor in
a workspace, not with Edit > Preferences in a new window.

Differential Revision: https://developer.blender.org/D7001
2020-03-09 20:18:11 +01:00
Adrian Newton
2d8d30e17b UI: make workbench viewport samples label consistent with Cycles and Eevee
Differential Revision: https://developer.blender.org/D7082
2020-03-09 20:18:11 +01:00
Adrian Newton
848a4f002d UI: add "Samples" text to audio mixing buffer size preference for clarity
Differential Revision: https://developer.blender.org/D7076
2020-03-09 20:18:11 +01:00
18e3615a68 Face Sets: Use white color for a default Face Set to enable the overlay
This introduces a variable to store a face set ID which is going to be
rendered white. When initializing a mesh or randomizing the colors, this
variable gets updated to always render a white face set. This way the
face set overlay can be enabled without adding colors to the mesh if
face sets are not in use. After creating the first face set, new colors
are generated randomly like usual.

The face set stored as default does not have any special meaning for
tools or brushes, it just affects the rendering color.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7035
2020-03-09 20:11:18 +01:00
0dfb4ac1ff Face Sets: Add relax support to Mesh Filter and Draw Face Sets
This enables a relax operation that works only on face sets boundaries,
which smooths the jagged edges that are produced when painting or
expanding face sets by sliding the topology without affecting the shape
of the mesh. This has many uses in hard surface sculpting for things
like sculpting panels or smoothing surfaces. It can also help when
working with remeshed topology as it makes the face sets looks better
and more organized if needed.

The operation is implemented as an Shift smooth in the Draw Face sets
tool, similar to the Slide/Relax tool.

The same operation is also available in the mesh filter to smooth all
the face sets boundaries uniformly or to smooth the face set under the
cursor with the Use Face Sets option.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7034
2020-03-09 20:04:05 +01:00
e702c9a700 Fix Cloth Brush not working with automasking
The cloth brush was not using the automasking values when calculating
the mask value on each vertex.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7083
2020-03-09 19:43:00 +01:00
0030e6a2fc Fix T74500: Rebuild the Face Sets datalayer after slicing the geometry
Was crashing SculptSession data will not longer be valid if the total
number of polys is modified when rendering the mesh again.
This deletes all face sets in the mesh when slicing the mask. I'll try
to add code to generate a new face set in with faces that are created
when filling the holes, but for now this avoids the crash.

Reviewed By: brecht

Maniphest Tasks: T74500

Differential Revision: https://developer.blender.org/D7049
2020-03-09 19:39:57 +01:00
503d5c0c65 Fix T74499: Add visibility checks to Face Sets creation operations
Create face sets by visibility needs to check if all face sets of a
vertex are visible to set the new face set. I renamed the functions to
make this more cleare in the API.

I also added a visibility check when creating by mask to avoid modifying
hidden areas.

Reviewed By: brecht

Maniphest Tasks: T74499

Differential Revision: https://developer.blender.org/D7048
2020-03-09 19:33:22 +01:00
c65b9fb825 Sculpt: Remove hardcoded hardness from Clay brush
Hardness is now a property implemented for all brushes, so this is no
longer needed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7078
2020-03-09 19:29:18 +01:00
6eb76f6430 Fix T74492: Reset Face Set data when cancelling the expand operator
The operator was resetting the mask data when cancelling instead of the
face set data, so it was crashing because mask data was not available
when starting the operator in expand face set mode.

Reviewed By: brecht

Maniphest Tasks: T74492

Differential Revision: https://developer.blender.org/D7043
2020-03-09 19:25:38 +01:00
a540d16ee8 Cleanup: Move Face Sets random color generation to its own function
This way we can change the color generation easily if we want to improve
it in the future. I also added more values to randomize a little bit the
saturation and value of the colors, as previously it was too easy to get
similar colors when creating new faces, forcing you to use the randomize
colors more than necessary.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D7042
2020-03-09 19:14:18 +01:00
1131e33026 Fix T74438: Vertex-only meshes disappear in wireframe mode
The problem happens because, in wireframe mode, `bool use_wire` is
always `true`, so the function that draws all edges is the called.

The solution is set `use_wire` as `false` when the mesh has no edges.

This matches the behavior of blender 2.79.

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D7041
2020-03-09 15:09:26 -03:00
d60c71f33d Cleanup: Avoid macros, don't print source location for errors 2020-03-09 18:58:20 +01:00
Adrian Newton
a468368540 UI: use pixel units for tile sizes and node auto-offset margin
Differential Revision: https://developer.blender.org/D7077
2020-03-09 18:49:42 +01:00
916efac0c8 Cleanup: Address various review comments 2020-03-09 18:47:31 +01:00
be2e41c397 Cleanup: Move BKE_animdata_free() call out of each IDType free data.
This has been long standing TODO...

Note that remaining usages of BKE_xxx_delete should all be carefully
checked for and utilmately nuked in favor of `BKE_id_delete()`, think we
still have quiet a few bugs hidden in those (code seems to usually
assume those functions do a full ID deletion, which is not the case).
2020-03-09 18:43:11 +01:00
6472a721f0 Cleanup: Remove unused switch/case from BKE_lib_id.
Only covers direct usages of new callbacks from IDTypeInfo.

We still have a lot of those switch/case, many can probably go away
with minimal refactor now, but that will be for later.
2020-03-09 18:43:11 +01:00
ef20e1d378 Add comments to C-API function declarations 2020-03-09 18:37:16 +01:00
b080de79db Alembic: constraint for transform animation is using world matrix again
In rB7c5a44c71f13 I changed the way transform matrices are loaded from
Alembic. Instead of having the Alembic importer convert matrices from
local (in the Alembic file) to World (to pass to the constraint handling
the animation of transforms), I set the constraint space to
`CONSTRAINT_SPACE_LOCAL`.

This worked thanks to rB7728bfd4c45c. However, that commit was reverted,
which meant that for parentless objects `CONSTRAINT_SPACE_LOCAL` no
longer means "local space".

The situation is resolved by setting the constraint to world space
again, and computing the world matrix in the Alembic importer.
2020-03-09 18:27:18 +01:00
e672cf11c3 Cleanup: palette: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
3e9dbe7f62 Cleanup: GreasePencil: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
c010290e75 Cleanup: Ipo: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 18:09:23 +01:00
214cc3c245 Fix failing assert because of invalid region coordinates
Steps to reproduce were:
* Disable tool settings region in 3D View (View > Tool Settings)
* Split the 3D View and drag all the way down

The removed code doesn't seem to be needed anymore. Tested this on hiDPI
too, seems fine.

These kind of fixes are always tricky, so I wouldn't be surprised if
there are any issues caused by this.
2020-03-09 18:02:08 +01:00
32fc22db56 Fix T72253: Mantaflow adaptive domain cuts off
The issue of T72253 was that the density threshold (RNA adapt_threshold) was considering cells as empty cells too early and thus also shrinking the domain too early. The fix for this is to use smaller threshold values for the adaptive domain. This fix gives more flexibility in the UI to do just that.
2020-03-09 17:42:38 +01:00
Yevgeny Makarov
07bdbeda84 UI: avoid blurring of view navigation widgets at some UI scales
Differential Revision: https://developer.blender.org/D6734
2020-03-09 17:11:24 +01:00
Ulysse Martin
aca222c3da Fix unnecessary grease pencil drawing when there are no grease pencil objects
Differential Revision: https://developer.blender.org/D6551
2020-03-09 17:11:24 +01:00
Yevgeny Makarov
bada2dcafd UI: improve layout of keymap preferences, more consistent with other areas
Differential Revision: https://developer.blender.org/D6592
2020-03-09 17:11:24 +01:00
Kai Jægersen
6f4612a7cc Python API: allow overriding context.workspace for workspace operators
Differential Revision: https://developer.blender.org/D6867
2020-03-09 17:11:24 +01:00
Yevgeny Makarov
da101eddef UI: input preferences layout tweaks for keymap search and zoom settings
Differential Revision: https://developer.blender.org/D6979
2020-03-09 17:11:24 +01:00
Johan Walles
8bc8713beb Cleanup: avoid (harmless) race condition reported by Helgrind
Differential Revision: https://developer.blender.org/D7058
2020-03-09 17:11:24 +01:00
Adrian Newton
58e6306b15 UI: reorder viewport/render toggle in particles for consistency with modifiers
Differential Revision: https://developer.blender.org/D7069
2020-03-09 17:11:24 +01:00
Adrian Newton
5543572cd2 Cleanup: remove unnecessary space at end of label
Differential Revision: https://developer.blender.org/D7070
2020-03-09 17:11:24 +01:00
Adrian Newton
1276380fd2 UI: add space before px unit in Eevee properties for consistency
Differential Revision: https://developer.blender.org/D7072
2020-03-09 17:11:24 +01:00
Eitan
3923738c8f UI: rename View Frame to Go to Current Frame in video sequencer
For consistency with other editors.

Differential Revision: https://developer.blender.org/D7025
2020-03-09 17:11:24 +01:00
324e24ee38 Fix layout.prop invert_checkbox not working combined with icons
Contributed by Valentin (Poulpator).

Differential Revision: https://developer.blender.org/D7027
2020-03-09 17:11:24 +01:00
81c18c2507 Fix part of T73921: hang with Eevee light baking and Mantaflow
Now it crashes instead.
2020-03-09 17:11:24 +01:00
29b405a327 Overlay: Add antialiasing to particle sprites 2020-03-09 17:09:32 +01:00
3912a2a227 Fix T74438: Overlay: Loose verts and particle not draw in some conditions
This was caused by a missing output variable for lineOutput.
This triggered some undefined behavior.
2020-03-09 17:09:32 +01:00
4d0d43ce8e Cleanup: FreestyleLineStyle: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
dab1d14a51 Cleanup: Mask: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
6965bcc0c9 Cleanup: MovieClip: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 16:56:53 +01:00
d43fbbb307 Cleanup: Silence warnings 2020-03-09 16:34:55 +01:00
29f3af9527 GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293
2020-03-09 16:27:24 +01:00
dcb9312687 Depsgraph: fix crash caused by removing too many NO-OP nodes
Unused no-op operation nodes are not bound to a callback function, and
have no outgoing relations. Incoming relations of such nodes are removed
since ff60dd8b18. However, this was done
too broadly, causing too many relations to be lost and indirectly linked
objects to be unevaluated.

This commit introduces a `DEPSOP_FLAG_FAKE_USER` flag for operation
nodes, which indicates they are not to be removed, even when they appear
to be unused.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D7074
2020-03-09 16:05:33 +01:00
93f6369573 Fix T74533: Crash when entering sculpt mode
Apparently this happened when the object is in a flat view and has
customdata `CD_SCULPT_FACE_SETS`

Differential Revision: https://developer.blender.org/D7073
2020-03-09 12:00:11 -03:00
598ab525da Cleanup: Replace ABS/SQUARE/CUBE with function calls
While it might be handy to have type-less functionality which is
similar to how C++ math is implemented it can not be easily achieved
with just preprocessor in a way which does not have side-effects on
wrong usage.

There macros where often used on a non-trivial expression, and there
was at least one usage where it was causing an actual side effect/bug
on Windows (see change around square_f(sh[index++]) in studiolight.c).

For such cases it is handy to have a function which is guaranteed to
have zero side-effects. The motivation behind actually removing the
macros is that there is already a way to do similar calculation. Also,
not having such macros is a way to guarantee that its usage is not
changed in a way which have side-effects and that it's not used as an
inspiration for cases where it should not be used.

Differential Revision: https://developer.blender.org/D7051
2020-03-09 14:47:59 +01:00
ee5d7bc16b Cleanup: clang-format 2020-03-09 10:11:31 -03:00
a922a097ef Transform Snap Object: Remove depsgraph when creating context
Currently, this change does not bring functional changes.
But it is necessary to extend the use of the snap system for gizmos,
since, after a Undo, the `depsgraph` pointed by the `snap_context`
has its memory invalidated.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D7013
2020-03-09 10:02:11 -03:00
3a10c61a7d Cleanup: ParticleSettings: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
b9d1026ce0 Cleanup: PaintCurve: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
b57d3afb76 Cleanup: CacheFile: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
613148ce5b Cleanup: WorkSpace: Move to IDTypeInfo and remove unused BKE API. 2020-03-09 12:49:04 +01:00
0de5156a24 Cleanup: WindowManager: Move to IDTypeInfo and remove unused WM API.
Getting rid of one static 'registered' callback in BKE, yeah!
2020-03-09 12:49:04 +01:00
f73a6c517c Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-09 11:56:13 +01:00
6e13062ddb Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-09 11:55:47 +01:00
73791a755a Merge branch 'master' into temp-openxr-ghostxr 2020-03-09 11:31:48 +01:00
f881162f81 Revert "Constraints: remove special meaning of Local Space for parentless Objects."
This reverts commit 7728bfd4c4.

Although this brings back an inconsistency in the behaviour of
constraints on objects and bones, people were relying on the old
behaviour, and the new behaviour broke their files.

It is still desired to remove this inconsistency, but it will happen
more gradually.
2020-03-09 10:44:55 +01:00
Stefan Werner
bc6bbe5fac Fix T74537: Fixed out of bounds memory access in Cycles' PMJ sampler. 2020-03-08 21:31:47 +01:00
668b64380a Cleanup: Sound: Move to IDTypeInfo and remove unused BKE API. 2020-03-08 20:45:00 +01:00
014f78b5b5 Cleanup: Speaker: Move to IDTypeInfo and remove unused BKE API. 2020-03-08 20:10:07 +01:00
0d05fd9b4c Install_deps: fix wrong XR_OPENXR_ROOT_DIR parameter for CMake.
Should be `XR_OPENXR_SDK_ROOT_DIR`.`
2020-03-08 17:14:58 +01:00
7f404f1c74 Fix T74395: Box interpolation does not support repeat extrapolation
Reviewers: fclem

Differential Revision: https://developer.blender.org/D7009
2020-03-08 14:43:06 +01:00
bc2343d5c3 Cleanup: comments in main()
Clarify references to functions.
2020-03-08 13:48:52 +11:00
52dc1ddaa0 Revert "Outliner: Allow deleting entire selection"
This reverts commit 62f238a65e.

This prevents undo steps from being stored.
2020-03-08 13:48:21 +11:00
62f238a65e Outliner: Allow deleting entire selection
This allows deleting both collections and objects in the outliner
selection at the same time. This only works using the keyboard shortcuts
(X or Delete).

While this works, a more robust solution should be implemented later to
allow deleting the whole selection from the context menu as well.
2020-03-07 14:46:22 -07:00
5539b68009 Fluid: Optimization for smoke simulation (multigrid)
The solver will now automatically detect static scenes (no moving obstacles) and use a slightly faster pressure solve in those cases.
2020-03-07 19:57:06 +01:00
9867a82072 Cleanup: Outliner: Remove unused parameter
Searching back in the outliner did not require the unused SpaceOutliner
parameter.
2020-03-07 11:26:02 -07:00
6b49a9db52 Fix T74513: Wrong naming in some Face Set comments and operators
Missing changes from one of the renamings of the initial face sets
patch.

Reviewed By: brecht

Maniphest Tasks: T74513

Differential Revision: https://developer.blender.org/D7054
2020-03-07 16:42:28 +01:00
db1d711458 Fix T74501: Wrong initial iteration when using mask expand
The initial iteration for all symmetry areas is always 0. We were using
1 for the main stroke, so it was 1 step behind.

This was broken for expanding masks and face sets, but with face sets it
is more noticeable.

Reviewed By: brecht

Maniphest Tasks: T74501

Differential Revision: https://developer.blender.org/D7050
2020-03-07 16:41:41 +01:00
7760cec5dc Fix T74498: Do not iterate over hidden vertices when using the transform tool
By using PBVH_ITER_UNIQUE hidden vertices are skipped, like in the rest of
the brushes and tools.

Reviewed By: brecht

Maniphest Tasks: T74498

Differential Revision: https://developer.blender.org/D7047
2020-03-07 16:40:19 +01:00
946d39f688 UI: move Cycles adaptive sampling settings to own subpanel 2020-03-07 12:40:06 +01:00
8a5a306a83 Fix key release event activating click-drag
A handled release event could still trigger a click-drag afterwards.
2020-03-07 18:21:01 +11:00
2534dffaa5 WM: include repeat value in WM_event_print 2020-03-07 16:26:22 +11:00
ef5c6361a5 Cleanup: replace BLI_make_file_string with BLI_join_dirfile for the file-selector
In these cases the file selectors directory is already expanded.
2020-03-07 13:52:41 +11:00
0964865568 Cleanup: replace BLI_make_file_string with BLI_join_dirfile where possible
Use 'BLI_join_dirfile' for joining paths that don't need to expand '//'.
2020-03-07 13:26:23 +11:00
8fb1ea857f Include file system encoding in 'System Info' operator
Help troubleshooting file system encoding issues.
2020-03-07 11:53:14 +11:00
dcdcc23488 Fix T74504: Cycles wrong progress bar with CPU adaptive sampling 2020-03-06 23:46:58 +01:00
b31b44c223 Fix error in Cycles Optix adaptive sampling after recent cleanup 2020-03-06 23:46:58 +01:00
afe6df1487 Cleanup: VFont: Move to IDTypeInfo and remove unused BKE API
This was particularly strange because we had a _free_data() function.
But still the one I replaced was of course the _free() one.

And we should rename the _free_data_ function later to avoid confusions.
2020-03-06 20:07:02 +01:00
558f449f8c Cleanup: Text: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 20:07:02 +01:00
7177862313 API Docs: Point to manual for Operator Cheat Sheet 2020-03-06 12:50:19 -05:00
13595c912c UI: Remove Windows 3D Object Folder Reference
Remove Windows special folder FOLDERID_Objects3D. Requires newer SDK.

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

Reviewed by Brecht Van Lommel
2020-03-06 09:33:13 -08:00
85424397b1 Cleanup: tweak Freestyle #includes in preparation for clang-format sorting 2020-03-06 17:26:32 +01:00
96e2bd8493 Cleanup: Fix forward declaration of headers 2020-03-06 17:26:32 +01:00
b2ee1770d4 Cleanup: Rename ARegion variables from ar to region
The old convention was easy to confuse with ScrArea.
Part of https://developer.blender.org/T74432.

This is mostly a batch rename with some manual fixing. Only single word
variable names are changed, no prefixed/suffixed names.

Brecht van Lommel and Campbell Barton both gave me a green light for
this convention change.

Also ran clan clang format on affected files.
2020-03-06 17:19:23 +01:00
b825a95ec3 Cleanup: Image: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 17:13:27 +01:00
f4936de918 Cleanup: Texture: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 17:13:27 +01:00
a7fb567c18 Cleanup: Material: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 17:13:27 +01:00
ae6a5629a5 Fix build error on windows
```
Error	C4013	'_VA_ELEM1' undefined; assuming extern returning int
```
2020-03-06 12:49:24 -03:00
68b6d0302a Cleanup: Action: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 16:43:09 +01:00
57daecc2cf Cleanup: Armature: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 16:43:09 +01:00
14d03af7ae Bring back code accidentally removed by previous commit
Probably got lost when resolving merge conflicts.
2020-03-06 16:41:57 +01:00
d5572eacc5 Cleanup: Reduce context usage in UI functions
Part of https://developer.blender.org/T74429.

There's a chance that this causes some issues becaue in some cases we
change from getting the window from context to getting it from somewhere
else.
2020-03-06 16:27:13 +01:00
b242cc6792 Cleanup: Lattice: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 16:23:23 +01:00
da7fcd3e52 Cleanup: MetaBall: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 16:23:23 +01:00
8c21668ee1 Cleanup: Curve: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 16:23:23 +01:00
bf6cf49133 Cleanup: Mesh: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 16:23:23 +01:00
eb522af4fe Cleanup: move Alembic, AVI, Collada, and USD to source/blender/io
This moves the `alembic`, `avi`, `collada`, and `usd` modules into a common
`io` directory.

This also cleans up some `#include "../../{somedir}/{somefile}.h"` by
adding `../../io/{somedir}` to `CMakeLists.txt` and then just using
`#include "{somefile}.h"`.

No functional changes.
2020-03-06 16:19:45 +01:00
ff60dd8b18 Depsgraph: remove unused no-op nodes after building
This is the companion of D7031. That patch adds a new DIMENSIONS node to
the depsgraph for each object that has geometry. However, this node is
only necessary when there are drivers using an object's dimensions as
variable. Since this is rare, it's easiest to remove these nodes after
they turn out to be unnecessary. This is what (almost) happens in this
patch.

Removing nodes from the depsgraph is hard, and there are no functions to
do this yet. Instead, this patch recursively removes all the incoming
relations from unused no-op nodes (i.e. no-op operation nodes without
outgoing connections). Actually removing the nodes will be left as a
future improvement.

I've tested this on a Spring file [1]. Here are there results of blender
--debug-depsgraph-time spring_02_055_A.eevee.blend and letting it run
for a while to stabilise the reported FPS:

    master: 11.7 FPS
    Just D7031: 11.7 FPS
    Just D7033: 11.8 FPS
    Both D7031 + D7033: 12.3 FPS

[1] https://cloud.blender.org/p/spring/5d30a1076249366fa1939cf1

Differential Revision: https://developer.blender.org/D7033
2020-03-06 16:19:45 +01:00
f2f8c5b2bd Cleanup: Move Multiplane Scrape brush to its own file 2020-03-06 16:00:33 +01:00
40ac8250b2 Fix narrowing from int to short when removing material slot 2020-03-06 15:56:09 +01:00
926f52edf0 Sculpt: Cleanup, remove macro re-definition 2020-03-06 15:52:36 +01:00
a16e4652e3 Fix integer overflow in BLI_mempool_as_arrayN()
`(size_t)(int * int)` will actually cast overflown integer to size_t,
which isn't what was intended here. Correct thing would be to cast
in the following manner `(size_t)int * int`.

In this particular case can as well use function which is designed to
allocate an array of memory without overflow.
2020-03-06 15:35:52 +01:00
c60366c01f Cycles: cleanup warning 2020-03-06 15:27:50 +01:00
17f08cff6a Cleanup: Collection: Move to IDTypeInfo, and remove unused BKE API.
Note: we still need BKE_collection_free since we call it from scene.c.
2020-03-06 15:27:50 +01:00
69d4aec55f Cleanup: Use the SCULPT_ prefix in all sculpt_intern functions 2020-03-06 15:24:15 +01:00
b201a67faa Cleanup: bScreen: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 15:20:04 +01:00
a5bbdd6998 Cleanup: use ELEM macro for path slash checks 2020-03-07 01:02:37 +11:00
b4f1edd98b Fluid: Revert bc2ce31d79 (changes to open boundaries)
Changes from that commit turned out to be unstable.
2020-03-06 15:01:30 +01:00
a9ac87be36 Fix T73842: UI: add cloth collision settings to Hair Dynamics panel
Since hair collisions were integrated with the cloth solver
(rBd42a7bbd6ea5), there are a couple of relevant settings which were not
exposed to the User:
- Collision Quality
- Minimum Distance (this was reported in T73842, default of 0.015m was
still limiting in certain scenarios - this can now be made smaller)
- Impulse clamping
- Collision collection

This will add a 'Collisions' panel to Hair Dynamics with those settings

Note: in contrast to 'real' cloth, self-collisions are not supported for
hair

Maniphest Tasks: T73842

Differential Revision: https://developer.blender.org/D7032
2020-03-06 14:59:02 +01:00
f9c7442479 Cleanup: bNodeTree: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 14:58:23 +01:00
165daee7cb Improve modifier error message with sculpt mode
Make it obvious that this relates to being in sculpt mode.

ref T74489

Maniphest Tasks: T74489

Differential Revision: https://developer.blender.org/D7044
2020-03-06 14:52:25 +01:00
c8ac760c59 Cleanup: tweak Cycles #includes in preparation for clang-format sorting 2020-03-06 14:44:42 +01:00
4102d67d32 Cleanup: avoid use of BLI_cleanup_dir
Some cases don't need to add the trailing slash.
Use BLI_cleanup_path in this case.
2020-03-07 00:39:28 +11:00
2d5773d11a Documentation: added bpy.msgbus description and examples
The `bpy.msgbus` namespace was not included in the documentation generation.
I've added it, and ported Campbell's examples from P563.
2020-03-06 14:29:03 +01:00
07c5ca7f2c Cleanup: Message bus, removed incorrect return type from docstring
The docstring was likely copy-pasted, and the return type was not adjusted.
Since the `bpy.msgbus.subscribe_rna()` returns nothing, I just removed the
return type documentation.
2020-03-06 14:29:03 +01:00
b839a5d076 Cleanup: remove BLI_cleanup_file
In practice, references to files rarely have trailing slashes
(by accident). Remove this function in favor of BLI_cleanup_path.
2020-03-07 00:19:01 +11:00
0b16b63d87 Cleanup: spelling 2020-03-07 00:19:01 +11:00
8bb0ac27dc Fix using wrong property name for preserve face sets when remeshing
Spotted by Roel Koster in the initial face set commit.
2020-03-06 14:17:30 +01:00
50d5050e9c Nodes: fix writing socket default values to file
Previously, `writedata` was used to store `bNodeSocket->default_value`.
There are a couple of issues with that:
* Breaks if someone tries to load the file on a big endian system (afaik).
* There is a `/* do not use for structs */` comment on `writedata`.
* Depends on `MEM_allocN_len` which should be avoided in my opinion.
* Now it is more apparent, that this should be handled by callbacks as well.

The part in `readfile.c` should work just fine still. I could also do a case
distinction there, but the code would be the same for every case for now.
Just `sock->default_value = newdataadr(fd, sock->default_value);`.

This might change, if we want to store more complex socket type specific data
that does not fit into a single struct.

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

Reviewers: brecht
2020-03-06 13:31:15 +01:00
63bb2007d8 CodeCleanup: Added View3DShading enums
Added the core enums that workbench draw engine uses.
2020-03-06 13:00:06 +01:00
f0808b53ab Cleanup: Brush: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 12:54:04 +01:00
15c834ebbf Cleanup: ShapeKey: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 12:52:52 +01:00
c08151c6fa Nodes: Support storing socket link limits in bNodeSocketType
Currently the link limit of sockets is stored in bNodeSocket->limit.
This allows for a lot of flexibility, but is also very redundant.
In every case I've had to deal with so far, it would have "more correct"
to set the link limit per socket type and not per socket. I did not enforce
this constraint yet, because the link limit is exposed in the Python API,
which I did not want to break here.

In the future it might even make sense to only support only three kinds of link limits:
a) no links, b) at most one link, c) an arbitrary number links links. The other link
limits usually don't work well with tools (e.g. which link should be removed when a new
one is connected?) and is not used in practice. However, that is for another day.

Eventually, I would like to get rid of bNodeSocket->limit completely and replace it
either with fixed link limits or a callback in bNodeSocketType.

This patch consists of three parts:

**1. Support defining link limit in socket type**
This introduces a new `nodeSocketLinkLimit` function that serves as an indirection to
hide where the link limit of a socket is defined.

**2. Define link limits for builtin sockets on socket type**
Data sockets: one input, many outputs
Virtual sockets: one input, one output
Undefined sockets: many inputs, many outputs (to avoid that links are removed when the type of the socket is not known)

**3. Remove `bNodeSocketTemplate->limit`**
This wasn't used anymore after the second commit. Removing it simplifies socket definitions
in hundreds of places and removes a lot of redundancy.

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

Reviewers: brecht
2020-03-06 12:33:04 +01:00
98d562af52 CodeCleanup: move include statements before extern "C"
Mistake on recent changes that would fail when used in CPP.
2020-03-06 12:32:53 +01:00
24a37b3c03 Fix memory leak in the colorio fallback implementation.
We would previously not store the transforms that were added to the
group transform node. This would lead to pointer to allocated memory
being lost and not freed.
2020-03-06 12:29:12 +01:00
e65f5c07b0 Fluid: Added missing UI options for effector objects
UI was missing some of the new functionality introduced in a5c4a44df6.
2020-03-06 12:26:47 +01:00
79558a581d CodeCleanup: Use eDrawType
This patch will make use of the eDrawType where it was used as a
variable or parameter name. The eObjectDrawType was renamed to eDrawType
as it is also used by `View3DShading.type`.
2020-03-06 12:23:46 +01:00
e96b103536 Cleanup: move camera, lights, world to IDTypeInfo 2020-03-06 12:19:11 +01:00
297261eb90 CodeCleanup: Added enums to opengl render functions
Motivation the functions get 3 different kind of flag parameters (ImBuf,
DrawType, OffscreenRendering) the naming of the flags were not clear,
leading to mistakes and unnecessary time spend debugging.
2020-03-06 12:11:55 +01:00
9fa29fe765 Cleanup: remove MLOOPUV_EDGESEL
This was not set anywhere, code relies on MLOOPUV_VERTSEL everywhere.

BMLoopUV.select_edge was never returning True and wasnt updating uv
select state when set manually.

Afaict, there were no official Addons using this from python.

Resolves T65836

Maniphest Tasks: T65836

Differential Revision: https://developer.blender.org/D6772
2020-03-06 11:59:28 +01:00
Julian Eisel
c72317943b Attempt to fix build errors on macOS
Mistake in 5be0e3430d
2020-03-06 11:43:13 +01:00
7d61132807 Animation: improved error handling when adding/deleting keyframes
There are two ways in which adding/deleting keyframes can fail, but only
one of those was handled. The other would be shown as a successful
add/delete of -2 keyframes.
2020-03-06 11:36:59 +01:00
d8491cb7c6 Cleanup: Animation, renamed and clarified 'success' variable
The `ANIM_apply_keyingset()` returns a value that indicates the number of
changed channels (if nonnegative) or an error state (negative). In the
places where the return value was actually used, this value was stored in
a badly named variable.
2020-03-06 11:36:59 +01:00
17e1fef85a Cleanup: Library: Move to IDTypeInfo, and remove unused BKE API. 2020-03-06 11:27:54 +01:00
c25f6e998b Cleanup: Object: remove unused BKE API. 2020-03-06 11:27:54 +01:00
af5d2e38f7 Cleanup: Scene: New IDTypeInfo, and remove unused API from BKE. 2020-03-06 11:27:54 +01:00
7d9a5b7b10 Fix T73254: Drivers with the object.dimension variable are not updated
This fixes an issue where drivers using `object.dimension` only add a dependency on `GEOMETRY` to the depsgraph, whereas they should also depend on `TRANSFORM`.

This patch adds a new no-op operation that depends on the geometry and transform components to the Parameters component.

An alternative implementation would be to have `RNANodeQuery::construct_node_identifier` return multiple node identifiers. However, this would spread throughout the depsgraph code and unnecessarily force many other functions to either return or handle multiple nodes where in 99.999% of the time a single node would suffice.

The new `DIMENSIONS` node is added for each object. An upcoming patch will go over all no-op operation nodes and remove them from the depsgraph. Since this is a more dangerous operation, it'll be reviewed separately.

Differential Revision: https://developer.blender.org/D7031
2020-03-06 11:05:22 +01:00
abd33a3c0c Fluid: Cleanup naming for emmission bounding box
Since the bounding boxes are now also being used for effector objects, there needs to be a better name for them. Instead of calling them EmissionMap, which caters only to emission objects, they will now be called FluidObjectBB.
2020-03-06 11:04:26 +01:00
2e7cfb86fe Keymap: ignore repeat events for transform actions
Resolves T54297
2020-03-06 21:02:11 +11:00
e6aa349c68 CodeCleanup: eevee_materials Use Struct Assignments 2020-03-06 10:28:02 +01:00
0b9c1c2b86 Cleanup: typo in function name
contect -> context
2020-03-06 09:47:27 +01:00
5be0e3430d GHOST/Keymap: support for detecting repeat events
- Keymap items now have 'repeat' boolean which can be set
  to make keymap items respond to key repeat events or not.
- Support for X11 & WIN32 (not macOS currently).

This allows for the possibility to perform actions while a key is held
and finish the action upon release.

Thanks to @Severin for review and WIN32 support.
2020-03-06 17:31:28 +11:00
73ef27f156 Cleanup: keyframing return arguments
- Use 'int' for counters instead of short.
- Use 'bool' instead of a counter when only a change is being detected.
- Use typed enum for keying set flags.
- Include in comments when a negate error code may be returned.
2020-03-06 17:05:18 +11:00
e97aed1e73 Cleanup: remove unused 'eInsertKeyFlags' from delete API call
There is no need for an insertion flag in a delete function.
2020-03-06 15:07:57 +11:00
b15c658801 Cleanup: keyframe API naming, high level keyframe API
- Split 'verify_fcurve' into two functions:

  ED_action_fcurve_ensure which adds the f-curve if needed.
  ED_action_fcurve_find which returns NULL when not found.

  Callers of ED_action_fcurve_find had unused 'group'
  argument which has been removed.

- Rename verify_adt_action to ED_id_action_ensure

  It had an argument to add data which was always true,
  remove this instead of splitting in into a separate function.
2020-03-06 14:16:38 +11:00
07d13be678 Cleanup: rename 'verify' to 'ensure' for BKE_image_viewer functions 2020-03-06 13:06:21 +11:00
54ab8c6abd Cleanup: rename 'verify' to 'ensure' for argument name 2020-03-06 13:00:01 +11:00
bba4a09b2f Cleanup: use 'BKE_' prefix for BKE_deform API calls
- Use 'BKE_object_defgroup' prefix for object functions.

- Rename 'defvert_verify_index' to 'defvert_ensure_index'
  since this adds the group if it isn't found.
2020-03-06 12:56:44 +11:00
1af83aa2dd Cleanup: use 'r_' prefix for return arguments
Also avoid a redundant strlen call.
2020-03-06 12:49:21 +11:00
088636bc38 Cleanup: use BLI_strnlen instead of strlen 2020-03-06 12:43:58 +11:00
5229448c43 Cleanup: clang-format 2020-03-06 12:39:00 +11:00
c19d2f2507 Cleanup: use MEM_recallocN_id 2020-03-06 12:00:37 +11:00
8574d68aa0 Cleanup: spelling 2020-03-06 11:52:32 +11:00
6c623b0e8c Cleanup: add decimal values for event types, order by value 2020-03-06 11:52:31 +11:00
da30e9a104 Cleanup: quiet switch warnings 2020-03-06 11:52:31 +11:00
310285b0c2 Cleanup: redundant-decls warning 2020-03-06 11:14:21 +11:00
eed1beff88 UI: Using Consistent Font Icon in File Browser
Use only one font icon in File Browser for all platforms. Correct mistake to allow this icon to be used.

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

Reviewed by Brecht Van Lommel
2020-03-05 13:23:28 -08:00
38d6533f21 Sculpt Face Sets
Face Sets are the new system to control the visibility state of the mesh in sculpt and paint modes. They are designed to work in modes where brushes are the primary way of interaction and they provide much more control when working with meshes with complex shapes and overlapping surfaces.

This initial commit includes:
- Sculpt Face Sets data structures and PBVH rendering.
- Face Set overlay and opacity controls.
- Sculpt Undo support.
- Remesher reprojection support. The visibility state of the mesh is also preserved when remeshing.
- Automasking and Mesh filter support.
- Mask expand operator mode to expand Face Sets (Shift + W) and flood fill areas by connectivity (press Ctrl while expanding).
- Sculpt Mode Face Sets and Visibility API.
- Sculpt Face Sets creation and visibility management operators.
- Operator to randomize the Face Sets colors.
- Draw Face Sets brush tool to create and edit the Face Sets. Drawing on the mesh creates a new Face Set. Pressing Ctrl before drawing modifies the Face Set under the brush at the beginning of the stroke.
- Updated keymap and menu to work with Face Sets from Sculpt Mode (H to toggle visibility, Alt + H to show all, Shit + H to hide).
- Pie menu on the W key with Face common Sets operations.

Know limitations:
- Multires support. The Face Sets and Visibility API needs to be implemented for Multires.

Reviewed By: jbakker, #user_interface, Severin

Differential Revision: https://developer.blender.org/D6070
2020-03-05 21:07:20 +01:00
e56471bcd3 UI: File Browser Favorites
Adding more Windows special folder locations, used when browsing or bookmarking.

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

Reviewed by Brecht Van Lommel
2020-03-05 11:49:56 -08:00
Yevgeny Makarov
84c9a99cca UI: Mac File Browser System List Changes
Nicer icons for File Browser System and Favorites lists on Mac.

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

Reviewed by Brecht Van Lommel
2020-03-05 10:40:02 -08:00
Julian Eisel
3b1ef223ba Ghost: Support drawing OpenGL framebuffers into a DirectX 11 buffer
Adds a minimal DirectX 11 Ghost context, plus some shared DirectX-OpenGL
resource interface using the NV_DX_interop2 WGL extension. From what I
know, this should be available on modern GPUs. If not, it should fail
gracefully.
There should be no user visible changes at this point.

Needed for DirectX-only OpenXR platforms (e.g. Windows Mixed Reality). I
heard there are other use-cases as well though.

It's known that this currently fails on some AMD systems, but that seems
to be fixable.

Most of this comes from the 2019 GSoC project, "Core Support of Virtual
Reality Headsets through OpenXR"
(https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).

Reviewed by: Jeroen Bakker, Ray Molenkam, Brecht van Lommel

Differential Revision: https://developer.blender.org/D6190
2020-03-05 18:29:29 +01:00
4a3377fcf6 Fluid: Optimization in mesh generating loop
No need to have three separate loops for vertices, normals and speed vectors. Since all of them loop over the vertex count, a single loop can be used.
2020-03-05 17:51:21 +01:00
a874cfb858 Cleanup: Move std::deque to depsgraph_type.h
Since `std::deque` is used in a few areas of the Depsgraph, and an
upcoming patch adds one more, it's time it's considered as "commonly
used type".

No functional changes.
2020-03-05 17:32:01 +01:00
c43725e189 Add an session-wise uuid integer to IDs.
"session-wise" here mean while editing a same .blend file. So creating
or opening a new one will reset the uuid counter. This should avoid any
overflow in practice.

Only IDs added to Main database get an uuid, runtime-only ones are not
affected.

This is intended to provide undo with a way to find IDs across several
'memory realms' (undo speedup project).

No behavior change is expected from this commit itself.

Part of T60695.

Differential Revision: https://developer.blender.org/D7007
2020-03-05 16:30:12 +01:00
88db9a17ce Fix T74393: Cycles crashes when both OSL and Optix Denoising are enabled
Enabling viewport denoising causes Cycles to use a multi-device, which always returned NULL when
asked for OSL memory and would subsequently crash. This fixes that by returning the correct OSL
memory pointer from the CPU device in the special viewport denoising multi-device.
2020-03-05 16:28:31 +01:00
fe7528ee91 Fix T74332: selection sync replacing parent selection
Selecting certain child datablocks also selects the parent (e.g.
selecting a pose bone selects the armature). The base was selected, but
the outliner tree element was left unselected. The subsequent selection
sync would then deselect the parent base because it was not flagged as
selected in the outliner.

This led to issues like T74332 where selecting a pose bone in the
outliner did not show drivers in the driver editor unless the armature
was explicitly added to the selection afterwards.

The solution is to also flag the outliner elements as selected when
selecting parent bases.

Differential Revision: https://developer.blender.org/D7029
2020-03-05 07:40:29 -07:00
60c208e2d6 Fluid: Fix initial velocities for new static emission mode
For now, disabling static mode whenever initial velocities are being used.
2020-03-05 14:58:15 +01:00
950a35e353 Fluid: More optimizations in smoke / liquid scripts
Reduced extrapolation distances, no need to extrapolate that far.
2020-03-05 14:22:51 +01:00
Julian Eisel
28321b064a Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-05 12:40:18 +01:00
Julian Eisel
10d563baf4 Add XR_ prefix like now in master 2020-03-05 12:36:40 +01:00
cd0a6ff5c4 Fluid: Diffusion settings now optional
For optimization purposes these settings need to be enabled explicitly from now on.
2020-03-05 12:36:00 +01:00
Julian Eisel
812c4f45f5 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-05 12:32:54 +01:00
4d3da4e1d0 EEVEE: Render Passes Blending
Changed the blending mode to full blending. I found the issue when
during development of a material pass containing alpha values.
2020-03-05 12:25:35 +01:00
Stefan Werner
51e898324d Adaptive Sampling for Cycles.
This feature takes some inspiration from
"RenderMan: An Advanced Path Tracing Architecture for Movie Rendering" and
"A Hierarchical Automatic Stopping Condition for Monte Carlo Global Illumination"

The basic principle is as follows:
While samples are being added to a pixel, the adaptive sampler writes half
of the samples to a separate buffer. This gives it two separate estimates
of the same pixel, and by comparing their difference it estimates convergence.
Once convergence drops below a given threshold, the pixel is considered done.

When a pixel has not converged yet and needs more samples than the minimum,
its immediate neighbors are also set to take more samples. This is done in order
to more reliably detect sharp features such as caustics. A 3x3 box filter that
is run periodically over the tile buffer is used for that purpose.

After a tile has finished rendering, the values of all passes are scaled as if
they were rendered with the full number of samples. This way, any code operating
on these buffers, for example the denoiser, does not need to be changed for
per-pixel sample counts.

Reviewed By: brecht, #cycles

Differential Revision: https://developer.blender.org/D4686
2020-03-05 12:21:38 +01:00
Julian Eisel
75163f2a7d Add XR_ prefix like now in master 2020-03-05 12:20:27 +01:00
Julian Eisel
3c0c28afe1 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-03-05 12:11:16 +01:00
Julian Eisel
4ecea3dd3e Merge branch 'master' into temp-openxr-directx 2020-03-05 12:10:58 +01:00
4ccbbd3080 Fix T74446: Liquid Inflow Does Not Work
Somehow this was forgotton in the optimization patch a5c4a44df6.
2020-03-05 11:41:09 +01:00
c328049535 Initial step for IDTypeInfo refactor 'cleanup' project.
Introduce new IDTypeInfo structure.

Each ID type will have its own, with some minimal basic common info,
and ID management callbacks.

This patch only does it for Object type, for demo/testing purpose.
Moving all existing IDs is a goal of next "cleanup Friday".

Note that BKE_idcode features should then be merged back into BKE_idtype -
but this will have to be done later, once all ID types have been properly
converted to the new system.

Another later TODO might be to try and add callbacks for file read/write,
and lib_query ID usages looper.

This is part of T73719.

Thanks to @brecht for initial idea, and reviewing the patch.

Differential Revision: https://developer.blender.org/D6966
2020-03-05 10:58:58 +01:00
6665ce8951 Cleanup: Clarified comment
No functional changes.
2020-03-05 10:46:52 +01:00
e5f98c79b0 Fix T74431: EEVEE AO Render Pass
Missing code-path in recent refactoring.
2020-03-05 08:58:00 +01:00
a0ea0153c2 Addons: Allow a user manual url prefix in doc_url
This was raised in T74017, the issue being that we point to `/dev` 
version of the manual for the addons when we want to point to a specific 
version instead.

Instead of manually updating the URL every release we can do this.

The `bl_info` for addons will need to be updated in the format of 
`'doc_url': 
{BLENDER_MANUAL_URL}/addons/import_export/scene_gltf2.html",`

Differential Revision: https://developer.blender.org/D6995
2020-03-04 23:24:13 -05:00
Aaron Carlisle
ae223ff52b Addons: deprecate 'wiki_url'
When running with debug enabled ('-d' argument),
warnings are printed for add-ons which are not yet updated.

Reminder to name things based on what they do,
not the technologies they use :)
2020-03-05 11:45:22 +11:00
3da2dc8213 Fix RNA runtime warning from recent commit 2020-03-04 17:43:17 -05:00
337e861486 UI: Fluid: Fix wrong uses of enabled 2020-03-04 17:41:42 -05:00
6ab14d971c UI: Fluid: Viewport Display
Cleanup the order of properties and hide sub setting as they were 
confusing before.
2020-03-04 17:41:42 -05:00
bd0f5fa71f UI: Fluid Group Liquid/Gas Panels
Part of T73617

Differential Revision: https://developer.blender.org/D6994
2020-03-04 17:41:42 -05:00
55b465f976 UI: Fluid: Use updated preset UI
Part of T73617
2020-03-04 17:41:41 -05:00
1d18a2a5ec Fix Unreported: Error adding fluid presets 2020-03-04 17:41:41 -05:00
1da8ed2a97 Cleanup: redundant casts 2020-03-05 08:38:41 +11:00
2fb4de1f8c Cleanup: material API naming
- Use 'BKE_object_material_*', 'BKE_id_material_*' prefix
  for functions that operate on Object and ID types.
- Use '_len' suffix for length (matching BLI naming).
- Use '_p' suffix for functions that return a pointer to values
  where the value would typically be returned.

Functions renamed:

- BKE_object_material_resize      was BKE_material_resize_object
- BKE_object_material_remap       was BKE_material_remap_object
- BKE_object_material_remap_calc  was BKE_material_remap_object_calc

- BKE_object_material_array_p     was BKE_object_material_array
- BKE_object_material_len_p       was BKE_object_material_num
- BKE_id_material_array_p         was BKE_id_material_array
- BKE_id_material_len_p           was BKE_id_material_num

- BKE_id_material_resize          was BKE_material_resize_id
- BKE_id_material_append          was BKE_material_append_id
- BKE_id_material_pop             was BKE_material_pop_id
- BKE_id_material_clear           was BKE_material_clear_id
2020-03-05 08:21:31 +11:00
5b0f1e7649 Cleanup: formatting, strip trailing space 2020-03-05 08:05:21 +11:00
a297a6c444 Cleanup: replace unnecessary MEM_callocN calls
Use MEM_mallocN when memory is immediately copied over.
2020-03-05 07:59:34 +11:00
a5c4a44df6 Fluid: Bounding boxes for effector objects
This commit adds bounding box support for emission objects - similarly to flow objects. Before, each effector object had to iterate over the entire domain. Bake times of scenes with multiple obstacles improved significantly with this optimization.

Other improvements that were implemented alongside the bbox feature:
- Option for subframe sampling for effector objects
- Option to enable / disable effectors (can be animated)
- Optimization for static objects. If a flow or effector object does not move and the adaptive domain is not in use, the bake time will be optimized further by reusing the flow / effector grids from the previous frame (no recalculation).
2020-03-04 18:46:48 +01:00
3c74d45c9e Fluid: Added sanity grid initializations in smoke / liquid scripts
Just a sanity check.
2020-03-04 18:46:48 +01:00
8f1876b4f0 Fluid: Fix issue with fire emission
Fixes weird behavior at inflow regions. Issue was introduced with d6d44ccc77.
2020-03-04 18:46:48 +01:00
bf8a73b4a7 Fluid: Naming cleanup for flags grid
Use flags instead of obstacle to avoid confusion with obstacle levelset grid.
2020-03-04 18:46:48 +01:00
6958ec3f7f Fluid: Added an option to delete fluid inside obstacles
Simple checkbox that - if enabled - will tell the solver to clear density or liquid particles in obstacle cells.
2020-03-04 18:46:48 +01:00
b32fd73b24 Fluid: Optimization for extrapolation functions in smoke / liquid scripts
Too much extrapolation can become expensive. Reducing it here since extrapolating levelsets into a couple of cells should be sufficient.
2020-03-04 18:46:48 +01:00
2a4f350940 Fix T74434: Video Sequencer: Alt+ clicking (assign to all selected) does
not work for unlocking

Special case for when we do this on "lock":
- locked sequences are not in "selected_editable_sequences"
- use "selected_sequences" in that case

Maniphest Tasks: T74434

Differential Revision: https://developer.blender.org/D7023
2020-03-04 17:35:39 +01:00
765f2a1bca Fix T71578: knife tool draws some points incorrectly
D6417 by @fbessou
2020-03-04 16:48:37 +01:00
Julian Eisel
a22573e243 Build System: Add OpenXR-SDK dependency and WITH_XR_OPENXR build option
The OpenXR-SDK contains utilities for using the OpenXR standard
(https://www.khronos.org/openxr/). Namely C-headers and a so called
"loader" to manage runtime linking to OpenXR platforms ("runtimes")
installed on the user's system.

The WITH_XR_OPENXR build option is disabled by default for now, as there
is no code using it yet. On macOS it will remain disabled for now, it's
untested and there's no OpenXR runtime in sight for it.

Some points on the OpenXR-SDK dependency:
* The repository is located at
  https://github.com/KhronosGroup/OpenXR-SDK (Apache 2).
* Notes on updating the dependency:
  https://wiki.blender.org/wiki/Source/OpenXR_SDK_Dependency
* It contains a bunch of generated files, for which the sources are in a
  separate repository
  (https://github.com/KhronosGroup/OpenXR-SDK-Source).
* We could use that other repo by default, but I'd rather go with the
  simpler solution and allow people to opt in if they want advanced dev
  features.
* We currently use the OpenXR loader lib from it and the headers.
* To use the injected OpenXR API-layers from the SDK (e.g. API
  validation layers), the SDK needs to be compiled from this other
  repository.

The extra "XR_" prefix in the build option is to avoid mix-ups of OpenXR
with OpenEXR.

Most of this comes from the 2019 GSoC project, "Core Support of Virtual
Reality Headsets through OpenXR"
(https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).

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

Reviewed by: Campbell Barton, Sergey Sharybin, Bastien Montagne, Ray
Molenkamp
2020-03-04 16:45:07 +01:00
e7f1de5e11 Cleanup: use MEM_recallocN_id utility function 2020-03-04 23:51:32 +11:00
f4463cd865 RNA: ensure missing calls to RNA_enum_item_end crash in debug mode
Would have prevented T74227 from slipping through
since it didn't crash on some systems.
2020-03-04 23:48:45 +11:00
d83c0969f6 Fix T74426: Crash in the IK Pose Brush preview with null preview chain
After switching tools, the active vertex can be the same and the cursor
won't update the previews, so the pose_ik_chain_preview will be null.
This often happens in low poly meshes where chances of hovering the same
vertex are high.

Reviewed By: sergey

Maniphest Tasks: T74426

Differential Revision: https://developer.blender.org/D7021
2020-03-04 12:24:02 +01:00
6706ae5712 Cleanup: spelling 2020-03-04 21:46:16 +11:00
4bfa256ea4 Refactor ID make local to use a single flag parameter.
Instead of using anonymous booleans flags, also allows to keep the same
behavior in all cases, without needing special handling from calling
code for our beloved oddballs object proxies...
2020-03-04 11:43:31 +01:00
4e597a5cff Cleanup: ID make local: remove id_in_bmain argument.
This info is now stored in ID tags themselves, so no need to pass an
extra anonymous boolean parameter around, yay!
2020-03-04 11:43:30 +01:00
76d8e8693f Cleanup: Rename 'make local' functions to new scheme.
Also removed some only used locally from the header, `BKE_lib_id.h`
is already way too big, no need to overload it with unused things.
2020-03-04 11:43:30 +01:00
Asad-ullah Khan
e4eede8318 UI: rename View Selected" to "Frame Selected"
Addresses T74331
2020-03-04 21:38:23 +11:00
9c62a8c8e5 Fix T73797: Selection/Editing after Make Single User for Object Data
fails

Exposed by rB50d5c03e2d14.

This was only a problem when _only_ 'Object Data' was made local.
If also e.g. 'Object' or 'Materials' was checked, these were already
making sure realations were updated [DEG_relations_tag_update(bmain)].

Now also call DEG_relations_tag_update(bmain) for the 'Object Data'
case.

I assume the underlying issue is that there is some ID_NEW_REMAP
happening in 'single_obdata_users()' -- including that for 'me-
>texcomesh', which might be responsible for the glitches in selection/
editing? Also not entirely sure why this wasnt a problem prior to
rB50d5c03e2d14.(I assume this was somewhat hidden by the fact this was
always called with a default action being nothing, the user would always
need to access the redo panel. So this might have been hidden by an Undo
step involved?)

Maniphest Tasks: T73797

Differential Revision: https://developer.blender.org/D7020
2020-03-04 11:27:56 +01:00
a9dc1f6d00 Cleanup: avoid the term old when storing/restoring context variables 2020-03-04 21:13:32 +11:00
fb330dd110 Cleanup: remove unused BLI_strncat_utf8
Behaves differently to strncat,
BLI_strncpy_utf8_rlen can be used for a similar purpose.
2020-03-04 15:24:06 +11:00
8931c4b18d Fix possible buffer overflow from incorrect 'strncat' use
The size argument is the maximum number of bytes to copy,
not the destination buffer size.

Replace with utility function that joins strings.
2020-03-04 15:17:04 +11:00
0baae18375 BLI_string_utils: add BLI_string_join_array_by_sep_char
Utility to join strings into a fixed size buffer.
2020-03-04 15:14:02 +11:00
38ed95fe8d Cleanup: replace CLAMP macros with functions 2020-03-04 11:31:51 +11:00
89b10b8d42 BLI_math: inline clamp functions
These are used in some per-pixel operations such as image sampling and
color conversion, where replacing existing macro use could add overhead.
2020-03-04 11:23:00 +11:00
a37dceb139 Cleanup: replace commented code with define check
Avoids duplicated comments,
also quiet warning accessing non-existing variable.
2020-03-04 11:05:08 +11:00
a5c984a57d Cleanup: cmake indentation 2020-03-04 11:02:35 +11:00
d09c5bdc28 CMake: make OpenVDB depend on OpenEXR
OpenVDB uses 'half' type & fails to link without it.
2020-03-04 10:39:53 +11:00
Tiago Chaves
14c9f64def BLI_math: add clamp_v# and clamp_v#_v#v# utility functions 2020-03-04 10:25:44 +11:00
31aefdeec5 Fix T72028: Crash switching to vertex paint
This would happen when done from editmode, on a mesh with any modifier,
after adding/removing geometry in editmode.

Similar to rBba0870713b9b (which did this for weightpaint and sculpt
already), ensure an evaluated depsgraph, otherwise
'runtime.mesh_deform_eval' would not be up to date causing problems
later.

Maniphest Tasks: T72028

Differential Revision: https://developer.blender.org/D7011
2020-03-03 19:38:40 +01:00
059f3c1a7e Modifiers: Wave add invert vgroup option
Adds the invert vgroup option to the Wave modifier.

Differential Revision: https://developer.blender.org/D6893
2020-03-03 18:41:50 +01:00
Brecht Van Lommel
2841b2be39 IDs: change FILTER_ID_* to 64 bit to make space for new ID types
And change file browser to boolean from bitflag enum, which is only 32 bit.

Differential Revision: https://developer.blender.org/D7004
2020-03-03 17:34:21 +01:00
Brecht Van Lommel
19785b96c4 IDs: modify wm.previews_clear operator to make space for new ID types
Use a regular enum, to avoid running out of bits.

Differential Revision: https://developer.blender.org/D7003
2020-03-03 17:22:30 +01:00
Brecht Van Lommel
0c603cffd1 RNA: support 64 bit boolean bitflags in DNA
This does not affect the RNA access API, since how the boolean is read from
DNA abstracted away in the API.

Differential Revision: https://developer.blender.org/D7002
2020-03-03 17:21:47 +01:00
78383f7a9f Fix: USD Build error on windows
USD is being included before the blender headers.

USD includes TBB, which includes the windows headers
which define rad2 as a constant conflicting with a field
with that exact name in the MetaElem dna struct.

Added `-DWIN32_LEAN_AND_MEAN` to keep the windows headers
from defining rad2.
2020-03-03 09:04:31 -07:00
daca00f187 Fix Snake Hook rake on rotated objects
It was missing this local space conversion before calculating the rake
angle.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7008
2020-03-03 16:16:34 +01:00
b39273c071 Fix hardness not resetting when using reset brush
Just add it to the list or properties to reset from DNA_brush_defaults

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6992
2020-03-03 16:12:25 +01:00
4b2b5fe4b8 USD: Added support for exporting metaballs
Metaballs are exported as evaluated polygonal mesh.

USDExporterContext::depsgraph was made non-const to allow calling
`BKE_mesh_new_from_object()`. The alternative was to make the depsgraph
parameter of that function const, but that would be too intrusive as
that would require even more functions to accept a const depsgraph
pointer.
2020-03-03 15:34:58 +01:00
453be9cc8a Cleanup: USD, marked overridden function with override
No functional changes.
2020-03-03 15:34:58 +01:00
c60e5211d7 Cleanup: USD, removed unused code
Removed an unused forward declaration.

No functional changes.
2020-03-03 15:34:58 +01:00
594945eb01 Fix T71871: Quadriflow remesh operator don't stack operations
Made an explicit call to the exec function be a blocking call and a call
from invoke (or otherwise) be nonblocking.

Reviewed By: Bastien

Differential Revision: http://developer.blender.org/D7006
2020-03-03 15:30:29 +01:00
1ba4aa37c9 Remove the "use mesh curvature" option from quadriflow
It sometimes caused the solver to get into an seemingly unrecoverable
state and crash. Therefore I will disable this feature for now.
2020-03-03 15:30:29 +01:00
ed29ff944a Fix delaunay triangulation, bad indices for output faces.
If there were merged vertices, sometimes the output faces
had wrong vertex indices. Added a test for this, and fixed.
2020-03-03 08:41:26 -05:00
40343a76c5 Revert "Fix T74110: EEVEE Shadow Pass"
This reverts commit 403bb357ae.
The old implementation matches cycles closer. See T74378
2020-03-03 12:35:50 +01:00
ce2dc6ef2b Cleanup: formatting, spelling 2020-03-03 22:23:10 +11:00
582205c134 Subdiv: Fix/Workaround for surface partial derivatives
Both partial derivatives were evaluated to 0 for a special vertex on
Suzanne model: this is happening on a vertex where two adjacent faces
with 2 common edges are connected (in the nose of Suzanne).

This was breaking multires in this point since tangent matrix is all
zeroes, and hence no displacement can be applied in that vertex.
2020-03-03 12:01:46 +01:00
b454a12233 Separate operators (mesh/curve/armature/gpencil): take user preferences
into account for duplicating actions

Previously actions remained linked after duplication, now this is based
on the User Preferences (PreferencesEdit.use_duplicate_action).

note: default is ON here, so this changes default behavior of separate
operators.

First intuition was to respect _all_ preferences here (e.g. also
duplicating materials if chosen in the User Preferences) but after
consideration this is probably not what the User would expect from such
'modeling' opertions (e.g. separate by loose parts resulting in possibly
many duplicate materials)

Fixes T71038

Maniphest Tasks: T71038

Differential Revision: https://developer.blender.org/D6120
2020-03-03 10:01:20 +01:00
ee7034949f Fix bone envelopes displaying wrong when armature is scaled
Object Scale was not taken into account.

This lead to reports like T74247 where the user scaled the envelope
distance and radii to the supposedly right values inthe viewport, but
these were actually 'wrong' under the hood. Assigning weights from bone
envelopes seemed like it would fail, but this code would actually take
the armature scaling into account when checking envelope distance and
weight.

ref T74247

Maniphest Tasks: T74247

Differential Revision: https://developer.blender.org/D6964
2020-03-03 09:48:04 +01:00
d6fd092495 Fix T74375: grid levels theme preference reset to default 2020-03-03 09:29:19 +01:00
73bd0ef12d Fix dope sheet (Mask mode) keyframe editing not image/clip views
Every key-frame edit was updating all grease pencil & mask data-blocks.

Change the logic to only update edited data-blocks.
2020-03-03 16:53:32 +11:00
8447f45f09 Fix T74292: Dope sheet (Mask mode) keyframe editing misses update 2020-03-03 15:50:11 +11:00
7a875922e7 Cleanup: Use a utility function to obtain the bvh_cache 2020-03-03 00:40:15 -03:00
29716abcd1 Missed in the last commit 2020-03-03 00:20:25 -03:00
3e1aa6cbf3 Transform Snap: Clear 'SnapObjectData' after changes in the geometry
Differential Revision: https://developer.blender.org/D6927
2020-03-03 00:08:16 -03:00
a976fe42ef Revert "Transform Snap: Clear 'SnapObjectData' after changes in the geometry"
This reverts commit fe7c4fb4a2.

It does not work because `mesh_eval_cage` and `mesh_eval_final` always is `NULL` in this case.
2020-03-02 22:12:46 -03:00
c549a9dd46 Fix error parsing XDG path values
Own error in recent changes to parsing.
2020-03-03 11:14:39 +11:00
fe7c4fb4a2 Transform Snap: Clear 'SnapObjectData' after changes in the geometry
Differential Revision: https://developer.blender.org/D6927
2020-03-02 20:59:11 -03:00
5a77748e47 Fix T74377: Weld Modifier destroys vertex groups
Differential Revision: https://developer.blender.org/D6997
2020-03-02 18:44:58 -03:00
98c74c6a6e Fix: Excessive (re)builds of subprojects
Recent refactor external dependencies handling (D6642)
improperly linked all library dependencies with public
linkage rather than interface linkage. Causing excessive
(re)builds of subprojects when not needed.

This patch restores the interface linkage.

Reviewed By: brecht sergey

Differential Revision: https://developer.blender.org/D6983
2020-03-02 12:42:01 -07:00
Stefan Werner
409074aae5 Cycles: add Progressive Multi-Jitter sampling pattern
This sampling pattern is particularly suited to adaptive sampling, and will
be used for that upcoming feature.

Based on "Progressive Multi-Jittered Sample Sequences" by Per Christensen,
Andrew Kensler and Charlie Kilpatrick.

Ref D4686
2020-03-02 16:35:52 +01:00
Valentin
7b8db971d4 Cleanup: Use generics properties for arrow keys navigation (walk-select)
This patch refactors arrow keys navigation to move properties and enum
to generic ED_select_utils.h and property to
WM_operator_properties_select_walk_direction()

No functional change

Reviewed By: Julian Eisel

Differential Revision: https://developer.blender.org/D4771
2020-03-02 16:07:34 +01:00
51bce18b6f Cleanup: make blf header work in C++ 2020-03-02 15:34:17 +01:00
Julian Eisel
68cec61dae Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-03-02 15:30:09 +01:00
f48b46860b Cleanup: make remaining gpu headers work in C++ 2020-03-02 15:29:09 +01:00
360443a483 Fix T74278: Light, Image Object, and Compositor Backdrop Viewer Node
gizmos are too big

Caused by rB9cac5fa681c5 which fixed the handles for the camera border
gizmo (being much too small)-- which in turn was broken by
rB98e4fbc7cc9e.

Camera border gizmo sets up its matrix_space a bit differently [this is
why we are getting very small values in gizmo_calc_rect_view_scale --
needs more investigation], but instead of breaking it for Light, Image
and Compositor Backdrop, lets just compensate by scaling the Camera
Border Gizmo for now.

Maniphest Tasks: T74278

Differential Revision: https://developer.blender.org/D6991
2020-03-02 15:21:07 +01:00
d8198b27df Cleanup: make remaining imbuf headers work in C++ 2020-03-02 15:20:13 +01:00
Julian Eisel
c822556e27 Update oculus.json file for the Oculus runtime on Windows 2020-03-02 15:12:53 +01:00
680b70f093 Cleanup: make remaining editor include headers work in C++ 2020-03-02 15:09:10 +01:00
5de56f9596 Cleanup: make remaining blenkernel headers work in C++ 2020-03-02 15:07:49 +01:00
cf93b65a65 Cleanup: make remaining blenlib headers work in C++
Differential Revision: https://developer.blender.org/D6988

Reviewers: brecht
2020-03-02 15:05:15 +01:00
Ish Bosamiya
5afa4b1dc8 Fix T65568: sewing and self collision issue
As explained in T65568 by @LucaRood, the self collision system should exclude triangles that are connected by sewing springs.

Differential Revision: https://developer.blender.org/D6911
2020-03-02 11:02:26 -03:00
1648a79036 Fix T74295: Cloth + Internal springs crashes on a non-polygonal geometry
Added check to see if the mesh has any polygons at all.
If there are no polygons, the bvh tree data will consist of null
pointers, so skip internal springs if this is the case.
2020-03-02 15:02:24 +01:00
Julian Eisel
e62a012f90 Fix compiler warning on Linux, swapping with wrong type 2020-03-02 14:51:20 +01:00
Julian Eisel
be7b41df3f Bring back vertically mirrored drawing for DirectX compatibility 2020-03-02 14:51:12 +01:00
Julian Eisel
6f977c5e6d Always do versioning code, even with WITH_OPENXR disabled 2020-03-02 14:41:56 +01:00
Julian Eisel
a74af5f6f0 Always generate XR-RNA, even with WITH_OPENXR disabled 2020-03-02 14:39:12 +01:00
9c4523b1fd Fix crash when compiling renderpass shader on some AMD drivers
Differential Revision: https://developer.blender.org/D6959
2020-03-02 10:33:45 -03:00
Julian Eisel
3e41ea03be Cleanup: Move struct forward declaration to top of header 2020-03-02 14:31:01 +01:00
847c091ae8 Shading: Add invert option to Vector Rotate Node
Checkbox to invert rotation angle, suggested by @simonthommes

Differential Revision: https://developer.blender.org/D6932
2020-03-02 12:49:19 +00:00
493c99078a Fix T74362: Material Preview Assert
When using Material Previews not all uniform blocks were filled. This
patch will add the renderpass_block when drawing the background.

Note that I wasn't able to reproduce the issue on my system, but
according the the backtrace it most likely solves the issue. I let the
reporter test.
2020-03-02 13:47:52 +01:00
6fa4581d92 Fix T74334: VSE can't import multiple movie files
Add `directory` RNA property to add operators.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6986
2020-03-02 13:16:01 +01:00
Julian Eisel
489da13b94 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-03-02 12:59:24 +01:00
Julian Eisel
f9a3a42412 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-03-02 12:52:41 +01:00
Julian Eisel
202623419e Use GL_NEAREST as interpolation mode for framebuffer blitting 2020-03-02 12:41:01 +01:00
Julian Eisel
49f7848589 Avoid clearing render-target on each redraw in release builds 2020-03-02 12:40:14 +01:00
Julian Eisel
6fda295034 Add comment on DirectX device debugging 2020-03-02 12:39:38 +01:00
Julian Eisel
2b7e94e35e Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-03-02 12:07:58 +01:00
bd25df3d68 Fix T74335: Text.use_module "Online Manual" leads to TextCurve pages. 2020-03-02 12:05:07 +01:00
c930cd7450 Clay Thumb: Remove hardcoded hardness value
Clay Thumb was using a custom hardness implementation and value to make
it functional. Hardness is now a property of brushes and it is
implemented for all brushes, so this is no longer needed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6981
2020-03-02 11:54:54 +01:00
Julian Eisel
65ceb8ee5d Don't attempt to force enable WITH_OPENXR on macOS 2020-03-02 11:01:26 +01:00
Julian Eisel
9b5a1edbc4 Remove unnecessary CMake search hints 2020-03-02 11:00:41 +01:00
Julian Eisel
6cceecb82f Mark WITH_OPENXR as advanced on macOS 2020-03-02 11:00:01 +01:00
Julian Eisel
166c1f9a92 Merge branch 'master' into temp-openxr-buildstuff 2020-03-02 10:46:59 +01:00
94937984b0 Cleanup: Correct forward declaration 2020-03-02 10:17:38 +01:00
e0ffb911a2 Fix T74299: PyGPUOffscreen Color Management
Color management currently happens after the python handlers. This means
that all common drawing operations needs to happen in SRS. The
PyGPUOffscreen requested that the color management was applied, that
resulted into applying colormanagement twice.

This patch makes sure that PyGPUOffscreen.draw_view3d renders in SRS.
There are more code paths that needs to be checked that the correct
space is being requested.
2020-03-02 09:24:06 +01:00
f78ca97cfc Bevel: Z-Up Custom Profile Orientation
When beveling architectural objects like baseboards or crown mouldings that
may consist of multiple	islands, it's useful if	the orientation	is at least
conistent.

This changes the arbitrary decision of how the orientation should start	at a
chain beginning to use the highest side of the profile in the Z direction.

Reviewed By: howardt

Differential Revision: https://developer.blender.org/D6946
2020-03-01 22:21:51 -06:00
e9e4f6af9e Fix T74320: Sound strip waveforms drawing allows negative volume values
While animating sound strips volume within the graph editor, it is possible to set keyframes to negative values.
The drawing code of waveforms wasn't clamping these values to zero and was instead drawing an "inverted" curve

Author: a.monti

Reviewed By: iss

Differential Revision: https://developer.blender.org/D6971
2020-03-02 02:49:35 +01:00
eaf0528749 Fix .arcconfig not working with latest arcanist version 2020-03-01 22:35:31 +01:00
3db948cffe Fix: Build error on windows.
Use of undefined GSQueue type was causing build errors.
2020-03-01 13:59:51 -07:00
Pablo Dobarro
ff0124418f Sculpt: Hardness brush property
The hardness property moves the brush falloff towards the edges, making
the brush sharper.

This should be the intended way to control the brush falloff instead of
tweaking the falloff curve manually, as it can be mapped to pressure to
make the falloff variable during the stroke.
It is also a good idea to show in the UI that the custom curves is an
advance features and it should almost never be modified when sculpting/
painting unless you want to create some advanced effects. By modifying
the curves freely it is really easy to break the brushes and make them
produce artifacts. This needs to be done in a later after merging the
pending projects to reorganize all the brush properties accordingly.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6902
2020-03-01 20:05:58 +01:00
fc7fdc5c4e Cleanup: Move pose brush to its own file
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6973
2020-03-01 19:54:31 +01:00
Pablo Dobarro
233158b555 Fix T74307: Add missing brushes to versioning_defaults
At least a brush under each tool needs to exist by default in the blend
file to reset its properties. If it does not exist, the user needs to
reset it manually.

Reviewed By: brecht

Maniphest Tasks: T74307

Differential Revision: https://developer.blender.org/D6972
2020-03-01 19:37:49 +01:00
Pablo Dobarro
3c9956a3ac Fix T73707: Missing mesh normals update on sculpt undo
When sculpting on multi user data normals needs to be recalculated to
avoid artifacts. I refactored that line to make it more readable.

Reviewed By: brecht

Maniphest Tasks: T73707

Differential Revision: https://developer.blender.org/D6957
2020-03-01 19:35:50 +01:00
Pablo Dobarro
a489d77c5b Fix T74074: Strokes with timer events don't get pressure values
When processing a timer event WM_event_tablet_data returns 0 instead of
the last valid pressure value from the tablet. This always stores the
last pressure value and uses it in case a timer event is being
processed.

Reviewed By: brecht

Maniphest Tasks: T74074

Differential Revision: https://developer.blender.org/D6950
2020-03-01 19:32:01 +01:00
Pablo Dobarro
c04c5ac4f6 Fix T73947: Support radial symmetry in Multiplane Scrape
This includes the following changes:
- Use always the angle stored in the StrokeCache when deforming
- Interpolate between the previous and the new sampled angles
- Calculate the cursor matrix only on the 0 radial symmetry iteration

Reviewed By: brecht

Maniphest Tasks: T73947

Differential Revision: https://developer.blender.org/D6901
2020-03-01 19:29:10 +01:00
f2557d137a Fix problem with Delaunay triangulalation re output mapping.
The array giving original vertex indices should not contain
entries for newly created vertices. Added a test to check this.
2020-03-01 12:25:44 -05:00
Peter Fog
38058833f1 UI: harmonize strip colors in video sequencer
Now only the hue is different between different strip types, with the
saturation the same for all.

Differential Revision: https://developer.blender.org/D6775
2020-03-01 16:20:44 +01:00
Phillip Thomas
6a6ccb26ec Build: show draco library under extern folder in Visual Studio
And other code tweaks to make this library more consistent with others.

Differential Revision: https://developer.blender.org/D6864
2020-03-01 16:19:37 +01:00
24ef1cf07e Fix show large cursor preference not being fully removed and causing warnings 2020-03-01 16:15:25 +01:00
Yevgeny Makarov
821ecbe805 UI: make Save Custom Studio Light pop-ups less wide
Differential Revision: https://developer.blender.org/D6977
2020-03-01 16:09:57 +01:00
Yevgeny Makarov
0373e300ea UI: use dedicated icons for topbar and statusbar in theme preferences
Differential Revision: https://developer.blender.org/D6978
2020-03-01 16:09:26 +01:00
22a8a3b214 Apply patch D6620, Adde tests for Deform modifiers.
This test is authored by Himanshi Kalra (calra).
It requires a new modifers.blend in the svn tests.
2020-02-29 14:07:14 -05:00
cb8b424c6b Made BLI_delaunay_2d_cdt_calc better at tiny feature elimination.
The 'random' unit tests and some examples from the new boolean code
triggered asserts and crashes. This fixes those.
There is a new flag in the input that optionally disables a pass
over input to snap segment edges to other segments.
2020-02-29 13:26:27 -05:00
a52eb7489f Cleanup: Move transform_constraints declarations to its own header 2020-02-28 21:25:47 -03:00
85f980c517 UI: Remove Support for Large Cursors
Removing the 'Large Cursors' option as it is no longer applicable or useful on any platform.

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

Reviewed by Brecht Van Lommel
2020-02-28 08:45:17 -08:00
4a373afa5f Sculpt: Cloth brush
This brush has a simple physics solver that helps when sculpting cloth.

- The mass and the damping properties of the simulation are properties of the brush.
- It has two additional radius control to limit the influence and falloff of the simulation.
- Masked vertices are pinned in the simulation, and it applies the sculpt gravity directly in the solver.
- The Cloth Brush has 7 deformation modes with 2 falloff types (radial and plane).

The brush can create the constraints only on the required PBVH nodes, so the simulation is isolated on high poly meshes. As long
as the brush size is not too big it should be possible to keep it real time.

Known issues:
- The way constraints are created is extremely basic and it creates repeated constraints. Maybe there is another way to create fewer constraints while keeping the simulation quality decent. This part can also be multithreaded. (As it is it works ok, but it could be better)

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6715
2020-02-28 17:03:20 +01:00
793135e190 Fix wrong coordinates being read when using the sculpt API
The coordinates should be read from the PBVH when using deform modifiers.
This is needed for the cloth brush to work with subdivisions, as it reads the
vertex coordinates using this function when building and updating the
constraints.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6967
2020-02-28 16:53:34 +01:00
bc2ce31d79 Fluid: Improved behavior at open boundaries
Use greater boundary width for smoke simulations
2020-02-28 16:20:13 +01:00
21bdeb5cc0 Fluid: Updated Manta pp files
Updates include:
- std::move() cleanup in rcmatrix.h
- Enabled parallelization for fluid guiding (fairly noticeable speed improvement).
- More flexible flags setter function with control over boundary width.
2020-02-28 16:20:13 +01:00
af54bbd61c Cycles: Rework tile scheduling for denoising
This fixes denoising being delayed until after all rendering has finished. Instead, tile-based
denoising is now part of the "RENDER" task again, so that it is all in one task and does not
cause issues with dedicated task pools where tasks are serialized.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6940
2020-02-28 16:12:29 +01:00
03e04d4db7 Cleanup: clang-format 2020-02-28 16:04:15 +01:00
Yevgeny Makarov
fe3ce61528 Fix T65351: visual glitches when scrolling in popovers 2020-02-28 16:03:53 +01:00
0cea9353fd Fix CUDA out of memory error with OptiX viewport denoising on small GPUs
This makes the memory allocation for the denoiser state use the memory allocator in Cycles, which
will evict textures to host memory when there is not enough space on the device. This means the
allocation for the denoiser state won't just fail if there is no more space and instead more space is
made for it to work. Also simplifies code somewhat.
2020-02-28 15:58:17 +01:00
Yevgeny Makarov
27fa33c143 Fix T72404: particle brush size radial control mismatch on high DPI display 2020-02-28 15:55:51 +01:00
498397f7bd Fix (unreported) Separate bones creates empty armature
Fix for fix (rB8bf7ca9fe31c).
The fix was not actually working [neither for multi-armature-editing as
intended nor for single armatures] and it broke single-armature bone
separation completely.

More or less indentation issue, move relevant code out of bone loop, do
after all bones have been checked, guess this was intended anyways.

Differential Revision: https://developer.blender.org/D6949
2020-02-28 15:26:57 +01:00
4c83e6bac0 Fix T71611: Outliner - Show only Visible/Hidden Objects not working when hiding Collections
Use BASE_VISIBLE_VIEWLAYER (rather than BASE_VISIBLE_DEPSGRAPH -- which
is not including the 'Hide in Viewport')

Note: the is one case where this still 'fails':
- 'Show only Hidden' plus excluding the parent collection (would be nice
to show those -- but contents of excluded excluded collections dont get
show in any case... this would be more work and for another report...)

Maniphest Tasks: T71611

Differential Revision: https://developer.blender.org/D6953
2020-02-28 15:20:59 +01:00
94dcfe7a77 Preview Render: Disable Unneeded Render Passes 2020-02-28 14:46:40 +01:00
e8ab0137f8 File Browser: Add Ctrl+F shortcut to activate filter textbox
Reviewers: Severin, brecht

Differential Revision: https://developer.blender.org/D6941
2020-02-28 14:34:56 +01:00
e0f41d32c9 Code Cleanup: UNDEF not existing define 2020-02-28 14:31:46 +01:00
bcac081ad5 OpenSubdiv: Allow less topology callbacks assigned
Useful for cases when topology does not need to have any
crease or UV layers. Now instead of assigning callbacks
which returns zero data is possible to simply assign the
callback itself to NULL.
2020-02-28 14:30:49 +01:00
95d0e04ed1 BLI: fix utf8 character counting when there is an incomplete utf8 char
D6923 by Kim Geonwoo
2020-02-28 14:26:07 +01:00
Pawel Franitza
2269759fdf UI: add theme option for grid levels to display in node editor background
Differential Revision: https://developer.blender.org/D6916
2020-02-28 14:11:48 +01:00
Yevgeny Makarov
e287122af6 UI: improve label text colors in save and security popups
This adds a utility functions to draw a label highlighted or in red.

Differential Revision: https://developer.blender.org/D6934
2020-02-28 13:57:32 +01:00
Brecht Van Lommel
318112379d Objects: make evaluated data runtime storage usable for types other than mesh
This is in preparation of new object types. This only changes mesh_eval, we
may do the same for mesh_deform_eval and other areas in the future if there is
a need for it.

This previously caused a bug in T74283, that should be fixed now.

Differential Revision: https://developer.blender.org/D6695
2020-02-28 13:49:35 +01:00
c60be37f3e Nodes: Use destructor callbacks for bNodeSocketType and bNodeType
Reviewers: brecht

Differential Revision: https://developer.blender.org/D6963
2020-02-28 13:28:16 +01:00
da1140f75e Revert "Objects: make evaluated data runtime storage usable for types other than mesh"
This reverts commit f2b95b9eae.

Fix T74283: modifier display lost when moving object in edit mode.

The cause is not immediately obvious so better to revert and look at this
carefully.
2020-02-28 13:01:02 +01:00
7a8a074a30 Multires: Move current reshaping/propagation logic to legacy file
It will eventually rewritten.
This commit prepares some clean space to start this process.

So far no functional changes.
2020-02-28 12:42:27 +01:00
Tobias Langen
8e8b4ec3a3 Fix T73587: Wrong sub-panel animation on double-click
Under the special circumstance of double clicking and then opening a
panel with sub-panels again, the parent panel's offset in y-direction
was added twice to the child panels: once inside "get_panel_real_ofsy"
and once within "align_sub_panels".
This introduced a visible glitch.

Reviewed by: Julian Eisel

Differential Revision: https://developer.blender.org/D6942
2020-02-28 12:39:11 +01:00
1eb73d1596 Multires: Fix CCG->MDISPS conversion happens twice
Was happening when leaving sculpt mode, introducing unnecessary lag
to the operation.
2020-02-28 12:24:26 +01:00
944da82eaf Multires: Cleanup, use early return 2020-02-28 12:24:26 +01:00
feead324fd Multires: Cleanup, naming 2020-02-28 12:24:26 +01:00
Julian Eisel
d9c25f0192 UI: Move menu shadow theme options next to each other
For some reason they were separated, even though they are closely
related.
2020-02-28 11:36:25 +01:00
9a855f94fc Cleanup: Spelling 2020-02-28 10:12:08 +01:00
4c4d36c25e Subdiv: Correct corner passed to foreach_loop callback
Was affecting quad faces. where 0 was always passed for inner
loops and a wrong one for boundary ones.

In the current code this change shouldn't cause any difference
since the corner index is ignored in the actual callback, but
it is required to have his fixed for an upcoming changes.
2020-02-28 10:12:08 +01:00
Julian Eisel
3da9ecc6c1 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-26 21:19:59 +01:00
Julian Eisel
0f979f3388 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-02-26 21:19:35 +01:00
Julian Eisel
72ad66b101 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-02-26 21:19:23 +01:00
Julian Eisel
f25a348915 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-02-26 21:19:09 +01:00
Julian Eisel
af00df3469 Update OpenXR SDK dependency to version 1.0.6
Also fix a merge error in install_deps.sh
2020-02-26 21:18:10 +01:00
Julian Eisel
80c6f6eb4e Merge branch 'master' into temp-openxr-buildstuff 2020-02-26 21:17:04 +01:00
Julian Eisel
62db972f0f Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-25 14:43:41 +01:00
Julian Eisel
e9036242fa Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-02-25 14:42:29 +01:00
Julian Eisel
83aebf759e Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-02-25 14:38:08 +01:00
Julian Eisel
5169f9e975 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-02-25 14:37:52 +01:00
Julian Eisel
d9c05e6997 Merge branch 'master' into temp-openxr-buildstuff 2020-02-25 14:36:28 +01:00
Julian Eisel
404cc8d1fc Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-20 12:56:11 +01:00
Julian Eisel
af928a2fb1 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-02-20 12:53:03 +01:00
Julian Eisel
b1c9434332 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-02-20 12:51:46 +01:00
Julian Eisel
4c2ec7c5ec Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-02-20 12:51:35 +01:00
Julian Eisel
79069884b1 Merge branch 'master' into temp-openxr-buildstuff 2020-02-20 12:51:09 +01:00
Julian Eisel
7254d1ae49 Merge branch 'master' into temp-openxr-buildstuff 2020-02-20 11:16:17 +01:00
Julian Eisel
a18c254c6d Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-17 16:57:21 +01:00
Julian Eisel
27bbbc9c57 Remove own GPUViewport and GPUContext binding
Draw-manager handles these as needed now, so we can remove this.
2020-02-17 16:53:56 +01:00
Julian Eisel
6dbe2d781d Don't create framebuffer for VR view, re-use GPUViewport one 2020-02-17 16:21:28 +01:00
Julian Eisel
19f3fdad97 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-17 12:21:00 +01:00
Julian Eisel
8d5996595f Fix compile errors and broken drawing after changes in master
There are still some issues left after the changes in master:
* Some optimizations need to be redone differently
* Color-space handling needs to be redone differently
* Upside-down drawing is broken
2020-02-17 12:15:42 +01:00
Julian Eisel
47baf42e2c Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside
This will currently fail to compile. Fixes upcoming.
2020-02-17 11:29:17 +01:00
Julian Eisel
cdfe5449df Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-02-17 11:04:02 +01:00
Julian Eisel
f0786dfc52 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-02-17 11:03:39 +01:00
Julian Eisel
de2d03ace9 Merge branch 'master' into temp-openxr-buildstuff 2020-02-17 11:01:47 +01:00
Julian Eisel
0a27ab2e93 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-02-05 14:38:19 +01:00
Julian Eisel
d930ff7f4f Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-02-05 14:37:59 +01:00
Julian Eisel
f3e9351111 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-02-05 14:37:45 +01:00
Julian Eisel
2a259497ae Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-02-05 14:37:30 +01:00
Julian Eisel
eecf3021d7 Merge branch 'master' into temp-openxr-buildstuff 2020-02-05 14:37:09 +01:00
Julian Eisel
0173800572 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-01-24 11:25:54 +01:00
Julian Eisel
bc38898cf4 Fix linking after recent build system changes in master 2020-01-24 11:24:34 +01:00
Julian Eisel
1a812145e0 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-01-24 11:22:04 +01:00
Julian Eisel
f430f6fa18 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-01-24 11:17:59 +01:00
Julian Eisel
2f6ebe1b99 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-01-24 11:17:43 +01:00
Julian Eisel
c706834749 Merge branch 'master' into temp-openxr-buildstuff 2020-01-24 11:17:23 +01:00
Julian Eisel
11ee2f1d09 Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2020-01-06 16:52:35 +01:00
Julian Eisel
fcc6e94897 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2020-01-06 14:59:25 +01:00
Julian Eisel
d6cce8bc8e Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2020-01-06 14:52:28 +01:00
Julian Eisel
4332e2b5fb Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2020-01-06 14:52:06 +01:00
Julian Eisel
3ff91e97d9 Merge branch 'master' into temp-openxr-buildstuff 2020-01-06 14:41:20 +01:00
Julian Eisel
06138de13a Color transforms were fixed in Windows MR -> disable our workaround 2019-11-29 12:40:55 +01:00
Julian Eisel
0c7ac28b8a SDK changed loader lib name on Windows, update for that 2019-11-28 19:05:07 +01:00
Julian Eisel
43cfa0b682 Merge branch 'master' into soc-2019-openxr 2019-11-27 15:25:47 +01:00
Julian Eisel
f426d3a002 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2019-11-27 15:25:12 +01:00
Julian Eisel
a1499f7f7d Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2019-11-27 12:26:56 +01:00
Julian Eisel
530a8d1ab1 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2019-11-27 12:24:12 +01:00
Julian Eisel
2232406394 Merge branch 'master' into temp-openxr-buildstuff 2019-11-27 12:21:32 +01:00
Julian Eisel
8f6b3d27d0 Remove files to sync with latest changes in patches 2019-11-19 15:33:30 +01:00
Julian Eisel
ffa16f677a Merge branch 'temp-openxr-blenderside' into soc-2019-openxr 2019-11-19 15:31:07 +01:00
Julian Eisel
85ccec8639 Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2019-11-19 15:30:42 +01:00
Julian Eisel
fc83dfdba1 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2019-11-19 15:29:29 +01:00
Julian Eisel
2448eb6136 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2019-11-19 15:29:11 +01:00
Julian Eisel
90df65892f Merge branch 'master' into temp-openxr-buildstuff 2019-11-19 15:28:53 +01:00
Julian Eisel
f07e361829 Update branch to include changes from split off patches 2019-11-15 11:27:46 +01:00
Julian Eisel
779b3f0cff Bring back utility batch and config file for Oculus support 2019-11-14 12:49:18 +01:00
Julian Eisel
561f4665a6 Merge branch 'master' into soc-2019-openxr 2019-11-14 12:40:20 +01:00
Julian Eisel
58f95e9e4d Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2019-11-14 12:37:10 +01:00
Julian Eisel
17121b2afd Add required OpenXR defines to Ghost CMakeLists (used to be in root one) 2019-11-14 12:35:30 +01:00
Julian Eisel
fc26797e72 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2019-11-14 12:21:47 +01:00
Julian Eisel
fa9707a712 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2019-11-14 12:17:05 +01:00
Julian Eisel
8d45b4f75c Disable XR features (and the OpenXR SDK dependency) by default on Apple 2019-11-14 12:04:02 +01:00
Julian Eisel
03ac9de0a9 Remove XR defines from top-level CMakeLists file, can be done locally 2019-11-14 12:01:06 +01:00
Julian Eisel
4456dbcded Remove now unnecessary OpenXR SDK patch for Win CRT linkage 2019-11-14 11:51:39 +01:00
Julian Eisel
cc23a8c84d Merge branch 'master' into temp-openxr-buildstuff 2019-11-14 11:43:19 +01:00
Julian Eisel
120d9c91dc Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2019-11-13 17:03:05 +01:00
Julian Eisel
e1db5cc2c7 Remove CMake include unneeded after recent build system changes 2019-11-13 17:01:42 +01:00
Julian Eisel
a347ec08bc Merge branch 'temp-openxr-ghostxr' into temp-openxr-blenderside 2019-11-13 13:02:32 +01:00
Julian Eisel
ee8e4b7db8 Merge branch 'temp-openxr-directx' into temp-openxr-ghostxr 2019-11-13 13:02:11 +01:00
Julian Eisel
8c7be58e72 Merge branch 'temp-openxr-buildstuff' into temp-openxr-directx 2019-11-13 13:01:39 +01:00
Julian Eisel
1b39eb1060 Merge branch 'master' into temp-openxr-buildstuff 2019-11-13 13:01:21 +01:00
Julian Eisel
0d98e665ea Core XR Support [part 1]: Add OpenXR-SDK dependency and WITH_OPENXR build option
Some points on the OpenXR-SDK dependency:
* The repository is located at https://github.com/KhronosGroup/OpenXR-SDK (Apache 2).
* We use the OpenXR loader lib from it, the headers, and some CMake utilities.
* It contains a bunch of generated files, for which the sources are in a separate repository.
* To use the injected OpenXR API-layers from the SDK (e.g. API validation layers), the SDK needs to be compiled from this other repository.
* We could use that other repo by default, but I'd rather go with the simpler solution and allow people to opt in if they want advanced dev features.
* For Windows a patch is needed to link the CRT in a compatible way.

All this is entirely untested on macOS.

Maniphest Tasks: T71365

Differential Revision: https://developer.blender.org/D6188
2019-11-13 12:57:35 +01:00
Julian Eisel
7f1fadba67 Core XR Support [part 4]: Blender-side changes (+ the remaining bits)
Changes for the higher level, more Blender specific side of the implementation.

Main additions:
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU context)
* DNA/RNA for initial management of VR session settings
* Utility batch & config file for using the Oculus runtime (Windows only)

Differential Revision: https://developer.blender.org/D6193
2019-11-05 15:33:48 +01:00
Julian Eisel
8537cdc71d Core XR Support [part 3]: Ghost-XR API based on OpenXR
## Design Overview
* For code using this API, the most important object is a GHOST_XrContext handle. Through it, all API functions and internal state can be accessed/modified.
* Main responsibilities of the Ghost XR-context are to manage lifetimes of the OpenXR runtime connection (represented by XrInstance), the session and to delegate operations/data to the session.
* The OpenXR related graphics code, which is OS dependent, is managed through a `GHOST_IXrGraphicsBinding` interface, that can be implemented for the different graphics libraries supported (currently OpenGL and DirectX).
* Much of this code here has to follow the OpenXR specification and is based on the OpenXR [[https://github.com/KhronosGroup/OpenXR-SDK-Source/tree/master/src/tests/hello_xr | `hello_xr`]] implentation.
* In future we may want to take some code out of the context, e.g. extension and API layer management.
* There are runtime debugging and benchmarking options (exposed through --debug-xr and --debug-xr-time, but not as part of this patch).
* Error handling is described in a section below.

## Why have this in Ghost?

Early on, I decided to do the OpenXR level access through GHOST. Main reasons:
* OpenXR requires access to low level, OS dependent graphics lib data (e.g. see [[https://www.khronos.org/registry/OpenXR/specs/0.90/man/html/openxr.html#XrGraphicsBindingOpenGLXlibKHR| XrGraphicsBindingOpenGLXlibKHR]])
* Some C++ features appeared handy (`std::vector`, RAII + exception handling, cleaner code through object methods, etc.)
* General low level nature of the OpenXR API

After all I think much of the functionality is too high level to live in GHOST however. I would like to address this by having a separate `VAMR` (virtual + augmented + mixed reality) module, placed in `intern/`.  The main issue is getting this to work well with Ghost data, especially how to get the mentioned low level data out of Ghost.
This is something I'd like to look into again before too long, but for now I think having this in Ghost is reasonable.

## Error Handling Strategy

The error handling strategy I chose uses C++ exceptions, a controversial feature. Let me explain why I think this is reasonable here.

The strategy requirements were:
* If an error occurs, cleanly exit the VR session (or destroy the entire context), causing no resource leaks or side effects to the rest of Blender.
* Show a *useful* error message to the user.
* Don't impair readability of code too much with error handling.

Here's why I chose an exception based strategy:
* Most alternatives require early exiting functions. This early exiting has to be 'bubbled up' the call stack to the point that performs error handling. For safe code, early exit checks have to be performed everywhere and code gets really impaired by error checking. Tried this first and wasn't happy at all. Even if error handling is wrapped into macros.
* All `GHOST_Xr` resources are managed via RAII. So stack unwinding will cause them to be released cleanly whenever an exception is thrown.
* `GHOST_Xr` has a clear boundary (the Ghost C-API) with only a handful of public functions. That is the only place we need to have try-catch blocks at. (Generally, try-catch blocks at kinda random places are a bad code smell IMHO. Module boundaries are a valid place to put them.)
* Exceptions allow us to pass multiple bits of error information through mulitple layers of the call stack. This information can also be made specific with a useful error message. As of now, they conain a user error message, the OpenXR error code (if any), as well as the exact source code location the error was caught at.

So the strategy I went with works as follows:
* If a VR related error occurs within `GHOST_Xr`, throw an exception (`GHOST_XrException` currently).
* OpenXR calls are wrapped into a macro throwing an exception if the return value indicates an error.
* Useful debugging information and user messages are stored in the exceptions.
* All resources must be managed through RAII, so throwing an exception will release 'dangling' ones cleanly.
* In the GHOST C-API wrappers, the exceptions are caught and contained error information is forwarded to a custom error handling callback.
* The error handling callback is set in `wm_xr.c`, prior to creating the XR-Context, and implements clean destruction of the context.

Differential Revision: https://developer.blender.org/D6192
2019-11-05 15:00:55 +01:00
Julian Eisel
6ae2979d05 Ghost DirectX compatibility from GSoC OpenXR branch
Needed for DirectX-only OpenXR runtimes (e.g. Windows Mixed Reality).

Adds a minimal DirectX 11 Ghost context, plus some shared DirectX-OpenGL resource interface using the NV_DX_interop2 WGL extension.
I know that the current implementation fails on some systems, which is something I'll have to fix at some point. Don't know if this is a showstopper though, I can fix that in master too. For now this isn't going to be used by many people anyway. Recently I also learned that OSVR uses the same extension, see https://github.com/sensics/OSVR-RenderManager/blob/master/osvr/RenderKit/RenderManagerD3DOpenGL.cpp. Their implementation may be useful to fix the issue, according to a OSVR dev, it works quite reliably for them.

Note: Didn't actually test just this patch on Windows yet.

Differential Revision: https://developer.blender.org/D6190
2019-11-05 13:39:44 +01:00
Julian Eisel
b698a926af Add back accidentally removed CMake files
No clue how those ended up tagged as removed.
2019-11-05 12:35:44 +01:00
Julian Eisel
fac53c7bc2 Core XR Support [part 1]: Add OpenXR-SDK dependency and WITH_XR build option
Some points on the OpenXR-SDK dependency:
* The repository is located at https://github.com/KhronosGroup/OpenXR-SDK (Apache 2).
* We use the OpenXR loader lib from it, the headers, and some CMake utilities.
* It contains a bunch of generated files, for which the sources are in a separate repository.
* To use the injected OpenXR API-layers from the SDK (e.g. API validation layers), the SDK needs to be compiled from this other repository.
* We could use that other repo by default, but I'd rather go with the simpler solution and allow people to opt in if they want advanced dev features.
* I copied `presentation.cmake` and `xr_platform_defines.cmake` from the SDK. They contain logic that is not needed for us and prints at CMake generation. We could change that but figured it would also be helpful to keep the files equal to the SDK ones.
* For Windows a patch is needed to link the CRT in a compatible way.
* @LazyDodo already pushed the precompiled binaries for Windows.

All this is entirely untested on macOS.

Differential Revision: https://developer.blender.org/D6188
2019-11-05 12:32:33 +01:00
Julian Eisel
88f234e27f Merge branch 'master' into soc-2019-openxr 2019-11-05 10:30:22 +01:00
Julian Eisel
0615321ca0 Fix too dark rendering on the Monado runtime
Just like the Windows Mixed Reality runtime, we have to apply a sRGB
OETF to get visually correct-ish looking colors.
We plan to further investigate if it's really WMR and Monado being wrong
here, or if it's Oculus (which doesn't need this additional transform),
but there are some details to check.
2019-10-16 14:36:13 +02:00
Julian Eisel
3bed8a7338 Refactor GPU viewport onscreen drawing for "upside down" drawing
Reduces code duplication for the DirectX specific upside down drawing.
Didn't actually test the upside down drawing, since I need to do that on
Windows.
2019-10-15 22:33:46 +02:00
Julian Eisel
ff03e3b7e0 Merge branch 'master' into soc-2019-openxr 2019-10-15 22:13:16 +02:00
Julian Eisel
350b7b378d Correct/remove disabled code for space conversion
Turns out we don't actually have to convert between spaces.
2019-10-15 22:10:08 +02:00
Julian Eisel
51af7510fb Cleanup: Avoid duplication of projection matrix calculation 2019-10-15 22:09:27 +02:00
Julian Eisel
927c300c02 Improve error messages & cleanup 2019-10-15 22:04:22 +02:00
Julian Eisel
fa9a841d43 Wrap WM XR data into own struct 2019-10-15 17:33:46 +02:00
Julian Eisel
b057298021 Revert accidental change in previour commit
Played around with the color management/transforms but forgot to undo.
2019-10-15 17:12:56 +02:00
Julian Eisel
1ada9f5bf9 Support VR Session settings & add some basic ones
* Adds the needed bits to support VR session settings and access them in
  the VR view drawing code.
* Added settings for: shading mode, grid floor, annotations, clipping.
  More can easily be added.
* The Add-on adds a "VR" tab in the side bar, containing buttons for the
  added settings
2019-10-15 16:01:06 +02:00
Julian Eisel
52c9d33cc2 Merge branch 'master' into soc-2019-openxr 2019-10-14 16:05:46 +02:00
Julian Eisel
db6657aa15 Fix compile error on Windows after last commit 2019-10-11 15:40:03 +02:00
Julian Eisel
941e1f5a98 Strictly follow specification to get OpenXR extension functions
This fixes linking errors with the Monado runtime. The specification
says that extension functions have to be gotten through
`xrGetInstanceProcAddr()` which we did for some extensions, but not for
the graphics extensions. Worked fine earlier, but broke meanwhile.
2019-10-10 14:47:00 +02:00
Julian Eisel
e9832f053b Merge branch 'master' into soc-2019-openxr 2019-10-10 11:30:14 +02:00
Julian Eisel
cddf043cca Cleanup: Don't pass unused lens value 2019-09-17 19:16:14 +02:00
Julian Eisel
6af2f222ca Cleanup: Comment style 2019-09-17 19:02:01 +02:00
Julian Eisel
639dffa43a CMake: Slight adjustment to warning message 2019-09-17 18:17:58 +02:00
Julian Eisel
9baa9e2bd3 Fix Linux linker config name for the OpenXR-SDK 2019-09-17 16:55:24 +02:00
Julian Eisel
3c38e67765 Fix mistakes in openxr build options
I remember merge conflicts here.
2019-09-17 16:54:28 +02:00
Julian Eisel
1849e4fe19 Merge branch 'master' into soc-2019-openxr 2019-09-17 13:48:54 +02:00
2ef7a1f24d Merge branch 'master' into soc-2019-openxr 2019-09-15 19:01:30 +02:00
Julian Eisel
bc8186b5d1 Merge branch 'master' into soc-2019-openxr 2019-08-30 14:22:04 +02:00
Julian Eisel
e0bb3f9286 Merge branch 'master' into soc-2019-openxr 2019-08-24 23:21:33 +02:00
Julian Eisel
d0b4ec00f6 Don't drwa relationship lines in the VR view 2019-08-24 22:06:23 +02:00
Julian Eisel
7b6514c222 Merge branch 'master' into soc-2019-openxr 2019-08-24 14:45:41 +02:00
Julian Eisel
c506acf2fc Add Oculus to the list of known runtimes
With this, all currently available runtimes are in the runtime map. So
removing the TODO comment.
2019-08-24 03:35:32 +02:00
Julian Eisel
31b8350b01 Cleanup: Refactor (hacky) swapchain image submission
Code now assumes that the view-draw callback left the OpenGL state for
ongoing use by Ghost-XR. So the state doesn't have to be set by the
swapchain image submission and thus it we don't need to pass the Ghost
OpenGL context to it in a hacky way.
Also, rename drawViewEnd (to submitToSwapchain) and remove
drawViewBegin.
2019-08-24 03:32:11 +02:00
Julian Eisel
d7a216704b Fix warning in release builds 2019-08-24 03:17:14 +02:00
Julian Eisel
4b67477732 Own FBO for VR viewport to get previous changes to work 2019-08-24 03:15:25 +02:00
Julian Eisel
4a039158e5 Avoid OpenGL context deactivation, just to reactivate it immediately 2019-08-24 00:13:36 +02:00
Julian Eisel
61014e1dd9 Remove hack to resize the usable default framebuffer region 2019-08-23 23:46:09 +02:00
Julian Eisel
3441314e40 Remove blitting from default framebuffer 2019-08-23 23:36:04 +02:00
Julian Eisel
f175dcc35f Add Monado to the list of known runtimes 2019-08-23 23:08:21 +02:00
Julian Eisel
756b676076 Merge branch 'master' into soc-2019-openxr 2019-08-23 17:51:28 +02:00
Julian Eisel
7462fca737 Avoid redundant framebuffer resize and offscreen texture drawing 2019-08-23 17:46:43 +02:00
Julian Eisel
7c9e18c193 Cleanup: Add comments 2019-08-23 17:00:30 +02:00
Julian Eisel
6b69b5349b Address and remove some TODOs marked in code 2019-08-22 23:24:05 +02:00
Julian Eisel
daba8140c2 Cleanup: Unused functions, add comments, sync to master 2019-08-22 23:02:01 +02:00
Julian Eisel
599d0611b0 Improve batch file text for starting Blender with Oculus support 2019-08-22 13:33:06 +02:00
Julian Eisel
e88970db82 Don't create a DirectX swap-chain
We only render offscreen anyway. There's no point in creating a
swap-chain. This simplifies things quite a bit.
2019-08-21 20:58:59 +02:00
Julian Eisel
20b0b36479 DirectX: Create an own render-target, don't use swapchain for blitting 2019-08-21 20:40:13 +02:00
Julian Eisel
2c77f2deac Remove GHOST API functions for OpenGL offscreen blitting
These were previously used to blit from a offscreen (non-OpenGL)
context, into an onscreen one. We do this differently, and only within
GHOST_XrGraphicsBinding now, so this can be removed.
2019-08-21 20:36:40 +02:00
Julian Eisel
fec7ac7c51 Refactor OpenGL/DirectX resource sharing for multiple shared resources
Rather than max. one shared resource per DirectX context, code can now
request a handle for a shared resource and ask the DirectX context to do
operations on that.
2019-08-21 19:44:08 +02:00
Julian Eisel
2a1ec8ec2a Fix missing CMake hint for OpenXR SDK path on linux 2019-08-21 13:24:16 +02:00
1548682cde Windows/deps: Add/fix openxr_sdk dependency
There were a few typos here and there, and the openxr_sdk does not respect the cflags we give it hence a patch was added to work around this undesirable behaviour.
2019-08-20 08:30:29 -06:00
Julian Eisel
588dea6751 Merge branch 'master' into soc-2019-openxr 2019-08-20 12:36:51 +02:00
Julian Eisel
ad4f9a4d98 Fix compiling with WITH_OPENXR disabled 2019-08-20 09:17:56 +02:00
Julian Eisel
84466c7d71 Blacklist VR add-on in Python tests if WITH_OPENXR is disabled 2019-08-20 00:55:21 +02:00
Julian Eisel
de037b031d Expose WITH_OPENXR build option to Python API 2019-08-20 00:12:59 +02:00
Julian Eisel
a21ae28f96 Prepare Toggle VR Session operator to be enabled by an add-on 2019-08-19 23:44:59 +02:00
Julian Eisel
b2424bd781 Windows: Print warning and disable WITH_OPENXR if SDK is not found 2019-08-19 15:41:27 +02:00
Julian Eisel
d0177fc541 Integrate the OpenXR SDK better into dependency management
Adds the SDK so that `make deps` works, on all platforms. On Windows,
the SDK headers and libraries are now assumed to be in the usual lib\
directory.
Also fixes a mistake in install_deps.sh

Note that none of this is tested as it requires an older Visual Studio
version than I have.
2019-08-18 13:06:48 +02:00
Julian Eisel
4cf8740790 Fix compile error on Linux 2019-08-17 23:59:39 +02:00
Julian Eisel
a53b90329a Merge branch 'master' into soc-2019-openxr 2019-08-17 23:58:09 +02:00
Julian Eisel
2c41ffa380 Fix compiling with external OpenXR SDK on Windows 2019-08-15 21:49:10 +02:00
Julian Eisel
cdc2768f65 Cleanup: Don't cast away const in GHOST C-API 2019-08-15 15:52:45 +02:00
Julian Eisel
eb477c67a1 Fix crash when no OpenXR runtime is found (or setup failed) 2019-08-15 15:50:01 +02:00
Julian Eisel
0dd3f3925b Remove bundled OpenXR-SDK sources from extern/
Removes the OPENXR_USE_BUNDLED_SRC option which allowed using the
OpenXR-SDK sources bundled in extern/. It would be too much hassle to
keept these updated.
Now these have to be provided on the system Blender is compiled on. I've
already added necessary bits to install_deps.sh and our Windows
maintainer is ready to provide builds with OpenXR-SDK linked.
Once this gets into master, platform maintainers will have to be
notified about the added dependency.

This also removes the JsonCpp dependency, it was only needed for the
OpenXR-SDK sources.
2019-08-15 15:42:23 +02:00
Julian Eisel
9e7c48575a Linux: Add OpenXR-SDK to install_deps.sh 2019-08-14 22:59:33 +02:00
Julian Eisel
8138099fa9 Silence warnings in OpenXR SDK API layer files 2019-08-14 17:44:02 +02:00
Julian Eisel
02de1b9860 Quiet warning 2019-08-14 16:11:14 +02:00
Julian Eisel
57712625f2 Merge branch 'master' into soc-2019-openxr 2019-08-14 16:01:30 +02:00
Julian Eisel
96a34d7f50 Cleanup: Unused includes, better structuring for wm_xr.c 2019-08-09 16:35:28 +02:00
Julian Eisel
873223f38d Cleanup: Remove unused support for non-OpenGL Windows
This was very useful for testing, but there's no current need for it.
Neither for VR code, nor for anything else in master.
2019-08-09 16:08:34 +02:00
Julian Eisel
716c6b0c01 Cleanup: Move secondary GHOST-context handle to XR surface data
This is used to refer to the DirectX context. For other (currently
non-existant) surfaces, this may not make much sense.
2019-08-09 13:29:08 +02:00
Julian Eisel
62bbd2e37d Don't swap buffers of offscreen surface OpenGL contexts
This does frame syncing to the regular screen, so hurts performance in
some cases.
2019-08-08 22:00:21 +02:00
Julian Eisel
ba223dfac8 Exit OpenXR context/session gracefully if the runtime reports loss pending
Handle XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING and
XR_SESSION_STATE_LOSS_PENDING according to the specification.
2019-08-07 23:58:28 +02:00
Julian Eisel
8557997e81 Disable specular highlights in the VR viewport 2019-08-07 23:05:24 +02:00
Julian Eisel
bcc8f7c6be Fix xrDestroy calls to data already implicitly destroyed by OpenXR
Would effectifely result in null-ops, since the loader does good sanity
checks. The failing functions would still lead to error prints though.
2019-08-07 22:17:55 +02:00
Julian Eisel
fe7b01a08f Correctly request session end according to OpenXR 1.0 specification 2019-08-07 22:13:35 +02:00
Julian Eisel
5350015d51 Fix dark VR rendering on Windows Mixed Reality by appyling SRGB OETF
Discussed this in length with @sobotka, and it seems WMR has an utterly
broken pixel color pipeline. So we apply a SRGB OETF for this specific
runtime to compensate.
2019-08-07 11:52:30 +02:00
Julian Eisel
3483aa57b3 Allow querying OpenXR runtime ID
Useful in case special treatment is needed for certain runtimes.
Currently only WMR gets its ID assigned correctly, others are TODO.
2019-08-07 03:22:33 +02:00
Julian Eisel
44a220f721 Merge branch 'master' into soc-2019-openxr 2019-08-07 02:20:22 +02:00
Julian Eisel
5274c5cce6 Merge branch 'master' into soc-2019-openxr 2019-08-05 12:52:57 +02:00
Julian Eisel
0d70afed19 Merge branch 'master' into soc-2019-openxr 2019-08-02 23:35:40 +02:00
Julian Eisel
03b09dbe32 Fix compile error after merge and warning 2019-08-01 21:53:57 +02:00
Julian Eisel
f04a5ad1e4 Merge branch 'master' into soc-2019-openxr 2019-08-01 21:27:08 +02:00
Julian Eisel
ab1455e972 Fix error in OpenGL version check for OpenXR 1.0 2019-08-01 01:56:35 +02:00
Julian Eisel
b94af38c31 Fix compile error on GCC 2019-08-01 01:39:27 +02:00
Julian Eisel
40db778de3 Add sources for OpenXR core API validation layer
Had to do quite some changes to CMakeLists.txt from the SDK this time.
2019-08-01 00:28:16 +02:00
Julian Eisel
22966f4d35 Address changes in OpenXR 1.0 to get rendering to work again 2019-07-31 02:19:35 +02:00
Julian Eisel
e8f66ff060 Update OpenXR to version 1.0
Only tested on Windows.

Updates loader sources from the OpenXR SDK to latest 1.0 SDK and updates
requiremed version to 1.0. The compile time generation of files is a
thing of the past now (although you can still force it).
1.0 got released yesterday. Only one line needed fixing in our OpenXR
code to get it to compile. Rendering is black though.

For now I tried to keep edits to CMakeList.txt files minimal. So now
there are OpenXR CMake options exposed (with bad names), CMake prints,
etc.
2019-07-31 02:18:28 +02:00
Julian Eisel
9ac33e56a1 Merge branch 'master' into soc-2019-openxr 2019-07-30 22:19:41 +02:00
Julian Eisel
091cc94379 Use fixed lighting, don't make it rotate with view rotation 2019-07-24 16:41:46 +02:00
Julian Eisel
fc31be5ab0 Fix broken VR viewport rotation and movement 2019-07-24 02:52:03 +02:00
Julian Eisel
aff49f607a Use draw manager offscreen context for the VR session
This way we avoid the big overhead of context switches. Makes frames
render about twice as fast here. For heavy Spring scenes I'm getting
around 20 FPS here, classroom scene is at 50 FPS.
This is great given that drawing itself still isn't optimized for dual
eye rendering.
2019-07-24 01:39:04 +02:00
Julian Eisel
57b77cd193 Print 8 Frame average FPS for --debug-xr-time
Much more useful than a per frame FPS estimation. 8 frames are used for
the Blender viewport FPS stats too.
Refactored drawing data storage a bit.
2019-07-23 19:16:39 +02:00
Julian Eisel
d58eb8d29d Add --debug-xr-time command line option for VR frame time info prints
Outputs frame render time in milliseconds and FPS this time would add up
to. We could average times so FPS is a bit more stable, but the
precision of un-averaged results may be helpful too.
2019-07-23 02:06:08 +02:00
Julian Eisel
a4310ba85f Merge branch 'master' into soc-2019-openxr 2019-07-23 00:18:08 +02:00
Julian Eisel
bd42740ef1 Silence GCC warning 2019-07-21 13:15:00 +02:00
Julian Eisel
679a4c34fc Fix compile error with bundled OpenXR sources 2019-07-21 03:18:02 +02:00
Julian Eisel
55362436d9 Fix troubling memory leak in offscreen viewport drawing
I'm not really sure why the leak happened - draw manager kept allocating
certain buffers - but I figured I could avoid it by not recreating
GPU_offscreen/GPU_viewport on every redraw.
This should also improve performance a bit.
2019-07-21 01:10:18 +02:00
Julian Eisel
c1d164070b Pure OpenGL backend works now, let it take priority over DirectX 2019-07-20 19:34:50 +02:00
Julian Eisel
3a4034a741 Make OpenGL-only session backend work
Previously, only DirectX HMD rendering would work (and still takes
priority).
2019-07-20 19:33:11 +02:00
Julian Eisel
a0be113d2e Fix DirectX context not freed on session exit
Also rename XrSurfaceData to wmXrSurfaceData
2019-07-17 15:18:27 +02:00
Julian Eisel
151fb129e7 Fix for previous commit, accidental call to xrDestroySwapchain 2019-07-17 14:51:21 +02:00
Julian Eisel
165c5a5259 Fix possible OpenXR swapchain leak by using new unique_oxr_ptr 2019-07-17 14:05:06 +02:00
Julian Eisel
74fc1db25b Add helper class to RAII manage OpenXR handles
Adds generic unique_oxr_ptr to wrap xrCreate and xrDestroy functions of
OpenXR handles into a unique_ptr like RAII interface.

While for most cases, OpenXR resources can be freed by their owning
object, sometimes errors may occor before final ownership is established.
E.g. swapchain ownership is only transfered to the session object once
its swapchain-images are created - which may fail. With this RAII
wrapper, the swapchain would be freed on error (as this triggers stack
unwinding through an exception), no matter who holds ownership to it
currently.
There are other solutions to this problem, e.g. by establishing final
ownership right after/upon creation, or by explicit freeing in case an
error is spotted; it's too easy to make mistakes here though. Plus, we
may want to experiment with using this API for all OpenXR resources, to
entirely avoid the possibility of them leaking.
2019-07-17 13:35:14 +02:00
Julian Eisel
03ff2a8dd5 Fix compile error with USE_FORCE_WINDOWED_SESSION enabled
At least get it to compile, this is still kinda broken though.
2019-07-17 11:29:34 +02:00
d99d15f48d Add helper batch file for testing on oculus rift. 2019-07-16 16:41:44 -06:00
Julian Eisel
6a998833cd Temporarily let DirectX take priority over OpenGL
OpenGL doesn't work yet. Shouldn't be too difficult to get working, but
I don't have a working OpenXR runtime with OpenGL support to test here.
2019-07-16 21:48:29 +02:00
Julian Eisel
fca4826c7f Merge branch 'master' into soc-2019-openxr 2019-07-16 21:09:30 +02:00
Julian Eisel
b0845fc133 Fix some issues, improve error message
Fixes:
* Destruct surface when destroying session on error. Fixes null pointer
  dereference when trying to draw the surface on next redraw.
* Fix trying to enable same extensions/API-layers multiple times due to
  static array usage not being cleared after error.
* Null pointer dereference with OpenGL drawing
2019-07-13 16:22:26 +02:00
Julian Eisel
70cf8bd9c6 Fix crash on OpenXR error before context is created fully 2019-07-13 01:19:58 +02:00
Julian Eisel
3a2e459f58 Show useful error reports in case of errors.
E.g. with an active OpenXR runtime installed, but no HMD plugged in,
Blender will now show: "Failed to get device information. Is a device
plugged in?".
In case of such errors, the VR-session will be cleanly exited, with
no side effects to the rest of Blender (at least if there are no bugs).

The GHOST_Xr API now allows setting a custom error handling callback
which may cleanly destroy all GHOST_Xr data.
2019-07-12 19:51:38 +02:00
Julian Eisel
330f062099 Safe and informative GHOST_Xr error handling
This wraps all functions that could fail into some proper (although
unfinished) error handling.

These were the requirements for the error handling strategy:
* If an error occurs, cleanly exit the VR session (or the context if the
  error happend during its set up), causing no resource leaks or side
  effects to the rest of Blender.
* Show a *useful* error message to the user.
* Don't impair readability of code too much with error handling.

After some back and forth I decided Ghost internal exceptions are the
best way to go about this. I get exceptions are a controversial feature,
IMHO that's because most people use them 'wrong' however. Here's the
rationale:
* Most alternatives require early exiting functions. This early exiting
  has to be 'bubbled up' the call stack to the point that performs error
  handling. So the code gets really impaired by error checking. Tried
  this first and wasn't happy with it at all. Even if error handling is
  wrapped into macros.
* All GHOST_Xr resources are managed via RAII. So stack unwinding will
  cause them to be released cleanly whenever an exception is thrown.
* GHOST_Xr has a clear boundary (the Ghost C-API) with only a handful of
  public functions. That is the only place we need to have try-catch
  blocks at.
  (Generally, try-catch blocks at kinda random places are a bad code
  smell IMHO. Module boundaries are a valid place to put them.)
* Exceptions allow us to pass multiple bits of error information through
  mulitple layers of the call stack. This information can also be made
  specific with a useful error message.
  As of now, they conain a user error message, the OpenXR error code (if
  any), as well as the exact source code location the error was caught
  at.

So if an error is caught inside GHOST_Xr code, an exception is thrown
with specific and hopefully useful information in it. In the Ghost C-API,
these exceptions are caught and passed on to a custom error handling
callback. This callback will be defined by the Blender window-manager
and output the error information via a usual user report popup (not done
yet). It can also ensure the entire session is shut down.

Note that the majority of errors OpenXR can return are for invalid API
usage. Assuming the API usage is valid though, most error messages
should never reach users and can be left a bit more vague. Maybe we can
add something like "This is probably a bug and should be reported" to
those.
2019-07-12 14:40:50 +02:00
Julian Eisel
09872df1c7 Check runtime DirectX requirements for graphics binding too 2019-07-11 21:05:13 +02:00
Julian Eisel
67d6399da6 Check runtime OpenGL requirements prior to creating graphics binding
DirectX will need these checks too.
Also fix warnings due to wrong printf formatting.
2019-07-11 20:36:54 +02:00
Julian Eisel
c29724912b Merge branch 'master' into soc-2019-openxr 2019-07-11 20:28:19 +02:00
Julian Eisel
99560d9657 Disable debug extension on Windows
Unfortunately, enabling XR_EXT_debug_utils crashes instance creation
with the Windows Mixed Reality runtime. Maybe I'm doing something wrong,
for now, just disable it.
2019-07-11 16:44:51 +02:00
Julian Eisel
b8a7b87873 General minor fixes and cleanup
* Initialize all class member variables
* Add version to runtime name printing
* Separate functionality code from debug prints
* Improve code structure using Doxygen groups
* Make accessors const functions
* Add (Doxygen) comments
* Naming
* Reorder functions
2019-07-11 16:36:04 +02:00
Julian Eisel
c9f6c1a054 Fix wrong return value causing OpenXR initialization to fail 2019-07-11 00:51:00 +02:00
Julian Eisel
dd0fcb50b4 Fix compile errors on windows and with bundled OpenXR SDK sources 2019-07-11 00:50:10 +02:00
Julian Eisel
c1e9cf00ac Refactor GHOST_XrContext into class + interface
Makes GHOST_Xr much more consistent with the rest of GHOST. Basically I
added a GHOST_IXrContext interface which can be called by the GHOST
C-API. The internal GHOST_XrContext class implements this.
Outside of GHOST only the opaque GHOST_XrContextHandle is accessible.

Kept GHOST_Xr_intern.h and GHOST_Xr.cpp for now. I'll probably remove
them soon. There's not much reason for both of them to be there.
2019-07-10 23:53:07 +02:00
Julian Eisel
84d609f67b Use OpenXR extension for extra debug messages in debug mode
Enables (or tries to) the XR_EXT_debug_utils extension which allows
setting a custom callback for additional debug prints. Note that I
haven't been able to test this really, as the Monado runtime appears to
not have this fully implemented (had to force sending a custom message
to find that out...). Will test with the Windows MR runtime in a bit. We
can also improve message quality then (it can print the exact function
name the message was sent from, print additional custom labels which
could indicate session state, etc.).
2019-07-10 15:08:52 +02:00
Julian Eisel
86178548d5 Only try to enable OpenXR API validation layer in debug mode 2019-07-10 15:08:10 +02:00
Julian Eisel
d711540a85 Cleanup: Rename XR_DEBUG_BEGIN -> XR_DEBUG_ONLY_BEGIN
Of course also renames XR_DEBUG_END accordingly.
2019-07-10 15:06:08 +02:00
Julian Eisel
6e3158cb00 Only print info messages with --debug-xr enabled 2019-07-09 17:49:54 +02:00
Julian Eisel
b216690505 Add --debug-xr commandline arg and pass on to GHOST XR contexts
Doesn't do anything yet.
2019-07-09 17:20:01 +02:00
Julian Eisel
b98896ddd9 Preparations to allow enabling OpenXR API validation layer
For this to work two environment variables have to be set:
XR_API_LAYER_PATH and LD_LIBRARY_PATH, both have to point to the API
layers built by the OpenXR SDK. It also requires you compile Blender
linked to your own SDK build (OPENXR_USE_BUNDLED_SRC disabled).
Further changes will make this set up unnecessary, so validation layers
can be enabled via some flag.
2019-07-09 16:45:21 +02:00
Julian Eisel
a05104d61f Fix warnings and compile error on GCC 2019-07-09 11:28:17 +02:00
Julian Eisel
7fe1cc8d24 Enable grid floor in VR session
Helps quite a bit orientating.
2019-07-09 10:56:37 +02:00
Julian Eisel
70e84a2c20 Merge branch 'master' into soc-2019-openxr 2019-07-08 14:18:08 +02:00
Julian Eisel
084a33ca94 Use base pose from Blender camera
I was trying to set the camera pose as OpenXR reference pose. But then I
got really strange poses for drawing back from OpenXR. Couldn't figure
out a way to solve this.
Now we just apply OpenXR's draw pose to the Blender camera pose. If we
later want to support moving around in the scene (e.g. via teleporting),
that has to be changed.

Also uses flipped drawing for DirectX surface to correct DirectX upside
down drawing (compared to OpenGL).
2019-07-08 14:13:14 +02:00
Julian Eisel
37f619aea3 Don't recreate reference local space on each redraw
Set this up on session start.
2019-07-07 13:07:51 +02:00
Julian Eisel
6904ab10f4 Add GHOST_XrSession class for cleaner & safer session management
Session code and data structures are now localized. But also, this
enables sessions to use deterministic destruction to end itself cleanly.
So whenever an error occurs, we can use stack unwinding which will cause
graceful ending of the session.
2019-07-07 12:45:37 +02:00
Julian Eisel
146ef0dd1e Properly end VR sessions fixing crash on next session start
Previously, you had to restart Blender to start another session.
2019-07-03 21:01:58 +02:00
Julian Eisel
5891e86420 Cleanup GHOST_Xr types and functions
* Move GHOST_Xr types to GHOST_Types.h
* Add GHOST_XrPose. We'll have to pass around pose data at multiple
  places.
* Don't require extra call to prepare session rendering, handle
everything through GHOST_XrSessionStart
* Naming
2019-07-01 19:04:54 +02:00
Julian Eisel
2cedad990a Initial HMD viewport rendering (DirectX only first)
Finally: This makes it possible to render a viewport to an HMD via
OpenXR. Pure OpenGL rendering will need some more tweaks to work.
To my great delight, performance is quite good for reasonably sized
scenes.

Had to do some hacks and marked some TODOs. Nothing too bad though.

Here are a couple of notes:
* Current initial pose is pretty useless, think it just looks downwards
  from world origin. Will change that soon.
* The rendered viewport has some issues: Too dark (bad lighting?), grid
  doesn't show up even though I told it to, lighting seems to change with
  view position/rotation, etc. Needs some polish.
* Ideally we'd just use the D3D11 Texture given to us via the OpenXR
  swapchain and blit the OpenGL framebuffer into that. However the
  NV_DX_interop extension fails doing this. Seems like this is a NVidia
  Optimus only issue, but I'm missing the hardware to confirm.
  So instead, we blit into the D3D11 back buffer first and then into the
  Texture.
* The draw-manager uses its own offscreen context so we have to get the
  render result from the draw-manager context to the VR session's
  context first. Luckily I've already added code to support blitting from
  one OpenGL context into another. But it requires blitting twice.
  Blitting should be very cheap, but still...
  Draw-manager could get a context to use passed instead.
2019-07-01 15:57:32 +02:00
Julian Eisel
109be29e42 Draw offscreen viewport in XR session surface callback
Not visible yet, but it should draw in the offscreen. The way this is
now, we don't depend on the Window->Workspace->bScreen->... chain. We
simply draw an offscreen viewport in the draw callback of the XR session
surface.

The drawing also uses view and projection matrices from OpenXR (or
calculated from OpenXR data).
2019-06-29 02:30:23 +02:00
Julian Eisel
13442da69f Move WM level XR functions to wm_xr.c
Operator is still in wm_operators.c, but only calls wm_xr.c functions.
2019-06-28 22:53:46 +02:00
Julian Eisel
231dbd53bf Support Window-less (offscreen) VR session on Windows
Uses the new wmSurface type (non-window drawable container) to manage
the OpenGL, DirectX and GPU module contexts. The draw callback of the XR
surface calls the GHOST_Xr session drawing routines.

What you should see when starting a VR session now (using the WMR
runtime): The Windows Mixed Reality Portal pops up, and a blue
background is drawn on the HMD. This is from the blue color clear call
we do in the drawing preparations of the GHOST_Xr session drawing.
2019-06-28 16:24:24 +02:00
Julian Eisel
d3e48fb096 Merge branch 'master' into soc-2019-openxr 2019-06-28 14:09:08 +02:00
Julian Eisel
d544a0b41c Avoid std::vector copy 2019-06-28 13:56:10 +02:00
Julian Eisel
cf4799e299 Add wmSurface for non-Window offscreen VR session drawing
Adds a wmSurface type which acts as a container for non-Window (offscreen)
draw surfaces. Ideally wmWindow would of course also just do C-style
inheritance from wmSurface, but I guess they can co-exist too.
For the VR session a surface is created on Linux and passed to the
graphics binding to use.

Note this is not used on Windows yet, it still opens a window there.
2019-06-28 13:38:34 +02:00
Julian Eisel
57d9f004aa Fix compile/CMake errors and warnings on Linux 2019-06-27 19:55:22 +02:00
Julian Eisel
62cde7a9ef Finish VR view drawing callback set up
* Allow passing custom data to session draw function, passed to the
  callback
* Actually call the callback
* Create and bind a WM level callback. Will later be used to draw the
  viewport.

Also, check if session is actually visible before drawing.
2019-06-27 19:17:12 +02:00
Julian Eisel
e4fcf25fc5 Don't use Microsoft::WRL::ComPtr<...> for COM types
Makes things difficult if you're not familar with COM.
2019-06-27 18:56:20 +02:00
Julian Eisel
215c919b33 Merge branch 'master' into soc-2019-openxr 2019-06-26 18:39:31 +02:00
Julian Eisel
da44a02d00 The first pixels pushed to Windows Mixed Reality HMDs!
Just a clear call for now, so all you see is a blue world. This blue
"world" is however drawn by Blender!

Also fixes use after destruction of compositor layer data.
2019-06-24 21:22:23 +02:00
Julian Eisel
867007d9d7 Set up OpenXR compositing layers for drawing
That should be one of the last steps to prepare pushing pixels to HMDs.
Fingers crossed!
2019-06-24 16:44:43 +02:00
Julian Eisel
e9ea814233 Merge branch 'master' into soc-2019-openxr 2019-06-24 12:52:37 +02:00
Julian Eisel
6b43c82cb5 Set up OpenXR views and spaces for drawing
Using a dummy identity pose at {0, 0, 0} to start with. This should
later use the current viewport position & orientation I guess.

Also adds function to set a draw callback. There's quite some OpenXR
related stuff to be done before and after drawing anyting, as well as
before and after drawing each view (eye). Quite some info would have to
be exposed to WM to let it manage drawing. So I think using a callback
called from GHOST_Xr to draw each eye instead is a good way to go.

VR session currently crashes after opening. Seems to be related to
blocking frame wait call. I'm not too worried about that though, might
disappear once OpenXR frame sync functions get proper timing info
passed.
2019-06-23 18:27:24 +02:00
Julian Eisel
afbb62fecd Bring back wm_xr.c for higher level XR functions 2019-06-23 15:42:18 +02:00
Julian Eisel
8a676e8fa9 Execute necessary OpenXR frame timing calls 2019-06-23 13:47:42 +02:00
Julian Eisel
c52111e983 Correctly destruct swapchain on shutdown 2019-06-23 02:46:25 +02:00
Julian Eisel
d749e8a2c4 Create graphics binding specific swapchain images
Following the OpenXR SDK's example code very closely here. We have to do
some nasty converting of graphics binding specific image vectors to
generalized base ones. The SDK's approach seems like a good way to go
about this.
2019-06-23 02:12:38 +02:00
Julian Eisel
8663aa80e6 Use abstract class/interface for generalized graphics binding operations
Rather than having switch case blocks throughout the session code, give
binding operations an own interface with dedicated implementations.
2019-06-23 00:37:17 +02:00
Julian Eisel
88b39444a0 Fix error causing sessions to not start correctly
With this, the Windows Mixed Reality Portal finally pops up when
starting the session. That is how it's supposed to work. After it's
initialization phase all you see is black. That's expected too as we
don't send anything to the device yet.
2019-06-22 22:08:50 +02:00
Julian Eisel
4cfc3caa09 OpenXR swapchain creation
Nothing special to say. Just calls needed OpenXR functions to create
swapchains. Swapchain images are not created yet.

Interestingly, the Windows Mixed Realtiy portal now pops up when closing
Blender after having created a VR session. So we're getting closer ;)
2019-06-22 21:25:58 +02:00
Julian Eisel
28428b3462 Merge branch 'master' into soc-2019-openxr 2019-06-21 22:31:01 +02:00
Julian Eisel
24146563a0 Cleanup: Use CamelCase for XR functions/types
Also silence warnings.
2019-06-21 22:27:40 +02:00
Julian Eisel
2ee9c60c20 Finish OpenXR GLX binding initialization
Monado now opens a window here when asking it to start a session. That
seems to be the case because it doesn't detect the HMD as direct mode
capable yet. But that shouldn't be an issue from our side.
2019-06-19 21:11:21 +02:00
Julian Eisel
fb64675209 Fix invalid delete operator use
Again a thing MSVC should warn about but didn't...
2019-06-19 19:09:40 +02:00
Julian Eisel
76385139cf Use friend class to access graphics data on Windows too
Also fix memory leak.
2019-06-19 18:30:19 +02:00
Julian Eisel
b18f5a6a81 Pass graphics context data to OpenXR graphics bindings on Linux too
Refactors function into a class, and make this class a friend of
GHOST_ContextGLX. That seems like a better way to access low level
graphics data for this specific case, rather than giving anyone access
via a getter.
2019-06-19 17:23:41 +02:00
Julian Eisel
9d29373b06 Init OpenXR graphics bindings with valid graphics context (Win only)
Will do this for Linux in a separate commit.

Also fixes a stupid mistake from previous commit on lazy-creation of XR
context.
2019-06-19 12:20:18 +02:00
Julian Eisel
f2f1e4dfed Remove CTX_wm_xr_context
Not really useful, plus XR-Context is now GHOST data.
2019-06-19 01:00:37 +02:00
Julian Eisel
0da0f29ade Rename of XR types (WM -> GHOST) 2019-06-19 00:57:50 +02:00
Julian Eisel
a8519dbac2 Lazy-create XR-context
Creating the context causes the OpenXR loader to try connect to a
runtime. That would involve reading the OS'es active_runtime.json and
dynamic linking based on that. So better avoid doing this on startup.
Also: don't pay for what you don't use!
2019-06-19 00:44:42 +02:00
Julian Eisel
d15d07c4f6 Rename wm_xr_ -> GHOST_XR 2019-06-19 00:28:37 +02:00
Julian Eisel
d356787a65 Merge branch 'soc-2019-openxr' into temp-ghost_openxr 2019-06-18 23:50:28 +02:00
Julian Eisel
a284fa3abb Merge branch 'master' into soc-2019-openxr 2019-06-18 23:49:54 +02:00
Julian Eisel
4eeb7523e9 Use some C++ features where useful
Also correct include guards.
2019-06-18 01:02:33 +02:00
Julian Eisel
f30fcd6c85 Initially move XR files to GHOST and compile in C++ 2019-06-17 23:45:28 +02:00
Julian Eisel
47e8133520 Merge branch 'master' into soc-2019-openxr 2019-06-17 22:24:51 +02:00
Julian Eisel
3fa7d59a04 Fail without crashing if no runtime is found
For now simply do nothing. Plan is to work on proper error handling and
reporting later.
2019-06-17 01:24:07 +02:00
Julian Eisel
df8dc43946 Fix compile errors and warnings on certain configs
Addresses:
* Compile error on Linux
* Compile error with WITH_OPENXR disabled
* Unused parameter warnings
2019-06-16 23:28:14 +02:00
Julian Eisel
3b0a2fecfc Fix missing return value... how did this work even?
Looking at the code this should've failed miserably. No idea how this
could still work fine... Maybe return vars used same stack location?
2019-06-16 23:12:13 +02:00
Julian Eisel
80af6d534d Merge branch 'master' into soc-2019-openxr 2019-06-16 22:58:56 +02:00
Julian Eisel
71c7d61808 Draw OpenGL framebuffer upside down in DirectX windows
DirectX is Y coordinates top to bottom, while OpenGL is the opposite.
For the final window manager on-screen drawing, draw to a texture first
and draw that upside down if needed.
2019-06-16 21:46:57 +02:00
Julian Eisel
637b803b97 Support drawing the VR view into a DirectX window!
Phew! That a fight. But this is also a pretty important feature as it
allows interfacing with Windows Mixed Reality OpenXR runtime and the
HMDs supported by it.

Important remaining issue: The rendered viewport is upside down :) That
is of course because DirectX has the opposite vertical direction than
OpenGL.

When creating a DirectX window, we also create an OpenGL offscreen
context to use for all drawing. Just before swapping framebuffers, the
DirectX window blits the framebuffer of the offscreen context into its
swapchain. This requires the WGL_NV_DX_interop and WGL_NV_DX_interop2
extensions.

For testing/dev purposes, also adds:
* Version of the offscreen to onscreen blitting that's OpenGL only. So
  it blits the default framebuffer of the offscreen context into the one
  of the onscreen context.
  This is disabled by a #define.
* Code to draw a colored triangle using DirectX, also for testing.
  Requires the D3DCompiler.lib to be available at compile time. This is
  also disabled using a #define.
2019-06-16 21:05:21 +02:00
Julian Eisel
314eef0df8 Merge branch 'master' into soc-2019-openxr 2019-06-14 20:41:09 +02:00
Julian Eisel
34fa0f8ac6 Set up DirectX window to support drawing
With this the VR window should open fine and get cleared in a red-ish
orange using Direct3D 11 calls (well, on Windows that is).

The window still draws a 3D view to an offscreen buffer. Where we
usually just swap the buffers, we now allow calling a GHOST function to
blit the offscreen OpenGL buffer to whatever type of graphics buffer the
window uses (DirectX here).
The nice thing about this approach is that all DirectX code stays in
GHOST_ContextD3D.cpp. And the entire compatibiliy code can go into a
single function higher level modules don't need to care about.

This also fixes a number of issues introduced in earlier commits.
2019-06-14 19:07:10 +02:00
Julian Eisel
16366724bd Draw into OpenGL offscreen context in the DirectX window.
The window doesn't show anything of course. However we draw (at least I
assume it does) as regular, just into a window offscreen context.

A valid 3D view is created in the window. It's not visible but you see
cursor changes as you move over the window. So handling works.
2019-06-14 02:41:59 +02:00
Julian Eisel
fc8127d070 (Disabled) code to open a DirectX window with the VR session
The window immediately crashes, hence keeping it disabled for now.

Not sure how much of this I'll leave in, for now this is mainly for
testing DirectX compatibility.
2019-06-13 23:24:30 +02:00
Julian Eisel
3ac37fb552 Fix compile errors with older MSVC/Win-SDK versions
Reported by @LazyDodo, thanks!
2019-06-13 18:22:26 +02:00
Julian Eisel
8e51a75772 Fix mistake causing compiler error on Windows
Stupid one...
2019-06-12 23:45:19 +02:00
Julian Eisel
ba2dab402d Merge branch 'master' into soc-2019-openxr 2019-06-12 21:28:40 +02:00
Julian Eisel
796994d222 Refactor graphics context binding to avoid memory leaks
* Retrieve graphics context to bind through callbacks so the XR code can
  manage their lifetime.
* Use static union to store system & chosen graphics lib specific
  graphics binding data.

Makes some things a bit cleaner, too.
2019-06-12 21:27:00 +02:00
Julian Eisel
66e90e9179 Fix compile error and warning on GCC 2019-06-12 19:28:51 +02:00
Julian Eisel
1404edbe3a Support DirectX Ghost context creation
Adds support for creating a DirectX 11 Ghost context. It's not used yet
and more stuff besides creation is needed. Also, other versions than 11
should probably be supported.
We need a DirectX context to support the Windows Mixed Reality OpenXR
Runtime, a rather important one to support. Idea is to use an extension
for OpenGL-DirectX interoperability for drawing the OpenGL offscreen
viewport render using DirectX.
2019-06-12 11:34:21 +02:00
Julian Eisel
2f68a76409 Split wm_xr.c into multiple files
Similar to gizmo/ and message_bus/, there's now a xr/ directory
containing header files and a intern/ directory for source and internal
header files.

Guess this is reasonable to do. And better to do early on to avoid
loosing much git history.
2019-06-11 17:52:04 +02:00
Julian Eisel
304d9a20fc Fix compile errors and crashes on Windows
* Include needed Windows/DirectX headers
* Disable zero sized arraz (GCC extension)
* Add missing break causing failling assert
* Add missing semicolon in Win only code :)
2019-06-11 16:35:31 +02:00
Julian Eisel
b169e327bf Fix compile error with system OpenXR SDK
Graphics binding types were disabled by a compiler flag then.
2019-06-11 14:18:35 +02:00
Julian Eisel
7238bbecc4 Cleanup: Rename graphics-lib to graphics-binding 2019-06-10 22:16:09 +02:00
Julian Eisel
a49b4ca402 Merge branch 'master' into soc-2019-openxr 2019-06-10 22:06:42 +02:00
Julian Eisel
eb0424c946 Proper management of OpenXR graphics bindings for session setup
OpenXR needs to interface with some graphics library (OpenGL, Vulkan,
DirectX, etc.). This is done through graphics binding extensions. The
OpenXR specification requires these to be properly set up before a
session is created.

Adds the following:
* Support priority list of multiple graphics binding extensions (e.g.
  check OpenGL extension availability first, DirectX on Windows second,
  etc.)
* Barebones for passing graphics library data to OpenXR session
  creation. This is highly system dependent, e.g. it requires GLX data
  for OpenGL on X11 systems (XrGraphicsBindingOpenGLXlibKHR). More work,
  including additions to GHOST, will be needed once I get to the more
  graphics related stuff.
* Create an own graphics context for the VR session. It's not doing
  anything useful yet. This is just to fool the Monado OpenXR runtime
  so that it actually attempts to create the OpenXR session.
* Had to add two CMake modules for platform dependent #define's required
  by the OpenXR specification.
2019-06-10 21:59:26 +02:00
Julian Eisel
5d6da57aa3 Cleanup: Move OpenXRData struct out of wmXRContext
Just to make access a bit more convenient.
2019-06-06 18:38:06 +02:00
Julian Eisel
e968bbc5d8 Fix wrong enum-type used for switch
Why doesn't MSVC warn about this, grr...
2019-06-06 17:37:18 +02:00
Julian Eisel
b1b0e05c54 Fix CMake errors after merge (?)
Not sure if this is caused by changes just merged in, or by a system
upgrade I just did. Either way, fixed it now.
2019-06-06 11:25:53 +02:00
Julian Eisel
e547026dfe Merge branch 'master' into soc-2019-openxr 2019-06-06 10:56:19 +02:00
Julian Eisel
f816380af5 Silence warning, fix mem-leak, don't destroy NULL session 2019-06-05 18:03:59 +02:00
Julian Eisel
5e642bfea1 Initial session state handling
To correctly start a session, a graphics extension specific object needs
to be passed to the OpenXR runtime. E.g. for the Windows Mixed Reality
runtime, XrGraphicsBindingD3D11KHR needs to be passed with a valid
DirectX device. Since we don't have any DirectX compatibility working,
I can't test this on Windows yet.
So to test this I finally need to get Monado to work on Linux and
correctly setup the OpenGL extension there.
2019-06-05 16:55:51 +02:00
Julian Eisel
0d1a22f74f Barebones for managing session changes
Adds initial OpenXR event querying so that session state change events
can be handled. Doesn't do any handling yet.
2019-06-05 10:20:51 +02:00
Julian Eisel
20a1af936d Enable graphics extensions if available
Check if available extensions includes the GL one, or the DirectX one on
Windows. Enable them if available.
2019-06-05 01:00:13 +02:00
Julian Eisel
c9c1b90532 Cleanup: Correct local variable name 2019-06-04 18:30:07 +02:00
Julian Eisel
4192281e14 Fix layer and extension count not stored as intended 2019-06-04 18:27:44 +02:00
Julian Eisel
329deadc9e Print OpenXR runtime name once connected 2019-06-04 17:39:12 +02:00
Julian Eisel
53845c554d Merge branch 'master' into soc-2019-openxr 2019-06-04 17:00:58 +02:00
Julian Eisel
35c9e3beed Initial VR-session starting/ending
Adds operator to toggle a VR session, exposed in the Window top-bar
menu. It triggers the needed calls for session creation and destruction.
Setting up the XR-system (a configuration of related devices) is also
done now.

Calling WMR runtime functions fails currently. Not sure why. So while
this executes required routines, it doesn't really work.
2019-06-04 16:42:42 +02:00
Julian Eisel
60f66768cf Fix GCC compile error, warnings and uninitialized use
extension_count could be used uninitialized if no valid OpenXR runtime
was run.
2019-06-02 22:04:52 +02:00
Julian Eisel
3e88974a80 Merge branch 'master' into soc-2019-openxr 2019-06-02 15:24:33 +02:00
Julian Eisel
09e7d6cd26 Correct previous commit
Intended to print out name, not address.
2019-06-02 02:24:04 +02:00
Julian Eisel
5d5ad5d6dd Gather available OpenXR extensions and API-layers on OpenXR setup
We don't actually enable any extension or layer yet. We just put their
names into arrays and print them. The printing can be disabled via a
compiler define, later we should put them behind a proper
logging/debugging mechanism (CLOG).

Also fixes a Visual Studio compile error.
2019-06-01 17:16:49 +02:00
Julian Eisel
e70894c360 Fix compiling with bundled OpenXR SDK sources
Also remove unused include.
2019-05-30 16:22:05 +02:00
Julian Eisel
4c11886c4e Corrections to previous commit
* Remove testing instance creation
* Rename function
2019-05-30 14:56:23 +02:00
Julian Eisel
41e2f2e75f Proper creation & destruction of OpenXR instances
Adds wm_xr.c for an XR management API and creates/destroys the OpenXR
instance through this. This is as planned in my proposal, to lock the
OpenXR calls behind an abstraction.
XR data will be stored in a (non-public) wmXRContext struct within the
window-manager.

For now, creates the OpenXR instance on startup. I think it's better to
lazy setup this, as in, only creating the instance once the user starts
the first XR session. Just to avoid costs for something that may not be
used (the OpenXR loader we use will try loading and parsing the system's
OpenXR active_runtime.json on instance creation). That's for later when
I introduce session management though.

Also added a context getter for the xr-context, which is unused but may
be handy later.
2019-05-30 14:48:13 +02:00
Julian Eisel
864abbd425 Support system installed OpenXR SDK
Adds OPENXR_USE_BUNDLED_SRC so that if disabled, CMake tries to find
the SDK headers and libraries in system paths or in specified root
directory.

I guess this is the way we'd want to do this in master. However for
people testing the branch the bundled sources are much more convenient
(should work out of the box, no need to compile the SDK manually).
2019-05-30 01:44:13 +02:00
Julian Eisel
f333e7eb56 Merge branch 'master' into soc-2019-openxr 2019-05-29 20:14:11 +02:00
Julian Eisel
a2ac2ec3c3 Merge branch 'master' into soc-2019-openxr 2019-05-29 15:17:41 +02:00
Julian Eisel
06d52afcda Linux: OpenXR Linking via OpenXR Loader
Calling OpenXR functions should now work on both Windows and Linux.

Also includes:
* Silence Linux only warnings
* Remove common_cmake_config.h and let CMake generate it when
  configuring (contents vary on system it's compiled on)
* Remove JsonCpp CMake install target
* Remove unnecessary CMakeLists for JsonCpp includes
* Remove unnecessary CMake commands
* Style cleanup
2019-05-28 21:58:18 +02:00
Julian Eisel
e65ba62c37 Windows: OpenXR Linking via OpenXR Loader
Adds needed headers for OpenXR, the loader from the OpenXR SDK and
JsonCpp into extern. Took a while to get this to compile/link, but on
Win10 it works fine now without patching #includes. Linux probably
needs more work.

Added a compile option WITH_OPENXR to toggle XR feature compiling.

Also does a dummy xrCreateInstance() call to test linking.
2019-05-28 01:21:25 +02:00
2102 changed files with 84422 additions and 90267 deletions

View File

@@ -1,6 +1,7 @@
{
"project_id" : "Blender",
"conduit_uri" : "https://developer.blender.org/",
"phabricator.uri" : "https://developer.blender.org/",
"git.default-relative-commit" : "origin/master",
"arc.land.update.default" : "rebase",
"arc.land.onto.default" : "master"

View File

@@ -180,6 +180,15 @@ option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced(WITH_SYSTEM_BULLET)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON)
if(APPLE)
# There's no OpenXR runtime in sight for macOS, neither is code well
# tested there -> disable it by default.
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF)
mark_as_advanced(WITH_XR_OPENXR)
else()
# Disabled until there's more than just the build system stuff. Should be enabled soon.
option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF)
endif()
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
@@ -633,6 +642,9 @@ set_and_warn_dependency(WITH_TBB WITH_OPENIMAGEDENOISE OFF)
set_and_warn_dependency(WITH_TBB WITH_OPENVDB OFF)
set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID OFF)
# OpenVDB uses 'half' type from OpenEXR & fails to link without OpenEXR enabled.
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
# auto enable openimageio for cycles
if(WITH_CYCLES)
set(WITH_OPENIMAGEIO ON)
@@ -1695,6 +1707,7 @@ if(FIRST_RUN)
info_cfg_option(WITH_CYCLES)
info_cfg_option(WITH_FREESTYLE)
info_cfg_option(WITH_OPENCOLORIO)
info_cfg_option(WITH_XR_OPENXR)
info_cfg_option(WITH_OPENIMAGEDENOISE)
info_cfg_option(WITH_OPENVDB)
info_cfg_option(WITH_ALEMBIC)

View File

@@ -99,6 +99,7 @@ else()
endif()
include(cmake/openimagedenoise.cmake)
include(cmake/embree.cmake)
include(cmake/xr_openxr.cmake)
if(WITH_WEBP)
include(cmake/webp.cmake)

View File

@@ -161,6 +161,8 @@ harvest(opensubdiv/include opensubdiv/include "*.h")
harvest(opensubdiv/lib opensubdiv/lib "*.a")
harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
harvest(openvdb/lib openvdb/lib "*.a")
harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
harvest(xr_openxr_sdk/lib xr_openxr_sdk/lib "*.a")
harvest(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")

View File

@@ -318,3 +318,7 @@ set(LIBGLU_HASH 151aef599b8259efe9acd599c96ea2a3)
set(MESA_VERSION 18.3.1)
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
set(XR_OPENXR_SDK_VERSION 1.0.6)
set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
set(XR_OPENXR_SDK_HASH 21daea7c3bfec365298d779a0e19caa1)

View File

@@ -0,0 +1,59 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENSE BLOCK *****
# Keep flags in sync with install_deps.sh ones in compile_XR_OpenXR_SDK()
set(XR_OPENXR_SDK_EXTRA_ARGS
-DBUILD_FORCE_GENERATION=OFF
-DBUILD_LOADER=ON
-DDYNAMIC_LOADER=OFF
)
if(UNIX AND NOT APPLE)
list(APPEND XR_OPENXR_SDK_EXTRA_ARGS
-DBUILD_WITH_WAYLAND_HEADERS=OFF
-DBUILD_WITH_XCB_HEADERS=OFF
-DBUILD_WITH_XLIB_HEADERS=ON
-DCMAKE_CXX_FLAGS=-DDISABLE_STD_FILESYSTEM=1
)
endif()
ExternalProject_Add(external_xr_openxr_sdk
URL ${XR_OPENXR_SDK_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${XR_OPENXR_SDK_HASH}
PREFIX ${BUILD_DIR}/xr_openxr_sdk
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xr_openxr_sdk ${DEFAULT_CMAKE_FLAGS} ${XR_OPENXR_SDK_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/xr_openxr_sdk
)
if(WIN32)
if(BUILD_MODE STREQUAL Release)
ExternalProject_Add_Step(external_xr_openxr_sdk after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/include/openxr ${HARVEST_TARGET}/xr_openxr_sdk/include/openxr
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/lib ${HARVEST_TARGET}/xr_openxr_sdk/lib
DEPENDEES install
)
endif()
if(BUILD_MODE STREQUAL Debug)
ExternalProject_Add_Step(external_xr_openxr_sdk after_install
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/xr_openxr_sdk/lib/openxr_loader.lib ${HARVEST_TARGET}/xr_openxr_sdk/lib/openxr_loader_d.lib
DEPENDEES install
)
endif()
endif()

View File

@@ -52,16 +52,19 @@ getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
with-all,with-opencollada,with-jack,with-embree,with-oidn,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,ver-xr-openxr:,\
force-all,force-python,force-numpy,force-boost,\
force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
force-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-usd,\
force-xr-openxr,\
build-all,build-python,build-numpy,build-boost,\
build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
build-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-usd,\
build-xr-openxr,\
skip-python,skip-numpy,skip-boost,\
skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd \
skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd, \
skip-xr-openxr\
-- "$@" \
)
@@ -169,6 +172,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--ver-openvdb=<ver>
Force version of OpenVDB library.
--ver-xr-openxr=<ver>
Force version of OpenXR-SDK.
Note about the --ver-foo options:
It may not always work as expected (some libs are actually checked out from a git rev...), yet it might help
to fix some build issues (like LLVM mismatch with the version used by your graphic system).
@@ -224,6 +230,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--build-usd
Force the build of Universal Scene Description.
--build-xr-openxr
Force the build of OpenXR-SDK.
Note about the --build-foo options:
* They force the script to prefer building dependencies rather than using available packages.
This may make things simpler and allow working around some distribution bugs, but on the other hand it will
@@ -285,6 +294,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-usd
Force the rebuild of Universal Scene Description.
--force-xr-openxr
Force the rebuild of OpenXR-SDK.
Note about the --force-foo options:
* They obviously only have an effect if those libraries are built by this script
(i.e. if there is no available and satisfactory package)!
@@ -337,7 +349,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
Unconditionally skip FFMpeg installation/building.
--skip-usd
Unconditionally skip Universal Scene Description installation/building.\""
Unconditionally skip Universal Scene Description installation/building.
--skip-xr-openxr
Unconditionally skip OpenXR-SDK installation/building.\""
# ----------------------------------------------------------------------------
# Main Vars
@@ -454,6 +469,11 @@ FFMPEG_FORCE_REBUILD=false
FFMPEG_SKIP=false
_ffmpeg_list_sep=";"
XR_OPENXR_VERSION="1.0.6"
XR_OPENXR_FORCE_BUILD=false
XR_OPENXR_FORCE_REBUILD=false
XR_OPENXR_SKIP=false
# FFMPEG optional libs.
VORBIS_USE=false
VORBIS_DEV=""
@@ -624,6 +644,11 @@ while true; do
OPENVDB_VERSION_MIN=$OPENVDB_VERSION
shift; shift; continue
;;
--ver-xr-openxr)
XR_OPENXR_VERSION="$2"
XR_OPENXR_VERSION_MIN=$XR_OPENXR_VERSION
shift; shift; continue
;;
--build-all)
PYTHON_FORCE_BUILD=true
NUMPY_FORCE_BUILD=true
@@ -641,6 +666,7 @@ while true; do
FFMPEG_FORCE_BUILD=true
ALEMBIC_FORCE_BUILD=true
USD_FORCE_BUILD=true
XR_OPENXR_FORCE_BUILD=true
shift; continue
;;
--build-python)
@@ -695,6 +721,9 @@ while true; do
--build-usd)
USD_FORCE_BUILD=true; shift; continue
;;
--build-xr-openxr)
XR_OPENXR_FORCE_BUILD=true; shift; continue
;;
--force-all)
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
@@ -712,6 +741,7 @@ while true; do
FFMPEG_FORCE_REBUILD=true
ALEMBIC_FORCE_REBUILD=true
USD_FORCE_REBUILD=true
XR_OPENXR_FORCE_REBUILD=true
shift; continue
;;
--force-python)
@@ -764,6 +794,9 @@ while true; do
--force-usd)
USD_FORCE_REBUILD=true; shift; continue
;;
--force-xr-openxr)
XR_OPENXR_FORCE_REBUILD=true; shift; continue
;;
--skip-python)
PYTHON_SKIP=true; shift; continue
;;
@@ -812,6 +845,9 @@ while true; do
--skip-usd)
USD_SKIP=true; shift; continue
;;
--skip-xr-openxr)
XR_OPENXR_SKIP=true; shift; continue
;;
--)
# no more arguments to parse
break
@@ -940,6 +976,12 @@ OIDN_SOURCE=( "https://github.com/OpenImageDenoise/oidn/releases/download/v${OID
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
XR_OPENXR_USE_REPO=false
XR_OPENXR_SOURCE=("https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_VERSION}.tar.gz")
#~ XR_OPENXR_SOURCE_REPO=("https://github.com/KhronosGroup/OpenXR-SDK-Source.git")
#~ XR_OPENXR_REPO_UID="5292e57fda47561e672fba0a4b6e545c0f25dd8d"
#~ XR_OPENXR_REPO_BRANCH="master"
# C++11 is required now
CXXFLAGS_BACK=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -std=c++11"
@@ -982,7 +1024,8 @@ You may also want to build them yourself (optional ones are [between brackets]):
* [Embree $EMBREE_VERSION] (from $EMBREE_SOURCE).
* [OpenImageDenoise $OIDN_VERSION] (from $OIDN_SOURCE).
* [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).
* [Universal Scene Description $USD_VERSION] (from $USD_SOURCE).\""
* [Universal Scene Description $USD_VERSION] (from $USD_SOURCE).
* [OpenXR-SDK $XR_OPENXR_VERSION] (from $XR_OPENXR_SOURCE).\""
if [ "$DO_SHOW_DEPS" = true ]; then
PRINT ""
@@ -3058,6 +3101,116 @@ compile_FFmpeg() {
fi
}
# ----------------------------------------------------------------------------
# Build OpenXR SDK
_init_xr_openxr_sdk() {
_src=$SRC/XR-OpenXR-SDK-$XR_OPENXR_VERSION
_git=true
_inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION
_inst_shortcut=$INST/xr-openxr-sdk
}
_update_deps_xr_openxr_sdk() {
:
}
clean_XR_OpenXR_SDK() {
_init_xr_openxr_sdk
_clean
_update_deps_xr_openxr_sdk
}
compile_XR_OpenXR_SDK() {
if [ "$NO_BUILD" = true ]; then
WARNING "--no-build enabled, OpenXR will not be compiled!"
return
fi
# To be changed each time we make edits that would modify the compiled result!
xr_openxr_magic=0
_init_xr_openxr_sdk
# Clean install if needed!
magic_compile_check xr-openxr-$OPENXR_VERSION $xr_openxr_magic
if [ $? -eq 1 -o "$XR_OPENXR_FORCE_REBUILD" = true ]; then
clean_XR_OpenXR_SDK
fi
if [ ! -d $_inst ]; then
INFO "Building XR-OpenXR-SDK-$XR_OPENXR_VERSION"
_is_building=true
# Rebuild dependencies as well!
_update_deps_xr_openxr_sdk
prepare_opt
if [ ! -d $_src ]; then
mkdir -p $SRC
if [ "$XR_OPENXR_USE_REPO" = true ]; then
git clone $XR_OPENXR_SOURCE_REPO $_src
else
download XR_OPENXR_SOURCE[@] "$_src.tar.gz"
INFO "Unpacking XR-OpenXR-SDK-$XR_OPENXR_VERSION"
tar -C $SRC --transform "s,(.*/?)OpenXR-SDK-[^/]*(.*),\1XR-OpenXR-SDK-$XR_OPENXR_VERSION\2,x" \
-xf $_src.tar.gz
fi
fi
cd $_src
if [ "$XR_OPENXR_USE_REPO" = true ]; then
git pull origin $XR_OPENXR_REPO_BRANCH
# Stick to same rev as windows' libs...
git checkout $XR_OPENXR_REPO_UID
git reset --hard
fi
# Always refresh the whole build!
if [ -d build ]; then
rm -rf build
fi
mkdir build
cd build
# Keep flags in sync with XR_OPENXR_SDK_EXTRA_ARGS in xr_openxr.cmake!
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D BUILD_FORCE_GENERATION=OFF"
cmake_d="$cmake_d -D BUILD_LOADER=ON"
cmake_d="$cmake_d -D DYNAMIC_LOADER=OFF"
cmake_d="$cmake_d -D BUILD_WITH_WAYLAND_HEADERS=OFF"
cmake_d="$cmake_d -D BUILD_WITH_XCB_HEADERS=OFF"
cmake_d="$cmake_d -D BUILD_WITH_XLIB_HEADERS=ON"
cmake $cmake_d ..
make -j$THREADS && make install
make clean
if [ -d $_inst ]; then
_create_inst_shortcut
else
ERROR "XR-OpenXR-SDK-$XR_OPENXR_VERSION failed to compile, exiting"
exit 1
fi
magic_compile_set xr-openxr-$XR_OPENXR_VERSION $xr_openxr_magic
cd $CWD
INFO "Done compiling XR-OpenXR-SDK-$XR_OPENXR_VERSION!"
_is_building=false
else
INFO "Own XR-OpenXR-SDK-$XR_OPENXR_VERSION is up to date, nothing to do!"
INFO "If you want to force rebuild of this lib, use the --force-xr-openxr option."
fi
run_ldconfig "xr-openxr-sdk"
}
# ----------------------------------------------------------------------------
# Install on DEB-like
@@ -3602,6 +3755,18 @@ install_DEB() {
compile_FFmpeg
fi
fi
PRINT ""
if [ "$XR_OPENXR_SKIP" = true ]; then
WARNING "Skipping OpenXR-SDK installation, as requested..."
elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
INFO "Forced OpenXR-SDK building, as requested..."
compile_XR_OpenXR_SDK
else
# No package currently!
PRINT ""
compile_XR_OpenXR_SDK
fi
}
@@ -4208,6 +4373,17 @@ install_RPM() {
compile_FFmpeg
fi
fi
PRINT ""
if [ "$XR_OPENXR_SKIP" = true ]; then
WARNING "Skipping OpenXR-SDK installation, as requested..."
elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
INFO "Forced OpenXR-SDK building, as requested..."
compile_XR_OpenXR_SDK
else
# No package currently!
compile_XR_OpenXR_SDK
fi
}
@@ -4709,6 +4885,17 @@ install_ARCH() {
compile_FFmpeg
fi
fi
PRINT ""
if [ "$XR_OPENXR_SKIP" = true ]; then
WARNING "Skipping OpenXR-SDK installation, as requested..."
elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
INFO "Forced OpenXR-SDK building, as requested..."
compile_XR_OpenXR_SDK
else
# No package currently!
compile_XR_OpenXR_SDK
fi
}
@@ -4906,6 +5093,17 @@ install_OTHER() {
INFO "Forced FFMpeg building, as requested..."
compile_FFmpeg
fi
PRINT ""
if [ "$XR_OPENXR_SKIP" = true ]; then
WARNING "Skipping OpenXR-SDK installation, as requested..."
elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
INFO "Forced OpenXR-SDK building, as requested..."
compile_XR_OpenXR_SDK
else
# No package currently!
compile_XR_OpenXR_SDK
fi
}
# ----------------------------------------------------------------------------
@@ -5174,6 +5372,17 @@ print_info() {
fi
fi
if [ "$XR_OPENXR_SKIP" = false ]; then
_1="-D WITH_XR_OPENXR=ON"
PRINT " $_1"
_buildargs="$_buildargs $_1"
if [ -d $INST/xr-openxr-sdk ]; then
_1="-D XR_OPENXR_SDK_ROOT_DIR=$INST/xr-openxr-sdk"
PRINT " $_1"
_buildargs="$_buildargs $_1"
fi
fi
PRINT ""
PRINT "Or even simpler, just run (in your blender-source dir):"
PRINT " make -j$THREADS BUILD_CMAKE_ARGS=\"$_buildargs\""

View File

@@ -98,7 +98,7 @@ class VersionInfo:
self.is_development_build = False
else:
# Development build
self.full_version = self.version + '-' + self.hash
self.full_version = self.version + self.version_char + '-' + self.hash
self.is_development_build = True
def _parse_header_file(self, filename, define):

View File

@@ -49,7 +49,6 @@ if(NOT LLVM_ROOT_DIR)
OUTPUT_VARIABLE LLVM_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_ROOT_DIR ${LLVM_ROOT_DIR} CACHE PATH "Path to the LLVM installation")
set(LLVM_INCLUDE_DIRS ${LLVM_ROOT_DIR}/include CACHE PATH "Path to the LLVM include directory")
endif()
if(NOT LLVM_LIBPATH)
execute_process(COMMAND ${LLVM_CONFIG} --libdir

View File

@@ -0,0 +1,73 @@
# - Find OpenXR-SDK libraries
# Find the native OpenXR-SDK includes and libraries
#
# Note that there is a distinction between the OpenXR standard and the SDK. The
# latter provides utilities to use the standard but is not part of it. Most
# importantly, it contains C headers and a loader library, which manages
# dynamic linking to OpenXR runtimes like Monado, Windows Mixed Reality or
# Oculus. See the repository for more details:
# https://github.com/KhronosGroup/OpenXR-SDK
#
# This module defines
# XR_OPENXR_SDK_INCLUDE_DIRS, where to find OpenXR-SDK headers, Set when
# XR_OPENXR_SDK_INCLUDE_DIR is found.
# XR_OPENXR_SDK_LIBRARIES, libraries to link against to use OpenXR.
# XR_OPENXR_SDK_ROOT_DIR, the base directory to search for OpenXR-SDK.
# This can also be an environment variable.
# XR_OPENXR_SDK_FOUND, if false, do not try to use OpenXR-SDK.
#
# also defined, but not for general use are
# XR_OPENXR_SDK_LOADER_LIBRARY, where to find the OpenXR-SDK loader library.
#=============================================================================
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If XR_OPENXR_SDK_ROOT_DIR was defined in the environment, use it.
IF(NOT XR_OPENXR_SDK_ROOT_DIR AND NOT $ENV{XR_OPENXR_SDK_ROOT_DIR} STREQUAL "")
SET(XR_OPENXR_SDK_ROOT_DIR $ENV{XR_OPENXR_SDK_ROOT_DIR})
ENDIF()
SET(_xr_openxr_sdk_SEARCH_DIRS
${XR_OPENXR_SDK_ROOT_DIR}
/opt/lib/xr-openxr-sdk
)
FIND_PATH(XR_OPENXR_SDK_INCLUDE_DIR
NAMES
openxr/openxr.h
HINTS
${_xr_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(XR_OPENXR_SDK_LOADER_LIBRARY
NAMES
openxr_loader
HINTS
${_xr_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set XR_OPENXR_SDK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OPENXR_SDK DEFAULT_MSG
XR_OPENXR_SDK_LOADER_LIBRARY XR_OPENXR_SDK_INCLUDE_DIR)
IF(XR_OPENXR_SDK_FOUND)
SET(XR_OPENXR_SDK_LIBRARIES ${XR_OPENXR_SDK_LOADER_LIBRARY})
SET(XR_OPENXR_SDK_INCLUDE_DIRS ${XR_OPENXR_SDK_INCLUDE_DIR})
ENDIF(XR_OPENXR_SDK_FOUND)
MARK_AS_ADVANCED(
XR_OPENXR_SDK_INCLUDE_DIR
XR_OPENXR_SDK_LOADER_LIBRARY
)

View File

@@ -61,3 +61,6 @@ if(UNIX AND NOT APPLE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
endif()
if(NOT APPLE)
set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
endif()

View File

@@ -44,6 +44,7 @@ set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE OFF CACHE BOOL "" FORCE)
set(WITH_XR_OPENXR OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENMP OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)

View File

@@ -65,3 +65,6 @@ if(UNIX AND NOT APPLE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
endif()
if(NOT APPLE)
set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
endif()

View File

@@ -122,7 +122,7 @@ function(target_link_libraries_optimized
)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} optimized "${_LIB}")
target_link_libraries(${TARGET} INTERFACE optimized "${_LIB}")
endforeach()
endfunction()
@@ -132,7 +132,7 @@ function(target_link_libraries_debug
)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} debug "${_LIB}")
target_link_libraries(${TARGET} INTERFACE debug "${_LIB}")
endforeach()
endfunction()
@@ -170,6 +170,7 @@ function(blender_include_dirs_sys
endfunction()
function(blender_source_group
name
sources
)
@@ -205,6 +206,13 @@ function(blender_source_group
source_group("${GROUP_ID}" FILES ${_SRC})
endforeach()
endif()
# if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
set_target_properties(${name} PROPERTIES FOLDER ${FolderDir})
endif()
endfunction()
@@ -295,11 +303,11 @@ function(blender_add_lib__impl
set(next_library_mode "${library_lower}")
else()
if("${next_library_mode}" STREQUAL "optimized")
target_link_libraries(${name} optimized ${library})
target_link_libraries(${name} INTERFACE optimized ${library})
elseif("${next_library_mode}" STREQUAL "debug")
target_link_libraries(${name} debug ${library})
target_link_libraries(${name} INTERFACE debug ${library})
else()
target_link_libraries(${name} ${library})
target_link_libraries(${name} INTERFACE ${library})
endif()
set(next_library_mode "")
endif()
@@ -308,14 +316,7 @@ function(blender_add_lib__impl
# works fine without having the includes
# listed is helpful for IDE's (QtCreator/MSVC)
blender_source_group("${sources}")
# if enabled, set the FOLDER property for visual studio projects
if(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS)
get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir})
set_target_properties(${name} PROPERTIES FOLDER ${FolderDir})
endif()
blender_source_group("${name}" "${sources}")
list_assert_duplicates("${sources}")
list_assert_duplicates("${includes}")
@@ -946,7 +947,7 @@ function(data_to_c_simple
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
endfunction()
# macro for converting pixmap directory to a png and then a c file
# Function for converting pixmap directory to a '.png' and then a '.c' file.
function(data_to_c_simple_icons
path_from icon_prefix icon_names
list_to_add
@@ -1159,12 +1160,12 @@ macro(blender_precompile_headers target cpp header)
endmacro()
macro(set_and_warn_dependency
_dependency _setting _val)
# when $_dependency is disabled, forces $_setting = $_val
if(NOT ${${_dependency}} AND ${${_setting}})
message(STATUS "'${_dependency}' is disabled: forcing 'set(${_setting} ${_val})'")
set(${_setting} ${_val})
endif()
_dependency _setting _val)
# when $_dependency is disabled, forces $_setting = $_val
if(NOT ${${_dependency}} AND ${${_setting}})
message(STATUS "'${_dependency}' is disabled: forcing 'set(${_setting} ${_val})'")
set(${_setting} ${_val})
endif()
endmacro()
macro(without_system_libs_begin)

View File

@@ -411,11 +411,21 @@ if(WITH_OPENMP)
# Copy libomp.dylib to allow executables like datatoc and tests to work.
execute_process(
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Resources/lib
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libomp.dylib)
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Resources/lib
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libomp.dylib
)
execute_process(
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin/Resources/lib
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/bin/Resources/lib/libomp.dylib)
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin/Resources/lib
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/bin/Resources/lib/libomp.dylib
)
endif()
endif()
if(WITH_XR_OPENXR)
find_package(OpenXR-SDK)
if(NOT OPENXR_SDK_FOUND)
message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
set(WITH_XR_OPENXR OFF)
endif()
endif()

View File

@@ -428,6 +428,14 @@ if(WITH_TBB)
find_package_wrapper(TBB)
endif()
if(WITH_XR_OPENXR)
find_package(XR-OpenXR-SDK)
if(NOT XR_OPENXR_SDK_FOUND)
message(WARNING "OpenXR-SDK not found, disabling WITH_XR_OPENXR")
set(WITH_XR_OPENXR OFF)
endif()
endif()
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()

View File

@@ -671,8 +671,8 @@ if(WITH_USD)
set(USD_DEBUG_LIB ${LIBDIR}/usd/lib/libusd_m_d.lib)
set(USD_LIBRARY_DIR ${LIBDIR}/usd/lib/usd)
set(USD_LIBRARIES
debug ${USD_DEBUG_LIB}
optimized ${USD_RELEASE_LIB}
debug ${USD_DEBUG_LIB}
optimized ${USD_RELEASE_LIB}
)
endif()
endif()
@@ -713,3 +713,15 @@ if(WINDOWS_PYTHON_DEBUG)
</Project>")
endif()
endif()
if(WITH_XR_OPENXR)
if(EXISTS ${LIBDIR}/xr_openxr_sdk)
set(XR_OPENXR_SDK ${LIBDIR}/xr_openxr_sdk)
set(XR_OPENXR_SDK_LIBPATH ${LIBDIR}/xr_openxr_sdk/lib)
set(XR_OPENXR_SDK_INCLUDE_DIR ${XR_OPENXR_SDK}/include)
set(XR_OPENXR_SDK_LIBRARIES optimized ${XR_OPENXR_SDK_LIBPATH}/openxr_loader.lib debug ${XR_OPENXR_SDK_LIBPATH}/openxr_loader_d.lib)
else()
message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
set(WITH_XR_OPENXR OFF)
endif()
endif()

View File

@@ -0,0 +1,44 @@
"""
The message bus system can be used to receive notifications when properties of
Blender datablocks are changed via the data API.
Limitations
-----------
The message bus system is triggered by updates via the RNA system. This means
that the following updates will result in a notification on the message bus:
- Changes via the Python API, for example ``some_object.location.x += 3``.
- Changes via the sliders, fields, and buttons in the user interface.
The following updates do **not** trigger message bus notifications:
- Moving objects in the 3D Viewport.
- Changes performed by the animation system.
Example Use
-----------
Below is an example of subscription to changes in the active object's location.
"""
import bpy
# Any Python object can act as the subscription's owner.
owner = object()
subscribe_to = bpy.context.object.location
def msgbus_callback(*args):
# This will print:
# Something changed! (1, 2, 3)
print("Something changed!", args)
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=owner,
args=(1, 2, 3),
notify=msgbus_callback,
)

View File

@@ -0,0 +1,6 @@
"""
Some properties are converted to Python objects when you retrieve them. This
needs to be avoided in order to create the subscription, by using
``datablock.path_resolve("property_name", False)``:
"""
subscribe_to = bpy.context.object.path_resolve("name", False)

View File

@@ -0,0 +1,5 @@
"""
It is also possible to create subscriptions on a property of all instances of a
certain type:
"""
subscribe_to = (bpy.types.Object, "location")

View File

@@ -6,7 +6,7 @@ bl_info = {
"location": "SpaceBar Search -> Add-on Preferences Example",
"description": "Example Add-on",
"warning": "",
"wiki_url": "",
"doc_url": "",
"tracker_url": "",
"category": "Object",
}

View File

@@ -255,9 +255,9 @@ Examples:
>>> bpy.ops.object.scale_apply()
{'FINISHED'}
.. note::
.. tip::
The menu item: :menuselection:`Help --> Operator Cheat Sheet`
The :ref:`Operator Cheat Sheet <blender_manual:bpy.ops.wm.operator_cheat_sheet>`.
gives a list of all operators and their default values in Python syntax, along with the generated docs.
This is a good way to get an overview of all Blender's operators.

View File

@@ -1756,6 +1756,7 @@ def write_rst_contents(basepath):
app_modules = (
"bpy.context", # note: not actually a module
"bpy.data", # note: not actually a module
"bpy.msgbus", # note: not actually a module
"bpy.ops",
"bpy.types",
@@ -1846,6 +1847,29 @@ def write_rst_ops_index(basepath):
file.close()
def write_rst_msgbus(basepath):
"""
Write the rst files of bpy.msgbus module
"""
if 'bpy.msgbus' in EXCLUDE_MODULES:
return
# Write the index.
filepath = os.path.join(basepath, "bpy.msgbus.rst")
file = open(filepath, "w", encoding="utf-8")
fw = file.write
fw(title_string("Message Bus (bpy.msgbus)", "="))
write_example_ref("", fw, "bpy.msgbus")
fw(".. toctree::\n")
fw(" :glob:\n\n")
fw(" bpy.msgbus.*\n\n")
file.close()
# Write the contents.
pymodule2sphinx(basepath, 'bpy.msgbus', bpy.msgbus, 'Message Bus')
EXAMPLE_SET_USED.add("bpy.msgbus")
def write_rst_data(basepath):
'''
Write the rst file of bpy.data module
@@ -2000,6 +2024,7 @@ def rna2sphinx(basepath):
write_rst_bpy(basepath) # bpy, disabled by default
write_rst_types_index(basepath) # bpy.types
write_rst_ops_index(basepath) # bpy.ops
write_rst_msgbus(basepath) # bpy.msgbus
pyrna2sphinx(basepath) # bpy.types.* and bpy.ops.*
write_rst_data(basepath) # bpy.data
write_rst_importable_modules(basepath)

View File

@@ -415,4 +415,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
endif()
if(MSVC)
# bullet is responsible for quite a few silly warnings
# suppress all of them. Not great, but they really needed
# to sort that out themselves.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
endif()
blender_add_lib(extern_bullet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -24,6 +24,21 @@ set(CMAKE_CXX_STANDARD 14)
add_subdirectory(dracoenc)
# Build blender-draco-exporter module.
add_library(extern_draco SHARED src/draco-compressor.cpp src/draco-compressor.h)
target_include_directories(extern_draco PUBLIC dracoenc/src)
target_link_libraries(extern_draco PUBLIC dracoenc)
set(SRC
src/draco-compressor.cpp
src/draco-compressor.h
)
set(INC
dracoenc/src
)
set(LIB
dracoenc
)
add_library(extern_draco SHARED "${SRC}")
target_include_directories(extern_draco PUBLIC "${INC}")
target_link_libraries(extern_draco PUBLIC "${LIB}")
blender_source_group(extern_draco "${SRC}")

View File

@@ -77,6 +77,11 @@ if(WIN32)
list(APPEND INC
src/windows
)
if(MSVC)
# Suppress warning about google::LogMessageFatal::~LogMessageFatal
# not returning.
add_definitions("/wd4722")
endif()
else()
list(APPEND INC
include

View File

@@ -192,7 +192,7 @@ int cbDisableConstructor(PyObject *self, PyObject *args, PyObject *kwds)
return -1;
}
PyMODINIT_FUNC PyInit_Main(void)
PyMODINIT_FUNC PyInit_manta_main(void)
{
MantaEnsureRegistration();
#if PY_MAJOR_VERSION >= 3
@@ -567,7 +567,7 @@ void WrapperRegistry::construct(const string &scriptname, const vector<string> &
registerDummyTypes();
// work around for certain gcc versions, cast to char*
PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_Main);
PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_manta_main);
}
inline PyObject *castPy(PyTypeObject *p)

View File

@@ -62,7 +62,7 @@ void MantaEnsureRegistration();
#ifdef BLENDER
# ifdef PyMODINIT_FUNC
PyMODINIT_FUNC PyInit_Main(void);
PyMODINIT_FUNC PyInit_manta_main(void);
# endif
#endif

View File

@@ -17,16 +17,13 @@
// link to omp & tbb for now
#if OPENMP == 1 || TBB == 1
# define MANTA_ENABLE_PARALLEL 0
# define MANTA_ENABLE_PARALLEL 1
// allow the preconditioner to be computed in parallel? (can lead to slightly non-deterministic
// results)
# define MANTA_ENABLE_PARALLEL_PC 0
// use c++11 code?
# define MANTA_USE_CPP11 1
#else
# define MANTA_ENABLE_PARALLEL 0
# define MANTA_ENABLE_PARALLEL_PC 0
# define MANTA_USE_CPP11 0
#endif
#if MANTA_ENABLE_PARALLEL == 1
@@ -503,11 +500,7 @@ template<class N, class T> struct RCMatrix {
for (Iterator it = row_begin(i); it; ++it)
result.fix_element(it.index(), i, it.value());
}
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
}
RCMatrix getKtK() const
@@ -532,12 +525,7 @@ template<class N, class T> struct RCMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix operator*(const RCMatrix &m) const
@@ -561,12 +549,7 @@ template<class N, class T> struct RCMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix sqrt() const
@@ -581,12 +564,7 @@ template<class N, class T> struct RCMatrix {
result.set_element(i, j, std::sqrt(it_A.value()));
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix operator*(const double k) const
@@ -601,12 +579,7 @@ template<class N, class T> struct RCMatrix {
result.add_to_element(i, j, it_A.value() * k);
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix applyKernel(const RCMatrix &kernel, const int nx, const int ny) const
@@ -640,12 +613,7 @@ template<class N, class T> struct RCMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix applyHorizontalKernel(const RCMatrix &kernel, const int nx, const int ny) const
@@ -679,12 +647,7 @@ template<class N, class T> struct RCMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix applyVerticalKernel(const RCMatrix &kernel, const int nx, const int ny) const
@@ -718,12 +681,7 @@ template<class N, class T> struct RCMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix applySeparableKernel(const RCMatrix &kernelH,
@@ -747,11 +705,7 @@ template<class N, class T> struct RCMatrix {
{
std::vector<T> result(n, 0.0);
multiply(rhs, result);
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
}
void multiply(const std::vector<T> &rhs, std::vector<T> &result) const
{
@@ -832,11 +786,7 @@ template<class N, class T> struct RCMatrix {
for (N i = 0; i < result.size(); i++) {
result[i] = std::abs(result[i] - rhs[i]);
}
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
}
T norm() const
{
@@ -1024,11 +974,7 @@ template<class N, class T> struct RCFixedMatrix {
{
std::vector<T> result(n, 0.0);
multiply(rhs, result);
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
}
void multiply(const std::vector<T> &rhs, std::vector<T> &result) const
{
@@ -1064,12 +1010,7 @@ template<class N, class T> struct RCFixedMatrix {
}
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
RCMatrix<N, T> toRCMatrix() const
@@ -1087,12 +1028,7 @@ template<class N, class T> struct RCFixedMatrix {
result.matrix[i]->value[j] = value[rowstart[i] + j];
}
}
parallel_end
#if MANTA_USE_CPP11 == 1
return std::move(result);
#else
return result;
#endif
parallel_end return result;
}
};

View File

@@ -15,7 +15,7 @@
#define _VECTORBASE_H
// get rid of windos min/max defines
#if defined(WIN32) || defined(_WIN32)
#if (defined(WIN32) || defined(_WIN32)) && !defined(NOMINMAX)
# define NOMINMAX
#endif

View File

@@ -1,3 +1,3 @@
#define MANTA_GIT_VERSION "commit ce000bcbd7004e6549ac2f118755fcdc1f679bc3"
#define MANTA_GIT_VERSION "commit 5fbd3d04381b21afce4a593d1fe2d9bc7bef5424"

View File

@@ -1829,13 +1829,15 @@ struct KnUpdateFlagsObs : public KernelBase {
const MACGrid *fractions,
const Grid<Real> &phiObs,
const Grid<Real> *phiOut,
const Grid<Real> *phiIn)
: KernelBase(&flags, 1),
const Grid<Real> *phiIn,
int boundaryWidth)
: KernelBase(&flags, boundaryWidth),
flags(flags),
fractions(fractions),
phiObs(phiObs),
phiOut(phiOut),
phiIn(phiIn)
phiIn(phiIn),
boundaryWidth(boundaryWidth)
{
runMessage();
run();
@@ -1847,7 +1849,8 @@ struct KnUpdateFlagsObs : public KernelBase {
const MACGrid *fractions,
const Grid<Real> &phiObs,
const Grid<Real> *phiOut,
const Grid<Real> *phiIn) const
const Grid<Real> *phiIn,
int boundaryWidth) const
{
bool isObs = false;
@@ -1910,6 +1913,11 @@ struct KnUpdateFlagsObs : public KernelBase {
return phiIn;
}
typedef Grid<Real> type4;
inline int &getArg5()
{
return boundaryWidth;
}
typedef int type5;
void runMessage()
{
debMsg("Executing kernel KnUpdateFlagsObs ", 3);
@@ -1923,15 +1931,15 @@ struct KnUpdateFlagsObs : public KernelBase {
const int _maxY = maxY;
if (maxZ > 1) {
for (int k = __r.begin(); k != (int)__r.end(); k++)
for (int j = 1; j < _maxY; j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, flags, fractions, phiObs, phiOut, phiIn);
for (int j = boundaryWidth; j < _maxY; j++)
for (int i = boundaryWidth; i < _maxX; i++)
op(i, j, k, flags, fractions, phiObs, phiOut, phiIn, boundaryWidth);
}
else {
const int k = 0;
for (int j = __r.begin(); j != (int)__r.end(); j++)
for (int i = 1; i < _maxX; i++)
op(i, j, k, flags, fractions, phiObs, phiOut, phiIn);
for (int i = boundaryWidth; i < _maxX; i++)
op(i, j, k, flags, fractions, phiObs, phiOut, phiIn, boundaryWidth);
}
}
void run()
@@ -1939,13 +1947,14 @@ struct KnUpdateFlagsObs : public KernelBase {
if (maxZ > 1)
tbb::parallel_for(tbb::blocked_range<IndexInt>(minZ, maxZ), *this);
else
tbb::parallel_for(tbb::blocked_range<IndexInt>(1, maxY), *this);
tbb::parallel_for(tbb::blocked_range<IndexInt>(boundaryWidth, maxY), *this);
}
FlagGrid &flags;
const MACGrid *fractions;
const Grid<Real> &phiObs;
const Grid<Real> *phiOut;
const Grid<Real> *phiIn;
int boundaryWidth;
};
//! update obstacle and outflow flags from levelsets
@@ -1954,9 +1963,10 @@ void setObstacleFlags(FlagGrid &flags,
const Grid<Real> &phiObs,
const MACGrid *fractions = NULL,
const Grid<Real> *phiOut = NULL,
const Grid<Real> *phiIn = NULL)
const Grid<Real> *phiIn = NULL,
int boundaryWidth = 1)
{
KnUpdateFlagsObs(flags, fractions, phiObs, phiOut, phiIn);
KnUpdateFlagsObs(flags, fractions, phiObs, phiOut, phiIn, boundaryWidth);
}
static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
{
@@ -1973,8 +1983,9 @@ static PyObject *_W_18(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
const MACGrid *fractions = _args.getPtrOpt<MACGrid>("fractions", 2, NULL, &_lock);
const Grid<Real> *phiOut = _args.getPtrOpt<Grid<Real>>("phiOut", 3, NULL, &_lock);
const Grid<Real> *phiIn = _args.getPtrOpt<Grid<Real>>("phiIn", 4, NULL, &_lock);
int boundaryWidth = _args.getOpt<int>("boundaryWidth", 5, 1, &_lock);
_retval = getPyNone();
setObstacleFlags(flags, phiObs, fractions, phiOut, phiIn);
setObstacleFlags(flags, phiObs, fractions, phiOut, phiIn, boundaryWidth);
_args.check();
}
pbFinalizePlugin(parent, "setObstacleFlags", !noTiming);

View File

@@ -1171,6 +1171,11 @@ void solvePressureSystem(Grid<Real> &rhs,
maxIter = 100;
pmg = gMapMG[parent];
// Release MG from previous step if present (e.g. if previous solve was with MGStatic)
if (pmg && preconditioner == PcMGDynamic) {
releaseMG(parent);
pmg = nullptr;
}
if (!pmg) {
pmg = new GridMg(pressure.getSize());
gMapMG[parent] = pmg;

View File

@@ -177,14 +177,11 @@ if(CXX_HAS_AVX2)
add_definitions(-DWITH_KERNEL_AVX2)
endif()
if(WITH_CYCLES_OSL)
# LLVM and OSL need to build without RTTI
if(WIN32 AND MSVC)
set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
# LLVM and OSL need to build without RTTI
if(WIN32 AND MSVC)
set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
endif()
# Definitions and Includes

View File

@@ -51,14 +51,16 @@ endif()
# Common configuration.
link_directories(${OPENIMAGEIO_LIBPATH}
${BOOST_LIBPATH}
${PNG_LIBPATH}
${JPEG_LIBPATH}
${ZLIB_LIBPATH}
${TIFF_LIBPATH}
${OPENEXR_LIBPATH}
${OPENJPEG_LIBPATH})
link_directories(
${OPENIMAGEIO_LIBPATH}
${BOOST_LIBPATH}
${PNG_LIBPATH}
${JPEG_LIBPATH}
${ZLIB_LIBPATH}
${TIFF_LIBPATH}
${OPENEXR_LIBPATH}
${OPENJPEG_LIBPATH}
)
if(WITH_OPENCOLORIO)
link_directories(${OPENCOLORIO_LIBPATH})

View File

@@ -292,7 +292,7 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node
filepath = path_join(state.base, filepath);
}
snode = ((OSLShaderManager *)manager)->osl_node(filepath);
snode = OSLShaderManager::osl_node(manager, filepath);
if (!snode) {
fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());

View File

@@ -38,6 +38,7 @@ set(SRC
CCL_api.h
blender_device.h
blender_id_map.h
blender_image.h
blender_object_cull.h
blender_sync.h
blender_session.h

View File

@@ -22,7 +22,7 @@ bl_info = {
"blender": (2, 80, 0),
"description": "Cycles renderer integration",
"warning": "",
"wiki_url": "https://docs.blender.org/manual/en/latest/render/cycles/",
"doc_url": "https://docs.blender.org/manual/en/latest/render/cycles/",
"tracker_url": "",
"support": 'OFFICIAL',
"category": "Render"}

View File

@@ -33,7 +33,7 @@ def _is_using_buggy_driver():
# in the version string, but those cards do not quite work and
# causing crashes.
return True
regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
regex = re.compile(".*Compatibility Profile Context ([0-9]+(\\.[0-9]+)+)$")
if not regex.match(version):
# Skip cards like FireGL
return False
@@ -255,6 +255,7 @@ def list_render_passes(srl):
if crl.pass_debug_bvh_traversed_instances: yield ("Debug BVH Traversed Instances", "X", 'VALUE')
if crl.pass_debug_bvh_intersections: yield ("Debug BVH Intersections", "X", 'VALUE')
if crl.pass_debug_ray_bounces: yield ("Debug Ray Bounces", "X", 'VALUE')
if crl.pass_debug_sample_count: yield ("Debug Sample Count", "X", 'VALUE')
if crl.use_pass_volume_direct: yield ("VolumeDir", "RGB", 'COLOR')
if crl.use_pass_volume_indirect: yield ("VolumeInd", "RGB", 'COLOR')

View File

@@ -112,6 +112,7 @@ enum_use_layer_samples = (
enum_sampling_pattern = (
('SOBOL', "Sobol", "Use Sobol random sampling pattern"),
('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"),
('PROGRESSIVE_MUTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern"),
)
enum_integrator = (
@@ -349,6 +350,26 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=0.01,
)
use_adaptive_sampling: BoolProperty(
name="Use Adaptive Sampling",
description="Automatically reduce the number of samples per pixel based on estimated noise level",
default=False,
)
adaptive_threshold: FloatProperty(
name="Adaptive Sampling Threshold",
description="Noise level step to stop sampling at, lower values reduce noise the cost of render time. Zero for automatic setting based on number of AA samples",
min=0.0, max=1.0,
default=0.0,
precision=4,
)
adaptive_min_samples: IntProperty(
name="Adaptive Min Samples",
description="Minimum AA samples for adaptive sampling, to discover noisy features before stopping sampling. Zero for automatic setting based on number of AA samples",
min=0, max=4096,
default=0,
)
min_light_bounces: IntProperty(
name="Min Light Bounces",
description="Minimum number of light bounces. Setting this higher reduces noise in the first bounces, "
@@ -1297,7 +1318,12 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
default=False,
update=update_render_passes,
)
pass_debug_sample_count: BoolProperty(
name="Debug Sample Count",
description="Number of samples/camera rays per pixel",
default=False,
update=update_render_passes,
)
use_pass_volume_direct: BoolProperty(
name="Volume Direct",
description="Deliver direct volumetric scattering pass",

View File

@@ -230,6 +230,32 @@ class CYCLES_RENDER_PT_sampling_sub_samples(CyclesButtonsPanel, Panel):
draw_samples_info(layout, context)
class CYCLES_RENDER_PT_sampling_adaptive(CyclesButtonsPanel, Panel):
bl_label = "Adaptive Sampling"
bl_parent_id = "CYCLES_RENDER_PT_sampling"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
layout = self.layout
scene = context.scene
cscene = scene.cycles
layout.prop(cscene, "use_adaptive_sampling", text="")
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
scene = context.scene
cscene = scene.cycles
layout.active = cscene.use_adaptive_sampling
col = layout.column(align=True)
col.prop(cscene, "adaptive_min_samples", text="Min Samples")
col.prop(cscene, "adaptive_threshold", text="Noise Threshold")
class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
bl_label = "Advanced"
bl_parent_id = "CYCLES_RENDER_PT_sampling"
@@ -247,7 +273,9 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
row.prop(cscene, "seed")
row.prop(cscene, "use_animated_seed", text="", icon='TIME')
layout.prop(cscene, "sampling_pattern", text="Pattern")
col = layout.column(align=True)
col.active = not(cscene.use_adaptive_sampling)
col.prop(cscene, "sampling_pattern", text="Pattern")
layout.prop(cscene, "use_square_samples")
@@ -742,6 +770,8 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_solid", text="Surfaces")
col = flow.column()
col.prop(view_layer, "use_strand", text="Hair")
col = flow.column()
col.prop(view_layer, "use_volumes", text="Volumes")
if with_freestyle:
col = flow.column()
col.prop(view_layer, "use_freestyle", text="Freestyle")
@@ -813,6 +843,8 @@ class CYCLES_RENDER_PT_passes_data(CyclesButtonsPanel, Panel):
col.prop(cycles_view_layer, "denoising_store_passes", text="Denoising Data")
col = flow.column()
col.prop(cycles_view_layer, "pass_debug_render_time", text="Render Time")
col = flow.column()
col.prop(cycles_view_layer, "pass_debug_sample_count", text="Sample Count")
layout.separator()
@@ -1383,8 +1415,6 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel):
light = context.light
clamp = light.cycles
layout.use_property_decorate = False
if self.bl_space_type == 'PROPERTIES':
layout.row().prop(light, "type", expand=True)
layout.use_property_split = True
@@ -2238,6 +2268,7 @@ classes = (
CYCLES_PT_integrator_presets,
CYCLES_RENDER_PT_sampling,
CYCLES_RENDER_PT_sampling_sub_samples,
CYCLES_RENDER_PT_sampling_adaptive,
CYCLES_RENDER_PT_sampling_advanced,
CYCLES_RENDER_PT_light_paths,
CYCLES_RENDER_PT_light_paths_max_bounces,

View File

@@ -17,6 +17,8 @@
#include "blender/blender_device.h"
#include "blender/blender_util.h"
#include "util/util_foreach.h"
CCL_NAMESPACE_BEGIN
enum DenoiserType {

View File

@@ -23,6 +23,8 @@
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
#include "util/util_foreach.h"
CCL_NAMESPACE_BEGIN
Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,

View File

@@ -14,206 +14,71 @@
* limitations under the License.
*/
#include "render/image.h"
#include "MEM_guardedalloc.h"
#include "blender/blender_sync.h"
#include "blender/blender_image.h"
#include "blender/blender_session.h"
#include "blender/blender_util.h"
CCL_NAMESPACE_BEGIN
/* builtin image file name is actually an image datablock name with
* absolute sequence frame number concatenated via '@' character
*
* this function splits frame from builtin name
*/
int BlenderSession::builtin_image_frame(const string &builtin_name)
/* Packed Images */
BlenderImageLoader::BlenderImageLoader(BL::Image b_image, int frame)
: b_image(b_image), frame(frame), free_cache(!b_image.has_data())
{
int last = builtin_name.find_last_of('@');
return atoi(builtin_name.substr(last + 1, builtin_name.size() - last - 1).c_str());
}
void BlenderSession::builtin_image_info(const string &builtin_name,
void *builtin_data,
ImageMetaData &metadata)
bool BlenderImageLoader::load_metadata(ImageMetaData &metadata)
{
/* empty image */
metadata.width = 1;
metadata.height = 1;
metadata.width = b_image.size()[0];
metadata.height = b_image.size()[1];
metadata.depth = 1;
metadata.channels = b_image.channels();
if (!builtin_data)
return;
/* recover ID pointer */
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::ID b_id(ptr);
if (b_id.is_a(&RNA_Image)) {
/* image data */
BL::Image b_image(b_id);
metadata.builtin_free_cache = !b_image.has_data();
metadata.is_float = b_image.is_float();
metadata.width = b_image.size()[0];
metadata.height = b_image.size()[1];
metadata.depth = 1;
metadata.channels = b_image.channels();
if (metadata.is_float) {
/* Float images are already converted on the Blender side,
* no need to do anything in Cycles. */
metadata.colorspace = u_colorspace_raw;
if (b_image.is_float()) {
if (metadata.channels == 1) {
metadata.type = IMAGE_DATA_TYPE_FLOAT;
}
}
else if (b_id.is_a(&RNA_Object)) {
/* smoke volume data */
BL::Object b_ob(b_id);
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
metadata.is_float = true;
metadata.depth = 1;
metadata.channels = 1;
if (!b_domain)
return;
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE))
metadata.channels = 1;
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR))
metadata.channels = 4;
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY))
metadata.channels = 3;
else
return;
int3 resolution = get_int3(b_domain.domain_resolution());
int amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
amplify = 1;
}
metadata.width = resolution.x * amplify;
metadata.height = resolution.y * amplify;
metadata.depth = resolution.z * amplify;
}
else {
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
metadata.channels = 4;
metadata.width = b_point_density_node.resolution();
metadata.height = metadata.width;
metadata.depth = metadata.width;
metadata.is_float = true;
}
}
}
bool BlenderSession::builtin_image_pixels(const string &builtin_name,
void *builtin_data,
int tile,
unsigned char *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache)
{
if (!builtin_data) {
return false;
}
const int frame = builtin_image_frame(builtin_name);
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::Image b_image(ptr);
const int width = b_image.size()[0];
const int height = b_image.size()[1];
const int channels = b_image.channels();
unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile);
const size_t num_pixels = ((size_t)width) * height;
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
}
else {
if (channels == 1) {
memset(pixels, 0, pixels_size * sizeof(unsigned char));
else if (metadata.channels == 4) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
}
else {
const size_t num_pixels_safe = pixels_size / channels;
unsigned char *cp = pixels;
for (size_t i = 0; i < num_pixels_safe; i++, cp += channels) {
cp[0] = 255;
cp[1] = 0;
cp[2] = 255;
if (channels == 4) {
cp[3] = 255;
}
}
return false;
}
/* Float images are already converted on the Blender side,
* no need to do anything in Cycles. */
metadata.colorspace = u_colorspace_raw;
}
else {
if (metadata.channels == 1) {
metadata.type = IMAGE_DATA_TYPE_BYTE;
}
else if (metadata.channels == 4) {
metadata.type = IMAGE_DATA_TYPE_BYTE4;
}
else {
return false;
}
}
if (image_pixels) {
MEM_freeN(image_pixels);
}
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
if (associate_alpha) {
/* Premultiply, byte images are always straight for Blender. */
unsigned char *cp = pixels;
for (size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = (cp[0] * cp[3]) >> 8;
cp[1] = (cp[1] * cp[3]) >> 8;
cp[2] = (cp[2] * cp[3]) >> 8;
}
}
return true;
}
bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
int tile,
float *pixels,
const size_t pixels_size,
const bool,
const bool free_cache)
bool BlenderImageLoader::load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha)
{
if (!builtin_data) {
return false;
}
const size_t num_pixels = ((size_t)metadata.width) * metadata.height;
const int channels = metadata.channels;
const int tile = 0; /* TODO(lukas): Support tiles here? */
PointerRNA ptr;
RNA_id_pointer_create((ID *)builtin_data, &ptr);
BL::ID b_id(ptr);
if (b_id.is_a(&RNA_Image)) {
if (b_image.is_float()) {
/* image data */
BL::Image b_image(b_id);
int frame = builtin_image_frame(builtin_name);
const int width = b_image.size()[0];
const int height = b_image.size()[1];
const int channels = b_image.channels();
float *image_pixels;
image_pixels = image_get_float_pixels_for_frame(b_image, frame, tile);
const size_t num_pixels = ((size_t)width) * height;
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(float));
@@ -224,7 +89,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
}
else {
const size_t num_pixels_safe = pixels_size / channels;
float *fp = pixels;
float *fp = (float *)pixels;
for (int i = 0; i < num_pixels_safe; i++, fp += channels) {
fp[0] = 1.0f;
fp[1] = 0.0f;
@@ -239,107 +104,91 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
if (image_pixels) {
MEM_freeN(image_pixels);
}
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
return true;
}
else if (b_id.is_a(&RNA_Object)) {
/* smoke volume data */
BL::Object b_ob(b_id);
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
#ifdef WITH_FLUID
int3 resolution = get_int3(b_domain.domain_resolution());
int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
amplify = 1;
}
const int width = resolution.x * amplify;
const int height = resolution.y * amplify;
const int depth = resolution.z * amplify;
const size_t num_pixels = ((size_t)width) * height * depth;
if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
FluidDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_density_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) {
/* this is in range 0..1, and interpreted by the OpenGL smoke viewer
* as 1500..3000 K with the first part faded to zero density */
FluidDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_flame_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) {
/* the RGB is "premultiplied" by density for better interpolation results */
FluidDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 4) {
FluidDomainSettings_color_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
FluidDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 3) {
FluidDomainSettings_velocity_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) {
FluidDomainSettings_heat_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_heat_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) {
FluidDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_temperature_grid_get(&b_domain.ptr, pixels);
return true;
}
}
else {
fprintf(
stderr, "Cycles error: unknown volume attribute %s, skipping\n", builtin_name.c_str());
pixels[0] = 0.0f;
return false;
}
#endif
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
}
else {
/* We originally were passing view_layer here but in reality we need a
* a depsgraph to pass to the RE_point_density_minmax() function.
*/
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
int length;
b_point_density_node.calc_point_density(b_depsgraph, &length, &pixels);
unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile);
if (image_pixels && num_pixels * channels == pixels_size) {
memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
}
else {
if (channels == 1) {
memset(pixels, 0, pixels_size * sizeof(unsigned char));
}
else {
const size_t num_pixels_safe = pixels_size / channels;
unsigned char *cp = (unsigned char *)pixels;
for (size_t i = 0; i < num_pixels_safe; i++, cp += channels) {
cp[0] = 255;
cp[1] = 0;
cp[2] = 255;
if (channels == 4) {
cp[3] = 255;
}
}
}
}
if (image_pixels) {
MEM_freeN(image_pixels);
}
if (associate_alpha) {
/* Premultiply, byte images are always straight for Blender. */
unsigned char *cp = (unsigned char *)pixels;
for (size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = (cp[0] * cp[3]) >> 8;
cp[1] = (cp[1] * cp[3]) >> 8;
cp[2] = (cp[2] * cp[3]) >> 8;
}
}
}
return false;
/* Free image buffers to save memory during render. */
if (free_cache) {
b_image.buffers_free();
}
return true;
}
string BlenderImageLoader::name() const
{
return BL::Image(b_image).name();
}
bool BlenderImageLoader::equals(const ImageLoader &other) const
{
const BlenderImageLoader &other_loader = (const BlenderImageLoader &)other;
return b_image == other_loader.b_image && frame == other_loader.frame;
}
/* Point Density */
BlenderPointDensityLoader::BlenderPointDensityLoader(BL::Depsgraph b_depsgraph,
BL::ShaderNodeTexPointDensity b_node)
: b_depsgraph(b_depsgraph), b_node(b_node)
{
}
bool BlenderPointDensityLoader::load_metadata(ImageMetaData &metadata)
{
metadata.channels = 4;
metadata.width = b_node.resolution();
metadata.height = metadata.width;
metadata.depth = metadata.width;
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
return true;
}
bool BlenderPointDensityLoader::load_pixels(const ImageMetaData &,
void *pixels,
const size_t,
const bool)
{
int length;
b_node.calc_point_density(b_depsgraph, &length, (float **)&pixels);
return true;
}
void BlenderSession::builtin_images_load()
@@ -357,4 +206,15 @@ void BlenderSession::builtin_images_load()
manager->device_load_builtin(device, session->scene, session->progress);
}
string BlenderPointDensityLoader::name() const
{
return BL::ShaderNodeTexPointDensity(b_node).name();
}
bool BlenderPointDensityLoader::equals(const ImageLoader &other) const
{
const BlenderPointDensityLoader &other_loader = (const BlenderPointDensityLoader &)other;
return b_node == other_loader.b_node && b_depsgraph == other_loader.b_depsgraph;
}
CCL_NAMESPACE_END

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2011-2020 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BLENDER_IMAGE_H__
#define __BLENDER_IMAGE_H__
#include "RNA_blender_cpp.h"
#include "render/image.h"
CCL_NAMESPACE_BEGIN
class BlenderImageLoader : public ImageLoader {
public:
BlenderImageLoader(BL::Image b_image, int frame);
bool load_metadata(ImageMetaData &metadata) override;
bool load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha) override;
string name() const override;
bool equals(const ImageLoader &other) const override;
BL::Image b_image;
int frame;
bool free_cache;
};
class BlenderPointDensityLoader : public ImageLoader {
public:
BlenderPointDensityLoader(BL::Depsgraph depsgraph, BL::ShaderNodeTexPointDensity b_node);
bool load_metadata(ImageMetaData &metadata) override;
bool load_pixels(const ImageMetaData &metadata,
void *pixels,
const size_t pixels_size,
const bool associate_alpha) override;
string name() const override;
bool equals(const ImageLoader &other) const override;
BL::Depsgraph b_depsgraph;
BL::ShaderNodeTexPointDensity b_node;
};
CCL_NAMESPACE_END
#endif /* __BLENDER_IMAGE_H__ */

View File

@@ -138,14 +138,6 @@ void BlenderSession::create_session()
scene = new Scene(scene_params, session->device);
scene->name = b_scene.name();
/* setup callbacks for builtin image support */
scene->image_manager->builtin_image_info_cb = function_bind(
&BlenderSession::builtin_image_info, this, _1, _2, _3);
scene->image_manager->builtin_image_pixels_cb = function_bind(
&BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5, _6, _7);
scene->image_manager->builtin_image_float_pixels_cb = function_bind(
&BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5, _6, _7);
session->scene = scene;
/* There is no single depsgraph to use for the entire render.
@@ -470,7 +462,8 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
b_rlay_name = b_view_layer.name();
/* add passes */
vector<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer);
vector<Pass> passes = sync->sync_render_passes(
b_rlay, b_view_layer, session_params.adaptive_sampling);
buffer_params.passes = passes;
PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");

View File

@@ -17,15 +17,19 @@
#ifndef __BLENDER_SESSION_H__
#define __BLENDER_SESSION_H__
#include "RNA_blender_cpp.h"
#include "device/device.h"
#include "render/bake.h"
#include "render/scene.h"
#include "render/session.h"
#include "render/bake.h"
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
class BlenderSync;
class ImageMetaData;
class Scene;
class Session;
@@ -153,22 +157,6 @@ class BlenderSession {
bool do_update_only);
void do_write_update_render_tile(RenderTile &rtile, bool do_update_only, bool highlight);
int builtin_image_frame(const string &builtin_name);
void builtin_image_info(const string &builtin_name, void *builtin_data, ImageMetaData &metadata);
bool builtin_image_pixels(const string &builtin_name,
void *builtin_data,
int tile,
unsigned char *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache);
bool builtin_image_float_pixels(const string &builtin_name,
void *builtin_data,
int tile,
float *pixels,
const size_t pixels_size,
const bool associate_alpha,
const bool free_cache);
void builtin_images_load();
/* Update tile manager to reflect resumable render settings. */

View File

@@ -23,6 +23,7 @@
#include "render/scene.h"
#include "render/shader.h"
#include "blender/blender_image.h"
#include "blender/blender_texture.h"
#include "blender/blender_sync.h"
#include "blender/blender_util.h"
@@ -327,6 +328,7 @@ static ShaderNode *add_node(Scene *scene,
BL::ShaderNodeVectorRotate b_vector_rotate_node(b_node);
VectorRotateNode *vector_rotate_node = new VectorRotateNode();
vector_rotate_node->type = (NodeVectorRotateType)b_vector_rotate_node.rotation_type();
vector_rotate_node->invert = b_vector_rotate_node.invert();
node = vector_rotate_node;
}
else if (b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
@@ -618,16 +620,16 @@ static ShaderNode *add_node(Scene *scene,
/* create script node */
BL::ShaderNodeScript b_script_node(b_node);
OSLShaderManager *manager = (OSLShaderManager *)scene->shader_manager;
ShaderManager *manager = scene->shader_manager;
string bytecode_hash = b_script_node.bytecode_hash();
if (!bytecode_hash.empty()) {
node = manager->osl_node("", bytecode_hash, b_script_node.bytecode());
node = OSLShaderManager::osl_node(manager, "", bytecode_hash, b_script_node.bytecode());
}
else {
string absolute_filepath = blender_absolute_path(
b_data, b_ntree, b_script_node.filepath());
node = manager->osl_node(absolute_filepath, "");
node = OSLShaderManager::osl_node(manager, absolute_filepath, "");
}
}
#else
@@ -649,6 +651,18 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(&image->tex_mapping, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
image->colorspace = get_enum_identifier(colorspace_ptr, "name");
image->animated = b_image_node.image_user().use_auto_refresh();
image->alpha_type = get_image_alpha_type(b_image);
image->tiles.clear();
BL::Image::tiles_iterator b_iter;
for (b_image.tiles.begin(b_iter); b_iter != b_image.tiles.end(); ++b_iter) {
image->tiles.push_back(b_iter->number());
}
/* builtin images will use callback-based reading because
* they could only be loaded correct from blender side
*/
@@ -665,34 +679,13 @@ static ShaderNode *add_node(Scene *scene,
*/
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, scene_frame);
image->filename = b_image.name() + "@" + string_printf("%d", image_frame);
image->builtin_data = b_image.ptr.data;
image->handle = scene->image_manager->add_image(
new BlenderImageLoader(b_image, image_frame), image->image_params());
}
else {
image->filename = image_user_file_path(
b_image_user, b_image, b_scene.frame_current(), true);
image->builtin_data = NULL;
}
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
image->colorspace = get_enum_identifier(colorspace_ptr, "name");
image->animated = b_image_node.image_user().use_auto_refresh();
image->alpha_type = get_image_alpha_type(b_image);
image->tiles.clear();
BL::Image::tiles_iterator b_iter;
for (b_image.tiles.begin(b_iter); b_iter != b_image.tiles.end(); ++b_iter) {
image->tiles.push_back(b_iter->number());
}
/* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
#if 0
if (b_image.is_updated()) {
scene->image_manager->tag_reload_image(image->image_key());
}
#endif
}
node = image;
}
@@ -708,6 +701,12 @@ static ShaderNode *add_node(Scene *scene,
get_tex_mapping(&env->tex_mapping, b_texture_mapping);
if (b_image) {
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
env->colorspace = get_enum_identifier(colorspace_ptr, "name");
env->animated = b_env_node.image_user().use_auto_refresh();
env->alpha_type = get_image_alpha_type(b_image);
bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED ||
b_image.source() == BL::Image::source_MOVIE ||
(b_engine.is_preview() && b_image.source() != BL::Image::source_SEQUENCE);
@@ -715,28 +714,13 @@ static ShaderNode *add_node(Scene *scene,
if (is_builtin) {
int scene_frame = b_scene.frame_current();
int image_frame = image_user_frame_number(b_image_user, scene_frame);
env->filename = b_image.name() + "@" + string_printf("%d", image_frame);
env->builtin_data = b_image.ptr.data;
env->handle = scene->image_manager->add_image(new BlenderImageLoader(b_image, image_frame),
env->image_params());
}
else {
env->filename = image_user_file_path(
b_image_user, b_image, b_scene.frame_current(), false);
env->builtin_data = NULL;
}
PointerRNA colorspace_ptr = b_image.colorspace_settings().ptr;
env->colorspace = get_enum_identifier(colorspace_ptr, "name");
env->animated = b_env_node.image_user().use_auto_refresh();
env->alpha_type = get_image_alpha_type(b_image);
/* TODO: restore */
/* TODO(sergey): Does not work properly when we change builtin type. */
#if 0
if (b_image.is_updated()) {
scene->image_manager->tag_reload_image(env->image_key());
}
#endif
}
node = env;
}
@@ -880,18 +864,13 @@ static ShaderNode *add_node(Scene *scene,
else if (b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
PointDensityTextureNode *point_density = new PointDensityTextureNode();
point_density->filename = b_point_density_node.name();
point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
point_density->interpolation = get_image_interpolation(b_point_density_node);
point_density->builtin_data = b_point_density_node.ptr.data;
point_density->image_manager = scene->image_manager;
point_density->handle = scene->image_manager->add_image(
new BlenderPointDensityLoader(b_depsgraph, b_point_density_node),
point_density->image_params());
/* TODO(sergey): Use more proper update flag. */
if (true) {
point_density->add_image();
b_point_density_node.cache_point_density(b_depsgraph);
scene->image_manager->tag_reload_image(point_density->image_key());
}
b_point_density_node.cache_point_density(b_depsgraph);
node = point_density;
/* Transformation form world space to texture space.

View File

@@ -296,6 +296,16 @@ void BlenderSync::sync_integrator()
integrator->sample_all_lights_indirect = get_boolean(cscene, "sample_all_lights_indirect");
integrator->light_sampling_threshold = get_float(cscene, "light_sampling_threshold");
if (RNA_boolean_get(&cscene, "use_adaptive_sampling")) {
integrator->sampling_pattern = SAMPLING_PATTERN_PMJ;
integrator->adaptive_min_samples = get_int(cscene, "adaptive_min_samples");
integrator->adaptive_threshold = get_float(cscene, "adaptive_threshold");
}
else {
integrator->adaptive_min_samples = INT_MAX;
integrator->adaptive_threshold = 0.0f;
}
int diffuse_samples = get_int(cscene, "diffuse_samples");
int glossy_samples = get_int(cscene, "glossy_samples");
int transmission_samples = get_int(cscene, "transmission_samples");
@@ -312,6 +322,8 @@ void BlenderSync::sync_integrator()
integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples;
integrator->subsurface_samples = subsurface_samples * subsurface_samples;
integrator->volume_samples = volume_samples * volume_samples;
integrator->adaptive_min_samples = min(
integrator->adaptive_min_samples * integrator->adaptive_min_samples, INT_MAX);
}
else {
integrator->diffuse_samples = diffuse_samples;
@@ -393,6 +405,7 @@ void BlenderSync::sync_view_layer(BL::SpaceView3D & /*b_v3d*/, BL::ViewLayer &b_
view_layer.use_background_ao = b_view_layer.use_ao();
view_layer.use_surfaces = b_view_layer.use_solid();
view_layer.use_hair = b_view_layer.use_strand();
view_layer.use_volumes = b_view_layer.use_volumes();
/* Material override. */
view_layer.material_override = b_view_layer.material_override();
@@ -484,6 +497,8 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass)
MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES);
#endif
MAP_PASS("Debug Render Time", PASS_RENDER_TIME);
MAP_PASS("AdaptiveAuxBuffer", PASS_ADAPTIVE_AUX_BUFFER);
MAP_PASS("Debug Sample Count", PASS_SAMPLE_COUNT);
if (string_startswith(name, cryptomatte_prefix)) {
return PASS_CRYPTOMATTE;
}
@@ -519,7 +534,9 @@ int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass)
return -1;
}
vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_view_layer)
vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
BL::ViewLayer &b_view_layer,
bool adaptive_sampling)
{
vector<Pass> passes;
@@ -595,6 +612,10 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa
b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time");
}
if (get_boolean(crp, "pass_debug_sample_count")) {
b_engine.add_pass("Debug Sample Count", 1, "X", b_view_layer.name().c_str());
Pass::add(PASS_SAMPLE_COUNT, passes, "Debug Sample Count");
}
if (get_boolean(crp, "use_pass_volume_direct")) {
b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str());
Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir");
@@ -641,6 +662,13 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLa
CRYPT_ACCURATE);
}
if (adaptive_sampling) {
Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes);
if (!get_boolean(crp, "pass_debug_sample_count")) {
Pass::add(PASS_SAMPLE_COUNT, passes);
}
}
RNA_BEGIN (&crp, b_aov, "aovs") {
bool is_color = (get_enum(b_aov, "type") == 1);
string name = get_string(b_aov, "name");
@@ -880,6 +908,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
params.use_profiling = params.device.has_profiling && !b_engine.is_preview() && background &&
BlenderSession::print_render_stats;
params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
return params;
}

View File

@@ -71,7 +71,9 @@ class BlenderSync {
int height,
void **python_thread_state);
void sync_view_layer(BL::SpaceView3D &b_v3d, BL::ViewLayer &b_view_layer);
vector<Pass> sync_render_passes(BL::RenderLayer &b_render_layer, BL::ViewLayer &b_view_layer);
vector<Pass> sync_render_passes(BL::RenderLayer &b_render_layer,
BL::ViewLayer &b_view_layer,
bool adaptive_sampling);
void sync_integrator();
void sync_camera(BL::RenderSettings &b_render,
BL::Object &b_override,
@@ -234,6 +236,7 @@ class BlenderSync {
use_background_ao(true),
use_surfaces(true),
use_hair(true),
use_volumes(true),
samples(0),
bound_samples(false)
{
@@ -245,6 +248,7 @@ class BlenderSync {
bool use_background_ao;
bool use_surfaces;
bool use_hair;
bool use_volumes;
int samples;
bool bound_samples;
} view_layer;

View File

@@ -1,4 +1,3 @@
/*
* Copyright 2011-2013 Blender Foundation
*
@@ -24,6 +23,152 @@
CCL_NAMESPACE_BEGIN
/* TODO: verify this is not loading unnecessary attributes. */
class BlenderSmokeLoader : public ImageLoader {
public:
BlenderSmokeLoader(const BL::Object &b_ob, AttributeStandard attribute)
: b_ob(b_ob), attribute(attribute)
{
}
bool load_metadata(ImageMetaData &metadata) override
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
if (attribute == ATTR_STD_VOLUME_DENSITY || attribute == ATTR_STD_VOLUME_FLAME ||
attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) {
metadata.type = IMAGE_DATA_TYPE_FLOAT;
metadata.channels = 1;
}
else if (attribute == ATTR_STD_VOLUME_COLOR) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
metadata.channels = 4;
}
else if (attribute == ATTR_STD_VOLUME_VELOCITY) {
metadata.type = IMAGE_DATA_TYPE_FLOAT4;
metadata.channels = 3;
}
else {
return false;
}
int3 resolution = get_int3(b_domain.domain_resolution());
int amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (attribute == ATTR_STD_VOLUME_VELOCITY || attribute == ATTR_STD_VOLUME_HEAT) {
amplify = 1;
}
metadata.width = resolution.x * amplify;
metadata.height = resolution.y * amplify;
metadata.depth = resolution.z * amplify;
return true;
}
bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override
{
/* smoke volume data */
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
if (!b_domain) {
return false;
}
#ifdef WITH_FLUID
int3 resolution = get_int3(b_domain.domain_resolution());
int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if (attribute == ATTR_STD_VOLUME_VELOCITY || attribute == ATTR_STD_VOLUME_HEAT) {
amplify = 1;
}
const int width = resolution.x * amplify;
const int height = resolution.y * amplify;
const int depth = resolution.z * amplify;
const size_t num_pixels = ((size_t)width) * height * depth;
float *fpixels = (float *)pixels;
if (attribute == ATTR_STD_VOLUME_DENSITY) {
FluidDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_density_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_FLAME) {
/* this is in range 0..1, and interpreted by the OpenGL smoke viewer
* as 1500..3000 K with the first part faded to zero density */
FluidDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_flame_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_COLOR) {
/* the RGB is "premultiplied" by density for better interpolation results */
FluidDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 4) {
FluidDomainSettings_color_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_VELOCITY) {
FluidDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels * 3) {
FluidDomainSettings_velocity_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_HEAT) {
FluidDomainSettings_heat_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_heat_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else if (attribute == ATTR_STD_VOLUME_TEMPERATURE) {
FluidDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length);
if (length == num_pixels) {
FluidDomainSettings_temperature_grid_get(&b_domain.ptr, fpixels);
return true;
}
}
else {
fprintf(stderr,
"Cycles error: unknown volume attribute %s, skipping\n",
Attribute::standard_name(attribute));
fpixels[0] = 0.0f;
return false;
}
#else
(void)pixels;
#endif
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
return false;
}
string name() const override
{
return Attribute::standard_name(attribute);
}
bool equals(const ImageLoader &other) const override
{
const BlenderSmokeLoader &other_loader = (const BlenderSmokeLoader &)other;
return b_ob == other_loader.b_ob && attribute == other_loader.attribute;
}
BL::Object b_ob;
AttributeStandard attribute;
};
static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float frame)
{
BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob);
@@ -31,7 +176,6 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
return;
}
ImageManager *image_manager = scene->image_manager;
AttributeStandard attributes[] = {ATTR_STD_VOLUME_DENSITY,
ATTR_STD_VOLUME_COLOR,
ATTR_STD_VOLUME_FLAME,
@@ -49,15 +193,12 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
mesh->volume_isovalue = b_domain.clipping();
Attribute *attr = mesh->attributes.add(std);
VoxelAttribute *volume_data = attr->data_voxel();
ImageMetaData metadata;
ImageKey key;
key.filename = Attribute::standard_name(std);
key.builtin_data = b_ob.ptr.data;
ImageLoader *loader = new BlenderSmokeLoader(b_ob, std);
ImageParams params;
params.frame = frame;
volume_data->manager = image_manager;
volume_data->slot = image_manager->add_image(key, frame, metadata);
attr->data_voxel() = scene->image_manager->add_image(loader, params);
}
/* Create a matrix to transform from object space to mesh texture space.
@@ -75,18 +216,33 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float
}
}
/* If the voxel attributes change, we need to rebuild the bounding mesh. */
static vector<int> get_voxel_image_slots(Mesh *mesh)
{
vector<int> slots;
for (const Attribute &attr : mesh->attributes.attributes) {
if (attr.element == ATTR_ELEMENT_VOXEL) {
slots.push_back(attr.data_voxel().svm_slot());
}
}
return slots;
}
void BlenderSync::sync_volume(BL::Object &b_ob, Mesh *mesh, const vector<Shader *> &used_shaders)
{
bool old_has_voxel_attributes = mesh->has_voxel_attributes();
vector<int> old_voxel_slots = get_voxel_image_slots(mesh);
mesh->clear();
mesh->used_shaders = used_shaders;
/* Smoke domain. */
sync_smoke_volume(scene, b_ob, mesh, b_scene.frame_current());
if (view_layer.use_volumes) {
sync_smoke_volume(scene, b_ob, mesh, b_scene.frame_current());
}
/* Tag update. */
bool rebuild = (old_has_voxel_attributes != mesh->has_voxel_attributes());
bool rebuild = (old_voxel_slots != get_voxel_image_slots(mesh));
mesh->tag_update(scene, rebuild);
}

View File

@@ -535,8 +535,9 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
/* Modify offsets into arrays */
int4 data = bvh_nodes[i + nsize_bbox];
int4 data1 = bvh_nodes[i + nsize_bbox - 1];
if (use_obvh) {
int4 data1 = bvh_nodes[i + nsize_bbox - 1];
data.z += (data.z < 0) ? -noffset_leaf : noffset;
data.w += (data.w < 0) ? -noffset_leaf : noffset;
data.x += (data.x < 0) ? -noffset_leaf : noffset;
@@ -545,6 +546,8 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
data1.w += (data1.w < 0) ? -noffset_leaf : noffset;
data1.x += (data1.x < 0) ? -noffset_leaf : noffset;
data1.y += (data1.y < 0) ? -noffset_leaf : noffset;
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1;
}
else {
data.z += (data.z < 0) ? -noffset_leaf : noffset;
@@ -553,10 +556,7 @@ void BVH::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
data.x += (data.x < 0) ? -noffset_leaf : noffset;
data.y += (data.y < 0) ? -noffset_leaf : noffset;
}
}
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
if (use_obvh) {
pack_nodes[pack_nodes_offset + nsize_bbox - 1] = data1;
pack_nodes[pack_nodes_offset + nsize_bbox] = data;
}
/* Usually this copies nothing, but we better

View File

@@ -22,6 +22,7 @@
# include "render/geometry.h"
# include "render/mesh.h"
# include "render/object.h"
# include "util/util_foreach.h"
# include "util/util_logging.h"
# include "util/util_progress.h"

View File

@@ -82,6 +82,17 @@ class CUDADevice : public Device {
device_vector<TextureInfo> texture_info;
bool need_texture_info;
/* Kernels */
struct {
bool loaded;
CUfunction adaptive_stopping;
CUfunction adaptive_filter_x;
CUfunction adaptive_filter_y;
CUfunction adaptive_scale_samples;
int adaptive_num_threads_per_block;
} functions;
static bool have_precompiled_kernels();
virtual bool show_samples() const;
@@ -114,6 +125,8 @@ class CUDADevice : public Device {
virtual bool load_kernels(const DeviceRequestedFeatures &requested_features);
void load_functions();
void reserve_local_memory(const DeviceRequestedFeatures &requested_features);
void init_host_memory();
@@ -142,9 +155,13 @@ class CUDADevice : public Device {
virtual void const_copy_to(const char *name, void *host, size_t size);
void tex_alloc(device_memory &mem);
void global_alloc(device_memory &mem);
void tex_free(device_memory &mem);
void global_free(device_memory &mem);
void tex_alloc(device_texture &mem);
void tex_free(device_texture &mem);
bool denoising_non_local_means(device_ptr image_ptr,
device_ptr guide_ptr,
@@ -197,6 +214,15 @@ class CUDADevice : public Device {
void denoise(RenderTile &rtile, DenoisingTask &denoising);
void adaptive_sampling_filter(uint filter_sample,
WorkTile *wtile,
CUdeviceptr d_wtile,
CUstream stream = 0);
void adaptive_sampling_post(RenderTile &rtile,
WorkTile *wtile,
CUdeviceptr d_wtile,
CUstream stream = 0);
void path_trace(DeviceTask &task, RenderTile &rtile, device_vector<WorkTile> &work_tiles);
void film_convert(DeviceTask &task,

View File

@@ -185,7 +185,7 @@ void CUDADevice::cuda_error_message(const string &message)
}
CUDADevice::CUDADevice(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background_)
: Device(info, stats, profiler, background_), texture_info(this, "__texture_info", MEM_TEXTURE)
: Device(info, stats, profiler, background_), texture_info(this, "__texture_info", MEM_GLOBAL)
{
first_error = true;
background = background_;
@@ -208,6 +208,8 @@ CUDADevice::CUDADevice(DeviceInfo &info, Stats &stats, Profiler &profiler, bool
map_host_used = 0;
can_map_host = 0;
functions.loaded = false;
/* Intialize CUDA. */
if (cuda_error(cuInit(0)))
return;
@@ -531,9 +533,42 @@ bool CUDADevice::load_kernels(const DeviceRequestedFeatures &requested_features)
reserve_local_memory(requested_features);
}
load_functions();
return (result == CUDA_SUCCESS);
}
void CUDADevice::load_functions()
{
/* TODO: load all functions here. */
if (functions.loaded) {
return;
}
functions.loaded = true;
cuda_assert(cuModuleGetFunction(
&functions.adaptive_stopping, cuModule, "kernel_cuda_adaptive_stopping"));
cuda_assert(cuModuleGetFunction(
&functions.adaptive_filter_x, cuModule, "kernel_cuda_adaptive_filter_x"));
cuda_assert(cuModuleGetFunction(
&functions.adaptive_filter_y, cuModule, "kernel_cuda_adaptive_filter_y"));
cuda_assert(cuModuleGetFunction(
&functions.adaptive_scale_samples, cuModule, "kernel_cuda_adaptive_scale_samples"));
cuda_assert(cuFuncSetCacheConfig(functions.adaptive_stopping, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuFuncSetCacheConfig(functions.adaptive_filter_x, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuFuncSetCacheConfig(functions.adaptive_filter_y, CU_FUNC_CACHE_PREFER_L1));
cuda_assert(cuFuncSetCacheConfig(functions.adaptive_scale_samples, CU_FUNC_CACHE_PREFER_L1));
int unused_min_blocks;
cuda_assert(cuOccupancyMaxPotentialBlockSize(&unused_min_blocks,
&functions.adaptive_num_threads_per_block,
functions.adaptive_scale_samples,
NULL,
0,
0));
}
void CUDADevice::reserve_local_memory(const DeviceRequestedFeatures &requested_features)
{
if (use_split_kernel()) {
@@ -649,7 +684,8 @@ void CUDADevice::move_textures_to_host(size_t size, bool for_texture)
device_memory &mem = *pair.first;
CUDAMem *cmem = &pair.second;
bool is_texture = (mem.type == MEM_TEXTURE) && (&mem != &texture_info);
bool is_texture = (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) &&
(&mem != &texture_info);
bool is_image = is_texture && (mem.data_height > 1);
/* Can't move this type of memory. */
@@ -689,8 +725,7 @@ void CUDADevice::move_textures_to_host(size_t size, bool for_texture)
device_ptr prev_pointer = max_mem->device_pointer;
size_t prev_size = max_mem->device_size;
tex_free(*max_mem);
tex_alloc(*max_mem);
mem_copy_to(*max_mem);
size = (max_size >= size) ? 0 : size - max_size;
max_mem->device_pointer = prev_pointer;
@@ -724,7 +759,7 @@ CUDADevice::CUDAMem *CUDADevice::generic_alloc(device_memory &mem, size_t pitch_
* If there is not enough room for working memory, we will try to move
* textures to host memory, assuming the performance impact would have
* been worse for working memory. */
bool is_texture = (mem.type == MEM_TEXTURE) && (&mem != &texture_info);
bool is_texture = (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) && (&mem != &texture_info);
bool is_image = is_texture && (mem.data_height > 1);
size_t headroom = (is_texture) ? device_texture_headroom : device_working_headroom;
@@ -887,6 +922,9 @@ void CUDADevice::mem_alloc(device_memory &mem)
else if (mem.type == MEM_TEXTURE) {
assert(!"mem_alloc not supported for textures.");
}
else if (mem.type == MEM_GLOBAL) {
assert(!"mem_alloc not supported for global memory.");
}
else {
generic_alloc(mem);
}
@@ -897,9 +935,13 @@ void CUDADevice::mem_copy_to(device_memory &mem)
if (mem.type == MEM_PIXELS) {
assert(!"mem_copy_to not supported for pixels.");
}
else if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else {
if (!mem.device_pointer) {
@@ -915,7 +957,7 @@ void CUDADevice::mem_copy_from(device_memory &mem, int y, int w, int h, int elem
if (mem.type == MEM_PIXELS && !background) {
pixels_copy_from(mem, y, w, h);
}
else if (mem.type == MEM_TEXTURE) {
else if (mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL) {
assert(!"mem_copy_from not supported for textures.");
}
else if (mem.host_pointer) {
@@ -958,8 +1000,11 @@ void CUDADevice::mem_free(device_memory &mem)
if (mem.type == MEM_PIXELS && !background) {
pixels_free(mem);
}
else if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_free((device_texture &)mem);
}
else {
generic_free(mem);
@@ -982,7 +1027,25 @@ void CUDADevice::const_copy_to(const char *name, void *host, size_t size)
cuda_assert(cuMemcpyHtoD(mem, host, size));
}
void CUDADevice::tex_alloc(device_memory &mem)
void CUDADevice::global_alloc(device_memory &mem)
{
CUDAContextScope scope(this);
generic_alloc(mem);
generic_copy_to(mem);
const_copy_to(mem.name, &mem.device_pointer, sizeof(mem.device_pointer));
}
void CUDADevice::global_free(device_memory &mem)
{
if (mem.device_pointer) {
CUDAContextScope scope(this);
generic_free(mem);
}
}
void CUDADevice::tex_alloc(device_texture &mem)
{
CUDAContextScope scope(this);
@@ -992,7 +1055,7 @@ void CUDADevice::tex_alloc(device_memory &mem)
size_t size = mem.memory_size();
CUaddress_mode address_mode = CU_TR_ADDRESS_MODE_WRAP;
switch (mem.extension) {
switch (mem.info.extension) {
case EXTENSION_REPEAT:
address_mode = CU_TR_ADDRESS_MODE_WRAP;
break;
@@ -1008,22 +1071,13 @@ void CUDADevice::tex_alloc(device_memory &mem)
}
CUfilter_mode filter_mode;
if (mem.interpolation == INTERPOLATION_CLOSEST) {
if (mem.info.interpolation == INTERPOLATION_CLOSEST) {
filter_mode = CU_TR_FILTER_MODE_POINT;
}
else {
filter_mode = CU_TR_FILTER_MODE_LINEAR;
}
/* Data Storage */
if (mem.interpolation == INTERPOLATION_NONE) {
generic_alloc(mem);
generic_copy_to(mem);
const_copy_to(bind_name.c_str(), &mem.device_pointer, sizeof(mem.device_pointer));
return;
}
/* Image Texture Storage */
CUarray_format_enum format;
switch (mem.data_type) {
@@ -1134,15 +1188,6 @@ void CUDADevice::tex_alloc(device_memory &mem)
}
/* Kepler+, bindless textures. */
int flat_slot = 0;
if (string_startswith(mem.name, "__tex_image")) {
int pos = string(mem.name).rfind("_");
flat_slot = atoi(mem.name + pos + 1);
}
else {
assert(0);
}
CUDA_RESOURCE_DESC resDesc;
memset(&resDesc, 0, sizeof(resDesc));
@@ -1179,25 +1224,20 @@ void CUDADevice::tex_alloc(device_memory &mem)
cuda_assert(cuTexObjectCreate(&cmem->texobject, &resDesc, &texDesc, NULL));
/* Resize once */
if (flat_slot >= texture_info.size()) {
const uint slot = mem.slot;
if (slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount
* of re-allocations. */
texture_info.resize(flat_slot + 128);
texture_info.resize(slot + 128);
}
/* Set Mapping and tag that we need to (re-)upload to device */
TextureInfo &info = texture_info[flat_slot];
info.data = (uint64_t)cmem->texobject;
info.cl_buffer = 0;
info.interpolation = mem.interpolation;
info.extension = mem.extension;
info.width = mem.data_width;
info.height = mem.data_height;
info.depth = mem.data_depth;
texture_info[slot] = mem.info;
texture_info[slot].data = (uint64_t)cmem->texobject;
need_texture_info = true;
}
void CUDADevice::tex_free(device_memory &mem)
void CUDADevice::tex_free(device_texture &mem)
{
if (mem.device_pointer) {
CUDAContextScope scope(this);
@@ -1666,6 +1706,80 @@ void CUDADevice::denoise(RenderTile &rtile, DenoisingTask &denoising)
denoising.run_denoising(&rtile);
}
void CUDADevice::adaptive_sampling_filter(uint filter_sample,
WorkTile *wtile,
CUdeviceptr d_wtile,
CUstream stream)
{
const int num_threads_per_block = functions.adaptive_num_threads_per_block;
/* These are a series of tiny kernels because there is no grid synchronization
* from within a kernel, so multiple kernel launches it is. */
uint total_work_size = wtile->h * wtile->w;
void *args2[] = {&d_wtile, &filter_sample, &total_work_size};
uint num_blocks = divide_up(total_work_size, num_threads_per_block);
cuda_assert(cuLaunchKernel(functions.adaptive_stopping,
num_blocks,
1,
1,
num_threads_per_block,
1,
1,
0,
stream,
args2,
0));
total_work_size = wtile->h;
num_blocks = divide_up(total_work_size, num_threads_per_block);
cuda_assert(cuLaunchKernel(functions.adaptive_filter_x,
num_blocks,
1,
1,
num_threads_per_block,
1,
1,
0,
stream,
args2,
0));
total_work_size = wtile->w;
num_blocks = divide_up(total_work_size, num_threads_per_block);
cuda_assert(cuLaunchKernel(functions.adaptive_filter_y,
num_blocks,
1,
1,
num_threads_per_block,
1,
1,
0,
stream,
args2,
0));
}
void CUDADevice::adaptive_sampling_post(RenderTile &rtile,
WorkTile *wtile,
CUdeviceptr d_wtile,
CUstream stream)
{
const int num_threads_per_block = functions.adaptive_num_threads_per_block;
uint total_work_size = wtile->h * wtile->w;
void *args[] = {&d_wtile, &rtile.start_sample, &rtile.sample, &total_work_size};
uint num_blocks = divide_up(total_work_size, num_threads_per_block);
cuda_assert(cuLaunchKernel(functions.adaptive_scale_samples,
num_blocks,
1,
1,
num_threads_per_block,
1,
1,
0,
stream,
args,
0));
}
void CUDADevice::path_trace(DeviceTask &task,
RenderTile &rtile,
device_vector<WorkTile> &work_tiles)
@@ -1715,6 +1829,9 @@ void CUDADevice::path_trace(DeviceTask &task,
}
uint step_samples = divide_up(min_blocks * num_threads_per_block, wtile->w * wtile->h);
if (task.adaptive_sampling.use) {
step_samples = task.adaptive_sampling.align_static_samples(step_samples);
}
/* Render all samples. */
int start_sample = rtile.start_sample;
@@ -1736,6 +1853,12 @@ void CUDADevice::path_trace(DeviceTask &task,
cuda_assert(
cuLaunchKernel(cuPathTrace, num_blocks, 1, 1, num_threads_per_block, 1, 1, 0, 0, args, 0));
/* Run the adaptive sampling kernels at selected samples aligned to step samples. */
uint filter_sample = sample + wtile->num_samples - 1;
if (task.adaptive_sampling.use && task.adaptive_sampling.need_filter(filter_sample)) {
adaptive_sampling_filter(filter_sample, wtile, d_work_tiles);
}
cuda_assert(cuCtxSynchronize());
/* Update progress. */
@@ -1747,6 +1870,14 @@ void CUDADevice::path_trace(DeviceTask &task,
break;
}
}
/* Finalize adaptive sampling. */
if (task.adaptive_sampling.use) {
CUdeviceptr d_work_tiles = (CUdeviceptr)work_tiles.device_pointer;
adaptive_sampling_post(rtile, wtile, d_work_tiles);
cuda_assert(cuCtxSynchronize());
task.update_progress(&rtile, rtile.w * rtile.h * wtile->num_samples);
}
}
void CUDADevice::film_convert(DeviceTask &task,
@@ -2144,7 +2275,7 @@ void CUDADevice::thread_run(DeviceTask *task)
{
CUDAContextScope scope(this);
if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE) {
if (task->type == DeviceTask::RENDER) {
DeviceRequestedFeatures requested_features;
if (use_split_kernel()) {
if (split_kernel == NULL) {
@@ -2159,7 +2290,7 @@ void CUDADevice::thread_run(DeviceTask *task)
RenderTile tile;
DenoisingTask denoising(this, *task);
while (task->acquire_tile(this, tile)) {
while (task->acquire_tile(this, tile, task->tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
if (use_split_kernel()) {
device_only_memory<uchar> void_buffer(this, "void_buffer");

View File

@@ -29,16 +29,19 @@
#include "device/device_intern.h"
#include "device/device_split_kernel.h"
// clang-format off
#include "kernel/kernel.h"
#include "kernel/kernel_compat_cpu.h"
#include "kernel/kernel_types.h"
#include "kernel/split/kernel_split_data.h"
#include "kernel/kernel_globals.h"
#include "kernel/kernel_adaptive_sampling.h"
#include "kernel/filter/filter.h"
#include "kernel/osl/osl_shader.h"
#include "kernel/osl/osl_globals.h"
// clang-format on
#include "render/buffers.h"
#include "render/coverage.h"
@@ -261,7 +264,7 @@ class CPUDevice : public Device {
CPUDevice(DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool background_)
: Device(info_, stats_, profiler_, background_),
texture_info(this, "__texture_info", MEM_TEXTURE),
texture_info(this, "__texture_info", MEM_GLOBAL),
#define REGISTER_KERNEL(name) name##_kernel(KERNEL_FUNCTIONS(name))
REGISTER_KERNEL(path_trace),
REGISTER_KERNEL(convert_to_half_float),
@@ -317,6 +320,10 @@ class CPUDevice : public Device {
REGISTER_SPLIT_KERNEL(next_iteration_setup);
REGISTER_SPLIT_KERNEL(indirect_subsurface);
REGISTER_SPLIT_KERNEL(buffer_update);
REGISTER_SPLIT_KERNEL(adaptive_stopping);
REGISTER_SPLIT_KERNEL(adaptive_filter_x);
REGISTER_SPLIT_KERNEL(adaptive_filter_y);
REGISTER_SPLIT_KERNEL(adaptive_adjust_samples);
#undef REGISTER_SPLIT_KERNEL
#undef KERNEL_FUNCTIONS
}
@@ -365,6 +372,9 @@ class CPUDevice : public Device {
if (mem.type == MEM_TEXTURE) {
assert(!"mem_alloc not supported for textures.");
}
else if (mem.type == MEM_GLOBAL) {
assert(!"mem_alloc not supported for global memory.");
}
else {
if (mem.name) {
VLOG(1) << "Buffer allocate: " << mem.name << ", "
@@ -389,9 +399,13 @@ class CPUDevice : public Device {
void mem_copy_to(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else if (mem.type == MEM_PIXELS) {
assert(!"mem_copy_to not supported for pixels.");
@@ -423,8 +437,11 @@ class CPUDevice : public Device {
void mem_free(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
}
else if (mem.device_pointer) {
if (mem.type == MEM_DEVICE_ONLY) {
@@ -446,51 +463,50 @@ class CPUDevice : public Device {
kernel_const_copy(&kernel_globals, name, host, size);
}
void tex_alloc(device_memory &mem)
void global_alloc(device_memory &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
VLOG(1) << "Global memory allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
if (mem.interpolation == INTERPOLATION_NONE) {
/* Data texture. */
kernel_tex_copy(&kernel_globals, mem.name, mem.host_pointer, mem.data_size);
}
else {
/* Image Texture. */
int flat_slot = 0;
if (string_startswith(mem.name, "__tex_image")) {
int pos = string(mem.name).rfind("_");
flat_slot = atoi(mem.name + pos + 1);
}
else {
assert(0);
}
if (flat_slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount
* of re-allocations. */
texture_info.resize(flat_slot + 128);
}
TextureInfo &info = texture_info[flat_slot];
info.data = (uint64_t)mem.host_pointer;
info.cl_buffer = 0;
info.interpolation = mem.interpolation;
info.extension = mem.extension;
info.width = mem.data_width;
info.height = mem.data_height;
info.depth = mem.data_depth;
need_texture_info = true;
}
kernel_global_memory_copy(&kernel_globals, mem.name, mem.host_pointer, mem.data_size);
mem.device_pointer = (device_ptr)mem.host_pointer;
mem.device_size = mem.memory_size();
stats.mem_alloc(mem.device_size);
}
void tex_free(device_memory &mem)
void global_free(device_memory &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;
stats.mem_free(mem.device_size);
mem.device_size = 0;
}
}
void tex_alloc(device_texture &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
mem.device_pointer = (device_ptr)mem.host_pointer;
mem.device_size = mem.memory_size();
stats.mem_alloc(mem.device_size);
const uint slot = mem.slot;
if (slot >= texture_info.size()) {
/* Allocate some slots in advance, to reduce amount of re-allocations. */
texture_info.resize(slot + 128);
}
texture_info[slot] = mem.info;
texture_info[slot].data = (uint64_t)mem.host_pointer;
need_texture_info = true;
}
void tex_free(device_texture &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;
@@ -511,7 +527,7 @@ class CPUDevice : public Device {
void thread_run(DeviceTask *task)
{
if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE)
if (task->type == DeviceTask::RENDER)
thread_render(*task);
else if (task->type == DeviceTask::SHADER)
thread_shader(*task);
@@ -823,6 +839,49 @@ class CPUDevice : public Device {
return true;
}
bool adaptive_sampling_filter(KernelGlobals *kg, RenderTile &tile)
{
WorkTile wtile;
wtile.x = tile.x;
wtile.y = tile.y;
wtile.w = tile.w;
wtile.h = tile.h;
wtile.offset = tile.offset;
wtile.stride = tile.stride;
wtile.buffer = (float *)tile.buffer;
bool any = false;
for (int y = tile.y; y < tile.y + tile.h; ++y) {
any |= kernel_do_adaptive_filter_x(kg, y, &wtile);
}
for (int x = tile.x; x < tile.x + tile.w; ++x) {
any |= kernel_do_adaptive_filter_y(kg, x, &wtile);
}
return (!any);
}
void adaptive_sampling_post(const RenderTile &tile, KernelGlobals *kg)
{
float *render_buffer = (float *)tile.buffer;
for (int y = tile.y; y < tile.y + tile.h; y++) {
for (int x = tile.x; x < tile.x + tile.w; x++) {
int index = tile.offset + x + y * tile.stride;
ccl_global float *buffer = render_buffer + index * kernel_data.film.pass_stride;
if (buffer[kernel_data.film.pass_sample_count] < 0.0f) {
buffer[kernel_data.film.pass_sample_count] = -buffer[kernel_data.film.pass_sample_count];
float sample_multiplier = tile.sample / max((float)tile.start_sample + 1.0f,
buffer[kernel_data.film.pass_sample_count]);
if (sample_multiplier != 1.0f) {
kernel_adaptive_post_adjust(kg, buffer, sample_multiplier);
}
}
else {
kernel_adaptive_post_adjust(kg, buffer, tile.sample / (tile.sample - 1.0f));
}
}
}
}
void path_trace(DeviceTask &task, RenderTile &tile, KernelGlobals *kg)
{
const bool use_coverage = kernel_data.film.cryptomatte_passes & CRYPT_ACCURATE;
@@ -855,14 +914,27 @@ class CPUDevice : public Device {
path_trace_kernel()(kg, render_buffer, sample, x, y, tile.offset, tile.stride);
}
}
tile.sample = sample + 1;
if (task.adaptive_sampling.use && task.adaptive_sampling.need_filter(sample)) {
const bool stop = adaptive_sampling_filter(kg, tile);
if (stop) {
const int num_progress_samples = end_sample - sample;
tile.sample = end_sample;
task.update_progress(&tile, tile.w * tile.h * num_progress_samples);
break;
}
}
task.update_progress(&tile, tile.w * tile.h);
}
if (use_coverage) {
coverage.finalize();
}
if (task.adaptive_sampling.use) {
adaptive_sampling_post(tile, kg);
}
}
void denoise(DenoisingTask &denoising, RenderTile &tile)
@@ -927,7 +999,7 @@ class CPUDevice : public Device {
DenoisingTask denoising(this, task);
denoising.profiler = &kg->profiler;
while (task.acquire_tile(this, tile)) {
while (task.acquire_tile(this, tile, task.tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
if (use_split_kernel) {
device_only_memory<uchar> void_buffer(this, "void_buffer");

View File

@@ -17,9 +17,15 @@
#ifndef __DEVICE_INTERN_H__
#define __DEVICE_INTERN_H__
#include "util/util_string.h"
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN
class Device;
class DeviceInfo;
class Profiler;
class Stats;
Device *device_cpu_create(DeviceInfo &info, Stats &stats, Profiler &profiler, bool background);
bool device_opencl_init();

View File

@@ -31,8 +31,6 @@ device_memory::device_memory(Device *device, const char *name, MemoryType type)
data_depth(0),
type(type),
name(name),
interpolation(INTERPOLATION_NONE),
extension(EXTENSION_REPEAT),
device(device),
device_pointer(0),
host_pointer(0),
@@ -76,7 +74,7 @@ void device_memory::host_free()
void device_memory::device_alloc()
{
assert(!device_pointer && type != MEM_TEXTURE);
assert(!device_pointer && type != MEM_TEXTURE && type != MEM_GLOBAL);
device->mem_alloc(*this);
}
@@ -96,7 +94,7 @@ void device_memory::device_copy_to()
void device_memory::device_copy_from(int y, int w, int h, int elem)
{
assert(type != MEM_TEXTURE && type != MEM_READ_ONLY);
assert(type != MEM_TEXTURE && type != MEM_READ_ONLY && type != MEM_GLOBAL);
device->mem_copy_from(*this, y, w, h, elem);
}
@@ -139,4 +137,93 @@ device_sub_ptr::~device_sub_ptr()
device->mem_free_sub_ptr(ptr);
}
/* Device Texture */
device_texture::device_texture(Device *device,
const char *name,
const uint slot,
ImageDataType image_data_type,
InterpolationType interpolation,
ExtensionType extension)
: device_memory(device, name, MEM_TEXTURE), slot(slot)
{
switch (image_data_type) {
case IMAGE_DATA_TYPE_FLOAT4:
data_type = TYPE_FLOAT;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_FLOAT:
data_type = TYPE_FLOAT;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_BYTE4:
data_type = TYPE_UCHAR;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_BYTE:
data_type = TYPE_UCHAR;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_HALF4:
data_type = TYPE_HALF;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_HALF:
data_type = TYPE_HALF;
data_elements = 1;
break;
case IMAGE_DATA_TYPE_USHORT4:
data_type = TYPE_UINT16;
data_elements = 4;
break;
case IMAGE_DATA_TYPE_USHORT:
data_type = TYPE_UINT16;
data_elements = 1;
break;
case IMAGE_DATA_NUM_TYPES:
assert(0);
return;
}
memset(&info, 0, sizeof(info));
info.data_type = image_data_type;
info.interpolation = interpolation;
info.extension = extension;
}
device_texture::~device_texture()
{
device_free();
host_free();
}
/* Host memory allocation. */
void *device_texture::alloc(const size_t width, const size_t height, const size_t depth)
{
const size_t new_size = size(width, height, depth);
if (new_size != data_size) {
device_free();
host_free();
host_pointer = host_alloc(data_elements * datatype_size(data_type) * new_size);
assert(device_pointer == 0);
}
data_size = new_size;
data_width = width;
data_height = height;
data_depth = depth;
info.width = width;
info.height = height;
info.depth = depth;
return host_pointer;
}
void device_texture::copy_to_device()
{
device_copy_to();
}
CCL_NAMESPACE_END

View File

@@ -23,6 +23,7 @@
#include "util/util_array.h"
#include "util/util_half.h"
#include "util/util_string.h"
#include "util/util_texture.h"
#include "util/util_types.h"
#include "util/util_vector.h"
@@ -31,7 +32,14 @@ CCL_NAMESPACE_BEGIN
class Device;
enum MemoryType { MEM_READ_ONLY, MEM_READ_WRITE, MEM_DEVICE_ONLY, MEM_TEXTURE, MEM_PIXELS };
enum MemoryType {
MEM_READ_ONLY,
MEM_READ_WRITE,
MEM_DEVICE_ONLY,
MEM_GLOBAL,
MEM_TEXTURE,
MEM_PIXELS
};
/* Supported Data Types */
@@ -208,8 +216,6 @@ class device_memory {
size_t data_depth;
MemoryType type;
const char *name;
InterpolationType interpolation;
ExtensionType extension;
/* Pointers. */
Device *device;
@@ -310,7 +316,7 @@ template<typename T> class device_only_memory : public device_memory {
* in and copied to the device with copy_to_device(). Or alternatively
* allocated and set to zero on the device with zero_to_device().
*
* When using memory type MEM_TEXTURE, a pointer to this memory will be
* When using memory type MEM_GLOBAL, a pointer to this memory will be
* automatically attached to kernel globals, using the provided name
* matching an entry in kernel_textures.h. */
@@ -503,6 +509,33 @@ class device_sub_ptr {
device_ptr ptr;
};
/* Device Texture
*
* 2D or 3D image texture memory. */
class device_texture : public device_memory {
public:
device_texture(Device *device,
const char *name,
const uint slot,
ImageDataType image_data_type,
InterpolationType interpolation,
ExtensionType extension);
~device_texture();
void *alloc(const size_t width, const size_t height, const size_t depth = 0);
void copy_to_device();
uint slot;
TextureInfo info;
protected:
size_t size(const size_t width, const size_t height, const size_t depth)
{
return width * ((height == 0) ? 1 : height) * ((depth == 0) ? 1 : depth);
}
};
CCL_NAMESPACE_END
#endif /* __DEVICE_MEMORY_H__ */

View File

@@ -183,6 +183,14 @@ class MultiDevice : public Device {
return true;
}
virtual void *osl_memory()
{
if (devices.size() > 1) {
return NULL;
}
return devices.front().device->osl_memory();
}
void mem_alloc(device_memory &mem)
{
device_ptr key = unique_key++;
@@ -482,11 +490,24 @@ class MultiDevice : public Device {
void task_add(DeviceTask &task)
{
list<SubDevice> &task_devices = denoising_devices.empty() ||
(task.type != DeviceTask::DENOISE &&
task.type != DeviceTask::DENOISE_BUFFER) ?
devices :
denoising_devices;
list<SubDevice> task_devices = devices;
if (!denoising_devices.empty()) {
if (task.type == DeviceTask::DENOISE_BUFFER) {
/* Denoising tasks should be redirected to the denoising devices entirely. */
task_devices = denoising_devices;
}
else if (task.type == DeviceTask::RENDER && (task.tile_types & RenderTile::DENOISE)) {
const uint tile_types = task.tile_types;
/* For normal rendering tasks only redirect the denoising part to the denoising devices.
* Do not need to split the task here, since they all run through 'acquire_tile'. */
task.tile_types = RenderTile::DENOISE;
foreach (SubDevice &sub, denoising_devices) {
sub.device->task_add(task);
}
/* Rendering itself should still be executed on the rendering devices. */
task.tile_types = tile_types ^ RenderTile::DENOISE;
}
}
list<DeviceTask> tasks;
task.split(tasks, task_devices.size());

View File

@@ -186,14 +186,15 @@ class OptiXDevice : public CUDADevice {
OptixTraversableHandle tlas_handle = 0;
OptixDenoiser denoiser = NULL;
pair<int2, CUdeviceptr> denoiser_state = {};
device_only_memory<unsigned char> denoiser_state;
int denoiser_input_passes = 0;
public:
OptiXDevice(DeviceInfo &info_, Stats &stats_, Profiler &profiler_, bool background_)
: CUDADevice(info_, stats_, profiler_, background_),
sbt_data(this, "__sbt", MEM_READ_ONLY),
launch_params(this, "__params")
launch_params(this, "__params"),
denoiser_state(this, "__denoiser_state")
{
// Store number of CUDA streams in device info
info.cpu_threads = DebugFlags().optix.cuda_streams;
@@ -255,13 +256,10 @@ class OptiXDevice : public CUDADevice {
cuMemFree(mem);
}
if (denoiser_state.second) {
cuMemFree(denoiser_state.second);
}
sbt_data.free();
texture_info.free();
launch_params.free();
denoiser_state.free();
// Unload modules
if (optix_module != NULL)
@@ -479,9 +477,9 @@ class OptiXDevice : public CUDADevice {
// Calculate maximum trace continuation stack size
unsigned int trace_css = stack_size[PG_HITD].cssCH;
// This is based on the maximum of closest-hit and any-hit/intersection programs
trace_css = max(trace_css, stack_size[PG_HITD].cssIS + stack_size[PG_HITD].cssAH);
trace_css = max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
trace_css = max(trace_css, stack_size[PG_HITS].cssIS + stack_size[PG_HITS].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITD].cssIS + stack_size[PG_HITD].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITL].cssIS + stack_size[PG_HITL].cssAH);
trace_css = std::max(trace_css, stack_size[PG_HITS].cssIS + stack_size[PG_HITS].cssAH);
OptixPipelineLinkOptions link_options;
link_options.maxTraceDepth = 1;
@@ -550,8 +548,9 @@ class OptiXDevice : public CUDADevice {
&pipelines[PIP_SHADER_EVAL]));
// Calculate continuation stack size based on the maximum of all ray generation stack sizes
const unsigned int css = max(stack_size[PG_BAKE].cssRG,
max(stack_size[PG_DISP].cssRG, stack_size[PG_BACK].cssRG)) +
const unsigned int css = std::max(stack_size[PG_BAKE].cssRG,
std::max(stack_size[PG_DISP].cssRG,
stack_size[PG_BACK].cssRG)) +
link_options.maxTraceDepth * trace_css;
check_result_optix_ret(optixPipelineSetStackSize(
@@ -571,9 +570,14 @@ class OptiXDevice : public CUDADevice {
if (have_error())
return; // Abort early if there was an error previously
if (task.type == DeviceTask::RENDER || task.type == DeviceTask::DENOISE) {
if (task.type == DeviceTask::RENDER) {
if (thread_index != 0) {
// Only execute denoising in a single thread (see also 'task_add')
task.tile_types &= ~RenderTile::DENOISE;
}
RenderTile tile;
while (task.acquire_tile(this, tile)) {
while (task.acquire_tile(this, tile, task.tile_types)) {
if (tile.task == RenderTile::PATH_TRACE)
launch_render(task, tile, thread_index);
else if (tile.task == RenderTile::DENOISE)
@@ -624,7 +628,11 @@ class OptiXDevice : public CUDADevice {
const int end_sample = rtile.start_sample + rtile.num_samples;
// Keep this number reasonable to avoid running into TDRs
const int step_samples = (info.display_device ? 8 : 32);
int step_samples = (info.display_device ? 8 : 32);
if (task.adaptive_sampling.use) {
step_samples = task.adaptive_sampling.align_static_samples(step_samples);
}
// Offset into launch params buffer so that streams use separate data
device_ptr launch_params_ptr = launch_params.device_pointer +
thread_index * launch_params.data_elements;
@@ -635,10 +643,9 @@ class OptiXDevice : public CUDADevice {
// Copy work tile information to device
wtile.num_samples = min(step_samples, end_sample - sample);
wtile.start_sample = sample;
check_result_cuda(cuMemcpyHtoDAsync(launch_params_ptr + offsetof(KernelParams, tile),
&wtile,
sizeof(wtile),
cuda_stream[thread_index]));
device_ptr d_wtile_ptr = launch_params_ptr + offsetof(KernelParams, tile);
check_result_cuda(
cuMemcpyHtoDAsync(d_wtile_ptr, &wtile, sizeof(wtile), cuda_stream[thread_index]));
OptixShaderBindingTable sbt_params = {};
sbt_params.raygenRecord = sbt_data.device_pointer + PG_RGEN * sizeof(SbtRecord);
@@ -663,6 +670,12 @@ class OptiXDevice : public CUDADevice {
wtile.h,
1));
// Run the adaptive sampling kernels at selected samples aligned to step samples.
uint filter_sample = wtile.start_sample + wtile.num_samples - 1;
if (task.adaptive_sampling.use && task.adaptive_sampling.need_filter(filter_sample)) {
adaptive_sampling_filter(filter_sample, &wtile, d_wtile_ptr, cuda_stream[thread_index]);
}
// Wait for launch to finish
check_result_cuda(cuStreamSynchronize(cuda_stream[thread_index]));
@@ -674,6 +687,14 @@ class OptiXDevice : public CUDADevice {
if (task.get_cancel() && !task.need_finish_queue)
return; // Cancel rendering
}
// Finalize adaptive sampling
if (task.adaptive_sampling.use) {
device_ptr d_wtile_ptr = launch_params_ptr + offsetof(KernelParams, tile);
adaptive_sampling_post(rtile, &wtile, d_wtile_ptr, cuda_stream[thread_index]);
check_result_cuda(cuStreamSynchronize(cuda_stream[thread_index]));
task.update_progress(&rtile, rtile.w * rtile.h * wtile.num_samples);
}
}
bool launch_denoise(DeviceTask &task, RenderTile &rtile)
@@ -813,32 +834,26 @@ class OptiXDevice : public CUDADevice {
check_result_optix_ret(
optixDenoiserComputeMemoryResources(denoiser, rect_size.x, rect_size.y, &sizes));
auto &state = denoiser_state.second;
auto &state_size = denoiser_state.first;
const size_t scratch_size = sizes.recommendedScratchSizeInBytes;
const size_t scratch_offset = sizes.stateSizeInBytes;
// Allocate denoiser state if tile size has changed since last setup
if (state_size.x != rect_size.x || state_size.y != rect_size.y || recreate_denoiser) {
// Free existing state before allocating new one
if (state) {
cuMemFree(state);
state = 0;
}
check_result_cuda_ret(cuMemAlloc(&state, scratch_offset + scratch_size));
if (recreate_denoiser || (denoiser_state.data_width != rect_size.x ||
denoiser_state.data_height != rect_size.y)) {
denoiser_state.alloc_to_device(scratch_offset + scratch_size);
// Initialize denoiser state for the current tile size
check_result_optix_ret(optixDenoiserSetup(denoiser,
0,
rect_size.x,
rect_size.y,
state,
denoiser_state.device_pointer,
scratch_offset,
state + scratch_offset,
denoiser_state.device_pointer + scratch_offset,
scratch_size));
state_size = rect_size;
denoiser_state.data_width = rect_size.x;
denoiser_state.data_height = rect_size.y;
}
// Set up input and output layer information
@@ -880,14 +895,14 @@ class OptiXDevice : public CUDADevice {
check_result_optix_ret(optixDenoiserInvoke(denoiser,
0,
&params,
state,
denoiser_state.device_pointer,
scratch_offset,
input_layers,
task.denoising.optix_input_passes,
overlap_offset.x,
overlap_offset.y,
output_layers,
state + scratch_offset,
denoiser_state.device_pointer + scratch_offset,
scratch_size));
# if OPTIX_DENOISER_NO_PIXEL_STRIDE
@@ -1459,7 +1474,7 @@ class OptiXDevice : public CUDADevice {
return;
}
if (task.type == DeviceTask::DENOISE || task.type == DeviceTask::DENOISE_BUFFER) {
if (task.type == DeviceTask::DENOISE_BUFFER) {
// Execute denoising in a single thread (e.g. to avoid race conditions during creation)
task_pool.push(new OptiXDeviceTask(this, task, 0));
return;

View File

@@ -55,6 +55,10 @@ DeviceSplitKernel::DeviceSplitKernel(Device *device)
kernel_next_iteration_setup = NULL;
kernel_indirect_subsurface = NULL;
kernel_buffer_update = NULL;
kernel_adaptive_stopping = NULL;
kernel_adaptive_filter_x = NULL;
kernel_adaptive_filter_y = NULL;
kernel_adaptive_adjust_samples = NULL;
}
DeviceSplitKernel::~DeviceSplitKernel()
@@ -83,6 +87,10 @@ DeviceSplitKernel::~DeviceSplitKernel()
delete kernel_next_iteration_setup;
delete kernel_indirect_subsurface;
delete kernel_buffer_update;
delete kernel_adaptive_stopping;
delete kernel_adaptive_filter_x;
delete kernel_adaptive_filter_y;
delete kernel_adaptive_adjust_samples;
}
bool DeviceSplitKernel::load_kernels(const DeviceRequestedFeatures &requested_features)
@@ -114,6 +122,10 @@ bool DeviceSplitKernel::load_kernels(const DeviceRequestedFeatures &requested_fe
LOAD_KERNEL(next_iteration_setup);
LOAD_KERNEL(indirect_subsurface);
LOAD_KERNEL(buffer_update);
LOAD_KERNEL(adaptive_stopping);
LOAD_KERNEL(adaptive_filter_x);
LOAD_KERNEL(adaptive_filter_y);
LOAD_KERNEL(adaptive_adjust_samples);
#undef LOAD_KERNEL
@@ -202,13 +214,21 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
/* initial guess to start rolling average */
const int initial_num_samples = 1;
/* approx number of samples per second */
int samples_per_second = (avg_time_per_sample > 0.0) ?
int(double(time_multiplier) / avg_time_per_sample) + 1 :
initial_num_samples;
const int samples_per_second = (avg_time_per_sample > 0.0) ?
int(double(time_multiplier) / avg_time_per_sample) + 1 :
initial_num_samples;
RenderTile subtile = tile;
subtile.start_sample = tile.sample;
subtile.num_samples = min(samples_per_second,
subtile.num_samples = samples_per_second;
if (task->adaptive_sampling.use) {
subtile.num_samples = task->adaptive_sampling.align_dynamic_samples(subtile.start_sample,
subtile.num_samples);
}
/* Don't go beyond requested number of samples. */
subtile.num_samples = min(subtile.num_samples,
tile.start_sample + tile.num_samples - tile.sample);
if (device->have_error()) {
@@ -302,6 +322,23 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
}
}
int filter_sample = tile.sample + subtile.num_samples - 1;
if (task->adaptive_sampling.use && task->adaptive_sampling.need_filter(filter_sample)) {
size_t buffer_size[2];
buffer_size[0] = round_up(tile.w, local_size[0]);
buffer_size[1] = round_up(tile.h, local_size[1]);
kernel_adaptive_stopping->enqueue(
KernelDimensions(buffer_size, local_size), kgbuffer, kernel_data);
buffer_size[0] = round_up(tile.h, local_size[0]);
buffer_size[1] = round_up(1, local_size[1]);
kernel_adaptive_filter_x->enqueue(
KernelDimensions(buffer_size, local_size), kgbuffer, kernel_data);
buffer_size[0] = round_up(tile.w, local_size[0]);
buffer_size[1] = round_up(1, local_size[1]);
kernel_adaptive_filter_y->enqueue(
KernelDimensions(buffer_size, local_size), kgbuffer, kernel_data);
}
double time_per_sample = ((time_dt() - start_time) / subtile.num_samples);
if (avg_time_per_sample == 0.0) {
@@ -324,6 +361,28 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
}
}
if (task->adaptive_sampling.use) {
/* Reset the start samples. */
RenderTile subtile = tile;
subtile.start_sample = tile.start_sample;
subtile.num_samples = tile.sample - tile.start_sample;
enqueue_split_kernel_data_init(KernelDimensions(global_size, local_size),
subtile,
num_global_elements,
kgbuffer,
kernel_data,
split_data,
ray_state,
queue_index,
use_queues_flag,
work_pool_wgs);
size_t buffer_size[2];
buffer_size[0] = round_up(tile.w, local_size[0]);
buffer_size[1] = round_up(tile.h, local_size[1]);
kernel_adaptive_adjust_samples->enqueue(
KernelDimensions(buffer_size, local_size), kgbuffer, kernel_data);
}
return true;
}

View File

@@ -75,6 +75,10 @@ class DeviceSplitKernel {
SplitKernelFunction *kernel_next_iteration_setup;
SplitKernelFunction *kernel_indirect_subsurface;
SplitKernelFunction *kernel_buffer_update;
SplitKernelFunction *kernel_adaptive_stopping;
SplitKernelFunction *kernel_adaptive_filter_x;
SplitKernelFunction *kernel_adaptive_filter_y;
SplitKernelFunction *kernel_adaptive_adjust_samples;
/* Global memory variables [porting]; These memory is used for
* co-operation between different kernels; Data written by one

View File

@@ -68,7 +68,7 @@ int DeviceTask::get_subtask_count(int num, int max_size)
if (type == SHADER) {
num = min(shader_w, num);
}
else if (type == RENDER || type == DENOISE) {
else if (type == RENDER) {
}
else {
num = min(h, num);
@@ -94,7 +94,7 @@ void DeviceTask::split(list<DeviceTask> &tasks, int num, int max_size)
tasks.push_back(task);
}
}
else if (type == RENDER || type == DENOISE) {
else if (type == RENDER) {
for (int i = 0; i < num; i++)
tasks.push_back(*this);
}
@@ -136,4 +136,59 @@ void DeviceTask::update_progress(RenderTile *rtile, int pixel_samples)
}
}
/* Adaptive Sampling */
AdaptiveSampling::AdaptiveSampling()
: use(true), adaptive_step(ADAPTIVE_SAMPLE_STEP), min_samples(0)
{
}
/* Render samples in steps that align with the adaptive filtering. */
int AdaptiveSampling::align_static_samples(int samples) const
{
if (samples > adaptive_step) {
/* Make multiple of adaptive_step. */
while (samples % adaptive_step != 0) {
samples--;
}
}
else if (samples < adaptive_step) {
/* Make divisor of adaptive_step. */
while (adaptive_step % samples != 0) {
samples--;
}
}
return max(samples, 1);
}
/* Render samples in steps that align with the adaptive filtering, with the
* suggested number of samples dynamically changing. */
int AdaptiveSampling::align_dynamic_samples(int offset, int samples) const
{
/* Round so that we end up on multiples of adaptive_samples. */
samples += offset;
if (samples > adaptive_step) {
/* Make multiple of adaptive_step. */
while (samples % adaptive_step != 0) {
samples--;
}
}
samples -= offset;
return max(samples, 1);
}
bool AdaptiveSampling::need_filter(int sample) const
{
if (sample > min_samples) {
return (sample & (adaptive_step - 1)) == (adaptive_step - 1);
}
else {
return false;
}
}
CCL_NAMESPACE_END

View File

@@ -62,9 +62,22 @@ class DenoiseParams {
}
};
class AdaptiveSampling {
public:
AdaptiveSampling();
int align_static_samples(int samples) const;
int align_dynamic_samples(int offset, int samples) const;
bool need_filter(int sample) const;
bool use;
int adaptive_step;
int min_samples;
};
class DeviceTask : public Task {
public:
typedef enum { RENDER, DENOISE, DENOISE_BUFFER, FILM_CONVERT, SHADER } Type;
typedef enum { RENDER, FILM_CONVERT, SHADER, DENOISE_BUFFER } Type;
Type type;
int x, y, w, h;
@@ -90,7 +103,7 @@ class DeviceTask : public Task {
void update_progress(RenderTile *rtile, int pixel_samples = -1);
function<bool(Device *device, RenderTile &)> acquire_tile;
function<bool(Device *device, RenderTile &, uint)> acquire_tile;
function<void(long, int)> update_progress_sample;
function<void(RenderTile &)> update_tile_sample;
function<void(RenderTile &)> release_tile;
@@ -98,6 +111,7 @@ class DeviceTask : public Task {
function<void(RenderTile *, Device *)> map_neighbor_tiles;
function<void(RenderTile *, Device *)> unmap_neighbor_tiles;
uint tile_types;
DenoiseParams denoising;
bool denoising_from_render;
vector<int> denoising_frames;
@@ -114,6 +128,7 @@ class DeviceTask : public Task {
bool need_finish_queue;
bool integrator_branched;
AdaptiveSampling adaptive_sampling;
protected:
double last_update_time;

View File

@@ -428,8 +428,10 @@ class OpenCLDevice : public Device {
int mem_sub_ptr_alignment();
void const_copy_to(const char *name, void *host, size_t size);
void tex_alloc(device_memory &mem);
void tex_free(device_memory &mem);
void global_alloc(device_memory &mem);
void global_free(device_memory &mem);
void tex_alloc(device_texture &mem);
void tex_free(device_texture &mem);
size_t global_size_round_up(int group_size, int global_size);
void enqueue_kernel(cl_kernel kernel,
@@ -445,6 +447,7 @@ class OpenCLDevice : public Device {
device_ptr rgba_byte,
device_ptr rgba_half);
void shader(DeviceTask &task);
void update_adaptive(DeviceTask &task, RenderTile &tile, int sample);
void denoise(RenderTile &tile, DenoisingTask &denoising);

View File

@@ -56,7 +56,11 @@ static const string SPLIT_BUNDLE_KERNELS =
"enqueue_inactive "
"next_iteration_setup "
"indirect_subsurface "
"buffer_update";
"buffer_update "
"adaptive_stopping "
"adaptive_filter_x "
"adaptive_filter_y "
"adaptive_adjust_samples";
const string OpenCLDevice::get_opencl_program_name(const string &kernel_name)
{
@@ -283,6 +287,10 @@ void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(next_iteration_setup);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(indirect_subsurface);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(buffer_update);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(adaptive_stopping);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(adaptive_filter_x);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(adaptive_filter_y);
ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(adaptive_adjust_samples);
programs.push_back(&program_split);
# undef ADD_SPLIT_KERNEL_PROGRAM
@@ -605,7 +613,7 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
kernel_programs(this),
preview_programs(this),
memory_manager(this),
texture_info(this, "__texture_info", MEM_TEXTURE)
texture_info(this, "__texture_info", MEM_GLOBAL)
{
cpPlatform = NULL;
cdDevice = NULL;
@@ -937,7 +945,7 @@ void OpenCLDevice::mem_alloc(device_memory &mem)
cl_mem_flags mem_flag;
void *mem_ptr = NULL;
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL)
mem_flag = CL_MEM_READ_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;
@@ -961,9 +969,13 @@ void OpenCLDevice::mem_alloc(device_memory &mem)
void OpenCLDevice::mem_copy_to(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
tex_alloc(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
tex_alloc((device_texture &)mem);
}
else {
if (!mem.device_pointer) {
@@ -1069,8 +1081,11 @@ void OpenCLDevice::mem_zero(device_memory &mem)
void OpenCLDevice::mem_free(device_memory &mem)
{
if (mem.type == MEM_TEXTURE) {
tex_free(mem);
if (mem.type == MEM_GLOBAL) {
global_free(mem);
}
else if (mem.type == MEM_TEXTURE) {
tex_free((device_texture &)mem);
}
else {
if (mem.device_pointer) {
@@ -1093,7 +1108,7 @@ int OpenCLDevice::mem_sub_ptr_alignment()
device_ptr OpenCLDevice::mem_alloc_sub_ptr(device_memory &mem, int offset, int size)
{
cl_mem_flags mem_flag;
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE)
if (mem.type == MEM_READ_ONLY || mem.type == MEM_TEXTURE || mem.type == MEM_GLOBAL)
mem_flag = CL_MEM_READ_ONLY;
else
mem_flag = CL_MEM_READ_WRITE;
@@ -1133,9 +1148,9 @@ void OpenCLDevice::const_copy_to(const char *name, void *host, size_t size)
data->copy_to_device();
}
void OpenCLDevice::tex_alloc(device_memory &mem)
void OpenCLDevice::global_alloc(device_memory &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
VLOG(1) << "Global memory allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
@@ -1147,7 +1162,7 @@ void OpenCLDevice::tex_alloc(device_memory &mem)
textures_need_update = true;
}
void OpenCLDevice::tex_free(device_memory &mem)
void OpenCLDevice::global_free(device_memory &mem)
{
if (mem.device_pointer) {
mem.device_pointer = 0;
@@ -1165,6 +1180,25 @@ void OpenCLDevice::tex_free(device_memory &mem)
}
}
void OpenCLDevice::tex_alloc(device_texture &mem)
{
VLOG(1) << "Texture allocate: " << mem.name << ", "
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
<< string_human_readable_size(mem.memory_size()) << ")";
memory_manager.alloc(mem.name, mem);
/* Set the pointer to non-null to keep code that inspects its value from thinking its
* unallocated. */
mem.device_pointer = 1;
textures[mem.name] = &mem;
textures_need_update = true;
}
void OpenCLDevice::tex_free(device_texture &mem)
{
global_free(mem);
}
size_t OpenCLDevice::global_size_round_up(int group_size, int global_size)
{
int r = global_size % group_size;
@@ -1265,10 +1299,10 @@ void OpenCLDevice::flush_texture_buffers()
foreach (TexturesMap::value_type &tex, textures) {
string name = tex.first;
device_memory *mem = tex.second;
if (string_startswith(name, "__tex_image")) {
int pos = name.rfind("_");
int id = atoi(name.data() + pos + 1);
if (mem->type == MEM_TEXTURE) {
const uint id = ((device_texture *)mem)->slot;
texture_slots.push_back(texture_slot_t(name, num_data_slots + id));
num_slots = max(num_slots, num_data_slots + id + 1);
}
@@ -1281,22 +1315,20 @@ void OpenCLDevice::flush_texture_buffers()
/* Fill in descriptors */
foreach (texture_slot_t &slot, texture_slots) {
device_memory *mem = textures[slot.name];
TextureInfo &info = texture_info[slot.slot];
MemoryManager::BufferDescriptor desc = memory_manager.get_descriptor(slot.name);
if (mem->type == MEM_TEXTURE) {
info = ((device_texture *)mem)->info;
}
else {
memset(&info, 0, sizeof(TextureInfo));
}
info.data = desc.offset;
info.cl_buffer = desc.device_buffer;
if (string_startswith(slot.name, "__tex_image")) {
device_memory *mem = textures[slot.name];
info.width = mem->data_width;
info.height = mem->data_height;
info.depth = mem->data_depth;
info.interpolation = mem->interpolation;
info.extension = mem->extension;
}
}
/* Force write of descriptors. */
@@ -1308,7 +1340,7 @@ void OpenCLDevice::thread_run(DeviceTask *task)
{
flush_texture_buffers();
if (task->type == DeviceTask::RENDER || task->type == DeviceTask::DENOISE) {
if (task->type == DeviceTask::RENDER) {
RenderTile tile;
DenoisingTask denoising(this, *task);
@@ -1317,7 +1349,7 @@ void OpenCLDevice::thread_run(DeviceTask *task)
kgbuffer.alloc_to_device(1);
/* Keep rendering tiles until done. */
while (task->acquire_tile(this, tile)) {
while (task->acquire_tile(this, tile, task->tile_types)) {
if (tile.task == RenderTile::PATH_TRACE) {
assert(tile.task == RenderTile::PATH_TRACE);
scoped_timer timer(&tile.buffers->render_time);

View File

@@ -36,6 +36,10 @@ set(SRC_CUDA_KERNELS
)
set(SRC_OPENCL_KERNELS
kernels/opencl/kernel_adaptive_stopping.cl
kernels/opencl/kernel_adaptive_filter_x.cl
kernels/opencl/kernel_adaptive_filter_y.cl
kernels/opencl/kernel_adaptive_adjust_samples.cl
kernels/opencl/kernel_bake.cl
kernels/opencl/kernel_base.cl
kernels/opencl/kernel_displace.cl
@@ -94,6 +98,7 @@ set(SRC_BVH_HEADERS
set(SRC_HEADERS
kernel_accumulate.h
kernel_adaptive_sampling.h
kernel_bake.h
kernel_camera.h
kernel_color.h
@@ -324,6 +329,10 @@ set(SRC_UTIL_HEADERS
)
set(SRC_SPLIT_HEADERS
split/kernel_adaptive_adjust_samples.h
split/kernel_adaptive_filter_x.h
split/kernel_adaptive_filter_y.h
split/kernel_adaptive_stopping.h
split/kernel_branched.h
split/kernel_buffer_update.h
split/kernel_data_init.h

View File

@@ -17,9 +17,12 @@
#include <embree3/rtcore_ray.h>
#include <embree3/rtcore_scene.h>
// clang-format off
#include "kernel/kernel_compat_cpu.h"
#include "kernel/split/kernel_split_data_types.h"
#include "kernel/kernel_globals.h"
// clang-format on
#include "util/util_vector.h"
CCL_NAMESPACE_BEGIN

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
// clang-format off
#include "kernel/closure/bsdf_ashikhmin_velvet.h"
#include "kernel/closure/bsdf_diffuse.h"
#include "kernel/closure/bsdf_oren_nayar.h"
@@ -32,6 +33,7 @@
#include "kernel/closure/bsdf_principled_sheen.h"
#include "kernel/closure/bssrdf.h"
#include "kernel/closure/volume.h"
// clang-format on
CCL_NAMESPACE_BEGIN

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
// clang-format off
#include "kernel/geom/geom_attribute.h"
#include "kernel/geom/geom_object.h"
#ifdef __PATCH_EVAL__
@@ -30,3 +31,4 @@
#include "kernel/geom/geom_curve_intersect.h"
#include "kernel/geom/geom_volume.h"
#include "kernel/geom/geom_primitive.h"
// clang-format on

View File

@@ -38,7 +38,7 @@ void *kernel_osl_memory(KernelGlobals *kg);
bool kernel_osl_use(KernelGlobals *kg);
void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size);
void kernel_tex_copy(KernelGlobals *kg, const char *name, void *mem, size_t size);
void kernel_global_memory_copy(KernelGlobals *kg, const char *name, void *mem, size_t size);
#define KERNEL_ARCH cpu
#include "kernel/kernels/cpu/kernel_cpu.h"

View File

@@ -0,0 +1,230 @@
/*
* Copyright 2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __KERNEL_ADAPTIVE_SAMPLING_H__
#define __KERNEL_ADAPTIVE_SAMPLING_H__
CCL_NAMESPACE_BEGIN
/* Determines whether to continue sampling a given pixel or if it has sufficiently converged. */
ccl_device void kernel_do_adaptive_stopping(KernelGlobals *kg,
ccl_global float *buffer,
int sample)
{
/* TODO Stefan: Is this better in linear, sRGB or something else? */
float4 I = *((ccl_global float4 *)buffer);
float4 A = *(ccl_global float4 *)(buffer + kernel_data.film.pass_adaptive_aux_buffer);
/* The per pixel error as seen in section 2.1 of
* "A hierarchical automatic stopping condition for Monte Carlo global illumination"
* A small epsilon is added to the divisor to prevent division by zero. */
float error = (fabsf(I.x - A.x) + fabsf(I.y - A.y) + fabsf(I.z - A.z)) /
(sample * 0.0001f + sqrtf(I.x + I.y + I.z));
if (error < kernel_data.integrator.adaptive_threshold * (float)sample) {
/* Set the fourth component to non-zero value to indicate that this pixel has converged. */
buffer[kernel_data.film.pass_adaptive_aux_buffer + 3] += 1.0f;
}
}
/* Adjust the values of an adaptively sampled pixel. */
ccl_device void kernel_adaptive_post_adjust(KernelGlobals *kg,
ccl_global float *buffer,
float sample_multiplier)
{
*(ccl_global float4 *)(buffer) *= sample_multiplier;
/* Scale the aux pass too, this is necessary for progressive rendering to work properly. */
kernel_assert(kernel_data.film.pass_adaptive_aux_buffer);
*(ccl_global float4 *)(buffer + kernel_data.film.pass_adaptive_aux_buffer) *= sample_multiplier;
#ifdef __PASSES__
int flag = kernel_data.film.pass_flag;
if (flag & PASSMASK(NORMAL))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_normal) *= sample_multiplier;
if (flag & PASSMASK(UV))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_uv) *= sample_multiplier;
if (flag & PASSMASK(MOTION)) {
*(ccl_global float4 *)(buffer + kernel_data.film.pass_motion) *= sample_multiplier;
*(ccl_global float *)(buffer + kernel_data.film.pass_motion_weight) *= sample_multiplier;
}
if (kernel_data.film.use_light_pass) {
int light_flag = kernel_data.film.light_pass_flag;
if (light_flag & PASSMASK(MIST))
*(ccl_global float *)(buffer + kernel_data.film.pass_mist) *= sample_multiplier;
/* Shadow pass omitted on purpose. It has its own scale parameter. */
if (light_flag & PASSMASK(DIFFUSE_INDIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_diffuse_indirect) *= sample_multiplier;
if (light_flag & PASSMASK(GLOSSY_INDIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_glossy_indirect) *= sample_multiplier;
if (light_flag & PASSMASK(TRANSMISSION_INDIRECT))
*(ccl_global float3 *)(buffer +
kernel_data.film.pass_transmission_indirect) *= sample_multiplier;
if (light_flag & PASSMASK(VOLUME_INDIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_volume_indirect) *= sample_multiplier;
if (light_flag & PASSMASK(DIFFUSE_DIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_diffuse_direct) *= sample_multiplier;
if (light_flag & PASSMASK(GLOSSY_DIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_glossy_direct) *= sample_multiplier;
if (light_flag & PASSMASK(TRANSMISSION_DIRECT))
*(ccl_global float3 *)(buffer +
kernel_data.film.pass_transmission_direct) *= sample_multiplier;
if (light_flag & PASSMASK(VOLUME_DIRECT))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_volume_direct) *= sample_multiplier;
if (light_flag & PASSMASK(EMISSION))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_emission) *= sample_multiplier;
if (light_flag & PASSMASK(BACKGROUND))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_background) *= sample_multiplier;
if (light_flag & PASSMASK(AO))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_ao) *= sample_multiplier;
if (light_flag & PASSMASK(DIFFUSE_COLOR))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_diffuse_color) *= sample_multiplier;
if (light_flag & PASSMASK(GLOSSY_COLOR))
*(ccl_global float3 *)(buffer + kernel_data.film.pass_glossy_color) *= sample_multiplier;
if (light_flag & PASSMASK(TRANSMISSION_COLOR))
*(ccl_global float3 *)(buffer +
kernel_data.film.pass_transmission_color) *= sample_multiplier;
}
#endif
#ifdef __DENOISING_FEATURES__
# define scale_float3_variance(buffer, offset, scale) \
*(buffer + offset) *= scale; \
*(buffer + offset + 1) *= scale; \
*(buffer + offset + 2) *= scale; \
*(buffer + offset + 3) *= scale * scale; \
*(buffer + offset + 4) *= scale * scale; \
*(buffer + offset + 5) *= scale * scale;
# define scale_shadow_variance(buffer, offset, scale) \
*(buffer + offset) *= scale; \
*(buffer + offset + 1) *= scale; \
*(buffer + offset + 2) *= scale * scale;
if (kernel_data.film.pass_denoising_data) {
scale_shadow_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_SHADOW_A, sample_multiplier);
scale_shadow_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_SHADOW_B, sample_multiplier);
if (kernel_data.film.pass_denoising_clean) {
scale_float3_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, sample_multiplier);
*(buffer + kernel_data.film.pass_denoising_clean) *= sample_multiplier;
*(buffer + kernel_data.film.pass_denoising_clean + 1) *= sample_multiplier;
*(buffer + kernel_data.film.pass_denoising_clean + 2) *= sample_multiplier;
}
else {
scale_float3_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR, sample_multiplier);
}
scale_float3_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL, sample_multiplier);
scale_float3_variance(
buffer, kernel_data.film.pass_denoising_data + DENOISING_PASS_ALBEDO, sample_multiplier);
*(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH) *= sample_multiplier;
*(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_DEPTH +
1) *= sample_multiplier * sample_multiplier;
}
#endif /* __DENOISING_FEATURES__ */
if (kernel_data.film.cryptomatte_passes) {
int num_slots = 0;
num_slots += (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) ? 1 : 0;
num_slots += (kernel_data.film.cryptomatte_passes & CRYPT_MATERIAL) ? 1 : 0;
num_slots += (kernel_data.film.cryptomatte_passes & CRYPT_ASSET) ? 1 : 0;
num_slots = num_slots * 2 * kernel_data.film.cryptomatte_depth;
ccl_global float2 *id_buffer = (ccl_global float2 *)(buffer +
kernel_data.film.pass_cryptomatte);
for (int slot = 0; slot < num_slots; slot++) {
id_buffer[slot].y *= sample_multiplier;
}
}
}
/* This is a simple box filter in two passes.
* When a pixel demands more adaptive samples, let its neighboring pixels draw more samples too. */
ccl_device bool kernel_do_adaptive_filter_x(KernelGlobals *kg, int y, ccl_global WorkTile *tile)
{
bool any = false;
bool prev = false;
for (int x = tile->x; x < tile->x + tile->w; ++x) {
int index = tile->offset + x + y * tile->stride;
ccl_global float *buffer = tile->buffer + index * kernel_data.film.pass_stride;
ccl_global float4 *aux = (ccl_global float4 *)(buffer +
kernel_data.film.pass_adaptive_aux_buffer);
if (aux->w == 0.0f) {
any = true;
if (x > tile->x && !prev) {
index = index - 1;
buffer = tile->buffer + index * kernel_data.film.pass_stride;
aux = (ccl_global float4 *)(buffer + kernel_data.film.pass_adaptive_aux_buffer);
aux->w = 0.0f;
}
prev = true;
}
else {
if (prev) {
aux->w = 0.0f;
}
prev = false;
}
}
return any;
}
ccl_device bool kernel_do_adaptive_filter_y(KernelGlobals *kg, int x, ccl_global WorkTile *tile)
{
bool prev = false;
bool any = false;
for (int y = tile->y; y < tile->y + tile->h; ++y) {
int index = tile->offset + x + y * tile->stride;
ccl_global float *buffer = tile->buffer + index * kernel_data.film.pass_stride;
ccl_global float4 *aux = (ccl_global float4 *)(buffer +
kernel_data.film.pass_adaptive_aux_buffer);
if (aux->w == 0.0f) {
any = true;
if (y > tile->y && !prev) {
index = index - tile->stride;
buffer = tile->buffer + index * kernel_data.film.pass_stride;
aux = (ccl_global float4 *)(buffer + kernel_data.film.pass_adaptive_aux_buffer);
aux->w = 0.0f;
}
prev = true;
}
else {
if (prev) {
aux->w = 0.0f;
}
prev = false;
}
}
return any;
}
CCL_NAMESPACE_END
#endif /* __KERNEL_ADAPTIVE_SAMPLING_H__ */

View File

@@ -195,4 +195,36 @@ ccl_device void cmj_sample_2D(int s, int N, int p, float *fx, float *fy)
}
#endif
ccl_device float pmj_sample_1D(KernelGlobals *kg, int sample, int rng_hash, int dimension)
{
/* Fallback to random */
if (sample >= NUM_PMJ_SAMPLES) {
int p = rng_hash + dimension;
return cmj_randfloat(sample, p);
}
uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
return __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ (tmp_rng & 0x007fffff)) -
1.0f;
}
ccl_device void pmj_sample_2D(
KernelGlobals *kg, int sample, int rng_hash, int dimension, float *fx, float *fy)
{
if (sample >= NUM_PMJ_SAMPLES) {
int p = rng_hash + dimension;
*fx = cmj_randfloat(sample, p);
*fy = cmj_randfloat(sample, p + 1);
return;
}
uint tmp_rng = cmj_hash_simple(dimension, rng_hash);
int index = ((dimension % NUM_PMJ_PATTERNS) * NUM_PMJ_SAMPLES + sample) * 2;
*fx = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index) ^ (tmp_rng & 0x007fffff)) -
1.0f;
tmp_rng = cmj_hash_simple(dimension + 1, rng_hash);
*fy = __uint_as_float(kernel_tex_fetch(__sample_pattern_lut, index + 1) ^
(tmp_rng & 0x007fffff)) -
1.0f;
}
CCL_NAMESPACE_END

View File

@@ -29,7 +29,9 @@ ccl_device_inline void kernel_write_denoising_shadow(KernelGlobals *kg,
if (kernel_data.film.pass_denoising_data == 0)
return;
buffer += (sample & 1) ? DENOISING_PASS_SHADOW_B : DENOISING_PASS_SHADOW_A;
buffer += sample_is_even(kernel_data.integrator.sampling_pattern, sample) ?
DENOISING_PASS_SHADOW_B :
DENOISING_PASS_SHADOW_A;
path_total = ensure_finite(path_total);
path_total_shaded = ensure_finite(path_total_shaded);
@@ -386,6 +388,41 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg,
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, L);
#endif
/* Adaptive Sampling. Fill the additional buffer with the odd samples and calculate our stopping
criteria. This is the heuristic from "A hierarchical automatic stopping condition for Monte
Carlo global illumination" except that here it is applied per pixel and not in hierarchical
tiles. */
if (kernel_data.film.pass_adaptive_aux_buffer &&
kernel_data.integrator.adaptive_threshold > 0.0f) {
if (sample_is_even(kernel_data.integrator.sampling_pattern, sample)) {
kernel_write_pass_float4(buffer + kernel_data.film.pass_adaptive_aux_buffer,
make_float4(L_sum.x * 2.0f, L_sum.y * 2.0f, L_sum.z * 2.0f, 0.0f));
}
#ifdef __KERNEL_CPU__
if (sample > kernel_data.integrator.adaptive_min_samples &&
(sample & (ADAPTIVE_SAMPLE_STEP - 1)) == (ADAPTIVE_SAMPLE_STEP - 1)) {
kernel_do_adaptive_stopping(kg, buffer, sample);
}
#endif
}
/* Write the sample count as negative numbers initially to mark the samples as in progress.
* Once the tile has finished rendering, the sign gets flipped and all the pixel values
* are scaled as if they were taken at a uniform sample count. */
if (kernel_data.film.pass_sample_count) {
/* Make sure it's a negative number. In progressive refine mode, this bit gets flipped between
* passes. */
#ifdef __ATOMIC_PASS_WRITE__
atomic_fetch_and_or_uint32((ccl_global uint *)(buffer + kernel_data.film.pass_sample_count),
0x80000000);
#else
if (buffer[kernel_data.film.pass_sample_count] > 0) {
buffer[kernel_data.film.pass_sample_count] *= -1.0f;
}
#endif
kernel_write_pass_float(buffer + kernel_data.film.pass_sample_count, -1.0f);
}
}
CCL_NAMESPACE_END

View File

@@ -18,6 +18,7 @@
# include "kernel/osl/osl_shader.h"
#endif
// clang-format off
#include "kernel/kernel_random.h"
#include "kernel/kernel_projection.h"
#include "kernel/kernel_montecarlo.h"
@@ -31,6 +32,7 @@
#include "kernel/kernel_accumulate.h"
#include "kernel/kernel_shader.h"
#include "kernel/kernel_light.h"
#include "kernel/kernel_adaptive_sampling.h"
#include "kernel/kernel_passes.h"
#if defined(__VOLUME__) || defined(__SUBSURFACE__)
@@ -48,6 +50,7 @@
#include "kernel/kernel_path_surface.h"
#include "kernel/kernel_path_volume.h"
#include "kernel/kernel_path_subsurface.h"
// clang-format on
CCL_NAMESPACE_BEGIN
@@ -656,6 +659,14 @@ ccl_device void kernel_path_trace(
buffer += index * pass_stride;
if (kernel_data.film.pass_adaptive_aux_buffer) {
ccl_global float4 *aux = (ccl_global float4 *)(buffer +
kernel_data.film.pass_adaptive_aux_buffer);
if (aux->w > 0.0f) {
return;
}
}
/* Initialize random numbers and sample ray. */
uint rng_hash;
Ray ray;

View File

@@ -523,6 +523,14 @@ ccl_device void kernel_branched_path_trace(
buffer += index * pass_stride;
if (kernel_data.film.pass_adaptive_aux_buffer) {
ccl_global float4 *aux = (ccl_global float4 *)(buffer +
kernel_data.film.pass_adaptive_aux_buffer);
if (aux->w > 0.0f) {
return;
}
}
/* initialize random numbers and ray */
uint rng_hash;
Ray ray;

View File

@@ -43,7 +43,7 @@ ccl_device uint sobol_dimension(KernelGlobals *kg, int index, int dimension)
uint i = index + SOBOL_SKIP;
for (int j = 0, x; (x = find_first_set(i)); i >>= x) {
j += x;
result ^= kernel_tex_fetch(__sobol_directions, 32 * dimension + j - 1);
result ^= kernel_tex_fetch(__sample_pattern_lut, 32 * dimension + j - 1);
}
return result;
}
@@ -56,7 +56,9 @@ ccl_device_forceinline float path_rng_1D(
#ifdef __DEBUG_CORRELATION__
return (float)drand48();
#endif
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_PMJ) {
return pmj_sample_1D(kg, sample, rng_hash, dimension);
}
#ifdef __CMJ__
# ifdef __SOBOL__
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ)
@@ -99,7 +101,10 @@ ccl_device_forceinline void path_rng_2D(KernelGlobals *kg,
*fy = (float)drand48();
return;
#endif
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_PMJ) {
pmj_sample_2D(kg, sample, rng_hash, dimension, fx, fy);
return;
}
#ifdef __CMJ__
# ifdef __SOBOL__
if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_CMJ)
@@ -284,4 +289,31 @@ ccl_device float lcg_step_float_addrspace(ccl_addr_space uint *rng)
return (float)*rng * (1.0f / (float)0xFFFFFFFF);
}
ccl_device_inline bool sample_is_even(int pattern, int sample)
{
if (pattern == SAMPLING_PATTERN_PMJ) {
/* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al.
* We can use this to get divide sample sequence into two classes for easier variance
* estimation. */
#if defined(__GNUC__) && !defined(__KERNEL_GPU__)
return __builtin_popcount(sample & 0xaaaaaaaa) & 1;
#elif defined(__NVCC__)
return __popc(sample & 0xaaaaaaaa) & 1;
#elif defined(__KERNEL_OPENCL__)
return popcount(sample & 0xaaaaaaaa) & 1;
#else
/* TODO(Stefan): popcnt intrinsic for Windows with fallback for older CPUs. */
int i = sample & 0xaaaaaaaa;
i = i - ((i >> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
i = (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
return i & 1;
#endif
}
else {
/* TODO(Stefan): Are there reliable ways of dividing CMJ and Sobol into two classes? */
return sample & 0x1;
}
}
CCL_NAMESPACE_END

View File

@@ -23,10 +23,12 @@
* Release.
*/
// clang-format off
#include "kernel/closure/alloc.h"
#include "kernel/closure/bsdf_util.h"
#include "kernel/closure/bsdf.h"
#include "kernel/closure/emissive.h"
// clang-format on
#include "kernel/svm/svm.h"

View File

@@ -77,7 +77,7 @@ KERNEL_TEX(KernelShader, __shaders)
KERNEL_TEX(float, __lookup_table)
/* sobol */
KERNEL_TEX(uint, __sobol_directions)
KERNEL_TEX(uint, __sample_pattern_lut)
/* image textures */
KERNEL_TEX(TextureInfo, __texture_info)

View File

@@ -63,6 +63,11 @@ CCL_NAMESPACE_BEGIN
#define VOLUME_STACK_SIZE 32
/* Adaptive sampling constants */
#define ADAPTIVE_SAMPLE_STEP 4
static_assert((ADAPTIVE_SAMPLE_STEP & (ADAPTIVE_SAMPLE_STEP - 1)) == 0,
"ADAPTIVE_SAMPLE_STEP must be power of two for bitwise operations to work");
/* Split kernel constants */
#define WORK_POOL_SIZE_GPU 64
#define WORK_POOL_SIZE_CPU 1
@@ -267,6 +272,7 @@ enum PathTraceDimension {
enum SamplingPattern {
SAMPLING_PATTERN_SOBOL = 0,
SAMPLING_PATTERN_CMJ = 1,
SAMPLING_PATTERN_PMJ = 2,
SAMPLING_NUM_PATTERNS,
};
@@ -373,6 +379,8 @@ typedef enum PassType {
PASS_CRYPTOMATTE,
PASS_AOV_COLOR,
PASS_AOV_VALUE,
PASS_ADAPTIVE_AUX_BUFFER,
PASS_SAMPLE_COUNT,
PASS_CATEGORY_MAIN_END = 31,
PASS_MIST = 32,
@@ -1222,6 +1230,9 @@ typedef struct KernelFilm {
int cryptomatte_depth;
int pass_cryptomatte;
int pass_adaptive_aux_buffer;
int pass_sample_count;
int pass_mist;
float mist_start;
float mist_inv_depth;
@@ -1255,6 +1266,8 @@ typedef struct KernelFilm {
int display_divide_pass_stride;
int use_display_exposure;
int use_display_pass_alpha;
int pad3, pad4, pad5;
} KernelFilm;
static_assert_align(KernelFilm, 16);
@@ -1336,6 +1349,8 @@ typedef struct KernelIntegrator {
/* sampler */
int sampling_pattern;
int aa_samples;
int adaptive_min_samples;
float adaptive_threshold;
/* volume render */
int use_volumes;
@@ -1347,7 +1362,7 @@ typedef struct KernelIntegrator {
int max_closures;
int pad1;
int pad1, pad2, pad3;
} KernelIntegrator;
static_assert_align(KernelIntegrator, 16);
@@ -1661,12 +1676,16 @@ typedef struct WorkTile {
uint start_sample;
uint num_samples;
uint offset;
int offset;
uint stride;
ccl_global float *buffer;
} WorkTile;
/* Precoumputed sample table sizes for PMJ02 sampler. */
#define NUM_PMJ_SAMPLES 64 * 64
#define NUM_PMJ_PATTERNS 48
CCL_NAMESPACE_END
#endif /* __KERNEL_TYPES_H__ */

View File

@@ -23,41 +23,6 @@ CCL_NAMESPACE_BEGIN
* Utility functions for work stealing
*/
#ifdef __KERNEL_OPENCL__
# pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#endif
#ifdef __SPLIT_KERNEL__
/* Returns true if there is work */
ccl_device bool get_next_work(KernelGlobals *kg,
ccl_global uint *work_pools,
uint total_work_size,
uint ray_index,
ccl_private uint *global_work_index)
{
/* With a small amount of work there may be more threads than work due to
* rounding up of global size, stop such threads immediately. */
if (ray_index >= total_work_size) {
return false;
}
/* Increase atomic work index counter in pool. */
uint pool = ray_index / WORK_POOL_SIZE;
uint work_index = atomic_fetch_and_inc_uint32(&work_pools[pool]);
/* Map per-pool work index to a global work index. */
uint global_size = ccl_global_size(0) * ccl_global_size(1);
kernel_assert(global_size % WORK_POOL_SIZE == 0);
kernel_assert(ray_index < global_size);
*global_work_index = (work_index / WORK_POOL_SIZE) * global_size + (pool * WORK_POOL_SIZE) +
(work_index % WORK_POOL_SIZE);
/* Test if all work for this pool is done. */
return (*global_work_index < total_work_size);
}
#endif
/* Map global work index to tile, pixel X/Y and sample. */
ccl_device_inline void get_work_pixel(ccl_global const WorkTile *tile,
uint global_work_index,
@@ -82,6 +47,71 @@ ccl_device_inline void get_work_pixel(ccl_global const WorkTile *tile,
*sample = tile->start_sample + sample_offset;
}
#ifdef __KERNEL_OPENCL__
# pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#endif
#ifdef __SPLIT_KERNEL__
/* Returns true if there is work */
ccl_device bool get_next_work_item(KernelGlobals *kg,
ccl_global uint *work_pools,
uint total_work_size,
uint ray_index,
ccl_private uint *global_work_index)
{
/* With a small amount of work there may be more threads than work due to
* rounding up of global size, stop such threads immediately. */
if (ray_index >= total_work_size) {
return false;
}
/* Increase atomic work index counter in pool. */
uint pool = ray_index / WORK_POOL_SIZE;
uint work_index = atomic_fetch_and_inc_uint32(&work_pools[pool]);
/* Map per-pool work index to a global work index. */
uint global_size = ccl_global_size(0) * ccl_global_size(1);
kernel_assert(global_size % WORK_POOL_SIZE == 0);
kernel_assert(ray_index < global_size);
*global_work_index = (work_index / WORK_POOL_SIZE) * global_size + (pool * WORK_POOL_SIZE) +
(work_index % WORK_POOL_SIZE);
/* Test if all work for this pool is done. */
return (*global_work_index < total_work_size);
}
ccl_device bool get_next_work(KernelGlobals *kg,
ccl_global uint *work_pools,
uint total_work_size,
uint ray_index,
ccl_private uint *global_work_index)
{
bool got_work = false;
if (kernel_data.film.pass_adaptive_aux_buffer) {
do {
got_work = get_next_work_item(kg, work_pools, total_work_size, ray_index, global_work_index);
if (got_work) {
ccl_global WorkTile *tile = &kernel_split_params.tile;
uint x, y, sample;
get_work_pixel(tile, *global_work_index, &x, &y, &sample);
uint buffer_offset = (tile->offset + x + y * tile->stride) * kernel_data.film.pass_stride;
ccl_global float *buffer = kernel_split_params.tile.buffer + buffer_offset;
ccl_global float4 *aux = (ccl_global float4 *)(buffer +
kernel_data.film.pass_adaptive_aux_buffer);
if (aux->w == 0.0f) {
break;
}
}
} while (got_work);
}
else {
got_work = get_next_work_item(kg, work_pools, total_work_size, ray_index, global_work_index);
}
return got_work;
}
#endif
CCL_NAMESPACE_END
#endif /* __KERNEL_WORK_STEALING_H__ */

View File

@@ -72,7 +72,7 @@ void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t s
assert(0);
}
void kernel_tex_copy(KernelGlobals *kg, const char *name, void *mem, size_t size)
void kernel_global_memory_copy(KernelGlobals *kg, const char *name, void *mem, size_t size)
{
if (0) {
}

View File

@@ -89,5 +89,9 @@ DECLARE_SPLIT_KERNEL_FUNCTION(enqueue_inactive)
DECLARE_SPLIT_KERNEL_FUNCTION(next_iteration_setup)
DECLARE_SPLIT_KERNEL_FUNCTION(indirect_subsurface)
DECLARE_SPLIT_KERNEL_FUNCTION(buffer_update)
DECLARE_SPLIT_KERNEL_FUNCTION(adaptive_stopping)
DECLARE_SPLIT_KERNEL_FUNCTION(adaptive_filter_x)
DECLARE_SPLIT_KERNEL_FUNCTION(adaptive_filter_y)
DECLARE_SPLIT_KERNEL_FUNCTION(adaptive_adjust_samples)
#undef KERNEL_ARCH

View File

@@ -474,7 +474,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
switch (kernel_tex_type(id)) {
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp(info, x, y);
case IMAGE_DATA_TYPE_BYTE:
@@ -503,7 +503,7 @@ ccl_device float4 kernel_tex_image_interp_3d(
{
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
switch (kernel_tex_type(id)) {
switch (info.data_type) {
case IMAGE_DATA_TYPE_HALF:
return TextureInterpolator<half>::interp_3d(info, x, y, z, interp);
case IMAGE_DATA_TYPE_BYTE:

View File

@@ -20,6 +20,7 @@
* simply includes this file without worry of copying actual implementation over.
*/
// clang-format off
#include "kernel/kernel_compat_cpu.h"
#ifndef KERNEL_STUB
@@ -58,6 +59,10 @@
# include "kernel/split/kernel_next_iteration_setup.h"
# include "kernel/split/kernel_indirect_subsurface.h"
# include "kernel/split/kernel_buffer_update.h"
# include "kernel/split/kernel_adaptive_stopping.h"
# include "kernel/split/kernel_adaptive_filter_x.h"
# include "kernel/split/kernel_adaptive_filter_y.h"
# include "kernel/split/kernel_adaptive_adjust_samples.h"
# endif /* __SPLIT_KERNEL__ */
#else
# define STUB_ASSERT(arch, name) \
@@ -67,6 +72,7 @@
# include "kernel/split/kernel_data_init.h"
# endif /* __SPLIT_KERNEL__ */
#endif /* KERNEL_STUB */
// clang-format on
CCL_NAMESPACE_BEGIN
@@ -204,6 +210,10 @@ DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(enqueue_inactive, uint)
DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(next_iteration_setup, uint)
DEFINE_SPLIT_KERNEL_FUNCTION(indirect_subsurface)
DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(buffer_update, uint)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_stopping)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_filter_x)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_filter_y)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_adjust_samples)
#endif /* __SPLIT_KERNEL__ */
#undef KERNEL_STUB

View File

@@ -33,6 +33,7 @@
#include "kernel/kernel_path_branched.h"
#include "kernel/kernel_bake.h"
#include "kernel/kernel_work_stealing.h"
#include "kernel/kernel_adaptive_sampling.h"
/* kernels */
extern "C" __global__ void
@@ -81,6 +82,75 @@ kernel_cuda_branched_path_trace(WorkTile *tile, uint total_work_size)
}
#endif
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_adaptive_stopping(WorkTile *tile, int sample, uint total_work_size)
{
int work_index = ccl_global_id(0);
bool thread_is_active = work_index < total_work_size;
KernelGlobals kg;
if(thread_is_active && kernel_data.film.pass_adaptive_aux_buffer) {
uint x = tile->x + work_index % tile->w;
uint y = tile->y + work_index / tile->w;
int index = tile->offset + x + y * tile->stride;
ccl_global float *buffer = tile->buffer + index * kernel_data.film.pass_stride;
kernel_do_adaptive_stopping(&kg, buffer, sample);
}
}
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_adaptive_filter_x(WorkTile *tile, int sample, uint)
{
KernelGlobals kg;
if(kernel_data.film.pass_adaptive_aux_buffer && sample > kernel_data.integrator.adaptive_min_samples) {
if(ccl_global_id(0) < tile->h) {
int y = tile->y + ccl_global_id(0);
kernel_do_adaptive_filter_x(&kg, y, tile);
}
}
}
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_adaptive_filter_y(WorkTile *tile, int sample, uint)
{
KernelGlobals kg;
if(kernel_data.film.pass_adaptive_aux_buffer && sample > kernel_data.integrator.adaptive_min_samples) {
if(ccl_global_id(0) < tile->w) {
int x = tile->x + ccl_global_id(0);
kernel_do_adaptive_filter_y(&kg, x, tile);
}
}
}
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_adaptive_scale_samples(WorkTile *tile, int start_sample, int sample, uint total_work_size)
{
if(kernel_data.film.pass_adaptive_aux_buffer) {
int work_index = ccl_global_id(0);
bool thread_is_active = work_index < total_work_size;
KernelGlobals kg;
if(thread_is_active) {
uint x = tile->x + work_index % tile->w;
uint y = tile->y + work_index / tile->w;
int index = tile->offset + x + y * tile->stride;
ccl_global float *buffer = tile->buffer + index * kernel_data.film.pass_stride;
if(buffer[kernel_data.film.pass_sample_count] < 0.0f) {
buffer[kernel_data.film.pass_sample_count] = -buffer[kernel_data.film.pass_sample_count];
float sample_multiplier = sample / max((float)start_sample + 1.0f, buffer[kernel_data.film.pass_sample_count]);
if(sample_multiplier != 1.0f) {
kernel_adaptive_post_adjust(&kg, buffer, sample_multiplier);
}
}
else {
kernel_adaptive_post_adjust(&kg, buffer, sample / (sample - 1.0f));
}
}
}
}
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)
kernel_cuda_convert_to_byte(uchar4 *rgba, float *buffer, float sample_scale, int sx, int sy, int sw, int sh, int offset, int stride)

View File

@@ -124,7 +124,7 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
CUtexObject tex = (CUtexObject)info.data;
/* float4, byte4, ushort4 and half4 */
const int texture_type = kernel_tex_type(id);
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) {
@@ -156,7 +156,7 @@ ccl_device float4 kernel_tex_image_interp_3d(
CUtexObject tex = (CUtexObject)info.data;
uint interpolation = (interp == INTERPOLATION_NONE) ? info.interpolation : interp;
const int texture_type = kernel_tex_type(id);
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 (interpolation == INTERPOLATION_CUBIC) {

View File

@@ -43,6 +43,10 @@
#include "kernel/split/kernel_next_iteration_setup.h"
#include "kernel/split/kernel_indirect_subsurface.h"
#include "kernel/split/kernel_buffer_update.h"
#include "kernel/split/kernel_adaptive_stopping.h"
#include "kernel/split/kernel_adaptive_filter_x.h"
#include "kernel/split/kernel_adaptive_filter_y.h"
#include "kernel/split/kernel_adaptive_adjust_samples.h"
#include "kernel/kernel_film.h"
@@ -121,6 +125,10 @@ DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(enqueue_inactive, uint)
DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(next_iteration_setup, uint)
DEFINE_SPLIT_KERNEL_FUNCTION(indirect_subsurface)
DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(buffer_update, uint)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_stopping)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_filter_x)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_filter_y)
DEFINE_SPLIT_KERNEL_FUNCTION(adaptive_adjust_samples)
extern "C" __global__ void
CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS)

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel/kernel_compat_opencl.h"
#include "kernel/split/kernel_split_common.h"
#include "kernel/split/kernel_adaptive_adjust_samples.h"
#define KERNEL_NAME adaptive_adjust_samples
#include "kernel/kernels/opencl/kernel_split_function.h"
#undef KERNEL_NAME

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel/kernel_compat_opencl.h"
#include "kernel/split/kernel_split_common.h"
#include "kernel/split/kernel_adaptive_filter_x.h"
#define KERNEL_NAME adaptive_filter_x
#include "kernel/kernels/opencl/kernel_split_function.h"
#undef KERNEL_NAME

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel/kernel_compat_opencl.h"
#include "kernel/split/kernel_split_common.h"
#include "kernel/split/kernel_adaptive_filter_y.h"
#define KERNEL_NAME adaptive_filter_y
#include "kernel/kernels/opencl/kernel_split_function.h"
#undef KERNEL_NAME

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2019 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel/kernel_compat_opencl.h"
#include "kernel/split/kernel_split_common.h"
#include "kernel/split/kernel_adaptive_stopping.h"
#define KERNEL_NAME adaptive_stopping
#include "kernel/kernels/opencl/kernel_split_function.h"
#undef KERNEL_NAME

View File

@@ -47,7 +47,7 @@ ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg,
int id,
int offset)
{
const int texture_type = kernel_tex_type(id);
const int texture_type = info->data_type;
/* Float4 */
if (texture_type == IMAGE_DATA_TYPE_FLOAT4) {

View File

@@ -28,3 +28,7 @@
#include "kernel/kernels/opencl/kernel_next_iteration_setup.cl"
#include "kernel/kernels/opencl/kernel_indirect_subsurface.cl"
#include "kernel/kernels/opencl/kernel_buffer_update.cl"
#include "kernel/kernels/opencl/kernel_adaptive_stopping.cl"
#include "kernel/kernels/opencl/kernel_adaptive_filter_x.cl"
#include "kernel/kernels/opencl/kernel_adaptive_filter_y.cl"
#include "kernel/kernels/opencl/kernel_adaptive_adjust_samples.cl"

View File

@@ -33,6 +33,9 @@ set(LIB
${LLVM_LIBRARY}
)
# OSL and LLVM are built without RTTI
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RTTI_DISABLE_FLAGS}")
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})

View File

@@ -36,9 +36,11 @@
#include "kernel/osl/osl_closures.h"
// clang-format off
#include "kernel/kernel_compat_cpu.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/emissive.h"
// clang-format on
CCL_NAMESPACE_BEGIN

View File

@@ -37,10 +37,12 @@
#include "kernel/kernel_compat_cpu.h"
#include "kernel/osl/osl_closures.h"
// clang-format off
#include "kernel/kernel_types.h"
#include "kernel/kernel_montecarlo.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/bsdf_diffuse_ramp.h"
// clang-format on
CCL_NAMESPACE_BEGIN

View File

@@ -37,9 +37,11 @@
#include "kernel/kernel_compat_cpu.h"
#include "kernel/osl/osl_closures.h"
// clang-format off
#include "kernel/kernel_types.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/bsdf_phong_ramp.h"
// clang-format on
CCL_NAMESPACE_BEGIN

View File

@@ -36,10 +36,12 @@
#include "kernel/osl/osl_closures.h"
// clang-format off
#include "kernel/kernel_compat_cpu.h"
#include "kernel/kernel_types.h"
#include "kernel/closure/alloc.h"
#include "kernel/closure/emissive.h"
// clang-format on
CCL_NAMESPACE_BEGIN

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