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.
|
supports QRhiGraphicsPipeline::TriangleFan.
|
||||||
|
|
||||||
\value ReadBackNonUniformBuffer Indicates that
|
\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
|
supported for QRhiBuffer instances with a usage different than
|
||||||
UniformBuffer. While this is supported in the majority of cases, it can be
|
UniformBuffer. While this is supported in the majority of cases, it will be
|
||||||
unsupported, for example, on OpenGL ES 2.0 implementations without the
|
unsupported with OpenGL ES older than 3.0.
|
||||||
MapBuffer extension.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -276,6 +276,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
#define GL_POINT_SPRITE 0x8861
|
#define GL_POINT_SPRITE 0x8861
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef GL_MAP_READ_BIT
|
||||||
|
#define GL_MAP_READ_BIT 0x0001
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(lcOpenGLProgramDiskCache)
|
Q_DECLARE_LOGGING_CATEGORY(lcOpenGLProgramDiskCache)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -492,7 +496,9 @@ bool QRhiGles2::create(QRhi::Flags flags)
|
|||||||
else
|
else
|
||||||
caps.textureCompareMode = true;
|
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) {
|
if (!caps.gles) {
|
||||||
f->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
f->glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||||
@ -737,7 +743,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
|
|||||||
case QRhi::TriangleFanTopology:
|
case QRhi::TriangleFanTopology:
|
||||||
return true;
|
return true;
|
||||||
case QRhi::ReadBackNonUniformBuffer:
|
case QRhi::ReadBackNonUniformBuffer:
|
||||||
return !caps.gles || caps.mapBuffer;
|
return !caps.gles || caps.properMapBuffer;
|
||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
return false;
|
return false;
|
||||||
@ -2107,13 +2113,14 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
|
|||||||
QRhiBufferReadbackResult *result = cmd.args.getBufferSubData.result;
|
QRhiBufferReadbackResult *result = cmd.args.getBufferSubData.result;
|
||||||
f->glBindBuffer(cmd.args.getBufferSubData.target, cmd.args.getBufferSubData.buffer);
|
f->glBindBuffer(cmd.args.getBufferSubData.target, cmd.args.getBufferSubData.buffer);
|
||||||
if (caps.gles) {
|
if (caps.gles) {
|
||||||
if (caps.mapBuffer) {
|
if (caps.properMapBuffer) {
|
||||||
void *p = f->glMapBuffer(cmd.args.getBufferSubData.target, GL_READ_ONLY);
|
void *p = f->glMapBufferRange(cmd.args.getBufferSubData.target,
|
||||||
|
cmd.args.getBufferSubData.offset,
|
||||||
|
cmd.args.getBufferSubData.size,
|
||||||
|
GL_MAP_READ_BIT);
|
||||||
if (p) {
|
if (p) {
|
||||||
result->data.resize(cmd.args.getBufferSubData.size);
|
result->data.resize(cmd.args.getBufferSubData.size);
|
||||||
memcpy(result->data.data(),
|
memcpy(result->data.data(), p, size_t(cmd.args.getBufferSubData.size));
|
||||||
reinterpret_cast<char *>(p) + cmd.args.getBufferSubData.offset,
|
|
||||||
size_t(cmd.args.getBufferSubData.size));
|
|
||||||
f->glUnmapBuffer(cmd.args.getBufferSubData.target);
|
f->glUnmapBuffer(cmd.args.getBufferSubData.target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ public:
|
|||||||
baseVertex(false),
|
baseVertex(false),
|
||||||
compute(false),
|
compute(false),
|
||||||
textureCompareMode(false),
|
textureCompareMode(false),
|
||||||
mapBuffer(false)
|
properMapBuffer(false)
|
||||||
{ }
|
{ }
|
||||||
int ctxMajor;
|
int ctxMajor;
|
||||||
int ctxMinor;
|
int ctxMinor;
|
||||||
@ -784,7 +784,7 @@ public:
|
|||||||
uint baseVertex : 1;
|
uint baseVertex : 1;
|
||||||
uint compute : 1;
|
uint compute : 1;
|
||||||
uint textureCompareMode : 1;
|
uint textureCompareMode : 1;
|
||||||
uint mapBuffer : 1;
|
uint properMapBuffer : 1;
|
||||||
} caps;
|
} caps;
|
||||||
QGles2SwapChain *currentSwapChain = nullptr;
|
QGles2SwapChain *currentSwapChain = nullptr;
|
||||||
QVector<GLint> supportedCompressedFormats;
|
QVector<GLint> supportedCompressedFormats;
|
||||||
|
Loading…
Reference in New Issue
Block a user