diff mbox series

[FFmpeg-devel] metal: Add hint to select low power device instead of the default one

Message ID 5B54A9AC-BC65-4159-8CE4-B3A1214A8454@gmail.com
State New
Headers show
Series [FFmpeg-devel] metal: Add hint to select low power device instead of the default one | expand

Commit Message

Jérémy Demeule Sept. 4, 2023, 9:58 p.m. UTC
SDL >= 2.28.3 introduce a renderer hint to allow selection of low-power
device on default macOS backend (i.e. metal).

<TLDR>
On some system like MacBook Pro Intel with AMD card, asking for the
default device will always return the AMD GPU.

This is not an issue for 99% of the case when the renderer context is
here to provide the maximum performance level like for game.

However, for video application using GPU for 1 quad and 1 texture,
using the discrete GPU for that lead to an important power consumption
(4 to 8W), heat increase, and fan noise.

With this patch, ffplay will use the integrated GPU (i.e. the Intel
one), instead of the discrete GPU (i.e. the AMD one).

Signed-off-by: Jérémy Demeule <jeremy.demeule@gmail.com>
---
fftools/ffplay.c | 3 +++
1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 5212ad053e..e766d502a8 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3712,6 +3712,9 @@  int main(int argc, char **argv)
#endif
        window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
+#if SDL_VERSION_ATLEAST(2,28,3)
+        SDL_SetHint(SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE, "true");
+#endif
        if (window) {
            renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
            if (!renderer) {