Skip to content

Commit 4c8b73e

Browse files
committed
Merge branch 'main' into external_sampler_research_2
2 parents 503a791 + ba99844 commit 4c8b73e

File tree

35,369 files changed

+9216090
-65500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

35,369 files changed

+9216090
-65500
lines changed

CMakeLists.txt

+37-20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ option(FILAMENT_ENABLE_MULTIVIEW "Enable multiview for Filament" OFF)
4747

4848
option(FILAMENT_SUPPORTS_OSMESA "Enable OSMesa (headless GL context) for Filament" OFF)
4949

50+
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
51+
5052
set(FILAMENT_NDK_VERSION "" CACHE STRING
5153
"Android NDK version or version prefix to be used when building for Android."
5254
)
@@ -517,6 +519,11 @@ if (FILAMENT_SUPPORTS_VULKAN)
517519
add_definitions(-DFILAMENT_DRIVER_SUPPORTS_VULKAN)
518520
endif()
519521

522+
if (FILAMENT_SUPPORTS_WEBGPU)
523+
message(AUTHOR_WARNING "WebGPU is in development stage and broken at this stage. Its support is very limited.")
524+
add_definitions(-DFILAMENT_SUPPORTS_WEBGPU)
525+
endif()
526+
520527
# Build with Metal support on non-WebGL Apple platforms.
521528
if (APPLE AND NOT WEBGL)
522529
option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" ON)
@@ -528,20 +535,17 @@ if (FILAMENT_SUPPORTS_METAL)
528535
endif()
529536

530537
# Building filamat increases build times and isn't required for web, so turn it off by default.
531-
if (NOT WEBGL)
538+
if (NOT WEBGL AND NOT IOS)
532539
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" ON)
533540
else()
534541
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" OFF)
535542
endif()
536543

537-
# By default, link in matdbg/fgviewer for Desktop + Debug only since it pulls in filamat and a web server.
544+
# By default, link in matdbg for Desktop + Debug only since it pulls in filamat and a web server.
538545
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND IS_HOST_PLATFORM)
539546
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" ON)
540-
# TODO: Uncomment below when fgviewer is ready
541-
# option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" ON)
542547
else()
543548
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" OFF)
544-
option(FILAMENT_ENABLE_FGVIEWER "Enable the frame graph viewer" OFF)
545549
endif()
546550

547551
# Only optimize materials in Release mode (so error message lines match the source code)
@@ -667,10 +671,6 @@ function(list_licenses OUTPUT MODULES)
667671
endfunction()
668672

669673
set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/linux/combine-static-libs.sh")
670-
if (WIN32)
671-
set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/windows/combine-static-libs.bat")
672-
set(CMAKE_AR "lib.exe")
673-
endif()
674674

675675
# Add a custom command to TARGET that combines the static libraries in DEPS into a single archive.
676676
function(combine_static_libs TARGET OUTPUT DEPS)
@@ -685,12 +685,22 @@ function(combine_static_libs TARGET OUTPUT DEPS)
685685
endif()
686686
endforeach()
687687

688-
add_custom_command(
689-
TARGET ${TARGET} POST_BUILD
690-
COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${OUTPUT}" ${DEPS_FILES}
691-
COMMENT "Combining ${target} dependencies into single shared library"
692-
VERBATIM
693-
)
688+
if (WIN32)
689+
add_custom_command(
690+
TARGET ${TARGET} POST_BUILD
691+
COMMAND lib.exe /nologo /out:temp.lib ${DEPS_FILES}
692+
COMMAND "${CMAKE_COMMAND}" -E rename temp.lib ${OUTPUT}
693+
COMMENT "Combining ${target} dependencies into single shared library"
694+
VERBATIM
695+
)
696+
else()
697+
add_custom_command(
698+
TARGET ${TARGET} POST_BUILD
699+
COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${OUTPUT}" ${DEPS_FILES}
700+
COMMENT "Combining ${target} dependencies into single shared library"
701+
VERBATIM
702+
)
703+
endif()
694704
endfunction()
695705

