Add ANGLE renderer support on Windows
Closed, ResolvedPublic

Description

From https://chromium.googlesource.com/angle/angle/+/master/README.md

ANGLE - Almost Native Graphics Layer Engine

The goal of ANGLE is to allow users of multiple operating systems to seamlessly run WebGL and other OpenGL ES content by translating OpenGL ES API calls to one of the hardware-supported APIs available for that platform. ANGLE currently provides translation from OpenGL ES 2.0 and 3.0 to desktop OpenGL, OpenGL ES, Direct3D 9, and Direct3D 11. Support for translation from OpenGL ES to Vulkan is underway, and future plans include compute shader support (ES 3.1) and MacOS support.

Further reading:


  • Qt supports using ANGLE and has it included in their source tree.
  • Sincd Qt 5.4 it can be compiled to dynamically choose to use desktop OpenGL (installed hardware driver), ANGLE, or a software OpenGL implementation (MESA Gallium llvmpipe).
  • ANGLE appears to implement the complete OpenGL ES 3.0. It requires Direct3D11 which is the version that comes with Windows 7 RTM, and it also supports WARP (built-in high-speed D3D11 software implementation), so it should be a suitable alternative for Windows users with broken OpenGL drivers. (We don't officially care Vista or below.)

Aim:

  • Krita can support OpenGL ES 3.0 (ANGLE can be considered to be a reference implementation)
  • Windows users with broken OpenGL drivers might be able to have GPU-accelerated canvas
  • Make use of QT_OPENGL_BUGLIST to ban known broken hardware/drivers from using OpenGL

Current tasks / progress w/ notes:

  • Compile Qt 5.9.1 with -opengl dynamic
    • I installed the DirectX June 2010 SDK and had to patch some files manually to get it to compile ANGLE properly. These might not be necessary in the future (but fxc.exe is still needed) when upstream fixed the support: https://bugreports.qt.io/browse/QTBUG-52487
  • Start Krita with ANGLE without crash (set env QT_OPENGL=angle)
    • Have to disable glLogicOp in libs/ui/opengl/kis_opengl_canvas2.cpp (revert D4506, which unfortunately will cause the selection and brush outline to be green again)
    • Need to change shader version string to #version 300 es and add a line to fragment shader to set float precision
  • Get canvas to render properly
    • Area outside of canvas is painted in grey, which is correct.
    • Checkerboard texture format has to be changed to GL_RGBA instead of GL_BGRA which is not supported by OpenGL ES 3.0. (AFAIK this change should also work for desktop OpenGL.)
    • Canvas transformations works properly (pan rotate zoom)
    • Brush outline (albeit in green), guides, grids, etc. paints without issues
    • Image data drawn onto canvas is completely black, suspect problem with texture format and binding, verified that text coords are correct and fragment shader can output colours.
    • The texture formats are changed to support OpenGL ES 3 (and extensions).
  • (!) Check the texture pixel formats to make sure they map to D3D11 texture formats directly to avoid additional conversion in ANGLE.
  • (!) Fix 10-bit display support (if it even works with ANGLE at all)
  • (!) Make sure build system works properly

How to test with ANGLE:

  1. Checkout branch alvin/T6696-opengl-angle
  2. Add patch set 5 of this code review to ext_qt (add qtbase to the diff paths)
  3. Add the patch at this comment on QTBUG-52487 to ext_qt (add qtbase to the diff paths)
  4. Apply P84
  5. Set the WindowsSdkDir environment variable to the Window 10 SDK (probably C:\Program Files (x86)\Windows Kits\10)
  6. Do 3rdparty dependencies build
  7. Do Krita build.
  8. Run Krita with the environment variable QT_OPENGL set to angle.

Additional:

Env variables:

  • QT_OPENGL
    • desktop: installed OpenGL driver
    • angle
    • software: use ./opengl32sw.dll as driver if available
  • QT_ANGLE_PLATFORM
    • d3d11
    • d3d9: not useful
    • warp: software D3D11 renderer
  • QT_LOGGING_RULES=qt.qpa.gl=true;krita.ui=true for debugging
  • QSG_INFO=1 also for debugging
  • QT_OPENGL_BUGLIST to specify custom buglist

My own built ANGLE (built with Qt) does not spit debug messages and I got a crash with WARP, so I copied the DLLs from Chrome for testing. They work fine.

Related Objects

alvinhochun renamed this task from Support using ANGLE for OpenGL canvas on Windows (i.e. OpenGL ES 3.0 support) to Support using ANGLE for OpenGL canvas on Windows (also OpenGL ES 3.0 support).Aug 1 2017, 7:31 PM
alvinhochun updated the task description. (Show Details)
alvinhochun updated the task description. (Show Details)Aug 2 2017, 1:30 PM
alvinhochun updated the task description. (Show Details)Aug 2 2017, 5:37 PM
alvinhochun updated the task description. (Show Details)Aug 3 2017, 5:45 AM
alvinhochun updated the task description. (Show Details)Aug 3 2017, 9:13 AM
alvinhochun updated the task description. (Show Details)Aug 3 2017, 3:53 PM
alvinhochun updated the task description. (Show Details)Aug 3 2017, 4:53 PM
alvinhochun renamed this task from Support using ANGLE for OpenGL canvas on Windows (also OpenGL ES 3.0 support) to Add ANGLE renderer support on Windows.Aug 5 2017, 4:44 PM
alvinhochun updated the task description. (Show Details)
alvinhochun updated the task description. (Show Details)Aug 6 2017, 12:17 PM

Merged to moth master and krita/3.3

These changes should be made for the documentation:

  • Mentions to the "OpenGL" checkbox config should be changed to "Canvas Graphics Acceleration"
  • In addition, for Windows there is the "Renderer" combobox option:
    • Recommend to set at "Auto (xxx)"
    • The other two options are "OpenGL" and "Direct3D 11 via ANGLE"
    • "xxx" in the parentheses shows the default renderer that is preferred by Qt (or when it's the only supported renderer on the system).
    • If default is "Auto (OpenGL)" but gets buggy canvas, please try "Direct3D11 via ANGLE", and report to the bug tracker with the info from "Help" -> "Show system information for bug reports"
    • If either one of OpenGL or ANGLE is not supported on a certain system, the unsupported option will not appear on the dropdown.
  • Rewrite the sections about Intel OpenGL in the FAQ
alvinhochun closed this task as Resolved.Sep 21 2017, 4:42 PM