Fix: EEVEE export CMDBuf out of memory in Metal

Previous commit 9333336a73f9e116771a52a2caa96455ea345c71
broke export rendering in Metal due to the command
submission not being flushed between samples.

This would lead to ghosting in export images due
to memory synchronization issues and GPU
scheduling dependency graph problems.

The in-flight memory could also get
extremely high if exporting high numbers
of samples due to all commands being
enqueued within a single submission.

Patch resolves this by flushing for
each render frame sample and
ensuring intermediate in-flight
memory remains controlled.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/114174
This commit is contained in:
Jason Fielder
2023-10-27 15:13:49 +02:00
committed by Clément Foucault
parent 585f43064a
commit b0a032e2eb

View File

@@ -663,6 +663,16 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
/* Perform render step between samples to allow
* flushing of freed GPUBackend resources. */
GPU_render_step();
if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_METAL)) {
if (render_samples > 0 && ((render_samples % 64) == 0)) {
/* Allow GPU to sync with CPU to prevent overly large command submissions being in-flight
* simultaneously. Reduces total in-flight memory required for rendering. */
GPU_finish();
}
else {
GPU_flush();
}
}
RE_engine_update_progress(engine, float(render_samples++) / float(tot_sample));
}