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 "qt_hardwarerenderer.hpp"
#include <QApplication> #include <QApplication>
#include <QVector2D> #include <QVector2D>
#include <QOpenGLPixelTransferOptions>
#include <atomic> #include <atomic>
#include <vector> #include <vector>
@@ -196,7 +198,7 @@ void HardwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h) {
return; return;
} }
m_context->makeCurrent(this); 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(); buf_usage[buf_idx].clear();
source.setRect(x, y, w, h); source.setRect(x, y, w, h);
if (origSource != source) onResize(this->width(), this->height()); if (origSource != source) onResize(this->width(), this->height());

View File

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