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

Side by Side Diff: src/gpu/vk/GrVkBuffer.h

Issue 2195713002: Properly recycle uniform buffers in vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@slownanobench
Patch Set: rebase Created 4 years, 4 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
« no previous file with comments | « no previous file | src/gpu/vk/GrVkBuffer.cpp » ('j') | 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 #ifndef GrVkBuffer_DEFINED 8 #ifndef GrVkBuffer_DEFINED
9 #define GrVkBuffer_DEFINED 9 #define GrVkBuffer_DEFINED
10 10
11 #include "GrVkResource.h" 11 #include "GrVkResource.h"
12 #include "vk/GrVkDefines.h" 12 #include "vk/GrVkDefines.h"
13 #include "vk/GrVkTypes.h" 13 #include "vk/GrVkTypes.h"
14 14
15 class GrVkGpu; 15 class GrVkGpu;
16 16
17 /** 17 /**
18 * This class serves as the base of GrVk*Buffer classes. It was written to avoid code 18 * This class serves as the base of GrVk*Buffer classes. It was written to avoid code
19 * duplication in those classes. 19 * duplication in those classes.
20 */ 20 */
21 class GrVkBuffer : public SkNoncopyable { 21 class GrVkBuffer : public SkNoncopyable {
22 public: 22 public:
23 ~GrVkBuffer() { 23 ~GrVkBuffer() {
24 // either release or abandon should have been called by the owner of thi s object. 24 // either release or abandon should have been called by the owner of thi s object.
25 SkASSERT(!fResource); 25 SkASSERT(!fResource);
26 } 26 }
27 27
28 VkBuffer buffer() const { return fResource->fBuffer; } 28 VkBuffer buffer() const { return fResource->fBuffer; }
29 const GrVkAlloc& alloc() const { return fResource->fAlloc; } 29 const GrVkAlloc& alloc() const { return fResource->fAlloc; }
30 const GrVkResource* resource() const { return fResource; } 30 const GrVkRecycledResource* resource() const { return fResource; }
31 size_t size() const { return fDesc.fSizeInBytes; } 31 size_t size() const { return fDesc.fSizeInBytes; }
32 VkDeviceSize offset() const { return fOffset; } 32 VkDeviceSize offset() const { return fOffset; }
33 33
34 void addMemoryBarrier(const GrVkGpu* gpu, 34 void addMemoryBarrier(const GrVkGpu* gpu,
35 VkAccessFlags srcAccessMask, 35 VkAccessFlags srcAccessMask,
36 VkAccessFlags dstAccessMask, 36 VkAccessFlags dstAccessMask,
37 VkPipelineStageFlags srcStageMask, 37 VkPipelineStageFlags srcStageMask,
38 VkPipelineStageFlags dstStageMask, 38 VkPipelineStageFlags dstStageMask,
39 bool byRegion) const; 39 bool byRegion) const;
40 40
41 enum Type { 41 enum Type {
42 kVertex_Type, 42 kVertex_Type,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void vkUnmap(GrVkGpu* gpu); 87 void vkUnmap(GrVkGpu* gpu);
88 // If the caller passes in a non null createdNewBuffer, this function will s et the bool to true 88 // If the caller passes in a non null createdNewBuffer, this function will s et the bool to true
89 // if it creates a new VkBuffer to upload the data to. 89 // if it creates a new VkBuffer to upload the data to.
90 bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes, 90 bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
91 bool* createdNewBuffer = nullptr); 91 bool* createdNewBuffer = nullptr);
92 92
93 void vkAbandon(); 93 void vkAbandon();
94 void vkRelease(const GrVkGpu* gpu); 94 void vkRelease(const GrVkGpu* gpu);
95 95
96 private: 96 private:
97 virtual const Resource* createResource(GrVkGpu* gpu,
98 const Desc& descriptor) {
99 return Create(gpu, descriptor);
100 }
101
97 void validate() const; 102 void validate() const;
98 bool vkIsMapped() const; 103 bool vkIsMapped() const;
99 104
100 Desc fDesc; 105 Desc fDesc;
101 const Resource* fResource; 106 const Resource* fResource;
102 VkDeviceSize fOffset; 107 VkDeviceSize fOffset;
103 void* fMapPtr; 108 void* fMapPtr;
104 109
105 typedef SkNoncopyable INHERITED; 110 typedef SkNoncopyable INHERITED;
106 }; 111 };
107 112
108 #endif 113 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/vk/GrVkBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698