Compare commits

..

182 Commits

Author SHA1 Message Date
Benjamin Doherty
18d7cf980b Merge branch 'rc/1.56.7' into release 2025-01-29 16:41:19 -08:00
Mathias Agopian
031981a72c Fix ShadowMapManager ShadowMap alignment (#8398) 2025-01-29 11:56:32 -08:00
Mathias Agopian
a495d90110 mistakenly enabled the Shadow Atlas feature 2025-01-27 22:16:09 -08:00
Benjamin Doherty
9686b3e294 Bump version to 1.56.7 2025-01-16 13:00:04 -08:00
Benjamin Doherty
69a327c7e7 Merge branch 'rc/1.56.6' into release 2025-01-16 13:00:03 -08:00
Benjamin Doherty
e1024123c1 Release Filament 1.56.6 2025-01-16 12:59:55 -08:00
Mathias Agopian
24ae0b20f3 Fix wrong comment on unlikely directive
Fixes #8325
2025-01-16 10:52:11 -08:00
Mathias Agopian
288e81fb31 Fix DEBUG_COMMAND_STREAM mode
Fixes #7966
2025-01-16 10:51:56 -08:00
Powei Feng
c435fc74c4 renderdiff: add initial code for updating goldens (#8349)
- Code for parsing tag in commit message
- Add placeholder for pulling and updating goldens in the script.
2025-01-16 07:08:48 +00:00
Mathias Agopian
eac99e5796 remove all remaining references to SamplerGroup 2025-01-15 16:17:16 -08:00
Powei Feng
97e7058037 docs: add script to download mdbook (#8351)
We add a bash script to download and install mdbook. For
linux or mac x86_64, we download prebuilts from github.
Otherwise, we use `cargo install` to build it with rust.
2025-01-15 22:18:47 +00:00
Ben Doherty
ac0aea98c9 Fix Web build, update Emscripten SDK to 3.1.60 (#8350) 2025-01-15 11:42:39 -08:00
Powei Feng
026b985c07 docs: new page with mdbook (#8342)
- Use mdbook to generate a book from collection of documents
 - documents are
     - copied and processed from READMEs
     - original content stored in the docs_src folder
     - markdeep docs transformed into embedded html
 - Main logic is in script docs_src/build/run.py
2025-01-14 06:56:30 +00:00
Powei Feng
65c30f3199 renderdiff: fix llvm-18 dep problem (#8347)
The public dep for mesa has moved on to beyond llvm-18, but the
version we're compiling against is not supported by this change.
We workaround by ensuring that the llvm dep is less than 18 but
consistent with the clang version.
2025-01-13 23:34:42 +00:00
Powei Feng
da99a0385c vk: print error code on failure for vk calls (#8348)
Fixes #8186
2025-01-13 15:18:52 -08:00
Mathias Agopian
37fd83af66 Add support for an Atlas allocator for shadow maps
This feature is controled by a feature flag and is turned off at this point.
This CL shouldn't change the existing behavior of shadowmap allocation as
long as the atlas feature is not enanled.

When enabled, shadowmap allocations are not limited to layers of the
shadowmap texture, instead, an atlas is used meaning a layer can
be shared by multiple shadowmaps. At the very least this can save
a lot of memory as smaller shadowmaps can be packed together.

Currently this feature breaks some VSM features:
- mipmapping
- blurring
2025-01-13 15:10:14 -08:00
Mathias Agopian
3abf131066 Trivial clean-ups that shouldn't affect the behavior
We add an offset to the shadowmap viewport, but in this change
it is always set to (0,0)
2025-01-13 15:10:14 -08:00
Mathias Agopian
2b0077eea2 AtlasAllocator fixes
- when inserting an entry at a root other than zero, we need to update
  the children count of the root's parent.

- the QuadTree array nodes need to be able to encode enough indices for
  the largest "layer" in the tree. With 7 layers the largest one has
  4096 entries, so we need 12 bits, not 8.
2025-01-13 15:10:14 -08:00
MinGyuJung1996
90a4c88a0c Fix: combine-static-libs.sh in macos universal 2025-01-13 14:18:38 -08:00
Mathias Agopian
d524bca73d fix a typo that prevented some spot shadows to appear 2025-01-13 14:15:44 -08:00
Sungun Park
d5bcc31c71 Merge branch 'rc/1.56.5' into release 2025-01-08 21:59:23 +00:00
Sungun Park
95894f9634 Bump version to 1.56.6 2025-01-08 21:59:23 +00:00
Sungun Park
29d2d819e3 Release Filament 1.56.5 2025-01-08 21:59:14 +00:00
Ben Doherty
863b1346e1 Rename IOS define to FILAMENT_IOS (#8340) 2025-01-08 13:11:39 -08:00
Powei Feng
f0b9a30bc1 matdbg: add option to hide inactive materials and variants (#8339)
The option will persist beyond user sessions through localStorage.
2025-01-07 19:42:17 +00:00
Powei Feng
a003d3721d matdbg: enable source formatting (#8338)
We use clang-format to format the shader files. Since we assume
clang is necessary for compilation, installing clang-format should
not be too much of an overhead in terms of adding dependency.

Currently, we only support posix systems (macOS, linux).
2025-01-07 18:11:12 +00:00
Mathias Agopian
ef6ef784c9 external textures are no longer restricted to SAMPLER_EXTERNAL
OpenGLES allows this when GL_OES_EGL_image is present.
2025-01-07 09:50:57 -08:00
Mathias Agopian
7d271cea1d remove backend deprecated and unused APIs 2025-01-07 09:50:57 -08:00
Powei Feng
7d0b652663 matdbg: fix two memory bugs (#8337)
- murmur3 expects word size not byte size
 - should use uint8_t in addressing blob source.

both would crash when asan is enabled.
2025-01-06 18:33:25 +00:00
seker
8c1e028b46 Fix : null pointer crash (#8326) 2024-12-30 11:42:18 -08:00
Doris Wu
757e3c57d8 Add skeleton code of fgviewer (#8303)
* Skeleton of fgviewer debug server

* Update the map for fg info

* Add ApiHandler skeleton class

* Format the files

Format the file

* Prevent fgviewer being built before ready

Add comment to fgviewer related lines

Fix cmake commands

* Update the copyright

* Address the comments

Address the comments

* Address the comments

* Specify the debug server

* Fix build options
2024-12-20 23:20:54 +08:00
Powei Feng
aa09d86b5a matdbg: Fix material collision (#8322)
Fix 3 bugs wrt matdbg:

1. The numbering scheme for materials with same name was buggy
2. The shared depth variants of the default material should also
   show up as active material variants.
3. When two instantiation of FMaterial point to the exact same
   bits, we still need to treat them as two materials. (Otherwise
   we wouldn't be able to modify one of them in matdbg).
2024-12-19 20:14:08 +00:00
Ben Doherty
1f1389e668 Metal: avoid crashing for invalid programs (#8321) 2024-12-19 10:00:51 -08:00
Pei Jia
32abd9ea90 Solve the bug: filament error: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'value_type' (aka 'filament::DescriptorSet::Desc') [-Werror,-Wnontrivial-memcall]
152 |     memcpy(set.mDescriptors.data(), mDescriptors.data(), mDescriptors.size() * sizeof(Desc));
2024-12-18 11:46:13 -08:00
Mathias Agopian
8724995042 TAA fixes and improvements
- use a lanczos filter for sampling the color buffer, instead of a
  blackman-Harris window. This improves sharpness quite a bit.

- some cleanups of the shader code

- never use YCoCg when rectification is not enabled.

- fix the calculation of the confidence paramter when upscaling is used.


Upscaling works a lot better now, but it is still work in progress.
2024-12-17 21:49:00 -08:00
Mathias Agopian
e75bf2f40f Fix an assert that prevented instancing to work
FIXES=[384588566]
2024-12-17 21:48:13 -08:00
Powei Feng
4695e93633 Merge branch 'rc/1.56.4' into release 2024-12-17 16:39:38 -08:00
Powei Feng
b332bf376f Bump version to 1.56.5 2024-12-17 16:39:38 -08:00
Powei Feng
45b0164c84 Release Filament 1.56.4 2024-12-17 16:39:29 -08:00
Powei Feng
8ddc4d3060 Fix compilation material failure log (#8317) 2024-12-18 00:27:05 +00:00
Mathias Agopian
377a1106aa Add a way to set the shadow sampling quality
FIXES=[379754325]
2024-12-17 16:07:40 -08:00
Doris Wu
6a547639d1 Specify the source of server log (#8313) 2024-12-14 10:28:59 +08:00
Mathias Agopian
d2e85290fe update web samples and remove ui 2024-12-12 22:21:42 -08:00
Powei Feng
aaac6e7662 renderdiff: allow for explicit (compile-time) linking of osmesa (#8301)
If the shared osmesa lib is not found, then we assume that the
library has been compile-time linked via the linker.  This is to
accommodate build frameworks where compile-time linking is
preferred.
2024-12-12 10:56:29 -08:00
Powei Feng
49d89298f8 renderdiff: allow for explicit (compile-time) linking of osmesa (#8301)
If the shared osmesa lib is not found, then we assume that the
library has been compile-time linked via the linker.  This is to
accommodate build frameworks where compile-time linking is
preferred.
2024-12-12 06:22:43 +00:00
Powei Feng
6a772bf715 vk: fix typo that caused debug builds to fail (#8309) 2024-12-11 19:39:04 -08:00
Powei Feng
23847c4314 vk: Use-after-free coverage (#8273)
To allow for use-after-free discovery with ref-counting, we keep
a bit to indicate whether the handle is considered destroyed by
Filament. We assert against "cast"-ing a destroyed handle.
2024-12-12 00:53:00 +00:00
Thoren Paulson
96278f7999 Fix shadow cascade calculatioins
The `ShadowCascade` functions for computing splits all attempted to clamp `cascades` to [0,4] (evidently to avoid out-of-bounds access), but used `max`, instead giving a range of [4, x].

For applications using less than 4 cascades, this results in incorrect split locations and lower quality (much more obvious seam between cascades).

This change just switches to use `min` to ensure `cascades` is in the range [0,4].
2024-12-11 16:21:44 -08:00
Mathias Agopian
ba6bee10f7 matc: remove access to public functions that should be undefined
When tangents are not supplied in a material, all "normals" related
public methods become undefined; remove access to them so we get 
compile time errors instead of garbage values in the shader.
2024-12-11 12:49:05 -08:00
Serge Metral
93790cd06c Android hardware buffer import in Vulkan (#8295)
- Platform changes for the extensions
- Platform changes for the processing of the AHB
2024-12-11 19:00:42 +00:00
Sungun Park
8ef8b345ae Merge branch 'rc/1.56.3' into release 2024-12-11 02:17:56 +00:00
Sungun Park
2cc375e4cc Bump version to 1.56.4 2024-12-11 02:17:56 +00:00
Sungun Park
94c1657ca0 Release Filament 1.56.3 2024-12-11 02:17:39 +00:00
Mathias Agopian
776a748e05 fix a ResourceList<> "soft" leak when destroying a material
A ResourceList<> object was leaked when destroying a material until the 
Engine was shut down. This could however grow unbounded if churning 
through Materials.

What was actually leaked was entries in the hashmap linking a material
to its material instance list.

BUGS=[383158161]
2024-12-10 14:22:57 -08:00
Mathias Agopian
03fdadf417 Fix ARC objects leak in MetalShaderCompiler thread
When using async shader compilation, the compiler thread pool is a 
standard pthread and not an NSThread. Therefore, it needs a manual
@autorelease pool, otherwise ARC objects never get truly released. 

BUGS=[383167935]
2024-12-10 14:22:40 -08:00
Mathias Agopian
592c91f20e pre-populate the default material's depth variants
This restores the old behavior with depth variant caching. We pay the
price at engine init time, instead of when the variant is needed the
first time. We can revisit this later.

Note that the default material doesn't have all possible depth variants
(e.g. VSM), but that pre-caches the most popular ones.

BUGS=[381946222]
2024-12-09 18:18:19 +00:00
Mathias Agopian
6b7080e8b6 fix a use-after-free of texture handles
Because ColorPassDescriptorSet is used for both the color pass and the
picking/ssr/structure passes, the texture it holds can be stale.

In this CL we fix this by reseting the offending textures when preparing
the picking/ssr/structure passes. This has a side effect of recreating
the descriptor-set internally. A better fix would be to use separate
descriptor-sets for these two cases and rely on the texture cache
to avoid recreation from a frame to the next.

BUGS=[376705346]
2024-12-06 21:48:56 -08:00
Mathias Agopian
6bb7f890ef pre-populate the default material's depth variants
This restores the old behavior with depth variant caching. We pay the
price at engine init time, instead of when the variant is needed the
first time. We can revisit this later.

Note that the default material doesn't have all possible depth variants
(e.g. VSM), but that pre-caches the most popular ones.

BUGS=[381946222]
2024-12-05 15:59:39 -08:00
feelamee
4ea3f7476d Fix typo in Camera doc comment 2024-12-04 21:48:32 -08:00
Mathias Agopian
b48a1556b6 Fix a couple depthClamp issues on metal
- depthClamp is only supported from iOS 11.0
- reset the depthClamp state at the beginning of the renderpass


BUGS=[379729888]
2024-12-04 21:47:56 -08:00
Mathias Agopian
8088db6282 Fix scissor with negative left/bottom
When a viewport with a negative left/bottom was used, an assert would
trigger on debug builds and release builds would get a wrong scissor.

This bug was introduced recently, we now do the offset/clipping math
in 64 bits, which is way simpler and convert back to Viewport at
the end.

BUGS=[381902791]
2024-12-02 22:34:51 -08:00
Mathias Agopian
5817ddf248 update web docs 2024-12-02 22:34:14 -08:00
Mathias Agopian
04de23aaa1 Attempt to fix WebGL build on Qualcomm hardware
The workaround which were intended to be used with the native driver
only, were picked-up by the webgl backend when running on firefox,
probably because of the different GL string.

BUGS=[380425595]
2024-12-02 21:17:29 -08:00
Romain Guy
e1c7a643ed Copy back local values to Java array (#8290)
When releasing array elements, we need to pass 0 as the
last argument if we want to copy local chnages back to
the Java array. JNI_ABORT should only be used when we
don't want the copy, i.e. when the array is read-only.

Fixes issue #8278.
2024-12-02 21:41:57 +00:00
Powei Feng
04b62960de Merge branch 'rc/1.56.2' into release 2024-11-25 15:46:04 -08:00
Powei Feng
e2492dfde8 Bump version to 1.56.3 2024-11-25 15:46:04 -08:00
Powei Feng
2381551ab9 Release Filament 1.56.2 2024-11-25 15:45:52 -08:00
Evan Mezeske
16bab2479a When applying animations, allow the time to be exactly equal to the duration before taking the fmod(), so that it is possible to animate to the exact last keyframe. Without this change, trying to animate to the last keyframe wraps back to the first, which only works for animations that loop. (#8287) 2024-11-25 09:47:28 -08:00
Mathias Agopian
64eb27af8a fix a HwProgram leak related to depth variant pre-caching (#8276)
* fix a HwProgram leak related to depth variant pre-caching

Materials that don't use a custom depth can share the same program for
all depth variants. We take advantage of that by pre-caching the
depths variants when a program is loaded. The depth variants themselves
are owned by the default material which is created first. When a
material is destroyed it skips deletion of those variants which will
be truly destroyed when the default material is destroyed.

Unfortunately, the default material doesn't contain all depth variants,
in particular, it doesn't have the VSM ones (because it's an unlit
material).  On top of that, the way it pre-cached depth variant had
a bug that made it miss some picking variants.

Because of that, these variants were skipped during material destruction
but never actually destroyed, since the default material didn't know
anything about them.

This PR fixes this by making the pre-caching completely lazy. When
any material needs such a "precacheable" variant, it first checks if
the default material has it. If not, it creates the variant, caches it
locally and forwards it to the default material, which implicitly
becomes the owner. Just like before newly created material precache
everything the default material already has.

With this mechanism, it's impossible to have a depth variant without it
also existing in the default material.

This also simplify the non-public invalidate() method, which doesn't
need to populate the pre-cached programs, since this will happen
naturally when needed.

There was also another issue where post-process materials were
handled like regular materials. This didn't cause an problem but was
inefficient since these only have a handful of variants.

* Update filament/src/details/Material.cpp

Co-authored-by: Powei Feng <powei@google.com>

---------

Co-authored-by: Powei Feng <powei@google.com>
2024-11-19 22:38:30 -08:00
Doris Wu
98585bdc30 Disable transparent picking by default 2024-11-19 22:37:51 -08:00
Powei Feng
0803987df3 samples: clean-up automation objects in gltf-viewer (#8285) 2024-11-19 15:38:28 -08:00
Sungun Park
60ce48e327 Merge branch 'rc/1.56.1' into release 2024-11-19 17:20:17 +00:00
Sungun Park
7588189874 Bump version to 1.56.2 2024-11-19 17:20:17 +00:00
Sungun Park
ffd32e9309 Release Filament 1.56.1 2024-11-19 17:20:09 +00:00
Sungun Park
b6a69fba18 Update missing version bumps from last update 2024-11-19 17:19:22 +00:00
Sungun Park
a3bfad95ab Bump material version to 56 (#8281)
Fix the material version correctly.
2024-11-18 16:08:06 -08:00
Sungun Park
b587028aa5 Bump material version to 56 (#8281)
Fix the material version correctly.
2024-11-19 00:04:15 +00:00
Powei Feng
43b9c06f79 vk: increase number of command buffers (#8271)
Small number of pre-allocated command buffers can cause
unnecessary blocking on the CPU.  We increase this number.
2024-11-14 19:24:29 +00:00
Powei Feng
05ffc76032 vk: clean up group marker logic (#8272)
The old logic was unnecessarily complex. We simplify it and also
properly store the marker stack on the CommandPool instead of
VulkanCommands.
2024-11-14 19:11:17 +00:00
Ben Doherty
8e5ba51718 Fix TSAN warning in MetalHandles (#8262) 2024-11-14 10:12:53 -08:00
Mathias Agopian
8aa9c4d004 Don't use AtomicFreeList to squash TSAN complains
The previous fix attempt didn't work on some test. There are no known
bugs with AtomicFreeList other than tripping TSAN, and it's unclear
that TSAN isn't at fault.

However, switching to using a mutex works fine and doesn't appear to
be slower (it's actually faster with synthetic benchmarks on macOS)

BUGS=[377369108]
2024-11-14 10:00:00 -08:00
Mathias Agopian
d075a877f2 Fix TSAN warnings with AtomicFreeList
I do not think there was an actual error with AtomicFreeList, however
TSAN detected a data race when concurrent pop() happened. In that case,
there is indeed a race, where we can end-up reading data that is
already corrupted by the concurrent pop. However, that situation is
corrected by the following CAS. Somehow TSAN didn't see that.
The fix is strange and consists in replacing:
```
auto pNext = storage[offset].next;
```

with

```
auto s = storage[offset];
auto pNext = s.next;
```

In this PR we also adjust the memory ordering to be less strong. i.e.
we do not need `memory_order_seq_cst`, only the appropriate acquire or
release semantic.

In addition we also make `Node* next` a non-atomic variable again. It
should have been, but was change to placate an older version of TSAN.

BUGS=[377369108]
2024-11-13 21:50:05 -08:00
Mathias Agopian
cf7360bf8b fix uninitialized variable on ES2 devices
On ES2 devices (or in forceES2 mode), we emulate the sRGB swapchain
in the shader if the h/w doesn't support it. In that case, the emulation
is controlled by a uniform that technically lives in the frameUniforms
block. However, the frameUniforms buffer is not updated, instead,
the uniform is manually set. Unfortunately, the UBO emulation
overrides it with the uninitialized variable.

BUGS=[377913730]
2024-11-13 13:54:00 -08:00
Ben Doherty
2a9dcd7c40 Metal: unbind descriptor sets upon destruction (#8268) 2024-11-13 12:21:44 -08:00
Mathias Agopian
5dfd285105 ostream buffer growth was broken
It only grew by 3/2 of the needed size instead of the needed capacity,
which could be extremely slow when growing by a constant amount
many times.
2024-11-12 16:03:35 -08:00
Ben Doherty
51392c77aa Metal: unbind descriptor sets upon destruction (#8268) 2024-11-12 14:08:15 -08:00
mdagois
e78691b12b Forcing profile mode (#8256) 2024-11-12 20:05:08 +00:00
Powei Feng
bc65135c51 vk: refactor resource ref-counting (#8254)
Continuing from PR #8220.

Here we change all of the references from the old ref-counting ways
to the new ref-counting structs and mechanisms. There should be no
functional change.
2024-11-12 10:33:00 -08:00
Serge Metral
0108d66aa1 vk: Implement protected content
- Cache the render buffer in the render pass strucutre
- Enable the proteded path in the Render Target
- Make sure we build the protected version of the depth/color in the swap chaing
- Minor cleanup/restrucuring of the code
2024-11-12 09:10:03 -08:00
1558287830
96443fa1fd vk: fix stage pool gc logic (#8260)
* vk: fix stage pool gc logic

* Update NEW_RELEASE_NOTES.md

---------

Co-authored-by: linkunhai <linkunhai@bytedance.com>
2024-11-12 06:49:12 +00:00
Mathias Agopian
61c4df9503 fix uninitialized variable on ES2 devices
On ES2 devices (or in forceES2 mode), we emulate the sRGB swapchain
in the shader if the h/w doesn't support it. In that case, the emulation
is controlled by a uniform that technically lives in the frameUniforms
block. However, the frameUniforms buffer is not updated, instead,
the uniform is manually set. Unfortunately, the UBO emulation
overrides it with the uninitialized variable.

BUGS=[377913730]
2024-11-11 16:30:24 -08:00
Mathias Agopian
b990652702 assert if post-processing is used at Feature Level 0
We assert in Renderer::render(View*) as early as possible. The
current behavior can result in a SEG FAULT which is harder to debug.
2024-11-11 16:30:24 -08:00
Mathias Agopian
7f7d4d89ea fix some missing highp qualifiers
BUGS=[377751005]
2024-11-08 14:37:34 -08:00
Powei Feng
2b7f325cc7 renderdiff: Use single lib for osmesa (#8255)
Previously, we linked against libOSMesa through the linker and
then used dlopen to link against libGL. This is not how libOSMesa
is intended to be used.  Instead, we use dlopen on libOSMesa
(via bluegl), which then will map the correct GL methods for us,
and for the OSMesa functions, we also map those functions
from libOSMesa (instead of relying on compile-time linker).
2024-11-07 21:55:20 +00:00
Ben Doherty
b9768394a1 Metal: remove cached pipeline states with deleted programs (#8243) 2024-11-07 11:23:30 -08:00
Powei Feng
e726964b85 vk: fix uninitialized param (#8253) 2024-11-06 14:34:38 -08:00
Powei Feng
3e02d5016e vk: fix uninitialized param (#8253) 2024-11-06 22:04:57 +00:00
Benjamin Doherty
483ef2f125 Release Filament 1.56.0 2024-11-06 10:48:24 -08:00
Serge Metral
46dc9e7772 vk: Refactor command buffers to include protected buffers (#8246)
By providing a queue and the family index, we can now create
protected comand buffers that will be submitted to a protected
queue.  The main abstraction is in VulkanCommands.h where we
introduced a CommandBufferPool.

Also did refactor on the "mStorage", fences, and semaphores of
the original VulkanCommands so that each buffer is associated
with one fence and one semaphore.
2024-11-06 00:41:37 +00:00
Mathias Agopian
b8551e50e1 a new Feature Flag API
Feature flags are intended to be used when a new feature is added to 
filament and have generally two purposes:

1) during feature development, the feature can be implemented but
   disabled which can help developing large features. This way the
   feature can be tested by stakeholders while it's being developed
   without impacting other clients.

2) once a feature is ready, its flag can be enabled by default, but 
   in case the feature breaks something or has unintended consequence,
   clients have the option to turn it off.

Feature flags are intended to have a relatively short life span, i.e.
once a feature is stable, the flag fill be removed.

There two types of feature flags. Constant feature flags can only be
set during Engine initialization via Engine::Builder. Non-constant
feature flags can be set at any time. 

Feature flags SHOULD NOT be used as configuration or settings.


Feature flags are designed with a few ideas in mind:
- they are very cheap to check inside the engine
- non-constant flags can easily be toggled using ImGUI
2024-11-05 15:34:56 -08:00
Powei Feng
b64df46522 vk: temporary workaround for sampler external (#8250) 2024-11-05 11:23:51 -08:00
Benjamin Doherty
003e500571 Merge branch 'rc/1.56.0' into release 2024-11-04 15:21:18 -08:00
Benjamin Doherty
72ae60fa64 Bump MATERIAL_VERSION to 56 2024-11-04 09:41:41 -08:00
Benjamin Doherty
06106b7a00 Bump version to 1.56.0 2024-11-04 09:34:10 -08:00
Benjamin Doherty
c7319ac559 Merge branch 'rc/1.55.1' into release 2024-11-04 09:34:09 -08:00
Benjamin Doherty
7f92dfd06c Release Filament 1.55.1 2024-11-04 09:34:01 -08:00
Powei Feng
3304a0c8b6 vk: add resource ref-counting alternative (#8220)
We add a set of classes to the vk backend that will enable
cleaner ref-counting.

In particular, all allocation from the HandleAllocator will be
wrapped within a resource_ptr<> smart pointer. This struct will
maintain a count that will increment/decrement with respect to
references (similar to std::shared_ptr).

This commit only introduces the new classes/structs and does not
actually make any functional difference. A follow-up commit will
make the switch to use the smart pointer.

We also put VulkanFence and VulkanTimerQuery in a different header
because we will need to depend on them separately in the follow-up
(reason: they are accessed on the backend thread but allocated on
"sync"/filament thread).
2024-11-01 21:36:56 +00:00
Ben Doherty
0c2d23e55c Metal: unbind SwapChain upon destruction (#8244) 2024-11-01 14:16:54 -07:00
mdagois
59d1ed6a94 Trace (#8218)
Add performance tracing for GL/VK on Android
2024-11-01 14:11:32 -07:00
Evan Mezeske
33c299d3ba Ignore another warning for vk_mem_alloc.h so that Filament can compile with -Wthread-safety enabled 2024-10-30 11:57:18 -07:00
Mathias Agopian
1cc87aa9af descriptor layouts distinguish samplers and external samplers
BUGS=[376089915]
2024-10-30 11:17:38 -07:00
Serge Metral
eb1b30c7b1 vk: protected content platform (#8226)
Adding the basic mechanisms for creating and managing the protected
state. We also create the queue and get it. Finally we allocate
protected memory. Also removed some of the shared context logic
2024-10-29 21:32:18 +00:00
Mathias Agopian
ecedbad5ba allow bindDescriptorSet() to take a null handle 2024-10-29 11:10:52 -07:00
Ben Doherty
d1998c1b67 Metal: unbind descriptor set with null handle (#8237) 2024-10-29 10:53:24 -07:00
Powei Feng
c2177ab86a vk: implement descriptor set unbind (#8236) 2024-10-29 17:21:13 +00:00
Powei Feng
66abb75bc4 vk: remove incorrect assert 2024-10-28 15:54:09 -07:00
Mathias Agopian
f4d87ad526 prepare rendering loop for multithreading
The goal of this PR is to get closer to being able to run all
FrameGraph passes in parallel. To achieve this we need all data
consumed by the "execute" closure of the FrameGraph passes to be
immutable or thread-safe. We also need the passes to never use the
Engine's global `DriverAPi&` object.

Specifically in this PR, we turn as many objects to `const` as possible
without major changes, and we pass the `DriverApi&` object as parameter
to render passes.

This work is far from being complete. So we also annotate with FIXMEs
all the places we can identify will be problematic (there are probably
others).

The main remaining issues are:
- main allocator is not thread-safe
- some places take a non-const View, Scene or Engine
- lazy allocation of materials and material instance usages are not
  thread-safe.

This PR shouldn't change any behavior.
2024-10-28 12:31:24 -07:00
Evan Mezeske
f2f9c547b0 Fix clang c++20 compilation under debug mode as well. (#8233)
* Fix clang c++20 compilation under debug mode as well.

* Fix whitespace
2024-10-25 11:10:46 -07:00
Powei Feng
ea1c5d8f24 vk: improve rendertarget initialization (#8228)
Move a lot of the code from beginRenderPass() to the initialization
of the RenderTarget. This will save us a bit of CPU when
RenderTarget is re-used.

We also reduce the size of the VulkanRenderTarget handle and put
must of the caching bits into a heap struct.
2024-10-25 17:36:30 +00:00
Mathias Agopian
42d39834df update remote ui 2024-10-25 00:30:10 -07:00
Mathias Agopian
7ea7fa18eb update beamsplitter template
the generated file was modified, which would be undo'ed next time
we run beamsplitter
2024-10-25 00:29:13 -07:00
Mathias Agopian
a6b4c9fae1 fix gltf_viewer android sample build 2024-10-25 00:14:08 -07:00
Evan Mezeske
8d02cd0383 Fix bug in ResourceAllocator with erasing iterators inside loops (#8223) 2024-10-24 13:56:41 -07:00
Bob Conan
016882336a Update RELEASE_NOTES.md, fix a typo (#8227) 2024-10-24 13:56:05 -07:00
Ben Doherty
3f150e03bf Check that SwapChain is valid in endFrame (#8219) 2024-10-24 12:33:11 -07:00
Romain Guy
99308c98ba Update Android dependencies (#8224) 2024-10-23 15:49:01 -07:00
Evan Mezeske
6eee4520c7 vk: Add a workaround for a Windows NVIDIA Vulkan driver bug that causes swap chains to be created with incorrect dimensions for native windows created with thread-specific DPI-awareness context. (#8221) 2024-10-22 22:01:58 -07:00
Sungun Park
fa3a5d9eb4 Use xvp for multiview + debug view (#8222)
When multiview is enabled with the combining debug option toggled on, we
use an intermediate buffer that requires us to use the entire area of
the buffer as the viewport. Use xvp in this case.
2024-10-22 21:21:53 +00:00
show50726
17e4d2b92e Add public API in View for transparent picking (#8206) 2024-10-22 10:46:24 -07:00
kunyoung.park
13310e4ba0 Fix issue where material instance name cannot be set without creating a default instance (#8213) 2024-10-22 10:45:32 -07:00
Ben Doherty
eab8490d14 Metal: add better logging for invalid index element size (#8194) 2024-10-22 11:08:51 -04:00
Evan Mezeske
edece8f3dc Fix a bug in the OpenGL backend that causes win32 errors not to be logged #8214 (#8216)
* Capture the last win32 error immediately after failing win32 API functions are called in order to log it correctly. Prior to this change, intervening win32 API calls could clear the error code and it would not be logged.

* Oops fix bad whitespace in previous commit
2024-10-21 16:35:54 -07:00
Sungun Park
2456299337 Add a warning for FRenderableManager (#8210)
In some cases, users set materials first without providing render primitives, which has incurred the attribute mismatching warning. This isn't helpful because users don't know what action they should take to remove the warning.

Emit the warning only when the primitive handle is initialized so the AttributeBitset is properly populated.

BUGS=[372755205]
2024-10-20 15:08:13 +00:00
Ben Doherty
9e1ee2f290 Fix potential crash when a descriptor set is destroyed but not unbound (#8215) 2024-10-18 16:42:52 -04:00
Ben Doherty
6e9afff7ba Fix potential crash when a descriptor set is destroyed but not unbound (#8215) 2024-10-18 16:42:14 -04:00
Mathias Agopian
4425338559 avoid setting the scissor rect when possible
RenderPass is now tracking the scissor state locally so it can avoid
re-setting the scissor when it doesn't change.

We also consolidate the scissor override and the scissor-viewport in
RenderPass::Execute.
2024-10-18 10:05:02 -07:00
Ben Doherty
a494f9ff6a Metal: avoid redundant scissor rect state changes (#8207) 2024-10-18 11:07:11 -04:00
Mathias Agopian
ba680cf11a Revert "avoid setting the scissor rect when possible"
This reverts commit fc095413b3.

clipping is wrong when post-processing is disabled
2024-10-17 16:00:48 -07:00
Mathias Agopian
fc095413b3 avoid setting the scissor rect when possible
RenderPass is now tracking the scissor state locally so it can avoid
re-setting the scissor when it doesn't change.

We also consolidate the scissor override and the scissor-viewport in
RenderPass::Execute.
2024-10-17 14:16:36 -07:00
Mathias Agopian
d80526528c Cleanup PostPorcessManager rendering
- the main goal of this change was to move some state changes outside
  of loops, usually with mip generation.

- for instance bindPostProcessDesciptorSet() must now be issued
  manually (and can be done outside the loop)

- we also don't set the scissor for each pass

- we also move prepareMaterial() outside of getPipelineState(), it's
  now done in PostProcessMaterial::getMaterial().

- We use PostProcessVariant instead of uint8_t everywhere

In the end we have three drawing helpers:

- commitAndRenderFullScreenQuad() which updates a material instance,
  binds the corresponding material and draws a full screen quad.
- renderFullScreenQuad() which just renders a full screen quad.
- renderFullScreenQuadWithScissor() which does the same but scisorred

Additionally, we have the following helpers for getting materials and
instances:

- PostProcessMaterial::getMaterial(): which returns the FMaterial
- PostProcessMaterial::getMaterialInstance(): which is now a helper
  returning a material instance from a PostProcessMaterial or FMaterial

Most of the change is pluming through these API changes.
2024-10-17 14:16:05 -07:00
Guilhem Saurel
38e59fbd6b add missing includes 2024-10-17 14:15:40 -07:00
show50726
a5e6df1ad3 Address the comments 2024-10-17 10:19:02 -07:00
show50726
23d1329f37 Disable transparent pickable by default 2024-10-17 10:19:02 -07:00
show50726
25b37d36ad First push
Fix the texture format

Decide texture format based on feature level
2024-10-17 10:19:02 -07:00
Mathias Agopian
68265ae793 no need to copy the PostProcessMaterial mConstants field
It always references static data. Additionally, we don't need
to use a vector to store the specialization constants, because
it's also all static data.

And finally, we don't need a boolean to know the state of the
PostProcessMaterial, the mSize field can encode the same
information.
2024-10-16 17:25:38 -07:00
Ben Doherty
e8f3fc5a46 Implement setThreadPriority for Apple devices (#8200) 2024-10-16 12:55:25 -04:00
Evan Mezeske
22db1be939 Add support for compiling under c++20 on clang-based compilers. The warnings that this change ignores are tricky to fix in the code in a way that is backwards compatible with c++17, but it is possible to do and it would allow these warnings to be reinstated. (#8199) 2024-10-15 16:45:32 -04:00
Powei Feng
a3290d7656 vk: remove history from DescriptorSetManager (#8193)
"history" is a map from a DescriptorSet pointer to a set of
bookkeeping values (we delay "binding" until "commit" so need to
keep values until then). Instead of using a map, we can store
these values in the DescriptorSet itself so that we save on a
map look-up.
2024-10-14 19:46:27 +00:00
Powei Feng
22bb67e0b0 Bump version to 1.55.1 2024-10-14 06:07:43 +00:00
Powei Feng
4ee33cd591 Release Filament 1.55.0 2024-10-14 06:07:34 +00:00
Evan Mezeske
fd2f9555f1 Fix tiny typo in VulkanPlatformSwapChainImpl.cpp logging (#8196) 2024-10-11 23:09:32 +00:00
Mathias Agopian
ccdb58e93c don't set ANGLE features in filament (#8192)
ANGLE features should be set by apps, the system or developers but it's
not a good idea to set them in a library as it might conflict with other
libs etc.

we did it because it improved performance, but that should be fixed at
the angle level instead.
2024-10-11 13:52:54 -07:00
Ben Doherty
1eb1df2cf2 Check for use-after-free for heap handles (#8182) 2024-10-11 20:28:18 +00:00
Mathias Agopian
d784ce311f gles: add a flag to enable the validation of the nativewindow
We are seeing a cluster of crashes that could be due to using an
EGLSurface whose ANativeWindow has become invalid. This could happen if
we continued to use (i.e. draw with) an EGLSurface after 
SurfaceHolder::onSurfaceDestroyed() has returned.

This new flag enables an assertion that the native window is valid at
the time of makeCurrent(), which happens early in the frame.

BUG=[330392256]
2024-10-10 13:38:35 -07:00
Powei Feng
875b295967 vk: refactor texture default layout (#8183)
Previously, default layout is based on usage, but this actually
has two paths (Filament's TextureUsage and the computed
VkTextureUsage) that do not always agree.  We simplify so that
default layout is stored in the texture itself.

Also remove some unnecessary code that is no longer necessary.
In particular, we shouldn't be doing a flush and wait for the
transition to complete before updating a sampler descriptor.
We just need to make sure the layout before it is accessed is
correctly given in the update struct.
2024-10-10 19:31:20 +00:00
Powei Feng
b1b2d7072d Revert "Release Filament 1.55.0" (#8191)
This reverts commit 4f5369cefa.

Reason: Initial attempt to release 1.55.0 failed due to a few
   small bugs.
2024-10-10 12:16:00 -07:00
Sungun Park
014e6bcbde Update hardware Handle (#8187)
In certain compilers, the assignment operators defined as default
doesn't automatically make a call to the parent's method if it's
user-defined.

Make this behavior explicit to avoid this edge case.

BUGS=[371980551]
2024-10-10 17:12:22 +00:00
Powei Feng
614dbb44d5 Make sure color attachment textures have copy-able usage set (#8184)
To ensure the source of readPixels() is properly copy-able, we
want the backing textures to be created with the right BLIT_SRC usage.
However, this was not documented in the API. We workaround the issue
to tag all color attachment textures as BLIT_SRC.

This workaround will be removed in the future. For now, violations of
this condition will elicit a warning being printed out.
2024-10-10 16:02:11 +00:00
Ben Doherty
40c0d59464 Metal: enhance assertions for buffer uploads (#8188) 2024-10-09 16:54:14 -07:00
mdagois
1b0ff3aadb vk: Transient attachment support (#8021) 2024-10-08 23:20:35 +00:00
Haneul Kim
164a25cac4 Update FreeFlightManipulator.h 2024-10-08 10:38:00 -07:00
Mathias Agopian
2bbcb6de4c fix potential shadow rendering bug
the problem stems from a mismatch between the shader code
and the cpu code. if the shader is configured to read the shadow
map, then the cpu must generate it, otherwise we can get stale data.

Wether the shader reads the shadow map depends on the shadow type.
For directional shadows, the shader needs the SRE variant + a
"shadow enabled" bit per cascade in the main UBO.
For punctual shadows, the shader only needs the SRE variant.

Because of all that, if the conditions are met on the CPU side for
the shader to access the shadow map, we must make sure to generate it,
but in the case the shadow map would be empty (e.g. no shadow receivers),
we need to initialize it (and we can skip some work in the case of VSM).

BUGS=[369908659]
2024-10-08 10:22:50 -07:00
Mathias Agopian
58aa74b4ae cleanup code so it's easier to understand
this should make it clearer how we set the per primitive variant
when SSR and shadowin is involved
2024-10-08 10:22:50 -07:00
Mathias Agopian
26b42a7685 fix typo when generating the SSR pass
this caused the HAS_SHADOWS flag to not be disabled, this didn't
actually cause a problem because shadowing and SSR share the same
SRE variant bit. But both should never be active together.
2024-10-08 10:22:50 -07:00
Mathias Agopian
99b55cb888 minor renaming to be more consistant 2024-10-08 10:22:50 -07:00
Powei Feng
4375ffb3e8 vk: remove unnecessary hiding of impl for DescriptorSetManager (#8170)
We remove one layer of indirection for clarity and very small bit
performance saving.
2024-10-07 19:06:38 +00:00
Mathias Agopian
e9aeb9312b fix shadow multiplier mode
when shadow multiplier was used, the material used the wrong
variant (unlit).
2024-10-04 15:18:23 -07:00
Benjamin Doherty
4be172050d Fix Android build 2024-10-04 13:45:22 -07:00
Ben Doherty
3b9fc8f751 Remove textureUseAfterFreePoolSize (#8163) 2024-10-04 10:33:09 -07:00
Mathias Agopian
3bd4c45d6e workaround Mesa glDeleteBuffers() bug
Mesa always clears the generic binding if the buffer deleted
is bound to an indexed binding, even if it's not bound to the
generic binding.

BUGS=[371324321]
2024-10-04 10:17:19 -07:00
Ben Doherty
1809aa7b11 Fix OpenGL ES 2.0 descriptor set crash (#8176) 2024-10-03 17:23:20 -07:00
Powei Feng
739d4007e2 Fix imported texture path (#8175)
We need to also account for external image textures that are
imported in texture creation.
2024-10-03 15:16:56 -07:00
Powei Feng
3ed9e8f2c0 Initialize bool in DescriptorSet.h (#8173)
This class has a ( = default) constructor and hence should have
explicit initialization in its definition.
2024-10-02 13:45:05 -07:00
Powei Feng
e77ae6ec2c Work around client descriptor set issues (#8171)
- We change GLDescriptorSet::Buffer default constructor to
  workaround a client's compiler set up issue.
- We removed the assert_invariant that checks that ubo/samplers
  are not changed after committed in DescriptorSet. This caused
  an existing client's build to crash.
2024-10-02 06:24:41 -07:00
Powei Feng
4f5369cefa Release Filament 1.55.0 2024-10-01 17:09:03 +00:00
Powei Feng
93d28bc16a Change std::memcpy to memcpy in SkinningBuffer (#8169) 2024-10-01 09:53:14 -07:00
Sungun Park
e85c22c6f5 Fix incomplete use of MI for debugCombineArrayTexture (#8168)
`commit` call is required before `use`, which became a new norm for the
new descriptor set design.
2024-09-30 10:54:10 -07:00
Powei Feng
2cade209b5 Add Descriptor Sets to Filament (#8165)
We add the concept of the descriptor set as a way to describe
shader resources into Filament. This is a comprehensive change
across Filament.

Info on descriptor sets is available here:
https://docs.vulkan.org/spec/latest/chapters/descriptorsets.html

Co-authored-by: Benjamin Doherty <bendoherty@google.com>
Co-authored-by: Mathias Agopian <mathias@google.com>
Co-authored-by: Sungun Park <sungunpark@google.com>
2024-09-27 23:20:20 -07:00
Powei Feng
3d4fc7852b github: add software rasterizer job for GL to presubmit (#8158)
We use Mesa's gallium swrast to render as the driver with
Filament's backend set to GL. We provide a few scripts to parse
the tests (as jsons) and run gltf_viewer to produce the rendering.
2024-09-26 16:06:40 -07:00
Powei Feng
7dc17980a3 addressed comment 2024-09-25 21:05:42 -07:00
Powei Feng
7da09a7f45 gl: add PlatformOSMesa as an offscreen context
For GL+Linux, PlatformGLX will try to open an X11 window
regardless of whether we are doing headless/offscreen rendering
or not.

Here we add an OSMesa platform, which will allow us to avoid
opening any window on Linux. This is particularly useful for
situation where a display is not available, like for CI.

One important detail is that even though we are displaying through
a window, we keep the SDL2 dependency in tact for gltf_viewer.
This is due to the fact that gltf_viewer is built upon
FilamentApp, which is heavily integrated with SDL2. This is mostly
ok since we won't be hitting any path for opening a window due to
gltf_viewer's existing support for headless mode.
2024-09-25 21:05:42 -07:00
Ben Doherty
b97221b8de Improve setFrameScheduled threading (#8139) 2024-09-25 10:43:19 -07:00
472 changed files with 23425 additions and 4543 deletions

View File

@@ -0,0 +1,9 @@
name: 'ubuntu apt add deb-src'
runs:
using: "composite"
steps:
- name: "ubuntu apt add deb-src"
run: |
echo "deb-src http://archive.ubuntu.com/ubuntu jammy main restricted universe" | sudo tee /etc/apt/sources.list.d/my.list
sudo apt-get update
shell: bash

View File

@@ -76,3 +76,18 @@ jobs:
- name: Run build script
run: |
cd build/web && printf "y" | ./build.sh presubmit
test-renderdiff:
name: test-renderdiff
runs-on: ubuntu-22.04-32core
steps:
- uses: actions/checkout@v4.1.6
- uses: ./.github/actions/ubuntu-apt-add-src
- name: Run script
run: |
source ./build/linux/ci-common.sh && bash test/renderdiff/test.sh
- uses: actions/upload-artifact@v4
with:
name: presubmit-renderdiff-result
path: ./out/renderdiff_tests

View File

@@ -356,7 +356,7 @@ same version that our continuous builds use.
```shell
cd <your chosen parent folder for the emscripten SDK>
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.zip > emsdk.zip
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.60.zip > emsdk.zip
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
python ./emsdk.py install latest
python ./emsdk.py activate latest

View File

@@ -45,6 +45,8 @@ option(FILAMENT_ENABLE_FEATURE_LEVEL_0 "Enable Feature Level 0" ON)
option(FILAMENT_ENABLE_MULTIVIEW "Enable multiview for Filament" OFF)
option(FILAMENT_SUPPORTS_OSMESA "Enable OSMesa (headless GL context) for Filament" OFF)
set(FILAMENT_NDK_VERSION "" CACHE STRING
"Android NDK version or version prefix to be used when building for Android."
)
@@ -73,6 +75,10 @@ set(FILAMENT_BACKEND_DEBUG_FLAG "" CACHE STRING
"A debug flag meant for enabling/disabling backend debugging paths"
)
set(FILAMENT_OSMESA_PATH "" CACHE STRING
"Path to the OSMesa header and lib"
)
# Enable exceptions by default in spirv-cross.
set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS OFF)
@@ -132,12 +138,22 @@ else()
endif()
if (LINUX)
if (NOT FILAMENT_OSMESA_PATH STREQUAL "")
if (NOT EXISTS ${FILAMENT_OSMESA_PATH}/)
message(FATAL_ERROR "Cannot find specified OSMesa build directory: ${FILAMENT_OSMESA_PATH}")
endif()
set(FILAMENT_SUPPORTS_OSMESA TRUE)
endif()
if (FILAMENT_SUPPORTS_WAYLAND)
add_definitions(-DFILAMENT_SUPPORTS_WAYLAND)
set(FILAMENT_SUPPORTS_X11 FALSE)
elseif (FILAMENT_SUPPORTS_EGL_ON_LINUX)
add_definitions(-DFILAMENT_SUPPORTS_EGL_ON_LINUX)
set(FILAMENT_SUPPORTS_X11 FALSE)
elseif (FILAMENT_SUPPORTS_OSMESA)
set(FILAMENT_SUPPORTS_X11 FALSE)
add_definitions(-DFILAMENT_SUPPORTS_OSMESA)
else ()
if (FILAMENT_SUPPORTS_XCB)
add_definitions(-DFILAMENT_SUPPORTS_XCB)
@@ -509,11 +525,14 @@ else()
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" OFF)
endif()
# By default, link in matdbg for Desktop + Debug only since it pulls in filamat and a web server.
# By default, link in matdbg/fgviewer for Desktop + Debug only since it pulls in filamat and a web server.
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND IS_HOST_PLATFORM)
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" ON)
# TODO: Uncomment below when fgviewer is ready
# option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" ON)
else()
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" OFF)
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
endif()
# Only optimize materials in Release mode (so error message lines match the source code)
@@ -762,6 +781,11 @@ if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
if (FILAMENT_ENABLE_MATDBG OR IS_HOST_PLATFORM)
add_subdirectory(${LIBRARIES}/matdbg)
endif()
# TODO: Uncomment below when fgviewer is ready
# if (FILAMENT_ENABLE_FGVIEWER OR IS_HOST_PLATFORM)
# add_subdirectory(${LIBRARIES}/fgviewer)
# endif()
endif()
if (FILAMENT_SUPPORTS_VULKAN)

View File

@@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.55.0'
implementation 'com.google.android.filament:filament-android:1.56.7'
}
```
@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
iOS projects can use CocoaPods to install the latest release:
```shell
pod 'Filament', '~> 1.55.0'
pod 'Filament', '~> 1.56.7'
```
## Documentation

View File

@@ -7,6 +7,35 @@ A new header is inserted each time a *tag* is created.
Instead, if you are authoring a PR for the main branch, add your release note to
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
## v1.56.7
## v1.56.6
fix crash: the 'target_node' of Animation Channel may be nullpointer.
## v1.56.5
## v1.56.4
## v1.56.3
## v1.56.2
- vk: fix stage pool gc logic
## v1.56.1
## v1.56.0
- backend: descriptor layouts distinguish samplers and external samplers (b/376089915) [⚠️ **New Material Version**]
## v1.55.1
## v1.55.0
- Add descriptor sets to describe shader resources. [⚠️ **New Material Version**]
@@ -651,7 +680,7 @@ Instead, if you are authoring a PR for the main branch, add your release note to
- engine: Binary size improvements.
- engine: Add basic support for instanced renderables [**NEW API**].
- engine: Fix, first imaged passsed to `Stream::SetAcquiredImage` is ignored and leaked.
- engine: Fix, first imaged passed to `Stream::SetAcquiredImage` is ignored and leaked.
- Vulkan: Robustness improvements.
- Java: Fix, lookAt z axis negated.
- gltfio: Be graceful when model has > 4 weights per vert.

View File

@@ -11,6 +11,9 @@
// com.google.android.filament.exclude-vulkan
// When set, support for Vulkan will be excluded.
//
// com.google.android.filament.fgviewer
// When set, enables fgviewer
//
// com.google.android.filament.matdbg
// When set, enables matdbg
//
@@ -61,6 +64,11 @@ buildscript {
.gradleProperty("com.google.android.filament.exclude-vulkan")
.isPresent()
// TODO: Uncomment below when fgviewer is ready
// def fgviewer = providers
// .gradleProperty("com.google.android.filament.fgviewer")
// .isPresent()
def matdbg = providers
.gradleProperty("com.google.android.filament.matdbg")
.isPresent()
@@ -83,12 +91,12 @@ buildscript {
'minSdk': 21,
'targetSdk': 34,
'compileSdk': 34,
'kotlin': '2.0.0',
'kotlin_coroutines': '1.9.0-RC',
'buildTools': '34.0.0',
'kotlin': '2.0.21',
'kotlin_coroutines': '1.9.0',
'buildTools': '35.0.0',
'ndk': '27.0.11718014',
'androidx_core': '1.13.1',
'androidx_annotations': '1.8.0'
'androidx_annotations': '1.9.0'
]
ext.deps = [
@@ -104,7 +112,7 @@ buildscript {
]
dependencies {
classpath 'com.android.tools.build:gradle:8.4.1'
classpath 'com.android.tools.build:gradle:8.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}
@@ -115,6 +123,8 @@ buildscript {
"-DANDROID_STL=c++_static",
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString(),
// TODO: Uncomment below when fgviewer is ready
// "-DFILAMENT_ENABLE_FGVIEWER=${fgviewer ? 'ON' : 'OFF'}".toString(),
"-DFILAMENT_ENABLE_MATDBG=${matdbg ? 'ON' : 'OFF'}".toString(),
"-DFILAMENT_DISABLE_MATOPT=${matnopt ? 'ON' : 'OFF'}".toString()
]

View File

@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.19)
project(filament-android)
option(FILAMENT_SUPPORTS_VULKAN "Enables Vulkan on Android" OFF)
# TODO: Uncomment below when fgviewer is ready
# option(FILAMENT_ENABLE_FGVIEWER "Enables Frame Graph Viewer" OFF)
option(FILAMENT_ENABLE_MATDBG "Enables Material debugger" OFF)
option(FILAMENT_DISABLE_MATOPT "Disables material optimizations" OFF)
@@ -51,6 +53,13 @@ add_library(smol-v STATIC IMPORTED)
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
# TODO: Uncomment below when fgviewer is ready
# if (FILAMENT_ENABLE_FGVIEWER)
# add_library(fgviewer STATIC IMPORTED)
# set_target_properties(fgviewer PROPERTIES IMPORTED_LOCATION
# ${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfgviewer.a)
# endif()
if (FILAMENT_ENABLE_MATDBG)
add_library(matdbg STATIC IMPORTED)
set_target_properties(matdbg PROPERTIES IMPORTED_LOCATION
@@ -117,6 +126,8 @@ target_link_libraries(filament-jni
# libgeometry is PUBLIC because gltfio uses it.
PUBLIC geometry
# TODO: Uncomment below when fgviewer is ready
# $<$<STREQUAL:${FILAMENT_ENABLE_FGVIEWER},ON>:fgviewer>
$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:matdbg>
$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:filamat>
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:bluevk>

View File

@@ -499,6 +499,37 @@ Java_com_google_android_filament_Engine_nGetActiveFeatureLevel(JNIEnv *, jclass,
return (jint)engine->getActiveFeatureLevel();
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_Engine_nHasFeatureFlag(JNIEnv *env, jclass clazz,
jlong nativeEngine, jstring name_) {
Engine* engine = (Engine*) nativeEngine;
const char *name = env->GetStringUTFChars(name_, 0);
std::optional<bool> result = engine->getFeatureFlag(name);
env->ReleaseStringUTFChars(name_, name);
return result.has_value();
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_Engine_nSetFeatureFlag(JNIEnv *env, jclass clazz,
jlong nativeEngine, jstring name_, jboolean value) {
Engine* engine = (Engine*) nativeEngine;
const char *name = env->GetStringUTFChars(name_, 0);
jboolean result = engine->setFeatureFlag(name, (bool)value);
env->ReleaseStringUTFChars(name_, name);
return result;
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_Engine_nGetFeatureFlag(JNIEnv *env, jclass clazz,
jlong nativeEngine, jstring name_) {
Engine* engine = (Engine*) nativeEngine;
const char *name = env->GetStringUTFChars(name_, 0);
std::optional<bool> result = engine->getFeatureFlag(name);
env->ReleaseStringUTFChars(name_, name);
return result.value_or(false); // we should never fail here
}
extern "C" JNIEXPORT jlong JNICALL Java_com_google_android_filament_Engine_nCreateBuilder(JNIEnv*,
jclass) {
Engine::Builder* builder = new Engine::Builder{};
@@ -520,13 +551,12 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBuilderConfig(JNIEnv*,
jclass, jlong nativeBuilder, jlong commandBufferSizeMB, jlong perRenderPassArenaSizeMB,
jlong driverHandleArenaSizeMB, jlong minCommandBufferSizeMB, jlong perFrameCommandsSizeMB,
jlong jobSystemThreadCount,
jlong textureUseAfterFreePoolSize, jboolean disableParallelShaderCompile,
jlong jobSystemThreadCount, jboolean disableParallelShaderCompile,
jint stereoscopicType, jlong stereoscopicEyeCount,
jlong resourceAllocatorCacheSizeMB, jlong resourceAllocatorCacheMaxAge,
jboolean disableHandleUseAfterFreeCheck,
jint preferredShaderLanguage,
jboolean forceGLES2Context) {
jboolean forceGLES2Context, jboolean assertNativeWindowIsValid) {
Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
Engine::Config config = {
.commandBufferSizeMB = (uint32_t) commandBufferSizeMB,
@@ -535,7 +565,6 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu
.minCommandBufferSizeMB = (uint32_t) minCommandBufferSizeMB,
.perFrameCommandsSizeMB = (uint32_t) perFrameCommandsSizeMB,
.jobSystemThreadCount = (uint32_t) jobSystemThreadCount,
.textureUseAfterFreePoolSize = (uint32_t) textureUseAfterFreePoolSize,
.disableParallelShaderCompile = (bool) disableParallelShaderCompile,
.stereoscopicType = (Engine::StereoscopicType) stereoscopicType,
.stereoscopicEyeCount = (uint8_t) stereoscopicEyeCount,
@@ -544,6 +573,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu
.disableHandleUseAfterFreeCheck = (bool) disableHandleUseAfterFreeCheck,
.preferredShaderLanguage = (Engine::Config::ShaderLanguage) preferredShaderLanguage,
.forceGLES2Context = (bool) forceGLES2Context,
.assertNativeWindowIsValid = (bool) assertNativeWindowIsValid,
};
builder->config(&config);
}
@@ -566,6 +596,16 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu
builder->paused((bool) paused);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_Engine_nSetBuilderFeature(JNIEnv *env, jclass clazz,
jlong nativeBuilder, jstring name_, jboolean value) {
Engine::Builder* builder = (Engine::Builder*) nativeBuilder;
const char *name = env->GetStringUTFChars(name_, 0);
builder->feature(name, (bool)value);
env->ReleaseStringUTFChars(name_, name);
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Engine_nBuilderBuild(JNIEnv*, jclass, jlong nativeBuilder) {
Engine::Builder* builder = (Engine::Builder*) nativeBuilder;

View File

@@ -38,7 +38,7 @@ Java_com_google_android_filament_EntityManager_nCreateArray(JNIEnv* env, jclass,
// (which it is), but still.
em->create((size_t) n, reinterpret_cast<Entity *>(entities));
env->ReleaseIntArrayElements(entities_, entities, JNI_ABORT);
env->ReleaseIntArrayElements(entities_, entities, 0);
}
extern "C" JNIEXPORT jint JNICALL

View File

@@ -167,7 +167,7 @@ Java_com_google_android_filament_IndirectLight_nGetDirectionEstimateStatic(JNIEn
jfloat *outDirection = env->GetFloatArrayElements(outDirection_, NULL);
*reinterpret_cast<filament::math::float3*>(outDirection) = IndirectLight::getDirectionEstimate((filament::math::float3*)sh);
env->ReleaseFloatArrayElements(outDirection_, outDirection, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
env->ReleaseFloatArrayElements(sh_, sh, 0);
}
extern "C" JNIEXPORT void JNICALL
@@ -178,5 +178,5 @@ Java_com_google_android_filament_IndirectLight_nGetColorEstimateStatic(JNIEnv *e
*reinterpret_cast<filament::math::float4*>(outColor) =
IndirectLight::getColorEstimate((filament::math::float3*)sh, math::float3{x, y, z});
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
env->ReleaseFloatArrayElements(sh_, sh, 0);
}

View File

@@ -25,13 +25,14 @@ using namespace filament;
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Material_nBuilderBuild(JNIEnv *env, jclass,
jlong nativeEngine, jobject buffer_, jint size, jint shBandCount) {
jlong nativeEngine, jobject buffer_, jint size, jint shBandCount, jint shadowQuality) {
Engine* engine = (Engine*) nativeEngine;
AutoBuffer buffer(env, buffer_, size);
auto builder = Material::Builder();
if (shBandCount) {
builder.sphericalHarmonicsBandCount(shBandCount);
}
builder.shadowSamplingQuality((Material::Builder::ShadowSamplingQuality)shadowQuality);
Material* material = builder
.package(buffer.getData(), buffer.getSize())
.build(*engine);

View File

@@ -138,6 +138,13 @@ Java_com_google_android_filament_Texture_nBuilderImportTexture(JNIEnv*, jclass,
builder->import((intptr_t)id);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_Texture_nBuilderExternal(JNIEnv*, jclass, jlong nativeBuilder) {
Texture::Builder *builder = (Texture::Builder *) nativeBuilder;
builder->external();
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Texture_nBuilderBuild(JNIEnv*, jclass,
jlong nativeBuilder, jlong nativeEngine) {

View File

@@ -222,6 +222,20 @@ Java_com_google_android_filament_View_nIsFrontFaceWindingInverted(JNIEnv*,
return static_cast<jboolean>(view->isFrontFaceWindingInverted());
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetTransparentPickingEnabled(JNIEnv*,
jclass, jlong nativeView, jboolean enabled) {
View* view = (View*) nativeView;
view->setTransparentPickingEnabled(enabled);
}
extern "C" JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_View_nIsTransparentPickingEnabled(JNIEnv*,
jclass, jlong nativeView) {
View* view = (View*) nativeView;
return static_cast<jboolean>(view->isTransparentPickingEnabled());
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_View_nSetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView, jint ordinal) {
View* view = (View*) nativeView;

View File

@@ -224,13 +224,12 @@ public class Engine {
nSetBuilderConfig(mNativeBuilder, config.commandBufferSizeMB,
config.perRenderPassArenaSizeMB, config.driverHandleArenaSizeMB,
config.minCommandBufferSizeMB, config.perFrameCommandsSizeMB,
config.jobSystemThreadCount,
config.textureUseAfterFreePoolSize, config.disableParallelShaderCompile,
config.jobSystemThreadCount, config.disableParallelShaderCompile,
config.stereoscopicType.ordinal(), config.stereoscopicEyeCount,
config.resourceAllocatorCacheSizeMB, config.resourceAllocatorCacheMaxAge,
config.disableHandleUseAfterFreeCheck,
config.preferredShaderLanguage.ordinal(),
config.forceGLES2Context);
config.forceGLES2Context, config.assertNativeWindowIsValid);
return this;
}
@@ -259,6 +258,17 @@ public class Engine {
return this;
}
/**
* Set a feature flag value. This is the only way to set constant feature flags.
* @param name feature name
* @param value true to enable, false to disable
* @return A reference to this Builder for chaining calls.
*/
public Builder feature(@NonNull String name, boolean value) {
nSetBuilderFeature(mNativeBuilder, name, value);
return this;
}
/**
* Creates an instance of Engine
*
@@ -394,6 +404,7 @@ public class Engine {
/**
* Set to `true` to forcibly disable parallel shader compilation in the backend.
* Currently only honored by the GL backend.
* @Deprecated use "backend.disable_parallel_shader_compile" feature flag instead
*/
public boolean disableParallelShaderCompile = false;
@@ -419,12 +430,12 @@ public class Engine {
*/
public long stereoscopicEyeCount = 2;
/*
/**
* @Deprecated This value is no longer used.
*/
public long resourceAllocatorCacheSizeMB = 64;
/*
/**
* This value determines how many frames texture entries are kept for in the cache. This
* is a soft limit, meaning some texture older than this are allowed to stay in the cache.
* Typically only one texture is evicted per frame.
@@ -432,12 +443,13 @@ public class Engine {
*/
public long resourceAllocatorCacheMaxAge = 1;
/*
/**
* Disable backend handles use-after-free checks.
* @Deprecated use "backend.disable_handle_use_after_free_check" feature flag instead
*/
public boolean disableHandleUseAfterFreeCheck = false;
/*
/**
* Sets a preferred shader language for Filament to use.
*
* The Metal backend supports two shader languages: MSL (Metal Shading Language) and
@@ -459,12 +471,20 @@ public class Engine {
};
public ShaderLanguage preferredShaderLanguage = ShaderLanguage.DEFAULT;
/*
/**
* When the OpenGL ES backend is used, setting this value to true will force a GLES2.0
* context if supported by the Platform, or if not, will have the backend pretend
* it's a GLES2 context. Ignored on other backends.
*/
public boolean forceGLES2Context = false;
/**
* Assert the native window associated to a SwapChain is valid when calling makeCurrent().
* This is only supported for:
* - PlatformEGLAndroid
* @Deprecated use "backend.opengl.assert_native_window_is_valid" feature flag instead
*/
public boolean assertNativeWindowIsValid = false;
}
private Engine(long nativeEngine, Config config) {
@@ -687,11 +707,11 @@ public class Engine {
/**
* Returns the maximum number of stereoscopic eyes supported by Filament. The actual number of
* eyes rendered is set at Engine creation time with the {@link
* Engine#Config#stereoscopicEyeCount} setting.
* eyes rendered is set at Engine creation time with the {@link Config#stereoscopicEyeCount}
* setting.
*
* @return the max number of stereoscopic eyes supported
* @see Engine#Config#stereoscopicEyeCount
* @see Config#stereoscopicEyeCount
*/
public long getMaxStereoscopicEyes() {
return nGetMaxStereoscopicEyes(getNativeObject());
@@ -888,7 +908,8 @@ public class Engine {
/**
* Returns whether the object is valid.
* @param object Object to check for validity
* @param ma Material
* @param mi MaterialInstance to check for validity
* @return returns true if the specified object is valid.
*/
public boolean isValidMaterialInstance(@NonNull Material ma, MaterialInstance mi) {
@@ -1310,6 +1331,39 @@ public class Engine {
*/
public static native long getSteadyClockTimeNano();
/**
* Checks if a feature flag exists
* @param name name of the feature flag to check
* @return true if it exists false otherwise
*/
public boolean hasFeatureFlag(@NonNull String name) {
return nHasFeatureFlag(mNativeObject, name);
}
/**
* Set the value of a non-constant feature flag.
* @param name name of the feature flag to set
* @param value value to set
* @return true if the value was set, false if the feature flag is constant or doesn't exist.
*/
public boolean setFeatureFlag(@NonNull String name, boolean value) {
return nSetFeatureFlag(mNativeObject, name, value);
}
/**
* Retrieves the value of any feature flag.
* @param name name of the feature flag
* @return the value of the flag if it exists
* @exception IllegalArgumentException is thrown if the feature flag doesn't exist
*/
public boolean getFeatureFlag(@NonNull String name) {
if (!hasFeatureFlag(name)) {
throw new IllegalArgumentException("The feature flag \"" + name + "\" doesn't exist");
}
return nGetFeatureFlag(mNativeObject, name);
}
@UsedByReflection("TextureHelper.java")
public long getNativeObject() {
if (mNativeObject == 0) {
@@ -1399,6 +1453,9 @@ public class Engine {
private static native int nGetSupportedFeatureLevel(long nativeEngine);
private static native int nSetActiveFeatureLevel(long nativeEngine, int ordinal);
private static native int nGetActiveFeatureLevel(long nativeEngine);
private static native boolean nHasFeatureFlag(long nativeEngine, String name);
private static native boolean nSetFeatureFlag(long nativeEngine, String name, boolean value);
private static native boolean nGetFeatureFlag(long nativeEngine, String name);
private static native long nCreateBuilder();
private static native void nDestroyBuilder(long nativeBuilder);
@@ -1406,14 +1463,14 @@ public class Engine {
private static native void nSetBuilderConfig(long nativeBuilder, long commandBufferSizeMB,
long perRenderPassArenaSizeMB, long driverHandleArenaSizeMB,
long minCommandBufferSizeMB, long perFrameCommandsSizeMB, long jobSystemThreadCount,
long textureUseAfterFreePoolSize, boolean disableParallelShaderCompile,
int stereoscopicType, long stereoscopicEyeCount,
boolean disableParallelShaderCompile, int stereoscopicType, long stereoscopicEyeCount,
long resourceAllocatorCacheSizeMB, long resourceAllocatorCacheMaxAge,
boolean disableHandleUseAfterFreeCheck,
int preferredShaderLanguage,
boolean forceGLES2Context);
boolean forceGLES2Context, boolean assertNativeWindowIsValid);
private static native void nSetBuilderFeatureLevel(long nativeBuilder, int ordinal);
private static native void nSetBuilderSharedContext(long nativeBuilder, long sharedContext);
private static native void nSetBuilderPaused(long nativeBuilder, boolean paused);
private static native void nSetBuilderFeature(long nativeBuilder, String name, boolean value);
private static native long nBuilderBuild(long nativeBuilder);
}

View File

@@ -344,9 +344,18 @@ public class Material {
}
public static class Builder {
public enum ShadowSamplingQuality {
/** 2x2 PCF */
HARD,
/** 3x3 gaussian filter */
LOW,
}
private Buffer mBuffer;
private int mSize;
private int mShBandCount = 0;
private ShadowSamplingQuality mShadowSamplingQuality = ShadowSamplingQuality.LOW;
/**
* Specifies the material data. The material data is a binary blob produced by
@@ -378,6 +387,18 @@ public class Material {
return this;
}
/**
* Set the quality of shadow sampling. This is only taken into account
* if this material is lit and in the surface domain.
* @param quality
* @return Reference to this Builder for chaining calls.
*/
@NonNull
public Builder shadowSamplingQuality(ShadowSamplingQuality quality) {
mShadowSamplingQuality = quality;
return this;
}
/**
* Creates and returns the Material object.
*
@@ -390,7 +411,7 @@ public class Material {
@NonNull
public Material build(@NonNull Engine engine) {
long nativeMaterial = nBuilderBuild(engine.getNativeObject(),
mBuffer, mSize, mShBandCount);
mBuffer, mSize, mShBandCount, mShadowSamplingQuality.ordinal());
if (nativeMaterial == 0) throw new IllegalStateException("Couldn't create Material");
return new Material(nativeMaterial);
}
@@ -1041,7 +1062,7 @@ public class Material {
mNativeObject = 0;
}
private static native long nBuilderBuild(long nativeEngine, @NonNull Buffer buffer, int size, int shBandCount);
private static native long nBuilderBuild(long nativeEngine, @NonNull Buffer buffer, int size, int shBandCount, int shadowQuality);
private static native long nCreateInstance(long nativeMaterial);
private static native long nCreateInstanceWithName(long nativeMaterial, @NonNull String name);
private static native long nGetDefaultInstance(long nativeMaterial);

View File

@@ -800,6 +800,19 @@ public class Texture {
return this;
}
/**
* Creates an external texture. The content must be set using setExternalImage().
* The sampler can be SAMPLER_EXTERNAL or SAMPLER_2D depending on the format. Generally
* YUV formats must use SAMPLER_EXTERNAL. This depends on the backend features and is not
* validated.
* @return This Builder, for chaining calls.
*/
@NonNull
public Builder external() {
nBuilderExternal(mNativeBuilder);
return this;
}
/**
* Creates a new <code>Texture</code> instance.
* @param engine The {@link Engine} to associate this <code>Texture</code> with.
@@ -1261,6 +1274,7 @@ public class Texture {
private static native void nBuilderUsage(long nativeBuilder, int flags);
private static native void nBuilderSwizzle(long nativeBuilder, int r, int g, int b, int a);
private static native void nBuilderImportTexture(long nativeBuilder, long id);
private static native void nBuilderExternal(long nativeBuilder);
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
private static native int nGetWidth(long nativeTexture, int level);

View File

@@ -745,6 +745,33 @@ public class View {
nSetFrontFaceWindingInverted(getNativeObject(), inverted);
}
/**
* Returns true if transparent picking is enabled.
*
* @see #setTransparentPickingEnabled
*/
public boolean isTransparentPickingEnabled() {
return nIsTransparentPickingEnabled(getNativeObject());
}
/**
* Enables or disables transparent picking. Disabled by default.
*
* When transparent picking is enabled, View::pick() will pick from both
* transparent and opaque renderables. When disabled, View::pick() will only
* pick from opaque renderables.
*
* <p>
* Transparent picking will create an extra pass for rendering depth
* from both transparent and opaque renderables.
* </p>
*
* @param enabled true enables transparent picking, false disables it.
*/
public void setTransparentPickingEnabled(boolean enabled) {
nSetTransparentPickingEnabled(getNativeObject(), enabled);
}
/**
* Sets options relative to dynamic lighting for this view.
*
@@ -1281,6 +1308,8 @@ public class View {
private static native boolean nIsPostProcessingEnabled(long nativeView);
private static native void nSetFrontFaceWindingInverted(long nativeView, boolean inverted);
private static native boolean nIsFrontFaceWindingInverted(long nativeView);
private static native void nSetTransparentPickingEnabled(long nativeView, boolean enabled);
private static native boolean nIsTransparentPickingEnabled(long nativeView);
private static native void nSetAmbientOcclusion(long nativeView, int ordinal);
private static native int nGetAmbientOcclusion(long nativeView);
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution, float intensity, float bilateralThreshold, int quality, int lowPassFilter, int upsampling, boolean enabled, boolean bentNormals, float minHorizonAngleRad);

View File

@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
VERSION_NAME=1.55.0
VERSION_NAME=1.56.7
POM_DESCRIPTION=Real-time physically based rendering engine for Android.

View File

@@ -1,6 +1,6 @@
#Wed Nov 17 10:40:18 PST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -6,6 +6,10 @@ plugins {
project.ext.isSample = true
kotlin {
jvmToolchain(versions.jdk)
}
filamentTools {
cmgenArgs = "-q --format=ktx --size=256 --extract-blur=0.1 --deploy=src/main/assets/envs/default_env"
iblInputFile = project.layout.projectDirectory.file("../../../third_party/environments/lightroom_14b.hdr")
@@ -13,7 +17,7 @@ filamentTools {
}
// don't forget to update MainACtivity.kt when/if changing this.
task copyMesh(type: Copy) {
tasks.register('copyMesh', Copy) {
from "../../../third_party/models/BusterDrone"
into "src/main/assets/models"
}

View File

@@ -112,7 +112,13 @@ class MainActivity : Activity() {
}
private fun setupFilament() {
engine = Engine.Builder().featureLevel(Engine.FeatureLevel.FEATURE_LEVEL_0).build()
val config = Engine.Config()
//config.forceGLES2Context = true
engine = Engine.Builder()
.config(config)
.featureLevel(Engine.FeatureLevel.FEATURE_LEVEL_0)
.build()
renderer = engine.createRenderer()
scene = engine.createScene()
view = engine.createView()
@@ -123,7 +129,9 @@ class MainActivity : Activity() {
scene.skybox = Skybox.Builder().color(0.035f, 0.035f, 0.035f, 1.0f).build(engine)
// post-processing is not supported at feature level 0
view.isPostProcessingEnabled = false
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
view.isPostProcessingEnabled = false
}
// Tell the view which camera we want to use
view.camera = camera

View File

@@ -23,6 +23,8 @@ function print_help {
echo " This is sometimes needed instead of -c (which still misses some clean steps)."
echo " -d"
echo " Enable matdbg."
echo " -t"
echo " Enable fgviewer."
echo " -f"
echo " Always invoke CMake before incremental builds."
echo " -g"
@@ -64,6 +66,9 @@ function print_help {
echo " enabling debug paths in the backend from the build script. For example, make a"
echo " systrace-enabled build without directly changing #defines. Remember to add -f when"
echo " changing this option."
echo " -X osmesa_path"
echo " Indicates a path to a completed OSMesa build. OSMesa is used to create an offscreen GL"
echo " context for software rasterization"
echo " -S type"
echo " Enable stereoscopic rendering where type is one of [instanced|multiview]. This is only"
echo " meant for building the samples."
@@ -122,6 +127,27 @@ function print_matdbg_help {
echo ""
}
function print_fgviewer_help {
echo "fgviewer is enabled in the build, but some extra steps are needed."
echo ""
echo "FOR DESKTOP BUILDS:"
echo ""
echo "Please set the port environment variable before launching. e.g., on macOS do:"
echo " export FILAMENT_FGVIEWER_PORT=8085"
echo ""
echo "FOR ANDROID BUILDS:"
echo ""
echo "1) For Android Studio builds, make sure to set:"
echo " -Pcom.google.android.filament.fgviewer"
echo " option in Preferences > Build > Compiler > Command line options."
echo ""
echo "2) The port number is hardcoded to 8085 so you will need to do:"
echo " adb forward tcp:8085 tcp:8085"
echo ""
echo "3) Be sure to enable INTERNET permission in your app's manifest file."
echo ""
}
# Unless explicitly specified, NDK version will be selected as highest available version within same major release chain
FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/build/android/ndk.version | cut -f 1 -d ".")}
@@ -169,6 +195,7 @@ VULKAN_ANDROID_GRADLE_OPTION=""
EGL_ON_LINUX_OPTION="-DFILAMENT_SUPPORTS_EGL_ON_LINUX=OFF"
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=OFF"
FGVIEWER_OPTION="-DFILAMENT_ENABLE_FGVIEWER=OFF"
MATDBG_GRADLE_OPTION=""
MATOPT_OPTION=""
@@ -180,6 +207,8 @@ BACKEND_DEBUG_FLAG_OPTION=""
STEREOSCOPIC_OPTION=""
OSMESA_OPTION=""
IOS_BUILD_SIMULATOR=false
BUILD_UNIVERSAL_LIBRARIES=false
@@ -235,11 +264,13 @@ function build_desktop_target {
-DCMAKE_BUILD_TYPE="$1" \
-DCMAKE_INSTALL_PREFIX="../${lc_target}/filament" \
${EGL_ON_LINUX_OPTION} \
${FGVIEWER_OPTION} \
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${ASAN_UBSAN_OPTION} \
${BACKEND_DEBUG_FLAG_OPTION} \
${STEREOSCOPIC_OPTION} \
${OSMESA_OPTION} \
${architectures} \
../..
ln -sf "out/cmake-${lc_target}/compile_commands.json" \
@@ -370,6 +401,7 @@ function build_android_target {
-DFILAMENT_NDK_VERSION="${FILAMENT_NDK_VERSION}" \
-DCMAKE_INSTALL_PREFIX="../android-${lc_target}/filament" \
-DCMAKE_TOOLCHAIN_FILE="../../build/toolchain-${arch}-linux-android.cmake" \
${FGVIEWER_OPTION} \
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${VULKAN_ANDROID_OPTION} \
@@ -607,6 +639,7 @@ function build_ios_target {
-DPLATFORM_NAME="${platform}" \
-DIOS=1 \
-DCMAKE_TOOLCHAIN_FILE=../../third_party/clang/iOS.cmake \
${FGVIEWER_OPTION} \
${MATDBG_OPTION} \
${MATOPT_OPTION} \
${STEREOSCOPIC_OPTION} \
@@ -796,7 +829,7 @@ function check_debug_release_build {
pushd "$(dirname "$0")" > /dev/null
while getopts ":hacCfgijmp:q:uvslwedk:bx:S:" opt; do
while getopts ":hacCfgijmp:q:uvslwedtk:bx:S:X:" opt; do
case ${opt} in
h)
print_help
@@ -817,6 +850,12 @@ while getopts ":hacCfgijmp:q:uvslwedk:bx:S:" opt; do
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_BUILD_FILAMAT=ON"
MATDBG_GRADLE_OPTION="-Pcom.google.android.filament.matdbg"
;;
t)
# TODO: Uncomment below when fgviewer is ready
# PRINT_FGVIEWER_HELP=true
# FGVIEWER_OPTION="-DFILAMENT_ENABLE_FGVIEWER=ON"
#FGVIEWER_GRADLE_OPTION="-Pcom.google.android.filament.fgviewer"
;;
f)
ISSUE_CMAKE_ALWAYS=true
;;
@@ -950,6 +989,8 @@ while getopts ":hacCfgijmp:q:uvslwedk:bx:S:" opt; do
exit 1
esac
;;
X) OSMESA_OPTION="-DFILAMENT_OSMESA_PATH=${OPTARG}"
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
echo ""
@@ -1019,3 +1060,7 @@ fi
if [[ "${PRINT_MATDBG_HELP}" == "true" ]]; then
print_matdbg_help
fi
if [[ "${PRINT_FGVIEWER_HELP}" == "true" ]]; then
print_fgviewer_help
fi

View File

@@ -131,7 +131,7 @@ if [[ "${has_universal}" == "true" ]]; then
archives+=("$REPLY")
done < <(find "$(pwd)/${archs_temp_dir}/${arch}" -iname '*.a' -print0)
combine_static_libs "$arch_output" "$archives"
combine_static_libs "$arch_output" "${archives[@]}"
done
# Finally, combine the single-architecture archives into a universal binary.

View File

@@ -13,7 +13,7 @@ chmod +x ninja
export PATH="$PWD:$PATH"
# Install emscripten.
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.zip > emsdk.zip
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.60.zip > emsdk.zip
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
./emsdk install latest
./emsdk activate latest

File diff suppressed because one or more lines are too long

View File

@@ -1787,7 +1787,12 @@ non-shader data.
declare a variable called <code>eyeDirection</code> you can access it in the fragment shader using
<code>variable_eyeDirection</code>. In the vertex shader, the interpolant name is simply a member of
the <code>MaterialVertexInputs</code> structure (<code>material.eyeDirection</code> in your example). Each
interpolant is of type <code>float4</code> (<code>vec4</code>) in the shaders.
interpolant is of type <code>float4</code> (<code>vec4</code>) in the shaders. By default the precision of the
interpolant is <code>highp</code> in <em class="asterisk">both</em> the vertex and fragment shaders.
An alternate syntax can be used to specify both the name and precision of the interpolant.
In this case the specified precision is used as-is in both fragment and vertex stages, in
particular if <code>default</code> is specified the default precision is used is the fragment shader
(<code>mediump</code>) and in the vertex shader (<code>highp</code>).
</p></dd></dl><p></p><pre class="listing tilde"><code><span class="line">material {</span>
<span class="line"> name : Skybox,</span>
@@ -1798,7 +1803,11 @@ non-shader data.
<span class="line"> }</span>
<span class="line"> ],</span>
<span class="line"> variables : [</span>
<span class="line"> eyeDirection</span>
<span class="line"> eyeDirection,</span>
<span class="line"> {</span>
<span class="line"> name : eyeColor,</span>
<span class="line"> precision : medium</span>
<span class="line"> }</span>
<span class="line"> ],</span>
<span class="line"> vertexDomain : device,</span>
<span class="line"> depthWrite : <span class="hljs-literal">false</span>,</span>

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
docs_src/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
book
src/dup/*.md

89
docs_src/README.md Normal file
View File

@@ -0,0 +1,89 @@
# Documentation
Filament's documentation (which you are reading) is a collection of pages created with [`mdBook`].
## How the book is created and updated {#how-to-create}
### Prerequisites
- Install [`mdBook`] for your platform
- `selenium` package for python
```shell
python3 -m pip install selenium
```
### Generate {#how-to-generate}
We wrote a python script to gather and transform the different documents in the project tree into a
single book. This script can be found in [`docs_src/build/run.py`]. In addition,
[`docs_src/build/duplicates.json`] is used to describe the markdown files that are copied and
transformed from the source tree. These copies are placed into `docs_src/src/dup`.
To collect the pages and generate the book, run the following
```shell
cd docs_src
python3 build/run.py
```
### Copy to `docs`
`docs` is the github-specfic directory for producing a web frontend (i.e. documentation) for a
project.
(To be completed)
## Document sources
We list the different document sources and how they are copied and processed into the collection
of markdown files that are then processed with `mdBook`.
### Introductory docs {#introductory-doc}
The [github landing page] for Filament displays an extensive introduction to Filament. It
links to `BUILDING.md` and `CONTRIBUTING.md`, which are conventional pages for building or
contributing to the project. We copy these pages from their respective locations in the project
tree into `docs_src/src/dup`. Moreover, to restore valid linkage between the pages, we need
to perform a number of URL replacements in addition to the copy. These replacements are
described in [`docs_src/build/duplicates.json`].
### Core concept docs
The primary design of Filament as a phyiscally-based renderer and details of its materials
system are described in `Filament.md.html` and `Materials.md.html`, respectively. These two
documents are written in [`markdeep`]. To embed them into our book, we
1. Convert the markdeep into html
2. Embed the html output in a markdown file
3. Place the markdown file in `docs_src/src/main`
We describe step 1 in detail for the sake of record:
- Start a local-only server to serve the markdeep file (e.g. `Filament.md.html`)
- Start a `selenium` driver (essentially run chromium in headless mode)
- Visit the local page through the driver (i.e. open url `http://localhost:xx/Filament.md.html?export`)
- Parse out the exported output in the retrieved html (note that the output of the markdeep
export is an html with the output captured in a `<pre>` tag).
- Replace css styling in the exported output as needed (so they don't interfere with the book's css.
- Replace resource urls to refer to locations relative to the mdbook structure.
### READMEs
Filament depends on a number of libraries, which reside in the directory `libs`. These individual
libaries often have README.md in their root to describe itself. We collect these descriptions into our
book. In addition, client usage of Filament also requires using a set of binary tools, which are
located in `tools`. Some of tools also have README.md as description. We also collect them into the book.
The process for copying and processing these READMEs is outlined in [Introductory docs](#introductory-doc).
### Other technical notes
These are technical documents that do not fit into a library, tool, or directory of the
Filament source tree. We collect them into the `docs_src/src/notes` directory. No additional
processing are needed for these documents.
## Adding more documents
To add any documentation, first consider the type of the document you like to add. If it
belongs to any of the above sources, then simply place the document in the appropriate place,
add a link in `SUMMARY.md`, and perform the steps outlined in
[how-to create section](#how-to-create).
For example, if you are adding a general technical note, then you would
- Place the document (file with extension `.md`) in `docs_src/src/notes`
- Add a link in [`docs_src/src/SUMMARY.md`]
- Run the commands in the [Generate](#how-to-generate) section
[github landing page]: https://google.github.io/filament
[`mdBook`]: https://rust-lang.github.io/mdBook/
[`markdeep`]: https://casual-effects.com/markdeep/
[`docs_src/build/run.py`]: https://github.com/google/filament/blob/main/docs_src/build/run.py
[`docs_src/build/duplicates.json`]: https://github.com/google/filament/blob/main/docs_src/build/duplicates.json
[`docs_src/src/SUMMARY.md`]: https://github.com/google/filament/blob/main/docs_src/src/SUMMARY.md

20
docs_src/book.toml Normal file
View File

@@ -0,0 +1,20 @@
[book]
authors = []
language = "en"
multilingual = false
src = "src"
title = "Filament"
[build]
create-missing = false
[output.html]
mathjax-support = true
default-theme = "light"
preferred-dark-theme = "light"
[output.html.print]
enable = false
[output.html.fold]
enable = false

View File

@@ -0,0 +1,74 @@
{
"README.md": {
"dest": "dup/intro.md",
"link_transforms": {
"BUILDING.md": "building.md",
"/CONTRIBUTING.md": "contributing.md",
"/CODE_STYLE.md": "code_style.md",
"docs/images/samples": "../images/samples"
}
},
"BUILDING.md": {
"dest": "dup/building.md"
},
"CONTRIBUTING.md": {
"dest": "dup/contributing.md"
},
"CODE_STYLE.md": {
"dest": "dup/code_style.md"
},
"libs/uberz/README.md": {
"dest": "dup/uberz.md"
},
"libs/bluegl/README.md": {
"dest": "dup/bluegl.md"
},
"libs/bluevk/README.md": {
"dest": "dup/bluevk.md"
},
"libs/gltfio/README.md": {
"dest": "dup/gltfio.md"
},
"libs/filamat/README.md": {
"dest": "dup/filamat.md"
},
"libs/iblprefilter/README.md": {
"dest": "dup/iblprefilter.md"
},
"libs/matdbg/README.md": {
"dest": "dup/matdbg.md"
},
"tools/normal-blending/README.md": {
"dest": "dup/normal_blending.md"
},
"tools/filamesh/README.md": {
"dest": "dup/filamesh.md"
},
"tools/beamsplitter/README.md": {
"dest": "dup/beamsplitter.md"
},
"tools/cmgen/README.md": {
"dest": "dup/cmgen.md"
},
"tools/mipgen/README.md": {
"dest": "dup/mipgen.md"
},
"tools/matinfo/README.md": {
"dest": "dup/matinfo.md"
},
"tools/roughness-prefilter/README.md": {
"dest": "dup/roughness_prefilter.md"
},
"tools/zbloat/README.md": {
"dest": "dup/zbloat.md"
},
"tools/cso-lut/README.md": {
"dest": "dup/cso_lut.md"
},
"tools/specular-color/README.md": {
"dest": "dup/specular_color.md"
},
"docs_src/README.md": {
"dest": "dup/docs.md"
}
}

View File

@@ -0,0 +1,87 @@
#!/usr/bin/bash
# Copyright (C) 2025 The Android Open Source Project
#
# 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.
DARWIN_X86=1
LINUX_X86=2
DARWIN_ARM=3
LINUX_ARM=4
function add_cargo_path() {
local BASH_P="${HOME}/.bashrc"
local PATH_LINE='export PATH=${PATH}:~/.cargo/bin'
local TYPE=$1
if [ ${TYPE} == ${DARWIN_ARM} ] || [ ${TYPE} == ${DARWIN_X86} ]; then
BASH_P="${HOME}/.bash_profile"
fi
if ! (grep "${PATH_LINE}" ${BASH_P}); then
echo "${PATH_LINE}" >> ${BASH_P}
fi
source ${BASH_P}
}
function download_mdbook() {
if command -v mdbook >/dev/null 2>&1; then
echo "mdbook already installed"
exit 0
fi
local CHECK_UNAME="
import sys;
parts=[a.lower() for a in sys.stdin.read().strip().split(' ')];
def get_type():
if 'darwin' in parts:
if 'x86_64' in parts:
return ${DARWIN_X86}
elif 'aarch' in parts:
return ${DARWIN_ARM}
elif 'linux' in parts:
if 'x86_64' in parts:
return ${LINUX_X86}
elif 'aarch' in parts:
return ${LINUX_ARM}
return 0
print(get_type())
"
local TYPE=`uname -a | python3 -c "${CHECK_UNAME}"`
if [ ${TYPE} == ${DARWIN_ARM} ] || [ ${TYPE} == ${LINUX_ARM} ]; then
# No github prebuilts are available, we build it with rust from source.
# First, need to install rust and cargo
if ! (command -v rustc >/dev/null 2>&1) || ! (command -v cargo >/dev/null 2>&1); then
echo "*** Need to install Rust ***"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi
if ! (command -v cargo >/dev/null 2>&1); then
echo "*** Still cannot find `cargo` ***"
exit 1
fi
cargo install mdbook
else
# Download prebuilts from github
mkdir -p ${HOME}/.cargo/bin
echo "*** Downloading mdbook from github release ***"
DL_URL='https://github.com/rust-lang/mdBook/releases/download/v0.4.43/mdbook-v0.4.43-x86_64-apple-darwin.tar.gz '
if [ ${TYPE} == ${LINUX_X86} ]; then
DL_URL='https://github.com/rust-lang/mdBook/releases/download/v0.4.43/mdbook-v0.4.43-x86_64-unknown-linux-gnu.tar.gz'
fi
curl -L -o ~/Downloads/mdbook.tar.gz ${DL_URL}
mkdir -p /tmp/mdbook
tar -xvzf ~/Downloads/mdbook.tar.gz -C /tmp/mdbook >/dev/null 2>&1
mv /tmp/mdbook/mdbook ~/.cargo/bin/
fi
add_cargo_path ${TYPE}
}
download_mdbook

128
docs_src/build/run.py Normal file
View File

@@ -0,0 +1,128 @@
# Copyright (C) 2025 The Android Open Source Project
#
# 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.
import json
import os
import re
from utils import execute, ArgParseImpl
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
DOCS_SRC_DIR = os.path.join(CUR_DIR, '../')
ROOT_DIR = os.path.join(CUR_DIR, '../../')
SRC_DIR = os.path.join(CUR_DIR, '../src')
MARKDEEP_DIR = os.path.join(CUR_DIR, '../markdeep')
DUP_DIR = os.path.join(SRC_DIR, 'dup')
MAIN_DIR = os.path.join(SRC_DIR, 'main')
def transform_dup_file_link(line, transforms):
URL_CONTENT = '[-a-zA-Z0-9()@:%_\+.~#?&//=]+'
res = re.findall(f'\[(.+)\]\(({URL_CONTENT})\)', line)
for text, url in res:
word = f'[{text}]({url})'
for tkey in transforms.keys():
if url.startswith(tkey):
nurl = url.replace(tkey, transforms[tkey])
line = line.replace(word, f'[{text}]({nurl})')
break
return line
def pull_duplicates():
if not os.path.exists(DUP_DIR):
os.mkdir(DUP_DIR)
config = {}
with open(f'{CUR_DIR}/duplicates.json') as config_txt:
config = json.loads(config_txt.read())
for fin in config.keys():
new_name = config[fin]['dest']
link_transforms = config[fin].get('link_transforms', {})
fpath = os.path.join(ROOT_DIR, fin)
new_fpath = os.path.join(SRC_DIR, new_name)
with open(fpath, 'r') as in_file:
with open(new_fpath, 'w') as out_file:
for line in in_file.readlines():
out_file.write(transform_dup_file_link(line, link_transforms))
def pull_markdeep_docs():
import http.server
import socketserver
import threading
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import time
class Server(socketserver.ThreadingMixIn, http.server.HTTPServer):
"""Handle requests in a separate thread."""
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=MARKDEEP_DIR, **kwargs)
def start_server(port):
"""Starts the web server in a separate thread."""
httpd = Server(("", port), Handler)
server_thread = threading.Thread(target=httpd.serve_forever)
server_thread.daemon = True # Allow main thread to exit
server_thread.start()
print(f"Server started on port {port}...")
return httpd
PORT = 12345
httpd = start_server(PORT)
# Set up Chrome options for headless mode
chrome_options = Options()
chrome_options.add_argument("--headless")
# This option is necessary for running on some VMs
chrome_options.add_argument("--no-sandbox")
# Create a new Chrome instance in headless mode
driver = webdriver.Chrome(options=chrome_options)
for doc in ['Filament', 'Materials']:
# Open the URL with ?export, which markdeep will export the resulting html.
driver.get(f"http://localhost:{PORT}/{doc}.md.html?export")
time.sleep(3)
# We extract the html from the resulting "page" (an html output itself).
text = driver.find_elements(By.TAG_NAME, "pre")[0].text
# 1. Remove the double empty lines. These make the following text seem like markdown text as oppose to embedded html.
# 2. Remove the max-width styling from the body tag.
# 3. Remove the font-family styling from the body tag.
text = text.replace("\n\n","\n")\
.replace("max-width:680px;", "")\
.replace("font-family:Palatino", "--font-family:Palatino")\
.replace("\"./images", "\"../images")\
.replace("\"images/", "\"../images/")
# Save the page source as .md with embedded html
with open(f'{MAIN_DIR}/{doc.lower()}.md', "w", encoding="utf-8") as f:
f.write(text)
# Close the browser
driver.quit()
# Shutdown the server
httpd.shutdown()
if __name__ == "__main__":
pull_duplicates()
pull_markdeep_docs()
res, err = execute('mdbook build', cwd=DOCS_SRC_DIR)
assert res == 0, f"failed to execute `mdbook`. return-code={res} err=\"{err}\""

68
docs_src/build/utils.py Normal file
View File

@@ -0,0 +1,68 @@
# Copyright (C) 2025 The Android Open Source Project
#
# 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.
import subprocess
import os
import argparse
import sys
def execute(cmd,
cwd=None,
capture_output=True,
stdin=None,
env=None,
raise_errors=False):
in_env = os.environ
in_env.update(env if env else {})
home = os.environ['HOME']
if f'{home}/bin' not in in_env['PATH']:
in_env['PATH'] = in_env['PATH'] + f':{home}/bin'
stdout = subprocess.PIPE if capture_output else sys.stdout
stderr = subprocess.PIPE if capture_output else sys.stdout
output = ''
err_output = ''
return_code = -1
kwargs = {
'cwd': cwd,
'env': in_env,
'stdout': stdout,
'stderr': stderr,
'stdin': stdin,
'universal_newlines': True
}
if capture_output:
process = subprocess.Popen(cmd.split(' '), **kwargs)
output, err_output = process.communicate()
return_code = process.returncode
else:
return_code = subprocess.call(cmd.split(' '), **kwargs)
if return_code:
# Error
if raise_errors:
raise subprocess.CalledProcessError(return_code, cmd)
if output:
if type(output) != str:
try:
output = output.decode('utf-8').strip()
except UnicodeDecodeError as e:
print('cannot decode ', output, file=sys.stderr)
return return_code, (output if return_code == 0 else err_output)
class ArgParseImpl(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(1)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
# Markdeep documents
Markdeep documents require special processing before they can be compiled into the group.
The "original" are stored in this folder. The processing part takes place in
`docs_src/build/run.py`.
## Editing
While editing the file, you might consider doing the following
- `python3 -m http.server 8001`
- visit `http://localhost:8001/Filament.md.html` in the browser to view the result

39
docs_src/src/SUMMARY.md Normal file
View File

@@ -0,0 +1,39 @@
# Summary
- [Introduction](./dup/intro.md)
- [Build](./dup/building.md)
- [Build for Android on Windows](./build/windows_android.md)
- [Contribute](./dup/contributing.md)
- [Coding Style](./dup/code_style.md)
- [Core Concepts](./main/README.md)
- [Filament](./main/filament.md)
- [Materials](./main/materials.md)
- [Tutorials and Samples](./samples/README.md)
- [iOS Tutorial](./samples/ios.md)
- [Web Tutorial](./samples/web.md)
- [Technical Notes](./notes/README.md)
- [Versioning](./notes/versioning.md)
- [Documentation](./dup/docs.md)
- [Debugging](./notes/debugging.md)
- [Metal](./notes/metal_debugging.md)
- [Vulkan](./notes/vulkan_debugging.md)
- [SPIR-V](./notes/spirv_debugging.md)
- [Libraries](./notes/libs.md)
- [bluegl](./dup/bluegl.md)
- [bluevk](./dup/bluevk.md)
- [filamat](./dup/filamat.md)
- [gltfio](./dup/gltfio.md)
- [iblprefilter](./dup/iblprefilter.md)
- [matdbg](./dup/matdbg.md)
- [uberz](./dup/uberz.md)
- [Tools](./notes/tools.md)
- [beamsplitter](./dup/beamsplitter.md)
- [cmgen](./dup/cmgen.md)
- [cso-lut](./dup/cso_lut.md)
- [filamesh](./dup/filamesh.md)
- [normal-blending](./dup/normal_blending.md)
- [mipgen](./dup/mipgen.md)
- [matinfo](./dup/matinfo.md)
- [roughness-prefilter](./dup/roughness_prefilter.md)
- [specular-color](./dup/specular_color.md)
- [zbloat](./dup/zbloat.md)

View File

@@ -0,0 +1,2 @@
Do not manually edit any file in this folder. They have been autogenerated
by a script.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

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