[VP] Enable Bindless Kernel

enable bindless features
This commit is contained in:
Gu_Peiyi 2025-05-15 22:00:15 +08:00 committed by intel-mediadev
parent 5252db968a
commit 2e050c1dde
18 changed files with 393 additions and 163 deletions

View File

@ -310,8 +310,6 @@ typedef struct _MHW_GPGPU_WALKER_PARAMS
MHW_EMIT_LOCAL_MODE emitLocal; MHW_EMIT_LOCAL_MODE emitLocal;
bool hasBarrier; bool hasBarrier;
PMHW_INLINE_DATA_PARAMS inlineDataParamBase;
uint32_t inlineDataParamSize;
uint32_t simdSize; uint32_t simdSize;

View File

@ -700,14 +700,6 @@ typedef enum _MHW_CHROMAKEY_MODE
MHW_CHROMAKEY_MODE_REPLACE_BLACK = 1 MHW_CHROMAKEY_MODE_REPLACE_BLACK = 1
} MHW_CHROMAKEY_MODE; } MHW_CHROMAKEY_MODE;
typedef struct _MHW_INLINE_DATA_PARAMS
{
uint32_t dwOffset;
uint32_t dwSize;
PMOS_RESOURCE resource;
bool isPtrType;
} MHW_INLINE_DATA_PARAMS, *PMHW_INLINE_DATA_PARAMS;
typedef struct _MHW_SAMPLER_STATE_UNORM_PARAM typedef struct _MHW_SAMPLER_STATE_UNORM_PARAM
{ {
MHW_SAMPLER_FILTER_MODE SamplerFilterMode; MHW_SAMPLER_FILTER_MODE SamplerFilterMode;

View File

@ -84,6 +84,8 @@ class XRenderHal_Platform_Interface;
#define MHW_RENDERHAL_CHK_NULL_RETURN(_ptr) \ #define MHW_RENDERHAL_CHK_NULL_RETURN(_ptr) \
MOS_CHK_NULL_RETURN(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr) MOS_CHK_NULL_RETURN(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, _ptr)
#define MHW_RENDERHAL_CHK_VALUE_RETURN(_value, _expect_value) \
MOS_CHK_STATUS_RETURN(MOS_COMPONENT_VP, MOS_VP_SUBCOMP_PUBLIC, ((_value) == (_expect_value)) ? MOS_STATUS_SUCCESS : MOS_STATUS_INVALID_PARAMETER)
#define MHW_RENDERHAL_UNUSED(x) \ #define MHW_RENDERHAL_UNUSED(x) \
MOS_UNUSED(x) MOS_UNUSED(x)
@ -1066,6 +1068,7 @@ typedef struct _RENDERHAL_SURFACE_STATE_ENTRY
uint16_t wUYOffset; // uint16_t wUYOffset; //
uint16_t wVXOffset; // (X,Y) offset V (AVS/ADI) uint16_t wVXOffset; // (X,Y) offset V (AVS/ADI)
uint16_t wVYOffset; // uint16_t wVYOffset; //
uint64_t stateGfxAddress; // Gfx Address of Surface State
} RENDERHAL_SURFACE_STATE_ENTRY, *PRENDERHAL_SURFACE_STATE_ENTRY; } RENDERHAL_SURFACE_STATE_ENTRY, *PRENDERHAL_SURFACE_STATE_ENTRY;
//! //!
@ -1385,6 +1388,7 @@ typedef struct _RENDERHAL_INTERFACE
MOS_STATUS (*pfnSendBindlessSurfaceStates) ( MOS_STATUS (*pfnSendBindlessSurfaceStates) (
PRENDERHAL_INTERFACE pRenderHal, PRENDERHAL_INTERFACE pRenderHal,
PMOS_COMMAND_BUFFER pCmdBuffer,
bool bNeedNullPatch); bool bNeedNullPatch);
MOS_STATUS (* pfnBindSurfaceState) ( MOS_STATUS (* pfnBindSurfaceState) (
@ -1484,7 +1488,7 @@ typedef struct _RENDERHAL_INTERFACE
int32_t iMediaID, int32_t iMediaID,
PMHW_SAMPLER_STATE_PARAM pSamplerParams, PMHW_SAMPLER_STATE_PARAM pSamplerParams,
int32_t iSamplers, int32_t iSamplers,
std::map<uint32_t, uint32_t> &samplerMap); std::map<uint32_t, uint64_t> &samplerMap);
int32_t (* pfnAllocateMediaID) ( int32_t (* pfnAllocateMediaID) (
PRENDERHAL_INTERFACE pRenderHal, PRENDERHAL_INTERFACE pRenderHal,

View File

@ -565,6 +565,13 @@ public:
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
}; };
virtual MOS_STATUS SendStateComputeMpde(
PRENDERHAL_INTERFACE pRenderHal,
PMOS_COMMAND_BUFFER pCmdBuffer)
{
return MOS_STATUS_SUCCESS;
}
virtual bool IsBindlessHeapInUse( virtual bool IsBindlessHeapInUse(
PRENDERHAL_INTERFACE pRenderHal) PRENDERHAL_INTERFACE pRenderHal)
{ {

View File

@ -75,6 +75,8 @@ public:
void RefreshSync(); void RefreshSync();
MOS_STATUS RegisterHeap();
MOS_STATUS DestroyHeap(); MOS_STATUS DestroyHeap();
MOS_STATUS AssignSurfaceState(); MOS_STATUS AssignSurfaceState();

View File

@ -179,7 +179,7 @@ MOS_STATUS RenderHal_SendSurfaces_PatchList(
if (pRenderHal->isBindlessHeapInUse) if (pRenderHal->isBindlessHeapInUse)
{ {
bool bNeedNullPatch = MEDIA_IS_SKU(pOsInterface->pfnGetSkuTable(pOsInterface), FtrMediaPatchless); bool bNeedNullPatch = MEDIA_IS_SKU(pOsInterface->pfnGetSkuTable(pOsInterface), FtrMediaPatchless);
MHW_RENDERHAL_CHK_STATUS_RETURN(pRenderHal->pfnSendBindlessSurfaceStates(pRenderHal, bNeedNullPatch)); MHW_RENDERHAL_CHK_STATUS_RETURN(pRenderHal->pfnSendBindlessSurfaceStates(pRenderHal, pCmdBuffer, bNeedNullPatch));
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }

View File

@ -64,8 +64,7 @@ struct MHW_VFE_SCOREBOARD
struct MHW_HEAPS_RESOURCE struct MHW_HEAPS_RESOURCE
{ {
PMOS_RESOURCE presInstructionBuffer = nullptr; PMOS_RESOURCE presInstructionBuffer = nullptr;
PMHW_INLINE_DATA_PARAMS inlineDataParamsBase = nullptr; uint64_t kernelStartGfxAddress = 0;
uint32_t inlineDataParamSize = 0;
}; };
enum MHW_VFE_SLICE_DISABLE enum MHW_VFE_SLICE_DISABLE

View File

@ -133,7 +133,8 @@ extern const RENDERHAL_SURFACE_STATE_ENTRY g_cInitSurfaceStateEntry =
0, // wUXOffset 0, // wUXOffset
0, // wUYOffset 0, // wUYOffset
0, // wVXOffset 0, // wVXOffset
0 // wVYOffset 0, // wVYOffset
0 // stateGfxAddress
}; };
const MHW_MEDIA_STATE_FLUSH_PARAM g_cRenderHal_InitMediaStateFlushParams = const MHW_MEDIA_STATE_FLUSH_PARAM g_cRenderHal_InitMediaStateFlushParams =
@ -3024,6 +3025,7 @@ MOS_STATUS RenderHal_AssignSurfaceState(
pStateHeap = pRenderHal->pStateHeap; pStateHeap = pRenderHal->pStateHeap;
uint8_t *pCurSurfaceState; uint8_t *pCurSurfaceState;
uint64_t stateGfxAddress = 0;
// Calculate the Offset to the Surface State // Calculate the Offset to the Surface State
MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal->pRenderHalPltInterface); MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal->pRenderHalPltInterface);
@ -3051,9 +3053,13 @@ MOS_STATUS RenderHal_AssignSurfaceState(
SURFACE_STATES_HEAP_OBJ *sufStateHeap = pStateHeap->surfaceStateMgr->m_surfStateHeap; SURFACE_STATES_HEAP_OBJ *sufStateHeap = pStateHeap->surfaceStateMgr->m_surfStateHeap;
MHW_RENDERHAL_CHK_NULL_RETURN(sufStateHeap); MHW_RENDERHAL_CHK_NULL_RETURN(sufStateHeap);
MHW_RENDERHAL_CHK_NULL_RETURN(sufStateHeap->pLockedOsResourceMem); MHW_RENDERHAL_CHK_NULL_RETURN(sufStateHeap->pLockedOsResourceMem);
MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal->pOsInterface);
MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal->pOsInterface->pfnGetResourceGfxAddress);
MHW_RENDERHAL_CHK_VALUE_RETURN(Mos_ResourceIsNull(&sufStateHeap->osResource), false);
dwOffset = sufStateHeap->uiCurState * sufStateHeap->uiInstanceSize; dwOffset = sufStateHeap->uiCurState * sufStateHeap->uiInstanceSize;
pCurSurfaceState =sufStateHeap->pLockedOsResourceMem + dwOffset; pCurSurfaceState =sufStateHeap->pLockedOsResourceMem + dwOffset;
pStateHeap->iCurrentSurfaceState = sufStateHeap->uiCurState; pStateHeap->iCurrentSurfaceState = sufStateHeap->uiCurState;
stateGfxAddress = pRenderHal->pOsInterface->pfnGetResourceGfxAddress(pRenderHal->pOsInterface, &sufStateHeap->osResource) + dwOffset;
MHW_RENDERHAL_CHK_STATUS_RETURN(pStateHeap->surfaceStateMgr->AssignUsedSurfaceState(pStateHeap->iCurrentSurfaceState)); MHW_RENDERHAL_CHK_STATUS_RETURN(pStateHeap->surfaceStateMgr->AssignUsedSurfaceState(pStateHeap->iCurrentSurfaceState));
// Obtain new surface entry and initialize // Obtain new surface entry and initialize
@ -3074,6 +3080,7 @@ MOS_STATUS RenderHal_AssignSurfaceState(
pSurfaceEntry->dwSurfStateOffset = (uint32_t)-1; // Each platform to setup pSurfaceEntry->dwSurfStateOffset = (uint32_t)-1; // Each platform to setup
pSurfaceEntry->pSurfaceState = pCurSurfaceState; pSurfaceEntry->pSurfaceState = pCurSurfaceState;
pSurfaceEntry->pSurface = (PMOS_SURFACE)MOS_AllocAndZeroMemory(sizeof(MOS_SURFACE)); pSurfaceEntry->pSurface = (PMOS_SURFACE)MOS_AllocAndZeroMemory(sizeof(MOS_SURFACE));
pSurfaceEntry->stateGfxAddress = stateGfxAddress;
if (pSurfaceEntry->pSurface == nullptr) if (pSurfaceEntry->pSurface == nullptr)
{ {
MHW_RENDERHAL_ASSERTMESSAGE("Allocating Surface failed!"); MHW_RENDERHAL_ASSERTMESSAGE("Allocating Surface failed!");
@ -5700,6 +5707,7 @@ MOS_STATUS RenderHal_AssignBindlessSurfaceStates(
MOS_STATUS RenderHal_SendSurfaces_Bindelss( MOS_STATUS RenderHal_SendSurfaces_Bindelss(
PRENDERHAL_INTERFACE pRenderHal, PRENDERHAL_INTERFACE pRenderHal,
PMOS_COMMAND_BUFFER pCmdBuffer,
bool bNeedNullPatch) bool bNeedNullPatch)
{ {
PRENDERHAL_STATE_HEAP pStateHeap = nullptr; PRENDERHAL_STATE_HEAP pStateHeap = nullptr;
@ -5722,6 +5730,7 @@ MOS_STATUS RenderHal_SendSurfaces_Bindelss(
return eStatus; return eStatus;
} }
MHW_CHK_STATUS_RETURN(pRenderHal->pStateHeap->surfaceStateMgr->RegisterHeap());
for (uint32_t i = 0; i < pStateHeap->surfaceStateMgr->m_usedStates.size(); i++) for (uint32_t i = 0; i < pStateHeap->surfaceStateMgr->m_usedStates.size(); i++)
{ {
uint32_t index = pStateHeap->surfaceStateMgr->m_usedStates[i]; uint32_t index = pStateHeap->surfaceStateMgr->m_usedStates[i];
@ -5733,7 +5742,7 @@ MOS_STATUS RenderHal_SendSurfaces_Bindelss(
SendSurfaceParams.pSurfaceToken = (uint8_t *)&pStateHeap->pSurfaceEntry[index].SurfaceToken; SendSurfaceParams.pSurfaceToken = (uint8_t *)&pStateHeap->pSurfaceEntry[index].SurfaceToken;
SendSurfaceParams.pSurfaceStateSource = (uint8_t *)pStateHeap->pSurfaceEntry[index].pSurfaceState; SendSurfaceParams.pSurfaceStateSource = (uint8_t *)pStateHeap->pSurfaceEntry[index].pSurfaceState;
SendSurfaceParams.iSurfaceStateOffset = index * pStateHeap->surfaceStateMgr->m_surfStateHeap->uiInstanceSize; SendSurfaceParams.iSurfaceStateOffset = index * pStateHeap->surfaceStateMgr->m_surfStateHeap->uiInstanceSize;
pRenderHal->pfnSendSurfaceStateEntry(pRenderHal, nullptr, &SendSurfaceParams); pRenderHal->pfnSendSurfaceStateEntry(pRenderHal, pCmdBuffer, &SendSurfaceParams);
} }
return eStatus; return eStatus;
@ -6729,7 +6738,7 @@ MOS_STATUS RenderHal_SetAndGetSamplerStates(
int32_t iMediaID, int32_t iMediaID,
PMHW_SAMPLER_STATE_PARAM pSamplerParams, PMHW_SAMPLER_STATE_PARAM pSamplerParams,
int32_t iSamplers, int32_t iSamplers,
std::map<uint32_t, uint32_t> &samplerMap) std::map<uint32_t, uint64_t> &samplerMap)
{ {
MOS_STATUS eStatus; MOS_STATUS eStatus;
PRENDERHAL_STATE_HEAP pStateHeap; PRENDERHAL_STATE_HEAP pStateHeap;
@ -6738,7 +6747,7 @@ MOS_STATUS RenderHal_SetAndGetSamplerStates(
int32_t iOffsetSampler; int32_t iOffsetSampler;
uint8_t *pPtrSampler; uint8_t *pPtrSampler;
int32_t i; int32_t i;
uint32_t stateOffsets = 0; uint64_t stateGfxAddress = 0;
eStatus = MOS_STATUS_UNKNOWN; eStatus = MOS_STATUS_UNKNOWN;
@ -6793,7 +6802,9 @@ MOS_STATUS RenderHal_SetAndGetSamplerStates(
switch (pSamplerStateParams->SamplerType) switch (pSamplerStateParams->SamplerType)
{ {
case MHW_SAMPLER_TYPE_3D: case MHW_SAMPLER_TYPE_3D:
stateOffsets = iOffsetSampler + i * pRenderHal->pHwSizes->dwSizeSamplerState; MHW_RENDERHAL_CHK_VALUE_RETURN(Mos_ResourceIsNull(&pStateHeap->GshOsResource), false);
stateGfxAddress = pRenderHal->pOsInterface->pfnGetResourceGfxAddress(pRenderHal->pOsInterface, &pStateHeap->GshOsResource) + iOffsetSampler;
stateGfxAddress += (pRenderHal->pHwSizes->dwSizeSamplerState * i);
eStatus = pRenderHal->pMhwStateHeap->SetSamplerState(pPtrSampler, pSamplerStateParams); eStatus = pRenderHal->pMhwStateHeap->SetSamplerState(pPtrSampler, pSamplerStateParams);
break; break;
default: default:
@ -6802,7 +6813,7 @@ MOS_STATUS RenderHal_SetAndGetSamplerStates(
break; break;
} }
samplerMap.emplace(i, stateOffsets); samplerMap.insert(std::make_pair(i, stateGfxAddress));
if (MOS_FAILED(eStatus)) if (MOS_FAILED(eStatus))
{ {

View File

@ -126,6 +126,18 @@ MOS_STATUS SurfaceStateHeapManager::DestroyHeap()
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
MOS_STATUS SurfaceStateHeapManager::RegisterHeap()
{
MHW_CHK_NULL_RETURN(m_osInterface);
if (Mos_ResourceIsNull(&m_surfStateHeap->osResource))
{
MHW_CHK_STATUS_RETURN(MOS_STATUS_NULL_POINTER);
}
MHW_CHK_STATUS_RETURN(m_osInterface->pfnRegisterResource(m_osInterface, &m_surfStateHeap->osResource, false, true));
return MOS_STATUS_SUCCESS;
}
void SurfaceStateHeapManager::RefreshSync() void SurfaceStateHeapManager::RefreshSync()
{ {
SURFACE_STATES_OBJ *pCurInstance; SURFACE_STATES_OBJ *pCurInstance;

View File

@ -481,7 +481,7 @@ uint32_t RenderCmdPacket::SetSurfaceForHwAccess(
PRENDERHAL_SURFACE_NEXT pRenderSurface, PRENDERHAL_SURFACE_NEXT pRenderSurface,
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets) std::vector<uint64_t> &stateGfxAddress)
{ {
PMOS_INTERFACE pOsInterface; PMOS_INTERFACE pOsInterface;
PRENDERHAL_SURFACE_STATE_ENTRY pSurfaceEntries[MHW_MAX_SURFACE_PLANES]; PRENDERHAL_SURFACE_STATE_ENTRY pSurfaceEntries[MHW_MAX_SURFACE_PLANES];
@ -580,7 +580,7 @@ uint32_t RenderCmdPacket::SetSurfaceForHwAccess(
{ {
for (i = 0; i < iSurfaceEntries; i++) for (i = 0; i < iSurfaceEntries; i++)
{ {
stateOffsets.insert(pSurfaceEntries[i]->dwSurfStateOffset); stateGfxAddress.push_back(pSurfaceEntries[i]->stateGfxAddress);
} }
} }
@ -694,7 +694,7 @@ MOS_STATUS RenderCmdPacket::SetSurfaceForHwAccess(
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
std::set<uint32_t> &bindingIndexes, std::set<uint32_t> &bindingIndexes,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets, std::vector<uint64_t> &stateGfxAddress,
uint32_t capcityOfSurfaceEntries, uint32_t capcityOfSurfaceEntries,
PRENDERHAL_SURFACE_STATE_ENTRY *surfaceEntries, PRENDERHAL_SURFACE_STATE_ENTRY *surfaceEntries,
uint32_t *numOfSurfaceEntries) uint32_t *numOfSurfaceEntries)
@ -795,7 +795,7 @@ MOS_STATUS RenderCmdPacket::SetSurfaceForHwAccess(
{ {
for (i = 0; i < iSurfaceEntries; i++) for (i = 0; i < iSurfaceEntries; i++)
{ {
stateOffsets.insert(pSurfaceEntries[i]->dwSurfStateOffset); stateGfxAddress.push_back(pSurfaceEntries[i]->stateGfxAddress);
} }
} }
@ -813,7 +813,7 @@ uint32_t RenderCmdPacket::SetBufferForHwAccess(
PRENDERHAL_SURFACE_NEXT pRenderSurface, PRENDERHAL_SURFACE_NEXT pRenderSurface,
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets) std::vector<uint64_t> &stateGfxAddress)
{ {
RENDERHAL_SURFACE RenderHalSurface; RENDERHAL_SURFACE RenderHalSurface;
RENDERHAL_SURFACE_STATE_PARAMS SurfaceParam; RENDERHAL_SURFACE_STATE_PARAMS SurfaceParam;
@ -869,7 +869,7 @@ uint32_t RenderCmdPacket::SetBufferForHwAccess(
} }
else else
{ {
stateOffsets.insert(pSurfaceEntry->dwSurfStateOffset); stateGfxAddress.push_back(pSurfaceEntry->stateGfxAddress);
} }
return pRenderSurface->Index; return pRenderSurface->Index;
} }
@ -936,7 +936,7 @@ MOS_STATUS RenderCmdPacket::SetBufferForHwAccess(
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
std::set<uint32_t> &bindingIndexes, std::set<uint32_t> &bindingIndexes,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets) std::vector<uint64_t> &stateGfxAddress)
{ {
RENDERHAL_SURFACE RenderHalSurface = {}; RENDERHAL_SURFACE RenderHalSurface = {};
RENDERHAL_SURFACE_STATE_PARAMS SurfaceParam = {}; RENDERHAL_SURFACE_STATE_PARAMS SurfaceParam = {};
@ -998,7 +998,7 @@ MOS_STATUS RenderCmdPacket::SetBufferForHwAccess(
} }
else else
{ {
stateOffsets.insert(pSurfaceEntry->dwSurfStateOffset); stateGfxAddress.push_back(pSurfaceEntry->stateGfxAddress);
} }
return eStatus; return eStatus;
@ -1265,8 +1265,6 @@ MOS_STATUS RenderCmdPacket::PrepareComputeWalkerParams(KERNEL_WALKER_PARAMS para
gpgpuWalker.SLMSize = params.slmSize; gpgpuWalker.SLMSize = params.slmSize;
gpgpuWalker.hasBarrier = params.hasBarrier; gpgpuWalker.hasBarrier = params.hasBarrier;
gpgpuWalker.inlineDataParamBase = params.inlineDataParamBase;
gpgpuWalker.inlineDataParamSize = params.inlineDataParamSize;
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }

View File

@ -121,8 +121,6 @@ typedef struct _KERNEL_WALKER_PARAMS
bool hasBarrier; bool hasBarrier;
uint32_t slmSize; uint32_t slmSize;
PMHW_INLINE_DATA_PARAMS inlineDataParamBase;
uint32_t inlineDataParamSize;
uint32_t simdSize; uint32_t simdSize;
}KERNEL_WALKER_PARAMS, * PKERNEL_WALKER_PARAMS; }KERNEL_WALKER_PARAMS, * PKERNEL_WALKER_PARAMS;
@ -206,7 +204,7 @@ public:
PRENDERHAL_SURFACE_NEXT pRenderSurface, PRENDERHAL_SURFACE_NEXT pRenderSurface,
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets); std::vector<uint64_t> &stateGfxAddress);
// Step3: RSS Setup, return index insert in binding table // Step3: RSS Setup, return index insert in binding table
virtual uint32_t SetSurfaceForHwAccess( virtual uint32_t SetSurfaceForHwAccess(
@ -231,7 +229,7 @@ public:
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
std::set<uint32_t> &bindingIndexes, std::set<uint32_t> &bindingIndexes,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets, std::vector<uint64_t> &stateGfxAddress,
uint32_t capcityOfSurfaceEntries = 0, uint32_t capcityOfSurfaceEntries = 0,
PRENDERHAL_SURFACE_STATE_ENTRY *surfaceEntries = nullptr, PRENDERHAL_SURFACE_STATE_ENTRY *surfaceEntries = nullptr,
uint32_t *numOfSurfaceEntries = nullptr); uint32_t *numOfSurfaceEntries = nullptr);
@ -241,7 +239,7 @@ public:
PRENDERHAL_SURFACE_NEXT pRenderSurface, PRENDERHAL_SURFACE_NEXT pRenderSurface,
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets); std::vector<uint64_t> &stateGfxAddress);
virtual uint32_t SetBufferForHwAccess( virtual uint32_t SetBufferForHwAccess(
PMOS_SURFACE buffer, PMOS_SURFACE buffer,
@ -256,7 +254,7 @@ public:
PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams, PRENDERHAL_SURFACE_STATE_PARAMS pSurfaceParams,
std::set<uint32_t> &bindingIndexes, std::set<uint32_t> &bindingIndexes,
bool bWrite, bool bWrite,
std::set<uint32_t> &stateOffsets); std::vector<uint64_t> &stateGfxAddress);
virtual uint32_t SetBufferForHwAccess( virtual uint32_t SetBufferForHwAccess(
MOS_BUFFER buffer, MOS_BUFFER buffer,

View File

@ -134,6 +134,8 @@ MOS_STATUS VpRenderCmdPacket::LoadKernel()
return MOS_STATUS_UNKNOWN; return MOS_STATUS_UNKNOWN;
} }
// Allocate Media ID, link to kernel // Allocate Media ID, link to kernel
// iCurbeOffset and iCurbeLength is useless in bindless mode
// pRenderHal->pfnSetupInterfaceDesc is not used in bindless mode, it's set in send compute walker
m_renderData.mediaID = m_renderHal->pfnAllocateMediaID( m_renderData.mediaID = m_renderHal->pfnAllocateMediaID(
m_renderHal, m_renderHal,
iKrnAllocation, iKrnAllocation,
@ -271,12 +273,23 @@ MOS_STATUS VpRenderCmdPacket::Prepare()
VP_RENDER_CHK_STATUS_RETURN(SetupSurfaceState()); // once Surface setup done, surface index should be created here VP_RENDER_CHK_STATUS_RETURN(SetupSurfaceState()); // once Surface setup done, surface index should be created here
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeState()); // Set Curbe with updated surface index if (m_renderHal->isBindlessHeapInUse == false)
{
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeState()); // Set Curbe with updated surface index
}
VP_RENDER_CHK_STATUS_RETURN(LoadKernel()); VP_RENDER_CHK_STATUS_RETURN(LoadKernel());
VP_RENDER_CHK_STATUS_RETURN(SetupSamplerStates()); VP_RENDER_CHK_STATUS_RETURN(SetupSamplerStates());
if (m_renderHal->isBindlessHeapInUse)
{
// In bindless mode, Curbe need to set after surface state setup and sampler state setup
// Since bindless surface and bindless sampler only can be set into curbe after they are setup
// In bindful mode, they don't need to be set in curbe
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeStateInBindlessMode());
}
VP_RENDER_CHK_STATUS_RETURN(SetupWalkerParams()); VP_RENDER_CHK_STATUS_RETURN(SetupWalkerParams());
VP_RENDER_CHK_STATUS_RETURN(m_renderHal->pfnSetVfeStateParams( VP_RENDER_CHK_STATUS_RETURN(m_renderHal->pfnSetVfeStateParams(
@ -349,12 +362,23 @@ MOS_STATUS VpRenderCmdPacket::Prepare()
VP_RENDER_CHK_STATUS_RETURN(SetupSurfaceState()); // once Surface setup done, surface index should be created here VP_RENDER_CHK_STATUS_RETURN(SetupSurfaceState()); // once Surface setup done, surface index should be created here
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeState()); // Set Curbe with updated surface index if (m_renderHal->isBindlessHeapInUse == false)
{
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeState()); // Set Curbe with updated surface index
}
VP_RENDER_CHK_STATUS_RETURN(LoadKernel()); VP_RENDER_CHK_STATUS_RETURN(LoadKernel());
VP_RENDER_CHK_STATUS_RETURN(SetupSamplerStates()); VP_RENDER_CHK_STATUS_RETURN(SetupSamplerStates());
if (m_renderHal->isBindlessHeapInUse)
{
// In bindless mode, Curbe need to set after surface state setup and sampler state setup
// Since bindless surface and bindless sampler only can be set into curbe after they are setup
// In bindful mode, they don't need to be set in curbe
VP_RENDER_CHK_STATUS_RETURN(SetupCurbeStateInBindlessMode());
}
VP_RENDER_CHK_STATUS_RETURN(SetupWalkerParams()); VP_RENDER_CHK_STATUS_RETURN(SetupWalkerParams());
m_kernelRenderData.emplace(it->first, m_renderData); m_kernelRenderData.emplace(it->first, m_renderData);
@ -402,6 +426,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSamplerStates()
} }
else else
{ {
VP_RENDER_NORMALMESSAGE("Sampler State is empty for samplerIndex %d", samplerIndex);
MHW_SAMPLER_STATE_PARAM param = {}; MHW_SAMPLER_STATE_PARAM param = {};
samplerStates.push_back(param); samplerStates.push_back(param);
} }
@ -756,7 +781,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
bWrite = false; bWrite = false;
} }
std::set<uint32_t> stateOffsets; std::vector<uint64_t> stateGfxAddress;
if (kernelSurfaceParam->surfaceOverwriteParams.bindedKernel && !kernelSurfaceParam->surfaceOverwriteParams.bufferResource) if (kernelSurfaceParam->surfaceOverwriteParams.bindedKernel && !kernelSurfaceParam->surfaceOverwriteParams.bufferResource)
{ {
auto bindingMap = m_kernel->GetSurfaceBindingIndex(type); auto bindingMap = m_kernel->GetSurfaceBindingIndex(type);
@ -770,7 +795,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
&renderSurfaceParams, &renderSurfaceParams,
bindingMap, bindingMap,
bWrite, bWrite,
stateOffsets, stateGfxAddress,
kernelSurfaceParam->iCapcityOfSurfaceEntry, kernelSurfaceParam->iCapcityOfSurfaceEntry,
kernelSurfaceParam->surfaceEntries, kernelSurfaceParam->surfaceEntries,
kernelSurfaceParam->sizeOfSurfaceEntries)); kernelSurfaceParam->sizeOfSurfaceEntries));
@ -796,7 +821,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
&renderSurfaceParams, &renderSurfaceParams,
bindingMap, bindingMap,
bWrite, bWrite,
stateOffsets)); stateGfxAddress));
for (uint32_t const &bti : bindingMap) for (uint32_t const &bti : bindingMap)
{ {
VP_RENDER_NORMALMESSAGE("Using Binded Index Buffer. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, bti); VP_RENDER_NORMALMESSAGE("Using Binded Index Buffer. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, bti);
@ -814,7 +839,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
&renderHalSurface, &renderHalSurface,
&renderSurfaceParams, &renderSurfaceParams,
bWrite, bWrite,
stateOffsets); stateGfxAddress);
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCurbeBindingIndex(type, index)); 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); VP_RENDER_NORMALMESSAGE("Using UnBinded Index Buffer. KernelID %d, SurfType %d, bti %d", m_kernel->GetKernelId(), type, index);
} }
@ -825,15 +850,15 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
&renderHalSurface, &renderHalSurface,
&renderSurfaceParams, &renderSurfaceParams,
bWrite, bWrite,
stateOffsets); stateGfxAddress);
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCurbeBindingIndex(type, index)); 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_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);
} }
} }
if (stateOffsets.size() > 0) if (stateGfxAddress.size() > 0)
{ {
m_kernel->UpdateBindlessSurfaceResource(type, stateOffsets); m_kernel->UpdateBindlessSurfaceResource(type, stateGfxAddress);
} }
} }
VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCompParams()); VP_RENDER_CHK_STATUS_RETURN(m_kernel->UpdateCompParams());
@ -946,6 +971,54 @@ bool VpRenderCmdPacket::IsRenderUncompressedWriteNeeded(PVP_SURFACE VpSurface)
return false; return false;
} }
MOS_STATUS VpRenderCmdPacket::SetupCurbeStateInBindlessMode()
{
VP_FUNC_CALL();
MT_LOG1(MT_VP_HAL_RENDER_SETUP_CURBE_STATE, MT_NORMAL, MT_FUNC_START, 1);
VP_RENDER_CHK_NULL_RETURN(m_kernel);
VP_PUBLIC_CHK_NULL_RETURN(m_renderHal->pStateHeap);
VP_PUBLIC_CHK_NULL_RETURN(m_osInterface);
VP_PUBLIC_CHK_NULL_RETURN(m_osInterface->pfnGetResourceGfxAddress);
// set the Curbe Data length
void *curbeData = nullptr;
uint32_t curbeLength = 0;
uint32_t curbeLengthAligned = 0;
VP_RENDER_CHK_STATUS_RETURN(m_kernel->GetCurbeState(curbeData, curbeLength, curbeLengthAligned, m_renderData.KernelParam, m_renderHal->dwCurbeBlockAlign));
m_renderData.iCurbeOffset = m_renderHal->pfnLoadCurbeData(
m_renderHal,
m_renderData.mediaState,
curbeData,
curbeLength);
if (m_renderData.iCurbeOffset < 0 ||
(m_renderData.iCurbeOffset & 0x1F) != 0 ||
(m_renderData.iCurbeOffset + static_cast<int32_t>(curbeLengthAligned)) > m_renderData.mediaState->iCurbeOffset)
{
RENDER_PACKET_ASSERTMESSAGE("Curbe Set Fail, return error");
return MOS_STATUS_UNKNOWN;
}
PMOS_RESOURCE resource = &m_renderHal->pStateHeap->GshOsResource;
VP_PUBLIC_CHK_VALUE_RETURN(Mos_ResourceIsNull(resource), false);
uint64_t gfxAddress = m_osInterface->pfnGetResourceGfxAddress(m_osInterface, resource) +
m_renderHal->pStateHeap->pCurMediaState->dwOffset +
m_renderHal->pStateHeap->dwOffsetCurbe +
m_renderData.iCurbeOffset;
VP_PUBLIC_CHK_STATUS_RETURN(m_kernel->SetCurbeGfxAddress(gfxAddress));
m_renderData.iCurbeLength = curbeLengthAligned;
m_totalCurbeSize += m_renderData.iCurbeLength;
m_kernel->FreeCurbe(curbeData);
MT_LOG2(MT_VP_HAL_RENDER_SETUP_CURBE_STATE, MT_NORMAL, MT_FUNC_END, 1, MT_MOS_STATUS, MOS_STATUS_SUCCESS);
return MOS_STATUS_SUCCESS;
}
MOS_STATUS VpRenderCmdPacket::SetupCurbeState() MOS_STATUS VpRenderCmdPacket::SetupCurbeState()
{ {
VP_FUNC_CALL(); VP_FUNC_CALL();
@ -1953,9 +2026,16 @@ MOS_STATUS VpRenderCmdPacket::SendMediaStates(
// Send State Base Address command // Send State Base Address command
MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnSendStateBaseAddress(pRenderHal, pCmdBuffer)); MHW_RENDERHAL_CHK_STATUS(pRenderHal->pfnSendStateBaseAddress(pRenderHal, pCmdBuffer));
if (pRenderHal->bComputeContextInUse && !pRenderHal->isBindlessHeapInUse) if (pRenderHal->bComputeContextInUse)
{ {
pRenderHal->pRenderHalPltInterface->SendTo3DStateBindingTablePoolAlloc(pRenderHal, pCmdBuffer); if (!pRenderHal->isBindlessHeapInUse)
{
pRenderHal->pRenderHalPltInterface->SendTo3DStateBindingTablePoolAlloc(pRenderHal, pCmdBuffer);
}
else
{
pRenderHal->pRenderHalPltInterface->SendStateComputeMpde(pRenderHal, pCmdBuffer);
}
} }
// Send Surface States // Send Surface States

View File

@ -94,6 +94,8 @@ protected:
virtual MOS_STATUS SetupCurbeState(); virtual MOS_STATUS SetupCurbeState();
virtual MOS_STATUS SetupCurbeStateInBindlessMode();
virtual VP_SURFACE* GetSurface(SurfaceType type); virtual VP_SURFACE* GetSurface(SurfaceType type);
virtual MOS_STATUS SetupWalkerParams(); virtual MOS_STATUS SetupWalkerParams();

View File

@ -85,9 +85,7 @@ enum IMPLICIT_ARG_TYPE
{ {
ValueType = 0, ValueType = 0,
IndirectDataPtr, IndirectDataPtr,
ScratchPtr, ScratchPtr
SamplerStateBasePtr,
SurfaceStateBasePtr
}; };
struct KRN_ARG struct KRN_ARG
@ -142,6 +140,7 @@ typedef struct MOS_ALIGNED(16) _SURFACE_PARAMS
bool isOutput; bool isOutput;
bool needVerticalStirde; bool needVerticalStirde;
bool combineChannelY; bool combineChannelY;
uint32_t planeIndex;
} SURFACE_PARAMS, *PSURFACE_PARAMS; } SURFACE_PARAMS, *PSURFACE_PARAMS;
using KERNEL_ARG_INDEX_SURFACE_MAP = std::map<uint32_t, SURFACE_PARAMS>; using KERNEL_ARG_INDEX_SURFACE_MAP = std::map<uint32_t, SURFACE_PARAMS>;

