XITRIX / Moonlight-Switch

Moonlight port for Nintendo Switch
777 stars 47 forks source link

NVDEC Support #108

Closed benwa closed 9 months ago

benwa commented 10 months ago

I was approached by @averne that they have solved my bounty for NVDEC in their repo here. Can you make a test build of Moonlight-Switch to see if this has improved performance?

averne commented 10 months ago

Note that this would need a deko3d graphics backend for best performance, since you can import decoded frames directly into the graphics context without extraneous copies (using the DkImageFlags_UsageVideo flag).

If you need help please contact me on discord (username avhe).

XITRIX commented 10 months ago

Thanks for the info, I try to check it

XITRIX commented 10 months ago

@averne, currently Moonlight-Switch uses OpenGL as it's graphical backend, will I be able to use your modified FFmpeg lib with it or app should be rewritten using deko3d first?

averne commented 10 months ago

OpenGL should be able to work, but unoptimally. It boils down to its inability to directly import frames from the decoder, so the following happens: decoder output (block linear) -> copied to staging buffer (pitch linear) using VIC -> copied to GPU texture (block linear) using GPU copy engine.

With deko3d, you're able to directly import frame data into GPU textures, removing those two extraneous copies.

averne commented 10 months ago

Though I think even with those copies, you should be able to achieve 1080p@60fps playback, maybe even at higher resolutions (As a point of reference, my hwaccel backend can decode 4k HEVC footage at around 90fps).

So I would try to work with OpenGL first, then assess whether writing a new graphics backend with deko3d is worthwhile.

XITRIX commented 10 months ago

@averne, could you please send me a compiled .a files for avcodec and avutil from your FFmpeg branch if it's not a problem?

averne commented 10 months ago

Sorry but those files are quite large (especially libavcodec) so it's a bit inconvenient to send over. Here's my configuration:

./configure --cc=aarch64-none-elf-gcc --cxx=aarch64-none-elf-g++ --ar=aarch64-none-elf-ar --nm=aarch64-none-elf-nm --extra-cflags='-isystem /opt/devkitpro/libnx/include -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -Wno-deprecated-declarations' --enable-asm --enable-gpl --enable-tx1 --enable-static --disable-shared --enable-zlib --enable-bzlib --enable-libass --enable-libfreetype --enable-libfribidi --disable-doc --disable-programs --target-os=horizon --enable-cross-compile --cross-prefix=aarch64-none-elf- --arch=aarch64 --cpu=cortex-a57 --enable-neon --enable-pic --disable-autodetect --disable-runtime-cpudetect --disable-debug
benwa commented 9 months ago

Closed with v0.13.1