Skip to content

Commit

Permalink
[Decode] Null HW Mode Proxy enabling
Browse files Browse the repository at this point in the history
This patch is for Null HW Mode Proxy Enabling
  • Loading branch information
SteveZIntel authored and intel-mediadev committed Dec 25, 2024
1 parent d94bcf2 commit 5921165
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 4 deletions.
3 changes: 3 additions & 0 deletions media_common/agnostic/common/os/mos_util_user_feature_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@
#define __MEDIA_USER_FEATURE_VALUE_VP_MMC_IN_USE "VP MMC In Use"

#define __MEDIA_USER_FEATURE_VALUE_NULLHW_ENABLE "NULL HW Enable"
#if (_DEBUG || _RELEASE_INTERNAL)
#define __MEDIA_USER_FEATURE_VALUE_NULLHW_PROXY_REPEAT_COUNT "NULL HW Proxy Repeat Count"
#endif
#define __MEDIA_USER_FEATURE_VALUE_MOCKADAPTOR_PLATFORM "MockAdaptor Platform"
#define __MEDIA_USER_FEATURE_VALUE_MOCKADAPTOR_STEPPING "MockAdaptor Stepping"
#define __MEDIA_USER_FEATURE_VALUE_MOCKADAPTOR_DEVICE "MockAdaptor Device ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
#include "decode_status_report_defs.h"
#include "decode_predication_packet.h"
#include "decode_marker_packet.h"

#if (_DEBUG || _RELEASE_INTERNAL)
#include "decode_nullhw_proxy_test_packet.h"
#endif
namespace decode {

MOS_STATUS HevcDecodePkt::Init()
Expand All @@ -47,6 +49,28 @@ MOS_STATUS HevcDecodePkt::Init()
m_allocator = m_hevcPipeline->GetDecodeAllocator();
DECODE_CHK_NULL(m_allocator);

#if (_DEBUG || _RELEASE_INTERNAL)
if (m_osInterface->bNullHwIsEnabled)
{
auto nullhwProxy = DecodeNullHWProxyTestPkt::Instance();
DECODE_CHK_NULL(nullhwProxy);
nullhwProxy->Init(m_hevcPipeline, m_osInterface);
}
#endif

return MOS_STATUS_SUCCESS;
}

