Commit Graph

6322 Commits

Author SHA1 Message Date
Powei Feng
bf8bcef35c Add option to define a backend debug flag (#7798)
To allow easy enabling/disabling of debug options like vulkan
validation, android systrace, debug printing, and others, we
introduce an option to add a preprocessor flag so that a
backend can (optionally) use it to manage debug options.
2024-04-25 23:42:55 +00:00
Eliza Velasquez
bfab9f9c32 engine: Add isPaused() 2024-04-25 16:11:14 -07:00
Powei Feng
c8335fade7 vk: Fix unsupported depth blitting (#7789)
* vk: Fix unsupported depth blitting

On certain hardware (pixel 4 for example), blitting of depth texture
is not supported as an "optimalTilingFeature".  In these cases, we'd
would need to do a shader-based blit. We
 - Add the shader blit in PostProcessingManager
 - Add a driver API to check for support for blitting depthStencil
   attachments.
 - Fix some debugging ifdefs in vk backend.

The validation fixed is:
`[ VUID-vkCmdBlitImage-dstImage-02000 ] Object 0: handle = 0xb400007c300701d0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xf2039b0000000771, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x86bc2a78 | In vkCmdBlitImage, VkFormatFeatureFlags (0x1c601) does not support required feature VK_FORMAT_FEATURE_2_BLIT_DST_BIT for format 126 used by VkImage 0xf2039b0000000771[] with tiling VK_IMAGE_TILING_OPTIMAL. The Vulkan spec states: The format features of dstImage must contain VK_FORMAT_FEATURE_BLIT_DST_BIT`
2024-04-24 18:27:57 +00:00
Mathias Agopian
99eac62b4e give proper move semantics to Handle<> 2024-04-23 15:38:29 -07:00
Mathias Agopian
6146d071ba StructureOfArray::push_back(&&) didn't do a move 2024-04-23 15:38:29 -07:00
Mathias Agopian
d26c972f5b add missing includes in RenerableManager 2024-04-23 15:38:29 -07:00
Mathias Agopian
93dc218b83 fix PerShadowMapUniform includes 2024-04-23 15:38:29 -07:00
Ben Doherty
b56379dc0f Add license information to matedit (#7790) 2024-04-23 14:05:53 -06:00
Mathias Agopian
e4442a5eb2 optimize the inner rendering loop
This largely undoes a change I did recently where PrimitiveInfo has
a FRenderPrimitive* to save some space and keep a command at 64 bytes.

This wasn't a good idea because the inner rendering loop shouldn't 
to any dereference in the common case.

This change reorganises PrimitiveInfo such that it stores all the data
necessary to render a primitive in the common case. The less common
cases are when hybrid instancing, morphing or skinning are used; in 
those cases, a dereference into the renderable SOA is needed.

PrimitiveInfo currently has 16 bytes free, which we keep for futur use.
2024-04-23 10:22:33 -07:00
Ben Doherty
490e8cf0d0 Add option to preserve text shaders (#7786) 2024-04-23 10:38:23 -06:00
Mathias Agopian
0d25f79421 gl: simplify how we track bound textures
In opengl it's possible to bind several textures to the same texture
unit as long as they're a different target. Until now we were tracking
that state. In practice it's not very useful to bind several textures
to the same unit (it is a little bit when updating texture data, but
not when rendering). With the coming change to a descriptor set API, it
is better to have a 1-to-1 mapping between bound textures and texture
units.

So with this change, only a single texture can be bound to a texture 
unit. If another texture in bound to the same unit with a different
target, we first unbind the texture from the current target.

There is less state to track, and it allows us to 
"unbind a texture unit" (whereas before we'd have to iterate through 
all the possible targets for that unit and unbind all of them).
2024-04-22 16:03:24 -07:00
Mathias Agopian
d0586743f6 add ADPF support for backend thread 2024-04-22 15:09:08 -07:00
Mathias Agopian
14a99cbc63 add the target refresh interval to the backend beginFrame 2024-04-22 15:09:08 -07:00
Benjamin Doherty
808b51c1cf matedit: fix use-after-free 2024-04-22 16:06:39 -06:00
Sungun Park
315726678e Release Filament 1.51.5 2024-04-22 20:47:55 +00:00
Ben Doherty
bac8e58ee7 Support backends with multiple shader languages and precompiled Metal libraries (#7769) 2024-04-21 21:59:22 -04:00
Mathias Agopian
ec31a516f7 don't rely on FMaterialInstance having a default ctor (#7781)
* don't rely on FMaterialInstance having a default ctor

FMaterialInstance needed a default ctor because it is a field of
FMaterial but cannot be initialized before FMaterial itself is
initialized. So we had a defautl ctor and we'd finish the initialization
later. Conceptually the default material instance should have been 
new'ed and a pointer to it stored instead. 

That's basically what we do now, but to avoid the extra allocation,
we in-place new and delete the default material instance into an
aligned_storage inside FMaterial.

* Update filament/src/details/Material.h

Co-authored-by: Ben Doherty <bendoherty@google.com>

---------

Co-authored-by: Ben Doherty <bendoherty@google.com>
2024-04-19 21:38:30 +00:00
Mathias Agopian
7a3b762b53 cleanup details/Material.h
Should Fix #7774
2024-04-19 12:08:03 -07:00
Eliza Velasquez
67268cb76d filagui: Use material constants in uiBlit 2024-04-18 13:46:46 -07:00
Eliza Velasquez
0b34dc6608 filagui: Add support for external textures
We have an instance of a client trying to render a GL_TEXTURE_EXTERNAL_OES
texture with filagui, which currently fails.
2024-04-18 13:46:46 -07:00
Ben Doherty
afe292986e Introduce new matedit tool (#7759) 2024-04-18 12:18:29 -04:00
Mathias Agopian
83acf0f9de fix hello triangle build 2024-04-18 00:38:26 -07:00
Mathias Agopian
69d9c8b72c fix a GL backend crash when shutting down
the gl backend did some of its cleanup in the its destructor,
including calling into OpenGL, however, the destructor is called from
the main thread, not the GL thread, so these calls would be no-ops at
best, and crashes in the worst case.
2024-04-16 15:08:45 -07:00
Mathias Agopian
3bffd90357 don't crash if we don't have a Camera set on View (#7766)
* don't crash if we don't have a Camera set on View

- also add a method to query if a camera was set

* Update android/filament-android/src/main/java/com/google/android/filament/View.java

Co-authored-by: Powei Feng <powei@google.com>

---------

Co-authored-by: Powei Feng <powei@google.com>
2024-04-16 21:09:21 +00:00
Mathias Agopian
b21dfd5ea2 add a couple way of validating MaterialInstances (#7754)
* add a couple way of validating MaterialInstances

BUGS=[333907416]

* Update filament/include/filament/Engine.h

Co-authored-by: Powei Feng <powei@google.com>

* Update filament/include/filament/Engine.h

Co-authored-by: Powei Feng <powei@google.com>

---------

Co-authored-by: Powei Feng <powei@google.com>
2024-04-16 12:12:20 -07:00
Mathias Agopian
8af2d7512d cleanup and small improvements to JobSystem
- add missing includes
- wake-up one or several threads based on the number of jobs available
2024-04-16 12:11:15 -07:00
Mathias Agopian
785592293c don't use thread affinity for the thread-pool
using thread affinity naively on big.little architectures is very flaky,
for now it's better to simplify and not use it at all, let the kernel
figure things out.

BUGS=[333582569]
2024-04-16 12:11:15 -07:00
Maximilien Dagois
613b1fc246 Fixed a comment 2024-04-16 12:10:49 -07:00
Powei Feng
c8098a4c15 gltfio: add Asset/Resource extended implementations (#7678)
* gltfio: add Asset/Resource extended implementations

 - Add gltfio/src/extended to implement an alternate loader for
   primitives. This is largely based on the implementation in
   AssetLoader/ResourceLoader
 - Able to correctly produce flat shading from gltf that only have
   vertex positions and indices.
 - This is not hooked into current code and should have no
   practical effect on gltfio.
2024-04-16 17:46:48 +00:00
Powei Feng
d8eee061e8 vk: Fix clang-18 compiler warning (#7764)
Fixes #7762
2024-04-16 17:14:57 +00:00
Powei Feng
0ebe888344 Fix broken dynamic resolution (#7763)
Previous PR #7758 accidentally removed the setting of 'resolution'
for shaders other than 'blitLow'.  This PR undoes that.
2024-04-16 09:52:43 -07:00
Powei Feng
c20496a461 Remove unused parameter in blitLow (#7758) 2024-04-15 16:19:54 -07:00
tomnomgoogleuk
8955a61df3 Set VkApplicationInfo.pEngineName to Filament (#7756)
Setting the pEngineName helps with the collection of metrics and is generally good practice.
2024-04-15 19:42:36 +00:00
Powei Feng
9e0e3262c3 Release Filament 1.51.4 2024-04-15 11:05:12 -07:00
Mathias Agopian
d3d5281488 cleanup the Material constructor
We move some large blocks of code out of line.
2024-04-15 10:27:07 -07:00
Mathias Agopian
075f3d0869 fix another ibl-prefilter bug introduced recently
The top and bottom faces were swapped in the reflection map.

FIXES=[333421281]
2024-04-15 10:25:52 -07:00
Mathias Agopian
3ca9b9cd0f don't use thread affinity for the backend thread
Originally we did this because we wanted to run on a big core on 
android. However setting the thread affinity in this way is fragile,
we are not guaranteed to be on a big core, and we don't even know
if some thread is pinned to that core already; which was the case
with some GL drivers. This can also cause scheduling problems with
other threads.

We just remove this logic entirely for now, and we'll figure out 
something better later to run on a big core.

Fixes #7748
BUGS=[333949404]
2024-04-12 15:55:56 -07:00
Mathias Agopian
eb33ce35ef make the Systrace class public
BUGS=[331834298]
2024-04-12 14:44:48 -07:00
Ben Doherty
cddd22da28 Introduce a new precompiled Metal material chunk type (#7749)
This change introduces a new chunk type to material files for precompiled Metal libraries. Previously, SPIR-V was the only binary type, so there's also a couple of refactor commits present here. Nothing is changed in Filament or matc yet.

BUGS=[333547148]
2024-04-12 00:42:10 -04:00
Powei Feng
05ce5ead8d vk: Use new descriptor set caching (#7735)
- Use new descriptor set and layout caching
 - Remove descriptor set related code in VulkanPipelineCache
 -  fix leaks for descriptor sets/layouts

FIXES=248594812,325157400
2024-04-09 23:29:27 +00:00
Sungun Park
4bed88289f Release Filament 1.51.3 2024-04-08 20:49:02 +00:00
Ben Doherty
7a6138597e Metal re-apply: throw an NSException when attempting to draw with invalid program (#7741) 2024-04-05 17:50:07 -07:00
Ben Doherty
28da328815 Export utils::panic function (#7740) 2024-04-05 17:49:56 -07:00
Mathias Agopian
de3c4b6d56 fix a possible leak when editing a material with matdbg
A MaterialParser could be leaked if several edits happened before they
were latched -- this was because the MaterialParser was stored as
a raw pointer instead of a unique_ptr<>, this was done as an attempt
to avoid to use a lock around accessing mPendingEdits.
2024-04-04 10:15:43 -07:00
Mathias Agopian
5d27240e0c clean-up lifetime of MaterialParser 2024-04-04 10:15:43 -07:00
Mathias Agopian
94fc37b8c2 fix missing headers 2024-04-04 10:15:43 -07:00
Powei Feng
532cb28ce9 vk: Introduce caches for descriptor sets/layouts (#7731)
Added
 - Cache for layouts
 - Pools for descriptor sets
 - Cache for descriptor set updates
 - Cache for pipeline layouts

Does not have effect on implementation.
2024-04-03 17:51:42 +00:00
Mathias Agopian
b30d12aca5 split GLTexture and GLBufferObject to their own file 2024-04-02 23:34:30 -07:00
Mathias Agopian
d891a6927f program is now 48 bytes instead of 56 2024-04-02 23:34:30 -07:00
Mathias Agopian
22b5715837 move mSamplerMap and ES2's mUniformBindings to OpenGLContext 2024-04-02 23:34:30 -07:00