From 20cb2c72a559786b69a3f45695b072dd0beae99a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 10 Jan 2022 15:56:44 +0100 Subject: Fix second render failure with Cycles persistent data The issue was caused by the recent changes in the way how the render result is drawn: the display driver now could hold an OpenGL resources. Those resources are not shared across contexts so whenever OpenGL context is destroyed those resources are to be destroyed as well (and not attempted to be re-used for a next render). Do such destruction and entire driver re-creation since it does simplifies things from API usage point of view without causing measurable slowdown. Steps to reproduce the issue: - Set the render resolution to 2x of Full HD - Enable persistent data - Render (F12) - Render again Observe OpenGL state being corrupted. Easy to see in debug mode where IMM abstraction level reports issues about the buffer size not being the proper size. This was caused by the display driver trying to use VAO from the previous OpenGL context. Differential Revision: https://developer.blender.org/D13789 --- intern/cycles/blender/session.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'intern') diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index b6f72707fe0..c81a0f4edb2 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -502,10 +502,15 @@ void BlenderSession::render_frame_finish() path_remove(filename); } - /* Clear driver. */ + /* Clear output driver. */ session->set_output_driver(nullptr); session->full_buffer_written_cb = function_null; + /* The display driver holds OpenGL resources which belong to an OpenGL context held by the render + * engine on Blender side. Force destruction of those resources. */ + display_driver_ = nullptr; + session->set_display_driver(nullptr); + /* All the files are handled. * Clear the list so that this session can be re-used by Persistent Data. */ full_buffer_files_.clear(); -- cgit v1.2.3