Metal Backend: Add fallback for Add-ons that use BGL or Incorrect shader-code with GPU module. #103863

Closed
opened 2023-01-13 15:48:54 +01:00 by Jeroen Bakker · 6 comments
Member

In order to make metal default for blender it should not crash when add-ons are enabled that use the BGL module or has shaders that don't compile on Metal.
The idea as discussed is to have a fallback opengl context around where GL calls can be passed to, so it doesn't fail when Metal backend isn't supported. This fallback won't draw/read from the screen, it only makes sure that Blender doesn't crash. Perhaps in stead of an OpenGL context we could create a dummy context where unsupported calls will land.

Looking at how BGL accesses OpenGL we could modify the BGL_Wrap to do nothing when Metal is the active backend.

See release/scripts/addons/measureit/measureit_render.py.

buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4)
        bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0)
        bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)```

In the case shaders cannot compile the metal backend will set a flag that will control an error message to be displayed to the user.

In order to make metal default for blender it should not crash when add-ons are enabled that use the BGL module or has shaders that don't compile on Metal. The idea as discussed is to have a fallback opengl context around where GL calls can be passed to, so it doesn't fail when Metal backend isn't supported. This fallback won't draw/read from the screen, it only makes sure that Blender doesn't crash. Perhaps in stead of an OpenGL context we could create a dummy context where unsupported calls will land. Looking at how BGL accesses OpenGL we could modify the `BGL_Wrap` to do nothing when Metal is the active backend. See `release/scripts/addons/measureit/measureit_render.py`. ``` buffer = bgl.Buffer(bgl.GL_BYTE, width * height * 4) bgl.glReadBuffer(bgl.GL_COLOR_ATTACHMENT0) bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)``` In the case shaders cannot compile the metal backend will set a flag that will control an error message to be displayed to the user.
Jeroen Bakker self-assigned this 2023-01-13 15:48:54 +01:00
Author
Member
Added subscribers: @Jeroen-Bakker, @Michael-Parkin-White-Apple
Author
Member

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

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

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123

Added subscriber: @mycoconut

Added subscriber: @mycoconut

This issue was referenced by cac6b6f388

This issue was referenced by cac6b6f388812cb3f0d0e2515fa4ac7f13335903
Member

Added subscriber: @Alaska

Added subscriber: @Alaska
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-02-08 09:41:42 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
5 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#103863
No description provided.