Cycles: Properly default to Metal-RT off unless GPU is a M3 or newer #120299

Merged
Sergey Sharybin merged 1 commits from Alaska/blender:default-to-metal-rt-off into main 2024-04-09 16:19:37 +02:00
Member

Ever since commit [1], use_metalrt_by_default will be True
if the GPU being used is not a M1 or M2 based system.
The intention of this was to enable MetalRT by default for
M3 and newer devices that have hardware for ray traversal.

However the side effect of this change was that all AMD GPUs would
have use_metalrt_by_default set to True. Which appears to be the
main culprit causing crashes on older AMD GPUs in #120126.
Since these GPUs don't support MetalRT.

This commit fixes this issue by only setting
use_metalrt_by_default to True if the GPU is not M1 or M2 based,
and the GPU is Apple Silicon based. Which equates to M3 or newer.
Which is the original intent of this code.

This resolves the issue where AMD GPUs were being told to use MetalRT
by default, when they shouldn't be.

[1] 322a2f7b12

Ever since commit [1], `use_metalrt_by_default` will be True if the GPU being used is not a M1 or M2 based system. The intention of this was to enable MetalRT by default for M3 and newer devices that have hardware for ray traversal. However the side effect of this change was that all AMD GPUs would have `use_metalrt_by_default` set to True. Which appears to be the main culprit causing crashes on older AMD GPUs in #120126. Since these GPUs don't support MetalRT. This commit fixes this issue by only setting `use_metalrt_by_default` to True if the GPU is not M1 or M2 based, and the GPU is Apple Silicon based. Which equates to M3 or newer. Which is the original intent of this code. This resolves the issue where AMD GPUs were being told to use MetalRT by default, when they shouldn't be. [1] 322a2f7b12bba610a70df3af90e236d0c0ef03f6
Alaska added the
Module
Render & Cycles
label 2024-04-05 13:58:04 +02:00
Alaska added 1 commit 2024-04-05 13:58:13 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2f6048c298
Default to turning Metal-RT off unless the device is a M3 or newer.
This may fix issues with crashes on some AMD GPUs
Alaska requested review from Sergey Sharybin 2024-04-05 13:58:27 +02:00
Alaska requested review from Brecht Van Lommel 2024-04-05 13:58:34 +02:00
Alaska changed title from Cycles: Default to Metal-RT off unless the device is a M3 or newer to Cycles: Properly default to Metal-RT off unless GPU is a M3 or newer 2024-04-05 14:06:37 +02:00
Alaska added this to the Render & Cycles project 2024-04-06 14:58:34 +02:00
Author
Member

It seems this pull request also fixes the performance regression seen on Vega II reported in #120006

I don't believe Vega II officially supports MetalRT, so I assume the performance regression mostly comes from MetalRT being a bit broken/slow on that hardware.

It seems this pull request also fixes the performance regression seen on Vega II reported in #120006 I don't believe Vega II officially supports MetalRT, so I assume the performance regression mostly comes from MetalRT being a bit broken/slow on that hardware.
Author
Member

There is another way of doing this change. Add a NOT_APPLE_SILICON item to the start of the AppleGPUArchitecture enum, then get MetalInfo::get_apple_gpu_architecture() to return NOT_APPLE_SILICON if the GPU vendor is not Apple. This way if any new code in the future makes use of get_apple_gpu_architecture for a similar purpose as the MetalRT check, it also benefits from this change.

If you would prefer this approach, let me know.

There is another way of doing this change. Add a `NOT_APPLE_SILICON` item to the start of the `AppleGPUArchitecture` enum, then get `MetalInfo::get_apple_gpu_architecture()` to return `NOT_APPLE_SILICON` if the GPU vendor is not Apple. This way if any new code in the future makes use of `get_apple_gpu_architecture` for a similar purpose as the MetalRT check, it also benefits from this change. If you would prefer this approach, let me know.

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120299) when ready.
Sergey Sharybin approved these changes 2024-04-09 16:15:08 +02:00
Sergey Sharybin left a comment
Owner

