Commit Graph

968 Commits

Author SHA1 Message Date
Philip Rideout
70dba2398e gltfio: add createInstance() to AssetLoader.
Note that this API is on the loader rather than the asset. This is
because the loader knows how to create Filament entities by traversing
a cgltf node hierarchy.

Animation on dynamically added instances is not yet supported.

We did not add destroyInstance() because gltfio favors flat arrays for
long term storage of entity lists and instance lists, which would be
slow to shift. We also wish to discourage create/destroy churn since it
is more efficient to pre-allocate instances and selectively add them
into the scene.

Fixes #3137.
2020-11-02 09:47:14 -08:00
Philip Rideout
47521d70a1 gltfio: fix ASAN issue when consuming invalid animation.
Release builds do not call cgltf_validate() so it was possible to
read out-of-bounds animation data when encountering a badly formed glTF
file with mismatched counts between sampler inputs and outputs.
2020-10-31 15:17:15 -07:00
Philip Rideout
468992f4cd gltfio: do not segfault on invalid primitives. 2020-10-31 13:28:13 -07:00
Philip Rideout
6abef94d95 mathio: add ostream operator for quaternions. 2020-10-29 17:04:03 -07:00
Philip Rideout
2fe4f6cbe7 AutomationEngine: fix regression with screenshots. 2020-10-28 12:58:54 -07:00
Philip Rideout
1159435d47 gltfio: add safety checks to getAnimator. 2020-10-28 11:51:06 -07:00
Philip Rideout
a6f364e0f3 gltfio: fix segfault when consuming invalid file. 2020-10-28 11:50:54 -07:00
Philip Rideout
c6942a52e6 gltfio: refactor the instancing cache.
This prepares for #3137 by moving the mesh cache and material instance
cache out of the loader (where they were transient anyway) and into the
actual asset. This paves the way for a `createInstance()` API.
2020-10-27 10:30:18 -07:00
Philip Rideout
d84bb82e44 Merge duplicated implementations of toLinear(). 2020-10-22 17:03:06 -07:00
Philip Rideout
2e10fe6680 PlatformVkLinux now supports all combos of XLIB and XCB.
You can now build Filament with support for both X11 APIs, or neither.
If both are supported, run-time selection is achieved using a SwapChain
flag.

Supporting only one API at build time (or neither) is useful because our
list of "required" VkInstance extensions can vary according to which
API's are supported. During VkInstance creation, we do not have a priori
knowledge about what kinds of swap chains will be created. (headless vs
non-headless, XCB vs XLIB, etc)

Note that some Vulkan implementation (e.g. some builds of SwiftShader)
only support XCB.
2020-10-22 16:55:25 -07:00
dsternfeld7
4533a42a6f Makes it possible to have multiple instances of ImGuiHelper at the same time
This change fixes an issue where ImGuiHelper would crash on destruction if you created more than one instance at the same time.

This crash occurred when ImGui::DestroyContext() was called, because when the second instance was destroyed there was no current context causing it to crash.

This fixes it by making ImGuiHelper store and manage it's own context.

