1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

GPU Flocking

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

  1. TheKingInTheNorth

    TheKingInTheNorth

    Joined:
    Jun 16, 2017
    Posts:
    2
    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:
    22
    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)
     
    eXonius likes this.
  3. TheKingInTheNorth

    TheKingInTheNorth

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