Metal: Resolve high memory pressure on EEVEE render

When EEVEE is rendering multiple samples via
eevee_draw_scene, the command submission and in-flight
memory pressure would grow until all samples completed,
due to lack of intermediate flushing of GPU work and memory.

This patch adds a command flush and memory clear for this case
which occurs with high TAA sample counts during saving, similar
to the process in EEVEE_render_draw.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/107221
This commit is contained in:
Jason Fielder 2023-04-21 18:24:30 +02:00 committed by Clément Foucault
parent 35a8341d7b
commit 29a4903eb8
1 changed files with 12 additions and 0 deletions

View File

@ -19,6 +19,8 @@
#include "DNA_world_types.h"
#include "GPU_context.h"
#include "IMB_imbuf.h"
#include "eevee_private.h"
@ -348,6 +350,16 @@ static void eevee_draw_scene(void *vedata)
EEVEE_temporal_sampling_reset(vedata);
stl->effects->ssr_was_valid_double_buffer = stl->g_data->valid_double_buffer;
}
/* Perform render step between samples to allow flushing of freed temporary GPUBackend
* resources. This prevents the GPU backend accumulating a high amount of in-flight memory when
* performing renders using eevee_draw_scene. e.g. During file thumbnail generation. */
if (loop_len > 2) {
if (GPU_backend_get_type() == GPU_BACKEND_METAL) {
GPU_flush();
GPU_render_step();
}
}
}
if ((stl->g_data->render_passes & EEVEE_RENDER_PASS_COMBINED) != 0) {