xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/vulkan/CLEventVk.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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 // CLEventVk.h: Defines the class interface for CLEventVk, implementing CLEventImpl.
7 
8 #ifndef LIBANGLE_RENDERER_VULKAN_CLEVENTVK_H_
9 #define LIBANGLE_RENDERER_VULKAN_CLEVENTVK_H_
10 
11 #include <condition_variable>
12 #include <mutex>
13 
14 #include "libANGLE/renderer/vulkan/CLContextVk.h"
15 #include "libANGLE/renderer/vulkan/cl_types.h"
16 #include "libANGLE/renderer/vulkan/vk_resource.h"
17 
18 #include "libANGLE/renderer/CLEventImpl.h"
19 
20 #include "libANGLE/CLCommandQueue.h"
21 #include "libANGLE/CLContext.h"
22 #include "libANGLE/CLEvent.h"
23 
24 namespace rx
25 {
26 
27 class CLEventVk : public CLEventImpl, public vk::Resource
28 {
29   public:
30     CLEventVk(const cl::Event &event);
31     ~CLEventVk() override;
32 
getCommandType()33     cl_int getCommandType() const { return mEvent.getCommandType(); }
isUserEvent()34     bool isUserEvent() const { return mEvent.isUserEvent(); }
getFrontendObject()35     cl::Event &getFrontendObject() { return const_cast<cl::Event &>(mEvent); }
36 
37     angle::Result getCommandExecutionStatus(cl_int &executionStatus) override;
38 
39     angle::Result setUserEventStatus(cl_int executionStatus) override;
40 
41     angle::Result setCallback(cl::Event &event, cl_int commandExecCallbackType) override;
42 
43     angle::Result getProfilingInfo(cl::ProfilingInfo name,
44                                    size_t valueSize,
45                                    void *value,
46                                    size_t *valueSizeRet) override;
47 
48     angle::Result waitForUserEventStatus();
49     angle::Result setStatusAndExecuteCallback(cl_int status);
50     angle::Result setTimestamp(cl_int status);
51 
52   private:
53     std::mutex mUserEventMutex;
54     angle::SynchronizedValue<cl_int> mStatus;
55     std::condition_variable mUserEventCondition;
56     angle::SynchronizedValue<cl::EventStatusMap<bool>> mHaveCallbacks;
57 
58     // Event profiling timestamps
59     struct ProfilingTimestamps
60     {
61         cl_ulong commandEndTS;
62         cl_ulong commandStartTS;
63         cl_ulong commandQueuedTS;
64         cl_ulong commandSubmitTS;
65         cl_ulong commandCompleteTS;
66     };
67     angle::SynchronizedValue<ProfilingTimestamps> mProfilingTimestamps;
68 };
69 
70 }  // namespace rx
71 
72 #endif  // LIBANGLE_RENDERER_VULKAN_CLEVENTVK_H_
73