Search Unity

GPU poor performance on my UWP game

Discussion in 'Windows' started by IElectric, Aug 5, 2018.

  1. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Hello, I have a question on how to automatic select high performance GPU on my deployed UWP game;

    On the most recent computers, expecially notebook, there are two GPU available, one integrated on the CPU and one high performance GPU like NVIDIA;

    When I run my game it's works on Intel HD Graphics as default, I know that I can select high performance GPU on the NVIDIA panel but I don't know how to run my game on nvidia GPU without change nvidia control panel option;

    My game has poor performance on integrated graphics GPU;

    This behavoir appen also on other computers where my game is deployed, I'd like to force my game to run always on high performance GPU without change any option on the target computer, can someone help me to find a solution ?

    Thank you very much, Best regards...
     
    Last edited: Nov 30, 2020
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Which scripting backend are you using?
     
  3. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Hello, .NET, Cheers...
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Making this work on .NET scripting backend will be complicated. See this:

    https://forum.unity.com/threads/windows-store-universal-app-not-using-gpu.462227/

    Basically, the game executable has to export those two symbols, but C# with .NET native has no mechanism to do it. One way you could achieve this is to modify the executable after compilation has taken place by patching the binary. I haven't tried it myself, though.
     
  5. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    OK, I will deploy my game to IL2CPP script and then add the code to run on high performance GPU, thank you very much for your suggestion, Best regards...
     
  6. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Hello, I confirm that by adding the following code as suggested to the Main.cpp file of IL2CPP Visual Studio project my game works on high performance GPU, with automatic graphics processor settings in the NVIDIA control panel, thank you very much, Best regards...

    extern "C"
    {
    __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
    __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
    }
     
    Last edited: Nov 30, 2020
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'm glad it works!