From 001083cdbfed02964efd1a5cc8efb24685c43dbb Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Wed, 15 Dec 2021 17:13:26 +0100 Subject: [PATCH] chore: cherry-pick 2b98abd8cb6c from angle --- patches/angle/.patches | 1 + patches/angle/cherry-pick-2b98abd8cb6c.patch | 97 ++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 patches/angle/.patches create mode 100644 patches/angle/cherry-pick-2b98abd8cb6c.patch diff --git a/patches/angle/.patches b/patches/angle/.patches new file mode 100644 index 0000000000000..dd1377c3d4b94 --- /dev/null +++ b/patches/angle/.patches @@ -0,0 +1 @@ +cherry-pick-2b98abd8cb6c.patch diff --git a/patches/angle/cherry-pick-2b98abd8cb6c.patch b/patches/angle/cherry-pick-2b98abd8cb6c.patch new file mode 100644 index 0000000000000..4275b4635a8d8 --- /dev/null +++ b/patches/angle/cherry-pick-2b98abd8cb6c.patch @@ -0,0 +1,97 @@ +From 2b98abd8cb6caae2f3b6cd9e5ab7e70f2ee25e57 Mon Sep 17 00:00:00 2001 +From: Shahbaz Youssefi +Date: Tue, 30 Nov 2021 23:48:30 -0500 +Subject: [PATCH] M96: Vulkan: Fix image respecify's usage tracking + +When respecifying an image due to mip level count changes, the previous +image is staged as an update to the new image. The resource usage info +was not being transferred to the image being staged as an update, +causing it to be prematurely deleted. + +Test based on one authored by sugoi@google.com. + +Bug: chromium:1270658 +Bug: angleproject:4835 +Change-Id: I9810f8940e0107bc8a04fa3fb9c26a045c0d689c +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3318257 +Reviewed-by: Lingfeng Yang +--- + +diff --git a/src/libANGLE/renderer/vulkan/ResourceVk.cpp b/src/libANGLE/renderer/vulkan/ResourceVk.cpp +index 78485f7..860b426 100644 +--- a/src/libANGLE/renderer/vulkan/ResourceVk.cpp ++++ b/src/libANGLE/renderer/vulkan/ResourceVk.cpp +@@ -58,6 +58,12 @@ + mUse = std::move(other.mUse); + } + ++Resource &Resource::operator=(Resource &&rhs) ++{ ++ std::swap(mUse, rhs.mUse); ++ return *this; ++} ++ + Resource::~Resource() + { + mUse.release(); +diff --git a/src/libANGLE/renderer/vulkan/ResourceVk.h b/src/libANGLE/renderer/vulkan/ResourceVk.h +index 1170011..10eeadc 100644 +--- a/src/libANGLE/renderer/vulkan/ResourceVk.h ++++ b/src/libANGLE/renderer/vulkan/ResourceVk.h +@@ -192,6 +192,7 @@ + protected: + Resource(); + Resource(Resource &&other); ++ Resource &operator=(Resource &&rhs); + + // Current resource lifetime. + SharedResourceUse mUse; +diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp +index fc74e9f..fd3dd35 100644 +--- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp ++++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp +@@ -6441,6 +6441,9 @@ + // Move the necessary information for staged update to work, and keep the rest as part of this + // object. + ++ // Usage info ++ prevImage->get().Resource::operator=(std::move(*this)); ++ + // Vulkan objects + prevImage->get().mImage = std::move(mImage); + prevImage->get().mDeviceMemory = std::move(mDeviceMemory); +diff --git a/src/tests/gl_tests/MipmapTest.cpp b/src/tests/gl_tests/MipmapTest.cpp +index 4db00e7..8a6d01c 100644 +--- a/src/tests/gl_tests/MipmapTest.cpp ++++ b/src/tests/gl_tests/MipmapTest.cpp +@@ -2106,6 +2106,30 @@ + glGenerateMipmap(GL_TEXTURE_3D); + } + ++// Test that reducing the size of the mipchain by resizing the base image then deleting it doesn't ++// cause a crash. Issue found by fuzzer. ++TEST_P(MipmapTestES3, ResizeBaseMipTo1x1ThenDelete) ++{ ++ GLTexture tex; ++ glBindTexture(GL_TEXTURE_2D, tex); ++ ++ std::vector data(2, GLColor::blue); ++ ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.data()); ++ glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.data()); ++ ++ clearAndDrawQuad(m2DProgram, getWindowWidth(), getWindowHeight()); ++ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); ++ ++ data[0] = GLColor::green; ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.data()); ++ ++ clearAndDrawQuad(m2DProgram, getWindowWidth(), getWindowHeight()); ++ ++ tex.reset(); ++ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); ++} ++ + // Use this to select which configurations (e.g. which renderer, which GLES major version) these + // tests should be run against. + ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(MipmapTest);