Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

GPU Flocking

Discussion in 'Shaders' started by TheKingInTheNorth, Jun 16, 2017.

  1. TheKingInTheNorth

    TheKingInTheNorth

    Joined:
    Jun 16, 2017
    Posts:
    4
    Hey Everyone!
    I've been trying to implement GPU Flocking using compute shaders in Unity. I've tried multiple methods including GetData, an external plugin, and even GPU Instancing. However, the CPU Flocking still remains faster than GPU. Obviously GPU Flocking is supposed to be faster. Anyone have any suggestions on improving the frame rate?
     
  2. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    40
    Hey, so without knowing your GPU flocking implementation, I'm going to give few scenarios or points that might help u:
    - First of all always make your GPU jobs big! Because dispatching jobs on GPU has pretty big overhead, it is very likely that with small job count CPU will outperform GPU.
    - Try to avoid synchronization! The more stalls there is the slower gpu will perform, that includes:
    -- Try to avoid atomics.
    -- Try to avoid sync with CPU (ComputeBuffer.GetData).
    - Threads > ThreadGroups! I mean always try to have more threads in each group as possible ([numthreads(x, y, z)], this way drivers can do more optimization.
    - Avoid branching! This one basically kills performance by most - if possible change all ure if conditions to inlined ones (CONDITION ? RESULT_IF_TRUE : RESULT_IF_FALSE)
     
    asdzxcv777 and eXonius like this.
  3. TheKingInTheNorth

    TheKingInTheNorth

    Joined:
    Jun 16, 2017
    Posts:
    4
    Thanks @LukasCh for the help! Will try to implement these now!