Skip to content

Commit

Permalink
fix compressed surface width not align with 32 and seg fault
Browse files Browse the repository at this point in the history
 caused by wrong plane number
  • Loading branch information
Dylan-debug committed Aug 1, 2023
1 parent 55c4003 commit ca1abd0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "vphal_debug.h"
#include "vp_utils.h"

#define DECOMPRESSION_WIDTH_ALIGNMENT_IN_BYTE 32

MediaVeboxDecompState::MediaVeboxDecompState():
MediaMemDecompBaseState(),
m_osInterface(nullptr),
Expand Down Expand Up @@ -663,7 +665,32 @@ MOS_STATUS MediaVeboxDecompState::GetResourceInfo(PMOS_SURFACE surface)
&resDetails));

surface->Format = resDetails.Format;
#if defined(LINUX) && !defined(WDDM_LINUX)
if ((surface->Format == Format_NV12 || surface->Format == Format_P010) && surface->OsResource.iWidth & 1 != 0)
{
uint32_t bitsPerPixel = 8;
if (surface->Format == Format_P010)
{
bitsPerPixel = 16;
}
uint32_t alignWidth = MOS_ALIGN_CEIL(resDetails.dwWidth, DECOMPRESSION_WIDTH_ALIGNMENT_IN_BYTE*8/bitsPerPixel);
if (alignWidth <= resDetails.dwPitch*8/bitsPerPixel)
{
surface->dwWidth = alignWidth;
}
else
{
VPHAL_MEMORY_DECOMP_ASSERTMESSAGE("May got green line corruption.");
surface->dwWidth = resDetails.dwWidth;
}
}
else
{
surface->dwWidth = resDetails.dwWidth;
}
#else
surface->dwWidth = resDetails.dwWidth;
#endif
surface->dwHeight = resDetails.dwHeight;
surface->dwPitch = resDetails.dwPitch;
surface->dwDepth = resDetails.dwDepth;
Expand Down
2 changes: 1 addition & 1 deletion media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5192,7 +5192,7 @@ VAStatus SwizzleSurface(PDDI_MEDIA_CONTEXT mediaCtx, PGMM_RESOURCE_INFO pGmmResI

memset(&gmmResCopyBlt, 0x0, sizeof(GMM_RES_COPY_BLT));
uiPicHeight = pGmmResInfo->GetBaseHeight();
uiSize = pGmmResInfo->GetSizeSurface();
uiSize = pGmmResInfo->GetSizeMainSurface();
uiPitch = pGmmResInfo->GetRenderPitch();
gmmResCopyBlt.Gpu.pData = pLockedAddr;
gmmResCopyBlt.Sys.pData = pResourceBase;
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/common/ddi/media_libva_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ VAStatus DdiMediaUtil_AllocateSurface(
uiPlanesOrAuxPlanes = mediaSurface->pSurfDesc->uiPlanes/2;
gmmCustomParams.AuxSurf.BaseAlignment = {0};
gmmCustomParams.Size = (uiPlanesOrAuxPlanes == 1) ? mediaSurface->pSurfDesc->uiOffsets[1]:mediaSurface->pSurfDesc->uiOffsets[2];
gmmCustomParams.NoOfPlanes = mediaSurface->pSurfDesc->uiPlanes/2;
}
switch(uiPlanesOrAuxPlanes)
{
Expand Down

0 comments on commit ca1abd0

Please sign in to comment.