mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
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:

committed by
Compute-Runtime-Automation

parent
4c27d46de3
commit
ccf9d72019
@ -141,7 +141,6 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
|
||||
cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_object_type imageType,
|
||||
cl_uint plane,
|
||||
cl_uint numEntries,
|
||||
VAImageFormat *vaApiFormats,
|
||||
cl_uint *numImageFormats) {
|
||||
@ -156,5 +155,5 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
|
||||
return CL_INVALID_CONTEXT;
|
||||
}
|
||||
|
||||
return pSharing->getSupportedFormats(flags, imageType, plane, numEntries, vaApiFormats, numImageFormats);
|
||||
return pSharing->getSupportedFormats(flags, imageType, numEntries, vaApiFormats, numImageFormats);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
|
||||
cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_object_type imageType,
|
||||
cl_uint plane,
|
||||
cl_uint numEntries,
|
||||
VAImageFormat *vaApiFormats,
|
||||
cl_uint *numImageFormats);
|
||||
|
@ -76,16 +76,15 @@ void VASharingFunctions::initFunctions() {
|
||||
}
|
||||
|
||||
void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
|
||||
UNRECOVERABLE_IF(supportedFormats.size() != 0);
|
||||
int maxFormats = this->maxNumImageFormats(vaDisplay);
|
||||
if (maxFormats > 0) {
|
||||
std::unique_ptr<VAImageFormat[]> allVaFormats(new VAImageFormat[maxFormats]);
|
||||
this->queryImageFormats(vaDisplay, allVaFormats.get(), &maxFormats);
|
||||
|
||||
for (int i = 0; i < maxFormats; i++) {
|
||||
if (VASurface::isSupportedFourCCTwoPlaneFormat(allVaFormats[i].fourcc)) {
|
||||
supported2PlaneFormats.emplace_back(allVaFormats[i]);
|
||||
} else if (VASurface::isSupportedFourCCThreePlaneFormat(allVaFormats[i].fourcc)) {
|
||||
supported3PlaneFormats.emplace_back(allVaFormats[i]);
|
||||
if (VASurface::isSupportedFourCC(allVaFormats[i].fourcc)) {
|
||||
supportedFormats.emplace_back(allVaFormats[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +92,6 @@ void VASharingFunctions::querySupportedVaImageFormats(VADisplay vaDisplay) {
|
||||
|
||||
cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags,
|
||||
cl_mem_object_type imageType,
|
||||
cl_uint plane,
|
||||
cl_uint numEntries,
|
||||
VAImageFormat *formats,
|
||||
cl_uint *numImageFormats) {
|
||||
@ -106,26 +104,12 @@ cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags,
|
||||
}
|
||||
|
||||
if (numImageFormats != nullptr) {
|
||||
if (plane == 2) {
|
||||
*numImageFormats = static_cast<cl_uint>(supported3PlaneFormats.size());
|
||||
} else if (plane < 2) {
|
||||
*numImageFormats = static_cast<cl_uint>(supported2PlaneFormats.size() + supported3PlaneFormats.size());
|
||||
}
|
||||
*numImageFormats = static_cast<cl_uint>(supportedFormats.size());
|
||||
}
|
||||
|
||||
if (plane == 2) {
|
||||
if (formats != nullptr && supported3PlaneFormats.size() > 0) {
|
||||
uint32_t elementsToCopy = std::min(numEntries, static_cast<uint32_t>(supported3PlaneFormats.size()));
|
||||
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));
|
||||
}
|
||||
if (formats != nullptr && supportedFormats.size() > 0) {
|
||||
uint32_t elementsToCopy = std::min(numEntries, static_cast<uint32_t>(supportedFormats.size()));
|
||||
memcpy_s(formats, elementsToCopy * sizeof(VAImageFormat), &supportedFormats[0], elementsToCopy * sizeof(VAImageFormat));
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
@ -71,7 +71,6 @@ class VASharingFunctions : public SharingFunctions {
|
||||
|
||||
cl_int getSupportedFormats(cl_mem_flags flags,
|
||||
cl_mem_object_type imageType,
|
||||
cl_uint plane,
|
||||
cl_uint numEntries,
|
||||
VAImageFormat *formats,
|
||||
cl_uint *numImageFormats);
|
||||
@ -95,7 +94,6 @@ class VASharingFunctions : public SharingFunctions {
|
||||
VAQueryImageFormatsPFN vaQueryImageFormatsPFN;
|
||||
VAMaxNumImageFormatsPFN vaMaxNumImageFormatsPFN;
|
||||
|
||||
std::vector<VAImageFormat> supported2PlaneFormats;
|
||||
std::vector<VAImageFormat> supported3PlaneFormats;
|
||||
std::vector<VAImageFormat> supportedFormats;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
@ -210,20 +210,11 @@ const ClSurfaceFormatInfo *VASurface::getExtendedSurfaceFormatInfo(uint32_t form
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool VASurface::isSupportedFourCCTwoPlaneFormat(int fourcc) {
|
||||
bool VASurface::isSupportedFourCC(int fourcc) {
|
||||
if ((fourcc == VA_FOURCC_NV12) ||
|
||||
(fourcc == VA_FOURCC_P010) ||
|
||||
(fourcc == VA_FOURCC_P016)) {
|
||||
(DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_P010)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VASurface::isSupportedFourCCThreePlaneFormat(int fourcc) {
|
||||
if (DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_RGBP) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -25,8 +25,7 @@ class VASurface : VASharing {
|
||||
|
||||
static bool validate(cl_mem_flags flags, cl_uint plane);
|
||||
static const ClSurfaceFormatInfo *getExtendedSurfaceFormatInfo(uint32_t formatFourCC);
|
||||
static bool isSupportedFourCCTwoPlaneFormat(int fourcc);
|
||||
static bool isSupportedFourCCThreePlaneFormat(int fourcc);
|
||||
static bool isSupportedFourCC(int fourcc);
|
||||
|
||||
protected:
|
||||
VASurface(VASharingFunctions *sharingFunctions, VAImageID imageId,
|
||||
|
@ -17,8 +17,7 @@ namespace NEO {
|
||||
|
||||
class VASharingFunctionsMock : public VASharingFunctions {
|
||||
public:
|
||||
using VASharingFunctions::supported2PlaneFormats;
|
||||
using VASharingFunctions::supported3PlaneFormats;
|
||||
using VASharingFunctions::supportedFormats;
|
||||
|
||||
VAImage mockVaImage = {};
|
||||
int32_t derivedImageFormatFourCC = VA_FOURCC_NV12;
|
||||
@ -116,7 +115,7 @@ class VASharingFunctionsMock : public VASharingFunctions {
|
||||
return queryImageFormatsReturnStatus;
|
||||
}
|
||||
if (numFormats) {
|
||||
*numFormats = 4;
|
||||
*numFormats = 2;
|
||||
}
|
||||
|
||||
if (formatList) {
|
||||
@ -125,22 +124,14 @@ class VASharingFunctionsMock : public VASharingFunctions {
|
||||
formatList[0].byte_order = VA_LSB_FIRST;
|
||||
|
||||
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[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;
|
||||
}
|
||||
|
||||
int maxNumImageFormats(VADisplay vaDisplay) override {
|
||||
return 4;
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -188,19 +188,13 @@ TEST(VASharingFunctions, givenEnabledExtendedVaFormatsWhenQueryingSupportedForma
|
||||
|
||||
sharingFunctions.querySupportedVaImageFormats(VADisplay(1));
|
||||
|
||||
EXPECT_EQ(3u, sharingFunctions.supported2PlaneFormats.size());
|
||||
EXPECT_EQ(1u, sharingFunctions.supported3PlaneFormats.size());
|
||||
EXPECT_EQ(2u, sharingFunctions.supportedFormats.size());
|
||||
|
||||
size_t allFormatsFound = 0;
|
||||
for (const auto &supported2PlaneFormat : sharingFunctions.supported2PlaneFormats) {
|
||||
if (supported2PlaneFormat.fourcc == VA_FOURCC_NV12 || supported2PlaneFormat.fourcc == VA_FOURCC_P010 || supported2PlaneFormat.fourcc == VA_FOURCC_P016) {
|
||||
for (const auto &supportedFormat : sharingFunctions.supportedFormats) {
|
||||
if (supportedFormat.fourcc == VA_FOURCC_NV12 || supportedFormat.fourcc == VA_FOURCC_P010) {
|
||||
allFormatsFound++;
|
||||
}
|
||||
}
|
||||
for (const auto &supported3PlaneFormat : sharingFunctions.supported3PlaneFormats) {
|
||||
if (supported3PlaneFormat.fourcc == VA_FOURCC_RGBP) {
|
||||
allFormatsFound++;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(4u, allFormatsFound);
|
||||
EXPECT_EQ(2u, allFormatsFound);
|
||||
}
|
||||
|
@ -785,31 +785,22 @@ TEST_F(ApiVaSharingTests, givenSupportedImageTypeWhenGettingSupportedVAApiFormat
|
||||
VAImageFormat vaApiFormats[10] = {};
|
||||
cl_uint numImageFormats = 0;
|
||||
|
||||
std::vector<std::unique_ptr<VAImageFormat>> supportedFormats;
|
||||
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}));
|
||||
VAImageFormat supportedFormat = {VA_FOURCC_NV12, VA_LSB_FIRST, 8, 0, 0, 0, 0, 0};
|
||||
|
||||
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(
|
||||
&context,
|
||||
flag,
|
||||
image_type,
|
||||
plane,
|
||||
arrayCount(vaApiFormats),
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
EXPECT_EQ(CL_SUCCESS, result);
|
||||
EXPECT_EQ(1u, numImageFormats);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, result);
|
||||
EXPECT_EQ(3u, numImageFormats);
|
||||
int i = 0;
|
||||
for (auto &format : supportedFormats) {
|
||||
EXPECT_EQ(format->fourcc, vaApiFormats[i++].fourcc);
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(supportedFormat.fourcc, vaApiFormats[0].fourcc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -818,20 +809,16 @@ TEST_F(ApiVaSharingTests, givenZeroNumEntriesWhenGettingSupportedVAApiFormatsThe
|
||||
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
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(
|
||||
&context,
|
||||
flags,
|
||||
image_type,
|
||||
plane,
|
||||
0,
|
||||
nullptr,
|
||||
&numImageFormats);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, result);
|
||||
EXPECT_EQ(3u, numImageFormats);
|
||||
}
|
||||
EXPECT_EQ(CL_SUCCESS, result);
|
||||
EXPECT_EQ(1u, numImageFormats);
|
||||
}
|
||||
|
||||
TEST_F(ApiVaSharingTests, givenNullNumImageFormatsWhenGettingSupportedVAApiFormatsThenNumFormatsIsNotDereferenced) {
|
||||
@ -843,7 +830,6 @@ TEST_F(ApiVaSharingTests, givenNullNumImageFormatsWhenGettingSupportedVAApiForma
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
@ -860,7 +846,6 @@ TEST_F(ApiVaSharingTests, givenInvalidImageTypeWhenGettingSupportedVAApiFormatsT
|
||||
&context,
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
arrayCount(vaApiFormats),
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
@ -879,7 +864,6 @@ TEST_F(ApiVaSharingTests, givenInvalidFlagsWhenGettingSupportedVAApiFormatsThenI
|
||||
&context,
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
arrayCount(vaApiFormats),
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
@ -899,7 +883,6 @@ TEST_F(ApiVaSharingTests, givenInvalidContextWhenGettingSupportedVAApiFormatsThe
|
||||
&contextWihtoutVASharing,
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
arrayCount(vaApiFormats),
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
@ -923,10 +906,10 @@ TEST(VaSurface, givenInValidPlaneOrFlagsWhenValidatingInputsThenTrueIsReturned)
|
||||
}
|
||||
|
||||
TEST(VaSurface, givenNotSupportedVaFormatsWhenCheckingIfSupportedThenFalseIsReturned) {
|
||||
EXPECT_FALSE(VASurface::isSupportedFourCCTwoPlaneFormat(VA_FOURCC_NV11));
|
||||
EXPECT_FALSE(VASurface::isSupportedFourCC(VA_FOURCC_NV11));
|
||||
DebugManagerStateRestore restore;
|
||||
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));
|
||||
}
|
||||
|
||||
@ -936,14 +919,13 @@ TEST(VaSharingFunctions, givenErrorReturnedFromVaLibWhenQuerySupportedVaImageFor
|
||||
|
||||
sharingFunctions.querySupportedVaImageFormats(VADisplay(1));
|
||||
|
||||
EXPECT_EQ(0u, sharingFunctions.supported2PlaneFormats.size());
|
||||
EXPECT_EQ(0u, sharingFunctions.supported3PlaneFormats.size());
|
||||
EXPECT_EQ(0u, sharingFunctions.supportedFormats.size());
|
||||
}
|
||||
|
||||
TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormatsThenSupportedFormatsAreNotSet) {
|
||||
VASharingFunctionsMock sharingFunctions;
|
||||
EXPECT_EQ(0u, sharingFunctions.supported2PlaneFormats.size());
|
||||
EXPECT_EQ(0u, sharingFunctions.supported3PlaneFormats.size());
|
||||
EXPECT_EQ(0u, sharingFunctions.supportedFormats.size());
|
||||
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE;
|
||||
cl_mem_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_uint numImageFormats = 0;
|
||||
@ -952,7 +934,6 @@ TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormats
|
||||
sharingFunctions.getSupportedFormats(
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
10,
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
@ -963,11 +944,11 @@ TEST(VaSharingFunctions, givenNoSupportedFormatsWhenQuerySupportedVaImageFormats
|
||||
TEST(VaSharingFunctions, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupportedFormatsThenOnlyNumEntiresAreReturned) {
|
||||
VASharingFunctionsMock sharingFunctions;
|
||||
VAImageFormat imageFormat = {VA_FOURCC_NV12, 1, 12};
|
||||
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat);
|
||||
imageFormat.fourcc = VA_FOURCC_P010;
|
||||
sharingFunctions.supported2PlaneFormats.emplace_back(imageFormat);
|
||||
sharingFunctions.supportedFormats.emplace_back(imageFormat);
|
||||
imageFormat.fourcc = VA_FOURCC_NV21;
|
||||
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_object_type image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
@ -977,7 +958,6 @@ TEST(VaSharingFunctions, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupp
|
||||
sharingFunctions.getSupportedFormats(
|
||||
flags,
|
||||
image_type,
|
||||
0,
|
||||
1,
|
||||
vaApiFormats,
|
||||
&numImageFormats);
|
||||
@ -1018,212 +998,3 @@ TEST_F(VaSharingTests, givenInteropUserSyncIsNotSpecifiedDuringContextCreationWh
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user