Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Radeon performance woes #300

Closed
waywardmonkeys opened this issue Apr 15, 2020 · 12 comments
Closed

macOS Radeon performance woes #300

waywardmonkeys opened this issue Apr 15, 2020 · 12 comments
Labels

Comments

@waywardmonkeys
Copy link

@waywardmonkeys waywardmonkeys commented Apr 15, 2020

It appears to be compiling shaders constantly as seen in the
attached Instruments screenshot.

Screen Shot 2020-04-15 at 11 16 29 PM

My system is:

Model Name: MacBook Pro
Model Identifier: MacBookPro14,3
Processor Name: Intel Core i7
Processor Speed: 2.9 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB

System Version: macOS 10.14.6 (18G3020)
Kernel Version: Darwin 18.7.0

And my graphics / display hardware is:

Radeon Pro 560:

Chipset Model: Radeon Pro 560
Type: GPU
Bus: PCIe
PCIe Lane Width: x8
VRAM (Total): 4 GB
Vendor: AMD (0x1002)
Device ID: 0x67ef
Revision ID: 0x00c0
ROM Revision: 113-C980AJ-927
VBIOS Version: 113-C9801AU-A02
EFI Driver Version: 01.A0.927
Automatic Graphics Switching: Supported
gMux Version: 4.0.29 [3.2.8]
Metal: Supported, feature set macOS GPUFamily2 v1
Displays:
Color LCD:
Display Type: Built-In Retina LCD
Resolution: 2880 x 1800 Retina
Framebuffer Depth: 30-Bit Color (ARGB2101010)
Main Display: Yes
Mirror: Off
Online: Yes
Rotation: Supported
Automatically Adjust Brightness: No
LG UltraFine:
Resolution: 5120 x 2880 (5K/UHD+ - Ultra High Definition Plus)
UI Looks like: 2560 x 1440 @ 60 Hz
Framebuffer Depth: 30-Bit Color (ARGB2101010)
Display Serial Number: 910NTXRBJ538
Mirror: Off
Online: Yes
Rotation: Supported
Automatically Adjust Brightness: No
Connection Type: DisplayPort

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Apr 17, 2020

I've long had issues with Radeon OpenGL drivers on macOS. The solution may just be to move to the Metal backend…

@cemelo
Copy link

@cemelo cemelo commented Apr 19, 2020

I did some quick and dirty® change from OpenGL to Metal and, although performance improved significantly, it still had pretty low fps. (Compiled with --release)

ezgif com-video-to-gif

https://gist.github.com/cemelo/213fcccad2605c9c4e61cd85355a59eb

Specs:

Captura de Tela 2020-04-19 às 15 09 16

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Apr 21, 2020

Yeah, I've consistently noticed performance problems with Radeon. It may have to do with the floating point render targets. On macOS I usually use Intel. Switching to surfman will let us do that.

@pcwalton pcwalton changed the title Performance problem with canvas_nanovg on macOS macOS Radeon performance woes Apr 21, 2020
@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Apr 30, 2020

I've found a fix for this and it will probably land as part of the compute shader work I'm doing right now.

@cemelo
Copy link

@cemelo cemelo commented Apr 30, 2020

Awesome! Thanks, Patrick.

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Apr 30, 2020

This is significantly improved now.

@pcwalton pcwalton added the performance label May 1, 2020
@waywardmonkeys
Copy link
Author

@waywardmonkeys waywardmonkeys commented May 1, 2020

I'm still seeing this happen when using AMD graphics (to drive external monitor). When I unplug that and switch to Intel, this goes away.

Doing some more research, and it sounds like when some shader state changes, the driver is incorrectly deciding it needs to recompile the shader.

There are discussions of similar things around:

@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented May 8, 2020

What about the Metal backend?

@cemelo
Copy link

@cemelo cemelo commented May 9, 2020

I haven't tried to port the code to use the Metal backend directly, but trying it out using surfman and using the low power adaptor, I get a framerate of ~60fps.

Switching it over to hardware adaptor, it hangs as if it was in a busy loop. It shows a framerate of ~95fps, but that's clearly not true, as the screen freezes for a couple of seconds, refreshes, then freezes again.

Another thing I noticed is that, if you're using an external monitor, it doesn't matter whether you choose low power or hardware, it will always use the AMD GPU.

All above applies only to the canvas_nanovg example. I tried out the native demo, and it worked correctly, both on high performance and low power, even with an external monitor.

pcwalton added a commit to pcwalton/pathfinder that referenced this issue May 13, 2020
…to work

around a macOS Radeon driver bug.

Also, ensure there is always a dummy texture bound to every parameter in the
OpenGL backend.

These together stop the macOS Radeon drivers from recompiling the shader on
every drawcall.

Possibly addresses servo#300.
@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented May 13, 2020

OK, with #337, the OpenGL Radeon backend on macOS seems to have better performance than Metal for me.

@cemelo
Copy link

@cemelo cemelo commented May 13, 2020

Woah! This is looking great now!

The GIF doesn't do justice, but you can see by the framerates that the animation runs smoothly. Also, you can see it's using the Radeon GPU, even though the example asks for a low power adapter. I guess this is because I'm using an external monitor.

In my machine, FPS on Radeon is roughly twice as much as using Intel, and GPU time ~50%.

Thank you, @pcwalton!

ezgif-1-a2b38543fd19

@pcwalton pcwalton closed this Jul 28, 2020
@pcwalton
Copy link
Collaborator

@pcwalton pcwalton commented Jul 28, 2020

Closing as this seems resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.