mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.89k stars 2.87k forks source link

RFC: Prefer integrated GPUs over discrete GPUs by default? #5304

Open haasn opened 6 years ago

haasn commented 6 years ago

Currently, mpv's ra_vk picks the physical device based on the following priority list:

    static const struct m_opt_choice_alternatives types[] = {
        {"discrete",   VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU},
        {"integrated", VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU},
        {"virtual",    VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU},
        {"software",   VK_PHYSICAL_DEVICE_TYPE_CPU},
        {"unknown",    VK_PHYSICAL_DEVICE_TYPE_OTHER},
        {0}
    };

It was suggested that perhaps integrated GPUs should be above discrete GPUs by default, so that users of dual-GPU systems (typically laptops?) would use the more power-friendly integrated by default. This might be more in line with what's expected of a media player. I was personally thinking that we'd always want to use the fastest GPU so users can use the highest quality settings.

I'm not sure what users expect the default to be here. Opinions?

haasn commented 6 years ago

One point worth noting is that mpv will always make sure the chosen GPU can render to the target surface (e.g. X11 window), regardless of the GPU's type. So it will never auto-pick an integrated GPU if it can't actually render any images using it. (This is probably relevant for desktop PCs with discrete GPUs plugged into the monitor and onboard graphics that are inactive)

ChrisK2 commented 6 years ago

I would say this this should simply be in line with the general default-settings philosophy. Do we want mpv to be as high-quality or as "efficient"/compatible as possible by default?

pigoz commented 6 years ago

Maybe it should prefer the default GPU based on power management info. i.e. prefer discrete GPU while connected to power, and integrated when running on battery.

EDIT: but that would the defeat the purpose, since you'd want different settings anyway. I think saving battery is more reasonable.

Akemi commented 6 years ago

in the case for macOS we have a similar situation and i added a switch for it. maybe we could repurpose it and make it more general?

kevmitch commented 6 years ago

I think we already are on the "efficient"/compatible side since opengl-hq is not the default. If there's a flag to enable discrete gpu, we should just put it in there.

haasn commented 6 years ago

@Akemi a switch would be cool. For vulkan in particular I was leaning towards making a --vulkan-device-type=auto|integrated|discrete|... but we can certainly rename vulkan -> gpu and make it affect OS X too.

That still leaves open the question of what auto should prefer by default, but it would certainly remove weight from this decision.

I think we already are on the "efficient"/compatible side since opengl-hq is not the default. If there's a flag to enable discrete gpu, we should just put it in there.

Yeah that's a good point. Maybe, if we introduce the above discussed setting, we could make it default to integrated and have the gpu-hq profile set it to discrete instead?

FireBurn commented 6 years ago

As a user of a PRIME laptop (Skylake & Tonga) I'd much prefer the integrated GPU to have priority over the dedicated GPU when it comes to video. I really don't want my laptop using all that power / producing all that heat, just to render a video to the screen. (Obviously I feel differently about games)

Once vulkan video acceleration interops are in place maybe base it on the code list of both cards, i.e. if you're playing a 4K HVEC_10bit stream, use the lowest powered device to decode it

DeadSix27 commented 6 years ago

Generally I'd prefer iGPU because of the power efficiency. Same applies to hw-decoding, I would prefer having the iGPU default there (or an option, which doesn't exist yet for DX11VA) since my iGPU supports more decoding codecs.

Akemi commented 6 years ago

i am also leaning towards preferring the integrated GPU over the dedicated one.

@haasn yeah that what was on my mind too. just on a side note for macOS, in the case of opengl it only supports either auto or dedicated. so i would make integrated behave like auto in that case.

haasn commented 6 years ago

@Akemi Based on this, and the fact that you probably also don't have a use for the other vulkan device types (software, virtual, other) maybe we should just make this a boolean option, like --gpu-prefer-discrete=no|yes with no being the default?

Akemi commented 6 years ago

@haasn i am kinda indifferent about this. i don't want to limit other platforms just for the sake of macOS.

rossy commented 6 years ago

I haven't looked into this too much, but I think Windows/Direct3D might benefit from a auto|integrated|discrete option. On Windows, you can use the default adapter, which I think can change depending on app profiles in the GPU settings dialog. You can also prefer "minimum power" or "high performance" adapters.

I'm not sure if the GPU settings affect how the adapters are seen by Vulkan applications on Windows.

dnmTX commented 6 years ago

I asked this question in another post with no response from any of you(not sure why i was being ignored) and i'm glad that finally somebody addressed this issue.I personally use eGPU(external GPU-GTX 1080 connected to my laptop) and would really like to be the one rendering instead of my weak iGPU.Wright now,under Windows it's defaulting to my iGPU all the time.Would really like to see option that i can choose and not relying on Windows to decide.I mean not only for Vulkan but for d3d11 as well,basically in general. eGPU trend is getting more and more popular as MPV Player as well so trust me,many will appreciate that option present.

kkkrackpot commented 6 years ago

