Fix border update when rendering to cube face

Any notification that the contents of an image has been modified was
marked as requiring the image to have the VK_IMAGE_USAGE_STORAGE_BIT
set. This was only true for a subset of the cases and most cases
actually perform modifications using a direct memory accesses on the
vk::Image memory, so this requirement was wrong most of the time.

This CL adds an explicit argument to ImageView::contentsChanged() so
that we can specify if the VK_IMAGE_USAGE_STORAGE_BIT is expected to
be set or not, depending on where the update comes from.

Bug: b/197658470
Tests: dEQP-VK.image.sample_cubemap.write_face_0
Change-Id: I8290e329fa13215c23b31feef4fc8de391ce8032
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/58008
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index 8a33854..bcf0218 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -2005,7 +2005,7 @@
 		dest += pitch;
 	}
 
-	dst->contentsChanged();
+	dst->contentsChanged(vk::Image::DIRECT_MEMORY_ACCESS);
 }
 
 static void resolveStencil(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc)
@@ -2037,7 +2037,7 @@
 		dest += pitch;
 	}
 
-	dst->contentsChanged();
+	dst->contentsChanged(vk::Image::DIRECT_MEMORY_ACCESS);
 }
 
 void Blitter::resolveDepthStencil(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc)
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index 6b632ed..7d9009e 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -471,7 +471,7 @@
 	{
 		if(target)
 		{
-			target->contentsChanged();
+			target->contentsChanged(vk::Image::DIRECT_MEMORY_ACCESS);
 		}
 	}
 
diff --git a/src/Vulkan/VkDescriptorSet.cpp b/src/Vulkan/VkDescriptorSet.cpp
index b9e2814..5c2af95 100644
--- a/src/Vulkan/VkDescriptorSet.cpp
+++ b/src/Vulkan/VkDescriptorSet.cpp
@@ -67,7 +67,7 @@
 						}
 						else if((notificationType == CONTENTS_CHANGED) && (type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
 						{
-							device->contentsChanged(memoryOwner);
+							device->contentsChanged(memoryOwner, Image::USING_STORAGE);
 						}
 					}
 					descriptorMemory += descriptorSize;
diff --git a/src/Vulkan/VkDevice.cpp b/src/Vulkan/VkDevice.cpp
index 80caad3..161cb0a 100644
--- a/src/Vulkan/VkDevice.cpp
+++ b/src/Vulkan/VkDevice.cpp
@@ -458,7 +458,7 @@
 	}
 }
 
-void Device::contentsChanged(ImageView *imageView)
+void Device::contentsChanged(ImageView *imageView, Image::ContentsChangedContext context)
 {
 	if(imageView != nullptr)
 	{
@@ -467,7 +467,7 @@
 		auto it = imageViewSet.find(imageView);
 		if(it != imageViewSet.end())
 		{
-			imageView->contentsChanged();
+			imageView->contentsChanged(context);
 		}
 	}
 }
diff --git a/src/Vulkan/VkDevice.hpp b/src/Vulkan/VkDevice.hpp
index 70330ef..9e02379 100644
--- a/src/Vulkan/VkDevice.hpp
+++ b/src/Vulkan/VkDevice.hpp
@@ -72,7 +72,7 @@
 	void registerImageView(ImageView *imageView);
 	void unregisterImageView(ImageView *imageView);
 	void prepareForSampling(ImageView *imageView);
-	void contentsChanged(ImageView *imageView);
+	void contentsChanged(ImageView *imageView, Image::ContentsChangedContext context);
 
 	class SamplingRoutineCache
 	{
diff --git a/src/Vulkan/VkImageView.hpp b/src/Vulkan/VkImageView.hpp
index 86bfd38..2121c5b 100644
--- a/src/Vulkan/VkImageView.hpp
+++ b/src/Vulkan/VkImageView.hpp
@@ -127,9 +127,7 @@
 	bool hasDepthAspect() const { return (subresourceRange.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != 0; }
 	bool hasStencilAspect() const { return (subresourceRange.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) != 0; }
 
-	// This function is only called from the renderer, so use the USING_STORAGE flag,
-	// as it is required in order to write to an image from a shader
-	void contentsChanged() { image->contentsChanged(subresourceRange, Image::USING_STORAGE); }
+	void contentsChanged(Image::ContentsChangedContext context) { image->contentsChanged(subresourceRange, context); }
 
 	void prepareForSampling() { image->prepareForSampling(subresourceRange); }