USD: Implement incremental save for export

USD export currently only saves to disk at the very end of export. Due
to how USD de-duplicates data, all timeSamples remain in memory until
that time. This is problematic for cases such as #156402 that, due to
their size, quickly exhausts memory.

The solution is to call Stage Save() throughout the export process
instead of waiting until the end. However, it needs to be configurable.
Incremental saves have caused issues in the past for Google Drive
locations and it will be slower to export (slightly). Additionally, it's
not trivial or elegant to estimate the size of the exported data either.
We leave it up to the user to decide how frequently to save.

The new option will be displayed when the Animation option is selected.

Fixes #156402

Pull Request: https://projects.blender.org/blender/blender/pulls/158069
This commit is contained in:
Jesse Yurkovich 2026-05-06 21:02:49 +02:00 • committed by Jesse Yurkovich
parent eb2a9f9e60
commit aabaffd311
4 changed files with 31 additions and 3 deletions

View file

@ -281,7 +281,8 @@ class USDExportTest(AbstractUSDTest):
bpy.context.scene.frame_set(1)
export_path = self.tempdir / "usd_materials_multi.usda"
self.export_and_validate(filepath=str(export_path), export_animation=True, evaluation_mode="RENDER")
self.export_and_validate(
filepath=str(export_path), export_animation=True, incremental_frames=1, evaluation_mode="RENDER")
stage = Usd.Stage.Open(str(export_path))
@ -737,7 +738,8 @@ class USDExportTest(AbstractUSDTest):
bpy.context.scene.frame_set(1)
export_path = self.tempdir / "usd_attribute_varying_test.usda"
self.export_and_validate(filepath=str(export_path), export_animation=True, evaluation_mode="RENDER")
self.export_and_validate(
filepath=str(export_path), export_animation=True, incremental_frames=2, evaluation_mode="RENDER")
stage = Usd.Stage.Open(str(export_path))
sparse_frames = [4.0, 5.0, 8.0, 9.0, 12.0, 13.0]