Expose video driver settings on Qt6, sans ANGLE

This commit is contained in:
Damien Elmes 2022-04-03 19:57:30 +10:00
parent 0db921dd39
commit e4f46463f2
3 changed files with 15 additions and 11 deletions

View file

@ -361,9 +361,6 @@ def parseArgs(argv: list[str]) -> tuple[argparse.Namespace, list[str]]:
def setupGL(pm: aqt.profiles.ProfileManager) -> None:
if is_mac:
return
driver = pm.video_driver()
# work around pyqt loading wrong GL library
@ -413,19 +410,23 @@ def setupGL(pm: aqt.profiles.ProfileManager) -> None:
qInstallMessageHandler(msgHandler)
# ignore set graphics driver on Qt6 for now
if qtmajor > 5:
return
if driver == VideoDriver.OpenGL:
# Leaving QT_OPENGL unset appears to sometimes produce different results
# to explicitly setting it to 'auto'; the former seems to be more compatible.
pass
else:
if is_win:
# on Windows, this appears to be sufficient on Qt5/Qt6.
# On Qt6, ANGLE is excluded by the enum.
os.environ["QT_OPENGL"] = driver.value
elif is_mac:
QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
elif is_lin:
# Qt5 only
os.environ["QT_XCB_FORCE_SOFTWARE_OPENGL"] = "1"
# Required on Qt6
if "QTWEBENGINE_CHROMIUM_FLAGS" not in os.environ:
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--disable-gpu"
PROFILE_CODE = os.environ.get("ANKI_PROFILE_CODE")

View file

@ -290,7 +290,6 @@ class Preferences(QDialog):
self.form.video_driver.setCurrentIndex(
self.video_drivers.index(self.mw.pm.video_driver())
)
self.form.video_driver.setVisible(qtmajor == 5)
def update_video_driver(self) -> None:
new_driver = self.video_drivers[self.form.video_driver.currentIndex()]

View file

@ -44,22 +44,26 @@ class VideoDriver(Enum):
return VideoDriver.Software
def constrained_to_platform(self) -> VideoDriver:
if self == VideoDriver.ANGLE and not is_win:
if self == VideoDriver.ANGLE and not VideoDriver.supports_angle():
return VideoDriver.Software
return self
def next(self) -> VideoDriver:
if self == VideoDriver.Software:
return VideoDriver.OpenGL
elif self == VideoDriver.OpenGL and is_win:
elif self == VideoDriver.OpenGL and VideoDriver.supports_angle():
return VideoDriver.ANGLE
else:
return VideoDriver.Software
@staticmethod
def supports_angle() -> bool:
return is_win and qtmajor < 6
@staticmethod
def all_for_platform() -> list[VideoDriver]:
all = [VideoDriver.OpenGL]
if is_win:
if VideoDriver.supports_angle():
all.append(VideoDriver.ANGLE)
all.append(VideoDriver.Software)
return all