Avoid graphical glitches during threaded preview generation #83896

Open
opened 2020-12-17 14:16:51 +01:00 by Julian Eisel · 19 comments
Member

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.

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.
Author
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel

#96002 was marked as duplicate of this issue

#96002 was marked as duplicate of this issue

#95057 was marked as duplicate of this issue

#95057 was marked as duplicate of this issue

#85929 was marked as duplicate of this issue

#85929 was marked as duplicate of this issue

#84062 was marked as duplicate of this issue

#84062 was marked as duplicate of this issue

#83905 was marked as duplicate of this issue

#83905 was marked as duplicate of this issue

Added subscriber: @dgsantana

Added subscriber: @dgsantana
Author
Member

Added subscriber: @TasosK

Added subscriber: @TasosK

Added subscriber: @georgK

Added subscriber: @georgK

Added subscribers: @gusdleon, @rboxman

Added subscribers: @gusdleon, @rboxman

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @Kdaf

Added subscriber: @Kdaf

Added subscriber: @JasonvanGumster

Added subscriber: @JasonvanGumster
Member

Added subscriber: @Harley

Added subscriber: @Harley
Member

Can't think of a reason for this to change U.pixelsize for the render. Maybe if the render included wireframes or showed cavity extras since those change with line size. And they would become less than a pixel when these previews are shown. But they don't.

I comment that part out and I can't tell a difference:

{F12787423,width=100%}

Can't think of a reason for this to change U.pixelsize for the render. Maybe if the render included wireframes or showed cavity extras since those change with line size. And they would become less than a pixel when these previews are shown. *But they don't*. I comment that part out and I can't tell a difference: {[F12787423](https://archive.blender.org/developer/F12787423/PixelSizePreview.png),width=100%}

Added subscribers: @LalaGhost, @RedMser

Added subscribers: @LalaGhost, @RedMser
Member

The primary issue stated here, the modification of u.pixelsize within object_preview_render, was fixed in the following:

https://developer.blender.org/D13717

The primary issue stated here, the modification of u.pixelsize within object_preview_render, was fixed in the following: https://developer.blender.org/D13717
Author
Member

Setting this to normal priority now. There are still notable glitches while generating the previews, but it's mostly things like buttons using wrong colors for a frame. Something that should be fixed, but nothing critical.

Setting this to normal priority now. There are still notable glitches while generating the previews, but it's mostly things like buttons using wrong colors for a frame. Something that should be fixed, but nothing critical.
Member

Added subscribers: @ArmandoTello, @PratikPB2123, @Alaska

Added subscribers: @ArmandoTello, @PratikPB2123, @Alaska
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#83896
No description provided.