Skip to content

Commit 0a3fc14

Browse files
xiaoton1intel-mediadev
authored andcommitted
[Media Common][VP] Add 64-bit semaphore wait support for HEVCe and AV1e scalability
* [Media Common] Add 64-bit hardware semaphore support with fallback Adds conditional support for MI_SEMAPHORE_WAIT_64 command on platforms with FtrHwSemaphore64 SKU capability. Implements INIT_MHW_MI_SEMAPHORE_WAIT_64_PARAMS macro to initialize 64-bit semaphore parameters with semaphoreToken hardcoded to 0 and context switch inhibition enabled. Falls back to existing MI_SEMAPHORE_WAIT for platforms without 64-bit support.
1 parent 5adf944 commit 0a3fc14

File tree

4 files changed

+57
-14
lines changed

4 files changed

+57
-14
lines changed

media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,15 @@ namespace encode
13021302

13031303
MHW_VDBOX_STATE_CMDSIZE_PARAMS stateCmdSizeParams;
13041304

1305+
// Determine semaphore wait command size based on hardware capability
1306+
uint32_t semaphoreWaitSize = 0;
1307+
#ifdef _MEDIA_RESERVED
1308+
bool isSemaphore64Supported = MEDIA_IS_SKU(m_hwInterface->GetSkuTable(), FtrHwSemaphore64);
1309+
semaphoreWaitSize = isSemaphore64Supported ? m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT_64)() : m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)();
1310+
#else
1311+
semaphoreWaitSize = m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)();
1312+
#endif
1313+
13051314
hcpCommandsSize =
13061315
m_vdencItf->MHW_GETSIZE_F(VD_PIPELINE_FLUSH)() +
13071316
m_miItf->MHW_GETSIZE_F(MI_FLUSH_DW)() +
@@ -1334,9 +1343,9 @@ namespace encode
13341343
m_miItf->MHW_GETSIZE_F(MI_LOAD_REGISTER_MEM)() + // 1 for RC6 WA
13351344
2 * m_hcpItf->MHW_GETSIZE_F(HCP_PAK_INSERT_OBJECT)() + // Two PAK insert object commands are for headers before the slice header and the header for the end of stream
13361345
4 * m_miItf->MHW_GETSIZE_F(MI_STORE_DATA_IMM)() + // two (BRC+reference frame) for clean-up HW semaphore memory and another two for signal it
1337-
17 * m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() + // Use HW wait command for each reference and one wait for current semaphore object
1338-
m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() + // Use HW wait command for each BRC pass
1339-
+m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() // Use HW wait command for each VDBOX
1346+
17 * semaphoreWaitSize + // Use HW wait command for each reference and one wait for current semaphore object
1347+
semaphoreWaitSize + // Use HW wait command for each BRC pass
1348+
semaphoreWaitSize // Use HW wait command for each VDBOX
13401349
+ 2 * m_miItf->MHW_GETSIZE_F(MI_STORE_DATA_IMM)() // One is for reset and another one for set per VDBOX
13411350
+ 8 * m_miItf->MHW_GETSIZE_F(MI_COPY_MEM_MEM)() // Need to copy SSE statistics/ Slice Size overflow into memory
13421351
;

media_softlet/agnostic/common/codec/hal/enc/shared/packet/encode_preenc_packet.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,15 @@ namespace encode
864864

865865
MHW_VDBOX_STATE_CMDSIZE_PARAMS stateCmdSizeParams;
866866

