Skip to content

Commit

Permalink
[VP] Refactor VpRenderKernelObj
Browse files Browse the repository at this point in the history
Make one BTI map to one SurfType instead of one SurfType map to one BTI. One SurfType can map to multiple BTI.
  • Loading branch information
peiyigu-intel authored and intel-mediadev committed Nov 7, 2023
1 parent e5d9401 commit e81fe19
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
{
KERNEL_SURFACE_STATE_PARAM *kernelSurfaceParam = &surface->second;
SurfaceType type = surface->first;
auto bindingMap = m_kernel->GetSurfaceBindingIndex(type);

RENDERHAL_SURFACE_NEXT renderHalSurface;
MOS_ZeroMemory(&renderHalSurface, sizeof(RENDERHAL_SURFACE_NEXT));
Expand Down Expand Up @@ -741,29 +742,44 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()

if (kernelSurfaceParam->surfaceOverwriteParams.bindedKernel && !kernelSurfaceParam->surfaceOverwriteParams.bufferResource)
{
VP_RENDER_CHK_STATUS_RETURN(SetSurfaceForHwAccess(
&renderHalSurface.OsSurface,
&renderHalSurface,
&renderSurfaceParams,
kernelSurfaceParam->surfaceOverwriteParams.bindIndex,
bWrite,
kernelSurfaceParam->surfaceEntries,
kernelSurfaceParam->sizeOfSurfaceEntries));

index = kernelSurfaceParam->surfaceOverwriteParams.bindIndex;
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
}
for (uint32_t bti : bindingMap)
{
VP_RENDER_CHK_STATUS_RETURN(SetSurfaceForHwAccess(
&renderHalSurface.OsSurface,
&renderHalSurface,
&renderSurfaceParams,
bti,
bWrite,
kernelSurfaceParam->surfaceEntries,
kernelSurfaceParam->sizeOfSurfaceEntries));
index = bti;
VP_RENDER_NORMALMESSAGE("Using Binded Index Surface. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, index);
}
}
else
{
if ((kernelSurfaceParam->surfaceOverwriteParams.updatedSurfaceParams &&
kernelSurfaceParam->surfaceOverwriteParams.bufferResource &&
kernelSurfaceParam->surfaceOverwriteParams.bindedKernel))
{
index = SetBufferForHwAccess(
&renderHalSurface.OsSurface,
&renderHalSurface,
&renderSurfaceParams,
kernelSurfaceParam->surfaceOverwriteParams.bindIndex,
bWrite);
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
}
for (uint32_t bti : bindingMap)
{
index = SetBufferForHwAccess(
&renderHalSurface.OsSurface,
&renderHalSurface,
&renderSurfaceParams,
bti,
bWrite);
VP_RENDER_NORMALMESSAGE("Using Binded Index Buffer. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, index);
}
}
else if ((kernelSurfaceParam->surfaceOverwriteParams.updatedSurfaceParams &&
kernelSurfaceParam->surfaceOverwriteParams.bufferResource &&
Expand All @@ -777,18 +793,20 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
&renderHalSurface,
&renderSurfaceParams,
bWrite);
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCurbeBindingIndex(type, index));
VP_RENDER_NORMALMESSAGE("Using UnBinded Index Buffer. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, index);
}
else
{
VP_RENDER_NORMALMESSAGE("If 1D buffer overwrite to 2D for use, it will go SetSurfaceForHwAccess()");
index = SetSurfaceForHwAccess(
&renderHalSurface.OsSurface,
&renderHalSurface,
&renderSurfaceParams,
bWrite);
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCurbeBindingIndex(type, index));
VP_RENDER_NORMALMESSAGE("Using UnBinded Index Surface. KernelID %d, SurfType %d, bti %d. If 1D buffer overwrite to 2D for use, it will go SetSurfaceForHwAccess()", m_kernel->GetKernelId(), type, index);
}
}
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCurbeBindingIndex(type, index));
}
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCompParams());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ MOS_STATUS VpRenderFcKernel::SetupSurfaceState()
VP_COMPOSITE_PARAMS &compParams = m_fcParams->compParams;

m_surfaceState.clear();
m_surfaceBindingIndex.clear();

