diff options
Diffstat (limited to 'src/quick/scenegraph/shaders_ng')
109 files changed, 1008 insertions, 298 deletions
diff --git a/src/quick/scenegraph/shaders_ng/24bittextmask.frag b/src/quick/scenegraph/shaders_ng/24bittextmask.frag index bc3826a924..c6e39c80db 100644 --- a/src/quick/scenegraph/shaders_ng/24bittextmask.frag +++ b/src/quick/scenegraph/shaders_ng/24bittextmask.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,14 +9,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; // only alpha is used, but must be vec4 due to layout compat + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; + vec4 color; +}; void main() { vec4 glyph = texture(_qt_texture, sampleCoord); - fragColor = vec4(glyph.rgb * ubuf.color.a, glyph.a); + fragColor = glyph * color.a; } diff --git a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb Binary files differdeleted file mode 100644 index 1850d061f9..0000000000 --- a/src/quick/scenegraph/shaders_ng/24bittextmask.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag index 63e445f90b..9d67c8b302 100644 --- a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag +++ b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,13 +9,18 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; // only alpha is used, but must be vec4 due to layout compat + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; + vec4 color; +}; void main() { - fragColor = texture(_qt_texture, sampleCoord) * ubuf.color.a; + fragColor = texture(_qt_texture, sampleCoord) * color.a; } diff --git a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb b/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb Binary files differdeleted file mode 100644 index 99ba159189..0000000000 --- a/src/quick/scenegraph/shaders_ng/32bitcolortext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask.frag b/src/quick/scenegraph/shaders_ng/8bittextmask.frag index 6304e821ff..530ebd69ef 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask.frag +++ b/src/quick/scenegraph/shaders_ng/8bittextmask.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,13 +9,18 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; + vec4 color; +}; void main() { - fragColor = ubuf.color * texture(_qt_texture, sampleCoord).r; + fragColor = color * texture(_qt_texture, sampleCoord).r; } diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb Binary files differdeleted file mode 100644 index ed45c364ca..0000000000 --- a/src/quick/scenegraph/shaders_ng/8bittextmask.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag index 0d0fa1cd3a..d6ace867a3 100644 --- a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag +++ b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,13 +9,18 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; + vec4 color; +}; void main() { - fragColor = ubuf.color * texture(_qt_texture, sampleCoord).a; // take .a instead of .r + fragColor = color * texture(_qt_texture, sampleCoord).a; // take .a instead of .r } diff --git a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb b/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb Binary files differdeleted file mode 100644 index 427a6dfaf8..0000000000 --- a/src/quick/scenegraph/shaders_ng/8bittextmask_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/compile.bat b/src/quick/scenegraph/shaders_ng/compile.bat deleted file mode 100755 index bd73016be5..0000000000 --- a/src/quick/scenegraph/shaders_ng/compile.bat +++ /dev/null @@ -1,98 +0,0 @@ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Copyright (C) 2019 The Qt Company Ltd. -:: Contact: https://www.qt.io/licensing/ -:: -:: This file is part of the QtQuick module of the Qt Toolkit. -:: -:: $QT_BEGIN_LICENSE:LGPL$ -:: Commercial License Usage -:: Licensees holding valid commercial Qt licenses may use this file in -:: accordance with the commercial license agreement provided with the -:: Software or, alternatively, in accordance with the terms contained in -:: a written agreement between you and The Qt Company. For licensing terms -:: and conditions see https://www.qt.io/terms-conditions. For further -:: information use the contact form at https://www.qt.io/contact-us. -:: -:: GNU Lesser General Public License Usage -:: Alternatively, this file may be used under the terms of the GNU Lesser -:: General Public License version 3 as published by the Free Software -:: Foundation and appearing in the file LICENSE.LGPL3 included in the -:: packaging of this file. Please review the following information to -:: ensure the GNU Lesser General Public License version 3 requirements -:: will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -:: -:: GNU General Public License Usage -:: Alternatively, this file may be used under the terms of the GNU -:: General Public License version 2.0 or (at your option) the GNU General -:: Public license version 3 or any later version approved by the KDE Free -:: Qt Foundation. The licenses are as published by the Free Software -:: Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -:: included in the packaging of this file. Please review the following -:: information to ensure the GNU General Public License requirements will -:: be met: https://www.gnu.org/licenses/gpl-2.0.html and -:: https://www.gnu.org/licenses/gpl-3.0.html. -:: -:: $QT_END_LICENSE$ -:: -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:: For HLSL we invoke fxc.exe (-c argument) and store the resulting intermediate format -:: instead of HLSL source, so this needs to be run on Windows from a developer command prompt. - -:: For SPIR-V the optimizer is requested (-O argument) which means spirv-opt must be -:: invokable (e.g. because it's in the PATH from the Vulkan SDK) - -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o vertexcolor.vert.qsb vertexcolor.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o vertexcolor.frag.qsb vertexcolor.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o flatcolor.vert.qsb flatcolor.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o flatcolor.frag.qsb flatcolor.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o smoothcolor.vert.qsb smoothcolor.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o smoothcolor.frag.qsb smoothcolor.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o stencilclip.vert.qsb stencilclip.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o stencilclip.frag.qsb stencilclip.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o texture.vert.qsb texture.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o texture.frag.qsb texture.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o opaquetexture.vert.qsb opaquetexture.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o opaquetexture.frag.qsb opaquetexture.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o smoothtexture.vert.qsb smoothtexture.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o smoothtexture.frag.qsb smoothtexture.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o textmask.vert.qsb textmask.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o textmask.frag.qsb textmask.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o 8bittextmask.frag.qsb 8bittextmask.frag -qsb --glsl "150,120,100 es" -o 8bittextmask_a.frag.qsb 8bittextmask_a.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o 24bittextmask.frag.qsb 24bittextmask.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o 32bitcolortext.frag.qsb 32bitcolortext.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o outlinedtext.vert.qsb outlinedtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o outlinedtext.frag.qsb outlinedtext.frag -qsb --glsl "150,120,100 es" -o outlinedtext_a.frag.qsb outlinedtext_a.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o styledtext.vert.qsb styledtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o styledtext.frag.qsb styledtext.frag -qsb --glsl "150,120,100 es" -o styledtext_a.frag.qsb styledtext_a.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldtext.vert.qsb distancefieldtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldtext.frag.qsb distancefieldtext.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldtext_fwidth.frag.qsb distancefieldtext_fwidth.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldtext_a.frag.qsb distancefieldtext_a.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldtext_a_fwidth.frag.qsb distancefieldtext_a_fwidth.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldshiftedtext.vert.qsb distancefieldshiftedtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldshiftedtext.frag.qsb distancefieldshiftedtext.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldshiftedtext_fwidth.frag.qsb distancefieldshiftedtext_fwidth.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldshiftedtext_a.frag.qsb distancefieldshiftedtext_a.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldshiftedtext_a_fwidth.frag.qsb distancefieldshiftedtext_a_fwidth.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldoutlinetext.vert.qsb distancefieldoutlinetext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldoutlinetext.frag.qsb distancefieldoutlinetext.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldoutlinetext_fwidth.frag.qsb distancefieldoutlinetext_fwidth.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldoutlinetext_a.frag.qsb distancefieldoutlinetext_a.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o distancefieldoutlinetext_a_fwidth.frag.qsb distancefieldoutlinetext_a_fwidth.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o hiqsubpixeldistancefieldtext.vert.qsb hiqsubpixeldistancefieldtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o hiqsubpixeldistancefieldtext.frag.qsb hiqsubpixeldistancefieldtext.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o hiqsubpixeldistancefieldtext_a.frag.qsb hiqsubpixeldistancefieldtext_a.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o loqsubpixeldistancefieldtext.vert.qsb loqsubpixeldistancefieldtext.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o loqsubpixeldistancefieldtext.frag.qsb loqsubpixeldistancefieldtext.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o loqsubpixeldistancefieldtext_a.frag.qsb loqsubpixeldistancefieldtext_a.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o shadereffect.vert.qsb shadereffect.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o shadereffect.frag.qsb shadereffect.frag -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o sprite.vert.qsb sprite.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o sprite.frag.qsb sprite.frag -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o visualization.vert.qsb visualization.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o visualization.frag.qsb visualization.frag diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag index b1551d8ef4..1ece7b1e51 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,7 +9,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,12 +22,12 @@ layout(std140, binding = 0) uniform buf { vec4 styleColor; float outlineAlphaMax0; float outlineAlphaMax1; -} ubuf; +}; void main() { float d = texture(_qt_texture, sampleCoord).r; - float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, d); - fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) - * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); + float a = smoothstep(alphaMin, alphaMax, d); + fragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) + * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb Binary files differdeleted file mode 100644 index 4b775fab75..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert index 8f0d618503..107ec9dfdc 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert @@ -6,7 +6,11 @@ layout(location = 1) in vec2 tCoord; layout(location = 0) out vec2 sampleCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,12 +19,14 @@ layout(std140, binding = 0) uniform buf { vec4 styleColor; float outlineAlphaMax0; float outlineAlphaMax1; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + sampleCoord = tCoord * textureScale; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vCoord; +#else + gl_Position = matrix * vCoord; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb Binary files differdeleted file mode 100644 index fd8f8465d1..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag index 7c6bd9a493..ac289221f9 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,7 +9,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,12 +22,12 @@ layout(std140, binding = 0) uniform buf { vec4 styleColor; float outlineAlphaMax0; float outlineAlphaMax1; -} ubuf; +}; void main() { float d = texture(_qt_texture, sampleCoord).a; - float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, d); - fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) - * smoothstep(ubuf.outlineAlphaMax0, ubuf.outlineAlphaMax1, d); + float a = smoothstep(alphaMin, alphaMax, d); + fragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) + * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb Binary files differdeleted file mode 100644 index c9b59f7373..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag index 30ec465791..ddf8f28d1d 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,7 +9,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,7 +22,7 @@ layout(std140, binding = 0) uniform buf { vec4 styleColor; float outlineAlphaMax0; float outlineAlphaMax1; -} ubuf; +}; void main() { @@ -24,8 +31,8 @@ void main() // The outlineLimit is based on font size, but scales with the transform, so // we can calculate it from the outline span. - float outlineLimit = (ubuf.outlineAlphaMax1 - ubuf.outlineAlphaMax0) / 2.0 + ubuf.outlineAlphaMax0; + float outlineLimit = (outlineAlphaMax1 - outlineAlphaMax0) / 2.0 + outlineAlphaMax0; float a = smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); - fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) * smoothstep(max(0.0, outlineLimit - f), min(outlineLimit + f, 0.5 - f), distance); + fragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) * smoothstep(max(0.0, outlineLimit - f), min(outlineLimit + f, 0.5 - f), distance); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag.qsb Binary files differdeleted file mode 100644 index 6054685664..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag index 511bffb09a..8aa5326be0 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,7 +9,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,7 +22,7 @@ layout(std140, binding = 0) uniform buf { vec4 styleColor; float outlineAlphaMax0; float outlineAlphaMax1; -} ubuf; +}; void main() { @@ -24,8 +31,8 @@ void main() // The outlineLimit is based on font size, but scales with the transform, so // we can calculate it from the outline span. - float outlineLimit = (ubuf.outlineAlphaMax1 - ubuf.outlineAlphaMax0) / 2.0 + ubuf.outlineAlphaMax0; + float outlineLimit = (outlineAlphaMax1 - outlineAlphaMax0) / 2.0 + outlineAlphaMax0; float a = smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); - fragColor = step(1.0 - a, 1.0) * mix(ubuf.styleColor, ubuf.color, a) * smoothstep(max(0.0, outlineLimit - f), min(outlineLimit + f, 0.5 - f), distance); + fragColor = step(1.0 - a, 1.0) * mix(styleColor, color, a) * smoothstep(max(0.0, outlineLimit - f), min(outlineLimit + f, 0.5 - f), distance); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag.qsb Binary files differdeleted file mode 100644 index 22141bc69b..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag index aa3390094b..6374f2d3ac 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,12 +23,12 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { - float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, texture(_qt_texture, sampleCoord).r); - vec4 shifted = ubuf.styleColor * smoothstep(ubuf.alphaMin, ubuf.alphaMax, + float a = smoothstep(alphaMin, alphaMax, texture(_qt_texture, sampleCoord).r); + vec4 shifted = styleColor * smoothstep(alphaMin, alphaMax, texture(_qt_texture, shiftedSampleCoord).r); - fragColor = mix(shifted, ubuf.color, a); + fragColor = mix(shifted, color, a); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb Binary files differdeleted file mode 100644 index 0e1d8c558c..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert index f3a7671435..5eeb6d8ecb 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert @@ -7,7 +7,11 @@ layout(location = 0) out vec2 sampleCoord; layout(location = 1) out vec2 shiftedSampleCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,13 +19,15 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext vec4 styleColor; vec2 shift; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - shiftedSampleCoord = (tCoord - ubuf.shift) * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + sampleCoord = tCoord * textureScale; + shiftedSampleCoord = (tCoord - shift) * textureScale; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vCoord; +#else + gl_Position = matrix * vCoord; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb Binary files differdeleted file mode 100644 index a5764aa06c..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag index ab3a5f63ff..cd505e35fb 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,12 +23,12 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { - float a = smoothstep(ubuf.alphaMin, ubuf.alphaMax, texture(_qt_texture, sampleCoord).a); - vec4 shifted = ubuf.styleColor * smoothstep(ubuf.alphaMin, ubuf.alphaMax, + float a = smoothstep(alphaMin, alphaMax, texture(_qt_texture, sampleCoord).a); + vec4 shifted = styleColor * smoothstep(alphaMin, alphaMax, texture(_qt_texture, shiftedSampleCoord).a); - fragColor = mix(shifted, ubuf.color, a); + fragColor = mix(shifted, color, a); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb Binary files differdeleted file mode 100644 index 5174bed978..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag index 8f528fea1e..e7112929a7 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,7 +23,7 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { @@ -28,6 +35,6 @@ void main() float shiftedF = fwidth(shiftedDistance); float shiftedA = smoothstep(0.5 - shiftedF, 0.5 + shiftedF, shiftedDistance); - vec4 shifted = ubuf.styleColor * shiftedA; - fragColor = mix(shifted, ubuf.color, a); + vec4 shifted = styleColor * shiftedA; + fragColor = mix(shifted, color, a); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag.qsb Binary files differdeleted file mode 100644 index d664f3d223..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag index a71cc1d9b0..373e97ffff 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,7 +23,7 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { @@ -28,6 +35,6 @@ void main() float shiftedF = fwidth(shiftedDistance); float shiftedA = smoothstep(0.5 - shiftedF, 0.5 + shiftedF, shiftedDistance); - vec4 shifted = ubuf.styleColor * shiftedA; - fragColor = mix(shifted, ubuf.color, a); + vec4 shifted = styleColor * shiftedA; + fragColor = mix(shifted, color, a); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag.qsb Binary files differdeleted file mode 100644 index 82fc991f43..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag b/src/quick/scenegraph/shaders_ng/distancefieldtext.frag index d594207567..a94a1257b9 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,15 +9,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; float alphaMax; -} ubuf; +}; void main() { - fragColor = ubuf.color * smoothstep(ubuf.alphaMin, ubuf.alphaMax, - texture(_qt_texture, sampleCoord).r); + fragColor = color * smoothstep(alphaMin, alphaMax, + texture(_qt_texture, sampleCoord).r); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb Binary files differdeleted file mode 100644 index 77efd80911..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert b/src/quick/scenegraph/shaders_ng/distancefieldtext.vert index d56ddddd24..eeb9f7bcce 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext.vert @@ -6,17 +6,23 @@ layout(location = 1) in vec2 tCoord; layout(location = 0) out vec2 sampleCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; float alphaMax; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + sampleCoord = tCoord * textureScale; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vCoord; +#else + gl_Position = matrix * vCoord; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb Binary files differdeleted file mode 100644 index f2ec30c757..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag b/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag index bb807d86d8..dccca64a34 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,15 +9,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; float alphaMax; -} ubuf; +}; void main() { - fragColor = ubuf.color * smoothstep(ubuf.alphaMin, ubuf.alphaMax, - texture(_qt_texture, sampleCoord).a); + fragColor = color * smoothstep(alphaMin, alphaMax, + texture(_qt_texture, sampleCoord).a); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb Binary files differdeleted file mode 100644 index f28b6df278..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag index 1aa1175b57..e4d2bced7a 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,16 +9,20 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; float alphaMax; -} ubuf; +}; void main() { float distance = texture(_qt_texture, sampleCoord).a; float f = fwidth(distance); - fragColor = ubuf.color * smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); + fragColor = color * smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag.qsb Binary files differdeleted file mode 100644 index f420bf5f23..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag b/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag index a698c19550..e895071811 100644 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag +++ b/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,16 +9,20 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; float alphaMax; -} ubuf; +}; void main() { float distance = texture(_qt_texture, sampleCoord).r; float f = fwidth(distance); - fragColor = ubuf.color * smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); + fragColor = color * smoothstep(max(0.0, 0.5 - f), min(1.0, 0.5 + f), distance); } diff --git a/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag.qsb b/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag.qsb Binary files differdeleted file mode 100644 index 4373f625ce..0000000000 --- a/src/quick/scenegraph/shaders_ng/distancefieldtext_fwidth.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.frag b/src/quick/scenegraph/shaders_ng/flatcolor.frag index 3a677b7c93..c5f9f3f2c4 100644 --- a/src/quick/scenegraph/shaders_ng/flatcolor.frag +++ b/src/quick/scenegraph/shaders_ng/flatcolor.frag @@ -1,13 +1,20 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec4 color; -} ubuf; +}; void main() { - fragColor = ubuf.color; + fragColor = color; } diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb Binary files differdeleted file mode 100644 index 1fa16190c9..0000000000 --- a/src/quick/scenegraph/shaders_ng/flatcolor.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.vert b/src/quick/scenegraph/shaders_ng/flatcolor.vert index b5dfd32197..eec2a2d6ed 100644 --- a/src/quick/scenegraph/shaders_ng/flatcolor.vert +++ b/src/quick/scenegraph/shaders_ng/flatcolor.vert @@ -3,13 +3,19 @@ layout(location = 0) in vec4 vertexCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec4 color; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - gl_Position = ubuf.matrix * vertexCoord; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vertexCoord; +#else + gl_Position = matrix * vertexCoord; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb Binary files differdeleted file mode 100644 index 87442cde0b..0000000000 --- a/src/quick/scenegraph/shaders_ng/flatcolor.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag index 723227a04d..fc3d04cb60 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -11,7 +14,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -19,7 +26,7 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; +}; void main() { @@ -31,10 +38,10 @@ void main() n.w = textureProj(_qt_texture, sampleFarRight).r; vec2 d = min(abs(n.yw - n.xz) * 2., 0.67); - vec2 lo = mix(vec2(ubuf.alphaMin), vec2(0.5), d); - vec2 hi = mix(vec2(ubuf.alphaMax), vec2(0.5), d); + vec2 lo = mix(vec2(alphaMin), vec2(0.5), d); + vec2 hi = mix(vec2(alphaMax), vec2(0.5), d); n = smoothstep(lo.xxyy, hi.xxyy, n); c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c); - fragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * ubuf.color.w; + fragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w; } diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb Binary files differdeleted file mode 100644 index 0204ca992d..0000000000 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert index 9c7281c31c..922074791b 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert @@ -10,7 +10,11 @@ layout(location = 3) out vec3 sampleNearRight; layout(location = 4) out vec3 sampleFarRight; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -18,24 +22,26 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + sampleCoord = tCoord * textureScale; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vCoord; +#else + gl_Position = matrix * vCoord; +#endif // Calculate neighbor pixel position in item space. - vec3 wDelta = gl_Position.w * ubuf.vecDelta.xyw; + vec3 wDelta = gl_Position.w * vecDelta.xyw; vec3 farLeft = vCoord.xyw - 0.667 * wDelta; vec3 nearLeft = vCoord.xyw - 0.333 * wDelta; vec3 nearRight = vCoord.xyw + 0.333 * wDelta; vec3 farRight = vCoord.xyw + 0.667 * wDelta; // Calculate neighbor texture coordinate. - vec2 scale = ubuf.textureScale / ubuf.fontScale; + vec2 scale = textureScale / fontScale; vec2 base = sampleCoord - scale * vCoord.xy; sampleFarLeft = vec3(base * farLeft.z + scale * farLeft.xy, farLeft.z); sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z); diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb Binary files differdeleted file mode 100644 index 2ec5f72563..0000000000 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag index a9d56f6380..3bd18f1dec 100644 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -11,7 +14,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -19,7 +26,7 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; +}; void main() { @@ -31,10 +38,10 @@ void main() n.w = textureProj(_qt_texture, sampleFarRight).a; vec2 d = min(abs(n.yw - n.xz) * 2., 0.67); - vec2 lo = mix(vec2(ubuf.alphaMin), vec2(0.5), d); - vec2 hi = mix(vec2(ubuf.alphaMax), vec2(0.5), d); + vec2 lo = mix(vec2(alphaMin), vec2(0.5), d); + vec2 hi = mix(vec2(alphaMax), vec2(0.5), d); n = smoothstep(lo.xxyy, hi.xxyy, n); c = smoothstep(lo.x + lo.y, hi.x + hi.y, 2. * c); - fragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * ubuf.color.w; + fragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w; } diff --git a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb Binary files differdeleted file mode 100644 index d90384a974..0000000000 --- a/src/quick/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag index 08b2ce5187..5571417bc5 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec3 sampleNearLeft; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,14 +23,14 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; +}; void main() { vec2 n; n.x = textureProj(_qt_texture, sampleNearLeft).r; n.y = textureProj(_qt_texture, sampleNearRight).r; - n = smoothstep(ubuf.alphaMin, ubuf.alphaMax, n); + n = smoothstep(alphaMin, alphaMax, n); float c = 0.5 * (n.x + n.y); - fragColor = vec4(n.x, c, n.y, c) * ubuf.color.w; + fragColor = vec4(n.x, c, n.y, c) * color.w; } diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb Binary files differdeleted file mode 100644 index bd9aaf243b..0000000000 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert index 187c384959..1b1d3b4013 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert @@ -7,7 +7,11 @@ layout(location = 0) out vec3 sampleNearLeft; layout(location = 1) out vec3 sampleNearRight; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -15,22 +19,24 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - vec2 sampleCoord = tCoord * ubuf.textureScale; - gl_Position = ubuf.matrix * vCoord; + vec2 sampleCoord = tCoord * textureScale; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vCoord; +#else + gl_Position = matrix * vCoord; +#endif // Calculate neighbor pixel position in item space. - vec3 wDelta = gl_Position.w * ubuf.vecDelta.xyw; + vec3 wDelta = gl_Position.w * vecDelta.xyw; vec3 nearLeft = vCoord.xyw - 0.25 * wDelta; vec3 nearRight = vCoord.xyw + 0.25 * wDelta; // Calculate neighbor texture coordinate. - vec2 scale = ubuf.textureScale / ubuf.fontScale; + vec2 scale = textureScale / fontScale; vec2 base = sampleCoord - scale * vCoord.xy; sampleNearLeft = vec3(base * nearLeft.z + scale * nearLeft.xy, nearLeft.z); sampleNearRight = vec3(base * nearRight.z + scale * nearRight.xy, nearRight.z); diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb Binary files differdeleted file mode 100644 index 6050bb6d16..0000000000 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag index ef9407491b..3cd7176721 100644 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec3 sampleNearLeft; @@ -8,7 +11,11 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 textureScale; vec4 color; float alphaMin; @@ -16,14 +23,14 @@ layout(std140, binding = 0) uniform buf { // up to this point it must match distancefieldtext float fontScale; vec4 vecDelta; -} ubuf; +}; void main() { vec2 n; n.x = textureProj(_qt_texture, sampleNearLeft).a; n.y = textureProj(_qt_texture, sampleNearRight).a; - n = smoothstep(ubuf.alphaMin, ubuf.alphaMax, n); + n = smoothstep(alphaMin, alphaMax, n); float c = 0.5 * (n.x + n.y); - fragColor = vec4(n.x, c, n.y, c) * ubuf.color.w; + fragColor = vec4(n.x, c, n.y, c) * color.w; } diff --git a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb Binary files differdeleted file mode 100644 index 0593243f36..0000000000 --- a/src/quick/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.frag b/src/quick/scenegraph/shaders_ng/opaquetexture.frag index 2cd2175f87..18dd7e0fcb 100644 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.frag +++ b/src/quick/scenegraph/shaders_ng/opaquetexture.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 qt_TexCoord; diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb b/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb Binary files differdeleted file mode 100644 index beb6e97b0d..0000000000 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.vert b/src/quick/scenegraph/shaders_ng/opaquetexture.vert index 5b52a59004..22df4a239a 100644 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.vert +++ b/src/quick/scenegraph/shaders_ng/opaquetexture.vert @@ -6,13 +6,19 @@ layout(location = 1) in vec2 qt_VertexTexCoord; layout(location = 0) out vec2 qt_TexCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +#endif +}; void main() { qt_TexCoord = qt_VertexTexCoord; - gl_Position = ubuf.qt_Matrix * qt_VertexPosition; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = qt_Matrix[gl_ViewIndex] * qt_VertexPosition; +#else + gl_Position = qt_Matrix * qt_VertexPosition; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb b/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb Binary files differdeleted file mode 100644 index 835c046830..0000000000 --- a/src/quick/scenegraph/shaders_ng/opaquetexture.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag b/src/quick/scenegraph/shaders_ng/outlinedtext.frag index 947d161a50..5c81f26272 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -11,14 +14,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - // must match styledtext - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; + // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { @@ -29,5 +37,5 @@ void main() texture(_qt_texture, sCoordRight).r, 0.0, 1.0) - glyph, 0.0, 1.0); - fragColor = outline * ubuf.styleColor + step(1.0 - glyph, 1.0) * glyph * ubuf.color; + fragColor = outline * styleColor + step(1.0 - glyph, 1.0) * glyph * color; } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb Binary files differdeleted file mode 100644 index cf7e60e620..0000000000 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.vert b/src/quick/scenegraph/shaders_ng/outlinedtext.vert index 023f9dfdc2..a75b15556d 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.vert +++ b/src/quick/scenegraph/shaders_ng/outlinedtext.vert @@ -10,24 +10,31 @@ layout(location = 3) out vec2 sCoordLeft; layout(location = 4) out vec2 sCoordRight; layout(std140, binding = 0) uniform buf { - // must match styledtext - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; + // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - sCoordUp = (tCoord - vec2(0.0, -1.0)) * ubuf.textureScale; - sCoordDown = (tCoord - vec2(0.0, 1.0)) * ubuf.textureScale; - sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * ubuf.textureScale; - sCoordRight = (tCoord - vec2(1.0, 0.0)) * ubuf.textureScale; - vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; - gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); + sampleCoord = tCoord * textureScale; + sCoordUp = (tCoord - vec2(0.0, -1.0)) * textureScale; + sCoordDown = (tCoord - vec2(0.0, 1.0)) * textureScale; + sCoordLeft = (tCoord - vec2(-1.0, 0.0)) * textureScale; + sCoordRight = (tCoord - vec2(1.0, 0.0)) * textureScale; + vec4 xformed = modelViewMatrix * vCoord; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = projectionMatrix[gl_ViewIndex] * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#else + gl_Position = projectionMatrix * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#endif } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb Binary files differdeleted file mode 100644 index 160b77531c..0000000000 --- a/src/quick/scenegraph/shaders_ng/outlinedtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag index 5b7bd9ca82..c4db8b54f0 100644 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -11,14 +14,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - // must match styledtext - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; + // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { @@ -29,5 +37,5 @@ void main() texture(_qt_texture, sCoordRight).a, 0.0, 1.0) - glyph, 0.0, 1.0); - fragColor = outline * ubuf.styleColor + step(1.0 - glyph, 1.0) * glyph * ubuf.color; + fragColor = outline * styleColor + step(1.0 - glyph, 1.0) * glyph * color; } diff --git a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb Binary files differdeleted file mode 100644 index c6465c612d..0000000000 --- a/src/quick/scenegraph/shaders_ng/outlinedtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.frag b/src/quick/scenegraph/shaders_ng/shadereffect.frag index bde493f6ce..3d1037ed05 100644 --- a/src/quick/scenegraph/shaders_ng/shadereffect.frag +++ b/src/quick/scenegraph/shaders_ng/shadereffect.frag @@ -1,10 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 qt_TexCoord0; layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform qt_buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; +#endif float qt_Opacity; } qt_ubuf; diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb b/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb Binary files differdeleted file mode 100644 index 3a5dc85b98..0000000000 --- a/src/quick/scenegraph/shaders_ng/shadereffect.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.vert b/src/quick/scenegraph/shaders_ng/shadereffect.vert index ae65059f19..e030b5ee71 100644 --- a/src/quick/scenegraph/shaders_ng/shadereffect.vert +++ b/src/quick/scenegraph/shaders_ng/shadereffect.vert @@ -6,14 +6,20 @@ layout(location = 1) in vec2 qt_MultiTexCoord0; layout(location = 0) out vec2 qt_TexCoord0; layout(std140, binding = 0) uniform qt_buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; +#endif float qt_Opacity; } qt_ubuf; // must use a name that does not clash with custom code when no uniform blocks -out gl_PerVertex { vec4 gl_Position; }; - void main() { qt_TexCoord0 = qt_MultiTexCoord0; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = qt_ubuf.qt_Matrix[gl_ViewIndex] * qt_Vertex; +#else gl_Position = qt_ubuf.qt_Matrix * qt_Vertex; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb b/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb Binary files differdeleted file mode 100644 index 97f0395f35..0000000000 --- a/src/quick/scenegraph/shaders_ng/shadereffect.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/shapecurve.frag b/src/quick/scenegraph/shaders_ng/shapecurve.frag new file mode 100644 index 0000000000..594bed7c11 --- /dev/null +++ b/src/quick/scenegraph/shaders_ng/shapecurve.frag @@ -0,0 +1,168 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#version 440 + +layout(location = 0) in vec4 qt_TexCoord; +layout(location = 1) in vec4 gradient; + +#if defined(LINEARGRADIENT) +layout(location = 2) in float gradTabIndex; +#elif defined(RADIALGRADIENT) || defined(CONICALGRADIENT) +layout(location = 2) in vec2 coord; +#endif + + +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else + mat4 qt_Matrix; +#endif + float matrixScale; + float opacity; + float debug; + float reserved3; + +#if defined(STROKE) + vec4 strokeColor; + float strokeWidth; + float reserved4; + float reserved5; + float reserved6; +#endif + +#if defined(LINEARGRADIENT) + vec2 gradientStart; + vec2 gradientEnd; +#elif defined(RADIALGRADIENT) + vec2 translationPoint; + vec2 focalToCenter; + float centerRadius; + float focalRadius; +#elif defined(CONICALGRADIENT) + vec2 translationPoint; + float angle; +#else + vec4 color; +#endif +} ubuf; + +#define INVERSE_2PI 0.1591549430918953358 + +#if defined(LINEARGRADIENT) || defined(RADIALGRADIENT) || defined(CONICALGRADIENT) +layout(binding = 1) uniform sampler2D gradTabTexture; +#endif + +vec4 baseColor() +{ +#if defined(LINEARGRADIENT) + return texture(gradTabTexture, vec2(gradTabIndex, 0.5)); +#elif defined(RADIALGRADIENT) + float rd = ubuf.centerRadius - ubuf.focalRadius; + float b = 2.0 * (rd * ubuf.focalRadius + dot(coord, ubuf.focalToCenter)); + float fmp2_m_radius2 = -ubuf.focalToCenter.x * ubuf.focalToCenter.x - ubuf.focalToCenter.y * ubuf.focalToCenter.y + rd * rd; + float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2); + float det = b * b - 4.0 * fmp2_m_radius2 * ((ubuf.focalRadius * ubuf.focalRadius) - dot(coord, coord)); + vec4 result = vec4(0.0); + if (det >= 0.0) { + float detSqrt = sqrt(det); + float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); + if (ubuf.focalRadius + w * (ubuf.centerRadius - ubuf.focalRadius) >= 0.0) + result = texture(gradTabTexture, vec2(w, 0.5)); + } + + return result; +#elif defined(CONICALGRADIENT) + float t; + if (abs(coord.y) == abs(coord.x)) + t = (atan(-coord.y + 0.002, coord.x) + ubuf.angle) * INVERSE_2PI; + else + t = (atan(-coord.y, coord.x) + ubuf.angle) * INVERSE_2PI; + return texture(gradTabTexture, vec2(t - floor(t), 0.5)); +#else + return vec4(ubuf.color.rgb, 1.0) * ubuf.color.a; +#endif +} + +void main() +{ + float f = qt_TexCoord.z * (qt_TexCoord.x * qt_TexCoord.x - qt_TexCoord.y) // curve + + (1.0 - abs(qt_TexCoord.z)) * (qt_TexCoord.x - qt_TexCoord.y); // line + +#if defined(USE_DERIVATIVES) + float _ddx = dFdx(f); + float _ddy = dFdy(f); + float df = length(vec2(_ddx, _ddy)); +#else + // We calculate the partial derivatives for f'(x, y) based on knowing the partial derivatives + // for the texture coordinates (u, v). + // So for curves: + // f(x,y) = u(x, y) * u(x, y) - v(x, y) + // f(x,y) = p(u(x,y)) - v(x, y) where p(u) = u^2 + // So f'(x, y) = p'(u(x, y)) * u'(x, y) - v'(x, y) + // (by chain rule and sum rule) + // f'(x, y) = 2 * u(x, y) * u'(x, y) - v'(x, y) + // And so: + // df/dx = 2 * u(x, y) * du/dx - dv/dx + // df/dy = 2 * u(x, y) * du/dy - dv/dy + // + // and similarly for straight lines: + // f(x, y) = u(x, y) - v(x, y) + // f'(x, y) = dudx - dvdx + + float dudx = gradient.x; + float dvdx = gradient.y; + float dudy = gradient.z; + float dvdy = gradient.w; + + // Test with analytic derivatives +// dudx = dFdx(qt_TexCoord.x); +// dvdx = dFdx(qt_TexCoord.y); +// dudy = dFdy(qt_TexCoord.x); +// dvdy = dFdy(qt_TexCoord.y); + + float dfx_curve = 2.0f * qt_TexCoord.x * dudx - dvdx; + float dfy_curve = 2.0f * qt_TexCoord.x * dudy - dvdy; + + float dfx_line = dudx - dvdx; + float dfy_line = dudy - dvdy; + + float dfx = qt_TexCoord.z * dfx_curve + (1.0 - abs(qt_TexCoord.z)) * dfx_line; + float dfy = qt_TexCoord.z * dfy_curve + (1.0 - abs(qt_TexCoord.z)) * dfy_line; + float df = length(vec2(dfx, dfy)); +#endif + + float isLine = 1.0 - abs(qt_TexCoord.z); + float isCurve = 1.0 - isLine; + float debugR = isCurve * min(1.0, 1.0 - qt_TexCoord.z); + float debugG = isLine; + float debugB = isCurve * min(1.0, 1.0 - qt_TexCoord.z * -1.0) + debugG; + vec3 debugColor = vec3(debugR, debugG, debugB); + +#if defined(STROKE) + float distance = (f / df); // distance from centre of fragment to line + + float halfStrokeWidth = ubuf.strokeWidth / 2.0; + + // calculate stroke + float strokeCoverage = 1.0 - clamp(0.5 + abs(distance) - halfStrokeWidth, 0.0, 1.0); + vec4 stroke = ubuf.strokeColor * strokeCoverage; + + float fillCoverage = clamp(0.5 + f / df, 0.0, 1.0); + vec4 fill = baseColor() * fillCoverage; + + vec4 combined = fill * (1.0 - stroke.a) + stroke * stroke.a; + + // finally mix in debug + fragColor = mix(combined, vec4(debugColor, 1.0), ubuf.debug) * ubuf.opacity; +#else + // Special case: mask out concave curve in "negative space". + int specialCaseMask = 1 - int(qt_TexCoord.w != 0.0) * (int(qt_TexCoord.x < 0.0) + int(qt_TexCoord.x > 1.0)); + float fillCoverage = clamp(0.5 + f / df, 0.0, 1.0) * float(specialCaseMask); + + fragColor = mix(baseColor() * fillCoverage, vec4(debugColor, 1.0), ubuf.debug) * ubuf.opacity; +#endif +} diff --git a/src/quick/scenegraph/shaders_ng/shapecurve.vert b/src/quick/scenegraph/shaders_ng/shapecurve.vert new file mode 100644 index 0000000000..59f4ddb77d --- /dev/null +++ b/src/quick/scenegraph/shaders_ng/shapecurve.vert @@ -0,0 +1,87 @@ +#version 440 + +layout(location = 0) in vec4 vertexCoord; +layout(location = 1) in vec4 vertexTexCoord; +layout(location = 2) in vec4 vertexGradient; +layout(location = 3) in vec2 normalVector; + +layout(location = 0) out vec4 qt_TexCoord; +layout(location = 1) out vec4 gradient; + +#if defined(LINEARGRADIENT) +layout(location = 2) out float gradTabIndex; +#elif defined(RADIALGRADIENT) || defined(CONICALGRADIENT) +layout(location = 2) out vec2 coord; +#endif + +layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else + mat4 qt_Matrix; +#endif + float matrixScale; + float opacity; + float debug; + float reserved3; + +#if defined(STROKE) + vec4 strokeColor; + float strokeWidth; + float reserved4; + float reserved5; + float reserved6; +#endif + +#if defined(LINEARGRADIENT) + vec2 gradientStart; + vec2 gradientEnd; +#elif defined(RADIALGRADIENT) + vec2 translationPoint; + vec2 focalToCenter; + float centerRadius; + float focalRadius; +#elif defined(CONICALGRADIENT) + vec2 translationPoint; + float angle; +#else + vec4 color; +#endif +} ubuf; + +#define SQRT2 1.41421356237 + +vec4 addOffset(vec4 texCoord, vec2 offset, vec4 duvdxy) +{ + float dudx = duvdxy.x; + float dvdx = duvdxy.y; + float dudy = duvdxy.z; + float dvdy = duvdxy.w; + float u = offset.x * dudx + offset.y * dudy; + float v = offset.x * dvdx + offset.y * dvdy; + // special case external triangles for concave curves + int specialCase = int(texCoord.z > 0) * (int(offset.x != 0) + int(offset.y != 0)); + return vec4(texCoord.x + u, texCoord.y + v, texCoord.z, float(specialCase)); +} + +void main() +{ + vec2 offset = normalVector * SQRT2/ubuf.matrixScale; + + qt_TexCoord = addOffset(vertexTexCoord, offset, vertexGradient); + + gradient = vertexGradient / ubuf.matrixScale; + +#if defined(LINEARGRADIENT) + vec2 gradVec = ubuf.gradientEnd - ubuf.gradientStart; + gradTabIndex = dot(gradVec, vertexCoord.xy - ubuf.gradientStart.xy) / dot(gradVec, gradVec); +#elif defined(RADIALGRADIENT) || defined(CONICALGRADIENT) + coord = vertexCoord.xy - ubuf.translationPoint; +#endif + +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = ubuf.qt_Matrix[gl_ViewIndex] * (vertexCoord + vec4(offset, 0, 0)); +#else + gl_Position = ubuf.qt_Matrix * (vertexCoord + vec4(offset, 0, 0)); +#endif +} diff --git a/src/quick/scenegraph/shaders_ng/shapestroke.frag b/src/quick/scenegraph/shaders_ng/shapestroke.frag new file mode 100644 index 0000000000..cedfa0845a --- /dev/null +++ b/src/quick/scenegraph/shaders_ng/shapestroke.frag @@ -0,0 +1,134 @@ +#version 440 + +layout(location = 0) in vec4 P; +layout(location = 1) in vec2 A; +layout(location = 2) in vec2 B; +layout(location = 3) in vec2 C; +layout(location = 4) in vec2 HG; +layout(location = 5) in float offset; + +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else + mat4 qt_Matrix; +#endif + + float matrixScale; + float opacity; + float reserved2; + float reserved3; + + vec4 strokeColor; + + float strokeWidth; + float debug; + float reserved5; + float reserved6; +} ubuf; + +float cuberoot(float x) +{ + return sign(x) * pow(abs(x), 1 / 3.); +} + +#define PI 3.1415926538 + +vec3 solveDepressedCubic(float p, float q) +{ + float D = q * q / 4. + p * p * p / 27.; + + float u1 = cuberoot(-q / 2. - sqrt(D)); + float u2 = cuberoot(-q / 2. + sqrt(D)); + vec3 rootsD1 = vec3(u1 - p / (3. * u1), u2 - p / (3. * u2), 0); + + float v = 2.*sqrt(-p / 3.); + float t = acos(3. * q / p / v) / 3.; + float k = 2. * PI / 3.; + vec3 rootsD2 = vec3(v * cos(t), v * cos(t - k), v * cos(t - 2. * k)); + + return D > 0 ? rootsD1 : rootsD2; +} + +mat2 qInverse(mat2 matrix) { + float a = matrix[0][0], b = matrix[0][1]; + float c = matrix[1][0], d = matrix[1][1]; + + float determinant = a * d - b * c; + float invDet = 1.0 / determinant; + + mat2 inverseMatrix; + inverseMatrix[0][0] = d * invDet; + inverseMatrix[0][1] = -b * invDet; + inverseMatrix[1][0] = -c * invDet; + inverseMatrix[1][1] = a * invDet; + + return inverseMatrix; +} + +void main() +{ + vec3 s = solveDepressedCubic(HG.x, HG.y) - vec3(offset, offset, offset); + + vec2 Qmin = vec2(1e10, 1e10); + float dmin = 1e4; + for (int i = 0; i < 3; i++) { + float t = clamp(s[i], 0., 1.); + vec2 Q = A * t * t + B * t + C; + float d = length(Q - P.xy); + float foundNewMin = step(d, dmin); + dmin = min(d, dmin); + Qmin = foundNewMin * Q + (1. - foundNewMin) * Qmin; + } + vec2 n = (P.xy - Qmin) / dmin; + vec2 Q1 = (Qmin + ubuf.strokeWidth / 2. * n); + vec2 Q2 = (Qmin - ubuf.strokeWidth / 2. * n); + + // Converting to screen coordinates: +#if defined(USE_DERIVATIVES) + mat2 T = mat2(dFdx(P.x), dFdy(P.x), dFdx(P.y), dFdy(P.y)); + mat2 Tinv = qInverse(T); + vec2 Q1_s = Tinv * Q1; + vec2 Q2_s = Tinv * Q2; + vec2 P_s = Tinv * P.xy; + vec2 n_s = Tinv * n; + n_s = n_s / length(n_s); +#else + vec2 Q1_s = ubuf.matrixScale * Q1; + vec2 Q2_s = ubuf.matrixScale * Q2; + vec2 P_s = ubuf.matrixScale * P.xy; + vec2 n_s = n; +#endif + + // Geometric solution for anti aliasing using the known distances + // to the edges of the path in the screen coordinate system. + float dist1 = dot(P_s - Q1_s, n_s); + float dist2 = dot(P_s - Q2_s, n_s); + + // Calculate the fill coverage if the line is crossing the square cell + // normally (vertically or horizontally). + // float fillCoverageLin = clamp(0.5-dist1, 0., 1.) - clamp(0.5-dist2, 0., 1.); + + // Calculate the fill coverage if the line is crossing the square cell + // diagonally. + float fillCoverageDia = clamp(step(0., -dist1) + sign(dist1) * pow(max(0., sqrt(2.) / 2. - abs(dist1)), 2.), 0., 1.) - + clamp(step(0., -dist2) + sign(dist2) * pow(max(0., sqrt(2.) / 2. - abs(dist2)), 2.), 0., 1.); + + // Merge the normal and the diagonal solution. The merge factor is periodic + // in 90 degrees and 0/1 at 0 and 45 degree. The simple equation was + // estimated after numerical experiments. + // float mergeFactor = 2 * abs(n_s.x) * abs(n_s.y); + // float fillCoverage = mergeFactor * fillCoverageDia + (1-mergeFactor) * fillCoverageLin; + + // It seems to be sufficient to use the equation for the diagonal. + float fillCoverage = fillCoverageDia; + + // The center line is sometimes not filled because of numerical issues. This fixes this. + float centerline = step(ubuf.strokeWidth * 0.01, dmin); + fillCoverage = fillCoverage * centerline + min(1., ubuf.strokeWidth * ubuf.matrixScale) * (1. - centerline); + + fragColor = vec4(ubuf.strokeColor.rgb, 1.0) *ubuf.strokeColor.a * fillCoverage * ubuf.opacity + + ubuf.debug * vec4(0.0, 0.5, 1.0, 1.0) * (1.0 - fillCoverage) * ubuf.opacity; +} diff --git a/src/quick/scenegraph/shaders_ng/shapestroke.vert b/src/quick/scenegraph/shaders_ng/shapestroke.vert new file mode 100644 index 0000000000..e358e059eb --- /dev/null +++ b/src/quick/scenegraph/shaders_ng/shapestroke.vert @@ -0,0 +1,82 @@ +#version 440 + +layout(location = 0) in vec4 vertexCoord; +layout(location = 1) in vec2 inA; +layout(location = 2) in vec2 inB; +layout(location = 3) in vec2 inC; +layout(location = 4) in vec2 normalVector; + +layout(location = 0) out vec4 P; +layout(location = 1) out vec2 A; +layout(location = 2) out vec2 B; +layout(location = 3) out vec2 C; +layout(location = 4) out vec2 HG; +layout(location = 5) out float offset; + + +layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else + mat4 qt_Matrix; +#endif + + float matrixScale; + float opacity; + float reserved2; + float reserved3; + + vec4 strokeColor; + + float strokeWidth; + float debug; + float reserved5; + float reserved6; +} ubuf; + +#define SQRT2 1.41421356237 + +float qdot(vec2 a, vec2 b) +{ + return a.x * b.x + a.y * b.y; +} + +void main() +{ + P = vertexCoord + vec4(normalVector, 0.0, 0.0) * SQRT2/ubuf.matrixScale; + + A = inA; + B = inB; + C = inC; + + // Find the parameters H, G for the depressed cubic + // t^2+H*t+G=0 + // that results from the equation + // Q'(s).(p-Q(s)) = 0 + // The last parameter is the static offset between s and t: + // s = t - b/(3a) + // use it to get back the parameter t + + // this is a constant for the curve + float a = -2. * qdot(A, A); + // this is a constant for the curve + float b = -3. * qdot(A, B); + //this is linear in p so it can be put into the shader with vertex data + float c = 2. * qdot(A, P.xy) - qdot(B, B) - 2. * qdot(A, C); + //this is linear in p so it can be put into the shader with vertex data + float d = qdot(B, P.xy) - qdot(B, C); + // convert to depressed cubic. + // both functions are linear in c and d and thus linear in p + float H = (3. * a * c - b * b) / (3. * a * a); + float G = (2. * b * b * b - 9. * a * b * c + 27. * a * a * d) / (27. * a * a * a); + HG = vec2(H, G); + offset = b/(3*a); + + + +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = ubuf.qt_Matrix[gl_ViewIndex] * P; +#else + gl_Position = ubuf.qt_Matrix * P; +#endif +} diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.frag b/src/quick/scenegraph/shaders_ng/smoothcolor.frag index ede283be0c..314a387922 100644 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.frag +++ b/src/quick/scenegraph/shaders_ng/smoothcolor.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec4 color; diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb Binary files differdeleted file mode 100644 index e598857192..0000000000 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.vert b/src/quick/scenegraph/shaders_ng/smoothcolor.vert index 03a3ff8975..6ec10a7e70 100644 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.vert +++ b/src/quick/scenegraph/shaders_ng/smoothcolor.vert @@ -7,22 +7,32 @@ layout(location = 2) in vec4 vertexOffset; layout(location = 0) out vec4 color; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec2 pixelSize; float opacity; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - vec4 pos = ubuf.matrix * vertex; +#if QSHADER_VIEW_COUNT >= 2 + vec4 pos = matrix[gl_ViewIndex] * vertex; + vec4 m0 = matrix[gl_ViewIndex][0]; + vec4 m1 = matrix[gl_ViewIndex][1]; +#else + vec4 pos = matrix * vertex; + vec4 m0 = matrix[0]; + vec4 m1 = matrix[1]; +#endif gl_Position = pos; if (vertexOffset.x != 0.) { - vec4 delta = ubuf.matrix[0] * vertexOffset.x; + vec4 delta = m0 * vertexOffset.x; vec2 dir = delta.xy * pos.w - pos.xy * delta.w; - vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize); + vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); dir -= ndir * delta.w * pos.w; float numerator = dot(dir, ndir * pos.w * pos.w); float scale = 0.0; @@ -34,9 +44,9 @@ void main() } if (vertexOffset.y != 0.) { - vec4 delta = ubuf.matrix[1] * vertexOffset.y; + vec4 delta = m1 * vertexOffset.y; vec2 dir = delta.xy * pos.w - pos.xy * delta.w; - vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize); + vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); dir -= ndir * delta.w * pos.w; float numerator = dot(dir, ndir * pos.w * pos.w); float scale = 0.0; @@ -47,5 +57,5 @@ void main() gl_Position += scale * delta; } - color = vertexColor * ubuf.opacity; + color = vertexColor * opacity; } diff --git a/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb Binary files differdeleted file mode 100644 index e301f561ce..0000000000 --- a/src/quick/scenegraph/shaders_ng/smoothcolor.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.frag b/src/quick/scenegraph/shaders_ng/smoothtexture.frag index b06764ad95..a7ddc57535 100644 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.frag +++ b/src/quick/scenegraph/shaders_ng/smoothtexture.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 texCoord; diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb b/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb Binary files differdeleted file mode 100644 index 12d3465f66..0000000000 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.vert b/src/quick/scenegraph/shaders_ng/smoothtexture.vert index 965c837852..4edde5472c 100644 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.vert +++ b/src/quick/scenegraph/shaders_ng/smoothtexture.vert @@ -9,23 +9,33 @@ layout(location = 0) out vec2 texCoord; layout(location = 1) out float vertexOpacity; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; +#endif float opacity; vec2 pixelSize; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - vec4 pos = ubuf.qt_Matrix * vertex; +#if QSHADER_VIEW_COUNT >= 2 + vec4 pos = qt_Matrix[gl_ViewIndex] * vertex; + vec4 m0 = qt_Matrix[gl_ViewIndex][0]; + vec4 m1 = qt_Matrix[gl_ViewIndex][1]; +#else + vec4 pos = qt_Matrix * vertex; + vec4 m0 = qt_Matrix[0]; + vec4 m1 = qt_Matrix[1]; +#endif gl_Position = pos; texCoord = multiTexCoord; if (vertexOffset.x != 0.) { - vec4 delta = ubuf.qt_Matrix[0] * vertexOffset.x; + vec4 delta = m0 * vertexOffset.x; vec2 dir = delta.xy * pos.w - pos.xy * delta.w; - vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize); + vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); dir -= ndir * delta.w * pos.w; float numerator = dot(dir, ndir * pos.w * pos.w); float scale = 0.0; @@ -38,9 +48,9 @@ void main() } if (vertexOffset.y != 0.) { - vec4 delta = ubuf.qt_Matrix[1] * vertexOffset.y; + vec4 delta = m1 * vertexOffset.y; vec2 dir = delta.xy * pos.w - pos.xy * delta.w; - vec2 ndir = .5 * ubuf.pixelSize * normalize(dir / ubuf.pixelSize); + vec2 ndir = .5 * pixelSize * normalize(dir / pixelSize); dir -= ndir * delta.w * pos.w; float numerator = dot(dir, ndir * pos.w * pos.w); float scale = 0.0; @@ -57,5 +67,5 @@ void main() if (onEdge && outerEdge) vertexOpacity = 0.; else - vertexOpacity = ubuf.opacity; + vertexOpacity = opacity; } diff --git a/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb b/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb Binary files differdeleted file mode 100644 index 2f7fa1bcd9..0000000000 --- a/src/quick/scenegraph/shaders_ng/smoothtexture.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/sprite.frag b/src/quick/scenegraph/shaders_ng/sprite.frag index 338f5e957e..387be43bb1 100644 --- a/src/quick/scenegraph/shaders_ng/sprite.frag +++ b/src/quick/scenegraph/shaders_ng/sprite.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec4 fTexS; @@ -8,15 +11,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D tex; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec4 animPos; vec3 animData; float opacity; -} ubuf; +}; void main() { fragColor = mix(texture(tex, fTexS.xy), texture(tex, fTexS.zw), - progress) * ubuf.opacity; + progress) * opacity; } diff --git a/src/quick/scenegraph/shaders_ng/sprite.frag.qsb b/src/quick/scenegraph/shaders_ng/sprite.frag.qsb Binary files differdeleted file mode 100644 index 479695b7fe..0000000000 --- a/src/quick/scenegraph/shaders_ng/sprite.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/sprite.vert b/src/quick/scenegraph/shaders_ng/sprite.vert index b76e2b206f..b693e31334 100644 --- a/src/quick/scenegraph/shaders_ng/sprite.vert +++ b/src/quick/scenegraph/shaders_ng/sprite.vert @@ -7,23 +7,29 @@ layout(location = 0) out vec4 fTexS; layout(location = 1) out float progress; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif vec4 animPos; // x,y, x,y (two frames for interpolation) vec3 animData; // w,h(premultiplied of anim), interpolation progress float opacity; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - progress = ubuf.animData.z; + progress = animData.z; // Calculate frame location in texture - fTexS.xy = ubuf.animPos.xy + vTex.xy * ubuf.animData.xy; + fTexS.xy = animPos.xy + vTex.xy * animData.xy; // Next frame is also passed, for interpolation - fTexS.zw = ubuf.animPos.zw + vTex.xy * ubuf.animData.xy; + fTexS.zw = animPos.zw + vTex.xy * animData.xy; - gl_Position = ubuf.matrix * vec4(vPos.x, vPos.y, 0, 1); +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vec4(vPos.x, vPos.y, 0, 1); +#else + gl_Position = matrix * vec4(vPos.x, vPos.y, 0, 1); +#endif } diff --git a/src/quick/scenegraph/shaders_ng/sprite.vert.qsb b/src/quick/scenegraph/shaders_ng/sprite.vert.qsb Binary files differdeleted file mode 100644 index 0c2fd4f403..0000000000 --- a/src/quick/scenegraph/shaders_ng/sprite.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/stencilclip.frag b/src/quick/scenegraph/shaders_ng/stencilclip.frag index 3f6222389d..ec4d3a05b1 100644 --- a/src/quick/scenegraph/shaders_ng/stencilclip.frag +++ b/src/quick/scenegraph/shaders_ng/stencilclip.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) out vec4 fragColor; diff --git a/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb b/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb Binary files differdeleted file mode 100644 index 7505d2c918..0000000000 --- a/src/quick/scenegraph/shaders_ng/stencilclip.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb b/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb Binary files differdeleted file mode 100644 index cd94715353..0000000000 --- a/src/quick/scenegraph/shaders_ng/stencilclip.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/styledtext.frag b/src/quick/scenegraph/shaders_ng/styledtext.frag index 0b16396037..e55e10b05e 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.frag +++ b/src/quick/scenegraph/shaders_ng/styledtext.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,19 +11,24 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { float glyph = texture(_qt_texture, sampleCoord).r; float style = clamp(texture(_qt_texture, shiftedSampleCoord).r - glyph, 0.0, 1.0); - fragColor = style * ubuf.styleColor + glyph * ubuf.color; + fragColor = style * styleColor + glyph * color; } diff --git a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb Binary files differdeleted file mode 100644 index 41c3419709..0000000000 --- a/src/quick/scenegraph/shaders_ng/styledtext.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/styledtext.vert b/src/quick/scenegraph/shaders_ng/styledtext.vert index beadf07c79..5e0a8fa5c9 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext.vert +++ b/src/quick/scenegraph/shaders_ng/styledtext.vert @@ -7,21 +7,28 @@ layout(location = 0) out vec2 sampleCoord; layout(location = 1) out vec2 shiftedSampleCoord; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - shiftedSampleCoord = (tCoord - ubuf.shift) * ubuf.textureScale; - vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; - gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); + sampleCoord = tCoord * textureScale; + shiftedSampleCoord = (tCoord - shift) * textureScale; + vec4 xformed = modelViewMatrix * vCoord; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = projectionMatrix[gl_ViewIndex] * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#else + gl_Position = projectionMatrix * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#endif } diff --git a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb b/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb Binary files differdeleted file mode 100644 index 96d60d5e88..0000000000 --- a/src/quick/scenegraph/shaders_ng/styledtext.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/styledtext_a.frag b/src/quick/scenegraph/shaders_ng/styledtext_a.frag index b673137895..6a684c2abb 100644 --- a/src/quick/scenegraph/shaders_ng/styledtext_a.frag +++ b/src/quick/scenegraph/shaders_ng/styledtext_a.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -8,19 +11,24 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; + vec4 color; // the above must stay compatible with textmask/8bittextmask vec4 styleColor; vec2 shift; -} ubuf; +}; void main() { float glyph = texture(_qt_texture, sampleCoord).a; // take .a instead of .r float style = clamp(texture(_qt_texture, shiftedSampleCoord).a - glyph, 0.0, 1.0); - fragColor = style * ubuf.styleColor + glyph * ubuf.color; + fragColor = style * styleColor + glyph * color; } diff --git a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb b/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb Binary files differdeleted file mode 100644 index 45a3366a33..0000000000 --- a/src/quick/scenegraph/shaders_ng/styledtext_a.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/textmask.frag b/src/quick/scenegraph/shaders_ng/textmask.frag index 518d5c965f..0f9d6b4567 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.frag +++ b/src/quick/scenegraph/shaders_ng/textmask.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 sampleCoord; @@ -6,14 +9,19 @@ layout(location = 0) out vec4 fragColor; layout(binding = 1) uniform sampler2D _qt_texture; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; + vec4 color; +}; void main() { vec4 glyph = texture(_qt_texture, sampleCoord); - fragColor = vec4(glyph.rgb * ubuf.color.a, glyph.a); + fragColor = vec4(glyph.rgb * color.a, glyph.a); } diff --git a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb b/src/quick/scenegraph/shaders_ng/textmask.frag.qsb Binary files differdeleted file mode 100644 index da5f54db15..0000000000 --- a/src/quick/scenegraph/shaders_ng/textmask.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/textmask.vert b/src/quick/scenegraph/shaders_ng/textmask.vert index 9d80d5dadb..41fffa282f 100644 --- a/src/quick/scenegraph/shaders_ng/textmask.vert +++ b/src/quick/scenegraph/shaders_ng/textmask.vert @@ -6,17 +6,24 @@ layout(location = 1) in vec2 tCoord; layout(location = 0) out vec2 sampleCoord; layout(std140, binding = 0) uniform buf { - mat4 matrix; - vec4 color; + mat4 modelViewMatrix; +#if QSHADER_VIEW_COUNT >= 2 + mat4 projectionMatrix[QSHADER_VIEW_COUNT]; +#else + mat4 projectionMatrix; +#endif vec2 textureScale; float dpr; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; + vec4 color; +}; void main() { - sampleCoord = tCoord * ubuf.textureScale; - vec3 dprSnapPos = floor(vCoord.xyz * ubuf.dpr + 0.5) / ubuf.dpr; - gl_Position = ubuf.matrix * vec4(dprSnapPos, vCoord.w); + sampleCoord = tCoord * textureScale; + vec4 xformed = modelViewMatrix * vCoord; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = projectionMatrix[gl_ViewIndex] * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#else + gl_Position = projectionMatrix * vec4(floor(xformed.xyz * dpr + 0.5) / dpr, xformed.w); +#endif } diff --git a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb b/src/quick/scenegraph/shaders_ng/textmask.vert.qsb Binary files differdeleted file mode 100644 index c2554dceb3..0000000000 --- a/src/quick/scenegraph/shaders_ng/textmask.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/texture.frag b/src/quick/scenegraph/shaders_ng/texture.frag index bd22f817e0..a591e72ccf 100644 --- a/src/quick/scenegraph/shaders_ng/texture.frag +++ b/src/quick/scenegraph/shaders_ng/texture.frag @@ -1,16 +1,23 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 qt_TexCoord; layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; +#endif float opacity; -} ubuf; +}; layout(binding = 1) uniform sampler2D qt_Texture; void main() { - fragColor = texture(qt_Texture, qt_TexCoord) * ubuf.opacity; + fragColor = texture(qt_Texture, qt_TexCoord) * opacity; } diff --git a/src/quick/scenegraph/shaders_ng/texture.frag.qsb b/src/quick/scenegraph/shaders_ng/texture.frag.qsb Binary files differdeleted file mode 100644 index b7b5c481a7..0000000000 --- a/src/quick/scenegraph/shaders_ng/texture.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/texture.vert b/src/quick/scenegraph/shaders_ng/texture.vert index 537852d2bd..ae8a27f4a6 100644 --- a/src/quick/scenegraph/shaders_ng/texture.vert +++ b/src/quick/scenegraph/shaders_ng/texture.vert @@ -6,14 +6,20 @@ layout(location = 1) in vec2 qt_VertexTexCoord; layout(location = 0) out vec2 qt_TexCoord; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 qt_Matrix[QSHADER_VIEW_COUNT]; +#else mat4 qt_Matrix; +#endif float opacity; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { qt_TexCoord = qt_VertexTexCoord; - gl_Position = ubuf.qt_Matrix * qt_VertexPosition; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = qt_Matrix[gl_ViewIndex] * qt_VertexPosition; +#else + gl_Position = qt_Matrix * qt_VertexPosition; +#endif } diff --git a/src/quick/scenegraph/shaders_ng/texture.vert.qsb b/src/quick/scenegraph/shaders_ng/texture.vert.qsb Binary files differdeleted file mode 100644 index fba7d35301..0000000000 --- a/src/quick/scenegraph/shaders_ng/texture.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.frag b/src/quick/scenegraph/shaders_ng/vertexcolor.frag index ede283be0c..314a387922 100644 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.frag +++ b/src/quick/scenegraph/shaders_ng/vertexcolor.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec4 color; diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb b/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb Binary files differdeleted file mode 100644 index 24ec283c72..0000000000 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.vert b/src/quick/scenegraph/shaders_ng/vertexcolor.vert index bfb9a95073..792f663b86 100644 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.vert +++ b/src/quick/scenegraph/shaders_ng/vertexcolor.vert @@ -6,14 +6,20 @@ layout(location = 1) in vec4 vertexColor; layout(location = 0) out vec4 color; layout(std140, binding = 0) uniform buf { +#if QSHADER_VIEW_COUNT >= 2 + mat4 matrix[QSHADER_VIEW_COUNT]; +#else mat4 matrix; +#endif float opacity; -} ubuf; - -out gl_PerVertex { vec4 gl_Position; }; +}; void main() { - gl_Position = ubuf.matrix * vertexCoord; - color = vertexColor * ubuf.opacity; +#if QSHADER_VIEW_COUNT >= 2 + gl_Position = matrix[gl_ViewIndex] * vertexCoord; +#else + gl_Position = matrix * vertexCoord; +#endif + color = vertexColor * opacity; } diff --git a/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb b/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb Binary files differdeleted file mode 100644 index e1d3ce6d61..0000000000 --- a/src/quick/scenegraph/shaders_ng/vertexcolor.vert.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/visualization.frag b/src/quick/scenegraph/shaders_ng/visualization.frag index 29f718fe5d..378afc2088 100644 --- a/src/quick/scenegraph/shaders_ng/visualization.frag +++ b/src/quick/scenegraph/shaders_ng/visualization.frag @@ -1,3 +1,6 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + #version 440 layout(location = 0) in vec2 pos; diff --git a/src/quick/scenegraph/shaders_ng/visualization.frag.qsb b/src/quick/scenegraph/shaders_ng/visualization.frag.qsb Binary files differdeleted file mode 100644 index af5b9b5b96..0000000000 --- a/src/quick/scenegraph/shaders_ng/visualization.frag.qsb +++ /dev/null diff --git a/src/quick/scenegraph/shaders_ng/visualization.vert.qsb b/src/quick/scenegraph/shaders_ng/visualization.vert.qsb Binary files differdeleted file mode 100644 index c44d8a6dc2..0000000000 --- a/src/quick/scenegraph/shaders_ng/visualization.vert.qsb +++ /dev/null |