mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 22:23:31 +00:00
Add VAAPI DRM support
This commit is contained in:
@@ -84,6 +84,9 @@ unix:!macx {
|
|||||||
packagesExist(libva-wayland) {
|
packagesExist(libva-wayland) {
|
||||||
CONFIG += libva-wayland
|
CONFIG += libva-wayland
|
||||||
}
|
}
|
||||||
|
packagesExist(libva-drm) {
|
||||||
|
CONFIG += libva-drm
|
||||||
|
}
|
||||||
CONFIG += libva
|
CONFIG += libva
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +219,12 @@ libva-wayland {
|
|||||||
PKGCONFIG += libva-wayland
|
PKGCONFIG += libva-wayland
|
||||||
DEFINES += HAVE_LIBVA_WAYLAND
|
DEFINES += HAVE_LIBVA_WAYLAND
|
||||||
}
|
}
|
||||||
|
libva-wayland {
|
||||||
|
message(VAAPI DRM support enabled)
|
||||||
|
|
||||||
|
PKGCONFIG += libva-drm
|
||||||
|
DEFINES += HAVE_LIBVA_DRM
|
||||||
|
}
|
||||||
libvdpau {
|
libvdpau {
|
||||||
message(VDPAU renderer selected)
|
message(VDPAU renderer selected)
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,12 @@
|
|||||||
|
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
VAAPIRenderer::VAAPIRenderer()
|
VAAPIRenderer::VAAPIRenderer()
|
||||||
: m_HwContext(nullptr)
|
: m_HwContext(nullptr),
|
||||||
|
m_DrmFd(-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +30,10 @@ VAAPIRenderer::~VAAPIRenderer()
|
|||||||
vaTerminate(display);
|
vaTerminate(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_DrmFd != -1) {
|
||||||
|
close(m_DrmFd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -86,6 +94,39 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Moonlight not compiled with VAAPI Wayland support!");
|
"Moonlight not compiled with VAAPI Wayland support!");
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
// TODO: Upstream a better solution for SDL_GetWindowWMInfo on KMSDRM
|
||||||
|
else if (strcmp(SDL_GetCurrentVideoDriver(), "KMSDRM") == 0) {
|
||||||
|
#ifdef HAVE_LIBVA_DRM
|
||||||
|
const char* device = SDL_getenv("DRM_DEV");
|
||||||
|
|
||||||
|
if (device == nullptr) {
|
||||||
|
device = "/dev/dri/card0";
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Opening DRM device: %s",
|
||||||
|
device);
|
||||||
|
|
||||||
|
m_DrmFd = open(device, O_RDWR | O_CLOEXEC);
|
||||||
|
if (m_DrmFd < 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Failed to open DRM device: %d",
|
||||||
|
errno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vaDeviceContext->display = vaGetDisplayDRM(m_DrmFd);
|
||||||
|
if (!vaDeviceContext->display) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Unable to open DRM display for VAAPI");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Moonlight not compiled with VAAPI DRM support!");
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ extern "C" {
|
|||||||
#ifdef HAVE_LIBVA_WAYLAND
|
#ifdef HAVE_LIBVA_WAYLAND
|
||||||
#include <va/va_wayland.h>
|
#include <va/va_wayland.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBVA_DRM
|
||||||
|
#include <va/va_drm.h>
|
||||||
|
#endif
|
||||||
#include <libavutil/hwcontext_vaapi.h>
|
#include <libavutil/hwcontext_vaapi.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +42,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_WindowSystem;
|
int m_WindowSystem;
|
||||||
AVBufferRef* m_HwContext;
|
AVBufferRef* m_HwContext;
|
||||||
|
int m_DrmFd;
|
||||||
|
|
||||||
#ifdef HAVE_LIBVA_X11
|
#ifdef HAVE_LIBVA_X11
|
||||||
Window m_XWindow;
|
Window m_XWindow;
|
||||||
|
|||||||
Reference in New Issue
Block a user