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

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

Issue 2127183002: Add offsets to GrVkBuffer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 GrVkResource* 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 33
33 void addMemoryBarrier(const GrVkGpu* gpu, 34 void addMemoryBarrier(const GrVkGpu* gpu,
34 VkAccessFlags srcAccessMask, 35 VkAccessFlags srcAccessMask,
35 VkAccessFlags dstAccessMask, 36 VkAccessFlags dstAccessMask,
36 VkPipelineStageFlags srcStageMask, 37 VkPipelineStageFlags srcStageMask,
37 VkPipelineStageFlags dstStageMask, 38 VkPipelineStageFlags dstStageMask,
38 bool byRegion) const; 39 bool byRegion) const;
39 40
40 enum Type { 41 enum Type {
41 kVertex_Type, 42 kVertex_Type,
(...skipping 28 matching lines...) Expand all
70 void freeGPUData(const GrVkGpu* gpu) const; 71 void freeGPUData(const GrVkGpu* gpu) const;
71 72
72 typedef GrVkResource INHERITED; 73 typedef GrVkResource INHERITED;
73 }; 74 };
74 75
75 // convenience routine for raw buffer creation 76 // convenience routine for raw buffer creation
76 static const Resource* Create(const GrVkGpu* gpu, 77 static const Resource* Create(const GrVkGpu* gpu,
77 const Desc& descriptor); 78 const Desc& descriptor);
78 79
79 GrVkBuffer(const Desc& desc, const GrVkBuffer::Resource* resource) 80 GrVkBuffer(const Desc& desc, const GrVkBuffer::Resource* resource)
80 : fDesc(desc), fResource(resource), fMapPtr(nullptr) { 81 : fDesc(desc), fResource(resource), fOffset(0), fMapPtr(nullptr) {
81 } 82 }
82 83
83 void* vkMap(const GrVkGpu* gpu); 84 void* vkMap(const GrVkGpu* gpu);
84 void vkUnmap(GrVkGpu* gpu); 85 void vkUnmap(GrVkGpu* gpu);
85 // If the caller passes in a non null createdNewBuffer, this function will s et the bool to true 86 // If the caller passes in a non null createdNewBuffer, this function will s et the bool to true
86 // if it creates a new VkBuffer to upload the data to. 87 // if it creates a new VkBuffer to upload the data to.
87 bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes, 88 bool vkUpdateData(GrVkGpu* gpu, const void* src, size_t srcSizeInBytes,
88 bool* createdNewBuffer = nullptr); 89 bool* createdNewBuffer = nullptr);
89 90
90 void vkAbandon(); 91 void vkAbandon();
91 void vkRelease(const GrVkGpu* gpu); 92 void vkRelease(const GrVkGpu* gpu);
92 93
93 private: 94 private:
94 void validate() const; 95 void validate() const;
95 bool vkIsMapped() const; 96 bool vkIsMapped() const;
96 97
97 Desc fDesc; 98 Desc fDesc;
98 const Resource* fResource; 99 const Resource* fResource;
100 VkDeviceSize fOffset;
99 void* fMapPtr; 101 void* fMapPtr;
100 102
101 typedef SkNoncopyable INHERITED; 103 typedef SkNoncopyable INHERITED;
102 }; 104 };
103 105
104 #endif 106 #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