diff options
author | Juan José Casafranca <jjcasmar@gmail.com> | 2016-12-20 10:12:55 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-01-31 08:59:41 +0000 |
commit | 1025ec92da6360a516a34e4fb483f82505f656ea (patch) | |
tree | 6460fd707d8dd46ba0af95e5b86a5e3080111ac8 /src/render/graphicshelpers/graphicscontext.cpp | |
parent | 38a284dce96b14f695a27879119e7a28b20756e1 (diff) |
Transfers gpu buffer data to cpu
Added some code to retrieve the data in the gpu back to a cpu pointer
in the opengl helpers.
Added a framegraph node which specifies if any data must be downloaded
from the gpu
Added a flag in the buffer object to specify if the data from that
buffer must be downloaded.
Added a job to send the data back to the frontend.
Added a path in the renderer to download the gpu data.
Task number: QTBUG-57727
Change-Id: I315a9221e5116c7d07f818e00c654fe1901144f4
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/graphicshelpers/graphicscontext.cpp')
-rw-r--r-- | src/render/graphicshelpers/graphicscontext.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 8a2919a96..d27b7cd06 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -1073,6 +1073,16 @@ void GraphicsContext::dispatchCompute(int x, int y, int z) m_glHelper->dispatchCompute(x, y, z); } +GLboolean GraphicsContext::unmapBuffer(GLenum target) +{ + return m_glHelper->unmapBuffer(target); +} + +char *GraphicsContext::mapBuffer(GLenum target) +{ + return m_glHelper->mapBuffer(target); +} + void GraphicsContext::enablei(GLenum cap, GLuint index) { m_glHelper->enablei(cap, index); @@ -1426,6 +1436,16 @@ void GraphicsContext::updateBuffer(Buffer *buffer) uploadDataToGLBuffer(buffer, m_renderer->nodeManagers()->glBufferManager()->data(it.value())); } +QByteArray GraphicsContext::downloadBufferContent(Buffer *buffer) +{ + const QHash<Qt3DCore::QNodeId, HGLBuffer>::iterator it = m_renderBufferHash.find(buffer->peerId()); + if (it != m_renderBufferHash.end()) + return downloadDataFromGLBuffer(buffer, m_renderer->nodeManagers()->glBufferManager()->data(it.value())); + return QByteArray(); +} + + + void GraphicsContext::releaseBuffer(Qt3DCore::QNodeId bufferId) { auto it = m_renderBufferHash.find(bufferId); @@ -1522,6 +1542,15 @@ void GraphicsContext::uploadDataToGLBuffer(Buffer *buffer, GLBuffer *b, bool rel qCDebug(Render::Io) << "uploaded buffer size=" << buffer->data().size(); } +QByteArray GraphicsContext::downloadDataFromGLBuffer(Buffer *buffer, GLBuffer *b) +{ + if (!bindGLBuffer(b, bufferTypeToGLBufferType(buffer->type()))) + qCWarning(Render::Io) << Q_FUNC_INFO << "buffer bind failed"; + + QByteArray data = b->download(this, buffer->data().size()); + return data; +} + GLint GraphicsContext::elementType(GLint type) { switch (type) { |