From 88aa5250d58900653192c45e41f182ec88474e38 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 28 Aug 2024 16:18:32 +0200 Subject: [PATCH] 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 Reviewed-by: Andy Nichols --- src/gui/rhi/qrhigles2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index b18b850f4b5..7d7068087a3 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -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.