|
@@ -5,8 +5,6 @@
|
|
|
#include <util/c99defs.h>
|
|
|
#include <util/dstr.h>
|
|
|
#include <va/va_drm.h>
|
|
|
-#include <va/va_x11.h>
|
|
|
-#include <va/va_wayland.h>
|
|
|
#include <va/va_str.h>
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
@@ -18,6 +16,12 @@
|
|
|
#include <obs.h>
|
|
|
#include <obs-nix-platform.h>
|
|
|
|
|
|
+// Set during check_adapters to work-around VPL dispatcher not setting a VADisplay
|
|
|
+// for the MSDK runtime.
|
|
|
+static const char *default_h264_device = nullptr;
|
|
|
+static const char *default_hevc_device = nullptr;
|
|
|
+static const char *default_av1_device = nullptr;
|
|
|
+
|
|
|
mfxStatus simple_alloc(mfxHDL pthis, mfxFrameAllocRequest *request,
|
|
|
mfxFrameAllocResponse *response)
|
|
|
{
|
|
@@ -77,7 +81,8 @@ void ClearRGBSurfaceVMem(mfxMemId memId);
|
|
|
// Initialize Intel VPL Session, device/display and memory manager
|
|
|
mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
|
|
|
mfxFrameAllocator *pmfxAllocator, mfxHDL *deviceHandle,
|
|
|
- bool bCreateSharedHandles, bool dx9hack)
|
|
|
+ bool bCreateSharedHandles, bool dx9hack,
|
|
|
+ enum qsv_codec codec)
|
|
|
{
|
|
|
UNUSED_PARAMETER(ver);
|
|
|
UNUSED_PARAMETER(pmfxAllocator);
|
|
@@ -107,22 +112,39 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
|
|
|
cfg, (const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
impl);
|
|
|
|
|
|
- mfxHDL vaDisplay = nullptr;
|
|
|
- if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL) {
|
|
|
- vaDisplay =
|
|
|
- vaGetDisplay((Display *)obs_get_nix_platform_display());
|
|
|
- } else if (obs_get_nix_platform() == OBS_NIX_PLATFORM_WAYLAND) {
|
|
|
- vaDisplay = vaGetDisplayWl(
|
|
|
- (wl_display *)obs_get_nix_platform_display());
|
|
|
+ // We cant cleanup FDs because Release() is only called for gpu texture sharing cases.
|
|
|
+ int fd = -1;
|
|
|
+ if (codec == QSV_CODEC_AVC)
|
|
|
+ fd = open(default_h264_device, O_RDWR);
|
|
|
+ if (codec == QSV_CODEC_HEVC)
|
|
|
+ fd = open(default_hevc_device, O_RDWR);
|
|
|
+ if (codec == QSV_CODEC_AV1)
|
|
|
+ fd = open(default_av1_device, O_RDWR);
|
|
|
+ if (fd < 0) {
|
|
|
+ blog(LOG_ERROR, "Failed to open device '%s'",
|
|
|
+ default_h264_device);
|
|
|
+ return MFX_ERR_DEVICE_FAILED;
|
|
|
+ }
|
|
|
+
|
|
|
+ mfxHDL vaDisplay = vaGetDisplayDRM(fd);
|
|
|
+ if (!vaDisplay) {
|
|
|
+ return MFX_ERR_DEVICE_FAILED;
|
|
|
}
|
|
|
|
|
|
sts = MFXCreateSession(loader, 0, pSession);
|
|
|
- MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
+ if (MFX_ERR_NONE > sts) {
|
|
|
+ blog(LOG_ERROR, "Failed to initialize MFX");
|
|
|
+ MSDK_PRINT_RET_MSG(sts);
|
|
|
+ close(fd);
|
|
|
+ return sts;
|
|
|
+ }
|
|
|
|
|
|
// VPL expects the VADisplay to be initialized.
|
|
|
int major;
|
|
|
int minor;
|
|
|
if (vaInitialize(vaDisplay, &major, &minor) != VA_STATUS_SUCCESS) {
|
|
|
+ blog(LOG_ERROR, "Failed to initialize VA-API");
|
|
|
+ close(fd);
|
|
|
vaTerminate(vaDisplay);
|
|
|
return MFX_ERR_DEVICE_FAILED;
|
|
|
}
|
|
@@ -315,6 +337,18 @@ void check_adapters(struct adapter_info *adapters, size_t *adapter_count)
|
|
|
vaapi_supports_av1(device.display);
|
|
|
adapter->supports_hevc =
|
|
|
vaapi_supports_hevc(device.display);
|
|
|
+
|
|
|
+ if (adapter->is_intel && default_h264_device == nullptr)
|
|
|
+ default_h264_device = strdup(full_path.array);
|
|
|
+
|
|
|
+ if (adapter->supports_av1 &&
|
|
|
+ default_av1_device == nullptr)
|
|
|
+ default_av1_device = strdup(full_path.array);
|
|
|
+
|
|
|
+ if (adapter->supports_hevc &&
|
|
|
+ default_hevc_device == nullptr)
|
|
|
+ default_hevc_device = strdup(full_path.array);
|
|
|
+
|
|
|
vaapi_close(&device);
|
|
|
|
|
|
next_entry:
|