blob: c6ca2147b38b1caa08ceed5c7892bf4c25fef497 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
2* Copyright 2015 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 GrVkTransferBuffer_DEFINED
9#define GrVkTransferBuffer_DEFINED
10
cdalton8b1bff22016-03-25 01:54:54 -070011#include "GrBuffer.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050012#include "GrVkBuffer.h"
13#include "vk/GrVkInterface.h"
14
15class GrVkGpu;
16
cdalton8b1bff22016-03-25 01:54:54 -070017class GrVkTransferBuffer : public GrBuffer, public GrVkBuffer {
Greg Daniel164a9f02016-02-22 09:56:40 -050018
19public:
20 static GrVkTransferBuffer* Create(GrVkGpu* gpu, size_t size, GrVkBuffer::Type type);
21
22protected:
23 void onAbandon() override;
24 void onRelease() override;
25
26private:
27 GrVkTransferBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc,
28 const GrVkBuffer::Resource* resource);
29 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
30 const SkString& dumpName) const override;
31
cdalton8b1bff22016-03-25 01:54:54 -070032 void onMap() override {
Greg Daniel164a9f02016-02-22 09:56:40 -050033 if (!this->wasDestroyed()) {
cdalton8b1bff22016-03-25 01:54:54 -070034 this->GrBuffer::fMapPtr = this->vkMap(this->getVkGpu());
Greg Daniel164a9f02016-02-22 09:56:40 -050035 }
36 }
37
38 void onUnmap() override {
39 if (!this->wasDestroyed()) {
40 this->vkUnmap(this->getVkGpu());
41 }
42 }
43
cdalton8b1bff22016-03-25 01:54:54 -070044 bool onUpdateData(const void* src, size_t srcSizeInBytes) override {
45 SkFAIL("Not implemented for transfer buffers.");
46 return false;
47 }
48
Greg Daniel164a9f02016-02-22 09:56:40 -050049 GrVkGpu* getVkGpu() const {
50 SkASSERT(!this->wasDestroyed());
51 return reinterpret_cast<GrVkGpu*>(this->getGpu());
52 }
53
cdalton8b1bff22016-03-25 01:54:54 -070054 typedef GrBuffer INHERITED;
Greg Daniel164a9f02016-02-22 09:56:40 -050055};
56
57#endif