summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhigles2.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-02-02 12:41:45 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-02-03 10:40:47 +0100
commitd136299bb83f5343a62f9e02693f6737981edf62 (patch)
treec7c69e3c2e364094a5b30065dc9dc1acafff1727 /src/gui/rhi/qrhigles2.cpp
parenteadbf2dd0bbddd2cf891851e8a39289857a4ef2d (diff)
rhi: gl: Attempt reading back floating point formats
...in the hope that they may work. If not, that's it, but at least we tried. Task-number: QTBUG-76970 Change-Id: I134c5cc4cfb5ad1e6f9edbfcf506df20022e127a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhigles2.cpp')
-rw-r--r--src/gui/rhi/qrhigles2.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index fac05f4947..cd1e4ec944 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -2740,8 +2740,23 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
}
}
} else {
- result->data.resize(w * h * 4);
- f->glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, result->data.data());
+ switch (result->format) {
+ // For floating point formats try it because this can be
+ // relevant for some use cases; if it works, then fine, if
+ // not, there's nothing we can do.
+ case QRhiTexture::RGBA16F:
+ result->data.resize(w * h * 8);
+ f->glReadPixels(0, 0, w, h, GL_RGBA, GL_HALF_FLOAT, result->data.data());
+ break;
+ case QRhiTexture::RGBA32F:
+ result->data.resize(w * h * 16);
+ f->glReadPixels(0, 0, w, h, GL_RGBA, GL_FLOAT, result->data.data());
+ break;
+ default:
+ result->data.resize(w * h * 4);
+ f->glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, result->data.data());
+ break;
+ }
}
} else {
result->data.resize(w * h * 4);