Don't know if this question concerns only laptop users or all users. But I think the majority of PC users use integrated GPU anyway, because they simply don't have a discrete GPU. However, personally, I would vote for discrete GPU, because I have one and "hi-quality" is exactly what I use mpv for.

FireBurn commented 6 years ago

Is there an advantage of using a dGPU over in integrated one? Surely if the integrated one has enough muscle to push the pixels to the screen it should be used. This is a video player, having a fancier graphics card wont make the picture nicer

kkkrackpot commented 6 years ago

@FireBurn you could read about custom shaders stuff first.

haasn commented 6 years ago

@FireBurn many settings, like scale=ewa_lanczos, require a comparatively powerful GPU - especially at large resolutions.

For example, my discrete RX 560 has trouble pushing 4K 60 Hz with high quality settings (e.g. debanding+RAVU), and my GTX 970 has trouble with 8K 60 Hz

FireBurn commented 6 years ago

@fhlfibh @haasn I think you're making my point, selection should be based on need of resources, for general playback not much is required. If you're using shaders select the best option, but most people won't be using custom shaders.

DeadSix27 commented 6 years ago

Isn't the question whether we should default to iGPU? Sure, fancy scalers and shader scripts require beefier GPU's but in that case using the config option to always select the dGPU is better, no? Or the other way around.

haasn commented 6 years ago

@FireBurn well this is why I suggested making the default be iGPU and having gpu-hq default to dGPU instead

Hrxn commented 6 years ago

[..] default be iGPU and having gpu-hq default to dGPU instead

That seems like a reasonable choice to me.

I would like to add that using ewa_lanczos for scaling together with debanding appears as pretty normal, "general playback" to me. That's nothing especially fancy. Not really what I would call custom shader level stuff. Let me defend that with my new favorite argument: It's 2017!

zc62 commented 6 years ago

@dnmTX Couldn't you force mpv to use eGPU in Nvidia control panel? Not sure if it works for eGPU but changing to force using dGPU in Nvidia control panel was the first thing I did when I got mpv on my laptop.

dnmTX commented 6 years ago

@zc62 everything in NVCP-Global/Individual is set to use the eGPU,With Optimus it doesn't matter if it's dGPU or eGPU,both are treated equally.It's partially drivers fault and partially MPV's fault as well.I did run the player with Vulkan just to test it and it default it to NVIDIA GPU right away,on d3d11 is using the iGPU all the time.What we need is OPTION to choose which gpu to be used on switchable graphics system(can't rely on broken Nvidia drivers and buggy Windows).Also "HELP" option to list the gpu's (same as --audio-device=help) would be very much appreciated. With few words: GIVE US A CHOICE !!!!!

haasn commented 6 years ago

Also "HELP" option to list the gpu's (same as --audio-device=help) would be very much appreciated. With few words: GIVE US A CHOICE !!!!!

--vulkan-device=help already exists

dnmTX commented 6 years ago

@haasn what about --d3d11-device=help or --angle-device=help?....hardly doubt it.I don't use Vulkan,i just used it to test and see which gpu will be used.I guess you missed the point of my last post.

"What we need is OPTION to choose which gpu to be used on switchable graphics system(can't rely on broken Nvidia drivers and buggy Windows)"

haasn commented 6 years ago

@dnmTX Those APIs don't support choosing the GPU to use afaik

DeadSix27 commented 6 years ago

@haasn In D3D11? Isn't there D3D11CreateDevice which allows a pointer to a DX device? Which can be retrieved from IDXGIFactory1::EnumAdapters which lists all adapters? (I'm just going through MS docs, correct me if I'm completely wrong here)

rossy commented 6 years ago

@haasn @DeadSix27 Yep. I managed to enable the iGPU in my desktop PC to test this. Creating a D3D11 device on the iGPU by passing an IDXGIAdapter to D3D11CreateDevice seems to work as expected. Adding something like --d3d11-device or --angle-device would definitely be possible.

Artoriuz commented 6 years ago

As an user I think having a flag to switch between them makes sense, defaulting to the iGPU when nothing is explicitly chosen and at the same time including the "prioritise using the dGPU" flag in gpu-hq.

I'm not exactly sure this is the case for every *nix DE, but at least on GNOME with a right click you can choose to launch a program using the dGPU. Same behavior on Windows.

Nvidia also has a section in their control panel for the user to choose which GPU to use with different programs, wouldn't it always overwrite whatever mpv would try to do?

badhras commented 6 years ago

I'm trying to experiment with using different adapters for playback on Windows. Because I'm using media-autobuild_suite-master to build mpv-git, I don't have any convenient debug symbols. Can somebody tell me where/how mpv-git is calling D3D11CreateDevice when a video is drag-and-dropped into the mpv window?

I was hoping by modifying the behavior of d3d11_create_standalone() in video/d3d.c, I could modify the IDXGIAdapter instance passed into D3D11CreateDevice when a video is drag-and-dropped into the window. I put a few calls to MessageBoxA in d3d11_create_standalone(), and it seems that function isn't getting called.

shanechko commented 2 years ago

I can't use hwdec=vaapi with dGPU vulkan device.

dGPU is not always better for video processing.