867+
// Determine semaphore wait command size based on hardware capability
868+
uint32_t semaphoreWaitSize = 0;
869+
#ifdef _MEDIA_RESERVED
870+
bool isSemaphore64Supported = MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrHwSemaphore64);
871+
semaphoreWaitSize = isSemaphore64Supported ? m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT_64)() : m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)();
872+
#else
873+
semaphoreWaitSize = m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)();
874+
#endif
875+
867876
hcpCommandsSize =
868877
m_vdencItf->MHW_GETSIZE_F(VD_PIPELINE_FLUSH)() +
869878
m_miItf->MHW_GETSIZE_F(MI_FLUSH_DW)() +
@@ -896,9 +905,9 @@ namespace encode
896905
m_miItf->MHW_GETSIZE_F(MI_LOAD_REGISTER_MEM)() + // 1 for RC6 WA
897906
2 * m_hcpItf->MHW_GETSIZE_F(HCP_PAK_INSERT_OBJECT)() + // Two PAK insert object commands are for headers before the slice header and the header for the end of stream
898907
4 * m_miItf->MHW_GETSIZE_F(MI_STORE_DATA_IMM)() + // two (BRC+reference frame) for clean-up HW semaphore memory and another two for signal it
899-
17 * m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() + // Use HW wait command for each reference and one wait for current semaphore object
900-
m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() + // Use HW wait command for each BRC pass
901-
+m_miItf->MHW_GETSIZE_F(MI_SEMAPHORE_WAIT)() // Use HW wait command for each VDBOX
908+
17 * semaphoreWaitSize + // Use HW wait command for each reference and one wait for current semaphore object
909+
semaphoreWaitSize + // Use HW wait command for each BRC pass
910+
semaphoreWaitSize // Use HW wait command for each VDBOX
902911
+ 2 * m_miItf->MHW_GETSIZE_F(MI_STORE_DATA_IMM)() // One is for reset and another one for set per VDBOX
903912
+ 8 * m_miItf->MHW_GETSIZE_F(MI_COPY_MEM_MEM)() // Need to copy SSE statistics/ Slice Size overflow into memory
904913
;

media_softlet/agnostic/common/codec/hal/shared/codec_hw_next.h

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,37 @@ class CodechalHwInterfaceNext
841841
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
842842

843843
CODEC_HW_CHK_NULL_RETURN(m_miItf);
844-
auto &params = m_miItf->MHW_GETPAR_F(MI_SEMAPHORE_WAIT)();
845-
params = {};
846-
params.presSemaphoreMem = semaMem;
847-
params.bPollingWaitMode = true;
848-
params.dwSemaphoreData = semaData;
849-
params.CompareOperation = (mhw::mi::MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION) opCode;
850-
params.dwResourceOffset = semaMemOffset;
851-
eStatus = m_miItf->MHW_ADDCMD_F(MI_SEMAPHORE_WAIT)(cmdBuffer);
844+
845+
// Check if 64-bit hardware semaphore is supported
846+
bool isSemaphore64Supported = MEDIA_IS_SKU(m_osInterface->pfnGetSkuTable(m_osInterface), FtrHwSemaphore64);
847+
848+
#ifdef _MEDIA_RESERVED
849+
if (isSemaphore64Supported)
850+
{
851+
// Use MI_SEMAPHORE_WAIT_64 for 64-bit semaphore support
852+
auto &params = m_miItf->MHW_GETPAR_F(MI_SEMAPHORE_WAIT_64)();
853+
params = {};
854+
855+
// Initialize parameters using helper macro
856+
// This macro hardcodes semaphoreToken to 0 and sets other parameters
857+
INIT_MHW_MI_SEMAPHORE_WAIT_64_PARAMS(params, semaMem, semaData, opCode, semaMemOffset);
858+
859+
eStatus = m_miItf->MHW_ADDCMD_F(MI_SEMAPHORE_WAIT_64)(cmdBuffer);
860+
}
861+
else
862+
#endif
863+
{
864+
// Fallback to MI_SEMAPHORE_WAIT for platforms without 64-bit support
865+
// or when _MEDIA_RESERVED is not defined
866+
auto &params = m_miItf->MHW_GETPAR_F(MI_SEMAPHORE_WAIT)();
867+
params = {};
868+
params.presSemaphoreMem = semaMem;
869+
params.bPollingWaitMode = true;
870+
params.dwSemaphoreData = semaData;
871+
params.CompareOperation = (mhw::mi::MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION) opCode;
872+
params.dwResourceOffset = semaMemOffset;
873+
eStatus = m_miItf->MHW_ADDCMD_F(MI_SEMAPHORE_WAIT)(cmdBuffer);
874+
}
852875

853876
return eStatus;
854877
}

media_softlet/agnostic/common/hw/mhw_mi_cmdpar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ namespace mi
406406

407407
#ifdef _MEDIA_RESERVED
408408
#include "mhw_mi_cmdpar_ext.h"
409+
#else
410+
#define INIT_MHW_MI_SEMAPHORE_WAIT_64_PARAMS(params, semaMem, semaData, opCode, semaMemOffset)
409411
#endif
410412

411413
#endif // __MHW_MI_CMDPAR_H__

0 commit comments

Comments
 (0)