rhi: gl: Make QQuickWidget and QRhiWidget work on eglfs

Strictly speaking, the problem has nothing to do with QRhi. What is
special with the eglfs' backingstore is that it creates a QRhiTexture
and then pulls out the OpenGL texture ID via nativeTexture() right
afterwards.

In this setup there is nothing that would ensure glTexParameteri is
called to override the silly default of OpenGL. Normally this cannot
happen because once the QRhiTexture is used for sampling purposes
together with a QRhiSampler, all necessary state gets updated.

Starting from Qt 6.4, with the QRhi-based backingstore composition
changes, the special case where we create QRhiTextures just to get the
underlying OpenGL texture got introduced.

Ideally the eglfs side should provide its in MIN/MAG filter state, but
in the meantime, to be more robust, always set a MIN filter already in
QRhiTexture::create(). For most textures this will get changed
afterwards.

Change-Id: I305cdbb5576b977887b85a15b72455bb3ae430c4
Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-123551
Reviewed-by: Karim Pinter <karim.pinter@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 88aa5250d58900653192c45e41f182ec88474e38)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2024-08-28 16:18:32 +02:00 committed by Qt Cherry-pick Bot
parent 5b4842c992
commit fb6cfadc38

View File

@ -5728,6 +5728,11 @@ bool QGles2Texture::create()
rhiD->f->glTexStorage2D(target, mipLevelCount, glsizedintformat, size.width(),
is1D ? qMax(0, m_arraySize) : size.height());
}
// Make sure the min filter is set to something non-mipmap-based already
// here, given the ridiculous default of GL. It is changed based on
// the sampler later, but there could be cases when one pulls the native
// object out via nativeTexture() right away.
rhiD->f->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
specified = true;
} else {
// Cannot use glCompressedTexImage2D without valid data, so defer.