summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/rhi/qrhi.cpp7
-rw-r--r--src/gui/rhi/qrhigles2.cpp21
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h4
3 files changed, 19 insertions, 13 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 8ec8ae9208..bea8890234 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -568,11 +568,10 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
supports QRhiGraphicsPipeline::TriangleFan.
\value ReadBackNonUniformBuffer Indicates that
- {QRhiResourceUpdateBatch::readBackBuffer()}{reading buffer contents} is
+ \l{QRhiResourceUpdateBatch::readBackBuffer()}{reading buffer contents} is
supported for QRhiBuffer instances with a usage different than
- UniformBuffer. While this is supported in the majority of cases, it can be
- unsupported, for example, on OpenGL ES 2.0 implementations without the
- MapBuffer extension.
+ UniformBuffer. While this is supported in the majority of cases, it will be
+ unsupported with OpenGL ES older than 3.0.
*/
/*!
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index a6094183fb..fa99ee5e25 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -276,6 +276,10 @@ QT_BEGIN_NAMESPACE
#define GL_POINT_SPRITE 0x8861
#endif
+#ifndef GL_MAP_READ_BIT
+#define GL_MAP_READ_BIT 0x0001
+#endif
+
Q_DECLARE_LOGGING_CATEGORY(lcOpenGLProgramDiskCache)
/*!
@@ -492,7 +496,9 @@ bool QRhiGles2::create(QRhi::Flags flags)
else
caps.textureCompareMode = true;
- caps.mapBuffer = f->hasOpenGLExtension(QOpenGLExtensions::MapBuffer);
+ // proper as in ES 3.0 (glMapBufferRange), not the old glMapBuffer
+ // extension(s) (which is not in ES 3.0...messy)
+ caps.properMapBuffer = f->hasOpenGLExtension(QOpenGLExtensions::MapBufferRange);
if (!caps.gles) {
f->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
@@ -737,7 +743,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
case QRhi::TriangleFanTopology:
return true;
case QRhi::ReadBackNonUniformBuffer:
- return !caps.gles || caps.mapBuffer;
+ return !caps.gles || caps.properMapBuffer;
default:
Q_UNREACHABLE();
return false;
@@ -2107,13 +2113,14 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
QRhiBufferReadbackResult *result = cmd.args.getBufferSubData.result;
f->glBindBuffer(cmd.args.getBufferSubData.target, cmd.args.getBufferSubData.buffer);
if (caps.gles) {
- if (caps.mapBuffer) {
- void *p = f->glMapBuffer(cmd.args.getBufferSubData.target, GL_READ_ONLY);
+ if (caps.properMapBuffer) {
+ void *p = f->glMapBufferRange(cmd.args.getBufferSubData.target,
+ cmd.args.getBufferSubData.offset,
+ cmd.args.getBufferSubData.size,
+ GL_MAP_READ_BIT);
if (p) {
result->data.resize(cmd.args.getBufferSubData.size);
- memcpy(result->data.data(),
- reinterpret_cast<char *>(p) + cmd.args.getBufferSubData.offset,
- size_t(cmd.args.getBufferSubData.size));
+ memcpy(result->data.data(), p, size_t(cmd.args.getBufferSubData.size));
f->glUnmapBuffer(cmd.args.getBufferSubData.target);
}
}
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index a4a9c15ce7..29cccb0c9c 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -753,7 +753,7 @@ public:
baseVertex(false),
compute(false),
textureCompareMode(false),
- mapBuffer(false)
+ properMapBuffer(false)
{ }
int ctxMajor;
int ctxMinor;
@@ -784,7 +784,7 @@ public:
uint baseVertex : 1;
uint compute : 1;
uint textureCompareMode : 1;
- uint mapBuffer : 1;
+ uint properMapBuffer : 1;
} caps;
QGles2SwapChain *currentSwapChain = nullptr;
QVector<GLint> supportedCompressedFormats;