diff options
| author | Laszlo Agocs <laszlo.agocs@qt.io> | 2025-06-04 15:10:41 +0200 |
|---|---|---|
| committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2025-06-10 13:25:50 +0200 |
| commit | 6cc919ab3f1782f37b05f3f445dad62672fe9895 (patch) | |
| tree | 40439832085b150bb1520cff29f9e588c4c4af0f /src/qml/jsruntime/qv4function.cpp | |
| parent | f20a020b741606de972d7c575c24330115734fcd (diff) | |
sg: Fix recursive layers losing the previous texture
...under certain conditions, such as when the size changes.
The recursive layer itself will likely depend on the texture backing the
layer when rendering. Typically, the fragment shader samples it. To make
this work, in recursive mode there are two backing textures.
There are two problems for recursive mode in the Qt 6 layer
implementation. (that in in some ways works quite differently from Qt 5,
due to the QRhi migration)
1. When new backing buffers are needed, for example because the item
size changes, immediately releasing the main backing texture in favor of
a new texture that is correctly sized but has uninitialized content is
not ideal, and is not what Qt 5 was doing.
Qt 5 continued to use the previous OpenGL texture when rendering for the
first time after a size change. As in, exposing the old texture as the
layer's backing texture, thus a recursive shader effect was sampling
that in the shader. (that the size of that input texture is technically
incorrect now is usually not a visible issue, and comes by design with
recursive mode)
Only once rendering to the new texture has been done for the first time
is the old texture released. The new one (which we just rendered into)
then takes over as the backing texture returned from rhiTexture() (or
the equivalent in Qt 5).
Make the Qt 6 implementation of layers to be identical to Qt 5 in this
regard.
2. There is an additional problem in the very first frame. Neither Qt 5
nor 6 clears the main backing texture. Because rendering to it does that
anyway. In recursive mode however, the very first frame will also sample
the texture. And the texture has uninitialized content at that point,
similarly to problem #1.
The result is that a non-live, recursive effect source exhibits either
artifacts, magenta (Metal) content, or just happens to look correct (so
not a visible issue usually with Qt 5 and OpenGL) With live: true (the
default) this issue is hidden, although the garbage my still flicker in
from the first frame.
Do an explicit clear now, so the first frame does not sample potential
garbage.
Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-112355
Change-Id: Ic9d2b0dc4aa6ab1e99d456bcce48ffa9ffbfecfe
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
0 files changed, 0 insertions, 0 deletions
