Commit Graph

710 Commits

Author SHA1 Message Date
Mathias Agopian
adbe3a75f2 don't use a deque for the frame history
deque is not worth it with few items.
2018-11-21 13:46:07 -08:00
Mathias Agopian
75aaa3d9ab don't use a deque for just a handful of elements
this eliminates a bunch of code
2018-11-21 13:46:07 -08:00
Mathias Agopian
265bae40db Improve/comment FrameSkipper
Try to make FrameSkipper a little less confusing.
2018-11-21 13:46:07 -08:00
Mathias Agopian
9e39004b1f Add wait_for and wait_until to our Condition implementation
We're using timed condition variable in one place, but the STL version
pulls in a lot of code because it does clock calculations in 
"long double" (!!!!). Since we already had an implementation
of condition_variable, we just add the timed version.
This saves several KiB of code.

Also don't use unique_lock() lock/unlock because it can throw exceptions.
2018-11-21 13:46:07 -08:00
Mathias Agopian
7b2a1b0018 Get rid of the memory pool for UniformBuffer
The Pool wasn't used much anymore, since we're explicitly copy
the data into the command stream. Moreover, it generated a lot of code
and in fact was probably less efficient than malloc itself -- 
I think this was a misguided optimization in the first place.
2018-11-21 13:46:07 -08:00
Mathias Agopian
1212728e45 get rid of std::string in OpenGLProgram
This was generating tons of code.
2018-11-21 13:46:07 -08:00
Mathias Agopian
815fb36b98 code size optimizations
- prevent unrolling of some loops. e.g. one loop generated more than
  1 KB of code!
