revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

feat(window): Add option for choosing acceleration strategy #984

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

This change adds an option when creating a window to determine the acceleration strategy:

The motivation for this change comes from investigating https://github.com/onivim/oni2/issues/2225 https://github.com/onivim/oni2/issues/1185 - it seems that, in some multiple-display cases, there may not be a hardware-accelerated renderer available.

In that case, Onivim fails to start (no pixel format available) - because when it queries the available renderers, there is none matching a hardware-supported OGL context.

This can also allow Onivim to have a configuration setting - --gpu-acceleration=hardware/--gpu-acceleration=software/--gpu-acceleration=auto (default)

I believe this should fix #2225 and #1185 once brought into Onivim (with the caveat that the software renderer will be used, which may have perf implications - but the OpenGL software implementation on Apple actually seems pretty performant...)

zbaylin commented 4 years ago

Mostly unrelated to this PR, but would it ever be possible to use Metal rather than OpenGL on macOS? Considering OpenGL on macOS has been deprecated since 10.14 and Apple seemingly has no problem breaking compatibility with "old" software (re: x86 → ARM), it might not be too much longer until OpenGL is removed

bryphe commented 4 years ago

Mostly unrelated to this PR, but would it ever be possible to use Metal rather than OpenGL on macOS?

@zbaylin - Yes, good question, there are two options:

1) ANGLE also has planned/in-progress support for Metal: image

2) Skia also has a Vulkan backend, and SDL supports creating a Vulkan instance

I think 2 - Vulkan backend - is the most likely route; and maybe can even be prototyped once we upgrade to latest Skia

zbaylin commented 4 years ago

Awesome @bryphe -- that will be really nice to have!