Warning, /graphics/krita/3rdparty/ext_qt/0010-Request-floating-point-format-properly-for-scRGB.patch is written in an unsupported language. File is not indexed.

0001 From a15844e6d0a1ef355c697f9878b583f300f407b9 Mon Sep 17 00:00:00 2001
0002 From: Alvin Wong <alvinhochun@gmail.com>
0003 Date: Tue, 15 Mar 2022 21:11:37 +0800
0004 Subject: [PATCH] Request floating-point format properly for scRGB
0005 
0006 `EGL_EXT_gl_colorspace_scrgb_linear` uses floating-point surface
0007 formats. When calling `eglChooseConfig` for an scRGB surface, we must
0008 pass the attribute `EGL_COLOR_COMPONENT_TYPE_EXT` with the value
0009 `EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT` to request a floating-point format.
0010 Otherwise, `EXT_pixel_format_float` specifies that its default value
0011 will be `EGL_COLOR_COMPONENT_TYPE_FIXED_EXT`.
0012 
0013 It used to work with Qt's copy of ANGLE without specifying this
0014 attribute because it did not have such defaults. proper defaults were
0015 implemented for upstream ANGLE in 2019 [1], therefore it is now
0016 necessary to specify this attribute for it to work (and to be
0017 compliant).
0018 ---
0019  .../platforms/windows/qwindowseglcontext.cpp  | 19 ++++++++++++++++++-
0020  .../platforms/windows/qwindowseglcontext.h    |  3 +++
0021  2 files changed, 21 insertions(+), 1 deletion(-)
0022 
0023 diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
0024 index fc1b3a7..4d2ce9f 100644
0025 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
0026 +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
0027 @@ -201,12 +201,17 @@ QWindowsEGLStaticContext::QWindowsEGLStaticContext(EGLDisplay display)
0028      : m_display(display),
0029        m_hasSRGBColorSpaceSupport(false),
0030        m_hasSCRGBColorSpaceSupport(false),
0031 -      m_hasBt2020PQColorSpaceSupport(false)
0032 +      m_hasBt2020PQColorSpaceSupport(false),
0033 +      m_hasPixelFormatFloatSupport(false)
0034  {
0035      const char *eglExtensions = libEGL.eglQueryString(display, EGL_EXTENSIONS);
0036      m_hasSRGBColorSpaceSupport = strstr(eglExtensions, "EGL_KHR_gl_colorspace") != nullptr;
0037      m_hasSCRGBColorSpaceSupport = strstr(eglExtensions, "EGL_EXT_gl_colorspace_scrgb_linear") != nullptr;
0038      m_hasBt2020PQColorSpaceSupport = strstr(eglExtensions, "EGL_EXT_gl_colorspace_bt2020_pq") != nullptr;
0039 +    m_hasPixelFormatFloatSupport = strstr(eglExtensions, "EGL_EXT_pixel_format_float") != nullptr;
0040 +    if (m_hasSCRGBColorSpaceSupport && !m_hasPixelFormatFloatSupport) {
0041 +        qWarning("EGL: EGL_EXT_gl_colorspace_scrgb_linear supported but EGL_EXT_pixel_format_float not available!");
0042 +    }
0043  }
0044  
0045  bool QWindowsEGLStaticContext::initializeAngle(QWindowsOpenGLTester::Renderers preferredType, HDC dc,
0046 @@ -912,6 +917,18 @@ EGLConfig QWindowsEGLContext::chooseConfig(const QSurfaceFormat &format)
0047      configureAttributes.append(EGL_WINDOW_BIT);
0048      configureAttributes.append(EGL_RENDERABLE_TYPE);
0049      configureAttributes.append(EGL_OPENGL_ES2_BIT);
0050 +    if (format.colorSpace() == QSurfaceFormat::scRGBColorSpace) {
0051 +        if (m_staticContext->hasPixelFormatFloatSupport()) {
0052 +#if defined(QT_OPENGL_ES_2_ANGLE) || defined(QT_OPENGL_DYNAMIC)
0053 +            configureAttributes.append(EGL_COLOR_COMPONENT_TYPE_EXT);
0054 +            configureAttributes.append(EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT);
0055 +#else
0056 +            qWarning("EGL: scRGB requested but we are not using ANGLE!");
0057 +#endif
0058 +        } else {
0059 +            qWarning("EGL: scRGB requested but EGL_EXT_pixel_format_float not available!");
0060 +        }
0061 +    }
0062      configureAttributes.append(EGL_NONE);
0063  
0064      EGLDisplay display = m_staticContext->display();
0065 diff --git a/src/plugins/platforms/windows/qwindowseglcontext.h b/src/plugins/platforms/windows/qwindowseglcontext.h
0066 index 9f7742e..1cf1236 100644
0067 --- a/src/plugins/platforms/windows/qwindowseglcontext.h
0068 +++ b/src/plugins/platforms/windows/qwindowseglcontext.h
0069 @@ -127,6 +127,8 @@ public:
0070  
0071      QSurfaceFormat formatFromConfig(EGLDisplay display, EGLConfig config, const QSurfaceFormat &referenceFormat);
0072  
0073 +    bool hasPixelFormatFloatSupport() const { return m_hasPixelFormatFloatSupport; }
0074 +
0075      static QWindowsLibEGL libEGL;
0076      static QWindowsLibGLESv2 libGLESv2;
0077  
0078 @@ -139,6 +141,7 @@ private:
0079      bool m_hasSRGBColorSpaceSupport;
0080      bool m_hasSCRGBColorSpaceSupport;
0081      bool m_hasBt2020PQColorSpaceSupport;
0082 +    bool m_hasPixelFormatFloatSupport;
0083  };
0084  
0085  class QWindowsEGLContext : public QWindowsOpenGLContext
0086 -- 
0087 2.24.1.windows.2
0088