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