These changes make it easier to test headless rendering in macOS.
I verified that this works using the frame_generator tool, however
it requires the fixes in PR #2529.
This is done for consistency with the Android samples. Tested with
gltf_viewer against Vulkan, Metal, and OpenGL. Dragged window between
high DPI and low DPI displays.
Since resizing does not trigger the "NSView has changed" handler in
PlatformCocoaGL, it now must to detect a resize in order to make the
required call to NSOpenGLContext::update() as per the following
documentation.
https://developer.apple.com/documentation/appkit/nsopenglcontext/1436135-updateFixes#2528
We were not holding a global ref on more recent version of android,
this made the Stream API inconsistant.
Filament now always keeps a global ref on the surfacetexture while in
use.
this was a misguided optimization, on low-end devices this actually
has a large overhead (presumably because of the smaller cache and
increased branch missprediction as well as extra synchronization).
on some low-end devices we see the gl thread go from ~40ms to ~10ms
with the gltf sample.
- only triangular noise needs to be scaled between +/-1, other noises
have a uniform distribution and need to be scaled between +/-0.5
- all dither routines work in RGBA
- fixed FXAA in opaque mode when dithering modified the alpha channel
(which is used by FXAA). This fixes flickering when FXAA and dithering
was enabled.
- use triangular noise dithering on mobile and desktop. The cost in
not measurable on a pixel 4 / 1080p, and the quality is better.
- refactor dithering code a bit such that:
- noise methods are not temporal
- all dither functions have the same structure
* debug option to track Entities
Set FILAMENT_UTILS_TRACK_ENTITIES to true when building libutils to
activate entity tracking. This adds two public methods:
getActiveEntities() and dumpActiveEntities() the later displays the
stack trace of where the remaining entities were allocated.
This is useful for tracking leaks.
* Update libs/utils/include/utils/EntityManager.h
Co-authored-by: Philip Rideout <philiprideout@gmail.com>
Co-authored-by: Philip Rideout <philiprideout@gmail.com>
* Very basic SwiftShader support
- we only provide SwiftShader's khornos headers in third_party
- swiftshader itself must be available on the host (for instance it
can be compiled from source).
- to enable pass -DFILAMENT_USE_SWIFTSHADER=ON option to cmake
- only GLES 3.0 is supported. Vulkan is not yet supported.
CMake should find the swiftshader libraries automatically, but if
they're installed in a non-standard place, the environment variable
SWIFTSHADER_LD_LIBRARY_PATH can be set to that place.
We also use the GLES 3.0 headers everywhere, since we don't rely on 3.1
at this point.
* add a tnt folder with a README
This removes (rather than deprecates) all public constructors that
take a native pointer without an accompanying Engine.
Most notably, MaterialInstance had a public pointer constructor which
is now package private. This means that FilamentAsset needs an Engine,
so it now takes the one from AssetLoader.
- When creating a Camera component, it is the responsibility of the caller
to destroy the Entity. ShadowMap didn't do that, so it would leak two
entities.
- When destroying a Camera component with the legacy (and deprecated)
API, Engine::destroyCamera() should destroy the associated Entity
(and was documented as doing so). However, it actually didn't.
- don't use the static EntityManager is ShadowMap.
* fix compile error when vulkan
* matc:print shaders support
* fix link error
* ussage for matc print flag
Co-authored-by: brian.wang <brian.wang@noitom.com>
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)
}
```
* Fix filament-utils-android build on Windows
* Update build.gradle
* nit: use char version instead
* Fix No signature of method: java.lang.String.replace() is applicable for argument types: (Character, String) values: [\, /]
deprecated Texture(long nativeTexture) in favor of
Texture(Engine, long nativeTexture), there is no difference
currently, but in the future Texture(Engine, long nativeTexture)
will be able to validate the native pointer.
The JNI layer already does this, but can only track objects it created,
sometimes developers might create filament objects on the native side
and wrap them into java objects and this might cause a failure to
detected when objects are double-destroyed.
However, this can often be caught by the native code -- so, when the
native side is asked to destroy an object that doesn't exist, we now
return an error (exception if enabled) and we throw an exception
on the java side.
Filament typically doesn't do this kind of tests, however these bugs
can be very hard to find, and the cost is small.
- all backend return nullptr when handle_cast<> is called with
an invalid handle. this ensures a prompt crash on all backends rather
than different behaviors, some including potential memory corruptions.
assert() in debug builds. The proper way to check is to cast the
handle to bool.
- be more consistent in the GL backend about where we check for the
validity of handle -- which is basically nowhere, except for destroy
(because we have the same semantic than free(nullptr) -- i.e. no-op.
Other places are treated like bad pointers, and as per above
handle_cast<> will return nullptr.
- make sure we don't call FScene::updateUBOs with an invalid handle
when the scene is empty
To see proof that this works, use gltf_viewer with -u and examine the
node hierarchy. You will now see the correct material names instead of
the ubershader names.
When no name is provided during instance creation, it does NOT inherit
the name of its parent material. This is because instances should be
lightweight and users can already do instance->getMaterial()->getName().
In a subsequent PR, this feature will be exercised and tested via the
gltfio AssetLoader.
Fixes#2485.
- we were allocating objects with a destructor in the command stream
which is always invalid because there is no guarantee that when
the callback is called, the underlaying memory is still valid
(and it wasn't).
- AutoBuffer move-ctor wasn't moving some of its state, which would
lead to destroying the same ref several times.