diff options
author | Jonas Karlsson <jonas.karlsson@qt.io> | 2024-02-19 18:09:05 +0100 |
---|---|---|
committer | Jonas Karlsson <jonas.karlsson@qt.io> | 2024-02-22 23:08:34 +0100 |
commit | aedbc7ba7a00d473764323969560bc30fba35523 (patch) | |
tree | dbe2737748c1b889245f44beebb66345d254b9ef /src/gui/rhi | |
parent | 4c1e23c9d3053771c88449025ea332ce723ab665 (diff) |
rhi: gl: Add R16F/R32F handling in pixel readback
When reading pixels back from a QRhiTexture if the format is R16F/R32F
then we will read pixels to a buffer with just a red component comprised
of (half) floats instead of the default case (RGBA). This is useful when
reading back a shadow map.
Change-Id: Iff2881992f0341252d5c565b5dd64bed078319bc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r-- | src/gui/rhi/qrhigles2.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 2f0659909f..d42e72301b 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3386,6 +3386,14 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) result->data.resize(w * h * 8); f->glReadPixels(0, 0, w, h, GL_RGBA, GL_HALF_FLOAT, result->data.data()); break; + case QRhiTexture::R16F: + result->data.resize(w * h * 2); + f->glReadPixels(0, 0, w, h, GL_RED, GL_HALF_FLOAT, result->data.data()); + break; + case QRhiTexture::R32F: + result->data.resize(w * h * 4); + f->glReadPixels(0, 0, w, h, GL_RED, GL_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()); |