summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/rhi/qrhi.cpp5
-rw-r--r--src/gui/rhi/qrhigles2.cpp10
2 files changed, 11 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 7770cac870..7443c0a04f 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -4947,6 +4947,11 @@ QRhiShaderResourceBindings *QRhi::newShaderResourceBindings()
backends. See \l{QRhiBuffer::UsageFlag}{UsageFlags} and
\l{QRhi::NonDynamicUniformBuffers}{the feature flags}.
+ \note Backends may choose to allocate buffers bigger than \a size. This is
+ done transparently to applications, so there are no special restrictions on
+ the value of \a size. QRhiBuffer::size() will always report back the value
+ that was requested in \a size.
+
\sa QRhiResource::release()
*/
QRhiBuffer *QRhi::newBuffer(QRhiBuffer::Type type,
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index a4ab1cf2ec..379801efbd 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -2847,13 +2847,15 @@ bool QGles2Buffer::build()
QRHI_RES_RHI(QRhiGles2);
QRHI_PROF;
+ const int nonZeroSize = m_size <= 0 ? 256 : m_size;
+
if (m_usage.testFlag(QRhiBuffer::UniformBuffer)) {
if (int(m_usage) != QRhiBuffer::UniformBuffer) {
qWarning("Uniform buffer: multiple usages specified, this is not supported by the OpenGL backend");
return false;
}
- ubuf.resize(m_size);
- QRHI_PROF_F(newBuffer(this, m_size, 0, 1));
+ ubuf.resize(nonZeroSize);
+ QRHI_PROF_F(newBuffer(this, nonZeroSize, 0, 1));
return true;
}
@@ -2868,11 +2870,11 @@ bool QGles2Buffer::build()
rhiD->f->glGenBuffers(1, &buffer);
rhiD->f->glBindBuffer(targetForDataOps, buffer);
- rhiD->f->glBufferData(targetForDataOps, m_size, nullptr, m_type == Dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
+ rhiD->f->glBufferData(targetForDataOps, nonZeroSize, nullptr, m_type == Dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
usageState.access = AccessNone;
- QRHI_PROF_F(newBuffer(this, m_size, 1, 0));
+ QRHI_PROF_F(newBuffer(this, nonZeroSize, 1, 0));
rhiD->registerResource(this);
return true;
}