| 1 | /* |
| 2 | * Copyright (C) 2018-2025 Intel Corporation |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include "shared/source/execution_environment/execution_environment.h" |
| 9 | #include "shared/source/memory_manager/os_agnostic_memory_manager.h" |
| 10 | #include "shared/source/os_interface/os_interface.h" |
| 11 | #include "shared/test/common/mocks/mock_csr.h" |
| 12 | #include "shared/test/common/mocks/mock_device.h" |
| 13 | #include "shared/test/common/test_macros/hw_test.h" |
| 14 | |
| 15 | #include "opencl/source/context/context.h" |
| 16 | #include "opencl/source/event/user_event.h" |
| 17 | #include "opencl/source/platform/platform.h" |
| 18 | #include "opencl/source/sharings/gl/gl_arb_sync_event.h" |
| 19 | #include "opencl/source/sharings/sharing.h" |
| 20 | #include "opencl/test/unit_test/mocks/gl/windows/mock_gl_arb_sync_event_windows.h" |
| 21 | #include "opencl/test/unit_test/mocks/gl/windows/mock_gl_sharing_windows.h" |
| 22 | #include "opencl/test/unit_test/mocks/mock_cl_device.h" |
| 23 | #include "opencl/test/unit_test/mocks/mock_command_queue.h" |
| 24 | #include "opencl/test/unit_test/mocks/mock_context.h" |
| 25 | #include "opencl/test/unit_test/mocks/mock_event.h" |
| 26 | #include "opencl/test/unit_test/mocks/mock_platform.h" |
| 27 | |
| 28 | using namespace NEO; |
| 29 | |
| 30 | TEST(GlArbSyncEvent, whenCreateArbSyncEventNameIsCalledMultipleTimesThenEachCallReturnsUniqueName) { |
| 31 | char *name1 = NEO::createArbSyncEventName(); |
| 32 | EXPECT_NE(nullptr, name1); |
| 33 | EXPECT_STRNE("", name1); |
| 34 | |
| 35 | char *name2 = NEO::createArbSyncEventName(); |
| 36 | EXPECT_NE(nullptr, name2); |
| 37 | EXPECT_STRNE("", name2); |
| 38 | |
| 39 | char *name3 = NEO::createArbSyncEventName(); |
| 40 | EXPECT_NE(nullptr, name3); |
| 41 | EXPECT_STRNE("", name3); |
| 42 | |
| 43 | EXPECT_STRNE(name1, name2); |
| 44 | EXPECT_STRNE(name1, name3); |
| 45 | EXPECT_STRNE(name2, name3); |
| 46 | |
| 47 | NEO::destroyArbSyncEventName(name1); |
| 48 | NEO::destroyArbSyncEventName(name2); |
| 49 | NEO::destroyArbSyncEventName(name3); |
| 50 | } |
| 51 | |
| 52 | template <bool signalWaited> |
| 53 | inline void glArbSyncObjectWaitServerMock(NEO::OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) { |
| 54 | glSyncInfo.waitCalled = signalWaited; |
| 55 | } |
| 56 | |
| 57 | struct MockBaseEvent : Event { |
| 58 | using Event::Event; |
| 59 | bool wasUpdated = false; |
| 60 | void updateExecutionStatus() override { |
| 61 | Event::updateExecutionStatus(); |
| 62 | wasUpdated = true; |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | struct GlArbSyncEventTest : public ::testing::Test { |
| 67 | GlArbSyncEventTest(void) { |
| 68 | } |
| 69 | |
| 70 | void SetUp() override { |
| 71 | EnvironmentWithCsrWrapper environment; |
| 72 | environment.setCsrType<MockCommandStreamReceiver>(); |
| 73 | executionEnvironment = platform()->peekExecutionEnvironment(); |
| 74 | executionEnvironment->memoryManager = std::make_unique<OsAgnosticMemoryManager>(*executionEnvironment); |
| 75 | device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0u)); |
| 76 | ctx.reset(new MockContext); |
| 77 | cmdQ.reset(new MockCommandQueue(ctx.get(), device.get(), nullptr, false)); |
| 78 | sharing = new GlSharingFunctionsMock(); |
| 79 | ctx->setSharingFunctions(sharing); |
| 80 | sharing->pfnGlArbSyncObjectCleanup = glArbSyncObjectCleanupMockDoNothing; |
| 81 | sharing->pfnGlArbSyncObjectSetup = mockGlArbSyncObjectSetup<false>; |
| 82 | sharing->pfnGlArbSyncObjectSignal = glArbSyncObjectSignalMockDoNothing; |
| 83 | sharing->pfnGlArbSyncObjectWaitServer = glArbSyncObjectWaitServerMock<false>; |
| 84 | osInterface = new OSInterface; |
| 85 | executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(osInterface); |
| 86 | } |
| 87 | |
| 88 | void TearDown() override { |
| 89 | if (baseEvent) { |
| 90 | triggerEvent->setStatus(-1); |
| 91 | baseEvent->release(); |
| 92 | triggerEvent->release(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | template <typename T> |
| 97 | T *createArbEventMock() { |
| 98 | T *ret = new T(*ctx); |
| 99 | ret->osInterface = osInterface; |
| 100 | |
| 101 | ret->baseEvent = getBaseEvent(); |
| 102 | baseEvent->incRefInternal(); |
| 103 | baseEvent->addChild(*ret); |
| 104 | |
| 105 | return ret; |
| 106 | } |
| 107 | |
| 108 | MockBaseEvent *getBaseEvent() { |
| 109 | if (baseEvent == nullptr) { |
| 110 | triggerEvent = new UserEvent(ctx.get()); |
| 111 | baseEvent = new MockBaseEvent(cmdQ.get(), CL_COMMAND_RELEASE_GL_OBJECTS, CompletionStamp::notReady, CompletionStamp::notReady); |
| 112 | triggerEvent->addChild(*baseEvent); |
| 113 | } |
| 114 | return baseEvent; |
| 115 | } |
| 116 | |
| 117 | void failSyncObjectCreation() { |
| 118 | sharing->pfnGlArbSyncObjectSetup = mockGlArbSyncObjectSetup<true>; |
| 119 | } |
| 120 | |
| 121 | void setWaitCalledFlagOnServerWait() { |
| 122 | sharing->pfnGlArbSyncObjectWaitServer = glArbSyncObjectWaitServerMock<true>; |
| 123 | } |
| 124 | |
| 125 | std::unique_ptr<MockClDevice> device; |
| 126 | std::unique_ptr<MockContext> ctx; |
| 127 | std::unique_ptr<MockCommandQueue> cmdQ; |
| 128 | OSInterface *osInterface = nullptr; |
| 129 | Event *triggerEvent = nullptr; |
| 130 | MockBaseEvent *baseEvent = nullptr; |
| 131 | GlSharingFunctionsMock *sharing = nullptr; |
| 132 | ExecutionEnvironment *executionEnvironment = nullptr; |
| 133 | }; |
| 134 | |
| 135 | TEST_F(GlArbSyncEventTest, whenGlArbEventIsCreatedThenBaseEventObjectIsConstructedWithProperContextAndCommandType) { |
| 136 | auto *syncEv = createArbEventMock<DummyArbEvent<false>>(); |
| 137 | |
| 138 | EXPECT_EQ(static_cast<unsigned int>(CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR), syncEv->getCommandType()); |
| 139 | EXPECT_EQ(ctx.get(), syncEv->getContext()); |
| 140 | EXPECT_NE(nullptr, syncEv->glSyncInfo); |
| 141 | |
| 142 | syncEv->release(); |
| 143 | } |
| 144 | |
| 145 | TEST_F(GlArbSyncEventTest, whenGetSyncInfoisCalledThenEventsSyncInfoIsReturned) { |
| 146 | auto *syncEv = createArbEventMock<DummyArbEvent<false>>(); |
| 147 | |
| 148 | EXPECT_NE(nullptr, syncEv->glSyncInfo); |
| 149 | EXPECT_EQ(syncEv->glSyncInfo.get(), syncEv->getSyncInfo()); |
| 150 | |
| 151 | syncEv->release(); |
| 152 | } |
| 153 | |
| 154 | TEST_F(GlArbSyncEventTest, whenSetBaseEventIsCalledThenProperMembersOfParentEventAreCopiedToSyncEventAndReferenceCountersAreUpdated) { |
| 155 | ASSERT_NE(nullptr, getBaseEvent()->getCommandQueue()); |
| 156 | EXPECT_EQ(2, getBaseEvent()->getRefInternalCount()); |
| 157 | EXPECT_EQ(2, getBaseEvent()->getCommandQueue()->getRefInternalCount()); |
| 158 | EXPECT_FALSE(getBaseEvent()->peekHasChildEvents()); |
| 159 | auto *syncEv = new DummyArbEvent<false>(*ctx); |
| 160 | |
| 161 | EXPECT_EQ(nullptr, syncEv->baseEvent); |
| 162 | EXPECT_EQ(nullptr, syncEv->osInterface); |
| 163 | EXPECT_EQ(nullptr, syncEv->getCommandQueue()); |
| 164 | |
| 165 | syncEv->useBaseSetEvent = true; |
| 166 | bool ret = syncEv->setBaseEvent(*getBaseEvent()); |
| 167 | EXPECT_TRUE(ret); |
| 168 | |
| 169 | EXPECT_TRUE(getBaseEvent()->peekHasChildEvents()); |
| 170 | EXPECT_EQ(getBaseEvent(), syncEv->baseEvent); |
| 171 | EXPECT_EQ(getBaseEvent()->getCommandQueue(), syncEv->getCommandQueue()); |
| 172 | EXPECT_EQ(syncEv->getCommandQueue()->getGpgpuCommandStreamReceiver().getOSInterface(), syncEv->osInterface); |
| 173 | |
| 174 | EXPECT_EQ(3, getBaseEvent()->getRefInternalCount()); |
| 175 | EXPECT_EQ(3, getBaseEvent()->getCommandQueue()->getRefInternalCount()); |
| 176 | EXPECT_TRUE(getBaseEvent()->peekHasChildEvents()); |
| 177 | |
| 178 | syncEv->release(); |
| 179 | } |
| 180 | |
| 181 | TEST_F(GlArbSyncEventTest, whenSetBaseEventIsCalledButGlArbSyncObjectCreationFailsThenOperationIsAborted) { |
| 182 | ASSERT_NE(nullptr, getBaseEvent()->getCommandQueue()); |
| 183 | EXPECT_EQ(2, getBaseEvent()->getRefInternalCount()); |
| 184 | EXPECT_EQ(2, getBaseEvent()->getCommandQueue()->getRefInternalCount()); |
| 185 | EXPECT_FALSE(getBaseEvent()->peekHasChildEvents()); |
| 186 | auto *syncEv = new DummyArbEvent<false>(*ctx); |
| 187 | |
| 188 | EXPECT_EQ(nullptr, syncEv->baseEvent); |
| 189 | EXPECT_EQ(nullptr, syncEv->osInterface); |
| 190 | EXPECT_EQ(nullptr, syncEv->getCommandQueue()); |
| 191 | |
| 192 | syncEv->useBaseSetEvent = true; |
| 193 | failSyncObjectCreation(); |
| 194 | bool ret = syncEv->setBaseEvent(*getBaseEvent()); |
| 195 | EXPECT_FALSE(ret); |
| 196 | |
| 197 | EXPECT_EQ(2, getBaseEvent()->getRefInternalCount()); |
| 198 | EXPECT_EQ(2, getBaseEvent()->getCommandQueue()->getRefInternalCount()); |
| 199 | EXPECT_FALSE(getBaseEvent()->peekHasChildEvents()); |
| 200 | |
| 201 | EXPECT_EQ(nullptr, syncEv->baseEvent); |
| 202 | EXPECT_EQ(nullptr, syncEv->osInterface); |
| 203 | EXPECT_EQ(nullptr, syncEv->getCommandQueue()); |
| 204 | |
| 205 | syncEv->osInterface = this->osInterface; |
| 206 | syncEv->baseEvent = getBaseEvent(); |
| 207 | getBaseEvent()->incRefInternal(); |
| 208 | syncEv->release(); |
| 209 | } |
| 210 | |
| 211 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventGetsUnblockedByTerminatedBaseEventThenSyncObjectDoesntGetSignalled) { |
| 212 | auto *syncEv = createArbEventMock<DummyArbEvent<false>>(); |
| 213 | triggerEvent->setStatus(-1); |
| 214 | EXPECT_FALSE(syncEv->getSyncInfo()->waitCalled); |
| 215 | syncEv->release(); |
| 216 | } |
| 217 | |
| 218 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventGetsUnblockedByQueuedBaseEventThenSyncObjectDoesntGetSignalled) { |
| 219 | auto *syncEv = createArbEventMock<DummyArbEvent<false>>(); |
| 220 | syncEv->unblockEventBy(*this->baseEvent, 0, CL_QUEUED); |
| 221 | EXPECT_FALSE(syncEv->getSyncInfo()->waitCalled); |
| 222 | syncEv->release(); |
| 223 | } |
| 224 | |
| 225 | TEST_F(GlArbSyncEventTest, whenUnblockCompletedEventThenStopDirectSubmission) { |
| 226 | auto *syncEv = new DummyArbEvent<false>(*ctx); |
| 227 | syncEv->useBaseSetEvent = true; |
| 228 | bool ret = syncEv->setBaseEvent(*getBaseEvent()); |
| 229 | EXPECT_TRUE(ret); |
| 230 | EXPECT_FALSE(static_cast<MockCommandStreamReceiver *>(&syncEv->getCommandQueue()->getGpgpuCommandStreamReceiver())->blockingStopDirectSubmissionCalled); |
| 231 | syncEv->unblockEventBy(*this->baseEvent, 0, CL_COMPLETE); |
| 232 | EXPECT_TRUE(static_cast<MockCommandStreamReceiver *>(&syncEv->getCommandQueue()->getGpgpuCommandStreamReceiver())->blockingStopDirectSubmissionCalled); |
| 233 | syncEv->release(); |
| 234 | } |
| 235 | |
| 236 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventGetsUnblockedBySubmittedOrCompletedEventThenSyncObjectGetsSignalled) { |
| 237 | setWaitCalledFlagOnServerWait(); |
| 238 | |
| 239 | auto *syncEv = createArbEventMock<DummyArbEvent<false>>(); |
| 240 | triggerEvent->setStatus(CL_COMPLETE); |
| 241 | EXPECT_TRUE(syncEv->getSyncInfo()->waitCalled); |
| 242 | syncEv->release(); |
| 243 | } |
| 244 | |
| 245 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventIsCreatedFromBaseEventWithoutValidContextThenCreationFails) { |
| 246 | Event *baseEvent = new Event(nullptr, CL_COMMAND_RELEASE_GL_OBJECTS, CompletionStamp::notReady, CompletionStamp::notReady); |
| 247 | auto *arbEvent = GlArbSyncEvent::create(*baseEvent); |
| 248 | EXPECT_EQ(nullptr, arbEvent); |
| 249 | baseEvent->release(); |
| 250 | } |
| 251 | |
| 252 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventIsCreatedAndSetEventFailsThenCreationFails) { |
| 253 | failSyncObjectCreation(); |
| 254 | auto *arbEvent = GlArbSyncEvent::create(*this->getBaseEvent()); |
| 255 | EXPECT_EQ(nullptr, arbEvent); |
| 256 | } |
| 257 | |
| 258 | TEST_F(GlArbSyncEventTest, whenGlArbSyncEventIsCreatedThenBaseEventIsProperlySet) { |
| 259 | auto *arbEvent = GlArbSyncEvent::create(*this->getBaseEvent()); |
| 260 | EXPECT_NE(nullptr, arbEvent); |
| 261 | EXPECT_TRUE(this->baseEvent->peekHasChildEvents()); |
| 262 | EXPECT_EQ(arbEvent, this->baseEvent->peekChildEvents()->ref); |
| 263 | arbEvent->release(); |
| 264 | } |
| 265 | |
| 266 | TEST_F(GlArbSyncEventTest, whenClEnqueueMarkerWithSyncObjectINTELIsCalledThenInvalidOperationErrorCodeIsReturned) { |
| 267 | cl_command_queue queue = static_cast<cl_command_queue>(this->cmdQ.get()); |
| 268 | auto ret = clEnqueueMarkerWithSyncObjectINTEL(queue, nullptr, nullptr); |
| 269 | EXPECT_EQ(CL_INVALID_OPERATION, ret); |
| 270 | } |
| 271 | |
| 272 | TEST_F(GlArbSyncEventTest, whenClGetCLObjectInfoINTELIsCalledThenInvalidOperationErrorCodeIsReturned) { |
| 273 | cl_mem mem = {}; |
| 274 | auto ret = clGetCLObjectInfoINTEL(mem, nullptr); |
| 275 | EXPECT_EQ(CL_INVALID_OPERATION, ret); |
| 276 | } |
| 277 | |
| 278 | TEST_F(GlArbSyncEventTest, givenNullSynInfoParameterWhenClGetCLEventInfoINTELIsCalledThenInvalidArgValueErrorCodeIsReturned) { |
| 279 | cl_event ev = getBaseEvent(); |
| 280 | cl_context ctxRet = {}; |
| 281 | auto ret = clGetCLEventInfoINTEL(ev, nullptr, &ctxRet); |
| 282 | EXPECT_EQ(CL_INVALID_ARG_VALUE, ret); |
| 283 | } |
| 284 | |
| 285 | TEST_F(GlArbSyncEventTest, givenNullContextParameterWhenClGetCLEventInfoINTELIsCalledThenInvalidArgValueErrorCodeIsReturned) { |
| 286 | cl_event ev = getBaseEvent(); |
| 287 | CL_GL_SYNC_INFO *synInfoRet = nullptr; |
| 288 | auto ret = clGetCLEventInfoINTEL(ev, &synInfoRet, nullptr); |
| 289 | EXPECT_EQ(CL_INVALID_ARG_VALUE, ret); |
| 290 | } |
| 291 | |
| 292 | TEST_F(GlArbSyncEventTest, givenUnknownEventWhenclGetCLEventInfoINTELIsCalledThenInvalidEventErrorCodeIsReturned) { |
| 293 | auto deadEvent = new MockEvent<Event>(nullptr, 0, 0, 0); |
| 294 | deadEvent->magic = Event::deadMagic; |
| 295 | cl_event unknownEvent = deadEvent; |
| 296 | CL_GL_SYNC_INFO *synInfoRet = nullptr; |
| 297 | cl_context ctxRet = {}; |
| 298 | auto ret = clGetCLEventInfoINTEL(unknownEvent, &synInfoRet, &ctxRet); |
| 299 | EXPECT_EQ(CL_INVALID_EVENT, ret); |
| 300 | deadEvent->release(); |
| 301 | } |
| 302 | |
| 303 | TEST_F(GlArbSyncEventTest, givenEventWithCommandDifferentThanReleaseGlObjectsWhenClGetCLEventInfoINTELIsCalledThenValidContextIsReturned) { |
| 304 | getBaseEvent(); |
| 305 | cl_event ev = triggerEvent; |
| 306 | CL_GL_SYNC_INFO *synInfoRet = reinterpret_cast<CL_GL_SYNC_INFO *>(static_cast<uintptr_t>(0xFF)); |
| 307 | cl_context ctxRet = {}; |
| 308 | auto ret = clGetCLEventInfoINTEL(ev, &synInfoRet, &ctxRet); |
| 309 | EXPECT_EQ(CL_SUCCESS, ret); |
| 310 | EXPECT_EQ(nullptr, synInfoRet); |
| 311 | EXPECT_EQ(ctxRet, ctx.get()); |
| 312 | } |
| 313 | |
| 314 | TEST_F(GlArbSyncEventTest, givenDisabledSharingWhenClGetCLEventInfoINTELIsCalledThenInvalidOperationErrorCodeIsReturned) { |
| 315 | getBaseEvent(); |
| 316 | cl_event ev = baseEvent; |
| 317 | CL_GL_SYNC_INFO *synInfoRet = reinterpret_cast<CL_GL_SYNC_INFO *>(static_cast<uintptr_t>(0xFF)); |
| 318 | cl_context ctxRet = {}; |
| 319 | auto sharing = ctx->getSharing<NEO::GLSharingFunctions>(); |
| 320 | ctx->sharingFunctions[sharing->getId()] = nullptr; |
| 321 | auto ret = clGetCLEventInfoINTEL(ev, &synInfoRet, &ctxRet); |
| 322 | ctx->setSharingFunctions(new GlSharingFunctionsMock()); |
| 323 | EXPECT_EQ(CL_INVALID_OPERATION, ret); |
| 324 | } |
| 325 | |
| 326 | TEST_F(GlArbSyncEventTest, givenCallToClGetCLEventInfoINTELWhenGetOrCreateGlArbSyncFailsThenOutOfMemoryErrorCodeIsReturned) { |
| 327 | getBaseEvent(); |
| 328 | cl_event ev = this->baseEvent; |
| 329 | CL_GL_SYNC_INFO *synInfoRet = reinterpret_cast<CL_GL_SYNC_INFO *>(static_cast<uintptr_t>(0xFF)); |
| 330 | cl_context ctxRet = {}; |
| 331 | sharing->pfnGlArbSyncObjectSetup = mockGlArbSyncObjectSetup<true>; |
| 332 | auto ret = clGetCLEventInfoINTEL(ev, &synInfoRet, &ctxRet); |
| 333 | EXPECT_EQ(CL_OUT_OF_RESOURCES, ret); |
| 334 | } |
| 335 | |
| 336 | TEST_F(GlArbSyncEventTest, givenCallToClGetCLEventInfoINTELWhenFunctionSucceedsThenEventsGetUpdatedAndValidContextAndSyncInfoAreReturned) { |
| 337 | auto *arbEvent = GlArbSyncEvent::create(*this->getBaseEvent()); |
| 338 | this->sharing->glArbEventMapping[this->baseEvent] = arbEvent; |
| 339 | cl_event ev = this->baseEvent; |
| 340 | CL_GL_SYNC_INFO *synInfoRet = reinterpret_cast<CL_GL_SYNC_INFO *>(static_cast<uintptr_t>(0xFF)); |
| 341 | cl_context ctxRet = {}; |
| 342 | EXPECT_FALSE(this->baseEvent->wasUpdated); |
| 343 | auto ret = clGetCLEventInfoINTEL(ev, &synInfoRet, &ctxRet); |
| 344 | EXPECT_TRUE(this->baseEvent->wasUpdated); |
| 345 | EXPECT_EQ(CL_SUCCESS, ret); |
| 346 | EXPECT_EQ(ctx.get(), ctxRet); |
| 347 | EXPECT_EQ(arbEvent->getSyncInfo(), synInfoRet); |
| 348 | arbEvent->release(); |
| 349 | } |
| 350 | |
| 351 | TEST_F(GlArbSyncEventTest, givenUnknownEventWhenClReleaseGlSharedEventINTELIsCalledThenInvalidEventErrorCodeIsReturned) { |
| 352 | auto deadEvent = new MockEvent<Event>(nullptr, 0, 0, 0); |
| 353 | deadEvent->magic = Event::deadMagic; |
| 354 | cl_event unknownEvent = deadEvent; |
| 355 | auto ret = clReleaseGlSharedEventINTEL(unknownEvent); |
| 356 | EXPECT_EQ(CL_INVALID_EVENT, ret); |
| 357 | deadEvent->release(); |
| 358 | } |
| 359 | |
| 360 | TEST_F(GlArbSyncEventTest, givenEventWithoutArbSyncWhenClReleaseGlSharedEventINTELIsCalledThenThisEventsRefcountIsDecreased) { |
| 361 | this->getBaseEvent(); |
| 362 | triggerEvent->retain(); |
| 363 | EXPECT_EQ(2, triggerEvent->getRefInternalCount()); |
| 364 | cl_event ev = triggerEvent; |
| 365 | auto ret = clReleaseGlSharedEventINTEL(ev); |
| 366 | EXPECT_EQ(CL_SUCCESS, ret); |
| 367 | EXPECT_EQ(1, triggerEvent->getRefInternalCount()); |
| 368 | } |
| 369 | |
| 370 | TEST_F(GlArbSyncEventTest, givenEventWithArbSyncWhenClReleaseGlSharedEventINTELIsCalledThenThisEventsAndArbSyncsRefcountsAreDecreased) { |
| 371 | auto *arbEvent = GlArbSyncEvent::create(*this->getBaseEvent()); |
| 372 | baseEvent->retain(); |
| 373 | arbEvent->retain(); |
| 374 | this->sharing->glArbEventMapping[baseEvent] = arbEvent; |
| 375 | EXPECT_EQ(4, baseEvent->getRefInternalCount()); |
| 376 | EXPECT_EQ(3, arbEvent->getRefInternalCount()); |
| 377 | cl_event ev = baseEvent; |
| 378 | auto ret = clReleaseGlSharedEventINTEL(ev); |
| 379 | EXPECT_EQ(CL_SUCCESS, ret); |
| 380 | EXPECT_EQ(3, baseEvent->getRefInternalCount()); |
| 381 | EXPECT_EQ(2, arbEvent->getRefInternalCount()); |
| 382 | arbEvent->release(); |
| 383 | } |