1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // CLEventCL.cpp: Implements the class methods for CLEventCL.
7
8 #include "libANGLE/renderer/cl/CLEventCL.h"
9
10 #include "libANGLE/CLEvent.h"
11 #include "libANGLE/cl_utils.h"
12
13 namespace rx
14 {
15
CLEventCL(const cl::Event & event,cl_event native)16 CLEventCL::CLEventCL(const cl::Event &event, cl_event native) : CLEventImpl(event), mNative(native)
17 {}
18
~CLEventCL()19 CLEventCL::~CLEventCL()
20 {
21 if (mNative->getDispatch().clReleaseEvent(mNative) != CL_SUCCESS)
22 {
23 ERR() << "Error while releasing CL event";
24 }
25 }
26
onEventCreate()27 angle::Result CLEventCL::onEventCreate()
28 {
29 return angle::Result::Continue;
30 }
31
getCommandExecutionStatus(cl_int & executionStatus)32 angle::Result CLEventCL::getCommandExecutionStatus(cl_int &executionStatus)
33 {
34 ANGLE_CL_TRY(mNative->getDispatch().clGetEventInfo(mNative, CL_EVENT_COMMAND_EXECUTION_STATUS,
35 sizeof(executionStatus), &executionStatus,
36 nullptr));
37 return angle::Result::Continue;
38 }
39
setUserEventStatus(cl_int executionStatus)40 angle::Result CLEventCL::setUserEventStatus(cl_int executionStatus)
41 {
42 ANGLE_CL_TRY(mNative->getDispatch().clSetUserEventStatus(mNative, executionStatus));
43 return angle::Result::Continue;
44 }
45
setCallback(cl::Event & event,cl_int commandExecCallbackType)46 angle::Result CLEventCL::setCallback(cl::Event &event, cl_int commandExecCallbackType)
47 {
48 ANGLE_CL_TRY(mNative->getDispatch().clSetEventCallback(mNative, commandExecCallbackType,
49 Callback, &event));
50 return angle::Result::Continue;
51 }
52
getProfilingInfo(cl::ProfilingInfo name,size_t valueSize,void * value,size_t * valueSizeRet)53 angle::Result CLEventCL::getProfilingInfo(cl::ProfilingInfo name,
54 size_t valueSize,
55 void *value,
56 size_t *valueSizeRet)
57 {
58 ANGLE_CL_TRY(mNative->getDispatch().clGetEventProfilingInfo(mNative, cl::ToCLenum(name),
59 valueSize, value, valueSizeRet));
60 return angle::Result::Continue;
61 }
62
Cast(const cl::EventPtrs & events)63 std::vector<cl_event> CLEventCL::Cast(const cl::EventPtrs &events)
64 {
65 std::vector<cl_event> nativeEvents;
66 nativeEvents.reserve(events.size());
67 for (const cl::EventPtr &event : events)
68 {
69 nativeEvents.emplace_back(event->getImpl<CLEventCL>().getNative());
70 }
71 return nativeEvents;
72 }
73
Callback(cl_event event,cl_int commandStatus,void * userData)74 void CLEventCL::Callback(cl_event event, cl_int commandStatus, void *userData)
75 {
76 static_cast<cl::Event *>(userData)->callback(commandStatus);
77 }
78
79 } // namespace rx
80