1
1

Compare commits

...

959 Commits

Author SHA1 Message Date
Julian Eisel
1fcc5adc60 Merge branch 'soc-2019-openxr' into temp-vr-draw-thread 2019-08-07 13:31:17 +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
85c843b115 Remove compiler fix for unsupported MSVC version 2019-08-07 01:55:16 +02:00
f4e27bc2c9 Fix not reported: Face selection sometimes does not work in weight, paint and texture mode. 2019-08-06 17:27:00 -03:00
00cb31de65 Cleanup: use BKE_ prefix for BKE_colortools.h 2019-08-07 03:38:01 +10:00
e2630f388d Cleanup: clang-format 2019-08-07 03:34:59 +10:00
3227b37141 Fix Dopesheet transform regressions due to rB81dc76c19cff
Functions that begin with the name `apply` closely resemble the main callback to apply.
Ref T68137
2019-08-06 14:02:29 -03:00
317033a1be Annotations: Remove Simplify option from Userprefs
This option was an old option for Grease Pencil tools and it's not logic for Annotations.

Differential Revision: http://developer.blender.org/D5426
2019-08-06 18:53:39 +02:00
467b0aa227 Fix T68320: measure tool memoryleak
It was a stupid mistake with the wrong pointer being referenced.
It was a serious problem because the memory leak was considerable.
2019-08-06 12:50:08 -03:00
edb828d0d7 DrawManager: Fixed Assertion In Workbench 2019-08-06 16:49:02 +02:00
88a872dd6e Fix T68227: Pinning the particles system data-block causes error
The 'Seed' setting is not part of the pinned data-block. When pinning,
the local variable `psys` is `None`, and this wasn't properly checked for
when drawing the 'Seed' setting.
2019-08-06 15:31:49 +02:00
6b0c97466f Keymap: add sequencer left/right select
Matches graph editor keys.

D5192 by @tintwotin
2019-08-06 22:40:34 +10:00
39f005eae8 Fix crash when opening files with missing armature libaries
In the case where the library is missing, the armature object is
replaced with an empty. This would crash the armature modifier.

Now we check if the armature object really is an armature or not.
2019-08-06 14:34:48 +02:00
dcad1eb03c Cleanup: move utf8 offset conversion into BLI_string_utf8
There isn't anything specific to text data with these functions.
2019-08-06 21:59:13 +10:00
8b2810a32f Cleanup: spelling (neighbor) 2019-08-06 21:59:13 +10:00
199c37d7e4 Fix T68291: crash snapping to both verts and edges with linked meshes
this was also happening in snapping with the measure tool

same method as in snap_mesh_polygon() (from rB59286ddcf80c) now used in
snap_mesh_edge_verts_mixed() as well...

Reviewers: mano-wii

Maniphest Tasks: T68291

Differential Revision: https://developer.blender.org/D5422
2019-08-06 13:28:20 +02:00
45ae33a952 Fix T66731: Part 3: Labels translations when tools are in 'compact' mode.
Very annoying that this whole UI thingy uses its own cooking... This is
more a quick-slap fix than a proper solution, would expect it to work in
nearly all cases though...
2019-08-06 12:18:42 +02:00
785301e5ac Annotation: Simplify only 3D annotations and reduce factor
The old factor was too much and the lines could be changed. Anyway, when use simplify the number of points is reduced and the general shape is the same but not as smooth as original stroke.

Also, the simplify is only used in 3D view.

Note: Not sure if we would have to remove this simplify option for annotations.
2019-08-06 09:06:29 +02:00
bb53d2b07a Sequencer: frame offset feature usability
- Expose the operator in the panel,
  (wasn't available in the UI at all).
- Offset frame was hard coded to a color matching the background.
  Use the current frame color with dashes instead.
- Overlay toggle had wrong name.
2019-08-06 17:05:07 +10:00
1aabb0bfcf Cleanup: redundant const usage 2019-08-06 17:05:07 +10:00
85c3e12049 Fix T66100: WorkBench Banding Issues
Color banding issues can appear, as result of the 8 bitdepth RGBA that
is used in the viewport.

This change will use `GPU_RGBA16F` for final renderings and for drawing textures. This
allows displaying HDRI textures. Vertex Colors uses `GPU_RGBA16` to resolve
color banding issues. All other modes use `GPU_RGBA8` to reduce
bandwidth and gpu memory.

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5179
2019-08-06 08:34:39 +02:00
0394f2ab30 Fix T66671: Memory Leak Material Preview
During generating of a material preview with world lighting only the
copy world was being freed. The material was removed from the main, but
was not freed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5224
2019-08-06 08:30:59 +02:00
694f9cb18c DrawManager: Fix Camera Images Interfere During Selection
When drawing the selection buffer the camera images were drawn. This
resulted in unneeded extra clicking for the user. This change will
ignore camera images during the selection.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5276
2019-08-06 08:26:43 +02:00
972c05537d Refactor Paint Overlay Opacity Panel
It is now possible to translate this panel. Due to the previous
structure the translation tools were not able to pick the strings up as
translatable strings.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5279
2019-08-06 08:20:56 +02:00
08717f4a2c Fix T67437: Vertex Colors Not Visible In SculptMode
Recently Shader parameter names for UVMaps and vertex colors were renamed.
The sculpt drawing code still used the old parameter names.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5320
2019-08-06 08:18:28 +02:00
4cdc5a12da UI: rename Border to Box Select
Missed in previous renaming commits.
2019-08-06 16:10:48 +10:00
95de738953 Fix T68283: Missing operator in graph context menu 2019-08-06 14:49:59 +10:00
dcbce4b924 Fix T6813: Dopesheet Editor: Moving keyframes by a number value doesn't work
It was a mistake to add the line `t->values_final[0] = t->values[0];`
2019-08-05 21:47:22 -03:00
Julian Eisel
fa7643bc7b Fix mistake in earlier commit, removed required call
Turns out I my compile and launch directories diverged, so I was running
an outdated executable.
2019-08-06 01:39:31 +02:00
Julian Eisel
02aca1bfb7 Merge branch 'temp-concurrent-viewport-theme' into temp-vr-draw-thread 2019-08-06 00:41:49 +02:00
cdeda1fa6c Fix T68272: Annotations segment fault when use Simplify option
This error was introduced with the array dynamic system for very long stroke.

Now, instead to use a custom code for simplify annotations, it uses the standard simplify BKE function more robust and with better results.

The factor of 0.15f has been set fixed after testing a good result value.
2019-08-05 20:52:10 +02:00
b4a325f535 Cleanup: use unsigned char for theme colors
Nearly all byte-color functions use 'uchar'
causing casts when then colors were passed in.

Declare as uchar to remove the need for casts.
2019-08-06 04:35:22 +10:00
17f299c5d1 Cleanup: quiet cast warnings in recent commit 2019-08-06 04:35:22 +10:00
ad417f73c0 New BLI Function: projmat_from_window_region
Creates a projection matrix for a small region of the viewport.

Reviewers: campbellbarton, brecht

Differential Revision: https://developer.blender.org/D5412
2019-08-05 14:04:43 -03:00
Julian Eisel
43d4ac5db6 Cleanup: Remove unnecessary call & var 2019-08-05 19:02:08 +02:00
0c4ee9e13d Fix T67665 "Affect Alpha" in Texture Paint mode doesn't work as expected
The "alpha lock" check was missing for the smear and soften brush.
Added checks to make sure that the alpha values are kept the same.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5416
2019-08-05 18:50:34 +02:00
9fe592ab8f Fix (unreported) transfer mesh data operator not enabling autosmooth.
When we transfer custom normals and allow for data creation, we should
also enable autosmooth on destination meshes.
2019-08-05 18:44:10 +02:00
Julian Eisel
834b0b8262 Share code of new functions in resources.c 2019-08-05 18:38:23 +02:00
64b092974c Cleanup/windows: Remove 32 bit support from make.bat helper script
This change removes 32 bit support from the helper make.bat scripts
as we are dropping official 32 bit support, you can still build for
32 bit by configuring your build yourself using cmake and pointing
the LIBDIR cmake variable to your own 32 bit library folder.
2019-08-05 10:31:51 -06:00
Julian Eisel
d20393c8bd Cover all UI_GetTheme calls in draw manager
Previous commit wasn't nearly covering all of them.
2019-08-05 18:25:04 +02:00
592759e3d6 Fix T68211: Transfer Mesh Data with Custom Normal crash when Auto Smooth is enabled.
Code in modifier stack ensuring requested CDLayers are provided was not
working very well for polynors in several cases:
* We cannot share the orig mesh if we have to generate pnors/lnors;
* Generating pnors without lnors was not possible.
2019-08-05 18:07:49 +02:00
Julian Eisel
6a46860220 Merge branch 'temp-concurrent-viewport-theme' into temp-vr-draw-thread 2019-08-05 16:38:47 +02:00
52f83011c8 Fix T67259 : Auto depth not working with multires in sculpt mode
Basically the solution is to call `DRW_shgroup_call_sculpt` when `BKE_sculptsession_use_pbvh_draw(...)` is true.

Ref T67259

Reviewers: fclem, jbakker, brecht

Reviewed By: fclem, brecht

Maniphest Tasks: T67259

Differential Revision: https://developer.blender.org/D5396
2019-08-05 11:04:40 -03:00
58229b191a Fix T68145: Bone Rotate Individual Axes fail.
Rotation matrix would not get updated every time it would need to, after
own changes to handle 'big' rotations from keyboard input (rBcee484a4c51a3d2).
2019-08-05 15:47:28 +02:00
8f1a55831c Cycles: Fix wrong number of threads on multi-socket machines
The issue was caused by a limitation of GetNumaNodeProcessorMask():
on systems with more than 64 processors, this parameter is set to the
processor mask for the node only if the node is in the same processor
group as the calling thread. Otherwise, the parameter is set to zero.

Patch from Max Dmitrichenko, thanks!
2019-08-05 15:33:47 +02:00
afff94f09f Build: add ninja target to make wrapper
To use the ninja build tool which is typically faster than make, especially
for quick rebuilds.
2019-08-05 15:25:36 +02:00
2d60a54649 Build: add config for developers
This has faster builds, error checks and tests. The number of cmake options
for this type of thing has grown over the years and it's convenient to be
able to point new developers to a single target.

Previously the combination of all these options did not work correctly, now
all tests should pass.

The easiest way to use this is with the make wrapper, for example:
make full developer debug

Or set it manually with CMake:
cmake -C ../blender/build_files/cmake/config/blender_developer.cmake .

Differential Revision: https://developer.blender.org/D5149
2019-08-05 15:25:36 +02:00
47bf754de4 Build: disable address sanitizer for Cycles optimized kernels with GCC
It's extremely slow to compile and run, so just disable it unless
WITH_CYCLES_KERNEL_ASAN is manually enabled. For Clang it's always
enabled since that appears to work ok.

This also limits the -fno-sanitize=vptr flag to the Cycles kernel, as it
was added specifically to work around an issue there.

Differential Revision: https://developer.blender.org/D5404
2019-08-05 15:23:57 +02:00
916e51a407 PyRNA: support separators in enum-items lists
Resolves T68260
2019-08-05 23:10:44 +10:00
fa1d470692 GTest: test cases for polyfill2d bug T67109 2019-08-05 22:44:16 +10:00
e31a1c6fd3 Fix T67109: n-gon tessellation error with co-linear edges
Improve the area calculation method for better precision,
so faces offset from the center don't have a less precise area.
2019-08-05 22:43:23 +10:00
f9cf815160 ED_view3D: Remove and replace ED_view3d_select_id_read
It is very similar to `ED_view3d_select_id_read_rect`.
2019-08-05 09:30:55 -03:00
38d7e14dc8 Fix (unreported0 bad usage of do_versions_find_region() in versionning code.
When NULL pointer can be a valid return value, one has to use
`do_versions_find_region_or_null()` instead...

Fixes asserts as reported in rBa2fe386153e.
2019-08-05 14:24:44 +02:00
Julian Eisel
34506a1276 Merge branch 'soc-2019-openxr' into temp-vr-draw-thread 2019-08-05 12:53:18 +02:00
Julian Eisel
5274c5cce6 Merge branch 'master' into soc-2019-openxr 2019-08-05 12:52:57 +02:00
Julian Eisel
eee5ba5cc3 Merge branch 'master' into temp-concurrent-viewport-theme 2019-08-05 12:50:15 +02:00
Julian Eisel
f5c023dfd7 Avoid change to global theme state in draw-manager
Changing the global state would obviously cause issues for async
execution. This is the simplest solution for a simple problem.

Reviewers: fclem, brecht

Differential Revision: https://developer.blender.org/D5413
2019-08-05 11:55:29 +02:00
9620b8f6bb Cycles: Fix compilation on 32bit Linux with GCC-9
We don't use explicit SIMD flags on 32bit, so trying to use
intrinsics was causing issues.
2019-08-05 11:47:47 +02:00
94dce826a9 Text: only un-comment blocks which are completely commented
It's common to select a block of code and comment it
which may already contains some comments.

Now only un-comment blocks which are completely commented
(ignoring white-space).

Makes toggle comments behave more usefully, resolves T68060.
2019-08-05 15:53:27 +10:00
91fa07dfb1 Text: merge toggle comments into a single operator
This allows users to map comment/un-comment to be mapped to keys.
2019-08-05 13:54:27 +10:00
8b4f00269c UI: rename rotate to orbit for viewport sensitivity
Matches names of related preferences.
2019-08-05 13:15:36 +10:00
cd02fe5d70 Cleanup: remove underscore prefix for used vars
Also remove unused vars.
2019-08-05 12:47:55 +10:00
f69ea92599 Cleanup: add braces 2019-08-05 12:46:58 +10:00
9fbf522dd8 Cleanup: Fix eeve_lut arrays being duplicated in blender binary.
Both eevee_materials.c and workbench_deferred.c include eeve_lut.h which has its arrays marked as static leading to the blue_noise array being embedded into our binary twice.

This change takes the arrays out of the header and properly marks them as const since they are lookup tables and should not be written to.

Reviewers: fclem, brecht

Differential Revision: https://developer.blender.org/D5346
2019-08-04 14:32:53 -06:00
418fdee5dc Cleanup: Mark large arrays of of constant data as const.
For background information see D5345

Reviewers: brecht, sergey

Differential Revision: https://developer.blender.org/D5345
2019-08-04 14:24:29 -06:00
37cef86f0d Fix: msgfmt add support for cr-lf style line endings
linux did not recognize cr as a valid character.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5337
2019-08-04 11:46:00 -06:00
Your Name
f08662d3ed Sculpting: Remove Show Diffuse Color Option
This should have been removed in 2.80 as the functionality was removed.
This feature now does not do anything and can be removed.

Differential Revision: https://developer.blender.org/D5411
2019-08-04 11:53:48 -04:00
47335b4e61 Add a new Copy As Driver context menu option for properties.
It is a very common need to create drivers that set the value of
a property to the value of some other property, but it currently
requires multiple actions: Copy Data Path on the input property,
adding a driver to the output property, selecting the input ID
reference, and pasting the path.

This adds a new Copy As Driver context menu option, which creates
a complete driver in the clipboard that reads the current property,
so all that remains is to paste it to the output property. It is
also possible to paste just the new driver variable into an existing
driver to combine multiple inputs.

Reviewers: brecht, billreynish

Differential Revision: https://developer.blender.org/D5382
2019-08-04 13:58:15 +03:00
a2fe386153 Text Editor UI
Tweak Text Editor to fit better with the rest of Blender 2.8:

  - Move sidebar to the right
  - Add proper context menu
  - Move view toggles to the View menu
  - Change the indentation option to be an enum between spaces and tabs
  - Several layout tweaks

Patch by @tintwotin / Peter Fog with additional tweaks by me.

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

Reviewers: Brecht, Campbell
2019-08-04 12:51:28 +02:00
c0aada58c9 Tweak Brush Gradient UI
Gradient and Color are mutually exclusive, so we now communicate this in the UI much more clearly

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

Reviewers: brechrt
2019-08-04 12:37:22 +02:00
dd3cdf6f1e Fix T68202: GPencil Set Origin do not refresh until object is moved 2019-08-04 10:21:02 +02:00
18540f41d7 Cleanup: improve comments 2019-08-04 12:53:06 +10:00
2425401a59 Cleanup: spelling 2019-08-04 12:51:44 +10:00
Your Name
85a7cebd53 UI: Fix Small inconsistency in particle emission
This property was being called something
else depending on the distribution type
2019-08-03 16:22:04 -04:00
edcefb739a Cleanup: Fix build error with msvc
math.h does not define M_PI on windows, needs BLI_math_base.h to get them.

thanks to @quollism on chat for spotting it.
2019-08-03 10:47:35 -06:00
e82b7f1527 3D View: preferences for rotate sensitivity
Added because the current default is too fast
for painting with tablets, see D5385.

Turntable and trackball have different settings because
turn-table uses an angle-per-pixel, where as trackball
values are relative to the view-port size so a scale is used.

The sensitivity is scaled by the pixel size so hi-dpi views don't rotate faster.
2019-08-04 01:31:25 +10:00
27aef8b551 3D View: aspect correct trackball rotation
Hard coded aspect was used, doubling horizontal input
however this caused sliding for views which didn't match this aspect.

Calculate the aspect based on the view bounds instead.
2019-08-04 01:19:22 +10:00
7f8d620e20 Cleanup: trackball direction calculation
Remove z axis flipping, only needed because x & y were flipped.
2019-08-04 01:18:23 +10:00
5e5cf9ea9f Fix T68161: typo in ui_text of RNA scene.objects 2019-08-03 12:22:23 +02:00
Julian Eisel
06e0ea0c16 Remove unnecessary calls 2019-08-03 01:51:08 +02:00
Julian Eisel
41ed61b273 Merge branch 'temp-gpu-context-matrix' into temp-vr-draw-thread
Solves drawing issues while drawing the VR session.
2019-08-03 00:50:55 +02:00
Julian Eisel
88b79cacb2 Merge branch 'soc-2019-openxr' into temp-vr-draw-thread 2019-08-02 23:37:31 +02:00
Julian Eisel
0d70afed19 Merge branch 'master' into soc-2019-openxr 2019-08-02 23:35:40 +02:00
3232fc335d Deps: Fix build error with theora on windows. 2019-08-02 13:29:29 -06:00
6de4123ebd GPencil: Replace Separate menu by operator Enum to display assigned key
As the operator was using a menu, the keymap was not displayed. Now, the operator is used directly and don't need the menu.
2019-08-02 21:24:00 +02:00
f7d5941faa Fix freestyle tests failing when using WITH_PYTHON_SAFETY 2019-08-02 19:53:59 +02:00
15e224dca3 Build: disable RTTI for the entire Cycles module, not only the kernel
The partial disabling was causing issues with Clang and ASAN, and it seems we
don't need to restrict it to the kernel anymore now that we are no longer using
boost directly.
2019-08-02 19:03:57 +02:00
a744fedc85 Fix T68129: Bridge edge loops fails on small edge loops 2019-08-03 02:52:30 +10:00
26d5fae284 Fix T68135: Do not return NULL/None when converting an object to a mesh.
Does not make sense in the use-cases of that function, especially since
we don't know whether it is actually due to an error, or some glitch
(like an empty curve).

Think we always want to get a mesh when using either operator
conversion, or the `bpy.data.meshes.new_from_object` function.

Note that an assert was also added to ensure we do try to convert from a
valid 'geometry' object type.
2019-08-02 18:24:59 +02:00
Julian Eisel
c7653fad67 Manage GPU_matrix stacks per GPUContext
Previous global GPU_matrix stacks weren't safe for access from multiple
threads. With this, GPU_matrix stacks are concurrent in combination
with GPUContext.
Needed for VR session drawing on a separate thread.

Reviewers: fclem, brecht

Differential Revision: https://developer.blender.org/D5405
2019-08-02 18:05:40 +02:00
dda0de4a3d Fix address sanitizer overflow warnings for bit manipulation functions
Perform with unsigned int instead of signed int.

Differential Revision: https://developer.blender.org/D5402
2019-08-02 17:25:25 +02:00
256c412b31 Tests: also don't fail on memory leaks for gtests 2019-08-02 17:25:25 +02:00
5ba070ce53 DRW: Select Engine: Create DRWPass only when context requests it 2019-08-02 12:14:12 -03:00
454daf9b6b Upgrade Python from 3.7.0 to 3.7.4 2019-08-02 16:49:26 +02:00
53ae209d25 make deps: avoid running pdflatex as part of building Theora
On machines with pdflatex installed, this is run to build Theora.pdf.
Unfortunately this process breaks, at least on my Ubuntu 18.04 LTS
system. By setting `HAVE_PDFLATEX=no` (or any other value that is not
"yes") this can be avoided. I don't think that it's important to have
this PDF file built anyway, as it's not a dependency of Blender itself.
2019-08-02 16:49:26 +02:00
369ffbd911 Fix T68073: Wacom Intuos 5S no pen pressure on Wayland
The issue is that wayland seems to impose a generic device naming scheme
when using Xwayland For example any table stylus will show up with the
following naming convention: xwayland-stylus:33

For this to work in blender, I had to modify how the identifier string
is extracted. I also renamed the two char pointers in the search
algorithm to be more logical.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5401
2019-08-02 16:42:24 +02:00
455a1e210b Fix T68021: GPencil After using eraser when draw primitives, next primitive has missing handles
The problem was related to wrong Brush. After using the Eraser or Fill, the default brush was not the drawing one, so the handles were missing.

Now, the operator force the drawing brush.

Reviewer: @campbellbarton
Differential Revision: http://developer.blender.org/D5403
2019-08-02 16:25:49 +02:00
9198ff4306 Cleanup/Win: Fix build folder name if no target is set
When you call make.bat without a target the build folder name would
have a double underscore in it which looked odd.
2019-08-02 08:25:18 -06:00
630747ca66 Fix T66731: Translated texts remain original english (Tools' tips part).
This should fix all remaining issues reported in T66731 I think.
2019-08-02 16:20:06 +02:00
820522d514 Fix (unreported) missing/broken translations in Text space.
As a reminder, no new fancy python string formatting is just
not working (tm) with i18n translations system...
2019-08-02 16:20:06 +02:00
15b848ef60 Fix most (if not all) untranslated Panel-labels reported in T66731. 2019-08-02 16:20:06 +02:00
8936479f76 Cleanup/Win: Remove unused game engine variables in build helper scripts 2019-08-02 08:19:04 -06:00
e5a5d28c3e Fix T67670: Sculpt doesn't mark the file as modified
Was also an issue for texture & paint curve.
2019-08-03 00:12:55 +10:00
05226e1512 Fix T68122: Settings for Select root and Select tip in particle edit mode are missing
Do not hide the redo window for root/tip select anymore.
2019-08-02 16:03:26 +02:00
cb1b7e8a48 Cleanup: clang format
Strange, this was not applied automatically.
2019-08-02 11:00:49 -03:00
8fbe18dc8d DRW: Select Engine: Set uniform only once per ShadowGroup 2019-08-02 10:48:16 -03:00
ae7137cdf8 View3D Mesh Selection: Specify select_mode directly for Circle, Lasso and Box selection
No functional changes.
2019-08-02 10:48:16 -03:00
5f4e99b7a2 Fix broken add_python_test after recent changes 2019-08-02 15:45:01 +02:00
ab3de09591 Fix T68112: Align View on object add is broken
No need to use BKE_object_where_is_calc() in this case: there is no
parenting or constraint system involved on object add.

So simply use direct object matrix calculation from it's local
transform. No need in dependency graph either in this case.
2019-08-02 15:15:41 +02:00
5cf6d7e2b0 Fix edge selection ignoring clipping in wire-frame display 2019-08-02 23:01:19 +10:00
d8c6105366 Fix ignored window clipping test in foreach edge function 2019-08-02 22:54:17 +10:00
38ff5064b3 Tests: don't fail on leaks detected by leak sanitizer
These often happen in external libraries that we can't fix. The leaks are
still printed in the logs.
2019-08-02 14:42:25 +02:00
f4b0900856 Cleanup: refactor tests executing Blender to use add_blender_test function 2019-08-02 14:42:25 +02:00
22f17551e5 Fix scene units test failure after recent changes 2019-08-02 14:42:25 +02:00
Julian Eisel
7a711e133c Keep a single OpenGL/GPU context alive on the drawing thread
Avoids expensive context switches.
2019-08-02 13:45:11 +02:00
b5807be437 Fix T68126: Cycles not enabled with factory settings 2019-08-02 13:04:10 +02:00
0c7a4c74d3 Cleanup: clang-format, also typo fix. 2019-08-02 20:04:45 +10:00
67e5422970 Fix text editor undo sync when mixed with other undo systems
Undo rewrite broke test_undo.text_editor_edit_mode_mix.

Relatively harmless since it's only out of sync by one action.
2019-08-02 19:48:08 +10:00
8949dd6cb6 Cleanup: correct name for scene frame conversion
Thanks to @sybren for pointing out issue from 299ff91ea1
2019-08-02 19:30:38 +10:00
a89ecd9617 Cleanup: GPencil dissolve operator now uses GP_EDITABLE_STROKES_BEGIN macro
This reduces the number of loops
2019-08-02 11:29:12 +02:00
cb6e3e82b0 GPencil: Make GP_EDITABLE_STROKES_BEGIN macro safe when stroke is removed
If the macro was used in a loop where the stroke was removed, the macro failed.
2019-08-02 11:29:11 +02:00
eb2a078f4d GPencil: New function to dissolve points in stroke
This function will be used for new operators.
2019-08-02 11:29:11 +02:00
b54528fa1e BrightContrast not working correctly with negative contrast
followup to rB8dd95abb2ff9 (which fixed this for the Compositor node),
turns out this was also wrong for the VSE modifier and in vertex color
operator.

- also adjust min/max for VSE modifier
- also guard against division by zero

Reviewers: brecht

Maniphest Tasks: T67808

Differential Revision: https://developer.blender.org/D5398
2019-08-02 10:09:29 +02:00
31da3936b4 GPencil: Add Frame parameter to modifier deformStroke Callback
This commit adds the frame to deformStroke Callback as a preparation for new modifiers that will need this variable.

Actually, the existing modifiers are not using the frame.
2019-08-02 09:50:33 +02:00
a897c8e342 Fix unreported: length measure displayed on the "Sequence Slide" operator panel 2019-08-02 01:49:49 -03:00
2074d850ee Docs: correct comment for PROP_THICK_WRAP 2019-08-02 14:32:17 +10:00
81dc76c19c Fix T63570: Proportional editing resets scaling along Y and Z axis on mouse wheel
`applyResize(...)` considers that `t->values` always represents a `ratio`.
But this is only `true` with the `MOUSEMOVE` event.
The solution proposed is to never change `t->values`.
The result of the final transformation is now written to `t->values_final`.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D5212
2019-08-02 01:15:33 -03:00
14b2c41216 Cleanup: doxy sections 2019-08-02 12:30:57 +10:00
c060a835bb Fix unreported: Selection of mesh_cage element occluded by the mesh_cage itself.
The right thing is to be occluded by the visible mesh (in the case with modifiers).
2019-08-01 23:19:00 -03:00
58a2b2dd7e Cleanup: spelling 2019-08-02 12:05:13 +10:00
9be956c326 Cleanup: unused variable 2019-08-02 12:05:13 +10:00
53a0916636 DRW: Select Engine: Add a utility to detect select_node 2019-08-01 23:00:34 -03:00
65b6d4a34d Edit Mesh Select: Remove redundant and deprecated FAKE_SELECT_MODE_... 2019-08-01 23:00:34 -03:00
eff91da4df DRW: Select Engine: Use specified offset.
Due to current uses, this does not bring functional changes.
2019-08-01 23:00:34 -03:00
abebb27644 DRW: Select Engine: remove unnecessary DRWShadingGroup creations 2019-08-01 23:00:34 -03:00
ec131e2d53 Object Mode: add back non '_ex' versions of mode-switching functions
While these aren't currently used, its strange to have
extended versions of a function without the non-extended versions
it also avoids callers needing to add them back if they need -
or duplicating the same boiler plate when calling the '_ex' versions.

Reverts 11da3b132a, 11da3b132a, adds depsgraph argument
so the caller is responsible for the evaluation state.
2019-08-02 11:44:01 +10:00
7a47c0031f Cleanup: quiet maybe-unused warnings
While harmless, use flow control that always sets the variable.
2019-08-02 11:44:01 +10:00
7f9b1fe73c Cleanup: quiet maybe-unused warning
While harmless, use flow control that always sets the variable.
2019-08-02 11:21:22 +10:00
cfaef2db30 Cleanup: padding in windowmanager 2019-08-01 18:32:12 -06:00
Julian Eisel
7922bd26a2 Fix objects not visible
Object.base_flag was not updated correctly so objects were hidden.
2019-08-02 02:24:36 +02:00
Julian Eisel
9b6ce439bb Fix race condition in state changes + related cleanup + add assert 2019-08-02 00:38:22 +02:00
066a7173c0 Keymap: add fractional zoom shortcuts for sequencer preview
Matches shortcuts from the image editor.

D5341 by @tintwotin
2019-08-02 08:36:03 +10:00
Julian Eisel
11975d5d95 Merge branch 'soc-2019-openxr' into temp-vr-draw-thread 2019-08-01 23:23:59 +02:00
Julian Eisel
03b09dbe32 Fix compile error after merge and warning 2019-08-01 21:53:57 +02:00
f66b5edf98 VSE: Use sequencer boundbox for view_all operator
Fix T67279
Fix T59954

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5368
2019-08-01 12:43:46 -07:00
2c4dfbb002 Fix T66028: Move sequence, movieclip and text editor progressbars to status bar
Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5219
2019-08-01 12:42:01 -07:00
Julian Eisel
f04a5ad1e4 Merge branch 'master' into soc-2019-openxr 2019-08-01 21:27:08 +02:00
aa0322524e GPU: more complete coverage of drivers for Intel shader compilation workaround 2019-08-01 21:11:28 +02:00
80123efc5f Fix T67939: GPencil Noise modifier wrong random calculation
There were several problems in the old random calculation:

* Different result in the viewport and render.
* Noise "pop" in some frames. 
* Random number was calculated every time the file was opened, so get different results.

Now, instead to calculate the random numbers when n number of frames changed, the random values are calculated using a unique seed by stroke.

Also, a new Seed parameter has been added and this adds more control in the noise generated. This value can be animated and get more variations.

Differential Revision: http://developer.blender.org/D5393
2019-08-01 18:07:57 +02:00
49b2162309 Cleanup: remove unnecessary include 2019-08-01 11:31:25 -03:00
895201808c Fix T66040: Make Data Transfer' Mix Factor multiply with vgroup weights when given, instead of ignoring it.
Brings behavior of those options in line with the VGroup editing
modifiers ones e.g.
2019-08-01 16:01:50 +02:00
21c039f6ef Alembic: fix heap-use-after-free error
The mesh can be freed by BKE_mesh_nomain_to_mesh(), so we need to get
the `ME_AUTOSMOOTH` flag before that call, and not after.
2019-08-01 15:14:57 +02:00
2741992f66 Fix T61935: load camera transforms from Alembic files written by Meshroom
Meshroom writes two hierarchies to Alembic, one rooted at
`/mvgRoot/mvgCameras` and the other at `/mvgRoot/mvgCamerasUndefined`.
These paths have no schema definition, and thus are ignored by Blender.
The cameras themselves have those schemaless paths as parent, and have
their transforms marked as "inherited", e.g. relative to their parent.
As these cameras have no valid parent, there is no Blender object to use
to convert their local matrices to world matrices, and Blender just
decided to reset them to the unit matrix.

Now "inherited" transforms without a parent in Blender are interpreted
as world transforms. Reparenting those objects to a Blender object will
re-interpret the transforms as local to the parent again.
2019-08-01 14:54:22 +02:00
08a6321501 FFmpeg pixel format conversion improvements
FFmpeg expects Blender to feed it pixels in the output pixel format. If
the output pixel format is different than Blender's RGBA, a conversion
is needed (via FFmpeg's `sws_scale()` function). There were a few issues
with this conversion (and surrounding code) that are fixed in this
commit:

- When conversion was necessary a temporary buffer was allocated and
  deallocated for every frame. This is now allocated once and re-used.
- Copying data to the buffer was done byte-for-byte. On little-endian
  machines it is now done line-by-line using `memcpy` for a little speedup.
- The decision whether pixel format conversion is necessary is now
  correctly done based on the pixel format Blender is actually using.
- The pixel format of the buffer sent to FFmpeg is no longer hard-coded
  incorrectly to a fixed pixel format, but uses the actual output pixel
  format. This is fixes T53058 properly, making RGB QTRLE export possible.
- I added some comments to make it clear which pixel format is referred
  to (either Blender's internal format or the FFmpeg output format).

Combined these improvements not only correct a bug (T53058) but also
results in approximately 5% speed improvement (tested with a 117-frame
shot from Spring, loaded as PNGs in the VSE, encoding to h.264 with
preset 'realtime').

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D5174
2019-08-01 13:37:48 +02:00
eb7fe7546c Fix T68055: mesh selection issues, once blend is loaded second time in a Blender session
The depth attachment of the framebuffer was missing.
2019-08-01 08:30:57 -03:00
6786c336bd Added FFmpeg preset for WebM + VP9 video + Opus audio
This is a standard combination (VP9 video, Opus audio, in WebM container),
so it's nice to have as a preset.
2019-08-01 12:53:11 +02:00
4cbcbacc6a I18n messages extraction: do not report multi-lines messages anymore.
Those are now supported for tooltips.
2019-08-01 12:52:52 +02:00
4b37abd61f Cleanup a bit i18n message extraction code. 2019-08-01 12:52:52 +02:00
5fde4494f6 Keymap: use Ctrl-/ to toggle comments
Consistent with many code editors, see: D5175
2019-08-01 20:32:25 +10:00
433eb3f35d Text: toggle comment operator 2019-08-01 20:31:57 +10:00
3a47fbfac5 Cleanup: quiet gcc warning 'alloc-size-larger-than' 2019-08-01 20:28:39 +10:00
7c5838cfd6 Cleanup: use doxy sections for text operators 2019-08-01 19:27:59 +10:00
765ed6ffb9 Fix T68036: VSE: 'Remove Gaps' causes audio to go out of sync
Reviewers: sergey

Maniphest Tasks: T68036

Differential Revision: https://developer.blender.org/D5391
2019-08-01 11:22:46 +02:00
eb0902243e Linux: resolve issue compiling on mint 18.3
size_t wasn't declared. While this could be resolved differently,
convention is to include BKE after BLI.
2019-08-01 19:17:22 +10:00
b5b0804c5a Cleanup: use _ex suffix instead of _ext
Convention is to use ex, not ext for extended
versions of a functions.
2019-08-01 18:39:21 +10:00
502c2c233d Cleanup: misc spelling fixes in variable names & defines
T68045 by @luzpaz
2019-08-01 17:35:59 +10:00
46c22f33b2 Cleanup: remove redundant LMB select default. 2019-08-01 17:23:58 +10:00
d1848b80f1 Fix error setting the user preferences
User preferences from the startup.blend was still being used,
fixing this exposed missing theme initialization, now fixed.
2019-08-01 17:23:41 +10:00
036312ecff Fix error de-duplicating BLI_file_read functions
Own error in recent code de-duplication: a345f56ce3
causing issues on Windows.

Flipped argument for reading the exact size.
2019-08-01 16:14:54 +10:00
760dbd1cbf Cleanup: misc spelling fixes
T68035 by @luzpaz
2019-08-01 14:02:41 +10:00
135413e324 Cleanup/msvc: Remove math.h from creator_signals.c
Was never needed, looks like it was copy/pasted from creator.c

spotted by @campbellbarton
2019-07-31 21:36:52 -06:00
fc982c102b Cleanup: Remove FMA3 Disable for msvc
We no longer build with or support msvc2013, so this hack can be removed.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5298
2019-07-31 20:18:44 -06:00
421280a3f7 Cleanup: remove unused member 2019-07-31 22:46:41 -03:00
2b99faed52 Cleanup: move defaults into U_default struct 2019-08-01 10:03:20 +10: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
1ec1797d35 Cleanup: remove unused compute-id from preferences 2019-08-01 09:08:43 +10:00
059d61ae9d Cleanup: use braces, unused variable, unused enum 2019-08-01 09:03:50 +10: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
d8fb63661b Fix T67951: Bone selection is broken on some Intel GPUs
The problem is that the `glDrawArraysInstancedBaseInstance` is ignoring the last parameter.
The solution is to indicate that `GLEW_ARB_base_instance` is not supported in these cases.

Reviewers: fclem, brecht, jbakker

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5383
2019-07-31 16:36:18 -03:00
ea3690e329 Fix several undefined-behaviour-sanitizer warnings
Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D4222
2019-07-31 12:24:34 -07:00
77d7cc9ba7 UI: Correct Spacing for Short Unit Names
This adds a space between a value and its short unit name except for foot, inch, degree, arcminute, arcsecond

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

Reviewed by Brecht Van Lommel
2019-07-31 12:17:33 -07:00
a2f357edc2 Add operator for removing unused material slots
Reviewers: campbellbarton, brecht

Reviewed By: brecht

Subscribers: brecht

Differential Revision: https://developer.blender.org/D4991
2019-07-31 12:08:18 -07:00
feed46c4ae Merge per-shader SVM nodes in the main update thread to avoid locking and resizing overhead
In a test file containing 1300 copies of the same shader, this reduces shader update time from 3.1 sec to 0.05 sec.

Thanks to @swerner for noticing this issue.

Reviewers: brecht, sergey, swerner

Subscribers: swerner

Differential Revision: https://developer.blender.org/D5376
2019-07-31 12:03:45 -07:00
c72f6b713f Fix T66785: Blender Menu As Text When Main Menu Collapsed
This makes the blender logo menu appear as text if 'Show Menus' is off

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

Reviewed by Brecht Van Lommel
2019-07-31 11:38:55 -07:00
881675dff1 Clarify in FloatProperty generated docs: single precision floats.
At least one script writer was upset that this was not specified,
as it is different from "floating point" in Python.
Also, docstring for hard and soft min and max for FloatProperty
was wrong, using sys.float_info.min and sys.float_info.max.
2019-07-31 14:01:42 -04:00
f7c13f2d76 Revert "UI: remove checks for other popovers when switching menu"
This reverts commit 7761657129.

This commit broke overlapping popovers. For example in the color
management tab it would be impossible to select and of the popover
alternatives as it would switch to the menu button under the cursor.
2019-07-31 19:16:47 +02:00
81d4cf5f5a Fix build error after recent cleanup 2019-07-31 18:57:55 +02:00
6bda1fbd2e Cleanup: typo in parameter name in function declarations. 2019-07-31 18:47:26 +02:00
Habib Gahbiche
ffda674893 Fix: test object_modifier_array is passing when it shouldn't.
From D5253.
2019-07-31 18:31:15 +02:00
4c12764a7f Fix negative boolean
Was a nice looking invention, but is obviously wrong.

Is likely no function changes, since -false is like -0
which is 0 and which false. And -true is like -<non-zero> which
is non-zero as well.

Spotted by Sybren, thanks!
2019-07-31 18:21:08 +02:00
bcda8cc89b Fix T65837: "Zoom Axis" is not working on the node editor
We would not take into account the user "Zoom Axis" setting in certain
2D space viewports.  In addition to this, the "Scale Zoom" didn't work
consistently in these spaces either.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5132
2019-07-31 18:16:37 +02:00
0516d49d0c Fix T63921: Unable to use confirm on release for keyboard shortcuts
The first issue was that we were still working around a Xorg bug that
has been solved since a very long time:

https://bugs.freedesktop.org/show_bug.cgi?id=22515

The second issue was that the global "confirm on release for mouse
clicks" was used for keyboard shortcuts as well.
2019-07-31 18:01:28 +02:00
e34587922c Cleanup: remove unused boost code 2019-07-31 17:52:07 +02:00
92a3995c6d Fix T67999: calling obj.data.materials.clear() crashes Blender
The `BKE_material_clear_id()` didn't call `test_all_objects_materials()`,
which caused the object and mesh material slot count to go out of sync.
2019-07-31 17:18:21 +02:00
3566b81c8b Refactor access to dependency graph
This change ensures that operators which needs access to evaluated data
first makes sure there is a dependency graph.

Other accesses to the dependency graph made it more explicit about
whether they just need a valid dependency graph pointer or whether they
expect the graph to be already evaluated.

This replaces OPTYPE_USE_EVAL_DATA which is now removed.

Some general rules about usage of accessors:

- Drawing is expected to happen from a fully evaluated dependency graph.
  There is now a function to access it, which will in the future control
  that dependency graph is actually evaluated.

  This check is not yet done because there are some things to be taken
  care about first: for example, post-update hooks might leave scene in
  a state where something is still tagged for update.

- All operators which needs to access evaluated state must use
  CTX_data_ensure_evaluated_depsgraph().

  This function replaces OPTYPE_USE_EVAL_DATA.

  The call is generally to be done in the very beginning of the
  operator, prior other logic (unless this is some comprehensive
  operator which might or might not need access to an evaluated state).

  This call is never to be used from a loop.

  If some utility function requires evaluated state of dependency graph
  the graph is to be passed as an explicit argument. This way it is
  clear that no evaluation happens in a loop or something like this.

- All cases which needs to know dependency graph pointer, but which
  doesn't want to actually evaluate it can use old-style function
  CTX_data_depsgraph_pointer(), assuming that underlying code will
  ensure dependency graph is evaluated prior to accessing it.

- The new functions are replacing OPTYPE_USE_EVAL_DATA, so now it is
  explicit and local about where dependency graph is being ensured.

This commit also contains some fixes of wrong usage of evaluation
functions on original objects. Ideally should be split out, but in
reality with all the APIs being renamed is quite tricky.

Fixes T67454: Blender crash on rapid undo and select

Speculation here is that sometimes undo and selection operators are
sometimes handled in the same event loop iteration, which leaves
non-evaluated dependency graph.

Fixes T67973: Crash on Fix Deforms operator
Fixes T67902: Crash when undo a loop cut

Reviewers: brecht

Reviewed By: brecht

Subscribers: lichtwerk

Maniphest Tasks: T67454

Differential Revision: https://developer.blender.org/D5343
2019-07-31 16:55:15 +02:00
f5f3003874 Fix: build error with MSVC
Reviewed By: Brecht

Differential Revision: https://developer.blender.org/D5381
2019-07-31 08:45:41 -06:00
0b2cb96725 Depsgraph: Fix wrong check for need-to-be-evaluated
Was missing since 1693a5efe9.
2019-07-31 16:40:10 +02:00
96843ae85c Fix T67883: Time Remapping doesn't work
Was caused by 1693a5efe9.
2019-07-31 16:40:10 +02:00
bc42092a7d Fix T67597: Texture painting: Texture slots that correspond to nodes inside node_groups don't remain active
Unlike `fill_texpaint_slots_recursive`, `rna_Material_active_paint_texture_index_update` did not search for texture nodes that are inside node groups.

Reviewers: sergey, psy-fi, zeddb, brecht

Subscribers: brecht

Differential Revision: https://developer.blender.org/D5338
2019-07-31 11:39:30 -03:00
8dd95abb2f Fix T67808: Bright/Contrast node wrong for negative contrast
strange nobody noticed since 2012...

thx @jenkm for spotting

Reviewers: brecht

Subscribers: jenkm

Maniphest Tasks: T67808

Differential Revision: https://developer.blender.org/D5378
2019-07-31 16:29:51 +02:00
Alessio Monti di Sopra
200c9f37d6 Fix T67573: Missing offset in marker names on current frame
Differential Revision: https://developer.blender.org/D5333
2019-07-31 16:18:10 +02:00
fb03a86b1b Have CMake be more strict when optional x11 libraries are missing but enabled
Previously cmake would silently disable features that depended on
certain x11 libraries if they were not found. Now we instead error out
and inform the user that these are missing but optional.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5380
2019-07-31 16:18:17 +02:00
b0531227d4 Fix T68001: Rotating vertices on the UV map by a fixed number immediately crashes Blender.
Spaghetti Transform code can use same code for different kind of data.
The 'stepped rotation' process is actually only useful/doable in a few
cases (when we do have some real place to store rotation value, and we
are using Eulers).
2019-07-31 16:14:34 +02:00
03be31e817 Cleanup: Remove unused function 2019-07-31 15:42:42 +02:00
4328b56980 Fix T66031: Text Material Change broken.
font_to_curve code was not handling properly the case where it has nop
object to check for mat indices validity. Check should just not happen
then, not reset mat indices of chars to default 0 value.
2019-07-31 15:38:01 +02:00
8b1041d510 Fix Visual Studio compatibility in writeffmpeg.c
This fixes an incompatibility with Visual Studio 2019 introduced in
631d5026c7. It is likely caused by using
`#  ifdef` inside the use of the `ELEM()` macro.
2019-07-31 15:26:29 +02:00
64e029ea92 Animation: Remove depsgraph argument from a lot of API
Use explicit boolean flag to indicate whether flush to original data
is needed or not. Makes it possible to avoid confusion on whether an
evaluated or any depsgraph can be passed to the API.

Allows to remove depsgraph from bAnimContext as well.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5379
2019-07-31 15:11:38 +02:00
9c0e7f7dd6 Animation: Remove depsgraph argument from direct keyframing
It was used to access evaluated object and pose and was done prior
to implementation of flushing values back to original data for an
active dependency graph.

Removing the argument allows to simplify API and solve issues with
accessing missing dependency graph on redo.
2019-07-31 15:10:49 +02:00
0d3493d6d9 Fix: Cycles reporting incorrect number of samples in viewport render
During viewport rendering where the viewport samples are set to 0 the UI
showed 16777216 as number of samples. We should not show the number of
samples when the number of viewport samples are set to 0.

Differential Revision: https://developer.blender.org/D5301
2019-07-31 14:32:41 +02:00
604fdb6e85 Spelling fixes in comments and descriptions, patch by luzpaz
Differential Revision: https://developer.blender.org/D3744
2019-07-31 14:27:35 +02:00
136a7a7fe8 Fix error in user preferences commit
Add include & initialize variable.
2019-07-31 22:25:49 +10:00
0272b7c814 Fix T67652: editing UV vertex location does not work with multiple objects
Patch contributed by matc.

Differential Revision: https://developer.blender.org/D5355
2019-07-31 14:03:33 +02:00
f7adb78828 Cleanup: remove BLO_update_defaults_userpref_blend
Merge into BKE_blendfile_userdef_from_defaults
2019-07-31 21:52:42 +10:00
07499c04f6 Preferences: don't store preferences in the startup
Simplify preferences by removing the ability to load them from
either the startup.blend or userpref.blend.

Also simplifies updating default preferences by moving
them to a struct definition.
2019-07-31 21:36:12 +10:00
86029b5071 UI: tweak naming in snapping popover to be "Snap with" and "Snap to"
To replace "Target" and "Snapping", this should be more clear.

Differential Revision: https://developer.blender.org/D5242
2019-07-31 13:11:38 +02:00
4bb9fbd3a8 Sculpt/Paint: Brush curve presets
This patch introduces the same presets that are used for proportional editing in the brush falloff menu. The user can select any of these presets or use the regular custom falloff curve. The presets are hardcoded formulas, so the falloff curve is not used when they are active.

This change improves the general feeling of the brushes and it is more convenient and simpler to use. The CUSTOM curve option should now be used in the case that an unusual deformation is needed, in other cases, the hardcoded curve presets should be the default.

The smooth curve presets is a must in the grab brush, as it fixes the deformation issue with the current custom curve setting. The user may try to adjust the deformation by tweaking the curve, but it is nearly impossible to replicate this desired behavior.

{F7636217}

Other brushes that are included in the sculpt branch also rely on this as they need specific hardcoded falloffs to produce the desired effect.

Reviewers: brecht, billreynish

Reviewed By: brecht

Subscribers: JulienKaspar

Differential Revision: https://developer.blender.org/D5367
2019-07-31 13:04:55 +02:00
03f652b2c1 FIx T66019: Text cutoffs for descriptions in keyframe insertion (keyingsets). 2019-07-31 12:30:03 +02:00
6d2f9b1dfa Added BKE_mesh_clear_geometry() function
This function makes it possible to clear/remove/nuke all the geometry in
a mesh, allowing functions like `Mesh.from_python()` to construct a new
mesh in its place. Without this function, code like in T67627 have to
allocate a new Mesh datablock, fill that, and swap out the old Mesh for
the new one. This introduces issues when exporting, as the new mesh
could be seen by an exporter as unrelated to the old one.

Shape keys are not freed by this function. Freeing those would require
tagging the depsgraph for relations update, which is an expensive
operation. They should be removed explicitly if necessary.

Material slots are also not cleared by this function, in the same way
that they are not cleared when manually removing all geometry from a
mesh.

The `BKE_mesh_clear_geometry()` function is available in Python as
`mesh.clear_geometry()`.

Reviewed by: mont29, brecht

Differential Revision: https://developer.blender.org/D5373
2019-07-31 12:23:56 +02:00
e51067505b Cleanup: Use explicit forward declaration 2019-07-31 11:58:53 +02:00
7761657129 UI: remove checks for other popovers when switching menu
I'm unable to redo the original report,
Revert fix for T43247..
2019-07-31 19:50:13 +10:00
94b81d51a6 UI: simplify check for active menu button
Dragging to select another popup now checks the menus active button.
2019-07-31 19:50:13 +10:00
ce0582ee2b Particle: Cleanup, remove unused depsgraph argument 2019-07-31 11:51:38 +02:00
11da3b132a Cleanup: Remove unused functions 2019-07-31 11:46:45 +02:00
2ddfd51810 FFmpeg: Added support for writing Opus audio.
This audio format is often used in conjunction with VP9 video in a WebM
container. Opus was created with the intention to replace Vorbis and
Speex ([source](https://en.wikipedia.org/wiki/Opus_(audio_format))).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5156
2019-07-31 11:28:48 +02:00
ca0b5529d0 FFmpeg: Added writing of WebM containers
This commit adds support for the WebM container. Previously we only
supported the WebM/VP9 video codec, but still required that it was
stored in a Matroska, MP4, or other compatible container format.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5156
2019-07-31 11:28:38 +02:00
43b7512a59 FFmpeg: Added support for writing alpha values in WebM/VP9 video
The VP9 video codec supports writing alpha values; now this is available
in Blender too.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5156
2019-07-31 11:28:36 +02:00
631d5026c7 Cleanup: Simplification of BKE_ffmpeg_alpha_channel_is_supported()
Simplified `BKE_ffmpeg_alpha_channel_is_supported()` to use `ELEM()`
instead of a row consecutive `if`-statements.

No functional changes.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5156
2019-07-31 11:28:33 +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
af4dcc6073 DRW manager: select engine: create generic draw_select_id_mesh 2019-07-30 20:47:18 -03:00
43ec8d7ae9 Cleanup: Rearrange Select Engine into multiple files 2019-07-30 20:47:18 -03:00
5359b7a033 cleanup: Fix typo in last commit
Accidentally took the C flags as a base.
2019-07-30 14:50:53 -06:00
19b72f50d7 CMake/Windows: Enable JMC on compilers that support it.
JMC [1] enables more productive debugging of C++ code in visual studio
this change enables it on debug builds for builds with visual studio 15.8
or higher.

[1] https://devblogs.microsoft.com/cppblog/announcing-jmc-stepping-in-visual-studio/
2019-07-30 14:40:05 -06:00
Julian Eisel
8d3f4a1df3 Merge branch 'soc-2019-openxr' into temp-vr-draw-thread 2019-07-30 22:26:37 +02:00
Julian Eisel
9ac33e56a1 Merge branch 'master' into soc-2019-openxr 2019-07-30 22:19:41 +02:00
fe47c7bf84 DRW manager: select engine: remove redundant calls 2019-07-30 16:32:08 -03:00
34b3a9583a Cmake/windows: Fix vcpkg bypassing our libs folder.
Occasionally we get reports of people that build blender and end up
with either build errors or end up with builds that do not run on
other systems. The root cause is when you install vpckg and integrate
it into the build system it puts the search path for its includes and
libraries before anything else.

previously we told people to either uninstall vcpkg or remove the
conflicting packages, which was not great.

this change opts out of the use of vcpkg for blender only, so people
can keep using it for other work without issues.
2019-07-30 11:46:13 -06:00
9d7a03ab11 Fix T67939: GPencil Noise modifier step is ignored in render
The value of the step was calculated using a variable that was removed when the render frame change.

Now, the step is calculated using the modulus of the current frame and recalculate noise only if the remainder that results from performing integer division is equal to 0.

To calculate current frame, the first used frame is calculated to adjust real frame range.

This approach is more stable in viewport and render.
2019-07-30 19:43:17 +02:00
28bd15cdf0 Fix snap package to work with 2.80 version number
Without this it rounds to 2.8.
2019-07-30 18:11:42 +02:00
7f29fc7415 Fix T65691: GPencil Drawing long strokes turn invisible
There was a fixed limit to the number of points available in a buffer stroke.

Now, the array is expanded as needed using a predefined number of points for each expansion, instead to add one by one. This is done to reduce the number of times the memory allocation is required.

As part of the fix, some variables have been renamed to reflect better their use.
2019-07-30 17:11:56 +02:00
f69e57a53f Alembic export: fix exporting of loop normals
When the mesh is using custom normals, those should always be exported,
regardless of the `ME_SMOOTH` flag on the invidivual polys.

Also replaced the loop normal writing with the same logic as we use for
reading (less pointer arithmetic, more normal counting).
2019-07-30 17:06:47 +02:00
e9c149d911 Alembic import: load face-varying normals
Loop normals are called 'Face-varying normals' in Alembic. Before this
commit, the existence of such normals was used to enable smooth shading.
This is incorrect, as the normals could encode flat faces just as well.

This commit adds the loading of these normals as custom loop normals. It
then also enables Auto-Smoothing on the mesh (which is a bit of a
misnomer and indicates to Blender that the custom normals should be
used).

Fixes the glitching described in T65959.

Differential Revision: https://developer.blender.org/D5191
2019-07-30 17:06:47 +02:00
dde978d149 Cleanup: Alembic: renamed 'smooth_normals' to 'export_loop_normals'
The name now indicates what happens when the variable is set to true.

No functional changes.
2019-07-30 16:59:10 +02:00
e74847e6bb Alembic: changed 'void *user_data' to 'Mesh *mesh'
The only thing that is stored in this pointer is a `Mesh*`, and casting
it from/to `void*` is unnecessary and confusing. Maybe the entire
CDStreamConfig class could/should be removed at some point.

No functional changes.
2019-07-30 16:59:10 +02:00
3568d56bcc Alembic: transformed chain-of-ifs into switch statement
By having a switch statement that lists all the values of the enum, it is
clear which cases we're not handling, and it also allows for warnings in
the future when the enum expands.

No functional changes.
2019-07-30 16:59:10 +02:00
d65a4b5990 Alembic: use r_ prefix for return variables
No functional changes.
2019-07-30 16:59:10 +02:00
7f552be7d1 Alembic: removal of always-zero parameter
The `poly_start` parameter was always 0, so adding it to a poly index
from Alembic is a no-op.

No functional changes.
2019-07-30 16:59:10 +02:00
0dece50667 Fix T65717: Alembic (camera - also mesh) import scale issue
The w-component of the translation column of the scaled matrix wasn't
set to 1.0, which, apart from being incorrect, caused drawing problems.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5290
2019-07-30 16:55:29 +02:00
406e960327 Fix T67904: GPencil clone brush doesn't copy the right color and layer
When using the clone brush, the first time the brush worked, but the next time no. The reasons were two:

1) The strokes were copied to the active layer, but if there were more than one layer, the stroke must be copied to the original layer.

2) The materials were not assigned properly and the materials were set as the first slot in the list always.

Now, the original layer name is used to try to find the same layer in destination. If the layer is missing, the active layer is used.

For materials, the bug in the hash lookup is fixed and the material is assigned to the right slot.
2019-07-30 16:51:37 +02:00
77cc69d66f Fix T67460: Vertex painting: Sampling color opens empty options window in viewport
The issue was that the redo panel area would call with region type HUD (not WINDOW).
Now we make sure that the redo panel always polls the operator in the original area type context.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5361
2019-07-30 16:01:51 +02:00
d87fb0356a Make 3d projpaint iteration lockless.
While speedup is hard to detect (highly fluctuent), it seems to be
around 5% on average on my 8 threads machine...

It also remove usage of a 'global' thread lock, which is always good.

Note that I also tried to use proper foreach threaded iterator construct
(see D5372), but that proved to be relatively slower (presumably due to
the very high dissymmetry between tasks, usually during a paint stroke
only a few chunks will require most of the computing effort, overhead of
threaded foreach management is then noticeable).

This concludes (for now) the work on
T51133 Bad performance with texture painting depending on multi-thread settings.
2019-07-30 15:42:16 +02:00
363dd97ae8 Fix T67370 Normal Tools(Alt +N), copy and paste not work
The copy operator requried at least a vert AND a face to be selected.
It should only require that a vert OR a face is selected.
2019-07-30 15:41:19 +02:00
5f405728bb BLI_task: Cleanup: rename some structs to make them more generic.
TLS and Settings can be used by other types of parallel 'for loops', so
removing 'Range' from their names.

No functional changes expected here.
2019-07-30 14:56:47 +02:00
b9c257019f BLI_task: tweak default chunk size for BLI_task_parallel_range().
Previously we were setting it to 1 (aka no 'chunking'), to follow
previous behavior. However, this is far from optimal, especially with
CPUs that can have tens of threads nowadays.

Now taking an heuristic approach (inspired from the one already existing
for `BLI_task_parallel_listbase()`, which tries to guesstimate best
chunk sizes based on several factors (amount of threads/parallel tasks,
total number of items, ...).

Think this is a reasonable base ground, more optimization here would of
course be possible.

Note that code that was already explicitely settings some value here
won't be affected at all by that change.
2019-07-30 14:36:59 +02:00
ae7db53744 Fix T66629: Library override - fails when armature and mesh are in separate collections.
Some ugly very low-level collection code was using the generic
LIB_TAG_DOIT tag... should never happen, that one is for rather
high-level code to use, core process shall use own tags.
2019-07-30 14:25:41 +02:00
cee484a4c5 Fix T67067: Wrong rotation input values when using shortcuts on keyboard like rx720.
This allows to type in numinput 720 and indeed get a rotation of 720°, not 0°...

This patch basically applies 'big rotations' in steps < 180°, such that
compatible rotation works as expected. This implies resetting current
rotation to initial one first, otherwise we'd end up applying much more
turns than expected when that code is called more than once.

It also makes things somewhat slower for big rotations (millions of degrees),
Hence we clamp to 1000 turns max.

And since that's a case that cannot happen with regular tool/widget-driven rotation,
it's only enabled when numinput is used for now.

Review task: https://developer.blender.org/D5289
2019-07-30 14:25:41 +02:00
b9718299ea Fix crash clicking in the 3D view on startup
Setting the 3D view cursor on startup could crash because the
viewport hasn't been assigned to the region.
2019-07-30 21:43:40 +10:00
Julian Eisel
b961b3f0c9 Initial, mostly broken VR viewport drawing on own thread
Spawns a separate thread to do any VR session drawing on. There are
four reasons for this:
* VR session doesn't need the usual main loop procedure for drawing.
  With the drawing on a separate thread, the session doesn't have the
  overhead of the other parts of the main loop.
* OpenXR performs thread blocking operations to synchronize rendering
  with the device refresh rate. This would conflict with the rest of
  Blender, causing lags on event handling, drawing, etc.
* With an own thread, we can keep a single OpenGL context alive,
  avoiding expensive context switches. This should improve performance
  significantly.
* With a bit more work, viewports can draw entirely in parallel (at
  least the CPU side of it), pushing performance even further.

Drawing the viewport on a separate thread shouldn't be much of an
issue. The draw-manager is already thread safe (mutex guarded). Not much
seems needed to get it entirely concurrent, allowing viewport drawing
from separate threads without any synchronization (i.e. only one at a
time).
I had to create an own depsgraph for the VR draw thread so the viewport
gets its own buffers for its own OpenGL context.

Right now this is utterly broken, but at least an empty viewport is
drawn for the VR session in a separate thread. Issues are:
* VR viewport doesn't draw any objects, just background + overlays
  (apparently the VR session depsgraph isn't built correctly).
* OpenGL context of the main thread seems messed up when drawing the VR
  view. Result is drawing glitches and eventually Blender crashes.
* Exiting the VR session causes failed assertions and memory leaks.
2019-07-30 13:28:20 +02:00
51be0a765e Tracking: Fix wrong usage of draw buffers
Curve drawing was attempting to draw reprojection error curve when it was
not visible.

Worst thing is that the imm was not informed about vertices, so the code
was causing an assert in debug mode. Probably, it is also what have caused
random crashes after recent changes.
2019-07-30 13:00:22 +02:00
edb3b7a323 Fix T67274: Graph Editor Normalization broken by Keyframe that uses Easing or Dynamic interpolation
We didn't include and of the newer interpolation types in the
normalization function.
Besides taking into account these newer types, we now also only evaluate
the curves when needed. If the values between the control points won't
exceed the control point values, we only use the start/end values for
our normalization

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5365
2019-07-30 12:25:39 +02:00
5662a5969b Particle: Fix incorrect access to evaluated mesh
Mesh can not be requested from original object, and it can not be
copied into evaluated modifier because there is no such a thing yet.

It can not be done this way now, because getting evaluated object
will force it to re-calculate, which kind of defeats idea of this
code to preserve un-baked particles.
2019-07-30 11:57:33 +02:00
651d8bfd98 3D View: Move selection API to a Selection engine.
This commit moves the API of selecting faces, vertices and edges to a DRW manager engine.

Reviewers: campbellbarton, fclem

Subscribers: jbakker, brecht

Differential Revision: https://developer.blender.org/D5090
2019-07-30 06:46:59 -03:00
a85963bed8 Fix T67906: empty menus for hooks if non-hook modifiers are present 2019-07-30 11:30:13 +02:00
db0782e946 Py node shader wrapper: Add clamping to official min/max values.
Taking values from relevant node definition C file...

Related to T67889.
2019-07-30 11:24:10 +02:00
286c921c25 Tracking: Fix crash happening after removing object 2019-07-30 11:11:54 +02:00
58b554c7a4 Fix T66591: GPencil layer visibility control via driver doesn't work 2019-07-30 10:27:13 +02:00
6fa47f656e Fix T67882: buttons are interrupt drag actions 2019-07-30 17:39:06 +10:00
d2063f7bc3 Fix edit-mode interfering with brush swap color
D5353 by @robert-wallis
2019-07-30 15:37:45 +10:00
369b574fd5 UI: add use_button option to popovers
This is useful when popovers are launched from operators
instead of as button popover types.
Where the connection between the button and the popover is useful to keep.
2019-07-30 10:57:47 +10:00
a345f56ce3 Cleanup: de-duplicate file reading code
Also remove goto's.
2019-07-30 10:43:07 +10:00
f1516ae637 Cleanup: check is_startup parameters instead of the path 2019-07-30 10:41:34 +10:00
0a2fd63383 Cleanup: replace unused return defines with bool 2019-07-30 10:31:27 +10:00
1178046ed2 GPencil: Remove Annotations panel from non-preview Sequencer areas
Fix by: Peter Fog (@tintwotin)

I did some small changes to original differential code.

Differential Revision: http://developer.blender.org/D5306
2019-07-29 22:43:25 +02:00
2b8bc1a22e Doxygen: update version number to 2.81 2019-07-29 19:10:48 +02:00
daa7b56890 Fix T67874: Show gizmo incorrectly uses Cmd-` on macOS 2019-07-30 01:55:06 +10:00
770b496729 Cleanup: GPencil replace cfra_eval by cfra or CFRA
Don't need these variable because this code was part of using depsgraph frame number, but now using scene framenumber only add noise to the code.
2019-07-29 17:07:37 +02:00
453586be06 Fix T67849: Offset after "Hook to Selected Object" 2019-07-30 00:36:10 +10:00
0ae52711b6 Fix T67857: crash assigning None to the data of an empty using python
Assigning None is allowed for (image) empties.

Reviewers: sergey

Maniphest Tasks: T67857

Differential Revision: https://developer.blender.org/D5362
2019-07-29 15:28:00 +02:00
baff245b9d Fix T67860: missing 3d cursor update when picking texture clone location
Reviewers: sergey

Maniphest Tasks: T67860

Differential Revision: https://developer.blender.org/D5360
2019-07-29 15:24:25 +02:00
a7d9e2f57e Fix T67221: Auto-offset in VSE doesn't refresh audio
Reviewers: sergey, ISS

Maniphest Tasks: T67221

Differential Revision: https://developer.blender.org/D5300
2019-07-29 15:21:04 +02:00
a3c66680fd Fix T66931: "reset to default value" of metaball - viewport resolution is way too high
Maniphest Tasks: T66931

Differential Revision: https://developer.blender.org/D5251
2019-07-29 15:10:38 +02:00
537209cb4b Remove debug prints from previous commit.
Sorry for the noise...
2019-07-29 14:45:56 +02:00
3b6c75dc31 Fix T67620: Font preview translations malfunction in Blender 2.8
We cannot reliably use translations API from non-main threads.

Now storing translated strings in a static cache, with basic mechanism
to update it on language change.

Reviewers: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D5350
2019-07-29 14:11:35 +02:00
b83a1b62c7 Fix T66233: Grease Pencil Swirl Effect not working at origin
If the control object is in the origin the radius is wrongly calculated because the result is 0.

Now, this value is clamped to avoid this situation
2019-07-29 12:41:24 +02:00
13f57237f2 Fix T67331: Annotations: Rename old grease pencil panels
These panels were using the old names, but now they are not grease pencil, but annotations.

Also removed old Tools panel. This must be replaced with new Toolbar
2019-07-29 12:39:39 +02:00
3ee246f614 Fix T67338 : GPencil Disable material properties when material is locked
When the material was locked, the properties were deactivated but not disabled.

Differential Revision: http://developer.blender.org/D5309
2019-07-29 12:35:12 +02:00
92f6e60f46 Fix T67876: 2D Stabilization doesn't compensate rotation in spacial cases
This was caused by 2D stabilization trying to be smart and lower weight
of tracks which are too close to the rotation center. This was causing
algorithm to ignore a single track which was set to constant 1 weight and
used for rotation compensation.

It is quite tricky to quantify this change without having comprehensive
regression suit, so can only hope that initial intention is still working
as expected.
2019-07-29 12:30:45 +02:00
60d71ffbe9 Fix T67811: GPencil Weights shift when use dissolve in Edit Mode
The problem was the index was not right calculated for unselected points.
2019-07-29 12:13:39 +02:00
801962e2b6 Fix T67813: Remove mask from Weight Paint
Weight Painting was using mask if "Selection Mask" in Sculpt Mode is turned on.

This can be quite confusing because the option to turn it off is not available in Weight Painting and the selection is also not visible.

Now the mask is not checked in weight paint mode.
2019-07-29 12:12:43 +02:00
d438e71729 GPencil: Use uniform_int_copy instead to pass reference
The constant variable was passed as reference to constant variable, but it's better use the new function to copy values.

This could be the problem with T67772
2019-07-29 12:10:48 +02:00
fd730fce0c GPencil: Add inverse diff matrix to iterator macro
GPencil: Cleanup inverse mat code

This calculation is done in the macro, so don't need do it again in loop.
2019-07-29 12:10:48 +02:00
d3ca0bf6f8 Version bump to 2.81 alpha, master is now open for new features and changes 2019-07-29 12:00:52 +02:00
7ac0c87473 Fix T67800: Incorrect behavior of simple Subdivision Surface
Stupid typo in an original fix, need to operate in 3D, not in 2D.
2019-07-29 11:26:16 +02:00
0528ef0b4d Fix T67777: Linked rig crashes Blender 2.8 RC3 on File|New.
Sync back between proxy armature pose and linked one was not properly
clearing the posebone runtime data, ending up with shared memory between
both (direct cause of reported crash), and probably some other nasty
issues.

While this crash is not critical in itself, I would suggest to add this
fix to 2.80 branch, as it is super-safe and simple, and is probably
fixing some other un-reported issues?
2019-07-29 10:54:28 +02:00
a38759f017 Fix T67863: Crash pressing Ctrl +/- in gpencil action editor 2019-07-29 17:22:12 +10:00
314891b1c5 Fix T67826: View selected fails with files from 2.7x
Grease pencil could have edit mode enabled in old files.
2019-07-29 15:31:00 +10:00
matc
a542f50b51 Fix T67523: Incorrect UV's for grid primitive 2019-07-29 14:28:02 +10:00
a49838ccb0 Tracking: Fix missing camera depsgraph update tag
Was causing lack of proper viewport update when camera solve assigned
new focal length to the camera.
2019-07-28 17:07:39 +02:00
fc5ba7e0bd Tracking: Support selecting tracks by their reprojection error curve
Quite straightforward after previous refactor: now speed and error curves
are handled in the same exact manner.
2019-07-28 17:04:10 +02:00
bf637984d1 Tracking: Refactor, generalize curve iteration API
Make it generic enough to support iterating over reprojection error
in the same manner as coordinate speed.
2019-07-28 17:04:10 +02:00
1c40227bfa Fix related to T67385: disallow some modifiers ops from Edit mode.
Some modifier operators cannot be reliably executed from Edit mode
currently, so disable them from the generic mod ops pool function.

Have been very conservative here from now, keeping existing behavior
most of the time, and only forbidding Edit mode when code was already
doing it in its own way, or when it was obviously not possible.
2019-07-28 16:11:42 +02:00
3e45f01494 Fix T67385: Bind in Laplacian Deform Modifier with new vertex group in Edit Mode crashes Blender.
Main issue in that report was that meshes generated from
`mesh_create_eval_final_view()` and the like need some
special freeing handling (as, among other things, they borrow and do not
own their potential editmesh data...).

Factorized that into a helper func also used by
`BKE_object_free_derived_caches()`.
2019-07-28 16:11:42 +02:00
c4cf14d161 Cleanup: Spelling in comments 2019-07-28 15:31:20 +02:00
1f47916664 Depsgraph: Fix changes in tracking invalidating movie cache
Added special exception in legacy tag with 0 flag.
2019-07-28 15:08:41 +02:00
11814080a6 Depsgraph: Fix missing cases of SOURCE ID recalc tag 2019-07-28 15:07:06 +02:00
5e56cfa958 Cleanup: Fix strict compiler warning 2019-07-28 15:05:10 +02:00
2cce65de96 Fix T66872: Changing clip color space does not update background images
Such reload can no longer happen directly and is to be done via dependency
graph.

Eventually, the movie cache will become shared across all copies of the
clip, but even then we still need to have dependency graph mechanism because
we need to update FFmpeg animation handle (which can not be shared across
the copies).
2019-07-28 13:24:18 +02:00
233f78c017 Cleanup: remove unused ID-map undo API
Removing this since it was added for TexFace support
which has since been removed.
2019-07-28 17:53:41 +10:00
ae19f68d45 Cleanup: pep8 2019-07-28 17:45:55 +10:00
79ce2054d4 Linux: add script and instructions for creating snap packages
We will now maintain the Blender package on snapcraft.io/blender.

Differential Revision: https://developer.blender.org/D5342
2019-07-26 17:34:45 +02:00
d25386b8a7 Linux: update appdata description 2019-07-26 17:34:45 +02:00
963b761144 WM: Pre-fill bug-reports for addons
This is an increment of the proposed changes in D4507.

Differential Revision: https://developer.blender.org/D5303
2019-07-26 11:19:21 -03:00
9270c15af8 GPencil: Get current frame from scene
This change makes it so current frame is queried from a scene rather
than from a dependency graph. This makes it possible to avoid the
fact that dependency graph might not be fully evaluated yet.

There are still some cases where it frame is queried from the graph,
but those seems to be in a code path where we need to ensure valid
dependency graph anyway.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5349
2019-07-26 15:16:52 +02:00
ad18d331d7 Cleanup: Remove unused depsgraph pointer 2019-07-26 15:16:12 +02:00
6cb8bd0a1c Modifiers: Update LaplacianDeform error message about vgroups.
Vgroup might be also 'invalid' because it is empty (and no other vgroup
with vertices currently exists on that mesh).

Related to T67385.
2019-07-26 14:45:55 +02:00
523de7ae9b Fix T66325: Animation Keyframe Undo/Redo Bug
The issue was caused by dependency graph always ignoring animation
update when it is first time constructed. This was a way to make it
preserve unkeyed changes on undo/redo. This, however, made it so
changes of animation data itself (such as deleting/moving keyframes)
did not trigger animation update by the dependency graph.

This worked prior to copy-on-write because animation recalc flags
were stored in the DNA and never re-set on file/undo load. This was
giving dependency graph a clue that animation is to be re-evaluated
when operator explicitly asked to (more precisely, when such operator
was undone/redone).

This change makes it so original ID's recalc flags are storing
recalc flags when ID is tagged for update as an response to user
input. This way re-building dependency graph can force animation
to be updated on redo.

Tricky part here is that ID's recalc flag is no longer to be zeroed
when loading undo step (which is the same as reading .blend file).
This is something what works differently comparing to legacy
dependency graph, which was zeroing object's recalc flags there but
not animation data's recalc flags.
Shouldn't be causing issues, since unkeyed changes are not preserved
upon opening a file anyway, at least to my knowledge.

Related reports which are to be taken into account and verified
they are not re-introduced when making changes in the area:

- T63111: Auto-Bake stuck at constant re-rendering
- T54296: Cycles viewport render stuck on constant re-render

Reviewers: campbellbarton, brecht

Reviewed By: campbellbarton, brecht

Maniphest Tasks: T66325

Differential Revision: https://developer.blender.org/D5316
2019-07-26 14:33:51 +02:00
ba94aaedba Fix T67639: Default cube UVs are incorrectly arranged 2019-07-26 21:55:53 +10:00
9e9c6eac6a Fix T67595: bevel concave cube corner.
The special case test for cube-like corner did not work if normals
are flipped.
2019-07-26 07:41:28 -04:00
11b994e26e Fix T67671: Blender crashes when resizing sidebar with a colorbamp
The amount of triangles drawn by the button depends on its `sizex`.
See:
```
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
```
Therefore the `sizex` cannot be 0.

Solution a bit similar to rB56b0cd1d.

Ref T67671

Reviewers: fclem, brecht

Maniphest Tasks: T67671

Differential Revision: https://developer.blender.org/D5347
2019-07-26 08:29:38 -03:00
1d7be99ba4 Fix missing ID pointer updates for texture paint undo
Partial fix for T61263, however mem-file undo sometimes reloads imbuf's.
2019-07-26 20:05:04 +10:00
81043397d7 Undo System: correct fix for T67709 2019-07-26 20:04:28 +10:00
62338abde4 Cleanup: Remove unused depsgraph pointer 2019-07-26 11:51:43 +02:00
1693a5efe9 Fix T66378: Missing animation update when switching view layer
Current frame is stored in a scene, and scene might have multiple view
layers. The inactive view layers were not informed about scene's frame
being changed, so when user switched back to view after changing scene
frame it was in an inconsistent state between current scene frame and
animation.

Now we tag scene for time changes, so dependency graph can catch up
and do proper update.

Currently tagging is from quite generic place. Probably better approach
would be to tag from where frame is actually being assigned. Downside
of this is that it's easy to miss some places.

Reviewers: brecht, mont29

Reviewed By: brecht

Maniphest Tasks: T66378

Differential Revision: https://developer.blender.org/D5332
2019-07-26 10:23:38 +02:00
250995d67b Fix T67507: Set origin on armature moves incorrectly parented objects
Need to copy changes from original armature to evaluated one prior to
BKE_pose_where_is(), otherwise the pose matrix in pose channels will
not be correct.

Can not use dependency graph update here, since we must not re-evaluate
possible dependencies of the changed armature.

Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T67507

Differential Revision: https://developer.blender.org/D5331
2019-07-26 10:15:39 +02:00
cf0f2f2d3d Fix T67256: Add object redo duplicates, after exiting sculpt mode 2019-07-26 14:33:00 +10:00
ac7fe46ec3 Fix T67709: Texture paint undo gets out of sync 2019-07-26 13:14:24 +10:00
cb10bd379b Fix T67599: Issue with Simple subdivision of loose edges
They were always acting as a B-Spline subdivision.
2019-07-25 16:34:01 +02:00
4f363283eb Fix T67593: Crash when making link for instance collection 2019-07-25 10:02:00 +02:00
829cbd88ff Fix T67588: Crash after clearing animation in outliner 2019-07-25 09:47:43 +02:00
6a7fcf725e Fix app-template keymap preferences being ignored 2019-07-25 17:39:32 +10:00
d24300da5f Fix app-template keymap being ignored 2019-07-25 16:36:59 +10:00
e51943bd73 UI: clarify tip for viewport mouse position property
This is an hidden property only visible in the keymap editor.

Addresses T67589
2019-07-25 13:47:47 +10:00
410eddcbcc Fix T67603: Selecting toolbar from search raises error 2019-07-25 13:35:01 +10:00
2e92791074 Fix crash validating mesh polygons with invalid loop-start
Add check for negative loop-start,
fixes crash validating test file from T67605.
2019-07-25 13:23:05 +10:00
419f137c64 Doxygen: update version number 2019-07-25 13:08:44 +10:00
76dfbee423 Fix T67472: Gizmo overlap causes cursor to get stuck 2019-07-25 10:53:04 +10:00
Julian Eisel
091cc94379 Use fixed lighting, don't make it rotate with view rotation 2019-07-24 16:41:46 +02:00
bfe580642f Fix background image rotation and offset
- Offset was halved & not compensating for non-square aspect.
- Rotation was flipped.
2019-07-24 22:32:17 +10:00
4fe0fafb87 Fix T67548: Camera background-image ignores shift
Regression from 2.79
2019-07-24 20:42:39 +10:00
552cc30f3a Fix T65980: Boolean crash with many intersections on a single face 2019-07-24 19:33:55 +10:00
52fb8b1e80 Fix T67117: Font thumbnails crash to desktop
We were missing a null pointer check for invalid fonts.
2019-07-24 11:26:21 +02:00
53944e2f9f Fix T67315: Redo transform disables snap 2019-07-24 17:07:55 +10:00
796a2b5fc7 Fix T66768: Grid fill span not working 2019-07-24 16:32:15 +10: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
b63f0266a0 Fix T67459: Dope Editor, muting channels with shortcut doesn't work 2019-07-23 15:52:39 +02:00
4cf8f35cc1 Tracking: Give more reasonable error message directly in the interface
Before this the message could be too generic which was simply saying
that console is to be checked. This isn't very useful in cases when
we know that reconstruction is failed because of lack of good keyframes
or failure of initial reconstruction if there is no enough parallax
on the selected keyframes.
2019-07-23 15:12:35 +02:00
7d65827980 Fix T67089: Solve camera motion generates "Solve error: nan"
The code was missing some checks for whether keyframe selection
went successfully and whether reconstruction has been successfully
initialized.

The interface still gives quite generic message, with the details
printed to the console. This can be addressed separately.
2019-07-23 15:12:35 +02:00
361d578f9d fix: unreported: Collada using incompatible Enumeration types for compare 2019-07-23 15:09:02 +02:00
9e3ff9e059 Fix T67334: Blender does not exit after saving 2019-07-23 14:32:32 +02:00
ef0e06d764 Fix T65386 Eevee: Crash after baking indirect lights or cubemap
I'm not sure this fixes the root of the problem. The file from the ticket
seems to have been corrupted in some way.

We MIGHT want this in 2.80.
2019-07-23 13:21:03 +02:00
84c11e8644 Cleanup: Rearrange the order of isect_ray_ray_v3 parameters
And remove redundant add operation.
2019-07-23 08:11:46 -03:00
19aa873f70 Fix T67299: UV Stretching Overlay of type "Area" fail when any face is hidden
We want to include this for 2.80
2019-07-23 07:51:16 -03:00
matc
2d98ac33be Fix T65402: Syntax error causes CPython assert 2019-07-23 20:31:27 +10:00
34ad6da4a0 Fix T67450: Crash undoing edit-mode lattice resolution 2019-07-23 17:25:28 +10:00
07f3ad06fc Fix T63775: Toolbar icons ignore BLENDER_SYSTEM_DATAFILES
The environment variable to locate system data-files was
ignored by toolbar icons.

Add bpy.utils.system_resource
to match Blender's internal data-file access.
2019-07-23 16:30:26 +10:00
6e72d3e00e Fix T67389: Transform constraints fail at large distances 2019-07-23 14:56:49 +10:00
0a0e2dd8a2 Fix T67040: Undo crashes after renaming
Correct fix that doesn't cause T67217.

Temporarily removing the excluded undo step broke memfile-undo
since freeing the undo steps needs to access other steps in
the list to merge shared chunks, see: memfile_undosys_step_free.

Pass the exclude step as an argument instead.
2019-07-23 13:06:26 +10: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
8c61837150 Incompatible usage of the Collada transparency value
Some external tools seem to have issues with the definition
of Collada <transparency> - a float value in range (0,1).
However it is possible to use the <transparent> color as a container
for the <transparency> value. This seems to be a more reliable
method to export transparency values from Blender PBSDF Shaders.

The relevant documentation is in the collada 1.14 reference manual,
page 7-5 about the usage of transparent and transparency.

This fix makes export and import of the <transparency>
and <transparent> values more convenient and more reliable.

Reviewers: brecht, jesterking

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5305
2019-07-22 19:03:56 +02:00
2de95e8149 Fix missing subversion bump for 2.80 release.
We need a final subversion bump before release in case there are
remaining 'unversioned' code in our versionning callbacks...

Should have been done before first RC actually. ;)

To be ported to 2.80 release branch.
2019-07-22 18:44:22 +02:00
02c5c091df Bevel modifier: let it work on wire edges when vertex_only. 2019-07-22 07:13:04 -04:00
2c1d23f209 fix unreported: typo in python documentation
Fix as approved by dr.sybren in blender chat
2019-07-22 11:43:07 +02:00
Julian Eisel
bd42740ef1 Silence GCC warning 2019-07-21 13:15:00 +02:00
45ae9edbd5 Revert "Fix T67040: Undo crashes after renaming"
This reverts commit c635663e4a. This is causing
crashes with sculpt mode and object mode switching.

Fixes T67217.
2019-07-21 12:59:36 +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
e2b0647272 Industry Compat keymap: Fix inconsistencies and conflicts with color swatches and other over-widget hotkeys
Sample hotkey is set to the I key now, similar to other apps.

Reported on Devtalk
2019-07-20 14:45:45 +02:00
4b980e2f57 Fix T67196: bevel bad at a 3-edge bevel.
The test for whether or not this was a "pipe" neglected to use
fabsf() around a dot result.
2019-07-20 08:38:41 -04:00
c2e8e249ac Fix assert in some cases when using DataTransfer modifier for custom normals.
Reported by @sybren on IRC, thanks.

Should be safe for 2.80.
2019-07-19 16:17:09 +02:00
65aac86d5a GPencil: Fix wrong material when apply Opacity, Hue or Tint modifier
When apply the modifier a new material is created, but it was assigned wrongly. The problem was the index was base 0 already, so subtract 1, got a wrong value.
2019-07-19 15:22:42 +02:00
23ea4b56ad GPencil: Fix showing wrong material in brush panel with pinning
The options of the material are from object material not pinned material.

If the brush is pinned, the material must be the brush material and not the object material.
2019-07-19 15:22:42 +02:00
d5c0a02f86 Fix T67033 EEVEE: Random Flickering Materials
This was a read after free error. This only fix the undefined behavior.
The result is still not correct in certain cases (see T67226).

We want to include this for 2.80
2019-07-19 14:38:09 +02:00
69ba3b98e4 Fix new Text ID usercount handling in add/load cases.
Text datablocks should always have a 'single user' flag set, and they
usually do not have any user (since neither text editor itself, nor
Freestyle usage are text users - the second is odd btw...), the only one
am aware of is the script node (e.g. for OSL).

Add text case was simply not doing anything, so added.

Load text case was doing things in inversed logic (setting user count to
zero in BKE, then setting 'real user' flag in ED code). Made it the
other way around (BKE ID creation code should not care about usercount
usually, this is up to higher-level code to decide what to do
(operators, RNA...).

Note: tried to check all cases, but there might very well be some more
hidden bugs here...
2019-07-19 13:58:26 +02:00
48418ec125 Revert "Fix assert unlinking text"
This reverts commit b0b2546d4a.

Please do not sweept the dirt under the carpet like that! If there is a
bug, either report it or fix it, but do not silence it!
2019-07-19 13:58:01 +02:00
0d3e055bda Cleanup messed-up comment formating from codestyle apply... 2019-07-19 13:58:01 +02:00
fb84ef58c4 Fix T67191: Redo fails for 3D text operations 2019-07-19 19:21:00 +10:00
7fe81fe5a3 Fix T63090: Delete keyframe reports invalid for multiple objects 2019-07-19 18:43:12 +10:00
5f140e61c2 DRW: lattice vertices were too small 2019-07-19 10:44:09 +10:00
1ae4311902 Fix T66492: Divide by zero with cursor to selected 2019-07-19 10:31:51 +10:00
48b4d42bce CMake: Fix WITH_CODEC_SNDFILE detection
D5296 by @frispete
2019-07-19 09:24:08 +10:00
4b2e6d4e22 Fix T67062: Movie Clip Editor does not update Editor Type when changing Editing Context
Previously when switching modes, the code didn't check if we were in the
correct view for the masking mode.

Reviewed By: Sergey

Differential Revision: http://developer.blender.org/D5288
2019-07-18 15:29:03 +02:00
2e6139dfc2 Fix context menu Remove Shortcut not being available for non-keyboard shortcuts 2019-07-18 14:15:31 +02:00
b58a6a3e72 Disable b-bone spline gizmo for now
This wasn't working properly and needs to be finished,
disable for release.
2019-07-18 22:04:21 +10:00
687f1df5db Fix T66811 Eevee: Flickering in weight paint mode
This was caused by TAA offset being computed as the 2nd sample even if the
sampling was reset afterwards.

The fix is to update the matrices after any potential reset.
2019-07-18 12:55:26 +02:00
7a82896fbc Keymap: use number keys to change particle modes
Match behavior for meshes.

Fixes T67161
2019-07-18 20:27:21 +10:00
5c8b1a1266 Fix edit-mode particle vertex draw size
Vertices were hard to see, draw the same size as edit-mesh vertices.
2019-07-18 20:11:18 +10:00
c6c9e168e2 Fix T58447: Unselected bone used for constraint target 2019-07-18 19:12:09 +10:00
20c725ed62 Cleanup: remove redundant preference check
Missing from f2df520698, harmless but confusing to leave
in checks for preferences having asked to skip them.
2019-07-18 16:58:38 +10:00
098f60f1b8 Fix T67105: Missing Update Add Camera Background Image
Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D5284
2019-07-18 08:44:30 +02:00
5d4bd8f1bb Fix T66949: Can't select bones from multiple objects in wpaint mode
This fix relies on 2.7x logic, only de-selecting other armature objects,
making multiple armatures in weight paint mode usable.
2019-07-18 15:45:39 +10:00
bf8393c1c9 Fix weight-paint & pose-select & lock-mode combination
Extend pose object checks to all pose-mode objects
used by the mesh.
2019-07-18 15:42:14 +10:00
8a083ef3b7 Fix weight paint mode setting with multiple armatures
Selecting multiple armature objects and entering weight paint mode
wasn't working.

Entering weight + pose modes at once was only done when
object mode locking was enabled. Now it's done even when
mode-locking is off - because it's still inconvenient to setup
and useful default behavior.

Resolves issues raised by T66949
2019-07-18 15:40:52 +10:00
0b4c0472a3 Fix T61117: Selecting an armature doesn't select the bone
Regression from 2.7x caused by 28dfc47cf0
2019-07-18 14:26:34 +10:00
112f0db40d Fix pose de-selection when selecting from object mode 2019-07-18 14:24:55 +10:00
807b6c4848 Revert "Fix T66949: Can't select bones from multiple objects in wpaint mode"
This reverts commit 9e9fbb39d7.

Adding back object+pose bone selection support removes the need for this fix.
2019-07-18 12:22:39 +10:00
Dalai Felinto
a6b7ee2a1e Fix T66948: Outliner - collections/objects with wrong active state
If the parent collection was out of view we were not taking its
properties into consideration. We need it even when not drawing the
parent to set active/inactive values for its children.

Related Task: T66948

Reviewers: brecht

Subscribers: Zachman

Differential Revision: https://developer.blender.org/D5272
2019-07-17 19:38:54 -03:00
Dalai Felinto
bfa6cb3a7d Fix T64312: Selection inconsistencies when switching collections
Basically layer_collection_sync was calling BKE_base_eval_flags right away while
iterating over the bases.

However when a parent/sibling collection is to influence the collection flag of
an object that exists in more than one collection, it is too late since we
deselect the object in BKE_base_eval_flags right away.

Related to T64312.

Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D5243
2019-07-17 19:38:16 -03:00
158eb98c22 GPencil: Fix usability problem with curve control points apart
Based on feedback from @matiasmendio

There was a problem with the control points because it was very difficult to know what point move. Now the points are moved apart and makes easy to know what point use.
2019-07-17 22:24:39 +02:00
eee46769ce Fix T66515, T67112, T61607: failure to read EXR files with single, named layer
Like Blender renders without a Z channel. The single layer case assume that channel
names are just R/G/B/A without any layer name prefix, and would not read channels
like "Image.R".

Carefully tested for regressions with the openexr project tests images, so this
should be safe.
2019-07-17 20:55:53 +02:00
709f126e81 Fix T59713: Armature layer dots not updated on changes
`layer_used` runtime data, which controls the drawing of dots in the UI was not getting refreshed properly.
This used to happen in the drawing code, but was no longer working for reasons explained in:
{rB2b09062defa093a243b5fe64b099accb07b440a3}

The solution was to update each layer manually in the operators:
* ARMATURE_OT_bone_primitive_add
* ARMATURE_OT_delete
* ARMATURE_OT_dissolve
* ARMATURE_OT_fill
* ARMATURE_OT_merge
* ARMATURE_OT_separate
* ARMATURE_OT_bone_layers
* POSE_OT_bone_layers

Differential Revision: https://developer.blender.org/D5281
2019-07-17 14:17:34 -03:00
4ddc7e8d1b Fix T66919: Force field does not affect particles
Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T66919

Differential Revision: https://developer.blender.org/D5275
2019-07-17 16:51:02 +02:00
c722c5204f Fix T67075: make object.visible_get() and similar APIs more forgiving
When objects are not in the view layer, just return false rather than throwing
an error. As far as the script is concerned the object is not visible or
selected when it's not in the current view layer.
2019-07-17 16:30:42 +02:00
c1bd5bcbfa Fix T66091: paint curve point slide conflicts with 2D cursor 2019-07-17 16:30:42 +02:00
b69c33aeba Fix T67099: entering color picker hex value #FF results in 1.000001 2019-07-17 16:30:42 +02:00
f17e2f8dac Fix T67127: Crash Missing DEG tag update mask layer
When ng mask layer operations (add, remove, move) the
original mask was not tagged to be updated resulting
in missing data on the copy. The Masking function
assumes that the copy and the original is always
structured the same.

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D5283
2019-07-17 16:24:00 +02:00
2e15b72089 Clip editor: Fix missing frame update on undo
It is possible that undo will change current scene frame and that was
not synchronizing current frame from scene to movie clip user.

Reported as a part of T66519.

Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T66519

Differential Revision: https://developer.blender.org/D5280
2019-07-17 16:05:33 +02:00
58db64a3b6 Revert "Fix T59713: Moving bones between layers in edit mode doesn't show the dot icon in the layers UI"
This commit did not follow the protocol that requires a review first.

This reverts commit 580acab173.
2019-07-17 10:32:50 -03: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
580acab173 Fix T59713: Moving bones between layers in edit mode doesn't show the dot icon in the layers UI 2019-07-17 10:16:17 -03: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
11741ff682 Fix T67001: Studio and Flat lightning in single color do not respect clipping region
`DRW_STATE_CLIP_PLANES` has to be enabled independent of the workbench material.

Reviewers: fclem, jbakker

Differential Revision: https://developer.blender.org/D5278
2019-07-17 08:51:57 -03: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
526272bf7c Fix T67115: Changing the Shape of a Force Field object does not refresh the animation 2019-07-17 08:30:37 -03:00
366865dd02 Undo System: replace with simpler binary diffing buffer storage
Applying/undoing incremental changes didn't fit well when
mixed with periodic snapshots from mem-file undo.

This moves to a much simpler undo system.

- Uses array storage with de-duplication from `BLI_array_store`.
- Loads the buffer into existing text data,
  for better performance on large files.
- Has the advantage that Python operators can be supported
  since we don't depend on hard coded undo operations.

Solves T67045, T66695, T65909.
2019-07-17 21:19:22 +10: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
9e9fbb39d7 Fix T66949: Can't select bones from multiple objects in wpaint mode 2019-07-17 18:39:42 +10:00
f8a70db556 Fix T67047: Can't jump to frame when using jack in A/V sync mode
Similar fix to 495aff7.

Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T67047

Differential Revision: https://developer.blender.org/D5268
2019-07-17 09:56:47 +02:00
d8cebcfebf Fix object selection when in pose mode
The new selected object was activated but not selected.
2019-07-17 16:57:45 +10:00
Dalai Felinto
d90201aee2 Edge Slide: Fix multi-object for loop early exit
Part of D5274, reviewed by Campbell Barton.
2019-07-16 23:01:42 -03:00
Dalai Felinto
5ca302cb0c Fix T67078: Crash with vertex slide and multi-objects
If one of the objects had invalid selected edges, it would lead to a
crash since none of the for loops were checking for whether the edge
slide data is valid.

We could refactor the macros to create a new
FOREACH_TRANS_DATA_CONTAINER_WITH_DATA

However we are too close to 2.80 final release so we manually skip them
for now.

Note: TRANS_DATA_CONTAINER_FIRST_OK cannot be used either for the same
reason.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D5274
2019-07-16 23:01:03 -03:00
4a5e046c92 UI: remove button to enable auto-save after load factory preferences
Based on feedback from T66675, the current interface is confusing,
leading to users accidentally overwriting their preferences.

Now, once factory settings are loaded preferences are not saved
and the save button is shown (as when auto-save is disabled).

Tool tips note that factory settings require manual saving
afterwards.

Also rename preference menu items for better consistency
(settings/state -> preferences).
2019-07-17 09:38:30 +10: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
a36a44bb81 Fix paint curve not drawing selection colors properly
This code is not guaranteed to run with any specific space theme, so pass
it explicitly.
2019-07-16 20:31:23 +02:00
9742fa6668 Fix T66964: sculpting box hide tool can't select multiple areas
Only deselect all on mouse release when no box dragging was done.
2019-07-16 19:10:18 +02:00
35aa13734d Fix T66862: crash with bevel modifier harden normals applied to curve object 2019-07-16 18:06:49 +02:00
8a7dedc9d2 Fix T66011: Transformed objects break sculpt tools
The Pinch, Push, Twist and Clone were not using the object transformation to compute point changes, so the point was way off of the right place.
2019-07-16 17:57:25 +02:00
1f1d302950 Fix T66940, T67005, T60651: append workspace from old startup file fails
Don't try to use old screens as workspaces, just leave them out of the menu.

Differential Revision: https://developer.blender.org/D5270
2019-07-16 17:46:45 +02:00
91f539b384 Fix T66862: crash with mirror modifier applied to curve object 2019-07-16 17:46:42 +02:00
28c684f66b Fix T66999: Blender creates new cache for particles with step 10 instead 1
Update the default init step values to be the same for all caches.
This is actually a small hack as these values are not used on the
creation of the first cache. But the default init value is 1, so this
will not be noticeable anymore.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5271
2019-07-16 17:33:24 +02:00
105ae3be99 Fix T66944: Rigid Body Constraint in duplicated collection is not added to RigidBodyConstraints collection.
We only had a very limited, specific handling of that in collection
duplication code, but this has to be handled at a much more general
level in Object copy code itself, since it makes no sense to duplicate
rigidbody object data without adding new copy to relevant rigidbody
collections...

WARNING: This is a fairly risky rework of rigidbody handling logic
when copying an Object data-block. It is *NOT* considered safe enough
for 2.80 release.

I tried to take into account copy flags to not mess with other IDs
(collections) when we are copying outside of Main, and also not do deg
tags when this is forbidden, but risk of something going wrong here is
too high...
2019-07-16 16:08:32 +02:00
e6e69a28ab Fixed crash when adding/removing custom normals from pinned mesh
When a mesh is pinned in the properties panel, Blender crashes when you
click the "Add Custom Split Normals Data".

The code calls `ob = ED_object_context(C)` which returns NULL when the
mesh is pinned in the properties panel, causing a segfault when trying
to get the mesh via `ob->data`.

A new function `ED_mesh_context(C)` avoids this by first checking
whether a mesh was pinned in the context. If not, it checks the pinned
object's data. If that's not there, or it's not a mesh, it returns the
active object's mesh. Finally it returns NULL if there is no active
object, or if the active object is not a mesh object.

Reviewed By: brecht, mont29

Differential Revision: https://developer.blender.org/D5223
2019-07-16 15:06:25 +02:00
dd3e3474ab fix T66899: Collada: Shininess/Reflectivity not handled correct
Fixed: The Collada Exporter only supports export of
Lambert Shaders. But Shininess is not supported with
Lambert Shaders. The exporter must not add Shininess
to the Shader data!

Fixed: The Collada Importer adds an illegal value of -1
for reflectivity when this parameters is not defined in
the imported collada data. Now reflectivity is only
set when the import data contains a valid value.

Discarded: The Collada Importer handles shininess in a
dubious way. I have discarded import for now.
This needs to be reworked carefully in 2.81.

Differential Revision: https://developer.blender.org/D5262
2019-07-16 13:28:40 +02:00
965bd4c8c3 Fix T66742: Frame selected last weightpaint/vertexpaint stroke not
working

Mouse values [for 'paint_last_stroke_update()'] gone missing in
rB4f616c93f7cb.

Thx @campbellbarton for hinting at convention to get mouse from sculpt
caches.

Reviewers: campbellbarton

Maniphest Tasks: T66742

Differential Revision: https://developer.blender.org/D5267
2019-07-16 13:27:12 +02:00
c4a62493de Fix T66835: Dynamic Paint weight group isn't updated unless weight has been assigned
The dvert layer was not assigned to the mesh data if it had to be
created by the dpaint modifier.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5263
2019-07-16 11:44:08 +02:00
6b3c1192e1 Fix error in app-template image size check 2019-07-16 19:40:23 +10:00
b0b2546d4a Fix assert unlinking text
Interferes with debugging.
2019-07-16 17:27:53 +10:00
c635663e4a Fix T67040: Undo crashes after renaming
Caused by error keeping the first memfile undo step.
2019-07-16 17:14:19 +10:00
d5f725a238 Cleanup: typos in comments 2019-07-16 16:58:04 +10:00
1fa61c8843 Fix typo in background_job template
D5264 by @dimtion
2019-07-16 16:56:25 +10:00
d5fa230736 Fix T67002: Crash redoing an action after ID rename 2019-07-16 15:53:15 +10:00
fdf2d8728a Docs: remove debug value, matching source 2019-07-16 13:26:37 +10:00
af51988115 Fix T67009, T67013: crash with Intel HD Graphics and some older drivers
Add more versions to the workaround list.
2019-07-15 22:44:29 +02:00
f3899c13cd Fix T64827: "Batch-Generate Previews" crashes.
Second completely unrelated issue reported in same task (tssst...),
caused by missing doversion code of some changes in recent-ish 2.80
development (tsst... again).

Proper fix for the issue (reverted rB8a5a8282ce48 was merely sweeping
the dirt under the carpet...).
2019-07-15 22:33:55 +02:00
125e0cfb25 Revert "Fix T64827 (part two): "Batch-Generate Previews" fails with certain files"
This reverts commit 8a5a8282ce.
2019-07-15 22:33:55 +02:00
c42b7f8434 Fix T66986: fix dylib plugins on macOS not working in code signed release
Add more entitlements for code signing.
2019-07-15 22:22:50 +02:00
8faaeef5fb Fix T67016: crash drawing image editor without image 2019-07-15 22:22:50 +02:00
d061154b93 Fix T66983 Wireframe Display in edit mode edges missing when overlays are disabled 2019-07-15 19:55:09 +02:00
4404a0dcd4 Fix T66707 Modifying bone's 'Custom Object' reference shape causes blender to crash
This was caused by an instancing batch not being initialized correctly.
2019-07-15 19:27:54 +02:00
0b25566143 Fix T66955: Cannot delete data from file in outliner.
That switch on ID types had not been updated since quiet some time it’d
seem... Using the ID_Type enum type now, so this should not happen again
(compiler will yell at you if you forget to add here any new ID type ;) ).

Also had to change a bit the code layout then, to deal with fake NLA ID
type...

Note that for now, Screen IDs remain excluded from the ID menu usage,
due to T67004.
2019-07-15 18:10:26 +02:00
9cdd2df277 Fix T66712: A model shows artifacts in the sculpt mode
Was a mistake in normals calculation: need to consider all grids for correct
average in the center of the face.

Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T66712

Differential Revision: https://developer.blender.org/D5254
2019-07-15 17:38:47 +02:00
ff1b5af307 Fix compositor ignoring mask parenting
There are two aspects to the problem:

- Dependency graph update for compositor preview was missing
  updates flush.

  Apparently, update for new frame style of update will take
  care of flushing, but not the update tagged style of update.

  This goes to a legacy dependency graph and is to be changed
  at some point, but not so close to the release.

- Movie clips were missing from the compositor dependency graph.

This fixes part of T66519.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5256
2019-07-15 17:36:54 +02:00
ee55ac19dc Fix T66870: AutoIK-Len stops working after releasing the mouse
The code didn't check if we should initialize the transform auto IK parameters.
Cleaned up the code a bit too.

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5260
2019-07-15 17:30:12 +02:00
daff18dd28 Fix T63349: image texture garbage collection causing freezes
Images were being freed often because the tagging for when the image was last
used was missing.

Differential Revision: https://developer.blender.org/D5252
2019-07-15 17:24:20 +02:00
846e5f1dc0 Fix T66812: Particles + Build Modifier = Crash
Particles can not be used with a destructive modifiers, so we can not
maker such configuration fully reliable.

Not sure this specific setup ever worked in 2.7x, maybe DM index was
somehow reset somewhere in particle system in older Blender version,
or maybe all of Blender version were crashing.

Anyway, seems to be very easy to avoid obvious index past the array
boundary in the mapping,

Reviewers: brecht, zeddb

Reviewed By: brecht

Maniphest Tasks: T66812

Differential Revision: https://developer.blender.org/D5257
2019-07-15 17:03:33 +02:00
69aa5bba4f Fix T66941: GPencil wrong interpolation calculation for last keyframe
The range used for frames was wrong and the last keyframe was way off of the correct place.

Thanks to @MagnumOctopus for catching the bug.
2019-07-15 16:56:54 +02:00
8a5a8282ce Fix T64827 (part two): "Batch-Generate Previews" fails with certain files
Some values (not properly handled by do_versions?) could cause
'rna_backup_restore()' to throw an error resulting in the whole preview
generation not being saved to the .blend file.

I've checked folowwing demo files:
- race_spaceship.blend
- wasp_bot.blend

Here the offending seetings were:
- `UnitSettings` (`length_unit`, ...)
- `FFmpegSettings` (`ffmpeg_preset`, ...)

For now, these are now excluded in `exclude_props`

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5255
2019-07-15 16:38:59 +02:00
70d193203b Fix T66668: frame selected bone not working in weight paint mode
'viewselected_exec()' [which uses evaluated view layer] would query
BASE_SELECTED flag, but it was not set on base_eval, but on its
base_orig.

reason for this is 'ed_object_select_pick()' would modify base flags
[through 'ED_object_base_select()'], but not tag scene
ID_RECALC_BASE_FLAGS.

thx @sergey for hinting.

Reviewers: sergey, brecht

Maniphest Tasks: T66668

Differential Revision: https://developer.blender.org/D5235
2019-07-15 16:20:11 +02:00
914427afd5 Fix T66686: Crash on Particle Edit, then Render
Reviewers: brecht, zeddb

Reviewed By: brecht

Maniphest Tasks: T66686

Differential Revision: https://developer.blender.org/D5259
2019-07-15 15:54:27 +02:00
9db772fe9a Fix T66991 Crash when deleting edit bones when pchan is referenced by bendybone
This was caused by loose pointers.

This diff takes care of clearing the fields of other bones before deleting the pchan.

Reviewers: brecht, sergey

Reviewed By: brecht, sergey

Differential Revision: https://developer.blender.org/D5258
2019-07-15 15:13:45 +02:00
e66c3589a2 Fix T66986: errors with add-ons using ctypes in macOS release
Add extra entitlements to allow the kind of unsigned executable memory access
that cytpes does.
2019-07-15 14:20:27 +02:00
ef35dc68d6 Fix T66774 Lookdev: Assert switching from rendered to lookdev
The View was being reused accross different redraw (not allowed).
2019-07-15 13:14:50 +02:00
65a3624877 Fix T66860 Crash on opening .blend file from 2.79
This was caused by the preview render of the material property panel being
1px wide. The computed half buffers width were rounded to 0.
2019-07-15 13:07:42 +02:00
761135a284 Fix showing "__pycache__" in templates menu 2019-07-15 19:40:27 +10:00
d2a4a03890 Fix reading directory as file content on Linux
Reading a directory as a file on Linux was attempting to allocate LONG_MAX,
this happens in template file lists (fix for that coming next).
2019-07-15 19:40:27 +10:00
576963d7c1 Fix crash running GPU shader.format_calc() with attributes like gl_VertexID
When using opengl attributes such as gl_VertexID in a shader its
location is set to -1. This location was used without checking in an
attribute array. This fails big time when called from python. For
example `print(shader.format_calc())` made python crash immediately.

this fixes https://github.com/JacquesLucke/animation_nodes/issues/1141

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5231
2019-07-15 11:24:38 +02:00
872025c4e5 Fix crash HD Graphics 4000 Series On Windows
There was an workaround implemented for specific the Intel HD Graphics
4000 GPU on Windows platform. Other GPU from the same series also need
this workaround.

We will enable the workaround for specific drivers.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5239
2019-07-15 11:22:35 +02:00
8fa50b522a Fix T66587: Can't bake second dynamic paint canvas to image sequence
The issue was the the copy data function didn't copy the active canvas number.
So it would always be 0 and thus use the first canvas when trying to bake.

Also fix not copying unused type data (unused canvas/brush settings).

Reviewed By: Brecht

Differential Revision: http://developer.blender.org/D5220
2019-07-15 10:47:49 +02:00
bb165d6df1 Fix T66957: GPencil material isolate crash when slot is empty
When the slot of the material is empty, the loop to lock the materials tried to use the material but this was NULL.

Check if material is NULL before using it in other operators too.
2019-07-15 09:53:27 +02:00
986c283c07 Fix T66953: Duplicate items in pose context menu 2019-07-15 14:22:22 +10:00
65168825e0 cleanup: typo in cycles 'min_transparent_bounces' tooltip
Reviewers: brecht

Differential Revision: https://developer.blender.org/D5249
2019-07-14 23:02:51 +02:00
1f57157601 Cleanup: Do not use camel case for "Freestyle" 2019-07-14 15:29:15 -04: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
e3c586e262 macOS: clarify bundle script instructions 2019-07-12 19:50:39 +02:00
1c73b60484 macOS: allow bundle script to re-codesign a Blender.app that was already signed 2019-07-12 19:19:10 +02:00
b94df17ae5 macOS: remove hardcoded paths for code signing python/dylib/so
Differential Revision: https://developer.blender.org/D5234
2019-07-12 18:59:27 +02:00
8d4800990c Fix T66601: Redo Panels are empty the first time a workspace is active
We need to indicate a preferred size to avoid `RGN_FLAG_TOO_SMALL` the first time the region is created.

Differential revision: https://developer.blender.org/D5238
2019-07-12 11:37:18 -03:00
18310ad509 Fix T66773: Active edit-bone isn't updating 2019-07-13 00:20:28 +10:00
3569fdb745 Cleanup: use _orig as a suffix 2019-07-13 00:14:14 +10: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
53a7ce1f8a UI: increase contrast for active bone
Follow up for T66747 fix, active color didn't contrast enough.
2019-07-12 22:30:25 +10:00
f3848e8e1e Fix T66747: Active bone not showing in edit-mode 2019-07-12 22:24:37 +10:00
325501247d Fix AttributeError in mesh properties panel when mesh is pinned
When a mesh datablock is pinned in the properties panel,
`context.object` is `None`. This in turn causes `obj.mode` to raise an
`AttributeError` exception as `None.mode` doesn't exist.

Since there is no (fast/simple) way to check whether the owning object
is in edit mode or not, the properties will be disabled. Not ideal, but
better than spewing an exception on every panel draw.

Reviewed By: campbellbarton, brecht

Differential Revision: https://developer.blender.org/D5237
2019-07-12 14:18:17 +02:00
439777f081 Fix T66689: Viewport isn't updating children hair particle on particle edit
Reviewers: fclem, brecht

Maniphest Tasks: T66689

Differential Revision: https://developer.blender.org/D5229
2019-07-12 14:09:20 +02:00
2048db06d3 Fix T66694: depthdropper (camera focus distance) not working from View3D context menu
Reviewers: campbellbarton, brecht

Maniphest Tasks: T66694

Differential Revision: https://developer.blender.org/D5233
2019-07-12 14:03:58 +02:00
83010c2f02 Fix T66446: UV editor "Deselect on Nothing" not working 2019-07-12 19:19:37 +10:00
f1af8908b3 Fix keymap editor missing tools for UV/Image space 2019-07-12 19:05:03 +10:00
1499994557 Fix T66675: Auto-Save override button has no tooltip 2019-07-12 15:45:52 +10:00
f2df520698 Preferences: disable reading preferences for regular file loading
Although the Auto-Run Python Scripts flag isn't used,
this is still a security risk since exclude paths list is.

Further this isn't what users would expect when loading a file &
only some preferences were being loaded so it's not useful.
2019-07-12 15:04:36 +10: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
7ad21c3876 Fix T66604: Cycles bake crash on specific scene with volume
The issue was caused by un-initialized local storage for volume
intersection hits which are supposed to be stored in per-thread
KernelGlobals.

Fix is to make thread_shader() be the same as thread_render() in
respect of KernelGlobals.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5230
2019-07-11 15:44:09 +02:00
f0b72a776e Fix T66706: crash in viewport shading popover for workbench engine
Differential Revision: https://developer.blender.org/D5226
2019-07-11 15:03:13 +02:00
8a1552545a Fix T66672: auto and manual texture space affected by modifiers
It should be based on the mesh bounds before modifier stack evaluation, but
some modifiers were causing it to be recomputed. The flag to disable texture
space recomputation was not preserved through modifier evaluation.

Differential Revision: https://developer.blender.org/D5225
2019-07-11 14:44:57 +02:00
d663048696 Fix T66691: Ceash trying to render the 2.80 splash image
Was caused by ray direction becoming NaN after some of the bounces.
2019-07-11 13:00:26 +02:00
03d8bfb144 API Doc link: make releases/RC's point to their own version of the doc.
Sounds kind of stupid to have 2.79 pointing to "current" which is now
2.80 API doc... Let's try to avoid that in future.
2019-07-11 12:13:11 +02:00
7c48b6c84c Fix for RC release step to also point at 'current' API doc link.
RC's are supposed to be like "real" releases...
2019-07-11 12:13:11 +02:00
3c4f6399d9 Fix T66628: "Auto Saved Modified Image" not working
Reviewer: brecht
2019-07-11 12:06:21 +02:00
a7ac40888f Text: buffer from text, optional length return arg
No functional changes (currently unused).
2019-07-11 14:19:55 +10:00
676543d91f Fix T66658: Undo steps gets out sync with text/edit-mode 2019-07-11 09:46:47 +10:00
1544b9322c Undo System: add is_final argument (no functional changes)
This is needed step out of undo steps which accumulate changes,
larger changes could be made to handle this but better not
make them at this point.
2019-07-11 09:36:59 +10:00
e60d35153f Cleanup: avoid recursion for undo/redo step skipping
Simplifies making further changes.
2019-07-11 09:22:42 +10:00
d3a8d25fb3 Cleanup: clang-format 2019-07-11 09:22:42 +10:00
de203b26c2 Cleanup: quiet warning 2019-07-11 09:22:42 +10: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
bb7b741d2f Fix T66654: wireframe overlay crash in vertex paint in some cases
Differential Revision: https://developer.blender.org/D5218
2019-07-10 17:05:19 +02:00
91d3b00395 Splash: new image for 2.80 by Andy Goralczyk and the Spring team 2019-07-10 16:48:06 +02:00
53c8fd5447 Fix T66567: Weight painting crashes with specific mesh
Seems the deform group index and deform vertices went out of sync somehow.

Added extra NULL pointer check, which seems to be safe and matches checks
in other places in the neighbourhood.
2019-07-10 16:03:19 +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
a6ae53ef49 Fix strict compiler warning 2019-07-10 15:03:57 +02:00
8d8ebc73b6 Splash: put version number in top right, refactor code for easier changes 2019-07-10 14:56:19 +02:00
dc2b562ace Splash: use red heart icon for development fund
Now that the development fund image will disappear from the splash, this
draws a little more attention to this link.
2019-07-10 14:51:30 +02:00
7a431d40e3 Fix splash screen margins not being even and buttons not centered 2019-07-10 14:51:14 +02:00
7695fd9cff Fix release notes not showing in splash without recent files 2019-07-10 14:51:14 +02:00
526876a634 Fix T61770 Multiple Hair Systems Not visible while in particle edit mode
The check was for the whole object instead of individual particle system.
2019-07-10 14:44:09 +02:00
b39d7e484c Fix T66631: Crash when converting objects from Curve to Mesh
When `BKE_mesh_new_from_object()` cannot convert an object to a mesh, it
returns `NULL`. This case was not handled at all in
`BKE_mesh_new_from_object_to_bmain()` or `curvetomesh()`, causing a
segmentation fault.

This commit fixes the segmentation fault, and leaves the curve object as
a curve object.

Reviewed By: mont29, brecht, sergey

Differential Revision: https://developer.blender.org/D5217
2019-07-10 14:13:42 +02:00
Dalai Felinto
d3e1782abc Fix T66530: set_stereo_3d (pageflip) exists Blender
Note: Although this fixes the issue (as in, it prevents a crash)
BKE_reports are not working because of CTX_wm_window_set().

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D5210
2019-07-10 09:11:33 -03:00
Dalai Felinto
fde88ad9d2 Fix T66627: Multiobject Edit UV constraint to image bounds
This was broken since the original commit to handle multi-object
editing: rBbfc9d426bb95.
2019-07-10 09:04:24 -03:00
91b4262728 Fix T57489 Eevee: Texture coordinate object reference not working for world 2019-07-10 13:46:28 +02:00
956d38488a Undo System: ensure the text ID for each undo step is used
In practice this wasn't causing errors,
however it could be an issue in the future.
2019-07-10 21:42:17 +10:00
56ec8108e2 Fix T65850 Sculpt: Vertices not hidden if using shape keys 2019-07-10 13:23:54 +02:00
ee4fa41245 Fix T66560 Sequencer: Shortcut keys no showing in menu for 'Move' and 'Refresh All'
The menu shortcut context for 'Refresh All' was wrong and the actual operation
exectuted in the menu for the 'Move' command was different from the shortcut.
2019-07-10 12:57:58 +02:00
12ceea0434 Fix crash when clicking in window while Blender starts
A mouse click in the window will trigger the `VIEW3D_OT_cursor3d` operator
before the viewport is available. This causes a segfault in
`GPU_viewport_engines_data_validate()`.

Other callers of `WM_draw_region_get_viewport()` already check for `NULL`
being returned and handle it gracefully.

Reviewed By: jbakker, fclem

Differential Revision: https://developer.blender.org/D5216
2019-07-10 12:32:10 +02:00
f9232c080d DrawManager: Crash Face Selection
Init the scene of the draw context when selecting. When using face dot selection on
when the subsurf modifier is active on the cage, the scene needs to be
valid. It is read from the context in the
`DRW_mesh_batch_cache_create_requested` and used in the `isDisabled`
method of the SubSurfModifier.

Reviewers: fclem, sergey

Differential Revision: https://developer.blender.org/D5214
2019-07-10 12:18:41 +02:00
6f1190cbf0 Fix T66630 X-Ray + Subdivision surface Face select problem 2019-07-10 12:13:08 +02:00
d3b42fc167 Fix T66626: Crash when using JACK audio device
Restore some context overrides which were originally happening in 2.79.

Made it a bit more paranoid, by storing old values and restoring them
afterwards, so the context is not being changed at the end of the function.
2019-07-10 11:58:37 +02:00
f4b963dbdd Undo: print the undo stack when ed.undo logging is enabled
Print the undo stack on undo/redo when ed.undo logging is enabled.
2019-07-10 19:39:53 +10:00
167f5a61e5 C Logging: add macro to check if logging is enabled 2019-07-10 19:39:53 +10:00
d4d16e7a03 Docs: note about select debug value 2019-07-10 19:39:53 +10:00
2e91fc39ac Fix broken Mesh 'calc_smooth_groups' logic.
We need to check both polygons of a manifold edge to be sure it is
actually smooth...

Reported by Hugo Sales (@someonewithpc) on blender.chat, thanks.
2019-07-10 11:24:37 +02:00
e9d3e056d1 Fix T66571: Unable to change input color space of PSD
Image reader must not override file's color space specification if it
is already specified.
2019-07-10 10:08:18 +02:00
0829bd7b66 Alembic export: avoid BLI_assert() failure when object is not in depsgraph
When the object we iterate over is not part of the depsgraph, we cannot
get the evaluated copy to export. This workaround is temporary to avoid
a BLI_assert() failure getting the evaluated mesh of this object.

This will be handled more elegantly in the new AbstractHierarchyIterator
that I'm working on, but that requires a bigger change than we should
allow this close to the 2.80 release candidate.

This fixes a problem described in T58686.
2019-07-10 09:56:27 +02:00
e927ce8acb Cleanup: avoid line breaks from trailing comments 2019-07-10 14:41:19 +10:00
91b8e57d65 Cleanup: avoid accessing same vars multiple times 2019-07-10 14:01:39 +10:00
31f922bff6 UI: use a label for strip 'frame_final_end'
This is intended for Python access and allows temporary negative frames
which is a problem when accessed from the UI.

This allows:

    seq.frame_final_start, seq.frame_final_end = frame_range

However it allows invalid sequence strips,
using a label is fine since there is a duration property here which
can change the length.
2019-07-10 13:48:03 +10:00
95fcdb0401 Cleanup: reserve single quotes for enums 2019-07-10 13:39:56 +10:00
3b4054cb58 Revert strip start property to strip_start
Using strip_final_start affects strip offset while not moving content.
2019-07-09 15:45:45 -07:00
2893417d67 Fix T62580 Workbench: Shadow glitch due to degenerate threshold
Fix by adding a threshold instead of direct null comparison.
2019-07-09 20:38:46 +02:00
29ebb37419 Fix T66565: crash linking unused light datablock during Cycles preview render 2019-07-09 19:49:09 +02:00
23f1bc7414 Fix T66605: Operation on origins not working correct 2019-07-09 18:52:41 +02:00
Julian Eisel
6e3158cb00 Only print info messages with --debug-xr enabled 2019-07-09 17:49:54 +02:00
3f208ed927 Raise particle count limit for 2.8 release
Blender 2.8 features significant improvements in the creation of particles.
Removed hard limit and increased soft limit.

Patch by Gottfried Hofmann.
Differential Revision: https://developer.blender.org/D5120
2019-07-09 17:43:54 +02:00
b77c01924a Alembic import: fix crash when loading invalid mesh
These were just some missing nullptr checks.
2019-07-09 17:39:02 +02:00
817e2796cb Fix T52814 and T58686: Alembic crashing on fluid sim export
The velocities std::vector was allocated in too narrow a scope, causing
use-after-free errors.
2019-07-09 17:39:02 +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
6510ab8676 Fix T66456: UV Editor missing update after selection change in 3D viewport
Reviewers: brecht

Maniphest Tasks: T66456

Differential Revision: https://developer.blender.org/D5207
2019-07-09 15:49:40 +02:00
32f591c0a3 Fix T66610: Planar Track extremely laggy when 3D View is open
The issue was caused by modifications to planar track tagging clip for
copy-on-write, which was invalidating its cache and forcing current
frame in 3D viewport to be re-load.

Ideal solution would be to share movie cache across original and
evaluated movie clips which will reduce memory usage. However, doing
such ownership changes so close to the code freeze is not something
comfortable to do.
2019-07-09 15:46:29 +02:00
fd48ef25a0 Fix (minor) some typos and other errors in UI messages. 2019-07-09 15:30:24 +02:00
b1020ca169 Fix crash on redo applying transforms
When accessing evaluated objects, make sure access to an
evaluated dependency graph is done. This solves possible
access to NULL data on redo.

See https://developer.blender.org/D5209
2019-07-09 14:59:30 +02:00
7bf820fb96 Fix uninitialized loop variable
Fix commit 226c6f086a
2019-07-09 14:55:32 +02:00
977c48b88d Fix T64149: Texture paint can act as a canvas and brush at the same time
I don't know if it was the intended behavior or not, but having brush
and canvas data at the same time with dymanic paint, would lead to the
object trying to act as a brush and a canvas at the same time.

We can't currently handle this with the new depsgraph, and it could
legitimately lead to bad feedback loops.

So now, to be more consistent with the GUI, I've made it only use the
current set type (brush or canvas) as the final type of the object.
That is, you can only have a object be a brush or a canvas, not both at
the same time.
2019-07-09 14:49:08 +02:00
dd84ff212a Fix crash when redoing Set Origin operator
The operator was using a non-evaluated depsgraph to get the evaluated
scene, which caused the crash.

This fixes the crash reported in T66605, but not the problem where
sometimes object origins aren't set.
2019-07-09 14:45:20 +02:00
484794ce67 Eevee: Fix first sample being accumulated without SSR
We check if the previous iteration (sample) was using a valid double buffer.
If it wasn't, we request another iteration.

This fix the issue for viewport,viewport render and image render.

Related to T65761 Eevee render inconsistency between 3D View, Viewport render, and F12 Render
2019-07-09 14:34:56 +02:00
986ff461fb Fix T65761 Eevee: SSRefraction not working on first sample
There is no reason to disable the refraction on the first sample like SSR
does.

This was caussing issues when rendering.
2019-07-09 14:34:56 +02:00
7e34846176 Cleanup: GPU: Correct comment 2019-07-09 14:34:56 +02:00
db45aaafab Fix T61474: laggy interaction on Windows/NVIDIA when gizmos are visible
Thanks to Sergey and Clément for helping to track this down.
2019-07-09 14:03:25 +02:00
89c762dd99 Fix T57652: Multires undo broken with shared object data 2019-07-09 12:12:54 +02:00
25a0acd0a6 GPU: ATI Proxy check
The AMD PRO driver on linux PROXY check also fails. Now the
configuration ATI/Unix/Official driver  will also bypass the
Proxy test.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5205
2019-07-09 12:01:25 +02:00
805cabdf17 Fix T64483: crash when hovering over outliner after closing render window
The `tselem->id` pointer can also be used for non-ID data (according to
this comment in DNA_outliner_types.h:

```
/* XXX We actually also store non-ID data in this pointer for identifying
 * the TreeStoreElem for a TreeElement when rebuilding the tree. Ugly! */
```

As such, I don't mind adding a `NULL`-check in the
`is_object_data_in_editmode()` function. After all, when there is no
object, its data certainly is not in edit mode.
2019-07-09 11:52:16 +02:00
Julian Eisel
a05104d61f Fix warnings and compile error on GCC 2019-07-09 11:28:17 +02:00
2b43ec56af Fix T66274: Object Texture Coordinate mode not updating in Lookdev / Eevee 2019-07-09 11:24:39 +02:00
Julian Eisel
7fe1cc8d24 Enable grid floor in VR session
Helps quite a bit orientating.
2019-07-09 10:56:37 +02:00
516afd0162 Implement Movieclip filter for action editors
Allows to disable keyframes from movie clips in dopesheet.

Reviewers: brecht

Reviewed By: brecht

Subscribers: sebastian_k

Differential Revision: https://developer.blender.org/D5203
2019-07-09 09:59:34 +02:00
ef5d0a927e Fix T66516: WPaint crash selecting bone with wire & face-mask 2019-07-09 15:14:46 +10:00
05d14c4560 Fix T66359: UV editor ignores face-dot size
D5178 by @deadpin
2019-07-09 12:25:19 +10:00
52cf94eeb5 API Docs: Change handling of Blender Version 2019-07-08 20:53:15 -04:00
75d48c6efd API Docs: Hide Home Icon in Seach Area 2019-07-08 20:53:15 -04:00
ac8c795429 GPU: added debug value to investigate lagging issue in T6147 2019-07-09 01:33:20 +02:00
a42cae1600 Fix T55192: Speed fx applied to scene messed up animation
Don't update animdata after rendering scene
Rendering host scene from sequencer is not supported, removed code is unnecessary.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5199
2019-07-08 15:16:46 -07:00
f04424a15d Fix T66573 Heap Corruption when baking to irradiance volume probe
This is an AMD Proprietary driver bug. Will be reported upstream.
2019-07-08 23:52:06 +02:00
96f5918407 Fix (unreported) UI: useless setting shown for Text data-blocks.
Since we do not have start/end settings for bevel object for Text,
mapping taper to those ends makes no sense here, we can hide that
setting.
2019-07-08 22:48:17 +02:00
fa27d81937 Fix T61401: Failure to register a GizmoGroup after unregistering it
It does not seem right to rely on the python code to fix problems in the C code.
But this already works like this with the other Python Classes.
2019-07-08 13:48:01 -03:00
ff91f605f0 Revert "Fix T61401: Failure to register a GizmoGroup after unregistering it"
Problems with ClangFormat

This reverts commit c1bcde0c0f.
2019-07-08 13:44:03 -03:00
be5911571e Revert "Revert "Fix T63447 Particle system: No particles after switching from hair to ...""
This reverts commit 45761e4c7c.
2019-07-08 13:41:27 -03:00
45761e4c7c Revert "Fix T63447 Particle system: No particles after switching from hair to ..."
Problems with clang style

This reverts commit 8d6a5fb5d3.
2019-07-08 13:40:06 -03:00
c1bcde0c0f Fix T61401: Failure to register a GizmoGroup after unregistering it 2019-07-08 13:37:51 -03:00
8d6a5fb5d3 Fix T63447 Particle system: No particles after switching from hair to ...
... emitter type
2019-07-08 18:09:52 +02:00
3f6e17ddaf Fix T63659 "Viewport render image" don't process corectly "Display As" option 2019-07-08 18:09:52 +02:00
7767e080a0 Fix T66008 Viewport: hidden edges are partially visible
This was a regression from 2.79. The zoffset was doubled for some reason.
2019-07-08 18:09:52 +02:00
1715c396e4 Fix T65534 Eevee don't respect active UVmap 2019-07-08 18:09:52 +02:00
8a7c2c4192 Fix T66351 Wireframe display in sculpt-mode broke when hiding parts 2019-07-08 18:09:52 +02:00
9526e236fc Fix T66348 Eevee: Broken shader if using textures and shader_to_rgb node
Was caused by a missing texture resource.
2019-07-08 18:09:52 +02:00
473259f98b Fix T66475 Spin Modifier: Merge Vert Makes mesh disappear 2019-07-08 18:09:52 +02:00
6b7bc30c64 Fix T66470 Planar track is not adjustable
The issue was that the shader used was expecting GL_LINES and the points
were using GL_TRIANGLE_FAN.
2019-07-08 18:09:52 +02:00
226c6f086a Fix T62941 Subdivision Modifier Showing all face dots
Previously in 2.79 we were using a specialized drawing using derivedMesh.

Now the subsurf modifier tag each center vertex as facedot and let the
DRWManager pick it up.

Some modifiers (deforming ones) do not clear the tag so we can use this
technique even if there is deforming modifiers after subsurf modifiers.
2019-07-08 18:09:52 +02:00
0a16519f5d Fix T61129 Eevee: alpha texture shadow bug
Seems like the AMD pro driver does not consider dead code the same as other
glsl compiler.
2019-07-08 18:09:52 +02:00
9a0a952f72 API Docs: Fix file name 2019-07-08 11:45:25 -04:00
867cd8218a Fix T66556: Noisy drivers relations in certain cases 2019-07-08 17:38:40 +02:00
b2a9627600 Fix T62903: black line in UV editor on 32 bit 2019-07-08 17:34:22 +02:00
50d0a74833 Fix T66538: Menus in popups opening on mouse over
Caused by b708917d94

Solve by restricting this change to popovers
instead of other kinds of menus (enums mainly).
2019-07-09 00:55:26 +10:00
a4bc6aca0e Fix T66554: Measure doesn't snap with Ctrl 2019-07-09 00:18:24 +10:00
6546442f4f Fix (unreported) broken 'compse' feature when editing text.
Looks like that code was not updated when we switched to unicode, it was
still returning axtended ascii codes (iso-8859-15 ones I think)...

That was breaking some chars, which have a very different value in
unicode. Found while working on Text section of the Manual! ;)
2019-07-08 16:11:55 +02:00
9cb1810551 Fix T66431: SE - Audio Caching crash
Moved the caching code from direct calls in DNA to dependency graph.

In fact, not much was needed to be done apart form removing the direct
cache updates. The rest seemed to work fine.

Possible to avoid full sound file re-load, but doesn't seem this is
causing any issues.
2019-07-08 15:57:33 +02:00
8066784ac2 Fix T66499: Parenting a Mask to Plane Track doesnt work 2019-07-08 14:48:42 +02:00
27adc4aa33 UI: Update tooltip of Vertex Selection masking
Since it is now possible to use it in Vertex Paint, not just Weight Paint.
2019-07-08 14:40:48 +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
4ca054617b Fix T66526: child's objects move if change their origin position
Reviewers: sergey

Maniphest Tasks: T66526

Differential Revision: https://developer.blender.org/D5201
2019-07-08 14:06:10 +02:00
90dae36213 Fix T66524: Eyedropper in popover crashes 2019-07-08 20:40:34 +10:00
d6ebd04bb3 Fix T66525: Wrong apply scale for children chain
The operator did not behave correct when there was a chain of parents
longer than 1.
2019-07-08 12:23:24 +02:00
118a0df7a7 Fix T66517: Clip editor doesn't respect the 2D cursor
Was caused by 91b768ccb1 which re-defined masks menu with the wrong
invoke type.
2019-07-08 11:46:40 +02:00
08aad00a5d Fix wrong colors when creating a float normal map image in texture paint 2019-07-08 11:05:45 +02:00
f49692f429 Cleanup: Spelling in function name 2019-07-08 10:53:37 +02:00
bb2abacb4b Keymap: Vertex Paint: Add ctrl to temporarily swich colors
This now matches Texture Painting
This was added in rB7d5fb2e103e03046194d69640aadf7e76a700620 but was 
lost probably when migrating to python keymap.
2019-07-07 19:53:44 -04:00
d19d0ff99e Fix T66376: Problem with Gpencil fill tool
The fill material has an alpha > 0, but the show fill is disabled, but as the fill tool is considered the fill as visible and the stroke is not drawn, the fill area had a gap.
2019-07-07 22:28:41 +02:00
ad16af7a7e Cleanup: split enum types, use PF_CMP prefix 2019-07-08 00:43:44 +10:00
1357dd7d3c Cleanup: move enum unto BKE_packedFile.h
Use enum type for functions arguments.

Removed -1 check in switch statement, this isn't needed.
2019-07-08 00:17:40 +10:00
084d545202 Cleanup: use BKE_packedfile prefix for function names
Avoid ambiguity with terms check & compare.
2019-07-07 23:57:35 +10:00
28057d54de Cleanup: clang-format 2019-07-07 23:45:35 +10:00
9e12d762a2 Fix crash running an operator from a popup,
Cell fracture redraw option was crashing.
Change operator popup behavior to close the UI before executing
since the operator may perform operations which change/remove the UI.
2019-07-07 22:35:52 +10:00
414875ce96 Cleanup: unused vars, redundant parenthisis 2019-07-07 22:33:35 +10:00
d7f687c833 Cleanup: use static set 2019-07-07 22:33:35 +10: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
0735c12ca8 GPencil: Hide reference points when use Parallel or Grid guide
These options are not used by these modes. Detected while writing the manual.
2019-07-07 09:38:52 +02:00
cd6b49f995 Cleanup: spelling 2019-07-07 15:38:41 +10:00
a3e2076bc4 Docs: update window/screen introduction
Include global region/areas.
2019-07-07 15:22:16 +10:00
f2a11550b9 Fix T66493: Enable Add-on name not showing in favorites 2019-07-07 14:17:33 +10:00
b1c3038f18 Fix Filter Add-ons panel display for missing add-ons
Check the add-on exists before getting it's info.
2019-07-07 14:15:28 +10:00
e68c8ba24e Cleanup: rename gpencil chess -> checker
Match existing texture name.
2019-07-07 13:54:25 +10:00
7a6c50e79c UI: Correct tooltip 2019-07-06 20:35:52 -04:00
313097c267 API Docs: Fix Links 2019-07-06 19:46:05 -04:00
903b5e1082 UI: Cleanup tooltip format 2019-07-06 19:39:48 -04:00
e106765c96 UI: Cleanup tooltip format 2019-07-06 18:58:03 -04:00
e1fbab12dc API Docs: Update Changlog for 2.80 2019-07-06 17:01:11 -04:00
8933a3bbd0 API Docs: Fix Update changelog script to python3 2019-07-06 17:01:11 -04:00
1f2f5f660b API Docs: Use Opensearch 2019-07-06 17:01:11 -04:00
f702830a79 API Docs: Theme: Prevent Super Long Enums 2019-07-06 17:01:10 -04:00
6fad70d551 Cleanup: API Doc Gen: move copying static dir to own function 2019-07-06 17:01:10 -04:00
df5f06cac2 GPencil: Close Box and Circle primitives with geometry
Before the primitives were closed only with cyclic flag, but this doesn't create geometry for the gap. Now, a new geometry is created using close stroke function to have geometry for sculpt or edit.
2019-07-06 16:10:21 +02:00
741f80864e Fix T66501: Eraser very slow with guides
After testing the file, the problem was related to the fill material. As the fill material had the alpha channel set to 1.0, the fill triangulation was calculated, but the fill was disabled.

Now, the fill flag is checked in order to avoid fill triangulation update.
2019-07-06 13:50:24 +02:00
6c1419d1f4 GPencil: Don't add missing events for Eraser mode
This avoid some code that can delay the easer, but still some problems with the test file.

Related to T66501
2019-07-06 13:10:51 +02:00
a0f3ea7da3 Fix T62101: GPencil: selection order is wrong
Following the advices of @Germano Cavalcante (mano-wii) , I have exposed as a workaround the free function to be called from draw manager for selection.

Now, the free function is not called for selection inside gpencil draw_scene, but it's called from draw_manager.c.

The real fix would be create a new Scene_finish callback in draw manager, but as the release of 2.80 is almost here, we fix this with a workaround that must be removed when new callback is in place.

Differential Revision: http://developer.blender.org/D5193
2019-07-05 23:52:26 +02:00
a7a9c0e50d transform_snap_object: return type of element snapped.
This can be useful for filtering some of the returns.
2019-07-05 18:23:06 -03:00
699193713f Fix T66282: Make Instances Real: Keep Hierarchy option broken with recursive instancing.
Preserving/rebuilding relashionships in recursive instancing was simply
not supported at all, code handling that was assuming a single level of
instancing.

This commit makes the following changes:
* Mixing DupliCollection and DupliVerts/Faces in the recursive chain is
now supported (by using a same GHash in all cases, differences of
persistent_id handling in hashing and comparison is now down inside the
relevant functions).
* When both "keep hierarchy" and "parent" options are enabled, code will
attempt to parent new objects to their version of instancer (instead of
parenting them systematically to the root object). This will preserve
the hierarchy much better.
* Collection is removed from dupli empties that have been made 'real'
(the duplication flag itself was already cleared, but the link to the
instantiated collection was kept).
2019-07-05 18:36:47 +02:00
Dalai Felinto
784121d62a Fix T66327 2/2: Make instance real does not clear collection 2019-07-05 12:24:31 -03:00
Dalai Felinto
68c39e2b41 Fix T66327 1/2: Outliner dupli empty is shown as collection when a different duplitype 2019-07-05 12:24:31 -03:00
7b93aebff9 Transform Snap: Fix dependency cycle between transformed object and object with modifiers 2019-07-05 12:13:08 -03:00
18e619ac69 Fix strict compiler warnings 2019-07-05 16:08:51 +02:00
599626edd5 Fix T64342: Incorrect snapping of focus object in camera view
Use more granular dependency graph traversal, which allows to ignore
dependencies which are not related on transform.

Reviewers: mano-wii, brecht

Differential Revision: https://developer.blender.org/D5184
2019-07-05 16:06:13 +02:00
16307d1e2a Depsgraph: Cleanup, more clear naming 2019-07-05 16:06:12 +02:00
97aa43c364 Depsgraph: Make component traversal more granular
Now it is possible to start traversal from a given component.
2019-07-05 16:06:12 +02:00
9e155eb1f0 Depsgraph: Add dependencies traversal which is aware of component
Sometimes it is required to know which exact part of ID is being
dependent on the given iD. Now it is possible.
2019-07-05 16:06:12 +02:00
03ac94f46a Depsgraph: Add inverse of node type conversion functions 2019-07-05 16:06:12 +02:00
ea05edceaa Depsgraph: Make object component conversion more accessible 2019-07-05 16:06:12 +02:00
609e16339f Fix "child of" constraint "set inverse" problematic with bones
For bone owners we want to do this in evaluated domain since
BKE_pose_where_is() / BKE_pose_where_is_bone() rely on (re)evaluating
parts of the scene and copying new evaluated stuff back to original.

Fixes T66080, T66397

Reviewers: sergey

Maniphest Tasks: T66080

Differential Revision: https://developer.blender.org/D5189
2019-07-05 16:00:52 +02:00
34a0b65ba6 GPencil: Remove select keymap definition for Weight Paint mode
This removes the keymap, but the B key is still available, so in some top level the selection is enabled.

Related to T66458.
2019-07-05 16:00:30 +02:00
5cb3d9df1e Fix T66006: View 3D select enumerate + other options fail
Support other options when using the enumerate option.
2019-07-05 23:55:23 +10:00
9ffb87c629 Fix T66296: Black artefacts on materials with refraction on CPU
The issue was in the optimization code path for opaque shadow rays
which was wrongly considering all primitives in the node to have
same visibility flags.
2019-07-05 15:48:50 +02:00
3c7814d7de Workbench: Disable texture paint drawing for final render 2019-07-05 15:40:48 +02:00
d1349bd0c7 TexturePaint: Force Workbench Texture Color Mode
When in texture paint mode and in solid mode the object that is being
texture painted will be rendered by the workbench engine with textures.
All other objects would render the same. For other cases the texture paint
draw engine will still draw the texture.

The texture mode draw engine now only drawn the masks. The opacity
sliders influences the texture mask.

This change has been implemented conserably. In the future we need to
look into making this better, like adding support that every object
can be colored differently. Currently when rendering in the workbench
we can have up to 3 different color types active (what the user selected,
the fallback in case no materials have been configured and this one,
forcing textures)

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5190
2019-07-05 15:21:11 +02:00
15cc4c4cb3 Cleanup: use doxy comments for WM_types.h 2019-07-05 21:42:21 +10:00
db8c93c02f DRW: add back gl_PointSize for AMD drivers 2019-07-05 21:42:35 +10:00
3640a58b9b Keymap: add V-key to toggle vertex select in vertex paint mode
Match weight paint mode.
2019-07-05 20:20:26 +10:00
4125a330b9 Cleanup: remove redundant gl_PointSize assignment 2019-07-05 20:07:33 +10:00
e7325bedfb DRW: weight-paint wire overlay made vertex selection hard to see 2019-07-05 20:06:47 +10:00
68ec4c26b9 Fix paint modes using edge-selection in non-selection modes 2019-07-05 19:04:37 +10:00
5d75672720 DRW: tweak paint edge drawing to show all unselected edges
32d3bce1ea changed behavior when it shouldn't have.
2019-07-05 18:43:32 +10:00
Alessio Monti di Sopra
1468f77a29 VSE: draw cache on top of markers area
Differential Revision: https://developer.blender.org/D5104
2019-07-05 09:51:12 +02:00
Eitan
baf3887207 UI: Smaller minimum size of scrollbar
Differential Revision: https://developer.blender.org/D5086
2019-07-05 09:46:18 +02:00
c27d70853d Fix T66404: knife tool doesn't use knife cursor 2019-07-05 17:44:47 +10:00
338cbe4ad6 Fix T66453: navigation gizmo doesn't refresh on theme change 2019-07-05 16:36:01 +10:00
31d762c3a8 Fix T66356: runtime assert disabling a collection 2019-07-05 16:28:01 +10:00
66684bdff3 Cleanup: redundant scene access, duplicate flag clear 2019-07-05 16:13:24 +10:00
4a08b974f4 Workaround T61948: Undo steps created for non-paint operations
Changing the brush size for example,
was adding redundant undo steps in paint-modes.

For now, don't store undo steps for property changes
in paint & edit modes.

While not ideal, this is similar to 2.7x behavior.
2019-07-05 13:48:17 +10:00
fdcfc263e9 Use latest/version number for manual links
We want users to go to the current version for their current version 
when possible if not point to latest.

/dev should really only be for development related work. End users 
should not be browsing /dev unless they are reading about upcoming 
features ahead of time.
2019-07-04 18:24:36 -04:00
2740bdfff9 Fix T66362, T66004: Cycles holdout should override indirect only
Now it works again like 2.7, rather than objects disappearing from camera
rays when both options are on.
2019-07-04 18:16:36 +02:00
eed19d9f45 Fix T64253: missing update when moving nodegroup input/output sockets up or down
Reviewers: brecht

Maniphest Tasks: T64253

Differential Revision: https://developer.blender.org/D4959
2019-07-04 18:03:27 +02:00
ab71991a78 Fix T66433: skin resize (Ctrl+A) crashes non-mesh objects
slow poll was altered in rBc252fe7a32ab after recent fix, now be a bit
more specific about meshes only.

Reviewers: brecht

Maniphest Tasks: T66433

Differential Revision: https://developer.blender.org/D5185
2019-07-04 17:39:17 +02:00
178bae9504 GPencil: Fix unreported error with occlude eraser
The option was inverted in RNA and worked opposite of expected.
2019-07-04 17:38:40 +02:00
9ffce6da65 T66266: Grease Pencil Simplify Adaptive is not behaving correctly
Now the simplify code works correctly in 3D space. Before it was trying
to project the strokes down into a local 2D space, but that didn't work
nicely for strokes with overhangs or big changes in the stroke
direction.

The code in question was simplified as well which lead to some nice code
reduction.

Reviewed By: Antonio Vazquez

Differential Revision: http://developer.blender.org/D5183
2019-07-04 16:29:05 +02:00
7ba096e1e7 Fix T63788: Crash if particle system is turned off in particle editing mode
Make sure particle system edit never points to a modifier or particle system
which becomes inactive.

This is needed because copy-on-write will change pointers of them and those
pointers are supposed to be restored from particle system evaluation. But
since the particle system is disabled it never updates pointers.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5180
2019-07-04 15:47:41 +02:00
9e8e479a52 Cleanup: Suppress warning
Introduced by previous commit
2019-07-04 15:44:49 +02:00
88d8f3a765 Workbench: Support for MatCap + Textured models
Now it is possible to enable MatCap lighting on top of textured models
in the workbench engine.

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5182
2019-07-04 15:42:46 +02:00
e2bf240cbf GreasePencil: Image render artifacts
When doing image rendering with grease pencil, it reused the view of
workbench or EEVEE. These views might be offsetted due to TAA.

This shifted the view a tiny bit. We will not reset the view in between
render engines.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5171
2019-07-04 15:41:36 +02:00
2ee257e2c3 ImBuf Py API: add crop method 2019-07-04 22:18:30 +10:00
c06eb4ab94 Fix T66414: Brush Color Flip from keyboard (X) does not update color picker panel
Reviewers: brecht

Maniphest Tasks: T66414

Differential Revision: https://developer.blender.org/D5181
2019-07-04 13:39:44 +02:00
c497a7efab ImBuf: add crop function (move out of screendump.c) 2019-07-04 21:15:18 +10:00
b2e3f23bec Cleanup: remove redundant cast 2019-07-04 21:14:12 +10:00
acf26dee5f Fix T66412: crash with displacement and AO node in viewport renders 2019-07-04 13:11:55 +02:00
33987caf3e Fix T63260: Rigid body connect 2019-07-04 13:10:27 +02:00
944458fe6c Industry Compat keymap: Fix keymap conflict related to snapping
There were some keymap conflicts and inconsistencies here. After this change, it works as follows:

Snap toggle on/off: X
Snap pie: Shift-X
Viewpoint pie: V

This is now consistent in all editors and the 3d View conflict should be gone
2019-07-04 13:04:40 +02:00
711960b3c2 node_shader_utils: add possibility to override image colorspace
'is_data'

since the move from 'cycles_shader_compat' (2.79) to
'PrincipledBSDFWrapper' (2.8) we lost the ability to (automatically) set
this colorspace setting for imported textures. This was useful for e.g.
normalmaps to always assume 'Non-Color' data.

This adds the possibility to overide and uses this for normalmaps...

Fixes T66368

Reviewers: mont29, brecht

Maniphest Tasks: T66368

Differential Revision: https://developer.blender.org/D5176
2019-07-04 12:32:25 +02:00
669d50f803 Fix T66405: Python API documentation
removed glVertex from the Python bgl api documentation as they are
deprecated.
2019-07-04 09:19:48 +02:00
d2788510fb API Docs: Update Build Dependencies 2019-07-03 22:47:44 -04:00
66a69fa220 API Docs: Theme Options
- Limit Nav depth to 1
- Turn off stick nav
- Add canonical_url
2019-07-03 22:46:52 -04:00
c252fe7a32 Transform: don't inspect all scene objects in poll
From fix for T66311, c6a199e254

Poll functions should never loop over entire scene,
in this case behave as other transform operators,
only checking the active screen.
2019-07-04 08:34:25 +10:00
cc667854a9 Fix T66372 Convert to mesh with subdivision breaks topology
This was caused by a check that was not taking the restart index into
account.
2019-07-03 21:06:33 +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
b8ed75ab6d Fix T61808: remove confusing graying out of workspace that already exist
This was meant to help users see which users are likely useful to add, but
it's not so obvious and there are cases where it's useful to re-append the
same workspace.
2019-07-03 20:44:04 +02:00
0a3e73a91f Fix T65899, T66314, T61808: various issues appending workspaces
This fixes crashes, wrong names and inability to append workspaces in
edit mode. We now bypass the append operator so we can easily return
a datablock pointer and work in any mode.
2019-07-03 20:44:04 +02:00
466cc3fbe4 Fix invalid state after calling append/link operator without any items 2019-07-03 20:44:04 +02:00
771ea2d73f Fix missing update when setting rigid body world collection 2019-07-03 20:44:04 +02:00
4d6172044c Fix T66332: Move gizmo stays in place when vertex is deleted
Reviewers: brecht

Maniphest Tasks: T66332

Differential Revision: https://developer.blender.org/D5177
2019-07-03 19:48:57 +02:00
2866c74208 Fix T59225 Screw modifier not displayed when using single vertex 2019-07-03 18:39:10 +02:00
c6a199e254 Fix T66311: skin resize (ctrl+a) could crash
could happen when used on multiple objects with multi edit, and skin
modifier was not present on all participating objects

Reviewers: brecht

Maniphest Tasks: T66311

Differential Revision: https://developer.blender.org/D5165
2019-07-03 17:51:13 +02:00
5277557755 Fix T66165: RGB Curve node generates too bright color
The issue was that the end point would be extrapolated and it would lead to
very high values if the curve had a near inf slope. Now we use the actual end
point value and only extrapolate values that are outside of the start and
endpoint range.

Differential Revision: https://developer.blender.org/D5151
2019-07-03 17:18:13 +02:00
82990ce2b5 Cleanup: rename variables for easier understanding 2019-07-03 17:11:19 +02:00
eb0142e9af Cleanup debug print left in by mistake.
Thanks to @brecht for noticing it. :)
2019-07-03 16:45:35 +02:00
21668359b7 Fix T66234: Issue on switching material mode between Object and Data
The root of the issue comes to the fact that part of dependency graph
is being removed, without doing any further remapping.
This was happening because only materials used by objects were pulled
in, so when material mode is changed some material became unused and
removed from the dependency graph and freed, causing object or its
data to point to a freed memory in its materials array.

Simplest and safest way to solve this is to pull materials referenced
by both object and object data. This causes somewhat higher memory
usage but keeps evaluated state of scene in an always consistent state,
without any need to tag/update object's data on material mode change.

Don't think it is a problem in practice.

Reviewers: brecht, fclem

Reviewed By: brecht, fclem

Differential Revision: https://developer.blender.org/D5172
2019-07-03 16:32:13 +02:00
5b2705adf6 Fix T66353: VSE: Missing updates when moving strip with animation 2019-07-03 16:31:33 +02:00
c441448359 Fix T66369: Excessive WARN messages in console when opening older files
CDData checking on file load was not taking into account deprecated
CD_MTEXPOLY datatype, which unfortunately shows same weird glitch as
CD_PAINT_MASK and CD_FACEMAP ones...

Note that it was annoying (due to amount of warnings in console), but
totally harmless, since that data type is just deleted anyway.

This commit also generally cleans up the CD_MTEXPOLY deprecation code, we
have a system to handle that, let's use it, instead of defining local
static values to replace it...
2019-07-03 16:05:31 +02:00
3d187a2764 Fix T66377: Applying rotation/scale on a parent changes location of a child 2019-07-03 16:03:17 +02:00
65b2cc2301 Fix T66370: add_relation Message in Console with certain shaders 2019-07-03 14:27:28 +02:00
bad5c379c6 Fix T66374: Crash when adding non-mesh object 2019-07-03 14:06:54 +02:00
f990c23bcf Fix T66366: Multi object edit makes blender crash
Two issues here:

- Evaluated object data is to only be updated for selection only after modifier
  stack is done its job. Otherwise it's possible to have selection batch update
  called on an input data, at the same time as original object data is being
  evaluated.

- If object's modifier stack did not create its own evaluated mesh (in case
  when there is no effective modifiers, for example) can not update selection
  on object's data, as it might cause threading issues between objects sharing
  same data.
2019-07-03 11:54:56 +02:00
055289a95f Fix: failing test gp_workbench 2019-07-03 08:23:52 +02:00
c122bcc182 BKE Particle: Simplify recent changes in distribution code 2019-07-03 00:58:14 -03:00
Dalai Felinto
50ccbe6bb2 Fix T63302: Crash when baking normals from selected to active with no cage
When we create the cage procedurally, we need to remove any edge split
modifiers. Since the new depsgraph in 2.80 we were removing the
modifiers straight from the evaluated object (it is a copy anyways).

On top of that we need to reset its eval data state (BKE_object_eval_reset)
to make sure the call to BKE_object_to_mesh to generate the cage would take the
new modifier stack state into account.

However doing so was freeing the low poly mesh we use later to convert
the normal space.

The solution (and this patch in fact ;) ) as suggested by Sergey Sharybin is to
use BKE_mesh_new_from_object() directly as well as force the modifiers to be
recalculated when any edge split modifier is removed.
2019-07-02 19:33:49 -03:00
2d35fed6f8 GPencil: Fix unreported error in stroke thickness when applies scale.
When apply the transformation, the thickness of the stroke was wrong because the scale was not applied to pressure.
2019-07-02 19:17:38 +02:00
a5b7cf9b5f Fix T53058: Crash when rendering to Quicktime RLE codec
The root cause seems to be an assumption in
[generate_video_frame()](https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/writeffmpeg.c)
that we're always using 4 bytes per pixel. This is not true when using
QTRLE in RGB mode, because that uses the RGB24 pixel format (so 3 bytes
per pixel). Just updating the `linesize` property doesn't fix it though,
but just creates a crash somewhere else.

This at least fixes the crash by always forcing RGBA to be written, even
when the user selects RGB.
2019-07-02 18:20:52 +02:00
09ea5dfd09 Fix assert in Alembic tests with constraints
Leave the reader to be created on the CoW object in the depsgraph evaluation,
don't assign the one used for importing to the original object.
2019-07-02 18:09:01 +02:00
2062d649bf Fix workbench render crash in background mode 2019-07-02 18:09:01 +02:00
87c39f1123 Fix T65798: Incorrect auto-tex space for Curves
There are several aspects to the fix:

- Always calculate bounding box for meshes and curves from dependency
  graph evaluation function.

  There is a reason why mesh was tagged for geometry update, so can not
  be spare here in attempts to avoid calculation.

- Copy bounding box and texture space to original object for active
  dependency graph.

  This matches object-level bounding box and allows to remove bounding
  box evaluation from RNA.
2019-07-02 16:51:17 +02:00
65bc59a56d Fix T66340: Missing particles in Grid and Volume distribution.
This solution only alleviates the problem.
2019-07-02 11:44:50 -03:00
57c26453f8 Fix T66295 Collection instance duplicates don't have selection outline
Was cause by shgroup reuse even if select state changed from previous dupli.

Also fixes T64438 Collection Instance object highlight wrong
2019-07-02 16:04:38 +02:00
c362ca3b8a Fix (unreported) untranslatable title of Quick Favorites menu.
Side minor fix found while checking on T66235.
2019-07-02 15:41:20 +02:00
1f65606911 Buildbot: Disable test step for now
It causes some false indication of a failed build on soma platforms
where it times out.

Windows and macOS needs extra work to properly support python paths
and path to the bundle.

This can now happen without poking git every time by doing local
modifications on a builder prior to commit.
2019-07-02 15:39:47 +02:00
e7356bb011 Buildbot: Fix missing configuration for Win ctest 2019-07-02 15:31:06 +02:00
e4df8b005f Fix T64805: Can't generate particle hair edit 'comb cache' in blender 2.8
Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5162
2019-07-02 15:19:02 +02:00
26e6bb3fa3 Fix T65778: Missing selection update with linked objects in edit mode 2019-07-02 15:17:17 +02:00
71099a3d67 Fix T66290: new Node's init api callback was not handling ID usercount.
As Usual...

Note that we have to edit each C-defined of those callbacks that set
Node->id pointer, instead of just moving the generic call to
`id_us_plus()` in `node_init()` below the call to
`ntype->initfunc_api()`, since that one manipulates RNA pointers, which
are supposed to already handle usercounts themselves on assignment.

The C callbacks are moving back to manipulating directly DNA, so it's
their responsability to handle user count then (Py code should do that
automatically through RNA assignement).
2019-07-02 15:12:59 +02:00
163996b681 Cleanup: move comments onto own lines to avoid breaking lines 2019-07-02 22:17:22 +10:00
b708917d94 Fix T66316: "Open on Mouse Over" doesn't work in some popovers
Popovers created from `UILayout.prop_with_popover` opening on mouse-over.
2019-07-02 22:16:33 +10:00
df330ab2bb Buildbot: Fix missing environment for schroot tests 2019-07-02 14:15:44 +02:00
bc0a0a1005 Fix T66322 Object with particle system have expanded selection region
This was caused by wrong pixsize calculation during selection.

Note that this was affecting selectability of lamps too.
2019-07-02 14:06:03 +02:00
ef750790d2 Compositor: Background Fit UI Scale
Make the fit background relative to the UI scale.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5150
2019-07-02 13:35:23 +02:00
5439f682fd Buildbot: Correct previous commit 2019-07-02 12:56:07 +02:00
3cc51cf28c Buildbot: Use correct path to scripts
The `scripts` is to be included into the path, not just the
folder where the scripts are.

Also specify path to datafiles.
2019-07-02 12:52:53 +02:00
6b17b51baa Buildbot: Attempt to make ctest use proper installed scripts 2019-07-02 12:36:07 +02:00
3ff984d746 Buildbot: Enable GTests and test step 2019-07-02 12:07:20 +02:00
10b694877b Cleanup: spelling 2019-07-02 18:05:10 +10:00
a9635c6384 Cleanup: rename set_inverted_drawing, move to GPU_state 2019-07-02 12:34:27 +10:00
1278853849 Fix T61360: Smooth Weights affects all objects 2019-07-02 08:59:40 +10:00
4f321a3373 Fix crash unlinking non-ID types in the outliner 2019-07-02 08:45:28 +10:00
5892233319 Fix submodules hash in previous commit 2019-07-01 23:50:50 +02:00
983ca12d82 Fix T65468 Nurbs: Broken display when hiding control points 2019-07-01 23:49:31 +02:00
9fbfa218e0 Updated tooltips for operators 'Transfer Mix' and 'Join Shapes'. Fixes typo 2019-07-01 23:06:32 +02:00
fcc567b797 GPencil: New python API for closing strokes with geometry
Adds to API the last function created to close strokes in a previous commit.
2019-07-01 23:03:03 +02:00
05a54beb88 GPencil: Add new parameter to python API for activating the new created frame
Sometimes is required to enable the frame created and new "active" parameter allows to do that.

Use: `gpl.frames.new(5, active=True)`
2019-07-01 22:48:48 +02:00
cbc0ad07b3 Fix T65974 Workbench: transparency rendering broken 2019-07-01 22:32:25 +02:00
2002b29ecd Workbench: Combine Xray Alpha with object/material alpha ...
... instead of overiding it (previous behavior).

In practice it's not really noticeable.
This means an object with alpha will never be more opaque when enabling
xray.
2019-07-01 22:29:16 +02:00
c2a762c8e6 Fix T65771 Eevee: Volume Emission not working if density is zero 2019-07-01 20:05:13 +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
dcf520cdad UI: increase size of scale gizmo circle
The scale gizmo wasn't working usefully for uniform scale.
2019-07-02 01:48:58 +10:00
016d5cf919 Gizmo: support for filled circle with inner non-zero radius
Needed for changes to the scale gizmo.
2019-07-02 01:48:58 +10:00
4749edccdd Tests: Point ffmpeg data to a new folder 2019-07-01 17:19:01 +02:00
c6d073f6a4 Revert "Rename operator 'Join Shapes' to 'Transfer Mix'."
This reverts commit 741967079c.
We are in UI and API freeze, and this changes both.
2019-07-01 16:53:41 +02:00
510daea545 Linux: add initial 2.80 release information in appdata 2019-07-01 16:53:41 +02:00
69b5a06823 Docs: for release builds, link to specific manual version 2019-07-01 16:53:41 +02:00
9197462e07 Revert "Fix T65798: Incorrect auto-tex space for Curves"
The fix broke a lot of Cycles regression tests. Reverting for now.

This reverts commit 6b9c41719b.
2019-07-01 16:49:12 +02:00
6b3e709feb Theme: minor tweaks to state colors
Use full saturation (since some intensity is lost when blending),
Set blend back to 0.5, made color look dull which isn't good when
some of the colors are similar (faded orange/yellow).
2019-07-02 00:35:27 +10:00
32d3bce1ea DRW: replace edge hash with an edge aligned bitmap 2019-07-02 00:29:31 +10:00
a6fe4d112f Fix: widget states had too low contrast
It was very hard to read the sliders when they had states such as animated or changed.
Slightly increase contrast to alleviate this.
2019-07-01 16:26:06 +02:00
31b2c4c10a Fix T60289: changing gizmo properties causes excessive redraws 2019-07-01 16:15:07 +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
bbbb5cad31 Fix T66277: Pinning Fluid Domain properties causes bake error
Reviewers: brecht

Maniphest Tasks: T66277

Differential Revision: https://developer.blender.org/D5161
2019-07-01 15:47:43 +02:00
28fee762ae DRW: Fix Crash in DRW_draw_depth_object when object batch cache is not init
This can happen if the viewport is not redrawn before calling an operator
(frequent in python scripting).

Related to T64805
2019-07-01 15:46:28 +02:00
2698544db2 Fix T66262: slow preview icon loading 2019-07-01 15:36:02 +02:00
3c6260d42d Fix T66301: Crash on vertex slide when the vertex is not linked to a face. 2019-07-01 10:27:26 -03:00
7a4c99de5a Fix T66292: Alpha Blend transparency glitches with volume 2019-07-01 14:44:01 +02:00
809f81cc3a Fix T66207: Invalid depsgraph relation when driver uses object dimension
Would be nice to find a more proper and generic solution instead of name
based comparison, but can not really think a nice way to go currently.
2019-07-01 14:34:23 +02:00
e1cb15c5d6 Fix T66300: GPencil layer context menu not working in topbar layer popover 2019-07-01 13:24:41 +02:00
76aff66301 PaintingModes: Facemask Wireframe Drawing
The wireframe drawing for face masks is intrusive as selected wires
were solid white and always drawn. This made it hard for users to see
the exact color near edges.

This patch draws only the border of the selected faces,
edges between two selected faces are not drawn at all.

Reviewed By: brecht, fclem

Differential Revision: https://developer.blender.org/D5147
2019-07-01 12:47:12 +02:00
6b9c41719b Fix T65798: Incorrect auto-tex space for Curves
There are several aspects to the fix:

- Always calculate bounding box for meshes and curves from dependency
  graph evaluation function.

  There is a reason why mesh was tagged for geometry update, so can not
  be spare here in attempts to avoid calculation.

- Remove texture space evaluation from RNA accessor.

  Such data is to be evaluated by a dependency graph.

  Don't see a reason to be different here: we never force evaluation of
  any kind from RNA.

- Copy bounding box and texture space to original object for active
  dependency graph.

  This matches object-level bounding box and allows to remove bounding
  box evaluation from RNA.
2019-07-01 12:42:42 +02:00
67fc4f4bed Fix T66267: only add DEG cloth collision relations if collisions are
enabled

was detecting unneccessary dependency cycle

Reviewers: sergey, brecht

Maniphest Tasks: T66267

Differential Revision: https://developer.blender.org/D5160
2019-07-01 12:31:41 +02:00
1f79aa602e Fix T66297: Blender on macOS does not open on case-sensitive file system 2019-07-01 12:17:58 +02:00
c64b72998c Fix T66283: Crash on redo/undo during playback 2019-07-01 11:31:53 +02:00
89946834a1 Fix T66279: Strip sound keeps playing after toggling to Camera
Before this change using Sequencer input for the scene strip would
permanently enable sound playing back for that strip. Going back to
Camera would have been still playing sound from the strip, which is
rather misleading since rest of the nested sequencer is not used.
2019-07-01 11:14:18 +02:00
65d770ffa3 Fix T66287: use keyword argument in freestyle text style loading 2019-07-01 09:44:08 +02:00
cf73569d89 UI: run interactive 'Point From Normal' in normal menu 2019-07-01 16:48:47 +10:00
cfea0d9eb8 GPencil: Fix wrong title missing in previous change 2019-07-01 08:40:31 +02:00
c74626c54f Fix keymap editing not tagging dirty
Partial fix for T65629
2019-07-01 16:11:37 +10:00
6f61b6aa44 Fix T66289: Default keymap conflict selecting curve/channels
The default keymap conflicted selecting by curves and channel.

Caused by 325b0ad2ed

Revert to original keys, use click instead of press
to avoid conflicting with box-select.
2019-07-01 16:04:17 +10:00
8eae674eee Fix preferences setting dirty when editing keymap items 2019-07-01 15:16:23 +10:00
fc10a5cf9e Fix T66229: gizmos overlap when switching modes 2019-07-01 13:51:13 +10:00
1a5e1273c1 Fix T66192: Remove gizmos label from topbar 2019-07-01 13:24:57 +10:00
05129ffb3e Cleanup: move screen region find into utility function 2019-07-01 12:10:49 +10:00
26e05cf67a Fix T66246: Key accelerators crashing on save dialog 2019-07-01 11:47:01 +10:00
bbb3500c97 UI: Use Plural Panel Names 2019-06-30 15:51:01 -04:00
ea4b279c32 UI: Use term "3D Viewport" 2019-06-30 15:51:00 -04:00
35045b6135 Fixed compiler warning
`(1L << 31)` can cause an integer overflow on 32-bit systems, `(1UL << 31)`
won't. Fixed as per LazyDodo's suggestion in
https://developer.blender.org/rB956cb4f403dd3a6ddb379202dc1f2770b9820073#238718
2019-06-30 21:49:10 +02:00
789c6e94fb GPencil: Improve Cyclic operator to generate geometry
Now, when close a geometry with cyclic is possible generate new geometry for the gap.

The cyclic operator now supports multiframe edition too. Before only worked with active frame.

Also added the corresponding missing menu options and the new F keymap. All these features were missing, pending of the fix of the alpha glitches in stroke already done.
2019-06-30 21:06:10 +02:00
741967079c Rename operator 'Join Shapes' to 'Transfer Mix'.
The new name is consistent with the 'Transfer Shape' operator.

- Updated the UI descriptions for both transfer operators.
2019-06-30 20:07:17 +02:00
7c8bf77e13 Fix T66204, bevel numeric input respect scene units. 2019-06-30 11:32:38 -04:00
f8f3aca1d4 Fix T66264: UI: Repeated word typo 2019-06-30 11:26:32 -04:00
e40f3f5c48 GPencil: Fix text for Pattern stroke as Stencil Mask
Detected while writting manual.
2019-06-30 09:30:05 +02:00
be060c3990 Fix T65929: multi-object editing for new normals tools.
Leaving the modal point-at as a TODO for now.
All the rest of the new split normal tools converted to
operate on all selected objects.
2019-06-29 16:58:11 -04:00
3994084e6a Cleanup: Fix build warnings with MSVC
gflags emits a few unused variable warnings since the main
CMakeLists.txt raised the warning from w4 down to w3. This
restores it back to w4 in the remove_strict_flags macro.
2019-06-29 09:42:49 -06:00
e981d93fa6 UI: Make Panel Name Plural
This is more consistent with other panels; for example "Shadows"
2019-06-29 11:35:30 -04:00
6f002d1a92 Fix T66250: Repeated word typo 2019-06-29 11:12:50 -04:00
f566212aa2 Fix T66230: delay in the material preview panel after recent changes 2019-06-29 16:01:28 +02:00
1044a3b657 Fix wrong usage of U.ui_scale, drawing code must use U.dpi_fac 2019-06-29 16:01:28 +02:00
8637ff5c96 Fix T66240: clip editor shows Python error about tool header 2019-06-29 16:01:28 +02:00
dd6aff71a7 Fix compilation error without Cycles logging 2019-06-29 13:54:38 +02:00
f021635bd5 WM: support window context override
This makes it possible to take a screenshot from any window in Python.
2019-06-29 18:21:53 +10:00
71086995a5 Cleanup: Fix build warnings with MSVC.
ffmpeg defines some of the math constants if they are not
found before including any of its headers, this lead to
a build warnings about M_E, M_LN2 and M_SQRT1_2 being
redefined once BLI_math_base.h gets included.
2019-06-28 22:53:58 -06:00
97e3af9a05 RNA: Add Screen.is_temporary
Useful to check if the current window is temporary.
2019-06-29 13:39:34 +10:00
b7a03eed8b Fix T66238: Spelling typo 2019-06-28 22:01:26 -04:00
b93e57dcdf Fix T66102: Animation color hard to see when sliders is set to full
Change logic for slider coloring, instead of reducing the blend,
de-saturate the slider and ensure contrast.
2019-06-29 11:24:14 +10:00
4afc9d8e4d Cleanup: de-duplicate button color flag checks 2019-06-29 11:20:09 +10: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
648e8a1f1d UI: Add "(Walk/Fly)" to navigation operator name
Without this, searching for the operator is more difficult.

D5148 by @a.monti
2019-06-29 08:08:02 +10: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
5762137f35 Fix T66224: Grammar in Key Set error messages 2019-06-28 21:44:19 +02:00
daf8e73886 Sequencer: Assign Refresh All to Ctrl-R.
This is needed based on studio feedback to make it quicker to refresh the sequencer clips.
2019-06-28 19:16:04 +02:00
b31af8682c Fix audio not updating when snapping strips in sequencer 2019-06-28 18:02:54 +02:00
c9238e638f Cycles: add back control to render first N bounces with path termination
It's found in the Sampling > Advanced panel and 0 by default. This helps to
reduce noise in some scenes, while making others slower.
2019-06-28 17:47:53 +02:00
4e8c5f4bc8 Fix Cycles OSL assert when running tests 2019-06-28 17:42:35 +02:00
d44aebd3fe Previews: delay icon preview renders a bit for smoother interaction
With Eevee the user interface, 3D viewport and small icon materials previews
are rendered on the same GPU. This can lead to some choppy interaction when
dragging sliders. Delaying the icon preview render until the user is done with
that helps a bit, though it's no guarantee.
2019-06-28 16:47:55 +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
e8cb477f8a Creator: Clarify verbosity command line argument
Hopefully it is now clear that verbosity needs to be used with
flags which are enabling debug messages.
2019-06-28 15:45:29 +02:00
0511de99bb Fix non-working verbosity when set prior to --debug
Before this change doing something like `--verbose 10 --debug-cycles`
did not properly set verbosity, only using those arguments in an other
way around was leading to a correct verbosity level.
2019-06-28 15:45:29 +02:00
8401ee24ff Fix issue in Blender 2.7x mask keymap after recent changes 2019-06-28 15:05:36 +02:00
533e267e95 Remove Sticky option from the Floor constraint
This option from the very beginning of its existence needed more work
to make it work correct and this was never done.

This option was working fine during continuous playback, when there
are no skipped frames, but it was failing when AV-sync of framedrop
was enabled.
It was never working correct when jumping between frames, including
rendering on a farm which usually does frame-range based rendering.

With copy-on-write things became even more tricky, since the "stuck"
flag was never preserved between re-evaluations.

Fixes T65683: Sticky Option in Floor Constraint for Bones Not Working
2019-06-28 15:03:24 +02:00
Dalai Felinto
f5e0ae655e Python Templates: Small fix for gizmo custom geometry
The mouse offset was inverted (the widget was going the opposite direction as the
mouse movement).
2019-06-28 09:57:16 -03:00
Dalai Felinto
30d65c326a Python Templates: Update Custom Nodes tooltip
Since we exposed the editors sub-types to the type editor selector, this template
no longer shows in the head, but in the type editor selector.
2019-06-28 09:57:16 -03:00
Dalai Felinto
0519bb584b Python Templates: Silence _MT_ warning in pie menu template 2019-06-28 09:57:16 -03:00
Dalai Felinto
da25748be7 Python Templates: Fix Operator Mesh Add
This was broken since: 06fe2a5e0c
2019-06-28 09:57:16 -03:00
2ffcb80cb6 Python tests: replaced imp with importlib
The `imp` module has been deprecated since Python 3.4, and is replaced
by `importlib`.
2019-06-28 14:37:04 +02:00
dee6fe1441 GPencil: Rename "Clamp Layer" to "Mask Layer"
The old name was not meaning what this option does. Dtected while writting the manual.
2019-06-28 14:24:23 +02:00
Julian Eisel
d3e48fb096 Merge branch 'master' into soc-2019-openxr 2019-06-28 14:09:08 +02:00
4f3f68df30 Fix T66126: Non-active Grease Pencil object stuck in draw mode
Now the modes are reset for grease pencil objects.

Differential Revision: http://developer.blender.org/D5138
Reviewers: @dfelinto
2019-06-28 13:56:16 +02:00
Julian Eisel
d544a0b41c Avoid std::vector copy 2019-06-28 13:56:10 +02:00
d7d9320f09 Tests: disable keymap hierarchy tests until they are fixed
This is not a critical issue, and it's important to have tests always passing.
Ref T65963.
2019-06-28 13:49:04 +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
Dalai Felinto
40a1c67165 Fix T65263: Outliner doesn't display selected object if parent not selected
This works for most situations, however if you have:

```
A
 |-> B
     |--> C
```

And only A and C are selected, C will be shown nested under A, instead
being by its side.

I still have to think on how to address these cases since they are
slightly misleading.

Related: T65263.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5134
2019-06-28 08:38:04 -03:00
782813e463 Fix T65956: node reroute no longer working in right click keymap
It's now always on shift + RMB drag, regardless of the keymap.
2019-06-28 13:06:50 +02:00
980726c1d4 Fix issues with masking tools and RMB/LMB keymaps
This makes things work more similar to 2.79 until there is a toolbar for
mask editing. Select & slide is now always on the left mouse button.

For the LMB keymap the context menu is on the right mouse button. For the
RMB keymap the select & move is on the right mouse button, which is almost
the same as select & slide but for historical reasons there is still a
distinction.

Differential Revision: https://developer.blender.org/D5070
2019-06-28 12:34:02 +02:00
56d52466ef Fix message subscriber using the wrong workspace 2019-06-28 19:38:44 +10:00
f35ef57c8c Revert "Fix invalid area tool being set from message passing"
This reverts commit 9ec8887599.

Causes assert when selection changes modes.
2019-06-28 19:38:44 +10:00
6f0de2328c Fix OpenMP library for tests on macOS 2019-06-28 11:22:33 +02:00
9bcab8050f Fix T63694: Crash using tool gizmos with multiple windows
Gizmo group types now store a user count so they aren't unlinked
while other tools are using them.

The tool system now works with multiple windows.
2019-06-28 18:22:53 +10:00
eac11046a1 Fix T62990: Selecting bones causes pose to be re-evaluated 2019-06-28 10:13:57 +02:00
2110f4a76c Fix T66105: Changing force field does not update simulation 2019-06-28 09:48:44 +02:00
37d5d10849 Fix T66200: Changing workspaces / modes doesn't update tools
Changing the workspace or mode from one window may need to change the
active tool in another window since two different workspaces
may share an object.
2019-06-28 17:43:14 +10:00
9ec8887599 Fix invalid area tool being set from message passing
This wasn't working with multiple windows,
WM_toolsystem_do_msg_notify_tag_refresh could use a workspace
from a different window to the screen that owned the area.

Instead of fixing, remove these since they aren't needed anymore
since changing modes now refreshes the tool system.
2019-06-28 17:38:42 +10:00
bd227d1378 install_deps: Bumped OSL version to 3.4.0_RC2 2019-06-28 08:38:34 +02:00
83d92f55b8 Fix error for tools that share gizmo types doubling up gizmos
Introduced in recent commit c93af8529d
2019-06-28 11:27:11 +10:00
651e574153 Cleanup: unused var, sort structs 2019-06-28 10:07:21 +10:00
5dd8c3f0cb GPencil: Cleanup commented lines from previous commit 2019-06-27 23:28:44 +02:00
d06671b3d9 GPencil: Don't hide Cursor while drawing
This is a partial solution for T62446 while we prepare a way to hide the cursor all the time.
2019-06-27 23:19:05 +02:00
Julian Eisel
57d9f004aa Fix compile/CMake errors and warnings on Linux 2019-06-27 19:55:22 +02:00
b5a1a2d186 GPencil: Fix missing Fill area when drawing an stroke
There was a mistake in the shading group name.
2019-06-27 19:34:04 +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
b2c92d90c8 Cleanup: fix compiler warnings 2019-06-27 19:11:19 +02:00
c187fc09b6 Masking: make image editor UI consistent with clip editor
* Mask Display menu is now part of the header
* Sidebar now has a separate Mask tab
* Add context menu when in mask mode

Differential Revision: https://developer.blender.org/D5102
2019-06-27 19:11:19 +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
1cd11c9d75 Fix T66166: NLA invisible source list selection 2019-06-27 18:22:34 +02:00
7ee5ea7751 Fix T65010: Affect options not being displayed in the UV editor snap settings.
Reviewers: brecht, billreynish

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5141
2019-06-27 12:24:03 -03:00
c5eceb3582 Cleanup: EditMode: Remove uneeded shader depth bias
The bias is done using the DRWView now, no need to double it.
2019-06-27 17:02:22 +02:00
19d90c8602 Fix T66119: Assert editing Lattice 2019-06-27 17:02:22 +02:00
4b124143b1 ObjectMode: Fix selection points of LightGrids 2019-06-27 17:02:22 +02:00
c74ccf6a97 DRW: Fix point shaders not using gl_PointSize
All Shaders inside DRW should use gl_PointSize.
2019-06-27 17:02:22 +02:00
58996e3057 Cleanup: GPencil remove DRW_ prefix for internal functions.
The prefix DRW_ must be used only for modules inside Draw Manager and not in the Engines.
2019-06-27 16:42:38 +02:00
91e00bd703 Fix compositor preview not respecting un-keyed changes
This is a part of T66099.
2019-06-27 16:21:18 +02:00
ccfb98511b GPencil: Fix Control points of primitives clampoed by Stencil
The control points were clamped to the stroke thickness due the last stencil change.

Now, the shading group is not clamped.
2019-06-27 16:05:58 +02:00
658aa00718 Build environment: Update OpenSubdiv to 3.4.0 RC 2
Newer OpenSubdiv brings fixes and improvements for non-manifold meshes,
which fixes some crashes we've experienced in the recent past when using
Gregory patches.

Additionally, thing new version of OpenSubdiv brings sparse patches,
which allows to multi-thread topology refinement step.
2019-06-27 15:15:08 +02:00
2a22b8af04 Eevee: Make use of dual source blending for volumetric resolve
This simplify the code and add an example use of dual source
blending.
2019-06-27 14:41:35 +02:00
1f4e9754c0 DRW: Add DRW_STATE_BLEND_CUSTOM
This one enable dual source blending, enabling more fine tuned
blending parameters inside the shader.
2019-06-27 14:41:35 +02:00
7f5a21177a Cleanup: de-duplicate flag checks for button colors 2019-06-27 21:20:29 +10:00
0f983e8540 Fix T65893: Edit Mesh Culling
The edit mesh is culled by object. When the object is not visible on
screen, the edit mesh may still be visible. This change will not  cull the
edit mesh anymore.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5144
2019-06-27 12:53:17 +02:00
5eb156e769 Fix T66171: Cycles OSL trace() crashing in displacement shaders
This is not supported, meshes do not exist in the BVH before displacement.
2019-06-27 12:46:04 +02:00
6f516fcc63 Tests: speed up render tests by running multiple in the same process
Blender startup time and shader compilation is a big factor when running
hundreds of tests, so now all renders in the same ctest run in the same
process.

This was previously reverted due to skipping other tests when one test
crashed. Now if a test crashes, Blender is re-run with the remaining
tests so we get results from them still.
2019-06-27 12:46:04 +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
1159 changed files with 86225 additions and 46649 deletions

View File

@@ -241,7 +241,7 @@ ForEachMacros:
- SEQ_BEGIN
- foreach
# Use once we bump the minimum verison to version 8.
# Use once we bump the minimum version to version 8.
# # Without this string literals that in-line 'STRINGIFY' behave strangely (a bug?).
# StatementMacros:
# - PyObject_VAR_HEAD

View File

@@ -234,6 +234,17 @@ 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" ${_init_OPENCOLORIO})
option(WITH_OPENXR "Enable VR features through the OpenXR specification" ON)
if(WITH_OPENXR)
option(OPENXR_USE_BUNDLED_SRC "Compile using the bundled OpenXR SDK sources (otherwise it has to be compiled manually)" ON)
if(NOT OPENXR_USE_BUNDLED_SRC)
find_package(OpenXR-SDK)
if(NOT OPENXR_SDK_FOUND)
message(WARNING "OpenXR-SDK was not found, disabling WITH_OPENXR")
set(WITH_OPENXR OFF)
endif()
endif()
endif()
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
@@ -413,6 +424,8 @@ unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF)
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
option(WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF)
mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_LOGGING)
mark_as_advanced(WITH_CYCLES_DEBUG)
@@ -471,7 +484,7 @@ endif()
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
mark_as_advanced(
WITH_OPENGL
@@ -822,12 +835,6 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}")
if(WITH_CYCLES_OSL)
# With OSL, Cycles disables rtti in some modules, wich then breaks at linking
# when trying to use vptr sanitizer (included into 'undefined' general option).
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr")
endif()
if(MSVC)
set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
endif()
@@ -852,7 +859,8 @@ if(WITH_X11)
if(X11_Xinput_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
else()
set(WITH_X11_XINPUT OFF)
message(FATAL_ERROR "LibXi not found. Disable WITH_X11_XINPUT if you
want to build without tablet support")
endif()
endif()
@@ -863,7 +871,8 @@ if(WITH_X11)
if(X11_Xxf86vmode_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
else()
set(WITH_X11_XF86VMODE OFF)
message(FATAL_ERROR "libXxf86vm not found. Disable WITH_X11_XF86VMODE if you
want to build without")
endif()
endif()
@@ -871,7 +880,8 @@ if(WITH_X11)
if(X11_Xfixes_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
else()
set(WITH_X11_XFIXES OFF)
message(FATAL_ERROR "libXfixes not found. Disable WITH_X11_XFIXES if you
want to build without")
endif()
endif()
@@ -881,7 +891,8 @@ if(WITH_X11)
if(X11_Xrender_LIB)
list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
else()
set(WITH_X11_ALPHA OFF)
message(FATAL_ERROR "libXrender not found. Disable WITH_X11_ALPHA if you
want to build without")
endif()
endif()
@@ -1760,6 +1771,7 @@ if(FIRST_RUN)
info_cfg_option(WITH_CYCLES)
info_cfg_option(WITH_FREESTYLE)
info_cfg_option(WITH_OPENCOLORIO)
info_cfg_option(WITH_OPENXR)
info_cfg_option(WITH_OPENVDB)
info_cfg_option(WITH_ALEMBIC)

View File

@@ -37,14 +37,16 @@ Convenience Targets
* bpy: Build as a python module which can be loaded from python directly.
* deps: Build library dependencies (intended only for platform maintainers).
* developer: Enable faster builds, error checking and tests, recommended for developers.
* config: Run cmake configuration tool to set build options.
* ninja: Use ninja build tool for faster builds.
Note: passing the argument 'BUILD_DIR=path' when calling make will override the default build dir.
Note: passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments.
Project Files
Generate poject files for development environments.
Generate project files for development environments.
* project_qtcreator: QtCreator Project Files.
* project_netbeans: NetBeans Project Files.
@@ -221,6 +223,19 @@ ifneq "$(findstring bpy, $(MAKECMDGOALS))" ""
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake"
endif
ifneq "$(findstring developer, $(MAKECMDGOALS))" ""
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake"
endif
# -----------------------------------------------------------------------------
# build tool
ifneq "$(findstring ninja, $(MAKECMDGOALS))" ""
BUILD_COMMAND:=ninja
BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -G Ninja
else
BUILD_COMMAND:=make -s
endif
# -----------------------------------------------------------------------------
# Blender binary path
@@ -282,7 +297,7 @@ all: .FORCE
@echo
@echo Building Blender ...
$(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install
$(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install
@echo
@echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild.
@echo Blender successfully built, run from: $(BLENDER_BIN)
@@ -294,6 +309,8 @@ lite: all
cycles: all
headless: all
bpy: all
developer: all
ninja: all
# -----------------------------------------------------------------------------
# Build dependencies
@@ -312,7 +329,7 @@ deps: .FORCE
@echo
@echo Building dependencies ...
$(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET)
$(BUILD_COMMAND) -C "$(DEPS_BUILD_DIR)" -j $(NPROCS) $(DEPS_TARGET)
@echo
@echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR).
@echo
@@ -548,7 +565,7 @@ help_features: .FORCE
@$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt"
clean: .FORCE
$(MAKE) -C "$(BUILD_DIR)" clean
$(BUILD_COMMAND) -C "$(BUILD_DIR)" clean
.PHONY: all

View File

@@ -70,7 +70,6 @@ ExternalProject_Add(external_opensubdiv
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH MD5=${OPENSUBDIV_Hash}
PREFIX ${BUILD_DIR}/opensubdiv
PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/opensubdiv/src/external_opensubdiv < ${PATCH_DIR}/opensubdiv.diff
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS}
INSTALL_DIR ${LIBDIR}/opensubdiv
)

View File

@@ -16,20 +16,26 @@
#
# ***** END GPL LICENSE BLOCK *****
if (UNIX)
set(THEORA_CONFIGURE_ENV ${CONFIGURE_ENV} && export HAVE_PDFLATEX=no)
else()
set(THEORA_CONFIGURE_ENV ${CONFIGURE_ENV})
endif()
ExternalProject_Add(external_theora
URL ${THEORA_URI}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH SHA256=${THEORA_HASH}
PREFIX ${BUILD_DIR}/theora
CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora
--disable-shared
--enable-static
--with-pic
--with-ogg=${LIBDIR}/ogg
--with-vorbis=${LIBDIR}/vorbis
--disable-examples
BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install
BUILD_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS}
INSTALL_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install
INSTALL_DIR ${LIBDIR}/theora
)

View File

@@ -105,8 +105,8 @@ set(CUEW_GIT_UID 1744972026de9cf27c8a7dc39cf39cd83d5f922f)
set(CUEW_URI https://github.com/CudaWrangler/cuew/archive/${CUEW_GIT_UID}.zip)
set(CUEW_HASH 86760d62978ebfd96cd93f5aa1abaf4a)
set(OPENSUBDIV_VERSION v3_3_3)
set(OPENSUBDIV_Hash 29c79dc01ef616aab02670bed5544ddd)
set(OPENSUBDIV_VERSION v3_4_0_RC2)
set(OPENSUBDIV_Hash f6a10ba9efaa82fde86fe65aad346319)
set(OPENSUBDIV_URI https://github.com/PixarAnimationStudios/OpenSubdiv/archive/${OPENSUBDIV_VERSION}.tar.gz)
set(SDL_VERSION 2.0.8)
@@ -143,11 +143,11 @@ set(OSL_VERSION 1.9.9)
set(OSL_URI https://github.com/imageworks/OpenShadingLanguage/archive/Release-${OSL_VERSION}.tar.gz)
set(OSL_HASH 44ad511e424965a10fce051a053b0605)
set(PYTHON_VERSION 3.7.0)
set(PYTHON_VERSION 3.7.4)
set(PYTHON_SHORT_VERSION 3.7)
set(PYTHON_SHORT_VERSION_NO_DOTS 37)
set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz)
set(PYTHON_HASH eb8c2a6b1447d50813c02714af4681f3)
set(PYTHON_HASH d33e4aae66097051c2eca45ee3604803)
set(TBB_VERSION 2018_U5)
set(TBB_URI https://github.com/01org/tbb/archive/${TBB_VERSION}.tar.gz)

View File

@@ -303,7 +303,7 @@ USE_CXX11=true
CLANG_FORMAT_VERSION_MIN="6.0"
PYTHON_VERSION="3.7.0"
PYTHON_VERSION="3.7.4"
PYTHON_VERSION_MIN="3.7"
PYTHON_FORCE_BUILD=false
PYTHON_FORCE_REBUILD=false
@@ -358,7 +358,7 @@ OSL_FORCE_REBUILD=false
OSL_SKIP=false
# OpenSubdiv needs to be compiled for now
OSD_VERSION="3.3.3"
OSD_VERSION="3.4.0_RC2"
OSD_VERSION_MIN=$OSD_VERSION
OSD_FORCE_BUILD=false
OSD_FORCE_REBUILD=false

View File

@@ -1,13 +0,0 @@
diff --git a/opensubdiv/far/topologyRefiner.cpp b/opensubdiv/far/topologyRefiner.cpp
index 3754b36e..7fe42bcc 100644
--- a/opensubdiv/far/topologyRefiner.cpp
+++ b/opensubdiv/far/topologyRefiner.cpp
@@ -263,7 +263,7 @@ namespace internal {
bool IsEmpty() const { return *((int_type*)this) == 0; }
FeatureMask() { Clear(); }
- FeatureMask(Options const & options, Sdc::SchemeType sType) { InitializeFeatures(options, sType); }
+ FeatureMask(Options const & options, Sdc::SchemeType sType) { Clear(); InitializeFeatures(options, sType); }
// These are the two primary methods intended for use -- intialization via a set of Options
// and reduction of the subsequent feature set (which presumes prior initialization with the

View File

@@ -6,7 +6,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/config/blender_release.cmake")
# There we can not use CPU bitness check since it is always 64bit. So instead
# we check for a specific libraries.
#
# Other builders we are runnign in a bare virtual machine, and the libraries
# Other builders we are running in a bare virtual machine, and the libraries
# are installed to /opt/.
# We assume that only 64bit builders exists in such configuration.
if(EXISTS "/lib/x86_64-linux-gnu/libc-2.24.so")

View File

@@ -61,7 +61,8 @@ if 'cmake' in builder:
# Set build options.
cmake_options = []
cmake_extra_options = ['-DCMAKE_BUILD_TYPE:STRING=Release']
cmake_extra_options = ['-DCMAKE_BUILD_TYPE:STRING=Release',
'-DWITH_GTESTS=ON']
if builder.startswith('mac'):
# Set up OSX architecture

View File

@@ -33,27 +33,44 @@ builder = sys.argv[1]
blender_dir = '../blender.git'
if "cmake" in builder:
# cmake
print("Automated tests are still DISABLED!")
sys.exit(0)
build_dir = os.path.abspath(os.path.join('..', 'build', builder))
chroot_name = None
chroot_prefix = []
install_dir = os.path.abspath(os.path.join('..', 'install', builder))
# NOTE: For quick test only to see if the approach work.
# n the future must be replaced with an actual blender version.
blender_version = '2.80'
blender_version_dir = os.path.join(install_dir, blender_version)
command_prefix = []
extra_ctest_args = []
"""
if builder.endswith('x86_64_cmake'):
chroot_name = 'buildbot_jessie_x86_64'
elif builder.endswith('i686_cmake'):
chroot_name = 'buildbot_jessie_i686'
if chroot_name:
chroot_prefix = ['schroot', '-c', chroot_name, '--']
"""
if builder.startswith('win'):
extra_ctest_args += ['-C', 'Release']
elif builder.startswith('linux'):
tokens = builder.split("_")
glibc = tokens[1]
if glibc == 'glibc224':
deb_name = "stretch"
if builder.endswith('x86_64_cmake'):
chroot_name = 'buildbot_' + deb_name + '_x86_64'
elif builder.endswith('i686_cmake'):
chroot_name = 'buildbot_' + deb_name + '_i686'
command_prefix = ['schroot', '--preserve-environment', '-c', chroot_name, '--']
elif glibc == 'glibc217':
command_prefix = ['scl', 'enable', 'devtoolset-6', '--']
ctest_env = os.environ.copy()
ctest_env['BLENDER_SYSTEM_SCRIPTS'] = os.path.join(blender_version_dir, 'scripts')
ctest_env['BLENDER_SYSTEM_DATAFILES'] = os.path.join(blender_version_dir, 'datafiles')
os.chdir(build_dir)
retcode = subprocess.call(chroot_prefix + ['ctest', '--output-on-failure'])
sys.exit(retcode)
retcode = subprocess.call(command_prefix + ['ctest', '--output-on-failure'] + extra_ctest_args,
env=ctest_env)
# Always exit with a success, for until we know all the tests are passing
# on all builders.
sys.exit(0)
else:
print("Unknown building system")
sys.exit(1)

View File

@@ -0,0 +1,67 @@
# - Find OpenXR-SDK library
# Find the native OpenXR-SDK includes and library
# This module defines
# OPENXR_SDK_INCLUDE_DIRS, where to find OpenXR-SDK headers, Set when
# OPENXR_SDK_INCLUDE_DIR is found.
# OPENXR_SDK_LIBRARIES, libraries to link against to use OpenXR-SDK.
# OPENXR_SDK_ROOT_DIR, the base directory to search for OpenXR-SDK.
# This can also be an environment variable.
# OPENXR_SDK_FOUND, if false, do not try to use OpenXR-SDK.
#
# also defined, but not for general use are
# OPENXR_LOADER_LIBRARY, where to find the OpenXR-SDK 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 OPENXR_SDK_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENXR_SDK_ROOT_DIR AND NOT $ENV{OPENXR_SDK_ROOT_DIR} STREQUAL "")
SET(OPENXR_SDK_ROOT_DIR $ENV{OPENXR_SDK_ROOT_DIR})
ENDIF()
SET(_openxr_sdk_SEARCH_DIRS
${OPENXR_SDK_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
)
FIND_PATH(OPENXR_SDK_INCLUDE_DIR
NAMES
openxr/openxr.h
HINTS
${_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
include
)
FIND_LIBRARY(OPENXR_LOADER_LIBRARY
NAMES
openxr_loader
HINTS
${_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set OPENXR_SDK_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENXR_SDK DEFAULT_MSG
OPENXR_LOADER_LIBRARY OPENXR_SDK_INCLUDE_DIR)
IF(OPENXR_SDK_FOUND)
SET(OPENXR_SDK_LIBRARIES ${OPENXR_LOADER_LIBRARY})
SET(OPENXR_SDK_INCLUDE_DIRS ${OPENXR_SDK_INCLUDE_DIR})
ENDIF(OPENXR_SDK_FOUND)
MARK_AS_ADVANCED(
OPENXR_SDK_INCLUDE_DIR
OPENXR_LOADER_LIBRARY
)

View File

@@ -6,7 +6,7 @@
# LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
# LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
# This can also be an environment variable.
# LIBSNDFILE_FOUND, If false, do not try to use SndFile.
# SNDFILE_FOUND, If false, do not try to use SndFile.
#
# also defined, but not for general use are
# LIBSNDFILE_LIBRARY, where to find the SndFile library.
@@ -50,16 +50,16 @@ FIND_LIBRARY(LIBSNDFILE_LIBRARY
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set LIBSNDFILE_FOUND to TRUE if
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SndFile DEFAULT_MSG
LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
IF(LIBSNDFILE_FOUND)
IF(SNDFILE_FOUND)
SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
SET(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
ENDIF(LIBSNDFILE_FOUND)
ENDIF(SNDFILE_FOUND)
MARK_AS_ADVANCED(
LIBSNDFILE_INCLUDE_DIR

View File

@@ -50,6 +50,10 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
INCLUDE_DIRECTORIES "${TEST_INC}")
if(${DO_ADD_TEST})
add_test(NAME ${NAME}_test COMMAND ${TESTS_OUTPUT_DIR}/${NAME}_test WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>)
# Don't fail tests on leaks since these often happen in external libraries
# that we can't fix.
set_tests_properties(${NAME}_test PROPERTIES ENVIRONMENT LSAN_OPTIONS=exitcode=0)
endif()
endif()
endmacro()

View File

@@ -0,0 +1,101 @@
set(PRESENTATION_BACKENDS xlib xcb wayland)
set(PRESENTATION_BACKEND xlib CACHE STRING
"Presentation backend chosen at configure time")
set_property(CACHE PRESENTATION_BACKEND PROPERTY STRINGS
${PRESENTATION_BACKENDS})
list(FIND PRESENTATION_BACKENDS ${PRESENTATION_BACKEND} index)
if(index EQUAL -1)
message(FATAL_ERROR "Presentation backend must be one of
${PRESENTATION_BACKENDS}")
endif()
message(STATUS "Using presentation backend: ${PRESENTATION_BACKEND}")
if( PRESENTATION_BACKEND MATCHES "xlib" )
find_package(X11 REQUIRED)
if ((NOT X11_Xxf86vm_LIB) OR (NOT X11_Xrandr_LIB))
message(FATAL_ERROR "OpenXR xlib backend requires Xxf86vm and Xrandr")
endif()
add_definitions( -DSUPPORT_X )
add_definitions( -DOS_LINUX_XLIB )
set( XLIB_LIBRARIES
${X11_LIBRARIES}
${X11_Xxf86vm_LIB}
${X11_Xrandr_LIB} )
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
find_package(PkgConfig REQUIRED)
# XCB + XCB GLX is limited to OpenGL 2.1
# add_definitions( -DOS_LINUX_XCB )
# XCB + Xlib GLX 1.3
add_definitions( -DOS_LINUX_XCB_GLX )
pkg_search_module(X11 REQUIRED x11)
pkg_search_module(XCB REQUIRED xcb)
pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
pkg_search_module(XCB_KEYSYMS REQUIRED xcb-keysyms)
pkg_search_module(XCB_GLX REQUIRED xcb-glx)
pkg_search_module(XCB_DRI2 REQUIRED xcb-dri2)
pkg_search_module(XCB_ICCCM REQUIRED xcb-icccm)
set( XCB_LIBRARIES
${XCB_LIBRARIES}
${XCB_KEYSYMS_LIBRARIES}
${XCB_RANDR_LIBRARIES}
${XCB_GLX_LIBRARIES}
${XCB_DRI2_LIBRARIES}
${X11_LIBRARIES} )
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
find_package(PkgConfig REQUIRED)
pkg_search_module(WAYLAND_CLIENT REQUIRED wayland-client)
pkg_search_module(WAYLAND_EGL REQUIRED wayland-egl)
pkg_search_module(WAYLAND_SCANNER REQUIRED wayland-scanner)
pkg_search_module(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.7)
pkg_search_module(EGL REQUIRED egl)
add_definitions( -DOS_LINUX_WAYLAND )
set( WAYLAND_LIBRARIES
${EGL_LIBRARIES}
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_EGL_LIBRARIES} )
# generate wayland protocols
set(WAYLAND_PROTOCOLS_DIR ${CMAKE_SOURCE_DIR}/wayland-protocols/)
file(MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR})
pkg_get_variable(WAYLAND_PROTOCOLS_DATADIR wayland-protocols pkgdatadir)
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
set(PROTOCOL xdg-shell-unstable-v6)
set(PROTOCOL_XML
${WAYLAND_PROTOCOLS_DATADIR}/unstable/xdg-shell/${PROTOCOL}.xml)
if( EXISTS ${PROTOCOL_XML} )
execute_process(COMMAND
${WAYLAND_SCANNER}
code
${PROTOCOL_XML}
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c)
execute_process(COMMAND
${WAYLAND_SCANNER}
client-header
${PROTOCOL_XML}
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h)
set( WAYLAND_PROTOCOL_SRC
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h )
include_directories(${WAYLAND_PROTOCOLS_DIR})
else()
message(FATAL_ERROR
"xdg-shell-unstable-v6.xml not found in "
${WAYLAND_PROTOCOLS_DATADIR}
"\nYour wayland-protocols package does not "
"contain xdg-shell-unstable-v6.")
endif()
endif()

View File

@@ -0,0 +1,47 @@
# Copyright (c) 2017 The Khronos Group Inc.
#
# 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.
if(WIN32)
add_definitions(-DXR_OS_WINDOWS)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DXR_OS_LINUX)
endif()
# Determine the presentation backend for Linux systems.
# Use an include because the code is pretty big.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(presentation)
endif()
# Several files use these compile-time platform switches
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_definitions( -DXR_USE_PLATFORM_WIN32 )
elseif( PRESENTATION_BACKEND MATCHES "xlib" )
add_definitions( -DXR_USE_PLATFORM_XLIB )
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
add_definitions( -DXR_USE_PLATFORM_XCB )
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
add_definitions( -DXR_USE_PLATFORM_WAYLAND )
endif()
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_definitions(-DXR_USE_GRAPHICS_API_D3D)
add_definitions(-DXR_USE_GRAPHICS_API_D3D10)
add_definitions(-DXR_USE_GRAPHICS_API_D3D11)
add_definitions(-DXR_USE_GRAPHICS_API_D3D12)
endif()

View File

@@ -130,7 +130,7 @@ def function_parm_wash_tokens(parm):
)
"""
Return tolens without trailing commands and 'const'
Return tokens without trailing commands and 'const'
"""
tokens = [t for t in parm.get_tokens()]

View File

@@ -238,7 +238,7 @@ def create_nb_project_main():
f.write(' </makeTool>\n')
f.write(' </makefileType>\n')
# finishe makefle info
# finished makefile info
f.write(' \n')

View File

@@ -0,0 +1,19 @@
# Configuration for developers, with faster builds, error checking and tests.
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_developer.cmake ../blender
#
set(WITH_ASSERT_ABORT ON CACHE BOOL "" FORCE)
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
set(WITH_COMPILER_ASAN ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEBUG ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_NATIVE_ONLY ON CACHE BOOL "" FORCE)
set(WITH_GTESTS ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS OFF CACHE BOOL "" FORCE)
set(WITH_PYTHON_SAFETY ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE)
# This may have issues with C++ initialization order, needs to be tested
# on all platforms to be sure this is safe to enable.
# set(WITH_CXX_GUARDEDALLOC ON CACHE BOOL "" FORCE)

View File

@@ -40,6 +40,7 @@ set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
set(WITH_OPENXR ON CACHE BOOL "" FORCE)
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)

View File

@@ -45,6 +45,7 @@ set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
set(WITH_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

@@ -41,6 +41,7 @@ set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA ON CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO ON CACHE BOOL "" FORCE)
set(WITH_OPENXR ON CACHE BOOL "" FORCE)
set(WITH_OPENMP ON CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)

View File

@@ -468,6 +468,9 @@ function(setup_liblinks
if(WITH_OPENSUBDIV)
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
if(WITH_OPENXR)
target_link_libraries(${target} ${OPENXR_SDK_LIBRARIES})
endif()
if(WITH_CYCLES_EMBREE)
target_link_libraries(${target} ${EMBREE_LIBRARIES})
endif()
@@ -713,7 +716,7 @@ macro(remove_strict_flags)
endif()
if(MSVC)
# TODO
remove_cc_flag(/w34189) # Restore warn C4189 (unused variable) back to w4
endif()
endmacro()

View File

@@ -393,16 +393,13 @@ if(WITH_OPENMP)
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp -I'${LIBDIR}/openmp/include'")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L'${LIBDIR}/openmp/lib' -lomp")
# Copy libomp.dylib to allow executables like datatoc to work.
if(CMAKE_MAKE_PROGRAM MATCHES "xcodebuild")
set(OPENMP_DYLIB_AUX_PATH "${CMAKE_BINARY_DIR}/bin")
else()
set(OPENMP_DYLIB_AUX_PATH "${CMAKE_BINARY_DIR}")
endif()
# Copy libomp.dylib to allow executables like datatoc and tests to work.
execute_process(
COMMAND mkdir -p ${OPENMP_DYLIB_AUX_PATH}/Resources/lib
COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${OPENMP_DYLIB_AUX_PATH}/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)
endif()
endif()

View File

@@ -156,7 +156,7 @@ endif()
# Codecs
if(WITH_CODEC_SNDFILE)
find_package_wrapper(SndFile)
if(NOT LIBSNDFILE_FOUND)
if(NOT SNDFILE_FOUND)
set(WITH_CODEC_SNDFILE OFF)
endif()
endif()

View File

@@ -144,6 +144,11 @@ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
#JMC is available on msvc 15.8 (1915) and up
if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /JMC")
endif()
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
@@ -166,8 +171,7 @@ if(NOT DEFINED LIBDIR)
message(STATUS "64 bit compiler detected.")
set(LIBDIR_BASE "win64")
else()
message(STATUS "32 bit compiler detected.")
set(LIBDIR_BASE "windows")
message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder")
endif()
# Can be 1910..1912
if(MSVC_VERSION GREATER 1919)
@@ -381,9 +385,6 @@ if(WITH_BOOST)
if(CMAKE_CL_64)
set(BOOST_POSTFIX "vc140-mt-s-x64-1_68.lib")
set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x64-1_68.lib")
else()
set(BOOST_POSTFIX "vc140-mt-s-x32-1_68.lib")
set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x32-1_68.lib")
endif()
set(BOOST_LIBRARIES
optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX}

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Builds a debian package from SVN source.
#
# For paralelle builds use:
# For parallel builds use:
# DEB_BUILD_OPTIONS="parallel=5" sh build_files/package_spec/build_debian.sh
# this needs to run in the root dir.

View File

@@ -2,11 +2,7 @@ if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14
if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14
if "%BUILD_VS_YEAR%"=="2019" set BUILD_VS_LIBDIRPOST=vc14
if "%BUILD_ARCH%"=="x64" (
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
) else if "%BUILD_ARCH%"=="x86" (
set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST%
)
set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST%
set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%"
if NOT "%verbose%" == "" (

View File

@@ -1,14 +1,6 @@
set BUILD_GENERATOR_POST=
set BUILD_PLATFORM_SELECT=
if "%BUILD_ARCH%"=="x64" (
set MSBUILD_PLATFORM=x64
) else if "%BUILD_ARCH%"=="x86" (
set MSBUILD_PLATFORM=win32
if "%WITH_CLANG%"=="1" (
echo Clang not supported for X86
exit /b 1
)
)
set MSBUILD_PLATFORM=x64
if "%WITH_CLANG%"=="1" (
set CLANG_CMAKE_ARGS=-T"llvm"

View File

@@ -6,11 +6,13 @@ if "%BUILD_ARCH%"=="" (
set WINDOWS_ARCH= Win64
set BUILD_ARCH=x64
) else (
set WINDOWS_ARCH=
set BUILD_ARCH=x86
echo Error: 32 bit builds of blender are no longer supported.
goto ERR
)
) else if "%BUILD_ARCH%"=="x64" (
set WINDOWS_ARCH= Win64
) else if "%BUILD_ARCH%"=="x86" (
set WINDOWS_ARCH=
)
:EOF
exit /b 0
:ERR
exit /b 1

View File

@@ -2,10 +2,6 @@ if EXIST %BLENDER_DIR%\..\lib\win64_vc14\llvm\bin\clang-format.exe (
set CF_PATH=..\lib\win64_vc14\llvm\bin
goto detect_done
)
if EXIST %BLENDER_DIR%\..\lib\windows_vc14\llvm\bin\clang-format.exe (
set CF_PATH=..\lib\windows_vc14\llvm\bin
goto detect_done
)
echo clang-format not found
exit /b 1

View File

@@ -41,10 +41,13 @@ if NOT "%1" == "" (
) else if "%1" == "release" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake"
set TARGET=Release
) else if "%1" == "developer" (
set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_developer.cmake"
) else if "%1" == "asan" (
set WITH_ASAN=1
) else if "%1" == "x86" (
set BUILD_ARCH=x86
) else if "%1" == "x86" (
echo Error: 32 bit builds of blender are no longer supported.
goto ERR
) else if "%1" == "x64" (
set BUILD_ARCH=x64
) else if "%1" == "2017" (
@@ -97,10 +100,12 @@ if NOT "%1" == "" (
goto EOF
) else (
echo Command "%1" unknown, aborting!
exit /b 1
goto ERR
)
shift /1
goto argv_loop
)
:EOF
exit /b 0
exit /b 0
:ERR
exit /b 1

View File

@@ -7,7 +7,6 @@ set BUILD_VS_YEAR=
set BUILD_VS_LIBDIRPOST=
set BUILD_VS_LIBDIR=
set BUILD_VS_SVNDIR=
set BUILD_NGE=
set KEY_NAME=
set MSBUILD_PLATFORM=
set MUST_CLEAN=

View File

@@ -1,4 +1,9 @@
set BUILD_DIR=%BUILD_DIR%_%TARGET%%BUILD_NGE%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
if NOT "%TARGET%" == "" (
set BUILD_DIR=%BUILD_DIR%_%TARGET%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
) else (
set BUILD_DIR=%BUILD_DIR%_%BUILD_ARCH%_vc%BUILD_VS_VER%_%BUILD_TYPE%
)
if NOT "%BUILD_DIR_OVERRRIDE%"=="" (
set BUILD_DIR=%BUILD_DIR_OVERRRIDE%
)

View File

@@ -17,13 +17,12 @@ echo - format [path] ^(Format the source using clang-format, path is optional, r
echo.
echo Configuration options
echo - verbose ^(enable diagnostic output during configuration^)
echo - developer ^(enable faster builds, error checking and tests, recommended for developers^)
echo - with_tests ^(enable building unit tests^)
echo - nobuildinfo ^(disable buildinfo^)
echo - debug ^(Build an unoptimized debuggable build^)
echo - packagename [newname] ^(override default cpack package name^)
echo - buildir [newdir] ^(override default build folder^)
echo - x86 ^(override host auto-detect and build 32 bit code^)
echo - x64 ^(override host auto-detect and build 64 bit code^)
echo - 2017 ^(build with visual studio 2017^)
echo - 2017pre ^(build with visual studio 2017 pre-release^)
echo - 2017b ^(build with visual studio 2017 Build Tools^)

View File

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

View File

@@ -177,7 +177,7 @@ font:
With the new truetype option in Blender, this is used for all font families
When a uiBlock is created, each uiButton that is defined gets the uiBlock properties.
Changing Block properties in between will affact uiButtons defined thereafter.
Changing Block properties in between will effect uiButtons defined thereafter.

View File

@@ -1,2 +1,2 @@
Sphinx==1.7.6
sphinx_rtd_theme==0.4.1
Sphinx==1.8.5
sphinx_rtd_theme==0.4.3

View File

@@ -1208,27 +1208,6 @@ offers a set of extensive examples, including advanced features.
:arg x, y, z: Specify the x, y, and z coordinates of a translation vector.
.. function:: glVertex (x,y,z,w,v):
B{glVertex2d, glVertex2f, glVertex2i, glVertex2s, glVertex3d, glVertex3f, glVertex3i,
glVertex3s, glVertex4d, glVertex4f, glVertex4i, glVertex4s, glVertex2dv, glVertex2fv,
glVertex2iv, glVertex2sv, glVertex3dv, glVertex3fv, glVertex3iv, glVertex3sv, glVertex4dv,
glVertex4fv, glVertex4iv, glVertex4sv}
Specify a vertex
.. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glVertex.xml>`__
:type x, y, z, w: Depends on function prototype (z and w for '3' and '4' prototypes only)
:arg x, y, z, w: Specify x, y, z, and w coordinates of a vertex. Not all parameters
are present in all forms of the command.
:type v: :class:`bgl.Buffer` object. Depends of function prototype (for 'v'
prototypes only)
:arg v: Specifies a pointer to an array of two, three, or four elements. The
elements of a two-element array are x and y; of a three-element array,
x, y, and z; and of a four-element array, x, y, z, and w.
.. function:: glViewport(x,y,width,height):
Set the viewport

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ In most cases you can figure out what context an operator needs
simply be seeing how it's used in Blender and thinking about what it does.
Unfortunately if you're still stuck - the only way to **really** know
whats going on is to read the source code for the poll function and see what its checking.
what's going on is to read the source code for the poll function and see what its checking.
For Python operators it's not so hard to find the source
since it's included with Blender and the source file/line is included in the operator reference docs.
@@ -125,7 +125,7 @@ While a script executes Blender waits for it to finish and is effectively locked
while in this state Blender won't redraw or respond to user input.
Normally this is not such a problem because scripts distributed with Blender
tend not to run for an extended period of time,
nevertheless scripts *can* take ages to execute and its nice to see whats going on in the view port.
nevertheless scripts *can* take ages to execute and its nice to see what's going on in the view port.
Tools that lock Blender in a loop and redraw are highly discouraged
since they conflict with Blenders ability to run multiple operators

View File

@@ -45,7 +45,7 @@ scene manipulation, automation, defining your own toolset and customization.
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
The exact location of this directory depends on your installation.
See the :ref:`directory layout docs <blender_manual:getting-started_installing-config-directories>`.
See the :ref:`directory layout docs <blender_manual:blender-directory-layout>`.
Script Loading

View File

@@ -51,7 +51,7 @@ A quick list of helpful things to know before starting:
| ``scripts/startup/bl_operators`` for operators.
Exact location depends on platform, see:
:ref:`Configuration and Data Paths <blender_manual:getting-started_installing-config-directories>`.
:ref:`directory layout docs <blender_manual:blender-directory-layout>`.
Running Scripts

View File

@@ -239,7 +239,7 @@ Drop Into a Python Interpreter in Your Script
=============================================
In the middle of a script you may want to inspect some variables,
run some function and generally dig about to see whats going on.
run some function and generally dig about to see what's going on.
.. code-block:: python

View File

@@ -156,7 +156,8 @@ def api_dump():
for func_id, attr in funcs:
# arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
func_args_ids = tuple(inspect.getargspec(attr).args)
sig = inspect.signature(attr)
func_args_ids = [k for k, v in sig.parameters.items()]
dump_class[func_id] = (
"func_py", # basic_type
@@ -175,7 +176,7 @@ def api_dump():
import pprint
filename = api_dunp_fname()
filehandle = open(filename, 'w')
filehandle = open(filename, 'w', encoding='utf-8')
tot = filehandle.write(pprint.pformat(dump, width=1))
filehandle.close()
print("%s, %d bytes written" % (filename, tot))
@@ -199,11 +200,11 @@ def compare_props(a, b, fuzz=0.75):
def api_changelog(api_from, api_to, api_out):
file_handle = open(api_from, 'r')
file_handle = open(api_from, 'r', encoding='utf-8')
dict_from = eval(file_handle.read())
file_handle.close()
file_handle = open(api_to, 'r')
file_handle = open(api_to, 'r', encoding='utf-8')
dict_to = eval(file_handle.read())
file_handle.close()
@@ -266,7 +267,7 @@ def api_changelog(api_from, api_to, api_out):
# also document function argument changes
fout = open(api_out, 'w')
fout = open(api_out, 'w', encoding='utf-8')
fw = fout.write
# print(api_changes)

View File

@@ -320,8 +320,6 @@ EXTRA_SOURCE_FILES = (
"../../../release/scripts/templates_py/ui_previews_custom_icon.py",
"../examples/bmesh.ops.1.py",
"../examples/bpy.app.translations.py",
"../static/favicon.ico",
"../static/blender_logo.svg",
)
@@ -401,7 +399,6 @@ is_release = bpy.app.version_cycle in {"rc", "release"}
# converting bytes to strings, due to T30154
BLENDER_REVISION = str(bpy.app.build_hash, 'utf_8')
BLENDER_DATE = str(bpy.app.build_date, 'utf_8')
if is_release:
# '2.62a'
@@ -409,9 +406,13 @@ if is_release:
else:
# '2.62.1'
BLENDER_VERSION_DOTS = ".".join(blender_version_strings)
if BLENDER_REVISION != "Unknown":
# '2.62a SHA1' (release) or '2.62.1 SHA1' (non-release)
BLENDER_VERSION_DOTS += " " + BLENDER_REVISION
BLENDER_VERSION_HASH = BLENDER_REVISION
else:
# Fallback: Should not be used
BLENDER_VERSION_HASH = "Hash Unknown"
if is_release:
# '2_62a_release'
@@ -1610,26 +1611,39 @@ def write_sphinx_conf_py(basepath):
fw("import sys, os\n\n")
fw("extensions = ['sphinx.ext.intersphinx']\n\n")
fw("intersphinx_mapping = {'blender_manual': ('https://docs.blender.org/manual/en/dev/', None)}\n\n")
fw("project = 'Blender'\n")
fw("project = 'Blender %s Python API'\n" % BLENDER_VERSION_DOTS)
fw("master_doc = 'index'\n")
fw("copyright = u'Blender Foundation'\n")
fw("version = '%s'\n" % BLENDER_VERSION_DOTS)
fw("release = '%s'\n" % BLENDER_VERSION_DOTS)
fw("version = '%s'\n" % BLENDER_VERSION_HASH)
fw("release = '%s'\n" % BLENDER_VERSION_HASH)
# Quiet file not in table-of-contents warnings.
fw("exclude_patterns = [\n")
fw(" 'include__bmesh.rst',\n")
fw("]\n\n")
fw("html_title = 'Blender %s Python API'\n" % BLENDER_VERSION_DOTS)
fw("html_title = 'Blender Python API'\n")
fw("html_theme = 'sphinx_rtd_theme'\n")
fw("html_theme_options = {\n")
fw(" 'canonical_url': 'https://docs.blender.org/api/current/',\n")
# fw(" 'analytics_id': '',\n")
# fw(" 'collapse_navigation': True,\n")
fw(" 'sticky_navigation': False,\n")
fw(" 'navigation_depth': 1,\n")
# fw(" 'includehidden': True,\n")
# fw(" 'titles_only': False\n")
fw(" }\n\n")
# not helpful since the source is generated, adds to upload size.
fw("html_copy_source = False\n")
fw("html_show_sphinx = False\n")
fw("html_use_opensearch = 'https://docs.blender.org/api/current'\n")
fw("html_split_index = True\n")
fw("html_extra_path = ['__/static/favicon.ico', '__/static/blender_logo.svg']\n")
fw("html_favicon = '__/static/favicon.ico'\n")
fw("html_logo = '__/static/blender_logo.svg'\n\n")
fw("html_static_path = ['static']\n")
fw("html_extra_path = ['static/favicon.ico', 'static/blender_logo.svg']\n")
fw("html_favicon = 'static/favicon.ico'\n")
fw("html_logo = 'static/blender_logo.svg'\n")
fw("html_last_updated_fmt = '%m/%d/%Y'\n\n")
# needed for latex, pdf gen
fw("latex_elements = {\n")
@@ -1649,12 +1663,13 @@ class PatchedPythonDomain(PythonDomain):
del node['refspecific']
return super(PatchedPythonDomain, self).resolve_xref(
env, fromdocname, builder, typ, target, node, contnode)
def setup(sphinx):
sphinx.override_domain(PatchedPythonDomain)
""")
# end workaround
fw("def setup(app):\n")
fw(" app.add_stylesheet('css/theme_overrides.css')\n")
fw(" app.override_domain(PatchedPythonDomain)\n\n")
file.close()
@@ -1673,14 +1688,14 @@ def write_rst_contents(basepath):
file = open(filepath, "w", encoding="utf-8")
fw = file.write
fw(title_string("Blender Python API Documentation", "%", double=True))
fw(title_string("Blender %s Python API Documentation" % BLENDER_VERSION_DOTS, "%", double=True))
fw("\n")
fw("Welcome to the API reference for Blender %s, built %s.\n" %
(BLENDER_VERSION_DOTS, BLENDER_DATE))
fw("Welcome to the Python API documentation for `Blender <https://www.blender.org>`__, ")
fw("the free and open source 3D creation suite.\n")
fw("\n")
# fw("`A PDF version of this document is also available <%s>`_\n" % BLENDER_PDF_FILENAME)
fw("This site can be downloaded for offline use: `Download the full Documentation (zipped HTML files) <%s>`_\n" %
fw("This site can be used offline: `Download the full documentation (zipped HTML files) <%s>`__\n" %
BLENDER_ZIP_FILENAME)
fw("\n")
@@ -1912,6 +1927,12 @@ def copy_handwritten_extra(basepath):
shutil.copy2(f_src, f_dst)
def copy_theme_assets(basepath):
shutil.copytree(os.path.join(SCRIPT_DIR, "static"),
os.path.join(basepath, "static"),
copy_function=shutil.copy)
def rna2sphinx(basepath):
try:
@@ -1946,6 +1967,9 @@ def rna2sphinx(basepath):
# copy source files referenced
copy_handwritten_extra(basepath)
# copy extra files needed for theme
copy_theme_assets(basepath)
def align_sphinx_in_to_sphinx_in_tmp(dir_src, dir_dst):
'''

View File

@@ -0,0 +1,11 @@
/* Prevent Long enum lists */
.field-body {
display: block;
width: 100%;
max-height: 245px;
overflow-y: auto !important;
}
/* Hide home icon in search area */
.wy-side-nav-search > a:hover {background: none; opacity: 0.9}
.wy-side-nav-search > a.icon::before {content: none}

View File

@@ -105,3 +105,8 @@ if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_CMAKE_CFG ${CMAKE_CURRENT_SOURCE_DIR}/audaspace/blender_config.cmake)
add_subdirectory(audaspace)
endif()
if(WITH_OPENXR AND OPENXR_USE_BUNDLED_SRC)
add_subdirectory(jsoncpp)
add_subdirectory(openxr)
endif()

20
extern/jsoncpp/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,20 @@
# ***** 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.
#
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
add_subdirectory(src)

98
extern/jsoncpp/include/json/allocator.h vendored Normal file
View File

@@ -0,0 +1,98 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
#include <cstring>
#include <memory>
#pragma pack(push, 8)
namespace Json {
template<typename T>
class SecureAllocator {
public:
// Type definitions
using value_type = T;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
/**
* Allocate memory for N items using the standard allocator.
*/
pointer allocate(size_type n) {
// allocate using "global operator new"
return static_cast<pointer>(::operator new(n * sizeof(T)));
}
/**
* Release memory which was allocated for N items at pointer P.
*
* The memory block is filled with zeroes before being released.
* The pointer argument is tagged as "volatile" to prevent the
* compiler optimizing out this critical step.
*/
void deallocate(volatile pointer p, size_type n) {
std::memset(p, 0, n * sizeof(T));
// free using "global operator delete"
::operator delete(p);
}
/**
* Construct an item in-place at pointer P.
*/
template<typename... Args>
void construct(pointer p, Args&&... args) {
// construct using "placement new" and "perfect forwarding"
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
}
size_type max_size() const {
return size_t(-1) / sizeof(T);
}
pointer address( reference x ) const {
return std::addressof(x);
}
const_pointer address( const_reference x ) const {
return std::addressof(x);
}
/**
* Destroy an item in-place at pointer P.
*/
void destroy(pointer p) {
// destroy using "explicit destructor"
p->~T();
}
// Boilerplate
SecureAllocator() {}
template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
template<typename U> struct rebind { using other = SecureAllocator<U>; };
};
template<typename T, typename U>
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
return true;
}
template<typename T, typename U>
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
return false;
}
} //namespace Json
#pragma pack(pop)
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED

View File

@@ -0,0 +1,54 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
#include <stdlib.h>
#include <sstream>
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
/** It should not be possible for a maliciously designed file to
* cause an abort() or seg-fault, so these macros are used only
* for pre-condition violations and internal logic errors.
*/
#if JSON_USE_EXCEPTION
// @todo <= add detail about condition in exception
# define JSON_ASSERT(condition) \
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
# define JSON_FAIL_MESSAGE(message) \
{ \
JSONCPP_OSTRINGSTREAM oss; oss << message; \
Json::throwLogicError(oss.str()); \
abort(); \
}
#else // JSON_USE_EXCEPTION
# define JSON_ASSERT(condition) assert(condition)
// The call to assert() will show the failure message in debug builds. In
// release builds we abort, for a core-dump or debugger.
# define JSON_FAIL_MESSAGE(message) \
{ \
JSONCPP_OSTRINGSTREAM oss; oss << message; \
assert(false && oss.str().c_str()); \
abort(); \
}
#endif
#define JSON_ASSERT_MESSAGE(condition, message) \
if (!(condition)) { \
JSON_FAIL_MESSAGE(message); \
}
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED

25
extern/jsoncpp/include/json/autolink.h vendored Normal file
View File

@@ -0,0 +1,25 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_AUTOLINK_H_INCLUDED
#define JSON_AUTOLINK_H_INCLUDED
#include "config.h"
#ifdef JSON_IN_CPPTL
#include <cpptl/cpptl_autolink.h>
#endif
#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && \
!defined(JSON_IN_CPPTL)
#define CPPTL_AUTOLINK_NAME "json"
#undef CPPTL_AUTOLINK_DLL
#ifdef JSON_DLL
#define CPPTL_AUTOLINK_DLL
#endif
#include "autolink.h"
#endif
#endif // JSON_AUTOLINK_H_INCLUDED

184
extern/jsoncpp/include/json/config.h vendored Normal file
View File

@@ -0,0 +1,184 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <stddef.h>
#include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
#ifndef JSON_USE_EXCEPTION
#define JSON_USE_EXCEPTION 1
#endif
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGAMATION
#ifdef JSON_IN_CPPTL
#include <cpptl/config.h>
#ifndef JSON_USE_CPPTL
#define JSON_USE_CPPTL 1
#endif
#endif
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#endif // ifdef JSON_IN_CPPTL
#if !defined(JSON_API)
#define JSON_API
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) // MSVC
# if _MSC_VER <= 1200 // MSVC 6
// Microsoft Visual Studio 6 only support conversion from __int64 to double
// (no conversion from unsigned __int64).
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
// characters in the debug information)
// All projects I've ever seen with VS6 were using this globally (not bothering
// with pragma push/pop).
# pragma warning(disable : 4786)
# endif // MSVC 6
# if _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
# endif
#endif // defined(_MSC_VER)
// In c++11 the override keyword allows you to explicity define that a function
// is intended to override the base-class version. This makes the code more
// managable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L
# define JSONCPP_OVERRIDE override
# define JSONCPP_NOEXCEPT noexcept
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
# define JSONCPP_OVERRIDE override
# define JSONCPP_NOEXCEPT throw()
#elif defined(_MSC_VER) && _MSC_VER >= 1900
# define JSONCPP_OVERRIDE override
# define JSONCPP_NOEXCEPT noexcept
#else
# define JSONCPP_OVERRIDE
# define JSONCPP_NOEXCEPT throw()
#endif
#ifndef JSON_HAS_RVALUE_REFERENCES
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // MSVC >= 2010
#ifdef __clang__
#if __has_feature(cxx_rvalue_references)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // has_feature
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // GXX_EXPERIMENTAL
#endif // __clang__ || __GNUC__
#endif // not defined JSON_HAS_RVALUE_REFERENCES
#ifndef JSON_HAS_RVALUE_REFERENCES
#define JSON_HAS_RVALUE_REFERENCES 0
#endif
#ifdef __clang__
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
# endif // GNUC version
#endif // __clang__ || __GNUC__
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
#if __GNUC__ >= 6
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif
#if !defined(JSON_IS_AMALGAMATION)
# include "version.h"
# if JSONCPP_USING_SECURE_MEMORY
# include "allocator.h" //typedef Allocator
# endif
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef int64_t Int64;
typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
#if JSONCPP_USING_SECURE_MEMORY
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_ISTREAM std::istream
#else
#define JSONCPP_STRING std::string
#define JSONCPP_OSTRINGSTREAM std::ostringstream
#define JSONCPP_OSTREAM std::ostream
#define JSONCPP_ISTRINGSTREAM std::istringstream
#define JSONCPP_ISTREAM std::istream
#endif // if JSONCPP_USING_SECURE_MEMORY
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED

61
extern/jsoncpp/include/json/features.h vendored Normal file
View File

@@ -0,0 +1,61 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
#define CPPTL_JSON_FEATURES_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
#pragma pack(push, 8)
namespace Json {
/** \brief Configuration passed to reader and writer.
* This configuration object can be used to force the Reader or Writer
* to behave in a standard conforming way.
*/
class JSON_API Features {
public:
/** \brief A configuration that allows all features and assumes all strings
* are UTF-8.
* - C & C++ comments are allowed
* - Root object can be any JSON value
* - Assumes Value strings are encoded in UTF-8
*/
static Features all();
/** \brief A configuration that is strictly compatible with the JSON
* specification.
* - Comments are forbidden.
* - Root object must be either an array or an object value.
* - Assumes Value strings are encoded in UTF-8
*/
static Features strictMode();
/** \brief Initialize the configuration like JsonConfig::allFeatures;
*/
Features();
/// \c true if comments are allowed. Default: \c true.
bool allowComments_;
/// \c true if root must be either an array or an object value. Default: \c
/// false.
bool strictRoot_;
/// \c true if dropped null placeholders are allowed. Default: \c false.
bool allowDroppedNullPlaceholders_;
/// \c true if numeric object key are allowed. Default: \c false.
bool allowNumericKeys_;
};
} // namespace Json
#pragma pack(pop)
#endif // CPPTL_JSON_FEATURES_H_INCLUDED

37
extern/jsoncpp/include/json/forwards.h vendored Normal file
View File

@@ -0,0 +1,37 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
#define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED

15
extern/jsoncpp/include/json/json.h vendored Normal file
View File

@@ -0,0 +1,15 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_JSON_H_INCLUDED
#define JSON_JSON_H_INCLUDED
#include "autolink.h"
#include "value.h"
#include "reader.h"
#include "writer.h"
#include "features.h"
#endif // JSON_JSON_H_INCLUDED

408
extern/jsoncpp/include/json/reader.h vendored Normal file
View File

@@ -0,0 +1,408 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef CPPTL_JSON_READER_H_INCLUDED
#define CPPTL_JSON_READER_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "features.h"
#include "value.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <deque>
#include <iosfwd>
#include <stack>
#include <string>
#include <istream>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(push)
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
*Value.
*
* \deprecated Use CharReader and CharReaderBuilder.
*/
class JSON_API Reader {
public:
typedef char Char;
typedef const Char* Location;
/** \brief An error tagged with where in the JSON text it was encountered.
*
* The offsets give the [start, limit) range of bytes within the text. Note
* that this is bytes, not codepoints.
*
*/
struct StructuredError {
ptrdiff_t offset_start;
ptrdiff_t offset_limit;
JSONCPP_STRING message;
};
/** \brief Constructs a Reader allowing all features
* for parsing.
*/
Reader();
/** \brief Constructs a Reader allowing the specified feature set
* for parsing.
*/
Reader(const Features& features);
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
* document.
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them
* back during
* serialization, \c false to discard comments.
* This parameter is ignored if
* Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an
* error occurred.
*/
bool
parse(const std::string& document, Value& root, bool collectComments = true);
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
document.
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
document to read.
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
document to read.
* Must be >= beginDoc.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them
back during
* serialization, \c false to discard comments.
* This parameter is ignored if
Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an
error occurred.
*/
bool parse(const char* beginDoc,
const char* endDoc,
Value& root,
bool collectComments = true);
/// \brief Parse from input stream.
/// \see Json::operator>>(std::istream&, Json::Value&).
bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
/** \brief Returns a user friendly string that list errors in the parsed
* document.
* \return Formatted error message with the list of errors with their location
* in
* the parsed document. An empty string is returned if no error
* occurred
* during parsing.
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
JSONCPP_STRING getFormatedErrorMessages() const;
/** \brief Returns a user friendly string that list errors in the parsed
* document.
* \return Formatted error message with the list of errors with their location
* in
* the parsed document. An empty string is returned if no error
* occurred
* during parsing.
*/
JSONCPP_STRING getFormattedErrorMessages() const;
/** \brief Returns a vector of structured erros encounted while parsing.
* \return A (possibly empty) vector of StructuredError objects. Currently
* only one error can be returned, but the caller should tolerate
* multiple
* errors. This can occur if the parser recovers from a non-fatal
* parse error and then encounters additional errors.
*/
std::vector<StructuredError> getStructuredErrors() const;
/** \brief Add a semantic error message.
* \param value JSON Value location associated with the error
* \param message The error message.
* \return \c true if the error was successfully added, \c false if the
* Value offset exceeds the document size.
*/
bool pushError(const Value& value, const JSONCPP_STRING& message);
/** \brief Add a semantic error message with extra context.
* \param value JSON Value location associated with the error
* \param message The error message.
* \param extra Additional JSON Value location to contextualize the error
* \return \c true if the error was successfully added, \c false if either
* Value offset exceeds the document size.
*/
bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
/** \brief Return whether there are any errors.
* \return \c true if there are no errors to report \c false if
* errors have occurred.
*/
bool good() const;
private:
enum TokenType {
tokenEndOfStream = 0,
tokenObjectBegin,
tokenObjectEnd,
tokenArrayBegin,
tokenArrayEnd,
tokenString,
tokenNumber,
tokenTrue,
tokenFalse,
tokenNull,
tokenArraySeparator,
tokenMemberSeparator,
tokenComment,
tokenError
};
class Token {
public:
TokenType type_;
Location start_;
Location end_;
};
class ErrorInfo {
public:
Token token_;
JSONCPP_STRING message_;
Location extra_;
};
typedef std::deque<ErrorInfo> Errors;
bool readToken(Token& token);
void skipSpaces();
bool match(Location pattern, int patternLength);
bool readComment();
bool readCStyleComment();
bool readCppStyleComment();
bool readString();
void readNumber();
bool readValue();
bool readObject(Token& token);
bool readArray(Token& token);
bool decodeNumber(Token& token);
bool decodeNumber(Token& token, Value& decoded);
bool decodeString(Token& token);
bool decodeString(Token& token, JSONCPP_STRING& decoded);
bool decodeDouble(Token& token);
bool decodeDouble(Token& token, Value& decoded);
bool decodeUnicodeCodePoint(Token& token,
Location& current,
Location end,
unsigned int& unicode);
bool decodeUnicodeEscapeSequence(Token& token,
Location& current,
Location end,
unsigned int& unicode);
bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
bool recoverFromError(TokenType skipUntilToken);
bool addErrorAndRecover(const JSONCPP_STRING& message,
Token& token,
TokenType skipUntilToken);
void skipUntilSpace();
Value& currentValue();
Char getNextChar();
void
getLocationLineAndColumn(Location location, int& line, int& column) const;
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token);
typedef std::stack<Value*> Nodes;
Nodes nodes_;
Errors errors_;
JSONCPP_STRING document_;
Location begin_;
Location end_;
Location current_;
Location lastValueEnd_;
Value* lastValue_;
JSONCPP_STRING commentsBefore_;
Features features_;
bool collectComments_;
}; // Reader
/** Interface for reading JSON from a char array.
*/
class JSON_API CharReader {
public:
virtual ~CharReader() {}
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
document.
* The document must be a UTF-8 encoded string containing the document to read.
*
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
document to read.
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
document to read.
* Must be >= beginDoc.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param errs [out] Formatted error messages (if not NULL)
* a user friendly string that lists errors in the parsed
* document.
* \return \c true if the document was successfully parsed, \c false if an
error occurred.
*/
virtual bool parse(
char const* beginDoc, char const* endDoc,
Value* root, JSONCPP_STRING* errs) = 0;
class JSON_API Factory {
public:
virtual ~Factory() {}
/** \brief Allocate a CharReader via operator new().
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
virtual CharReader* newCharReader() const = 0;
}; // Factory
}; // CharReader
/** \brief Build a CharReader implementation.
Usage:
\code
using namespace Json;
CharReaderBuilder builder;
builder["collectComments"] = false;
Value value;
JSONCPP_STRING errs;
bool ok = parseFromStream(builder, std::cin, &value, &errs);
\endcode
*/
class JSON_API CharReaderBuilder : public CharReader::Factory {
public:
// Note: We use a Json::Value so that we can add data-members to this class
// without a major version bump.
/** Configuration of this builder.
These are case-sensitive.
Available settings (case-sensitive):
- `"collectComments": false or true`
- true to collect comment and allow writing them
back during serialization, false to discard comments.
This parameter is ignored if allowComments is false.
- `"allowComments": false or true`
- true if comments are allowed.
- `"strictRoot": false or true`
- true if root must be either an array or an object value
- `"allowDroppedNullPlaceholders": false or true`
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
- `"allowNumericKeys": false or true`
- true if numeric object keys are allowed.
- `"allowSingleQuotes": false or true`
- true if '' are allowed for strings (both keys and values)
- `"stackLimit": integer`
- Exceeding stackLimit (recursive depth of `readValue()`) will
cause an exception.
- This is a security issue (seg-faults caused by deeply nested JSON),
so the default is low.
- `"failIfExtra": false or true`
- If true, `parse()` returns false when extra non-whitespace trails
the JSON value in the input string.
- `"rejectDupKeys": false or true`
- If true, `parse()` returns false when a key is duplicated within an object.
- `"allowSpecialFloats": false or true`
- If true, special float values (NaNs and infinities) are allowed
and their values are lossfree restorable.
You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any
JSON Value.
\sa setDefaults()
*/
Json::Value settings_;
CharReaderBuilder();
~CharReaderBuilder() JSONCPP_OVERRIDE;
CharReader* newCharReader() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
*/
bool validate(Json::Value* invalid) const;
/** A simple way to update a specific setting.
*/
Value& operator[](JSONCPP_STRING key);
/** Called by ctor, but you can use this to reset settings_.
* \pre 'settings' != NULL (but Json::null is fine)
* \remark Defaults:
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
*/
static void setDefaults(Json::Value* settings);
/** Same as old Features::strictMode().
* \pre 'settings' != NULL (but Json::null is fine)
* \remark Defaults:
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
*/
static void strictMode(Json::Value* settings);
};
/** Consume entire stream and use its begin/end.
* Someday we might have a real StreamReader, but for now this
* is convenient.
*/
bool JSON_API parseFromStream(
CharReader::Factory const&,
JSONCPP_ISTREAM&,
Value* root, std::string* errs);
/** \brief Read from 'sin' into 'root'.
Always keep comments from the input JSON.
This can be used to read a file into a particular sub-object.
For example:
\code
Json::Value root;
cin >> root["dir"]["file"];
cout << root;
\endcode
Result:
\verbatim
{
"dir": {
"file": {
// The input stream JSON would be nested here.
}
}
}
\endverbatim
\throw std::exception on parse error.
\see Json::operator<<()
*/
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
} // namespace Json
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#endif // CPPTL_JSON_READER_H_INCLUDED

888
extern/jsoncpp/include/json/value.h vendored Normal file
View File

@@ -0,0 +1,888 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef CPPTL_JSON_H_INCLUDED
#define CPPTL_JSON_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <string>
#include <vector>
#include <exception>
#ifndef JSON_USE_CPPTL_SMALLMAP
#include <map>
#else
#include <cpptl/smallmap.h>
#endif
#ifdef JSON_USE_CPPTL
#include <cpptl/forwards.h>
#endif
//Conditional NORETURN attribute on the throw functions would:
// a) suppress false positives from static code analysis
// b) possibly improve optimization opportunities.
#if !defined(JSONCPP_NORETURN)
# if defined(_MSC_VER)
# define JSONCPP_NORETURN __declspec(noreturn)
# elif defined(__GNUC__)
# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
# else
# define JSONCPP_NORETURN
# endif
#endif
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(push)
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
/** \brief JSON (JavaScript Object Notation).
*/
namespace Json {
/** Base class for all exceptions we throw.
*
* We use nothing but these internally. Of course, STL can throw others.
*/
class JSON_API Exception : public std::exception {
public:
Exception(JSONCPP_STRING const& msg);
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
protected:
JSONCPP_STRING msg_;
};
/** Exceptions which the user cannot easily avoid.
*
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
*
* \remark derived from Json::Exception
*/
class JSON_API RuntimeError : public Exception {
public:
RuntimeError(JSONCPP_STRING const& msg);
};
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
*
* These are precondition-violations (user bugs) and internal errors (our bugs).
*
* \remark derived from Json::Exception
*/
class JSON_API LogicError : public Exception {
public:
LogicError(JSONCPP_STRING const& msg);
};
/// used internally
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
/// used internally
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
/** \brief Type of the value held by a Value object.
*/
enum ValueType {
nullValue = 0, ///< 'null' value
intValue, ///< signed integer value
uintValue, ///< unsigned integer value
realValue, ///< double value
stringValue, ///< UTF-8 string value
booleanValue, ///< bool value
arrayValue, ///< array value (ordered list)
objectValue ///< object value (collection of name/value pairs).
};
enum CommentPlacement {
commentBefore = 0, ///< a comment placed on the line before a value
commentAfterOnSameLine, ///< a comment just after a value on the same line
commentAfter, ///< a comment on the line after a value (only make sense for
/// root value)
numberOfCommentPlacement
};
//# ifdef JSON_USE_CPPTL
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
//# endif
/** \brief Lightweight wrapper to tag static string.
*
* Value constructor and objectValue member assignement takes advantage of the
* StaticString and avoid the cost of string duplication when storing the
* string or the member name.
*
* Example of usage:
* \code
* Json::Value aValue( StaticString("some text") );
* Json::Value object;
* static const StaticString code("code");
* object[code] = 1234;
* \endcode
*/
class JSON_API StaticString {
public:
explicit StaticString(const char* czstring) : c_str_(czstring) {}
operator const char*() const { return c_str_; }
const char* c_str() const { return c_str_; }
private:
const char* c_str_;
};
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
*
* This class is a discriminated union wrapper that can represents a:
* - signed integer [range: Value::minInt - Value::maxInt]
* - unsigned integer (range: 0 - Value::maxUInt)
* - double
* - UTF-8 string
* - boolean
* - 'null'
* - an ordered list of Value
* - collection of name/value pairs (javascript object)
*
* The type of the held value is represented by a #ValueType and
* can be obtained using type().
*
* Values of an #objectValue or #arrayValue can be accessed using operator[]()
* methods.
* Non-const methods will automatically create the a #nullValue element
* if it does not exist.
* The sequence of an #arrayValue will be automatically resized and initialized
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
*
* The get() methods can be used to obtain default value in the case the
* required element does not exist.
*
* It is possible to iterate over the list of a #objectValue values using
* the getMemberNames() method.
*
* \note #Value string-length fit in size_t, but keys must be < 2^30.
* (The reason is an implementation detail.) A #CharReader will raise an
* exception if a bound is exceeded to avoid security holes in your app,
* but the Value API does *not* check bounds. That is the responsibility
* of the caller.
*/
class JSON_API Value {
friend class ValueIteratorBase;
public:
typedef std::vector<JSONCPP_STRING> Members;
typedef ValueIterator iterator;
typedef ValueConstIterator const_iterator;
typedef Json::UInt UInt;
typedef Json::Int Int;
#if defined(JSON_HAS_INT64)
typedef Json::UInt64 UInt64;
typedef Json::Int64 Int64;
#endif // defined(JSON_HAS_INT64)
typedef Json::LargestInt LargestInt;
typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex;
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
/// Minimum signed integer value that can be stored in a Json::Value.
static const LargestInt minLargestInt;
/// Maximum signed integer value that can be stored in a Json::Value.
static const LargestInt maxLargestInt;
/// Maximum unsigned integer value that can be stored in a Json::Value.
static const LargestUInt maxLargestUInt;
/// Minimum signed int value that can be stored in a Json::Value.
static const Int minInt;
/// Maximum signed int value that can be stored in a Json::Value.
static const Int maxInt;
/// Maximum unsigned int value that can be stored in a Json::Value.
static const UInt maxUInt;
#if defined(JSON_HAS_INT64)
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
static const Int64 minInt64;
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
static const Int64 maxInt64;
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
static const UInt64 maxUInt64;
#endif // defined(JSON_HAS_INT64)
private:
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
class CZString {
public:
enum DuplicationPolicy {
noDuplication = 0,
duplicate,
duplicateOnCopy
};
CZString(ArrayIndex index);
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
CZString(CZString const& other);
#if JSON_HAS_RVALUE_REFERENCES
CZString(CZString&& other);
#endif
~CZString();
CZString& operator=(const CZString& other);
#if JSON_HAS_RVALUE_REFERENCES
CZString& operator=(CZString&& other);
#endif
bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const;
ArrayIndex index() const;
//const char* c_str() const; ///< \deprecated
char const* data() const;
unsigned length() const;
bool isStaticString() const;
private:
void swap(CZString& other);
struct StringStorage {
unsigned policy_: 2;
unsigned length_: 30; // 1GB max
};
char const* cstr_; // actually, a prefixed string, unless policy is noDup
union {
ArrayIndex index_;
StringStorage storage_;
};
};
public:
#ifndef JSON_USE_CPPTL_SMALLMAP
typedef std::map<CZString, Value> ObjectValues;
#else
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
public:
/** \brief Create a default Value of the given type.
This is a very useful constructor.
To create an empty array, pass arrayValue.
To create an empty object, pass objectValue.
Another Value can then be set to this one by assignment.
This is useful since clear() and resize() will not alter types.
Examples:
\code
Json::Value null_value; // null
Json::Value arr_value(Json::arrayValue); // []
Json::Value obj_value(Json::objectValue); // {}
\endcode
*/
Value(ValueType type = nullValue);
Value(Int value);
Value(UInt value);
#if defined(JSON_HAS_INT64)
Value(Int64 value);
Value(UInt64 value);
#endif // if defined(JSON_HAS_INT64)
Value(double value);
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
/** \brief Constructs a value from a static string.
* Like other value string constructor but do not duplicate the string for
* internal storage. The given string must remain alive after the call to this
* constructor.
* \note This works only for null-terminated strings. (We cannot change the
* size of this class, so we have nowhere to store the length,
* which might be computed later for various operations.)
*
* Example of usage:
* \code
* static StaticString foo("some text");
* Json::Value aValue(foo);
* \endcode
*/
Value(const StaticString& value);
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
#ifdef JSON_USE_CPPTL
Value(const CppTL::ConstString& value);
#endif
Value(bool value);
/// Deep copy.
Value(const Value& other);
#if JSON_HAS_RVALUE_REFERENCES
/// Move constructor
Value(Value&& other);
#endif
~Value();
/// Deep copy, then swap(other).
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
Value& operator=(const Value& other);
#if JSON_HAS_RVALUE_REFERENCES
Value& operator=(Value&& other);
#endif
/// Swap everything.
void swap(Value& other);
/// Swap values but leave comments and source offsets in place.
void swapPayload(Value& other);
/// copy everything.
void copy(const Value& other);
/// copy values but leave comments and source offsets in place.
void copyPayload(const Value& other);
ValueType type() const;
/// Compare payload only, not comments etc.
bool operator<(const Value& other) const;
bool operator<=(const Value& other) const;
bool operator>=(const Value& other) const;
bool operator>(const Value& other) const;
bool operator==(const Value& other) const;
bool operator!=(const Value& other) const;
int compare(const Value& other) const;
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
#if JSONCPP_USING_SECURE_MEMORY
unsigned getCStringLength() const; //Allows you to understand the length of the CString
#endif
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
/** Get raw char* of string-value.
* \return false if !string. (Seg-fault if str or end are NULL.)
*/
bool getString(
char const** begin, char const** end) const;
#ifdef JSON_USE_CPPTL
CppTL::ConstString asConstString() const;
#endif
Int asInt() const;
UInt asUInt() const;
#if defined(JSON_HAS_INT64)
Int64 asInt64() const;
UInt64 asUInt64() const;
#endif // if defined(JSON_HAS_INT64)
LargestInt asLargestInt() const;
LargestUInt asLargestUInt() const;
float asFloat() const;
double asDouble() const;
bool asBool() const;
bool isNull() const;
bool isBool() const;
bool isInt() const;
bool isInt64() const;
bool isUInt() const;
bool isUInt64() const;
bool isIntegral() const;
bool isDouble() const;
bool isNumeric() const;
bool isString() const;
bool isArray() const;
bool isObject() const;
bool isConvertibleTo(ValueType other) const;
/// Number of values in array or object
ArrayIndex size() const;
/// \brief Return true if empty array, empty object, or null;
/// otherwise, false.
bool empty() const;
/// Return isNull()
bool operator!() const;
/// Remove all object members and array elements.
/// \pre type() is arrayValue, objectValue, or nullValue
/// \post type() is unchanged
void clear();
/// Resize the array to size elements.
/// New elements are initialized to null.
/// May only be called on nullValue or arrayValue.
/// \pre type() is arrayValue or nullValue
/// \post type() is arrayValue
void resize(ArrayIndex size);
/// Access an array element (zero based index ).
/// If the array contains less than index element, then null value are
/// inserted
/// in the array so that its size is index+1.
/// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.)
Value& operator[](ArrayIndex index);
/// Access an array element (zero based index ).
/// If the array contains less than index element, then null value are
/// inserted
/// in the array so that its size is index+1.
/// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.)
Value& operator[](int index);
/// Access an array element (zero based index )
/// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.)
const Value& operator[](ArrayIndex index) const;
/// Access an array element (zero based index )
/// (You may need to say 'value[0u]' to get your compiler to distinguish
/// this from the operator[] which takes a string.)
const Value& operator[](int index) const;
/// If the array contains at least index+1 elements, returns the element
/// value,
/// otherwise returns defaultValue.
Value get(ArrayIndex index, const Value& defaultValue) const;
/// Return true if index < size().
bool isValidIndex(ArrayIndex index) const;
/// \brief Append value to array at the end.
///
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
Value& append(const Value& value);
#if JSON_HAS_RVALUE_REFERENCES
Value& append(Value&& value);
#endif
/// Access an object value by name, create a null member if it does not exist.
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
/// Exceeding that will cause an exception.
Value& operator[](const char* key);
/// Access an object value by name, returns null if there is no member with
/// that name.
const Value& operator[](const char* key) const;
/// Access an object value by name, create a null member if it does not exist.
/// \param key may contain embedded nulls.
Value& operator[](const JSONCPP_STRING& key);
/// Access an object value by name, returns null if there is no member with
/// that name.
/// \param key may contain embedded nulls.
const Value& operator[](const JSONCPP_STRING& key) const;
/** \brief Access an object value by name, create a null member if it does not
exist.
* If the object has no entry for that name, then the member name used to store
* the new entry is not duplicated.
* Example of use:
* \code
* Json::Value object;
* static const StaticString code("code");
* object[code] = 1234;
* \endcode
*/
Value& operator[](const StaticString& key);
#ifdef JSON_USE_CPPTL
/// Access an object value by name, create a null member if it does not exist.
Value& operator[](const CppTL::ConstString& key);
/// Access an object value by name, returns null if there is no member with
/// that name.
const Value& operator[](const CppTL::ConstString& key) const;
#endif
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
Value get(const char* key, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
/// \note key may contain embedded nulls.
Value get(const char* begin, const char* end, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
/// \param key may contain embedded nulls.
Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
#ifdef JSON_USE_CPPTL
/// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
#endif
/// Most general and efficient version of isMember()const, get()const,
/// and operator[]const
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
Value const* find(char const* begin, char const* end) const;
/// Most general and efficient version of object-mutators.
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
Value const* demand(char const* begin, char const* end);
/// \brief Remove and return the named member.
///
/// Do nothing if it did not exist.
/// \return the removed Value, or null.
/// \pre type() is objectValue or nullValue
/// \post type() is unchanged
/// \deprecated
Value removeMember(const char* key);
/// Same as removeMember(const char*)
/// \param key may contain embedded nulls.
/// \deprecated
Value removeMember(const JSONCPP_STRING& key);
/// Same as removeMember(const char* begin, const char* end, Value* removed),
/// but 'key' is null-terminated.
bool removeMember(const char* key, Value* removed);
/** \brief Remove the named map member.
Update 'removed' iff removed.
\param key may contain embedded nulls.
\return true iff removed (no exceptions)
*/
bool removeMember(JSONCPP_STRING const& key, Value* removed);
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
bool removeMember(const char* begin, const char* end, Value* removed);
/** \brief Remove the indexed array element.
O(n) expensive operations.
Update 'removed' iff removed.
\return true iff removed (no exceptions)
*/
bool removeIndex(ArrayIndex i, Value* removed);
/// Return true if the object has a member named key.
/// \note 'key' must be null-terminated.
bool isMember(const char* key) const;
/// Return true if the object has a member named key.
/// \param key may contain embedded nulls.
bool isMember(const JSONCPP_STRING& key) const;
/// Same as isMember(JSONCPP_STRING const& key)const
bool isMember(const char* begin, const char* end) const;
#ifdef JSON_USE_CPPTL
/// Return true if the object has a member named key.
bool isMember(const CppTL::ConstString& key) const;
#endif
/// \brief Return a list of the member names.
///
/// If null, return an empty list.
/// \pre type() is objectValue or nullValue
/// \post if type() was nullValue, it remains nullValue
Members getMemberNames() const;
//# ifdef JSON_USE_CPPTL
// EnumMemberNames enumMemberNames() const;
// EnumValues enumValues() const;
//# endif
/// \deprecated Always pass len.
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
void setComment(const char* comment, CommentPlacement placement);
/// Comments must be //... or /* ... */
void setComment(const char* comment, size_t len, CommentPlacement placement);
/// Comments must be //... or /* ... */
void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
bool hasComment(CommentPlacement placement) const;
/// Include delimiters and embedded newlines.
JSONCPP_STRING getComment(CommentPlacement placement) const;
JSONCPP_STRING toStyledString() const;
const_iterator begin() const;
const_iterator end() const;
iterator begin();
iterator end();
// Accessors for the [start, limit) range of bytes within the JSON text from
// which this value was parsed, if any.
void setOffsetStart(ptrdiff_t start);
void setOffsetLimit(ptrdiff_t limit);
ptrdiff_t getOffsetStart() const;
ptrdiff_t getOffsetLimit() const;
private:
void initBasic(ValueType type, bool allocated = false);
Value& resolveReference(const char* key);
Value& resolveReference(const char* key, const char* end);
struct CommentInfo {
CommentInfo();
~CommentInfo();
void setComment(const char* text, size_t len);
char* comment_;
};
// struct MemberNamesTransform
//{
// typedef const char *result_type;
// const char *operator()( const CZString &name ) const
// {
// return name.c_str();
// }
//};
union ValueHolder {
LargestInt int_;
LargestUInt uint_;
double real_;
bool bool_;
char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
ObjectValues* map_;
} value_;
ValueType type_ : 8;
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
// If not allocated_, string_ must be null-terminated.
CommentInfo* comments_;
// [start, limit) byte offsets in the source JSON text from which this Value
// was extracted.
ptrdiff_t start_;
ptrdiff_t limit_;
};
/** \brief Experimental and untested: represents an element of the "path" to
* access a node.
*/
class JSON_API PathArgument {
public:
friend class Path;
PathArgument();
PathArgument(ArrayIndex index);
PathArgument(const char* key);
PathArgument(const JSONCPP_STRING& key);
private:
enum Kind {
kindNone = 0,
kindIndex,
kindKey
};
JSONCPP_STRING key_;
ArrayIndex index_;
Kind kind_;
};
/** \brief Experimental and untested: represents a "path" to access a node.
*
* Syntax:
* - "." => root node
* - ".[n]" => elements at index 'n' of root node (an array value)
* - ".name" => member named 'name' of root node (an object value)
* - ".name1.name2.name3"
* - ".[0][1][2].name1[3]"
* - ".%" => member name is provided as parameter
* - ".[%]" => index is provied as parameter
*/
class JSON_API Path {
public:
Path(const JSONCPP_STRING& path,
const PathArgument& a1 = PathArgument(),
const PathArgument& a2 = PathArgument(),
const PathArgument& a3 = PathArgument(),
const PathArgument& a4 = PathArgument(),
const PathArgument& a5 = PathArgument());
const Value& resolve(const Value& root) const;
Value resolve(const Value& root, const Value& defaultValue) const;
/// Creates the "path" to access the specified node and returns a reference on
/// the node.
Value& make(Value& root) const;
private:
typedef std::vector<const PathArgument*> InArgs;
typedef std::vector<PathArgument> Args;
void makePath(const JSONCPP_STRING& path, const InArgs& in);
void addPathInArg(const JSONCPP_STRING& path,
const InArgs& in,
InArgs::const_iterator& itInArg,
PathArgument::Kind kind);
void invalidPath(const JSONCPP_STRING& path, int location);
Args args_;
};
/** \brief base class for Value iterators.
*
*/
class JSON_API ValueIteratorBase {
public:
typedef std::bidirectional_iterator_tag iterator_category;
typedef unsigned int size_t;
typedef int difference_type;
typedef ValueIteratorBase SelfType;
bool operator==(const SelfType& other) const { return isEqual(other); }
bool operator!=(const SelfType& other) const { return !isEqual(other); }
difference_type operator-(const SelfType& other) const {
return other.computeDistance(*this);
}
/// Return either the index or the member name of the referenced value as a
/// Value.
Value key() const;
/// Return the index of the referenced Value, or -1 if it is not an arrayValue.
UInt index() const;
/// Return the member name of the referenced Value, or "" if it is not an
/// objectValue.
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
JSONCPP_STRING name() const;
/// Return the member name of the referenced Value. "" if it is not an
/// objectValue.
/// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
JSONCPP_DEPRECATED("Use `key = name();` instead.")
char const* memberName() const;
/// Return the member name of the referenced Value, or NULL if it is not an
/// objectValue.
/// \note Better version than memberName(). Allows embedded nulls.
char const* memberName(char const** end) const;
protected:
Value& deref() const;
void increment();
void decrement();
difference_type computeDistance(const SelfType& other) const;
bool isEqual(const SelfType& other) const;
void copy(const SelfType& other);
private:
Value::ObjectValues::iterator current_;
// Indicates that iterator is for a null value.
bool isNull_;
public:
// For some reason, BORLAND needs these at the end, rather
// than earlier. No idea why.
ValueIteratorBase();
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
};
/** \brief const iterator for object and array value.
*
*/
class JSON_API ValueConstIterator : public ValueIteratorBase {
friend class Value;
public:
typedef const Value value_type;
//typedef unsigned int size_t;
//typedef int difference_type;
typedef const Value& reference;
typedef const Value* pointer;
typedef ValueConstIterator SelfType;
ValueConstIterator();
ValueConstIterator(ValueIterator const& other);
private:
/*! \internal Use by Value to create an iterator.
*/
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
public:
SelfType& operator=(const ValueIteratorBase& other);
SelfType operator++(int) {
SelfType temp(*this);
++*this;
return temp;
}
SelfType operator--(int) {
SelfType temp(*this);
--*this;
return temp;
}
SelfType& operator--() {
decrement();
return *this;
}
SelfType& operator++() {
increment();
return *this;
}
reference operator*() const { return deref(); }
pointer operator->() const { return &deref(); }
};
/** \brief Iterator for object and array value.
*/
class JSON_API ValueIterator : public ValueIteratorBase {
friend class Value;
public:
typedef Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef Value& reference;
typedef Value* pointer;
typedef ValueIterator SelfType;
ValueIterator();
explicit ValueIterator(const ValueConstIterator& other);
ValueIterator(const ValueIterator& other);
private:
/*! \internal Use by Value to create an iterator.
*/
explicit ValueIterator(const Value::ObjectValues::iterator& current);
public:
SelfType& operator=(const SelfType& other);
SelfType operator++(int) {
SelfType temp(*this);
++*this;
return temp;
}
SelfType operator--(int) {
SelfType temp(*this);
--*this;
return temp;
}
SelfType& operator--() {
decrement();
return *this;
}
SelfType& operator++() {
increment();
return *this;
}
reference operator*() const { return deref(); }
pointer operator->() const { return &deref(); }
};
} // namespace Json
namespace std {
/// Specialize std::swap() for Json::Value.
template<>
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
}
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#endif // CPPTL_JSON_H_INCLUDED

20
extern/jsoncpp/include/json/version.h vendored Normal file
View File

@@ -0,0 +1,20 @@
// DO NOT EDIT. This file (and "version") is generated by CMake.
// Run CMake configure step to update it.
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "1.8.1"
# define JSONCPP_VERSION_MAJOR 1
# define JSONCPP_VERSION_MINOR 8
# define JSONCPP_VERSION_PATCH 1
# define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
#ifdef JSONCPP_USING_SECURE_MEMORY
#undef JSONCPP_USING_SECURE_MEMORY
#endif
#define JSONCPP_USING_SECURE_MEMORY 0
// If non-zero, the library zeroes any memory that it has allocated before
// it frees its memory.
#endif // JSON_VERSION_H_INCLUDED

335
extern/jsoncpp/include/json/writer.h vendored Normal file
View File

@@ -0,0 +1,335 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_WRITER_H_INCLUDED
#define JSON_WRITER_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "value.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <vector>
#include <string>
#include <ostream>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(push)
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma pack(push, 8)
namespace Json {
class Value;
/**
Usage:
\code
using namespace Json;
void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
std::unique_ptr<StreamWriter> const writer(
factory.newStreamWriter());
writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush
}
\endcode
*/
class JSON_API StreamWriter {
protected:
JSONCPP_OSTREAM* sout_; // not owned; will not delete
public:
StreamWriter();
virtual ~StreamWriter();
/** Write Value into document as configured in sub-class.
Do not take ownership of sout, but maintain a reference during function.
\pre sout != NULL
\return zero on success (For now, we always return zero, so check the stream instead.)
\throw std::exception possibly, depending on configuration
*/
virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
/** \brief A simple abstract factory.
*/
class JSON_API Factory {
public:
virtual ~Factory();
/** \brief Allocate a CharReader via operator new().
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
virtual StreamWriter* newStreamWriter() const = 0;
}; // Factory
}; // StreamWriter
/** \brief Write into stringstream, then return string, for convenience.
* A StreamWriter will be created from the factory, used, and then deleted.
*/
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
/** \brief Build a StreamWriter implementation.
Usage:
\code
using namespace Json;
Value value = ...;
StreamWriterBuilder builder;
builder["commentStyle"] = "None";
builder["indentation"] = " "; // or whatever you like
std::unique_ptr<Json::StreamWriter> writer(
builder.newStreamWriter());
writer->write(value, &std::cout);
std::cout << std::endl; // add lf and flush
\endcode
*/
class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
public:
// Note: We use a Json::Value so that we can add data-members to this class
// without a major version bump.
/** Configuration of this builder.
Available settings (case-sensitive):
- "commentStyle": "None" or "All"
- "indentation": "<anything>"
- "enableYAMLCompatibility": false or true
- slightly change the whitespace around colons
- "dropNullPlaceholders": false or true
- Drop the "null" string from the writer's output for nullValues.
Strictly speaking, this is not valid JSON. But when the output is being
fed to a browser's Javascript, it makes for smaller output and the
browser can handle the output just fine.
- "useSpecialFloats": false or true
- If true, outputs non-finite floating point values in the following way:
NaN values as "NaN", positive infinity as "Infinity", and negative infinity
as "-Infinity".
You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any
JSON Value.
\sa setDefaults()
*/
Json::Value settings_;
StreamWriterBuilder();
~StreamWriterBuilder() JSONCPP_OVERRIDE;
/**
* \throw std::exception if something goes wrong (e.g. invalid settings)
*/
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
/** \return true if 'settings' are legal and consistent;
* otherwise, indicate bad settings via 'invalid'.
*/
bool validate(Json::Value* invalid) const;
/** A simple way to update a specific setting.
*/
Value& operator[](JSONCPP_STRING key);
/** Called by ctor, but you can use this to reset settings_.
* \pre 'settings' != NULL (but Json::null is fine)
* \remark Defaults:
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
*/
static void setDefaults(Json::Value* settings);
};
/** \brief Abstract class for writers.
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
*/
class JSON_API Writer {
public:
virtual ~Writer();
virtual JSONCPP_STRING write(const Value& root) = 0;
};
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
*without formatting (not human friendly).
*
* The JSON document is written in a single line. It is not intended for 'human'
*consumption,
* but may be usefull to support feature such as RPC where bandwith is limited.
* \sa Reader, Value
* \deprecated Use StreamWriterBuilder.
*/
class JSON_API FastWriter : public Writer {
public:
FastWriter();
~FastWriter() JSONCPP_OVERRIDE {}
void enableYAMLCompatibility();
/** \brief Drop the "null" string from the writer's output for nullValues.
* Strictly speaking, this is not valid JSON. But when the output is being
* fed to a browser's Javascript, it makes for smaller output and the
* browser can handle the output just fine.
*/
void dropNullPlaceholders();
void omitEndingLineFeed();
public: // overridden from Writer
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
JSONCPP_STRING document_;
bool yamlCompatiblityEnabled_;
bool dropNullPlaceholders_;
bool omitEndingLineFeed_;
};
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
*human friendly way.
*
* The rules for line break and indent are as follow:
* - Object value:
* - if empty then print {} without indent and line break
* - if not empty the print '{', line break & indent, print one value per
*line
* and then unindent and line break and print '}'.
* - Array value:
* - if empty then print [] without indent and line break
* - if the array contains no object value, empty array or some other value
*types,
* and all the values fit on one lines, then print the array on a single
*line.
* - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line.
*
* If the Value have comments then they are outputed according to their
*#CommentPlacement.
*
* \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder.
*/
class JSON_API StyledWriter : public Writer {
public:
StyledWriter();
~StyledWriter() JSONCPP_OVERRIDE {}
public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
void writeArrayValue(const Value& value);
bool isMultineArray(const Value& value);
void pushValue(const JSONCPP_STRING& value);
void writeIndent();
void writeWithIndent(const JSONCPP_STRING& value);
void indent();
void unindent();
void writeCommentBeforeValue(const Value& root);
void writeCommentAfterValueOnSameLine(const Value& root);
bool hasCommentForValue(const Value& value);
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
typedef std::vector<JSONCPP_STRING> ChildValues;
ChildValues childValues_;
JSONCPP_STRING document_;
JSONCPP_STRING indentString_;
unsigned int rightMargin_;
unsigned int indentSize_;
bool addChildValues_;
};
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
human friendly way,
to a stream rather than to a string.
*
* The rules for line break and indent are as follow:
* - Object value:
* - if empty then print {} without indent and line break
* - if not empty the print '{', line break & indent, print one value per
line
* and then unindent and line break and print '}'.
* - Array value:
* - if empty then print [] without indent and line break
* - if the array contains no object value, empty array or some other value
types,
* and all the values fit on one lines, then print the array on a single
line.
* - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line.
*
* If the Value have comments then they are outputed according to their
#CommentPlacement.
*
* \param indentation Each level will be indented by this amount extra.
* \sa Reader, Value, Value::setComment()
* \deprecated Use StreamWriterBuilder.
*/
class JSON_API StyledStreamWriter {
public:
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
~StyledStreamWriter() {}
public:
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param out Stream to write to. (Can be ostringstream, e.g.)
* \param root Value to serialize.
* \note There is no point in deriving from Writer, since write() should not
* return a value.
*/
void write(JSONCPP_OSTREAM& out, const Value& root);
private:
void writeValue(const Value& value);
void writeArrayValue(const Value& value);
bool isMultineArray(const Value& value);
void pushValue(const JSONCPP_STRING& value);
void writeIndent();
void writeWithIndent(const JSONCPP_STRING& value);
void indent();
void unindent();
void writeCommentBeforeValue(const Value& root);
void writeCommentAfterValueOnSameLine(const Value& root);
bool hasCommentForValue(const Value& value);
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
typedef std::vector<JSONCPP_STRING> ChildValues;
ChildValues childValues_;
JSONCPP_OSTREAM* document_;
JSONCPP_STRING indentString_;
unsigned int rightMargin_;
JSONCPP_STRING indentation_;
bool addChildValues_ : 1;
bool indented_ : 1;
};
#if defined(JSON_HAS_INT64)
JSONCPP_STRING JSON_API valueToString(Int value);
JSONCPP_STRING JSON_API valueToString(UInt value);
#endif // if defined(JSON_HAS_INT64)
JSONCPP_STRING JSON_API valueToString(LargestInt value);
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
JSONCPP_STRING JSON_API valueToString(double value);
JSONCPP_STRING JSON_API valueToString(bool value);
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
/// \brief Output using the StyledStreamWriter.
/// \see Json::operator>>()
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
} // namespace Json
#pragma pack(pop)
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#endif // JSON_WRITER_H_INCLUDED

80
extern/jsoncpp/src/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,80 @@
IF( CMAKE_COMPILER_IS_GNUCXX )
#Get compiler version.
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GNUCXX_VERSION )
#-Werror=* was introduced -after- GCC 4.1.2
IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
ENDIF()
ENDIF( CMAKE_COMPILER_IS_GNUCXX )
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckTypeSize)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckCXXSymbolExists)
check_include_file_cxx(clocale HAVE_CLOCALE)
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
IF(CMAKE_VERSION VERSION_LESS 3.0.0)
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
# so the C compiler and header has to be used.
check_include_file(locale.h HAVE_LOCALE_H)
SET(CMAKE_EXTRA_INCLUDE_FILES locale.h)
check_type_size("struct lconv" LCONV_SIZE)
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
ELSE()
SET(CMAKE_EXTRA_INCLUDE_FILES clocale)
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
ENDIF()
IF(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
MESSAGE(WARNING "Locale functionality is not supported")
ADD_DEFINITIONS(-DJSONCPP_NO_LOCALE_SUPPORT)
ENDIF()
SET( JSONCPP_INCLUDE_DIR ../include )
SET( PUBLIC_HEADERS
${JSONCPP_INCLUDE_DIR}/json/config.h
${JSONCPP_INCLUDE_DIR}/json/forwards.h
${JSONCPP_INCLUDE_DIR}/json/features.h
${JSONCPP_INCLUDE_DIR}/json/value.h
${JSONCPP_INCLUDE_DIR}/json/reader.h
${JSONCPP_INCLUDE_DIR}/json/writer.h
${JSONCPP_INCLUDE_DIR}/json/assertions.h
${JSONCPP_INCLUDE_DIR}/json/version.h
)
SOURCE_GROUP( "Public API" FILES ${PUBLIC_HEADERS} )
SET(jsoncpp_sources
json_tool.h
json_reader.cpp
json_valueiterator.inl
json_value.cpp
json_writer.cpp
version.h.in
)
# Install instructions for this target
IF(JSONCPP_WITH_CMAKE_PACKAGE)
SET(INSTALL_EXPORT EXPORT jsoncpp)
ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
SET(INSTALL_EXPORT)
ENDIF()
set(SRC
${PUBLIC_HEADERS}
${jsoncpp_sources}
)
set(INC
../include
)
blender_add_lib(jsoncpp_lib "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

2036
extern/jsoncpp/src/json_reader.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

117
extern/jsoncpp/src/json_tool.h vendored Normal file
View File

@@ -0,0 +1,117 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
// Also support old flag NO_LOCALE_SUPPORT
#ifdef NO_LOCALE_SUPPORT
#define JSONCPP_NO_LOCALE_SUPPORT
#endif
#ifndef JSONCPP_NO_LOCALE_SUPPORT
#include <clocale>
#endif
/* This header provides common string manipulation support, such as UTF-8,
* portable conversion from/to string...
*
* It is an internal header that must not be exposed.
*/
namespace Json {
static char getDecimalPoint() {
#ifdef JSONCPP_NO_LOCALE_SUPPORT
return '\0';
#else
struct lconv* lc = localeconv();
return lc ? *(lc->decimal_point) : '\0';
#endif
}
/// Converts a unicode code-point to UTF-8.
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
JSONCPP_STRING result;
// based on description from http://en.wikipedia.org/wiki/UTF-8
if (cp <= 0x7f) {
result.resize(1);
result[0] = static_cast<char>(cp);
} else if (cp <= 0x7FF) {
result.resize(2);
result[1] = static_cast<char>(0x80 | (0x3f & cp));
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
} else if (cp <= 0xFFFF) {
result.resize(3);
result[2] = static_cast<char>(0x80 | (0x3f & cp));
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
} else if (cp <= 0x10FFFF) {
result.resize(4);
result[3] = static_cast<char>(0x80 | (0x3f & cp));
result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
}
return result;
}
/// Returns true if ch is a control character (in range [1,31]).
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
enum {
/// Constant that specify the size of the buffer that must be passed to
/// uintToString.
uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1
};
// Defines a char buffer for use with uintToString().
typedef char UIntToStringBuffer[uintToStringBufferSize];
/** Converts an unsigned integer to string.
* @param value Unsigned interger to convert to string
* @param current Input/Output string buffer.
* Must have at least uintToStringBufferSize chars free.
*/
static inline void uintToString(LargestUInt value, char*& current) {
*--current = 0;
do {
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
value /= 10;
} while (value != 0);
}
/** Change ',' to '.' everywhere in buffer.
*
* We had a sophisticated way, but it did not work in WinCE.
* @see https://github.com/open-source-parsers/jsoncpp/pull/9
*/
static inline void fixNumericLocale(char* begin, char* end) {
while (begin < end) {
if (*begin == ',') {
*begin = '.';
}
++begin;
}
}
static inline void fixNumericLocaleInput(char* begin, char* end) {
char decimalPoint = getDecimalPoint();
if (decimalPoint != '\0' && decimalPoint != '.') {
while (begin < end) {
if (*begin == '.') {
*begin = decimalPoint;
}
++begin;
}
}
}
} // namespace Json {
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED

1665
extern/jsoncpp/src/json_value.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,167 @@
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
// included by json_value.cpp
namespace Json {
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueIteratorBase
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueIteratorBase::ValueIteratorBase()
: current_(), isNull_(true) {
}
ValueIteratorBase::ValueIteratorBase(
const Value::ObjectValues::iterator& current)
: current_(current), isNull_(false) {}
Value& ValueIteratorBase::deref() const {
return current_->second;
}
void ValueIteratorBase::increment() {
++current_;
}
void ValueIteratorBase::decrement() {
--current_;
}
ValueIteratorBase::difference_type
ValueIteratorBase::computeDistance(const SelfType& other) const {
#ifdef JSON_USE_CPPTL_SMALLMAP
return other.current_ - current_;
#else
// Iterator for null value are initialized using the default
// constructor, which initialize current_ to the default
// std::map::iterator. As begin() and end() are two instance
// of the default std::map::iterator, they can not be compared.
// To allow this, we handle this comparison specifically.
if (isNull_ && other.isNull_) {
return 0;
}
// Usage of std::distance is not portable (does not compile with Sun Studio 12
// RogueWave STL,
// which is the one used by default).
// Using a portable hand-made version for non random iterator instead:
// return difference_type( std::distance( current_, other.current_ ) );
difference_type myDistance = 0;
for (Value::ObjectValues::iterator it = current_; it != other.current_;
++it) {
++myDistance;
}
return myDistance;
#endif
}
bool ValueIteratorBase::isEqual(const SelfType& other) const {
if (isNull_) {
return other.isNull_;
}
return current_ == other.current_;
}
void ValueIteratorBase::copy(const SelfType& other) {
current_ = other.current_;
isNull_ = other.isNull_;
}
Value ValueIteratorBase::key() const {
const Value::CZString czstring = (*current_).first;
if (czstring.data()) {
if (czstring.isStaticString())
return Value(StaticString(czstring.data()));
return Value(czstring.data(), czstring.data() + czstring.length());
}
return Value(czstring.index());
}
UInt ValueIteratorBase::index() const {
const Value::CZString czstring = (*current_).first;
if (!czstring.data())
return czstring.index();
return Value::UInt(-1);
}
JSONCPP_STRING ValueIteratorBase::name() const {
char const* keey;
char const* end;
keey = memberName(&end);
if (!keey) return JSONCPP_STRING();
return JSONCPP_STRING(keey, end);
}
char const* ValueIteratorBase::memberName() const {
const char* cname = (*current_).first.data();
return cname ? cname : "";
}
char const* ValueIteratorBase::memberName(char const** end) const {
const char* cname = (*current_).first.data();
if (!cname) {
*end = NULL;
return NULL;
}
*end = cname + (*current_).first.length();
return cname;
}
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueConstIterator
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueConstIterator::ValueConstIterator() {}
ValueConstIterator::ValueConstIterator(
const Value::ObjectValues::iterator& current)
: ValueIteratorBase(current) {}
ValueConstIterator::ValueConstIterator(ValueIterator const& other)
: ValueIteratorBase(other) {}
ValueConstIterator& ValueConstIterator::
operator=(const ValueIteratorBase& other) {
copy(other);
return *this;
}
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueIterator
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueIterator::ValueIterator() {}
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
: ValueIteratorBase(current) {}
ValueIterator::ValueIterator(const ValueConstIterator& other)
: ValueIteratorBase(other) {
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
}
ValueIterator::ValueIterator(const ValueIterator& other)
: ValueIteratorBase(other) {}
ValueIterator& ValueIterator::operator=(const SelfType& other) {
copy(other);
return *this;
}
} // namespace Json

1223
extern/jsoncpp/src/json_writer.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

8
extern/jsoncpp/src/sconscript vendored Normal file
View File

@@ -0,0 +1,8 @@
Import( 'env buildLibrary' )
buildLibrary( env, Split( """
json_reader.cpp
json_value.cpp
json_writer.cpp
""" ),
'json' )

20
extern/jsoncpp/src/version.h.in vendored Normal file
View File

@@ -0,0 +1,20 @@
// DO NOT EDIT. This file (and "version") is generated by CMake.
// Run CMake configure step to update it.
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "@JSONCPP_VERSION@"
# define JSONCPP_VERSION_MAJOR @JSONCPP_VERSION_MAJOR@
# define JSONCPP_VERSION_MINOR @JSONCPP_VERSION_MINOR@
# define JSONCPP_VERSION_PATCH @JSONCPP_VERSION_PATCH@
# define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
#ifdef JSONCPP_USING_SECURE_MEMORY
#undef JSONCPP_USING_SECURE_MEMORY
#endif
#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@
// If non-zero, the library zeroes any memory that it has allocated before
// it frees its memory.
#endif // JSON_VERSION_H_INCLUDED

71
extern/openxr/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,71 @@
# Copyright (c) 2017-2019 The Khronos Group Inc.
#
# 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.
#
# Author:
#
# Note: This is the top-level CMake file for the OpenXR project.
# It should contain only definitions that are applicable to the
# entire project and includes for the sub-directories.
cmake_minimum_required(VERSION 3.0)
project(OPENXR)
#find_package(PythonInterp 3)
# Enable IDE GUI folders. "Helper targets" that don't have interesting source code should set their FOLDER property to this
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake predefined targets")
set(LOADER_FOLDER "Loader")
set(HELPER_FOLDER "Helpers")
set(CODEGEN_FOLDER "Generated")
set(TESTS_FOLDER "Tests")
set(API_LAYERS_FOLDER "Layers")
set(SAMPLES_FOLDER "Samples")
option(BUILD_FORCE_GENERATION "Force re-generation of files even in the presence of pre-generated copies, replacing those copies." OFF)
if(BUILD_FORCE_GENERATION AND NOT PYTHON_EXECUTABLE)
message(FATAL_ERROR "BUILD_FORCE_GENERATION requires Python")
endif()
set(OPENXR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(include)
add_subdirectory(src)
# uninstall target
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE
@ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
set_target_properties(uninstall PROPERTIES FOLDER ${HELPER_FOLDER})
endif()
find_program(BASH_COMMAND NAMES bash)
if(BASH_COMMAND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/specification/Makefile")
option(BUILD_SPECIFICATION "Run './makeAllExts all' in the specification directory as part of the build - intended for one-step checking of spec changes" OFF)
if(BUILD_SPECIFICATION)
add_custom_target(spec-all ALL
${BASH_COMMAND} ./makeAllExts all
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/specification"
VERBATIM
COMMENT "Running './makeAllExts all' in the specification directory"
USES_TERMINAL)
endif()
endif()
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" DESTINATION share/doc/openxr)

202
extern/openxr/LICENSE vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

18
extern/openxr/include/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,18 @@
# Copyright (c) 2017 The Khronos Group Inc.
#
# 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.
#
# Author:
#
add_subdirectory(openxr)

View File

@@ -0,0 +1,94 @@
# Copyright (c) 2017-2019 The Khronos Group Inc.
#
# 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.
#
# Author:
#
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
configure_file(openxr_platform_defines.h ${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h COPYONLY)
# Generate OpenXR header files.
set(HEADERS
openxr.h
openxr_platform.h
openxr_reflection.h)
set(HAVE_PREGENERATED TRUE)
set(SOURCE_HEADERS)
foreach(output ${HEADERS})
list(APPEND SOURCE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${output})
set(HAVE_PREGENERATED FALSE)
endif()
endforeach()
set(XR_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
if(HAVE_PREGENERATED AND NOT BUILD_FORCE_GENERATION)
add_custom_target(generate_openxr_header
COMMENT "Using found pre-generated OpenXR headers.")
set(INSTALL_HEADERS ${SOURCE_HEADERS})
else()
set(GENERATED_HEADERS)
set(OUTPUT_STAMPS)
# Copy the openxr_platform_defines.h file and place it in the binary (build) directory.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/openxr_platform_defines.h
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
COPYONLY)
# Generate the header files and place it in the binary (build) directory.
foreach(output ${HEADERS})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}
COMMAND ${PYTHON_EXECUTABLE} ${XR_ROOT}/specification/scripts/genxr.py
-registry ${XR_ROOT}/specification/registry/xr.xml
-o ${CMAKE_CURRENT_BINARY_DIR} ${output}
DEPENDS
${XR_ROOT}/specification/scripts/genxr.py
${XR_ROOT}/specification/scripts/cgenerator.py
${XR_ROOT}/specification/scripts/creflectiongenerator.py
${XR_ROOT}/specification/scripts/generator.py
${XR_ROOT}/specification/scripts/reg.py
${XR_ROOT}/specification/registry/xr.xml
COMMENT "Generating ${CMAKE_CURRENT_BINARY_DIR}/${output}"
)
list(APPEND GENERATED_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${output}")
endforeach()
set_source_files_properties(
${GENERATED_HEADERS}
PROPERTIES GENERATED TRUE
)
set(INSTALL_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform_defines.h
${CMAKE_CURRENT_BINARY_DIR}/openxr.h
${CMAKE_CURRENT_BINARY_DIR}/openxr_platform.h)
# Define generate_openxr_header target to generate the OpenXR header files.
# Other targets that need the OpenXR headers should use generate_openxr_header as a dependency.
add_custom_target(generate_openxr_header
SOURCES ${XR_ROOT}/specification/registry/xr.xml
DEPENDS
${GENERATED_HEADERS}
${OUTPUT_STAMPS}
)
endif()
set_target_properties(generate_openxr_header PROPERTIES FOLDER ${CODEGEN_FOLDER})
INSTALL(FILES ${INSTALL_HEADERS}
DESTINATION include/openxr
)

1538
extern/openxr/include/openxr/openxr.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,383 @@
#ifndef OPENXR_PLATFORM_H_
#define OPENXR_PLATFORM_H_ 1
/*
** Copyright (c) 2017-2019 The Khronos Group Inc.
**
** 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.
*/
/*
** This header is generated from the Khronos OpenXR XML API Registry.
**
*/
#include "openxr.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XR_USE_PLATFORM_ANDROID
#define XR_KHR_android_thread_settings 1
#define XR_KHR_android_thread_settings_SPEC_VERSION 5
#define XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME "XR_KHR_android_thread_settings"
typedef enum XrAndroidThreadTypeKHR {
XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR = 1,
XR_ANDROID_THREAD_TYPE_APPLICATION_WORKER_KHR = 2,
XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR = 3,
XR_ANDROID_THREAD_TYPE_RENDERER_WORKER_KHR = 4,
XR_ANDROID_THREAD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF
} XrAndroidThreadTypeKHR;
typedef XrResult (XRAPI_PTR *PFN_xrSetAndroidApplicationThreadKHR)(XrSession session, XrAndroidThreadTypeKHR threadType, uint32_t threadId);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrSetAndroidApplicationThreadKHR(
XrSession session,
XrAndroidThreadTypeKHR threadType,
uint32_t threadId);
#endif
#endif /* XR_USE_PLATFORM_ANDROID */
#ifdef XR_USE_PLATFORM_ANDROID
#define XR_KHR_android_surface_swapchain 1
#define XR_KHR_android_surface_swapchain_SPEC_VERSION 4
#define XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME "XR_KHR_android_surface_swapchain"
typedef XrResult (XRAPI_PTR *PFN_xrCreateSwapchainAndroidSurfaceKHR)(XrSession session, const XrSwapchainCreateInfo* info, XrSwapchain* swapchain, jobject* surface);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrCreateSwapchainAndroidSurfaceKHR(
XrSession session,
const XrSwapchainCreateInfo* info,
XrSwapchain* swapchain,
jobject* surface);
#endif
#endif /* XR_USE_PLATFORM_ANDROID */
#ifdef XR_USE_PLATFORM_ANDROID
#define XR_KHR_android_create_instance 1
#define XR_KHR_android_create_instance_SPEC_VERSION 3
#define XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME "XR_KHR_android_create_instance"
typedef struct XrInstanceCreateInfoAndroidKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
void* XR_MAY_ALIAS applicationVM;
void* XR_MAY_ALIAS applicationActivity;
} XrInstanceCreateInfoAndroidKHR;
#endif /* XR_USE_PLATFORM_ANDROID */
#ifdef XR_USE_GRAPHICS_API_VULKAN
#define XR_KHR_vulkan_swapchain_format_list 1
#define XR_KHR_vulkan_swapchain_format_list_SPEC_VERSION 2
#define XR_KHR_VULKAN_SWAPCHAIN_FORMAT_LIST_EXTENSION_NAME "XR_KHR_vulkan_swapchain_format_list"
typedef struct XrVulkanSwapchainFormatListCreateInfoKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
uint32_t viewFormatCount;
const VkFormat* viewFormats;
} XrVulkanSwapchainFormatListCreateInfoKHR;
#endif /* XR_USE_GRAPHICS_API_VULKAN */
#ifdef XR_USE_GRAPHICS_API_OPENGL
#define XR_KHR_opengl_enable 1
#define XR_KHR_opengl_enable_SPEC_VERSION 7
#define XR_KHR_OPENGL_ENABLE_EXTENSION_NAME "XR_KHR_opengl_enable"
#ifdef XR_USE_PLATFORM_WIN32
typedef struct XrGraphicsBindingOpenGLWin32KHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
HDC hDC;
HGLRC hGLRC;
} XrGraphicsBindingOpenGLWin32KHR;
#endif // XR_USE_PLATFORM_WIN32
#ifdef XR_USE_PLATFORM_XLIB
typedef struct XrGraphicsBindingOpenGLXlibKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
Display* xDisplay;
uint32_t visualid;
GLXFBConfig glxFBConfig;
GLXDrawable glxDrawable;
GLXContext glxContext;
} XrGraphicsBindingOpenGLXlibKHR;
#endif // XR_USE_PLATFORM_XLIB
#ifdef XR_USE_PLATFORM_XCB
typedef struct XrGraphicsBindingOpenGLXcbKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
xcb_connection_t* connection;
uint32_t screenNumber;
xcb_glx_fbconfig_t fbconfigid;
xcb_visualid_t visualid;
xcb_glx_drawable_t glxDrawable;
xcb_glx_context_t glxContext;
} XrGraphicsBindingOpenGLXcbKHR;
#endif // XR_USE_PLATFORM_XCB
#ifdef XR_USE_PLATFORM_WAYLAND
typedef struct XrGraphicsBindingOpenGLWaylandKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
struct wl_display* display;
} XrGraphicsBindingOpenGLWaylandKHR;
#endif // XR_USE_PLATFORM_WAYLAND
typedef struct XrSwapchainImageOpenGLKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
uint32_t image;
} XrSwapchainImageOpenGLKHR;
typedef struct XrGraphicsRequirementsOpenGLKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
XrVersion minApiVersionSupported;
XrVersion maxApiVersionSupported;
} XrGraphicsRequirementsOpenGLKHR;
typedef XrResult (XRAPI_PTR *PFN_xrGetOpenGLGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsOpenGLKHR* graphicsRequirements);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetOpenGLGraphicsRequirementsKHR(
XrInstance instance,
XrSystemId systemId,
XrGraphicsRequirementsOpenGLKHR* graphicsRequirements);
#endif
#endif /* XR_USE_GRAPHICS_API_OPENGL */
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
#define XR_KHR_opengl_es_enable 1
#define XR_KHR_opengl_es_enable_SPEC_VERSION 6
#define XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME "XR_KHR_opengl_es_enable"
#ifdef XR_USE_PLATFORM_ANDROID
typedef struct XrGraphicsBindingOpenGLESAndroidKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
EGLDisplay display;
EGLConfig config;
EGLContext context;
} XrGraphicsBindingOpenGLESAndroidKHR;
#endif // XR_USE_PLATFORM_ANDROID
typedef struct XrSwapchainImageOpenGLESKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
uint32_t image;
} XrSwapchainImageOpenGLESKHR;
typedef struct XrGraphicsRequirementsOpenGLESKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
XrVersion minApiVersionSupported;
XrVersion maxApiVersionSupported;
} XrGraphicsRequirementsOpenGLESKHR;
typedef XrResult (XRAPI_PTR *PFN_xrGetOpenGLESGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsOpenGLESKHR* graphicsRequirements);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetOpenGLESGraphicsRequirementsKHR(
XrInstance instance,
XrSystemId systemId,
XrGraphicsRequirementsOpenGLESKHR* graphicsRequirements);
#endif
#endif /* XR_USE_GRAPHICS_API_OPENGL_ES */
#ifdef XR_USE_GRAPHICS_API_VULKAN
#define XR_KHR_vulkan_enable 1
#define XR_KHR_vulkan_enable_SPEC_VERSION 6
#define XR_KHR_VULKAN_ENABLE_EXTENSION_NAME "XR_KHR_vulkan_enable"
typedef struct XrGraphicsBindingVulkanKHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
VkInstance instance;
VkPhysicalDevice physicalDevice;
VkDevice device;
uint32_t queueFamilyIndex;
uint32_t queueIndex;
} XrGraphicsBindingVulkanKHR;
typedef struct XrSwapchainImageVulkanKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
VkImage image;
} XrSwapchainImageVulkanKHR;
typedef struct XrGraphicsRequirementsVulkanKHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
XrVersion minApiVersionSupported;
XrVersion maxApiVersionSupported;
} XrGraphicsRequirementsVulkanKHR;
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanInstanceExtensionsKHR)(XrInstance instance, XrSystemId systemId, uint32_t bufferCapacityInput, uint32_t* bufferCountOutput, char* buffer);
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanDeviceExtensionsKHR)(XrInstance instance, XrSystemId systemId, uint32_t bufferCapacityInput, uint32_t* bufferCountOutput, char* buffer);
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDeviceKHR)(XrInstance instance, XrSystemId systemId, VkInstance vkInstance, VkPhysicalDevice* vkPhysicalDevice);
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanInstanceExtensionsKHR(
XrInstance instance,
XrSystemId systemId,
uint32_t bufferCapacityInput,
uint32_t* bufferCountOutput,
char* buffer);
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanDeviceExtensionsKHR(
XrInstance instance,
XrSystemId systemId,
uint32_t bufferCapacityInput,
uint32_t* bufferCountOutput,
char* buffer);
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsDeviceKHR(
XrInstance instance,
XrSystemId systemId,
VkInstance vkInstance,
VkPhysicalDevice* vkPhysicalDevice);
XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsRequirementsKHR(
XrInstance instance,
XrSystemId systemId,
XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
#endif
#endif /* XR_USE_GRAPHICS_API_VULKAN */
#ifdef XR_USE_GRAPHICS_API_D3D11
#define XR_KHR_D3D11_enable 1
#define XR_KHR_D3D11_enable_SPEC_VERSION 4
#define XR_KHR_D3D11_ENABLE_EXTENSION_NAME "XR_KHR_D3D11_enable"
typedef struct XrGraphicsBindingD3D11KHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
ID3D11Device* device;
} XrGraphicsBindingD3D11KHR;
typedef struct XrSwapchainImageD3D11KHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
ID3D11Texture2D* texture;
} XrSwapchainImageD3D11KHR;
typedef struct XrGraphicsRequirementsD3D11KHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
LUID adapterLuid;
D3D_FEATURE_LEVEL minFeatureLevel;
} XrGraphicsRequirementsD3D11KHR;
typedef XrResult (XRAPI_PTR *PFN_xrGetD3D11GraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsD3D11KHR* graphicsRequirements);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetD3D11GraphicsRequirementsKHR(
XrInstance instance,
XrSystemId systemId,
XrGraphicsRequirementsD3D11KHR* graphicsRequirements);
#endif
#endif /* XR_USE_GRAPHICS_API_D3D11 */
#ifdef XR_USE_GRAPHICS_API_D3D12
#define XR_KHR_D3D12_enable 1
#define XR_KHR_D3D12_enable_SPEC_VERSION 5
#define XR_KHR_D3D12_ENABLE_EXTENSION_NAME "XR_KHR_D3D12_enable"
typedef struct XrGraphicsBindingD3D12KHR {
XrStructureType type;
const void* XR_MAY_ALIAS next;
ID3D12Device* device;
ID3D12CommandQueue* queue;
} XrGraphicsBindingD3D12KHR;
typedef struct XrSwapchainImageD3D12KHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
ID3D12Resource* texture;
} XrSwapchainImageD3D12KHR;
typedef struct XrGraphicsRequirementsD3D12KHR {
XrStructureType type;
void* XR_MAY_ALIAS next;
LUID adapterLuid;
D3D_FEATURE_LEVEL minFeatureLevel;
} XrGraphicsRequirementsD3D12KHR;
typedef XrResult (XRAPI_PTR *PFN_xrGetD3D12GraphicsRequirementsKHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsD3D12KHR* graphicsRequirements);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrGetD3D12GraphicsRequirementsKHR(
XrInstance instance,
XrSystemId systemId,
XrGraphicsRequirementsD3D12KHR* graphicsRequirements);
#endif
#endif /* XR_USE_GRAPHICS_API_D3D12 */
#ifdef XR_USE_PLATFORM_WIN32
#define XR_KHR_win32_convert_performance_counter_time 1
#define XR_KHR_win32_convert_performance_counter_time_SPEC_VERSION 1
#define XR_KHR_WIN32_CONVERT_PERFORMANCE_COUNTER_TIME_EXTENSION_NAME "XR_KHR_win32_convert_performance_counter_time"
typedef XrResult (XRAPI_PTR *PFN_xrConvertWin32PerformanceCounterToTimeKHR)(XrInstance instance, const LARGE_INTEGER* performanceCounter, XrTime* time);
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimeToWin32PerformanceCounterKHR)(XrInstance instance, XrTime time, LARGE_INTEGER* performanceCounter);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrConvertWin32PerformanceCounterToTimeKHR(
XrInstance instance,
const LARGE_INTEGER* performanceCounter,
XrTime* time);
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimeToWin32PerformanceCounterKHR(
XrInstance instance,
XrTime time,
LARGE_INTEGER* performanceCounter);
#endif
#endif /* XR_USE_PLATFORM_WIN32 */
#ifdef XR_USE_TIMESPEC
#define XR_KHR_convert_timespec_time 1
#define XR_KHR_convert_timespec_time_SPEC_VERSION 1
#define XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME "XR_KHR_convert_timespec_time"
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimespecTimeToTimeKHR)(XrInstance instance, const struct timespec* timespecTime, XrTime* time);
typedef XrResult (XRAPI_PTR *PFN_xrConvertTimeToTimespecTimeKHR)(XrInstance instance, XrTime time, struct timespec* timespecTime);
#ifndef XR_NO_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimespecTimeToTimeKHR(
XrInstance instance,
const struct timespec* timespecTime,
XrTime* time);
XRAPI_ATTR XrResult XRAPI_CALL xrConvertTimeToTimespecTimeKHR(
XrInstance instance,
XrTime time,
struct timespec* timespecTime);
#endif
#endif /* XR_USE_TIMESPEC */
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,124 @@
/*
** Copyright (c) 2017-2019 The Khronos Group Inc.
**
** 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 OPENXR_PLATFORM_DEFINES_H_
#define OPENXR_PLATFORM_DEFINES_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/* Platform-specific calling convention macros.
*
* Platforms should define these so that OpenXR clients call OpenXR functions
* with the same calling conventions that the OpenXR implementation expects.
*
* XRAPI_ATTR - Placed before the return type in function declarations.
* Useful for C++11 and GCC/Clang-style function attribute syntax.
* XRAPI_CALL - Placed after the return type in function declarations.
* Useful for MSVC-style calling convention syntax.
* XRAPI_PTR - Placed between the '(' and '*' in function pointer types.
*
* Function declaration: XRAPI_ATTR void XRAPI_CALL xrFunction(void);
* Function pointer type: typedef void (XRAPI_PTR *PFN_xrFunction)(void);
*/
#if defined(_WIN32)
#ifdef XRAPI_DLL_EXPORT
#define XRAPI_ATTR __declspec(dllexport)
#else
#define XRAPI_ATTR
#endif
// On Windows, functions use the stdcall convention
#define XRAPI_CALL __stdcall
#define XRAPI_PTR XRAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
#error "API not supported for the 'armeabi' NDK ABI"
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
// On Android 32-bit ARM targets, functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
// is true even if the rest of the application passes floats on the stack,
// as it does by default when compiling for the armeabi-v7a NDK ABI.
#define XRAPI_ATTR __attribute__((pcs("aapcs-vfp")))
#define XRAPI_CALL
#define XRAPI_PTR XRAPI_ATTR
#else
// On other platforms, use the default calling convention
#define XRAPI_ATTR
#define XRAPI_CALL
#define XRAPI_PTR
#endif
#include <stddef.h>
#if !defined(XR_NO_STDINT_H)
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#endif // !defined( XR_NO_STDINT_H )
// XR_PTR_SIZE (in bytes)
#if (defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__))
#define XR_PTR_SIZE 8
#else
#define XR_PTR_SIZE 4
#endif
// Needed so we can use clang __has_feature portably.
#if !defined(XR_COMPILER_HAS_FEATURE)
#if defined(__clang__)
#define XR_COMPILER_HAS_FEATURE(x) __has_feature(x)
#else
#define XR_COMPILER_HAS_FEATURE(x) 0
#endif
#endif
// Identifies if the current compiler has C++11 support enabled.
// Does not by itself identify if any given C++11 feature is present.
#if !defined(XR_CPP11_ENABLED) && defined(__cplusplus)
#if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define XR_CPP11_ENABLED 1
#elif defined(_MSC_VER) && (_MSC_VER >= 1600)
#define XR_CPP11_ENABLED 1
#elif (__cplusplus >= 201103L) // 201103 is the first C++11 version.
#define XR_CPP11_ENABLED 1
#endif
#endif
// Identifies if the current compiler supports C++11 nullptr.
#if !defined(XR_CPP_NULLPTR_SUPPORTED)
#if defined(XR_CPP11_ENABLED) && \
((defined(__clang__) && XR_COMPILER_HAS_FEATURE(cxx_nullptr)) || \
(defined(__GNUC__) && (((__GNUC__ * 1000) + __GNUC_MINOR__) >= 4006)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1600)) || \
(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403)))
#define XR_CPP_NULLPTR_SUPPORTED 1
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

194
extern/openxr/src/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,194 @@
# Copyright (c) 2017 The Khronos Group Inc.
#
# 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.
#
# Author:
#
# Entire project uses C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# All options defined here
option(BUILD_LOADER "Build loader" ON)
option(BUILD_LOADER_WITH_EXCEPTION_HANDLING "Enable exception handling in the loader. Leave this on unless your standard library is built to not throw." ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(DYNAMIC_LOADER "Build the loader as a .dll library" OFF)
else()
option(DYNAMIC_LOADER "Build the loader as a .dll library" ON)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/api_layers")
option(BUILD_API_LAYERS "Build API layers" ON)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
option(BUILD_TESTS "Build tests" ON)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conformance")
option(BUILD_CONFORMANCE_TESTS "Build conformance tests" ON)
endif()
# Several files use these compile-time OS switches
if(WIN32)
add_definitions(-DXR_OS_WINDOWS)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DXR_OS_LINUX)
endif()
# Determine the presentation backend for Linux systems.
# Use an include because the code is pretty big.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(presentation)
endif()
# Several files use these compile-time platform switches
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_definitions( -DXR_USE_PLATFORM_WIN32 )
elseif( PRESENTATION_BACKEND MATCHES "xlib" )
add_definitions( -DXR_USE_PLATFORM_XLIB )
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
add_definitions( -DXR_USE_PLATFORM_XCB )
# TODO remove once conformance supports XCB
set(BUILD_CONFORMANCE_TESTS OFF)
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
add_definitions( -DXR_USE_PLATFORM_WAYLAND )
# TODO remove once conformance supports Wayland
set(BUILD_CONFORMANCE_TESTS OFF)
endif()
# Enable graphics API available to the build.
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
# Find the Vulkan headers
find_package(VulkanHeaders)
if (VulkanHeaders_FOUND)
add_definitions(-DXR_USE_GRAPHICS_API_VULKAN)
endif()
# Find the Vulkan loader.
find_package(Vulkan)
# To use simply include ${Vulkan_LIBRARY} in your target_link_library or
# wherever you normally link your library files to your target.
endif()
find_package(OpenGL)
if (OPENGL_FOUND)
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_definitions(-DXR_USE_GRAPHICS_API_D3D)
add_definitions(-DXR_USE_GRAPHICS_API_D3D11)
add_definitions(-DXR_USE_GRAPHICS_API_D3D12)
endif()
if(BUILD_LOADER_WITH_EXCEPTION_HANDLING)
set(XRLOADER_ENABLE_EXCEPTION_HANDLING TRUE)
endif()
# Check for the existence of the secure_getenv or __secure_getenv commands
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(secure_getenv HAVE_SECURE_GETENV)
CHECK_FUNCTION_EXISTS(__secure_getenv HAVE___SECURE_GETENV)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/common_cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/common_cmake_config.h)
# Be able to find pre-generated files, if used.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DXR_USE_TIMESPEC)
# Set up the OpenXR version variables, used by several targets in this project.
include(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
# Path separators ( : or ; ) are not handled well in CMake.
# This seems like a reasonable approach.
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CODEGEN_PYTHON_PATH "${CMAKE_SOURCE_DIR}/specification/scripts;${CMAKE_SOURCE_DIR}/src/scripts;$ENV{PYTHONPATH}")
else()
set(CODEGEN_PYTHON_PATH "${CMAKE_SOURCE_DIR}/specification/scripts:${CMAKE_SOURCE_DIR}/src/scripts:$ENV{PYTHONPATH}")
endif()
# General code generation macro used by several targets.
macro(run_xr_xml_generate dependency output)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${output}" AND NOT BUILD_FORCE_GENERATION)
# pre-generated found
message(STATUS "Found and will use pre-generated ${output} in source tree")
list(APPEND GENERATED_OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${output}")
else()
if(NOT PYTHON_EXECUTABLE)
message(FATAL_ERROR "Python 3 not found, but pre-generated ${CMAKE_CURRENT_SOURCE_DIR}/${output} not found")
endif()
add_custom_command(OUTPUT ${output}
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CODEGEN_PYTHON_PATH}"
${PYTHON_EXECUTABLE}
${CMAKE_SOURCE_DIR}/src/scripts/src_genxr.py
-registry ${CMAKE_SOURCE_DIR}/specification/registry/xr.xml
${output}
DEPENDS
"${CMAKE_SOURCE_DIR}/specification/registry/xr.xml"
"${CMAKE_SOURCE_DIR}/specification/scripts/generator.py"
"${CMAKE_SOURCE_DIR}/specification/scripts/reg.py"
"${CMAKE_SOURCE_DIR}/src/scripts/${dependency}"
"${CMAKE_SOURCE_DIR}/src/scripts/src_genxr.py"
${ARGN}
COMMENT "Generating ${output} using ${PYTHON_EXECUTABLE} on ${dependency}"
)
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
list(APPEND GENERATED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${output}")
list(APPEND GENERATED_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${output}")
endif()
endmacro()
# Layer JSON generation macro used by several targets.
macro(gen_xr_layer_json filename layername libfile version desc genbad)
add_custom_command(OUTPUT ${filename}
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CODEGEN_PYTHON_PATH}"
${PYTHON_EXECUTABLE}
${CMAKE_SOURCE_DIR}/src/scripts/generate_api_layer_manifest.py
-f ${filename} -n ${layername} -l ${libfile} -a ${MAJOR}.${MINOR} -v ${version} ${genbad} -d ${desc}
DEPENDS ${CMAKE_SOURCE_DIR}/src/scripts/generate_api_layer_manifest.py
COMMENT "Generating API Layer JSON ${filename} using -f ${filename} -n ${layername} -l ${libfile} -a ${MAJOR}.${MINOR} -v ${version} ${genbad} -d ${desc}"
)
endmacro()
# Custom target for generated dispatch table sources, used by several targets.
set(GENERATED_OUTPUT)
run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.h)
run_xr_xml_generate(utility_source_generator.py xr_generated_dispatch_table.c)
run_xr_xml_generate(utility_source_generator.py xr_generated_utilities.h)
run_xr_xml_generate(utility_source_generator.py xr_generated_utilities.c)
add_custom_target(xr_global_generated_files DEPENDS
${GENERATED_DEPENDS}
)
set_target_properties(xr_global_generated_files PROPERTIES FOLDER ${CODEGEN_FOLDER})
set(COMMON_GENERATED_OUTPUT ${GENERATED_OUTPUT})
if(BUILD_LOADER)
add_subdirectory(loader)
endif()
if(BUILD_API_LAYERS)
add_subdirectory(api_layers)
endif()
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
if(BUILD_CONFORMANCE_TESTS)
add_subdirectory(conformance)
endif()

View File

@@ -0,0 +1,103 @@
# Copyright (c) 2017-2019 The Khronos Group Inc.
#
# 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.
#
# Author:
#
# Force all compilers to output to binary folder without additional output (like Windows adds "Debug" and "Release" folders)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
# Copy the api_layer_platform_defines.h file and place it in the binary (build) directory.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/api_layer_platform_defines.h ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
# Basics for core_validation API Layer
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XrApiLayer_core_validation.json ${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.json COPYONLY)
add_library(XrApiLayer_core_validation SHARED
core_validation.cpp
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.cpp
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.h
${OPENXR_ROOT_DIR}/src/xr_generated_dispatch_table.c
${OPENXR_ROOT_DIR}/src/api_layers/xr_generated_core_validation.cpp
${OPENXR_ROOT_DIR}/src/api_layers/xr_generated_core_validation.hpp
# Included in this list to force generation
${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.json
)
set_target_properties(XrApiLayer_core_validation PROPERTIES FOLDER ${API_LAYERS_FOLDER})
add_dependencies(XrApiLayer_core_validation
generate_openxr_header
xr_global_generated_files
)
target_include_directories(XrApiLayer_core_validation
PRIVATE ${OPENXR_ROOT_DIR}/src/common
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_BINARY_DIR}/include
PRIVATE ${CMAKE_BINARY_DIR}/src
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
if(VulkanHeaders_FOUND)
target_include_directories(XrApiLayer_core_validation
PRIVATE ${Vulkan_INCLUDE_DIRS}
)
endif()
# Flag generated files
set_source_files_properties(
${CMAKE_BINARY_DIR}/src/xr_generated_dispatch_table.c
PROPERTIES GENERATED TRUE
)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
# Windows core_validation-specific information
target_compile_definitions(XrApiLayer_core_validation PRIVATE _CRT_SECURE_NO_WARNINGS)
# Turn off transitional "changed behavior" warning message for Visual Studio versions prior to 2015.
# The changed behavior is that constructor initializers are now fixed to clear the struct members.
target_compile_options(XrApiLayer_core_validation PRIVATE "$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,19>>:/wd4351>")
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/XrApiLayer_core_validation.def DEF_FILE)
add_custom_target(copy-core_validation-def-file ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEF_FILE} ${CMAKE_CURRENT_BINARY_DIR}/XrApiLayer_core_validation.def
VERBATIM
)
set_target_properties(copy-core_validation-def-file PROPERTIES FOLDER ${HELPER_FOLDER})
elseif(APPLE)
# Apple core_validation-specific information
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl")
else()
# Linux core_validation-specific information
target_compile_options(XrApiLayer_core_validation PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare)
set_target_properties(XrApiLayer_core_validation PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
endif()
# Install explicit layers on Linux
set(TARGET_NAMES
XrApiLayer_core_validation)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
foreach(TARGET_NAME ${TARGET_NAMES})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.json DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openxr/${MAJOR}/api_layers/explicit.d)
install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endforeach()
endif()

View File

@@ -0,0 +1,27 @@
;;;; Begin Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2017-2019 The Khronos Group Inc.
; Copyright (c) 2017-2019 Valve Corporation
; Copyright (c) 2017-2019 LunarG, Inc.
;
; 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.
;
; Author: Mark Young <marky@lunarg.com>
;
;;;; End Copyright Notice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LIBRARY XrApiLayer_core_validation
EXPORTS
xrNegotiateLoaderApiLayerInterface

View File

@@ -0,0 +1,10 @@
{
"file_format_version": "1.0.0",
"api_layer": {
"name": "XR_APILAYER_LUNARG_core_validation",
"library_path": "libXrApiLayer_core_validation.dll",
"api_version": "1.0",
"implementation_version": "1",
"description": "API Layer to perform validation of api calls and parameters as they occur"
}
}

View File

@@ -0,0 +1,48 @@
// Copyright (c) 2018-2019 The Khronos Group Inc.
// Copyright (c) 2018-2019 Valve Corporation
// Copyright (c) 2018-2019 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#ifndef API_LAYER_PLATFORM_DEFINES_H_
#define API_LAYER_PLATFORM_DEFINES_H_ 1
#ifdef _WIN32
#define XR_USE_PLATFORM_WIN32 1 // Win32 platform
#endif // _WIN32
#if defined(OS_LINUX_XLIB)
#define XR_USE_PLATFORM_XLIB 1 // Xlib platform
#endif // OS_LINUX_XLIB
#if defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX)
#define XR_USE_PLATFORM_XCB 1 // Xcb platform
#endif // OS_LINUX_XCB || OS_LINUX_XCB_GLX
#if defined(OS_LINUX_WAYLAND)
#define XR_USE_PLATFORM_WAYLAND 1 // Wayland platform
#endif // OS_LINUX_WAYLAND
#if defined(XR_OS_APPLE_IOS)
#define XR_USE_PLATFORM_IOS 1 // iOS platform
#define XR_USE_GRAPHICS_API_OPENGL_ES 1 // OpenGLES exists
#define XR_USE_GRAPHICS_API_METAL 1 // Metal exists
#endif // XR_OS_APPLE_IOS
#if defined(XR_OS_APPLE_MACOS)
#define XR_USE_PLATFORM_MACOS 1 // MacOS platform
#define XR_USE_GRAPHICS_API_OPENGL 1 // OpenGL exists
#define XR_USE_GRAPHICS_API_METAL 1 // Metal exists
#endif // XR_OS_APPLE_MACOS
#include "xr_dependencies.h" // IWYU pragma: export
#endif // API_LAYER_PLATFORM_DEFINES_H_

View File

@@ -0,0 +1,932 @@
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#include "api_layer_platform_defines.h"
#include "extra_algorithms.h"
#include "hex_and_handles.h"
#include "loader_interfaces.h"
#include "platform_utils.hpp"
#include "validation_utils.h"
#include "xr_generated_core_validation.hpp"
#include "xr_generated_dispatch_table.h"
#include <openxr/openxr.h>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <mutex>
#include <sstream>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#if defined(__GNUC__) && __GNUC__ >= 4
#define LAYER_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define LAYER_EXPORT __attribute__((visibility("default")))
#else
#define LAYER_EXPORT
#endif
// Log recording information
enum CoreValidationRecordType {
RECORD_NONE = 0,
RECORD_TEXT_COUT,
RECORD_TEXT_FILE,
RECORD_HTML_FILE,
};
struct CoreValidationRecordInfo {
bool initialized;
CoreValidationRecordType type;
std::string file_name;
};
static CoreValidationRecordInfo g_record_info = {};
static std::mutex g_record_mutex = {};
// HTML utilities
bool CoreValidationWriteHtmlHeader() {
try {
std::unique_lock<std::mutex> mlock(g_record_mutex);
std::ofstream html_file;
html_file.open(g_record_info.file_name, std::ios::out);
html_file
<< "<!doctype html>\n"
"<html>\n"
" <head>\n"
" <title>OpenXR Core Validation</title>\n"
" <style type='text/css'>\n"
" html {\n"
" background-color: #0b1e48;\n"
" background-image: url('https://vulkan.lunarg.com/img/bg-starfield.jpg');\n"
" background-position: center;\n"
" -webkit-background-size: cover;\n"
" -moz-background-size: cover;\n"
" -o-background-size: cover;\n"
" background-size: cover;\n"
" background-attachment: fixed;\n"
" background-repeat: no-repeat;\n"
" height: 100%;\n"
" }\n"
" #header {\n"
" z-index: -1;\n"
" }\n"
" #header>img {\n"
" position: absolute;\n"
" width: 160px;\n"
" margin-left: -280px;\n"
" top: -10px;\n"
" left: 50%;\n"
" }\n"
" #header>h1 {\n"
" font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;\n"
" font-size: 48px;\n"
" font-weight: 200;\n"
" text-shadow: 4px 4px 5px #000;\n"
" color: #eee;\n"
" position: absolute;\n"
" width: 600px;\n"
" margin-left: -80px;\n"
" top: 8px;\n"
" left: 50%;\n"
" }\n"
" body {\n"
" font-family: Consolas, monaco, monospace;\n"
" font-size: 14px;\n"
" line-height: 20px;\n"
" color: #eee;\n"
" height: 100%;\n"
" margin: 0;\n"
" overflow: hidden;\n"
" }\n"
" #wrapper {\n"
" background-color: rgba(0, 0, 0, 0.7);\n"
" border: 1px solid #446;\n"
" box-shadow: 0px 0px 10px #000;\n"
" padding: 8px 12px;\n"
" display: inline-block;\n"
" position: absolute;\n"
" top: 80px;\n"
" bottom: 25px;\n"
" left: 50px;\n"
" right: 50px;\n"
" overflow: auto;\n"
" }\n"
" details>*:not(summary) {\n"
" margin-left: 22px;\n"
" }\n"
" summary:only-child {\n"
" display: block;\n"
" padding-left: 15px;\n"
" }\n"
" details>summary:only-child::-webkit-details-marker {\n"
" display: none;\n"
" padding-left: 15px;\n"
" }\n"
" .headervar, .generalheadertype, .warningheadertype, .errorheadertype, .debugheadertype, .headerval {\n"
" display: inline;\n"
" margin: 0 9px;\n"
" }\n"
" .var, .type, .val {\n"
" display: inline;\n"
" margin: 0 6px;\n"
" }\n"
" .warningheadertype, .type {\n"
" color: #dce22f;\n"
" }\n"
" .errorheadertype, .type {\n"
" color: #ff1616;\n"
" }\n"
" .debugheadertype, .type {\n"
" color: #888;\n"
" }\n"
" .generalheadertype, .type {\n"
" color: #acf;\n"
" }\n"
" .headerval, .val {\n"
" color: #afa;\n"
" text-align: right;\n"
" }\n"
" .thd {\n"
" color: #888;\n"
" }\n"
" </style>\n"
" </head>\n"
" <body>\n"
" <div id='header'>\n"
" <img src='https://lunarg.com/wp-content/uploads/2016/02/LunarG-wReg-150.png' />\n"
" <h1>OpenXR Core Validation</h1>\n"
" </div>\n"
" <div id='wrapper'>\n";
return true;
} catch (...) {
return false;
}
}
bool CoreValidationWriteHtmlFooter() {
try {
std::unique_lock<std::mutex> mlock(g_record_mutex);
std::ofstream html_file;
html_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
html_file << " </div>\n"
" </body>\n"
"</html>";
// Writing the footer means we're done.
if (g_record_info.initialized) {
g_record_info.initialized = false;
g_record_info.type = RECORD_NONE;
}
return true;
} catch (...) {
return false;
}
}
// Function to record all the core validation information
void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message) {
if (g_record_info.initialized) {
std::unique_lock<std::mutex> mlock(g_record_mutex);
// Debug Utils items (in case we need them)
XrDebugUtilsMessageSeverityFlagsEXT debug_utils_severity = 0;
std::vector<XrDebugUtilsObjectNameInfoEXT> debug_utils_objects;
std::vector<XrDebugUtilsLabelEXT> session_labels;
std::string severity_string;
switch (message_severity) {
case VALID_USAGE_DEBUG_SEVERITY_DEBUG:
severity_string = "VALID_DEBUG";
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
break;
case VALID_USAGE_DEBUG_SEVERITY_INFO:
severity_string = "VALID_INFO";
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
break;
case VALID_USAGE_DEBUG_SEVERITY_WARNING:
severity_string = "VALID_WARNING";
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
break;
case VALID_USAGE_DEBUG_SEVERITY_ERROR:
severity_string = "VALID_ERROR";
debug_utils_severity = XR_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
break;
default:
severity_string = "VALID_UNKNOWN";
break;
}
// If we have instance information, see if we need to log this information out to a debug messenger
// callback.
if (nullptr != instance_info) {
if (!objects_info.empty()) {
for (auto &obj : objects_info) {
XrDebugUtilsObjectNameInfoEXT obj_name_info = {};
obj_name_info.next = nullptr;
obj_name_info.objectType = obj.type;
obj_name_info.objectHandle = obj.handle;
// If there's a session in the list, see if it has labels
if (XR_OBJECT_TYPE_SESSION == obj.type) {
XrSession session = TreatIntegerAsHandle<XrSession>(obj.handle);
auto session_label_iterator = g_xr_session_labels.find(session);
if (session_label_iterator != g_xr_session_labels.end()) {
auto rev_iter = session_label_iterator->second->rbegin();
for (; rev_iter != session_label_iterator->second->rend(); ++rev_iter) {
session_labels.push_back((*rev_iter)->debug_utils_label);
}
}
}
// Loop through all object names and see if any match
for (auto &object_name : instance_info->object_names) {
if (object_name->objectType == obj.type && object_name->objectHandle == obj.handle) {
obj_name_info.objectName = object_name->objectName;
break;
}
}
debug_utils_objects.push_back(obj_name_info);
}
}
if (!instance_info->debug_messengers.empty()) {
// Setup our callback data once
XrDebugUtilsMessengerCallbackDataEXT callback_data = {};
callback_data.type = XR_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
callback_data.messageId = message_id.c_str();
callback_data.functionName = command_name.c_str();
callback_data.message = message.c_str();
callback_data.objectCount = static_cast<uint8_t>(debug_utils_objects.size());
if (debug_utils_objects.empty()) {
callback_data.objects = nullptr;
} else {
callback_data.objects = debug_utils_objects.data();
}
callback_data.sessionLabelCount = static_cast<uint8_t>(session_labels.size());
if (session_labels.empty()) {
callback_data.sessionLabels = nullptr;
} else {
callback_data.sessionLabels = session_labels.data();
}
// Loop through all active messengers and give each a chance to output information
for (auto &debug_messenger : instance_info->debug_messengers) {
CoreValidationMessengerInfo *validation_messenger_info = debug_messenger.get();
XrDebugUtilsMessengerCreateInfoEXT *messenger_create_info = validation_messenger_info->create_info;
// If a callback exists, and the message is of a type this callback cares about, call it.
if (nullptr != messenger_create_info->userCallback &&
0 != (messenger_create_info->messageSeverities & debug_utils_severity) &&
0 != (messenger_create_info->messageTypes & XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT)) {
XrBool32 ret_val = messenger_create_info->userCallback(debug_utils_severity,
XR_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT,
&callback_data, messenger_create_info->userData);
}
}
}
}
switch (g_record_info.type) {
case RECORD_TEXT_COUT: {
std::cout << "[" << severity_string << " | " << message_id << " | " << command_name << "]: " << message
<< std::endl;
if (!objects_info.empty()) {
std::cout << " Objects:" << std::endl;
uint32_t count = 0;
for (auto object_info : objects_info) {
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
std::ostringstream oss_object_handle;
std::cout << " [" << std::to_string(count++) << "] - " << object_type << " ("
<< Uint64ToHexString(object_info.handle) << ")";
std::cout << std::endl;
}
}
if (!session_labels.empty()) {
std::cout << " Session Labels:" << std::endl;
uint32_t count = 0;
for (auto session_label : session_labels) {
std::cout << " [" << std::to_string(count++) << "] - " << session_label.labelName << std::endl;
}
}
std::cout << std::flush;
break;
}
case RECORD_TEXT_FILE: {
std::ofstream text_file;
text_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
text_file << "[" << severity_string << " | " << message_id << " | " << command_name << "]: " << message
<< std::endl;
if (!objects_info.empty()) {
text_file << " Objects:" << std::endl;
uint32_t count = 0;
for (auto object_info : objects_info) {
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
text_file << " [" << std::to_string(count++) << "] - " << object_type << " ("
<< Uint64ToHexString(object_info.handle) << ")";
text_file << std::endl;
}
}
if (!session_labels.empty()) {
text_file << " Session Labels:" << std::endl;
uint32_t count = 0;
for (auto session_label : session_labels) {
text_file << " [" << std::to_string(count++) << "] - " << session_label.labelName << std::endl;
}
}
text_file << std::flush;
text_file.close();
break;
}
case RECORD_HTML_FILE: {
std::ofstream text_file;
text_file.open(g_record_info.file_name, std::ios::out | std::ios::app);
text_file << "<details class='data'>\n";
std::string header_type = "generalheadertype";
switch (message_severity) {
case VALID_USAGE_DEBUG_SEVERITY_DEBUG:
header_type = "debugheadertype";
severity_string = "Debug Message";
break;
case VALID_USAGE_DEBUG_SEVERITY_INFO:
severity_string = "Info Message";
break;
case VALID_USAGE_DEBUG_SEVERITY_WARNING:
header_type = "warningheadertype";
severity_string = "Warning Message";
break;
case VALID_USAGE_DEBUG_SEVERITY_ERROR:
header_type = "errorheadertype";
severity_string = "Error Message";
break;
default:
severity_string = "Unknown Message";
break;
}
text_file << " <summary>\n"
<< " <div class='" << header_type << "'>" << severity_string << "</div>\n"
<< " <div class='headerval'>" << command_name << "</div>\n"
<< " <div class='headervar'>" << message_id << "</div>\n"
<< " </summary>\n";
text_file << " <div class='data'>\n";
text_file << " <div class='val'>" << message << "</div>\n";
if (!objects_info.empty()) {
text_file << " <details class='data'>\n";
text_file << " <summary>\n";
text_file << " <div class='type'>Relevant OpenXR Objects</div>\n";
text_file << " </summary>\n";
uint32_t count = 0;
for (auto object_info : objects_info) {
std::string object_type = GenValidUsageXrObjectTypeToString(object_info.type);
text_file << " <div class='data'>\n";
text_file << " <div class='var'>[" << count++ << "]</div>\n";
text_file << " <div class='type'>" << object_type << "</div>\n";
text_file << " <div class='val'>" << Uint64ToHexString(object_info.handle) << "</div>\n";
text_file << " </div>\n";
}
text_file << " </details>\n";
text_file << std::flush;
}
if (!session_labels.empty()) {
text_file << " <details class='data'>\n";
text_file << " <summary>\n";
text_file << " <div class='type'>Relevant Session Labels</div>\n";
text_file << " </summary>\n";
uint32_t count = 0;
for (auto session_label : session_labels) {
text_file << " <div class='data'>\n";
text_file << " <div class='var'>[" << count++ << "]</div>\n";
text_file << " <div class='type'>" << session_label.labelName << "</div>\n";
text_file << " </div>\n";
}
text_file << " </details>\n";
}
text_file << " </div>\n";
text_file << "</details>\n";
break;
}
default:
break;
}
}
}
void reportInternalError(std::string const &message) {
std::cerr << "INTERNAL VALIDATION LAYER ERROR: " << message << std::endl;
throw std::runtime_error("Internal validation layer error: " + message);
}
void InvalidStructureType(GenValidUsageXrInstanceInfo *instance_info, const std::string &command_name,
std::vector<GenValidUsageXrObjectInfo> &objects_info, const char *structure_name, XrStructureType type,
const char *vuid, XrStructureType expected, const char *expected_name) {
std::ostringstream oss_type;
oss_type << structure_name << " has an invalid XrStructureType ";
oss_type << Uint32ToHexString(static_cast<uint32_t>(type));
if (expected != 0) {
oss_type << ", expected " << Uint32ToHexString(static_cast<uint32_t>(type));
oss_type << " (" << expected_name << ")";
}
if (vuid != nullptr) {
CoreValidLogMessage(instance_info, vuid, VALID_USAGE_DEBUG_SEVERITY_ERROR, command_name, objects_info, oss_type.str());
} else {
CoreValidLogMessage(instance_info, "VUID-" + std::string(structure_name) + "-type-type", VALID_USAGE_DEBUG_SEVERITY_ERROR,
command_name, objects_info, oss_type.str());
}
}
// NOTE: Can't validate the following VUIDs since the command never enters a layer:
// Command: xrEnumerateApiLayerProperties
// VUIDs: "VUID-xrEnumerateApiLayerProperties-propertyCountOutput-parameter"
// "VUID-xrEnumerateApiLayerProperties-properties-parameter"
// Command: xrEnumerateInstanceExtensionProperties
// VUIDs: "VUID-xrEnumerateInstanceExtensionProperties-layerName-parameter"
// "VUID-xrEnumerateInstanceExtensionProperties-propertyCountOutput-parameter"
// "VUID-xrEnumerateInstanceExtensionProperties-properties-parameter"
XrResult CoreValidationXrCreateInstance(const XrInstanceCreateInfo * /*info*/, XrInstance * /*instance*/) {
// Shouldn't be called, coreValidationXrCreateApiLayerInstance should called instead
return XR_SUCCESS;
}
GenValidUsageXrInstanceInfo::GenValidUsageXrInstanceInfo(XrInstance inst, PFN_xrGetInstanceProcAddr next_get_instance_proc_addr)
: instance(inst), dispatch_table(new XrGeneratedDispatchTable()) {
/// @todo smart pointer here!
// Create the dispatch table to the next levels
GeneratedXrPopulateDispatchTable(dispatch_table, instance, next_get_instance_proc_addr);
}
GenValidUsageXrInstanceInfo::~GenValidUsageXrInstanceInfo() { delete dispatch_table; }
// See if there is a debug utils create structure in the "next" chain
XrResult CoreValidationXrCreateApiLayerInstance(const XrInstanceCreateInfo *info, const struct XrApiLayerCreateInfo *apiLayerInfo,
XrInstance *instance) {
try {
XrApiLayerCreateInfo new_api_layer_info = {};
XrResult validation_result = XR_SUCCESS;
bool user_defined_output = false;
bool first_time = !g_record_info.initialized;
if (!g_record_info.initialized) {
g_record_info.initialized = true;
g_record_info.type = RECORD_NONE;
}
char *export_type = PlatformUtilsGetEnv("XR_CORE_VALIDATION_EXPORT_TYPE");
char *file_name = PlatformUtilsGetEnv("XR_CORE_VALIDATION_FILE_NAME");
if (nullptr != file_name) {
g_record_info.file_name = file_name;
PlatformUtilsFreeEnv(file_name);
}
if (nullptr != export_type) {
std::string string_export_type = export_type;
PlatformUtilsFreeEnv(export_type);
std::transform(string_export_type.begin(), string_export_type.end(), string_export_type.begin(),
[](unsigned char c) { return std::tolower(c); });
std::cerr << "Core Validation output type: " << string_export_type << ", first time = " << std::to_string(first_time)
<< std::endl;
if (string_export_type == "text") {
if (!g_record_info.file_name.empty()) {
g_record_info.type = RECORD_TEXT_FILE;
} else {
g_record_info.type = RECORD_TEXT_COUT;
}
user_defined_output = true;
} else if (string_export_type == "html" && first_time) {
g_record_info.type = RECORD_HTML_FILE;
if (!CoreValidationWriteHtmlHeader()) {
return XR_ERROR_INITIALIZATION_FAILED;
}
}
}
// Call the generated pre valid usage check.
validation_result = GenValidUsageInputsXrCreateInstance(info, instance);
// Copy the contents of the layer info struct, but then move the next info up by
// one slot so that the next layer gets information.
memcpy(&new_api_layer_info, apiLayerInfo, sizeof(XrApiLayerCreateInfo));
new_api_layer_info.nextInfo = apiLayerInfo->nextInfo->next;
// Get the function pointers we need
PFN_xrGetInstanceProcAddr next_get_instance_proc_addr = apiLayerInfo->nextInfo->nextGetInstanceProcAddr;
PFN_xrCreateApiLayerInstance next_create_api_layer_instance = apiLayerInfo->nextInfo->nextCreateApiLayerInstance;
// Create the instance using the layer create instance command for the next layer
XrInstance returned_instance = *instance;
XrResult next_result = next_create_api_layer_instance(info, &new_api_layer_info, &returned_instance);
*instance = returned_instance;
// Create the instance information
std::unique_ptr<GenValidUsageXrInstanceInfo> instance_info(
new GenValidUsageXrInstanceInfo(returned_instance, next_get_instance_proc_addr));
// Save the enabled extensions.
for (uint32_t extension = 0; extension < info->enabledExtensionCount; ++extension) {
instance_info->enabled_extensions.emplace_back(info->enabledExtensionNames[extension]);
}
g_instance_info.insert(returned_instance, std::move(instance_info));
// See if a debug utils messenger is supposed to be created as part of the instance
// NOTE: We have to wait until after the instance info is added to the map for this
// to work properly.
const auto *next_header = reinterpret_cast<const XrBaseInStructure *>(info->next);
const XrDebugUtilsMessengerCreateInfoEXT *dbg_utils_create_info = nullptr;
while (next_header != nullptr) {
if (next_header->type == XR_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
dbg_utils_create_info = reinterpret_cast<const XrDebugUtilsMessengerCreateInfoEXT *>(next_header);
// Create the debug messenger. We don't have to keep track of it because it will be tracked as part
// of the instance info from here on out.
XrDebugUtilsMessengerEXT messenger;
validation_result = CoreValidationXrCreateDebugUtilsMessengerEXT(*instance, dbg_utils_create_info, &messenger);
// If we created a debug messenger, turn off the text output unless a user indicates they wanted it
if (XR_SUCCESS == validation_result && !user_defined_output) {
g_record_info.type = RECORD_NONE;
}
break;
}
next_header = reinterpret_cast<const XrBaseInStructure *>(next_header->next);
}
if (XR_SUCCESS == validation_result) {
return next_result;
}
return validation_result;
} catch (std::bad_alloc &) {
return XR_ERROR_OUT_OF_MEMORY;
} catch (...) {
return XR_ERROR_INITIALIZATION_FAILED;
}
}
void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value) {
typedef typename InstanceHandleInfo::value_t value_t;
auto map_with_lock = g_instance_info.lockMap();
auto &map = map_with_lock.second;
map_erase_if(map, [=](value_t const &data) { return data.second.get() == search_value; });
}
XrResult CoreValidationXrDestroyInstance(XrInstance instance) {
GenValidUsageInputsXrDestroyInstance(instance);
if (XR_NULL_HANDLE != instance) {
auto info_with_lock = g_instance_info.getWithLock(instance);
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
if (nullptr != gen_instance_info) {
gen_instance_info->object_names.clear();
gen_instance_info->debug_messengers.clear();
}
}
XrResult result = GenValidUsageNextXrDestroyInstance(instance);
if (!g_instance_info.empty() && g_record_info.type == RECORD_HTML_FILE) {
CoreValidationWriteHtmlFooter();
}
return result;
return XR_SUCCESS;
}
XrResult CoreValidationXrCreateSession(XrInstance instance, const XrSessionCreateInfo *createInfo, XrSession *session) {
try {
XrResult test_result = GenValidUsageInputsXrCreateSession(instance, createInfo, session);
if (XR_SUCCESS != test_result) {
return test_result;
}
GenValidUsageXrInstanceInfo *gen_instance_info = g_instance_info.get(instance);
// Check the next chain for a graphics binding structure, we need at least one.
uint32_t num_graphics_bindings_found = 0;
const auto *cur_ptr = reinterpret_cast<const XrBaseInStructure *>(createInfo->next);
while (nullptr != cur_ptr) {
switch (cur_ptr->type) {
default:
continue;
#ifdef XR_USE_PLATFORM_WIN32
case XR_TYPE_GRAPHICS_BINDING_OPENGL_WIN32_KHR:
num_graphics_bindings_found++;
break;
#endif
#ifdef XR_USE_PLATFORM_XLIB
case XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR:
num_graphics_bindings_found++;
break;
#endif
#ifdef XR_USE_PLATFORM_XCB
case XR_TYPE_GRAPHICS_BINDING_OPENGL_XCB_KHR:
num_graphics_bindings_found++;
break;
#endif
#ifdef XR_USE_PLATFORM_WAYLAND
case XR_TYPE_GRAPHICS_BINDING_OPENGL_WAYLAND_KHR:
num_graphics_bindings_found++;
break;
#endif
}
cur_ptr = reinterpret_cast<const XrBaseInStructure *>(cur_ptr->next);
}
auto const &enabled_extensions = gen_instance_info->enabled_extensions;
#ifdef XR_KHR_headless
bool has_headless = (enabled_extensions.end() !=
std::find(enabled_extensions.begin(), enabled_extensions.end(), XR_KHR_HEADLESS_EXTENSION_NAME));
#else
bool has_headless = false;
#endif // XR_KHR_headless
bool got_right_graphics_binding_count = (num_graphics_bindings_found == 1);
if (!got_right_graphics_binding_count && has_headless) {
// This permits 0 as well.
got_right_graphics_binding_count = (num_graphics_bindings_found == 0);
}
if (!got_right_graphics_binding_count) {
std::vector<GenValidUsageXrObjectInfo> objects_info;
objects_info.emplace_back(instance, XR_OBJECT_TYPE_INSTANCE);
std::ostringstream error_stream;
error_stream << "Invalid number of graphics binding structures provided. ";
error_stream << "Expected ";
if (has_headless) {
error_stream << "0 or 1";
} else {
error_stream << "1";
}
error_stream << ", but received ";
error_stream << num_graphics_bindings_found;
error_stream << ".";
// TODO: This needs to be updated with the actual VUID once we generate it.
CoreValidLogMessage(gen_instance_info, "VUID-xrCreateSession-next-parameter", VALID_USAGE_DEBUG_SEVERITY_ERROR,
"xrCreateSession", objects_info, error_stream.str());
return XR_ERROR_GRAPHICS_DEVICE_INVALID;
}
return GenValidUsageNextXrCreateSession(instance, createInfo, session);
} catch (...) {
return XR_SUCCESS;
}
}
// ---- XR_EXT_debug_utils extension commands
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT *nameInfo) {
try {
XrResult result = GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
result = GenValidUsageNextXrSetDebugUtilsObjectNameEXT(instance, nameInfo);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
auto info_with_lock = g_instance_info.getWithLock(instance);
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
if (nullptr != gen_instance_info) {
// Create a copy of the base object name info (no next items)
auto len = strlen(nameInfo->objectName);
char *name_string = new char[len + 1];
strncpy(name_string, nameInfo->objectName, len);
bool found = false;
for (auto &object_name : gen_instance_info->object_names) {
if (object_name->objectHandle == nameInfo->objectHandle && object_name->objectType == nameInfo->objectType) {
delete[] object_name->objectName;
object_name->objectName = name_string;
found = true;
break;
}
}
if (!found) {
UniqueXrDebugUtilsObjectNameInfoEXT new_object_name(new XrDebugUtilsObjectNameInfoEXT(*nameInfo));
new_object_name->next = nullptr;
new_object_name->objectName = name_string;
gen_instance_info->object_names.push_back(std::move(new_object_name));
}
}
return result;
} catch (...) {
return XR_ERROR_VALIDATION_FAILURE;
}
}
XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT *createInfo,
XrDebugUtilsMessengerEXT *messenger) {
try {
XrResult result = GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
result = GenValidUsageNextXrCreateDebugUtilsMessengerEXT(instance, createInfo, messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
auto info_with_lock = g_instance_info.getWithLock(instance);
GenValidUsageXrInstanceInfo *gen_instance_info = info_with_lock.second;
if (nullptr != gen_instance_info) {
auto *new_create_info = new XrDebugUtilsMessengerCreateInfoEXT(*createInfo);
new_create_info->next = nullptr;
UniqueCoreValidationMessengerInfo new_messenger_info(new CoreValidationMessengerInfo);
new_messenger_info->messenger = *messenger;
new_messenger_info->create_info = new_create_info;
gen_instance_info->debug_messengers.push_back(std::move(new_messenger_info));
}
return result;
} catch (...) {
return XR_ERROR_VALIDATION_FAILURE;
}
}
XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger) {
try {
XrResult result = GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
result = GenValidUsageNextXrDestroyDebugUtilsMessengerEXT(messenger);
if (!XR_UNQUALIFIED_SUCCESS(result)) {
return result;
}
if (XR_NULL_HANDLE == messenger) {
return XR_ERROR_HANDLE_INVALID;
}
auto info_with_lock = g_debugutilsmessengerext_info.getWithLock(messenger);
GenValidUsageXrHandleInfo *gen_handle_info = info_with_lock.second;
if (nullptr != gen_handle_info) {
auto &debug_messengers = gen_handle_info->instance_info->debug_messengers;
vector_remove_if_and_erase(debug_messengers,
[=](UniqueCoreValidationMessengerInfo const &msg) { return msg->messenger == messenger; });
}
return result;
} catch (...) {
return XR_ERROR_VALIDATION_FAILURE;
}
}
// We always want to remove the old individual label before we do anything else.
// So, do that in it's own method
void CoreValidationRemoveIndividualLabel(std::vector<GenValidUsageXrInternalSessionLabel *> *label_vec) {
if (!label_vec->empty()) {
GenValidUsageXrInternalSessionLabel *cur_label = label_vec->back();
if (cur_label->is_individual_label) {
label_vec->pop_back();
delete cur_label;
}
}
}
void CoreValidationBeginLabelRegion(XrSession session, const XrDebugUtilsLabelEXT *label_info) {
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
auto session_label_iterator = g_xr_session_labels.find(session);
if (session_label_iterator == g_xr_session_labels.end()) {
vec_ptr = new std::vector<GenValidUsageXrInternalSessionLabel *>;
g_xr_session_labels[session] = vec_ptr;
} else {
vec_ptr = session_label_iterator->second;
}
// Individual labels do not stay around in the transition into a new label region
CoreValidationRemoveIndividualLabel(vec_ptr);
// Start the new label region
auto *new_session_label = new GenValidUsageXrInternalSessionLabel;
new_session_label->label_name = label_info->labelName;
new_session_label->debug_utils_label = *label_info;
new_session_label->debug_utils_label.labelName = new_session_label->label_name.c_str();
new_session_label->is_individual_label = false;
vec_ptr->push_back(new_session_label);
}
void CoreValidationEndLabelRegion(XrSession session) {
auto session_label_iterator = g_xr_session_labels.find(session);
if (session_label_iterator == g_xr_session_labels.end()) {
return;
}
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = session_label_iterator->second;
// Individual labels do not stay around in the transition out of label region
CoreValidationRemoveIndividualLabel(vec_ptr);
// Remove the last label region
if (!vec_ptr->empty()) {
GenValidUsageXrInternalSessionLabel *cur_label = vec_ptr->back();
vec_ptr->pop_back();
delete cur_label;
}
}
void CoreValidationInsertLabel(XrSession session, const XrDebugUtilsLabelEXT *label_info) {
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
auto session_label_iterator = g_xr_session_labels.find(session);
if (session_label_iterator == g_xr_session_labels.end()) {
vec_ptr = new std::vector<GenValidUsageXrInternalSessionLabel *>;
g_xr_session_labels[session] = vec_ptr;
} else {
vec_ptr = session_label_iterator->second;
}
// Remove any individual layer that might already be there
CoreValidationRemoveIndividualLabel(vec_ptr);
// Insert a new individual label
auto *new_session_label = new GenValidUsageXrInternalSessionLabel;
new_session_label->label_name = label_info->labelName;
new_session_label->debug_utils_label = *label_info;
new_session_label->debug_utils_label.labelName = new_session_label->label_name.c_str();
new_session_label->is_individual_label = true;
vec_ptr->push_back(new_session_label);
}
// Called during xrDestroySession. We need to delete all session related labels.
void CoreValidationDeleteSessionLabels(XrSession session) {
std::vector<GenValidUsageXrInternalSessionLabel *> *vec_ptr = nullptr;
auto session_label_iterator = g_xr_session_labels.find(session);
if (session_label_iterator == g_xr_session_labels.end()) {
return;
}
vec_ptr = session_label_iterator->second;
while (!vec_ptr->empty()) {
delete vec_ptr->back();
vec_ptr->pop_back();
}
delete vec_ptr;
g_xr_session_labels.erase(session);
}
XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
XrResult test_result = GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
if (XR_SUCCESS != test_result) {
return test_result;
}
CoreValidationBeginLabelRegion(session, labelInfo);
return GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(session, labelInfo);
}
XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(XrSession session) {
XrResult test_result = GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(session);
if (XR_SUCCESS != test_result) {
return test_result;
}
CoreValidationEndLabelRegion(session);
return GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(session);
}
XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT *labelInfo) {
XrResult test_result = GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
if (XR_SUCCESS != test_result) {
return test_result;
}
CoreValidationInsertLabel(session, labelInfo);
return GenValidUsageNextXrSessionInsertDebugUtilsLabelEXT(session, labelInfo);
}
// ############################################################
// NOTE: Add new validation checking above this comment block
// ############################################################
extern "C" {
// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
// more API layers needs to expose at least this function.
LAYER_EXPORT XrResult xrNegotiateLoaderApiLayerInterface(const XrNegotiateLoaderInfo *loaderInfo, const char * /*apiLayerName*/,
XrNegotiateApiLayerRequest *apiLayerRequest) {
if (nullptr == loaderInfo || nullptr == apiLayerRequest || loaderInfo->structType != XR_LOADER_INTERFACE_STRUCT_LOADER_INFO ||
loaderInfo->structVersion != XR_LOADER_INFO_STRUCT_VERSION || loaderInfo->structSize != sizeof(XrNegotiateLoaderInfo) ||
apiLayerRequest->structType != XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST ||
apiLayerRequest->structVersion != XR_API_LAYER_INFO_STRUCT_VERSION ||
apiLayerRequest->structSize != sizeof(XrNegotiateApiLayerRequest) ||
loaderInfo->minInterfaceVersion > XR_CURRENT_LOADER_API_LAYER_VERSION ||
loaderInfo->maxInterfaceVersion < XR_CURRENT_LOADER_API_LAYER_VERSION ||
loaderInfo->maxInterfaceVersion > XR_CURRENT_LOADER_API_LAYER_VERSION ||
loaderInfo->maxApiVersion < XR_CORE_VALIDATION_API_VERSION || loaderInfo->minApiVersion > XR_CORE_VALIDATION_API_VERSION) {
return XR_ERROR_INITIALIZATION_FAILED;
}
apiLayerRequest->layerInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
apiLayerRequest->layerApiVersion = XR_CORE_VALIDATION_API_VERSION;
apiLayerRequest->getInstanceProcAddr = reinterpret_cast<PFN_xrGetInstanceProcAddr>(GenValidUsageXrGetInstanceProcAddr);
apiLayerRequest->createApiLayerInstance =
reinterpret_cast<PFN_xrCreateApiLayerInstance>(CoreValidationXrCreateApiLayerInstance);
return XR_SUCCESS;
}
} // extern "C"

View File

@@ -0,0 +1,324 @@
// Copyright (c) 2018-2019 The Khronos Group Inc.
// Copyright (c) 2018-2019 Valve Corporation
// Copyright (c) 2018-2019 LunarG, Inc.
// Copyright (c) 2019, Collabora, Ltd.
//
// 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.
//
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
// Mark Young <marky@lunarg.com>
//
#ifndef VALIDATION_UTILS_H_
#define VALIDATION_UTILS_H_ 1
#include "api_layer_platform_defines.h"
#include "hex_and_handles.h"
#include "extra_algorithms.h"
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#include <vector>
#include <unordered_map>
#include <string>
#include <mutex>
#include <memory>
/// Prints a message to stderr then throws an exception.
///
/// The printing of the message is because the exception will probably be caught and silently turned into a validation error.
[[noreturn]] void reportInternalError(std::string const &message);
// Structure used for storing the instance information we need for validating
// various aspects of the OpenXR API.
// Debug Utils items
struct CoreValidationMessengerInfo {
XrDebugUtilsMessengerEXT messenger;
XrDebugUtilsMessengerCreateInfoEXT *create_info;
};
struct XrGeneratedDispatchTable;
struct CoreValidationMessengerInfoDeleter {
void operator()(CoreValidationMessengerInfo *ptr) const {
delete ptr->create_info;
delete ptr;
}
};
struct XrDebugUtilsObjectNameInfoEXTDeleter {
void operator()(XrDebugUtilsObjectNameInfoEXT *ptr) const {
delete ptr->objectName;
delete ptr;
}
};
typedef std::unique_ptr<XrDebugUtilsObjectNameInfoEXT, XrDebugUtilsObjectNameInfoEXTDeleter> UniqueXrDebugUtilsObjectNameInfoEXT;
typedef std::unique_ptr<CoreValidationMessengerInfo, CoreValidationMessengerInfoDeleter> UniqueCoreValidationMessengerInfo;
// Define the instance struct used for passing information around.
// This information includes things like the dispatch table as well as the
// enabled extensions.
struct GenValidUsageXrInstanceInfo {
GenValidUsageXrInstanceInfo(XrInstance inst, PFN_xrGetInstanceProcAddr next_get_instance_proc_addr);
~GenValidUsageXrInstanceInfo();
const XrInstance instance;
XrGeneratedDispatchTable *dispatch_table;
std::vector<std::string> enabled_extensions;
std::vector<UniqueCoreValidationMessengerInfo> debug_messengers;
std::vector<UniqueXrDebugUtilsObjectNameInfoEXT> object_names;
};
// Structure used for storing information for other handles
struct GenValidUsageXrHandleInfo {
GenValidUsageXrInstanceInfo *instance_info;
XrObjectType direct_parent_type;
uint64_t direct_parent_handle;
};
// Structure used for storing session label information
struct GenValidUsageXrInternalSessionLabel {
XrDebugUtilsLabelEXT debug_utils_label;
std::string label_name;
bool is_individual_label;
};
// Enum used for indicating handle validation status.
enum ValidateXrHandleResult {
VALIDATE_XR_HANDLE_NULL,
VALIDATE_XR_HANDLE_INVALID,
VALIDATE_XR_HANDLE_SUCCESS,
};
// Unordered Map associating pointer to a vector of session label information to a session's handle
extern std::unordered_map<XrSession, std::vector<GenValidUsageXrInternalSessionLabel *> *> g_xr_session_labels;
// This function is used to delete session labels when a session is destroyed
extern void CoreValidationDeleteSessionLabels(XrSession session);
// Object information used for logging.
struct GenValidUsageXrObjectInfo {
uint64_t handle;
XrObjectType type;
GenValidUsageXrObjectInfo() = default;
template <typename T>
GenValidUsageXrObjectInfo(T h, XrObjectType t) : handle(MakeHandleGeneric(h)), type(t) {}
};
// Debug message severity levels for logging.
enum GenValidUsageDebugSeverity {
VALID_USAGE_DEBUG_SEVERITY_DEBUG = 0,
VALID_USAGE_DEBUG_SEVERITY_INFO = 7,
VALID_USAGE_DEBUG_SEVERITY_WARNING = 14,
VALID_USAGE_DEBUG_SEVERITY_ERROR = 21,
};
// in core_validation.cpp
void EraseAllInstanceTableMapElements(GenValidUsageXrInstanceInfo *search_value);
typedef std::unique_lock<std::mutex> UniqueLock;
template <typename HandleType, typename InfoType>
class HandleInfoBase {
public:
typedef InfoType info_t;
typedef HandleType handle_t;
typedef std::unordered_map<HandleType, std::unique_ptr<InfoType>> map_t;
typedef typename map_t::value_type value_t;
/// Validate a handle.
///
/// Returns an enum indicating null, invalid (not found), or success.
ValidateXrHandleResult verifyHandle(HandleType const *handle_to_check);
/// Lookup a handle.
/// Throws if not found.
InfoType *get(HandleType handle);
/// Lookup a handle, returning a pointer (if found) as well as a lock for this object's dispatch mutex.
std::pair<UniqueLock, InfoType *> getWithLock(HandleType handle);
bool empty() const { return info_map_.empty(); }
/// Insert an info for the supplied handle.
/// Throws if it's already there.
void insert(HandleType handle, std::unique_ptr<InfoType> &&info);
/// Remove the info associated with the supplied handle.
/// Throws if not found.
void erase(HandleType handle);
/// Get a constant reference to the whole map as well as a lock for this object's dispatch mutex.
std::pair<UniqueLock, map_t const &> lockMapConst();
/// Get a reference to the whole map as well as a lock for this object's dispatch mutex.
std::pair<UniqueLock, map_t &> lockMap();
protected:
map_t info_map_;
std::mutex dispatch_mutex_;
};
/// Subclass used exclusively for instances.
class InstanceHandleInfo : public HandleInfoBase<XrInstance, GenValidUsageXrInstanceInfo> {
public:
typedef HandleInfoBase<XrInstance, GenValidUsageXrInstanceInfo> base_t;
typedef typename base_t::info_t info_t;
typedef typename base_t::handle_t handle_t;
};
/// Generic handle info for everything-except-instance handles.
template <typename HandleType>
class HandleInfo : public HandleInfoBase<HandleType, GenValidUsageXrHandleInfo> {
public:
typedef HandleInfoBase<HandleType, GenValidUsageXrHandleInfo> base_t;
typedef typename base_t::info_t info_t;
typedef typename base_t::handle_t handle_t;
/// Lookup a handle and its instance info
/// Throws if not found.
std::pair<GenValidUsageXrHandleInfo *, GenValidUsageXrInstanceInfo *> getWithInstanceInfo(HandleType handle);
/// Removes handles associated with an instance.
void removeHandlesForInstance(GenValidUsageXrInstanceInfo *search_value);
};
/// Function to record all the core validation information
void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message);
void InvalidStructureType(GenValidUsageXrInstanceInfo *instance_info, const std::string &command_name,
std::vector<GenValidUsageXrObjectInfo> &objects_info, const char *structure_name, XrStructureType type,
const char *vuid = nullptr, XrStructureType expected = XrStructureType(0),
const char *expected_name = "");
// -- Only implementations of templates follow --//
template <typename HT, typename IT>
inline std::pair<UniqueLock, typename HandleInfoBase<HT, IT>::map_t const &> HandleInfoBase<HT, IT>::lockMapConst() {
return {UniqueLock(dispatch_mutex_), info_map_};
}
template <typename HT, typename IT>
inline std::pair<UniqueLock, typename HandleInfoBase<HT, IT>::map_t &> HandleInfoBase<HT, IT>::lockMap() {
return {UniqueLock(dispatch_mutex_), info_map_};
}
template <typename HandleType, typename InfoType>
inline ValidateXrHandleResult HandleInfoBase<HandleType, InfoType>::verifyHandle(HandleType const *handle_to_check) {
try {
if (nullptr == handle_to_check) {
return VALIDATE_XR_HANDLE_INVALID;
}
// XR_NULL_HANDLE is valid in some cases, so we want to return that we found that value
// and let the calling function decide what to do with it.
if (*handle_to_check == XR_NULL_HANDLE) {
return VALIDATE_XR_HANDLE_NULL;
}
// Try to find the handle in the appropriate map
UniqueLock lock(dispatch_mutex_);
auto entry_returned = info_map_.find(*handle_to_check);
// If it is not a valid handle, it should return the end of the map.
if (info_map_.end() == entry_returned) {
return VALIDATE_XR_HANDLE_INVALID;
}
return VALIDATE_XR_HANDLE_SUCCESS;
} catch (...) {
return VALIDATE_XR_HANDLE_INVALID;
}
}
template <typename HandleType, typename InfoType>
inline InfoType *HandleInfoBase<HandleType, InfoType>::get(HandleType handle) {
if (handle == XR_NULL_HANDLE) {
reportInternalError("Null handle passed to HandleInfoBase::get()");
}
// Try to find the handle in the appropriate map
UniqueLock lock(dispatch_mutex_);
auto entry_returned = info_map_.find(handle);
if (entry_returned == info_map_.end()) {
reportInternalError("Handle passed to HandleInfoBase::insert() not inserted");
}
return entry_returned->second.get();
}
template <typename HandleType, typename InfoType>
inline std::pair<UniqueLock, InfoType *> HandleInfoBase<HandleType, InfoType>::getWithLock(HandleType handle) {
if (handle == XR_NULL_HANDLE) {
reportInternalError("Null handle passed to HandleInfoBase::getWithLock()");
}
// Try to find the handle in the appropriate map
UniqueLock lock(dispatch_mutex_);
auto it = info_map_.find(handle);
// If it is not a valid handle, it should return the end of the map.
if (info_map_.end() == it) {
return {std::move(lock), nullptr};
}
return {std::move(lock), it->second.get()};
}
template <typename HandleType, typename InfoType>
inline void HandleInfoBase<HandleType, InfoType>::insert(HandleType handle, std::unique_ptr<InfoType> &&info) {
if (handle == XR_NULL_HANDLE) {
reportInternalError("Null handle passed to HandleInfoBase::insert()");
}
UniqueLock lock(dispatch_mutex_);
auto entry_returned = info_map_.find(handle);
if (entry_returned != info_map_.end()) {
reportInternalError("Handle passed to HandleInfoBase::insert() already inserted");
}
info_map_[handle] = std::move(info);
}
template <typename HandleType, typename InfoType>
inline void HandleInfoBase<HandleType, InfoType>::erase(HandleType handle) {
if (handle == XR_NULL_HANDLE) {
reportInternalError("Null handle passed to HandleInfoBase::erase()");
}
UniqueLock lock(dispatch_mutex_);
auto entry_returned = info_map_.find(handle);
if (entry_returned == info_map_.end()) {
reportInternalError("Handle passed to HandleInfoBase::insert() not inserted");
}
info_map_.erase(handle);
}
template <typename HandleType>
inline std::pair<GenValidUsageXrHandleInfo *, GenValidUsageXrInstanceInfo *> HandleInfo<HandleType>::getWithInstanceInfo(
HandleType handle) {
if (handle == XR_NULL_HANDLE) {
reportInternalError("Null handle passed to HandleInfoBase::getWithInstanceInfo()");
}
// Try to find the handle in the appropriate map
UniqueLock lock(this->dispatch_mutex_);
auto entry_returned = this->info_map_.find(handle);
if (entry_returned == this->info_map_.end()) {
reportInternalError("Handle passed to HandleInfoBase::getWithInstanceInfo() not inserted");
}
GenValidUsageXrHandleInfo *info = entry_returned->second.get();
GenValidUsageXrInstanceInfo *instance_info = info->instance_info;
return {info, instance_info};
}
template <typename HandleType>
inline void HandleInfo<HandleType>::removeHandlesForInstance(GenValidUsageXrInstanceInfo *search_value) {
typedef typename base_t::value_t value_t;
UniqueLock lock(this->dispatch_mutex_);
map_erase_if(this->info_map_, [=](value_t const &data) { return data.second && data.second->instance_info == search_value; });
}
#endif // VALIDATION_UTILS_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,156 @@
// *********** THIS FILE IS GENERATED - DO NOT EDIT ***********
// See validation_layer_generator.py for modifications
// ************************************************************
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#pragma once
#include "xr_generated_dispatch_table.h"
#include "validation_utils.h"
#include "api_layer_platform_defines.h"
#include "xr_dependencies.h"
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#include <vector>
#include <string>
#include <unordered_map>
#include <thread>
#include <mutex>
// Unordered Map associating pointer to a vector of session label information to a session's handle
extern std::unordered_map<XrSession, std::vector<GenValidUsageXrInternalSessionLabel*>*> g_xr_session_labels;
// ---- Core 1.0 commands
XrResult GenValidUsageXrGetInstanceProcAddr(
XrInstance instance,
const char* name,
PFN_xrVoidFunction* function);
XrResult CoreValidationXrCreateInstance(
const XrInstanceCreateInfo* createInfo,
XrInstance* instance);
XrResult GenValidUsageInputsXrCreateInstance(const XrInstanceCreateInfo* createInfo, XrInstance* instance);
XrResult GenValidUsageNextXrCreateInstance(
const XrInstanceCreateInfo* createInfo,
XrInstance* instance);
XrResult CoreValidationXrDestroyInstance(
XrInstance instance);
XrResult GenValidUsageInputsXrDestroyInstance(XrInstance instance);
XrResult GenValidUsageNextXrDestroyInstance(
XrInstance instance);
XrResult CoreValidationXrCreateSession(
XrInstance instance,
const XrSessionCreateInfo* createInfo,
XrSession* session);
XrResult GenValidUsageInputsXrCreateSession(XrInstance instance, const XrSessionCreateInfo* createInfo, XrSession* session);
XrResult GenValidUsageNextXrCreateSession(
XrInstance instance,
const XrSessionCreateInfo* createInfo,
XrSession* session);
// ---- XR_KHR_android_thread_settings extension commands
// ---- XR_KHR_android_surface_swapchain extension commands
// ---- XR_KHR_opengl_enable extension commands
// ---- XR_KHR_opengl_es_enable extension commands
// ---- XR_KHR_vulkan_enable extension commands
// ---- XR_KHR_D3D11_enable extension commands
// ---- XR_KHR_D3D12_enable extension commands
// ---- XR_KHR_visibility_mask extension commands
// ---- XR_KHR_win32_convert_performance_counter_time extension commands
// ---- XR_KHR_convert_timespec_time extension commands
// ---- XR_EXT_performance_settings extension commands
// ---- XR_EXT_thermal_query extension commands
// ---- XR_EXT_debug_utils extension commands
XrResult CoreValidationXrSetDebugUtilsObjectNameEXT(
XrInstance instance,
const XrDebugUtilsObjectNameInfoEXT* nameInfo);
XrResult GenValidUsageInputsXrSetDebugUtilsObjectNameEXT(XrInstance instance, const XrDebugUtilsObjectNameInfoEXT* nameInfo);
XrResult GenValidUsageNextXrSetDebugUtilsObjectNameEXT(
XrInstance instance,
const XrDebugUtilsObjectNameInfoEXT* nameInfo);
XrResult CoreValidationXrCreateDebugUtilsMessengerEXT(
XrInstance instance,
const XrDebugUtilsMessengerCreateInfoEXT* createInfo,
XrDebugUtilsMessengerEXT* messenger);
XrResult GenValidUsageInputsXrCreateDebugUtilsMessengerEXT(XrInstance instance, const XrDebugUtilsMessengerCreateInfoEXT* createInfo, XrDebugUtilsMessengerEXT* messenger);
XrResult GenValidUsageNextXrCreateDebugUtilsMessengerEXT(
XrInstance instance,
const XrDebugUtilsMessengerCreateInfoEXT* createInfo,
XrDebugUtilsMessengerEXT* messenger);
XrResult CoreValidationXrDestroyDebugUtilsMessengerEXT(
XrDebugUtilsMessengerEXT messenger);
XrResult GenValidUsageInputsXrDestroyDebugUtilsMessengerEXT(XrDebugUtilsMessengerEXT messenger);
XrResult GenValidUsageNextXrDestroyDebugUtilsMessengerEXT(
XrDebugUtilsMessengerEXT messenger);
XrResult CoreValidationXrSessionBeginDebugUtilsLabelRegionEXT(
XrSession session,
const XrDebugUtilsLabelEXT* labelInfo);
XrResult GenValidUsageInputsXrSessionBeginDebugUtilsLabelRegionEXT(XrSession session, const XrDebugUtilsLabelEXT* labelInfo);
XrResult GenValidUsageNextXrSessionBeginDebugUtilsLabelRegionEXT(
XrSession session,
const XrDebugUtilsLabelEXT* labelInfo);
XrResult CoreValidationXrSessionEndDebugUtilsLabelRegionEXT(
XrSession session);
XrResult GenValidUsageInputsXrSessionEndDebugUtilsLabelRegionEXT(XrSession session);
XrResult GenValidUsageNextXrSessionEndDebugUtilsLabelRegionEXT(
XrSession session);
XrResult CoreValidationXrSessionInsertDebugUtilsLabelEXT(
XrSession session,
const XrDebugUtilsLabelEXT* labelInfo);
XrResult GenValidUsageInputsXrSessionInsertDebugUtilsLabelEXT(XrSession session, const XrDebugUtilsLabelEXT* labelInfo);
XrResult GenValidUsageNextXrSessionInsertDebugUtilsLabelEXT(
XrSession session,
const XrDebugUtilsLabelEXT* labelInfo);
// Current API version of the Core Validation API Layer
#define XR_CORE_VALIDATION_API_VERSION XR_CURRENT_API_VERSION
// Externs for Core Validation
extern InstanceHandleInfo g_instance_info;
extern HandleInfo<XrSession> g_session_info;
extern HandleInfo<XrSpace> g_space_info;
extern HandleInfo<XrAction> g_action_info;
extern HandleInfo<XrSwapchain> g_swapchain_info;
extern HandleInfo<XrActionSet> g_actionset_info;
extern HandleInfo<XrDebugUtilsMessengerEXT> g_debugutilsmessengerext_info;void GenValidUsageCleanUpMaps(GenValidUsageXrInstanceInfo *instance_info);
// Function to convert XrObjectType to string
std::string GenValidUsageXrObjectTypeToString(const XrObjectType& type);
// Function to record all the core validation information
extern void CoreValidLogMessage(GenValidUsageXrInstanceInfo *instance_info, const std::string &message_id,
GenValidUsageDebugSeverity message_severity, const std::string &command_name,
std::vector<GenValidUsageXrObjectInfo> objects_info, const std::string &message);

View File

@@ -0,0 +1,86 @@
# ~~~
# Copyright (c) 2018-2019 Valve Corporation
# Copyright (c) 2018-2019 LunarG, Inc.
#
# 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.
# ~~~
#.rst:
# FindVulkanHeaders
# -----------------
#
# Try to find Vulkan Headers and Registry.
#
# This module is intended to be used by projects that build Vulkan
# "system" components such as the loader and layers.
# Vulkan applications should instead use the FindVulkan (or similar)
# find module that locates the headers and the loader library.
#
# When using this find module to locate the headers and registry
# in a Vulkan-Headers repository, the Vulkan-Headers repository
# should be built with 'install' target and the following environment
# or CMake variable set to the location of the install directory.
#
# VULKAN_HEADERS_INSTALL_DIR
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines no IMPORTED targets
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables::
#
# VulkanHeaders_FOUND - True if VulkanHeaders was found
# VulkanHeaders_INCLUDE_DIRS - include directories for VulkanHeaders
#
# VulkanRegistry_FOUND - True if VulkanRegistry was found
# VulkanRegistry_DIRS - directories for VulkanRegistry
#
# The module will also define two cache variables::
#
# VulkanHeaders_INCLUDE_DIR - the VulkanHeaders include directory
# VulkanRegistry_DIR - the VulkanRegistry directory
#
# Use HINTS instead of PATH to search these locations before
# searching system environment variables like $PATH that may
# contain SDK directories.
find_path(VulkanHeaders_INCLUDE_DIR
NAMES vulkan/vulkan.h
HINTS
${VULKAN_HEADERS_INSTALL_DIR}/include
"$ENV{VULKAN_HEADERS_INSTALL_DIR}/include"
"$ENV{VULKAN_SDK}/include")
if(VulkanHeaders_INCLUDE_DIR)
get_filename_component(VULKAN_REGISTRY_PATH_HINT ${VulkanHeaders_INCLUDE_DIR} DIRECTORY)
find_path(VulkanRegistry_DIR
NAMES vk.xml
HINTS "${VULKAN_REGISTRY_PATH_HINT}/share/vulkan/registry")
endif()
set(VulkanHeaders_INCLUDE_DIRS ${VulkanHeaders_INCLUDE_DIR})
set(VulkanRegistry_DIRS ${VulkanRegistry_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VulkanHeaders
DEFAULT_MSG
VulkanHeaders_INCLUDE_DIR)
find_package_handle_standard_args(VulkanRegistry
DEFAULT_MSG
VulkanRegistry_DIR)
mark_as_advanced(VulkanHeaders_INCLUDE_DIR VulkanRegistry_DIR)

View File

@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View File

@@ -0,0 +1,101 @@
set(PRESENTATION_BACKENDS xlib xcb wayland)
set(PRESENTATION_BACKEND xlib CACHE STRING
"Presentation backend chosen at configure time")
set_property(CACHE PRESENTATION_BACKEND PROPERTY STRINGS
${PRESENTATION_BACKENDS})
list(FIND PRESENTATION_BACKENDS ${PRESENTATION_BACKEND} index)
if(index EQUAL -1)
message(FATAL_ERROR "Presentation backend must be one of
${PRESENTATION_BACKENDS}")
endif()
message(STATUS "Using presentation backend: ${PRESENTATION_BACKEND}")
if( PRESENTATION_BACKEND MATCHES "xlib" )
find_package(X11 REQUIRED)
if ((NOT X11_Xxf86vm_LIB) OR (NOT X11_Xrandr_LIB))
message(FATAL_ERROR "OpenXR xlib backend requires Xxf86vm and Xrandr")
endif()
add_definitions( -DSUPPORT_X )
add_definitions( -DOS_LINUX_XLIB )
set( XLIB_LIBRARIES
${X11_LIBRARIES}
${X11_Xxf86vm_LIB}
${X11_Xrandr_LIB} )
elseif( PRESENTATION_BACKEND MATCHES "xcb" )
find_package(PkgConfig REQUIRED)
# XCB + XCB GLX is limited to OpenGL 2.1
# add_definitions( -DOS_LINUX_XCB )
# XCB + Xlib GLX 1.3
add_definitions( -DOS_LINUX_XCB_GLX )
pkg_search_module(X11 REQUIRED x11)
pkg_search_module(XCB REQUIRED xcb)
pkg_search_module(XCB_RANDR REQUIRED xcb-randr)
pkg_search_module(XCB_KEYSYMS REQUIRED xcb-keysyms)
pkg_search_module(XCB_GLX REQUIRED xcb-glx)
pkg_search_module(XCB_DRI2 REQUIRED xcb-dri2)
pkg_search_module(XCB_ICCCM REQUIRED xcb-icccm)
set( XCB_LIBRARIES
${XCB_LIBRARIES}
${XCB_KEYSYMS_LIBRARIES}
${XCB_RANDR_LIBRARIES}
${XCB_GLX_LIBRARIES}
${XCB_DRI2_LIBRARIES}
${X11_LIBRARIES} )
elseif( PRESENTATION_BACKEND MATCHES "wayland" )
find_package(PkgConfig REQUIRED)
pkg_search_module(WAYLAND_CLIENT REQUIRED wayland-client)
pkg_search_module(WAYLAND_EGL REQUIRED wayland-egl)
pkg_search_module(WAYLAND_SCANNER REQUIRED wayland-scanner)
pkg_search_module(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.7)
pkg_search_module(EGL REQUIRED egl)
add_definitions( -DOS_LINUX_WAYLAND )
set( WAYLAND_LIBRARIES
${EGL_LIBRARIES}
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_EGL_LIBRARIES} )
# generate wayland protocols
set(WAYLAND_PROTOCOLS_DIR ${CMAKE_SOURCE_DIR}/wayland-protocols/)
file(MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR})
pkg_get_variable(WAYLAND_PROTOCOLS_DATADIR wayland-protocols pkgdatadir)
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
set(PROTOCOL xdg-shell-unstable-v6)
set(PROTOCOL_XML
${WAYLAND_PROTOCOLS_DATADIR}/unstable/xdg-shell/${PROTOCOL}.xml)
if( EXISTS ${PROTOCOL_XML} )
execute_process(COMMAND
${WAYLAND_SCANNER}
code
${PROTOCOL_XML}
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c)
execute_process(COMMAND
${WAYLAND_SCANNER}
client-header
${PROTOCOL_XML}
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h)
set( WAYLAND_PROTOCOL_SRC
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.c
${WAYLAND_PROTOCOLS_DIR}/${PROTOCOL}.h )
include_directories(${WAYLAND_PROTOCOLS_DIR})
else()
message(FATAL_ERROR
"xdg-shell-unstable-v6.xml not found in "
${WAYLAND_PROTOCOLS_DATADIR}
"\nYour wayland-protocols package does not "
"contain xdg-shell-unstable-v6.")
endif()
endif()

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
// Copyright (c) 2019 Collabora, Ltd.
//
// 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.
//
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
//
/*!
* @file
*
* Additional functions along the lines of the standard library algorithms.
*/
#pragma once
#include <algorithm>
#include <vector>
/// Like std::remove_if, except it works on associative containers and it actually removes this.
///
/// The iterator stuff in here is subtle - .erase() invalidates only that iterator, but it returns a non-invalidated iterator to the
/// next valid element which we can use instead of incrementing.
template <typename T, typename Pred>
static inline void map_erase_if(T &container, Pred &&predicate) {
for (auto it = container.begin(); it != container.end();) {
if (predicate(*it)) {
it = container.erase(it);
} else {
++it;
}
}
}
/*!
* Moves all elements matching the predicate to the end of the vector then erases them.
*
* Combines the two parts of the erase-remove idiom to simplify things and avoid accidentally using the wrong erase overload.
*/
template <typename T, typename Alloc, typename Pred>
static inline void vector_remove_if_and_erase(std::vector<T, Alloc> &vec, Pred &&predicate) {
auto b = vec.begin();
auto e = vec.end();
vec.erase(std::remove_if(b, e, std::forward<Pred>(predicate)), e);
}

View File

@@ -0,0 +1,330 @@
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017 Valve Corporation
// Copyright (c) 2017 LunarG, Inc.
//
// 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.
//
// Authors: Mark Young <marky@lunarg.com>
// Nat Brown <natb@valvesoftware.com>
//
#include "filesystem_utils.hpp"
#include "platform_utils.hpp"
#ifdef _WIN32
#include "xr_dependencies.h"
#endif
#include <cstring>
#if defined DISABLE_STD_FILESYSTEM
#define USE_EXPERIMENTAL_FS 0
#define USE_FINAL_FS 0
#else
// If the C++ macro is set to the version containing C++17, it must support
// the final C++17 package
#if __cplusplus >= 201703L
#define USE_EXPERIMENTAL_FS 0
#define USE_FINAL_FS 1
#elif defined(_MSC_VER) && _MSC_VER >= 1900
#if defined(_HAS_CXX17) && _HAS_CXX17
// When MSC supports c++17 use <filesystem> package.
#define USE_EXPERIMENTAL_FS 0
#define USE_FINAL_FS 1
#endif // !_HAS_CXX17
// Right now, GCC still only supports the experimental filesystem items starting in GCC 6
#elif (__GNUC__ >= 6)
#define USE_EXPERIMENTAL_FS 1
#define USE_FINAL_FS 0
// If Clang, check for feature support
#elif defined(__clang__) && (__cpp_lib_filesystem || __cpp_lib_experimental_filesystem)
#if __cpp_lib_filesystem
#define USE_EXPERIMENTAL_FS 0
#define USE_FINAL_FS 1
#else
#define USE_EXPERIMENTAL_FS 1
#define USE_FINAL_FS 0
#endif
// If all above fails, fall back to standard C++ and OS-specific items
#else
#define USE_EXPERIMENTAL_FS 0
#define USE_FINAL_FS 0
#endif
#endif
#if USE_FINAL_FS == 1
#include <filesystem>
#define FS_PREFIX std::filesystem
#elif USE_EXPERIMENTAL_FS == 1
#include <experimental/filesystem>
#define FS_PREFIX std::experimental::filesystem
#elif defined(XR_USE_PLATFORM_WIN32)
// Windows fallback includes
#include <stdint.h>
#include <direct.h>
#else
// Linux/Apple fallback includes
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
#include <stdlib.h>
#include <dirent.h>
#endif
#if defined(XR_USE_PLATFORM_WIN32)
#define PATH_SEPARATOR ';'
#define DIRECTORY_SYMBOL '\\'
#else
#define PATH_SEPARATOR ':'
#define DIRECTORY_SYMBOL '/'
#endif
#if (USE_FINAL_FS == 1) || (USE_EXPERIMENTAL_FS == 1)
// We can use one of the C++ filesystem packages
bool FileSysUtilsIsRegularFile(const std::string& path) { return FS_PREFIX::is_regular_file(path); }
bool FileSysUtilsIsDirectory(const std::string& path) { return FS_PREFIX::is_directory(path); }
bool FileSysUtilsPathExists(const std::string& path) { return FS_PREFIX::exists(path); }
bool FileSysUtilsIsAbsolutePath(const std::string& path) {
FS_PREFIX::path file_path(path);
return file_path.is_absolute();
}
bool FileSysUtilsGetCurrentPath(std::string& path) {
FS_PREFIX::path cur_path = FS_PREFIX::current_path();
path = cur_path.string();
return true;
}
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
FS_PREFIX::path path_var(file_path);
parent_path = path_var.parent_path().string();
return true;
}
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
absolute = FS_PREFIX::absolute(path).string();
return true;
}
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
FS_PREFIX::path parent_path(parent);
FS_PREFIX::path child_path(child);
FS_PREFIX::path full_path = parent_path / child_path;
combined = full_path.string();
return true;
}
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
std::string::size_type start = 0;
std::string::size_type location = path_list.find(PATH_SEPARATOR);
while (location != std::string::npos) {
paths.push_back(path_list.substr(start, location));
start = location + 1;
location = path_list.find(PATH_SEPARATOR, start);
}
paths.push_back(path_list.substr(start, location));
return true;
}
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
for (auto& dir_iter : FS_PREFIX::directory_iterator(path)) {
files.push_back(dir_iter.path().filename().string());
}
return true;
}
#elif defined(XR_OS_WINDOWS)
// For pre C++17 compiler that doesn't support experimental filesystem
#include <shlwapi.h>
bool FileSysUtilsIsRegularFile(const std::string& path) { return (1 != PathIsDirectoryW(utf8_to_wide(path).c_str())); }
bool FileSysUtilsIsDirectory(const std::string& path) { return (1 == PathIsDirectoryW(utf8_to_wide(path).c_str())); }
bool FileSysUtilsPathExists(const std::string& path) { return (1 == PathFileExistsW(utf8_to_wide(path).c_str())); }
bool FileSysUtilsIsAbsolutePath(const std::string& path) {
if ((path[0] == '\\') || (path[1] == ':' && (path[2] == '\\' || path[2] == '/'))) {
return true;
}
return false;
}
bool FileSysUtilsGetCurrentPath(std::string& path) {
wchar_t tmp_path[MAX_PATH];
if (nullptr != _wgetcwd(tmp_path, MAX_PATH - 1)) {
path = wide_to_utf8(tmp_path);
return true;
}
return false;
}
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
std::string full_path;
if (FileSysUtilsGetAbsolutePath(file_path, full_path)) {
std::string::size_type lastSeperator = full_path.find_last_of(DIRECTORY_SYMBOL);
parent_path = (lastSeperator == 0) ? full_path : full_path.substr(0, lastSeperator);
return true;
}
return false;
}
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
wchar_t tmp_path[MAX_PATH];
if (0 != GetFullPathNameW(utf8_to_wide(path).c_str(), MAX_PATH, tmp_path, NULL)) {
absolute = wide_to_utf8(tmp_path);
return true;
}
return false;
}
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
std::string::size_type parent_len = parent.length();
if (0 == parent_len || "." == parent || ".\\" == parent || "./" == parent) {
combined = child;
return true;
}
char last_char = parent[parent_len - 1];
if (last_char == DIRECTORY_SYMBOL) {
parent_len--;
}
combined = parent.substr(0, parent_len) + DIRECTORY_SYMBOL + child;
return true;
}
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
std::string::size_type start = 0;
std::string::size_type location = path_list.find(PATH_SEPARATOR);
while (location != std::string::npos) {
paths.push_back(path_list.substr(start, location));
start = location + 1;
location = path_list.find(PATH_SEPARATOR, start);
}
paths.push_back(path_list.substr(start, location));
return true;
}
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
WIN32_FIND_DATAW file_data;
HANDLE file_handle = FindFirstFileW(utf8_to_wide(path).c_str(), &file_data);
if (file_handle != INVALID_HANDLE_VALUE) {
do {
if (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
files.push_back(wide_to_utf8(file_data.cFileName));
}
} while (FindNextFileW(file_handle, &file_data));
return true;
}
return false;
}
#else // XR_OS_LINUX/XR_OS_APPLE fallback
// simple POSIX-compatible implementation of the <filesystem> pieces used by OpenXR
bool FileSysUtilsIsRegularFile(const std::string& path) {
struct stat path_stat;
stat(path.c_str(), &path_stat);
return S_ISREG(path_stat.st_mode);
}
bool FileSysUtilsIsDirectory(const std::string& path) {
struct stat path_stat;
stat(path.c_str(), &path_stat);
return S_ISDIR(path_stat.st_mode);
}
bool FileSysUtilsPathExists(const std::string& path) { return (access(path.c_str(), F_OK) != -1); }
bool FileSysUtilsIsAbsolutePath(const std::string& path) { return (path[0] == DIRECTORY_SYMBOL); }
bool FileSysUtilsGetCurrentPath(std::string& path) {
char tmp_path[PATH_MAX];
if (nullptr != getcwd(tmp_path, PATH_MAX - 1)) {
path = tmp_path;
return true;
}
return false;
}
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path) {
std::string full_path;
if (FileSysUtilsGetAbsolutePath(file_path, full_path)) {
std::string::size_type lastSeperator = full_path.find_last_of(DIRECTORY_SYMBOL);
parent_path = (lastSeperator == 0) ? full_path : full_path.substr(0, lastSeperator);
return true;
}
return false;
}
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute) {
char buf[PATH_MAX];
if (nullptr != realpath(path.c_str(), buf)) {
absolute = buf;
return true;
}
return false;
}
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined) {
std::string::size_type parent_len = parent.length();
if (0 == parent_len || "." == parent || "./" == parent) {
combined = child;
return true;
}
char last_char = parent[parent_len - 1];
if (last_char == DIRECTORY_SYMBOL) {
parent_len--;
}
combined = parent.substr(0, parent_len) + DIRECTORY_SYMBOL + child;
return true;
}
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths) {
std::string::size_type start = 0;
std::string::size_type location = path_list.find(PATH_SEPARATOR);
while (location != std::string::npos) {
paths.push_back(path_list.substr(start, location));
start = location + 1;
location = path_list.find(PATH_SEPARATOR, start);
}
paths.push_back(path_list.substr(start, location));
return true;
}
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files) {
DIR* dir = opendir(path.c_str());
if (dir == nullptr) {
return false;
}
struct dirent* entry;
while ((entry = readdir(dir)) != nullptr) {
files.emplace_back(entry->d_name);
}
closedir(dir);
return true;
}
#endif

View File

@@ -0,0 +1,53 @@
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017 Valve Corporation
// Copyright (c) 2017 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#pragma once
#include <string>
#include <vector>
// Determine if the path indicates a regular file (not a directory or symbolic link)
bool FileSysUtilsIsRegularFile(const std::string& path);
// Determine if the path indicates a directory
bool FileSysUtilsIsDirectory(const std::string& path);
// Determine if the provided path exists on the filesystem
bool FileSysUtilsPathExists(const std::string& path);
// Get the current directory of the executable
bool FileSysUtilsGetCurrentPath(std::string& path);
// Get the parent path of a file
bool FileSysUtilsGetParentPath(const std::string& file_path, std::string& parent_path);
// Determine if the provided path is an absolute path
bool FileSysUtilsIsAbsolutePath(const std::string& path);
// Get the absolute path for a provided file
bool FileSysUtilsGetAbsolutePath(const std::string& path, std::string& absolute);
// Combine a parent and child directory
bool FileSysUtilsCombinePaths(const std::string& parent, const std::string& child, std::string& combined);
// Parse out individual paths in a path list
bool FileSysUtilsParsePathList(std::string& path_list, std::vector<std::string>& paths);
// Record all the filenames for files found in the provided path.
bool FileSysUtilsFindFilesInPath(const std::string& path, std::vector<std::string>& files);

View File

@@ -0,0 +1,44 @@
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
// Copyright (c) 2019 Collabora, Ltd.
//
// 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.
//
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
//
/*!
* @file
*
* Implementations of the include-requiring hex conversion functions.
*/
#include "hex_and_handles.h"
#include <sstream>
#include <iomanip>
std::string Uint64ToHexString(uint64_t val) {
std::ostringstream oss;
oss << "0x";
oss << std::hex << std::setw(16) << std::setfill('0') << val;
return oss.str();
}
std::string Uint32ToHexString(uint32_t val) {
std::ostringstream oss;
oss << "0x";
oss << std::hex << std::setw(8) << std::setfill('0') << val;
return oss.str();
}

View File

@@ -0,0 +1,108 @@
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
// Copyright (c) 2019 Collabora, Ltd.
//
// 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.
//
// Author: Ryan Pavlik <ryan.pavlik@collabora.com>
//
/*!
* @file
*
* Some utilities, primarily for working with OpenXR handles in a generic way.
*
* Most are trivial and inlined by default, but a few involve some non-trivial standard headers:
* the various `...ToHexString`functions.
* If you want those, make sure your build includes the corresponding hex_and_handles.cpp file.
*/
#pragma once
#include <openxr/openxr.h>
#include <string>
#include <stdint.h>
#if XR_PTR_SIZE == 8
/// Convert a handle into a same-sized integer.
template <typename T>
static inline uint64_t MakeHandleGeneric(T handle) {
return reinterpret_cast<uint64_t>(handle);
}
/// Treat an integer as a handle
template <typename T>
static inline T& TreatIntegerAsHandle(uint64_t& handle) {
return reinterpret_cast<T&>(handle);
}
/// @overload
template <typename T>
static inline T const& TreatIntegerAsHandle(uint64_t const& handle) {
return reinterpret_cast<T const&>(handle);
}
/// Does a correctly-sized integer represent a null handle?
static inline bool IsIntegerNullHandle(uint64_t handle) { return XR_NULL_HANDLE == reinterpret_cast<void*>(handle); }
#else
/// Convert a handle into a same-sized integer: no-op on 32-bit systems
static inline uint64_t MakeHandleGeneric(uint64_t handle) { return handle; }
/// Treat an integer as a handle: no-op on 32-bit systems
template <typename T>
static inline T& TreatIntegerAsHandle(uint64_t& handle) {
return handle;
}
/// @overload
template <typename T>
static inline T const& TreatIntegerAsHandle(uint64_t const& handle) {
return handle;
}
/// Does a correctly-sized integer represent a null handle?
static inline bool IsIntegerNullHandle(uint64_t handle) { return XR_NULL_HANDLE == handle; }
#endif
/// Turns a uint64_t into a string formatted as hex.
///
/// The core of the HandleToHexString implementation is in here.
std::string Uint64ToHexString(uint64_t val);
/// Turns a uint32_t into a string formatted as hex.
std::string Uint32ToHexString(uint32_t val);
/// Turns an OpenXR handle into a string formatted as hex.
template <typename T>
static inline std::string HandleToHexString(T handle) {
return Uint64ToHexString(MakeHandleGeneric(handle));
}
#if XR_PTR_SIZE == 8
/// Turns a pointer-sized integer into a string formatted as hex.
static inline std::string UintptrToHexString(uintptr_t val) { return Uint64ToHexString(val); }
#else
/// Turns a pointer-sized integer into a string formatted as hex.
static inline std::string UintptrToHexString(uintptr_t val) { return Uint32ToHexString(val); }
#endif
/// Convert a pointer to a string formatted as hex.
template <typename T>
static inline std::string PointerToHexString(T const* ptr) {
return UintptrToHexString(reinterpret_cast<uintptr_t>(ptr));
}

View File

@@ -0,0 +1,122 @@
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017 Valve Corporation
// Copyright (c) 2017 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
// Forward declare.
typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo;
// Function pointer prototype for the xrCreateApiLayerInstance function used in place of xrCreateInstance.
// This function allows us to pass special API layer information to each layer during the process of creating an Instance.
typedef XrResult(XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo *info,
const XrApiLayerCreateInfo *apiLayerInfo, XrInstance *instance);
// Loader/API Layer Interface versions
// 1 - First version, introduces negotiation structure and functions
#define XR_CURRENT_LOADER_API_LAYER_VERSION 1
// Loader/Runtime Interface versions
// 1 - First version, introduces negotiation structure and functions
#define XR_CURRENT_LOADER_RUNTIME_VERSION 1
// Version negotiation values
typedef enum XrLoaderInterfaceStructs {
XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0,
XR_LOADER_INTERFACE_STRUCT_LOADER_INFO,
XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST,
XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST,
XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO,
XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO,
} XrLoaderInterfaceStructs;
#define XR_LOADER_INFO_STRUCT_VERSION 1
typedef struct XrNegotiateLoaderInfo {
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_LOADER_INFO
uint32_t structVersion; // XR_LOADER_INFO_STRUCT_VERSION
size_t structSize; // sizeof(XrNegotiateLoaderInfo)
uint32_t minInterfaceVersion;
uint32_t maxInterfaceVersion;
XrVersion minApiVersion;
XrVersion maxApiVersion;
} XrNegotiateLoaderInfo;
#define XR_API_LAYER_INFO_STRUCT_VERSION 1
typedef struct XrNegotiateApiLayerRequest {
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST
uint32_t structVersion; // XR_API_LAYER_INFO_STRUCT_VERSION
size_t structSize; // sizeof(XrNegotiateApiLayerRequest)
uint32_t layerInterfaceVersion; // CURRENT_LOADER_API_LAYER_VERSION
XrVersion layerApiVersion;
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
PFN_xrCreateApiLayerInstance createApiLayerInstance;
} XrNegotiateApiLayerRequest;
#define XR_RUNTIME_INFO_STRUCT_VERSION 1
typedef struct XrNegotiateRuntimeRequest {
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST
uint32_t structVersion; // XR_RUNTIME_INFO_STRUCT_VERSION
size_t structSize; // sizeof(XrNegotiateRuntimeRequest)
uint32_t runtimeInterfaceVersion; // CURRENT_LOADER_RUNTIME_VERSION
XrVersion runtimeApiVersion;
PFN_xrGetInstanceProcAddr getInstanceProcAddr;
} XrNegotiateRuntimeRequest;
// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
// more API layers needs to expose at least this function.
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo *loaderInfo,
const char *apiLayerName,
XrNegotiateApiLayerRequest *apiLayerRequest);
// Function used to negotiate an interface betewen the loader and a runtime. Each runtime should expose
// at least this function.
typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo *loaderInfo,
XrNegotiateRuntimeRequest *runtimeRequest);
// Forward declare.
typedef struct XrApiLayerNextInfo XrApiLayerNextInfo;
#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1
struct XrApiLayerNextInfo {
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO
uint32_t structVersion; // XR_API_LAYER_NEXT_INFO_STRUCT_VERSION
size_t structSize; // sizeof(XrApiLayerNextInfo)
char layerName[XR_MAX_API_LAYER_NAME_SIZE]; // Name of API layer which should receive this info
PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr; // Pointer to next API layer's xrGetInstanceProcAddr
PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance; // Pointer to next API layer's xrCreateApiLayerInstance
XrApiLayerNextInfo *next; // Pointer to the next API layer info in the sequence
};
#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512
#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1
typedef struct XrApiLayerCreateInfo {
XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO
uint32_t structVersion; // XR_API_LAYER_CREATE_INFO_STRUCT_VERSION
size_t structSize; // sizeof(XrApiLayerCreateInfo)
void *loaderInstance; // Pointer to the LoaderInstance class
char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE]; // Location to the found settings file (or empty '\0')
XrApiLayerNextInfo *nextInfo; // Pointer to the next API layer's Info
} XrApiLayerCreateInfo;
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -0,0 +1,221 @@
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017 Valve Corporation
// Copyright (c) 2017 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#pragma once
#include "xr_dependencies.h"
#include <string>
#if defined(XR_OS_LINUX)
#include <unistd.h>
#include <fcntl.h>
#include <iostream>
#endif
// This is a CMake generated file with #defines for any functions/includes
// that it found present. This is currently necessary to properly determine
// if secure_getenv or __secure_getenv are present
#if !defined(OPENXR_NON_CMAKE_BUILD)
#include "common_cmake_config.h"
#endif // !defined(OPENXR_NON_CMAKE_BUILD)
// Environment variables
#if defined(XR_OS_LINUX)
static inline char* PlatformUtilsGetEnv(const char* name) { return getenv(name); }
static inline char* PlatformUtilsGetSecureEnv(const char* name) {
#ifdef HAVE_SECURE_GETENV
return secure_getenv(name);
#elif defined(HAVE___SECURE_GETENV)
return __secure_getenv(name);
#else
#pragma message( \
"Warning: Falling back to non-secure getenv for environmental" \
"lookups! Consider updating to a different libc.")
return PlatformUtilsGetEnv(name);
#endif
}
static inline void PlatformUtilsFreeEnv(const char* val) {
// No freeing of memory necessary for Linux, but we should at least touch
// the val and inst pointers to get rid of compiler warnings.
(void)val;
}
#elif defined(XR_OS_APPLE)
static inline char *PlatformUtilsGetEnv(const char *name) { return getenv(name); }
static inline char *PlatformUtilsGetSecureEnv(const char *name) {
#ifdef HAVE_SECURE_GETENV
return secure_getenv(name);
#elif defined(HAVE___SECURE_GETENV)
return __secure_getenv(name);
#else
#pragma message( \
"Warning: Falling back to non-secure getenv for environmental" \
"lookups! Consider updating to a different libc.")
return PlatformUtilsGetEnv(name);
#endif
}
static inline void PlatformUtilsFreeEnv(char *val) {
// No freeing of memory necessary for Linux, but we should at least touch
// the val and inst pointers to get rid of compiler warnings.
(void)val;
}
// Prefix for the Apple global runtime JSON file name
static const std::string rt_dir_prefix = "/usr/local/share/openxr/";
static const std::string rt_filename = "/active_runtime.json";
static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string &file_name) {
file_name = rt_dir_prefix;
file_name += std::to_string(major_version);
file_name += rt_filename;
return true;
}
#elif defined(XR_OS_WINDOWS)
#if defined(_DEBUG)
inline void LogError(const std::string& error) { OutputDebugStringA(error.c_str()); }
#else
#define LogError(x)
#endif
inline std::wstring utf8_to_wide(const std::string& utf8Text) {
if (utf8Text.empty()) {
return {};
}
std::wstring wideText;
const int wideLength = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (int)utf8Text.size(), nullptr, 0);
if (wideLength == 0) {
LogError("utf8_to_wide get size error: " + std::to_string(::GetLastError()));
return {};
}
// MultiByteToWideChar returns number of chars of the input buffer, regardless of null terminitor
wideText.resize(wideLength, 0);
wchar_t* wideString = const_cast<wchar_t*>(wideText.data()); // mutable data() only exists in c++17
const int length = ::MultiByteToWideChar(CP_UTF8, 0, utf8Text.data(), (int)utf8Text.size(), wideString, wideLength);
if (length != wideLength) {
LogError("utf8_to_wide convert string error: " + std::to_string(::GetLastError()));
return {};
}
return wideText;
}
inline std::string wide_to_utf8(const std::wstring& wideText) {
if (wideText.empty()) {
return {};
}
std::string narrowText;
int narrowLength = ::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (int)wideText.size(), nullptr, 0, nullptr, nullptr);
if (narrowLength == 0) {
LogError("wide_to_utf8 get size error: " + std::to_string(::GetLastError()));
return {};
}
// WideCharToMultiByte returns number of chars of the input buffer, regardless of null terminitor
narrowText.resize(narrowLength, 0);
char* narrowString = const_cast<char*>(narrowText.data()); // mutable data() only exists in c++17
const int length =
::WideCharToMultiByte(CP_UTF8, 0, wideText.data(), (int)wideText.size(), narrowString, narrowLength, nullptr, nullptr);
if (length != narrowLength) {
LogError("wide_to_utf8 convert string error: " + std::to_string(::GetLastError()));
return {};
}
return narrowText;
}
static inline char* PlatformUtilsGetEnv(const char* name) {
const std::wstring wname = utf8_to_wide(name);
const DWORD valSize = ::GetEnvironmentVariableW(wname.c_str(), nullptr, 0);
// GetEnvironmentVariable returns 0 when environment variable does not exist
if (valSize == 0) {
return nullptr;
}
// GetEnvironmentVariable returns size including null terminator for "query size" call.
std::wstring wValue(valSize, 0);
wchar_t* wValueData = const_cast<wchar_t*>(wValue.data()); // mutable data() only exists in c++17
// GetEnvironmentVariable returns string length, excluding null terminator for "get value" call.
const int length = ::GetEnvironmentVariableW(wname.c_str(), wValueData, (DWORD)wValue.size());
if (!length) {
LogError("GetEnvironmentVariable get value error: " + std::to_string(::GetLastError()));
return nullptr;
}
const std::string value = wide_to_utf8(wValue);
// Allocate the space necessary for the result
char* retVal = new char[value.size() + 1]{};
value.copy(retVal, value.size());
return retVal;
}
static inline char* PlatformUtilsGetSecureEnv(const char* name) {
// No secure version for Windows as far as I know
return PlatformUtilsGetEnv(name);
}
static inline void PlatformUtilsFreeEnv(char* val) {
if (nullptr != val) {
delete[] val;
val = nullptr;
}
}
#else // Not Linux or Windows
static inline char *PlatformUtilsGetEnv(const char *name) {
// Stub func
(void)name;
return nullptr;
}
static inline char *PlatformUtilsGetSecureEnv(const char *name) {
// Stub func
(void)name;
return nullptr;
}
static inline void PlatformUtilsFreeEnv(char *val) {
// Stub func
(void)val;
}
static inline bool PlatformGetGlobalRuntimeFileName(uint16_t major_version, std::string &file_name) {
// Stub func
(void)major_version;
(void)file_name;
return false;
}
#endif

View File

@@ -0,0 +1,78 @@
// Copyright (c) 2018-2019 The Khronos Group Inc.
//
// 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.
//
// This file includes headers with types which openxr.h depends on in order
// to compile when platforms, graphics apis, and the like are enabled.
#pragma once
#ifdef XR_USE_PLATFORM_ANDROID
#include <android/native_window.h>
#endif // XR_USE_PLATFORM_ANDROID
#ifdef XR_USE_PLATFORM_WIN32
#include <winapifamily.h>
#if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM))
// Enable desktop partition APIs, such as RegOpenKeyEx, LoadLibraryEx, PathFileExists etc.
#undef WINAPI_PARTITION_DESKTOP
#define WINAPI_PARTITION_DESKTOP 1
#endif
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif // XR_USE_PLATFORM_WIN32
#ifdef XR_USE_GRAPHICS_API_D3D11
#include <d3d11.h>
#endif // XR_USE_GRAPHICS_API_D3D11
#ifdef XR_USE_GRAPHICS_API_D3D12
#include <d3d12.h>
#endif // XR_USE_GRAPHICS_API_D3D12
#ifdef XR_USE_PLATFORM_XLIB
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#endif // XR_USE_PLATFORM_XLIB
#ifdef XR_USE_PLATFORM_XCB
#include <xcb/xcb.h>
#endif // XR_USE_PLATFORM_XCB
#ifdef XR_USE_GRAPHICS_API_OPENGL
#if defined(XR_USE_PLATFORM_XLIB) || defined(XR_USE_PLATFORM_XCB)
#include <GL/glx.h>
#endif // (XR_USE_PLATFORM_XLIB || XR_USE_PLATFORM_XCB)
#ifdef XR_USE_PLATFORM_XCB
#include <xcb/glx.h>
#endif // XR_USE_PLATFORM_XCB
#ifdef XR_USE_PLATFORM_MACOS
#include <CL/cl_gl_ext.h>
#endif // XR_USE_PLATFORM_MACOS
#endif // XR_USE_GRAPHICS_API_OPENGL
#ifdef XR_USE_GRAPHICS_API_OPENGL_ES
#include <EGL/egl.h>
#endif // XR_USE_GRAPHICS_API_OPENGL_ES
#ifdef XR_USE_GRAPHICS_API_VULKAN
#include <vulkan/vulkan.h>
#endif // XR_USE_GRAPHICS_API_VULKAN
#ifdef XR_USE_PLATFORM_WAYLAND
#include "wayland-client.h"
#endif // XR_USE_PLATFORM_WAYLAND

773
extern/openxr/src/common/xr_linear.h vendored Normal file
View File

@@ -0,0 +1,773 @@
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2016 Oculus VR, LLC.
//
// 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.
//
// Author: J.M.P. van Waveren
//
#ifndef XR_LINEAR_H_
#define XR_LINEAR_H_
#if defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) || defined(OS_LINUX_WAYLAND)
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunused-function"
#endif
#include <openxr/openxr.h>
/*
================================================================================================
Description : Vector, matrix and quaternion math.
Author : J.M.P. van Waveren
Date : 12/10/2016
Language : C99
Format : Indent 4 spaces - no tabs.
Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved.
DESCRIPTION
===========
All matrices are column-major.
INTERFACE
=========
XrVector2f
XrVector3f
XrVector4f
XrQuaternionf
XrMatrix4x4f
inline static void XrVector3f_Set(XrVector3f* v, const float value);
inline static void XrVector3f_Add(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
inline static void XrVector3f_Sub(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
inline static void XrVector3f_Min(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
inline static void XrVector3f_Max(XrVector3f* result, const XrVector3f* a, const XrVector3f* b);
inline static void XrVector3f_Decay(XrVector3f* result, const XrVector3f* a, const float value);
inline static void XrVector3f_Lerp(XrVector3f* result, const XrVector3f* a, const XrVector3f* b, const float fraction);
inline static void XrVector3f_Normalize(XrVector3f* v);
inline static float XrVector3f_Length(const XrVector3f* v);
inline static void XrQuaternionf_Lerp(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b, const float fraction);
inline static void XrMatrix4x4f_CreateIdentity(XrMatrix4x4f* result);
inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const float x, const float y, const float z);
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
const float degreesZ);
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z);
inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* result, const XrVector3f* translation,
const XrQuaternionf* rotation, const XrVector3f* scale);
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, const float tanAngleLeft, const float tanAngleRight,
const float tanAngleUp, float const tanAngleDown, const float nearZ,
const float farZ);
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, const float fovDegreesLeft, const float fovDegreesRight,
const float fovDegreeUp, const float fovDegreesDown, const float nearZ,
const float farZ);
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* src);
inline static void XrMatrix4x4f_CreateOffsetScaleForBounds(XrMatrix4x4f* result, const XrMatrix4x4f* matrix, const XrVector3f* mins,
const XrVector3f* maxs);
inline static bool XrMatrix4x4f_IsAffine(const XrMatrix4x4f* matrix, const float epsilon);
inline static bool XrMatrix4x4f_IsOrthogonal(const XrMatrix4x4f* matrix, const float epsilon);
inline static bool XrMatrix4x4f_IsOrthonormal(const XrMatrix4x4f* matrix, const float epsilon);
inline static bool XrMatrix4x4f_IsRigidBody(const XrMatrix4x4f* matrix, const float epsilon);
inline static void XrMatrix4x4f_GetTranslation(XrVector3f* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_GetRotation(XrQuaternionf* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_GetScale(XrVector3f* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_Multiply(XrMatrix4x4f* result, const XrMatrix4x4f* a, const XrMatrix4x4f* b);
inline static void XrMatrix4x4f_Transpose(XrMatrix4x4f* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_Invert(XrMatrix4x4f* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_InvertRigidBody(XrMatrix4x4f* result, const XrMatrix4x4f* src);
inline static void XrMatrix4x4f_TransformVector3f(XrVector3f* result, const XrMatrix4x4f* m, const XrVector3f* v);
inline static void XrMatrix4x4f_TransformVector4f(XrVector4f* result, const XrMatrix4x4f* m, const XrVector4f* v);
inline static void XrMatrix4x4f_TransformBounds(XrVector3f* resultMins, XrVector3f* resultMaxs, const XrMatrix4x4f* matrix,
const XrVector3f* mins, const XrVector3f* maxs);
inline static bool XrMatrix4x4f_CullBounds(const XrMatrix4x4f* mvp, const XrVector3f* mins, const XrVector3f* maxs);
================================================================================================
*/
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#define MATH_PI 3.14159265358979323846f
#define DEFAULT_NEAR_Z 0.015625f // exact floating point representation
#define INFINITE_FAR_Z 0.0f
static const XrColor4f XrColorRed = {1.0f, 0.0f, 0.0f, 1.0f};
static const XrColor4f XrColorGreen = {0.0f, 1.0f, 0.0f, 1.0f};
static const XrColor4f XrColorBlue = {0.0f, 0.0f, 1.0f, 1.0f};
static const XrColor4f XrColorYellow = {1.0f, 1.0f, 0.0f, 1.0f};
static const XrColor4f XrColorPurple = {1.0f, 0.0f, 1.0f, 1.0f};
static const XrColor4f XrColorCyan = {0.0f, 1.0f, 1.0f, 1.0f};
static const XrColor4f XrColorLightGrey = {0.7f, 0.7f, 0.7f, 1.0f};
static const XrColor4f XrColorDarkGrey = {0.3f, 0.3f, 0.3f, 1.0f};
enum GraphicsAPI { GRAPHICS_VULKAN, GRAPHICS_OPENGL, GRAPHICS_OPENGL_ES, GRAPHICS_D3D };
// Column-major, pre-multiplied. This type does not exist in the OpenXR API and is provided for convenience.
struct XrMatrix4x4f {
float m[16];
};
inline static float XrRcpSqrt(const float x) {
const float SMALLEST_NON_DENORMAL = 1.1754943508222875e-038f; // ( 1U << 23 )
const float rcp = (x >= SMALLEST_NON_DENORMAL) ? 1.0f / sqrtf(x) : 1.0f;
return rcp;
}
inline static void XrVector3f_Set(XrVector3f* v, const float value) {
v->x = value;
v->y = value;
v->z = value;
}
inline static void XrVector3f_Add(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
result->x = a->x + b->x;
result->y = a->y + b->y;
result->z = a->z + b->z;
}
inline static void XrVector3f_Sub(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
result->x = a->x - b->x;
result->y = a->y - b->y;
result->z = a->z - b->z;
}
inline static void XrVector3f_Min(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
result->x = (a->x < b->x) ? a->x : b->x;
result->y = (a->y < b->y) ? a->y : b->y;
result->z = (a->z < b->z) ? a->z : b->z;
}
inline static void XrVector3f_Max(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
result->x = (a->x > b->x) ? a->x : b->x;
result->y = (a->y > b->y) ? a->y : b->y;
result->z = (a->z > b->z) ? a->z : b->z;
}
inline static void XrVector3f_Decay(XrVector3f* result, const XrVector3f* a, const float value) {
result->x = (fabsf(a->x) > value) ? ((a->x > 0.0f) ? (a->x - value) : (a->x + value)) : 0.0f;
result->y = (fabsf(a->y) > value) ? ((a->y > 0.0f) ? (a->y - value) : (a->y + value)) : 0.0f;
result->z = (fabsf(a->z) > value) ? ((a->z > 0.0f) ? (a->z - value) : (a->z + value)) : 0.0f;
}
inline static void XrVector3f_Lerp(XrVector3f* result, const XrVector3f* a, const XrVector3f* b, const float fraction) {
result->x = a->x + fraction * (b->x - a->x);
result->y = a->y + fraction * (b->y - a->y);
result->z = a->z + fraction * (b->z - a->z);
}
inline static float XrVector3f_Dot(const XrVector3f* a, const XrVector3f* b) { return a->x * b->x + a->y * b->y + a->z * b->z; }
// Compute cross product, which generates a normal vector.
// Direction vector can be determined by right-hand rule: Pointing index finder in
// direction a and middle finger in direction b, thumb will point in Cross(a, b).
inline static void XrVector3f_Cross(XrVector3f* result, const XrVector3f* a, const XrVector3f* b) {
result->x = a->y * b->z - a->z * b->y;
result->y = a->z * b->x - a->x * b->z;
result->x = a->x * b->y - a->y * b->x;
}
inline static void XrVector3f_Normalize(XrVector3f* v) {
const float lengthRcp = XrRcpSqrt(v->x * v->x + v->y * v->y + v->z * v->z);
v->x *= lengthRcp;
v->y *= lengthRcp;
v->z *= lengthRcp;
}
inline static float XrVector3f_Length(const XrVector3f* v) { return sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); }
inline static void XrQuaternionf_CreateFromAxisAngle(XrQuaternionf* result, const XrVector3f* axis, const float angleInRadians) {
float s = sinf(angleInRadians / 2.0f);
float lengthRcp = XrRcpSqrt(axis->x * axis->x + axis->y * axis->y + axis->z * axis->z);
result->x = s * axis->x * lengthRcp;
result->y = s * axis->y * lengthRcp;
result->z = s * axis->z * lengthRcp;
result->w = cosf(angleInRadians / 2.0f);
}
inline static void XrQuaternionf_Lerp(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b, const float fraction) {
const float s = a->x * b->x + a->y * b->y + a->z * b->z + a->w * b->w;
const float fa = 1.0f - fraction;
const float fb = (s < 0.0f) ? -fraction : fraction;
const float x = a->x * fa + b->x * fb;
const float y = a->y * fa + b->y * fb;
const float z = a->z * fa + b->z * fb;
const float w = a->w * fa + b->w * fb;
const float lengthRcp = XrRcpSqrt(x * x + y * y + z * z + w * w);
result->x = x * lengthRcp;
result->y = y * lengthRcp;
result->z = z * lengthRcp;
result->w = w * lengthRcp;
}
// Use left-multiplication to accumulate transformations.
inline static void XrMatrix4x4f_Multiply(XrMatrix4x4f* result, const XrMatrix4x4f* a, const XrMatrix4x4f* b) {
result->m[0] = a->m[0] * b->m[0] + a->m[4] * b->m[1] + a->m[8] * b->m[2] + a->m[12] * b->m[3];
result->m[1] = a->m[1] * b->m[0] + a->m[5] * b->m[1] + a->m[9] * b->m[2] + a->m[13] * b->m[3];
result->m[2] = a->m[2] * b->m[0] + a->m[6] * b->m[1] + a->m[10] * b->m[2] + a->m[14] * b->m[3];
result->m[3] = a->m[3] * b->m[0] + a->m[7] * b->m[1] + a->m[11] * b->m[2] + a->m[15] * b->m[3];
result->m[4] = a->m[0] * b->m[4] + a->m[4] * b->m[5] + a->m[8] * b->m[6] + a->m[12] * b->m[7];
result->m[5] = a->m[1] * b->m[4] + a->m[5] * b->m[5] + a->m[9] * b->m[6] + a->m[13] * b->m[7];
result->m[6] = a->m[2] * b->m[4] + a->m[6] * b->m[5] + a->m[10] * b->m[6] + a->m[14] * b->m[7];
result->m[7] = a->m[3] * b->m[4] + a->m[7] * b->m[5] + a->m[11] * b->m[6] + a->m[15] * b->m[7];
result->m[8] = a->m[0] * b->m[8] + a->m[4] * b->m[9] + a->m[8] * b->m[10] + a->m[12] * b->m[11];
result->m[9] = a->m[1] * b->m[8] + a->m[5] * b->m[9] + a->m[9] * b->m[10] + a->m[13] * b->m[11];
result->m[10] = a->m[2] * b->m[8] + a->m[6] * b->m[9] + a->m[10] * b->m[10] + a->m[14] * b->m[11];
result->m[11] = a->m[3] * b->m[8] + a->m[7] * b->m[9] + a->m[11] * b->m[10] + a->m[15] * b->m[11];
result->m[12] = a->m[0] * b->m[12] + a->m[4] * b->m[13] + a->m[8] * b->m[14] + a->m[12] * b->m[15];
result->m[13] = a->m[1] * b->m[12] + a->m[5] * b->m[13] + a->m[9] * b->m[14] + a->m[13] * b->m[15];
result->m[14] = a->m[2] * b->m[12] + a->m[6] * b->m[13] + a->m[10] * b->m[14] + a->m[14] * b->m[15];
result->m[15] = a->m[3] * b->m[12] + a->m[7] * b->m[13] + a->m[11] * b->m[14] + a->m[15] * b->m[15];
}
// Creates the transpose of the given matrix.
inline static void XrMatrix4x4f_Transpose(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
result->m[0] = src->m[0];
result->m[1] = src->m[4];
result->m[2] = src->m[8];
result->m[3] = src->m[12];
result->m[4] = src->m[1];
result->m[5] = src->m[5];
result->m[6] = src->m[9];
result->m[7] = src->m[13];
result->m[8] = src->m[2];
result->m[9] = src->m[6];
result->m[10] = src->m[10];
result->m[11] = src->m[14];
result->m[12] = src->m[3];
result->m[13] = src->m[7];
result->m[14] = src->m[11];
result->m[15] = src->m[15];
}
// Returns a 3x3 minor of a 4x4 matrix.
inline static float XrMatrix4x4f_Minor(const XrMatrix4x4f* matrix, int r0, int r1, int r2, int c0, int c1, int c2) {
return matrix->m[4 * r0 + c0] *
(matrix->m[4 * r1 + c1] * matrix->m[4 * r2 + c2] - matrix->m[4 * r2 + c1] * matrix->m[4 * r1 + c2]) -
matrix->m[4 * r0 + c1] *
(matrix->m[4 * r1 + c0] * matrix->m[4 * r2 + c2] - matrix->m[4 * r2 + c0] * matrix->m[4 * r1 + c2]) +
matrix->m[4 * r0 + c2] *
(matrix->m[4 * r1 + c0] * matrix->m[4 * r2 + c1] - matrix->m[4 * r2 + c0] * matrix->m[4 * r1 + c1]);
}
// Calculates the inverse of a 4x4 matrix.
inline static void XrMatrix4x4f_Invert(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
const float rcpDet =
1.0f / (src->m[0] * XrMatrix4x4f_Minor(src, 1, 2, 3, 1, 2, 3) - src->m[1] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 2, 3) +
src->m[2] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 3) - src->m[3] * XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 2));
result->m[0] = XrMatrix4x4f_Minor(src, 1, 2, 3, 1, 2, 3) * rcpDet;
result->m[1] = -XrMatrix4x4f_Minor(src, 0, 2, 3, 1, 2, 3) * rcpDet;
result->m[2] = XrMatrix4x4f_Minor(src, 0, 1, 3, 1, 2, 3) * rcpDet;
result->m[3] = -XrMatrix4x4f_Minor(src, 0, 1, 2, 1, 2, 3) * rcpDet;
result->m[4] = -XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 2, 3) * rcpDet;
result->m[5] = XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 2, 3) * rcpDet;
result->m[6] = -XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 2, 3) * rcpDet;
result->m[7] = XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 2, 3) * rcpDet;
result->m[8] = XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 3) * rcpDet;
result->m[9] = -XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 1, 3) * rcpDet;
result->m[10] = XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 1, 3) * rcpDet;
result->m[11] = -XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 1, 3) * rcpDet;
result->m[12] = -XrMatrix4x4f_Minor(src, 1, 2, 3, 0, 1, 2) * rcpDet;
result->m[13] = XrMatrix4x4f_Minor(src, 0, 2, 3, 0, 1, 2) * rcpDet;
result->m[14] = -XrMatrix4x4f_Minor(src, 0, 1, 3, 0, 1, 2) * rcpDet;
result->m[15] = XrMatrix4x4f_Minor(src, 0, 1, 2, 0, 1, 2) * rcpDet;
}
// Calculates the inverse of a rigid body transform.
inline static void XrMatrix4x4f_InvertRigidBody(XrMatrix4x4f* result, const XrMatrix4x4f* src) {
result->m[0] = src->m[0];
result->m[1] = src->m[4];
result->m[2] = src->m[8];
result->m[3] = 0.0f;
result->m[4] = src->m[1];
result->m[5] = src->m[5];
result->m[6] = src->m[9];
result->m[7] = 0.0f;
result->m[8] = src->m[2];
result->m[9] = src->m[6];
result->m[10] = src->m[10];
result->m[11] = 0.0f;
result->m[12] = -(src->m[0] * src->m[12] + src->m[1] * src->m[13] + src->m[2] * src->m[14]);
result->m[13] = -(src->m[4] * src->m[12] + src->m[5] * src->m[13] + src->m[6] * src->m[14]);
result->m[14] = -(src->m[8] * src->m[12] + src->m[9] * src->m[13] + src->m[10] * src->m[14]);
result->m[15] = 1.0f;
}
// Creates an identity matrix.
inline static void XrMatrix4x4f_CreateIdentity(XrMatrix4x4f* result) {
result->m[0] = 1.0f;
result->m[1] = 0.0f;
result->m[2] = 0.0f;
result->m[3] = 0.0f;
result->m[4] = 0.0f;
result->m[5] = 1.0f;
result->m[6] = 0.0f;
result->m[7] = 0.0f;
result->m[8] = 0.0f;
result->m[9] = 0.0f;
result->m[10] = 1.0f;
result->m[11] = 0.0f;
result->m[12] = 0.0f;
result->m[13] = 0.0f;
result->m[14] = 0.0f;
result->m[15] = 1.0f;
}
// Creates a translation matrix.
inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const float x, const float y, const float z) {
result->m[0] = 1.0f;
result->m[1] = 0.0f;
result->m[2] = 0.0f;
result->m[3] = 0.0f;
result->m[4] = 0.0f;
result->m[5] = 1.0f;
result->m[6] = 0.0f;
result->m[7] = 0.0f;
result->m[8] = 0.0f;
result->m[9] = 0.0f;
result->m[10] = 1.0f;
result->m[11] = 0.0f;
result->m[12] = x;
result->m[13] = y;
result->m[14] = z;
result->m[15] = 1.0f;
}
// Creates a rotation matrix.
// If -Z=forward, +Y=up, +X=right, then degreesX=pitch, degreesY=yaw, degreesZ=roll.
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
const float degreesZ) {
const float sinX = sinf(degreesX * (MATH_PI / 180.0f));
const float cosX = cosf(degreesX * (MATH_PI / 180.0f));
const XrMatrix4x4f rotationX = {{1, 0, 0, 0, 0, cosX, sinX, 0, 0, -sinX, cosX, 0, 0, 0, 0, 1}};
const float sinY = sinf(degreesY * (MATH_PI / 180.0f));
const float cosY = cosf(degreesY * (MATH_PI / 180.0f));
const XrMatrix4x4f rotationY = {{cosY, 0, -sinY, 0, 0, 1, 0, 0, sinY, 0, cosY, 0, 0, 0, 0, 1}};
const float sinZ = sinf(degreesZ * (MATH_PI / 180.0f));
const float cosZ = cosf(degreesZ * (MATH_PI / 180.0f));
const XrMatrix4x4f rotationZ = {{cosZ, sinZ, 0, 0, -sinZ, cosZ, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}};
XrMatrix4x4f rotationXY;
XrMatrix4x4f_Multiply(&rotationXY, &rotationY, &rotationX);
XrMatrix4x4f_Multiply(result, &rotationZ, &rotationXY);
}
// Creates a scale matrix.
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z) {
result->m[0] = x;
result->m[1] = 0.0f;
result->m[2] = 0.0f;
result->m[3] = 0.0f;
result->m[4] = 0.0f;
result->m[5] = y;
result->m[6] = 0.0f;
result->m[7] = 0.0f;
result->m[8] = 0.0f;
result->m[9] = 0.0f;
result->m[10] = z;
result->m[11] = 0.0f;
result->m[12] = 0.0f;
result->m[13] = 0.0f;
result->m[14] = 0.0f;
result->m[15] = 1.0f;
}
// Creates a matrix from a quaternion.
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* quat) {
const float x2 = quat->x + quat->x;
const float y2 = quat->y + quat->y;
const float z2 = quat->z + quat->z;
const float xx2 = quat->x * x2;
const float yy2 = quat->y * y2;
const float zz2 = quat->z * z2;
const float yz2 = quat->y * z2;
const float wx2 = quat->w * x2;
const float xy2 = quat->x * y2;
const float wz2 = quat->w * z2;
const float xz2 = quat->x * z2;
const float wy2 = quat->w * y2;
result->m[0] = 1.0f - yy2 - zz2;
result->m[1] = xy2 + wz2;
result->m[2] = xz2 - wy2;
result->m[3] = 0.0f;
result->m[4] = xy2 - wz2;
result->m[5] = 1.0f - xx2 - zz2;
result->m[6] = yz2 + wx2;
result->m[7] = 0.0f;
result->m[8] = xz2 + wy2;
result->m[9] = yz2 - wx2;
result->m[10] = 1.0f - xx2 - yy2;
result->m[11] = 0.0f;
result->m[12] = 0.0f;
result->m[13] = 0.0f;
result->m[14] = 0.0f;
result->m[15] = 1.0f;
}
// Creates a combined translation(rotation(scale(object))) matrix.
inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* result, const XrVector3f* translation,
const XrQuaternionf* rotation, const XrVector3f* scale) {
XrMatrix4x4f scaleMatrix;
XrMatrix4x4f_CreateScale(&scaleMatrix, scale->x, scale->y, scale->z);
XrMatrix4x4f rotationMatrix;
XrMatrix4x4f_CreateFromQuaternion(&rotationMatrix, rotation);
XrMatrix4x4f translationMatrix;
XrMatrix4x4f_CreateTranslation(&translationMatrix, translation->x, translation->y, translation->z);
XrMatrix4x4f combinedMatrix;
XrMatrix4x4f_Multiply(&combinedMatrix, &rotationMatrix, &scaleMatrix);
XrMatrix4x4f_Multiply(result, &translationMatrix, &combinedMatrix);
}
// Creates a projection matrix based on the specified dimensions.
// The projection matrix transforms -Z=forward, +Y=up, +X=right to the appropriate clip space for the graphics API.
// The far plane is placed at infinity if farZ <= nearZ.
// An infinite projection matrix is preferred for rasterization because, except for
// things *right* up against the near plane, it always provides better precision:
// "Tightening the Precision of Perspective Rendering"
// Paul Upchurch, Mathieu Desbrun
// Journal of Graphics Tools, Volume 16, Issue 1, 2012
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const float tanAngleLeft,
const float tanAngleRight, const float tanAngleUp, float const tanAngleDown,
const float nearZ, const float farZ) {
const float tanAngleWidth = tanAngleRight - tanAngleLeft;
// Set to tanAngleDown - tanAngleUp for a clip space with positive Y down (Vulkan).
// Set to tanAngleUp - tanAngleDown for a clip space with positive Y up (OpenGL / D3D / Metal).
const float tanAngleHeight = graphicsApi == GRAPHICS_VULKAN ? (tanAngleDown - tanAngleUp) : (tanAngleUp - tanAngleDown);
// Set to nearZ for a [-1,1] Z clip space (OpenGL / OpenGL ES).
// Set to zero for a [0,1] Z clip space (Vulkan / D3D / Metal).
const float offsetZ = (graphicsApi == GRAPHICS_OPENGL || graphicsApi == GRAPHICS_OPENGL_ES) ? nearZ : 0;
if (farZ <= nearZ) {
// place the far plane at infinity
result->m[0] = 2 / tanAngleWidth;
result->m[4] = 0;
result->m[8] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
result->m[12] = 0;
result->m[1] = 0;
result->m[5] = 2 / tanAngleHeight;
result->m[9] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
result->m[13] = 0;
result->m[2] = 0;
result->m[6] = 0;
result->m[10] = -1;
result->m[14] = -(nearZ + offsetZ);
result->m[3] = 0;
result->m[7] = 0;
result->m[11] = -1;
result->m[15] = 0;
} else {
// normal projection
result->m[0] = 2 / tanAngleWidth;
result->m[4] = 0;
result->m[8] = (tanAngleRight + tanAngleLeft) / tanAngleWidth;
result->m[12] = 0;
result->m[1] = 0;
result->m[5] = 2 / tanAngleHeight;
result->m[9] = (tanAngleUp + tanAngleDown) / tanAngleHeight;
result->m[13] = 0;
result->m[2] = 0;
result->m[6] = 0;
result->m[10] = -(farZ + offsetZ) / (farZ - nearZ);
result->m[14] = -(farZ * (nearZ + offsetZ)) / (farZ - nearZ);
result->m[3] = 0;
result->m[7] = 0;
result->m[11] = -1;
result->m[15] = 0;
}
}
// Creates a projection matrix based on the specified FOV.
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const XrFovf fov,
const float nearZ, const float farZ) {
const float tanLeft = tanf(fov.angleLeft);
const float tanRight = tanf(fov.angleRight);
const float tanDown = tanf(fov.angleDown);
const float tanUp = tanf(fov.angleUp);
XrMatrix4x4f_CreateProjection(result, graphicsApi, tanLeft, tanRight, tanUp, tanDown, nearZ, farZ);
}
// Creates a matrix that transforms the -1 to 1 cube to cover the given 'mins' and 'maxs' transformed with the given 'matrix'.
inline static void XrMatrix4x4f_CreateOffsetScaleForBounds(XrMatrix4x4f* result, const XrMatrix4x4f* matrix, const XrVector3f* mins,
const XrVector3f* maxs) {
const XrVector3f offset = {(maxs->x + mins->x) * 0.5f, (maxs->y + mins->y) * 0.5f, (maxs->z + mins->z) * 0.5f};
const XrVector3f scale = {(maxs->x - mins->x) * 0.5f, (maxs->y - mins->y) * 0.5f, (maxs->z - mins->z) * 0.5f};
result->m[0] = matrix->m[0] * scale.x;
result->m[1] = matrix->m[1] * scale.x;
result->m[2] = matrix->m[2] * scale.x;
result->m[3] = matrix->m[3] * scale.x;
result->m[4] = matrix->m[4] * scale.y;
result->m[5] = matrix->m[5] * scale.y;
result->m[6] = matrix->m[6] * scale.y;
result->m[7] = matrix->m[7] * scale.y;
result->m[8] = matrix->m[8] * scale.z;
result->m[9] = matrix->m[9] * scale.z;
result->m[10] = matrix->m[10] * scale.z;
result->m[11] = matrix->m[11] * scale.z;
result->m[12] = matrix->m[12] + matrix->m[0] * offset.x + matrix->m[4] * offset.y + matrix->m[8] * offset.z;
result->m[13] = matrix->m[13] + matrix->m[1] * offset.x + matrix->m[5] * offset.y + matrix->m[9] * offset.z;
result->m[14] = matrix->m[14] + matrix->m[2] * offset.x + matrix->m[6] * offset.y + matrix->m[10] * offset.z;
result->m[15] = matrix->m[15] + matrix->m[3] * offset.x + matrix->m[7] * offset.y + matrix->m[11] * offset.z;
}
// Returns true if the given matrix is affine.
inline static bool XrMatrix4x4f_IsAffine(const XrMatrix4x4f* matrix, const float epsilon) {
return fabsf(matrix->m[3]) <= epsilon && fabsf(matrix->m[7]) <= epsilon && fabsf(matrix->m[11]) <= epsilon &&
fabsf(matrix->m[15] - 1.0f) <= epsilon;
}
// Returns true if the given matrix is orthogonal.
inline static bool XrMatrix4x4f_IsOrthogonal(const XrMatrix4x4f* matrix, const float epsilon) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i != j) {
if (fabsf(matrix->m[4 * i + 0] * matrix->m[4 * j + 0] + matrix->m[4 * i + 1] * matrix->m[4 * j + 1] +
matrix->m[4 * i + 2] * matrix->m[4 * j + 2]) > epsilon) {
return false;
}
if (fabsf(matrix->m[4 * 0 + i] * matrix->m[4 * 0 + j] + matrix->m[4 * 1 + i] * matrix->m[4 * 1 + j] +
matrix->m[4 * 2 + i] * matrix->m[4 * 2 + j]) > epsilon) {
return false;
}
}
}
}
return true;
}
// Returns true if the given matrix is orthonormal.
inline static bool XrMatrix4x4f_IsOrthonormal(const XrMatrix4x4f* matrix, const float epsilon) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
const float kd = (i == j) ? 1.0f : 0.0f; // Kronecker delta
if (fabsf(kd - (matrix->m[4 * i + 0] * matrix->m[4 * j + 0] + matrix->m[4 * i + 1] * matrix->m[4 * j + 1] +
matrix->m[4 * i + 2] * matrix->m[4 * j + 2])) > epsilon) {
return false;
}
if (fabsf(kd - (matrix->m[4 * 0 + i] * matrix->m[4 * 0 + j] + matrix->m[4 * 1 + i] * matrix->m[4 * 1 + j] +
matrix->m[4 * 2 + i] * matrix->m[4 * 2 + j])) > epsilon) {
return false;
}
}
}
return true;
}
// Returns true if the given matrix is a rigid body transform.
inline static bool XrMatrix4x4f_IsRigidBody(const XrMatrix4x4f* matrix, const float epsilon) {
return XrMatrix4x4f_IsAffine(matrix, epsilon) && XrMatrix4x4f_IsOrthonormal(matrix, epsilon);
}
// Get the translation from a combined translation(rotation(scale(object))) matrix.
inline static void XrMatrix4x4f_GetTranslation(XrVector3f* result, const XrMatrix4x4f* src) {
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
result->x = src->m[12];
result->y = src->m[13];
result->z = src->m[14];
}
// Get the rotation from a combined translation(rotation(scale(object))) matrix.
inline static void XrMatrix4x4f_GetRotation(XrQuaternionf* result, const XrMatrix4x4f* src) {
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
const float rcpScaleX = XrRcpSqrt(src->m[0] * src->m[0] + src->m[1] * src->m[1] + src->m[2] * src->m[2]);
const float rcpScaleY = XrRcpSqrt(src->m[4] * src->m[4] + src->m[5] * src->m[5] + src->m[6] * src->m[6]);
const float rcpScaleZ = XrRcpSqrt(src->m[8] * src->m[8] + src->m[9] * src->m[9] + src->m[10] * src->m[10]);
const float m[9] = {src->m[0] * rcpScaleX, src->m[1] * rcpScaleX, src->m[2] * rcpScaleX,
src->m[4] * rcpScaleY, src->m[5] * rcpScaleY, src->m[6] * rcpScaleY,
src->m[8] * rcpScaleZ, src->m[9] * rcpScaleZ, src->m[10] * rcpScaleZ};
if (m[0 * 3 + 0] + m[1 * 3 + 1] + m[2 * 3 + 2] > 0.0f) {
float t = +m[0 * 3 + 0] + m[1 * 3 + 1] + m[2 * 3 + 2] + 1.0f;
float s = XrRcpSqrt(t) * 0.5f;
result->w = s * t;
result->z = (m[0 * 3 + 1] - m[1 * 3 + 0]) * s;
result->y = (m[2 * 3 + 0] - m[0 * 3 + 2]) * s;
result->x = (m[1 * 3 + 2] - m[2 * 3 + 1]) * s;
} else if (m[0 * 3 + 0] > m[1 * 3 + 1] && m[0 * 3 + 0] > m[2 * 3 + 2]) {
float t = +m[0 * 3 + 0] - m[1 * 3 + 1] - m[2 * 3 + 2] + 1.0f;
float s = XrRcpSqrt(t) * 0.5f;
result->x = s * t;
result->y = (m[0 * 3 + 1] + m[1 * 3 + 0]) * s;
result->z = (m[2 * 3 + 0] + m[0 * 3 + 2]) * s;
result->w = (m[1 * 3 + 2] - m[2 * 3 + 1]) * s;
} else if (m[1 * 3 + 1] > m[2 * 3 + 2]) {
float t = -m[0 * 3 + 0] + m[1 * 3 + 1] - m[2 * 3 + 2] + 1.0f;
float s = XrRcpSqrt(t) * 0.5f;
result->y = s * t;
result->x = (m[0 * 3 + 1] + m[1 * 3 + 0]) * s;
result->w = (m[2 * 3 + 0] - m[0 * 3 + 2]) * s;
result->z = (m[1 * 3 + 2] + m[2 * 3 + 1]) * s;
} else {
float t = -m[0 * 3 + 0] - m[1 * 3 + 1] + m[2 * 3 + 2] + 1.0f;
float s = XrRcpSqrt(t) * 0.5f;
result->z = s * t;
result->w = (m[0 * 3 + 1] - m[1 * 3 + 0]) * s;
result->x = (m[2 * 3 + 0] + m[0 * 3 + 2]) * s;
result->y = (m[1 * 3 + 2] + m[2 * 3 + 1]) * s;
}
}
// Get the scale from a combined translation(rotation(scale(object))) matrix.
inline static void XrMatrix4x4f_GetScale(XrVector3f* result, const XrMatrix4x4f* src) {
assert(XrMatrix4x4f_IsAffine(src, 1e-4f));
assert(XrMatrix4x4f_IsOrthogonal(src, 1e-4f));
result->x = sqrtf(src->m[0] * src->m[0] + src->m[1] * src->m[1] + src->m[2] * src->m[2]);
result->y = sqrtf(src->m[4] * src->m[4] + src->m[5] * src->m[5] + src->m[6] * src->m[6]);
result->z = sqrtf(src->m[8] * src->m[8] + src->m[9] * src->m[9] + src->m[10] * src->m[10]);
}
// Transforms a 3D vector.
inline static void XrMatrix4x4f_TransformVector3f(XrVector3f* result, const XrMatrix4x4f* m, const XrVector3f* v) {
const float w = m->m[3] * v->x + m->m[7] * v->y + m->m[11] * v->z + m->m[15];
const float rcpW = 1.0f / w;
result->x = (m->m[0] * v->x + m->m[4] * v->y + m->m[8] * v->z + m->m[12]) * rcpW;
result->y = (m->m[1] * v->x + m->m[5] * v->y + m->m[9] * v->z + m->m[13]) * rcpW;
result->z = (m->m[2] * v->x + m->m[6] * v->y + m->m[10] * v->z + m->m[14]) * rcpW;
}
// Transforms a 4D vector.
inline static void XrMatrix4x4f_TransformVector4f(XrVector4f* result, const XrMatrix4x4f* m, const XrVector4f* v) {
result->x = m->m[0] * v->x + m->m[4] * v->y + m->m[8] * v->z + m->m[12] * v->w;
result->y = m->m[1] * v->x + m->m[5] * v->y + m->m[9] * v->z + m->m[13] * v->w;
result->z = m->m[2] * v->x + m->m[6] * v->y + m->m[10] * v->z + m->m[14] * v->w;
result->w = m->m[3] * v->x + m->m[7] * v->y + m->m[11] * v->z + m->m[15] * v->w;
}
// Transforms the 'mins' and 'maxs' bounds with the given 'matrix'.
inline static void XrMatrix4x4f_TransformBounds(XrVector3f* resultMins, XrVector3f* resultMaxs, const XrMatrix4x4f* matrix,
const XrVector3f* mins, const XrVector3f* maxs) {
assert(XrMatrix4x4f_IsAffine(matrix, 1e-4f));
const XrVector3f center = {(mins->x + maxs->x) * 0.5f, (mins->y + maxs->y) * 0.5f, (mins->z + maxs->z) * 0.5f};
const XrVector3f extents = {maxs->x - center.x, maxs->y - center.y, maxs->z - center.z};
const XrVector3f newCenter = {matrix->m[0] * center.x + matrix->m[4] * center.y + matrix->m[8] * center.z + matrix->m[12],
matrix->m[1] * center.x + matrix->m[5] * center.y + matrix->m[9] * center.z + matrix->m[13],
matrix->m[2] * center.x + matrix->m[6] * center.y + matrix->m[10] * center.z + matrix->m[14]};
const XrVector3f newExtents = {
fabsf(extents.x * matrix->m[0]) + fabsf(extents.y * matrix->m[4]) + fabsf(extents.z * matrix->m[8]),
fabsf(extents.x * matrix->m[1]) + fabsf(extents.y * matrix->m[5]) + fabsf(extents.z * matrix->m[9]),
fabsf(extents.x * matrix->m[2]) + fabsf(extents.y * matrix->m[6]) + fabsf(extents.z * matrix->m[10])};
XrVector3f_Sub(resultMins, &newCenter, &newExtents);
XrVector3f_Add(resultMaxs, &newCenter, &newExtents);
}
// Returns true if the 'mins' and 'maxs' bounds is completely off to one side of the projection matrix.
inline static bool XrMatrix4x4f_CullBounds(const XrMatrix4x4f* mvp, const XrVector3f* mins, const XrVector3f* maxs) {
if (maxs->x <= mins->x && maxs->y <= mins->y && maxs->z <= mins->z) {
return false;
}
XrVector4f c[8];
for (int i = 0; i < 8; i++) {
const XrVector4f corner = {(i & 1) ? maxs->x : mins->x, (i & 2) ? maxs->y : mins->y, (i & 4) ? maxs->z : mins->z, 1.0f};
XrMatrix4x4f_TransformVector4f(&c[i], mvp, &corner);
}
int i;
for (i = 0; i < 8; i++) {
if (c[i].x > -c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
for (i = 0; i < 8; i++) {
if (c[i].x < c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
for (i = 0; i < 8; i++) {
if (c[i].y > -c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
for (i = 0; i < 8; i++) {
if (c[i].y < c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
for (i = 0; i < 8; i++) {
if (c[i].z > -c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
for (i = 0; i < 8; i++) {
if (c[i].z < c[i].w) {
break;
}
}
if (i == 8) {
return true;
}
return false;
}
#endif // XR_LINEAR_H_

View File

@@ -0,0 +1,3 @@
#cmakedefine HAVE_SECURE_GETENV
#cmakedefine HAVE___SECURE_GETENV
#cmakedefine XRLOADER_ENABLE_EXCEPTION_HANDLING

183
extern/openxr/src/loader/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,183 @@
# Copyright (c) 2017 The Khronos Group Inc.
#
# 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.
#
# Author:
#
#set (CMAKE_VERBOSE_MAKEFILE 1)
include(GNUInstallDirs)
# Use this feature for Windows to automatically generate an exports file for the DLL.
# See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
include(GenerateExportHeader)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS false)
set(LOADER_NAME openxr_loader)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
"Search path to use when XDG_CONFIG_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
set(FALLBACK_DATA_DIRS "/usr/local/share:/usr/share" CACHE STRING
"Search path to use when XDG_DATA_DIRS is unset or empty or the current process is SUID/SGID. Default is freedesktop compliant.")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(openxr_loader_RESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/loader.rc)
set(LOADER_NAME ${LOADER_NAME}-${MAJOR}_${MINOR})
endif()
# List of all files externally generated outside of the loader that the loader
# needs to build with.
SET(LOADER_EXTERNAL_GEN_FILES
${COMMON_GENERATED_OUTPUT}
)
run_xr_xml_generate(loader_source_generator.py xr_generated_loader.hpp)
run_xr_xml_generate(loader_source_generator.py xr_generated_loader.cpp)
if(DYNAMIC_LOADER)
add_definitions(-DXRAPI_DLL_EXPORT)
set(LIBRARY_TYPE SHARED)
else() # build static lib
set(LIBRARY_TYPE STATIC)
endif()
set(JSONCPP_ROOT_DIR ${CMAKE_SOURCE_DIR}/extern/jsoncpp)
add_library(${LOADER_NAME} ${LIBRARY_TYPE}
api_layer_interface.cpp
api_layer_interface.hpp
loader_core.cpp
loader_instance.cpp
loader_instance.hpp
loader_logger.cpp
loader_logger.hpp
loader_logger_recorders.cpp
loader_logger_recorders.hpp
manifest_file.cpp
${GENERATED_OUTPUT}
manifest_file.hpp
runtime_interface.cpp
runtime_interface.hpp
${OPENXR_ROOT_DIR}/src/common/filesystem_utils.cpp
${OPENXR_ROOT_DIR}/src/common/filesystem_utils.hpp
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.cpp
${OPENXR_ROOT_DIR}/src/common/hex_and_handles.h
${JSONCPP_ROOT_DIR}/src/json_reader.cpp
${JSONCPP_ROOT_DIR}/src/json_value.cpp
${JSONCPP_ROOT_DIR}/src/json_writer.cpp
${LOADER_EXTERNAL_GEN_FILES}
${openxr_loader_RESOURCE_FILE}
)
set_target_properties(${LOADER_NAME} PROPERTIES FOLDER ${LOADER_FOLDER})
set_source_files_properties(
${LOADER_EXTERNAL_GEN_FILES}
PROPERTIES GENERATED TRUE
)
add_dependencies(${LOADER_NAME}
generate_openxr_header
xr_global_generated_files
)
target_include_directories(${LOADER_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_BINARY_DIR}/include
PRIVATE ${CMAKE_BINARY_DIR}/src
PRIVATE ${OPENXR_ROOT_DIR}/src/common
PRIVATE ${JSONCPP_ROOT_DIR}/include
)
if(VulkanHeaders_FOUND)
target_include_directories(${LOADER_NAME}
PRIVATE ${Vulkan_INCLUDE_DIRS}
)
endif()
target_compile_definitions(${LOADER_NAME}
PRIVATE API_NAME="OpenXR"
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(${LOADER_NAME}
PRIVATE FALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}"
PRIVATE FALLBACK_DATA_DIRS="${FALLBACK_DATA_DIRS}"
PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}"
)
if(NOT(CMAKE_INSTALL_FULL_SYSCONFDIR STREQUAL "/etc"))
target_compile_definitions(openxr_loader PRIVATE EXTRASYSCONFDIR="/etc")
endif()
set_target_properties(${LOADER_NAME} PROPERTIES SOVERSION "${MAJOR}" VERSION "${MAJOR}.${MINOR}.${PATCH}")
target_link_libraries(${LOADER_NAME} -lstdc++fs -ldl -lpthread -lm)
add_custom_target(lib${LOADER_NAME}.so.${MAJOR}.${MINOR} ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink lib${LOADER_NAME}.so.${MAJOR}.${MINOR}.${PATCH} lib${LOADER_NAME}.so.${MAJOR}.${MINOR})
install(TARGETS ${LOADER_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
set(XR_API_VERSION "${MAJOR}.${MINOR}")
configure_file("openxr.pc.in" "openxr.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openxr.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
foreach(configuration in CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
# If building DLLs, force static CRT linkage
if(DYNAMIC_LOADER)
if (${configuration} MATCHES "/MD")
# string(REGEX REPLACE "/MD" "/MT" ${configuration} "${${configuration}}")
endif()
else() # Otherwise for static libs, link the CRT dynamically
if (${configuration} MATCHES "/MT")
# string(REGEX REPLACE "/MT" "/MD" ${configuration} "${${configuration}}")
endif()
endif()
endforeach()
target_link_libraries(${LOADER_NAME} shlwapi)
target_compile_options(${LOADER_NAME} PRIVATE)
generate_export_header(${LOADER_NAME})
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS false)
# Need to copy DLL to client directories so clients can easily load it.
if( (DYNAMIC_LOADER) AND (CMAKE_GENERATOR MATCHES "^Visual Studio.*") )
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/${LOADER_NAME}.dll COPY_SRC_PATH )
# file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/triangle/$<CONFIGURATION>/ COPY_DST_TEST_PATH )
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/hello_xr/$<CONFIGURATION>/ COPY_DST_TEST_PATH )
file( TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/loader_test/$<CONFIGURATION>/ COPY_DST_LOADER_TEST_PATH )
add_custom_command( TARGET ${LOADER_NAME} POST_BUILD
COMMAND xcopy /Y /I ${COPY_SRC_PATH} ${COPY_DST_TEST_PATH}
COMMAND xcopy /Y /I ${COPY_SRC_PATH} ${COPY_DST_LOADER_TEST_PATH}
)
endif()
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(openxr_loader
PRIVATE -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wpointer-arith
PRIVATE -fno-strict-aliasing -fno-builtin-memcmp "$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>"
)
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since
# there's no consistent way to satisfy all compilers until they all accept the C++17 standard
if (CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
target_compile_options(openxr_loader PRIVATE -Wimplicit-fallthrough=0)
endif()
endif()
install(TARGETS ${LOADER_NAME} DESTINATION lib)
# Custom commands to build dependencies for above targets

View File

@@ -0,0 +1,403 @@
// Copyright (c) 2017-2019 The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
// 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.
//
// Author: Mark Young <marky@lunarg.com>
//
#include "api_layer_interface.hpp"
#include "loader_interfaces.h"
#include "loader_logger.hpp"
#include "loader_platform.hpp"
#include "manifest_file.hpp"
#include "platform_utils.hpp"
#include <openxr/openxr.h>
#include <cstring>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define OPENXR_ENABLE_LAYERS_ENV_VAR "XR_ENABLE_API_LAYERS"
// Add any layers defined in the loader layer environment variable.
static void AddEnvironmentApiLayers(const std::string& openxr_command, std::vector<std::string>& enabled_layers) {
char* layer_environment_variable = PlatformUtilsGetEnv(OPENXR_ENABLE_LAYERS_ENV_VAR);
if (nullptr != layer_environment_variable) {
std::string layers = layer_environment_variable;
PlatformUtilsFreeEnv(layer_environment_variable);
std::size_t last_found = 0;
std::size_t found = layers.find_first_of(PATH_SEPARATOR);
std::string cur_search;
// Handle any path listings in the string (separated by the appropriate path separator)
while (found != std::string::npos) {
cur_search = layers.substr(last_found, found);
enabled_layers.push_back(cur_search);
last_found = found + 1;
found = layers.find_first_of(PATH_SEPARATOR, last_found);
}
// If there's something remaining in the string, copy it over
if (last_found < layers.size()) {
cur_search = layers.substr(last_found);
enabled_layers.push_back(cur_search);
}
}
}
XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_command, uint32_t incoming_count,
uint32_t* outgoing_count, XrApiLayerProperties* api_layer_properties) {
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
uint32_t manifest_count = 0;
// Find any implicit layers which we may need to report information for.
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
if (XR_SUCCESS == result) {
// Find any explicit layers which we may need to report information for.
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files);
}
if (XR_SUCCESS != result) {
LoaderLogger::LogErrorMessage(openxr_command,
"ApiLayerInterface::GetApiLayerProperties - failed searching for API layer manifest files");
return result;
}
manifest_count = static_cast<uint32_t>(manifest_files.size());
if (0 == incoming_count) {
if (nullptr == outgoing_count) {
return XR_ERROR_VALIDATION_FAILURE;
}
*outgoing_count = manifest_count;
} else if (nullptr != api_layer_properties) {
if (incoming_count < manifest_count && nullptr != api_layer_properties) {
LoaderLogger::LogErrorMessage(
"xrEnumerateInstanceExtensionProperties",
"VUID-xrEnumerateApiLayerProperties-propertyCapacityInput-parameter: insufficient space in array");
*outgoing_count = manifest_count;
return XR_ERROR_SIZE_INSUFFICIENT;
}
uint32_t prop = 0;
bool properties_valid = true;
for (; prop < incoming_count && prop < manifest_count; ++prop) {
if (XR_TYPE_API_LAYER_PROPERTIES != api_layer_properties[prop].type) {
LoaderLogger::LogErrorMessage(openxr_command,
"VUID-XrApiLayerProperties-type-type: unknown type in api_layer_properties");
properties_valid = false;
}
if (nullptr != api_layer_properties[prop].next) {
LoaderLogger::LogErrorMessage(openxr_command, "VUID-XrApiLayerProperties-next-next: expected NULL");
properties_valid = false;
}
if (properties_valid) {
api_layer_properties[prop] = manifest_files[prop]->GetApiLayerProperties();
}
}
if (!properties_valid) {
LoaderLogger::LogErrorMessage(openxr_command,
"VUID-xrEnumerateApiLayerProperties-properties-parameter: invalid properties");
return XR_ERROR_VALIDATION_FAILURE;
}
if (nullptr != outgoing_count) {
*outgoing_count = prop;
}
}
return XR_SUCCESS;
}
XrResult ApiLayerInterface::GetInstanceExtensionProperties(const std::string& openxr_command, const char* layer_name,
std::vector<XrExtensionProperties>& extension_properties) {
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
// If a layer name is supplied, only use the information out of that one layer
if (nullptr != layer_name && 0 != strlen(layer_name)) {
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
if (XR_SUCCESS == result) {
// Find any explicit layers which we may need to report information for.
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, manifest_files);
if (XR_SUCCESS != result) {
LoaderLogger::LogErrorMessage(
openxr_command,
"ApiLayerInterface::GetInstanceExtensionProperties - failed searching for API layer manifest files");
return result;
}
bool found = false;
auto num_files = static_cast<uint32_t>(manifest_files.size());
for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
// If a layer with the provided name exists, get it's instance extension information.
if (manifest_files[man_file]->LayerName() == layer_name) {
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
found = true;
break;
}
}
// If nothing found, report 0
if (!found) {
return XR_ERROR_API_LAYER_NOT_PRESENT;
}
}
// Otherwise, we want to add only implicit API layers and explicit API layers enabled using the environment variables
} else {
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, manifest_files);
if (XR_SUCCESS == result) {
// Find any environmentally enabled explicit layers. If they're present, treat them like implicit layers
// since we know that they're going to be enabled.
std::vector<std::string> env_enabled_layers;
AddEnvironmentApiLayers(openxr_command, env_enabled_layers);
if (!env_enabled_layers.empty()) {
std::vector<std::unique_ptr<ApiLayerManifestFile>> exp_layer_man_files = {};
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, exp_layer_man_files);
if (XR_SUCCESS == result) {
for (auto l_iter = exp_layer_man_files.begin();
!exp_layer_man_files.empty() && l_iter != exp_layer_man_files.end();
/* No iterate */) {
for (std::string& enabled_layer : env_enabled_layers) {
// If this is an enabled layer, transfer it over to the manifest list.
if (enabled_layer == (*l_iter)->LayerName()) {
manifest_files.push_back(std::move(*l_iter));
break;
}
}
exp_layer_man_files.erase(l_iter);
}
}
}
}
// Grab the layer instance extensions information
auto num_files = static_cast<uint32_t>(manifest_files.size());
for (uint32_t man_file = 0; man_file < num_files; ++man_file) {
manifest_files[man_file]->GetInstanceExtensionProperties(extension_properties);
}
}
return XR_SUCCESS;
}
XrResult ApiLayerInterface::LoadApiLayers(const std::string& openxr_command, uint32_t enabled_api_layer_count,
const char* const* enabled_api_layer_names,
std::vector<std::unique_ptr<ApiLayerInterface>>& api_layer_interfaces) {
XrResult last_error = XR_SUCCESS;
bool any_loaded = false;
std::vector<bool> layer_found;
std::vector<std::unique_ptr<ApiLayerManifestFile>> layer_manifest_files = {};
// Find any implicit layers which we may need to report information for.
XrResult result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_IMPLICIT_API_LAYER, layer_manifest_files);
if (XR_SUCCESS == result) {
// Find any explicit layers which we may need to report information for.
result = ApiLayerManifestFile::FindManifestFiles(MANIFEST_TYPE_EXPLICIT_API_LAYER, layer_manifest_files);
}
// Put all the enabled layers into a string vector
std::vector<std::string> enabled_api_layers = {};
AddEnvironmentApiLayers(openxr_command, enabled_api_layers);
if (enabled_api_layer_count > 0) {
if (nullptr == enabled_api_layer_names) {
LoaderLogger::LogErrorMessage(
"xrCreateInstance",
"VUID-XrInstanceCreateInfo-enabledApiLayerNames-parameter: enabledApiLayerCount is non-0 but array is NULL");
LoaderLogger::LogErrorMessage(
"xrCreateInstance", "VUID-xrCreateInstance-info-parameter: something wrong with XrInstanceCreateInfo contents");
return XR_ERROR_VALIDATION_FAILURE;
}
auto num_env_api_layers = static_cast<uint32_t>(enabled_api_layers.size());
uint32_t total_api_layers = num_env_api_layers + enabled_api_layer_count;
enabled_api_layers.resize(total_api_layers);
for (uint32_t layer = 0; layer < enabled_api_layer_count; ++layer) {
enabled_api_layers[num_env_api_layers + layer] = enabled_api_layer_names[layer];
}
}
// Initialize the layer found vector to false
layer_found.resize(enabled_api_layers.size());
for (auto&& layer : layer_found) {
layer = false;
}
for (std::unique_ptr<ApiLayerManifestFile>& manifest_file : layer_manifest_files) {
bool enabled = false;
// Always add implicit layers. They would only be in this list if they were enabled
// (i.e. the disable environment variable is not set).
if (manifest_file->Type() == MANIFEST_TYPE_IMPLICIT_API_LAYER) {
enabled = true;
} else {
// Only add explicit layers if they are called out by the application
for (uint32_t layer = 0; layer < enabled_api_layers.size(); ++layer) {
if (enabled_api_layers[layer] == manifest_file->LayerName()) {
layer_found[layer] = true;
enabled = true;
break;
}
}
}
// If this layer isn't enabled, skip it.
if (!enabled) {
continue;
}
LoaderPlatformLibraryHandle layer_library = LoaderPlatformLibraryOpen(manifest_file->LibraryPath());
if (nullptr == layer_library) {
if (!any_loaded) {
last_error = XR_ERROR_FILE_ACCESS_ERROR;
}
std::string library_message = LoaderPlatformLibraryOpenError(manifest_file->LibraryPath());
std::string warning_message = "ApiLayerInterface::LoadApiLayers skipping layer ";
warning_message += manifest_file->LayerName();
warning_message += ", failed to load with message \"";
warning_message += library_message;
warning_message += "\"";
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
continue;
}
// Get and settle on an layer interface version (using any provided name if required).
std::string function_name = manifest_file->GetFunctionName("xrNegotiateLoaderApiLayerInterface");
auto negotiate = reinterpret_cast<PFN_xrNegotiateLoaderApiLayerInterface>(
LoaderPlatformLibraryGetProcAddr(layer_library, function_name));
if (nullptr == negotiate) {
std::ostringstream oss;
oss << "ApiLayerInterface::LoadApiLayers skipping layer " << manifest_file->LayerName()
<< " because negotiation function " << function_name << " was not found";
LoaderLogger::LogErrorMessage(openxr_command, oss.str());
LoaderPlatformLibraryClose(layer_library);
last_error = XR_ERROR_API_LAYER_NOT_PRESENT;
continue;
}
// Loader info for negotiation
XrNegotiateLoaderInfo loader_info = {};
loader_info.structType = XR_LOADER_INTERFACE_STRUCT_LOADER_INFO;
loader_info.structVersion = XR_LOADER_INFO_STRUCT_VERSION;
loader_info.structSize = sizeof(XrNegotiateLoaderInfo);
loader_info.minInterfaceVersion = 1;
loader_info.maxInterfaceVersion = XR_CURRENT_LOADER_API_LAYER_VERSION;
loader_info.minApiVersion = XR_MAKE_VERSION(1, 0, 0);
loader_info.maxApiVersion = XR_MAKE_VERSION(1, 0x3ff, 0xfff); // Maximum allowed version for this major version.
// Set up the layer return structure
XrNegotiateApiLayerRequest api_layer_info = {};
api_layer_info.structType = XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST;
api_layer_info.structVersion = XR_API_LAYER_INFO_STRUCT_VERSION;
api_layer_info.structSize = sizeof(XrNegotiateApiLayerRequest);
XrResult res = negotiate(&loader_info, manifest_file->LayerName().c_str(), &api_layer_info);
// If we supposedly succeeded, but got a nullptr for getInstanceProcAddr
// then something still went wrong, so return with an error.
if (XR_SUCCESS == res && nullptr == api_layer_info.getInstanceProcAddr) {
std::string warning_message = "ApiLayerInterface::LoadApiLayers skipping layer ";
warning_message += manifest_file->LayerName();
warning_message += ", negotiation did not return a valid getInstanceProcAddr";
LoaderLogger::LogWarningMessage(openxr_command, warning_message);
res = XR_ERROR_FILE_CONTENTS_INVALID;
}
if (XR_SUCCESS != res) {
if (!any_loaded) {
last_error = res;
}
std::ostringstream oss;
oss << "ApiLayerInterface::LoadApiLayers skipping layer " << manifest_file->LayerName()
<< " due to failed negotiation with error " << res;
LoaderLogger::LogWarningMessage(openxr_command, oss.str());
LoaderPlatformLibraryClose(layer_library);
continue;
}
{
std::ostringstream oss;
oss << "ApiLayerInterface::LoadApiLayers succeeded loading layer " << manifest_file->LayerName()
<< " using interface version " << api_layer_info.layerInterfaceVersion << " and OpenXR API version "
<< XR_VERSION_MAJOR(api_layer_info.layerApiVersion) << "." << XR_VERSION_MINOR(api_layer_info.layerApiVersion);
LoaderLogger::LogInfoMessage(openxr_command, oss.str());
}
// Grab the list of extensions this layer supports for easy filtering after the
// xrCreateInstance call
std::vector<std::string> supported_extensions;
std::vector<XrExtensionProperties> extension_properties;
manifest_file->GetInstanceExtensionProperties(extension_properties);
supported_extensions.reserve(extension_properties.size());
for (XrExtensionProperties& ext_prop : extension_properties) {
supported_extensions.emplace_back(ext_prop.extensionName);
}
// Add this runtime to the vector
api_layer_interfaces.emplace_back(new ApiLayerInterface(manifest_file->LayerName(), layer_library, supported_extensions,
api_layer_info.getInstanceProcAddr,
api_layer_info.createApiLayerInstance));
// If we load one, clear all errors.
any_loaded = true;
last_error = XR_SUCCESS;
}
// If even one of the layers wasn't found, we want to return an error
for (uint32_t layer = 0; layer < layer_found.size(); ++layer) {
if (!layer_found[layer]) {
std::string error_message = "ApiLayerInterface::LoadApiLayers - failed to find layer ";
error_message += enabled_api_layers[layer];
LoaderLogger::LogErrorMessage(openxr_command, error_message);
last_error = XR_ERROR_API_LAYER_NOT_PRESENT;
}
}
// Always clear the manifest file list. Either we use them or we don't.
layer_manifest_files.clear();
// If we failed catastrophically for some reason, clean up everything.
if (XR_SUCCESS != last_error) {
api_layer_interfaces.clear();
}
return last_error;
}
ApiLayerInterface::ApiLayerInterface(const std::string& layer_name, LoaderPlatformLibraryHandle layer_library,
std::vector<std::string>& supported_extensions,
PFN_xrGetInstanceProcAddr get_instant_proc_addr,
PFN_xrCreateApiLayerInstance create_api_layer_instance)
: _layer_name(layer_name),
_layer_library(layer_library),
_get_instant_proc_addr(get_instant_proc_addr),
_create_api_layer_instance(create_api_layer_instance),
_supported_extensions(supported_extensions) {}
ApiLayerInterface::~ApiLayerInterface() {
std::string info_message = "ApiLayerInterface being destroyed for layer ";
info_message += _layer_name;
LoaderLogger::LogInfoMessage("", info_message);
LoaderPlatformLibraryClose(_layer_library);
}
bool ApiLayerInterface::SupportsExtension(const std::string& extension_name) {
bool found_prop = false;
for (const std::string& supported_extension : _supported_extensions) {
if (supported_extension == extension_name) {
found_prop = true;
break;
}
}
return found_prop;
}

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