summaryrefslogtreecommitdiffstats
path: root/tests/auto/opengl
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2018-02-14 16:59:52 +0200
committerKari Oikarinen <kari.oikarinen@qt.io>2018-03-02 07:20:32 +0000
commitd42a9d19ff1ed83bdb31a62e28a5757384e05367 (patch)
treedf8a76ff351af5d1d9ab45d8574ac4e20080a7f7 /tests/auto/opengl
parent810bc3fb1942fa241c7ca263aec6eb53085003bf (diff)
Remove tst_QGLThreads::textureUploadInThread
The test has been crashing flakily recently. 1) It is creating a QGLWidget 2) It is stealing the QGLContext of that widget and moves it into a separate thread. 3) In that secondary thread it makes the context current. 4) Meanwhile the QGLWidget itself may receive for example a resizeEvent or other events and - since it assumes that it owns the context - attempts to make it current. 5) Attempting to call makeCurrent() on a QGLContext that is in a different thread than the current thread (via QObject thread affinity) will result in a call to qFatal() and consequently the test aborts. The conclusion from Simon Hausmann is that this test is testing a pattern from Qt4 times that may or may not have worked back then. Nowadays with the Qt5 QOpenGL* API we do support this properly and there appears little sense testing this. Therefore remove the test altogether. Task-number: QTBUG-66411 Task-number: QTBUG-66216 Change-Id: Ie2d66705bc7c3914ace6abcba9557c7c67ad4db3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto/opengl')
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.cpp133
-rw-r--r--tests/auto/opengl/qglthreads/tst_qglthreads.h1
2 files changed, 0 insertions, 134 deletions
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
index 90fc4e0f2a..76186f5575 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp
@@ -185,139 +185,6 @@ void tst_QGLThreads::swapInThread()
QVERIFY(true);
}
-
-
-
-
-
-
-/*
- textureUploadInThread
-
- The purpose of this testcase is to verify that doing texture uploads in a background
- thread is possible and that it works.
- */
-
-class CreateAndUploadThread : public QThread
-{
- Q_OBJECT
-public:
- CreateAndUploadThread(QGLWidget *shareWidget, QSemaphore *semaphore)
- : m_semaphore(semaphore)
- {
- m_gl = new QGLWidget(0, shareWidget);
- moveToThread(this);
-
- }
-
- void moveContextToThread()
- {
- m_gl->context()->moveToThread(this);
- }
-
- ~CreateAndUploadThread()
- {
- delete m_gl;
- }
-
- void run() {
- m_gl->makeCurrent();
- QTime time;
- time.start();
- while (time.elapsed() < RUNNING_TIME) {
- int width = 400;
- int height = 300;
- QImage image(width, height, QImage::Format_RGB32);
- QPainter p(&image);
- p.fillRect(image.rect(), QColor(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256)));
- p.setPen(Qt::red);
- p.setFont(QFont("SansSerif", 24));
- p.drawText(image.rect(), Qt::AlignCenter, "This is an autotest");
- p.end();
- m_gl->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
-
- m_semaphore->acquire(1);
-
- createdAndUploaded(image);
- }
- }
-
-signals:
- void createdAndUploaded(const QImage &image);
-
-private:
- QGLWidget *m_gl;
- QSemaphore *m_semaphore;
-};
-
-class TextureDisplay : public QGLWidget
-{
- Q_OBJECT
-public:
- TextureDisplay(QSemaphore *semaphore)
- : m_semaphore(semaphore)
- {
- }
-
- void paintEvent(QPaintEvent *) {
- QPainter p(this);
- for (int i=0; i<m_images.size(); ++i) {
- p.drawImage(m_positions.at(i), m_images.at(i));
- m_positions[i] += QPoint(1, 1);
- }
- update();
- }
-
-public slots:
- void receiveImage(const QImage &image) {
- m_images << image;
- m_positions << QPoint(-QRandomGenerator::global()->bounded(width() / 2), -QRandomGenerator::global()->bounded(height() / 2));
-
- m_semaphore->release(1);
-
- if (m_images.size() > 100) {
- m_images.takeFirst();
- m_positions.takeFirst();
- }
- }
-
-private:
- QList <QImage> m_images;
- QList <QPoint> m_positions;
-
- QSemaphore *m_semaphore;
-};
-
-void tst_QGLThreads::textureUploadInThread()
-{
- if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))
- QSKIP("No platformsupport for ThreadedOpenGL");
-
- // prevent producer thread from queuing up too many images
- QSemaphore semaphore(100);
- TextureDisplay display(&semaphore);
- CreateAndUploadThread thread(&display, &semaphore);
-
- connect(&thread, SIGNAL(createdAndUploaded(QImage)), &display, SLOT(receiveImage(QImage)));
-
- display.show();
- QVERIFY(QTest::qWaitForWindowActive(&display));
-
- thread.moveContextToThread();
- thread.start();
-
- while (thread.isRunning()) {
- qApp->processEvents();
- }
-
- QVERIFY(true);
-}
-
-
-
-
-
-
/*
renderInThread
diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.h b/tests/auto/opengl/qglthreads/tst_qglthreads.h
index 037655c60f..e4b496c163 100644
--- a/tests/auto/opengl/qglthreads/tst_qglthreads.h
+++ b/tests/auto/opengl/qglthreads/tst_qglthreads.h
@@ -39,7 +39,6 @@ public:
private slots:
void swapInThread();
- void textureUploadInThread();
void renderInThread_data();
void renderInThread();