diff --git a/tests/qml/src/main.cpp b/tests/qml/src/main.cpp index 349ac55d88..d983353893 100644 --- a/tests/qml/src/main.cpp +++ b/tests/qml/src/main.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -88,7 +88,7 @@ private: OffscreenGLCanvas _sharedContext; std::array, DIVISIONS_X> _surfaces; - QOpenGLFunctions_4_5_Core _glf; + QOpenGLFunctions_4_1_Core _glf; std::function _discardLamdba; QSize _size; size_t _surfaceCount{ 0 }; @@ -145,7 +145,7 @@ void TestWindow::initGl() { gl::initModuleGl(); _glf.initializeOpenGLFunctions(); - _glf.glCreateFramebuffers(1, &_fbo); + _glf.glGenFramebuffers(1, &_fbo); if (!_sharedContext.create(&_glContext) || !_sharedContext.makeCurrent()) { qFatal("Unable to intialize Shared GL context"); @@ -196,6 +196,12 @@ void TestWindow::buildSurface(QmlInfo& qmlInfo, bool video) { void TestWindow::destroySurface(QmlInfo& qmlInfo) { auto& surface = qmlInfo.surface; + auto& currentTexture = qmlInfo.texture; + if (currentTexture) { + auto readFence = _glf.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + _discardLamdba(currentTexture, readFence); + } auto webView = surface->getRootItem(); if (webView) { // stop loading @@ -274,16 +280,19 @@ void TestWindow::draw() { if (!qmlInfo.surface || !qmlInfo.texture) { continue; } - _glf.glNamedFramebufferTexture(_fbo, GL_COLOR_ATTACHMENT0, qmlInfo.texture, 0); - _glf.glBlitNamedFramebuffer(_fbo, 0, - // src coordinates - 0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1, - // dst coordinates - incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1), - // blit mask and filter - GL_COLOR_BUFFER_BIT, GL_NEAREST); + _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo); + _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, qmlInfo.texture, 0); + _glf.glBlitFramebuffer( + // src coordinates + 0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1, + // dst coordinates + incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1), + // blit mask and filter + GL_COLOR_BUFFER_BIT, GL_NEAREST); } } + _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); + _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); _glContext.swapBuffers(this); }