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

#ifndef GrVkTransferBuffer_DEFINED
#define GrVkTransferBuffer_DEFINED

#include "GrBuffer.h"
#include "GrVkBuffer.h"

class GrVkGpu;

class GrVkTransferBuffer : public GrBuffer, public GrVkBuffer {

public:
    static GrVkTransferBuffer* Create(GrVkGpu* gpu, size_t size, GrVkBuffer::Type type);

protected:
    void onAbandon() override;
    void onRelease() override;

private:
    GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc,
                       const GrVkBuffer::Resource* resource);
    void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
                          const SkString& dumpName) const override;

    void onMap() override {
        if (!this->wasDestroyed()) {
            this->GrBuffer::fMapPtr = this->vkMap(this->getVkGpu());
        }
    }

    void onUnmap() override {
        if (!this->wasDestroyed()) {
            this->vkUnmap(this->getVkGpu());
        }
    }

    bool onUpdateData(const void* src, size_t srcSizeInBytes) override {
        SkFAIL("Not implemented for transfer buffers.");
        return false;
    }

    GrVkGpu* getVkGpu() const {
        SkASSERT(!this->wasDestroyed());
        return reinterpret_cast<GrVkGpu*>(this->getGpu());
    }

    typedef GrBuffer INHERITED;
};

#endif