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

Unified Diff: src/gpu/vk/GrVkImage.h

Issue 1974983002: Refactor Vulkan image, texture, RTs so that create and getter handles match. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixLayerVersion
Patch Set: nits Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | src/gpu/vk/GrVkImage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkImage.h
diff --git a/src/gpu/vk/GrVkImage.h b/src/gpu/vk/GrVkImage.h
index e73d314e5e82a8ab2d2a6ee49d8bd2680c20af6a..30b6b89a13ac5aa540a89b7a40be8743a1cc93b0 100644
--- a/src/gpu/vk/GrVkImage.h
+++ b/src/gpu/vk/GrVkImage.h
@@ -14,77 +14,41 @@
#include "SkTypes.h"
#include "vk/GrVkDefines.h"
+#include "vk/GrVkTypes.h"
class GrVkGpu;
class GrVkImage : SkNoncopyable {
-public:
- // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can use it
- class Resource : public GrVkResource {
- public:
- enum Flags {
- kNo_Flags = 0,
- kLinearTiling_Flag = 0x01,
- kBorrowed_Flag = 0x02
- };
-
- VkImage fImage;
- VkDeviceMemory fAlloc;
- VkFormat fFormat;
- uint32_t fLevelCount;
- uint32_t fFlags;
-
- Resource()
- : INHERITED()
- , fImage(VK_NULL_HANDLE)
- , fAlloc(VK_NULL_HANDLE)
- , fFormat(VK_FORMAT_UNDEFINED)
- , fLevelCount(0)
- , fFlags(kNo_Flags) {}
-
- Resource(VkImage image, VkDeviceMemory alloc, VkFormat format, uint32_t levelCount,
- uint32_t flags)
- : fImage(image), fAlloc(alloc), fFormat(format), fLevelCount(levelCount)
- , fFlags(flags) {}
-
- ~Resource() override {}
+private:
+ class Resource;
- private:
- void freeGPUData(const GrVkGpu* gpu) const override;
-
- typedef GrVkResource INHERITED;
- };
-
- // for wrapped textures
- class BorrowedResource : public Resource {
- public:
- BorrowedResource(VkImage image, VkDeviceMemory alloc, VkFormat format, uint32_t levelCount,
- uint32_t flags)
- : Resource(image, alloc, format, levelCount, (flags | kBorrowed_Flag)) {
- }
- private:
- void freeGPUData(const GrVkGpu* gpu) const override;
+public:
+ enum Wrapped {
+ kNot_Wrapped,
+ kAdopted_Wrapped,
+ kBorrowed_Wrapped,
};
- GrVkImage(const Resource* imageResource) : fResource(imageResource) {
- if (imageResource->fFlags & Resource::kLinearTiling_Flag) {
- fCurrentLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
+ GrVkImage(const GrVkImageInfo& info, Wrapped wrapped)
+ : fInfo(info)
+ , fIsBorrowed(kBorrowed_Wrapped == wrapped) {
+ if (kBorrowed_Wrapped == wrapped) {
+ fResource = new BorrowedResource(info.fImage, info.fAlloc);
} else {
- fCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ fResource = new Resource(info.fImage, info.fAlloc);
}
- imageResource->ref();
}
-
virtual ~GrVkImage();
- VkImage textureImage() const { return fResource->fImage; }
- VkDeviceMemory textureMemory() const { return fResource->fAlloc; }
+ VkImage image() const { return fInfo.fImage; }
+ VkDeviceMemory memory() const { return fInfo.fAlloc; }
+ VkFormat imageFormat() const { return fInfo.fFormat; }
const Resource* resource() const { return fResource; }
bool isLinearTiled() const {
- return SkToBool(fResource->fFlags & Resource::kLinearTiling_Flag);
+ return SkToBool(VK_IMAGE_TILING_LINEAR == fInfo.fImageTiling);
}
- VkImageLayout currentLayout() const { return fCurrentLayout; }
+ VkImageLayout currentLayout() const { return fInfo.fImageLayout; }
void setImageLayout(const GrVkGpu* gpu,
VkImageLayout newLayout,
@@ -115,16 +79,54 @@ public:
, fMemProps(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {}
};
- static const Resource* CreateResource(const GrVkGpu* gpu, const ImageDesc& imageDesc);
+ static bool InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, GrVkImageInfo*);
+ // Destroys the internal VkImage and VkDeviceMemory in the GrVkImageInfo
+ static void DestroyImageInfo(const GrVkGpu* gpu, GrVkImageInfo*);
protected:
-
void releaseImage(const GrVkGpu* gpu);
void abandonImage();
+ void setNewResource(VkImage image, VkDeviceMemory alloc);
+
+ GrVkImageInfo fInfo;
+ bool fIsBorrowed;
+
+private:
+ // unlike GrVkBuffer, this needs to be public so GrVkStencilAttachment can use it
+ class Resource : public GrVkResource {
+ public:
+ Resource()
+ : INHERITED()
+ , fImage(VK_NULL_HANDLE)
+ , fAlloc(VK_NULL_HANDLE) {
+ }
+
+ Resource(VkImage image, VkDeviceMemory alloc) : fImage(image), fAlloc(alloc) {}
+
+ ~Resource() override {}
+
+ private:
+ void freeGPUData(const GrVkGpu* gpu) const override;
+
+ VkImage fImage;
+ VkDeviceMemory fAlloc;
+
+ typedef GrVkResource INHERITED;
+ };
+
+ // for wrapped textures
+ class BorrowedResource : public Resource {
+ public:
+ BorrowedResource(VkImage image, VkDeviceMemory alloc) : Resource(image, alloc) {
+ }
+ private:
+ void freeGPUData(const GrVkGpu* gpu) const override;
+ };
+
const Resource* fResource;
- VkImageLayout fCurrentLayout;
+ friend class GrVkRenderTarget;
};
#endif
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | src/gpu/vk/GrVkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698