Prevent accessing deleted ImageView objects
This cl adds a verification before using the imageView stored
within descriptor sets to make sure they still exist. These
imageView objects are used to make sure images which require
preprocessing (cubemaps and compressed images) are up to date.
The device contains the list of active ImageView objects.
Bug: b/163523811
Bug: b/152227757
Bug: chromium:1110549
Change-Id: I2e2190f2e61296ef3a2e4b699bda885d3a6595d9
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47588
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkDescriptorSet.cpp b/src/Vulkan/VkDescriptorSet.cpp
index 5cce513..a53ba6e 100644
--- a/src/Vulkan/VkDescriptorSet.cpp
+++ b/src/Vulkan/VkDescriptorSet.cpp
@@ -13,12 +13,13 @@
// limitations under the License.
#include "VkDescriptorSet.hpp"
+#include "VkDevice.hpp"
#include "VkImageView.hpp"
#include "VkPipelineLayout.hpp"
namespace vk {
-void DescriptorSet::ParseDescriptors(const Array &descriptorSets, const PipelineLayout *layout, NotificationType notificationType)
+void DescriptorSet::ParseDescriptors(const Array &descriptorSets, const PipelineLayout *layout, Device *device, NotificationType notificationType)
{
if(layout)
{
@@ -62,11 +63,11 @@
{
if(notificationType == PREPARE_FOR_SAMPLING)
{
- memoryOwner->prepareForSampling();
+ device->prepareForSampling(memoryOwner);
}
else if((notificationType == CONTENTS_CHANGED) && (type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE))
{
- memoryOwner->contentsChanged();
+ device->contentsChanged(memoryOwner);
}
}
descriptorMemory += descriptorSize;
@@ -76,14 +77,14 @@
}
}
-void DescriptorSet::ContentsChanged(const Array &descriptorSets, const PipelineLayout *layout)
+void DescriptorSet::ContentsChanged(const Array &descriptorSets, const PipelineLayout *layout, Device *device)
{
- ParseDescriptors(descriptorSets, layout, CONTENTS_CHANGED);
+ ParseDescriptors(descriptorSets, layout, device, CONTENTS_CHANGED);
}
-void DescriptorSet::PrepareForSampling(const Array &descriptorSets, const PipelineLayout *layout)
+void DescriptorSet::PrepareForSampling(const Array &descriptorSets, const PipelineLayout *layout, Device *device)
{
- ParseDescriptors(descriptorSets, layout, PREPARE_FOR_SAMPLING);
+ ParseDescriptors(descriptorSets, layout, device, PREPARE_FOR_SAMPLING);
}
} // namespace vk
\ No newline at end of file