696706
# ==================================================================================================
@@ -759,8 +769,8 @@ add_subdirectory(${LIBRARIES}/mathio)
759769
add_subdirectory(${LIBRARIES}/uberz)
760770
add_subdirectory(${LIBRARIES}/utils)
761771
add_subdirectory(${LIBRARIES}/viewer)
762-
add_subdirectory(${FILAMENT}/filament)
763772
add_subdirectory(${FILAMENT}/shaders)
773+
add_subdirectory(${EXTERNAL}/abseil/tnt)
764774
add_subdirectory(${EXTERNAL}/basisu/tnt)
765775
add_subdirectory(${EXTERNAL}/civetweb/tnt)
766776
add_subdirectory(${EXTERNAL}/imgui/tnt)
@@ -781,6 +791,7 @@ add_subdirectory(${LIBRARIES}/geometry)
781791
if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
782792
# spirv-tools must come before filamat, as filamat relies on the presence of the
783793
# spirv-tools_SOURCE_DIR variable.
794+
set(SPIRV-Headers_SOURCE_DIR ${EXTERNAL}/spirv-headers)
784795
add_subdirectory(${EXTERNAL}/spirv-tools)
785796
add_subdirectory(${EXTERNAL}/glslang/tnt)
786797
add_subdirectory(${EXTERNAL}/spirv-cross/tnt)
@@ -790,11 +801,10 @@ if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
790801
if (FILAMENT_ENABLE_MATDBG OR IS_HOST_PLATFORM)
791802
add_subdirectory(${LIBRARIES}/matdbg)
792803
endif()
804+
endif()
793805

794-
# TODO: Uncomment below when fgviewer is ready
795-
# if (FILAMENT_ENABLE_FGVIEWER OR IS_HOST_PLATFORM)
796-
# add_subdirectory(${LIBRARIES}/fgviewer)
797-
# endif()
806+
if (FILAMENT_ENABLE_FGVIEWER)
807+
add_subdirectory(${LIBRARIES}/fgviewer)
798808
endif()
799809

800810
if (FILAMENT_SUPPORTS_VULKAN)
@@ -804,6 +814,13 @@ if (FILAMENT_SUPPORTS_VULKAN)
804814
add_subdirectory(${EXTERNAL}/spirv-headers)
805815
endif()
806816

817+
if (FILAMENT_SUPPORTS_WEBGPU)
818+
add_subdirectory(${EXTERNAL}/dawn/tnt/)
819+
endif()
820+
821+
# Add filament after dawn, since filament/backend depends on dawn targets.
822+
add_subdirectory(${FILAMENT}/filament)
823+
807824
set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples)
808825

