|
|
@@ -16,6 +16,7 @@
|
|
|
|
|
|
#include <intrin.h>
|
|
|
#include <inttypes.h>
|
|
|
+#include <obs-module.h>
|
|
|
|
|
|
/* =======================================================
|
|
|
* Windows implementation of OS-specific utility functions
|
|
|
@@ -29,6 +30,29 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
|
|
|
UNUSED_PARAMETER(codec);
|
|
|
UNUSED_PARAMETER(data);
|
|
|
|
|
|
+ obs_video_info ovi;
|
|
|
+ obs_get_video_info(&ovi);
|
|
|
+ mfxU32 adapter_idx = ovi.adapter;
|
|
|
+
|
|
|
+ // Select current adapter - will be iGPU if exists due to adapter reordering
|
|
|
+ if (codec == QSV_CODEC_AV1 && !adapters[adapter_idx].supports_av1) {
|
|
|
+ for (mfxU32 i = 0; i < 4; i++) {
|
|
|
+ if (adapters[i].supports_av1) {
|
|
|
+ adapter_idx = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (!adapters[adapter_idx].is_intel) {
|
|
|
+ for (mfxU32 i = 0; i < 4; i++) {
|
|
|
+ if (adapters[i].is_intel) {
|
|
|
+ adapter_idx = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ adapter_index = adapter_idx;
|
|
|
+
|
|
|
mfxStatus sts = MFX_ERR_NONE;
|
|
|
mfxVariant impl;
|
|
|
|
|
|
@@ -56,7 +80,7 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
|
|
|
(const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
impl);
|
|
|
|
|
|
- sts = MFXCreateSession(loader, 0, pSession);
|
|
|
+ sts = MFXCreateSession(loader, adapter_idx, pSession);
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
|
|
|
// Create DirectX device context
|
|
|
@@ -109,7 +133,7 @@ mfxStatus Initialize(mfxVersion ver, mfxSession *pSession,
|
|
|
(const mfxU8 *)"mfxImplDescription.AccelerationMode",
|
|
|
impl);
|
|
|
|
|
|
- sts = MFXCreateSession(loader, 0, pSession);
|
|
|
+ sts = MFXCreateSession(loader, adapter_idx, pSession);
|
|
|
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
|
|
|
}
|
|
|
return sts;
|