for (i = 0; i < compParams.sourceCount; ++i)
{
Expand Down Expand Up @@ -305,7 +306,7 @@ MOS_STATUS VpRenderFcKernel::SetupSurfaceState()
}
}

surfParam.surfaceOverwriteParams.bindIndex = s_bindingTableIndex[layer->layerID];
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeFcInputLayer0 + layer->layerID), s_bindingTableIndex[layer->layerID]);

SetSurfaceParams(surfParam, *layer, false);
surfParam.surfaceOverwriteParams.renderSurfaceParams.bChromasiting = layer->calculatedParams.chromaSitingEnabled;
Expand All @@ -329,7 +330,7 @@ MOS_STATUS VpRenderFcKernel::SetupSurfaceState()
surfParamField.surfaceOverwriteParams.renderSurfaceParams.bVertStrideOffs = true;
}

surfParamField.surfaceOverwriteParams.bindIndex = s_bindingTableIndexField[layer->layerID];
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeFcInputLayer0Field1Dual + layer->layerID), s_bindingTableIndexField[layer->layerID]);
m_surfaceState.insert(std::make_pair(SurfaceType(SurfaceTypeFcInputLayer0Field1Dual + layer->layerID), surfParamField));

//update render GMM resource usage type
Expand Down Expand Up @@ -367,11 +368,11 @@ MOS_STATUS VpRenderFcKernel::SetupSurfaceState()
surfParam.surfaceOverwriteParams.bindedKernel = true;
if (compParams.targetCount > 1 && 0 == i)
{
surfParam.surfaceOverwriteParams.bindIndex = VP_COMP_BTINDEX_RT_SECOND;
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeFcTarget0 + i), VP_COMP_BTINDEX_RT_SECOND);
}
else
{
surfParam.surfaceOverwriteParams.bindIndex = VP_COMP_BTINDEX_RENDERTARGET;
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeFcTarget0 + i), VP_COMP_BTINDEX_RENDERTARGET);
}

SetSurfaceParams(surfParam, compParams.target[i], is32MWColorFillKern);
Expand Down Expand Up @@ -401,7 +402,7 @@ MOS_STATUS VpRenderFcKernel::SetupSurfaceState()
surfParam.surfaceOverwriteParams.updatedSurfaceParams = true;
// Only need to specify binding index in surface parameters.
surfParam.surfaceOverwriteParams.bindedKernel = true;
surfParam.surfaceOverwriteParams.bindIndex = VP_COMP_BTINDEX_CSC_COEFF;
UpdateCurbeBindingIndex(SurfaceTypeFcCscCoeff, VP_COMP_BTINDEX_CSC_COEFF);

surfParam.surfaceOverwriteParams.updatedRenderSurfaces = true;
surfParam.surfaceOverwriteParams.renderSurfaceParams.Type = RENDERHAL_SURFACE_TYPE_G10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3404,6 +3404,7 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()
VP_RENDER_CHK_NULL_RETURN(m_hwInterface);
VP_RENDER_CHK_NULL_RETURN(m_hwInterface->m_renderHal);
renderHal = m_hwInterface->m_renderHal;
m_surfaceBindingIndex.clear();

UpdatePerLayerPipelineStates(&dwUpdateMask);

Expand All @@ -3418,7 +3419,7 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()
surfParam.surfaceOverwriteParams.updatedSurfaceParams = true;
surfParam.surfaceOverwriteParams.bindedKernel = true;

surfParam.surfaceOverwriteParams.bindIndex = m_hdrParams->uSourceBindingTableIndex[i];
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeHdrInputLayer0 + i), m_hdrParams->uSourceBindingTableIndex[i]);
iBTentry = m_hdrParams->uSourceBindingTableIndex[i];

