diff --git a/README.md b/README.md index 4c0d4d7505..b454300bfa 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.12.10' + implementation 'com.google.android.filament:filament-android:1.12.11' } ``` @@ -52,7 +52,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ``` -pod 'Filament', '~> 1.12.10' +pod 'Filament', '~> 1.12.11' ``` ### Snapshots diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f5c43671c0..f0b596f24b 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,7 +3,12 @@ This file contains one line summaries of commits that are worthy of mentioning in release notes. A new header is inserted each time a *tag* is created. -## v1.12.11 (currently main branch) +## v1.12.12 (currently main branch) + +## v1.12.11 + +- Metal: Color grading performance improvement on M1 devices. +- samples: Fix glitchy animation seen in gltf-viewer iOS sample. ## v1.12.10 diff --git a/android/buildSrc/build.gradle b/android/buildSrc/build.gradle index b965e9bb6e..d4315035f0 100644 --- a/android/buildSrc/build.gradle +++ b/android/buildSrc/build.gradle @@ -1,3 +1,17 @@ + +plugins { + id 'groovy-gradle-plugin' +} + +gradlePlugin { + plugins { + create("filament-tools-plugin") { + id = "filament-tools-plugin" + implementationClass = "FilamentToolsPlugin" + } + } +} + repositories { mavenCentral() } diff --git a/android/filament-android/src/main/cpp/Filament.cpp b/android/filament-android/src/main/cpp/Filament.cpp index 2b06ed714d..0ae41e9270 100644 --- a/android/filament-android/src/main/cpp/Filament.cpp +++ b/android/filament-android/src/main/cpp/Filament.cpp @@ -18,21 +18,15 @@ #include "private/backend/VirtualMachineEnv.h" -namespace filament { - extern jint JNI_OnLoad(JavaVM* vm, void* reserved); -}; - JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv* env; if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { return -1; } -#if ANDROID - ::filament::JNI_OnLoad(vm, reserved); -#else + // This must be called when the library is loaded. We need this to get a reference to the + // global VM ::filament::VirtualMachineEnv::JNI_OnLoad(vm); -#endif return JNI_VERSION_1_6; } diff --git a/android/gradle.properties b/android/gradle.properties index 863b46e699..1af8b47219 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.12.10 +VERSION_NAME=1.12.11 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/android/samples/sample-gltf-viewer/build.gradle b/android/samples/sample-gltf-viewer/build.gradle index 2e1230aac6..39e923f023 100644 --- a/android/samples/sample-gltf-viewer/build.gradle +++ b/android/samples/sample-gltf-viewer/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-hello-camera/build.gradle b/android/samples/sample-hello-camera/build.gradle index eac4553fd4..3ff4b4b4e6 100644 --- a/android/samples/sample-hello-camera/build.gradle +++ b/android/samples/sample-hello-camera/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-hello-triangle/build.gradle b/android/samples/sample-hello-triangle/build.gradle index 8c4e76849d..cb768787ce 100644 --- a/android/samples/sample-hello-triangle/build.gradle +++ b/android/samples/sample-hello-triangle/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-image-based-lighting/build.gradle b/android/samples/sample-image-based-lighting/build.gradle index bf9a346a86..03328be1f4 100644 --- a/android/samples/sample-image-based-lighting/build.gradle +++ b/android/samples/sample-image-based-lighting/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-lit-cube/build.gradle b/android/samples/sample-lit-cube/build.gradle index d649fa7be8..432ca05b91 100644 --- a/android/samples/sample-lit-cube/build.gradle +++ b/android/samples/sample-lit-cube/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-material-builder/build.gradle b/android/samples/sample-material-builder/build.gradle index 4e9c186d6b..0d08d43b2c 100644 --- a/android/samples/sample-material-builder/build.gradle +++ b/android/samples/sample-material-builder/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-multi-view/build.gradle b/android/samples/sample-multi-view/build.gradle index 15a858cbc5..b0562428d5 100644 --- a/android/samples/sample-multi-view/build.gradle +++ b/android/samples/sample-multi-view/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-page-curl/build.gradle b/android/samples/sample-page-curl/build.gradle index 75efb4c90f..9a06422375 100644 --- a/android/samples/sample-page-curl/build.gradle +++ b/android/samples/sample-page-curl/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-stream-test/build.gradle b/android/samples/sample-stream-test/build.gradle index 865e031195..aea342fe4d 100644 --- a/android/samples/sample-stream-test/build.gradle +++ b/android/samples/sample-stream-test/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-texture-view/build.gradle b/android/samples/sample-texture-view/build.gradle index 0c29f20273..e793516329 100644 --- a/android/samples/sample-texture-view/build.gradle +++ b/android/samples/sample-texture-view/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-textured-object/build.gradle b/android/samples/sample-textured-object/build.gradle index 664398adc2..3228a5a2ed 100644 --- a/android/samples/sample-textured-object/build.gradle +++ b/android/samples/sample-textured-object/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/android/samples/sample-transparent-view/build.gradle b/android/samples/sample-transparent-view/build.gradle index 0c29f20273..e793516329 100644 --- a/android/samples/sample-transparent-view/build.gradle +++ b/android/samples/sample-transparent-view/build.gradle @@ -1,6 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: FilamentToolsPlugin +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'filament-tools-plugin' +} project.ext.isSample = true diff --git a/filament/backend/src/metal/MetalDriver.mm b/filament/backend/src/metal/MetalDriver.mm index ac30da6bb6..f111dc613a 100644 --- a/filament/backend/src/metal/MetalDriver.mm +++ b/filament/backend/src/metal/MetalDriver.mm @@ -64,16 +64,19 @@ MetalDriver::MetalDriver(backend::MetalPlatform* platform) noexcept initializeSupportedGpuFamilies(mContext); - utils::slog.d << "Supported GPU families: " << utils::io::endl; + utils::slog.v << "Supported GPU families: " << utils::io::endl; if (mContext->highestSupportedGpuFamily.common > 0) { - utils::slog.d << " MTLGPUFamilyCommon" << (int) mContext->highestSupportedGpuFamily.common << utils::io::endl; + utils::slog.v << " MTLGPUFamilyCommon" << (int) mContext->highestSupportedGpuFamily.common << utils::io::endl; } if (mContext->highestSupportedGpuFamily.apple > 0) { - utils::slog.d << " MTLGPUFamilyApple" << (int) mContext->highestSupportedGpuFamily.apple << utils::io::endl; + utils::slog.v << " MTLGPUFamilyApple" << (int) mContext->highestSupportedGpuFamily.apple << utils::io::endl; } if (mContext->highestSupportedGpuFamily.mac > 0) { - utils::slog.d << " MTLGPUFamilyMac" << (int) mContext->highestSupportedGpuFamily.mac << utils::io::endl; + utils::slog.v << " MTLGPUFamilyMac" << (int) mContext->highestSupportedGpuFamily.mac << utils::io::endl; } + utils::slog.v << "Features:" << utils::io::endl; + utils::slog.v << " readWriteTextureSupport: " << + (bool) mContext->device.readWriteTextureSupport << utils::io::endl; // In order to support texture swizzling, the GPU needs to support it and the system be running // iOS 13+. @@ -650,11 +653,10 @@ bool MetalDriver::isRenderTargetFormatSupported(TextureFormat format) { } bool MetalDriver::isFrameBufferFetchSupported() { -#if defined(IOS) && !defined(FILAMENT_IOS_SIMULATOR) - return true; -#else - return false; -#endif + // FrameBuffer fetch is achievable via "programmable blending" in Metal, and only supported on + // Apple GPUs with readWriteTextureSupport. + return mContext->highestSupportedGpuFamily.apple >= 1 && + mContext->device.readWriteTextureSupport; } bool MetalDriver::isFrameBufferFetchMultiSampleSupported() { diff --git a/filament/backend/src/metal/MetalHandles.mm b/filament/backend/src/metal/MetalHandles.mm index 2e3dad5636..88133e15bb 100644 --- a/filament/backend/src/metal/MetalHandles.mm +++ b/filament/backend/src/metal/MetalHandles.mm @@ -352,8 +352,7 @@ MetalProgram::MetalProgram(id device, const Program& program) noexcep length:source.size() encoding:NSUTF8StringEncoding]; NSError* error = nil; - MTLCompileOptions* options = [MTLCompileOptions new]; - options.languageVersion = MTLLanguageVersion1_1; + // When options is nil, Metal uses the most recent language version available. id library = [device newLibraryWithSource:objcSource options:nil error:&error]; diff --git a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp index 572ee44c80..fdbdbe0fe5 100644 --- a/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp +++ b/filament/backend/src/opengl/platforms/PlatformEGLAndroid.cpp @@ -245,11 +245,6 @@ AcquiredImage PlatformEGLAndroid::transformAcquiredImage(AcquiredImage source) n return { eglImage, patchedCallback, closure, source.handler }; } -// This must be called when the library is loaded. We need this to get a reference to the global VM -void JNI_OnLoad(JavaVM* vm, void* reserved) { - ::filament::VirtualMachineEnv::JNI_OnLoad(vm); -} - } // namespace filament // --------------------------------------------------------------------------------------------- diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 8b9cc223f2..71c8b62198 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.12.10" + spec.version = "1.12.11" 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.12.10/filament-v1.12.10-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.12.11/filament-v1.12.11-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/ios/samples/gltf-viewer/gltf-viewer/FILViewController.mm b/ios/samples/gltf-viewer/gltf-viewer/FILViewController.mm index a1a236fe4a..5ae108d847 100644 --- a/ios/samples/gltf-viewer/gltf-viewer/FILViewController.mm +++ b/ios/samples/gltf-viewer/gltf-viewer/FILViewController.mm @@ -45,6 +45,7 @@ using namespace utils; @implementation FILViewController { CADisplayLink* _displayLink; + CFTimeInterval _startTime; viewer::RemoteServer* _server; viewer::AutomationEngine* _automation; @@ -102,6 +103,7 @@ using namespace utils; [self stopDisplayLink]; // Call our render method 60 times a second. + _startTime = CACurrentMediaTime(); _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render)]; _displayLink.preferredFramesPerSecond = 60; [_displayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSDefaultRunLoopMode]; @@ -230,7 +232,8 @@ using namespace utils; auto* animator = self.modelView.animator; if (animator) { if (animator->getAnimationCount() > 0) { - animator->applyAnimation(0, CACurrentMediaTime()); + CFTimeInterval elapsedTime = CACurrentMediaTime() - _startTime; + animator->applyAnimation(0, static_cast(elapsedTime)); } animator->updateBoneMatrices(); } diff --git a/libs/filamat/src/GLSLPostProcessor.cpp b/libs/filamat/src/GLSLPostProcessor.cpp index 6c9de50f25..30d0f967f8 100644 --- a/libs/filamat/src/GLSLPostProcessor.cpp +++ b/libs/filamat/src/GLSLPostProcessor.cpp @@ -121,10 +121,16 @@ void GLSLPostProcessor::spirvToToMsl(const SpirvBlob *spirv, std::string *outMsl CompilerMSL::Options mslOptions = {}; mslOptions.platform = platform, - mslOptions.msl_version = CompilerMSL::Options::make_msl_version(1, 1); + mslOptions.msl_version = config.shaderModel == filament::backend::ShaderModel::GL_ES_30 ? + CompilerMSL::Options::make_msl_version(2, 0) : CompilerMSL::Options::make_msl_version(2, 2); - if (config.shaderModel == filament::backend::ShaderModel::GL_ES_30) { + if (config.hasFramebufferFetch) { mslOptions.use_framebuffer_fetch_subpasses = true; + // On macOS, framebuffer fetch is only available starting with MSL 2.3. Filament will only + // use framebuffer fetch materials on devices that support it. + if (config.shaderModel == filament::backend::ShaderModel::GL_CORE_41) { + mslOptions.msl_version = CompilerMSL::Options::make_msl_version(2, 3); + } } mslCompiler.set_msl_options(mslOptions); diff --git a/web/filament-js/package.json b/web/filament-js/package.json index b1248ad603..34ae334466 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.12.10", + "version": "1.12.11", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js",