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

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

Issue 2018933004: Add offset to memory allocations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Take care of some additional FreeMemorys 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 GrVkImage_DEFINED 8 #ifndef GrVkImage_DEFINED
9 #define GrVkImage_DEFINED 9 #define GrVkImage_DEFINED
10 10
(...skipping 15 matching lines...) Expand all
26 enum Wrapped { 26 enum Wrapped {
27 kNot_Wrapped, 27 kNot_Wrapped,
28 kAdopted_Wrapped, 28 kAdopted_Wrapped,
29 kBorrowed_Wrapped, 29 kBorrowed_Wrapped,
30 }; 30 };
31 31
32 GrVkImage(const GrVkImageInfo& info, Wrapped wrapped) 32 GrVkImage(const GrVkImageInfo& info, Wrapped wrapped)
33 : fInfo(info) 33 : fInfo(info)
34 , fIsBorrowed(kBorrowed_Wrapped == wrapped) { 34 , fIsBorrowed(kBorrowed_Wrapped == wrapped) {
35 if (kBorrowed_Wrapped == wrapped) { 35 if (kBorrowed_Wrapped == wrapped) {
36 fResource = new BorrowedResource(info.fImage, info.fAlloc); 36 fResource = new BorrowedResource(info.fImage, info.fAlloc, info.fOff set);
37 } else { 37 } else {
38 fResource = new Resource(info.fImage, info.fAlloc); 38 fResource = new Resource(info.fImage, info.fAlloc, info.fOffset);
39 } 39 }
40 } 40 }
41 virtual ~GrVkImage(); 41 virtual ~GrVkImage();
42 42
43 VkImage image() const { return fInfo.fImage; } 43 VkImage image() const { return fInfo.fImage; }
44 VkDeviceMemory memory() const { return fInfo.fAlloc; } 44 VkDeviceMemory memory() const { return fInfo.fAlloc; }
45 VkDeviceSize offset() const { return fInfo.fOffset; }
45 VkFormat imageFormat() const { return fInfo.fFormat; } 46 VkFormat imageFormat() const { return fInfo.fFormat; }
46 const Resource* resource() const { return fResource; } 47 const Resource* resource() const { return fResource; }
47 bool isLinearTiled() const { 48 bool isLinearTiled() const {
48 return SkToBool(VK_IMAGE_TILING_LINEAR == fInfo.fImageTiling); 49 return SkToBool(VK_IMAGE_TILING_LINEAR == fInfo.fImageTiling);
49 } 50 }
50 51
51 VkImageLayout currentLayout() const { return fInfo.fImageLayout; } 52 VkImageLayout currentLayout() const { return fInfo.fImageLayout; }
52 53
53 void setImageLayout(const GrVkGpu* gpu, 54 void setImageLayout(const GrVkGpu* gpu,
54 VkImageLayout newLayout, 55 VkImageLayout newLayout,
(...skipping 25 matching lines...) Expand all
80 }; 81 };
81 82
82 static bool InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr VkImageInfo*); 83 static bool InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, Gr VkImageInfo*);
83 // Destroys the internal VkImage and VkDeviceMemory in the GrVkImageInfo 84 // Destroys the internal VkImage and VkDeviceMemory in the GrVkImageInfo
84 static void DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo*); 85 static void DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo*);
85 86
86 protected: 87 protected:
87 void releaseImage(const GrVkGpu* gpu); 88 void releaseImage(const GrVkGpu* gpu);
88 void abandonImage(); 89 void abandonImage();
89 90
90 void setNewResource(VkImage image, VkDeviceMemory alloc); 91 void setNewResource(VkImage image, VkDeviceMemory alloc, VkDeviceSize offset );
91 92
92 GrVkImageInfo fInfo; 93 GrVkImageInfo fInfo;
93 bool fIsBorrowed; 94 bool fIsBorrowed;
94 95
95 private: 96 private:
96 // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can u se it 97 // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can u se it
97 class Resource : public GrVkResource { 98 class Resource : public GrVkResource {
98 public: 99 public:
99 Resource() 100 Resource()
100 : INHERITED() 101 : INHERITED()
101 , fImage(VK_NULL_HANDLE) 102 , fImage(VK_NULL_HANDLE)
102 , fAlloc(VK_NULL_HANDLE) { 103 , fAlloc(VK_NULL_HANDLE)
104 , fOffset(0) {
103 } 105 }
104 106
105 Resource(VkImage image, VkDeviceMemory alloc) : fImage(image), fAlloc(al loc) {} 107 Resource(VkImage image, VkDeviceMemory alloc, VkDeviceSize offset)
108 : fImage(image), fAlloc(alloc), fOffset(offset) {}
106 109
107 ~Resource() override {} 110 ~Resource() override {}
108 111
109 private: 112 private:
110 void freeGPUData(const GrVkGpu* gpu) const override; 113 void freeGPUData(const GrVkGpu* gpu) const override;
111 114
112 VkImage fImage; 115 VkImage fImage;
113 VkDeviceMemory fAlloc; 116 VkDeviceMemory fAlloc;
117 VkDeviceSize fOffset;
114 118
115 typedef GrVkResource INHERITED; 119 typedef GrVkResource INHERITED;
116 }; 120 };
117 121
118 // for wrapped textures 122 // for wrapped textures
119 class BorrowedResource : public Resource { 123 class BorrowedResource : public Resource {
120 public: 124 public:
121 BorrowedResource(VkImage image, VkDeviceMemory alloc) : Resource(image, alloc) { 125 BorrowedResource(VkImage image, VkDeviceMemory alloc, VkDeviceSize offse t)
126 : Resource(image, alloc, offset) {
122 } 127 }
123 private: 128 private:
124 void freeGPUData(const GrVkGpu* gpu) const override; 129 void freeGPUData(const GrVkGpu* gpu) const override;
125 }; 130 };
126 131
127 const Resource* fResource; 132 const Resource* fResource;
128 133
129 friend class GrVkRenderTarget; 134 friend class GrVkRenderTarget;
130 }; 135 };
131 136
132 #endif 137 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698