|
@@ -114,6 +114,49 @@ pc_type_v1<PointT> generic_pc::impl::get_pc_type_v1(smart_cuda_stream *stream) {
|
|
|
return pc_type_v1<PointT>((PointT *) store_cuda.ptr.get(), size);
|
|
return pc_type_v1<PointT>((PointT *) store_cuda.ptr.get(), size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+generic_pc::impl::gl_store_info::~gl_store_info() {
|
|
|
|
|
+ glDeleteVertexArrays(1, &vao);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void generic_pc::impl::create_gl_info(smart_cuda_stream *stream) {
|
|
|
|
|
+ assert(gl_info == nullptr);
|
|
|
|
|
+ gl_info = std::make_unique<gl_store_info>();
|
|
|
|
|
+
|
|
|
|
|
+ // upload to VBO
|
|
|
|
|
+ gl_info->vbo.upload(q_this->shared_from_this(), stream);
|
|
|
|
|
+ // TODO: chose upload source (HOST or CUDA)
|
|
|
|
|
+
|
|
|
|
|
+ GLuint vao = 0;
|
|
|
|
|
+ glGenVertexArrays(1, &vao);
|
|
|
|
|
+ glBindVertexArray(vao);
|
|
|
|
|
+ switch (fmt) {
|
|
|
|
|
+ case PC_XYZ_RGB: {
|
|
|
|
|
+ glEnableVertexAttribArray(0);
|
|
|
|
|
+ glEnableVertexAttribArray(1);
|
|
|
|
|
+ glVertexAttribPointer(0, 3, GL_FLOAT, false,
|
|
|
|
|
+ sizeof(pc_xyz_rgb_type), (void *) offsetof(pc_xyz_rgb_type, x));
|
|
|
|
|
+ glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, true,
|
|
|
|
|
+ sizeof(pc_xyz_rgb_type), (void *) offsetof(pc_xyz_rgb_type, r));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ default: {
|
|
|
|
|
+ RET_ERROR;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ gl_info->vao = vao;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+generic_pc::gl_info_type
|
|
|
|
|
+generic_pc::impl::get_gl_info(smart_cuda_stream *stream) {
|
|
|
|
|
+ if (gl_info == nullptr) [[unlikely]] {
|
|
|
|
|
+ create_gl_info(stream);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(gl_info != nullptr);
|
|
|
|
|
+ return {.vao = gl_info->vao,
|
|
|
|
|
+ .vbo = gl_info->vbo.id,
|
|
|
|
|
+ .num_points = (GLuint) size};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void generic_pc::impl::host_modified(smart_cuda_stream *stream) {
|
|
void generic_pc::impl::host_modified(smart_cuda_stream *stream) {
|
|
|
assert(store_host.ptr != nullptr);
|
|
assert(store_host.ptr != nullptr);
|
|
|
store_cuda.reset();
|
|
store_cuda.reset();
|
|
@@ -173,6 +216,11 @@ template pc_type_v1<pc_xyz_type> generic_pc::cuda(smart_cuda_stream *stream);
|
|
|
template pc_type_v1<pc_xyz_rgb_type> generic_pc::cuda(smart_cuda_stream *stream);
|
|
template pc_type_v1<pc_xyz_rgb_type> generic_pc::cuda(smart_cuda_stream *stream);
|
|
|
// @formatter:on
|
|
// @formatter:on
|
|
|
|
|
|
|
|
|
|
+generic_pc::gl_info_type
|
|
|
|
|
+generic_pc::get_gl_info(smart_cuda_stream *stream) {
|
|
|
|
|
+ return pimpl->get_gl_info(stream);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void generic_pc::host_modified(smart_cuda_stream *stream) {
|
|
void generic_pc::host_modified(smart_cuda_stream *stream) {
|
|
|
pimpl->host_modified(stream);
|
|
pimpl->host_modified(stream);
|
|
|
}
|
|
}
|