83 lines
3.7 KiB
C++
83 lines
3.7 KiB
C++
/*
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included
|
|
* in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
#include "runtime/device/device.h"
|
|
#include "runtime/helpers/options.h"
|
|
#include "runtime/helpers/get_info.h"
|
|
#include "gtest/gtest.h"
|
|
#include "gmock/gmock.h"
|
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
|
#include "unit_tests/mocks/mock_device.h"
|
|
|
|
using namespace ::testing;
|
|
|
|
namespace OCLRT {
|
|
TEST(DeviceOsTest, osSpecificExtensions) {
|
|
auto hwInfo = *platformDevices;
|
|
auto pDevice = Device::create<OCLRT::Device>(hwInfo);
|
|
|
|
std::string extensionString(pDevice->getDeviceInfo().deviceExtensions);
|
|
|
|
EXPECT_THAT(extensionString, Not(HasSubstr(std::string("cl_intel_va_api_media_sharing "))));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_intel_dx9_media_sharing ")));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_khr_dx9_media_sharing ")));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_khr_d3d10_sharing ")));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_khr_d3d11_sharing ")));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_intel_d3d11_nv12_media_sharing ")));
|
|
EXPECT_THAT(extensionString, HasSubstr(std::string("cl_intel_simultaneous_sharing ")));
|
|
|
|
delete pDevice;
|
|
}
|
|
|
|
TEST(DeviceOsTest, supportedSimultaneousInterops) {
|
|
auto pDevice = std::unique_ptr<Device>(Device::create<OCLRT::Device>(*platformDevices));
|
|
|
|
std::vector<unsigned int> expected = {CL_GL_CONTEXT_KHR,
|
|
CL_WGL_HDC_KHR,
|
|
CL_CONTEXT_ADAPTER_D3D9_KHR,
|
|
CL_CONTEXT_D3D9_DEVICE_INTEL,
|
|
CL_CONTEXT_ADAPTER_D3D9EX_KHR,
|
|
CL_CONTEXT_D3D9EX_DEVICE_INTEL,
|
|
CL_CONTEXT_ADAPTER_DXVA_KHR,
|
|
CL_CONTEXT_DXVA_DEVICE_INTEL,
|
|
CL_CONTEXT_D3D10_DEVICE_KHR,
|
|
CL_CONTEXT_D3D11_DEVICE_KHR,
|
|
0};
|
|
|
|
EXPECT_TRUE(pDevice->simultaneousInterops == expected);
|
|
}
|
|
|
|
TEST(DeviceOsTest, DeviceCreationFail) {
|
|
auto hwInfo = *platformDevices;
|
|
auto pDevice = Device::create<OCLRT::FailDevice>(hwInfo);
|
|
|
|
EXPECT_THAT(pDevice, nullptr);
|
|
}
|
|
|
|
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
|
|
DebugManagerStateRestore dbgRestore;
|
|
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
|
|
auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(nullptr);
|
|
|
|
EXPECT_THAT(pDevice, nullptr);
|
|
}
|
|
} // namespace OCLRT
|