diff --git a/android/filament-android/src/main/cpp/Engine.cpp b/android/filament-android/src/main/cpp/Engine.cpp index 9a2180e022..80409702c3 100644 --- a/android/filament-android/src/main/cpp/Engine.cpp +++ b/android/filament-android/src/main/cpp/Engine.cpp @@ -484,7 +484,9 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBuilderConfig(JNIEnv*, jclass, jlong nativeBuilder, jlong commandBufferSizeMB, jlong perRenderPassArenaSizeMB, jlong driverHandleArenaSizeMB, jlong minCommandBufferSizeMB, jlong perFrameCommandsSizeMB, - jlong jobSystemThreadCount, jint stereoscopicType, jlong stereoscopicEyeCount, + jlong jobSystemThreadCount, + jlong textureUseAfterFreePoolSize, jboolean disableParallelShaderCompile, + jint stereoscopicType, jlong stereoscopicEyeCount, jlong resourceAllocatorCacheSizeMB, jlong resourceAllocatorCacheMaxAge) { Engine::Builder* builder = (Engine::Builder*) nativeBuilder; Engine::Config config = { @@ -494,6 +496,8 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Engine_nSetBu .minCommandBufferSizeMB = (uint32_t) minCommandBufferSizeMB, .perFrameCommandsSizeMB = (uint32_t) perFrameCommandsSizeMB, .jobSystemThreadCount = (uint32_t) jobSystemThreadCount, + .textureUseAfterFreePoolSize = (uint32_t) textureUseAfterFreePoolSize, + .disableParallelShaderCompile = (bool) disableParallelShaderCompile, .stereoscopicType = (Engine::StereoscopicType) stereoscopicType, .stereoscopicEyeCount = (uint8_t) stereoscopicEyeCount, .resourceAllocatorCacheSizeMB = (uint32_t) resourceAllocatorCacheSizeMB, diff --git a/android/filament-android/src/main/java/com/google/android/filament/Engine.java b/android/filament-android/src/main/java/com/google/android/filament/Engine.java index 393b711ac9..06f0a2b8ae 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/Engine.java +++ b/android/filament-android/src/main/java/com/google/android/filament/Engine.java @@ -222,6 +222,7 @@ public class Engine { config.perRenderPassArenaSizeMB, config.driverHandleArenaSizeMB, config.minCommandBufferSizeMB, config.perFrameCommandsSizeMB, config.jobSystemThreadCount, + config.textureUseAfterFreePoolSize, config.disableParallelShaderCompile, config.stereoscopicType.ordinal(), config.stereoscopicEyeCount, config.resourceAllocatorCacheSizeMB, config.resourceAllocatorCacheMaxAge); return this; @@ -360,6 +361,22 @@ public class Engine { */ public long jobSystemThreadCount = 0; + /** + * Number of most-recently destroyed textures to track for use-after-free. + * + * This will cause the backend to throw an exception when a texture is freed but still bound + * to a SamplerGroup and used in a draw call. 0 disables completely. + * + * Currently only respected by the Metal backend. + */ + public long textureUseAfterFreePoolSize = 0; + + /** + * Set to `true` to forcibly disable parallel shader compilation in the backend. + * Currently only honored by the GL backend. + */ + public boolean disableParallelShaderCompile = false; + /** * The type of technique for stereoscopic rendering. * @@ -1264,6 +1281,7 @@ public class Engine { private static native void nSetBuilderConfig(long nativeBuilder, long commandBufferSizeMB, long perRenderPassArenaSizeMB, long driverHandleArenaSizeMB, long minCommandBufferSizeMB, long perFrameCommandsSizeMB, long jobSystemThreadCount, + long textureUseAfterFreePoolSize, boolean disableParallelShaderCompile, int stereoscopicType, long stereoscopicEyeCount, long resourceAllocatorCacheSizeMB, long resourceAllocatorCacheMaxAge); private static native void nSetBuilderFeatureLevel(long nativeBuilder, int ordinal); diff --git a/filament/include/filament/Engine.h b/filament/include/filament/Engine.h index 90cff6283d..2f8c6d4af7 100644 --- a/filament/include/filament/Engine.h +++ b/filament/include/filament/Engine.h @@ -298,6 +298,12 @@ public: */ size_t textureUseAfterFreePoolSize = 0; + /** + * Set to `true` to forcibly disable parallel shader compilation in the backend. + * Currently only honored by the GL backend. + */ + bool disableParallelShaderCompile = false; + /* * The type of technique for stereoscopic rendering. * diff --git a/filament/src/details/Engine.cpp b/filament/src/details/Engine.cpp index 82b9399ec6..2fce2349c3 100644 --- a/filament/src/details/Engine.cpp +++ b/filament/src/details/Engine.cpp @@ -98,7 +98,10 @@ Engine* FEngine::create(Engine::Builder const& builder) { return nullptr; } DriverConfig const driverConfig{ - .handleArenaSize = instance->getRequestedDriverHandleArenaSize() }; + .handleArenaSize = instance->getRequestedDriverHandleArenaSize(), + .textureUseAfterFreePoolSize = instance->getConfig().textureUseAfterFreePoolSize, + .disableParallelShaderCompile = instance->getConfig().disableParallelShaderCompile + }; instance->mDriver = platform->createDriver(sharedContext, driverConfig); } else { @@ -651,7 +654,8 @@ int FEngine::loop() { DriverConfig const driverConfig { .handleArenaSize = getRequestedDriverHandleArenaSize(), - .textureUseAfterFreePoolSize = mConfig.textureUseAfterFreePoolSize + .textureUseAfterFreePoolSize = mConfig.textureUseAfterFreePoolSize, + .disableParallelShaderCompile = mConfig.disableParallelShaderCompile }; mDriver = mPlatform->createDriver(mSharedGLContext, driverConfig);