clGetDeviceIDsFromVA_APIMediaAdapterINTEL support

Change-Id: I3d43f00795c36562585bee7b4ee96123389586c7
This commit is contained in:
Dunajski, Bartosz
2018-01-29 12:25:49 +01:00
parent f5513b6a1d
commit 6ab39150e0
9 changed files with 72 additions and 6 deletions

2
Jenkinsfile vendored
View File

@ -2,4 +2,4 @@
neoDependenciesRev='730226-753'
strategy='EQUAL'
allowedF=49
allowedCD=366
allowedCD=365

View File

@ -1045,6 +1045,15 @@ typedef CL_API_ENTRY cl_mem(CL_API_CALL *INTELpfn_clCreateFromVA_APIMediaSurface
cl_uint plane,
cl_int *errcodeRet) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int(CL_API_CALL *INTELpfn_clGetDeviceIDsFromVA_APIMediaAdapterINTEL)(
cl_platform_id platform,
cl_va_api_device_source_intel mediaAdapterType,
void *mediaAdapter,
cl_va_api_device_set_intel mediaAdapterSet,
cl_uint numEntries,
cl_device_id *devices,
cl_uint *numDevices) CL_API_SUFFIX__VERSION_1_2;
typedef CL_API_ENTRY cl_int(CL_API_CALL *INTELpfn_clEnqueueAcquireVA_APIMediaSurfacesINTEL)(
cl_command_queue commandQueue,
cl_uint numObjects,
@ -1062,6 +1071,7 @@ typedef CL_API_ENTRY cl_int(CL_API_CALL *INTELpfn_clEnqueueReleaseVA_APIMediaSur
cl_event *event) CL_API_SUFFIX__VERSION_1_2;
#else
typedef void (*INTELpfn_clCreateFromVA_APIMediaSurfaceINTEL)();
typedef void (*INTELpfn_clGetDeviceIDsFromVA_APIMediaAdapterINTEL)();
typedef void (*INTELpfn_clEnqueueAcquireVA_APIMediaSurfacesINTEL)();
typedef void (*INTELpfn_clEnqueueReleaseVA_APIMediaSurfacesINTEL)();
#endif
@ -1270,7 +1280,7 @@ struct SCRTDispatchTable {
// VAMedia sharing extension
#ifdef LIBVA
INTELpfn_clCreateFromVA_APIMediaSurfaceINTEL clCreateFromVA_APIMediaSurfaceINTEL;
void *placeholder15; // clGetDeviceIDsFromVA_APIMediaAdapterINTEL handled by CRT
INTELpfn_clGetDeviceIDsFromVA_APIMediaAdapterINTEL clGetDeviceIDsFromVA_APIMediaAdapterINTEL;
INTELpfn_clEnqueueReleaseVA_APIMediaSurfacesINTEL clEnqueueReleaseVA_APIMediaSurfacesINTEL;
INTELpfn_clEnqueueAcquireVA_APIMediaSurfacesINTEL clEnqueueAcquireVA_APIMediaSurfacesINTEL;
#else

View File

@ -26,6 +26,8 @@
#include "runtime/command_queue/command_queue.h"
#include "runtime/context/context.h"
#include "runtime/helpers/get_info.h"
#include "runtime/platform/platform.h"
#include "runtime/device/device.h"
#include "runtime/sharings/va/va_sharing.h"
#include "runtime/sharings/va/va_surface.h"
#include <cstring>
@ -49,6 +51,23 @@ clCreateFromVA_APIMediaSurfaceINTEL(cl_context context, cl_mem_flags flags, VASu
return VASurface::createSharedVaSurface(pContext, pContext->getSharing<VASharingFunctions>(), flags, surface, plane, errcodeRet);
}
cl_int CL_API_CALL
clGetDeviceIDsFromVA_APIMediaAdapterINTEL(cl_platform_id platform, cl_va_api_device_source_intel mediaAdapterType,
void *mediaAdapter, cl_va_api_device_set_intel mediaAdapterSet, cl_uint numEntries,
cl_device_id *devices, cl_uint *numDevices) {
Platform *pPlatform = nullptr;
auto status = validateObjects(WithCastToInternal(platform, &pPlatform));
if (status != CL_SUCCESS) {
return CL_INVALID_PLATFORM;
}
cl_device_id device = pPlatform->getDevice(0);
GetInfoHelper::set(devices, device);
GetInfoHelper::set(numDevices, 1u);
return CL_SUCCESS;
}
cl_int CL_API_CALL
clEnqueueAcquireVA_APIMediaSurfacesINTEL(cl_command_queue commandQueue,
cl_uint numObjects,

View File

@ -76,6 +76,7 @@ std::string VaSharingBuilderFactory::getExtensions() {
void VaSharingBuilderFactory::fillGlobalDispatchTable() {
crtGlobalDispatchTable.clCreateFromVA_APIMediaSurfaceINTEL = clCreateFromVA_APIMediaSurfaceINTEL;
crtGlobalDispatchTable.clGetDeviceIDsFromVA_APIMediaAdapterINTEL = clGetDeviceIDsFromVA_APIMediaAdapterINTEL;
crtGlobalDispatchTable.clEnqueueReleaseVA_APIMediaSurfacesINTEL = clEnqueueReleaseVA_APIMediaSurfacesINTEL;
crtGlobalDispatchTable.clEnqueueAcquireVA_APIMediaSurfacesINTEL = clEnqueueAcquireVA_APIMediaSurfacesINTEL;
}
@ -88,6 +89,7 @@ void VaSharingBuilderFactory::fillGlobalDispatchTable() {
}
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);
@ -95,5 +97,5 @@ void *VaSharingBuilderFactory::getExtensionFunctionAddress(const std::string &fu
}
static SharingFactory::RegisterSharing<VaSharingBuilderFactory, VASharingFunctions> vaSharing;
}
} // namespace OCLRT
#endif

View File

@ -226,8 +226,6 @@ TYPED_TEST(BaseObjectTests, commonRuntimeExpectsDispatchTableAtFirstPointerInObj
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder12);
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder13);
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder15);
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder18);
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder19);
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder20);

