Add graphics adapter (GPU) selection#1845
Conversation
|
Thank you for your contribution. It is a good idea, but it would nice to have some cross-platform support, particularly on Linux. I do not think it matters much on macOS any more since the advent of Apple Silicon. In any case, I just had to push a fix for the next release that created a merge conflict. Please fix that. Then, I will not be able to merge this until after the next release due by end of the month plus a quiet week. I require that I am able to test and support nearly everything in Shotcut because I cannot trust any outsider to be there to help. Currently, I do not have any multi-GPU system, but I have a couple that I can swap a PCIe card if the power supply supports it. So, in the meantime, I will try to get there in position to test and support it and possibly extend to Linux. |
f070361 to
defc1d0
Compare
|
Thanks for the detailed review — much appreciated. I've pushed an update (rebased onto master):
On the broader point: you're right that this currently only affects the UI/display adapter and the optional encoder, not hardware decoding or the GPU (Movit) processing mode. I scoped it conservatively for that reason — |
Add a "Graphics Adapter" submenu under Settings to choose which physical GPU
Shotcut renders, decodes, and encodes with. On systems where a low-power
integrated GPU drives the display while a more capable discrete GPU is also
present (e.g. an NVIDIA card with no monitor attached), this lets the user direct
preview rendering, hardware decoding and hardware export to the discrete GPU.
- gpuinfo.{h,cpp} (new): enumerate physical adapters via DXGI, de-duplicating
the same GPU that some drivers report multiple times; resolve a GPU's live
DXGI adapter index from its stable vendor+device id (the raw index is not
stable across runs on some systems); and pick the hardware encoder family
matching the selected vendor (NVIDIA->nvenc, AMD->amf, Intel->qsv), skipping
H.264 hardware encoders for 10-bit video since they do not support it.
- main.cpp: set QT_D3D_ADAPTER_INDEX (Qt RHI preview/UI) and
MLT_AVFORMAT_HWACCEL_DEVICE (FFmpeg hardware decoder) to the selected GPU
before the RHI is initialized (Windows Direct3D backend).
- docks/encodedock.cpp: when hardware encoding is enabled, prefer the encoder
family matching the selected GPU.
- mainwindow: Settings > Graphics Adapter menu with a restart prompt.
- tests: a QtTest suite for the encoder selection and adapter logic, built
behind the off-by-default SHOTCUT_BUILD_TESTS option (configure with
-DSHOTCUT_BUILD_TESTS=ON, run with ctest).
UI translations are intentionally omitted (handled via Transifex).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
defc1d0 to
e752f50
Compare
|
Thanks — good call. I've set One note on the Linux CI: the |
ddennedy
left a comment
There was a problem hiding this comment.
I successfully tested this and will merge it a few days after the next release.
What
Adds a Settings → Graphics Adapter submenu to choose which physical GPU Shotcut renders and encodes with.
Why
On a desktop where a low-power integrated GPU drives the display while a more capable discrete GPU is also installed (e.g. an NVIDIA card with no monitor attached), Shotcut renders the preview — and, depending on the chosen encoder, exports — on the integrated GPU, with no way to direct the work to the discrete GPU. This adds that choice.
How
gpuinfo.{h,cpp}, new): list physical adapters via DXGI. Some drivers (notably AMD integrated graphics) report the same physical GPU many times with different LUIDs, so adapters are de-duplicated by their stable hardware identity (vendor + device + subsys + revision).QT_D3D_ADAPTER_INDEXbefore the RHI is initialized, so the Direct3D scene graph (the default backend on Windows) creates its device on that adapter.*_nvenc, AMD →*_amf, Intel →*_qsv), and hardware encoding defaults on.Settings > Graphics Adapterwith the usual restart prompt, following the existing "Display Method" menu pattern.Scope / notes
enumerateGpuAdapters()returns empty elsewhere and the menu is hidden, so other platforms are unaffected.gpuinfo.{h,cpp}carry the Meltytech copyright header; formatted with clang-format 14.Tests
Adds a QtTest suite (
tests/test_gpuinfo.cpp, 11 cases) covering encoder-family selection, codec-type matching, fallbacks, adapter de-duplication and live index resolution, behind a new off-by-defaultSHOTCUT_BUILD_TESTSoption (default/official builds unchanged):Manually verified on an AMD iGPU + NVIDIA RTX 3090 machine: selecting the 3090 moves preview rendering to it (confirmed via
nvidia-smi) and routes hardware export through NVENC.🤖 Generated with Claude Code