Revert "Modifications to cl_intel_va_api_media_sharing"

This reverts commit 4c27d46de3.

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-01-27 10:07:26 +01:00
committed by Compute-Runtime-Automation
parent 4c27d46de3
commit ccf9d72019
9 changed files with 49 additions and 323 deletions

View File

@ -141,7 +141,6 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
cl_mem_object_type imageType, cl_mem_object_type imageType,
cl_uint plane,
cl_uint numEntries, cl_uint numEntries,
VAImageFormat *vaApiFormats, VAImageFormat *vaApiFormats,
cl_uint *numImageFormats) { cl_uint *numImageFormats) {
@ -156,5 +155,5 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
return CL_INVALID_CONTEXT; return CL_INVALID_CONTEXT;
} }
return pSharing->getSupportedFormats(flags, imageType, plane, numEntries, vaApiFormats, numImageFormats); return pSharing->getSupportedFormats(flags, imageType, numEntries, vaApiFormats, numImageFormats);
} }

View File

@ -12,7 +12,6 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
cl_context context, cl_context context,
cl_mem_flags flags, cl_mem_flags flags,
cl_mem_object_type imageType, cl_mem_object_type imageType,
cl_uint plane,
cl_uint numEntries, cl_uint numEntries,
VAImageFormat *vaApiFormats, VAImageFormat *vaApiFormats,
cl_uint *numImageFormats); cl_uint *numImageFormats);

View File

@ -76,16 +76,15 @@ void VASharingFunctions::initFunctions() {
} }
void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) { void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
UNRECOVERABLE_IF(supportedFormats.size() != 0);
int maxFormats = this->maxNumImageFormats(vaDisplay); int maxFormats = this->maxNumImageFormats(vaDisplay);
if (maxFormats > 0) { if (maxFormats > 0) {
std::unique_ptr<VAImageFormat[]> allVaFormats(new VAImageFormat[maxFormats]); std::unique_ptr<VAImageFormat[]> allVaFormats(new VAImageFormat[maxFormats]);
this->queryImageFormats(vaDisplay, allVaFormats.get(), &maxFormats); this->queryImageFormats(vaDisplay, allVaFormats.get(), &maxFormats);
for (int i = 0; i < maxFormats; i++) { for (int i = 0; i < maxFormats; i++) {
if (VASurface::isSupportedFourCCTwoPlaneFormat(allVaFormats[i].fourcc)) { if (VASurface::isSupportedFourCC(allVaFormats[i].fourcc)) {
supported2PlaneFormats.emplace_back(allVaFormats[i]); supportedFormats.emplace_back(allVaFormats[i]);
} else if (VASurface::isSupportedFourCCThreePlaneFormat(allVaFormats[i].fourcc)) {
supported3PlaneFormats.emplace_back(allVaFormats[i]);
} }
} }
} }
@ -93,7 +92,6 @@ void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags, cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags,
cl_mem_object_type imageType, cl_mem_object_type imageType,
cl_uint plane,
cl_uint numEntries, cl_uint numEntries,
VAImageFormat *formats, VAImageFormat *formats,
cl_uint *numImageFormats) { cl_uint *numImageFormats) {
@ -106,26 +104,12 @@ cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags,
} }
if (numImageFormats != nullptr) { if (numImageFormats != nullptr) {
if (plane == 2) { *numImageFormats = static_cast<cl_uint>(supportedFormats.size());
*numImageFormats = static_cast<cl_uint>(supported3PlaneFormats.size());
} else if (plane < 2) {
*numImageFormats = static_cast<cl_uint>(supported2PlaneFormats.size() + supported3PlaneFormats.size());
}
} }
if (plane == 2) { if (formats != nullptr && supportedFormats.size() > 0) {
if (formats != nullptr && supported3PlaneFormats.size() > 0) { uint32_t elementsToCopy = std::min(numEntries, static_cast<uint32_t>(supportedFormats.size()));
uint32_t elementsToCopy = std::min(numEntries, static_cast<uint32_t>(supported3PlaneFormats.size())); memcpy_s(formats, elementsToCopy * sizeof(VAImageFormat), &supportedFormats[0], elementsToCopy * sizeof(VAImageFormat));
memcpy_s(formats, elementsToCopy * sizeof(VAImageFormat), &supported3PlaneFormats[0], elementsToCopy * sizeof(VAImageFormat));
}
} else if (plane < 2) {
if (formats != nullptr && (supported2PlaneFormats.size() > 0 || supported3PlaneFormats.size() > 0)) {
uint32_t elementsToCopy = std::min(numEntries, static_cast<uint32_t>(supported2PlaneFormats.size() + supported3PlaneFormats.size()));
std::vector<VAImageFormat> tmp_formats;
tmp_formats.insert(tmp_formats.end(), supported2PlaneFormats.begin(), supported2PlaneFormats.end());
tmp_formats.insert(tmp_formats.end(), supported3PlaneFormats.begin(), supported3PlaneFormats.end());
memcpy_s(formats, elementsToCopy * sizeof(VAImageFormat), &tmp_formats[0], elementsToCopy * sizeof(VAImageFormat));
}
} }
return CL_SUCCESS; return CL_SUCCESS;

