Commit Graph

24 Commits

Author SHA1 Message Date
Mathias Agopian
f4a079f663 backend: Propagate backend thread exceptions to the main thread. (#9903)
* Filament Error Handling Remediation and noexcept Cleanup

- Replaced assert_invariant with FILAMENT_CHECK_PRECONDITION in
  Renderer::beginFrame for caller bugs.
- Removed noexcept from Camera::setCustomProjection to allow precondition
  checks to throw.
- Removed noexcept from Texture and InstanceBuffer methods using precondition
  checks.
- Documented silent clamping in View::setBloomOptions.
- Clarified comment in FrameGraphResources regarding preconditions.
- Refined MaterialInstance::commit to split texture loop into check and update
  passes, preventing partial state changes on precondition failure.

* backend: Propagate backend thread exceptions to the main thread.

Introduce a mechanism to catch exceptions thrown on the backend thread and
rethrow them on the main thread. This prevents deadlocks and allows the
application to handle fatal backend failures gracefully.

- Consolidate synchronization primitives in DriverBase.
- Add mHasUnrecoverableError flag to interrupt blocked fence waits.
- Optimize waitForFence to avoid extra atomic reads in common paths.
- Propagate FenceStatus::ERROR across all backends.
- CommandBufferQueue now stores a std::exception_ptr when the backend fails.
- The backend enters a "zombie" state on failure, skipping further command
  execution but allowing clean shutdown.
- Public APIs in Renderer and Engine now check for stored exceptions and
  rethrow them, documented with @throws.
- Guarded by __EXCEPTIONS to ensure no overhead when exceptions are disabled.
- Add unit test for fence interruption and document new APIs.

BUGS=[407545700]

* feat: harden backend exceptions and add hasUnrecoverableFailure API

- Update Renderer::beginFrame() and Renderer::shouldRenderFrame() to
  return false early if an unrecoverable backend exception has been
  delivered to the main thread.
- Document the new return behavior for beginFrame() and
  shouldRenderFrame() in Renderer.h.
- Add Engine::hasUnrecoverableFailure() to the public API to allow
  apps to check for fatal errors without relying on exceptions.
- Implement hasUnrecoverableFailure() in FEngine by delegating to
  CommandBufferQueue.
- Expose Engine::hasUnrecoverableFailure() to Java bindings
  (Engine.java and JNI).
- Expose Engine::hasUnrecoverableFailure() to JavaScript bindings
  (jsbindings.cpp).

* java: propagate C++ Panics & exceptions to JAVA
2026-04-22 10:56:09 -07:00
Mathias Agopian
ef42c55f56 update java and js bindings (#9676)
* implement some missing javascript bindings

DOCS_FORCE

* use exclusively javadoc comments in Options.h

This is because this file is currently used to generate java and
javascript bindings and doxygen can ingest javadoc.

And regenerate javascript and java bindings

* add missing java bindings
2026-02-03 13:16:01 -08:00
Sungun Park
09545690bf Revert "materials: introduce mutable spec constants (#8795)"
This reverts commit 8a1a0b0fd2.
2025-06-13 15:02:55 -07:00
Eliza
8a1a0b0fd2 materials: introduce mutable spec constants (#8795)
* materials: introduce mutable spec constants

Rationale & design of this feature has been discussed internally.

The current implementation uses a `FixedCapacityVector` to store the new program
handles, but I wouldn't object to replacing it with a hasmap as discussed
offline.

I have compiled but not tested this yet on Android, so I'm not certain that the
API bindings are correctly wired up.

* materials: mutable spec constant feedback

* materials: address mutable spec constant comments
2025-06-06 03:52:20 +00: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
Mathias Agopian
d9ee526a72 fix jni Scene.getEntities
we were using the version of ReleaseIntArrayElements that doesn't
always keep changes to the array.
2023-12-05 09:28:50 -08:00
Powei Feng
d5bab43ceb Revert "engine: move setFrontFaceWindingInverted from View to MaterialInstance (#7331)" (#7360)
This reverts commit 038f07cb34.
2023-11-13 22:26:03 -08:00
Powei Feng
038f07cb34 engine: move setFrontFaceWindingInverted from View to MaterialInstance (#7331)
Moving setFrontFaceWindingInverted to MaterialInstance will enable
finer control over face inversion and aligns better with Vulkan's
pipeline definition (see VkGraphicsPipelineCreateInfo).
2023-11-06 14:06:00 -08:00
Mathias Agopian
97f20afdd7 remove the anonymous union in SamplerParams
- don't rely on it being 32-bits
- update the jni code to store SamplerParams in a long (64 bits)
  instead of a int. This gives us some future-proofing of the java side.
2023-08-24 21:36:42 -07:00
mackong
549c582287 engine: support setDepthFunc for MaterialInstance (#7004)
Co-authored-by: Mathias Agopian <mathias@google.com>
2023-07-31 15:49:48 -07:00
Romain Guy
5a75fb9b53 Add new alphaToCoverage material property (#6606)
* Add new alphaToCoverage material property

The alphaToCoverage property lets you enable or disable alpha to coverage
in a material. More importantly it lets you overrides the behavior of
blending: masked which automatically enables alphaToCoverage.

* Update release notes
2023-03-02 12:40:55 -08:00
Mathias Agopian
41ef71abdf Add MaterialInstance getters for overridable properties (#6243)
In addition to the new getters, this change fixes the duplication of
a MaterialInstance, which didn't carry along the following states:
  - alpha mask threshold
  - specular AA threshold
  - specular AA variance
  - double sidedness

TODO: stencil state, polygon offset and scissor are stil not queryable
2022-11-01 11:22:01 -07:00
Ben Doherty
60294c2514 Add stencil API bindings for Java (#5949) 2022-08-23 11:54:09 -04:00
Mathias Agopian
363edb1427 added MaterialInstance::duplicate(...)
It's now possible to duplicate a MaterialInstance.
2021-05-21 22:57:28 -07:00
Philip Rideout
9a47178b3d gltfio: expose getMaterialInstances to Java.
Tested locally by hacking gltf-viewer on Android, added the following
lines to MainActivity:

```kotlin
for (mat in modelViewer.asset!!.materialInstances) {
    Log.d("gltf-viewer", mat.name)
}
```
2020-05-11 10:39:13 -07:00
Philip Rideout
f53f03b5dd Java MaterialInstance::getName now creates string lazily. 2020-05-08 09:44:49 -07:00
Philip Rideout
4665f6027f Add dynamic raster states to MaterialInstance.
Fulfills a request from tirichards@.

This is similar in some ways to dynamic backface culling but simpler
because there is no interaction with double-sided lighting.

For reference, dynamic backface culling was implemented with #1936, #1877, #1641.
2020-02-10 14:33:14 -08:00
Philip Rideout
8fc94f127b Add language bindings for setCullingMode. 2019-09-18 18:12:02 -07:00
Philip Rideout
a118299cfb Fix JNI for parameter arrays in MaterialInstance.
Previously we used the <T=float> template instantiation of setParameter
when the client specified FLOAT4. This resulted in the lower layer
adding needless padding, thus causing a buffer overflow.

Moreover the JNI code for this was somewhat cryptic because it casted an
enum value to an int, then added 1 to compute the size. We now use
a switch statement to improve readability.

This issue was discovered (and the fix was verified) with the upcoming
Android port of the bloom demo.
2019-06-25 15:32:30 -07:00
Romain Guy
0a5c068cb6 Switch specular AA to Tokuyoshi and Kaplanyan (#1218)
This replaces the previous "curvature to roughness" method. Both are related
and rely on the screen space variance of geometric normals but this new
solution offers more control (the screen space variance and the clamping
threshold can be controlled).
2019-05-23 12:56:26 -07:00
Philip Rideout
dcc17b9b7e Allow dynamic doubleSided and materialThreshold. (#1072)
* MaterialInstance now has setMaskThreshold for convenience.

* Materials now support dynamic doubleSided property.

This does not change the format of material packages because they
already have both getDoubleSided() and getDoubleSidedSet().

The only way in which this change could impact existing applications is
that materials that explicity set doubleSided to "false" will now
respect the material's culling mode, rather than forcing it to NONE.

Fixes gltf_viewer with littlest_tokyo in ubershader mode.

Fixes #963.

* JNI for dynamic material properties.

* Add underscore prefix to internal material params.

* Remove un-needed mat info field.
2019-04-08 11:43:01 -07:00
prideout
5ee359cf40 Move math namespace to fix #746. 2019-02-07 09:23:07 -08:00
Mathias Agopian
870d15b9ab Add MaterialInstance::setPolygonOffset()
The polygon offset can now be set through MaterialInstance. 
USE WITH CAUTION, this impacts performance negatively.
2018-11-13 19:27:52 -08:00
Romain Guy
b3d758f3b3 Initial commit 2018-08-03 10:38:22 -07:00