Fix: Assert when exiting Metal rendered viewport

This commit fixes the following assert:
  mtl_command_buffer.mm:165, submit(), at 'MTLBackend::get()->is_inside_render_boundary()'

It happens when toggling rendered state of viewport on macOS, and is
caused by incorrect order of setting active GPU context to null and
calling GPU_render_end.

This change makes the flow of GPU_render_{beign, end} and GPU context
activation closer to what it is in the draw manager's functions
DRW_render_context_{enable, disable}.

Pull Request: https://projects.blender.org/blender/blender/pulls/119868
This commit is contained in:
Sergey Sharybin
2024-03-25 11:28:28 +01:00
committed by Sergey Sharybin
parent fb6b4fe75c
commit 7e2d54e786

View File

@@ -1314,8 +1314,8 @@ bool RE_engine_gpu_context_enable(RenderEngine *engine)
/* Activate RenderEngine System and Blender GPU Context. */
WM_system_gpu_context_activate(engine->system_gpu_context);
if (engine->blender_gpu_context) {
GPU_context_active_set(engine->blender_gpu_context);
GPU_render_begin();
GPU_context_active_set(engine->blender_gpu_context);
}
return true;
}
@@ -1330,8 +1330,8 @@ void RE_engine_gpu_context_disable(RenderEngine *engine)
else {
if (engine->system_gpu_context) {
if (engine->blender_gpu_context) {
GPU_render_end();
GPU_context_active_set(nullptr);
GPU_render_end();
}
WM_system_gpu_context_release(engine->system_gpu_context);
/* Restore DRW state context if previously active. */