Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/gpu/vk/GrVkVertexBuffer.cpp

Issue 1825393002: Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/gpu/vk/GrVkBuffer.h ('K') | « src/gpu/vk/GrVkVertexBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkVertexBuffer.h" 8 #include "GrVkVertexBuffer.h"
9 #include "GrVkGpu.h" 9 #include "GrVkGpu.h"
10 10
11 GrVkVertexBuffer::GrVkVertexBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc, 11 GrVkVertexBuffer::GrVkVertexBuffer(GrVkGpu* gpu, const GrVkBuffer::Desc& desc,
12 const GrVkBuffer::Resource* bufferResource) 12 const GrVkBuffer::Resource* bufferResource)
13 : INHERITED(gpu, desc.fSizeInBytes, desc.fDynamic, false) 13 : INHERITED(gpu, desc, bufferResource) {
14 , GrVkBuffer(desc, bufferResource) {
15 this->registerWithCache(); 14 this->registerWithCache();
16 } 15 }
17 16
18 GrVkVertexBuffer* GrVkVertexBuffer::Create(GrVkGpu* gpu, size_t size, bool dynam ic) { 17 GrVkVertexBuffer* GrVkVertexBuffer::Create(GrVkGpu* gpu, size_t size,
18 GrAccessPattern accessPattern) {
19 GrVkBuffer::Desc desc; 19 GrVkBuffer::Desc desc;
20 desc.fDynamic = dynamic; 20 desc.fAccessPattern = accessPattern;
21 desc.fType = GrVkBuffer::kVertex_Type; 21 desc.fType = kVertex_GrBufferType;
22 desc.fSizeInBytes = size; 22 desc.fSizeInBytes = size;
23 23
24 const GrVkBuffer::Resource* bufferResource = GrVkBuffer::Create(gpu, desc); 24 const GrVkBuffer::Resource* bufferResource = GrVkBuffer::Create(gpu, desc);
25 if (!bufferResource) { 25 if (!bufferResource) {
26 return nullptr; 26 return nullptr;
27 } 27 }
28 28
29 GrVkVertexBuffer* buffer = new GrVkVertexBuffer(gpu, desc, bufferResource); 29 GrVkVertexBuffer* buffer = new GrVkVertexBuffer(gpu, desc, bufferResource);
30 if (!buffer) { 30 if (!buffer) {
31 bufferResource->unref(gpu); 31 bufferResource->unref(gpu);
32 } 32 }
33 return buffer; 33 return buffer;
34 } 34 }
35
36 void GrVkVertexBuffer::onRelease() {
37 if (!this->wasDestroyed()) {
38 this->vkRelease(this->getVkGpu());
39 }
40
41 INHERITED::onRelease();
42 }
43
44 void GrVkVertexBuffer::onAbandon() {
45 this->vkAbandon();
46 INHERITED::onAbandon();
47 }
48
49 void* GrVkVertexBuffer::onMap() {
50 if (!this->wasDestroyed()) {
51 return this->vkMap(this->getVkGpu());
52 } else {
53 return NULL;
54 }
55 }
56
57 void GrVkVertexBuffer::onUnmap() {
58 if (!this->wasDestroyed()) {
59 this->vkUnmap(this->getVkGpu());
60 }
61 }
62
63 bool GrVkVertexBuffer::onUpdateData(const void* src, size_t srcSizeInBytes) {
64 if (!this->wasDestroyed()) {
65 return this->vkUpdateData(this->getVkGpu(), src, srcSizeInBytes);
66 } else {
67 return false;
68 }
69 }
70
71 GrVkGpu* GrVkVertexBuffer::getVkGpu() const {
72 SkASSERT(!this->wasDestroyed());
73 return static_cast<GrVkGpu*>(this->getGpu());
74 }
75
OLDNEW
« src/gpu/vk/GrVkBuffer.h ('K') | « src/gpu/vk/GrVkVertexBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698