Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

(Case 946966) GPU Instancing significantly slower than no batching at all (UWP/Xbox One)

Discussion in 'Windows' started by Peter77, Aug 31, 2017.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    Rendering the provided test-scene on Xbox One (UWP, retail console using developer mode) with "GPU Instancing" enabled, renders significantly slower than using no draw-call batching at all, even though Unity does batch a lot of draw-calls when using GPU Instancing.

    Please see the provided screenshots.

    overview.png

    profiler_static_batching.png

    profiler_no_batching.png

    profiler_gpu_instancing.png


    Reproduce

    Unity
    0. Open user attached project
    1. Execute Mainmenu > BugReport > Disable GPU Instancing
    2. Open Player Settings and turn off Static and Dynamic Batching
    3. Press File/Build Setting
    4. Select "Universal Windows Platform" tab
    5. Turn on "Development Build" (to be able to attach the Unity Profiler)
    6. Build UWP Player with setting Target=Any Device, Build Type=D3D
    7. Open generated .sln file in Visual Studio 2017​

    Visual Studio
    8. Switch "Solution Configuration" to "Release"
    9. Switch "Solution Platforms" to "x64"
    10. Switch "Local Machine" to "Remote Machine"
    11. Open the "Wolf (Univeral Windows)" Project Properties
    12. Select the "Debugging" tab in the "Wolf Property Pages" dialog
    13. Set the "Machine Name" to your Xbox One name or IP address and press OK button
    14. Open file "Package.appxmanifest"
    15. Switch to "Capabilities" tab in "Package.appxmanifest"
    16. Enable the following Capabilities (not sure which of these is actually responsible to make the Profiler work): Internet (Client & Server), Internet (Client), Point of Service, Private Networks (Client & Server), Remove System
    17. Press in Mainmenu > Build > Build Solution
    18. Run on Xbox One​

    Unity
    19. Open Window > Profiler
    20. Connect to running Player on Xbox One
    21. Note the "CPU" and "Gfx.WaitForPresent" cost
    22. Close Profiler
    23. Execute Mainmenu > BugReport > Enable GPU Instancing
    24. Repeat reproduce list from step 2​

    Compare the "CPU" and "Gfx.WaitForPresent" cost of the different profiling sessions. Observe that GPU Instancing is significantly slower than using no draw-call batching at all.

    See overview.png for my test results.
    overview.png


    Expected
    GPU Instancing should not be slower than using no draw-call batching at all. Considering that it does seem to batch even more efficient than static batching from the numbers the Profiler is showing, I'd even expect that the test performs better with GPU Instancing than static batching.
     
    Last edited: Aug 31, 2017
  2. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    Hey,

    Does this issue happen on both Windows UWP and XboxOne?
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    I don't know, I tested XboxOne only. If this information is important to you, I can test that.

    Unity QA was able to reproduce the issue:
    For some reason I'm unable to locate the bug-report in the Unity Issue Tracker though, would have linked it here otherwise.
     
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,111
    Unfortunately the issue tracker is still broken.

    Edit:

    Apparently it has been fixed today and should work again.
     
    Last edited: Sep 11, 2017
  5. ickydime

    ickydime

    Joined:
    Nov 20, 2012
    Posts:
    110
    @Peter77 Link to the bug report? I can't find it and was about to implement gpu instancing in our UWP hololens application but may hold off if this is a platform issue.
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    @LeonhardP, bug-report Case 946966 continues to not exist in the public Issue Tracker. Could you take a look?
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    I just marked it to be available in issue tracker. It should show up shortly.
     
    Peter77 likes this.
  8. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    It's still not visible, seems problems with the public issue tracker continue to exist.
     
  9. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,111
    Last edited: Sep 14, 2017
    laurentlavigne likes this.
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    cthomas1970 likes this.
  11. PJayB

    PJayB

    Unity Technologies

    Joined:
    Apr 24, 2017
    Posts:
    105
    Hey. I took a look at this yesterday and the problem seems to be in the D3D11 driver for UWP. We Map/Unmap constant buffers for each of the instance batches, and while this works fine on PC, it seems to take forever on Xbox UWP only. I'm following up with Microsoft and will let you know when I hear back. I recommend you avoid instancing until they're able to resolve this.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    Good news! With newest Xbox update this seems to be fixed. I'm now getting 63 fps with instancing off and 135 fps with instancing off (I had to turn VSync off to go above 60 fps). No changes in Unity were needed ;).
     
    Peter77 likes this.
  13. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    That's excellent news, I have to give it a try later. Thanks for keeping us in the loop!
     
  14. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    The test scene I submitted with Case 946966 does run with 60 fps (I didn't turn off vsync), according to its fps overlay. Unfortunately, I can't attach the Unity Profiler to it to get meaningful data, it always times out.

    I'm going to test my actual project now.

    EDIT: The reason why I couldn't connect the profiler was I forgot to enable some networking Capabilities.
     
    Last edited: Feb 23, 2018
  15. StageClearStudios

    StageClearStudios

    Joined:
    Jan 30, 2018
    Posts:
    40
    Do you mean with XOne firmware update or Unity update?

    Thanks!
     
  16. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    Xbox update. He wrote no changes to unity were needed.
     
  17. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    My actual project also runs a lot better with the latest Xbox One update, so I assume GPU Instancing is indeed fixed. Awesome! :D
     
  18. StageClearStudios

    StageClearStudios

    Joined:
    Jan 30, 2018
    Posts:
    40
    Hey Peter, what update of Xbox One are you using? We have tested our project with the update of February 6 but it is not running better.
     
  19. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,471
    Here is what Sysem > Console info shows on Xbox:
     
  20. stevegreat

    stevegreat

    Joined:
    Sep 24, 2014
    Posts:
    15
    Has anyone tested this running in "Game" mode?
    I don't see the issue in "App" mode but when I switch to "Game" mode it runs very poorly.

    upload_2018-4-17_17-2-30.png

    Using OS version: 10.0.16299.5101 (rs3_release_xbox_dev_1802.180131-1450) as mentioned.
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    @stevegreat can you post a new thread? This issue doesn't seem to be related to the one discussed in this thread.

    Secondly, can you post your player log in that thread?
     
  22. stevegreat

    stevegreat

    Joined:
    Sep 24, 2014
    Posts:
    15