View File

@ -713,32 +713,57 @@ void VpRenderKernelObj::DumpSurface(VP_SURFACE* pSurface, PCCHAR fileName)
#endif #endif
} }
MOS_STATUS VpRenderKernelObj::SetInlineDataParameter(KRN_ARG args, RENDERHAL_INTERFACE *renderhal) MOS_STATUS VpRenderKernelObj::SetInlineDataParameter(KRN_ARG arg, uint8_t* inlineData)
{ {
VP_FUNC_CALL(); VP_FUNC_CALL();
MHW_INLINE_DATA_PARAMS inlineDataPar = {}; VP_RENDER_CHK_NULL_RETURN(inlineData);
VP_RENDER_CHK_NULL_RETURN(renderhal); if (arg.implicitArgType == IndirectDataPtr)
MHW_STATE_BASE_ADDR_PARAMS *pStateBaseParams = &renderhal->StateBaseAddressParams;
inlineDataPar.dwOffset = args.uOffsetInPayload;
inlineDataPar.dwSize = args.uSize;
if (args.implicitArgType == IndirectDataPtr || args.implicitArgType == SamplerStateBasePtr)
{ {
inlineDataPar.resource = pStateBaseParams->presGeneralState; MOS_SecureMemcpy(inlineData + arg.uOffsetInPayload, arg.uSize, &m_curbeGfxAddress, sizeof(m_curbeGfxAddress));
inlineDataPar.isPtrType = true; VP_RENDER_NORMALMESSAGE("Setting Inline Data KernelID %d, index %d , value 0x%x, argKind %d", m_kernelId, arg.uIndex, m_curbeGfxAddress, arg.eArgKind);
} }
else if (args.implicitArgType == SurfaceStateBasePtr) else if (arg.implicitArgType == ValueType)
{ {
// New Heaps if (arg.pData != nullptr)
inlineDataPar.isPtrType = true; {
MOS_SecureMemcpy(inlineData + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize);
VP_RENDER_NORMALMESSAGE("Setting Inline Data KernelID %d, index %d , value %d, argKind %d", m_kernelId, arg.uIndex, *(uint32_t *)arg.pData, arg.eArgKind);
}
else
{
VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind);
}
} }
else if (args.implicitArgType == ValueType)
{
inlineDataPar.isPtrType = false;
}
// walkerParam.inlineDataParamBase will add m_inlineDataParams.data() in each kernel
// walkerParam.inlineDataParamSize will add m_inlineDataParams.size() in each kernel
m_inlineDataParams.push_back(inlineDataPar);
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
MOS_STATUS VpRenderKernelObj::GetBindlessSamplerGfxAddress(uint32_t samplerIndex, uint64_t &address)
{
auto it = m_bindlessSamperArray.find(samplerIndex);
VP_PUBLIC_CHK_NOT_FOUND_RETURN(it, &m_bindlessSamperArray);
address = it->second;
VP_PUBLIC_CHK_VALUE_RETURN(address == 0, false);
return MOS_STATUS_SUCCESS;
}
MOS_STATUS VpRenderKernelObj::GetBindlessSurfaceStateGfxAddress(KRN_ARG &arg, uint64_t &address)
{
auto surfMapHandle = m_argIndexSurfMap.find(arg.uIndex);
VP_PUBLIC_CHK_NOT_FOUND_RETURN(surfMapHandle, &m_argIndexSurfMap);
if (surfMapHandle->second.surfType == SurfaceTypeInvalid)
{
address = 0; //for invalid surface type, it means the surface in not used in this senario
return MOS_STATUS_SUCCESS;
}
auto bindlessAddressHandle = m_bindlessSurfaceArray.find(surfMapHandle->second.surfType);
VP_PUBLIC_CHK_NOT_FOUND_RETURN(bindlessAddressHandle, &m_bindlessSurfaceArray);
if (surfMapHandle->second.planeIndex >= bindlessAddressHandle->second.size())
{
address = 0; //for those surfaces plane number less than kernel interface max, skip these sub planes
return MOS_STATUS_SUCCESS;
}
address = bindlessAddressHandle->second.at(surfMapHandle->second.planeIndex);
VP_PUBLIC_CHK_VALUE_RETURN(address == 0, false);
return MOS_STATUS_SUCCESS;
}

View File

@ -87,8 +87,8 @@ using KERNEL_SAMPLER_INDEX = std::vector<SamplerIndex>;
using KERNEL_SURFACE_CONFIG = std::map<SurfaceType, KERNEL_SURFACE_STATE_PARAM>; using KERNEL_SURFACE_CONFIG = std::map<SurfaceType, KERNEL_SURFACE_STATE_PARAM>;
using KERNEL_SURFACE_BINDING_INDEX = std::map<SurfaceType, std::set<uint32_t>>; using KERNEL_SURFACE_BINDING_INDEX = std::map<SurfaceType, std::set<uint32_t>>;
using KERNEL_STATELESS_BUFF_CONFIG = std::map<SurfaceType, uint64_t>; using KERNEL_STATELESS_BUFF_CONFIG = std::map<SurfaceType, uint64_t>;
using KERNEL_BINDELESS_SURFACE = std::map<SurfaceType, std::set<uint32_t>>; using KERNEL_BINDELESS_SURFACE = std::map<SurfaceType, std::vector<uint64_t>>;
using KERNEL_BINDELESS_SAMPLER = std::map<uint32_t, uint32_t>; using KERNEL_BINDELESS_SAMPLER = std::map<uint32_t, uint64_t>;
typedef struct _KERNEL_PARAMS typedef struct _KERNEL_PARAMS
{ {
@ -534,19 +534,25 @@ public:
virtual MOS_STATUS InitRenderHalSurfaceCMF(MOS_SURFACE* src, PRENDERHAL_SURFACE renderHalSurface); virtual MOS_STATUS InitRenderHalSurfaceCMF(MOS_SURFACE* src, PRENDERHAL_SURFACE renderHalSurface);
virtual MOS_STATUS SetInlineDataParameter(KRN_ARG args, RENDERHAL_INTERFACE *renderhal); virtual MOS_STATUS UpdateBindlessSurfaceResource(SurfaceType surf, std::vector<uint64_t> stateGfxAddress)
virtual MOS_STATUS UpdateBindlessSurfaceResource(SurfaceType surf, std::set<uint32_t> surfStateOffset)
{ {
if (surf != SurfaceTypeInvalid) if (surf != SurfaceTypeInvalid && surf != SurfaceTypeSubPlane)
{ {
m_bindlessSurfaceArray.emplace(surf, surfStateOffset); auto handle = m_bindlessSurfaceArray.find(surf);
if (handle == m_bindlessSurfaceArray.end())
{
m_bindlessSurfaceArray.insert(std::make_pair(surf, stateGfxAddress));
}
else
{
handle->second = stateGfxAddress;
}
} }
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
virtual std::map<uint32_t, uint32_t>& GetBindlessSamplers() virtual std::map<uint32_t, uint64_t>& GetBindlessSamplers()
{ {
return m_bindlessSamperArray; return m_bindlessSamperArray;
} }
@ -558,6 +564,12 @@ public:
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
virtual MOS_STATUS SetCurbeGfxAddress(uint64_t address)
{
m_curbeGfxAddress = address;
return MOS_STATUS_SUCCESS;
}
protected: protected:
virtual MOS_STATUS SetWalkerSetting(KERNEL_THREAD_SPACE &threadSpace, bool bSyncFlag, bool flushL1 = false); virtual MOS_STATUS SetWalkerSetting(KERNEL_THREAD_SPACE &threadSpace, bool bSyncFlag, bool flushL1 = false);
@ -588,6 +600,11 @@ protected:
virtual MOS_STATUS SetTuningFlag(PKERNEL_TUNING_PARAMS tuningParams); virtual MOS_STATUS SetTuningFlag(PKERNEL_TUNING_PARAMS tuningParams);
virtual MOS_STATUS SetInlineDataParameter(KRN_ARG arg, uint8_t *inlineData);
virtual MOS_STATUS GetBindlessSamplerGfxAddress(uint32_t samplerIndex, uint64_t &address);
virtual MOS_STATUS GetBindlessSurfaceStateGfxAddress(KRN_ARG &arg, uint64_t &address);
protected: protected:
VP_SURFACE_GROUP *m_surfaceGroup = nullptr; // input surface process surface groups VP_SURFACE_GROUP *m_surfaceGroup = nullptr; // input surface process surface groups
@ -608,6 +625,7 @@ protected:
VpKernelID m_kernelId = kernelCombinedFc; VpKernelID m_kernelId = kernelCombinedFc;
DelayLoadedKernelType m_kernelType = KernelNone; DelayLoadedKernelType m_kernelType = KernelNone;
KernelIndex m_kernelIndex = 0; // index of current kernel in KERNEL_PARAMS_LIST KernelIndex m_kernelIndex = 0; // index of current kernel in KERNEL_PARAMS_LIST
uint64_t m_curbeGfxAddress = 0;
PKERNEL_TUNING_PARAMS m_kernelTuningParams = nullptr; PKERNEL_TUNING_PARAMS m_kernelTuningParams = nullptr;
@ -615,7 +633,6 @@ protected:
bool m_useIndependentSamplerGroup = false; //true means multi kernels has their own stand alone sampler states group. only can be true when m_isAdvKernel is true. bool m_useIndependentSamplerGroup = false; //true means multi kernels has their own stand alone sampler states group. only can be true when m_isAdvKernel is true.
std::shared_ptr<mhw::vebox::Itf> m_veboxItf = nullptr; std::shared_ptr<mhw::vebox::Itf> m_veboxItf = nullptr;
std ::vector<MHW_INLINE_DATA_PARAMS> m_inlineDataParams = {};
KERNEL_ARG_INDEX_SURFACE_MAP m_argIndexSurfMap = {}; KERNEL_ARG_INDEX_SURFACE_MAP m_argIndexSurfMap = {};

View File

@ -195,12 +195,14 @@ MOS_STATUS VpRenderOclFcKernel::SetKernelArgs(KERNEL_ARGS &kernelArgs, VP_PACKET
{ {
if (*(uint32_t *)srcArg.pData == MHW_SAMPLER_FILTER_BILINEAR) if (*(uint32_t *)srcArg.pData == MHW_SAMPLER_FILTER_BILINEAR)
{ {
m_linearSamplerIndex = dstArg.uOffsetInPayload; m_linearSamplerIndex = (dstArg.addressMode == AddressingModeBindless) ? 1 : dstArg.uOffsetInPayload;
dstArg.pData = (dstArg.addressMode == AddressingModeBindless) ? srcArg.pData : nullptr;
srcArg.pData = nullptr; srcArg.pData = nullptr;
} }
else if (*(uint32_t *)srcArg.pData == MHW_SAMPLER_FILTER_NEAREST) else if (*(uint32_t *)srcArg.pData == MHW_SAMPLER_FILTER_NEAREST)
{ {
m_nearestSamplerIndex = dstArg.uOffsetInPayload; m_nearestSamplerIndex = (dstArg.addressMode == AddressingModeBindless) ? 0 : dstArg.uOffsetInPayload;
dstArg.pData = (dstArg.addressMode == AddressingModeBindless) ? srcArg.pData : nullptr;
srcArg.pData = nullptr; srcArg.pData = nullptr;
} }
else else
@ -245,7 +247,6 @@ MOS_STATUS VpRenderOclFcKernel::GetCurbeState(void *&curbe, uint32_t &curbeLengt
switch (arg.eArgKind) switch (arg.eArgKind)
{ {
case ARG_KIND_GENERAL: case ARG_KIND_GENERAL:
case ARG_KIND_SURFACE:
if (arg.pData != nullptr) if (arg.pData != nullptr)
{ {
MOS_SecureMemcpy(pCurbe + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize); MOS_SecureMemcpy(pCurbe + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize);
@ -256,8 +257,41 @@ MOS_STATUS VpRenderOclFcKernel::GetCurbeState(void *&curbe, uint32_t &curbeLengt
VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind); VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind);
} }
break; break;
case ARG_KIND_SURFACE:
if (arg.addressMode == AddressingModeBindless)
{
// this is bindless surface
uint64_t gfxAddress = 0;
VP_PUBLIC_CHK_STATUS_RETURN(GetBindlessSurfaceStateGfxAddress(arg, gfxAddress));
MOS_SecureMemcpy(pCurbe + arg.uOffsetInPayload, arg.uSize, &gfxAddress, sizeof(gfxAddress));
VP_RENDER_NORMALMESSAGE("Setting Curbe State Bindless Surface KernelID %d, index %d , value 0x%x, argKind %d", m_kernelId, arg.uIndex, gfxAddress, arg.eArgKind);
}
else
{
if (arg.pData != nullptr)
{
// this is statelss surface
MOS_SecureMemcpy(pCurbe + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize);
VP_RENDER_NORMALMESSAGE("Setting Curbe State KernelID %d, index %d , value %d, argKind %d", m_kernelId, arg.uIndex, *(uint32_t *)arg.pData, arg.eArgKind);
}
else
{
VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind);
}
}
break;
case ARG_KIND_INLINE: case ARG_KIND_INLINE:
break;
case ARG_KIND_SAMPLER: case ARG_KIND_SAMPLER:
if (arg.addressMode == AddressingModeBindless)
{
VP_RENDER_CHK_NULL_RETURN(arg.pData);
uint64_t gfxAddress = 0;
uint32_t samplerIndex = (*(uint32_t *)arg.pData == MHW_SAMPLER_FILTER_NEAREST) ? 0 : 1;
VP_RENDER_CHK_STATUS_RETURN(GetBindlessSamplerGfxAddress(samplerIndex, gfxAddress));
MOS_SecureMemcpy(pCurbe + arg.uOffsetInPayload, arg.uSize, &gfxAddress, sizeof(gfxAddress));
VP_RENDER_NORMALMESSAGE("Setting Curbe State Bindless Sampler KernelID %d, index %d , value 0x%x, argKind %d", m_kernelId, arg.uIndex, gfxAddress, arg.eArgKind);
}
break; break;
default: default:
VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_UNIMPLEMENTED); VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_UNIMPLEMENTED);
@ -269,6 +303,78 @@ MOS_STATUS VpRenderOclFcKernel::GetCurbeState(void *&curbe, uint32_t &curbeLengt
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
MOS_STATUS VpRenderOclFcKernel::GetKernelSurfaceParam(bool isBTI, SURFACE_PARAMS &surfParam, KERNEL_SURFACE_STATE_PARAM &kernelSurfaceParam)
{
MOS_ZeroMemory(&kernelSurfaceParam, sizeof(KERNEL_SURFACE_STATE_PARAM));
kernelSurfaceParam.surfaceOverwriteParams.updatedRenderSurfaces = true;
kernelSurfaceParam.surfaceOverwriteParams.bindedKernel = isBTI;
PRENDERHAL_SURFACE_STATE_PARAMS pRenderSurfaceParams = &kernelSurfaceParam.surfaceOverwriteParams.renderSurfaceParams;
pRenderSurfaceParams->bAVS = false;
pRenderSurfaceParams->Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
pRenderSurfaceParams->b2PlaneNV12NeededByKernel = true;
pRenderSurfaceParams->forceCommonSurfaceMessage = true;
MOS_HW_RESOURCE_DEF resourceType = MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_RENDER;
SurfaceType surfType = surfParam.surfType;
if (surfParam.combineChannelY)
{
pRenderSurfaceParams->combineChannelY = true;
}
pRenderSurfaceParams->isOutput = surfParam.isOutput;
auto surf = m_surfaceGroup->find(surfType);
if (m_surfaceGroup->end() == surf)
{
VP_RENDER_ASSERTMESSAGE("surf was not found %d", surfType);
return MOS_STATUS_NULL_POINTER;
}
VP_RENDER_CHK_NULL_RETURN(surf->second);
VP_RENDER_CHK_NULL_RETURN(surf->second->osSurface);
pRenderSurfaceParams->MemObjCtl = (m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject(
resourceType,
m_renderHal->pOsInterface->pfnGetGmmClientContext(m_renderHal->pOsInterface)))
.DwordValue;
pRenderSurfaceParams->Component = COMPONENT_VPCommon;
if (m_kernelId == kernelOclFcCommon ||
m_kernelId == kernelOclFcFP)
{
kernelSurfaceParam.surfaceOverwriteParams.updatedSurfaceParams = true;
kernelSurfaceParam.surfaceOverwriteParams.format = surf->second->osSurface->Format;
kernelSurfaceParam.surfaceOverwriteParams.width = MOS_MIN(static_cast<uint16_t>(surf->second->osSurface->dwWidth), static_cast<uint16_t>(surf->second->rcSrc.right));
kernelSurfaceParam.surfaceOverwriteParams.height = MOS_MIN(static_cast<uint16_t>(surf->second->osSurface->dwHeight), static_cast<uint16_t>(surf->second->rcSrc.bottom));
}
if (surfParam.needVerticalStirde)
{
switch (surf->second->SampleType)
{
case SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD:
case SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD:
pRenderSurfaceParams->bVertStride = true;
pRenderSurfaceParams->bVertStrideOffs = 0;
break;
case SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD:
case SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD:
pRenderSurfaceParams->bVertStride = true;
pRenderSurfaceParams->bVertStrideOffs = 1;
break;
default:
pRenderSurfaceParams->bVertStride = false;
pRenderSurfaceParams->bVertStrideOffs = 0;
break;
}
}
if (surf->second->osSurface->Format == Format_Buffer)
{
kernelSurfaceParam.surfaceOverwriteParams.updatedSurfaceParams = true;
kernelSurfaceParam.surfaceOverwriteParams.bufferResource = true;
}
return MOS_STATUS_SUCCESS;
}
MOS_STATUS VpRenderOclFcKernel::SetupSurfaceState() MOS_STATUS VpRenderOclFcKernel::SetupSurfaceState()
{ {
VP_FUNC_CALL(); VP_FUNC_CALL();
@ -277,94 +383,58 @@ MOS_STATUS VpRenderOclFcKernel::SetupSurfaceState()
m_surfaceState.clear(); m_surfaceState.clear();
for (auto it = m_kernelBtis.begin(); it != m_kernelBtis.end(); ++it) for (auto it = m_kernelBtis.begin(); it != m_kernelBtis.end(); ++it)
{ {
uint32_t argIndex = it->first; uint32_t argIndex = it->first;
uint32_t bti = it->second; uint32_t bti = it->second;
auto surfHandle = m_argIndexSurfMap.find(argIndex);
VP_RENDER_NORMALMESSAGE("Setting Surface State for OCL FC. KernelID %d, layer %d, argIndex %d , bti %d", m_kernelId, m_kernelIndex, argIndex, bti);
MOS_ZeroMemory(&kernelSurfaceParam, sizeof(KERNEL_SURFACE_STATE_PARAM));
kernelSurfaceParam.surfaceOverwriteParams.updatedRenderSurfaces = true;
kernelSurfaceParam.surfaceOverwriteParams.bindedKernel = true;
PRENDERHAL_SURFACE_STATE_PARAMS pRenderSurfaceParams = &kernelSurfaceParam.surfaceOverwriteParams.renderSurfaceParams;
pRenderSurfaceParams->bAVS = false;
pRenderSurfaceParams->Boundary = RENDERHAL_SS_BOUNDARY_ORIGINAL;
pRenderSurfaceParams->b2PlaneNV12NeededByKernel = true;
pRenderSurfaceParams->forceCommonSurfaceMessage = true;
SurfaceType surfType = SurfaceTypeInvalid;
MOS_HW_RESOURCE_DEF resourceType = MOS_HW_RESOURCE_USAGE_VP_INTERNAL_READ_WRITE_RENDER;
auto surfHandle = m_argIndexSurfMap.find(argIndex);
VP_PUBLIC_CHK_NOT_FOUND_RETURN(surfHandle, &m_argIndexSurfMap); VP_PUBLIC_CHK_NOT_FOUND_RETURN(surfHandle, &m_argIndexSurfMap);
if (surfHandle->second.combineChannelY) SURFACE_PARAMS &surfParam = surfHandle->second;
{ SurfaceType surfType = surfParam.surfType;
pRenderSurfaceParams->combineChannelY = true;
}
surfType = surfHandle->second.surfType;
if (surfType == SurfaceTypeSubPlane || surfType == SurfaceTypeInvalid) if (surfType == SurfaceTypeSubPlane || surfType == SurfaceTypeInvalid)
{ {
VP_RENDER_NORMALMESSAGE("Will skip surface argIndex %d, bti %d for its surf type is set as %d", argIndex, bti, surfType); VP_RENDER_NORMALMESSAGE("Will skip surface argIndex %d, bti %d for its surf type is set as %d", argIndex, bti, surfType);
continue; continue;
} }
pRenderSurfaceParams->isOutput = surfHandle->second.isOutput;
if (m_surfaceState.find(surfType) != m_surfaceState.end()) if (m_surfaceState.find(surfType) != m_surfaceState.end())
{ {
UpdateCurbeBindingIndex(surfType, bti); UpdateCurbeBindingIndex(surfType, bti);
continue; continue;
} }
auto surf = m_surfaceGroup->find(surfType);
if (m_surfaceGroup->end() == surf)
{
VP_RENDER_ASSERTMESSAGE("surf was not found %d", surfType);
return MOS_STATUS_NULL_POINTER;
}
VP_RENDER_CHK_NULL_RETURN(surf->second);
VP_RENDER_CHK_NULL_RETURN(surf->second->osSurface);
pRenderSurfaceParams->MemObjCtl = (m_renderHal->pOsInterface->pfnCachePolicyGetMemoryObject( VP_PUBLIC_CHK_STATUS_RETURN(GetKernelSurfaceParam(true, surfParam, kernelSurfaceParam));
resourceType,
m_renderHal->pOsInterface->pfnGetGmmClientContext(m_renderHal->pOsInterface)))
.DwordValue;
pRenderSurfaceParams->Component = COMPONENT_VPCommon;
if (m_kernelId == kernelOclFcCommon ||
m_kernelId == kernelOclFcFP)
{
kernelSurfaceParam.surfaceOverwriteParams.updatedSurfaceParams = true;
kernelSurfaceParam.surfaceOverwriteParams.format = surf->second->osSurface->Format;
kernelSurfaceParam.surfaceOverwriteParams.width = MOS_MIN(static_cast<uint16_t>(surf->second->osSurface->dwWidth), static_cast<uint16_t>(surf->second->rcSrc.right));
kernelSurfaceParam.surfaceOverwriteParams.height = MOS_MIN(static_cast<uint16_t>(surf->second->osSurface->dwHeight), static_cast<uint16_t>(surf->second->rcSrc.bottom));
}
if (surfHandle->second.needVerticalStirde)
{
switch (surf->second->SampleType)
{
case SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD:
case SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD:
pRenderSurfaceParams->bVertStride = true;
pRenderSurfaceParams->bVertStrideOffs = 0;
break;
case SAMPLE_INTERLEAVED_EVEN_FIRST_BOTTOM_FIELD:
case SAMPLE_INTERLEAVED_ODD_FIRST_BOTTOM_FIELD:
pRenderSurfaceParams->bVertStride = true;
pRenderSurfaceParams->bVertStrideOffs = 1;
break;
default:
pRenderSurfaceParams->bVertStride = false;
pRenderSurfaceParams->bVertStrideOffs = 0;
break;
}
}
if (surf->second->osSurface->Format == Format_Buffer)
{
kernelSurfaceParam.surfaceOverwriteParams.updatedSurfaceParams = true;
kernelSurfaceParam.surfaceOverwriteParams.bufferResource = true;
}
m_surfaceState.emplace(surfType, kernelSurfaceParam); m_surfaceState.emplace(surfType, kernelSurfaceParam);
UpdateCurbeBindingIndex(surfType, bti); UpdateCurbeBindingIndex(surfType, bti);
} }
for (auto &handle : m_kernelArgs)
{
KRN_ARG &arg = handle.second;
if (arg.addressMode != AddressingModeBindless || arg.eArgKind != ARG_KIND_SURFACE)
{
continue;
}
uint32_t argIndex = arg.uIndex;
auto surfHandle = m_argIndexSurfMap.find(argIndex);
VP_PUBLIC_CHK_NOT_FOUND_RETURN(surfHandle, &m_argIndexSurfMap);
SURFACE_PARAMS &surfParam = surfHandle->second;
SurfaceType surfType = surfParam.surfType;
if (surfParam.planeIndex != 0 || surfType == SurfaceTypeSubPlane || surfType == SurfaceTypeInvalid)
{
VP_RENDER_NORMALMESSAGE("Will skip bindless surface argIndex %d for its planeIndex is set as %d, surfType %d", argIndex, surfParam.planeIndex, surfType);
continue;
}
if (m_surfaceState.find(surfType) != m_surfaceState.end())
{
continue;
}
VP_PUBLIC_CHK_STATUS_RETURN(GetKernelSurfaceParam(false, surfParam, kernelSurfaceParam));
m_surfaceState.insert(std::make_pair(surfType, kernelSurfaceParam));
}
return MOS_STATUS_SUCCESS; return MOS_STATUS_SUCCESS;
} }
@ -373,6 +443,18 @@ MOS_STATUS VpRenderOclFcKernel::GetWalkerSetting(KERNEL_WALKER_PARAMS &walkerPar
{ {
VP_FUNC_CALL(); VP_FUNC_CALL();
if (m_renderHal && m_renderHal->isBindlessHeapInUse)
{
for (auto &handle : m_kernelArgs)
{
KRN_ARG &arg = handle.second;
if (arg.eArgKind == ARG_KIND_INLINE)
{
VP_PUBLIC_CHK_STATUS_RETURN(SetInlineDataParameter(arg, m_inlineData.data()));
}
}
}
walkerParam = m_walkerParam; walkerParam = m_walkerParam;
walkerParam.iBindingTable = renderData.bindingTable; walkerParam.iBindingTable = renderData.bindingTable;
@ -406,19 +488,22 @@ MOS_STATUS VpRenderOclFcKernel::SetWalkerSetting(KERNEL_THREAD_SPACE &threadSpac
m_walkerParam.pipeControlParams.bFlushRenderTargetCache = false; m_walkerParam.pipeControlParams.bFlushRenderTargetCache = false;
m_walkerParam.pipeControlParams.bInvalidateTextureCache = false; m_walkerParam.pipeControlParams.bInvalidateTextureCache = false;
for (auto &handle : m_kernelArgs) if (m_renderHal == nullptr || m_renderHal->isBindlessHeapInUse == false)
{ {
KRN_ARG &arg = handle.second; for (auto &handle : m_kernelArgs)
if (arg.eArgKind == ARG_KIND_INLINE)
{ {
if (arg.pData != nullptr) KRN_ARG &arg = handle.second;
if (arg.eArgKind == ARG_KIND_INLINE)
{ {
MOS_SecureMemcpy(m_inlineData.data() + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize); if (arg.pData != nullptr)
VP_RENDER_NORMALMESSAGE("Setting Inline Data KernelID %d, index %d , value %d, argKind %d", m_kernelId, arg.uIndex, *(uint32_t *)arg.pData, arg.eArgKind); {
} MOS_SecureMemcpy(m_inlineData.data() + arg.uOffsetInPayload, arg.uSize, arg.pData, arg.uSize);
else VP_RENDER_NORMALMESSAGE("Setting Inline Data KernelID %d, index %d , value %d, argKind %d", m_kernelId, arg.uIndex, *(uint32_t *)arg.pData, arg.eArgKind);
{ }
VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind); else
{
VP_RENDER_NORMALMESSAGE("KernelID %d, index %d, argKind %d is empty", m_kernelId, arg.uIndex, arg.eArgKind);
}
} }
} }
} }

View File

@ -55,6 +55,7 @@ protected:
virtual MOS_STATUS SetupSurfaceState() override; virtual MOS_STATUS SetupSurfaceState() override;
virtual MOS_STATUS SetWalkerSetting(KERNEL_THREAD_SPACE &threadSpace, bool bSyncFlag, bool flushL1 = false); virtual MOS_STATUS SetWalkerSetting(KERNEL_THREAD_SPACE &threadSpace, bool bSyncFlag, bool flushL1 = false);
virtual MOS_STATUS SetKernelArgs(KERNEL_ARGS &kernelArgs, VP_PACKET_SHARED_CONTEXT *sharedContext); virtual MOS_STATUS SetKernelArgs(KERNEL_ARGS &kernelArgs, VP_PACKET_SHARED_CONTEXT *sharedContext);
virtual MOS_STATUS GetKernelSurfaceParam(bool isBTI, SURFACE_PARAMS &surfParam, KERNEL_SURFACE_STATE_PARAM &kernelSurfaceParam);
PRENDERHAL_INTERFACE m_renderHal = nullptr; PRENDERHAL_INTERFACE m_renderHal = nullptr;