Add support for Y210 format in cl_va sharing

Related-To: NEO-7245

Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
Kamil Diedrich
2022-09-23 22:00:34 +02:00
committed by Compute-Runtime-Automation
parent 6102f02080
commit 842003f827
3 changed files with 86 additions and 7 deletions

View File

@@ -36,6 +36,8 @@ bool VASurface::isSupportedPackedFormat(uint32_t imageFourcc) {
switch (imageFourcc) {
case VA_FOURCC_YUY2:
return true;
case VA_FOURCC_Y210:
return true;
default:
return false;
}
@@ -287,6 +289,16 @@ const ClSurfaceFormatInfo *VASurface::getExtendedSurfaceFormatInfo(uint32_t form
2}};
return &formatInfoYUY2;
}
if (formatFourCC == VA_FOURCC_Y210) {
static const ClSurfaceFormatInfo formatInfoY210 = {{CL_RGBA, CL_UNORM_INT16},
{GMM_RESOURCE_FORMAT::GMM_FORMAT_Y210,
static_cast<GFX3DSTATE_SURFACEFORMAT>(GFX3DSTATE_SURFACEFORMAT_R16G16B16A16_UNORM),
0,
4,
2,
8}};
return &formatInfoY210;
}
return nullptr;
}

View File

@@ -124,7 +124,7 @@ class VASharingFunctionsMock : public VASharingFunctions {
return queryImageFormatsReturnStatus;
}
if (numFormats) {
*numFormats = 5;
*numFormats = 6;
}
if (formatList) {
@@ -147,12 +147,16 @@ class VASharingFunctionsMock : public VASharingFunctions {
formatList[4].fourcc = VA_FOURCC_YUY2;
formatList[4].bits_per_pixel = 16;
formatList[4].byte_order = VA_LSB_FIRST;
formatList[5].fourcc = VA_FOURCC_Y210;
formatList[5].bits_per_pixel = 32;
formatList[5].byte_order = VA_LSB_FIRST;
}
return VA_STATUS_SUCCESS;
}
int maxNumImageFormats(VADisplay vaDisplay) override {
return 5;
return 6;
}
};

View File

