[vlc-commits] [Git][videolan/vlc][master] 7 commits: qt: target minimum GLSL 1.30 and ESSL 3.00 when shader baking

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Sep 1 21:05:21 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
5d318868 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qt: target minimum GLSL 1.30 and ESSL 3.00 when shader baking

This is so that we can make use of `textureSize()`.

This increases the minimum required OpenGL version to 3.0,
which deviates from Qt 6's default of OpenGL 2.0.

- - - - -
ee3d7703 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qt: probe rhi in non-windows cases

This is to make sure the needed OpenGL (ES)
version (3.0) is used.

- - - - -
369bc56a by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qt: normalize the rectangle directly in `SubTexture.vert`

- - - - -
6013c179 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qt: use `textureSize()` in `SDFAARoundedTexture.frag`

- - - - -
79e637c3 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qml: do not provide native texture size to the shader in `ImageExt`

- - - - -
f82ba866 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qt: use `textureSize()` in `DualKawaseBlur.frag`

- - - - -
5af04b44 by Fatih Uzunoglu at 2026-09-01T22:56:06+02:00
qml: do not provide native texture size to the shader in `DualKawaseBlur`

- - - - -


12 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/qt.cpp
- modules/gui/qt/shaders/DualKawaseBlur.frag
- modules/gui/qt/shaders/DualKawaseBlur_downsample.frag
- modules/gui/qt/shaders/DualKawaseBlur_upsample.frag
- modules/gui/qt/shaders/DualKawaseBlur_upsample_postprocess.frag
- modules/gui/qt/shaders/SDFAARoundedTexture.frag
- modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
- modules/gui/qt/shaders/SubTexture.vert
- modules/gui/qt/shaders/meson.build
- modules/gui/qt/widgets/qml/DualKawaseBlur.qml
- modules/gui/qt/widgets/qml/ImageExt.qml


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -1485,7 +1485,7 @@ BUILT_SOURCES += \
     $(libqt_plugin_la_SHADER_FRAG:.frag=.frag.qsb) \
     $(libqt_plugin_la_SHADER_VERT:.vert=.vert.qsb)
 
-QSB_PARAMS = --glsl="100 es,120,150" --batchable -O
+QSB_PARAMS = --glsl="300 es,130,150" --batchable -O
 if HAVE_WIN32
 QSB_PARAMS += --hlsl=50 -c
 endif


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -59,12 +59,24 @@ extern "C" char **environ;
 #include <QQmlError>
 #include <QList>
 #include <QTranslator>
-#ifdef _WIN32
-#include <QOperatingSystemVersion>
-#include <QThreadPool>
-#include "util/asynctask.hpp"
+
+#if __has_include(<rhi/qrhi.h>) // Qt 6.6
+#define RHI_HEADER_AVAILABLE
 #include <rhi/qrhi.h>
+#elif __has_include(<QtGui/private/qrhi_p.h>) && \
+      QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) // `QRhi::probe()` is available since Qt 6.4
+#define RHI_HEADER_AVAILABLE
+#include <QtGui/private/qrhi_p.h>
+#include <QtGui/private/qrhigles2_p.h> // for `QRhiGles2InitParams`
+#endif
+#ifdef RHI_HEADER_AVAILABLE
 #include <QOffscreenSurface>
+#include <QThreadPool>
+#include "util/asynctask.hpp"
+#endif
+
+#ifdef _WIN32
+#include <QOperatingSystemVersion>
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
@@ -109,6 +121,7 @@ extern "C" char **environ;
 #include <vlc_messages.h>
 
 #include <QQuickWindow>
+#include <QOpenGLContext> // Available in Qt GUI, no need for Qt OpenGL module
 
 #ifndef X_DISPLAY_MISSING
 # include <vlc_xlib.h>
@@ -962,13 +975,47 @@ static void *Thread( void *obj )
 #endif
             QSettings::UserScope, "vlc", "vlc-qt-interface" );
 