View File

@ -71,7 +71,6 @@ class VASharingFunctions : public SharingFunctions {
cl_int getSupportedFormats(cl_mem_flags flags, cl_int getSupportedFormats(cl_mem_flags flags,
cl_mem_object_type imageType, cl_mem_object_type imageType,
cl_uint plane,
cl_uint numEntries, cl_uint numEntries,
VAImageFormat *formats, VAImageFormat *formats,
cl_uint *numImageFormats); cl_uint *numImageFormats);
@ -95,7 +94,6 @@ class VASharingFunctions : public SharingFunctions {
VAQueryImageFormatsPFN vaQueryImageFormatsPFN; VAQueryImageFormatsPFN vaQueryImageFormatsPFN;
VAMaxNumImageFormatsPFN vaMaxNumImageFormatsPFN; VAMaxNumImageFormatsPFN vaMaxNumImageFormatsPFN;
std::vector<VAImageFormat> supported2PlaneFormats; std::vector<VAImageFormat> supportedFormats;
std::vector<VAImageFormat> supported3PlaneFormats;
}; };
} // namespace NEO } // namespace NEO

View File

@ -210,20 +210,11 @@ const ClSurfaceFormatInfo *VASurface::getExtendedSurfaceFormatInfo(uint32_t form
return nullptr; return nullptr;
} }
bool VASurface::isSupportedFourCCTwoPlaneFormat(int fourcc) { bool VASurface::isSupportedFourCC(int fourcc) {
if ((fourcc == VA_FOURCC_NV12) || if ((fourcc == VA_FOURCC_NV12) ||
(fourcc == VA_FOURCC_P010) || (DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_P010)) {
(fourcc == VA_FOURCC_P016)) {
return true; return true;
} }
return false; return false;
} }
bool VASurface::isSupportedFourCCThreePlaneFormat(int fourcc) {
if (DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_RGBP) {
return true;
}
return false;
}
} // namespace NEO } // namespace NEO

View File

