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.

Question Default to High Performance Graphics Card

Discussion in 'Windows' started by ZLouie, Feb 8, 2021.

  1. ZLouie

    ZLouie

    Joined:
    Sep 23, 2020
    Posts:
    5
    I'm trying to force the user to use the best performing graphics card when starting my game. I read that this can be achieved through the following global variables. Currently, I am creating a native plugin with these defined and adding the dll to plugins. I have verified that the resultant plugin is successfully built and can be called through my C# code.
    Code (CSharp):
    1. #ifdef _WIN32
    2. #define DLLExport __declspec(dllexport)
    3. #include <windows.h>
    4. extern "C"
    5. {
    6.     //Tell Nvidia/AMD to use high-performance graphics card
    7.  
    8.     //Nvidia specifies this in their Optimus rendering specs.
    9.     //http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
    10.     DLLExport DWORD NvOptimusEnablement = 0x00000001;
    11.  
    12.     //AMD Specifies this in a tutorial doc for selecting the best graphics device
    13.     //https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/
    14.     DLLExport int AmdPowerXpressRequestHighPerformance = 1;
    15.  
    16.  
    17.     DLLExport int GetNvOptimusEnablement() { return NvOptimusEnablement; }
    18.     DLLExport int GetAmdPowerXpressRequest() { return AmdPowerXpressRequestHighPerformance; }
    19. }
    20. #endif
    However, I am still getting reports that this is not working. I was wondering if this approach is correct, and if not if there is something else I must do.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    Which platform are you targeting?
     
  3. ZLouie

    ZLouie

    Joined:
    Sep 23, 2020
    Posts:
    5
    Hey Tautvydas-Zilys, thanks for the reply. This is for windows.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    Windows Standalone player? If so, you shouldn't need to do anything: it should default to dedicated graphics card automatically.

    Do you have any logs from players that complained about this?
     
  5. ZLouie

    ZLouie

    Joined:
    Sep 23, 2020
    Posts:
    5
    Apologizes, yeah its for Windows Standalone player. I don't have logs but I do have a description of an internal user's steps.

    "I changed the preferred graphics to integrated (there's a motherboard setting you can set to IGD or PEG which is integrated vs pcie) so I had one monitor plugged into the motherboard and one still plugged into the GPU. I ran some other games as a quick check, and they would only run on the display plugged into the GPU."

    If the user specifies preference on their motherboard does that override the selection preference?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    I don't think motherboard settings would have anything to do with it. The only thing that could overwrite it is driver settings.

    Could you ask them for the game log file?
     
  7. ZLouie

    ZLouie

    Joined:
    Sep 23, 2020
    Posts:
    5
    Here's the game log file as requested
     

    Attached Files:

  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    The log indicates the game is running on NVIDIA GeForce RTX 2080 Ti. What made them think it's running on integrated graphics card?
     
  9. ZLouie

    ZLouie

    Joined:
    Sep 23, 2020
    Posts:
    5
    Hey Tautvydas - thanks for bearing with me here, I really appreciate your insight. Here's the response I got -

    "Looking at this again, even though it's still shown as switching between GPU-0 and GPU-1 in task manager, the game is probably only running on GPU-0 (integrated graphics) as it runs only on the display plugged into the motherboard and shows GPU-0 having consistently high power usage."
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,530
    If the game window is positioned on a monitor that's connected to a different GPU than it's running on, it will have to copy the frame buffer from VRAM into the system memory, then onto the other GPU memory before being able to display it on the screen. This will both have a significant performance impact, and show up as "Copy engine" GPU usage in the task manager.

    If they move the window to the correct monitor (they can either drag it if it's running in windowed mode, or use SHIFT + WIN + LEFT/RIGHT ARROW if it's running in fullscreen mode), the performance issues and the activity on the integrated GPU should disappear.
     
    ZLouie likes this.