Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/opengl/gl_storage_buffer.cc')
-rw-r--r--source/blender/gpu/opengl/gl_storage_buffer.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_storage_buffer.cc b/source/blender/gpu/opengl/gl_storage_buffer.cc
index 109bb65fcb7..b30674fe5fa 100644
--- a/source/blender/gpu/opengl/gl_storage_buffer.cc
+++ b/source/blender/gpu/opengl/gl_storage_buffer.cc
@@ -144,6 +144,30 @@ void GLStorageBuf::clear(eGPUTextureFormat internal_format, eGPUDataFormat data_
}
}
+void GLStorageBuf::copy_sub(VertBuf *src_, uint dst_offset, uint src_offset, uint copy_size)
+{
+ GLVertBuf *src = static_cast<GLVertBuf *>(src_);
+ GLStorageBuf *dst = this;
+
+ if (dst->ssbo_id_ == 0) {
+ dst->init();
+ }
+ if (src->vbo_id_ == 0) {
+ src->bind();
+ }
+
+ if (GLContext::direct_state_access_support) {
+ glCopyNamedBufferSubData(src->vbo_id_, dst->ssbo_id_, src_offset, dst_offset, copy_size);
+ }
+ else {
+ /* This binds the buffer to GL_ARRAY_BUFFER and upload the data if any. */
+ src->bind();
+ glBindBuffer(GL_COPY_WRITE_BUFFER, dst->ssbo_id_);
+ glCopyBufferSubData(GL_ARRAY_BUFFER, GL_COPY_WRITE_BUFFER, src_offset, dst_offset, copy_size);
+ glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
+ }
+}
+
/** \} */
} // namespace blender::gpu