obs-qsv11: Simplify tracking of which allocator is used

Replace the checks based on D3D11 and D3D9 to check a more informative
variable aptly named UseTexAlloc for which memory allocator should be
used within the encoder.
This commit is contained in:
Kurt Kartaltepe 2023-01-06 17:43:01 -08:00 committed by Ryan Foster
parent f473f45e03
commit 6acb16840d
2 changed files with 10 additions and 8 deletions

View file

@ -90,6 +90,7 @@ QSV_Encoder_Internal::QSV_Encoder_Internal(mfxIMPL &impl, mfxVersion &version,
m_bIsWindows8OrGreater = IsWindows8OrGreater();
m_bUseD3D11 = false;
m_bD3D9HACK = true;
m_bUseTexAlloc = (m_bUseD3D11 || m_bD3D9HACK);
if (m_bIsWindows8OrGreater) {
tempImpl = impl | MFX_IMPL_VIA_D3D11;
@ -425,7 +426,7 @@ mfxStatus QSV_Encoder_Internal::InitParams(qsv_param_t *pParams,
m_mfxEncParams.mfx.FrameInfo.Width = MSDK_ALIGN16(pParams->nWidth);
m_mfxEncParams.mfx.FrameInfo.Height = MSDK_ALIGN16(pParams->nHeight);
if (m_bUseD3D11 || m_bD3D9HACK)
if (m_bUseTexAlloc)
m_mfxEncParams.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
else
m_mfxEncParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
@ -480,7 +481,7 @@ mfxStatus QSV_Encoder_Internal::AllocateSurfaces()
EncRequest.NumFrameSuggested += m_mfxEncParams.AsyncDepth;
// Allocate required surfaces
if (m_bUseD3D11 || m_bD3D9HACK) {
if (m_bUseTexAlloc) {
sts = m_mfxAllocator.Alloc(m_mfxAllocator.pthis, &EncRequest,
&m_mfxResponse);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
@ -757,7 +758,7 @@ mfxStatus QSV_Encoder_Internal::Encode(uint64_t ts, uint8_t *pDataY,
}
mfxFrameSurface1 *pSurface = m_pmfxSurfaces[nSurfIdx];
if (m_bUseD3D11 || m_bD3D9HACK) {
if (m_bUseTexAlloc) {
sts = m_mfxAllocator.Lock(m_mfxAllocator.pthis,
pSurface->Data.MemId,
&(pSurface->Data));
@ -771,7 +772,7 @@ mfxStatus QSV_Encoder_Internal::Encode(uint64_t ts, uint8_t *pDataY,
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
pSurface->Data.TimeStamp = ts;
if (m_bUseD3D11 || m_bD3D9HACK) {
if (m_bUseTexAlloc) {
sts = m_mfxAllocator.Unlock(m_mfxAllocator.pthis,
pSurface->Data.MemId,
&(pSurface->Data));
@ -836,7 +837,7 @@ mfxStatus QSV_Encoder_Internal::Encode_tex(uint64_t ts, uint32_t tex_handle,
mfxFrameSurface1 *pSurface = m_pmfxSurfaces[nSurfIdx];
//copy to default surface directly
pSurface->Data.TimeStamp = ts;
if (m_bUseD3D11 || m_bD3D9HACK) {
if (m_bUseTexAlloc) {
sts = simple_copytex(m_mfxAllocator.pthis, pSurface->Data.MemId,
tex_handle, lock_key, next_key);
MSDK_CHECK_RESULT(sts, MFX_ERR_NONE, sts);
@ -893,12 +894,12 @@ mfxStatus QSV_Encoder_Internal::ClearData()
m_pmfxENC = NULL;
}
if (m_bUseD3D11 || m_bD3D9HACK)
if (m_bUseTexAlloc)
m_mfxAllocator.Free(m_mfxAllocator.pthis, &m_mfxResponse);
if (m_pmfxSurfaces) {
for (int i = 0; i < m_nSurfNum; i++) {
if (!m_bUseD3D11 && !m_bD3D9HACK)
if (!m_bUseTexAlloc)
delete m_pmfxSurfaces[i]->Data.Y;
delete m_pmfxSurfaces[i];
@ -921,7 +922,7 @@ mfxStatus QSV_Encoder_Internal::ClearData()
g_numEncodersOpen--;
}
if ((m_bUseD3D11 || m_bD3D9HACK) && (g_numEncodersOpen <= 0)) {
if ((m_bUseTexAlloc) && (g_numEncodersOpen <= 0)) {
Release();
g_DX_Handle = NULL;
}

View file

@ -132,6 +132,7 @@ private:
bool m_bIsWindows8OrGreater;
bool m_bUseD3D11;
bool m_bD3D9HACK;
bool m_bUseTexAlloc;
bool m_isDGPU;
static mfxU16 g_numEncodersOpen;
static mfxHDL