Add VAAPI DRM support
This commit is contained in:
parent
66863789c7
commit
6468efd7e4
3 changed files with 55 additions and 1 deletions
|
|
@ -84,6 +84,9 @@ unix:!macx {
|
|||
packagesExist(libva-wayland) {
|
||||
CONFIG += libva-wayland
|
||||
}
|
||||
packagesExist(libva-drm) {
|
||||
CONFIG += libva-drm
|
||||
}
|
||||
CONFIG += libva
|
||||
}
|
||||
|
||||
|
|
@ -216,6 +219,12 @@ libva-wayland {
|
|||
PKGCONFIG += libva-wayland
|
||||
DEFINES += HAVE_LIBVA_WAYLAND
|
||||
}
|
||||
libva-wayland {
|
||||
message(VAAPI DRM support enabled)
|
||||
|
||||
PKGCONFIG += libva-drm
|
||||
DEFINES += HAVE_LIBVA_DRM
|
||||
}
|
||||
libvdpau {
|
||||
message(VDPAU renderer selected)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@
|
|||
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
VAAPIRenderer::VAAPIRenderer()
|
||||
: m_HwContext(nullptr)
|
||||
: m_HwContext(nullptr),
|
||||
m_DrmFd(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -26,6 +30,10 @@ VAAPIRenderer::~VAAPIRenderer()
|
|||
vaTerminate(display);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DrmFd != -1) {
|
||||
close(m_DrmFd);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -86,6 +94,39 @@ VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
|||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Moonlight not compiled with VAAPI Wayland support!");
|
||||
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
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ extern "C" {
|
|||
#ifdef HAVE_LIBVA_WAYLAND
|
||||
#include <va/va_wayland.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBVA_DRM
|
||||
#include <va/va_drm.h>
|
||||
#endif
|
||||
#include <libavutil/hwcontext_vaapi.h>
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +42,7 @@ public:
|
|||
private:
|
||||
int m_WindowSystem;
|
||||
AVBufferRef* m_HwContext;
|
||||
int m_DrmFd;
|
||||
|
||||
#ifdef HAVE_LIBVA_X11
|
||||
Window m_XWindow;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue