Skip to content

Commit 72a54b3

Browse files
committed
Temporary workaround for PlatformMetal
1 parent 00b2ab7 commit 72a54b3

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

filament/backend/include/backend/Platform.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ class UTILS_PUBLIC Platform {
149149
* - PlatformEGLAndroid
150150
*/
151151
bool assertNativeWindowIsValid = false;
152+
153+
/**
154+
* The action to take if a Drawable cannot be acquired. If true, the
155+
* frame is aborted instead of panic. This is only supported for:
156+
* - PlatformMetal
157+
*/
158+
bool metalDisablePanicOnDrawableFailure = false;
152159
};
153160

154161
Platform() noexcept;

filament/backend/src/metal/PlatformMetal.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
}
5454

5555
Driver* PlatformMetal::createDriver(void* /*sharedContext*/, const Platform::DriverConfig& driverConfig) noexcept {
56+
pImpl->mDrawableFailureBehavior = driverConfig.metalDisablePanicOnDrawableFailure
57+
? DrawableFailureBehavior::ABORT_FRAME
58+
: DrawableFailureBehavior::PANIC;
5659
return MetalDriverFactory::create(this, driverConfig);
5760
}
5861

filament/include/filament/Engine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,15 @@ class UTILS_PUBLIC Engine {
317317
*/
318318
size_t metalUploadBufferSizeBytes = 512 * 1024;
319319

320+
/**
321+
* The action to take if a Drawable cannot be acquired.
322+
*
323+
* Each frame rendered requires a CAMetalDrawable texture, which is
324+
* presented on-screen at the completion of each frame. These are
325+
* limited and provided round-robin style by the system.
326+
*/
327+
bool metalDisablePanicOnDrawableFailure = false;
328+
320329
/**
321330
* Set to `true` to forcibly disable parallel shader compilation in the backend.
322331
* Currently only honored by the GL and Metal backends.

filament/src/details/Engine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Engine* FEngine::create(Builder const& builder) {
140140
.forceGLES2Context = instance->getConfig().forceGLES2Context,
141141
.stereoscopicType = instance->getConfig().stereoscopicType,
142142
.assertNativeWindowIsValid = instance->features.backend.opengl.assert_native_window_is_valid,
143+
.metalDisablePanicOnDrawableFailure = instance->getConfig().metalDisablePanicOnDrawableFailure,
143144
};
144145
instance->mDriver = platform->createDriver(sharedContext, driverConfig);
145146

@@ -759,6 +760,7 @@ int FEngine::loop() {
759760
.forceGLES2Context = mConfig.forceGLES2Context,
760761
.stereoscopicType = mConfig.stereoscopicType,
761762
.assertNativeWindowIsValid = features.backend.opengl.assert_native_window_is_valid,
763+
.metalDisablePanicOnDrawableFailure = mConfig.metalDisablePanicOnDrawableFailure,
762764
};
763765
mDriver = mPlatform->createDriver(mSharedGLContext, driverConfig);
764766

0 commit comments

Comments
 (0)