SetSurfaceParams(surfParam, layer, false);
Expand Down Expand Up @@ -3459,13 +3460,13 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()
if (m_hdrParams->LUTMode[i] == VPHAL_HDR_LUT_MODE_2D)
{
surfaceResource.surfaceOverwriteParams.renderSurfaceParams.MemObjCtl = m_surfMemCacheCtl.Lut2DSurfMemObjCtl;
surfaceResource.surfaceOverwriteParams.bindIndex = iBTentry + VPHAL_HDR_BTINDEX_OETF1DLUT_OFFSET;
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeHdrOETF1DLUTSurface0 + i), iBTentry + VPHAL_HDR_BTINDEX_OETF1DLUT_OFFSET);
m_surfaceState.insert(std::make_pair(SurfaceType(SurfaceTypeHdrOETF1DLUTSurface0 + i), surfaceResource));
}
else if (m_hdrParams->LUTMode[i] == VPHAL_HDR_LUT_MODE_3D)
{
surfaceResource.surfaceOverwriteParams.renderSurfaceParams.MemObjCtl = m_surfMemCacheCtl.Lut3DSurfMemObjCtl;
surfaceResource.surfaceOverwriteParams.bindIndex = iBTentry + VPHAL_HDR_BTINDEX_CRI3DLUT_OFFSET;
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeHdrCRI3DLUTSurface0 + i), iBTentry + VPHAL_HDR_BTINDEX_CRI3DLUT_OFFSET);
surfaceResource.surfaceOverwriteParams.renderSurfaceParams.bWidthInDword_Y = false;
surfaceResource.surfaceOverwriteParams.renderSurfaceParams.bWidthInDword_UV = false;
m_surfaceState.insert(std::make_pair(SurfaceType(SurfaceTypeHdrCRI3DLUTSurface0 + i), surfaceResource));
Expand All @@ -3480,7 +3481,7 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()

// Only need to specify binding index in surface parameters.
surfParam.surfaceOverwriteParams.bindedKernel = true;
surfParam.surfaceOverwriteParams.bindIndex = m_hdrParams->uTargetBindingTableIndex[i];
UpdateCurbeBindingIndex(SurfaceType(SurfaceTypeHdrTarget0 + i), m_hdrParams->uTargetBindingTableIndex[i]);

iBTentry = m_hdrParams->uTargetBindingTableIndex[i];
auto outputSrc = m_surfaceGroup->find(SurfaceTypeHdrTarget0);
Expand Down Expand Up @@ -3526,7 +3527,6 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()
surfCoeffParam.surfaceOverwriteParams.updatedSurfaceParams = true;
// Only need to specify binding index in surface parameters.
surfCoeffParam.surfaceOverwriteParams.bindedKernel = true;
surfCoeffParam.surfaceOverwriteParams.bindIndex = VPHAL_HDR_BTINDEX_COEFF;

surfCoeffParam.surfaceOverwriteParams.updatedRenderSurfaces = true;
surfCoeffParam.surfaceOverwriteParams.renderSurfaceParams.Type = RENDERHAL_SURFACE_TYPE_G10;
Expand All @@ -3537,10 +3537,12 @@ MOS_STATUS VpRenderHdrKernel::SetupSurfaceState()

if (m_hdrParams->bUsingAutoModePipe && bHasAutoModeLayer)
{
UpdateCurbeBindingIndex(SurfaceTypeHdrAutoModeCoeff, VPHAL_HDR_BTINDEX_COEFF);
m_surfaceState.insert(std::make_pair(SurfaceTypeHdrAutoModeCoeff, surfCoeffParam));
}
else
{
UpdateCurbeBindingIndex(SurfaceTypeHdrCoeff, VPHAL_HDR_BTINDEX_COEFF);
m_surfaceState.insert(std::make_pair(SurfaceTypeHdrCoeff, surfCoeffParam));
}

Expand Down
22 changes: 11 additions & 11 deletions media_softlet/agnostic/common/vp/hal/packet/vp_render_kernel_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "vp_platform_interface.h"
#include <vector>
#include <map>
#include <set>

class RenderCmdPacket;

Expand Down Expand Up @@ -62,7 +63,6 @@ typedef struct _KERNEL_SURFACE_STATE_PARAM
MOS_TILE_TYPE tileType;
bool bufferResource;
bool bindedKernel; // true if bind index is hardcoded by bindIndex.
uint32_t bindIndex;
bool updatedRenderSurfaces; // true if renderSurfaceParams be used.
RENDERHAL_SURFACE_STATE_PARAMS renderSurfaceParams; // default can be skip. for future usages, if surface configed by kernel, use it directlly
} surfaceOverwriteParams;
Expand All @@ -78,7 +78,7 @@ using KERNEL_SAMPLER_STATE_GROUP = std::map<SamplerIndex, MHW_SAMPLER_STATE_PARA
using KERNEL_SAMPLER_STATES = std::vector<MHW_SAMPLER_STATE_PARAM>;
using KERNEL_SAMPLER_INDEX = std::vector<SamplerIndex>;
using KERNEL_SURFACE_CONFIG = std::map<SurfaceType, KERNEL_SURFACE_STATE_PARAM>;
using KERNEL_SURFACE_BINDING_INDEX = std::map<SurfaceType, uint32_t>;
using KERNEL_SURFACE_BINDING_INDEX = std::map<SurfaceType, std::set<uint32_t>>;

