Compare commits

..
16 Commits
Author SHA1 Message Date
Benjamin Doherty 64f03b3832 Merge branch 'rc/1.53.0' into release 2024-06-17 17:26:55 -07:00
Benjamin Doherty 6e3cccf30c Bump version to 1.53.0 2024-06-11 16:42:17 -07:00
Benjamin Doherty df34f92f8f Release Filament 1.52.3 2024-06-11 16:42:10 -07:00
Powei Feng 43331d04e5 gltfio: [extended] Fix generated color default (#7917)
Fixes #7905
2024-06-11 12:21:14 -07:00
Powei Feng 9917d4b7d9 Null out pending edits once latched (#7916)
Otherwise, we'd keep swapping between the edited version and the
original, causing matdbg to not work.
2024-06-10 21:32:49 +00:00
Mathias Agopian 682150ceec add debug option to disable sub-passes 2024-06-10 13:18:59 -07:00
Powei Feng af2ecf201f vk: workaround extension name length = 0 (adreno) (#7910) 2024-06-07 10:29:38 -07:00
Serge Metral 020668733a Adding the begin frame message for later xtrace post processing. (#7903)
BUG=343930963
2024-06-05 21:58:31 +00:00
Powei Feng 4c6d653d60 samples: Enable backend selection for hellopbr (#7898) 2024-06-05 19:15:45 +00:00
Mathias Agopian d1022527ac export PanicStream since it's a public API 2024-06-05 11:00:06 -07:00
Romain Guy 68c7a6c7b6 Update Android dependencies to latest (#7902) 2024-06-04 22:33:02 +00:00
Romain Guy f077fff012 Update actions/checkout to a supported version of Node.js (#7904) 2024-06-04 15:03:43 -07:00
Mathias Agopian bea02427ed keep the normal transforms in float during skinning
FIXES=[342459864]
2024-06-04 13:37:47 -07:00
Mathias Agopian b5d7de06bc Engine::unprotected() drops the command queue back to unprotected mode
FIXES=[344021154]
2024-06-04 11:46:00 -07:00
Mathias Agopian 749b063af3 PerformanceHintManager needs a valid Java thread
FIXES=[343965368, 343550453]
2024-06-04 10:22:21 -07:00
Ryan 7aefa99e06 Acquire a mutex before releasing CAMetalDrawables on main thread. (#7888)
PresentDrawable was moved to main thread by default in google#7535 and stopped
most crashes when a drawable is released. But there still appears to be crashes
if a drawable is released on main thread at the same time that -nextDrawable is
called from the Filament render thread. (It's likely that the drawable pool in
CAMetalLayer is completely non-thread-safe.)

So, add a mutex to the swapchain and always acquire it before creating or
releasing a CAMetalDrawable.

Users can opt out of this behavior by passing
-DFILAMENT_LOCK_METAL_DRAWABLE_POOL=0.
2024-06-03 19:37:46 +00:00
42 changed files with 258 additions and 69 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/ios && printf "y" | ./build.sh continuous
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/linux && printf "y" | ./build.sh continuous
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/mac && printf "y" | ./build.sh continuous
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
name: npm-deploy
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ github.event.inputs.release_tag }}
# Setup .npmrc file to publish to npm
+5 -5
View File
@@ -18,7 +18,7 @@ jobs:
os: [macos-14, ubuntu-22.04]
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
@@ -32,7 +32,7 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
build\windows\build-github.bat presubmit
@@ -43,7 +43,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
@@ -57,7 +57,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/ios && printf "y" | ./build.sh presubmit
@@ -70,7 +70,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/web && printf "y" | ./build.sh presubmit
+5 -5
View File
@@ -41,7 +41,7 @@ jobs:
TAG=${REF##*/}
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
@@ -76,7 +76,7 @@ jobs:
TAG=${REF##*/}
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
@@ -109,7 +109,7 @@ jobs:
TAG=${REF##*/}
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ steps.git_ref.outputs.ref }}
- uses: actions/setup-java@v3
@@ -163,7 +163,7 @@ jobs:
TAG=${REF##*/}
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
@@ -197,7 +197,7 @@ jobs:
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
with:
ref: ${{ steps.git_ref.outputs.ref }}
- name: Run build script
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: macos-14
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
cd build/web && printf "y" | ./build.sh continuous
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v4.1.6
- name: Run build script
run: |
build\windows\build-github.bat continuous
+2 -2
View File
@@ -31,7 +31,7 @@ repositories {
}
dependencies {
implementation 'com.google.android.filament:filament-android:1.52.3'
implementation 'com.google.android.filament:filament-android:1.53.0'
}
```
@@ -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.52.3'
pod 'Filament', '~> 1.53.0'
```
### Snapshots
+4
View File
@@ -7,6 +7,10 @@ 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.0
- engine: fix skinning normals with large transforms (b/342459864) [⚠️ **New Material Version**]
## v1.52.3
+6 -6
View File
@@ -83,12 +83,12 @@ buildscript {
'minSdk': 21,
'targetSdk': 34,
'compileSdk': 34,
'kotlin': '1.9.21',
'kotlin_coroutines': '1.7.3',
'kotlin': '2.0.0',
'kotlin_coroutines': '1.9.0-RC',
'buildTools': '34.0.0',
'ndk': '26.1.10909125',
'androidx_core': '1.12.0',
'androidx_annotations': '1.7.0'
'ndk': '27.0.11718014',
'androidx_core': '1.13.1',
'androidx_annotations': '1.8.0'
]
ext.deps = [
@@ -104,7 +104,7 @@ buildscript {
]
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'com.android.tools.build:gradle:8.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
}
@@ -420,6 +420,13 @@ Java_com_google_android_filament_Engine_nSetPaused(JNIEnv*, jclass,
engine->setPaused(paused);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Engine_nUnprotected(JNIEnv*, jclass,
jlong nativeEngine, jboolean paused) {
Engine* engine = (Engine*) nativeEngine;
engine->unprotected();
}
// Managers...
extern "C" JNIEXPORT jlong JNICALL
@@ -1289,6 +1289,18 @@ public class Engine {
nSetPaused(getNativeObject(), paused);
}
/**
* Switch the command queue to unprotected mode. Protected mode can be activated via
* Renderer::beginFrame() using a protected SwapChain.
* @see Renderer
* @see SwapChain
*/
public void unprotected() {
nUnprotected(getNativeObject());
}
@UsedByReflection("TextureHelper.java")
public long getNativeObject() {
if (mNativeObject == 0) {
@@ -1366,6 +1378,7 @@ public class Engine {
private static native void nFlush(long nativeEngine);
private static native boolean nIsPaused(long nativeEngine);
private static native void nSetPaused(long nativeEngine, boolean paused);
private static native void nUnprotected(long nativeEngine);
private static native long nGetTransformManager(long nativeEngine);
private static native long nGetLightManager(long nativeEngine);
private static native long nGetRenderableManager(long nativeEngine);
+1 -1
View File
@@ -1,5 +1,5 @@
GROUP=com.google.android.filament
VERSION_NAME=1.52.3
VERSION_NAME=1.53.0
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
+1 -1
View File
@@ -1,6 +1,6 @@
#Wed Nov 17 10:40:18 PST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+2 -1
View File
@@ -57,7 +57,8 @@ FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/ndk.version)}
# Install the required NDK version specifically (if not present)
if [[ ! -d "${ANDROID_HOME}/ndk/$FILAMENT_NDK_VERSION" ]]; then
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
yes | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --licenses
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION"
fi
# Only build 1 64 bit target during presubmit to cut down build times during presubmit
+1 -1
View File
@@ -1 +1 @@
26.1.10909125
27.0.11718014
@@ -90,8 +90,13 @@ protected:
AcquiredImage transformAcquiredImage(AcquiredImage source) noexcept override;
private:
struct InitializeJvmForPerformanceManagerIfNeeded {
InitializeJvmForPerformanceManagerIfNeeded();
};
int mOSVersion;
ExternalStreamManagerAndroid& mExternalStreamManager;
InitializeJvmForPerformanceManagerIfNeeded const mInitializeJvmForPerformanceManagerIfNeeded;
utils::PerformanceHintManager mPerformanceHintManager;
utils::PerformanceHintManager::Session mPerformanceHintSession;
+11 -1
View File
@@ -16,13 +16,23 @@
#include "private/backend/VirtualMachineEnv.h"
#include <utils/compiler.h>
#include <utils/debug.h>
#include <jni.h>
namespace filament {
JavaVM* VirtualMachineEnv::sVirtualMachine = nullptr;
// This is called when the library is loaded. We need this to get a reference to the global VM
/*
* This is typically called by filament_jni.so when it is loaded. If filament_jni.so is not used,
* then this must be called manually -- however, this is a problem because VirtualMachineEnv.h
* is currently private and part of backend.
* For now, we authorize this usage, but we will need to fix it; by making a proper public
* API for this.
*/
UTILS_PUBLIC
UTILS_NOINLINE
jint VirtualMachineEnv::JNI_OnLoad(JavaVM* vm) noexcept {
JNIEnv* env = nullptr;
@@ -19,6 +19,8 @@
#include <backend/platforms/PlatformEGL.h>
#include <backend/platforms/PlatformEGLAndroid.h>
#include <private/backend/VirtualMachineEnv.h>
#include "opengl/GLUtils.h"
#include "ExternalStreamManagerAndroid.h"
@@ -82,9 +84,23 @@ using EGLStream = Platform::Stream;
// ---------------------------------------------------------------------------------------------
PlatformEGLAndroid::InitializeJvmForPerformanceManagerIfNeeded::InitializeJvmForPerformanceManagerIfNeeded() {
// PerformanceHintManager() needs the calling thread to be a Java thread; so we need
// to attach this thread to the JVM before we initialize PerformanceHintManager.
// This should be done in PerformanceHintManager(), but libutils doesn't have access to
// VirtualMachineEnv.
if (PerformanceHintManager::isSupported()) {
(void)VirtualMachineEnv::get().getEnvironment();
}
}
// ---------------------------------------------------------------------------------------------
PlatformEGLAndroid::PlatformEGLAndroid() noexcept
: PlatformEGL(),
mExternalStreamManager(ExternalStreamManagerAndroid::create()) {
mExternalStreamManager(ExternalStreamManagerAndroid::create()),
mInitializeJvmForPerformanceManagerIfNeeded(),
mPerformanceHintManager() {
char scratch[PROP_VALUE_MAX + 1];
int length = __system_property_get("ro.build.version.release", scratch);
@@ -397,7 +397,10 @@ void VulkanDriver::collectGarbage() {
}
void VulkanDriver::beginFrame(int64_t monotonic_clock_ns,
int64_t refreshIntervalNs, uint32_t frameId) {
FVK_SYSTRACE_CONTEXT();
FVK_SYSTRACE_START("beginFrame");
// Do nothing.
FVK_SYSTRACE_END();
}
void VulkanDriver::setFrameScheduledCallback(Handle<HwSwapChain> sch,
@@ -176,6 +176,12 @@ ExtensionSet getInstanceExtensions(ExtensionSet const& externallyRequiredExts =
static_cast<char const*>(nullptr) /* pLayerName */);
for (auto const& extProps: availableExts) {
utils::CString name { extProps.extensionName };
// To workaround an Adreno bug where the extension name could be of 0 length.
if (name.size() == 0) {
continue;
}
if (setContains(TARGET_EXTS, name) || setContains(externallyRequiredExts, name)) {
exts.insert(name);
}
@@ -200,6 +206,12 @@ ExtensionSet getDeviceExtensions(VkPhysicalDevice device) {
static_cast<const char*>(nullptr) /* pLayerName */);
for (auto const& extension: extensions) {
utils::CString name { extension.extensionName };
// To workaround an Adreno bug where the extension name could be of 0 length.
if (name.size() == 0) {
continue;
}
if (setContains(TARGET_EXTS, name)) {
exts.insert(name);
}
+8
View File
@@ -930,6 +930,14 @@ public:
*/
void pumpMessageQueues();
/**
* Switch the command queue to unprotected mode. Protected mode can be activated via
* Renderer::beginFrame() using a protected SwapChain.
* @see Renderer
* @see SwapChain
*/
void unprotected() noexcept;
/**
* Returns the default Material.
*
+4
View File
@@ -329,6 +329,10 @@ void Engine::pumpMessageQueues() {
downcast(this)->pumpMessageQueues();
}
void Engine::unprotected() noexcept {
downcast(this)->unprotected();
}
void Engine::setAutomaticInstancingEnabled(bool enable) noexcept {
downcast(this)->setAutomaticInstancingEnabled(enable);
}
+9
View File
@@ -476,6 +476,8 @@ void FEngine::shutdown() {
destroy(mDefaultMaterial);
destroy(mUnprotectedDummySwapchain);
/*
* clean-up after the user -- we call terminate on each "leaked" object and clear each list.
*
@@ -1253,6 +1255,13 @@ void FEngine::resetBackendState() noexcept {
}
#endif
void FEngine::unprotected() noexcept {
if (UTILS_UNLIKELY(!mUnprotectedDummySwapchain)) {
mUnprotectedDummySwapchain = createSwapChain(1, 1, 0);
}
mUnprotectedDummySwapchain->makeCurrent(getDriverApi());
}
// ------------------------------------------------------------------------------------------------
Engine::Builder::Builder() noexcept = default;
+4
View File
@@ -406,6 +406,8 @@ public:
getDriver().purge();
}
void unprotected() noexcept;
void setAutomaticInstancingEnabled(bool enable) noexcept {
// instancing is not allowed at feature level 0
if (hasFeatureLevel(FeatureLevel::FEATURE_LEVEL_1)) {
@@ -539,6 +541,7 @@ private:
mutable FMaterial const* mDefaultMaterial = nullptr;
mutable FMaterial const* mSkyboxMaterial = nullptr;
mutable FSwapChain* mUnprotectedDummySwapchain = nullptr;
mutable FTexture* mDefaultIblTexture = nullptr;
mutable FIndirectLight* mDefaultIbl = nullptr;
@@ -595,6 +598,7 @@ public:
// capture to file. At the moment, only supported by the Metal backend.
bool doFrameCapture = false;
bool disable_buffer_padding = false;
bool disable_subpasses = false;
} renderer;
struct {
bool debug_froxel_visualization = false;
+1 -1
View File
@@ -661,7 +661,7 @@ bool FMaterial::hasPendingEdits() noexcept {
void FMaterial::latchPendingEdits() noexcept {
std::lock_guard const lock(mPendingEditsLock);
std::swap(mPendingEdits, mMaterialParser);
mMaterialParser.reset(mPendingEdits.release());
}
/**
+6 -2
View File
@@ -95,6 +95,8 @@ FRenderer::FRenderer(FEngine& engine) :
&engine.debug.renderer.doFrameCapture);
debugRegistry.registerProperty("d.renderer.disable_buffer_padding",
&engine.debug.renderer.disable_buffer_padding);
debugRegistry.registerProperty("d.renderer.disable_subpasses",
&engine.debug.renderer.disable_subpasses);
debugRegistry.registerProperty("d.shadowmap.display_shadow_texture",
&engine.debug.shadowmap.display_shadow_texture);
debugRegistry.registerProperty("d.shadowmap.display_shadow_texture_scale",
@@ -596,12 +598,14 @@ void FRenderer::renderJob(RootArenaScope& rootArenaScope, FView& view) {
hasColorGrading &&
msaaSampleCount <= 1 &&
!bloomOptions.enabled && !dofOptions.enabled && !taaOptions.enabled &&
driver.isFrameBufferFetchSupported(),
driver.isFrameBufferFetchSupported() &&
!engine.debug.renderer.disable_subpasses,
.customResolve =
msaaOptions.customResolve &&
msaaSampleCount > 1 &&
hasColorGrading &&
driver.isFrameBufferFetchMultiSampleSupported(),
driver.isFrameBufferFetchMultiSampleSupported() &&
!engine.debug.renderer.disable_subpasses,
.translucent = needsAlphaChannel,
.fxaa = hasFXAA,
.dithering = hasDithering,
+3 -7
View File
@@ -114,6 +114,7 @@ void FSkinningBuffer::setBones(FEngine& engine,
setBones(engine, mHandle, transforms, count, offset);
}
UTILS_UNUSED
static uint32_t packHalf2x16(half2 v) noexcept {
uint32_t lo = getBits(v[0]);
uint32_t hi = getBits(v[1]);
@@ -144,13 +145,8 @@ PerRenderableBoneUib::BoneData FSkinningBuffer::makeBone(mat4f transform) noexce
transform[1],
transform[2]
},
.cof = {
packHalf2x16({ cofactors[0].x, cofactors[0].y }),
packHalf2x16({ cofactors[0].z, cofactors[1].x }),
packHalf2x16({ cofactors[1].y, cofactors[1].z }),
packHalf2x16({ cofactors[2].x, cofactors[2].y })
// cofactor[2][2] is not stored because we don't have space for it
}
.cof0 = cofactors[0],
.cof1x = cofactors[1].x
};
}
+2 -2
View File
@@ -1,12 +1,12 @@
Pod::Spec.new do |spec|
spec.name = "Filament"
spec.version = "1.52.3"
spec.version = "1.53.0"
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.52.3/filament-v1.52.3-ios.tgz" }
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.53.0/filament-v1.53.0-ios.tgz" }
# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
spec.pod_target_xcconfig = {
@@ -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 = 52;
static constexpr size_t MATERIAL_VERSION = 53;
/**
* Supported shading models
@@ -327,8 +327,9 @@ struct PerRenderableBoneUib { // NOLINT(cppcoreguidelines-pro-type-member-init)
struct alignas(16) BoneData {
// bone transform, last row assumed [0,0,0,1]
math::float4 transform[3];
// 8 first cofactor matrix of transform's upper left
math::uint4 cof;
// 4 first cofactor matrix of transform's upper left
math::float3 cof0;
float cof1x;
};
BoneData bones[CONFIG_MAX_BONE_COUNT];
};
@@ -207,7 +207,17 @@ std::vector<BufferSlot> computeGeometries(cgltf_primitive const* prim, uint8_t c
size_t const requiredSize = byteCount * vertexCount;
auto gendata = (uint8_t*) malloc(requiredSize);
memset(gendata, 0xff, requiredSize);
if (vattr == filament::VertexAttribute::COLOR) {
// Assume white as the default if colors need to be generated.
float4* dataf = (float4*) gendata;
for (size_t i = 0; i < vertexCount; ++i) {
dataf[i] = float4(1.0, 1.0, 1.0, 1.0f);
}
} else {
memset(gendata, 0xff, requiredSize);
}
vslots.push_back({
.slot = slot,
.sizeInBytes = requiredSize,
@@ -55,9 +55,15 @@ public:
int reportActualWorkDuration(int64_t actualDurationNanos) noexcept;
};
// caveat: This must be called on a Java thread
PerformanceHintManager() noexcept;
~PerformanceHintManager() noexcept;
// Whether PerformanceHintManager APIs are supported (which doesn't mean PerformanceHintManager
// itself is, use isValid()).
static bool isSupported() noexcept;
// Whether PerformanceHintManager can be used.
bool isValid() const;
int64_t getPreferredUpdateRateNanos() const noexcept;
@@ -47,6 +47,13 @@ PerformanceHintManager::PerformanceHintManager() noexcept {
PerformanceHintManager::~PerformanceHintManager() noexcept = default;
bool PerformanceHintManager::isSupported() noexcept {
if (__builtin_available(android __ANDROID_API_T__, *)) {
return true;
}
return false;
}
bool PerformanceHintManager::isValid() const {
return mImpl->mManager != nullptr;
}
+2
View File
@@ -856,6 +856,8 @@ int main(int argc, char** argv) {
}
ImGui::Checkbox("Disable buffer padding",
debug.getPropertyAddress<bool>("d.renderer.disable_buffer_padding"));
ImGui::Checkbox("Disable sub-passes",
debug.getPropertyAddress<bool>("d.renderer.disable_subpasses"));
ImGui::Checkbox("Camera at origin",
debug.getPropertyAddress<bool>("d.view.camera_at_origin"));
ImGui::Checkbox("Far Origin", &app.originIsFarAway);
+63 -6
View File
@@ -29,6 +29,10 @@
#include <filamentapp/Config.h>
#include <filamentapp/FilamentApp.h>
#include <getopt/getopt.h>
#include <iostream>
#include "generated/resources/resources.h"
#include "generated/resources/monkey.h"
@@ -39,6 +43,7 @@ using namespace filament::math;
using Backend = Engine::Backend;
struct App {
Config config;
utils::Entity light;
Material* material;
MaterialInstance* materialInstance;
@@ -48,13 +53,65 @@ struct App {
static const char* IBL_FOLDER = "assets/ibl/lightroom_14b";
int main(int argc, char** argv) {
Config config;
config.title = "hellopbr";
config.iblDirectory = FilamentApp::getRootAssetsPath() + IBL_FOLDER;
static void printUsage(char* name) {
std::string exec_name(utils::Path(name).getName());
std::string usage(
"EXEC renders a simple PBR example\n"
"Usage:\n"
" EXEC [options]\n"
"Options:\n"
" --help, -h\n"
" Prints this message\n\n"
" --api, -a\n"
" Specify the backend API: opengl, vulkan, or metal\n"
);
const std::string from("EXEC");
for (size_t pos = usage.find(from); pos != std::string::npos; pos = usage.find(from, pos)) {
usage.replace(pos, from.length(), exec_name);
}
std::cout << usage;
}
static int handleCommandLineArguments(int argc, char* argv[], App* app) {
static constexpr const char* OPTSTR = "ha:";
static const struct option OPTIONS[] = {
{ "help", no_argument, nullptr, 'h' },
{ "api", required_argument, nullptr, 'a' },
{ nullptr, 0, nullptr, 0 }
};
int opt;
int option_index = 0;
while ((opt = getopt_long(argc, argv, OPTSTR, OPTIONS, &option_index)) >= 0) {
std::string arg(optarg ? optarg : "");
switch (opt) {
default:
case 'h':
printUsage(argv[0]);
exit(0);
case 'a':
if (arg == "opengl") {
app->config.backend = Engine::Backend::OPENGL;
} else if (arg == "vulkan") {
app->config.backend = Engine::Backend::VULKAN;
} else if (arg == "metal") {
app->config.backend = Engine::Backend::METAL;
} else {
std::cerr << "Unrecognized backend. Must be 'opengl'|'vulkan'|'metal'.\n";
exit(1);
}
break;
}
}
return optind;
}
int main(int argc, char** argv) {
App app;
auto setup = [config, &app](Engine* engine, View* view, Scene* scene) {
app.config.title = "hellopbr";
app.config.iblDirectory = FilamentApp::getRootAssetsPath() + IBL_FOLDER;
handleCommandLineArguments(argc, argv, &app);
auto setup = [config=app.config, &app](Engine* engine, View* view, Scene* scene) {
auto& tcm = engine->getTransformManager();
auto& rcm = engine->getRenderableManager();
auto& em = utils::EntityManager::get();
@@ -100,7 +157,7 @@ int main(int argc, char** argv) {
tcm.setTransform(ti, app.transform * mat4f::rotation(now, float3{ 0, 1, 0 }));
});
FilamentApp::get().run(config, setup, cleanup);
FilamentApp::get().run(app.config, setup, cleanup);
return 0;
}
+2 -1
View File
@@ -19,7 +19,8 @@ struct ShadowData {
#if defined(VARIANT_HAS_SKINNING_OR_MORPHING)
struct BoneData {
highp mat3x4 transform; // bone transform is mat4x3 stored in row-major (last row [0,0,0,1])
highp uvec4 cof; // 8 first cofactor matrix of transform's upper left
highp float3 cof0; // 3 first cofactor matrix of transform's upper left
highp float cof1x; // 4th cofactor
};
#endif
+21 -14
View File
@@ -34,25 +34,32 @@ int getVertexIndex() {
#if defined(VARIANT_HAS_SKINNING_OR_MORPHING)
#define MAX_SKINNING_BUFFER_WIDTH 2048u
vec3 mulBoneNormal(vec3 n, uint i) {
vec3 mulBoneNormal(vec3 n, uint j) {
highp mat3 cof;
// the first 8 elements of the cofactor matrix are stored as fp16
highp vec2 x0y0 = unpackHalf2x16(bonesUniforms.bones[i].cof[0]);
highp vec2 z0x1 = unpackHalf2x16(bonesUniforms.bones[i].cof[1]);
highp vec2 y1z1 = unpackHalf2x16(bonesUniforms.bones[i].cof[2]);
highp vec2 x2y2 = unpackHalf2x16(bonesUniforms.bones[i].cof[3]);
// the last element must be computed by hand
highp float a = bonesUniforms.bones[i].transform[0][0];
highp float b = bonesUniforms.bones[i].transform[0][1];
highp float d = bonesUniforms.bones[i].transform[1][0];
highp float e = bonesUniforms.bones[i].transform[1][1];
highp float a = bonesUniforms.bones[j].transform[0][0];
highp float b = bonesUniforms.bones[j].transform[0][1];
highp float c = bonesUniforms.bones[j].transform[0][2];
highp float d = bonesUniforms.bones[j].transform[1][0];
highp float e = bonesUniforms.bones[j].transform[1][1];
highp float f = bonesUniforms.bones[j].transform[1][2];
highp float g = bonesUniforms.bones[j].transform[2][0];
highp float h = bonesUniforms.bones[j].transform[2][1];
highp float i = bonesUniforms.bones[j].transform[2][2];
cof[0].xyz = vec3(x0y0, z0x1.x);
cof[1].xyz = vec3(z0x1.y, y1z1);
cof[2].xyz = vec3(x2y2, a * e - b * d);
cof[0] = bonesUniforms.bones[j].cof0;
cof[1].xyz = vec3(
bonesUniforms.bones[j].cof1x,
a * i - c * g,
c * d - a * f);
cof[2].xyz = vec3(
d * h - e * g,
b * g - a * h,
a * e - b * d);
return normalize(cof * n);
}
+2
View File
@@ -388,6 +388,8 @@ class_<Engine>("Engine")
return Engine::create();
}, allow_raw_pointers())
.function("unprotected", &Engine::unprotected)
.function("enableAccurateTranslations", &Engine::enableAccurateTranslations)
.function("setAutomaticInstancingEnabled", &Engine::setAutomaticInstancingEnabled)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "filament",
"version": "1.52.3",
"version": "1.53.0",
"description": "Real-time physically based rendering engine",
"main": "filament.js",
"module": "filament.js",