From 9de29a475e51ae31e8e91ec430e39487c237ece8 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Tue, 13 Aug 2024 01:31:10 +0000 Subject: [PATCH 1/4] Add warning for the incompatibility of stereo type (#8031) Print a warning in case the sterescopic type in a compiled package is different than what's in the engine's setting. The application may proceed, but it could end up visual glitches when enabling stereoscopic rendering. This requires the stereoscopic type to be written into the package, which needs a material version bump. --- NEW_RELEASE_NOTES.md | 1 + filament/src/MaterialParser.cpp | 6 ++++++ filament/src/MaterialParser.h | 1 + filament/src/details/Material.cpp | 19 +++++++++++++++++-- .../include/filament/MaterialChunkType.h | 1 + .../include/filament/MaterialEnums.h | 2 +- libs/filagui/CMakeLists.txt | 10 ++++++++-- libs/filamat/src/MaterialBuilder.cpp | 1 + 8 files changed, 36 insertions(+), 5 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index ad978f29d1..d3de284524 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -8,4 +8,5 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut +- materials: add a new `stereoscopicType` material parameter. [⚠️ **New Material Version**] - Fix a crash when compiling shaders on IMG devices diff --git a/filament/src/MaterialParser.cpp b/filament/src/MaterialParser.cpp index 0304253b90..128288136a 100644 --- a/filament/src/MaterialParser.cpp +++ b/filament/src/MaterialParser.cpp @@ -354,6 +354,12 @@ bool MaterialParser::getSpecularAntiAliasingThreshold(float* value) const noexce return mImpl.getFromSimpleChunk(ChunkType::MaterialSpecularAntiAliasingThreshold, value); } +bool MaterialParser::getStereoscopicType(backend::StereoscopicType* value) const noexcept { + static_assert(sizeof(StereoscopicType) == sizeof(uint8_t), + "StereoscopicType expected size is wrong"); + return mImpl.getFromSimpleChunk(ChunkType::MaterialStereoscopicType, reinterpret_cast(value)); +} + bool MaterialParser::getRequiredAttributes(AttributeBitset* value) const noexcept { uint32_t rawAttributes = 0; if (!mImpl.getFromSimpleChunk(ChunkType::MaterialRequiredAttributes, &rawAttributes)) { diff --git a/filament/src/MaterialParser.h b/filament/src/MaterialParser.h index b10a549d8b..a524b18410 100644 --- a/filament/src/MaterialParser.h +++ b/filament/src/MaterialParser.h @@ -122,6 +122,7 @@ public: bool hasSpecularAntiAliasing(bool* value) const noexcept; bool getSpecularAntiAliasingVariance(float* value) const noexcept; bool getSpecularAntiAliasingThreshold(float* value) const noexcept; + bool getStereoscopicType(backend::StereoscopicType*) const noexcept; bool getShader(filaflat::ShaderContent& shader, backend::ShaderModel shaderModel, Variant variant, backend::ShaderStage stage) noexcept; diff --git a/filament/src/details/Material.cpp b/filament/src/details/Material.cpp index 64eabe0368..69c1e529ff 100644 --- a/filament/src/details/Material.cpp +++ b/filament/src/details/Material.cpp @@ -192,6 +192,22 @@ Material* Material::Builder::build(Engine& engine) { return nullptr; } + MaterialDomain materialDomain; + materialParser->getMaterialDomain(&materialDomain); + if (materialDomain == MaterialDomain::SURFACE) { + StereoscopicType const engineStereoscopicType = engine.getConfig().stereoscopicType; + StereoscopicType materialStereoscopicType = StereoscopicType::NONE; + materialParser->getStereoscopicType(&materialStereoscopicType); + if (materialStereoscopicType != engineStereoscopicType) { + CString name; + materialParser->getName(&name); + slog.w << "The stereoscopic type in the compiled material '" << name.c_str_safe() + << "' is " << (int)materialStereoscopicType + << ", which is not compatiable with the engine's setting " + << (int)engineStereoscopicType << "." << io::endl; + } + } + return downcast(engine).createMaterial(*this, std::move(materialParser)); } @@ -200,8 +216,7 @@ FMaterial::FMaterial(FEngine& engine, const Material::Builder& builder, : mIsDefaultMaterial(builder->mDefaultMaterial), mEngine(engine), mMaterialId(engine.getMaterialId()), - mMaterialParser(std::move(materialParser)) -{ + mMaterialParser(std::move(materialParser)) { MaterialParser* const parser = mMaterialParser.get(); UTILS_UNUSED_IN_RELEASE bool const nameOk = parser->getName(&mName); diff --git a/libs/filabridge/include/filament/MaterialChunkType.h b/libs/filabridge/include/filament/MaterialChunkType.h index 4a4561c14a..d69e8595da 100644 --- a/libs/filabridge/include/filament/MaterialChunkType.h +++ b/libs/filabridge/include/filament/MaterialChunkType.h @@ -92,6 +92,7 @@ enum UTILS_PUBLIC ChunkType : uint64_t { MaterialVertexDomain = charTo64bitNum("MAT_VEDO"), MaterialInterpolation = charTo64bitNum("MAT_INTR"), + MaterialStereoscopicType = charTo64bitNum("MAT_STER"), DictionaryText = charTo64bitNum("DIC_TEXT"), DictionarySpirv = charTo64bitNum("DIC_SPIR"), diff --git a/libs/filabridge/include/filament/MaterialEnums.h b/libs/filabridge/include/filament/MaterialEnums.h index cad7057fb1..a2e1d4568c 100644 --- a/libs/filabridge/include/filament/MaterialEnums.h +++ b/libs/filabridge/include/filament/MaterialEnums.h @@ -28,7 +28,7 @@ namespace filament { // update this when a new version of filament wouldn't work with older materials -static constexpr size_t MATERIAL_VERSION = 53; +static constexpr size_t MATERIAL_VERSION = 54; /** * Supported shading models diff --git a/libs/filagui/CMakeLists.txt b/libs/filagui/CMakeLists.txt index 55f3d867ff..dac013ce7f 100644 --- a/libs/filagui/CMakeLists.txt +++ b/libs/filagui/CMakeLists.txt @@ -40,14 +40,20 @@ endif() file(MAKE_DIRECTORY ${MATERIAL_DIR}) +set (MATC_FLAGS ${MATC_BASE_FLAGS}) +if (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "instanced") + set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=instanced) +elseif (FILAMENT_SAMPLES_STEREO_TYPE STREQUAL "multiview") + set (MATC_FLAGS ${MATC_FLAGS} -PstereoscopicType=multiview) +endif () + foreach (mat_src ${MATERIAL_SRCS}) get_filename_component(localname "${mat_src}" NAME_WE) get_filename_component(fullname "${mat_src}" ABSOLUTE) set(output_path "${MATERIAL_DIR}/${localname}.filamat") - add_custom_command( OUTPUT ${output_path} - COMMAND matc ${MATC_BASE_FLAGS} -o ${output_path} ${fullname} + COMMAND matc ${MATC_FLAGS} -o ${output_path} ${fullname} DEPENDS ${mat_src} matc COMMENT "Compiling material ${mat_src} to ${output_path}" ) diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index 590fac7f25..35add4f503 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -1609,6 +1609,7 @@ void MaterialBuilder::writeCommonChunks(ChunkContainer& container, MaterialInfo& } } container.emplace(ChunkType::MaterialProperties, properties); + container.emplace(ChunkType::MaterialStereoscopicType, static_cast(mStereoscopicType)); } // create a unique material id From cdd0147a174efbb21d82a46a8e4e8b278de2bd0c Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Tue, 13 Aug 2024 15:59:08 -0700 Subject: [PATCH 2/4] Release Filament 1.53.5 --- NEW_RELEASE_NOTES.md | 3 --- README.md | 4 ++-- RELEASE_NOTES.md | 5 +++++ android/gradle.properties | 2 +- ios/CocoaPods/Filament.podspec | 4 ++-- web/filament-js/package.json | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index d3de284524..4a1a9c7fa7 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -7,6 +7,3 @@ for next branch cut* header. appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). ## Release notes for next branch cut - -- materials: add a new `stereoscopicType` material parameter. [⚠️ **New Material Version**] -- Fix a crash when compiling shaders on IMG devices diff --git a/README.md b/README.md index 9f4ffb12b2..66dfda7840 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.53.4' + implementation 'com.google.android.filament:filament-android:1.53.5' } ``` @@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ```shell -pod 'Filament', '~> 1.53.4' +pod 'Filament', '~> 1.53.5' ``` ### Snapshots diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d8d83f372f..95f63bfa5b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,11 @@ A new header is inserted each time a *tag* is created. Instead, if you are authoring a PR for the main branch, add your release note to [NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md). +## v1.53.6 + +- materials: add a new `stereoscopicType` material parameter. [⚠️ **New Material Version**] +- Fix a crash when compiling shaders on IMG devices + ## v1.53.5 - engine: Fix bug causing certain sampler parameters to not be applied correctly in GLES 2.0 and on diff --git a/android/gradle.properties b/android/gradle.properties index 4b7e670a41..a9eb5d0046 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.53.4 +VERSION_NAME=1.53.5 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 49be1bc40a..ad8c4c6add 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.53.4" + spec.version = "1.53.5" spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.homepage = "https://google.github.io/filament" spec.authors = "Google LLC." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.platform = :ios, "11.0" - spec.source = { :http => "https://github.com/google/filament/releases/download/v1.53.4/filament-v1.53.4-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.53.5/filament-v1.53.5-ios.tgz" } # Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon. spec.pod_target_xcconfig = { diff --git a/web/filament-js/package.json b/web/filament-js/package.json index aef76f6820..1397ef3231 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.53.4", + "version": "1.53.5", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js", From 44a954b55981a46da51eeec033017de4a1ab14f4 Mon Sep 17 00:00:00 2001 From: Powei Feng Date: Tue, 13 Aug 2024 16:28:33 -0700 Subject: [PATCH 3/4] Fix misnumbered version in RELEASE_NOTES --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 95f63bfa5b..84193ace37 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,7 +7,7 @@ A new header is inserted each time a *tag* is created. Instead, if you are authoring a PR for the main branch, add your release note to [NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md). -## v1.53.6 +## v1.54.0 - materials: add a new `stereoscopicType` material parameter. [⚠️ **New Material Version**] - Fix a crash when compiling shaders on IMG devices From 1c817026f28f172cd181e1ee0b7cd297c4359627 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Wed, 14 Aug 2024 08:41:10 -0700 Subject: [PATCH 4/4] Remove unused code (#8043) --- filament/src/PostProcessManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/filament/src/PostProcessManager.cpp b/filament/src/PostProcessManager.cpp index da5c120b8e..cc15f8b895 100644 --- a/filament/src/PostProcessManager.cpp +++ b/filament/src/PostProcessManager.cpp @@ -494,7 +494,6 @@ PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph struct StructureMipmapData { FrameGraphId depth; - uint32_t rt[8]; }; fg.addPass("StructureMipmap", @@ -505,7 +504,7 @@ PostProcessManager::StructurePassOutput PostProcessManager::structure(FrameGraph .level = uint8_t(i) }); out = builder.write(out, FrameGraphTexture::Usage::DEPTH_ATTACHMENT); - data.rt[i - 1] = builder.declareRenderPass("Structure mip target", { + builder.declareRenderPass("Structure mip target", { .attachments = { .depth = out } }); }