809826
if (WEBGL)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repositories {
3131
}
3232
3333
dependencies {
34-
implementation 'com.google.android.filament:filament-android:1.56.7'
34+
implementation 'com.google.android.filament:filament-android:1.57.2'
3535
}
3636
```
3737

@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
5151
iOS projects can use CocoaPods to install the latest release:
5252

5353
```shell
54-
pod 'Filament', '~> 1.56.7'
54+
pod 'Filament', '~> 1.57.2'
5555
```
5656

5757
## Documentation

RELEASE_NOTES.md

+16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ A new header is inserted each time a *tag* is created.
77
Instead, if you are authoring a PR for the main branch, add your release note to
88
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
99

10+
## v1.57.3
11+
12+
- android: breaking changes to API KTX1Loader::createIndirectLight and KTX1Loader::createSkybox
13+
14+
## v1.57.2
15+
16+
- Support including PlatformMetal.h in C++ files.
17+
18+
## v1.57.1
19+
20+
21+
## v1.57.0
22+
23+
- matdbg: Add support for debugging ESSL 1.0 shaders
24+
- backend: New platform API to better handle external textures [⚠️ **New Material Version**]
25+
1026
## v1.56.8
1127

1228

android/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// com.google.android.filament.exclude-vulkan
1212
// When set, support for Vulkan will be excluded.
1313
//
14+
// com.google.android.filament.include-webgpu
15+
// When set, enables WebGPU support.
16+
//
1417
// com.google.android.filament.fgviewer
1518
// When set, enables fgviewer
1619
//
@@ -64,6 +67,10 @@ buildscript {
6467
.gradleProperty("com.google.android.filament.exclude-vulkan")
6568
.isPresent()
6669

70+
def includeWebGPU = providers
71+
.gradleProperty("com.google.android.filament.include-webgpu")
72+
.isPresent()
73+
6774
// TODO: Uncomment below when fgviewer is ready
6875
// def fgviewer = providers
6976
// .gradleProperty("com.google.android.filament.fgviewer")
@@ -123,6 +130,7 @@ buildscript {
123130
"-DANDROID_STL=c++_static",
124131
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
125132
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString(),
133+
"-DFILAMENT_SUPPORTS_WEBGPU=${includeWebGPU ? 'ON' : 'OFF'}".toString(),
126134
// TODO: Uncomment below when fgviewer is ready
127135
// "-DFILAMENT_ENABLE_FGVIEWER=${fgviewer ? 'ON' : 'OFF'}".toString(),
128136
"-DFILAMENT_ENABLE_MATDBG=${matdbg ? 'ON' : 'OFF'}".toString(),

android/filamat-android/src/main/java/com/google/android/filament/filamat/MaterialBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ public enum TargetApi {
192192
OPENGL (0x1),
193193
VULKAN (0x2),
194194
METAL (0x4),
195-
ALL (0x7);
195+
WEBGPU (0x8),
196+
ALL (0x15);
196197

197198
final int number;
198199

android/filament-android/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ option(FILAMENT_SUPPORTS_VULKAN "Enables Vulkan on Android" OFF)
66
# option(FILAMENT_ENABLE_FGVIEWER "Enables Frame Graph Viewer" OFF)
77
option(FILAMENT_ENABLE_MATDBG "Enables Material debugger" OFF)
88
option(FILAMENT_DISABLE_MATOPT "Disables material optimizations" OFF)
9+
option(FILAMENT_SUPPORTS_WEBGPU "Enables WebGPU on Android" OFF)
910

1011
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
1112

@@ -49,6 +50,12 @@ add_library(vkshaders STATIC IMPORTED)
4950
set_target_properties(vkshaders PROPERTIES IMPORTED_LOCATION
5051
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libvkshaders.a)
5152

53+
if (FILAMENT_SUPPORTS_WEBGPU)
54+
add_library(webgpu_dawn STATIC IMPORTED)
55+
set_target_properties(webgpu_dawn PROPERTIES IMPORTED_LOCATION
56+
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libwebgpu_dawn.a)
57+
endif()
58+
5259
add_library(smol-v STATIC IMPORTED)
5360
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
5461
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
@@ -132,6 +139,7 @@ target_link_libraries(filament-jni
132139
$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:filamat>
133140
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:bluevk>
134141
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:vkshaders>
142+
$<$<STREQUAL:${FILAMENT_SUPPORTS_WEBGPU},ON>:webgpu_dawn>
135143
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:smol-v>
136144
)
137145

android/filament-android/src/main/cpp/MaterialInstance.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,18 @@ Java_com_google_android_filament_MaterialInstance_nSetCullingMode(JNIEnv*,
329329
instance->setCullingMode((MaterialInstance::CullingMode) cullingMode);
330330
}
331331

332+
333+
extern "C"
334+
JNIEXPORT void JNICALL
335+
Java_com_google_android_filament_MaterialInstance_nSetCullingModeSeparate(JNIEnv*, jclass,
336+
jlong nativeMaterialInstance,
337+
jlong colorPassCullingMode, jlong shadowPassCullingMode) {
338+
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
339+
instance->setCullingMode(
340+
(MaterialInstance::CullingMode) colorPassCullingMode,
341+
(MaterialInstance::CullingMode) shadowPassCullingMode);
342+
}
343+
332344
extern "C"
333345
JNIEXPORT void JNICALL
334346
Java_com_google_android_filament_MaterialInstance_nSetColorWrite(JNIEnv*,
@@ -505,6 +517,14 @@ Java_com_google_android_filament_MaterialInstance_nGetCullingMode(JNIEnv* env, j
505517
return (jint)instance->getCullingMode();
506518
}
507519

520+
extern "C"
521+
JNIEXPORT jint JNICALL
522+
Java_com_google_android_filament_MaterialInstance_nGetShadowCullingMode(JNIEnv* env, jclass,
523+
jlong nativeMaterialInstance) {
524+
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
525+
return (jint)instance->getShadowCullingMode();
526+
}
527+
508528
extern "C"
509529
JNIEXPORT jboolean JNICALL
510530
Java_com_google_android_filament_MaterialInstance_nIsColorWriteEnabled(JNIEnv* env, jclass clazz,

android/filament-android/src/main/cpp/Texture.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,31 @@ Java_com_google_android_filament_Texture_nIsTextureFormatSupported(JNIEnv*, jcla
5353
(Texture::InternalFormat) internalFormat);
5454
}
5555

56+
extern "C" JNIEXPORT jboolean JNICALL
57+
Java_com_google_android_filament_Texture_nIsTextureFormatMipmappable(JNIEnv*, jclass,
58+
jlong nativeEngine, jint internalFormat) {
59+
Engine *engine = (Engine *) nativeEngine;
60+
return (jboolean) Texture::isTextureFormatMipmappable(*engine,
61+
(Texture::InternalFormat) internalFormat);
62+
}
63+
5664
extern "C" JNIEXPORT jboolean JNICALL
5765
Java_com_google_android_filament_Texture_nIsTextureSwizzleSupported(JNIEnv*, jclass,
5866
jlong nativeEngine) {
5967
Engine *engine = (Engine *) nativeEngine;
6068
return (jboolean) Texture::isTextureSwizzleSupported(*engine);
6169
}
6270

71+
extern "C" JNIEXPORT jboolean JNICALL
72+
Java_com_google_android_filament_Texture_nValidatePixelFormatAndType(JNIEnv*, jclass,
73+
jint internalFormat, jint pixelDataFormat, jint pixelDataType) {
74+
return (jboolean) Texture::validatePixelFormatAndType(
75+
(Texture::InternalFormat) internalFormat,
76+
(Texture::Format) pixelDataFormat,
77+
(Texture::Type) pixelDataType
78+
);
79+
}
80+
6381
// Texture::Builder...
6482

6583
extern "C" JNIEXPORT jlong JNICALL

android/filament-android/src/main/java/com/google/android/filament/Engine.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ public enum Backend {
138138
* Selects the Metal driver if the platform supports it.
139139
*/
140140
METAL,
141+
/**
142+
* Select the WebGPU driver if platform supports it.
143+
*/
144+
WEBGPU,
141145
/**
142146
* Selects the no-op driver for testing purposes.
143147
*/
@@ -1271,7 +1275,7 @@ public EntityManager getEntityManager() {
12711275
* {@link android.view.SurfaceHolder.Callback#surfaceDestroyed surfaceDestroyed}.</p>
12721276
*/
12731277
public void flushAndWait() {
1274-
flushAndWait(Fence.WAIT_FOR_EVER);
1278+
boolean unused = flushAndWait(Fence.WAIT_FOR_EVER);
12751279
}
12761280

12771281
/**

android/filament-android/src/main/java/com/google/android/filament/MaterialInstance.java

+25
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,20 @@ public void setCullingMode(@NonNull Material.CullingMode mode) {
556556
nSetCullingMode(getNativeObject(), mode.ordinal());
557557
}
558558

559+
/**
560+
* Overrides the default triangle culling state that was set on the material separately for the
561+
* color and shadow passes
562+
*
563+
* @see
564+
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:culling">
565+
* Rasterization: culling</a>
566+
*/
567+
public void setCullingMode(@NonNull Material.CullingMode colorPassCullingMode,
568+
@NonNull Material.CullingMode shadowPassCullingMode) {
569+
nSetCullingModeSeparate(getNativeObject(),
570+
colorPassCullingMode.ordinal(), shadowPassCullingMode.ordinal());
571+
}
572+
559573
/**
560574
* Returns the face culling mode.
561575
*/
@@ -564,6 +578,14 @@ public Material.CullingMode getCullingMode() {
564578
return sCullingModeValues[nGetCullingMode(getNativeObject())];
565579
}
566580

581+
/**
582+
* Returns the face culling mode for the shadow passes.
583+
*/
584+
@NonNull
585+
public Material.CullingMode getShadowCullingMode() {
586+
return sCullingModeValues[nGetShadowCullingMode(getNativeObject())];
587+
}
588+
567589
/**
568590
* Overrides the default color-buffer write state that was set on the material.
569591
*
@@ -920,6 +942,8 @@ private static native void nSetSpecularAntiAliasingThreshold(long nativeMaterial
920942

921943
private static native void nSetDoubleSided(long nativeMaterialInstance, boolean doubleSided);
922944
private static native void nSetCullingMode(long nativeMaterialInstance, long mode);
945+
private static native void nSetCullingModeSeparate(long nativeMaterialInstance,
946+
long colorPassCullingMode, long shadowPassCullingMode);
923947
private static native void nSetColorWrite(long nativeMaterialInstance, boolean enable);
924948
private static native void nSetDepthWrite(long nativeMaterialInstance, boolean enable);
925949
private static native void nSetStencilWrite(long nativeMaterialInstance, boolean enable);
@@ -952,6 +976,7 @@ private static native void nSetStencilWriteMask(long nativeMaterialInstance, int
952976
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterialInstance);
953977
private static native boolean nIsDoubleSided(long nativeMaterialInstance);
954978
private static native int nGetCullingMode(long nativeMaterialInstance);
979+
private static native int nGetShadowCullingMode(long nativeMaterialInstance);
955980
private static native boolean nIsColorWriteEnabled(long nativeMaterialInstance);
956981
private static native boolean nIsDepthWriteEnabled(long nativeMaterialInstance);
957982
private static native boolean nIsStencilWriteEnabled(long nativeMaterialInstance);

0 commit comments

Comments
 (0)