Skip to content

Commit

Permalink
[Media Common] [VP] set right rw flag for media copy resource synchro…
Browse files Browse the repository at this point in the history
…nization

There will be perf issue if input resource is registered with write flag due to waiting on unexpected fence.
For input resource, no need to set write flag, while for output resource, make sure it is ready to be written.
Also remove all pfnSyncOnResource calls in media copy, as pfnuser featureResource will handle all possible hazards by previous change.
  • Loading branch information
MicroYY authored and intel-mediadev committed Jan 11, 2024
1 parent 80ac3bb commit f447816
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ MOS_STATUS MhwBltInterfaceXe_Hpc::AddFastCopyBlt(
ResourceParams.presResource = pFastCopyBltParam->pSrcOsResource;
ResourceParams.pdwCmd = &(cmd.DW8_9.Value[0]);
ResourceParams.dwLocationInCmd = 8;
ResourceParams.bIsWritable = true;
ResourceParams.bIsWritable = false;

MHW_CHK_STATUS(pfnAddResourceToCmd(
m_osInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ MOS_STATUS MhwBltInterfaceXe_Hp_Base::AddBlockCopyBlt(
ResourceParams.presResource = pFastCopyBltParam->pSrcOsResource;
ResourceParams.pdwCmd = &(cmd.DW9_10.Value[0]);
ResourceParams.dwLocationInCmd = 9;
ResourceParams.bIsWritable = true;
ResourceParams.bIsWritable = false;

MHW_CHK_STATUS(pfnAddResourceToCmd(
m_osInterface,
Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/hw/mhw_blt_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ MOS_STATUS MhwBltInterface::AddFastCopyBlt(
ResourceParams.presResource = pFastCopyBltParam->pSrcOsResource;
ResourceParams.pdwCmd = &(cmd.DW8_9.Value[0]);
ResourceParams.dwLocationInCmd = 8;
ResourceParams.bIsWritable = true;
ResourceParams.bIsWritable = false;

MHW_CHK_STATUS(pfnAddResourceToCmd(
m_osInterface,
Expand Down Expand Up @@ -161,7 +161,7 @@ MOS_STATUS MhwBltInterface::AddBlockCopyBlt(
ResourceParams.presResource = pFastCopyBltParam->pSrcOsResource;
ResourceParams.pdwCmd = &(cmd.DW9_10.Value[0]);
ResourceParams.dwLocationInCmd = 9;
ResourceParams.bIsWritable = true;
ResourceParams.bIsWritable = false;

MHW_CHK_STATUS(pfnAddResourceToCmd(
m_osInterface,
Expand Down
10 changes: 0 additions & 10 deletions media_driver/agnostic/common/shared/mediacopy/media_vebox_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ MOS_STATUS VeboxCopyState::CopyMainSurface(PMOS_RESOURCE src, PMOS_RESOURCE dst)
m_osInterface,
MOS_GPU_CONTEXT_VEBOX));

// Sync on Vebox Input Resource, Ensure the input is ready to be read
// Currently, MOS RegisterResourcere cannot sync the 3d resource.
// Temporaly, call sync resource to do the sync explicitly.
// Sync need be done after switching context.
m_osInterface->pfnSyncOnResource(
m_osInterface,
src,
MOS_GPU_CONTEXT_VEBOX,
false);

// Reset allocation list and house keeping
m_osInterface->pfnResetOsStates(m_osInterface);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,6 @@ MOS_STATUS RenderCopy_Xe_Hpm::SubmitCMD( )
// Register the resource of GSH
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnReset(pRenderHal));

// Register the input resource;
MCPY_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource(
pOsInterface,
(PMOS_RESOURCE)&pRenderCopy->m_Source.OsResource,
true,
true));

// Ensure input can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&pRenderCopy->m_Source.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);

// Ensure Output can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&pRenderCopy->m_Target.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);


// Set copy kernel
pRenderCopy->SetupKernel(m_currKernelId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,6 @@ MOS_STATUS RenderCopy_Xe_Xpm_Plus::SubmitCMD( )
// Register the resource of GSH
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnReset(pRenderHal));

// Register the input resource;
MCPY_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource(
pOsInterface,
(PMOS_RESOURCE)&pRenderCopy->m_KernelResource,
true,
true));

// Ensure input can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&pRenderCopy->m_Source.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);

// Ensure Output can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&pRenderCopy->m_Target.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);


// Set copy kernel
pRenderCopy->SetupKernel(m_currKernelId);

Expand Down
2 changes: 1 addition & 1 deletion media_softlet/agnostic/common/hw/mhw_blt_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Impl : public Itf, public mhw::Impl
ResourceParams.presResource = params.pSrcOsResource;
ResourceParams.pdwCmd = &(cmd.DW8_9.Value[0]);
ResourceParams.dwLocationInCmd = 8;
ResourceParams.bIsWritable = true;
ResourceParams.bIsWritable = false;

MHW_CHK_STATUS_RETURN(AddResourceToCmd(
this->m_osItf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,18 +836,6 @@ MOS_STATUS BltStateNext::SubmitCMD(
m_osInterface,
MOS_GPU_CONTEXT_BLT));

m_osInterface->pfnSyncOnResource(
m_osInterface,
pBltStateParam->pSrcSurface,
MOS_GPU_CONTEXT_BLT,
false);

m_osInterface->pfnSyncOnResource(
m_osInterface,
pBltStateParam->pDstSurface,
MOS_GPU_CONTEXT_BLT,
true);

// Initialize the command buffer struct
MOS_ZeroMemory(&cmdBuffer, sizeof(MOS_COMMAND_BUFFER));
BLT_CHK_STATUS_RETURN(m_osInterface->pfnGetCommandBuffer(m_osInterface, &cmdBuffer, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,28 +302,6 @@ MOS_STATUS RenderCopyStateNext::SubmitCMD()
// Register the resource of GSH
MCPY_CHK_STATUS_RETURN(pRenderHal->pfnReset(pRenderHal));

// Register the input resource;
MCPY_CHK_STATUS_RETURN(pOsInterface->pfnRegisterResource(
pOsInterface,
(PMOS_RESOURCE)&m_Source.OsResource,
true,
true));

// Ensure input can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&m_Source.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);

// Ensure Output can be read
pOsInterface->pfnSyncOnResource(
pOsInterface,
&m_Target.OsResource,
pOsInterface->CurrentGpuContextOrdinal,
false);


// Set copy kernel
SetupKernel(m_currKernelId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,6 @@ MOS_STATUS VeboxCopyStateNext::CopyMainSurface(PMOS_RESOURCE src, PMOS_RESOURCE
VEBOX_COPY_CHK_STATUS_RETURN(m_osInterface->pfnSetGpuContext(m_osInterface, VeboxGpuContext));

m_osInterface->pfnSetPerfTag(m_osInterface, VEBOX_COPY);
// Sync on Vebox Input Resource, Ensure the input is ready to be read
// Currently, MOS RegisterResourcere cannot sync the 3d resource.
// Temporaly, call sync resource to do the sync explicitly.
// Sync need be done after switching context.
m_osInterface->pfnSyncOnResource(
m_osInterface,
src,
VeboxGpuContext,
false);
m_osInterface->pfnSyncOnResource(
m_osInterface,
dst,
VeboxGpuContext,
false);

// Reset allocation list and house keeping
m_osInterface->pfnResetOsStates(m_osInterface);
Expand Down

0 comments on commit f447816

Please sign in to comment.