aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkSemaphore.h
blob: b99eb944f70fc2655deba774fb1faf14d3dfc9d1 (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
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrVkSemaphore_DEFINED
#define GrVkSemaphore_DEFINED

#include "GrSemaphore.h"
#include "GrVkResource.h"

#include "vk/GrVkTypes.h"

class GrBackendSemaphore;
class GrVkGpu;

class GrVkSemaphore : public GrSemaphore {
public:
    static sk_sp<GrVkSemaphore> Make(const GrVkGpu* gpu, bool isOwned);

    static sk_sp<GrVkSemaphore> MakeWrapped(const GrVkGpu* gpu,
                                            VkSemaphore semaphore,
                                            GrWrapOwnership);

    ~GrVkSemaphore() override;

    class Resource : public GrVkResource {
    public:
        Resource(VkSemaphore semaphore, bool isOwned)
                : INHERITED(), fSemaphore(semaphore), fIsOwned(isOwned) {}

        ~Resource() override {}

        VkSemaphore semaphore() const { return fSemaphore; }

#ifdef SK_TRACE_VK_RESOURCES
        void dumpInfo() const override {
            SkDebugf("GrVkSemaphore: %d (%d refs)\n", fSemaphore, this->getRefCnt());
        }
#endif
    private:
        void freeGPUData(const GrVkGpu* gpu) const override;

        VkSemaphore fSemaphore;
        bool        fIsOwned;

        typedef GrVkResource INHERITED;
    };

    const Resource* getResource() const { return fResource; }

private:
    GrVkSemaphore(const GrVkGpu* gpu, VkSemaphore semaphore, bool isOwned);

    void setBackendSemaphore(GrBackendSemaphore*) const override;

    const Resource* fResource;

    typedef GrSemaphore INHERITED;
};

#endif