From f8ba4d6012c2c6a853c0b9b31e2a3816ac8b3c0c Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Wed, 4 May 2022 16:28:55 +0200 Subject: [PATCH] chore: cherry-pick d27d9d059b51 from angle (#34045) * chore: cherry-pick d27d9d059b51 from angle * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Electron Bot --- patches/angle/.patches | 1 + patches/angle/cherry-pick-d27d9d059b51.patch | 100 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 patches/angle/cherry-pick-d27d9d059b51.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index 644eaae4f1bc7..ae9ae083e0dd2 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -12,4 +12,5 @@ m99_vulkan_prevent_out_of_bounds_read_in_divisor_emulation_path.patch m99_vulkan_streamvertexdatawithdivisor_write_beyond_buffer_boundary.patch m98_protect_against_deleting_a_current_xfb_buffer.patch m96-lts_vulkan_fix_issue_with_redefining_a_layered_attachment.patch +cherry-pick-d27d9d059b51.patch m100_fix_crash_when_pausing_xfb_then_deleting_a_buffer.patch diff --git a/patches/angle/cherry-pick-d27d9d059b51.patch b/patches/angle/cherry-pick-d27d9d059b51.patch new file mode 100644 index 0000000000000..5f4a253772c27 --- /dev/null +++ b/patches/angle/cherry-pick-d27d9d059b51.patch @@ -0,0 +1,100 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Charlie Lao +Date: Tue, 15 Mar 2022 09:39:36 -0700 +Subject: Vulkan: Update mCurrentElementArrayBuffersync based on dirty bit + +M96 merge issues: + ContextVk.cpp: + ContextVk::setupIndexedDraw: vertexArrayVk/getVertexArray() isn't present in M96 + ContextVk::syncState: M96 uses mVertexArray instead of vertexArrayVk + VertexArrayVk.cpp: + VertexArrayVk::updateCurrentElementArrayBuffer doesn't exist in M9 + Created it and kept M96 logic for retrieving buffer/offset + +The previous fix crrev.com/c/3513553 has run into corner case that +requires more follow up change crrev.com/c/3522565. But with that, there +is report that now we are hitting assertion in +handleDirtyGraphicsIndexBuffer(). This becomes a bit fragile This new +fix relies on the DIRTY_BIT_INDEX_BUFFER dirty bit and should be more +reliable as long as the dirty bit is set properly (if not, then we have +other bug that it won't even send down vulkan command to bind the +correct element buffer). We could further optimize the code path and +create a fast path for most common usages in the future. + +Bug: chromium:1299261 +Change-Id: Ifa8f86d431798c9ca4c128ed71a3e9e0a3537ccb +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3526021 +Commit-Queue: Charlie Lao +(cherry picked from commit 349636a05a3577a127adb6c79a1e947890bbe462) +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3605834 +Reviewed-by: Achuith Bhandarkar +Reviewed-by: Charlie Lao + +diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp +index 15243f0c5a42949c2ce94dbd415089b77a7e39bc..2ff2fd75a73b50e3bce5d72e64d5d3064f30bd66 100644 +--- a/src/libANGLE/renderer/vulkan/ContextVk.cpp ++++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp +@@ -954,6 +954,17 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context, + mGraphicsDirtyBits.set(DIRTY_BIT_INDEX_BUFFER); + mLastIndexBufferOffset = indices; + } ++ ++ // When you draw with LineLoop mode or GL_UNSIGNED_BYTE type, we may allocate its own ++ // element buffer and modify mCurrentElementArrayBuffer. When we switch out of that draw ++ // mode, we must reset mCurrentElementArrayBuffer back to the vertexArray's element buffer. ++ // Since in either case we set DIRTY_BIT_INDEX_BUFFER dirty bit, we use this bit to re-sync ++ // mCurrentElementArrayBuffer. ++ if (mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER]) ++ { ++ mVertexArray->updateCurrentElementArrayBuffer(); ++ } ++ + if (shouldConvertUint8VkIndexType(indexType) && mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER]) + { + ANGLE_PERF_WARNING(getDebug(), GL_DEBUG_SEVERITY_LOW, +diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp +index 93378c4b24495872405fc06ea01e15254229ab63..035c80a5ba95492247bd87e4189de602ffb47da1 100644 +--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp ++++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp +@@ -492,6 +492,17 @@ angle::Result VertexArrayVk::convertVertexBufferCPU(ContextVk *contextVk, + return angle::Result::Continue; + } + ++void VertexArrayVk::updateCurrentElementArrayBuffer() ++{ ++ ASSERT(mState.getElementArrayBuffer() != nullptr); ++ ASSERT(mState.getElementArrayBuffer()->getSize() > 0); ++ gl::Buffer *bufferGL = mState.getElementArrayBuffer(); ++ BufferVk *bufferVk = vk::GetImpl(bufferGL); ++ mCurrentElementArrayBuffer = ++ &bufferVk->getBufferAndOffset(&mCurrentElementArrayBufferOffset); ++ ++} ++ + angle::Result VertexArrayVk::syncState(const gl::Context *context, + const gl::VertexArray::DirtyBits &dirtyBits, + gl::VertexArray::DirtyAttribBitsArray *attribBits, +@@ -516,9 +527,7 @@ angle::Result VertexArrayVk::syncState(const gl::Context *context, + { + // Note that just updating buffer data may still result in a new + // vk::BufferHelper allocation. +- BufferVk *bufferVk = vk::GetImpl(bufferGL); +- mCurrentElementArrayBuffer = +- &bufferVk->getBufferAndOffset(&mCurrentElementArrayBufferOffset); ++ updateCurrentElementArrayBuffer(); + } + else + { +diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.h b/src/libANGLE/renderer/vulkan/VertexArrayVk.h +index c198265bf8ba2017a13fce558826862f450218b5..0b98a9ed46b7cd4b9588973c74b0bbaf9172ab6c 100644 +--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.h ++++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.h +@@ -34,6 +34,8 @@ class VertexArrayVk : public VertexArrayImpl + + angle::Result updateActiveAttribInfo(ContextVk *contextVk); + ++ void updateCurrentElementArrayBuffer(); ++ + angle::Result updateDefaultAttrib(ContextVk *contextVk, + size_t attribIndex, + VkBuffer bufferHandle,