rhi: gl: Switch GetBufferSubData emulation to MapBufferRange
Use only APIs that are in GLES 3.0. glMapBuffer() is an old OES extension, stop bothering with that. Not the least because ANGLE claims supporting it and then fails the map. (not that we care much about ANGLE, but, for instance, the qrhi autotest is run with ANGLE configurations as well in the CI, so have to still take care of it for the duration of Qt 5.x) Change-Id: I29140402cedffe0430f920ee0c061673257c3aa1 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
9c466946d0
commit
32924110ce
@ -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.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user