Commit Graph

8251 Commits

Author SHA1 Message Date
dependabot[bot]
af71d773ae build(deps): bump the npm_and_yarn group across 1 directory with 2 updates (#9870)
Bumps the npm_and_yarn group with 2 updates in the /build/common/upload-release-assets directory: [brace-expansion](https://github.com/juliangruber/brace-expansion) and [minimatch](https://github.com/isaacs/minimatch).


Updates `brace-expansion` from 1.1.12 to 1.1.13
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.12...v1.1.13)

Updates `minimatch` from 3.1.3 to 3.1.5
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.3...v3.1.5)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 1.1.13
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Powei Feng <powei@google.com>
2026-04-02 17:06:54 +00:00
Mathias Agopian
57faae4645 postfx materials now support sRGB emulation in FL0 (#9866)
FIXES=[498317018]
2026-04-02 09:08:50 -07:00
Filament Bot
e6cf5fa815 [automated] Updating /docs due to commit 426db0a
Full commit hash is 426db0a01d

DOCS_ALLOW_DIRECT_EDITS
2026-04-02 03:37:21 +00:00
Sungun Park
426db0a01d Release Filament 1.70.2 rc/1.71.0-cut 2026-04-01 20:08:07 -07:00
Mathias Agopian
bc0a547701 Support Engine::compile overload to generate view-dependent variants (#9857)
* a new tribool type in libutils (header only)

* Support `Engine::compile` overload to generate view-dependent variants

Implemented an `Engine::compile()` method to infer and generate shader 
permutations directly based on feature states from a provided `View` 
alongside `tribool` settings (skinning, shadowReceiver). 

- Added a new `Material::compile()` overload that directly accepts 
  a precalculated `FixedCapacityVector<Variant>`, decoupling the 
  Material compilation process from specific feature flag checks.

FIXES=[468058969]
2026-04-01 17:08:11 -07:00
Powei Feng
dd1f258a66 settings: add missing renderer options (#9863)
- Move the renderer options to be applied before others before view
   and camera options.
 - Add "render" field to the output of the json description of
   the settings (this was missing).
 - This fixes the Scene->Background Color setting for
   Android's gltf_viewer
2026-04-02 00:04:22 +00:00
Mathias Agopian
16a7047372 Strict bounds validation and parsing optimizations in Ktx1Bundle (#9858)
- Upgraded deserialization precondition checks to fail-fast 
  postconditions.

- Added strict OOB bounds tracking for metadata strings and dynamic 
  payload padding to prevent arbitrary memory corruption
  vulnerabilities.

- Mitigated heap buffer overflows by adding integer boundary constraints
  and dry-running contiguous sizes prior to container allocation.

- Flattened nested layer/face loops via `std::fill_n` and contiguous 
  `memcpy` operations to streamline serialization overhead.

- Updated header documentation explicitly detailing assert 
  circumstances on affected public methods.
2026-03-31 20:26:15 -07:00
Filament Bot
da836c8288 [automated] Updating /docs due to commit 23ee4de
Full commit hash is 23ee4deeab

DOCS_ALLOW_DIRECT_EDITS
2026-03-31 21:24:01 +00:00
Mathias Agopian
23ee4deeab add documentation for specularFactor and specularColorFactor (#9864)
FIXES=[454426385]
2026-03-31 13:56:30 -07:00
Mathias Agopian
face013e86 utils: Enforce geometric resize bounds limits in ostream to prevent massive out-of-bounds heap operations 2026-03-31 11:17:03 -07:00
Mathias Agopian
8f11927aae utils: Truncate oversized CString allocations rather than overflowing internal length logic 2026-03-31 11:17:03 -07:00
Mathias Agopian
2cdff4b521 utils: Protect InternPool references from overflowing to 0 and triggering heap UAF 2026-03-31 11:17:03 -07:00
Mathias Agopian
d1192544ca utils: Protect JobSystem from 8-bit ref-count overflow and UAF cascades 2026-03-31 11:17:03 -07:00
Mathias Agopian
8df899b111 utils: Protect CString routines against integer overflow heap corruption 2026-03-31 11:17:03 -07:00
Mathias Agopian
f8337c42cb utils: Prevent Win32 FindFirstFile handle leaks during exception unwinding in Path::listContents 2026-03-31 11:17:03 -07:00
Mathias Agopian
cb552def6c utils: Enforce format string boundaries to prevent stack injection during Panic events 2026-03-31 11:17:03 -07:00
Mathias Agopian
883f5bae4e utils: Prevent stack buffer leaks by safely trapping snprintf error bounds in Systrace 2026-03-31 11:17:03 -07:00
Mathias Agopian
6713c68791 utils: Enforce 64-bit boundaries and gracefully intercept 0 length in partition_point 2026-03-31 11:17:03 -07:00
Mathias Agopian
bdef97d52c utils: Prevent capacity overflow in StructureOfArrays scaling logic 2026-03-31 11:17:03 -07:00
Mathias Agopian
0016c0808b utils: Fix functional capture move-assignment leaks in Invocable wrappers 2026-03-31 11:17:03 -07:00
Mathias Agopian
c96edc2972 utils: Implement UTILS_MUL_OVERFLOW safely protecting allocators from multiplication overflows 2026-03-31 11:17:03 -07:00
Mathias Agopian
5c5c3b5bb1 utils: Implement generation counter to resolve CyclicBarrier Deadlocks 2026-03-31 11:17:03 -07:00
Mathias Agopian
8ac45bb391 utils: Safely handle NULL pointers returned by dladdr 2026-03-31 11:17:03 -07:00
Mathias Agopian
b351086bc4 utils: Fix integer underflow in generic vector ostream operator 2026-03-31 11:17:03 -07:00
Mathias Agopian
3bc67ca00f Fix heap corruption and memory leak in UniformBuffer move assignment 2026-03-31 11:16:29 -07:00
Mathias Agopian
ea3b0aa6f3 Safely clear DependencyGraph during FrameGraph::reset 2026-03-31 11:16:29 -07:00
Mathias Agopian
b93702203b Remove offset and size parameters from toBufferDescriptor to prevent OOB and logical desync 2026-03-31 11:16:29 -07:00
Mathias Agopian
f1abc9a4d2 Add precondition check for skinning offset bounds 2026-03-31 11:16:29 -07:00
Mathias Agopian
67e4561f2e Fix memory leak and iteration out of bounds in CameraManager termination 2026-03-31 11:16:29 -07:00
Mathias Agopian
86e7297b51 Allow compiler to safely vectorize LUT rendering with scalar epilogue
this is needed because the Builder() allows non POT LUT sizes.
2026-03-31 11:16:29 -07:00
Mathias Agopian
50e0c6bfbd Fix buffer over-read during skinning pairs upload 2026-03-31 11:16:29 -07:00
Doris Wu
cda86e6125 Fix potential memory corruption issue in UboManager (#9861) 2026-03-31 15:50:14 +08:00
Powei Feng
3ab0b41b7d android: [render-validation] support multiple backends (#9820)
This commit introduces several features:

- Backend Testing: Support testing across both OpenGL and Vulkan. Test
  configurations expand per backend, and the Filament Engine alongside
  ModelViewer is recreated dynamically when the backend switches to isolate
  resources.
- UI Controls: Added a backend filter toggle and a test progress bar to the
  main activity, themed appropriately using Material design.
- Memory Optimizations: Drastically reduced memory usage by displaying
  scaled-down thumbnails (128x128) in the main list. Full-resolution images
  are lazy-loaded from disk on demand when clicking a thumbnail to view, and
  large bitmaps are aggressively recycled.
- Device Info Collection: ValidationResultManager now collects and reports
  detailed GPU driver info for each instantiated backend in the output
  results.json.
- Engine Teardown: Introduced an explicit destroy() method in ModelViewer to
  ensure full resource cleanup during engine recreation.
2026-03-31 04:56:35 +00:00
Mathias Agopian
ffcccb336e Refactor EVSM shadowing to use per-shadowmap blurring (#9850)
This commit addresses several issues with EVSM blur precision 
and shadow atlas boundary handling by replacing the global layer blur 
with a dedicated, per-shadowmap separated Gaussian blur pass.

Key improvements:
- Per-ShadowMap Blurring: Moved the EVSM blurring and mipmap passes
  from `PostProcessManager` to `ShadowMapManager`. Blurring is now 
  applied individually per shadow map using its specific `blurWidth`, 
  rather than being incorrectly applied across the entire atlas layer.

- Custom EVSM Gaussian Shader: Introduced a new dedicated 
  post-processing material (`gaussian.fs` and `gaussian.mat`) tailored 
  specifically for EVSM. 

- Safe FP16 Accumulation: The new blur shader pre-scales the color
  accumulation using safe FP16 FMA to strictly prevent `+Inf` overflows
  during Gaussian pass sampling.

- Atlas Boundary Clamping: The custom blur shader enforces clamping
  to an explicit sub-rectangle (`bounds` uniform) preventing texture
  bleed across adjacent shadow maps in the atlas.

- Code Organization: Created a new `evsm/` material directory, 
  extracting `vsmMipmap.mat` and registering the new `gaussian.mat`.
2026-03-30 20:55:02 -07:00
Filament Bot
ae48711ae2 [automated] Updating /docs due to commit f9573a1
Full commit hash is f9573a112d

DOCS_ALLOW_DIRECT_EDITS
2026-03-31 00:57:54 +00:00
Mathias Agopian
f9573a112d fp32 texture formats are not necessarily filterable (#9855)
* fp32 texture formats are not necessarily filterable

Mobile devices don't always support filtering of fp32 textures.
This PR adds a query at the driver level.

High precision EVSM is now conditional to this feature being supported.

* use MTLDevice supports32BitFloatFiltering if available
2026-03-30 17:29:11 -07:00
Mathias Agopian
a007b59f39 repair matdbg shader editing (#9854)
The new LineDictionary API requires to call resolve().
2026-03-27 22:08:47 -07:00
Mathias Agopian
d7b10bdd3b update glslang, spirv-tools and spirv-opt to their latest version (#9845)
* update spirv-cross to a0fba56

* update spirv-tools to v2026.1

* update spirv-headers to 04f10f6

* update glslang to 16.2.0
2026-03-27 16:35:56 -07:00
Mathias Agopian
04270afb83 gltf_viewer should use a SUN light (#9848)
this matches the desktop version.
2026-03-27 16:06:28 -07:00
Ben Doherty
3b7ad307ff Dawn: silence availability warnings on macOS (#9849) 2026-03-27 22:54:52 +00:00
Sungun Park
bedbcbb7eb OpenGL: Factor per-thread state out of OpenGLContext (#9830)
The OpenGLContext class in the OpenGL backend currently conflates two
distinct parts: immutable configuration (extensions, bugs, capabilities)
and a mutable GL state cache. This single-object design is incompatible
with a multi-threaded rendering architecture, where each thread requires
a dedicated GL context and, critically, its own independent state
machine/cache.

This refactoring implements the proposed architecture by:
1. Introducing a new OpenGLState class to exclusively manage the mutable
   GL state cache (texture bindings, buffer bindings, etc.) with
   explicit per-thread ownership (e.g., mBackendState and mWorkerState).
2. Ensuring OpenGLContext retains only the shared, immutable
   configuration.
3. Preserving the existing gl.XXX usage pattern by implementing inline
   accessors in OpenGLState that forward read-only queries (e.g.,
   gl.ext.XXX, gl.isES2()) to the back-referenced OpenGLContext.
4. Updating common functions shared between backend and worker threads
   to explicitly accept an OpenGLState& parameter.

This change enables a multi-threaded approach by guaranteeing each
thread operates on its own dedicated GL state cache, while reusing the
shared, immutable context configuration.

BUGS=[487347473]
2026-03-27 20:53:53 +00:00
Filament Bot
58cd8624d2 [automated] Updating /docs due to commit 8a98387
Full commit hash is 8a9838706e

DOCS_ALLOW_DIRECT_EDITS
2026-03-27 20:19:13 +00:00
Mathias Agopian
f0108247d1 Fix various overflow, truncation, and NEON alignment bugs in bitset.h (#9843)
- Fix constant wrap-around: Define `BIT_COUNT`, `BITS_PER_WORD`, and 
  `WORD_COUNT` (fixed typo from `WORLD_COUNT`) as `size_t` rather than 
  `T` to prevent silent overflows on large bitsets using small integer 
  types.

- Fix NEON `all()` truncation: Remove the generic `T` cast to correctly
  evaluate bounds across the full 64-bit vector lanes.

- Fix non-NEON `count()` overflow: Use a `size_t` accumulator rather 
  than `T` to prevent overflow when counting >255 bits on `uint8_t` 
  parameters.

- Fix NEON strict alignment UB: Enforce unconditional `alignas(16)` on 
  `storage` when `BIT_COUNT` satisfies 128-bit vector multiples, adding 
  a compile-time `static_assert` to ensure ABI expectations match NEON 
  load intrinsics.

- Remove dead masking code inside `firstSetBit()`.
2026-03-27 12:51:40 -07:00
Powei Feng
8a9838706e viewer: update sunlight settings (#9846)
Missing the castShadows=true caused the shadows to be missing
on mobile (using the remote settings page).

Update README.md (this will trigger an update to the remote
page's filament.js)
2026-03-27 19:51:28 +00:00
Mathias Agopian
9511be4caa update draco to 1.5.7 (#9844) 2026-03-27 12:20:37 -07:00
Filament Bot
8705a627db [automated] Updating /docs due to commit 4b040fb
Full commit hash is 4b040fbae6

DOCS_ALLOW_DIRECT_EDITS
2026-03-27 06:08:44 +00:00
Mathias Agopian
167a91efaa Optimize Shader LineDictionary (#9814)
* Optimize Shader LineDictionary with Variable-Length 3-Streams

This commit completely reorganizes the string dictionary compression
pipeline used by compiled Material Text Chunks and improves matinfo
dictionary output.

1. Multi-Base Variable-Length Scaling:
We replaced the static 16-bit indices overhead with a
bounded payload. Now, indices scale dynamically:
- 0 to 239 evaluate in 1 byte.
- 240 to 3584 leverage 0xF0-0xFD escapes evaluating in 2 bytes.
- 3584+ are locked behind a 0xFF marker to 3 bytes.
This natively eradicated the massive monolithic lengths and zero-padding
issues previously dominating shader packages.

2. Variable-Length 3-Stream Decoding:
To solve the Zstandard/Zlib entropy fragmentation that conventionally
plagues interleaved variable byte lengths (which previously inflated
our `filament.aar` boundary constraint by +2KB), we segregated the encoded
payloads.

By grouping high-entropy string boundaries into a `Base Stream`
and isolating offset digits inside an `Extension Stream`,
predictive LZ77 ZIP sliding-windows perfectly map
over both arrays independently without disruption.

3. Optimize Numeric Stream using LEB128
Prior to this change, numerical suffixes split from shader
variables (e.g., `param_1024` -> `param_` + `1024`) were fed back
into the localized String Dictionary. Because high-frequency numbers were
assigned disjointed localized IDs per shader variant, LZ77
failed to cross-reference their repetitive structures across
shipped `.aar` archives, fracturing compression sequences.

This patch implements a unified 3-Stream topology. It
extracts numerical primitives (< 32768) away from the baseline
String Dictionary, writing them into an isolated, contiguous
LEB128 array.

By using a dedicated `[254]` Escape Token within the primary stream, numerical
variables maintain exact 1-byte (`< 128`) or 2-byte (`>= 128`)
geometric layouts across all permutations.

The resulting deterministic alignment guarantees that Zlib sliding windows
can deduplicate highly repetitive variables across the
entire application binary block.

4. We use the ShaderStage information to create distinct index ranges, which
further help use 1-byte indices.

Verification Metrics:
 `filament-android.aar`: -7,938 B
 `gltfio-android.aar`: -290,939 B
 `libfilament.a`: -18,464 B

* Optimize shader dictionary by decoding '_' for numeric literals

Most numbers extracted from the shader text are preceded by an 
underscore (e.g., from `_`, `hp_copy_`), which previously caused 
standalone `_` strings to heavily pollute the LineDictionary.

This change removes the standalone `_` from the dictionary index:
- `MaterialChunk` rehydrates the `_` prefix when decoding these numeric
literals.

This frees up dictionary indices, yielding massive byte savings across 
uncompressed binaries (e.g., -28.4 KB for volume_masked.filamat).

* Optimize ShaderMinifier to strip explicit spacing

Spirv-cross outputs GLSL with explicit spacing around generic
operators (e.g., ` = `, `, `, ` ) * `). This padding consumes a 
significant amount of uncompressed bytes across large ubershaders. 

By applying targeted string replacements at the end of the `ShaderMinifier` 
pass, we strip this extraneous padding down to its raw tokens 
(e.g., `a=b`, `a,b`, `a*b`). 

This optimization preserves isolating spaces where valuable, ensuring 
line-dictionary tokens (such as raw `=` or `,`)  remain deduplicated 
instead of fusing into unpredictable variables. 

Impact:
This saves roughly ~9.1 KB in `libfilament.a` and ~3.2 KB in 
`volume_masked.filamat` uncompressed, with proportional gains across 
the downstream LZ4 compressed archives.
2026-03-26 22:41:36 -07:00
Mathias Agopian
4b040fbae6 A new Sky simulation Web demo (#9828)
* sky simulation sample

Also added documentation on how to add another web sample

---------

Co-authored-by: Powei Feng <powei@google.com>
2026-03-26 22:40:34 -07:00
Evan Mezeske
566aeac5ed metal: Clamp minimum stencil texture size to 1x1 to avoid abort due to zero-size texture, e.g. when the attached NSView is being destroyed (#9835) (#9836) 2026-03-26 11:21:07 -07:00
Mathias Agopian
ab2ece54d7 Fix memory safety vulnerabilities in filaflat parsing components (#9832)
* Fix out-of-bounds string read by verifying null-terminator existence
  during extraction.
* Fix heap buffer overflow by validating dictionary string lengths 
  against target shader buffers before copying.
* Fix out-of-bounds array reads by validating chunk-provided lookup 
  indices against parsed dictionary sizes.
* Fix integer wrapping exploits by replacing pointer addition with 
  offset subtraction during chunk size verifications.

Add unit tests for these vulerabilities.
2026-03-26 11:19:08 -07:00