1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | #ifndef VK_SEMAPHORE_HPP_ |
16 | #define VK_SEMAPHORE_HPP_ |
17 | |
18 | #include "VkConfig.h" |
19 | #include "VkObject.hpp" |
20 | |
21 | #if SWIFTSHADER_EXTERNAL_SEMAPHORE_ZIRCON_EVENT |
22 | #include <zircon/types.h> |
23 | #endif |
24 | |
25 | namespace vk |
26 | { |
27 | |
28 | class Semaphore : public Object<Semaphore, VkSemaphore> |
29 | { |
30 | public: |
31 | Semaphore(const VkSemaphoreCreateInfo* pCreateInfo, void* mem); |
32 | void destroy(const VkAllocationCallbacks* pAllocator); |
33 | |
34 | static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo* pCreateInfo); |
35 | |
36 | void wait(); |
37 | |
38 | void wait(const VkPipelineStageFlags& flag) |
39 | { |
40 | // NOTE: not sure what else to do here? |
41 | wait(); |
42 | } |
43 | |
44 | void signal(); |
45 | |
46 | #if SWIFTSHADER_EXTERNAL_SEMAPHORE_LINUX_MEMFD |
47 | VkResult importFd(int fd, bool temporaryImport); |
48 | VkResult exportFd(int* pFd) const; |
49 | #endif |
50 | |
51 | #if SWIFTSHADER_EXTERNAL_SEMAPHORE_ZIRCON_EVENT |
52 | VkResult importHandle(zx_handle_t handle, bool temporaryImport); |
53 | VkResult exportHandle(zx_handle_t *pHandle) const; |
54 | #endif |
55 | |
56 | private: |
57 | class External; |
58 | class Impl; |
59 | Impl* impl = nullptr; |
60 | }; |
61 | |
62 | static inline Semaphore* Cast(VkSemaphore object) |
63 | { |
64 | return Semaphore::Cast(object); |
65 | } |
66 | |
67 | } // namespace vk |
68 | |
69 | #endif // VK_SEMAPHORE_HPP_ |
70 | |