mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 08:07:19 +08:00
Change-Id: If4fa5e748d673dedf85bc96d4311fcaf8c88a64e Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
94 lines
3.1 KiB
C++
94 lines
3.1 KiB
C++
/*
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#ifdef LIBVA
|
|
|
|
#include "runtime/sharings/va/enable_va.h"
|
|
|
|
#include "runtime/api/api.h"
|
|
#include "runtime/context/context.h"
|
|
#include "runtime/context/context.inl"
|
|
#include "runtime/sharings/sharing_factory.h"
|
|
#include "runtime/sharings/sharing_factory.inl"
|
|
#include "runtime/sharings/va/cl_va_api.h"
|
|
#include "runtime/sharings/va/va_sharing.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace NEO {
|
|
|
|
bool VaSharingContextBuilder::processProperties(cl_context_properties &propertyType, cl_context_properties &propertyValue, cl_int &errcodeRet) {
|
|
if (contextData.get() == nullptr) {
|
|
contextData = std::make_unique<VaCreateContextProperties>();
|
|
}
|
|
bool res = false;
|
|
|
|
switch (propertyType) {
|
|
case CL_CONTEXT_VA_API_DISPLAY_INTEL:
|
|
contextData->vaDisplay = (VADisplay)propertyValue;
|
|
res = true;
|
|
break;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
bool VaSharingContextBuilder::finalizeProperties(Context &context, int32_t &errcodeRet) {
|
|
if (contextData.get() == nullptr)
|
|
return true;
|
|
|
|
if (contextData->vaDisplay) {
|
|
context.registerSharing(new VASharingFunctions(contextData->vaDisplay));
|
|
if (!context.getSharing<VASharingFunctions>()->isValidVaDisplay()) {
|
|
errcodeRet = CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL;
|
|
return false;
|
|
}
|
|
context.getSharing<VASharingFunctions>()->querySupportedVaImageFormats(contextData->vaDisplay);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
std::unique_ptr<SharingContextBuilder> VaSharingBuilderFactory::createContextBuilder() {
|
|
return std::make_unique<VaSharingContextBuilder>();
|
|
};
|
|
|
|
std::string VaSharingBuilderFactory::getExtensions() {
|
|
if (VASharingFunctions::isVaLibraryAvailable()) {
|
|
return "cl_intel_va_api_media_sharing ";
|
|
}
|
|
return "";
|
|
}
|
|
|
|
void VaSharingBuilderFactory::fillGlobalDispatchTable() {
|
|
crtGlobalDispatchTable.clCreateFromVA_APIMediaSurfaceINTEL = clCreateFromVA_APIMediaSurfaceINTEL;
|
|
crtGlobalDispatchTable.clGetDeviceIDsFromVA_APIMediaAdapterINTEL = clGetDeviceIDsFromVA_APIMediaAdapterINTEL;
|
|
crtGlobalDispatchTable.clEnqueueReleaseVA_APIMediaSurfacesINTEL = clEnqueueReleaseVA_APIMediaSurfacesINTEL;
|
|
crtGlobalDispatchTable.clEnqueueAcquireVA_APIMediaSurfacesINTEL = clEnqueueAcquireVA_APIMediaSurfacesINTEL;
|
|
}
|
|
|
|
#define RETURN_FUNC_PTR_IF_EXIST(name) \
|
|
{ \
|
|
if (functionName == #name) { \
|
|
return ((void *)(name)); \
|
|
} \
|
|
}
|
|
void *VaSharingBuilderFactory::getExtensionFunctionAddress(const std::string &functionName) {
|
|
RETURN_FUNC_PTR_IF_EXIST(clCreateFromVA_APIMediaSurfaceINTEL);
|
|
RETURN_FUNC_PTR_IF_EXIST(clGetDeviceIDsFromVA_APIMediaAdapterINTEL);
|
|
RETURN_FUNC_PTR_IF_EXIST(clEnqueueAcquireVA_APIMediaSurfacesINTEL);
|
|
RETURN_FUNC_PTR_IF_EXIST(clEnqueueReleaseVA_APIMediaSurfacesINTEL);
|
|
|
|
if (DebugManager.flags.EnableFormatQuery.get()) {
|
|
RETURN_FUNC_PTR_IF_EXIST(clGetSupportedVA_APIMediaSurfaceFormatsINTEL);
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
static SharingFactory::RegisterSharing<VaSharingBuilderFactory, VASharingFunctions> vaSharing;
|
|
} // namespace NEO
|
|
#endif
|