Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Particle cloud with sfml!!  (Read 1257 times)

0 Members and 1 Guest are viewing this topic.

jimmyrickson

  • Guest
Particle cloud with sfml!!
« on: June 27, 2019, 09:03:02 am »
I've created a simple program that draws a "particle cloud" in the sfml window. With threads i can simulate about 100k particles that moves after the mouse, anything bigger makes it laggy. So my question is if there is anyway to use the gpu with the sfml library. I want to use the GPU to update the particle locations( this is what takes the most of the time to do). Have anyone of you guys tried anything similar? Thanks for reading, all the best


Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Particle cloud with sfml!!
« Reply #1 on: July 03, 2019, 09:56:22 pm »
Generally, it's possible to do computing on GPUs -- some keywords to look for more might be CUDA, OpenCL, OpenACC.

The question is if it's worth it. In order to outperform the CPU, you need to exploit a GPUs massive-parallelized and vector-optimized architecture (which depends on the update pattern of your particles). Also keep in mind that both video memory and bandwidth to upload/download data to the graphics card can be limiting factors depending on your application.

Since GPU programming comes with quite some complexity, I would first try to maximize the performance on the GPU. Did you use a profiler to find the bottleneck? If the computation is stuck on one core, could you try multi-threading? Are you sure you use optimal data structures, algorithms, avoid cache misses and bad branch predictions, etc?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: