Trigger save of the RD pipeline cache on application pause

This commit is contained in:
Fredia Huya-Kouadio
2025-12-30 19:25:29 -08:00
parent 1559ab34c6
commit be24804e1a
6 changed files with 28 additions and 6 deletions

View File

@@ -717,6 +717,14 @@ void DisplayServerAndroid::notify_surface_changed(int p_width, int p_height) {
}
}
void DisplayServerAndroid::notify_application_paused() {
#if defined(RD_ENABLED)
if (rendering_device) {
rendering_device->update_pipeline_cache();
}
#endif // defined(RD_ENABLED)
}
DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, DisplayServer::WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
rendering_driver = p_rendering_driver;

View File

@@ -247,6 +247,7 @@ public:
void reset_window();
void notify_surface_changed(int p_width, int p_height);
void notify_application_paused();
virtual Point2i mouse_get_position() const override;
virtual BitField<MouseButtonMask> mouse_get_button_state() const override;

View File

@@ -21,4 +21,12 @@ target_include_directories(${PROJECT_NAME}
${ANDROID_ROOT_DIR}
${OPENXR_INCLUDE_DIR})
add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DANDROID_ENABLED -DGLES3_ENABLED -DTOOLS_ENABLED -DDEBUG_ENABLED)
add_definitions(
-DUNIX_ENABLED
-DVULKAN_ENABLED
-DANDROID_ENABLED
-DGLES3_ENABLED
-DTOOLS_ENABLED
-DDEBUG_ENABLED
-DRD_ENABLED
)

View File

@@ -624,6 +624,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIE
if (os_android->get_main_loop()) {
os_android->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_PAUSED);
}
if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) {
dsa->notify_application_paused();
}
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onScreenRotationChange(JNIEnv *env, jclass clazz, jint p_orientation) {

View File

@@ -4224,7 +4224,7 @@ RID RenderingDevice::render_pipeline_create(RID p_shader, FramebufferFormatID p_
ERR_FAIL_COND_V(!pipeline.driver_id, RID());
if (pipeline_cache_enabled) {
_update_pipeline_cache();
update_pipeline_cache();
}
pipeline.shader = p_shader;
@@ -4312,7 +4312,7 @@ RID RenderingDevice::compute_pipeline_create(RID p_shader, const Vector<Pipeline
ERR_FAIL_COND_V(!pipeline.driver_id, RID());
if (pipeline_cache_enabled) {
_update_pipeline_cache();
update_pipeline_cache();
}
pipeline.shader = p_shader;
@@ -7195,7 +7195,7 @@ Vector<uint8_t> RenderingDevice::_load_pipeline_cache() {
}
}
void RenderingDevice::_update_pipeline_cache(bool p_closing) {
void RenderingDevice::update_pipeline_cache(bool p_closing) {
_THREAD_SAFE_METHOD_
{
@@ -7525,7 +7525,7 @@ void RenderingDevice::finalize() {
}
if (pipeline_cache_enabled) {
_update_pipeline_cache(true);
update_pipeline_cache(true);
driver->pipeline_cache_free();
}

View File

@@ -1215,7 +1215,6 @@ private:
WorkerThreadPool::TaskID pipeline_cache_save_task = WorkerThreadPool::INVALID_TASK_ID;
Vector<uint8_t> _load_pipeline_cache();
void _update_pipeline_cache(bool p_closing = false);
static void _save_pipeline_cache(void *p_data);
struct ComputePipeline {
@@ -1237,6 +1236,8 @@ public:
RID compute_pipeline_create(RID p_shader, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>());
bool compute_pipeline_is_valid(RID p_pipeline);
void update_pipeline_cache(bool p_closing = false);
private:
/****************/
/**** SCREEN ****/