Skip to content

Commit

Permalink
[Decode] This enables HW AV1 decode acceleration on Gen12
Browse files Browse the repository at this point in the history
This enables HW AV1 decode acceleration on Gen12.



Change-Id: I0c2014377527683cde6201a7e3efeb628159a779
  • Loading branch information
ZefuLI authored and hanlong1 committed Jul 9, 2020
1 parent 129d8b6 commit 9491998
Show file tree
Hide file tree
Showing 172 changed files with 33,984 additions and 48 deletions.
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/codec/shared/codec_def_decode.h
Expand Up @@ -130,9 +130,9 @@ struct CodechalDecodeParams
//! \brief Parameters used for processing the decode render target, if invalid, decode render target processing will not be used.
void *m_procParams = nullptr;
#endif

//! \brief Parameters used for codec frame processing
CodecProcessingParams m_codecProcParams;
CodecProcessingParams m_codecProcParams;

//! \brief [Predication] Resource for predication
PMOS_RESOURCE m_presPredication = nullptr;
Expand Down
Expand Up @@ -77,7 +77,8 @@ class MhwInterfaces
uint32_t m_huc : 1;
uint32_t m_vdenc : 1;
uint32_t m_blt : 1;
uint32_t m_reserved : 22;
uint32_t m_avp : 1;
uint32_t m_reserved : 21;
};
uint32_t m_value;
} Flags;
Expand Down
108 changes: 106 additions & 2 deletions media_driver/agnostic/gen12/codec/hal/codechal_hw_g12_X.cpp
Expand Up @@ -114,8 +114,7 @@ CodechalHwInterfaceG12::CodechalHwInterfaceG12(
{
CODECHAL_HW_FUNCTION_ENTER;

PLATFORM platform;
osInterface->pfnGetPlatform(osInterface, &platform);
m_avpInterface = static_cast<MhwInterfacesG12Tgllp*>(mhwInterfaces)->m_avpInterface;

InitCacheabilityControlSettings(codecFunction);

Expand Down Expand Up @@ -256,10 +255,109 @@ MOS_STATUS CodechalHwInterfaceG12::SetCacheabilitySettings(
{
CODECHAL_HW_CHK_STATUS_RETURN(m_vdencInterface->SetCacheabilitySettings(cacheabilitySettings));
}
if (m_avpInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_avpInterface->SetCacheabilitySettings(cacheabilitySettings));
}

return eStatus;
}

MOS_STATUS CodechalHwInterfaceG12::SetRowstoreCachingOffsets(
PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;

CODECHAL_HW_FUNCTION_ENTER;

CODECHAL_HW_CHK_STATUS_RETURN(CodechalHwInterface::SetRowstoreCachingOffsets(rowstoreParams));

if (m_avpInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_avpInterface->GetRowstoreCachingAddrs(rowstoreParams));
}

return eStatus;
}

MOS_STATUS CodechalHwInterfaceG12::GetAvpStateCommandSize(
uint32_t mode,
uint32_t *commandsSize,
uint32_t *patchListSize,
PMHW_VDBOX_STATE_CMDSIZE_PARAMS params)
{
CODECHAL_HW_FUNCTION_ENTER;

//calculate AVP related commands size
uint32_t avpCommandsSize = 0;
uint32_t avpPatchListSize = 0;

if (m_avpInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_avpInterface->GetAvpStateCommandSize(
(uint32_t *)&avpCommandsSize,
(uint32_t *)&avpPatchListSize,
params));
}

//calculate HUC related command size
uint32_t hucCommandsSize = 0;
uint32_t hucPatchListSize = 0;

if (m_hucInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_hucInterface->GetHucStateCommandSize(
mode,
(uint32_t*)&hucCommandsSize,
(uint32_t*)&hucPatchListSize,
params));
}

//Calc final command size
*commandsSize = avpCommandsSize + hucCommandsSize * 4;
*patchListSize = avpPatchListSize + hucPatchListSize * 4;

return MOS_STATUS_SUCCESS;
}

MOS_STATUS CodechalHwInterfaceG12::GetAvpPrimitiveCommandSize(
uint32_t mode,
uint32_t *commandsSize,
uint32_t *patchListSize)
{
CODECHAL_HW_FUNCTION_ENTER;

//calculate AVP related commands size
uint32_t avpCommandsSize = 0;
uint32_t avpPatchListSize = 0;

if (m_avpInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_avpInterface->GetAvpPrimitiveCommandSize(
(uint32_t*)&avpCommandsSize,
(uint32_t*)&avpPatchListSize));
}

//calculate HUC related command size
uint32_t hucCommandsSize = 0;
uint32_t hucPatchListSize = 0;

if (m_hucInterface)
{
CODECHAL_HW_CHK_STATUS_RETURN(m_hucInterface->GetHucPrimitiveCommandSize(
mode,
(uint32_t*)&hucCommandsSize,
(uint32_t*)&hucPatchListSize));
}

