Author Topic: Fastest way to upload vertices?  (Read 6601 times)

0 Members and 1 Guest are viewing this topic.

groundhog

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Fastest way to upload vertices?
« on: February 29, 2016, 03:27:08 PM »
I am rendering a point cloud with several million points.
At the moment I upload them in a python loop using gxl_vertex_pool.vertex_set_position() and .vertex_set_color().

Is there a way to upload them in bulk from a (numpy) python array?
Should I use a separate gpu buffer and then use gh_vertex_pool.vertices_from_gpu_buffer()?
Or should I use vertex_poll map & unmap? But where is the buffer mapped?

Please help!



JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2068
    • View Profile
    • Geeks3D.com
Re: Fastest way to upload vertices?
« Reply #1 on: March 01, 2016, 03:38:02 PM »
I think the fastest way to upload your vertices is to have functions in the gh_vertex_pool that take a Python array as input. I will add such functions (for positions, colors) asap.

groundhog

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: Fastest way to upload vertices?
« Reply #2 on: March 01, 2016, 04:52:33 PM »
Quote
I think the fastest way to upload your vertices is to have functions in the gh_vertex_pool that take a Python array as input.

That's what I had hoped for!

Would it be possible to specify the data type for the upload? E.g. using a numpy dtype or similar? I am uploading huge amounts of vertex data, but need only limited precision. int16 for xyz would suffice.

Thanks!

JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2068
    • View Profile
    • Geeks3D.com
Re: Fastest way to upload vertices?
« Reply #3 on: April 14, 2016, 06:27:32 PM »
A code sample that shows how to initialize a vertex pool with a Python array is available in the new code sample pack:

gl-21/vertex-pool-python/

I tested with 1'000'000 particles and initialization from Python arrays is really fast!

groundhog

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: Fastest way to upload vertices?
« Reply #4 on: April 18, 2016, 04:27:17 PM »
Great, thanks!

I already integrated it in my code and the only thing I had to change was adding another element per vertex to get the correct stride (4) and flatten the array.
Works really fine!

Again: Thank you!