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.8 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>
This commit is contained in:
Laszlo Agocs 2024-08-28 16:18:32 +02:00
parent 3cadd4b1f6
commit 88aa5250d5

View File

@ -5786,6 +5786,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.