summaryrefslogtreecommitdiffstats
path: root/src/render/io
diff options
context:
space:
mode:
authorJuan José Casafranca <jjcasmar@gmail.com>2016-12-20 10:12:55 +0200
committerSean Harmer <sean.harmer@kdab.com>2017-01-31 08:59:41 +0000
commit1025ec92da6360a516a34e4fb483f82505f656ea (patch)
tree6460fd707d8dd46ba0af95e5b86a5e3080111ac8 /src/render/io
parent38a284dce96b14f695a27879119e7a28b20756e1 (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/io')
-rw-r--r--src/render/io/glbuffer.cpp12
-rw-r--r--src/render/io/glbuffer_p.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/render/io/glbuffer.cpp b/src/render/io/glbuffer.cpp
index 074868528..4918f9a56 100644
--- a/src/render/io/glbuffer.cpp
+++ b/src/render/io/glbuffer.cpp
@@ -140,6 +140,18 @@ void GLBuffer::update(GraphicsContext *ctx, const void *data, uint size, int off
ctx->openGLContext()->functions()->glBufferSubData(m_lastTarget, offset, size, data);
}
+QByteArray GLBuffer::download(GraphicsContext *ctx, uint size)
+{
+ char *gpu_ptr = ctx->mapBuffer(m_lastTarget);
+ QByteArray data;
+ if (gpu_ptr != nullptr) {
+ data.resize(size);
+ std::copy(gpu_ptr, gpu_ptr+size, data.data());
+ }
+ ctx->unmapBuffer(m_lastTarget);
+ return data;
+}
+
void GLBuffer::bindBufferBase(GraphicsContext *ctx, int bindingPoint, GLBuffer::Type t)
{
ctx->bindBufferBase(glBufferTypes[t], bindingPoint, m_bufferId);
diff --git a/src/render/io/glbuffer_p.h b/src/render/io/glbuffer_p.h
index e800d2bc4..731634b6b 100644
--- a/src/render/io/glbuffer_p.h
+++ b/src/render/io/glbuffer_p.h
@@ -53,6 +53,7 @@
#include <QOpenGLContext>
#include <Qt3DCore/qnodeid.h>
+#include <qbytearray.h>
QT_BEGIN_NAMESPACE
@@ -85,6 +86,7 @@ public:
void allocate(GraphicsContext *ctx, uint size, bool dynamic = true);
void allocate(GraphicsContext *ctx, const void *data, uint size, bool dynamic = true);
void update(GraphicsContext *ctx, const void *data, uint size, int offset = 0);
+ QByteArray download(GraphicsContext *ctx, uint size);
void bindBufferBase(GraphicsContext *ctx, int bindingPoint, Type t);
void bindBufferBase(GraphicsContext *ctx, int bindingPoint);