• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 getCommandType() == CL_COMMAND_USER; }
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 
51   private:
52     std::mutex mUserEventMutex;
53     angle::SynchronizedValue<cl_int> mStatus;
54     std::condition_variable mUserEventCondition;
55     angle::SynchronizedValue<cl::EventStatusMap<bool>> mHaveCallbacks;
56 };
57 
58 }  // namespace rx
59 
60 #endif  // LIBANGLE_RENDERER_VULKAN_CLEVENTVK_H_
61