Unfortunately, I can not verify this patch on the current main, as it renders all black (even prior to this patch). So, instead i've tested the patch with 4.1. The timing goes as following:

                                         4.1                  PR120299
attic                                    0.2652s              0.2052s
barbershop_interior                      0.4292s              0.3740s
bistro                                   0.4109s              0.2958s
bmw27                                    0.0211s              0.0212s
classroom                                0.2186s              0.2078s
fishy_cat                                0.0470s              0.0459s
junkshop                                 0.1703s              0.1669s
koro                                     0.2210s              0.0902s
monster                                  0.1018s              0.0873s
pabellon                                 0.0857s              0.1086s
shaderball                               2.2884s              2.4061s
sponza                                   0.0481s              0.0400s
spring                                   7.9825s              0.2572s
victor                                   0.3753s              0.3410s
wdas_cloud                               0.1644s              0.1648s

Overall I think it is safe to assume the patch does what it is expected to do on both reading the code, andtesting the behavior on actual hardware.

Unfortunately, I can not verify this patch on the current main, as it renders all black (even prior to this patch). So, instead i've tested the patch with 4.1. The timing goes as following: ``` 4.1 PR120299 attic 0.2652s 0.2052s barbershop_interior 0.4292s 0.3740s bistro 0.4109s 0.2958s bmw27 0.0211s 0.0212s classroom 0.2186s 0.2078s fishy_cat 0.0470s 0.0459s junkshop 0.1703s 0.1669s koro 0.2210s 0.0902s monster 0.1018s 0.0873s pabellon 0.0857s 0.1086s shaderball 2.2884s 2.4061s sponza 0.0481s 0.0400s spring 7.9825s 0.2572s victor 0.3753s 0.3410s wdas_cloud 0.1644s 0.1648s ``` Overall I think it is safe to assume the patch does what it is expected to do on both reading the code, andtesting the behavior on actual hardware.

There is another way of doing this change. Add a NOT_APPLE_SILICON item to the start of the AppleGPUArchitecture enum, then get MetalInfo::get_apple_gpu_architecture() to return NOT_APPLE_SILICON if the GPU vendor is not Apple. This way if any new code in the future makes use of get_apple_gpu_architecture for a similar purpose as the MetalRT check, it also benefits from this change.

If you would prefer this approach, let me know.

It might indeed be better from code side, but it sounds to be a bigger (and hence more risky change) compared to what you originally proposed here. I think it is better to land the simple and more isolated version first, to allow an easier cherry-picking for 4.1.1.

> There is another way of doing this change. Add a `NOT_APPLE_SILICON` item to the start of the `AppleGPUArchitecture` enum, then get `MetalInfo::get_apple_gpu_architecture()` to return `NOT_APPLE_SILICON` if the GPU vendor is not Apple. This way if any new code in the future makes use of `get_apple_gpu_architecture` for a similar purpose as the MetalRT check, it also benefits from this change. > > If you would prefer this approach, let me know. It might indeed be better from code side, but it sounds to be a bigger (and hence more risky change) compared to what you originally proposed here. I think it is better to land the simple and more isolated version first, to allow an easier cherry-picking for 4.1.1.
Sergey Sharybin merged commit eff4fe24cf into main 2024-04-09 16:19:37 +02:00
Sergey Sharybin deleted branch default-to-metal-rt-off 2024-04-09 16:19:39 +02:00
Author
Member

It might indeed be better from code side, but it sounds to be a bigger (and hence more risky change) compared to what you originally proposed here. I think it is better to land the simple and more isolated version first, to allow an easier cherry-picking for 4.1.1.

Here is that code change: !120448

> It might indeed be better from code side, but it sounds to be a bigger (and hence more risky change) compared to what you originally proposed here. I think it is better to land the simple and more isolated version first, to allow an easier cherry-picking for 4.1.1. Here is that code change: !120448
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 Assignees
3 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#120299
No description provided.