Compare commits

..

91 Commits

Author SHA1 Message Date
Powei Feng
d064e2ed78 test: single simple program 2025-02-13 17:49:31 +00:00
Grant Commodore
a22873bb2e vk: extension support in shared context (#8415) 2025-02-11 14:04:24 -08:00
Ben Doherty
b2801d0a5c Support including PlatformMetal.h in C++ headers (#8431) 2025-02-11 10:11:11 -08:00
Powei Feng
1a5f1cc6ab matdbg: fix three bugs (#8430)
1. changes weren't refreshed for windows/linux-mesa vulkan. This
   is due to a reordering of the shaders when the shader source
   is replaced. We fix this by ensuring the ordering before
   writing out the edit.
   Fixes #7286

2. A condition was flipped in the SourceFormatter causing the
   format feature to not work on linux

3. The material update status wasn't really propagated to the
   front-end due to not updating the status counter.
2025-02-11 07:50:45 +00:00
Powei Feng
9f5001d347 vk: fix debug code (#8429)
Some debug code that are only enabled for debug purposes have
not been properly refactored after the fvkutils commit.
2025-02-11 07:37:04 +00:00
Grant Commodore
9042f628d4 vk: Adds the layercount to the VulkanTexture and SwapChainBundle (#8392) 2025-02-10 17:50:45 -08:00
Sungun Park
83d71d0f57 Release Filament 1.57.0 2025-02-10 23:33:15 +00:00
Benjamin Doherty
cb8b1bfefa Bump MATERIAL_VERSION to 57 2025-02-10 15:23:37 -08:00
Sungun Park
8824f59051 Move OpenGLDriverBase.h under src/opengl/ (#8433) 2025-02-10 15:21:02 -08:00
Benjamin Doherty
d8af04f08f Add missing setDithering to jsbindings 2025-02-10 09:37:13 -08:00
Mathias Agopian
559bc4eb96 fix some missing includes and trivial warnings (#8414) 2025-02-07 14:48:37 -08:00
GavinKG
c16cab239d Use CAMetalLayer to create MVK surfaces to avoid potential deadlocks. 2025-02-07 12:39:24 -08:00
wangjinhan
68719f913a Rename clearEntities to removeAllEntities and add noexcept. 2025-02-07 11:37:14 -08:00
wangjinhan
038ed69a92 Add clearEntities API in Scene.
The API works for Scene to clear all entities.
2025-02-07 11:37:14 -08:00
Mathias Agopian
69822a91cf the shadow passes get their own face culling mode
the new MaterialInstance::setCullingMode(color, shadow) API allows to
set a separate face culling mode for the color pass and the shadow 
passes.

FIXES[391679058]
2025-02-07 11:36:48 -08:00
Powei Feng
24ff10b5db vk: fix rendering to 2D view of 3D image (#8421)
FIXES=389760706
2025-02-07 16:32:25 +00:00
Sungun Park
ec2f5b8078 Promote getEyeIndex() as a common helper (#8418)
Now the helper function `getEyeIndex` becomes available for all shader
stages including post-processing. It used to be only accessible from
surface vertex shaders.
2025-02-06 22:41:30 +00:00
Powei Feng
538aa39127 Release Filament 1.56.8 2025-02-06 11:13:56 -08:00
Powei Feng
8de56a2bbc Add ostream operator for ExternalImageHandle (#8416)
Without it, DEBUG_COMMAND_STREAM does not compile.
2025-02-05 23:52:05 +00:00
Mathias Agopian
ea5d7d4f47 Add a way to retrieve the GL_RENDERER and GL_VENDOR strings
The API works this way:

```
auto vendor = OpenGLPlatform::getVendorString(engine->getDriver());
```

Obviously the Backend must be `Backend::OPENGL` and the `Driver` must 
have been created with an `OpenGLPlatform` subclass.


FIXES=[385367277]
2025-02-05 15:31:39 -08:00
Ben Doherty
05cdeccc27 Stop precaching stereo depth variants on non-supported platforms (#8413) 2025-02-05 11:05:03 -08:00
Mathias Agopian
ad4f349f00 Improve external texture image API
The current API used a void* in Texture::setExternalImage to pass
the platform specific image. This was a problem because on some
platform like Android, there could be several types (EGLImageKHR and
AHardwareBuffer), and with the void* there was no way to distinguish
them on the backend / platform side.

We now have a new Texture API which takes a
Platform::ExternalImageHandle, which is a reference-counted handle
to a Platform::ExternalImage. Platform::ExternalImage is an opaque
type only known by the platform.

This type must be created using a concrete Platform specific API, such
as:

PlatformEGL::createExternalImage
PlatformEGLAndroid::createExternalImage
PlatformCocoaGL::createExternalImage
PlatformCocoaTouchGL::createExternalImage

New types can easily be added in the future.

There is no "destroy" call because the Platform::ExternalImageHandle is
reference-counted and the client can let go of it as soon as it
doesn't need it any longer (typically after calling
Texture::setExternalImage). Platform::ExternalImage is a small
structure that just anonymously wraps the concrete types.

New internal driver APIs have been added to handle this functionality.
2025-02-04 13:16:56 -08:00
Mathias Agopian
06a2def85f make sure FXAA resets alpha channel when it's the last postfx (#8412)
If FXAA is the last post process effect (i.e. no upscaling), and
color grading produced a luma channel, then FXAA needs to reset the
alpha channel to 1.
2025-02-04 19:52:37 +00:00
Powei Feng
a04019937e Add feature flag for material/instance destroy assert (#8411)
This will allow a more lenient rollout of the assertion, which
otherwise will increase crashes for current clients.

We also disable features.engine.debug.assert_material_instance_in_use
by default (it was enabled for debug builds).
2025-02-04 19:30:40 +00:00
Ben Doherty
fff7bd2b28 Combine and install Abseil (#8387) 2025-02-04 09:32:49 -08:00
Powei Feng
3c4591df17 java: must use return var in Engine (#8409) 2025-02-03 22:53:44 -08:00
Sungun Park
4fe852e88a Ensure correct resource cleanup sequence to avoid crashes upon app closing (#8408)
The commit 1747ae8f5a enfoces a correct
order for releasing resource. Fix the order to avoid crashes.

Make some samples to use the DEPTH32F format for better compatibility.
Some manufacturers don't fully support DEPTH24 on Vulkan. E.g., AMD
Radeon PRO W6400
2025-02-03 21:23:53 +00:00
Mathias Agopian
864529254e fix color grading as subpass
This broke in 48a2c64. Fixes #8401.
2025-02-03 12:37:53 -08:00
Powei Feng
93fa55bd29 vk: refactor utils into its own namespace (#8280)
We move the code that was contained within two "utils" files
into separate utils sources in the vulkan/utils directory.
2025-02-03 19:10:19 +00:00
Sungun Park
fb9518e915 Fix warnings regarding #pragma clang (#8405)
'#pragma clang' is unavailable in MSVC. Wrap them with the proper
preprocessor to avoid warnings in MSVC.

BUGS=[390207431]
2025-02-03 17:43:44 +00:00
Mathias Agopian
b780cb36d0 attempt to fix crashers when initializing the JVM
- clarify precondition for VirtualMachineEnv, in particular, 
  JNI_OnLoad() must be called from a thread attached to the VM, and
  should be called once. This is now enforced internally, subsequent
  calls are ignored.

- sVirtualMachine was written and read from potentially different 
  threads without synchronization. It is now mutex protected.

- added fatal asserts in all locations that we cannot recover from;
  previously we would stay in an undefined state.

BUGS=[390724273]
2025-02-01 22:35:53 -08:00
Rafael Dominguez
62cd8f1d35 Update multiview shader code generator for Vulkan
When targeting Vulkan with multiview, the shader
code generator was using the OpenGL extension
and built-in variables, which are not supported on
Vulkan.

Changed it to use GL_EXT_multiview instead of
GL_OVR_multiview2 when the target API is Vulkan.
2025-01-31 16:50:02 -08:00
Doris Wu
793f2b4eb7 [Depends on #8332] Integrate fgviewer to the engine side (#8344)
* Introduce FrameGraphInfo class

* Move the assignment into pimpl

* Make ctors explicit

* Add ctors to fg info structs

* Revert the macro change to align with existing

* Address the comments

* Remove pimpl and move func def to .cc

* Fix

* Convert the FrameGraph to FrameGraphInfo

* Initialize and update debug server on engine side

* Fix compile error

* Address the comments

* Update

* Use camelCase

* Use camelCase

* Update
2025-01-31 23:39:47 +00:00
Ben Doherty
9a2ca8ddbb Metal: add config to abandon frame if drawable cannot be acquired (#8397) 2025-01-31 13:31:07 -08:00
Eliza Velasquez
67710723d7 c-filament-style.el: fix init list indent 2025-01-31 12:06:09 -08:00
Eliza Velasquez
40851f4b51 matdbg: add support for essl1 shader debugging
Fixes #8261
2025-01-31 11:44:51 -08:00
Sungun Park
87bdf96449 Refactor: Rename shader snippets w/ new naming convention (see README.md) (#8402)
This commit renames all shader snippet files to conform to the newly
introduced naming convention outlined in README.md.

The new naming convention uses a `prefix_name.suffix` format to clearly
indicate the purpose and target shader stage of each snippet. This
improves the overall organization and readability of the shader code,
making it easier to understand how each snippet contributes to the
shader generation process.

No functional changes were made to the shader code itself or source
code. This is purely a refactoring for clarity and maintainability.
2025-01-31 00:02:53 +00:00
Benjamin Doherty
f1c1aa155b Release Filament 1.56.7 2025-01-29 16:41:11 -08:00
Mathias Agopian
41f7dc384b add a version of Engine::flushAndWait that takes a timeout
The old version that doesn't take a timeout now always waits forever;
before it waited for a few seconds on Android debug builds.

The new version has an explicit timeout that works on all platforms and
returns success status.

FIXES=[384043020]
2025-01-29 14:47:21 -08:00
Evan Mezeske
4465e6c7f6 Remove noexcept from UserPanicHandler::call() so that panic handlers can throw. Without this change, throwing inside the user panic handler calls terminate(). Note that the docs for setPanicHandler() explicitly say that it's okay for the handler to throw, which is not true prior to this change. 2025-01-29 14:44:09 -08:00
Mathias Agopian
48a2c6483b Add support for SGSR 1.0
SGSR stands for Snapdragon Game Super Resolution. It is an efficient
upscaler for mobile.

Split the upscaling passes into multiple methods in PostProcessManager.
Also, add a way to preserve the alpha channel in the FXAA pass.
2025-01-29 14:43:20 -08:00
Mathias Agopian
5b3343fcc2 Fix ShadowMapManager ShadowMap alignment (#8398) 2025-01-29 11:55:23 -08:00
Mathias Agopian
68b3d9ba54 mistakenly enabled the Shadow Atlas feature 2025-01-27 22:20:27 -08:00
John Bampton
5fd84db447 docs: update ImageDecoder.h; fix spelling 2025-01-27 21:18:55 -08:00
Powei Feng
1dae41c607 matdbg: fix two bugs with formatting (#8388)
- return original source when on an unsupported platform
- check clang-format is available and return original source.
2025-01-27 11:51:48 -08:00
Ben Doherty
6f673753bd Sync abseil into the repository (#8385) 2025-01-24 14:39:28 -08:00
Powei Feng
6dc79a319e filamat: fix spirv remap intialization (#8384)
FIXES=390398814
2025-01-24 09:52:03 -08:00
Powei Feng
3b7cbd6bdb viewer: fix broken test 2025-01-21 16:53:36 -08:00
Mathias Agopian
ea21b740b2 use the move modern syntax for std::enable_if and friends
e.g. std::enable_if<cond>::type is replaced by std::enable_if_t<cond>

remove some unneeded typename keywords
2025-01-21 16:16:09 -08:00
Mathias Agopian
2d867a9dd6 Handle tags now work with heap allocated handles (#8370)
- uninlined getHandleTag so that the code is not duplicated when
  multiple backends are supported (e.g. GLES and Vulkan)
- added a lock for mDebugTags because, even if rare, it technically
  can be accessed from multiple threads. This would happen only
  on a failure. There should never be any contention on this lock.
2025-01-21 16:15:45 -08:00
Mathias Agopian
3f1e32c404 fix some trivial TODOs (#8371) 2025-01-21 09:49:02 -08:00
Powei Feng
ada5791daf vk: do not delay old swapchain destruction when creating new swapchain (#8368)
Because of a recent ref-counting refactor, the swapchains are not
being immediately destroyed when destorySwapChain is called. This
might cause issue with following calls to createSwapChain.

We make sure the ref-counted resources are cleaned-up before new
swapchains are created.

Fixes #8288
2025-01-21 08:32:22 +00:00
Powei Feng
db6ded4eec docs: disable validate script for now 2025-01-21 00:15:31 -08:00
Powei Feng
bfaf3fb87b docs: fix validate-docs on push 2025-01-21 00:09:09 -08:00
Powei Feng
bba254ba6d docs: add github presubmit workflow to prevent /docs edits (#8357)
The content of /docs should be generated and not manually
generated. We add a script to check for edits and also allow for
tags to override the check.
2025-01-21 07:08:11 +00:00
Doris Wu
85e2cc0844 Create data transmitting class for fgviewer (#8332)
* Introduce FrameGraphInfo class

* Move the assignment into pimpl

* Make ctors explicit

* Add ctors to fg info structs

* Revert the macro change to align with existing

* Address the comments

* Remove pimpl and move func def to .cc

* Fix

* Address the comment
2025-01-18 02:47:22 +00:00
Mathias Agopian
bef849b0e3 large code cleanup (#8364)
* Remove redundant qualifiers in filament public headers

* remove redundant qualifiers in filament implementation

* remove redundant qualifiers in libutils public headers

* remove redundant qualifier for libutils implementation

* remove redundant qualifiers for libmath

* use is_same_v<> instead of is_same<>

* bring back Builder::name()

we keep Builder::name() on all object, and forward to the MixIn class
that does the implementation, so that we have correct documentation, and
better IDE completion.

* add missing const parameters in filament's implementation

* various source cleanup

- missing includes
- missing const
- C cast style
- superfluous inline keyword
2025-01-17 17:50:16 -08:00
Mathias Agopian
1747ae8f5a validate MaterialInstance references when destroyed (#8366)
* validate MaterialInstance references when destroyed

With this change we now enforce two things:
- All MaterialInstance of a Material must be destroyed when
  destroying said Material. This has always been a documented 
  requirement of the public API, but wasn't enforced (only
  a warning was printed).
  This new assertion is unconditional.

- A MaterialInstance, when destroyed is no longer in use by any
  Renderable.

So before destroying a MaterialInstance, the user of API needs to 
ensure that either all Renderable using that MaterialInstance in one
of their Render Primitives are  destroyed, or, that these Renderable
using that MaterialInstance are reset to another one or to null.

There is a new RenderableManager::clearMaterialInstanceAt() that can
be used to clear a MaterialInstance on a Render Primitive.
  
Additionally, a Render Primitive with a null MaterialInstance is now
silently skipped during rendering, instead of a null-dereference.

Finally, that second assert is protected by a new feature flag: 
"features.engine.debug.assert_material_instance_in_use". This flag is
enabled on DEBUG builds and disabled on RELEASE builds by default.
The flag can be changed at any time using `Engine::setFeatureFlag()`.

BUGS=[333907416]

* Update filament/src/components/RenderableManager.cpp

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

---------

Co-authored-by: Powei Feng <powei@google.com>
2025-01-17 14:15:15 -08:00
Sungun Park
4c3a3241ca Fix compile & linker warnings (#8356)
Fix warnings emitted during the Filament compilation using CLion and
./build.sh script.

BUGS=[390207431]
2025-01-17 17:53:09 +00:00
Powei Feng
c49d72e7d3 vk: properly destroy swapchain on recreate (#8365)
Fixes #8185, #6445
2025-01-17 06:39:05 +00:00
Mathias Agopian
7c6463d01a update the documentation regarding STL usage (#8358)
* update the documentation regarding STL usage

* Update CODE_STYLE.md

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

---------

Co-authored-by: Powei Feng <powei@google.com>
2025-01-16 16:23:01 -08:00
Powei Feng
e6b15a90e9 renderdiff: fix mesa deps (#8362)
There are some packages that cannot be installed with
 apt-get -y build-dep mesa

We manually add those packages wrt to the expected clang version.
2025-01-16 23:20:40 +00: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
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
2185 changed files with 316018 additions and 4858 deletions

View File

@@ -77,16 +77,29 @@ jobs:
run: |
cd build/web && printf "y" | ./build.sh presubmit
validate-docs:
name: validate-docs
runs-on: ubuntu-22.04-4core
steps:
- uses: actions/checkout@v4.1.6
with:
fetch-depth: 0
- name: Check for manual edits to /docs
run: |
echo "${{ github.event.pull_request.head.sha }} -- ${{ github.event.pull_request.head.sha }}"
# disable for now
# bash docs_src/build/presubmit_check.sh ${{ github.event.pull_request.head.sha }}
test-renderdiff:
name: test-renderdiff
runs-on: ubuntu-22.04-32core
runs-on: ubuntu-22.04-16core
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_tests.sh
source ./build/linux/ci-common.sh && bash test/renderdiff/test.sh
- uses: actions/upload-artifact@v4
with:
name: presubmit-renderdiff-result

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

@@ -457,10 +457,19 @@ if (NOT WEBGL)
set(GC_SECTIONS "-Wl,--gc-sections")
endif()
# Prevents stacks from being made for executable by explicitly adding this linker flag. Otherwise,
# it generates warnings newly introduced as of GNU LD 2.39. Modern security practices strongly
# recommend marking the stack as non-executable using the -z noexecstack linker flag to prevent
# stack-based buffer overflow exploits.
# See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ffcf9c5700e49c0aee42dcba9a12ba21338e8136
if (LINUX)
set(NO_EXEC_STACK "-Wl,-z,noexecstack")
endif()
set(B_SYMBOLIC_FUNCTIONS "-Wl,-Bsymbolic-functions")
if (ANDROID)
set(BINARY_ALIGNMENT "-Wl,-z,max-page-size=16384")
set(BINARY_ALIGNMENT "-Wl,-z,max-page-size=16384")
endif()
if (APPLE)
@@ -475,7 +484,7 @@ if (APPLE)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qc -S <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS} ${NO_EXEC_STACK}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GC_SECTIONS} ${B_SYMBOLIC_FUNCTIONS} ${BINARY_ALIGNMENT}")
if (WEBGL_PTHREADS)
@@ -525,11 +534,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)
@@ -655,10 +667,6 @@ function(list_licenses OUTPUT MODULES)
endfunction()
set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/linux/combine-static-libs.sh")
if (WIN32)
set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/windows/combine-static-libs.bat")
set(CMAKE_AR "lib.exe")
endif()
# Add a custom command to TARGET that combines the static libraries in DEPS into a single archive.
function(combine_static_libs TARGET OUTPUT DEPS)
@@ -673,12 +681,22 @@ function(combine_static_libs TARGET OUTPUT DEPS)
endif()
endforeach()
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${OUTPUT}" ${DEPS_FILES}
COMMENT "Combining ${target} dependencies into single shared library"
VERBATIM
)
if (WIN32)
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND lib.exe /nologo /out:temp.lib ${DEPS_FILES}
COMMAND "${CMAKE_COMMAND}" -E rename temp.lib ${OUTPUT}
COMMENT "Combining ${target} dependencies into single shared library"
VERBATIM
)
else()
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${OUTPUT}" ${DEPS_FILES}
COMMENT "Combining ${target} dependencies into single shared library"
VERBATIM
)
endif()
endfunction()
# ==================================================================================================
@@ -749,6 +767,7 @@ add_subdirectory(${LIBRARIES}/utils)
add_subdirectory(${LIBRARIES}/viewer)
add_subdirectory(${FILAMENT}/filament)
add_subdirectory(${FILAMENT}/shaders)
add_subdirectory(${EXTERNAL}/abseil/tnt)
add_subdirectory(${EXTERNAL}/basisu/tnt)
add_subdirectory(${EXTERNAL}/civetweb/tnt)
add_subdirectory(${EXTERNAL}/imgui/tnt)
@@ -778,6 +797,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

@@ -121,9 +121,21 @@ private:
- other headers are sorted in reverse order of their layering, that is, lower layer headers last
- within a layer, headers are sorted alphabetically
- strive for implementing one class per file
- `STL` limited in public headers to:
- `type_traits`
- `STL` limited in **filament** public headers to:
- `array`
- `initializer_list`
- `iterator`
- `limits`
- `optional`
- `type_traits`
- `utility`
- `variant`
For **libfilament** the rule of thumb is that STL headers that don't generate code are allowed (e.g. `type_traits`),
conversely containers and algorithms are not allowed. There are exceptions such as `array`. See above for the full list.
- The following `STL` headers are banned entirely, from public and private headers as well as implementation files:
- `iostream`
*Sorting the headers is important to help catching missing `#include` directives.*

View File

@@ -7,3 +7,5 @@ for next branch cut* header.
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
## Release notes for next branch cut
- Support including PlatformMetal.h in C++ files.

View File

@@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.56.5'
implementation 'com.google.android.filament:filament-android:1.57.0'
}
```
@@ -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.56.5'
pod 'Filament', '~> 1.57.0'
```
## Documentation

View File

@@ -7,6 +7,24 @@ 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.57.1
## v1.57.0
- matdbg: Add support for debugging ESSL 1.0 shaders
- backend: New platform API to better handle external textures [⚠️ **New Material Version**]
## v1.56.8
## v1.56.7
## v1.56.6
fix crash: the 'target_node' of Animation Channel may be nullpointer.
## v1.56.5

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()
@@ -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

@@ -392,11 +392,11 @@ Java_com_google_android_filament_Engine_nIsValidSwapChain(JNIEnv*, jclass,
return (jboolean)engine->isValid((SwapChain*)nativeSwapChain);
}
extern "C" JNIEXPORT void JNICALL
extern "C" JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_Engine_nFlushAndWait(JNIEnv*, jclass,
jlong nativeEngine) {
jlong nativeEngine, jlong timeout) {
Engine* engine = (Engine*) nativeEngine;
engine->flushAndWait();
return engine->flushAndWait((uint64_t)timeout);
}
extern "C" JNIEXPORT void JNICALL

View File

@@ -329,6 +329,18 @@ Java_com_google_android_filament_MaterialInstance_nSetCullingMode(JNIEnv*,
instance->setCullingMode((MaterialInstance::CullingMode) cullingMode);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetCullingModeSeparate(JNIEnv*, jclass,
jlong nativeMaterialInstance,
jlong colorPassCullingMode, jlong shadowPassCullingMode) {
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
instance->setCullingMode(
(MaterialInstance::CullingMode) colorPassCullingMode,
(MaterialInstance::CullingMode) shadowPassCullingMode);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_google_android_filament_MaterialInstance_nSetColorWrite(JNIEnv*,
@@ -505,6 +517,14 @@ Java_com_google_android_filament_MaterialInstance_nGetCullingMode(JNIEnv* env, j
return (jint)instance->getCullingMode();
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_google_android_filament_MaterialInstance_nGetShadowCullingMode(JNIEnv* env, jclass,
jlong nativeMaterialInstance) {
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
return (jint)instance->getShadowCullingMode();
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_google_android_filament_MaterialInstance_nIsColorWriteEnabled(JNIEnv* env, jclass clazz,

View File

@@ -459,6 +459,13 @@ Java_com_google_android_filament_RenderableManager_nSetMaterialInstanceAt(JNIEnv
materialInstance);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_RenderableManager_nClearMaterialInstanceAt(JNIEnv*, jclass,
jlong nativeRenderableManager, jint i, jint primitiveIndex) {
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
rm->clearMaterialInstanceAt((RenderableManager::Instance) i, (size_t) primitiveIndex);
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_RenderableManager_nGetMaterialInstanceAt(JNIEnv*, jclass,
jlong nativeRenderableManager, jint i, jint primitiveIndex) {

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

@@ -1271,7 +1271,28 @@ public class Engine {
* {@link android.view.SurfaceHolder.Callback#surfaceDestroyed surfaceDestroyed}.</p>
*/
public void flushAndWait() {
nFlushAndWait(getNativeObject());
boolean unused = flushAndWait(Fence.WAIT_FOR_EVER);
}
/**
* Kicks the hardware thread (e.g. the OpenGL, Vulkan or Metal thread) and blocks until
* all commands to this point are executed. Note that does guarantee that the
* hardware is actually finished.
*
* A timeout can be specified, if for some reason this flushAndWait doesn't complete before the timeout, it will
* return false, true otherwise.
*
* <p>This is typically used right after destroying the <code>SwapChain</code>,
* in cases where a guarantee about the <code>SwapChain</code> destruction is needed in a
* timely fashion, such as when responding to Android's
* <code>android.view.SurfaceHolder.Callback.surfaceDestroyed</code></p>
*
* @param timeout A timeout in nanoseconds
* @return true if successful, false if flushAndWait timed out, in which case it wasn't successful and commands
* might still be executing on both the CPU and GPU sides.
*/
public boolean flushAndWait(long timeout) {
return nFlushAndWait(getNativeObject(), timeout);
}
/**
@@ -1437,7 +1458,7 @@ public class Engine {
private static native boolean nIsValidRenderTarget(long nativeEngine, long nativeTarget);
private static native boolean nIsValidSwapChain(long nativeEngine, long nativeSwapChain);
private static native void nDestroyEntity(long nativeEngine, int entity);
private static native void nFlushAndWait(long nativeEngine);
private static native boolean nFlushAndWait(long nativeEngine, long timeout);
private static native void nFlush(long nativeEngine);
private static native boolean nIsPaused(long nativeEngine);
private static native void nSetPaused(long nativeEngine, boolean paused);

View File

@@ -556,6 +556,20 @@ public class MaterialInstance {
nSetCullingMode(getNativeObject(), mode.ordinal());
}
/**
* Overrides the default triangle culling state that was set on the material separately for the
* color and shadow passes
*
* @see
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:culling">
* Rasterization: culling</a>
*/
public void setCullingMode(@NonNull Material.CullingMode colorPassCullingMode,
@NonNull Material.CullingMode shadowPassCullingMode) {
nSetCullingModeSeparate(getNativeObject(),
colorPassCullingMode.ordinal(), shadowPassCullingMode.ordinal());
}
/**
* Returns the face culling mode.
*/
@@ -564,6 +578,14 @@ public class MaterialInstance {
return sCullingModeValues[nGetCullingMode(getNativeObject())];
}
/**
* Returns the face culling mode for the shadow passes.
*/
@NonNull
public Material.CullingMode getShadowCullingMode() {
return sCullingModeValues[nGetShadowCullingMode(getNativeObject())];
}
/**
* Overrides the default color-buffer write state that was set on the material.
*
@@ -920,6 +942,8 @@ public class MaterialInstance {
private static native void nSetDoubleSided(long nativeMaterialInstance, boolean doubleSided);
private static native void nSetCullingMode(long nativeMaterialInstance, long mode);
private static native void nSetCullingModeSeparate(long nativeMaterialInstance,
long colorPassCullingMode, long shadowPassCullingMode);
private static native void nSetColorWrite(long nativeMaterialInstance, boolean enable);
private static native void nSetDepthWrite(long nativeMaterialInstance, boolean enable);
private static native void nSetStencilWrite(long nativeMaterialInstance, boolean enable);
@@ -952,6 +976,7 @@ public class MaterialInstance {
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterialInstance);
private static native boolean nIsDoubleSided(long nativeMaterialInstance);
private static native int nGetCullingMode(long nativeMaterialInstance);
private static native int nGetShadowCullingMode(long nativeMaterialInstance);
private static native boolean nIsColorWriteEnabled(long nativeMaterialInstance);
private static native boolean nIsDepthWriteEnabled(long nativeMaterialInstance);
private static native boolean nIsStencilWriteEnabled(long nativeMaterialInstance);

View File

@@ -869,6 +869,13 @@ public class RenderableManager {
nSetMaterialInstanceAt(mNativeObject, i, primitiveIndex, materialInstance.getNativeObject());
}
/**
* Clears the material instance for the given primitive.
*/
public void clearMaterialInstanceAt(@EntityInstance int i, @IntRange(from = 0) int primitiveIndex) {
nClearMaterialInstanceAt(mNativeObject, i, primitiveIndex);
}
/**
* Creates a MaterialInstance Java wrapper object for a particular material instance.
*/
@@ -1012,6 +1019,7 @@ public class RenderableManager {
private static native void nGetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float[] center, float[] halfExtent);
private static native int nGetPrimitiveCount(long nativeRenderableManager, int i);
private static native void nSetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex, long nativeMaterialInstance);
private static native void nClearMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex);
private static native long nGetMaterialInstanceAt(long nativeRenderableManager, int i, int primitiveIndex);
private static native void nSetGeometryAt(long nativeRenderableManager, int i, int primitiveIndex, int primitiveType, long nativeVertexBuffer, long nativeIndexBuffer, int offset, int count);
private static native void nSetBlendOrderAt(long nativeRenderableManager, int i, int primitiveIndex, int blendOrder);

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

@@ -1420,10 +1420,10 @@ public class View {
/**
* Upscaling quality
* LOW: bilinear filtered blit. Fastest, poor quality
* MEDIUM: AMD FidelityFX FSR1 w/ mobile optimizations
* MEDIUM: Qualcomm Snapdragon Game Super Resolution (SGSR) 1.0
* HIGH: AMD FidelityFX FSR1 w/ mobile optimizations
* ULTRA: AMD FidelityFX FSR1
* FSR1 require a well anti-aliased (MSAA or TAA), noise free scene.
* FSR1 and SGSR require a well anti-aliased (MSAA or TAA), noise free scene. Avoid FXAA and dithering.
*
* The default upscaling quality is set to LOW.
*/

View File

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

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"
@@ -125,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 ".")}
@@ -172,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=""
@@ -240,6 +264,7 @@ 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} \
@@ -376,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} \
@@ -613,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} \
@@ -802,7 +829,7 @@ function check_debug_release_build {
pushd "$(dirname "$0")" > /dev/null
while getopts ":hacCfgijmp:q:uvslwedk:bx:S:X:" opt; do
while getopts ":hacCfgijmp:q:uvslwedtk:bx:S:X:" opt; do
case ${opt} in
h)
print_help
@@ -823,6 +850,12 @@ while getopts ":hacCfgijmp:q:uvslwedk:bx:S:X:" 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
;;
@@ -1027,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

@@ -1,16 +1,16 @@
#!/bin/bash
# version of clang we want to use
GITHUB_CLANG_VERSION=14
export GITHUB_CLANG_VERSION=14
# version of CMake to use instead of the default one
CMAKE_VERSION=3.19.5
export GITHUB_CMAKE_VERSION=3.19.5
# version of ninja to use
NINJA_VERSION=1.10.2
export GITHUB_NINJA_VERSION=1.10.2
# Steps for GitHub Workflows
if [[ "$GITHUB_WORKFLOW" ]]; then
# Install ninja
wget -q https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-linux.zip
wget -q https://github.com/ninja-build/ninja/releases/download/v$GITHUB_NINJA_VERSION/ninja-linux.zip
unzip -q ninja-linux.zip
export PATH="$PWD:$PATH"
@@ -18,9 +18,9 @@ if [[ "$GITHUB_WORKFLOW" ]]; then
mkdir -p cmake
cd cmake
sudo wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo chmod +x ./cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo ./cmake-$CMAKE_VERSION-Linux-x86_64.sh --skip-license > /dev/null
sudo wget https://github.com/Kitware/CMake/releases/download/v$GITHUB_CMAKE_VERSION/cmake-$GITHUB_CMAKE_VERSION-Linux-x86_64.sh
sudo chmod +x ./cmake-$GITHUB_CMAKE_VERSION-Linux-x86_64.sh
sudo ./cmake-$GITHUB_CMAKE_VERSION-Linux-x86_64.sh --skip-license > /dev/null
sudo update-alternatives --install /usr/bin/cmake cmake $(pwd)/bin/cmake 1000 --force
cd ..

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

View File

@@ -1,39 +0,0 @@
@echo off
set selfName=%0
:: Check that we have at least 3 arguments.
set argC=0
for %%x in (%*) do Set /A argC+=1
if %argC% LSS 3 goto :print_help
set AR_TOOL=%1
shift
set OUTPUT_PATH=%1
shift
set ARCHIVES=
:loop
if [%1]==[] goto :finished
set ARCHIVES=%ARCHIVES% %1
shift
goto :loop
:finished
%AR_TOOL% /nologo /out:%OUTPUT_PATH% %ARCHIVES% || goto :error
exit /B %ERRORLEVEL%
:print_help
echo %selfName%. Combine multiple static libraries using an archiver tool.
echo;
echo Usage:
echo %selfName% ^<path-to-ar^> ^<output-archive^> ^<archives^>...
echo;
echo Notes:
echo ^<archives^> must be a list of absolute paths to static library archives.
echo This script creates a temporary working directory inside the current directory.
exit /B 1
:error
exit /B %ERRORLEVEL%

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

140
docs_src/build/checks.py Normal file
View File

@@ -0,0 +1,140 @@
# 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.
# This script contains several checks on the current commit, each corresponds to `possible_conditions`
# in the main function below
# - Direct (non-filamentbot) edits of /docs
# - Edits to sources of READMEs that are duplicated to /docs
# or edits to /docs_src sources
# - Commit message has DOCS_BYPASS
# - Commit message has DOCS_FORCE
# - Commit message has DOCS_ALLOW_DIRECT_EDITS
import json
import sys
import os
from utils import execute, ArgParseImpl
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.join(CUR_DIR, '../../')
def get_last_commit_hash():
res, ret = execute('git rev-parse HEAD', cwd=ROOT_DIR)
assert res == 0, 'Failed to get the last commit hash'
return ret.strip()
def get_edited_files(commit_hash):
INSERT = '#####?????'
res, ret = execute(f'git show --name-only --pretty=%b{INSERT} {commit_hash}')
assert res == 0, 'Failed to get edited filed'
files = []
_, after = ret.split(INSERT)
for r in filter(lambda a: len(a) > 0, after.split('\n')):
if r.startswith('commit'):
break
files.append(r)
return files
# Returns True if there were no direct edits to '/docs'
def check_no_direct_edits(commit_hash, printing=True):
bad = [f'\t{f}' for f in get_edited_files(commit_hash) if f.startswith('docs/')]
if printing and len(bad) > 0:
print(f'Found edits to /docs:\n' + '\n'.join(bad))
return len(bad) == 0
# Returns True if docs sources have been modified
def check_has_source_edits(commit_hash, printing=True):
config = {}
with open(f'{CUR_DIR}/duplicates.json') as config_txt:
config = json.loads(config_txt.read())
source_files = set(config.keys())
edited_files = set(get_edited_files(commit_hash))
overlap = [f'\t{f}' for f in list(source_files & edited_files)]
if printing and len(overlap) > 0:
print(f'Found edited source files:\n' + '\n'.join(overlap))
return len(overlap) > 0
# Returns true in a given TAG is found in the commit msg
def commit_msg_has_tag(commit_hash, tag, printing=True):
res, ret = execute(f'git log --pretty=%B {commit_hash}', cwd=ROOT_DIR)
for l in ret.split('\n'):
if tag == l.strip():
if printing:
print(f'Found tag={tag} in commit message')
return True
return False
if __name__ == "__main__":
parser = ArgParseImpl()
TAG_DOCS_BYPASS = 'DOCS_BYPASS'
TAG_DOCS_FORCE = 'DOCS_FORCE'
TAG_DOCS_ALLOW_DIRECT_EDITS = 'DOCS_ALLOW_DIRECT_EDITS'
possible_conditions = {
'no_direct_edits':
check_no_direct_edits,
'source_edits':
check_has_source_edits,
'commit_docs_bypass':
lambda h: commit_msg_has_tag(h, TAG_DOCS_BYPASS),
'commit_docs_force':
lambda h: commit_msg_has_tag(h, TAG_DOCS_FORCE),
'commit_docs_allow_direct_edits':
lambda h: commit_msg_has_tag(h, TAG_DOCS_ALLOW_DIRECT_EDITS),
}
possible_str = ', '.join(list(possible_conditions.keys()))
parser.add_argument(
'--do-and',
type=str,
help=(
f'A conjunction of boolean conditions. Possible values are={possible_str}. '
'Negation is done with `-`'
)
)
parser.add_argument(
'--do-or',
type=str,
help=(
f'A disjunction of boolean conditions. Possible values are={possible_str}. '
'Negation is done with `-`'
)
)
args, _ = parser.parse_known_args(sys.argv[1:len(sys.argv) - 1])
commit_hash = sys.argv[-1]
assert not (args.do_and and args.do_or), "Must not supply both '--do-and' and '--do-or'"
assert args.do_and or args.do_or, "Must supply argument '--do-and' or '--do-or'"
conds = args.do_and.split(',') if args.do_and else args.do_or.split(',')
conds = [c.strip() for c in conds]
assert all(
[c in possible_conditions.keys() for c in
[(c.replace('-', '') if c.startswith('-') else c) for c in conds]]),\
f"Not all conditions are valid names. Only {possible_str} are accepted"
res = []
for cond in conds:
if cond.startswith('-'):
f = lambda: not possible_conditions[cond.replace('-', '')]()
else:
f = possible_conditions[cond]
res.append(f(commit_hash))
if args.do_and:
exit(0 if all(res) else 1)
else:
exit(0 if any(res) else 1)

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

View File

@@ -0,0 +1,19 @@
#!/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.
COMMIT_HASH=$1
python3 docs_src/build/checks.py --do-or="no_direct_edits,commit_docs_allow_direct_edits" $COMMIT_HASH ||\
(echo "Direct edits to /docs are not allowed. Please see /docs_src/README.md if you need to bypass this check." && exit 1)

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

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