mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
Modifications to cl_intel_va_api_media_sharing
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
72e002a3ca
commit
4c27d46de3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -141,6 +141,7 @@ 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) {
|
||||
@@ -155,5 +156,5 @@ cl_int CL_API_CALL clGetSupportedVA_APIMediaSurfaceFormatsINTEL(
|
||||
return CL_INVALID_CONTEXT;
|
||||
}
|
||||
|
||||
return pSharing->getSupportedFormats(flags, imageType, numEntries, vaApiFormats, numImageFormats);
|
||||
return pSharing->getSupportedFormats(flags, imageType, plane, numEntries, vaApiFormats, numImageFormats);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -12,6 +12,7 @@ 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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -76,15 +76,16 @@ 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::isSupportedFourCC(allVaFormats[i].fourcc)) {
|
||||
supportedFormats.emplace_back(allVaFormats[i]);
|
||||
if (VASurface::isSupportedFourCCTwoPlaneFormat(allVaFormats[i].fourcc)) {
|
||||
supported2PlaneFormats.emplace_back(allVaFormats[i]);
|
||||
} else if (VASurface::isSupportedFourCCThreePlaneFormat(allVaFormats[i].fourcc)) {
|
||||
supported3PlaneFormats.emplace_back(allVaFormats[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +93,7 @@ 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) {
|
||||
@@ -104,12 +106,26 @@ cl_int VASharingFunctions::getSupportedFormats(cl_mem_flags flags,
|
||||
}
|
||||
|
||||
if (numImageFormats != nullptr) {
|
||||
*numImageFormats = static_cast<cl_uint>(supportedFormats.size());
|
||||
if (plane == 2) {
|
||||
*numImageFormats = static_cast<cl_uint>(supported3PlaneFormats.size());
|
||||
} else if (plane < 2) {
|
||||
*numImageFormats = static_cast<cl_uint>(supported2PlaneFormats.size() + supported3PlaneFormats.size());
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -71,6 +71,7 @@ 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);
|
||||
@@ -94,6 +95,7 @@ class VASharingFunctions : public SharingFunctions {
|
||||
VAQueryImageFormatsPFN vaQueryImageFormatsPFN;
|
||||
VAMaxNumImageFormatsPFN vaMaxNumImageFormatsPFN;
|
||||
|
||||
std::vector<VAImageFormat> supportedFormats;
|
||||
std::vector<VAImageFormat> supported2PlaneFormats;
|
||||
std::vector<VAImageFormat> supported3PlaneFormats;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -210,11 +210,20 @@ const ClSurfaceFormatInfo *VASurface::getExtendedSurfaceFormatInfo(uint32_t form
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool VASurface::isSupportedFourCC(int fourcc) {
|
||||
bool VASurface::isSupportedFourCCTwoPlaneFormat(int fourcc) {
|
||||
if ((fourcc == VA_FOURCC_NV12) ||
|
||||
(DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_P010)) {
|
||||
(fourcc == VA_FOURCC_P010) ||
|
||||
(fourcc == VA_FOURCC_P016)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VASurface::isSupportedFourCCThreePlaneFormat(int fourcc) {
|
||||
if (DebugManager.flags.EnableExtendedVaFormats.get() && fourcc == VA_FOURCC_RGBP) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -25,7 +25,8 @@ class VASurface : VASharing {
|
||||
|
||||
static bool validate(cl_mem_flags flags, cl_uint plane);
|
||||
static const ClSurfaceFormatInfo *getExtendedSurfaceFormatInfo(uint32_t formatFourCC);
|
||||
static bool isSupportedFourCC(int fourcc);
|
||||
static bool isSupportedFourCCTwoPlaneFormat(int fourcc);
|
||||
static bool isSupportedFourCCThreePlaneFormat(int fourcc);
|
||||
|
||||
protected:
|
||||
VASurface(VASharingFunctions *sharingFunctions, VAImageID imageId,
|
||||
|
||||
Reference in New Issue
Block a user