* Workaround for harmless warning about descriptor sets
The proper fix is difficult and will be handled later. Here we simply
suppress the warning at FL0.
BUGS=[468072646]
* Apply suggestions from code review
The "const char*" used for the string literal parameter of the `feature`
method becomes invalid once it passes outside the Java binding scope,
leading to invalid data access. This fix ensures the string is safely
stored.
Add support for heterogeneous lookup in associative containers that
use CString keys. Add conversion operators for std::string_view and
raw string literals to CString.
When emulating UBOs for feature level 0, we need to use packed
mat33 as source of glUniformMatrix3fv which doesn't expect the std140
alignments of UBOs.
FIXES=[468092808]
For reasons unknown, selenium will freeze when trying to make
request to the local server serving the markdown files. We add
a delay between the server and the selenium driver to hopefully
address this.
DOCS_FORCE
webgpu: refactors WebGPU Platform so each OS environment has its own WebGPU Platform
class derived from the same base, and use virtual functions for their own implementations.
The breakage is due to breaking changes in the latest version.
We use the repo checked-in version instead.
Also make sure postsubmit.sh script exits on any error
* add support for AHardwareBuffer to the java bindings
Texture.setEXternalIamge() now can take a AHArdwreBuffer Java object
as a parameter.
* add an API to set the priority of the Skybox
by default the skybox is always drawn last (priority 7) in order to
reduce overdraw. however, when depth culling is not enabled, it
needs to be drawn first. The new Builder::priority() allows to set
an arbitrary priority for the skybox.
* add rendertarget support for external textures
This was in fact mostly already supported, we just were artificially
preventing that usage. It is supported by the EGL_external_image
extension.
It's the responsibility of the caller/user to not attempt to use an
incompatible format, which has undefined behavior.
FIXES=[466395306]
* add a new android sample to test the AHardwareBuffer as render target
---------
Co-authored-by: Powei Feng <powei@google.com>
This change adds support for the KHR_materials_dispersion glTF extension, which introduces a dispersion property for refractive materials.
The dispersion property controls the angular separation of colors transmitting through a refractive object, allowing for more realistic rendering of materials like glass and diamonds.
Changes include:
- Added a dispersion property to the material definition.
- Updated the shaders to incorporate the dispersion effect in the refraction calculations.
- Added a new test case for dispersion.
- Updated the material documentation to include the new dispersion property.
this is not an error that should warrant an assertion, since it's
possible for fences to not be supported at all.
FIXES=[467782111]
Co-authored-by: Powei Feng <powei@google.com>
Seems to actually be initializing an engine
Failed with
reason: /Users/runner/work/filament/filament/filament/backend/src/opengl/platforms/PlatformCocoaGL.mm:177: failed assertion 'success == kCVReturnSuccess'
A. Move filament_test_material.cpp to be part of test_filament
(This won't be triggered during the windows build)
B. Add chaining dependencies in third_party/draco/tnt so that
there is no race in writing/reading generate.stamp
-------------
Failures
-------------
A.
C:\a\filament\filament\out\cmake-mtd\filament\test\resources\filament_test_resources.c(1,1): error C1083: Cannot open source file: 'C:\a\filament\filament\out\cmake-mtd\filament\test\resources\filament_test_resources.c': Permission denied [C:\a\filament\filament\out\cmake-mtd\filament\test\test_material_parser.vcxproj]
B.
CUSTOMBUILD : CMake error : Cannot restore timestamp "C:/a/filament/filament/out/cmake-mtd/third_party/draco/tnt/CMakeFiles/generate.stamp": Access is denied. [C:\a\filament\filament\out\cmake-mtd\third_party\draco\tnt\draco_compression_bit_coders.vcxproj]
- Fix Android build in build.sh so that the tools dir are
properly set to corresponding folders for debug vs. release.
- Update/consolidate documentation to explain the Android Studio
workflow better.
- Move documentation from outdated apps folder to BUILDING.md
- only MapAsync the staging buffers that are not being used by any command anymore (the commands have finished executing on GPU)
- additionally, in WebGPUQueueManager, create a blank new submission state when a new command encoder is generated instead of in submit()
BUGS=450620535
When the frame history's circular queue is full and the oldest
frame is not yet ready to be processed, we must skip the current
frame.
This change ensures that if `beginFrame` is skipped, the
corresponding `endFrame` is also skipped. This prevents data
corruption in the frame history.
Address potential issues in FrameInfoImpl and FrameInfoManager:
- Modify FrameInfoManager::beginFrame to handle cases where the
circular queue is full and the oldest frame is not yet ready,
logging a warning and skipping the frame.
This prevents potential use-after-free or data corruption by
ensuring only ready frames are removed from the history.
FIXES=[466081317]
PlatformEGLAndroid holds onto the current swapchain in order to use
it when beginFrame is called. Usually the swapchain is set just before
beginFrame is called. However, that's not the case for standalone
views. These are independent of the swapchain and doing "swapchain
stuff" for them is nonsensical.
So make sure that:
1. PlatfromEGLAndroid doesn't hold onto a dangling pointer when the
swapchain is destroyed. And add proper null checks.
2. Don't do the "swapchain stuff" when beginFrame is called in the
context of a standalone view.
We now reserve frameID 0 for that purpose (meaning the frameid is
non sensical for these).
We're currently relying on frameID to not wrap-around. At 120 fps,
that's about 1 year. This will be addressed in a later PR.
FIXES=[462827028, 461399487]
PlatformEGLAndroid holds onto the current swapchain in order to use
it when beginFrame is called. Usually the swapchain is set just before
beginFrame is called. However, that's not the case for standalone
views. These are independent of the swapchain and doing "swapchain
stuff" for them is nonsensical.
So make sure that:
1. PlatfromEGLAndroid doesn't hold onto a dangling pointer when the
swapchain is destroyed. And add proper null checks.
2. Don't do the "swapchain stuff" when beginFrame is called in the
context of a standalone view.
We now reserve frameID 0 for that purpose (meaning the frameid is
non sensical for these).
We're currently relying on frameID to not wrap-around. At 120 fps,
that's about 1 year. This will be addressed in a later PR.
FIXES=[462827028, 461399487]
filament_test_material should not need to depend on a "fixed"
(or checked in) material.
Now the dependent .filamat is generated as needed as is
packaged with the checked-in test_material.filamat as before.
also
- update the android build script to pull the version from
build/common/versions
- remove the ability to specify your own ndk version (this was
undocumented and not fully implemented)
The NDK version now needs to appear in two place (unfortunately):
1. build/common/versions
2. build/android/build.sh
`-mcpu` is intended to target a specific CPU instruction set and
optimization. That's not what we want to do here. What we want is
target an architecture, specifically armv8-a. So we use `-march`
instead. On 64 bits builds, we tune for cortex-a78, which is the
df the Pixel7 era. This doesn't mater much, but might give a little
boost on newer CPU cores. The idea here is that we care "less" about
older CPUs.
- Make sure that renderdiff fails when either building or
rendering fails (the previous problem was in the use of &&
that masked the non-zero exit).
- Make sure that golden branch is properly parsed in
postsubmit.yml
- Disable vk loader debug by default
This change fixes an intermittent crash caused by a thread race
condition.
The crash happened when a CallbackHandler::Callback (triggered by
engine.flush()) attempted to create an instance of a Structure of Arrays
(SoA) like TransformManager, which adds items to SoA) at the same time
that the garbage collection job (FEngine::gc, which removes items from
SoA) was running.
This conflict is resolved by modifying the logic to ensure that the
garbage collection task completes synchronously before the callback
operations begin.
* Adding the begin frame message for later xtrace post processing.
* First commit
* This is not needed
* Bypass the AHB* issue.
* Typo: Forgot to remove the function.
* Typo: No const specifier.
* Removing the const.
* no exception
* Feedback from discussions with Powei.
* Making the changes discussed with the team.
* Removing useless comments.
* Adding the required methods for allocation.
* Forgot one more switch case.
* Moving the resource to fvkmemory::Resource type.
* Adding streamed set.
* Allocating every frame for streamed textures.
* Changing the binding logic.
* Proper checks for the streamed texture.
* Cleanup.
* Chaning the logic of the state tracking for streamed textures.
* Fixed full screen bug.
* Refactoring of the code.
* Typo.
* GitHub feedback.
* Github feedback
* feedback.
* Typo
* Feedback.
* Feedback.
* Feedback
* Feedback
* Feedback
* Fixing the Android path.
* Fixing the Android path.
* Feedback.
* feedback
* Feedback.
* Nit
* Feedback
* Feedback
* Feedback
* vk: fix update after bind (wrt descriptor set) validation error
In filament, once a descriptor set is bound, we no longer make updates
to it. However, this guarrantee was broken in the external sampler/image
because a colorspace change might necessitate a layout change, and
thereby a new descriptor needs to be generated with the appropriate
externally sampled image updated in the new set.
Another use case is the Stream API, where each frame we might be
getting a different AHardwareBuffer, meaning we need to update one
or multiple sampler bindings in a set that might have been bound in
a previous frame.
In this change, we always create a new set when there's a change
in the image currently bound to an existing set (while accounting for
whether we need to use a new externally sampled layout or not).
* Removing the decision on whether to use external format or not out of the streamed texture manager. The issue is that all textures are external, not all are using external format. But it's more robust to let the external format image manager rely on the AHB* to decide if the format is external or not. Regardless (because the memory is external) we need to send this to the external image manager.
* Fixing the validation layer in the Stream CL.
* Typo and comment clarification.
---------
Co-authored-by: Powei Feng <powei@google.com>
- this is not true fro headless swapchains
- and potentially some timings might not be available on a given nativewindow
Previously the code would handle these errors gracefully, but the
errors were still generated. Now, we query the availability and only
make the calls if supported.
Also on EGL, we don't attempt to use private APIs -- this code path
should never be used anyways.
Depth testing come with a cost, so when the depth
test is marked to always pass and writting to depth
buffer is disable, just disable the feature.
This will also match the GL backend behavior.
- this is not true fro headless swapchains
- and potentially some timings might not be available on a given nativewindow
Previously the code would handle these errors gracefully, but the
errors were still generated. Now, we query the availability and only
make the calls if supported.
Also on EGL, we don't attempt to use private APIs -- this code path
should never be used anyways.
The frameId coming from a Renderer must be monotonic when seen from
a SwapChain (Specifically a ANativeWindow on Android), if it's not
the case, we must clear that part of the history.
This can happen if a SwapChain is used with two different Renderer; at
this point that SwapChain's history is no longer connected to that
Renderer.
The frameId coming from a Renderer must be monotonic when seen from
a SwapChain (Specifically a ANativeWindow on Android), if it's not
the case, we must clear that part of the history.
This can happen if a SwapChain is used with two different Renderer; at
this point that SwapChain's history is no longer connected to that
Renderer.
These headers are private but were used by public headers.
Refactor the platform code so that these headers stay private.
AndroidNdk.h is treated differently, it is now made public because
it simplifies a lot of things to be able to have the platform concrete
implementation derive from it.
- Adjust order of destroy call in both headless and platform
swapchains. We need to be careful of the order due to
assumptions made by the base class's destroy().
- remove `=0` since VulkanPlatformSwapChainBase::destroy() has
an implementation.
Fixes#9403
The root of the problem is that in the main rendering loop we need
to set the correct per-view descriptor-set based on the material and
variants.
But we have two cases, either the descriptor set is always constant,
which is the case with ssr, structure, shadows and postfx passes, or
it need to be dynamically changed based on the material & variant.
In the 2nd case, where was a problem where the postfx descriptor set
could be used, which is wrong (e.g. while rendering shadows we need
the shadow UBO, even with a postfx material), and would corrupt the
correct descriptor set, which would never be set back.
Another issue was related to running a custom command, it could
change the state without updating the local copy, causing corruptions
or validation errors.
In this CL we:
- use the same descriptorsetlayout for both postfx and depth
- invalidate the state after a custom command
- only switch to postfx descriptor set in dynamic mode (color pass)
This fixes setChannelDepthClearEnabled() which could cause
validation error, corruption or crashes.
FIXES=[459567258]
* VK: Add support for getting pipeline creation stats
When debugging is pipeline compilation related hitches
is useful to know more information about what happened
when building a new pipeline.
By levering the VK_EXT_pipeline_creation_feedback
extension, we can know if the pipeline creation was
speed up because of a cache hit, how much time it spent
creating it and also the stats related to each
pipeline stage.
This is only available when using the debug flag
FVK_DEBUG_SHADER_MODULE.
* Fix the unused build error
Doing a renderdoc capture when using transient memory
or importing AHardwareBuffers into Vulkan, makes it fail,
crash or not replay properly.
To improve the capture support, added a new constant to let the
backend know when renderdoc is expected to be used and configure
things appropietly.
- In the case of transient attachments that uses lazy allocated
memory, it will be disabled.
- In the case of AHardwareBuffers, a more robust memory heap
selection algorithm will be used.
Also a new VulkanPlatform function will be added, to let other
subclasses know that the transient attachments are enabled or not.
For sample-gltf-viewer, an asset was checked into the source tree.
But other assets are generated or copied from asset directories.
We remove the checked in gltf and copy the asset over during
build (as with other existing files).
* HandleAllocator::deallocate() was unsafe
It needs to know the concrete type to call the proper destructor, so
if it was given a base type handle (e.g. Handle<HwFoo>) it would not
destroy it properly.
* add AsyncJobQueue::cancelAll()
* Fix a race condition when tearing down FrameInfo
It is actually invalid to destroy a Handle<HwFence> while inside
fenceWait().
Updated the HwFence implementations so that they don't pretend they can
handle being destroyed during fenceWait(), they can't.
FrameInfo now cancels all the pending callbacks and waits for the
currently executing one to terminate, *before* destroying the
handles.
Reenable the gpuFrameComplete metric, as it should be working now.
* improve camera precondition checks and default state
- Camera is now initialized with a default projection matrix with
left/right, top/bottom set to (-1,1) and near/far set to (0.1,1).
- setLensProjection() and setProjection(FOV) now check the near/far
precondition (near>0 and far>near).
- sanitize user's light near/far to avoid infs and nans during
froxelization
- finally froxelizer asserts that near>0 and far>near on debug builds.
FIXES=[458030186]
* Move the include resolution functionality to matp
- matp::MaterialParser now has a function resolveIncludes that returns a pair of status and resolve string.
- all the include resolution classes are moved to matp private src.
- matp::resolveIncludes is renamed to matp::resolveIncludesRecursively and only used internally.
- added insertLineDirectives and insertLineDirectiveChecks in Config; add those in the CommandlineConfig.
- moved output format to public use.
Note: MaterialParser::resolveIncludes could take a includer instead of the materialFilePath, but i decided
to go with the materialFilePath because the most common use case is resolving from the file's directory.
This allows the parser to just create the default DirIncluder internally, and we don't need to expose it publicly.
* add const to the buffer param
With minSDK less than 26, it's unsafe to use APIs in nativewindow.h
that appeared at API 26 or more, even when using the weak symbol
technique. This is because pre 26, libnativewindow.h didn't exist and
therefore the build system cannot link against it.
Currently Filament's minSdk is 21, which means we should never use
nativewindow.h API after 26.
In this PR we chose the strategy at compile time; either the more
modern weak symbol or the old way with dlsym based on __ANDROID_API__.
queryFrameTimestamps() and queryCompositorTiming() are both
synchronous APIs, but VuklanSwapchain is not a thread-safe
ref-counted handle (i.e. fvkmemory::ThreadSafeResource). We move
the Platform::SwapChain* pointers to a thread-safe map that is
mapped by the handle id.
queryFrameTimestamps() and queryCompositorTiming() are both
synchronous APIs, but VuklanSwapchain is not a thread-safe
ref-counted handle (i.e. fvkmemory::ThreadSafeResource). We move
the Platform::SwapChain* pointers to a thread-safe map that is
mapped by the handle id.
* HandleAllocator::deallocate() was unsafe
It needs to know the concrete type to call the proper destructor, so
if it was given a base type handle (e.g. Handle<HwFoo>) it would not
destroy it properly.
* add AsyncJobQueue::cancelAll()
* Fix a race condition when tearing down FrameInfo
It is actually invalid to destroy a Handle<HwFence> while inside
fenceWait().
Updated the HwFence implementations so that they don't pretend they can
handle being destroyed during fenceWait(), they can't.
FrameInfo now cancels all the pending callbacks and waits for the
currently executing one to terminate, *before* destroying the
handles.
Reenable the gpuFrameComplete metric, as it should be working now.
With minSDK less than 26, it's unsafe to use APIs in nativewindow.h
that appeared at API 26 or more, even when using the weak symbol
technique. This is because pre 26, libnativewindow.h didn't exist and
therefore the build system cannot link against it.
Currently Filament's minSdk is 21, which means we should never use
nativewindow.h API after 26.
In this PR we chose the strategy at compile time; either the more
modern weak symbol or the old way with dlsym based on __ANDROID_API__.
- Adjust order of destroy call in both headless and platform
swapchains. We need to be careful of the order due to
assumptions made by the base class's destroy().
- remove `=0` since VulkanPlatformSwapChainBase::destroy() has
an implementation.
Fixes#9403
We refactor VulkanPlatform so that getSwapchainInstanceExtensions()
and createVkSurfaceKHR() are virtual functions that are implemented
by each platform. This will enable the use of polymorphism for
platform-dependent bits.
* use choreographer to access the system's expected present time
* more Android specific code into VulkanPlatformAndroid
* Fix race-condition between init() and terminate()
it was possible for the thread to not have been ready by the time
we call terminate.
* fix build and minor fixes
* Move resolving #includes from MaterialBuilder to MaterialCompiler, before parsing the material.
- resolving #includes was happening after parsing, now moving before parsing.
this is because we could offload this resolution at build time for RuntimeMaterialCompiler
- filamat::resolveIncludes used to have an assumption where the given text was already
a shader block. this assumption is now broken so it finds the line offset internally.
thus the line offset field is removed from IncludeResult.
* Move include related classes to matc
* adds third_party/libwebp and cmake option to enable building it.
* disable simd and default disable pthreads for webgl builds.
* ensure non-empty config var value
* Added notes on libwebp change to NEW_RELEASE_NOTES.md
* Update NEW_RELEASE_NOTES.md
Before the transformName field was expected to be
used together with the stream API, that is not the
case anymore.
In the scenario that isn't using the stream API,
filament will try to associate the transformName
field to a stream that doesn't exist, causing a
crash.
* Check for null fences to avoid segfault in tests
In some test environments, creating a sync or fence backed by an Android
fence returns null. In order to avoid NPEs, cover this scenario with a
null check.
* Address PR - add log statement
Log that native fences are not supported when unable to create a native
sync fence.
* Check for null fences to avoid segfault in tests
In some test environments, creating a sync or fence backed by an Android
fence returns null. In order to avoid NPEs, cover this scenario with a
null check.
* Address PR - add log statement
Log that native fences are not supported when unable to create a native
sync fence.
The deadlock happened because FrameInfoManager needs to wait that all
fences have signaled before it can be destroyed.
The fix here is simply to destroy the fence without waiting (for safety
we do wait after we destroy them).
This uncovered another problem where all backends didn't handle this
correctly.
We now explicitly handle this when destroying a fence: we make sure it
unblocks all the waiters and returns an error.
FIXES=[457243841]
Building tools separately is necessary for the existing
cross-complation usecase. We generalize this by introducing
two cmake vars that enable exporting and importing
prebuilt tools.
The intended usecase is to enable ASAN-built filament without
having to run ASAN-built matc (which is prohibitively slow).
build.sh has been modified to add a `-y` flag forprebuilding
tools.
WebGPU's rendering of bloom sems to be non-deterministic. This
is not expected. For now, we disable bloom+webgpu to avoid
hitting flakes in our CI.
This required a slight refactoring of the test configuration
parsing and execution scripts.
RDIFF_BRANCH=pf/renderdiff-disable-bloom-webgpu
* Use a custom, non-allocating map for frame ids
* use memory_order_relaxed for the id of heap allocated handles
* Added displayPresent time to FrameInfo
To do this, we added support for queryFrameTiming() to the backend,
as a synchronous API. Then FrameInfo uses it to update the
corresponding history entry.
displayPresent time can be used to detect "buffer stuffing", i.e.
when the GPU gets too much ahead of the display. Currently
the information is returned to the user only. Eventually filament will
make use of it to determine if a frame skip is mandated.
* API BREAK: rename frameTime to gpuFrameDuration
* FrameInfo now contains compositor timings
- the presentation deadline
- the refresh rate from the display
- the composition-display latency
* set FrameInfo data to INVALID if feature is not supported
report presentDeadline properly.
The deadlock happened because FrameInfoManager needs to wait that all
fences have signaled before it can be destroyed.
The fix here is simply to destroy the fence without waiting (for safety
we do wait after we destroy them).
This uncovered another problem where all backends didn't handle this
correctly.
We now explicitly handle this when destroying a fence: we make sure it
unblocks all the waiters and returns an error.
on mobile h/w, strong highlights generated by the lighting stages can
turn into +inf and eventually to NaN if more math is performed on them.
Some h/w will kill a while tile or even primitive when that happens,
resulting in strong visual artifacts.
We fix this by clamping to MEDIUMP_FLT_MAX.
* GL: Fix importing non srgb using the external image API
When importing a non srgb AHB but setting the srgb as true,
makes the eglCreateImageKHR function to fail because it tries
to set the colorspace as srgb for non srgb formats.
Example:
createExternalImage(yuv_ahardwaredbuffer, /*sRGB=*/true);
The fix is to only make sure that flag is set to true
if the corresponding filament format requires sRGB and
false otherwise.
* Fix mapToFilamentFormat to return the correct srgb formats
* fix build error on android
---------
Co-authored-by: Serge Metral <sergemetral@google.com>
Fix the callback by using a shared_ptr to store the callback.
The same logic exists in all other backends.
Re-enable corresponding backend test for webgpu.
Remove viewport size check in beingRenderPass. There is no similar
check in other backends.
Fix the callback by using a shared_ptr to store the callback.
The same logic exists in all other backends.
Re-enable corresponding backend test for webgpu.
Remove viewport size check in beingRenderPass. There is no similar
check in other backends.
Previously, Cleanup is scoped to the testing function, which will
go out of scope before BackendTest's destructor is called. We
need to order the cleanup (destruction of resources) to after
the readPixels and previous commands are complete - which is
in the destructor of BackendTest.
Additionally, we need to cleanup before the destruction of the
driver. This means we need to be able to order the destruction
of Cleanup (and not rely on RAII). This is done by having a
unique_ptr holding a Cleanup instance.
* Add Compositor Timing APIs to Platform
These APIs are currently modeled after Android capabilities, but a lot of
the concepts are generic enough to map to other system with a compositor.
This adds Platfrom::queryCompositorTiming() which is currently only
implementd by PlaftormEGLAndroid. Vulkan and WebGPU will come later.
The functionality is implement via EGL, but a new NativeWindow
helper is provided to access the same data from non-EGL backends.
Also to be on the safe side, PlatformEGLAndroid reverts to using
the ANativeWindow if EGL fails.
This CL also cleans-up PlatformEGLAndroid to accomodate those changes.
* Add queryFrameTimestamps() API to Platform.
This API allows to query very precise timing information of
past frames on a given swapchain. This information is provided
by the Android framework via EGL or ANativeWindow (albeit
through private APIs).
Currently only implemented by PlatformEGLAndroid.
SwapChainEGL is now implemented more idiomatically. It has a
constructor that does the initialization. This allows subclasses
to be implemented properly and safely.
PlatformEGL::createSwapChain() now just constructs SwapChainEGL and
does nothing else, which allows a subclass of PlatformEGL to "add" to
the PlatformEGL swapchain, buy simply subclassing from it and
constructing it normally.
The SwapChain doesn't need to have a vtable because polymorphism
is handled by the concrete Platform implementation.
Here we also implement a no-op SwapChainEGLAndroid to show how easy
it is to extend the swapchain. This functionality will be used soon.
- Also modify update script
- Renamed to update_remote_ui
- Repair path inside sciprt
- Ensure update script is not copied over to /docs
- Add requirements.txt (for python/pip dependencies)
- On webgpu, do not error on linux when we're building headless
only (without platform support for surface).
- For test/backend/test.sh, enable path for building on
Linux + 64-bit x86
If createSwapChain() fails, a SwapChain object is always returned
(this might itself be a problem, but we can address that later),
however in that case, destroySwapChain() would leak the EGLSwapChain
structure.
This commit enables running the backend tests for opengl and
vulkan on github CI. The script is located in test/backend.
We also add exceptions (SKIP_TEST) for the currently failing
tests. Issues have been filed to track addressing these failed
tests.
We also disable a series of broken webgpu tests.
* Add new public API to query a sampler transform name field.
This new API will let filament users query a Material object
the value of the `transformName` field of a specified sampler
parameter.
The transformName is an optional field, so if its not defined
by the user, it will return a nullptr value.
- A new test was added to test_filamat to validate the serialization.
- A new parameter was added to the test sandboxLit material to
validate the parsing a material with the new field.
* Addressing review comments
- Add java and js bindings for the new API
- Tests for querying the getParameterTransformName
* Use utils::ImmutableCString for transformName
* Updating release notes
* Review comments
* Addressing more review comments
- Fix comments
- For the java binding return an empty string when the
transform is not present.
Adds support for compiling filament libraries with GCC. Since GCC is not
officially supported, we prefer to disable warnings (incl. not treating
warnings as errors) rather than updating the code in order to compile
cleanly.
This flag is disabled by default.
nanosecond is long long and `timeout` is uint64_t. This creates
an overflow when timeout is too large (for example
timeout = std::numeric_limits<uint64_t>::max() when waiting
forver).
* Add missing includes.
* Add parenthesis around operators to suppress compiler warning.
* Remove duplicate definition of is_supported_aux_t.
* Explicitly create descriptions.
* Remove usage of anonymous struct with non-trivially constructible members.
This is an error on some compilers (e.g. gcc).
* Remove unnecessary rvalue-reference on pointer type.
* Explicitly construct SamplerParams to suppress compiler warnings.
* Place attribute specifier before declaration.
* Remove usage of anonymous struct with a non-trivially constructible member.
Replace the `array` union member with an `operator[]` to provide similar
functionality.
Some compilers (e.g. gcc) do not support this non-standard use-case.
* Use same warning settings as main filament project.
- Add transmission and ssao tests
- Small mods to README.md
- Add transmission models to gltf list
- Change focal length to zoom in for more details
RDIFF_BRANCH=pf/renderdiff-add-transmission
Context:
- Picking has switched to use integer textures and this texture
is meant to have only RG components (#8917).
- WebGPU only supports 4 component textures, and so we need to
to a blit-based transform to turn 2 components into 4.
- WebGPUBlitter supports only float textures
In this commit, we add support for integer textures to
WebGPUBlitter. In doing so, we refactor parts of the shader
construction code in the blitter class and introduce a couple
helper functions for texture formats.
This fixes picking (verifiable with gltf_viewer)
Co-authored-by: Ben Doherty <bendoherty@google.com>
`--headless_only`
Headless-only mode indicates that we will only use headless
swapchains. This is particularly useful if we want to test in
a CI (continuous integration) environment.
`--ci`
Having CONTINUOUS_INTEGRATION as an OS will allow us to have
CI-only temporary exceptions. Though it's expected that some
exceptions will be unfixable and will remain as workarounds.
If we assign the message (which might contain quotes) to an
environment variable and then echo it, this should prevent the
problem of having a double quote (").
Also fix a problem in docs script for checking TAGs in commits.
To enable the readPixels callback to be called, we need to make
move to 'AllowSpontaneous' mode in order to not have to call
Instance::ProcessEvents() to force process the callback.
* Introduce AllocationStrategy and its tests
* feedback
* feedback
* Add stress test
* Fix the build
* Minor fix
* Rename the class
* Rename
* Make const
In GLES the anisotropic filtering featuring is always
disabled even in the cases where is supported by the hardware
because the check for the extension is missing.
* Add a Renderer API to force skipping frames
Renderer::skipNextFrames(size_t) can be used to force filament to
pretend the next N frames must be skipped. This is mostly useful for
debugging.
* Add DebugOptions to Settings
We still need to move the "Debug" features of gltf_viewer to this,
but this give us a framework to do it.
Currently there is one debug option that allows to set a number of
frames to skip.
ViewerGui propose a button to skip 10 frames using this framework
* Update libs/viewer/src/Settings.cpp
Co-authored-by: Powei Feng <powei@google.com>
* Update libs/viewer/src/Settings.cpp
Co-authored-by: Powei Feng <powei@google.com>
---------
Co-authored-by: Powei Feng <powei@google.com>
The Glslang SPIR-V remapper was removed, and replaced by the CanonicalizeIds
pass in spirv-opt. See https://github.com/KhronosGroup/SPIRV-Tools/pull/6174
Filament's GLSL post-optimization algorithm already runs CanonicalizeIds.
Bug: b:450891564
* fix a possible deadlock in AsyncJobQueue
drainAndExit() could get stuck because it waited for the job
queue to be empty, but that was not signaled.
in fact, drainAndExit() didn't need to do that.
* Improvements to FrameInfo
- return the GPU Complete timestamp
- return the app VSYNC timestamp
- works TimerQueries are not supported
The VSYNC time is just a convenience as it is the same value
provided by the application during Renderer::beginFrame() or via
Renderer::setVsyncTime().
it used to return false when setting the same value for the constant,
which other code used to invalidate the material or not. but it
was recently changed to always return true on success.
this reestablish the previous behavior.
Using struct as keys simplifies the parameter definitions of the
relevant pipeline, pipelinelayout, shader module methods. This
enables adding or removing fields without adding major changes
to method definitions.
Using utils::hash::MurmurHashFn also aligns with the style of
the rest of filament.
* Add a workaround for Filament's breaking change to add_subdirectory for Abseil, see: https://github.com/google/filament/issues/8611
* Fix #pragma warning syntax for MSVC
* Only search for an external Abseil dependency if a new option FILAMENT_USE_EXTERNAL_ABSL is set
* Make JsonishParser use utils::Status
- add unsupported error in utils::Status
- add invalid case in the test
* return a pair of Status and string in resolveEscapes;
use initializer list for JsonishString and move that to the header.
This is needed to instantiate `std::streampos`. It currently relies on transitive header inclusion to get that, which is going away for libc++ in ebcf1bf2ec.
This is needed to instantiate `std::streampos`. It currently relies on transitive header inclusion to get that, which is going away for libc++ in ebcf1bf2ec.
- --no_rebuild will skip building the gltf_viewer again
- --num_threads will limit the number of threads used in running
the rendering test.
Both of these options are meant for debugging locally.
- Add WebGPUQeuueManager to manage queue submissions
- The manager will keep a "last status" field that will track
the status of the last submission.
- Any created HwFence will be associated with a status object.
- The object updates in a callback that indicates that the
submitted workfload has been completed.
This change addresses a platform-specific issue on Windows where shared
OpenGL contexts must be created on the same thread as the primary
context.
To resolve this, we now pre-create a pool of shared contexts when the
driver is initialized. These contexts are then distributed to other
threads as needed, ensuring shared context creation requirement on
Windows. This allows us to be able to use THREAD_POOL mode for shader
compiler service on Windows. So Windows build uses THREAD_POOL mode
instead of ASYNCHRONOUS mode as of this change.
This change also refactors the shader compiler service to catch and
report errors in the same thread where the program compilation and
linking actually performed as it's the correct way to use shared
contexts. Otherwise it may crashes.
* Use utils::Status in MaterialParser
* Use utils::sstream instead of std::stringstream
* Remove remaining std::cerr and dep; update MaterialParser::reflectParameters
* make error message in utils::Status more generic
---------
Co-authored-by: Powei Feng <powei@google.com>
- Fix the magnifier positioning for both compare and standalone
mode. Simplified a lot of the logic and streamlined passing
of states between components.
- Slight css adjustments
ImmutableCString is a string class similar to CString except it's
immutable. ImmutableCString occupies 16 bytes instead of 8 for CString.
However, ImmutableCString is able to avoid memory allocation when
constructed from a string literal, and in that way it us similar
to StaticString.
ImmutableCString can be auto converted from StaticString.
The backend tag tracking is updated to use ImmutableCString and
the FrameGraph resource manager us updated to use StaticString.
Together these changes significantly cut down heap allocations due to
internal tagging.
We also add optional tracking to {Immutable}CString.
* Minor changes in utils::Status
- << operator doesn't have to be friend
- simplify getErrorMessage to not use strlen internally
* Replace std::ostream to utils::io::ostream
* utils: RefCountedInternPool/RefCountedMap
First, introduce RefCountedInternPool, a reference counted intern pool of
Slice<const T>. Just acquire() a slice that you want and you're guaranteed to
get exactly one canonical value-equal Slice<const T> back.
Additionally, introduce the concept of NullValue to RefCountedMap. A NullValue
defines what should be considered an uninitialized value; by default, it's the
default value of that type (0 for ints, nullptr for pointers, etc). This allows
us to lazily-initialize values in the map. A client can acquire() a bunch of
different resources which will be initialized only when get(factory) is called.
If a client attempts to get() a value without specifying a factory, and the
value is not initialized (i.e. equal to NullValue{}()), RefCountedMap will
panic.
* utils: add unit tests for ref-counted collections
* utils: remove C++20 features, fix memory issue
* utils: remove RefCounted from InternPool
* engine: change spec constants to simple list
For a shader program cache to be keyed on the set of spec constants that a
program has set, we need to know full exact list of constants, including their
default values. If we're going to always hold a list of all constants all the
time, then we may as well store them as a simple list where each index is the ID
number of the spec constant.
As part of this change, we now write the default values of spec constants into
the material file metadata.
* fix indent
* engine: fix sRGB swapchain emulation
* slice: fix memory semantics
* slice: prefer passing slice by value
This lets us do nice things like coercing Slice<T> to Slice<const T>, etc.
* slice: fix unit tests
* slice: fix copy/assignment, hash function
Don't attempt to define a copy constructor/assignment operator which would
convert a constant type to a mutable type.
Additionally, fix the hash function such that we're hashing U instead of const
U.
* new utility AsyncJobQueue
this is a very simple job queue, it spawns a thread and runs the jobs
pushed to the queue in sequence.
* use AsyncJobQueue in OpenGLTimerQuery
The viewer supports pulling artifacts based on PR number, and now
we support providing Run ID as an alternative to identify the
renderdiff run on Github CI.
In the current implementation, the function std::cout is used inside a signal handler. This is problematic because std::cout is not
async-signal-safe. According to POSIX standards, only a small set of
functions are guaranteed to be safe when called from signal handlers,
and std::cout is not one of them. Using non-async-signal-safe functions
inside signal handlers leads to undefined behavior and can cause
crashes, deadlocks, or other unpredictable issues.
By making these changes, we avoid undefined behavior and ensure the
program can handle signals safely.
* new fenceWait() API in the backend
* correct implementation of fenceWait() for GL and WebGPU
- fenceWait() now works correctly if called before the fence is
created on the backend side
- the STL's condition wait_for() is actually a wait_until, which
means we have to make sure now() + timeout doesn't overflow.
- also we make sure to keep a reference to the fence internal state
while we wait so that we're safe if it's destroyed during that time.
* Implement fenceWait() properly on vulkan
On Vulkan, unfortunately, the implementation is complicated, as we
need three levels of "wait".
First we need to wait using a mutex/condition that the shared fence
is created (this is because on vulkan, all HwFence share the same
"state" associated to the same command buffer).
Once we have that, we need to wait for the VkFence to be submitted,
this is done using a read/write lock and condition variable. The
read/write lock is not needed at this stage, but in the next.
Once the fence is submitted, we can now wait using vkWaitForFences,
however, external host synchronization is needed. Multiple
vkWaitForFences can be issued together (and use the read lock), but
must be mutually exclusive with vkResetFences and vkQueueSubmit.
By construction, we know that this can't happen during vkQueueSubmit
due to the "2nd level" of wait, however we need to prevent
simultaneous calls to vkResetFences, this is done using a write lock.
By construction, we're guaranteed that when vkResetFences is called,
the fence has signaled, we just need to wait for all vkWaitForFences to
return.
A side effect of this change is that fenceGetStatus() has a better
implementation, since it's just a wait with timeout of 0.
* Update filament/backend/src/vulkan/VulkanDriver.cpp
Co-authored-by: Powei Feng <powei@google.com>
---------
Co-authored-by: Powei Feng <powei@google.com>
The parser object was accessed to generate a key after being passed to
the lambda using std::move(). This led to a crash on certain platforms
(at least on Windows).
This change fixes it by creating key first before moving the parser
object into the lambda.
The parser object was accessed to generate a key after being passed to
the lambda using std::move(). This led to a crash on certain platforms
(at least on Windows).
This change fixes it by creating key first before moving the parser
object into the lambda.
Since #9259, CString in VulkanPlatform fall into the literal
constructor path. But we really want the null-terminated
(char const*) path. So we cast the strings to (char const*)
to enforce null-teriminated behavior.
RDIFF_BRANCH=pf/renderdiff-add-tolerance
Since #9259, CString in VulkanPlatform fall into the literal
constructor path. But we really want the null-terminated
(char const*) path. So we cast the strings to (char const*)
to enforce null-teriminated behavior.
* VK: Allow memcpy of vertex/index buffers in UMA
- Renamed VulkanBufferUsage to VulkanBufferBinding
to avoid confusion with the BufferUsage enum.
- In UMA all buffers are persistently memory mapped.
- In the case of static buffers that are memory mapped
use memcpy directly to update their contents.
* PR Comments
The corruption seems to be triggered with a combination of using:
- spirv-opt
- RGBA16F (as opposed to e.g. RGBA8)
- framebuffer_fetch
In this CL we disable framebuffer_fetch for drivers we know have the
issue.
FIXES=[445721121]
Fix#7794
- Add a VulkanSemaphore ref-counted class to track the references
of a semamphore - i.e. in a command buffer or in a present.
- Add a VulkanSemaphoreManager class to keep a pool of
VkSempahores for better re-use.
This fixes a validation error where we were re-using a semaphore
that is associated with a command buffer while its being used
in a present (as a wait signal).
Error ris VUID-vkQueueSubmit-pSignalSemaphores-00067
* material cache: address comments
* material cache: simplify CRC32 comparison
* material cache: == if same address
* material cache: use plain type for cached crc32
Allow returning a list of supported shader languages
instead of only one.
Notify the backend which is the preferred language.
In the case of metal, the preferred language will be
the first element in the list.
This change will allow a backend to support multiple
languages as needed, in the case of the noop driver,
it will support a material with any shader languages.
* materials: introduce MaterialCache
Presently, Filament Materials are instantiated by first parsing a bunch of
read-only data from a material file, then applying a bunch of options from its
Builder before settling on a final, immutable Material object. If two different
Material instances need to be parameterized differently, e.g. setting their spec
constants independently, each has to do all of these steps independently for
each variation.
This change introduces two new concepts: MaterialDefinition, representing the
deserialized, read-only state of a material file, and MaterialCache, a
reference-counted system responsible for managing the lifetimes of
MaterialDefinitions. Now, each Material asks the cache if a MaterialDefinition
exists for the particular UUID of the data it's trying to read; if not,
MaterialCache creates a new entry transparently. If a hundred different
Materials all try to load the same material data, only one
MaterialDefinition (and its associated GPU resources) will be created.
This first PR is the least possible invasive implementation of this feature.
There are a lot of room for improvements (and more planned). For example, each
Material still manages its own compiled shader program cache, but we can easily
move this to the MaterialCache in future PRs, further enabling the planned
mutable spec constants feature.
Additionally, there's room here to add a Material::toBuilder() method, which
could take an extant material and create a Builder object from it already
parameterized with all of the same options, a la the prototype design pattern.
* material cache: key on crc32
* material cache: make materialParser private
* move RefCountedMap to utils and add unit tests
* material cache: make create functions private
* material cache: fix broken tests on iOS/web
* material cache: address more comments
The reason for this is that according to the GLES 3.0 spec, RG32UI is
guaranteed to be supported for writing, unlike RG32F.
We also use RGBA_INTEGER / UINT for readPixels() which is also a
guaranteed format.
Attempt to Fix#8762
* reorder backend methods
* add new "shared" buffer APIs to backends
We add the equivalent of GL's glMapBufferRange. The new APIs are:
- new "SHARED" flags when creating a BufferObject
- a new HwMemoryMappedBuffer handle
- mapBuffer() maps a range of the buffer to memory
- unmapBuffer() unmaps the range
- copyToMemoryMappedBuffer() is basically a deferred memcpy, where the
destination is a HwMemoryMappedBuffer and the source is a
BufferDecriptor
The actual implementation doesn't have to actually map/unmap the range
on mapBuffer/unmapBuffer. e.g. on Vulkan these method are used mostly
to set offsets (for copyToMemoryMappedBuffer) and trigger the necessary
synchronizations.
Added some basic unit tests.
* add basic support for MemoryMappedBuffer in vk and metal
we implement copyToMemoryMappedBuffer() by calling updateBufferObject(),
which is enough to satisfy the API (And pass the tests).
This saves a CString copy on the backend side and this forces the
frontend to make a copy explicitly.
In theory the CString should now ever be copied just once.
- Allow for presets to override selected models when presented
in order.
- Add 'gltf' for model search path
- Add a few simple gltf models to the 'base' preset
- Improve UI so that missing tests do not generate any html
bits.
- Add documentation on using the viewer
- Add renderdiff documentation to the project webpage.
RDIFF_BRANCH=pf/renderdiff-enable-webgpu
- The vk readPixels relies heavily on DataReshaper to transform
the output into the client's requested format. We make
additions to the DataReshaper to address previously unavailable
features:
- A copy for half floats - Assuming input and output are
both half floats. We just do memcpy.
- Reshaping with respect to PixelBufferDescriptor's top and
left parameters.
- On the test side, we do a bit of clean-up and add the ability
to export image correctly when the PBD has dimensions different
from the readRect and/or non-zero offsets.
- Also re-enable two LoadImage tests.
Make sure that the rendertarget dimensions matches the texture
dimensions. Update the expected image for the test.
Also fixed usage, rendertarget parameters to make sure vk does
not have any validation errors.
Add a way to show the difference between two rendererd image.
This is a convenience feature to see the differences between
backends.
Refactor the ExpandedFailedResult to use this new view.
We need to have an reference to the default render target for
the duration of the backend lifetime. So even if the client
tries to destroy the default render target, we don't actually
destroy it.
Note that it will be destroyed on driver shutdown.
filament/backend/test/Workarounds.h has a specific workaround
with regards to readPixels and texture usage. Originally this
was introduced for the WebGPU backend. This is needed
for the vulkan backend as well.
Also simplify BufferUpdatesTest.BufferObjectUpdateWithOffset
- no need to call flush() or executeCommands(), these are
called when the test terminates.
- layerCount for a rendertarget should be at least 1.
Users can now create a swapchain with MSAA support, which enables direct
rendering to a multi-sampled swapchain image and automatic resolution.
This is only supported by EGL(Android). Other GL platforms (GLX, WGL,
etc) don't support it because the swapchain MSAA settings must be
configured before window creation.
Support for other backends will follow.
BUGS=[433327615]
Hybrid (InstanceBuffer based) instancing no longer needs a
descriptor-set per object because we now use the same UBO for all
objects, so the "shared" per-object descriptor-set can be used.
This also implies that InstanceBuffer doesn't need to track the UBO
handle anymore, only its offset in the buffer.
VulkanDriver::finish() seems like it is waiting for all the
commands to be processed, but in reality, the present calls
are not waited on (because commands->wait() only waited on
the command buffers).
Here we just call vkQueueWaitIdle to address that case.
This fixes a validation error that occurs when running the
backend test BackendTest.MissingRequiredAttributes.
FSwapChain initialization logic would filter out unsupported flags but
would incorrectly use the original, unfiltered flags when creating the
swap chain.
This commit ensures the filtered flags are passed to the driver. It also
adds the warning to log which ones are removed.
BUGS=[433327615]
blitDEPRECATED can also be used in the context of a multisampled
texture resolve. Fix that case to use the resolve() path in the
VulkanBlitter.
Also fixed backend test BlitTest.ColorResolve to add the correct
usage bit (otherwise it'd have validation error).
FIXES=417229577
* Create exportable fences on Android
Also - create a conversion method for the driver api so that a fence can
be converted to an external handle, where available.
* Create a frontend API for external fences
Fences will be called 'Sync' on the frontend, and come with a method for
conversion to an external sync. This will typically be a file
descriptor, for use in posix systems.
* Refactor Sync to rely on opaque handles
Also - push the callback invocations into the backend, such that they
are scheduled on a worker thread, and not run on the Filament backend
thread.
* Address PR comment - minor refactor
Clear vectors after they've been consumed, and update null checks by
removing explicit reference to nullptr.
* Remove convertSyncToFd from non-android
Other platforms might have other handle types.
Also - remove unused header include
* Add logging for convert to fd
Also, remove duplicate includes
* Address PR - change fd type
As per request by rafadavi@, changed to match the Android spec for file
descriptor type, which is `int`.
* Address PR - remove vtable from sync
Also - rename derived sync classes
* Address comment - make SyncCallbackData private
It's technically implementation-specific, even though it currently
happens to be the same. Separate this into the different backends.
* Add stub for metal backend for sync
* Add stub impl for Sync in WebGPU
We need to modify spirv-tools existing CMakeLists.txt to make
sure that its binaries and libs are not included in the filament
installed output.
This change was present before, but overwritten when spirv-tools
updated (wrt the WebGPU project).
In addition to modifying the CMakeLists.txt, we add a script to
carry out the changes automatically when running the update script
in the future.
Fixes#9168
In the cases of a descriptor set being updated
with a external sampled texture but that descriptor
set doesn't get used later on for rendering.
Their corresponding entry in VulkanExternalImageManager::mSetBindings
will never get removed until the application is terminated, causing
performance issues or a fatal crash if run long enough.
The expectation is that the amount of bindings with
external samplers is low or none, so this won't cause
any regression when not using external samplers.
The backend call `isTextureFormatMipmappable` indicates whether
a format can be used to generate bitmap through graphics API.
(The issue is that previously there was a check to validate
whether a format is mipmappable and levels > 1. These two
conditions do not need to imply one another.)
The workaround option is now set to none by default. Use
```
matc -Wall
```
if you want to restore the previous behavior.
Current material workarounds:
- remove MergeReturnPass (except on Metal)
- remove SimplificationPass (except on Metal)
There are reason to believe these workarounds are no longer needed,
due to changes in spirv-opt.
It's possible that older devices might still need them.
These workaround affect *all* devices, this is why it is important
to disable them if not needed.
The script uses os.system to execute external commands like nm and
objdump. Instead we use the subprocess module, which is the recommended
approach in modern Python.
Properly handle potential errors if nm or objdump fail.
This new method, intended for the vertex shader, returns a matrix that
transforms vertices from view space (also known as head space) to the
current eye space.
BUGS=[441127971]
The new cmake FILAMENT_ENABLE_PERFETTO must be set to enable
perfetto traces on Android. It is disabled by default on release
builds, enabled otherwise.
The reason for this is that the perfetto SDK adds about 800K of code
to the library. The text section goes from 2.2 to 1.4 MB
This new method, intended for the vertex shader, returns a matrix that
transforms vertices from view space (also known as head space) to the
current eye space.
BUGS=[441127971]
- libbackend (except webgpu)
- libfilament
- libutils
std::string generates a lot of code bloat, we use CString instead.
We also update CString to be more compatible with std::string's api.
The semaphore stages between command buffer didn't consider the
data buffers (UBOS, vertices, indices) being shared across command
buffers
BUG=436853814
In ZstdHelper::isCompressed call, `src` may not be aligned to 4 bytes,
which is violating the alignment requirement of
`UndefinedBehaviorSanitizer: misaligned-pointer-use`, thereby resuling
in a runtime failure with UBSan enabled. So reconstruct the 32-bit
integer as a workaround.
In EGLAndroid, external textures imported from an AHB
that dont use a SAMPLER_EXTERNAL are not properly destroyed,
causing a memory leak that eventually leads to an OOM.
- by limiting the maximum number of point light to 255 instead of 256,
we can simplify some loops.
- hint the compiler that certain loop counters are multiple of 16 and
non 0, which helps vectorizing.
The record buffer is were we store the light indices, its maximum
size is 65536 entries, but is often limited to 16384 on about 30%
of Android devices because of the 16KB UBO limit.
This PR makes the record buffer use up to 64K entries when allowed
but the h/w.
The record buffer can be a limiting factor when many lights are used
with many froxels. With the minimum of 4096 froxels and a 16KB record
buffer we get an average of 4 lights per froxel. With our maximum of
8192 froxels and a 64KB record buffer we get 8 lights in average per
froxel.
In EGLAndroid, external textures imported from an AHB
that dont use a SAMPLER_EXTERNAL are not properly destroyed,
causing a memory leak that eventually leads to an OOM.
In some places, this sampler was incorrectly assumed to be
sampler2darray, but it should be just a sampler2d. Additionally,
sampling from it should produce unfiltered values - this has been
changed accordingly.
gltf_viewer on android calls finish before creating any resources.
This causes a hang on OnSubmittedWorkDone for the work that was never
there. Put a check in Driver::finish call to avoid the deadlock.
In ZstdHelper::isCompressed call, `src` may not be aligned to 4 bytes,
which is violating the alignment requirement of
`UndefinedBehaviorSanitizer: misaligned-pointer-use`, thereby resuling
in a runtime failure with UBSan enabled. So reconstruct the 32-bit
integer as a workaround.
Window size should be calculated from windows not screen on XLIB.
XCB window is not implemented in Dawn. Remove the stale/wrong implementation in filament
In the case with external samplers, if another descriptor set gets
bound between draw2(), then we need to check to see if a rebinding
of the pipeline is necessary.
Co-authored-by: Serge Metral <sergemetral@google.com>
FilamentApp now has debugging options to enable or disable the
camera and directional shadow frustums, as well as the new
"froxel grid" visualization.
"froxel grid" is automatically enabled when "froxel debugging" is
enabled in the debug gui in gltf_viewer.
New corresponding debugging APIs were added to View.
Before this change once the froxel vizualizaition was enabled via
the Engine debug framework, it applied to all views. This adds a
debug API on View to control whether the view will display this
vizualization.
If screen-space refraction was used enabled but the thickness
parameter wasn't explicitly set in the material, it would end-up
being uninitialized. Now it's initialized to 0.5 by default,
which is the value used for subsurface.
Also removed some calculations dependent on thickness being set, as
they assumed a thickness of 0.
matinfo -w doesn't show the variants for any backend other than
metal. The reason is that the code for updating the variant
list wasn't being triggered on currentBackend changes.
- add conveniences function to make LineDictionary look like a vector
- a pattern must start on a word boundary but "_" wasn't treated as one
- getIndices() must return the empty vector when any of the substring
is not found
Currently the only values possible are 'none' and 'all'. 'all' is the
default. This option will be used to control code generation
workarounds individually. Currently 'all' disable the
MergeReturn and Simplification passes, which have causes issues in
the past on some older Android devices.
- Add a Configuration struct to the WebGPUPlatform class. This
allows for client-side setting of WebGPU backend configurations.
- Add a configuration for forcing the wgpu backend to pick a
certain backend.
- Add Vulkan as a potential backend for WebGPU + MacOS.
- Locally modify Dawn so that it does not assume only switfshader
is available for Vulkan on MacOS.
- Enable vulkan support for Dawn (third_party/dawn/tnt/CMakeLists.txt)
- Plumb option to pick different WebGPU backend through
FilamentApp and gltf_viewer.
- Fix broken links in https://google.github.io/filament/main/
- Make /README.md links consistent
- Add additional replacement recipes for /README.md
- Make /index.html redirect to /dup/intro.html because
/index.html has the wrong relative links. This is essentially
adding a redirect-only index.html to src_raw.
When calling setExternalSamplerVkSet the recycle
function lambda captured some variables allocated
on the stack, which are out of scope by the time
the function is called.
Change the capture to be done by value instead of
by ref to avoid this problem.
This commit enhances the material compilation process by embedding the
`matc` command-line parameters directly into the compiled material file.
This feature is valuable for debugging, as it allows developers to
inspect the exact compilation settings used for a given material.
A key consideration is the potential for personally identifiable
information (PII) in the command-line arguments (e.g., file paths). To
address this, a `toPIISafeString` method has been implemented to filter
out PII-sensitive options before they are stored in the material.
With this change, the matc command below
/path/to/matc -a opengl --api vulkan -p desktop -g -o /path/to/my.filamat /path/to/my.mat
is stored to the package as below. (veryfied by running `matinfo my.filamat`)
Compilation Parameters: -a opengl --api vulkan -p desktop -g
We link the behavior of certain precondition/postcondition checks to feature flag states.
- If provided *flag* is true, then this macro will assert when the *condition* is false.
- If provided *flag* is fase, then this macro will output a warning when the condition is false.
- If the condition is true, then neither of the above will happen
These two macros will enable us to provide less restrictive behavior for certain correctness assertions, allowing clients to modify their before enabling these assertions by default.
* gl: Enhance error reporting for asynchronous shader operations
When ShaderCompilerService asynchronously compiles and links shaders,
unexpected errors (e.g., GL_CONTEXT_LOST) can occur after the initial GL
call, complicating diagnostics.
This change improves error context by collecting the GL error status
when querying shader compilation and program link statuses. This
provides a more detailed understanding of error origins.
BUGS=[373396840]
* feedback
When a program was created directly from a cached blob in
`ShaderCompilerService`, its associated token was not signaled as ready
in the THREAD_POOL mode. This oversight caused a deadlock at the
`token->wait()` call during program destruction.
This commit resolves the issue by skipping the token's readiness check
upon destruction if the program was created from the cache blob.
BUGS=[423221474]
This reverts a behavioral regression introduced in commit c3542b135e,
which deferred callback submission until the program was first used.
This commit restores the correct behavior by submitting the callback
handle as soon as the token's work is complete. This occurs either upon
successful `gl.program` population or via cancellation, ensuring the
caller is properly notified that the resource loading operation has
concluded.
The addition JobSystem.cpp allows for defining
FILAMENT_TRACING_ENABLED across targets.
Addingin FILAMENT_TRACING_ENABLED to the #if in Tracing.h prevents
perfetto from being included.
There was several issues:
1) when we're switching contexts (e.g. between protect and regular) we
needed up reattach all SurfaceView (i.e. streams), because they need
to be attached on currently active context.
2) reattaching, because it's implemented as detach + attach, would
destroy the current gl texture id and create a new one. However,
because of the way descriptor-sets were implemented, that GL
texture id was kept inside the descriptor, later leading to using
a destroyed texture id.
The fix here is to store texture handles in descriptors, so that
we can update the id independently.
3) we also needed to invalidate all bound descriptor sets because it's
now possible for descriptor sets to have outdated descriptors
- Some tests require textures larger than 2048. Change the minimum
to 4096 for now, and file proper bugs for tests.
- The introduction of uint8_t to DescriptorSetLayoutBinding
caused unintended padding with using this struct as a hash key.
We comment out the relevent code for now.
Just like mCulling, mShadowCulling needs to be inherited from the
material.
Fix breakage introduced in #8422 with attempted fix in #8475 and
caused by an uninitialized variable (mShadowCulling).
BUGS=[391679058]
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.
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).
If the shared osmesa lib is not found, then we assume that the
library has been compile-time linked via the linker. This is to
accommodate build frameworks where compile-time linking is
preferred.
This restores the old behavior with depth variant caching. We pay the
price at engine init time, instead of when the variant is needed the
first time. We can revisit this later.
Note that the default material doesn't have all possible depth variants
(e.g. VSM), but that pre-caches the most popular ones.
BUGS=[381946222]
On ES2 devices (or in forceES2 mode), we emulate the sRGB swapchain
in the shader if the h/w doesn't support it. In that case, the emulation
is controlled by a uniform that technically lives in the frameUniforms
block. However, the frameUniforms buffer is not updated, instead,
the uniform is manually set. Unfortunately, the UBO emulation
overrides it with the uninitialized variable.
BUGS=[377913730]
Mesa always clears the generic binding if the buffer deleted
is bound to an indexed binding, even if it's not bound to the
generic binding.
BUGS=[371324321]
- We change GLDescriptorSet::Buffer default constructor to
workaround a client's compiler set up issue.
- We removed the assert_invariant that checks that ubo/samplers
are not changed after committed in DescriptorSet. This caused
an existing client's build to crash.
Found through testing that renderStandaloneView+vk+swiftshader
seems to cause synchronization issues, which results in incorrect
rendering. Here we workaround the issue by forcibly flush and
wait per renderStandaloneView call.
BUG=361822355
`DebugRegistry::setProperty` is no longer just applicable to debug
builds.
This change was previously added in 6c0bd36 but then reverted
in a7317e7. We re-enable it and separate it from the shadow
changes in this commit.
This fixes a crash introduced by a8ace2891d
The refactored FrameInfoManager can cause a crash when IBL resource loading
happens because now the getLastFrameInfo() references an invalid value via the
`front` method. Return the default FrameInfo to resolve this.
Also fix a null pointer reference bug for OpenGLTimer::State, which
happenes when the renderer for IBLPrefilterContext is destroyed.
- remove deprecated morphing APIs
- repair gltfio, samples and tests
The new API doesn't allow a MorphTargetBuffer per RenderPrimitive,
instead the MorphTargetBuffer is specified per Renderable.
gltfio separates RenderPrimitives from Renderables, in particular all
RenderPrimitives are created before their Renderable; this was
problematic for this change because all primitives must share
a single MorphTargetBuffer living in the Renderable.
To fix this, we're no longer initializing the morphing paramters
at RenderPrimitive creation, instead we store a reference to the
BufferSlot in the Primtive structure, so that later, when the Renderable
is created we can finally retrieve the BufferSlot and initialize its
morphing paramters, which are not available. The "morphing parameters"
are now expanded to contain the MorphTargetBuffer as before (except now
it's always the same for all the primitives of a Rendrable), as well
as the offset within the buffer and the vertex count.
If a user is using `setFrameScheduledCallback()`, managing the provided PresentCallable during engine shutdown is tricky -- we'll likely get a final frame scheduled when we flush the engine's work queue, but the PresentCallable will schedule the final CAMetalDrawable to be released on main thread afterwards, even if we call `present(false)` to skip it. If the swap chain is destroyed before that main queue block gets executed, the mutex presenting that drawable will no longer exist, causing a crash.
To make things easier, store the std::mutex in a shared_ptr, so that a PresentCallable can safely outlive the FSwapChain instance that created it and clean itself up afterwards.
Alternatives considered, all of which seem unfortunate:
* Require users to clear out the callback before shutting down the engine, so that any final drawables are immediately discarded instead of using PresentCallable
* Require users to split up the engine teardown across two main queue blocks, ensuring that the PresentCallable cleanup executes before swapchains are destroyed
* Drop the PresentCallable on the ground and leak the memory
PresentDrawable was moved to main thread by default in google#7535 and stopped
most crashes when a drawable is released. But there still appears to be crashes
if a drawable is released on main thread at the same time that -nextDrawable is
called from the Filament render thread. (It's likely that the drawable pool in
CAMetalLayer is completely non-thread-safe.)
So, add a mutex to the swapchain and always acquire it before creating or
releasing a CAMetalDrawable.
Users can opt out of this behavior by passing
-DFILAMENT_LOCK_METAL_DRAWABLE_POOL=0.
Currently, if this fails we log the error message to stderr (which
doesn't get captured by most crash reporting systems) and then crash in
a postcondition assert. By including the error message in an exception
reason and throwing an ObjC exception, we get better discoverability of
error causes.
(Building a render pipeline state from shaders is usually when a shader
actually gets JITted from LLVM IR to GPU-specific code, so if we
accidentally used a feature that's not available on the local GPU, we'll
find out about it here.)
The current API allowed to have a buffer for each primitive in a
renderable. We instead restrict the API so that there is a single
MorphTargetBuffer for the whole renderable, shared by all primitives.
The buffer can be shared thanks to the "offset" parameter on
setMorphTargetBufferAt().
Also
- fix FMorphTargetBuffer::updateDataAt()
- add support for the "offset" parameter of setMorphTargetBufferAt()
If a .metallib was compiled with a target iOS version that's newer than
the current device, loading the .metallib may succeed, but finding main0
(or any other function in it) will fail. Currently, this causes a crash
due to an assert. Logging the error and returning
MetalFunctionBundle::error() makes the crash slightly easier to
diagnose.
(Note that in practice, this will probably be a useless "Compiler
encountered an internal error" message -- the GPU backend is crashing,
and the Metal stub library sees XPC_ERROR_CONNECTION_INTERRUPTED. It
retries up to 3 times (crashing each time) and then gives up.)
I was unfortunately naive about the way that Filament handled external textures
on non-GLES platforms. This fix restricts the changes to Android (which is the
only place this change is required in the first place). Long story short, the
change broke WebGL. Desktop seems to be unaffected.
the gl backend did some of its cleanup in the its destructor,
including calling into OpenGL, however, the destructor is called from
the main thread, not the GL thread, so these calls would be no-ops at
best, and crashes in the worst case.
This PR adds a new `pause()` option to the `Engine` `Builder` and a new function
`setPaused()` to the `Engine`. While paused, the rendering thread will pause
indefinitely for commands as if none are available. As soon as the rendering
thread is unpaused, the commands are immediately executed.
in case the swapchain creation fails, it will now return a swapchain
with an EGL_NO_SURFACE handle. this will avoid having to nullptr check
the pointer in various places and will revert to the previous behavior
on failure.
FIXES=[329659681]
Previous commit [1] changed the semantic of the index to
mBufferObjects. Here we just make sure that if a buffer has been
allocated, we don't allocate another (otherwise, we'd leak).
Also cleaned up `updateBoneIndicesAndWeights` indexing
[1]: a3131a64b6
The OOB would happen is the scene never had any renderables, in that
case the scene's SoA would stay unallocated, but the summedAreaTable
code relies on it have at least a capacity of 1.
It was incorrect to skip the RenderPass entirely because it might have
had some custom commands that needed to be executed (e.g. for applying
post-processing in subpass mode).
This has caused issues and over time we have reduced the use of
spinlocks, it was only used in few places and we still have evidence
that it's causing ANRs.
We use utils::Mutex instead which is a low overhead mutex implementation
on Linux systems.
FIXES=[321101014]
See #7415 for a more detailed description of why this change is necessary.
The remaining variants which are filtered from FL0 materials are all related to
lighting, so further hacks like this won't be necessary.
Future work involves properly supporting differing sets of variants based on
shader language.
Even if skinning is not fully implemented on FL0, we have clients which depend
on materials with skinning variants that otherwise could easily be converted to
FL0 materials. There are two proper ways to deal with this:
1. Support skinning/morphing in Feature Level 0.
2. Allow ESSL 1.0 code and ESSL 3.0 code to support different sets of variants.
However, the simplest solution is to just include skinning/morphing variants,
but disable codegen for ESSL 1.0 code, making them identical to the base
variants. This shouldn't increase the file size much due to the dictionary
deflation. Of course, skinning will not work correctly on FL0, but this has
always been the case. Future work here would be to properly implement one of the
two solutions described above.
Swiftshader runs spirv validation before compilation. However,
the validation does not like having Nop (no-op) in the input.
So we skip instructions instead of writing no-op for the
output of `workaroundSpecConstant`.
Also, fix issue to keep the value in the original shader if a
specialization wasn't provided.
The CL introducing the ESSL 1.0 chunk in materials inadvertently disabled
optimizations for said code. This commit reintroduces those optimizations and
fixes associated bugs which manifested. In particular, spirv-cross was
generating uints for bools; this has been fixed with a hack. Additionally,
spirv-cross is now compiled with exceptions enabled so that matc can gracefully
fail and show the code which failed to compile rather than abruptly aborting.
Since #7358 is blocked by an upstream spirv-cross issue, we can at least do a
bit of preprocessor optimization for ESSL 1.0 code in the meantime and introduce
the FILAMENT_EFFECTIVE_VERSION preprocessor definitions.
This change in glslang removes the include of "intermediate.h" from
GlslangToSpv.h:
62de186c33
As a result, the definition of "class TIntermediate" is removed, and
will fail compilation of MaterialCompiler.cpp when glslang is updated to
a version including the aforementioned change. We fix this by adding an
explicit include to this header in MaterialCompiler.cpp.
Co-authored-by: Powei Feng <powei@google.com>
- gltfio: Enable -Wall -Werror for gltfio_core
- gltfio: Fix various errors that were missed warnings
- matdbg: switch from std::atomic_uint64_t to
std::atomic<uint64_t> for older clang
- we were not using the correct field in ShadowMapManager
- we were not computing the transform correctly, it should applied
after the local transform, not before.
FIXES=[299310624]
We've seen hangs/ANR that are not well understood on that spinlock, so
for now we're going back to mutexes, which, on android, are very
efficient under low contention (no syscall).
FIXES=[308029108]
* prevent public classes from being created on the stack
- we used to to this by deleting operator delete, but this prevented
the internal "F" classes from being virtual; which can be useful
when using EntityManger::Listener.
now we just make the destructor protected in each class.
- EntityManger::Listener now has a virtual destructor so that
objects could be correctly destroyed from Listener*
* improve EntityManger and Component managers
- all component managers now have the same "base" API
- getComponentCount()
- empty()
- getEntity()
- getEntities()
- Scene now has getEntityCount()
- EntityManager now has getEntityCount()
- all component manager implement gc() the same way, by calling destroy()
- SingleInstanceComponentManager::gc() that calls removeComponent() has
been removed because it's dangerous. removeComponent() is often
not enough, some additional cleanup might be needed.
CameraManager creates a Transform component for each Camera component
is not already present. However, it didn't destroy the transform
component when it's itself destroyed. the leaked transform component
would eventually be garbage collected, but caused significant
slow down and memory pressure. This is because camera components are
created every frame for the shadow maps.
FIXES=[303914944]
- the insert and retrieve handlers can now be set/unset independently.
this could be useful for debugging.
- program caching is disabled if the GL implementation doesn't support it.
- removed unused code
FIXES=[307549547]
This reverts most of commit 9a6b8bf24e. The hello
triangle sample remains unreverted.
The original commit inadvertently broke screen space reflections, and perhaps
other features when the default material was used. The source of the issue is
that MaterialBuilder.cpp (correctly) filters out variants that aren't supported
in feature level 0 materials, including screen space reflections.
Unfortunately, while the "feature level 0 compatibility" feature itself was
intended to make creating duplicate materials like this redundant in client
code, unfortunately, it seems the best solution for resolving this issue is to
simply keep these redundant materials in the core.
To elaborate: clients should expect that feature level 0 materials that they
create work on /all/ feature levels /exactly/ or /close to exactly/ identically.
This includes restricting more advanced features that theoretically could be
available on a higher feature level, like SSR. It's already true that if a user
would like to optionally opt-in to a more advanced material which takes
advantage of more advanced features, they would have to maintain two separate
versions of that material: one for feature level 3 and one for feature level 1.
It should be no different in this case.
However, the materials built into the engine core are an exception to this
expectation. Given that feature level 0 was tacked on after the fact with fewer
features, there must /by necessity/ have been a new material introduced for both
the default material and the default skybox specifically for feature level 0
with fewer features than extant client apps expected to be included by default.
I imagine if filament were to be rebuilt from the ground up, this exception
wouldn't exist. However, the end result is this somewhat messy redundancy.
We wrote a bool directly into 4 bytes (as the first byte). This has two issues:
- the other 3 bytes are not initialized
- should be writing VK_TRUE/FALSE instead
This reverts commit 58f96be2c4.
This caused material files to increase in size significantly. It turns
out that glslang has to generate a copy for each parameter that is
passed to a function as a non-const parameter.
This revert will break IMG devices again, but that should be the case
only on debug builds. Release builds lose the const qualifier by
virtue of going through spirv. We'll try to address this some other
way later.
This reverts commit 58f96be2c4.
This caused material files to increase in size significantly. It turns
out that glslang has to generate a copy for each parameter that is
passed to a function as a non-const parameter.
This revert will break IMG devices again, but that should be the case
only on debug builds. Release builds lose the const qualifier by
virtue of going through spirv. We'll try to address this some other
way later.
Previously, we have a VulkanSync with a default constructor that
allows us to have sync objects that returns error when
actual fences are not yet present. We need to replicate that
with VulkanFence since sync objects have been removed from the
API.
Fixes#7034
this is needed on armv7 because we use alignas to get strcture-alignment,
but that also implies (to the compiler) that the structure itself
is aligned properly.
There was two related issues:
- we need to "latch" the new TextureView size when its resized. That
can only be done by recreating the EGLSurface (i.e. recreating the
SwapChain). UiHelper now calls onNativeWindowChanged in the case of
the TextureView resize, so clients can recreate their SwapChain.
- we also needed to make sure that all current filament frames have
finished to render (i.e. the last eglSwapBuffers has been called) so
that they don't pick-up a new size (this happens after
eglSwapBuffers) that doesn't match the viewport.
Fixes b/282220665
- flush() and wait() before destroying a swapchain
- Make sure the debug marker extension is enabled under correct
circumstances.
- Change shared_ptrs to unique_ptrs and raw pointers.
- Rename most teardown methods to terminate()
Since cmake 3.25 LINUX is automatically set based on CMAKE_SYSTEM_NAME,
which the android cmake files are setting to "Linux". This created an
inconsistant state in our build system.
Since cmake 3.25 LINUX is automatically set based on CMAKE_SYSTEM_NAME,
which the android cmake files are setting to "Linux". This created an
inconsistant state in our build system.
WebGL complained about:
Precisions of uniform block 'ShadowUniforms' member
'ShadowUniforms.shadows.texelSizeAtOneMeter' differ between VERTEX and
FRAGMENT shaders.
this field didn't have a precision qualifier, this might be specific to
WebGL or a Chrome bug, unsure. Either we fix it by specifying all
qualifiers.
WebGL complained about:
Precisions of uniform block 'ShadowUniforms' member
'ShadowUniforms.shadows.texelSizeAtOneMeter' differ between VERTEX and
FRAGMENT shaders.
this field didn't have a precision qualifier, this might be specific to
WebGL or a Chrome bug, unsure. Either we fix it by specifying all
qualifiers.
glDispatchCompute requires Android API level 21, however bumping our
required minimum from 19 to 21 caused some clients' builds to fail.
Commenting-out that line for now to proceed with the 1.28.0 upgrade.
The VulkanProgram constructor was bailing out early and emitting a
warning because it saw that one of the stages wasn't fulfilled.
However it's okay for a pipeline to be missing a compute program.
Fixes regression that started with fabba73b1.
to emulate the bindless API in the gl backend we always used the highest
texture unit available. However at feature level 3, we support up to 62
textures, so the that max was bumped to 62 -- however, where we're not
on a feature level 2 device, that texture unit doesn't exist.
Instead we now always use binding 31, which is guaranteed to exist by
EGL's minspec.
This broke asyncGetLoadProgress() and caused WebGL to crash reliably
because ResourceLoader got destroyed too soon.
Bug was introduced with de7dfc2ea6.
I intend to cherry pick this to rc/1.27.0, which is where it was
introduced, so there's no need to update the release notes.
Filament does not yet fully support threads with WASM, but this is a
baby step in that direction.
To enable experimental pthreads support, enable the WEBGL_PTHREADS CMake
option. This will enable pthreads support in `gltfio` and `utils`, which
is known to work, but not when served with GitHub Pages.
The web server must emit COOP, COEP and CORP headers, so our build
instructions now recommend the use of `emrun` for local testing.
This also changes our demos so that they do not use unpkg, which
does not work when using `emrun`, due to cross-origin restrictions.
I have disabled building SDL with headless EGL, because
SDL_config_minimal.h doesn't work with EGL, and I don't know how to
implement a an SDL config that would work with EGL.
I have verified that this works in a separate project, and that it
compiles in this project.
```
$ ./build.sh -e release
$ find ./out/ -name "*EGL*"
./out/cmake-release/filament/backend/CMakeFiles/backend.dir/src/opengl/platforms/PlatformEGL.cpp.o
./out/cmake-release/filament/backend/CMakeFiles/backend.dir/src/opengl/platforms/PlatformEGLHeadless.cpp.o
./out/cmake-release/libs/bluegl/CMakeFiles/bluegl.dir/src/BlueGLLinuxEGL.cpp.o
```
Reflects a change from Betty and should be cherry picked to v1.23.3
Users could customize the ImGuiHelper camera, but they had no control
over the scissor coordinates. This allows them to use vertically flipped
coordinates, which, unfortunately, is required for MediaPipe
integration.
a 64 bytes pool seems to work with both clang and msvc, unfortunately,
c++ doesn't let us know the allocator object size at compile time
for map containers, so we have to guess.
This is a temporary workaround for a memory corruption issue observed on
some devices from a specific vendor. We will try to make this workaround
more targeted in a subequent change.
Partial revert for b2cdf9f2b4.
This fixes the emscripten binding errors that we've been seeing
with the <filament-viewer> test page, which prevented us from
including web in the last few Filament releases.
The binding errors were caused by double-initializing the emscripten
module.
I fixed this by allowing clients (e.g. FilamentViewer) to call
Filament.init() more than once. We now accumulate a list of "on ready"
callbacks that get triggered after the emscripten module becomes ready.
As far as I can tell, multiple canvases were actually always broken, and
the viewer test page worked in the past only because we got lucky.
The previous code would convert each element of the source data
into 8 bit-per-element, but we wnat to preserve the original format
that the user provides.
The new solution is to use `slice()` which is a robust way to clone
all the data in a typed array.
This fixes the new regression with Triangle that Ben caught.
If emscripten grows the heap inside one of our BufferDescriptor binding
functions, then the old heap becomes "detached" and an error can
occur.
This fixes the issue seen with the Parquet demo that Ben caught.
All three types of caches (descriptor sets, pipelines, and pipeline
layouts) are now managed in exactly the same way. They all use an LRU
eviction scheme that is based on a count of command buffer flush
events.
Vulkan objects can only be destroyed if there are no in-flight command
buffers that reference them, so an easy way to know when it is safe to
evict a given entry is to wait for "N" flushes after its last use, where
"N" is the number of command buffers in the command buffer ring.
Another big simplification is that there are no more dirty flags,
instead we store two sets of state vectors for each type of cache: the
"currently bound" state, and the "current requirements" state.
Fixes#5142 by replacing unsafe pointers with map keys.
One of the differences between robin_map and unordered_map is the
following:
pointers to keys or values in the map are invalidated in the same
way as iterators to these keys-values
Therefore it is unsafe to track the pointer to a value that is stored
in a robin_map.
This is mostly just code cleanup. One actual bug was the fact that the
dummy sampler was re-created every time a new pipeline layout was
created.
It also felt strange to use `auto&` to refer to a C-style array. I
changed this into a `std::array` which is more consistent with other
fixed size arrays in this class.
Support legacy morphing (morphing with targets supplied via VertexAttributes) for older clients. This gives clients more time to transition over to the new MorphTargetBuffer API.
This allows `MorphStressTest` to work on Vulkan.
However, `Horse` is still broken because it provides positions but not
tangents. Separate fix for that is coming.
Partial fix for #5109.
This fixes validation errors and makes a first pass at simplification.
VulkanTexture now tracks image layout using RangeMap, which paves the
way for further simplification.
This will allow the Vulkan backend to efficiently track the subresource
image layouts for each texture.
This is a sparse container for a series of ordered non-overlapping
integer intervals, where each interval maps to a concrete value.
This is because we're using the same program variant for skinning
and morphing, in the skinning-only case, the buffer won't be accessed
in the shader, but it must be present.
fixes#5085
A recent refactor was causing the following error when the vertex domain
was set to `device`:
```
ERROR: main.vs:23: 'material' : undeclared identifier
ERROR: main.vs:23: 'materialVertex' : no matching overloaded function found
```
Bring color grading back into the Rec.709 color space to match
previous behaviors. This change also implements an exact inverse
tone map function for the "Filmic" operator.
SamplerGroup was comparing texture handles to decide if a texture needed
to be updated, however, texture handles are (quickly) recycled and
therefore can't be used for that purpose. e.g. if a texture is destroyed,
its handle could be reused quickly by another texture, if that texture
is now set on the SamplerGroup, it will ignore it, thinking it's not
different.
We were inserting the colorgrading subpass command between the
refracted and blended objects, instead of after all of them.
Another bad side effect of this was to trigger the refraction pass for
no reason.
The operator!= in std::array compares SPLIT_COUNT elements, which
is potentially greater than cascadeCount, which was the number of
initialized elements in splitPercentages.
std::allocator::deallocate() expects the same value that was given
during allocate().
Interestingly, this bug did not manifest any issues (even with ASAN) on
some platforms.
We should take care not to call glVertexAttribPointer when there is
no bound ARRAY_BUFFER (i.e. when its binding is zero).
This fixes the black screen seen with some WebGL samples after
the recent memory leak fix related to the new BufferObject API.
This leak was introduced in the following PR on April 7.
https://github.com/google/filament/pull/3775
The guilty party has been contacted and properly admonished for his
transgression.
This was tested by adding the following code after applyAnimation in
gltf_viewer.cpp
static int nframes = 0;
if (!gpath.empty() && nframes++ > 100) {
static int count = 0;
printf("reloading %d\n", count++);
nframes = 0;
app.resourceLoader->asyncCancelLoad();
app.resourceLoader->evictResourceData();
app.viewer->removeAsset();
app.assetLoader->destroyAsset(app.asset);
loadAsset(gpath, app);
loadResources(gpath, app);
}
The hang was caused by a subtle race. When a job is completed, its
thread must signal all the threads that might be waiting on this job.
The signaling code was attempting to signal only the minimum number
of threads -- this was important especially in the case where no threads
were waiting, then the call to notify() could be avoided.
Unfortunately, for performance reasons we're not calling notify() with
the condition lock held, this meant that between the time the number of
waiting threads was latched and the time of the notify() call, more
threads could enter their condition variable wait(), and it would
then be possible for these threads to wake up, instead of the thread
we were trying to wake up (the one waiting on the job).
It would then get stuck forever.
This bug was introduced in 2df639133b
Also add some debugging code for this kind of failure (disabled)
This wasn't very useful in the first place because we're recycling
handles very quickly. Additionally there was a race condition
which cause false positives.
This reverts commit bc6acd5c5a.
This reverts commit 3a15756c78.
When running semantic analysis on a material, we were arbitrarily choosing the first code gen permutation to analyze. So, running matc with arguments --api metal versus --api all would run analysis on slightly different shader code. This causes bugs when flags passed to glslang differ during semantic analysis. This change updates all semantic analysis to always use the same shader code.
When passing only 1 fence to vkWaitForFences, the `waitAll` argument
should not have any effect, but SwiftShader seems to skip the wait
when this argument is set to VK_FALSE.
More specifically, the failure to wait in `acquireWorkCommandBuffer`
causes the subsequent destruction of an in-use fence, which causes
a TSAN failure with Google's internal tests.
I am consulting with the SwiftShader team on a real fix, meanwhile
we can commit this easy workaround.
We have 5 usages of vkWaitForFences, one of which uses multiple fences
and should have used VK_TRUE anyway.
This prevents a SwiftShader crash and/or a slew of "no texture bound"
warnings that would appear when the client provides an IBL without
providing reflections texture, which should be a valid thing to do.
Note that it is okay to declare a sampler in GLSL that never gets bound,
as long as it is never sampled from. Since we always sample from the
IBL specular texture, we should always bind something to it.
With Vulkan, this warning would sometimes be a false positive. It could
trigger for internal samplers like `ssao` and `structure`, even though
they were not declared in SPIR-V.
With OpenGL, this warning would never be a false positive because it has
the luxury of calling `glGetUniformLocation`.
This adds a private attribute to our samplers called `strict` that
indicates whether or not a sampler should always have a bound texture.
For now the only strict samplers are the custom ones declared in the
user's material.
At some point I think we should consider adding `spirv-reflect` to our
tree to help with problems like this.
This fixes a bug seen with client applications that use ClearOptions
instead of Skybox, and one or more offscreen RenderTarget objects.
These apps would see junk pixels because Filament would only clear the
first render target in the frame.
The fix is to factor some the flag-setting logic in `beginFrame()` into
a private method, and call this method from `render()` each time
the user-level RenderTarget has been changed.
I wrote a simple C++ demo to reproduce the issue and to verify that
this fix works.
**If you are merging a PR into main**: please add the release note below, under the *Release notes
We are chaning the way Vulkan buffers are handled. We need to switch over to a managed (or view-based) model where the data stored inside the object is a proxy to a Vulkan object that can dynamically be swapped around.
**If you are cherry-picking a commit into an rc/ branch**: add the release note under the
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
## Release notes for next branch cut
- Update CMake minimum version to 3.22.1
- material: Add a material parameter to control shadow far attenuation (b/436680157)
echo"Successfully checked out the specified models into the '${TARGET_DIR}' directory."
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.