-#if defined(_WIN32)
+    // It is guaranteed that the returned format is supported, if a format is returned.
+    static const auto createCompatibleOpenGLFormat = []() -> std::optional<QSurfaceFormat> {
+        QOpenGLContext defaultCtx;
+        // This is really unnecessary to check, since Qt should not be using unavailable contexts, but nevertheless.
+        if (Q_UNLIKELY(!defaultCtx.create()))
+            return std::nullopt;
+
+        const QSurfaceFormat format = defaultCtx.format();
+
+        if (format.majorVersion() >= 3) // We need OpenGL (ES) 3.0 since our shaders use `textureSize()`.
+            return format;
+
+        QSurfaceFormat compatibleFormat = format;
+        compatibleFormat.setMajorVersion(3);
+        compatibleFormat.setMinorVersion(0);
+
+        // OpenGL ES does not have core/compatibility profiles:
+        if (compatibleFormat.renderableType() == QSurfaceFormat::OpenGL)
+            compatibleFormat.setProfile(QSurfaceFormat::CoreProfile);
+
+        QOpenGLContext ctx;
+        ctx.setFormat(compatibleFormat);
+
+        if (!ctx.create() || ctx.format().majorVersion() < 3)
+        {
+            qCritical() << "OpenGL (ES) 3.0 context creation failed.";
+            return std::nullopt;
+        }
+        else
+        {
+            return compatibleFormat;
+        }
+    };
+
+#ifdef RHI_HEADER_AVAILABLE
     // NOTE: Qt Quick does not have a cross-API RHI fallback procedure (as of Qt 6.7.1).
     //       We have to manually pick a graphics api here, since the default graphics
     //       api (Direct3D 11.2) may not be supported.
     static const auto probeRhi = []() -> QPair<QSGRendererInterface::GraphicsApi,
                                                bool /* software through rhi, such as d3d warp */> {
-
+#if defined(_WIN32)
         // TODO: Investigate if we should use D3D12. Currently it is not the default by
         //       Qt (as of Qt 6.8), and is not as battle tested as the default D3D11.
 #ifndef NDEBUG
@@ -994,16 +1041,25 @@ static void *Thread( void *obj )
                 return {QSGRendererInterface::Direct3D11, false};
             }
         }
+#endif
 
         std::optional<QPair<QSGRendererInterface::GraphicsApi, bool>> retGlProbe;
         QMetaObject::invokeMethod(qApp, [&retGlProbe]() {
             // Due to offscreen surface involvement, this has to be done in the
             // gui thread only:
             QRhiGles2InitParams params;
+
+            const std::optional<QSurfaceFormat> format = createCompatibleOpenGLFormat();
+            if (format)
+                params.format = *format;
+            else
+                return;
+
             params.fallbackSurface = QRhiGles2InitParams::newFallbackSurface();
             if (QRhi::probe(QRhi::OpenGLES2, &params))
             {
                 retGlProbe = {QSGRendererInterface::OpenGL, false};
+                QSurfaceFormat::setDefaultFormat(*format);
             }
             delete params.fallbackSurface;
         }, Qt::BlockingQueuedConnection);
@@ -1013,6 +1069,7 @@ static void *Thread( void *obj )
         // TODO: Investigate if using Vulkan makes sense on Windows.
         // TODO: Investigate if it makes sense to try D3D12 when probing D3D11 failed.
 
+#if defined(_WIN32)
         {
             // D3D11 Warp:
 
@@ -1031,6 +1088,7 @@ static void *Thread( void *obj )
                 return {QSGRendererInterface::Direct3D11, true};
             }
         }
+#endif
 
         // Qt's own software renderer, it can not display shader effects and is very
         // primitive. Used as last resort:
@@ -1121,6 +1179,23 @@ static void *Thread( void *obj )
             p_intf->mainSettings->sync();
         }
     }