2018-11-21 13:46:07 -08:00
Mathias Agopian
5bcc4cfff1 Improve the slow-path of creating a program
This removes a lot of heap allocations/deallocations, and reduces
code size. Most improvements come from using CString and
StaticString instead of std::string and better using move
semantics.
2018-11-21 13:46:07 -08:00
Mathias Agopian
c1a7164084 Improve usage of CString
This cuts down 7 calls to free() to 1, when
instantiating a new program. There are still many low-hanging fruits
there.
2018-11-21 13:46:07 -08:00
Mathias Agopian
9bb87b8725 minor reorganizing of the command loop 2018-11-21 13:46:07 -08:00
Philip Rideout
454c102e3c Remove non-existing option from build help. 2018-11-21 12:12:37 -08:00
Philip Rideout
ee26f58dcf Improve error reporting for ShaderModel mismatch.
Aaron pointed out that this error is easy to run into and quite cryptic
since one value is decimal and the other is hex. Users might not be
aware that one of them is a bitmask, and that this is related to how
they invoke matc or filamat.
2018-11-21 12:12:37 -08:00
prideout
776284b2b5 Raise sampler limit to 16.
In practice this limits materials to 10 samplers since Filament uses 5
for lights and skips 1 slot for the post-process sampler. This can
probably be optimized.
2018-11-20 16:05:16 -08:00
Ben Doherty
86fb7b4524 Compile filamat and dependencies for all platforms (#506)
* Compile filamat and dependencies for all platforms

* Describe changes made to CMakeLists
2018-11-20 15:31:16 -08:00
prideout
cfa9895b96 Improve error reporting for bindings overflow.
We now check for sampler overflow during material compilation rather
than waiting for run-time checks. This allows for Kokoro-based
validation of sample materials, and allows developers to catch this
issue in their asset pipeline.

We should also probably raise the upper limit (Qualcomm allows up to 16
samplers in their Vulkan implementation) but that can be a separate PR.

Fixes #507
2018-11-20 15:28:02 -08:00
Ben Doherty
b5fa822e86 Move GLSLPostProcessor and dependencies into filamat (#500)
* Move GLSLPostProcessor into filamat
2018-11-20 12:30:26 -08:00
Philip Rideout
aa0090a85b Fix build warnings. 2018-11-19 15:59:31 -08:00
Philip Rideout
0d476b9f6d Fix debug builds. 2018-11-19 15:45:40 -08:00
prideout
694eab703c Remove usage of std::string in VulkanDriver. 2018-11-19 14:18:39 -08:00
Philip Rideout
b3dce967eb Rollback MeshAssimp enhancements.
This caused regressions with some of our samples like vk_hellopbr:

- For the new 1x1 textures, RGB isn't accepted by Vulkan and Metal.
  Currently these platforms require RGBA, although we plan on adding
  reshaping functionality for the future.
- Too many texture samplers in a single shader, this causes a run time
  error. This could be alleviated by creating an atlas.
- vk_hellopbr assumes that all materials have a "metallic" param.

Going forward, we plan on creating a new library that avoids MeshAssimp,
so for now let's just disable gltf_viewer.
2018-11-19 14:18:12 -08:00
Philip Rideout
1413b4d622 Fix path in vk_texturedquad 2018-11-19 14:17:13 -08:00
magicwhale
fc0d587b40 Added support for more features in gltf_viewer sample 2018-11-19 09:27:08 -08:00
magicwhale
1d392d38bd updated assimp 2018-11-19 09:27:08 -08:00
magicwhale
bc38c8a773 Edited MeshAssimp and added gltf_viewer sample code 2018-11-19 09:27:08 -08:00
Philip Rideout
84d2fb222b Flesh out JS bindings a bit. 2018-11-16 17:21:44 -08:00
Philip Rideout
1ed8618cca Refresh website to publish new tutorial. 2018-11-16 17:21:18 -08:00
Philip Rideout
edb545919a Fix regression with non-Vulkan backends.
This fixes the "shader is not ASCII" error seen with GL backend,
introduced when we changed blob ownership semantics to accommodate
shader compression. It was due to missing null terminators.

We actually never bothered including the trailing null in blob length,
which was wrong but happened to work because the BlobDictionary held a
weak reference to chunk data. SInce it now holds an actual copy, the
lack of null caused our strings to contain garbage memory.
2018-11-16 15:43:41 -08:00
Philip Rideout
e652507315 Tutorial fixups per code review feedback. 2018-11-16 14:09:41 -08:00
Philip Rideout
ffff8437ba Add tutorial that describes compression and async loading. 2018-11-16 14:09:41 -08:00
Philip Rideout
b2a2da532a Fix Android-with-Vulkan build. 2018-11-16 12:07:23 -08:00
Philip Rideout
e3a20e0dfe Fix Linux build failure. 2018-11-16 12:07:23 -08:00
Philip Rideout
2d0b2050fc Fix iOS build failure. 2018-11-16 12:07:23 -08:00
Philip Rideout
b83c82ea9b Enable SMOLV compression. 2018-11-16 12:07:23 -08:00
Romain Guy
0938051579 Fix docs 2018-11-15 16:57:16 -08:00
Philip Rideout
e0fd196530 Exclude SMOL from Vulkan-free builds. 2018-11-15 16:55:40 -08:00
Philip Rideout
55eaad9450 Add smol-v to third_party.
Since we use this for decoding, this adds a dependency to the core
filament renderer which in practice is only used for Vulkan. However
this is a tiny library, so it's simplest just to always include it.

The next PR will add the actual compression / decompression code to
filaflat and filamat. Here are the preliminary results.

   102K =>  29K  aiDefaultMat.filamat
   102K =>  29K  aiDefaultTrans.filamat
    21K => 5.0K  bakedColor.filamat
    22K => 5.2K  bakedTexture.filamat
    21K => 5.0K  depthVisualizer.filamat
    40K =>  10K  groundShadow.filamat
   102K =>  29K  sandboxCloth.filamat
   125K =>  36K  sandboxLit.filamat
   126K =>  36K  sandboxLitFade.filamat
   126K =>  36K  sandboxLitTransparent.filamat
   109K =>  31K  sandboxSubsurface.filamat
    21K => 4.9K  sandboxUnlit.filamat
    21K => 4.9K  transparentColor.filamat

Both the "before" and "after" numbers are excluding non-Vulkan targets,
and I also changed our CMakeLists to build filamat instead of inc.
2018-11-15 16:55:40 -08:00
Philip Rideout
d94a1610a5 Fix minor Vulkan warning. 2018-11-15 14:49:17 -08:00
Philip Rideout
307645c7ce Add Vulkan support for depth offset and face culling. 2018-11-15 08:29:29 -08:00
Philip Rideout
a5cdb89107 Handle Vulkan ClipSpace in GLSL rather than C++.
Recall that Vulkan has a right-handed NDC system. Currently, our Vulkan
backend is not handling VERTEX_DOMAIN_DEVICE correctly, but we didn't
notice because the culling mode is not honored yet (a separate PR is on
the way for that).

To fix this, we considered adding a shader-based fixup only for the
device domain and keeping our Vulkanish projection matrix as-is.
However, this would cause the skybox shader to compute an incorrect
wrong eye vector due to in the inconsistent definition of clip space.

After discussion with Mathias and Ben, we decided that the most elegant
fix is for Filament to have only one canonical clip space, which for
now is the clip space that OpenGL requires.

Ben pointed out that spirv-cross has a flag for injecting shader-based
fixups. However we don't invoke spirv-cross for the Vulkan target, and
it's easy just to do this on our own.
2018-11-15 08:08:16 -08:00
Romain Guy
f1c2c39a3d Cleanup matc a little bit (#488) 2018-11-14 11:58:06 -08:00
Vallentin
81e8035cbb Fixed typos (#487) 2018-11-14 09:19:04 -08:00
Mathias Agopian
870d15b9ab Add MaterialInstance::setPolygonOffset()
The polygon offset can now be set through MaterialInstance. 
USE WITH CAUTION, this impacts performance negatively.
2018-11-13 19:27:52 -08:00
Mathias Agopian
87d66b41d5 Add polygon offset to the driver API 2018-11-13 19:27:52 -08:00
Mathias Agopian
825a72df10 The driver Draw() command now takes a PipelineState
PipelineState contains the program and raster state, more
state might be added in the future. Currently it is passed by value
and doesn't have a HwHandle, but this may change in the future.
2018-11-13 19:27:52 -08:00
Ben Doherty
74573c7ce4 Fix undefined symbols issue with web builds (#482) 2018-11-13 18:11:03 -08:00
Philip Rideout
17003106d2 Prep for new JavaScript tutorial.
This adds a few new functions to the JavaScript bindings. It also adds
our JavaScript docs into the CMake build system for machines that meet
the Python requirements.
2018-11-13 17:27:34 -08:00
Mathias Agopian
f011a212bd Minor clean-ups of Program 2018-11-13 16:02:44 -08:00
Philip Rideout
73a2ef7944 Add favicon. 2018-11-13 12:07:57 -08:00
Philip Rideout
7c2c4f3b11 Fix parquet wrap mode. 2018-11-13 12:07:47 -08:00
Philip Rideout
0faf7bbcb6 Publish Hugo site and web tutorials.
This performs the steps described in site/README in order to publish
the Hugo site to GitHub Pages:

    https://google.github.io/filament
2018-11-13 11:24:41 -08:00