Drawing issues when running in multiple windows #51736

Closed
opened 2017-06-07 18:44:51 +02:00 by Dalai Felinto · 17 comments

Short description of error

When using Blender with multiple-windows, you can't use Clay, or Eevee.

Detailed issue

The OpenGL 3.3 core profile documentation , Appendix D, page 336 clearly states that:

Framebuffer, query, and vertex array objects are not shared.

If we force OpenGL context to share every single resource, things work. To try this in Linux you can apply the following hack/patch: P596. However this doesn't work well if user has multiple graphic cards and move windows around between them. In Blender we only resort to that if user has intel cards.

Proposed solution

First and foremost we need to get rid of static allocated elements as we do now in places like draw_cache.c. They can safely be moved to a struct owned by the Window, while some global stuff could be owned by WindowManager.

Second we need a non-shared-OpenGL-resources-manager. A system that allocates and retrieve them per window. We need this for OpenSubdiv as well, since we also rely on VAO there. Ideal solution and implementation open for discussions.

**Short description of error** When using Blender with multiple-windows, you can't use Clay, or Eevee. **Detailed issue** The [OpenGL 3.3 core profile documentation ](https://www.khronos.org/registry/OpenGL/specs/gl/glspec33.core.pdf), Appendix D, page 336 clearly states that: > Framebuffer, query, and vertex array objects are not shared. If we force OpenGL context to share every single resource, things work. To try this in Linux you can apply the following hack/patch: [P596](https://archive.blender.org/developer/P596.txt). However this doesn't work well if user has multiple graphic cards and move windows around between them. In Blender we only resort to that if user has intel cards. **Proposed solution** First and foremost we need to get rid of static allocated elements as we do now in places like draw_cache.c. They can safely be moved to a struct owned by the Window, while some global stuff could be owned by WindowManager. Second we need a non-shared-OpenGL-resources-manager. A system that allocates and retrieve them per window. We need this for OpenSubdiv as well, since we also rely on VAO there. Ideal solution and implementation open for discussions.
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'
Author
Owner

Added subscriber: @dfelinto

Added subscriber: @dfelinto
Mike Erwin was assigned by Dalai Felinto 2017-06-07 18:46:24 +02:00
Author
Owner

Added subscribers: @fclem, @Sergey

Added subscribers: @fclem, @Sergey
Author
Owner

Speculations

We seem to rely on VAOs for the Batches (see batch.c). And in some cases those batches are statically created (e.g., DRW_cache_fullscreen_quad_get).

**Speculations** We seem to rely on VAOs for the Batches (see batch.c). And in some cases those batches are statically created (e.g., DRW_cache_fullscreen_quad_get).
Member

How about a more radical approach? Have one drawing context that all the windows use. The GPU already draws in sequence whether we have one context or many. The one drawing context has all VAOs so we don't have to manage anything ourselves. Adding yet another manager isn't the only solution.

How important is the multi-different-GPU situation? I've thought about this but never worked out a real design or heard any feedback (until this task!). We currently make assumptions in the code about GL version, limits, capabilities being similar for the whole system. Assumptions that aren't true given different GPUs. Yet Blender still works! Which suggests people generally don't rely on multiple display GPUs from multiple vendors.

How about a more radical approach? Have one drawing context that all the windows use. The GPU already draws in sequence whether we have one context or many. The one drawing context has all VAOs so we don't have to manage anything ourselves. Adding yet another manager isn't the only solution. How important is the multi-different-GPU situation? I've thought about this but never worked out a real design or heard any feedback (until this task!). We currently make assumptions in the code about GL version, limits, capabilities being similar for the whole system. Assumptions that aren't true given different GPUs. Yet Blender still works! Which suggests people generally don't rely on multiple display GPUs from multiple vendors.
Member

FYI our new immediate mode handles this by recreating its internal VAO every time we start drawing to a different window (each window has its own GL context). Much simpler there because imm has only one VAO total, not one per batch, potentially thousands.

FYI our new immediate mode handles this by recreating its internal VAO every time we start drawing to a different window (each window has its own GL context). Much simpler there because imm has only one VAO total, not one per batch, potentially thousands.

I like what @MikeErwin said! Lets draw every viewport on context A. Since we already draw viewports to offscreen textures, we can just output the viewport texture (rendered in Ctx A) to window with Ctx B.

I like what @MikeErwin said! Lets draw every viewport on context A. Since we already draw viewports to offscreen textures, we can just output the viewport texture (rendered in Ctx A) to window with Ctx B.

How important is the multi-different-GPU situation?

Blender should work on any GPU configuration. Period.

> How important is the multi-different-GPU situation? Blender should work on any GPU configuration. Period.

Added subscriber: @StephenHamacek

Added subscriber: @StephenHamacek

I'm out of my depth, but I thought this might relate to this bug I reported #52886

I'm out of my depth, but I thought this might relate to this bug I reported [#52886 ](https://developer.blender.org/T52886)
Author
Owner
Recommended reading: https://blog.gvnott.com/some-usefull-facts-about-multipul-opengl-contexts/
Author
Owner

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @mano-wii

Added subscriber: @mano-wii

So I tried one approach that may not be sufficient.

See D3057 for my attempt on having only one context for every viewport.

While this works quite well, we have another issue. VAO management. The UI still uses batches (very sparsely) that have a single VAO and does not draw on every new window context.

@MikeErwin I too did not want a new manager for this issue but the bad VAO usage is hurting performance too. So I tried to come up with something as lightweight as possible for managing lots of VAOs. See P608 for more details.

So I tried one approach that may not be sufficient. See [D3057](https://archive.blender.org/developer/D3057) for my attempt on having only one context for every viewport. While this works quite well, we have another issue. VAO management. The UI still uses batches (very sparsely) that have a single VAO and does not draw on every new window context. @MikeErwin I too did not want a new manager for this issue but the bad VAO usage is hurting performance too. So I tried to come up with something as lightweight as possible for managing lots of VAOs. See [P608](https://archive.blender.org/developer/P608.txt) for more details.

Added subscriber: @brecht

Added subscriber: @brecht

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

I think this has all been addressed by D3057 and c5eba46d7f, so closing.

I think this has all been addressed by [D3057](https://archive.blender.org/developer/D3057) and c5eba46d7f, so closing.
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
7 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#51736
No description provided.