typedef struct _KERNEL_PARAMS
{
Expand Down Expand Up @@ -441,29 +441,29 @@ class VpRenderKernelObj
auto it = m_surfaceBindingIndex.find(surface);
if (it != m_surfaceBindingIndex.end())
{
it->second = index;
it->second.insert(index);
}
else
{
m_surfaceBindingIndex.insert(std::make_pair(surface, index));
std::set<uint32_t> bindingMap;
bindingMap.insert(index);
m_surfaceBindingIndex.insert(std::make_pair(surface, bindingMap));
}

return MOS_STATUS_SUCCESS;
}

uint32_t GetSurfaceBindingIndex(SurfaceType surface)
std::set<uint32_t>& GetSurfaceBindingIndex(SurfaceType surface)
{
auto it = m_surfaceBindingIndex.find(surface);

if (it != m_surfaceBindingIndex.end())
{
return it->second;
}
else
if (it == m_surfaceBindingIndex.end())
{
VP_RENDER_ASSERTMESSAGE("No surface index created for current surface");
return 0;
std::set<uint32_t> bindingMap;
it = m_surfaceBindingIndex.insert(std::make_pair(surface, bindingMap)).first;
}
return it->second;
}

MOS_STATUS InitKernel(void* binary, uint32_t size, KERNEL_CONFIGS& kernelConfigs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,18 @@ MOS_STATUS VpRenderHdr3DLutKernel::SetupSurfaceState()

PRENDERHAL_INTERFACE renderHal = m_hwInterface->m_renderHal;
PMOS_INTERFACE osInterface = m_hwInterface->m_osInterface;
m_surfaceBindingIndex.clear();

KERNEL_SURFACE_STATE_PARAM kernelSurfaceParam = {};
// Only need to specify binding index in surface parameters.
kernelSurfaceParam.surfaceOverwriteParams.updatedSurfaceParams = true;
kernelSurfaceParam.surfaceOverwriteParams.bindedKernel = true;
kernelSurfaceParam.surfaceOverwriteParams.bufferResource = true;

kernelSurfaceParam.surfaceOverwriteParams.bindIndex = BI_VEBOX_HDR_3DLUT_3DLUT;
UpdateCurbeBindingIndex(SurfaceType3DLut, BI_VEBOX_HDR_3DLUT_3DLUT);
kernelSurfaceParam.isOutput = true;
m_surfaceState.insert(std::make_pair(SurfaceType3DLut, kernelSurfaceParam));
kernelSurfaceParam.surfaceOverwriteParams.bindIndex = BI_VEBOX_HDR_3DLUT_COEF;
UpdateCurbeBindingIndex(SurfaceType3DLutCoef, BI_VEBOX_HDR_3DLUT_COEF);
kernelSurfaceParam.isOutput = false;
m_surfaceState.insert(std::make_pair(SurfaceType3DLutCoef, kernelSurfaceParam));

Expand Down Expand Up @@ -287,12 +288,19 @@ MOS_STATUS VpRenderHdr3DLutKernel::GetCurbeState(void *&curbe, uint32_t &curbeLe
{
VP_FUNC_CALL();
// init the hdr 3dlut static data
auto bindingMap3DLut = GetSurfaceBindingIndex(SurfaceType3DLut);
auto bindingMapCoef = GetSurfaceBindingIndex(SurfaceType3DLutCoef);
if (bindingMap3DLut.empty() || bindingMapCoef.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
}

MOS_ZeroMemory(&m_curbe, sizeof(m_curbe));
m_curbe.DW00.Thread_Group_X = LUT65_SEG_SIZE;
m_curbe.DW01.Thread_Group_Y = LUT65_SEG_SIZE;
m_curbe.DW02.Thread_Group_Z = 1;
m_curbe.DW06.hdr3DLutSurface = GetSurfaceBindingIndex(SurfaceType3DLut);
m_curbe.DW07.hdrCoefSurface = GetSurfaceBindingIndex(SurfaceType3DLutCoef);
m_curbe.DW06.hdr3DLutSurface = *bindingMap3DLut.begin();
m_curbe.DW07.hdrCoefSurface = *bindingMapCoef.begin();
m_curbe.DW08.hdr3DLutSurfaceHeight = LUT65_SEG_SIZE * LUT65_MUL_SIZE;
m_curbe.DW08.hdr3DLutSurfaceWidth = LUT65_SEG_SIZE * 2;

Expand Down Expand Up @@ -530,12 +538,12 @@ MOS_STATUS VpRenderHdr3DLutKernelCM::GetCurbeState(void *&curbe, uint32_t &curbe
{
// Resource need be added.
uint32_t *pSurfaceindex = static_cast<uint32_t *>(arg.pData);
auto it = m_surfaceBindingIndex.find((SurfaceType)*pSurfaceindex);
if (it == m_surfaceBindingIndex.end())
auto bindingMap = GetSurfaceBindingIndex((SurfaceType)*pSurfaceindex);
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
}
*((uint32_t *)(data + arg.uOffsetInPayload)) = it->second;
*((uint32_t *)(data + arg.uOffsetInPayload)) = *bindingMap.begin();
}
else if (arg.eArgKind == ARG_KIND_GENERAL)
{
Expand All @@ -560,15 +568,16 @@ MOS_STATUS VpRenderHdr3DLutKernelCM::SetupSurfaceState()

PRENDERHAL_INTERFACE renderHal = m_hwInterface->m_renderHal;
PMOS_INTERFACE osInterface = m_hwInterface->m_osInterface;
m_surfaceBindingIndex.clear();

KERNEL_SURFACE_STATE_PARAM kernelSurfaceParam = {};
kernelSurfaceParam.surfaceOverwriteParams.bindedKernel = true;
kernelSurfaceParam.surfaceOverwriteParams.bufferResource = true;

kernelSurfaceParam.surfaceOverwriteParams.bindIndex = BI_VEBOX_HDR_3DLUT_3DLUT_CM;
UpdateCurbeBindingIndex(SurfaceType3DLut, BI_VEBOX_HDR_3DLUT_3DLUT_CM);
kernelSurfaceParam.isOutput = true;
m_surfaceState.insert(std::make_pair(SurfaceType3DLut, kernelSurfaceParam));
kernelSurfaceParam.surfaceOverwriteParams.bindIndex = BI_VEBOX_HDR_3DLUT_COEF_CM;
UpdateCurbeBindingIndex(SurfaceType3DLutCoef, BI_VEBOX_HDR_3DLUT_COEF_CM);
kernelSurfaceParam.isOutput = false;
m_surfaceState.insert(std::make_pair(SurfaceType3DLutCoef, kernelSurfaceParam));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ MOS_STATUS VpRenderHVSKernel::GetCurbeState(void *&curbe, uint32_t &curbeLength)
{
// Resource need be added.
uint32_t *pSurfaceindex = static_cast<uint32_t *>(arg.pData);
auto it = m_surfaceBindingIndex.find((SurfaceType)*pSurfaceindex);
if (it == m_surfaceBindingIndex.end())
auto bindingMap = GetSurfaceBindingIndex((SurfaceType)*pSurfaceindex);
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
}
*((uint32_t *)(data + arg.uOffsetInPayload)) = it->second;
*((uint32_t *)(data + arg.uOffsetInPayload)) = *bindingMap.begin();
}
else if (arg.eArgKind == ARG_KIND_GENERAL)
{
Expand All @@ -305,6 +305,7 @@ MOS_STATUS VpRenderHVSKernel::SetupSurfaceState()

PRENDERHAL_INTERFACE renderHal = m_hwInterface->m_renderHal;
PMOS_INTERFACE osInterface = m_hwInterface->m_osInterface;
m_surfaceBindingIndex.clear();

for (auto arg : m_kernelArgs)
{
Expand Down

0 comments on commit e81fe19

Please sign in to comment.