rhi: gl: Add a helper virtual to punch through to glBufferSubData
The default implementation of the virtual is of course just memcopying into beginFullDynamicBufferUpdateForCurrentFrame()'s result, so not very useful for any backend except OpenGL where (for non-uniform buffers) it is implemented rather with glBufferSubData (leaving it up to the OpenGL implementation what's going to happen internally). The value is somewhat limited in practice, however one user is going to be Qt Quick: to get as identical as possible results to Qt 5 in artificial "benchmark" scenes, it becomes important to go directly to glBufferSubData (just as Qt 5 did) when updating geometry for a large number of items in every frame, and skip any intermediate resource update logic. Pick-to: 6.8 Task-number: QTBUG-125087 Change-Id: I780a1431e021b90590b493e1fb82334cd71bd75b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
f52018e45f
commit
cdaa4c317c
@ -3981,6 +3981,18 @@ void QRhiBuffer::endFullDynamicBufferUpdateForCurrentFrame()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QRhiBuffer::fullDynamicBufferUpdateForCurrentFrame(const void *data)
|
||||
{
|
||||
char *p = beginFullDynamicBufferUpdateForCurrentFrame();
|
||||
if (p) {
|
||||
memcpy(p, data, m_size);
|
||||
endFullDynamicBufferUpdateForCurrentFrame();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QRhiRenderBuffer
|
||||
\inmodule QtGui
|
||||
|
@ -881,6 +881,7 @@ public:
|
||||
|
||||
virtual char *beginFullDynamicBufferUpdateForCurrentFrame();
|
||||
virtual void endFullDynamicBufferUpdateForCurrentFrame();
|
||||
virtual void fullDynamicBufferUpdateForCurrentFrame(const void *data);
|
||||
|
||||
protected:
|
||||
QRhiBuffer(QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_);
|
||||
|
@ -5370,6 +5370,17 @@ void QGles2Buffer::endFullDynamicBufferUpdateForCurrentFrame()
|
||||
}
|
||||
}
|
||||
|
||||
void QGles2Buffer::fullDynamicBufferUpdateForCurrentFrame(const void *bufferData)
|
||||
{
|
||||
if (!m_usage.testFlag(UniformBuffer)) {
|
||||
QRHI_RES_RHI(QRhiGles2);
|
||||
rhiD->f->glBindBuffer(targetForDataOps, buffer);
|
||||
rhiD->f->glBufferSubData(targetForDataOps, 0, m_size, bufferData);
|
||||
} else {
|
||||
memcpy(data.data(), bufferData, m_size);
|
||||
}
|
||||
}
|
||||
|
||||
QGles2RenderBuffer::QGles2RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize,
|
||||
int sampleCount, QRhiRenderBuffer::Flags flags,
|
||||
QRhiTexture::Format backingFormatHint)
|
||||
|
@ -38,6 +38,7 @@ struct QGles2Buffer : public QRhiBuffer
|
||||
QRhiBuffer::NativeBuffer nativeBuffer() override;
|
||||
char *beginFullDynamicBufferUpdateForCurrentFrame() override;
|
||||
void endFullDynamicBufferUpdateForCurrentFrame() override;
|
||||
void fullDynamicBufferUpdateForCurrentFrame(const void *data) override;
|
||||
|
||||
quint32 nonZeroSize = 0;
|
||||
GLuint buffer = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user