Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
BackendSemaphore.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10namespace skgpu::graphite {
11
13
15
17 *this = that;
18}
19
21 if (!that.isValid()) {
22 fIsValid = false;
23 return *this;
24 }
25 SkASSERT(!this->isValid() || this->backend() == that.backend());
26 fIsValid = true;
27 fBackend = that.fBackend;
28
29 switch (that.backend()) {
30#ifdef SK_DAWN
32 SK_ABORT("Unsupported Backend");
33#endif
34 #ifdef SK_METAL
36 fMtlEvent = that.fMtlEvent;
37 fMtlValue = that.fMtlValue;
38 break;
39#endif
40#ifdef SK_VULKAN
42 fVkSemaphore = that.fVkSemaphore;
43 break;
44#endif
45 default:
46 SK_ABORT("Unsupported Backend");
47 }
48 return *this;
49}
50
51#ifdef SK_METAL
52BackendSemaphore::BackendSemaphore(CFTypeRef mtlEvent, uint64_t value)
53 : fMtlEvent(mtlEvent)
54 , fMtlValue(value) {}
55
56CFTypeRef BackendSemaphore::getMtlEvent() const {
57 if (this->isValid() && this->backend() == BackendApi::kMetal) {
58 return fMtlEvent;
59 }
60 return nullptr;
61}
62
63uint64_t BackendSemaphore::getMtlValue() const {
64 if (this->isValid() && this->backend() == BackendApi::kMetal) {
65 return fMtlValue;
66 }
67 return 0;
68}
69#endif // SK_METAL
70
71#ifdef SK_VULKAN
72BackendSemaphore::BackendSemaphore(VkSemaphore semaphore)
73 : fVkSemaphore(semaphore)
74 , fIsValid(true)
75 , fBackend(BackendApi::kVulkan) {}
76
77VkSemaphore BackendSemaphore::getVkSemaphore() const {
78 if (this->isValid() && this->backend() == BackendApi::kVulkan) {
79 return fVkSemaphore;
80 }
81 return VK_NULL_HANDLE;
82}
83#endif
84
85} // End of namespace skgpu::graphite
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116
BackendSemaphore & operator=(const BackendSemaphore &)
uint8_t value
BackendApi
Definition GpuTypes.h:22
#define VK_NULL_HANDLE
Definition vulkan_core.h:46