Skip to content

Commit

Permalink
Revert "vaGetImage optimization on D-card."
Browse files Browse the repository at this point in the history
This reverts commit b67820f.
  • Loading branch information
MicroYY authored and Sherry-Lin committed Jan 5, 2023
1 parent 48fa9d3 commit 3c2063c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
33 changes: 32 additions & 1 deletion media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5255,6 +5255,9 @@ static VAStatus DdiMedia_CopySurfaceToImage(
}
}

if (image->format.fourcc != VA_FOURCC_NV12)
flag = flag | MOS_LOCKFLAG_NO_SWIZZLE;

void* surfData = DdiMediaUtil_LockSurface(surface, flag);

if (surfData == nullptr)
Expand All @@ -5272,9 +5275,32 @@ static VAStatus DdiMedia_CopySurfaceToImage(
return vaStatus;
}

uint8_t *ySrc = (uint8_t*)surfData;
uint8_t *ySrc = nullptr;
uint8_t *yDst = (uint8_t*)imageData;

uint8_t* swizzleData = nullptr;

if (!surface->pMediaCtx->bIsAtomSOC && surface->TileType != I915_TILING_NONE && image->format.fourcc != VA_FOURCC_NV12)
{
swizzleData = (uint8_t*)MOS_AllocMemory(surface->data_size);
if (nullptr != swizzleData)
{
SwizzleSurface(surface->pMediaCtx, surface->pGmmResourceInfo, surfData, (MOS_TILE_TYPE)surface->TileType, (uint8_t*)swizzleData, false);
ySrc = swizzleData;
}
else
{
DDI_ASSERTMESSAGE("nullptr swizzleData.");
DdiMedia_UnmapBuffer(ctx, image->buf);
DdiMediaUtil_UnlockSurface(surface);
return VA_STATUS_ERROR_INVALID_BUFFER;
}
}
else
{
ySrc = (uint8_t*)surfData;
}

DdiMedia_CopyPlane(yDst, image->pitches[0], ySrc, surface->iPitch, image->height);
if (image->num_planes > 1)
{
Expand All @@ -5296,6 +5322,11 @@ static VAStatus DdiMedia_CopySurfaceToImage(
}
}

if (nullptr != swizzleData)
{
MOS_FreeMemory(swizzleData);
swizzleData = nullptr;
}
vaStatus = DdiMedia_UnmapBuffer(ctx, image->buf);
if (vaStatus != VA_STATUS_SUCCESS)
{
Expand Down
34 changes: 33 additions & 1 deletion media_softlet/linux/common/ddi/media_libva_interface_next.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,11 @@ VAStatus MediaLibvaInterfaceNext::CopySurfaceToImage(
}
}

if (image->format.fourcc != VA_FOURCC_NV12)
{
flag = flag | MOS_LOCKFLAG_NO_SWIZZLE;
}

void *surfData = MediaLibvaUtilNext::LockSurface(surface, flag);
if (surfData == nullptr)
{
Expand All @@ -1611,8 +1616,30 @@ VAStatus MediaLibvaInterfaceNext::CopySurfaceToImage(
return vaStatus;
}

uint8_t *ySrc = (uint8_t*)surfData;
uint8_t *ySrc = nullptr;
uint8_t *yDst = (uint8_t*)imageData;
uint8_t *swizzleData = nullptr;

if (!surface->pMediaCtx->bIsAtomSOC && surface->TileType != I915_TILING_NONE && image->format.fourcc != VA_FOURCC_NV12)
{
swizzleData = (uint8_t*)MOS_AllocMemory(surface->data_size);
if (nullptr != swizzleData)
{
MediaLibvaUtilNext::SwizzleSurface(surface->pMediaCtx, surface->pGmmResourceInfo, surfData, (MOS_TILE_TYPE)surface->TileType, (uint8_t*)swizzleData, false);
ySrc = swizzleData;
}
else
{
DDI_ASSERTMESSAGE("nullptr swizzleData.");
UnmapBuffer(ctx, image->buf);
MediaLibvaUtilNext::UnlockSurface(surface);
return VA_STATUS_ERROR_INVALID_BUFFER;
}
}
else
{
ySrc = (uint8_t*)surfData;
}

CopyPlane(yDst, image->pitches[0], ySrc, surface->iPitch, image->height);
if (image->num_planes > 1)
Expand All @@ -1635,6 +1662,11 @@ VAStatus MediaLibvaInterfaceNext::CopySurfaceToImage(
}
}

if (nullptr != swizzleData)
{
MOS_FreeMemory(swizzleData);
swizzleData = nullptr;
}
vaStatus = UnmapBuffer(ctx, image->buf);
if (vaStatus != VA_STATUS_SUCCESS)
{
Expand Down

0 comments on commit 3c2063c

Please sign in to comment.