Strange behavior with recursive shaders in threaded renderer loop
-
Hello everyone,
I wanted to ask you experts if what I'm experiencing when recursive ShaderEffectSource are used in ShaderEffect is the intended behaviour or if it's an issue. I can experience this issue in (https://github.com/Swordfish90/cool-retro-term ) where I'm using a live recursive shader to create the burn-in effect. This recursive source is used as texture in the last step of the rendering, which has a time property controlled by a configurable timer.When the basic renderer loop is used the recursive shaders is updated at every frame, causing the final step to be updated, even if the time hasn't changed across the frames. This is the behaviour which I personally expected.
Activating the threaded render loop instead causes the recursive shaders to be "idle", and updated only when the final shader updates (basically when the time property changes).
I'm attacching here a minimal test case which shows the issue. Running it with QSG_RENDER_LOOP=basic or QSG_RENDER_LOOP=threaded shows extremely different behaviours.
@import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.0ApplicationWindow {
title: qsTr("Tiger Test")
width: 640
height: 480Image { id: image anchors.fill: parent source: "http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/Winter-Tiger-Wild-Cat-Images.jpg" visible: false } ShaderEffectSource{ id: imageSource sourceItem: image visible: false } ShaderEffect { id: firstStep anchors.fill: parent property variant src: imageSource property variant src2: secondStep fragmentShader: " varying highp vec2 qt_TexCoord0; uniform sampler2D src; uniform sampler2D src2; uniform lowp float qt_Opacity; void main() { lowp vec4 tex = texture2D(src, qt_TexCoord0) * 0.01 + texture2D(src2, qt_TexCoord0); gl_FragColor = vec4(vec3(dot(tex.rgb, vec3(0.344, 0.5, 0.156))), tex.a) * qt_Opacity; }" } ShaderEffectSource{ id: secondStep sourceItem: firstStep recursive: true live: true } ShaderEffect { anchors.fill: parent property variant src: secondStep property real time: 0 Timer{ running: true onTriggered: parent.time += 0.1 repeat: true interval: 500 } fragmentShader: " varying highp vec2 qt_TexCoord0; uniform float time; uniform sampler2D src; uniform lowp float qt_Opacity; void main() { gl_FragColor = texture2D(src, qt_TexCoord0) * time; }" }
}
@I'm currently using this in CRT as a sort of optimization, but I'm not so sure if I can rely on this behaviour or not.
Thank you in advance.