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

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

Issue 2018933004: Add offset to memory allocations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix tests Created 4 years, 6 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
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 14
14 class GrVkGpu; 15 class GrVkGpu;
15 16
16 /** 17 /**
17 * 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
18 * duplication in those classes. 19 * duplication in those classes.
19 */ 20 */
20 class GrVkBuffer : public SkNoncopyable { 21 class GrVkBuffer : public SkNoncopyable {
21 public: 22 public:
22 ~GrVkBuffer() { 23 ~GrVkBuffer() {
23 // 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.
24 SkASSERT(!fResource); 25 SkASSERT(!fResource);
25 } 26 }
26 27
27 VkBuffer buffer() const { return fResource->fBuffer; } 28 VkBuffer buffer() const { return fResource->fBuffer; }
28 VkDeviceMemory alloc() const { return fResource->fAlloc; } 29 const GrVkAlloc& alloc() const { return fResource->fAlloc; }
29 const GrVkResource* resource() const { return fResource; } 30 const GrVkResource* resource() const { return fResource; }
30 size_t size() const { return fDesc.fSizeInBytes; } 31 size_t size() const { return fDesc.fSizeInBytes; }
31 32
32 void addMemoryBarrier(const GrVkGpu* gpu, 33 void addMemoryBarrier(const GrVkGpu* gpu,
33 VkAccessFlags srcAccessMask, 34 VkAccessFlags srcAccessMask,
34 VkAccessFlags dstAccessMask, 35 VkAccessFlags dstAccessMask,
35 VkPipelineStageFlags srcStageMask, 36 VkPipelineStageFlags srcStageMask,
36 VkPipelineStageFlags dstStageMask, 37 VkPipelineStageFlags dstStageMask,
37 bool byRegion) const; 38 bool byRegion) const;
38 39
39 enum Type { 40 enum Type {
40 kVertex_Type, 41 kVertex_Type,
41 kIndex_Type, 42 kIndex_Type,
42 kUniform_Type, 43 kUniform_Type,
43 kCopyRead_Type, 44 kCopyRead_Type,
44 kCopyWrite_Type, 45 kCopyWrite_Type,
45 }; 46 };
46 47
47 protected: 48 protected:
48 struct Desc { 49 struct Desc {
49 size_t fSizeInBytes; 50 size_t fSizeInBytes;
50 Type fType; // vertex buffer, index buffer, etc. 51 Type fType; // vertex buffer, index buffer, etc.
51 bool fDynamic; 52 bool fDynamic;
52 }; 53 };
53 54
54 class Resource : public GrVkResource { 55 class Resource : public GrVkResource {
55 public: 56 public:
56 Resource(VkBuffer buf, VkDeviceMemory alloc) : INHERITED(), fBuffer(buf) , fAlloc(alloc) {} 57 Resource(VkBuffer buf, const GrVkAlloc& alloc)
58 : INHERITED(), fBuffer(buf), fAlloc(alloc) {}
57 59
58 VkBuffer fBuffer; 60 VkBuffer fBuffer;
59 VkDeviceMemory fAlloc; 61 GrVkAlloc fAlloc;
62
60 private: 63 private:
61 void freeGPUData(const GrVkGpu* gpu) const; 64 void freeGPUData(const GrVkGpu* gpu) const;
62 65
63 typedef GrVkResource INHERITED; 66 typedef GrVkResource INHERITED;
64 }; 67 };
65 68
66 // convenience routine for raw buffer creation 69 // convenience routine for raw buffer creation
67 static const Resource* Create(const GrVkGpu* gpu, 70 static const Resource* Create(const GrVkGpu* gpu,
68 const Desc& descriptor); 71 const Desc& descriptor);
69 72
(...skipping 16 matching lines...) Expand all
86 bool vkIsMapped() const; 89 bool vkIsMapped() const;
87 90
88 Desc fDesc; 91 Desc fDesc;
89 const Resource* fResource; 92 const Resource* fResource;
90 void* fMapPtr; 93 void* fMapPtr;
91 94
92 typedef SkNoncopyable INHERITED; 95 typedef SkNoncopyable INHERITED;
93 }; 96 };
94 97
95 #endif 98 #endif
OLDNEW
« no previous file with comments | « include/gpu/vk/GrVkTypes.h ('k') | src/gpu/vk/GrVkBuffer.cpp » ('j') | src/gpu/vk/GrVkBuffer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698