Engine::unprotected() drops the command queue back to unprotected mode

FIXES=[344021154]
This commit is contained in:
Mathias Agopian
2024-06-03 13:55:01 -07:00
committed by Mathias Agopian
parent 749b063af3
commit b5d7de06bc
7 changed files with 46 additions and 0 deletions

View File

@@ -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

View File

@@ -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);

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.
*

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);
}

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;

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;

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)