Commit Graph

1030 Commits

Author SHA1 Message Date
Benjamin Doherty
fc896f81f0 Fix broken filamat lite build 2021-03-04 10:09:26 -08:00
Ben Doherty
884d5c1b87 Make material compilation deterministic (#3610)
With multithreaded variant compilation, compiled materials differ based on which variants finish first. This change ensures that compiled materials are always bit-for-bit identical.

This is helpful when comparing two compiled materials. Hashing the material files can be used to check for equality. It's also convenient for variants to occupy the same index when using matinfo's --print-glsl flag, for example.
2021-03-03 16:55:35 -08:00
Philip Rideout
30b0f39a36 sample-gltf-viewer: add polish to the drag-and-drop feature. 2021-03-03 14:41:22 -08:00
Philip Rideout
c3c2a732cd gltfio: Add ResourceLoader evict API. 2021-03-03 14:41:22 -08:00
Philip Rideout
5cc8ebd3e1 gltfio: fix ResourceLoader cache bug. 2021-03-03 14:41:22 -08:00
Philip Rideout
9ceb3b016c sample-gltf-viewer: add drag-and-drop feature.
This adds a WebSockets server to filament-utils-android.

Unlike my first attempt (#3599), this does not use a piping server and
is therefore much faster to use over a LAN. It also has lower user
friction because there is no need to touch a button in the app or
scan a QR code.
2021-03-03 14:41:22 -08:00
Philip Rideout
76e18475d3 gltf_viewer: avoid writeJson when automation is off. 2021-03-03 12:10:42 -08:00
Mathias Agopian
1189c9e294 FrameGraph rewrite from the ground up
The main goal of this rewrite was to make the code
simpler and easier to maintain.

The API is mostly unchanged, however there are some differences.
- we now have the concept of subresources, e.g. for Textures, as
  subresource is a mip level or layer.
- RenderTargets are no longer resources, instead they are transiant
  objects associated to a pass and are now called RenderPasses.
- RenderPasses take subresources for attachments.
- We have better validation of graph building.

We should also compute discard flags more accurately.
2021-03-02 22:25:56 -08:00
Philip Rideout
4b580b6eb1 Add automation to Android build, change PNG to PPM.
This adds libs/viewer to filament-utils-android and provides JNI
bindings for AutomationEngine.

This commit also changes the AutomationEngine to use PPM for screenshots
rather than PNG. The reasoning is that it is wasteful to include stb and
our two image-related libraries just to dump screenshots, especially for
a feature we might not use on Android.
2021-03-02 10:41:06 -08:00
Philip Rideout
1921536f90 filamat: Fix data race with SPIRV error registrations. 2021-02-24 10:17:51 -08:00
Mathias Agopian
bc6acd5c5a GL backend: fix race condition when asserting a handle exists 2021-02-22 23:25:43 -08:00
Mathias Agopian
f1fd96983b assert_invariant() now terminates the program in failure
rename logAndPanic to panicLog, since it doesn't actually panics.
2021-02-22 14:57:41 -08:00
Romain Guy
f2ed3480d8 Attempt at improving bloom/emissive with glTF files (#3560)
* Attempt at improving bloom/emissive with glTF files

* Publicly expose Exposure API for gltfio
2021-02-22 09:40:31 -08:00
Philip Rideout
20dadf06f1 Modernize Python print syntax to appease external codebase. 2021-02-18 13:31:02 -08:00
Philip Rideout
811e7c59cf Change abs() to std::abs to appease external codebase. 2021-02-17 14:45:17 -08:00
Philip Rideout
2b68665cd8 Avoid uninitialized reads in computeVisibilityMasks.
I verified that this code is not enabled in our GitHub builds, and I
verified that the MSAN error goes away.
2021-02-17 14:33:56 -08:00
Philip Rideout
6297ef9193 Remove some Windows line endings.
These line endings cause annoying diffs when comparing Filament's GitHub
source with its twin sister within Google.
2021-02-17 10:11:22 -08:00
Mathias Agopian
68e99240d0 don't use assert() inside filament
assert() is now replaced by assert_invariant() which has the same
prototype and (currently) behaves the same than assert().

<assert.h> should not be used anymore, and is replaced by 
<utils/debug.h>, which is where assert_invariant() is found.

The main motivation for this is to be able to set a breakpoint on the
assertion as lldb doesn't handle abort() very well, and doesn't
permit to inspect the stack trace.

A secondary motivation is to be able (at some point) to enable 
assertions without necessarily doing a debug build.
2021-02-16 20:30:04 -08:00
Philip Rideout
4d18c0d61c BlueVK: use slog for dlopen error message. 2021-02-11 12:51:40 -08:00
Philip Rideout
6fa8f48be5 BlueVK: optionally consult environment variable.
One of Filament's Linux clients at Google wishes to specify a special
path to the SwiftShader library that proffers Vulkan entry points, and
this path can only be determined at run time.

An environment variable seems like the easiest way to support this
functionality. To prevent a security hazard, the env var is checked only
if a special build-time flag is enabled.
2021-02-11 12:51:40 -08:00
Ben Doherty
3f32146849 Fix Android compilation error in UbershaderLoader (#3526) 2021-02-09 10:50:19 -08:00
Ben Doherty
1516b135fd matc: Use consistent params for semantic code analysis (#3524)
When running semantic analysis on a material, we were arbitrarily choosing the first code gen permutation to analyze. So, running matc with arguments --api metal versus --api all would run analysis on slightly different shader code. This causes bugs when flags passed to glslang differ during semantic analysis. This change updates all semantic analysis to always use the same shader code.
2021-02-08 14:06:11 -08:00
Philip Rideout
7b7d63a91f Fix ubershader regression with Transmission / Sheen. 2021-02-08 13:04:25 -08:00
Philip Rideout
297f3d9808 Fix logcat spam with ubershaders.
Since the ubershader does not have variants for clear coat, the dummy
texture there should be unconditional.
2021-02-05 09:07:58 -08:00
Ben Doherty
07ddd52dcf Add getVertexIndex API for vertex shaders (#3493) 2021-02-04 12:40:21 -08:00
Philip Rideout
2e8df10e6e Quaternion slerp: ensure "short path" when falling back to lerp.
I noticed that our slerp function sometimes produces a jolt in
animation, but only when the time delta is very small, and only when the
two operands have completely opposing signs.

For example, let's say you are slerping from <0.76, 0.39, 0.51, 0.19>
to <-0.72, -0.45, -0.49, -0.17>.

These quats are actually quite near to each other because the total
negation of the second quat is similar to the first quat.

We were already doing the short path check in the proper slerp path, but
not when falling back to lerp due to a small angle.
2021-02-01 14:35:05 -08:00
Philip Rideout
98ae61ffe5 gltfio: Fix "_maskThreshold not found" error.
MaterialGenerator selects a custom blend mode for transmissive models,
therefore the AssetLoader should look at the material's blend mode when
it sets up properties, not the one requested by the glTF file.

Fixes #3444.
2021-02-01 09:52:06 -08:00
Philip Rideout
893ed861e9 gltfio on Java: free material cache in AssetLoader#destroy
Fixes #3469
2021-01-29 14:42:54 -08:00
Romain Guy
4567b01c1d Multi-thread shaders generation when compiling materials (#3464)
* Stop using members as globals between methods

* Multi-thread shaders generation with JobSystem

* Pass JobSystem to MaterialBuilder::build()

* Fix MeshAssimp to use the new API

* Allow the Java API to pass a job system via Engine

* Update docs

* Apply suggestions from code review

Co-authored-by: Philip Rideout <philiprideout@gmail.com>
2021-01-29 09:30:37 -08:00
Philip Rideout
29315f9a1b gltfio: fix crash during async texture decode.
Recall that we now use shared_ptr to simplify lifetime management of
cgltf source data (#3413).

Before this commit, we were only using shared_ptr to retain the source
data during buffer uploads. After this commit, we are using it to retain
source data during texture decoding.

Fixes #3428.
2021-01-29 09:06:32 -08:00
Ben Doherty
d4a2d30a1c Fix sporatic data race warning seen in Google3 (#3462) 2021-01-27 16:38:38 -08:00
Philip Rideout
cec5f3e988 gltfio: disable shader optimizations by default
Note that ubershaders (which are always used on Android and WebGL) are
still optimized by default.
2021-01-27 11:40:51 -08:00
Adrian Perez
5ab7a9e3ab Add swap() methods to Allocator.h (#3445)
* Add swap() methods to Allocator.h

This allows StructureOfArraysBase's move constructor to compile.
Removed an apparent workaround in SingleInstanceComponentManager.

* swap can be noexcept

* Add swap() methods to Allocator.h

This allows StructureOfArraysBase's move constructor to compile.

Co-authored-by: Mathias Agopian <pixelflinger@gmail.com>
2021-01-22 15:45:20 -08:00
Philip Rideout
243ba77025 gltfio: support animation in dynamically-added instances.
I tested this by viewing CesiumMan with our `gltf_instances` sample app.

There is now a need for some general refactoring in gltfio. I feel that
the high-level objects have become too tightly coupled to each other.

Fixes #3137.
2021-01-19 16:37:54 -08:00
Mathias Agopian
af82aaa0fc remove unused code that causes warnings 2021-01-15 14:38:01 -08:00
Mathias Agopian
410ecfd014 support for Apple Silicon macs
- add darwin-aarch64 support to bluegl
- remove all aarch64 conditions in our cmakefiles, the architecture
  is better handled in the source files (to allow fat binaries later)
2021-01-15 14:02:19 -08:00
Philip Rideout
8252bbe512 gltf_viewer: fix very sporadic crash when exiting.
This could occur when trying to exit the app while textures
are still being decoded.
2021-01-13 09:48:36 -08:00
Philip Rideout
a4817f3e2a Simplify lifetime management of cgltf_data.
The gltfio API allows users to destroy ResourceLoader or FilamentAsset
even when various asynchronous work (e.g. uploading buffers to the GPU)
has not yet been completed. This was achieved in an error-prone manner
using manual reference counting and an internal management object called
AssetPool.

This PR refactors gltfio by wrapping cgltf_data in shared_ptr, which I
usually try to avoid. However in this case it provides the precisely the
functionality that is needed.

I tested this PR for memory leaks and crashes by hacking gltf_viewer
and monitoring memory usage in Activity Monitor.

This fixes #3383 and makes it easier to implement some missing features,
such as animation support for instanced assets.
2021-01-13 09:44:56 -08:00
Philip Rideout
fa879b4bd0 gltf_viewer: call asyncCancelLoad in drop handler
Relates to #3383
2021-01-08 09:40:39 -08:00
Philip Rideout
5c666c254e gltfio: Improve robustness when decoding textures.
Bad texture files would cause the background decoder thread to never
finish and would generate textures with 0x0 dimensions, which eventually
triggers GL_INVALID_VALUE.

To recap, gltfio texture loading has two phases: the first phase is
synchronous and uses stbi_info to gather texture info. The second phase
is asynchronous and uses stbi_load to do the actual decoding.

During the first phase, we now check the return code from stbi_info
rather than assuming that it worked.  :)

Fixes #3344
2021-01-05 12:00:29 -08:00
ritwik
a09c17bd4f Make install gltfio_resources and gltfio_resources_lite for desktop builds also 2021-01-05 10:35:13 -08:00
Romain Guy
eb70fd5dee Sample the proper channel for sheenRoughness 2020-12-12 18:05:02 -08:00
Romain Guy
986a3869cc Fix struct initialization 2020-12-12 17:40:48 -08:00
Romain Guy
9ad3d88d74 Fix build breakage.
We were declaring one too many material properties which would
lead to out of bounds writes/reads.
2020-12-12 12:04:24 -08:00
Romain Guy
2895530e09 Add support for sheenColor and sheenRoughness (#3358)
* Add support for sheenColor and sheenRoughness

This work is necessary to support the glTF extension KHR_materials_sheen.
This change effectively adds the specular lobe from the cloth material
model to the base material model. The cloth model remains useful for
its extra subsurface color feature but also because it's cheaper.

* Add support for KHR_materials_sheen to gltfio

* Update documentation

* Document default shading values
2020-12-12 11:07:40 -08:00
Philip Rideout
b70eea9556 filamat: minify struct fields.
This shrinks the arm64 so file by 24 KiB.
2020-12-10 11:20:14 -08:00
Philip Rideout
3bd066f993 math: reduce template bloat for matrices
This does not change our API, it merely reduces the number of
non-inlined function instantiations appearing in non-optimized binaries.
2020-12-10 11:19:46 -08:00
Philip Rideout
1b10afa9e6 Code review fixups for libibl_lite. 2020-12-10 11:19:36 -08:00
Philip Rideout
024910ba8e libibl: use C callback for progress 2020-12-10 11:19:36 -08:00
Philip Rideout
f2e3a132db Add libibl_lite. 2020-12-10 11:19:36 -08:00