Flutter Engine
The Flutter Engine
GrVkSemaphore.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
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
8#ifndef GrVkSemaphore_DEFINED
9#define GrVkSemaphore_DEFINED
10
12
16
17#include <cinttypes>
18
20class GrVkGpu;
21
22class GrVkSemaphore : public GrSemaphore {
23public:
24 static std::unique_ptr<GrVkSemaphore> Make(GrVkGpu* gpu, bool isOwned);
25
26 static std::unique_ptr<GrVkSemaphore> MakeWrapped(GrVkGpu*,
27 VkSemaphore,
30
31 ~GrVkSemaphore() override;
32
33 GrBackendSemaphore backendSemaphore() const override;
34
36 public:
37 Resource(const GrVkGpu* gpu, VkSemaphore semaphore,
38 bool prohibitSignal, bool prohibitWait, bool isOwned)
39 : INHERITED(gpu)
40 , fSemaphore(semaphore)
41 , fHasBeenSubmittedToQueueForSignal(prohibitSignal)
42 , fHasBeenSubmittedToQueueForWait(prohibitWait)
43 , fIsOwned(isOwned) {}
44
45 ~Resource() override {}
46
47 VkSemaphore semaphore() const { return fSemaphore; }
48
49 bool shouldSignal() const {
50 return !fHasBeenSubmittedToQueueForSignal;
51 }
52 bool shouldWait() const {
53 return !fHasBeenSubmittedToQueueForWait;
54 }
55
57 fHasBeenSubmittedToQueueForSignal = true;
58 }
59 void markAsWaited() {
60 fHasBeenSubmittedToQueueForWait = true;
61 }
62
63 void setIsOwned() {
64 fIsOwned = true;
65 }
66
67#ifdef SK_TRACE_MANAGED_RESOURCES
68 void dumpInfo() const override {
69 SkDebugf("GrVkSemaphore: %" PRIdPTR " (%d refs)\n", (intptr_t)fSemaphore,
70 this->getRefCnt());
71 }
72#endif
73 private:
74 void freeGPUData() const override;
75
76 VkSemaphore fSemaphore;
77 bool fHasBeenSubmittedToQueueForSignal;
78 bool fHasBeenSubmittedToQueueForWait;
79 bool fIsOwned;
80
81 using INHERITED = GrVkManagedResource;
82 };
83
84 Resource* getResource() { return fResource; }
85
86private:
87 GrVkSemaphore(GrVkGpu* gpu, VkSemaphore semaphore, bool prohibitSignal, bool prohibitWait,
88 bool isOwned);
89
90 void setIsOwned() override {
91 fResource->setIsOwned();
92 }
93
94 Resource* fResource;
95
96 using INHERITED = GrSemaphore;
97};
98
99#endif
GrWrapOwnership
Definition: GrTypesPriv.h:77
GrSemaphoreWrapType
Definition: GrTypesPriv.h:146
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GrVkManagedResource(const GrVkGpu *gpu)
Resource(const GrVkGpu *gpu, VkSemaphore semaphore, bool prohibitSignal, bool prohibitWait, bool isOwned)
Definition: GrVkSemaphore.h:37
bool shouldSignal() const
Definition: GrVkSemaphore.h:49
VkSemaphore semaphore() const
Definition: GrVkSemaphore.h:47
~GrVkSemaphore() override
Resource * getResource()
Definition: GrVkSemaphore.h:84
GrBackendSemaphore backendSemaphore() const override
static std::unique_ptr< GrVkSemaphore > Make(GrVkGpu *gpu, bool isOwned)
static std::unique_ptr< GrVkSemaphore > MakeWrapped(GrVkGpu *, VkSemaphore, GrSemaphoreWrapType, GrWrapOwnership)