Having two instances of ImGuiHelper is useful in cases where you want to use imgui with multiple views.
2020-10-22 11:39:33 -07:00
Ben Doherty
239246e221 Add ability to specify post-process material output location (#3205) 2020-10-21 12:19:46 -06:00
Philip Rideout
75c4f36f96 Add Dockerfile and test script for SwiftShader.
This adds a Dockerfile and a new bash script that makes it
east to invoke the appopriate Docker commands.

This does not yet enable a GitHub Action because of intermittent
issues that we have not yet ironed out.
2020-10-21 10:50:25 -07:00
Ben Doherty
e7250571e7 Add subpass parameter type to materials (#3193) 2020-10-19 16:28:26 -06:00
Philip Rideout
5ceb9fc5d5 Add optional XCB support to PlatformVkLinux.
This allows clients to build the Vulkan backend with either XLIB or XCB
support. I did a quick smoke test of the XCB option, but for now we are
continuing to default to XLIB. Note that the native window type used to
create the swap chain differs between these two API's.
2020-10-19 09:24:13 -07:00
Ben Doherty
d14ba856a7 matc: fix some compilation failures still exit with code 0 (#3192) 2020-10-15 14:11:46 -06:00
Ben Doherty
62d06592d3 VSM: add support for mipmaps and anisotropic sampling (#3185) 2020-10-14 11:48:23 -06:00
Philip Rideout
37768ed9e1 Various changes to help clients upgrade Filament.
The non-const getSkybox() method is especially useful to client code
that needs to change the clear color, but does not have direct
access to the Renderer object.
2020-10-13 10:10:59 -07:00
Philip Rideout
20abfec7d3 Minor change to adhere to CODE_STYLE. 2020-10-12 11:15:45 -07:00
Philip Rideout
b82dca4fac JobSystem: work around hang on 2-CPU machines
If hardware_concurrency() returned 2 while UTILS_HAS_HYPER_THREADING was
enabled, `mThreadCount` was resulting in zero, so jobs (such as texture
decoding) would simply never start. This problem was noticed with
GitHub Actions.

I tested this fix locally by replacing `hardware_concurrency()` with
fixed values like 1 or 2, and verified that the hang went away.
2020-10-09 16:14:50 -07:00
Philip Rideout
5ebc6bce04 Add schema for automation specs.
This can help when authoring a spec using your favorite text editor.
2020-10-09 10:23:27 -07:00
Philip Rideout
7471237178 Linux fixes for headless SwiftShader. 2020-10-07 11:24:33 -07:00
Yixing Lao
9ce2c319a9 ARM64 support for bluegl (#3150)
* ARM64 support for bluegl

* Detect arch with uname

* Use register x16
2020-10-05 10:19:05 -07:00
Philip Rideout
4fe5832333 gltf_viewer: add --headless option.
This should only be used in combination with --batch. Users are
admonished if they try using it on its own.
2020-10-04 10:02:10 -07:00
Philip Rideout
79f1744823 Automation: fix segfault when closing the app early.
The Filament View that gets passed to tick() is retained briefly when
screenshots are enabled, but it may be destroyed by the time the
PixelBufferDescriptor callback is invoked. So, we needed a way of
notifying the AutomationEngine.
2020-10-04 10:01:43 -07:00
Philip Rideout
e352542e24 Automation: add support for materials.
This adds a `material` key to `Settings`, as a sister to `view`.

Here's an example of an automation spec that manipulates material
parameters:

    [{
      "name": "metallic_vs_roughness",
      "permute": {
          "material.scalar.roughnessFactor": [0.0, 0.5, 1.0],
          "material.scalar.metallicFactor": [0.0, 1.0]
      }
    }]

Currently this is limited to float, vec3, and vec4 parameters.
2020-10-02 11:57:23 -07:00
Philip Rideout
5938242d61 gltf_viewer: Add automation UI and functionality.
This adds `AutomationEngine` to libs/viewer, which iterates through
`Settings` instances that were generated from a JSON spec and applies
them to a Filament `View`. It can be configured to sleep between tests
using a time delay or a frame count.

This also adds command line arguments and user-interface elements to
`gltf_viewer` for automated testing.
2020-10-02 11:00:26 -07:00
Philip Rideout
cfddd5b273 Rename AutomationList to AutomationSpec. 2020-10-01 19:07:24 -07:00
Philip Rideout
8a865e531e gltf_viewer: minor refactoring 2020-10-01 17:15:25 -07:00
Philip Rideout
fd142b9b84 gltf_viewer: add --settings, prep for automation. 2020-10-01 16:41:24 -07:00
Philip Rideout
6658283617 FilamentApp: Do not call postRender when skipping. 2020-10-01 16:41:24 -07:00
Pixelflinger
8b3caeffb9 ssct: decouple shadow distance from sample count 2020-10-01 10:20:38 -07:00
Philip Rideout
5fae33bde5 Automation: simplify API by flattening the test cases. 2020-09-30 16:17:23 -07:00
Philip Rideout
43cc5f9906 Automation: add a built-in default spec. 2020-09-30 16:17:23 -07:00
Philip Rideout
902eb32e3c Fix typo in copyright headers. 2020-09-30 16:17:23 -07:00
Philip Rideout
08f7973d0c Refactor Automation API. 2020-09-30 16:17:23 -07:00
Philip Rideout
a736b8b018 Rename parse.h to jsonParseUtils. 2020-09-30 16:17:23 -07:00
Philip Rideout
094e7169cc Introduce a configurable test case generator.
This lets us generate long lists of settings permutations by writing a
simple JSON spec. For example, the following spec would generate six
`Settings` objects, all of which have SSAO enabled. See the unit test
for a larger example.

```
{
    "name": "viewopts",
    "base": { "view.ssao.enabled": true }
    "permute": {
        "view.dithering": ["NONE", "TEMPORAL"],
        "view.sampleCount": [1, 4, 8]
    }
}
```
2020-09-30 16:17:23 -07:00
Ben Doherty
236ed9680c Add MSAA option to VSM (#3084) 2020-09-30 14:51:40 -06:00
Philip Rideout
451fac7d7b Fix writeJson() for vectors and enums. 2020-09-30 11:12:10 -07:00
Philip Rideout
617dc932bb Fix unit test failure. 2020-09-29 19:59:53 -07:00
Pixelflinger
583c1c07cf SSCT optimizations and fixes
- Use lower depth LOD as the cone radius increases.
  This is the same technique we use for SAO.
  The better cache access significantly improve performance.
  On a test on Pixel4 at 585MHz, SAO pass improves by 30%.
  This also helps the algorithm scale with the shadow distance.

- Shadow direction/length no longer dependent on aspect-ratio and camera
  orientation.
  This is fixed by doing all the computations in screen-space instead of 
  normalized screen space.

- Shadow parameters are no longer dependent on the field of view.

- Also rename dominantLightShadowing.fs to ssct.fs

- remove zoom parameter, it wasn't very useful.
2020-09-29 17:00:32 -07:00
Philip Rideout
ec2579bad5 Viewer Settings: remove SSCT scale. 2020-09-29 10:47:35 -07:00
Philip Rideout
e5a9a259de Fix build break. 2020-09-29 10:47:35 -07:00
Philip Rideout
6472f645fc viewer: add SCCT to JSON serializer. 2020-09-29 10:47:35 -07:00
Philip Rideout
e9ace4e5fb Add jsmn to third_party. 2020-09-29 10:47:35 -07:00
Philip Rideout
c119f9bdca gltf_viewer: Re-use ViewSettings structs. 2020-09-29 10:47:35 -07:00
Philip Rideout
7997e4aa21 Introduce libs/viewer and serializable view settings.
This introduces the `viewer::Settings` struct, and a JSON reader /
writer.

This will be used for automated testing and for client / server
communication.

Note that `viewer::Settings` is closely associated with the
`filament::View` API; when updating the latter we will often need to
update the former, as well as some serialization code. This increases
the maintenance burden and I think we should consider using a parser
library like libclang or a macro-based reflection utility.

This PR also migrates SimpleViewer into libs/viewer and un-inlines its
implementation. It does not belong in gltfio because it has an imgui
dependency.
2020-09-29 10:47:35 -07:00
Pixelflinger
bfd1de809a Implement screen space cone tracing (SSCT)
This is a technique from Naughty Dog used in TLOU2, where we compute
the "ambient" shadowing of a dominant light in screen-space.

This is currently integrated to the SSAO pass.
2020-09-28 10:53:30 -07:00
Pixelflinger
0f2993aec7 Decouple SSAO bilateral filter from quality setting 2020-09-28 10:53:30 -07:00