@@ -291,17 +291,19 @@ TEST_F(VaSharingTests, givenSupportedFourccFormatWhenIsSupportedPlanarFormatThen
TEST_F(VaSharingTests, givenSupportedPackedFormatWhenIsSupportedPlanarFormatThenFailIsReturned) {
EXPECT_FALSE(VASurface::isSupportedPlanarFormat(VA_FOURCC_YUY2));
EXPECT_FALSE(VASurface::isSupportedPlanarFormat(VA_FOURCC_Y210));
}
TEST_F(VaSharingTests, givenSupportedFourccFormatWhenIsSupportedPackedFormatThenSuccessIsReturned) {
EXPECT_TRUE(VASurface::isSupportedPackedFormat(VA_FOURCC_YUY2));
EXPECT_TRUE(VASurface::isSupportedPackedFormat(VA_FOURCC_Y210));
}
TEST_F(VaSharingTests, givenSupportedPlanarFormatWhenIsSupportedPackedFormatThenFailIsReturned) {
EXPECT_FALSE(VASurface::isSupportedPackedFormat(VA_FOURCC_NV12));
}
TEST_F(VaSharingTests, givenValidSurfaceWhenGetSurfaceDescriptionThenCLSuccessIsReturnedAndDataAreSet) {
TEST_F(VaSharingTests, givenValidYUY2SurfaceWhenGetSurfaceDescriptionThenCLSuccessIsReturnedAndDataAreSet) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true);
vaSharing->sharingFunctions.haveExportSurfaceHandle = true;
@@ -324,7 +326,30 @@ TEST_F(VaSharingTests, givenValidSurfaceWhenGetSurfaceDescriptionThenCLSuccessIs
EXPECT_FALSE(surfaceInfo.imgInfo.linearStorage);
}
TEST_F(VaSharingTests, givenValidSurfaceWithInvalidPlaneNumberWhenGetSurfaceDescriptionThenFailIsReturned) {
TEST_F(VaSharingTests, givenValidY210SurfaceWhenGetSurfaceDescriptionThenCLSuccessIsReturnedAndDataAreSet) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true);
vaSharing->sharingFunctions.haveExportSurfaceHandle = true;
vaSharing->sharingFunctions.mockVaSurfaceDesc.fourcc = VA_FOURCC_Y210;
vaSharing->sharingFunctions.mockVaSurfaceDesc.objects[0] = {8, 98304, I915_FORMAT_MOD_Y_TILED};
vaSharing->sharingFunctions.mockVaSurfaceDesc.num_layers = 1;
vaSharing->sharingFunctions.mockVaSurfaceDesc.layers[0] = {DRM_FORMAT_Y210, 1, {}, {0, 0, 0, 0}, {256, 0, 0, 0}};
vaSharing->sharingFunctions.mockVaSurfaceDesc.width = 24;
vaSharing->sharingFunctions.mockVaSurfaceDesc.height = 24;
vaSharing->sharingFunctions.derivedImageFormatBpp = 32;
vaSharing->sharingFunctions.derivedImageFormatFourCC = VA_FOURCC_Y210;
SharedSurfaceInfo surfaceInfo{};
EXPECT_EQ(VA_STATUS_SUCCESS, VASurface::getSurfaceDescription(surfaceInfo, &vaSharing->sharingFunctions, &vaSurfaceId));
EXPECT_EQ(vaSharing->sharingFunctions.mockVaSurfaceDesc.height, surfaceInfo.imgInfo.imgDesc.imageWidth);
EXPECT_EQ(vaSharing->sharingFunctions.mockVaSurfaceDesc.width, surfaceInfo.imgInfo.imgDesc.imageHeight);
EXPECT_EQ(static_cast<uint32_t>(vaSharing->sharingFunctions.mockVaSurfaceDesc.objects[0].fd), surfaceInfo.sharedHandle);
EXPECT_EQ(vaSharing->sharingFunctions.mockVaSurfaceDesc.fourcc, surfaceInfo.imageFourcc);
EXPECT_FALSE(surfaceInfo.imgInfo.linearStorage);
}
TEST_F(VaSharingTests, givenValidYUY2SurfaceWithInvalidPlaneNumberWhenGetSurfaceDescriptionThenFailIsReturned) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true);
vaSharing->sharingFunctions.haveExportSurfaceHandle = true;
@@ -343,6 +368,25 @@ TEST_F(VaSharingTests, givenValidSurfaceWithInvalidPlaneNumberWhenGetSurfaceDesc
EXPECT_EQ(VA_STATUS_ERROR_INVALID_PARAMETER, VASurface::getSurfaceDescription(surfaceInfo, &vaSharing->sharingFunctions, &vaSurfaceId));
}
TEST_F(VaSharingTests, givenValidY210SurfaceWithInvalidPlaneNumberWhenGetSurfaceDescriptionThenFailIsReturned) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true);
vaSharing->sharingFunctions.haveExportSurfaceHandle = true;
vaSharing->sharingFunctions.mockVaSurfaceDesc.fourcc = VA_FOURCC_Y210;
vaSharing->sharingFunctions.mockVaSurfaceDesc.objects[0] = {8, 98304, I915_FORMAT_MOD_Y_TILED};
vaSharing->sharingFunctions.mockVaSurfaceDesc.num_layers = 1;
vaSharing->sharingFunctions.mockVaSurfaceDesc.layers[0] = {DRM_FORMAT_Y210, 1, {}, {0, 0, 0, 0}, {256, 0, 0, 0}};
vaSharing->sharingFunctions.mockVaSurfaceDesc.width = 24;
vaSharing->sharingFunctions.mockVaSurfaceDesc.height = 24;
vaSharing->sharingFunctions.derivedImageFormatBpp = 32;
vaSharing->sharingFunctions.derivedImageFormatFourCC = VA_FOURCC_Y210;
SharedSurfaceInfo surfaceInfo{};
surfaceInfo.plane = 1;
EXPECT_EQ(VA_STATUS_ERROR_INVALID_PARAMETER, VASurface::getSurfaceDescription(surfaceInfo, &vaSharing->sharingFunctions, &vaSurfaceId));
}
TEST_F(VaSharingTests, givenValidPlanarSurfaceWithPlaneSetWhenGetSurfaceDescriptionThenCLSuccessIsReturnedAndDataAreSet) {
DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true);
@@ -378,7 +422,8 @@ TEST_F(VaSharingTests, givenValidPlanarSurfaceWithPlaneSetWhenGetSurfaceDescript
EXPECT_EQ(surfaceInfo.imageOffset, vaSharing->sharingFunctions.mockVaSurfaceDesc.layers[2].offset[0]);
EXPECT_EQ(surfaceInfo.imagePitch, vaSharing->sharingFunctions.mockVaSurfaceDesc.layers[2].pitch[0]);
}
TEST_F(VaSharingTests, givenValidSurfaceWhenGetSurfaceDescriptionWithDeriveImageThenCLSuccessIsReturnedAndDataAreSet) {
TEST_F(VaSharingTests, givenValidYUY2SurfaceWhenGetSurfaceDescriptionWithDeriveImageThenCLSuccessIsReturnedAndDataAreSet) {
vaSharing->sharingFunctions.derivedImageFormatBpp = 16;
vaSharing->sharingFunctions.derivedImageFormatFourCC = VA_FOURCC_YUY2;
vaSharing->sharingFunctions.derivedImageHeight = 24;
@@ -391,6 +436,23 @@ TEST_F(VaSharingTests, givenValidSurfaceWhenGetSurfaceDescriptionWithDeriveImage
EXPECT_EQ(static_cast<uint32_t>(vaSharing->sharingFunctions.derivedImageFormatFourCC), surfaceInfo.imageFourcc);
}
TEST_F(VaSharingTests, givenValidY210SurfaceWhenGetSurfaceDescriptionWithDeriveImageThenCLSuccessIsReturnedAndDataAreSet) {
vaSharing->sharingFunctions.derivedImageFormatBpp = 32;
vaSharing->sharingFunctions.derivedImageFormatFourCC = VA_FOURCC_Y210;
vaSharing->sharingFunctions.derivedImageHeight = 24;
vaSharing->sharingFunctions.derivedImageWidth = 24;
SharedSurfaceInfo surfaceInfo{};
EXPECT_EQ(VA_STATUS_SUCCESS, VASurface::getSurfaceDescription(surfaceInfo, &vaSharing->sharingFunctions, &vaSurfaceId));
EXPECT_EQ(vaSharing->sharingFunctions.derivedImageHeight, surfaceInfo.imgInfo.imgDesc.imageWidth);
EXPECT_EQ(vaSharing->sharingFunctions.derivedImageWidth, surfaceInfo.imgInfo.imgDesc.imageHeight);
EXPECT_EQ(static_cast<uint32_t>(vaSharing->sharingFunctions.derivedImageFormatFourCC), surfaceInfo.imageFourcc);
}
TEST(VASurface, givenSupportedY210PackedFormatWhenCheckingIfSupportedThenSurfaceDescIsReturned) {
EXPECT_NE(nullptr, VASurface::getExtendedSurfaceFormatInfo(VA_FOURCC_Y210));
}
TEST_F(VaSharingTests, givenValidSurfaceWithInvalidPlaneNumberWhenGetSurfaceDescriptionWithDeriveImageThenFailIsReturned) {
vaSharing->sharingFunctions.derivedImageFormatBpp = 16;
vaSharing->sharingFunctions.derivedImageFormatFourCC = VA_FOURCC_YUY2;
@@ -1111,6 +1173,7 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat
supportedFormats.push_back(std::make_unique<VAImageFormat>(VAImageFormat{VA_FOURCC_P010, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}));
supportedFormats.push_back(std::make_unique<VAImageFormat>(VAImageFormat{VA_FOURCC_P016, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}));
supportedFormats.push_back(std::make_unique<VAImageFormat>(VAImageFormat{VA_FOURCC_YUY2, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}));
supportedFormats.push_back(std::make_unique<VAImageFormat>(VAImageFormat{VA_FOURCC_Y210, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}));
for (auto flag : flags) {
@@ -1126,7 +1189,7 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat
&numImageFormats);
EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(4u, numImageFormats);
EXPECT_EQ(5u, numImageFormats);
int i = 0;
for (auto &format : supportedFormats) {
EXPECT_EQ(format->fourcc, vaApiFormats[i++].fourcc);
@@ -1152,7 +1215,7 @@ TEST_F(ApiVaSharingTests, givenZeroNumEntriesWhenGettingSupportedVAApiFormatsThe
&numImageFormats);
EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(4u, numImageFormats);
EXPECT_EQ(5u, numImageFormats);
}
}