|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Charlie Lao <cclao@google.com> |
| 3 | +Date: Tue, 15 Mar 2022 09:39:36 -0700 |
| 4 | +Subject: Vulkan: Update mCurrentElementArrayBuffersync based on dirty bit |
| 5 | + |
| 6 | +M96 merge issues: |
| 7 | + ContextVk.cpp: |
| 8 | + ContextVk::setupIndexedDraw: vertexArrayVk/getVertexArray() isn't present in M96 |
| 9 | + ContextVk::syncState: M96 uses mVertexArray instead of vertexArrayVk |
| 10 | + VertexArrayVk.cpp: |
| 11 | + VertexArrayVk::updateCurrentElementArrayBuffer doesn't exist in M9 |
| 12 | + Created it and kept M96 logic for retrieving buffer/offset |
| 13 | + |
| 14 | +The previous fix crrev.com/c/3513553 has run into corner case that |
| 15 | +requires more follow up change crrev.com/c/3522565. But with that, there |
| 16 | +is report that now we are hitting assertion in |
| 17 | +handleDirtyGraphicsIndexBuffer(). This becomes a bit fragile This new |
| 18 | +fix relies on the DIRTY_BIT_INDEX_BUFFER dirty bit and should be more |
| 19 | +reliable as long as the dirty bit is set properly (if not, then we have |
| 20 | +other bug that it won't even send down vulkan command to bind the |
| 21 | +correct element buffer). We could further optimize the code path and |
| 22 | +create a fast path for most common usages in the future. |
| 23 | + |
| 24 | +Bug: chromium:1299261 |
| 25 | +Change-Id: Ifa8f86d431798c9ca4c128ed71a3e9e0a3537ccb |
| 26 | +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3526021 |
| 27 | +Commit-Queue: Charlie Lao <cclao@google.com> |
| 28 | +(cherry picked from commit 349636a05a3577a127adb6c79a1e947890bbe462) |
| 29 | +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3605834 |
| 30 | +Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> |
| 31 | +Reviewed-by: Charlie Lao <cclao@google.com> |
| 32 | + |
| 33 | +diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp |
| 34 | +index 15243f0c5a42949c2ce94dbd415089b77a7e39bc..2ff2fd75a73b50e3bce5d72e64d5d3064f30bd66 100644 |
| 35 | +--- a/src/libANGLE/renderer/vulkan/ContextVk.cpp |
| 36 | ++++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp |
| 37 | +@@ -954,6 +954,17 @@ angle::Result ContextVk::setupIndexedDraw(const gl::Context *context, |
| 38 | + mGraphicsDirtyBits.set(DIRTY_BIT_INDEX_BUFFER); |
| 39 | + mLastIndexBufferOffset = indices; |
| 40 | + } |
| 41 | ++ |
| 42 | ++ // When you draw with LineLoop mode or GL_UNSIGNED_BYTE type, we may allocate its own |
| 43 | ++ // element buffer and modify mCurrentElementArrayBuffer. When we switch out of that draw |
| 44 | ++ // mode, we must reset mCurrentElementArrayBuffer back to the vertexArray's element buffer. |
| 45 | ++ // Since in either case we set DIRTY_BIT_INDEX_BUFFER dirty bit, we use this bit to re-sync |
| 46 | ++ // mCurrentElementArrayBuffer. |
| 47 | ++ if (mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER]) |
| 48 | ++ { |
| 49 | ++ mVertexArray->updateCurrentElementArrayBuffer(); |
| 50 | ++ } |
| 51 | ++ |
| 52 | + if (shouldConvertUint8VkIndexType(indexType) && mGraphicsDirtyBits[DIRTY_BIT_INDEX_BUFFER]) |
| 53 | + { |
| 54 | + ANGLE_PERF_WARNING(getDebug(), GL_DEBUG_SEVERITY_LOW, |
| 55 | +diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp |
| 56 | +index 93378c4b24495872405fc06ea01e15254229ab63..035c80a5ba95492247bd87e4189de602ffb47da1 100644 |
| 57 | +--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp |
| 58 | ++++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp |
| 59 | +@@ -492,6 +492,17 @@ angle::Result VertexArrayVk::convertVertexBufferCPU(ContextVk *contextVk, |
| 60 | + return angle::Result::Continue; |
| 61 | + } |
| 62 | + |
| 63 | ++void VertexArrayVk::updateCurrentElementArrayBuffer() |
| 64 | ++{ |
| 65 | ++ ASSERT(mState.getElementArrayBuffer() != nullptr); |
| 66 | ++ ASSERT(mState.getElementArrayBuffer()->getSize() > 0); |
| 67 | ++ gl::Buffer *bufferGL = mState.getElementArrayBuffer(); |
| 68 | ++ BufferVk *bufferVk = vk::GetImpl(bufferGL); |
| 69 | ++ mCurrentElementArrayBuffer = |
| 70 | ++ &bufferVk->getBufferAndOffset(&mCurrentElementArrayBufferOffset); |
| 71 | ++ |
| 72 | ++} |
| 73 | ++ |
| 74 | + angle::Result VertexArrayVk::syncState(const gl::Context *context, |
| 75 | + const gl::VertexArray::DirtyBits &dirtyBits, |
| 76 | + gl::VertexArray::DirtyAttribBitsArray *attribBits, |
| 77 | +@@ -516,9 +527,7 @@ angle::Result VertexArrayVk::syncState(const gl::Context *context, |
| 78 | + { |
| 79 | + // Note that just updating buffer data may still result in a new |
| 80 | + // vk::BufferHelper allocation. |
| 81 | +- BufferVk *bufferVk = vk::GetImpl(bufferGL); |
| 82 | +- mCurrentElementArrayBuffer = |
| 83 | +- &bufferVk->getBufferAndOffset(&mCurrentElementArrayBufferOffset); |
| 84 | ++ updateCurrentElementArrayBuffer(); |
| 85 | + } |
| 86 | + else |
| 87 | + { |
| 88 | +diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.h b/src/libANGLE/renderer/vulkan/VertexArrayVk.h |
| 89 | +index c198265bf8ba2017a13fce558826862f450218b5..0b98a9ed46b7cd4b9588973c74b0bbaf9172ab6c 100644 |
| 90 | +--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.h |
| 91 | ++++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.h |
| 92 | +@@ -34,6 +34,8 @@ class VertexArrayVk : public VertexArrayImpl |
| 93 | + |
| 94 | + angle::Result updateActiveAttribInfo(ContextVk *contextVk); |
| 95 | + |
| 96 | ++ void updateCurrentElementArrayBuffer(); |
| 97 | ++ |
| 98 | + angle::Result updateDefaultAttrib(ContextVk *contextVk, |
| 99 | + size_t attribIndex, |
| 100 | + VkBuffer bufferHandle, |
0 commit comments