Hey all,
I’m working on an app where every few frames I have to upload pointcloud data from the CPU to the GPU. I used the instanced teapots as a starting point for my app and worked my way from there. I get the visual I want, and can update the pointcloud but the issue is that mapReplace()
is quite slow. I’m using the following code to do the mapReplace:
void PointCloud::updateInstance()
{
Ply::Polygon dummy{ quat(), ci::ColorAf::zero(), vec3(std::numeric_limits<float>::max()), vec3(0) };
auto start = std::chrono::steady_clock::now();
Ply::Polygon *data = (Ply::Polygon*) m_vbo->mapReplace();
auto end = std::chrono::steady_clock::now();
std::cout << "replace took: " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
for (size_t i=0; i<POINTCLOUD_MAX; i++)
{
if (i < m_target->size())
*data++ = (*m_target)[i];
else
*data++ = dummy;
}
m_vbo->unmap();
}
Timing mapReplace like I do above results in a value all over the place, sometimes it takes 0ms, often it takes 50ms. I don’t really care if the mapReplace()
is done within a frame, but I don’t want the mapReplace to make my app lag like it does now. This made me wonder if there’s a way to ping-pong a VBO, or have it done in a separate thread? Here is where my knowledge ends though, and I’m not exactly sure where to start. Any tips hints and especially code is much appreciated…!
For reference, I’m using a NVidia 3080, Ryzen 7 5800X. Ideally I’d like to upload data for around 300k particles, but that’s definitely an ideal and can be much lower if impossible. Each particle has a quat
for rotation, a color, a vec3
for position and a vec3
for scale.
Many thanks!
Willem