diff --git a/opencl/test/unit_test/sharings/va/mock_va_sharing.h b/opencl/test/unit_test/sharings/va/mock_va_sharing.h index 04e4a47266..5995619019 100644 --- a/opencl/test/unit_test/sharings/va/mock_va_sharing.h +++ b/opencl/test/unit_test/sharings/va/mock_va_sharing.h @@ -124,7 +124,7 @@ class VASharingFunctionsMock : public VASharingFunctions { return queryImageFormatsReturnStatus; } if (numFormats) { - *numFormats = 4; + *numFormats = 5; } if (formatList) { @@ -143,12 +143,16 @@ class VASharingFunctionsMock : public VASharingFunctions { formatList[3].fourcc = VA_FOURCC_RGBP; formatList[3].bits_per_pixel = 8; formatList[3].byte_order = VA_LSB_FIRST; + + formatList[4].fourcc = VA_FOURCC_YUY2; + formatList[4].bits_per_pixel = 16; + formatList[4].byte_order = VA_LSB_FIRST; } return VA_STATUS_SUCCESS; } int maxNumImageFormats(VADisplay vaDisplay) override { - return 4; + return 5; } }; diff --git a/opencl/test/unit_test/sharings/va/va_sharing_tests.cpp b/opencl/test/unit_test/sharings/va/va_sharing_tests.cpp index 546852d788..c3950d73ee 100644 --- a/opencl/test/unit_test/sharings/va/va_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/va/va_sharing_tests.cpp @@ -1110,6 +1110,7 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat supportedFormats.push_back(std::make_unique(VAImageFormat{VA_FOURCC_NV12, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0})); supportedFormats.push_back(std::make_unique(VAImageFormat{VA_FOURCC_P010, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0})); supportedFormats.push_back(std::make_unique(VAImageFormat{VA_FOURCC_P016, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0})); + supportedFormats.push_back(std::make_unique(VAImageFormat{VA_FOURCC_YUY2, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0})); for (auto flag : flags) { @@ -1125,7 +1126,7 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat &numImageFormats); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(3u, numImageFormats); + EXPECT_EQ(4u, numImageFormats); int i = 0; for (auto &format : supportedFormats) { EXPECT_EQ(format->fourcc, vaApiFormats[i++].fourcc); @@ -1151,7 +1152,7 @@ TEST_F(ApiVaSharingTests, givenZeroNumEntriesWhenGettingSupportedVAApiFormatsThe &numImageFormats); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(3u, numImageFormats); + EXPECT_EQ(4u, numImageFormats); } } @@ -1477,6 +1478,30 @@ TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndSupportedF EXPECT_EQ(static_cast(VA_FOURCC_YUY2), vaApiFormats[4].fourcc); } +TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithPackedFormatsAndSupportedFormatsVectorsThenAllPackedFormatsAreReturned) { + VASharingFunctionsMock sharingFunctions; + EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u); + EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u); + EXPECT_EQ(sharingFunctions.supportedPackedFormats.size(), 0u); + + cl_mem_flags flags = CL_MEM_READ_WRITE; + cl_mem_object_type imageType = CL_MEM_OBJECT_IMAGE2D; + cl_uint numImageFormats = 5; + VAImageFormat vaApiFormats[5] = {}; + + sharingFunctions.supportedPackedFormats.push_back(VAImageFormat{VA_FOURCC_YUY2, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}); + + sharingFunctions.getSupportedFormats( + flags, + imageType, + 0, + 5, + vaApiFormats, + &numImageFormats); + + EXPECT_EQ(static_cast(VA_FOURCC_YUY2), vaApiFormats[0].fourcc); +} + TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndOnly3PlaneSupportedFormatsVectorThen3PlaneFormatIsReturned) { VASharingFunctionsMock sharingFunctions; EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);