Merge pull request #2659 from Cacodemon345/qt-hwrenderer-fix

qt_hardwarerenderer: Don't update the entire texture on blits
This commit is contained in:
Miran Grča
2022-09-01 16:48:37 +02:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -21,6 +21,8 @@
#include "qt_hardwarerenderer.hpp"
#include <QApplication>
#include <QVector2D>
#include <QOpenGLPixelTransferOptions>
#include <atomic>
#include <vector>
@@ -196,7 +198,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) {
return;
}
m_context->makeCurrent(this);
m_texture->setData(QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)imagebufs[buf_idx].get());
m_texture->setData(0, 0, 0, w + x, h + y, 0, QOpenGLTexture::PixelFormat::RGBA, QOpenGLTexture::PixelType::UInt8, (const void*)imagebufs[buf_idx].get(), &m_transferOptions);
buf_usage[buf_idx].clear();
source.setRect(x, y, w, h);
if (origSource != source) onResize(this->width(), this->height());

View File

@@ -8,6 +8,7 @@
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QOpenGLTextureBlitter>
#include <QOpenGLPixelTransferOptions>
#include <QPainter>
#include <QEvent>
#include <QKeyEvent>
@@ -38,6 +39,8 @@ private:
QOpenGLTextureBlitter* m_blt{nullptr};
QOpenGLBuffer m_vbo[2];
QOpenGLVertexArrayObject m_vao;
QOpenGLPixelTransferOptions m_transferOptions;
public:
enum class RenderType {
OpenGL,
@@ -67,6 +70,8 @@ public:
parentWidget = parent;
setRenderType(rtype);
m_transferOptions.setRowLength(2048);
m_context = new QOpenGLContext();
m_context->setFormat(format());
m_context->create();