MOS_STATUS HevcDecodePkt::Destroy()
{
#if (_DEBUG || _RELEASE_INTERNAL)
if (m_osInterface->bNullHwIsEnabled)
{
auto nullhwProxy = DecodeNullHWProxyTestPkt::Instance();
DECODE_CHK_NULL(nullhwProxy);
DECODE_CHK_STATUS(nullhwProxy->Destory());
}
#endif
return MOS_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -233,13 +257,25 @@ MOS_STATUS HevcDecodePkt::StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER*
{
DECODE_FUNC_CALL();
DECODE_CHK_NULL(cmdBuffer);
DECODE_CHK_STATUS(MediaPacket::StartStatusReportNext(srType, cmdBuffer));
DECODE_CHK_NULL(m_hevcPipeline);
DECODE_CHK_NULL(m_osInterface);

SetPerfTag(CODECHAL_DECODE_MODE_HEVCVLD, m_hevcBasicFeature->m_pictureCodingType);

MediaPerfProfiler *perfProfiler = MediaPerfProfiler::Instance();
DECODE_CHK_NULL(perfProfiler);
DECODE_CHK_STATUS(perfProfiler->AddPerfCollectStartCmd((void*)m_hevcPipeline, m_osInterface, m_miItf, cmdBuffer));
DECODE_CHK_STATUS(perfProfiler->AddPerfCollectStartCmd((void *)m_hevcPipeline, m_osInterface, m_miItf, cmdBuffer));

#if (_DEBUG || _RELEASE_INTERNAL)
if (m_osInterface->bNullHwIsEnabled)
{
DecodeNullHWProxyTestPkt *nullhwProxy = DecodeNullHWProxyTestPkt::Instance();
DECODE_CHK_NULL(nullhwProxy);
nullhwProxy->AddNullHwProxyCmd(m_hevcPipeline, m_osInterface, cmdBuffer);
}
#endif

DECODE_CHK_STATUS(MediaPacket::StartStatusReportNext(srType, cmdBuffer));

return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class HevcDecodePkt : public CmdPacket, public MediaStatusReportObserver
//!
virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override;

virtual MOS_STATUS Destroy() override;

protected:
void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ MOS_STATUS HevcDecodeBackEndPkt::Init()

MOS_STATUS HevcDecodeBackEndPkt::Destroy()
{
DECODE_CHK_STATUS(HevcDecodePkt::Destroy());
m_statusReport->UnregistObserver(this);
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ MOS_STATUS HevcDecodeFrontEndPkt::Init()

MOS_STATUS HevcDecodeFrontEndPkt::Destroy()
{
DECODE_CHK_STATUS(HevcDecodePkt::Destroy());
m_statusReport->UnregistObserver(this);
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ MOS_STATUS HevcDecodeLongPkt::Init()

MOS_STATUS HevcDecodeLongPkt::Destroy()
{
DECODE_CHK_STATUS(HevcDecodePkt::Destroy());
m_statusReport->UnregistObserver(this);
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ MOS_STATUS HevcDecodeRealTilePkt::Init()

MOS_STATUS HevcDecodeRealTilePkt::Destroy()
{
DECODE_CHK_STATUS(HevcDecodePkt::Destroy());
m_statusReport->UnregistObserver(this);
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ media_include_subdirectory(scalability)
media_include_subdirectory(statusreport)
media_include_subdirectory(mmc)
media_include_subdirectory(hucItf)
media_include_subdirectory(nullhwproxy)

set(SOFTLET_DECODE_COMMON_SOURCES_
${SOFTLET_DECODE_COMMON_SOURCES_}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
/*
* Copyright (c) 2024, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file decode_nullhw_proxy_test_packet.cpp
//!

#include "decode_nullhw_proxy_test_packet.h"
#include "decode_resource_auto_lock.h"

namespace decode
{
#if (_DEBUG || _RELEASE_INTERNAL)
MOS_STATUS DecodeNullHWProxyTestPkt::Init(DecodePipeline *pipeline, MOS_INTERFACE *osInterface)
{
MOS_STATUS status = MOS_STATUS_SUCCESS;
DECODE_CHK_NULL(osInterface);
PMOS_CONTEXT pOsContext = osInterface->pOsContext;
DECODE_CHK_NULL(pOsContext);
m_allocator = pipeline->GetDecodeAllocator();
DECODE_CHK_NULL(m_allocator);
MediaUserSettingSharedPtr userSettingPtr = osInterface->pfnGetUserSettingInstance(osInterface);
ReadUserSetting(
userSettingPtr,
m_isNullHWEnabled,
__MEDIA_USER_FEATURE_VALUE_NULLHW_ENABLE,
MediaUserSetting::Group::Device);
if (!m_isNullHWEnabled) //NullHW is Not Enabled, return
{
return MOS_STATUS_SUCCESS;
}
ReadUserSetting(
userSettingPtr,
m_repeatCount,
__MEDIA_USER_FEATURE_VALUE_NULLHW_PROXY_REPEAT_COUNT,
MediaUserSetting::Group::Device);

if (m_dataStoreBuf == nullptr)
{
m_dataStoreBuf = m_allocator->AllocateBuffer(2 * sizeof(uint32_t), "Store data buffer", resourceInternalReadWriteCache, notLockableVideoMem, true, 0);
DECODE_CHK_NULL(m_dataStoreBuf);
}
if (m_secondLevelBBArray == nullptr)
{
m_secondLevelBBArray = m_allocator->AllocateBatchBufferArray(
CODECHAL_CACHELINE_SIZE, 1, 64, true, lockableVideoMem);
DECODE_CHK_NULL(m_secondLevelBBArray);
}
m_miItf = pipeline->GetHwInterface()->GetMiInterfaceNext();
DECODE_CHK_NULL(m_miItf);

MOS_ZeroMemory(&m_conditionalBbEndDummy, sizeof(m_conditionalBbEndDummy));

return status;
}

MOS_STATUS DecodeNullHWProxyTestPkt::Destory()
{
DECODE_CHK_NULL(m_allocator);
DECODE_CHK_STATUS(m_allocator->Destroy(m_dataStoreBuf));
DECODE_CHK_STATUS(m_allocator->Destroy(m_secondLevelBBArray));

return MOS_STATUS_SUCCESS;
}

MOS_STATUS DecodeNullHWProxyTestPkt::Init2ndLevelCmdBuffer(MHW_BATCH_BUFFER& batchBuffer, uint8_t* batchBufBase)
{
DECODE_FUNC_CALL();

auto &cmdBuffer = m_statusCheckCmdBuffer;
MOS_ZeroMemory(&cmdBuffer, sizeof(MOS_COMMAND_BUFFER));
cmdBuffer.pCmdBase = (uint32_t *)batchBufBase;
cmdBuffer.pCmdPtr = cmdBuffer.pCmdBase;
cmdBuffer.iRemaining = batchBuffer.iSize;
cmdBuffer.OsResource = batchBuffer.OsResource;

return MOS_STATUS_SUCCESS;
}

//!
//! \brief Send conditional batch buffer end cmd
//! \details Send conditional batch buffer end cmd
//!
//! \param [in] resource
//! Reource used in conditional batch buffer end cmd
//! \param [in] offset
//! Reource offset used in mi atomic dword cmd
//! \param [in] compData
//! Compare data
//! \param [in] disableCompMask
//! Indicate disabling compare mask
//! \param [in] enableEndCurrentBatchBuffLevel
//! End Current Batch Buffer Level
//! \param [in] compareOperation
//! Compare operation
//! \param [in,out] cmdBuffer
//! command buffer
//!
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS DecodeNullHWProxyTestPkt::SendCondBbEndCmd(
PMOS_RESOURCE resource,
uint32_t offset,
uint32_t compData,
bool disableCompMask,
bool enableEndCurrentBatchBuffLevel,
uint32_t compareOperation,
PMOS_COMMAND_BUFFER cmdBuffer)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;

CODEC_HW_FUNCTION_ENTER;
DECODE_CHK_NULL(m_miItf);

if (!Mos_ResourceIsNull(&m_conditionalBbEndDummy))
{
auto &par = m_miItf->GETPAR_MI_FLUSH_DW();
par = {};
par.postSyncOperation = 1;
par.pOsResource = &m_conditionalBbEndDummy;
par.dwDataDW1 = 0;
CODEC_HW_CHK_STATUS_RETURN(m_miItf->ADDCMD_MI_FLUSH_DW(cmdBuffer));
}

auto &par = m_miItf->GETPAR_MI_CONDITIONAL_BATCH_BUFFER_END();
par = {};
par.presSemaphoreBuffer = resource;
par.dwOffset = offset;
par.dwValue = compData;
par.bDisableCompareMask = disableCompMask;
par.dwParamsType = mhw::mi::MHW_MI_ENHANCED_CONDITIONAL_BATCH_BUFFER_END_PARAMS::ENHANCED_PARAMS;
if (enableEndCurrentBatchBuffLevel)
{
par.enableEndCurrentBatchBuffLevel = enableEndCurrentBatchBuffLevel;
par.compareOperation = compareOperation;
}
eStatus = m_miItf->ADDCMD_MI_CONDITIONAL_BATCH_BUFFER_END(cmdBuffer);

return eStatus;
}

MOS_STATUS DecodeNullHWProxyTestPkt::Pack2ndLevelCmds(DecodePipeline* pipeline, MOS_COMMAND_BUFFER& cmdBuffer)
{
DECODE_FUNC_CALL();

// MI_ATOMIC: ADD 1 TO ORIGINAL DATA
auto &par = m_miItf->GETPAR_MI_ATOMIC();
par = {};
par.pOsResource = &m_dataStoreBuf->OsResource;
par.dwResourceOffset = sizeof(uint32_t);
par.dwDataSize = sizeof(uint32_t);
par.Operation = mhw::mi::MHW_MI_ATOMIC_INC;
DECODE_CHK_STATUS(m_miItf->ADDCMD_MI_ATOMIC(&cmdBuffer));

// check if loop stops
uint32_t compareOperation = 2; //COMPARE_OPERATION_MADLESSTHANIDD;
uint32_t compData = m_repeatCount;

DECODE_CHK_STATUS(SendCondBbEndCmd(
&m_dataStoreBuf->OsResource, 0, compData, false, true, compareOperation, &cmdBuffer));

// Chained BB loop
auto &chainedBBStartPar = m_miItf->GETPAR_MI_BATCH_BUFFER_START();
MOS_ZeroMemory(&chainedBBStartPar, sizeof(mhw::mi::MI_BATCH_BUFFER_START_PAR));
chainedBBStartPar.secondLevelBatchBuffer = false;
DECODE_CHK_STATUS(m_miItf->ADDCMD_MI_BATCH_BUFFER_START(&cmdBuffer, m_batchBuf));

return MOS_STATUS_SUCCESS;
}

MOS_STATUS DecodeNullHWProxyTestPkt::AddNullHwProxyCmd(DecodePipeline *pipeline, MOS_INTERFACE *osInterface, PMOS_COMMAND_BUFFER cmdBuffer)
{
DECODE_FUNC_CALL();

if (!m_isNullHWEnabled || m_repeatCount == 0)
{
return MOS_STATUS_SUCCESS;
}

DECODE_CHK_NULL(cmdBuffer);
DECODE_CHK_NULL(pipeline);
DECODE_CHK_NULL(osInterface);
DECODE_CHK_NULL(m_miItf);

// add 2nd level BB before start status reporting
auto &par = m_miItf->MHW_GETPAR_F(MI_STORE_DATA_IMM)();
par = {};
par.pOsResource = &m_dataStoreBuf->OsResource;
par.dwResourceOffset = 0;
par.dwValue = 0xFFFFFF;

DECODE_CHK_STATUS(m_miItf->MHW_ADDCMD_F(MI_STORE_DATA_IMM)(cmdBuffer));

// clear the data store buffer each time
par.dwResourceOffset = sizeof(uint32_t);
par.dwValue = 0;
DECODE_CHK_STATUS(m_miItf->MHW_ADDCMD_F(MI_STORE_DATA_IMM)(cmdBuffer));

// prepare 2nd level chained BB
m_batchBuf = m_secondLevelBBArray->Fetch();
if (m_batchBuf != nullptr)
{
ResourceAutoLock resLock(m_allocator, &m_batchBuf->OsResource);
uint8_t *batchBufBase = (uint8_t *)resLock.LockResourceForWrite();
DECODE_CHK_NULL(batchBufBase);
DECODE_CHK_STATUS(Init2ndLevelCmdBuffer(*m_batchBuf, batchBufBase));
m_statusCheckCmdBuffer.cmdBuf1stLvl = cmdBuffer;
DECODE_CHK_STATUS(Pack2ndLevelCmds(pipeline, m_statusCheckCmdBuffer));
if (!osInterface->pfnIsMismatchOrderProgrammingSupported())
{
DECODE_CHK_STATUS(m_miItf->AddMiBatchBufferEnd(&m_statusCheckCmdBuffer, nullptr));
}
}

auto &BBStartPar = m_miItf->GETPAR_MI_BATCH_BUFFER_START();
MOS_ZeroMemory(&BBStartPar, sizeof(mhw::mi::MI_BATCH_BUFFER_START_PAR));
BBStartPar.secondLevelBatchBuffer = true; // set chained BB mode
DECODE_CHK_STATUS(m_miItf->ADDCMD_MI_BATCH_BUFFER_START(cmdBuffer, m_batchBuf));

return MOS_STATUS_SUCCESS;
}
#endif
}
Loading

0 comments on commit 5921165

Please sign in to comment.