MaterialInstance: generate versions of setParameter() methods that
are templated on the parameter sizeof(), which allows us to
coalesce implementations, e.g. vec4<float> and vec4<int> are now
the same. We make the compiler generate non-inline version of all
these methods, the typed version just call through, taking
advantage of the tail-call optimization in clang.
MaterialParser: improve code to avoid calling multiple methods that
all did more or less the same thing and were inlined.
PostProcessManager: use a loop to initialize the materials
ToneMapping: de-dup ACES implementation
And other more minor optimizations.
Fix alignment issues with setting booleans in UBOs
The main goal of this rewrite was to make the code
simpler and easier to maintain.
The API is mostly unchanged, however there are some differences.
- we now have the concept of subresources, e.g. for Textures, as
subresource is a mip level or layer.
- RenderTargets are no longer resources, instead they are transiant
objects associated to a pass and are now called RenderPasses.
- RenderPasses take subresources for attachments.
- We have better validation of graph building.
We should also compute discard flags more accurately.
assert() is now replaced by assert_invariant() which has the same
prototype and (currently) behaves the same than assert().
<assert.h> should not be used anymore, and is replaced by
<utils/debug.h>, which is where assert_invariant() is found.
The main motivation for this is to be able to set a breakpoint on the
assertion as lldb doesn't handle abort() very well, and doesn't
permit to inspect the stack trace.
A secondary motivation is to be able (at some point) to enable
assertions without necessarily doing a debug build.
* Add swap() methods to Allocator.h
This allows StructureOfArraysBase's move constructor to compile.
Removed an apparent workaround in SingleInstanceComponentManager.
* swap can be noexcept
* Add swap() methods to Allocator.h
This allows StructureOfArraysBase's move constructor to compile.
Co-authored-by: Mathias Agopian <pixelflinger@gmail.com>
The non-const getSkybox() method is especially useful to client code
that needs to change the clear color, but does not have direct
access to the Renderer object.
If hardware_concurrency() returned 2 while UTILS_HAS_HYPER_THREADING was
enabled, `mThreadCount` was resulting in zero, so jobs (such as texture
decoding) would simply never start. This problem was noticed with
GitHub Actions.
I tested this fix locally by replacing `hardware_concurrency()` with
fixed values like 1 or 2, and verified that the hang went away.
* debug option to track Entities
Set FILAMENT_UTILS_TRACK_ENTITIES to true when building libutils to
activate entity tracking. This adds two public methods:
getActiveEntities() and dumpActiveEntities() the later displays the
stack trace of where the remaining entities were allocated.
This is useful for tracking leaks.
* Update libs/utils/include/utils/EntityManager.h
Co-authored-by: Philip Rideout <philiprideout@gmail.com>
Co-authored-by: Philip Rideout <philiprideout@gmail.com>
we've had issues with some devices running in arm mode, where they
would throw spurious SIGILL on the WFE instruction used in spin locks.
Since on Android Mutexes are very efficient, we just use that instead.
This might fix#2197
libmath itself doesn't expose any stream operators anymore. However,
libutils is able to automatically print libmath types into its
io::ostream -- however matrices are not formatted nicely.
Added a new optional library, libmathio, that provides std::ostream
operators for all libmath types. libmathio does a better job at
formating matrices.
Also removed apply() and map() from libmath because there were not used
anywhere and they forced us to depend on <functional> in public headers.
There was actually no need to give special treatment to leading drive
designators since they effectively form the first path segment anyway.
To help prevent regressions, I added a few unit tests in a previous CL.
The motivation for the CL is to remove a dependency on `locale.cpp`,
which can result in shorter build times and reduced binary sizes.
This is in preparation to supporting screen-space effects.
There are two major changes:
- RenderPass is now copiable and intended to be passed by copy to
the execute stage of frame graph passes
- The color pass is in its own function now
This actually simplify RenderPass api.
An version of clang is smarter about generating warnings for template code. `assert` here is not included, so clang generates: `error: use of undeclared identifier 'assert'`
TrackingPolicy::Debug didn't store the base pointer of the Area, and
instead relied on the first allocation to discover it, however, because
of alignment, the first allocation may not match the base pointer.
Because of that there could be an overflow in onRewind(), i.e. we
could rewind to a pointer before the (wrongly computed) base. This
overflow caused the debug memset to go awry and stomped on memory.
This is fixed by passing the base pointer to the constructor of the
TrackingPolicy. This base pointer could be nullptr with certain
allocators, but in that case, onReset/onRewind should never be called;
and this is enforced at compile time.
Also fixed a (luckily) harmless buffer overflow when preparing the
dynamic lights, if the number of lights wasn't a multiple of 4. This
was harmless because we use a linear allocator, so overflows are not
really overflows.
This was caught by ASAN.
Our algorithm header has many one-liners that compute the "next power of
two length / 2" but they all have the caveat that if the input is
already POT, then the "/ 2" part does not occur.
Usually we deal with this by testing the difference against zero.
However in `partition_point` we were skipping the test, thus causing a
potential out-of-bounds access.
I fixed `partition_point` and added a few more tests for non-POT cases.