aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkImage.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/vk/GrVkImage.h')
-rw-r--r--src/gpu/vk/GrVkImage.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gpu/vk/GrVkImage.h b/src/gpu/vk/GrVkImage.h
index 038b0ee86d..9e99743fe7 100644
--- a/src/gpu/vk/GrVkImage.h
+++ b/src/gpu/vk/GrVkImage.h
@@ -30,6 +30,7 @@ public:
, fLayout(std::move(layout))
, fIsBorrowed(GrBackendObjectOwnership::kBorrowed == ownership) {
SkASSERT(fLayout->getImageLayout() == fInfo.fImageLayout);
+ fTempLayoutTracker = fLayout->getImageLayout();
if (fIsBorrowed) {
fResource = new BorrowedResource(info.fImage, info.fAlloc, info.fImageTiling);
} else {
@@ -51,6 +52,23 @@ public:
sk_sp<GrVkImageLayout> grVkImageLayout() const { return fLayout; }
VkImageLayout currentLayout() const {
+ // This check and set is temporary since clients can still change the layout using
+ // the old GrBackendObject call and we need a way to respect those changes. This only works
+ // if the client isn't using GrBackendObjects and GrBackendTextures to update the layout
+ // at the same time. This check and set should all be made atomic but the plan is to remove
+ // the use of fInfo.fImageLayout so ignoring this issue for now.
+ // TODO: Delete all this ugliness as soon as we get rid of GrBackendObject getters.
+ if (fInfo.fImageLayout != fLayout->getImageLayout()) {
+ if (fLayout->getImageLayout() == fTempLayoutTracker) {
+ fLayout->setImageLayout(fInfo.fImageLayout);
+ } else {
+ SkASSERT(fInfo.fImageLayout == fTempLayoutTracker);
+ *const_cast<VkImageLayout*>(&fInfo.fImageLayout) = fLayout->getImageLayout();
+ }
+ *const_cast<VkImageLayout*>(&fTempLayoutTracker) = fLayout->getImageLayout();
+ }
+ SkASSERT(fInfo.fImageLayout == fTempLayoutTracker &&
+ fLayout->getImageLayout() == fTempLayoutTracker);
return fLayout->getImageLayout();
}
@@ -65,6 +83,8 @@ public:
// blit each layer, and then at the end need to update our tracking.
void updateImageLayout(VkImageLayout newLayout) {
fLayout->setImageLayout(newLayout);
+ fInfo.fImageLayout = newLayout;
+ fTempLayoutTracker = newLayout;
}
struct ImageDesc {
@@ -108,6 +128,11 @@ protected:
GrVkImageInfo fInfo;
sk_sp<GrVkImageLayout> fLayout;
+ // This is used while we still have GrBackendObjects around that are able to change our image
+ // layout without using the ref count method. This helps us determine which value has gotten out
+ // of sync.
+ // TODO: Delete this when get rid of a GrBackendObject getters
+ VkImageLayout fTempLayoutTracker;
bool fIsBorrowed;
private: