rhi: gl: Avoid a copy in partial texture uploads

Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-120565
Change-Id: I7f1f8c42b98c5743708c4ff80e401070d8ab24ac
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
bb10
Laszlo Agocs 2024-04-30 11:52:34 +02:00
parent d6bc7613ac
commit 690bb2e0c4
1 changed files with 9 additions and 1 deletions

View File

@ -2377,7 +2377,15 @@ void QRhiGles2::enqueueSubresUpload(QGles2Texture *texD, QGles2CommandBuffer *cb
const QPoint sp = subresDesc.sourceTopLeft();
if (!subresDesc.sourceSize().isEmpty())
size = subresDesc.sourceSize();
img = img.copy(sp.x(), sp.y(), size.width(), size.height());
if (caps.unpackRowLength) {
cbD->retainImage(img);
// create a non-owning wrapper for the subimage
const uchar *data = img.constBits() + sp.y() * img.bytesPerLine() + sp.x() * (qMax(1, img.depth() / 8));
img = QImage(data, size.width(), size.height(), img.bytesPerLine(), img.format());
} else {
img = img.copy(sp.x(), sp.y(), size.width(), size.height());
}
}
setCmdByNotCompressedData(cbD->retainImage(img), size, img.bytesPerLine());