+#else
+    if (qEnvironmentVariable("QT_QUICK_BACKEND", QStringLiteral("rhi")) == QLatin1String("rhi"))
+    {
+        if (QQuickWindow::graphicsApi() == QSGRendererInterface::OpenGL)
+        {
+            // At least set the default format without RHI probing if RHI headers are not available:
+            if (std::optional<QSurfaceFormat> format = createCompatibleOpenGLFormat())
+            {
+                QSurfaceFormat::setDefaultFormat(*format);
+            }
+            else
+            {
+                qCritical() << "Falling back to software mode...";
+                QQuickWindow::setGraphicsApi(QSGRendererInterface::Software);
+            }
+        }
+    }
 #endif
 
     app.setApplicationDisplayName( qtr("VLC media player") );


=====================================
modules/gui/qt/shaders/DualKawaseBlur.frag
=====================================
@@ -29,8 +29,7 @@ layout(std140, binding = 0) uniform qt_buf {
     mat4 qt_Matrix;
     float qt_Opacity;
 
-    vec4 normalRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
-    vec2 sourceTextureSize;
+    vec4 subRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
     int radius;
 
 #ifdef POSTPROCESS
@@ -96,25 +95,10 @@ void main()
     // sub-textures, so we don't need to calculate here:
     vec2 uv = qt_TexCoord0;
 
-    // We need to be careful to calculate the halfpixel properly for sub- and atlas textures:
-    // If sourceTextureSize is sourced from QML, such as `Image`'s implicit size which normally
-    // matches the texture size 1:1, if the texture is a sub-texture or atlas texture, the
-    // texture size would not reflect the actual texture size. For that, we need to divide
-    // `sourceTextureSize` by `qt_SubRect_source.zw` to get the actual texture size (which
-    // means the atlas size, for example). This was the case in the first iteration, however
-    // we started using a C++ utility class to get the texture size directly, so now we can
-    // use it as is. The disadvantage is that the size needs to hop through the QML engine,
-    // essentially SG -> QML -> SG (here), which may delay having the correct size here. If
-    // we use GLSL 1.30 feature `textureSize()` instead, this would not be an issue. Currently
-    // we can not do that because even though the shaders are written in GLSL 4.40, we target
-    // as low as GLSL 1.20/ESSL 1.0. But maybe this is not a big deal, because if the size
-    // (or texture altogether) changes, `QSGTextureProvider::textureChanged()` may need to
-    // be processed in QML anyway (so the new size comes at the same time as the texture updates).
-    // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `(radius - 0.5) / textureSize(source, 0)` instead.
     // TODO: This may be done in the vertex shader. I have not done that as this is a very simple
     //       calculation, and custom vertex shader in `ShaderEffect` breaks batching (which is not
     //       really important with the blur effect, so maybe it makes sense).
-    vec2 halfpixel = (radius - 0.5) / sourceTextureSize;
+    vec2 halfpixel = (radius - 0.5) / textureSize(source, 0);
 
     vec4 result = SAMPLE(uv, halfpixel);
 


=====================================
modules/gui/qt/shaders/DualKawaseBlur_downsample.frag
=====================================
@@ -33,8 +33,7 @@ layout(std140, binding = 0) uniform qt_buf {
     mat4 qt_Matrix;
     float qt_Opacity;
 
-    vec4 normalRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
-    vec2 sourceTextureSize;
+    vec4 subRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
     int radius;
 
 #ifdef POSTPROCESS
@@ -100,25 +99,10 @@ void main()
     // sub-textures, so we don't need to calculate here:
     vec2 uv = qt_TexCoord0;
 
-    // We need to be careful to calculate the halfpixel properly for sub- and atlas textures:
-    // If sourceTextureSize is sourced from QML, such as `Image`'s implicit size which normally
-    // matches the texture size 1:1, if the texture is a sub-texture or atlas texture, the
-    // texture size would not reflect the actual texture size. For that, we need to divide
-    // `sourceTextureSize` by `qt_SubRect_source.zw` to get the actual texture size (which
-    // means the atlas size, for example). This was the case in the first iteration, however
-    // we started using a C++ utility class to get the texture size directly, so now we can
-    // use it as is. The disadvantage is that the size needs to hop through the QML engine,
-    // essentially SG -> QML -> SG (here), which may delay having the correct size here. If
-    // we use GLSL 1.30 feature `textureSize()` instead, this would not be an issue. Currently
-    // we can not do that because even though the shaders are written in GLSL 4.40, we target
-    // as low as GLSL 1.20/ESSL 1.0. But maybe this is not a big deal, because if the size
-    // (or texture altogether) changes, `QSGTextureProvider::textureChanged()` may need to
-    // be processed in QML anyway (so the new size comes at the same time as the texture updates).
-    // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `(radius - 0.5) / textureSize(source, 0)` instead.
     // TODO: This may be done in the vertex shader. I have not done that as this is a very simple
     //       calculation, and custom vertex shader in `ShaderEffect` breaks batching (which is not
     //       really important with the blur effect, so maybe it makes sense).
-    vec2 halfpixel = (radius - 0.5) / sourceTextureSize;
+    vec2 halfpixel = (radius - 0.5) / textureSize(source, 0);
 
     vec4 result = SAMPLE(uv, halfpixel);
 


=====================================
modules/gui/qt/shaders/DualKawaseBlur_upsample.frag
=====================================
@@ -33,8 +33,7 @@ layout(std140, binding = 0) uniform qt_buf {
     mat4 qt_Matrix;
     float qt_Opacity;
 
-    vec4 normalRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
-    vec2 sourceTextureSize;
+    vec4 subRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
     int radius;
 
 #ifdef POSTPROCESS
@@ -100,25 +99,10 @@ void main()
     // sub-textures, so we don't need to calculate here:
     vec2 uv = qt_TexCoord0;
 
-    // We need to be careful to calculate the halfpixel properly for sub- and atlas textures:
-    // If sourceTextureSize is sourced from QML, such as `Image`'s implicit size which normally
-    // matches the texture size 1:1, if the texture is a sub-texture or atlas texture, the
-    // texture size would not reflect the actual texture size. For that, we need to divide
-    // `sourceTextureSize` by `qt_SubRect_source.zw` to get the actual texture size (which
-    // means the atlas size, for example). This was the case in the first iteration, however
-    // we started using a C++ utility class to get the texture size directly, so now we can
-    // use it as is. The disadvantage is that the size needs to hop through the QML engine,
-    // essentially SG -> QML -> SG (here), which may delay having the correct size here. If
-    // we use GLSL 1.30 feature `textureSize()` instead, this would not be an issue. Currently
-    // we can not do that because even though the shaders are written in GLSL 4.40, we target
-    // as low as GLSL 1.20/ESSL 1.0. But maybe this is not a big deal, because if the size
-    // (or texture altogether) changes, `QSGTextureProvider::textureChanged()` may need to
-    // be processed in QML anyway (so the new size comes at the same time as the texture updates).
-    // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `(radius - 0.5) / textureSize(source, 0)` instead.
     // TODO: This may be done in the vertex shader. I have not done that as this is a very simple
     //       calculation, and custom vertex shader in `ShaderEffect` breaks batching (which is not
     //       really important with the blur effect, so maybe it makes sense).
-    vec2 halfpixel = (radius - 0.5) / sourceTextureSize;
+    vec2 halfpixel = (radius - 0.5) / textureSize(source, 0);
 
     vec4 result = SAMPLE(uv, halfpixel);
 


=====================================
modules/gui/qt/shaders/DualKawaseBlur_upsample_postprocess.frag
=====================================
@@ -34,8 +34,7 @@ layout(std140, binding = 0) uniform qt_buf {
     mat4 qt_Matrix;
     float qt_Opacity;
 
-    vec4 normalRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
-    vec2 sourceTextureSize;
+    vec4 subRect; // unused, but Qt needs it as it used in first-pass vertex shader for sub-texturing (Qt bug?)
     int radius;
 
 #ifdef POSTPROCESS
@@ -101,25 +100,10 @@ void main()
     // sub-textures, so we don't need to calculate here:
     vec2 uv = qt_TexCoord0;
 
-    // We need to be careful to calculate the halfpixel properly for sub- and atlas textures:
-    // If sourceTextureSize is sourced from QML, such as `Image`'s implicit size which normally
-    // matches the texture size 1:1, if the texture is a sub-texture or atlas texture, the
-    // texture size would not reflect the actual texture size. For that, we need to divide
-    // `sourceTextureSize` by `qt_SubRect_source.zw` to get the actual texture size (which
-    // means the atlas size, for example). This was the case in the first iteration, however
-    // we started using a C++ utility class to get the texture size directly, so now we can
-    // use it as is. The disadvantage is that the size needs to hop through the QML engine,
-    // essentially SG -> QML -> SG (here), which may delay having the correct size here. If
-    // we use GLSL 1.30 feature `textureSize()` instead, this would not be an issue. Currently
-    // we can not do that because even though the shaders are written in GLSL 4.40, we target
-    // as low as GLSL 1.20/ESSL 1.0. But maybe this is not a big deal, because if the size
-    // (or texture altogether) changes, `QSGTextureProvider::textureChanged()` may need to
-    // be processed in QML anyway (so the new size comes at the same time as the texture updates).
-    // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `(radius - 0.5) / textureSize(source, 0)` instead.
     // TODO: This may be done in the vertex shader. I have not done that as this is a very simple
     //       calculation, and custom vertex shader in `ShaderEffect` breaks batching (which is not
     //       really important with the blur effect, so maybe it makes sense).
-    vec2 halfpixel = (radius - 0.5) / sourceTextureSize;
+    vec2 halfpixel = (radius - 0.5) / textureSize(source, 0);
 
     vec4 result = SAMPLE(uv, halfpixel);
 


=====================================
modules/gui/qt/shaders/SDFAARoundedTexture.frag
=====================================
@@ -49,7 +49,6 @@ layout(std140, binding = 0) uniform buf {
 #endif
 #ifdef CROP_SUPPORT
     int shouldCrop; // WARNING: intentionally not a boolean
-    vec2 sourceTextureSize; // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `textureSize()` instead.
 #endif
 #ifdef BACKGROUND_SUPPORT
     vec4 backgroundColor;
@@ -116,7 +115,8 @@ void main()
     {
         vec2 texCoord;
 
-        vec2 denormalSubTextureSize = vec2(sourceTextureSize.x * qt_SubRect_source.z, sourceTextureSize.y * qt_SubRect_source.w);
+        vec2 texSize = textureSize(source, 0);
+        vec2 denormalSubTextureSize = vec2(texSize.x * qt_SubRect_source.z, texSize.y * qt_SubRect_source.w);
 
         float implicitRatio = denormalSubTextureSize.x / denormalSubTextureSize.y;
         float ratio = size.x / size.y;


=====================================
modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
=====================================
@@ -62,7 +62,6 @@ layout(std140, binding = 0) uniform buf {
 #endif
 #ifdef CROP_SUPPORT
     int shouldCrop; // WARNING: intentionally not a boolean
-    vec2 sourceTextureSize; // TODO: Ditch targeting GLSL 1.20/ESSL 1.0, and use `textureSize()` instead.
 #endif
 #ifdef BACKGROUND_SUPPORT
     vec4 backgroundColor;
@@ -129,7 +128,8 @@ void main()
     {
         vec2 texCoord;
 
-        vec2 denormalSubTextureSize = vec2(sourceTextureSize.x * qt_SubRect_source.z, sourceTextureSize.y * qt_SubRect_source.w);
+        vec2 texSize = textureSize(source, 0);
+        vec2 denormalSubTextureSize = vec2(texSize.x * qt_SubRect_source.z, texSize.y * qt_SubRect_source.w);
 
         float implicitRatio = denormalSubTextureSize.x / denormalSubTextureSize.y;
         float ratio = size.x / size.y;


=====================================
modules/gui/qt/shaders/SubTexture.vert
=====================================
@@ -25,12 +25,14 @@ layout(std140, binding = 0) uniform buf {
     mat4 qt_Matrix;
     float qt_Opacity;
 
-    vec4 normalRect;
+    vec4 subRect;
 };
 
+layout(binding = 1) uniform sampler2D source;
+
 void main() {
-    // TODO: With GLSL 1.30, we can use `textureSize()` and normalize the coordinate here,
-    //       rather than asking an already normalized rectangle.
-    qt_TexCoord0 = normalRect.xy + normalRect.zw * qt_MultiTexCoord0;
+    vec2 size = textureSize(source, 0);
+
+    qt_TexCoord0 = vec2(subRect.x / size.x, subRect.y / size.y) + vec2(subRect.z / size.x, subRect.w / size.y) * qt_MultiTexCoord0;
     gl_Position = qt_Matrix * qt_Vertex;
 }


=====================================
modules/gui/qt/shaders/meson.build
=====================================
@@ -33,7 +33,7 @@ shader_files = files(shader_sources)
 qt_bin_directory = qt6_dep.get_variable(pkgconfig: 'bindir', configtool: 'QT_HOST_BINS')
 qsb = find_program('qsb', dirs: qt_bin_directory, required: true)
 
-qsb_params = ['--glsl=100 es,120,150', '--batchable', '-O']
+qsb_params = ['--glsl=300 es,130,150', '--batchable', '-O']
 if host_system == 'windows'
     qsb_params += ['--hlsl=50', '-c']
 elif host_system == 'darwin'


=====================================
modules/gui/qt/widgets/qml/DualKawaseBlur.qml
=====================================
@@ -236,26 +236,15 @@ Item {
         required property Item source
         readonly property int radius: root.radius
 
-        // TODO: We could use `textureSize()` and get rid of this, but we
-        //       can not because we are targeting GLSL 1.20/ESSL 1.0, even
-        //       though the shader is written in GLSL 4.40:
-        property size sourceTextureSize
-
-        Binding on sourceTextureSize {
-            when: root.live
-            value: textureProviderObserver.nativeTextureSize
-            restoreMode: Binding.RestoreNone // No need to restore
-        }
-
-        property rect normalRect // may not be necessary, but still needed to prevent warning
+        property rect subRect // may not be necessary, but still needed to prevent warning
 
         property alias tpObserver: textureProviderObserver
 
         // cullMode: ShaderEffect.BackFaceCulling // QTBUG-136611 (Layering breaks culling with OpenGL)
 
         // Maybe we should have vertex shader unconditionally, and calculate the half pixel there instead of fragment shader?
-        vertexShader: (normalRect.width > 0.0 && normalRect.height > 0.0) ? "qrc:///shaders/SubTexture.vert.qsb"
-                                                                          : ""
+        vertexShader: (subRect.width > 0.0 && subRect.height > 0.0) ? "qrc:///shaders/SubTexture.vert.qsb"
+                                                                    : ""
 
         supportsAtlasTextures: true
 
@@ -298,15 +287,11 @@ Item {
 
         source: root.source
 
-        // TODO: Instead of normalizing here, we could use GLSL 1.30's `textureSize()`
-        //       and normalize in the vertex shader, but we can not because we are
-        //       targeting GLSL 1.20/ESSL 1.0, even though the shader is written in
-        //       GLSL 4.40.
-        normalRect: (root.sourceRect.width > 0.0 && root.sourceRect.height > 0.0) ? Qt.rect(root.sourceRect.x * root.eDPR / sourceTextureSize.width,
-                                                                                            root.sourceRect.y * root.eDPR / sourceTextureSize.height,
-                                                                                            root.sourceRect.width * root.eDPR / sourceTextureSize.width,
-                                                                                            root.sourceRect.height * root.eDPR / sourceTextureSize.height)
-                                                                                  : Qt.rect(0.0, 0.0, 0.0, 0.0)
+        subRect: (root.sourceRect.width > 0.0 && root.sourceRect.height > 0.0) ? Qt.rect(root.sourceRect.x * root.eDPR,
+                                                                                         root.sourceRect.y * root.eDPR,
+                                                                                         root.sourceRect.width * root.eDPR,
+                                                                                         root.sourceRect.height * root.eDPR)
+                                                                               : Qt.rect(0.0, 0.0, 0.0, 0.0)
     }
 
     DefaultShaderEffectSource {
@@ -323,10 +308,6 @@ Item {
             if (!ds1layer) // context is lost, Qt bug (reproduced with 6.2)
                 return
 
-            ds1.sourceTextureSize = ds1.tpObserver.nativeTextureSize
-            if (ds1.ensurePolished)
-                ds1.ensurePolished()
-
             // Common for both four and two pass mode:
             ds1layer.parent = root
             ds1layer.scheduleUpdate()
@@ -388,10 +369,6 @@ Item {
                 return
             }
 
-            ds2.sourceTextureSize = ds2.tpObserver.nativeTextureSize
-            if (ds2.ensurePolished)
-                ds2.ensurePolished()
-
             ds2layer.inhibitParent = false
             ds2layer.scheduleUpdate()
 
@@ -446,10 +423,6 @@ Item {
                 return
             }
 
-            ds3.sourceTextureSize = ds3.tpObserver.nativeTextureSize
-            if (ds3.ensurePolished)
-                ds3.ensurePolished()
-
             ds3layer.inhibitParent = false
             ds3layer.scheduleUpdate()
 
@@ -500,10 +473,6 @@ Item {
                 return
             }
 
-            us0.sourceTextureSize = us0.tpObserver.nativeTextureSize
-            if (us0.ensurePolished)
-                us0.ensurePolished()
-
             us0layer.inhibitParent = false
             us0layer.scheduleUpdate()
 
@@ -585,10 +554,6 @@ Item {
                 return
             }
 
-            us1.sourceTextureSize = us1.tpObserver.nativeTextureSize
-            if (us1.ensurePolished)
-                us1.ensurePolished()
-
             us1layer.scheduleUpdate()
 
             if (root._window) {
@@ -613,8 +578,6 @@ Item {
             if (root.live)
                 return
 
-            us2.sourceTextureSize = us2.tpObserver.nativeTextureSize
-
             // Last layer is updated, now it is time to release the intermediate buffers:
             console.debug(root, ": releasing intermediate layers, expect the video memory consumption to drop.")
 
@@ -688,10 +651,10 @@ Item {
 
         // NOTE: Vertex shader is set in `DefaultShaderEffect` when `normalRect` is valid.
 
-        normalRect: useSubTexture ? Qt.rect((root._localVisualRect.x - root._localViewportRect.x) * root.eDPR / sourceTextureSize.width,
-                                            (root._localVisualRect.y - root._localViewportRect.y) * root.eDPR / sourceTextureSize.height,
-                                            root._localVisualRect.width * root.eDPR / sourceTextureSize.width,
-                                            root._localVisualRect.height * root.eDPR / sourceTextureSize.height)
+        subRect: useSubTexture ? Qt.rect((root._localVisualRect.x - root._localViewportRect.x) * root.eDPR,
+                                         (root._localVisualRect.y - root._localViewportRect.y) * root.eDPR,
+                                         root._localVisualRect.width * root.eDPR,
+                                         root._localVisualRect.height * root.eDPR)
                                   : Qt.rect(0,0,0,0)
     }
 }


=====================================
modules/gui/qt/widgets/qml/ImageExt.qml
=====================================
@@ -223,12 +223,6 @@ Item {
         // batch rendering in `ShaderEffect`.
         readonly property bool shouldCrop: (root.fillMode === Image.PreserveAspectCrop)
 
-        // Native texture size (atlas size if texture is in the atlas):
-        // TODO: We could use `textureSize()` and get rid of this, but we
-        //       can not because we are targeting GLSL 1.20/ESSL 1.0, even
-        //       though the shader is written in GLSL 4.40.
-        readonly property size sourceTextureSize: tpObserver.nativeTextureSize
-
         // WARNING: Do not put this into the uniform block of the shader,
         //          since it depends on the implicit size, it would break
         //          batch rendering. This is a concern for delegates.



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7960b4d7b4af212f3c00322e73e92c03f370f723...5af04b4428b316f7afd7e54224de8fe370304dca

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7960b4d7b4af212f3c00322e73e92c03f370f723...5af04b4428b316f7afd7e54224de8fe370304dca
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list