55 *
66 */
77
8- #include " core/helpers/options.h"
9- #include " core/unit_tests/helpers/debug_manager_state_restore.h"
10- #include " runtime/context/context.h"
11- #include " runtime/device/device.h"
12- #include " runtime/device_queue/device_queue.h"
13- #include " runtime/os_interface/windows/gl/gl_sharing_os.h"
14- #include " runtime/sharings/gl/windows/gl_sharing.h"
15- #include " unit_tests/fixtures/platform_fixture.h"
16- #include " unit_tests/mocks/mock_context.h"
17- #include " unit_tests/mocks/mock_deferred_deleter.h"
18- #include " unit_tests/mocks/mock_device.h"
19- #include " unit_tests/mocks/mock_memory_manager.h"
8+ #include " unit_tests/context/gl/context_gl_tests.h"
209
21- #include " gtest/gtest.h"
22- #include < GL/gl.h>
10+ #include " runtime/sharings/gl/gl_sharing.h"
2311
24- using namespace NEO ;
12+ namespace NEO {
2513
26- // use mockGlSharing class for cl-gl sharing tests
27- typedef bool (*MockGlIoctlFcn)();
28-
29- struct ContextTest : public PlatformFixture , public ::testing::Test {
30-
31- using PlatformFixture::SetUp;
32-
33- void SetUp () override {
34- PlatformFixture::SetUp ();
35-
36- cl_platform_id platform = pPlatform;
37- properties = new cl_context_properties[3 ];
38- properties[0 ] = CL_CONTEXT_PLATFORM;
39- properties[1 ] = (cl_context_properties)platform;
40- properties[2 ] = 0 ;
41-
42- context = Context::create<MockContext>(properties, ClDeviceVector (devices, num_devices), nullptr , nullptr , retVal);
43- ASSERT_NE (nullptr , context);
44- }
45-
46- void TearDown () override {
47- delete[] properties;
48- delete context;
49- PlatformFixture::TearDown ();
50- }
51-
52- cl_int retVal = CL_SUCCESS;
53- MockContext *context = nullptr ;
54- cl_context_properties *properties = nullptr ;
55- };
56-
57- TEST_F (ContextTest, GlSharingAreIstPresentByDefault) { ASSERT_EQ (context->getSharing <GLSharingFunctions>(), nullptr ); }
58-
59- TEST_F (ContextTest, GivenPropertiesWhenContextIsCreatedThenSuccess) {
60- cl_device_id deviceID = devices[0 ];
61- auto pPlatform = NEO::platform ();
62- cl_platform_id pid[1 ];
63- pid[0 ] = pPlatform;
64-
65- cl_context_properties validProperties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)pid[0 ], CL_GL_CONTEXT_KHR, 0x10000 , 0 };
66-
67- auto context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
68- EXPECT_EQ (CL_SUCCESS, retVal);
69- ASSERT_NE (nullptr , context);
70- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
71- delete context;
72-
73- validProperties[2 ] = CL_EGL_DISPLAY_KHR;
74- context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
75- EXPECT_EQ (CL_SUCCESS, retVal);
76- EXPECT_NE (nullptr , context);
77- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
78- delete context;
79-
80- validProperties[2 ] = CL_GLX_DISPLAY_KHR;
81- context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
82- EXPECT_EQ (CL_SUCCESS, retVal);
83- EXPECT_NE (nullptr , context);
84- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
85- delete context;
86-
87- validProperties[2 ] = CL_WGL_HDC_KHR;
88- context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
89- EXPECT_EQ (CL_SUCCESS, retVal);
90- EXPECT_NE (nullptr , context);
91- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
92- delete context;
93- }
94-
95- TEST_F (ContextTest, GivenTwoGlPropertiesWhenContextIsCreatedThenSuccess) {
96- cl_device_id deviceID = devices[0 ];
97- auto pPlatform = NEO::platform ();
98- cl_platform_id pid[1 ];
99- pid[0 ] = pPlatform;
100-
101- cl_context_properties validProperties[] = {
102- CL_CONTEXT_PLATFORM, (cl_context_properties)pid[0 ], CL_GL_CONTEXT_KHR, 0x10000 , CL_GL_CONTEXT_KHR, 0x10000 , 0 };
103-
104- validProperties[4 ] = CL_EGL_DISPLAY_KHR;
105- auto context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
106- EXPECT_EQ (CL_SUCCESS, retVal);
107- ASSERT_NE (nullptr , context);
108- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
109- delete context;
110-
111- validProperties[4 ] = CL_GLX_DISPLAY_KHR;
112- context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
113- EXPECT_EQ (CL_SUCCESS, retVal);
114- ASSERT_NE (nullptr , context);
115- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
116- delete context;
117-
118- validProperties[4 ] = CL_WGL_HDC_KHR;
119- context = Context::create<Context>(validProperties, ClDeviceVector (&deviceID, 1 ), nullptr , nullptr , retVal);
120- EXPECT_EQ (CL_SUCCESS, retVal);
121- ASSERT_NE (nullptr , context);
122- EXPECT_FALSE (context->getInteropUserSyncEnabled ());
123- delete context;
14+ TEST_F (GlContextTest, GivenDefaultContextThenGlSharingIsDisabled) {
15+ ASSERT_EQ (context->getSharing <GLSharingFunctions>(), nullptr );
12416}
12517
126- TEST_F (ContextTest , GivenGlContextParamWhenCreateContextThenInitSharingFunctions) {
18+ TEST_F (GlContextTest , GivenGlContextParamWhenCreateContextThenInitSharingFunctions) {
12719 cl_device_id deviceID = devices[0 ];
12820 auto pPlatform = NEO::platform ();
12921 cl_platform_id pid[1 ];
@@ -135,10 +27,10 @@ TEST_F(ContextTest, GivenGlContextParamWhenCreateContextThenInitSharingFunctions
13527 EXPECT_EQ (CL_SUCCESS, retVal);
13628 ASSERT_NE (nullptr , ctx);
13729
138- //
13930 auto sharing = ctx->getSharing <GLSharingFunctions>();
14031 ASSERT_NE (nullptr , sharing);
14132 EXPECT_FALSE (context->getInteropUserSyncEnabled ());
14233
14334 delete ctx;
14435}
36+ } // namespace NEO
0 commit comments