@ -25,8 +25,7 @@ class VASurface : VASharing {
static bool validate(cl_mem_flags flags, cl_uint plane); static bool validate(cl_mem_flags flags, cl_uint plane);
static const ClSurfaceFormatInfo *getExtendedSurfaceFormatInfo(uint32_t formatFourCC); static const ClSurfaceFormatInfo *getExtendedSurfaceFormatInfo(uint32_t formatFourCC);
static bool isSupportedFourCCTwoPlaneFormat(int fourcc); static bool isSupportedFourCC(int fourcc);
static bool isSupportedFourCCThreePlaneFormat(int fourcc);
protected: protected:
VASurface(VASharingFunctions *sharingFunctions, VAImageID imageId, VASurface(VASharingFunctions *sharingFunctions, VAImageID imageId,

View File

@ -17,8 +17,7 @@ namespace NEO {
class VASharingFunctionsMock : public VASharingFunctions { class VASharingFunctionsMock : public VASharingFunctions {
public: public:
using VASharingFunctions::supported2PlaneFormats; using VASharingFunctions::supportedFormats;
using VASharingFunctions::supported3PlaneFormats;
VAImage mockVaImage = {}; VAImage mockVaImage = {};
int32_t derivedImageFormatFourCC = VA_FOURCC_NV12; int32_t derivedImageFormatFourCC = VA_FOURCC_NV12;
@ -116,7 +115,7 @@ class VASharingFunctionsMock : public VASharingFunctions {
return queryImageFormatsReturnStatus; return queryImageFormatsReturnStatus;
} }
if (numFormats) { if (numFormats) {
*numFormats = 4; *numFormats = 2;
} }
if (formatList) { if (formatList) {
@ -125,22 +124,14 @@ class VASharingFunctionsMock : public VASharingFunctions {
formatList[0].byte_order = VA_LSB_FIRST; formatList[0].byte_order = VA_LSB_FIRST;
formatList[1].fourcc = VA_FOURCC_P010; formatList[1].fourcc = VA_FOURCC_P010;
formatList[1].bits_per_pixel = 10; formatList[1].bits_per_pixel = 24;
formatList[1].byte_order = VA_LSB_FIRST; formatList[1].byte_order = VA_LSB_FIRST;
formatList[2].fourcc = VA_FOURCC_P016;
formatList[2].bits_per_pixel = 16;
formatList[2].byte_order = VA_LSB_FIRST;
formatList[3].fourcc = VA_FOURCC_RGBP;
formatList[3].bits_per_pixel = 8;
formatList[3].byte_order = VA_LSB_FIRST;
} }
return VA_STATUS_SUCCESS; return VA_STATUS_SUCCESS;
} }
int maxNumImageFormats(VADisplay vaDisplay) override { int maxNumImageFormats(VADisplay vaDisplay) override {
return 4; return 2;
} }
}; };

View File

@ -188,19 +188,13 @@ TEST(VASharingFunctions, givenEnabledExtendedVaFormatsWhenQueryingSupportedForma
sharingFunctions.querySupportedVaImageFormats(VADisplay(1)); sharingFunctions.querySupportedVaImageFormats(VADisplay(1));
EXPECT_EQ(3u, sharingFunctions.supported2PlaneFormats.size()); EXPECT_EQ(2u, sharingFunctions.supportedFormats.size());
EXPECT_EQ(1u, sharingFunctions.supported3PlaneFormats.size());
size_t allFormatsFound = 0; size_t allFormatsFound = 0;
for (const auto &supported2PlaneFormat : sharingFunctions.supported2PlaneFormats) { for (const auto &supportedFormat : sharingFunctions.supportedFormats) {
if (supported2PlaneFormat.fourcc == VA_FOURCC_NV12 || supported2PlaneFormat.fourcc == VA_FOURCC_P010 || supported2PlaneFormat.fourcc == VA_FOURCC_P016) { if (supportedFormat.fourcc == VA_FOURCC_NV12 || supportedFormat.fourcc == VA_FOURCC_P010) {
allFormatsFound++; allFormatsFound++;
} }
} }
for (const auto &supported3PlaneFormat : sharingFunctions.supported3PlaneFormats) { EXPECT_EQ(2u, allFormatsFound);
if (supported3PlaneFormat.fourcc == VA_FOURCC_RGBP) {
allFormatsFound++;
}
}
EXPECT_EQ(4u, allFormatsFound);
} }

View File

@ -785,31 +785,22 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat
VAImageFormat vaApiFormats[10] = {}; VAImageFormat vaApiFormats[10] = {};
cl_uint numImageFormats = 0; cl_uint numImageFormats = 0;
std::vector<std::unique_ptr<VAImageFormat>> supportedFormats; VAImageFormat supportedFormat = {VA_FOURCC_NV12, VA_LSB_FIRST, 8, 0, 0, 0, 0, 0};
supportedFormats.push_back(std::make_unique<VAImageFormat>(VAImageFormat{VA_FOURCC_NV12, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0}));
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}));
for (auto flag : flags) { for (auto flag : flags) {
for (auto plane : {0, 1}) { cl_int result = clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
&context,
flag,
image_type,
arrayCount(vaApiFormats),
vaApiFormats,
&numImageFormats);
cl_int result = clGetSupportedVA_APIMediaSurfaceFormatsINTEL( EXPECT_EQ(CL_SUCCESS, result);
&context, EXPECT_EQ(1u, numImageFormats);
flag,
image_type,
plane,
arrayCount(vaApiFormats),
vaApiFormats,
&numImageFormats);
EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(supportedFormat.fourcc, vaApiFormats[0].fourcc);
EXPECT_EQ(3u, numImageFormats);
int i = 0;
for (auto &format : supportedFormats) {
EXPECT_EQ(format->fourcc, vaApiFormats[i++].fourcc);
}
}
} }
} }
@ -818,20 +809,16 @@ TEST_F(ApiVaSharingTests, givenZeroNumEntriesWhenGettingSupportedVAApiFormatsThe
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D; cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 0; cl_uint numImageFormats = 0;
for (auto plane : {0, 1}) { cl_int result = clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
&context,
flags,
image_type,
0,
nullptr,
&numImageFormats);
cl_int result = clGetSupportedVA_APIMediaSurfaceFormatsINTEL( EXPECT_EQ(CL_SUCCESS, result);
&context, EXPECT_EQ(1u, numImageFormats);
flags,
image_type,
plane,
0,
nullptr,
&numImageFormats);
EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(3u, numImageFormats);
}
} }
TEST_F(ApiVaSharingTests, givenNullNumImageFormatsWhenGettingSupportedVAApiFormatsThenNumFormatsIsNotDereferenced) { TEST_F(ApiVaSharingTests, givenNullNumImageFormatsWhenGettingSupportedVAApiFormatsThenNumFormatsIsNotDereferenced) {
@ -843,7 +830,6 @@ TEST_F(ApiVaSharingTests, givenNullNumImageFormatsWhenGettingSupportedVAApiForma
flags, flags,
image_type, image_type,
0, 0,
0,
nullptr, nullptr,
nullptr); nullptr);
@ -860,7 +846,6 @@ TEST_F(ApiVaSharingTests, givenInvalidImageTypeWhenGettingSupportedVAApiFormatsT
&context, &context,
flags, flags,
image_type, image_type,
0,
arrayCount(vaApiFormats), arrayCount(vaApiFormats),
vaApiFormats, vaApiFormats,
&numImageFormats); &numImageFormats);
@ -879,7 +864,6 @@ TEST_F(ApiVaSharingTests, givenInvalidFlagsWhenGettingSupportedVAApiFormatsThenI
&context, &context,
flags, flags,
image_type, image_type,
0,
arrayCount(vaApiFormats), arrayCount(vaApiFormats),
vaApiFormats, vaApiFormats,
&numImageFormats); &numImageFormats);
@ -899,7 +883,6 @@ TEST_F(ApiVaSharingTests, givenInvalidContextWhenGettingSupportedVAApiFormatsThe
&contextWihtoutVASharing, &contextWihtoutVASharing,
flags, flags,
image_type, image_type,
0,
arrayCount(vaApiFormats), arrayCount(vaApiFormats),
vaApiFormats, vaApiFormats,
&numImageFormats); &numImageFormats);
@ -923,10 +906,10 @@ TEST(VaSurface, givenInValidPlaneOrFlagsWhenValidatingInputsThenTrueIsReturned)
} }
TEST(VaSurface, givenNotSupportedVaFormatsWhenCheckingIfSupportedThenFalseIsReturned) { TEST(VaSurface, givenNotSupportedVaFormatsWhenCheckingIfSupportedThenFalseIsReturned) {
EXPECT_FALSE(VASurface::isSupportedFourCCTwoPlaneFormat(VA_FOURCC_NV11)); EXPECT_FALSE(VASurface::isSupportedFourCC(VA_FOURCC_NV11));
DebugManagerStateRestore restore; DebugManagerStateRestore restore;
DebugManager.flags.EnableExtendedVaFormats.set(true); DebugManager.flags.EnableExtendedVaFormats.set(true);
EXPECT_FALSE(VASurface::isSupportedFourCCThreePlaneFormat(VA_FOURCC_NV11)); EXPECT_FALSE(VASurface::isSupportedFourCC(VA_FOURCC_NV11));
EXPECT_EQ(nullptr, VASurface::getExtendedSurfaceFormatInfo(VA_FOURCC_NV11)); EXPECT_EQ(nullptr, VASurface::getExtendedSurfaceFormatInfo(VA_FOURCC_NV11));
} }
@ -936,14 +919,13 @@ TEST(VaSharingFunctions, givenErrorReturnedFromVaLibWhenQuerySupportedVaImageFor
sharingFunctions.querySupportedVaImageFormats(VADisplay(1)); sharingFunctions.querySupportedVaImageFormats(VADisplay(1));
EXPECT_EQ(0u, sharingFunctions.supported2PlaneFormats.size()); EXPECT_EQ(0u, sharingFunctions.supportedFormats.size());
EXPECT_EQ(0u, sharingFunctions.supported3PlaneFormats.size());
} }
TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormatsThenSupportedFormatsAreNotSet) { TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormatsThenSupportedFormatsAreNotSet) {
VASharingFunctionsMock sharingFunctions; VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(0u, sharingFunctions.supported2PlaneFormats.size()); EXPECT_EQ(0u, sharingFunctions.supportedFormats.size());
EXPECT_EQ(0u, sharingFunctions.supported3PlaneFormats.size());
cl_mem_flags flags = CL_MEM_READ_WRITE; cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D; cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 0; cl_uint numImageFormats = 0;
@ -952,7 +934,6 @@ TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormats
sharingFunctions.getSupportedFormats( sharingFunctions.getSupportedFormats(
flags, flags,
image_type, image_type,
0,
10, 10,
vaApiFormats, vaApiFormats,
&numImageFormats); &numImageFormats);
@ -963,11 +944,11 @@ TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormats
TEST(VaSharingFunctions, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupportedFormatsThenOnlyNumEntiresAreReturned) { TEST(VaSharingFunctions, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupportedFormatsThenOnlyNumEntiresAreReturned) {
VASharingFunctionsMock sharingFunctions; VASharingFunctionsMock sharingFunctions;
VAImageFormat imageFormat = {VA_FOURCC_NV12, 1, 12}; VAImageFormat imageFormat = {VA_FOURCC_NV12, 1, 12};
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat); sharingFunctions.supportedFormats.emplace_back(imageFormat);
imageFormat.fourcc = VA_FOURCC_P010; imageFormat.fourcc = VA_FOURCC_NV21;
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat); sharingFunctions.supportedFormats.emplace_back(imageFormat);
EXPECT_EQ(2u, sharingFunctions.supported2PlaneFormats.size()); EXPECT_EQ(2u, sharingFunctions.supportedFormats.size());
cl_mem_flags flags = CL_MEM_READ_WRITE; cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D; cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
@ -977,7 +958,6 @@ TEST(VaSharingFunctions, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupp
sharingFunctions.getSupportedFormats( sharingFunctions.getSupportedFormats(
flags, flags,
image_type, image_type,
0,
1, 1,
vaApiFormats, vaApiFormats,
&numImageFormats); &numImageFormats);
@ -1018,212 +998,3 @@ TEST_F(VaSharingTests, givenInteropUserSyncIsNotSpecifiedDuringContextCreationWh
EXPECT_EQ(!specifyInteropUseSync, mockCommandQueue.finishCalled); EXPECT_EQ(!specifyInteropUseSync, mockCommandQueue.finishCalled);
} }
} }
TEST_F(VaSharingTests, givenPlaneArgumentEquals2WithEmptySupported3PlaneFormatsVectorThentNoFormatIsReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 4;
VAImageFormat vaApiFormats[4] = {};
sharingFunctions.getSupportedFormats(
flags,
image_type,
2,
1,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(0u, vaApiFormats[0].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentGreaterThan2ThenNoFormatIsReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
VAImageFormat imageFormat = {VA_FOURCC_RGBP, 1, 12};
sharingFunctions.supported3PlaneFormats.emplace_back(imageFormat);
imageFormat = {VA_FOURCC_NV12, 1, 12};
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 2;
VAImageFormat vaApiFormats[2] = {};
sharingFunctions.getSupportedFormats(
flags,
image_type,
3,
1,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(0u, vaApiFormats[0].fourcc);
EXPECT_EQ(0u, vaApiFormats[1].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentEquals2ThenOnlyRGBPFormatIsReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
VAImageFormat imageFormat = {VA_FOURCC_RGBP, 1, 12};
sharingFunctions.supported3PlaneFormats.emplace_back(imageFormat);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 1;
VAImageFormat vaApiFormats[3] = {};
sharingFunctions.getSupportedFormats(
flags,
image_type,
2,
1,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_RGBP), vaApiFormats[0].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndEmptySupportedFormatsVectorsThenNoFormatIsReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 1;
VAImageFormat vaApiFormats[3] = {};
sharingFunctions.getSupportedFormats(
flags,
image_type,
0,
1,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(0u, vaApiFormats[0].fourcc);
VAImageFormat imageFormat = {VA_FOURCC_NV12, 1, 12};
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat);
sharingFunctions.supported3PlaneFormats.emplace_back(imageFormat);
sharingFunctions.getSupportedFormats(
flags,
image_type,
0,
1,
nullptr,
&numImageFormats);
EXPECT_EQ(0u, vaApiFormats[0].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndSupportedFormatsVectorsThenAll2And3PlaneFormatsAreReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 4;
VAImageFormat vaApiFormats[4] = {};
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_NV12, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_P010, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_P016, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.supported3PlaneFormats.push_back(VAImageFormat{VA_FOURCC_RGBP, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.getSupportedFormats(
flags,
image_type,
0,
4,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_NV12), vaApiFormats[0].fourcc);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_P010), vaApiFormats[1].fourcc);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_P016), vaApiFormats[2].fourcc);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_RGBP), vaApiFormats[3].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndOnly3PlaneSupportedFormatsVectorThen3PlaneFormatIsReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 4;
VAImageFormat vaApiFormats[4] = {};
sharingFunctions.supported3PlaneFormats.push_back(VAImageFormat{VA_FOURCC_RGBP, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
sharingFunctions.getSupportedFormats(
flags,
image_type,
0,
4,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_RGBP), vaApiFormats[0].fourcc);
EXPECT_EQ(0u, vaApiFormats[1].fourcc);
EXPECT_EQ(0u, vaApiFormats[2].fourcc);
EXPECT_EQ(0u, vaApiFormats[3].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentLessThan2WithProperFormatsAndOnly2PlaneSupportedFormatsVectorThen2PlaneFormatsAreReturned) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 4;
VAImageFormat vaApiFormats[4] = {};
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_NV12, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_P010, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
sharingFunctions.supported2PlaneFormats.push_back(VAImageFormat{VA_FOURCC_P016, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
sharingFunctions.getSupportedFormats(
flags,
image_type,
0,
4,
vaApiFormats,
&numImageFormats);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_NV12), vaApiFormats[0].fourcc);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_P010), vaApiFormats[1].fourcc);
EXPECT_EQ(static_cast<uint32_t>(VA_FOURCC_P016), vaApiFormats[2].fourcc);
EXPECT_EQ(0u, vaApiFormats[3].fourcc);
}
TEST_F(VaSharingTests, givenPlaneArgumentEquals2WithoutNoProperFormatsThenReturn) {
VASharingFunctionsMock sharingFunctions;
EXPECT_EQ(sharingFunctions.supported2PlaneFormats.size(), 0u);
EXPECT_EQ(sharingFunctions.supported3PlaneFormats.size(), 0u);
cl_mem_flags flags = CL_MEM_READ_WRITE;
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
cl_uint numImageFormats = 1;
sharingFunctions.supported3PlaneFormats.push_back(VAImageFormat{VA_FOURCC_RGBP, VA_LSB_FIRST, 0, 0, 0, 0, 0, 0});
cl_int result = sharingFunctions.getSupportedFormats(
flags,
image_type,
2,
4,
nullptr,
&numImageFormats);
EXPECT_EQ(result, CL_SUCCESS);
}