View File

@ -42,4 +42,9 @@ TEST_F(clGetExtensionFunctionAddressTests, clEnqueueReleaseVA_APIMediaSurfacesIN
auto retVal = clGetExtensionFunctionAddress("clEnqueueReleaseVA_APIMediaSurfacesINTEL");
EXPECT_EQ(retVal, reinterpret_cast<void *>(clEnqueueReleaseVA_APIMediaSurfacesINTEL));
}
TEST_F(clGetExtensionFunctionAddressTests, clGetDeviceIDsFromVA_APIMediaAdapterINTEL) {
auto retVal = clGetExtensionFunctionAddress("clGetDeviceIDsFromVA_APIMediaAdapterINTEL");
EXPECT_EQ(retVal, reinterpret_cast<void *>(clGetDeviceIDsFromVA_APIMediaAdapterINTEL));
}
} // namespace ULT

View File

@ -71,5 +71,8 @@ TYPED_TEST(VABaseObjectTests, commonRuntimeExpectsDispatchTableAtFirstPointerInO
EXPECT_EQ(reinterpret_cast<void *>(clEnqueueReleaseVA_APIMediaSurfacesINTEL),
genericObject->dispatch.crtDispatch->clEnqueueReleaseVA_APIMediaSurfacesINTEL);
EXPECT_EQ(reinterpret_cast<void *>(clGetDeviceIDsFromVA_APIMediaAdapterINTEL),
genericObject->dispatch.crtDispatch->clGetDeviceIDsFromVA_APIMediaAdapterINTEL);
}
} // namespace OCLRT

View File

@ -96,10 +96,12 @@ TEST_F(VaSharingEnablerTests, givenVaFactoryWhenAskedThenGlobalIcdIsConfigured)
crtGlobalDispatchTable.clCreateFromVA_APIMediaSurfaceINTEL = nullptr;
crtGlobalDispatchTable.clEnqueueReleaseVA_APIMediaSurfacesINTEL = nullptr;
crtGlobalDispatchTable.clEnqueueAcquireVA_APIMediaSurfacesINTEL = nullptr;
crtGlobalDispatchTable.clGetDeviceIDsFromVA_APIMediaAdapterINTEL = nullptr;
factory->fillGlobalDispatchTable();
EXPECT_NE(nullptr, crtGlobalDispatchTable.clCreateFromVA_APIMediaSurfaceINTEL);
EXPECT_NE(nullptr, crtGlobalDispatchTable.clEnqueueAcquireVA_APIMediaSurfacesINTEL);
EXPECT_NE(nullptr, crtGlobalDispatchTable.clEnqueueAcquireVA_APIMediaSurfacesINTEL);
EXPECT_NE(nullptr, crtGlobalDispatchTable.clGetDeviceIDsFromVA_APIMediaAdapterINTEL);
}
TEST_F(VaSharingEnablerTests, givenVaFactoryWhenAskedThenBuilderIsCreated) {

View File

@ -22,18 +22,21 @@
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "runtime/device/device.h"
#include "runtime/platform/platform.h"
#include "runtime/sharings/va/va_sharing.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/sharings/va/mock_va_sharing.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "runtime/sharings/va/va_surface.h"
#include "runtime/api/api.h"
#include "gtest/gtest.h"
using namespace OCLRT;
class VaSharingTests : public ::testing::Test {
class VaSharingTests : public ::testing::Test, public PlatformFixture {
public:
void SetUp() override {
PlatformFixture::SetUp(numPlatformDevices, platformDevices);
vaSharing = new MockVaSharing;
context.setSharingFunctions(&vaSharing->m_sharingFunctions);
vaSharing->updateAcquiredHandle(sharingHandle);
@ -47,6 +50,7 @@ class VaSharingTests : public ::testing::Test {
}
context.releaseSharingFunctions(SharingType::VA_SHARING);
delete vaSharing;
PlatformFixture::TearDown();
}
void updateAcquiredHandle(unsigned int handle) {
@ -398,3 +402,26 @@ TEST_F(VaSharingTests, givenContextWhenEmptySharingTableEmptyThenReturnsNullptr)
VASharingFunctions *sharingF = context.getSharing<VASharingFunctions>();
EXPECT_EQ(sharingF, nullptr);
}
TEST_F(VaSharingTests, givenValidPlatformWhenGetDeviceIdsFromVaApiMediaAdapterCalledThenReturnFirstDevice) {
cl_device_id devices = 0;
cl_uint numDevices = 0;
cl_platform_id platformId = this->pPlatform;
auto errCode = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(platformId, 0u, nullptr, 0u, 1, &devices, &numDevices);
EXPECT_EQ(CL_SUCCESS, errCode);
EXPECT_EQ(1u, numDevices);
EXPECT_NE(nullptr, platform()->getDevice(0));
EXPECT_EQ(platform()->getDevice(0), devices);
}
TEST_F(VaSharingTests, givenInValidPlatformWhenGetDeviceIdsFromVaApiMediaAdapterCalledThenReturnFirstDevice) {
cl_device_id devices = 0;
cl_uint numDevices = 0;
auto errCode = clGetDeviceIDsFromVA_APIMediaAdapterINTEL(nullptr, 0u, nullptr, 0u, 1, &devices, &numDevices);
EXPECT_EQ(CL_INVALID_PLATFORM, errCode);
EXPECT_EQ(0u, numDevices);
EXPECT_EQ(0u, devices);
}