Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discrete GPU is skipped on laptops (with optimus dual-graphics?) #707

Open
jeske opened this issue May 7, 2020 · 4 comments
Open

discrete GPU is skipped on laptops (with optimus dual-graphics?) #707

jeske opened this issue May 7, 2020 · 4 comments
Labels
area-Graphics bug Something isn't working

Comments

@jeske
Copy link

jeske commented May 7, 2020

Release Type: Release
Version: 4.0.0.1 beta2 0928
Platform(s): Windows

Describe the bug

On some laptops, Stride picks the slow integrated GPU even when there is a fast discrete GPU.

I believe this happens because on laptops with switchable graphics, only the "default" GPU has a display attached. Which is normally the integrated graphics. Stride checks for no display attached and skips that GPU in this code. Yet other game engines (in the user-report, Cryengine) still come up on the discrete GPU.

// Skip adapeters that don't have graphics output
// but only if no RequiredAdapterUid is provided (OculusVR at init time might be in a device with no outputs)
if (graphicsAdapter.Outputs.Length == 0 && string.IsNullOrEmpty(preferredParameters.RequiredAdapterUid))
{
continue;
}

I'll have to do more testing, but I think Stride should probably be using some method to get the default 3d device, instead of doing it's own picking algorithm based on the attached display. On D3D I believe this is to CreateDevice() with a D3DADAPTER_DEFAULT parameter. It could do this as part of the factory device enumeration, and then set some kind of default device flag in the enumerated device list.

To Reproduce
Steps to reproduce the behavior:

  1. Start Stride on a laptop with optimus style dual graphics, with the integrated graphics as default
  2. WITNESS: Stride starts on the integrated graphics GPU
  3. start some other heavy 3d application or game (Cryengine, Unreal, Blender)
  4. WITNESS: that other 3d app starts on the fast GPU

Expected behavior
Expected Stride to use the discrete GPU just like other games do.

@jeske jeske added the bug Something isn't working label May 7, 2020
@joaovsq
Copy link

joaovsq commented Jun 10, 2020

We could do something like this (C++):

#ifdef _WIN32

// Use discrete GPU by default.
extern "C" {
// nvidia
  __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
​
// amd
  __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
} 
#endif

References:

Nvidia
https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm

AMD
https://community.amd.com/thread/169965

(EDIT) By the way, as a example, this is what Cryengine does.

@tebjan
Copy link
Member

tebjan commented Jun 11, 2020

@joaovsq thanks for the hint. I've searched a little bit around and this seems to be very difficult to do from a managed executable. you have to do some IL hacks after compilation. i found this:

http://lucasmagder.com/blog/2014/05/exporting-data-symbols-in-c-for-nvidia-optimus/

and this:

https://stackoverflow.com/questions/17270429/forcing-hardware-accelerated-rendering

it might be possible since Stride is doing some assembly processing already.

but selecting the correct device in FindBestDevice might also just work...

@jeske
Copy link
Author

jeske commented Jun 12, 2020

I don't see anything in there for exporting constants.. here are are two references.

@tebjan
Copy link
Member

tebjan commented Oct 1, 2020

i found the right setting, this should be set in the registry by the installer/launcher. just added it to the vvvv installer and it works like a charm. it even allows to user to change the setting later and doesn't force it:

https://www.trishtech.com/2018/12/how-to-set-graphics-performance-preference-for-apps-in-windows-10/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Graphics bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants