Commit Graph

710 Commits

Author SHA1 Message Date
Philip Rideout
904573b374 Incorporate feedback into Hugo site. 2018-11-13 10:57:20 -08:00
Philip Rideout
df3c2b74fd Add two-column mobile-friendly Hugo site.
This is a simple place to host WebGL demos and tutorials, we can prettify later. It will show up at:

    https://google.github.io/filament/

The hugo config specifies the output holder to be ../docs which is where our GitHub Pages site is located.

Note that this commit adds the *source* to the site, it does not publish the actual site. When we're ready to publish the actual site, we'll do:

```terminal
cd site ; hugo ; cd ..
git add docs ; git commit
```
2018-11-13 10:57:20 -08:00
Philip Rideout
037a0007c2 Disable depth prepass for WebGL.
WebGL does not always honor the invariant GLSL decoration, so we cannot
allow the depth prepass on web.

This fixes the black flakes seen with the Intel HD Graphics 615 in
Pixelbook laptops.
2018-11-13 09:22:08 -08:00
Mathias Agopian
bc3aee118a code size and performance optimizations (#472)
* Clean-up EntityManager a bit

- use tsl::robin_set instead of std::set (which should have been unordered::set
  anyways).

- getListeners() now returns a vector which avoids to traverse a set twice.
  Turns out that copying the set wasn't as efficient as I thought.

* Improve jobsystem a bit

We recently added a job reference counting mechanism, but we were a bit
too aggressive about taking/release references.

Also make the API more complete by adding explicit retain/release,
which is needed to allow several threads to wait on the same job.

Also improve futex code by inlining it.
2018-11-12 14:11:31 -08:00
Philip Rideout
3407302954 Minor suzanne cleanup. 2018-11-08 16:21:54 -08:00
Philip Rideout
f4806461ee Fix JavaScript leaks with BufferDescriptor.
Fixes #429
2018-11-08 16:17:29 -08:00
Philip Rideout
207d4ea4c1 Fix JS API leaks by auto-deleting builders, etc.
While this solves the builder leak, it does not solve the tiny leak
incurred every time you call `getInstance` on a component manager
without calling embind's `delete` method afterwards. Since there's no
way to auto-delete component instances, this CL fixes up our sample
code and docstrings.

Fixes #429
2018-11-08 16:17:29 -08:00
Mathias Agopian
f8f24f492f minor typo / spelling / clang-tidy fixes (#468)
* Minor clean-ups

- fix a couple usage of std::function
- fix a couple usage of std::string
- remove ALIGN_LOOP, which didn't work
- fix a couple explicit/noexcept
- virtual -> override

* Fix spelling typos and other minor clang-tidy
sceneform-1.6pr6
2018-11-08 11:50:00 -08:00
Philip Rideout
5fb0696fb7 Resurrect the JS memory leak test (#429) 2018-11-08 11:16:41 -08:00
Philip Rideout
75ffbe13be Fix typos. 2018-11-07 16:28:57 -08:00
Philip Rideout
bf77a33e1f Include filament-js README in npm package. 2018-11-07 16:14:39 -08:00
Philip Rideout
b9bfda5704 The JS API now supports compressed textures. 2018-11-07 16:12:55 -08:00
Philip Rideout
ee5b0268fd Introduce KtxUtility to make it easier to translate enum values. 2018-11-07 16:12:55 -08:00
Philip Rideout
5f05180d0f Update "Directory structure" in toplevel README.
I don't think it's useful to indent the entire tree, so this removes
the redundant root. More importantly, it adds the "web" folder. :)
2018-11-07 10:48:22 -08:00
Ben Doherty
cf7e49f96a Fix max anisotropy in Vulkan backend (#466) 2018-11-07 10:46:49 -08:00
Philip Rideout
a052d6cf49 Fix STREAM uniform buffers for web. v1.0.0 2018-11-06 13:50:49 -08:00
Mathias Agopian
591c9f2454 Fix a crasher when allocating the last Job
Instead of returning nullptr, the pool allocator returned an
invalid pointer.
2018-11-06 13:44:35 -08:00
Mathias Agopian
e580bfed56 Fix allocator test when --gtest_repeat is used 2018-11-06 13:21:33 -08:00
Mathias Agopian
e2896f4632 Set cache size to 64 bytes on all platforms
We used to assume 32-bytes cache lines when running on ARM 32-bit mode,
however, that was wrong because 32-bit mode doesn't change the cpu's
cache line. On all modern platforms we support, the cache line
is 64 bytes.

Set Job storage to 48 bytes on all platforms.
2018-11-06 13:21:09 -08:00
Philip Rideout
a33c64c736 Update version doc and package per code review. 2018-11-06 12:48:56 -08:00
Philip Rideout
7ea04957d2 Introduce versioning scheme and npm package definition. 2018-11-06 12:48:56 -08:00
Mathias Agopian
8c6cfdba67 Fix erroneous assert 2018-11-06 11:01:08 -08:00
Mathias Agopian
e5cfbeff4d Attempt to fix windows build
Align atomic HeadPtr to 64-bits.
2018-11-05 19:37:31 -08:00
Mathias Agopian
68c6afa72e Fix reuse after free and API inconsistency in job system (#446)
* Fix a reuse after free in the job system

Jobs were destroyed and recycled while still in use
by wait() or run(). To fix this we introduce reference-counting of
jobs.

Jobs start with a ref-count of 1, which is decremented when a job
naturally finishes. Additionally, all user-facing methods acquire
a reference for the duration of the call.

* Fix an API inconsistency with JobSystem

JobSystem's API lets the user create jobs but not destroy them.
Jobs are destroyed automatically, without a way for the caller to
know when that happens.

We now explicitly enforce that jobs are no longer valid when
wait() returns. Multiple concurrent wait() are allowed however.

This is enforced by clearing the job pointer upon returning
from JobSystem::wait(Job* job).

* Rename linked-list put/get to push/pop

* Better fix for Job use after free

There was still a race condition where a run()'ed
job could be destroyed before wait() was called,
wait would then use a destroyed object.

The available APIs now are:

run() - runs and destroys a job
runAndWait() - run, then waits for and destroys a job
runAndRetain() - runs and keep a reference to the job
wait() - waits and destroys a job

wait() can only be used with a job obtained with runAndRetain().

* Get rid of unused code

This version of parallel_for has use-after-free issues anyways,
since we changed the semantics of run/wait/etc...

* Fix decRef() memory order

decRef() must ensure that all access to the 
object have happened before destroying it.

* Fix memory order in atomic linked list's pop()

It needs acquire semantic, since we want to make
sure that no read/write are reordered before the
pop() -- which returns an object to the caller.

* Fix memory order on runningJobCount

we needed acquire semantic when about to destroy
the last job -- it's similar to decRef.

* Comment usages of std::memory_order_*

* Fix AtomicFreeList A-B-A bug

Turns out AtomicFreeList was not immune to the ABA bug. W're fixing
it here by using a 64-bits CAS, which is available on aarch64 and armv7.
2018-11-05 19:12:13 -08:00
Romain Guy
bb3e9a47e5 Update link to CIE colormetric tables
Fixes #452
2018-11-05 15:53:41 -08:00
Philip Rideout
8d410af4b3 JS API: prepare for compressed textures.
Note that we need to allow clients to find out if compressed textures
are supported BEFORE the engine is created, so that they can start
downloading the correct set of texture files. To allow this, we now
expose a getSupportedFormats function that creates a throw-away canvas
in order to query extensions (creating a temporary canvas is a technique
that we also used in the old PNG decoder that we removed in 7b36ed4)
2018-11-03 13:07:02 -07:00
Romain Guy
61112c02c1 Fix typo 2018-11-02 17:23:14 -07:00
Philip Rideout
816fb99b2f Repair WebGL, which does not support MapBufferRange. 2018-11-01 21:55:10 -07:00
Philip Rideout
9de7ffaf84 Fix typo in title tag for suzanne. 2018-11-01 17:11:58 -07:00
Philip Rideout
e3e16fe28b Remove defunct web/tests folder.
These are broken and no longer necessary now that we have web/samples.

Despite the name, these weren't real tests; they were ignored by CMake
and did not run in an automated manner. Going forward we need a better
solution for automated testing.
2018-11-01 17:05:30 -07:00
Philip Rideout
bb0c21b8ea Rename filamentjs to filament-js to follow convention. 2018-11-01 17:05:30 -07:00
Philip Rideout
c46ecc6e05 Port the Suzanne demo to JavaScript. 2018-11-01 17:05:30 -07:00
Philip Rideout
fffb2c8c97 Add samples to the new web directory. 2018-11-01 17:05:30 -07:00
Philip Rideout
a42dcd2291 JavaScript code re-org (#443)
This removes the old CPP-based web samples in favor of the new JS API.

The `web/samples` folder will be added in a subsequent commit.
2018-11-01 17:05:30 -07:00
Romain Guy
4e3a88bbab Cleanup and documentation (#445) 2018-11-01 16:36:52 -07:00
Mathias Agopian
02d45d464c Never use QCOM_tiled_rendering
It turns out that it degrades performance even in cases where we
thought it would help. It seems to always trigger a "glFlush"
and has a very large CPU overhead. It looks like
glInvalidateFramebuffer() does a better job.
2018-11-01 11:30:38 -07:00
Mathias Agopian
c758b53f00 Factor out the UBO uploading code
This is just so that in the future we could reuse that
code for other buffers as it's not specific to UBOs.
2018-11-01 11:30:38 -07:00
Mathias Agopian
4e3c2582e0 Rename loadFoo() to updateFoo() in the driverAPI
Now all buffer updating methods are called updateXXX().
2018-11-01 11:30:38 -07:00
Mathias Agopian
cc1ba4fac7 Reorder methods in OpenGLDriver to match declaration
This change just reorder the load/update buffer/textures
methods so they match the declaration in DriverAPI.inc,
and are grouped together.
2018-11-01 11:30:38 -07:00
Mathias Agopian
f52087ec1e Attempt to upload streaming ubo data more efficiently
IF an UBO is marked as STREAM, meaning that data will
change every frame and the buffer content is invalidated
as well, then we use map/unmap buffer in asynchronous
mode to copy the data into the buffer.

This assumes the buffer is sized to be significantly
larger than the average amount of data used every
frame.
2018-11-01 11:30:38 -07:00
Mathias Agopian
2ac04c27d8 Add support for ANDROID_get_frame_timestamps
We don't make use of it yet, though.
2018-11-01 11:30:38 -07:00
Mathias Agopian
211eddfbe0 Add a couple missing DEBUG_MARKER() calls
Also, store a couple useful glGet*()
2018-11-01 11:30:38 -07:00
Philip Rideout
522a8bedb8 Update filamentjs test runner. 2018-10-30 16:50:24 -07:00
Philip Rideout
8ad655766b JavaScript: concise setBuffer API 2018-10-29 18:09:45 -07:00
Philip Rideout
5da454f652 JavaScript: concise texture creation functions
This makes our createTexture* helpers more consistent with the
createMaterial helper, and extends the wrapped Engine class with new
methods.

Before, clients did something like this:

    const ao = Filament.createTextureFromPng(Filament.assets['foo.png'], engine);
    ...
    engine.destroyTexture(ao);

Now, they can do:

    const ao = engine.createTextureFromPng('foo.png');
    ...
    engine.destroyTexture(ao);

This is more symmetric and concise. In general the JS API now supports a
class of "buffer-like" objects which exploit dynamic typing in order to
accept any of the following: BufferDescriptor, asset string, or
Uint8Array.
2018-10-29 18:09:45 -07:00
Philip Rideout
0deafea0da Add requirements.txt for Python scripts. 2018-10-29 17:53:09 -07:00
Philip Rideout
69e379cf90 Test for JS leaks using emcc --memoryprofiler. 2018-10-29 17:53:09 -07:00
Philip Rideout
e8fddba494 New JS test for memory leaks.
This test recreates a renderable every few frames and dumps the heap
pointer to the console so we can check if it increases over time.

Also simplified the personal web server script so that it uses twisted
and avoid doing a chdir, seems to be more reliable this way.
2018-10-29 17:53:09 -07:00
Romain Guy
31b9801f17 Move textures to nodpi to avoid upscales (#437) 2018-10-29 17:40:34 -07:00
Philip Rideout
4860ff816f JavaScript PNG utility now has SRGB flag. 2018-10-29 17:38:02 -07:00