- update the pools sizes for metal and vulkan, which were very outdated.
- add debug code on all backends to print the size of each handle
(with a compile time switch)
The most important change is that now the 3 pools of HandleAllocator
are sized so that each can accommodate about the same amount of handles.
This makes it easier to reason about. The total amount of handles is
three times that, since there are 3 pools.
We also try to allocate the buckets so that handles are evenly
distributed, however, that's very hand wavy.
With the current setup the number of handles per pool is as follows:
- GL : 3240 / pool / MiB
- VK : 1820 / pool / MiB
- MTL: 1310 / pool / MiB
* Automatically flush CommandStream
When generating commands, we now automatically flush the CommandStream,
so that we're guaranteed to not overrun the circular buffer.
* clenaup CircularBuffer implementation and API
Also fix a bug in DEBUG mode that could corrupt the CircularBuffer, it
was due to a wrong debugging code attempting to clear the unused
area of the buffer (this was wrong because in "ashmem" mode, there are
no guaranteed unused areas).
* Fix a couple threading vs. allocations
- prepareVisibleLights was run on a dedicated thread (via JobSystem),
but was using its own local ArenaScope. This is wrong because it
could reset the root arena at any later point. This is fixed by
just not using a local ArenaScope.
- related to the above, the root Arena (LinearAllocatorArena) didn't
use a locked policy, which cause also cause problems since some
allocations are done off the main thread. We now pre-allocate the one
buffer we need.
This PR also renames some variable and types to improve readability.
* Rework RenderPass to improve allocations and API
RenderPass now is a fully immutable object that gets constructed with a
RenderPassBuilder. RenderPassBuilder can be passed around and doesn't
do any (major) allocations.
All RenderPass allocations and heavy lifting is done in
RenderPassBuilder::Build().
Additionally, RenderPass cannot be copied anymore.
Where allocations happen is now much clearer.
* new LinearAllocatorWithFallback
LinearAllocatorWithFallback is a linear allocator that can fall back
to the heap allocator. We use it for the high level command buffer to
avoid crashing when running out of memory.
FIXES=[277115740]
* Update filament/src/RenderPass.h
Co-authored-by: Powei Feng <powei@google.com>
* Update libs/utils/include/utils/Allocator.h
Co-authored-by: Powei Feng <powei@google.com>
---------
Co-authored-by: Powei Feng <powei@google.com>
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]
Material constants (a.k.a: specialization constants) can only be set
during Material creation through Material::Builder.
This change somewhat relaxes that limitation by allowing constants to
be set at runtime on Material directly.
Currently this new API is still private and only supported on FMaterial.
This feature works by invalidating the HwProgram cache of the concerned
Material, causing a shader recompile per variant; so this API is costly
and should be used only for debugging or during app/game configuration.
The TAA material is modified to use constants instead of #defines for
various settings and those are exposed in TaaOptions as well is in
ViewerGui. So with this change all aspects of the TAA material can
be changed at runtime.
* 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.
- don't rely on it being 32-bits
- update the jni code to store SamplerParams in a long (64 bits)
instead of a int. This gives us some future-proofing of the java side.
It supports KHR_parallel_shader_compile as well as a
thread pool of GL contexts.
- we have a new 2-priorities queue for shader compilation
- use this feature in gltfio in the ubershader case
- StructureOfArray: don't initialize trivial ctors
We mimic the behavior of std::vector<> here, where a resize() won't
initialize the array if the type is trivially_default_constructible.
This can reveal existing bugs, where we depended on the initialization
to 0.
- StructureOfArray: add push_back(std::tuple<>)
This basically allows us to push_back() a struct of the SoA.
- Make PerRenderableData trivially constructible
this improves performance when we have tons of objects in the scene
because PerRenderableData is used in arrays.
Instead of storing the arrays into an array of void*, we use a
tuple<> instead. This improves debugging because now the tuple<>
has pointer with the correct types.
It also improves most of the code except `push_back` which now
relies on a hack -- this is the only place where I'm not able to
resolve the array strictly at compile time, even if in practice it is.
This 2D allocator only supports power-of-two, square allocations. It
uses a quadtree to store the allocated regions.
The quadtree implementation currently has a fixed depth (templated).
The allocator does a best-fit match, but currently doesn't implement a
free method.
* check that user materials don't exceed their allowed features
* backend sampler limits now take feature level into account
- in the backend, the constants are now in an array indexed by the
feature level
- samplerBindingMap now asserts only what it can.
- matc (filamat) now logs the user samplers when an error is detected.
* Fix warning C4146: unary minus operator applied to unsigned type, result still unsigned
* Fix warning C4068: unknown pragma 'nounroll'
* Fix warning C4068: unknown pragma 'unroll'
* Fix warning C4068: unknown pragma 'clang'
* Fix warning C4305: 'initializing': truncation from 'double' to 'float'
* Fix warning C4267: 'argument': conversion from 'size_t' to 'utils::FixedCapacityVector<filament::uberz::WritableArchive::Material,std::allocator<T>,true>::size_type', possible loss of data
* Fix warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
* Fix warning C4244: 'initializing': conversion from 'A' to 'T', possible loss of data
* Fix warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
* Fix warning C4293: '>>': shift count negative or too big, undefined behavior
* Fix diagnostic warning C4189: 'channels': local variable is initialized but not referenced
* Use [[maybe_unused]] where possible and revert aa79bd6fa8.
* Revert unary minus for non-MSVC compilers
* Add macro for enabling warnings temporarily
* Get rid of UTILS_HAS_CXX17
* Revisit warning related macros
Co-authored-by: Levente Koncz <levente.koncz@shapr3d.com>
GLES3.0 (and GL4.1) need informations about the uniform block bindings
because they don't allow to do that setup in the shaders. So we store
that information in the material blob and retrieve it on the filament
side in Material. This information is passed to Program so it can
create the bindings.
Prior to this change, this information was set by Material itself, but
this ment we had two places where these bindings were hardcoded.
The bulk of the change is to add a new material chunk which stores an
array of {name, binding}, retrieve it on the Material side and pass it
to Program.
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.
StructureOfArray always aligned each array to the same alignment as
malloc (usually 8 bytes), but that was not enough if one of its type
has stricter alignment requirements.
StructureOfArray now always honors at least the alignment requirement
of each array.
Also removed dependency on EntityInstance.h
Fixes#5727
In most places this is simply replaced by `std::string_view`.
We also change a few internal/private headers so they accept
`std::string_view` instead of `utils::CString`.
if we have more than 16K of UBO data, we now use a "out of band" buffer
on the heap instead of the command stream, which has limited space.
to minimize the heap allocation we use a simple pool allocator that
recycles a few heap buffers (per Scene).
By design we shouldn't access the scene SOA when executing the
high level commands.
This change increases the size of a command to 64 bytes and
PrimitiveInfo to 48 bytes (both with some small padding left).