Page MenuHome

Avoid graphical glitches during threaded preview generation
Confirmed, NormalPublicTO DO


When previews are generated using an OpenGL engine, there can be a number of glitches until the preview is done. That's because some data is accessed/modified that is not thread safe. E.g. object_preview_render() modifies U.pixelsize. I think other glitches are caused by overriding the active theme in ED_view3d_draw_offscreen() - although when I avoided this some time ago for similar work on threaded offscreen drawing for VR, this didn't solve the color flickering.
The active theme should probably use thread local storage.

Besides that, the preview generation should be thread safe with OpenGL:

  • It uses the draw-manager's own context, which is mutex protected.
  • The non-thread-safe immediate mode API is not used inside the draw-manager.
  • The draw-manager already has workarounds for GPU driver issues with threaded drawing.

A note: We could also speed up Eevee preview generation significantly by using viewport render quality, not final render quality. The _imbuf offscreen rendering functions don't expose the is_image_render option for that, which they probably should.