mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Remove access to global platform from cl_gl api
Related-To: NEO-4207 Change-Id: I27fd4e824f347820609e5b4d646f2d29301d6542 Signed-off-by: Andrzej Swierczynski <andrzej.swierczynski@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
2b6fa20e12
commit
6b9d85d2b6
@ -6,9 +6,12 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
|
||||
#include "opencl/source/device/cl_device.h"
|
||||
#include "opencl/test/unit_test/api/cl_api_tests.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_device.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/gl/gl_dll_helper.h"
|
||||
|
||||
using namespace NEO;
|
||||
@ -17,7 +20,7 @@ typedef api_tests clGetGLContextInfoKHR_;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
TEST_F(clGetGLContextInfoKHR_, success) {
|
||||
TEST_F(clGetGLContextInfoKHR_, successWithDefaultPlatform) {
|
||||
auto expectedDevice = ::platform()->getClDevice(0);
|
||||
cl_device_id retDevice = 0;
|
||||
size_t retSize = 0;
|
||||
@ -36,6 +39,35 @@ TEST_F(clGetGLContextInfoKHR_, success) {
|
||||
EXPECT_EQ(sizeof(cl_device_id), retSize);
|
||||
}
|
||||
|
||||
using clGetGLContextInfoKHRNonDefaultPlatform = ::testing::Test;
|
||||
|
||||
TEST_F(clGetGLContextInfoKHRNonDefaultPlatform, successWithNonDefaultPlatform) {
|
||||
platformsImpl.clear();
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
|
||||
auto nonDefaultPlatform = std::make_unique<MockPlatform>();
|
||||
nonDefaultPlatform->initializeWithNewDevices();
|
||||
cl_platform_id nonDefaultPlatformCl = nonDefaultPlatform.get();
|
||||
|
||||
auto expectedDevice = nonDefaultPlatform->getClDevice(0);
|
||||
size_t retSize = 0;
|
||||
cl_device_id retDevice = 0;
|
||||
|
||||
const cl_context_properties properties[] = {CL_GL_CONTEXT_KHR, 1, CL_WGL_HDC_KHR, 2, CL_CONTEXT_PLATFORM, reinterpret_cast<cl_context_properties>(nonDefaultPlatformCl), 0};
|
||||
retVal = clGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, sizeof(cl_device_id), &retDevice, &retSize);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(expectedDevice, retDevice);
|
||||
EXPECT_EQ(sizeof(cl_device_id), retSize);
|
||||
|
||||
retVal = clGetGLContextInfoKHR(properties, CL_DEVICES_FOR_GL_CONTEXT_KHR, sizeof(cl_device_id), &retDevice, &retSize);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(expectedDevice, retDevice);
|
||||
EXPECT_EQ(sizeof(cl_device_id), retSize);
|
||||
}
|
||||
|
||||
TEST_F(clGetGLContextInfoKHR_, invalidParam) {
|
||||
cl_device_id retDevice = 0;
|
||||
size_t retSize = 0;
|
||||
@ -86,10 +118,6 @@ TEST_F(clGetGLContextInfoKHR_, GivenIncorrectPropertiesWhenCallclGetGLContextInf
|
||||
const cl_context_properties propertiesLackOfCLGlContextKhr[] = {CL_WGL_HDC_KHR, 2, 0};
|
||||
retVal = clGetGLContextInfoKHR(propertiesLackOfCLGlContextKhr, 0, sizeof(cl_device_id), &retDevice, &retSize);
|
||||
EXPECT_EQ(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, retVal);
|
||||
|
||||
const cl_context_properties propertiesWithOutRequiredProperties[] = {CL_CONTEXT_PLATFORM, 3, 0};
|
||||
retVal = clGetGLContextInfoKHR(propertiesWithOutRequiredProperties, 0, sizeof(cl_device_id), &retDevice, &retSize);
|
||||
EXPECT_EQ(CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR, retVal);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
Reference in New Issue
Block a user