Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/libANGLE/CLEvent.h
1693 views
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
// CLEvent.h: Defines the cl::Event class, which can be used to track the execution status of an
7
// OpenCL command.
8
9
#ifndef LIBANGLE_CLEVENT_H_
10
#define LIBANGLE_CLEVENT_H_
11
12
#include "libANGLE/CLObject.h"
13
#include "libANGLE/renderer/CLEventImpl.h"
14
15
#include "common/SynchronizedValue.h"
16
17
#include <array>
18
19
namespace cl
20
{
21
22
class Event final : public _cl_event, public Object
23
{
24
public:
25
// Front end entry functions, only called from OpenCL entry points
26
27
cl_int setUserEventStatus(cl_int executionStatus);
28
29
cl_int getInfo(EventInfo name, size_t valueSize, void *value, size_t *valueSizeRet) const;
30
31
cl_int setCallback(cl_int commandExecCallbackType, EventCB pfnNotify, void *userData);
32
33
cl_int getProfilingInfo(ProfilingInfo name,
34
size_t valueSize,
35
void *value,
36
size_t *valueSizeRet);
37
38
public:
39
~Event() override;
40
41
Context &getContext();
42
const Context &getContext() const;
43
const CommandQueuePtr &getCommandQueue() const;
44
cl_command_type getCommandType() const;
45
bool wasStatusChanged() const;
46
47
template <typename T = rx::CLEventImpl>
48
T &getImpl() const;
49
50
void callback(cl_int commandStatus);
51
52
static EventPtrs Cast(cl_uint numEvents, const cl_event *eventList);
53
54
private:
55
using CallbackData = std::pair<EventCB, void *>;
56
using Callbacks = std::vector<CallbackData>;
57
58
Event(Context &context, cl_int &errorCode);
59
60
Event(CommandQueue &queue,
61
cl_command_type commandType,
62
const rx::CLEventImpl::CreateFunc &createFunc,
63
cl_int &errorCode);
64
65
const ContextPtr mContext;
66
const CommandQueuePtr mCommandQueue;
67
const cl_command_type mCommandType;
68
const rx::CLEventImpl::Ptr mImpl;
69
70
bool mStatusWasChanged = false;
71
72
// Create separate storage for each possible callback type.
73
static_assert(CL_COMPLETE == 0 && CL_RUNNING == 1 && CL_SUBMITTED == 2,
74
"OpenCL command execution status values are not as assumed");
75
angle::SynchronizedValue<std::array<Callbacks, 3u>> mCallbacks;
76
77
friend class Object;
78
};
79
80
inline Context &Event::getContext()
81
{
82
return *mContext;
83
}
84
85
inline const Context &Event::getContext() const
86
{
87
return *mContext;
88
}
89
90
inline const CommandQueuePtr &Event::getCommandQueue() const
91
{
92
return mCommandQueue;
93
}
94
95
inline cl_command_type Event::getCommandType() const
96
{
97
return mCommandType;
98
}
99
100
inline bool Event::wasStatusChanged() const
101
{
102
return mStatusWasChanged;
103
}
104
105
template <typename T>
106
inline T &Event::getImpl() const
107
{
108
return static_cast<T &>(*mImpl);
109
}
110
111
} // namespace cl
112
113
#endif // LIBANGLE_CLEVENT_H_
114
115