Commit Graph

25 Commits

Author SHA1 Message Date
Romain Guy
c429af310e Cleanup sample code 2018-08-13 17:01:04 -07:00
Philip Rideout
acffdb328a Fix release-only warnings. (#88) 2018-08-13 15:26:51 -07:00
Mathias Agopian
c91d2aedd8 per-light multithreading works again for froxelization
We spawn MAX_LIGHTS/32 (currently 8) jobs and
multi-threading is active as soon as we have more
than one light. All jobs work on disjoint buffers
to avoid false sharing between threads.

It’s possible to adjust roughly the number of jobs
by changing the group size (currently 32). However
this also affects vectorization.

With the current parameters, with 256 lights max
we get 8 jobs, and 4 spot-light test / froxel.
2018-08-13 11:36:24 -07:00
Mathias Agopian
7b7bd85def New froxelization algorithm that uses much less memory
Instead of building a list of froxel per light,
we now build a bitfield of lights per froxel.
To keep the code efficient we have to split
the bitfield array in 4, so that we can use
multiple threads without having them or’ing
each other’s cache-lines.

This data structure is also what we want in 
froxelizeAssignRecords(), and the conversion from
one format to the other is much faster.

Our internal data structure is now 256 KiB
instead of 2 MiB. It would be 1 MiB for 1024 lights
(down from 16 MiB)

Additionally, because the code is simpler, we get
more vectorization, especially with spot-lights.

One draw-back of the current version is that
multi-threading happens only every 64 lights.
This will be fixed later.
2018-08-13 11:36:24 -07:00
Philip Rideout
1f380a6ec6 Introduce new image library, Phase I. (#80)
* Overhaul the image library, Phase I.

The preps for our upcoming mipgen command line tool by adding filtering
capabilities and unit tests for a new LinearImage class, which will
subsume Image (deprecated).

Filament's new image library is composed of three components:

- LinearImage....simple 3D tensor of floats
- ImageOps.......free functions for simple transforms
- ImageSampler...high quality filtering

The old Image class was a simple untyped data blob and is now
deprecated. The new LinearImage class is always float32, and always
stores pixels in packed scanline order. This makes it easier to
implement image-based algorithms because they can be agnostic of the
underlying format.

Remaining refactorings:
- Phase  II will migrate imageio to LinearImage
- Phase III will migrate all downstream tools to LinearImage
- Phase  IV will remove old the Image class

* Image library code review feedback.
2018-08-13 10:39:57 -07:00
Mathias Agopian
a4851ed835 fix a bunch of clang-tidy warnings
fixed a couple actual real bugs (missing returns 
in operator=, wrong implicit bool conversion).

mostly added a bunch of explicit ctor.
2018-08-10 20:53:58 -07:00
Philip Rideout
fbe854e37d VulkanDriver now prints GPU info. (#73)
This is motivated by #71.
2018-08-10 11:58:03 -07:00
Mathias Agopian
8d2b3b2229 froxelization fixes (#70)
* fix stack corruption when the scene has more than 255 lights

* fix froxelization with more than 255 lights

Make sure froxelization works when the engine is
configured with more than a maximum of 255 lights.

The main issue was that the froxel structure on the
GPU uses 8 bits to encode the light count (per
froxel). So we have this 255 light max per
froxel limitation. The CPU code now honors this.

With this change we can go back to 256 lights
from 255!

All that said, it’s not recommended to increase
the maximum number of lights because the memory
usage on the CPU explodes. For instance we
go from 4 MiB with 256 lights to 18 MiB for 1024.
2018-08-09 23:07:24 -07:00
Mathias Agopian
d6746e1140 Set max number of lights to 255 instead of 256 (#66)
This always was the intention because internally 
it uses 8-bits buffers instead of 16-bits. One of
our temporary buffer goes from 4 MiB to 2 MiB.
This got mistakenly changed to 256 recently.
2018-08-09 17:30:59 -07:00
Philip Rideout
07c34ee833 Simplify Image by flipping RADIANCE images. (#63)
* Simplify Image by flipping RADIANCE images.

Unit test for the new flip() method is forthcoming.

* Optimize image flipping.
2018-08-09 17:30:17 -07:00
Philip Rideout
69b65d9e2d Rename ColorSpace header to ColorTransform. (#61) 2018-08-09 15:54:18 -07:00
Philip Rideout
9ed20705ec Refactor color space utilities. (#58)
* Refactor color space utilities.

* Repair Android build.
2018-08-09 13:58:58 -07:00
Mathias Agopian
a6877d5baa Fix cmgen cross cubmap input
Fixes bug #45
2018-08-08 16:50:02 -07:00
Ben Doherty
520ff90f34 Fix pathing issues on Windows (#49) 2018-08-08 12:17:30 -07:00
Damianno19
3d9dfd5085 Fix forward declaration type. (#44)
* Update MaterialBuilder.h

* Fix forward declaration type. Class instead struct
2018-08-08 08:53:32 -07:00
emmcbd
de1743c572 Fix huge memory allocation when decoding PNG, which can end up with std::bad_alloc (#43) 2018-08-08 07:45:57 -07:00
Romain Guy
bb75923b79 Fix post-process shader when not in Vulkan (#41)
* Fix post-process shader when not in Vulkan

The post-process shader must not flip the source texture when we compile for OpenGL. This happens because we use SPIR-V/Vulkan as an intermediate format.

* Fix the Android build

We need to output a location when targeting SPIR-V for mobile.
2018-08-07 18:46:30 -07:00
Philip Rideout
f8a8098e0f Split off imageio lib from image. (#36)
* Split off imageio lib from image.

* Remove duplicated math funcs.
2018-08-07 16:38:04 -07:00
Romain Guy
da03ef2378 Compile shaders in a separate static library (#34)
* Update build instructions

* Compile shaders in a separate static library

Each shader string is now part of a separate .o file, which should make recompiling filamat/matc a tad more enjoyable.

* Shaders.h belongs to filamat, not filament
2018-08-07 12:47:52 -07:00
Romain Guy
2b9a383c8b Prevent compilation error on Windows (#31)
The compiler cannot infer the type of the constructed object when
using the shorthand syntax.
2018-08-07 09:45:25 -07:00
Mathias Agopian
94c3623c1c clean-up formatting
Change-Id: I2071e53cceb93cbe02d6bdfa238aa6ce770b0534
2018-08-06 18:14:11 -07:00
Damianno19
9d14f6e907 Fix error
utils\src\Profiler.cpp(61): error : no member named 'uninitialized_fill' in namespace 'std'
2018-08-06 14:44:29 -07:00
Tact Yoshida
ad49986245 Remove execute permissions 2018-08-06 10:36:54 -07:00
Rich Wareham
a9153d9ce1 libs/image: fix structure-packing pragma warning
When compiling with clang on Linux, the following warning is generated:

../../libs/image/src/ImageDecoder.cpp:487:13: warning: unterminated '#pragma pack (push, ...)' at end of file [-Wpragma-pack]
    #pragma pack(push, 1)
            ^

According to [1], the correct pragma to pop the packing state from the
internal stack is "#pragma pack(pop)" rather than "#pragma pop()" which
is used currently. This commit replaces "#pragma pop()" with "#pragma
pack(pop)".

[1] http://gcc.gnu.org/onlinedocs/gcc-4.2.3/gcc/Structure_002dPacking-Pragmas.html
2018-08-04 09:47:01 -07:00
Romain Guy
b3d758f3b3 Initial commit 2018-08-03 10:38:22 -07:00