//Calc final command size
*commandsSize = avpCommandsSize + hucCommandsSize;
*patchListSize = avpPatchListSize + hucPatchListSize;

return MOS_STATUS_SUCCESS;
}


MOS_STATUS CodechalHwInterfaceG12::SendCondBbEndCmd(
PMOS_RESOURCE resource,
uint32_t offset,
Expand Down Expand Up @@ -346,4 +444,10 @@ CodechalHwInterfaceG12::~CodechalHwInterfaceG12()
MOS_FreeMemory(m_renderHal);
m_renderHal = nullptr;
}

if (m_avpInterface)
{
MOS_Delete(m_avpInterface);
m_avpInterface = nullptr;
}
}
78 changes: 77 additions & 1 deletion media_driver/agnostic/gen12/codec/hal/codechal_hw_g12_X.h
Expand Up @@ -21,14 +21,26 @@
*/
//!
//! \file codechal_hw_g12_X.h
//! \brief This modules implements HW interface layer to be used on Gen12 platforms on all operating systems/DDIs, across CODECHAL components.
//! \brief This modules implements HW interface layer to be used on Gen12 platforms on all operating systems/DDIs, across CODECHAL components.
//!
#ifndef __CODECHAL_HW_G12_X_H__
#define __CODECHAL_HW_G12_X_H__

#include "codechal_hw.h"
#include "mhw_mi_hwcmd_g12_X.h"
#include "mhw_render_hwcmd_g12_X.h"
#include "mhw_vdbox_avp_interface.h"

//!
//! \enum MediaStatesAv1FilmGrain
//!
enum
{
CODECHAl_MEDIA_STATE_AV1_FILM_GRAIN_GRV = CODECHAL_MEDIA_STATE_SW_SCOREBOARD_INIT + 1,
CODECHAl_MEDIA_STATE_AV1_FILM_GRAIN_RP1,
CODECHAl_MEDIA_STATE_AV1_FILM_GRAIN_RP2,
CODECHAl_MEDIA_STATE_AV1_FILM_GRAIN_AN,
}; //Please merge to CODECHAL_MEDIA_STATE_TYPE

#define CODECHAL_NUM_MEDIA_STATES_G12 (CODECHAL_NUM_MEDIA_STATES + 4)

Expand All @@ -41,6 +53,8 @@ class CodechalHwInterfaceG12 : public CodechalHwInterface
protected:
static const CODECHAL_SSEU_SETTING m_defaultSsEuLutG12[CODECHAL_NUM_MEDIA_STATES_G12];

MhwVdboxAvpInterface *m_avpInterface = nullptr; //!< Pointer to Mhw avp interface

public:
//!
//! \brief Constructor
Expand Down Expand Up @@ -83,6 +97,68 @@ class CodechalHwInterfaceG12 : public CodechalHwInterface
MOS_STATUS SetCacheabilitySettings(
MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC]) override;

//!
//! \brief Get avp interface
//! \details Get avp interface in codechal hw interface
//!
//! \return [out] MhwVdboxAvpInterface*
//! Interface got.
//!
inline MhwVdboxAvpInterface* GetAvpInterface()
{
return m_avpInterface;
}

//!
//! \brief Calculates the maximum size for AVP picture level commands
//! \details Client facing function to calculate the maximum size for AVP picture level commands
//! \param [in] mode
//! Indicate the codec mode
//! \param [out] commandsSize
//! The maximum command buffer size
//! \param [out] patchListSize
//! The maximum command patch list size
//! \param [in] params
//! Indicate the command size parameters
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS GetAvpStateCommandSize(
uint32_t mode,
uint32_t *commandsSize,
uint32_t *patchListSize,
PMHW_VDBOX_STATE_CMDSIZE_PARAMS params);

//!
//! \brief Calculates maximum size for AVP tile level commands
//! \details Client facing function to calculate maximum size for AVP tile level commands
//! \param [in] mode
//! Indicate the codec mode
//! \param [out] commandsSize
//! The maximum command buffer size
//! \param [out] patchListSize
//! The maximum command patch list size
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS GetAvpPrimitiveCommandSize(
uint32_t mode,
uint32_t *commandsSize,
uint32_t *patchListSize);

//!
//! \brief Set Rowstore Cache offsets for Gen12 specific interfaces
//! \details Set Rowstore Cache offsets in sub interfaces in codechal hw G12 interface
//!
//! \param [in] rowstoreParams
//! parameters to set rowstore cache offsets
//!
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS SetRowstoreCachingOffsets(
PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) override;

//!
//! \brief Send conditional batch buffer end cmd
//! \details Send conditional batch buffer end cmd
Expand Down

0 comments on commit 9491998

Please sign in to comment.