src/libANGLE/VertexArray.cpp


Log

Author Commit Date CI Message
Charlie Lao 555b2328 2025-08-08T13:32:13 BindVertexBuffer should pick up buffer change in other context Buffer is modified in the first context and calling glBindVertexBuffer() of the same buffer on the second context should pick up the buffer changes made in first context. Bug: b/433331119 Change-Id: I694f66b38b11b87e0efa8d9b939f8384120823af Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6830125 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 41e44587 2025-08-06T20:04:23 BufferBindingMask in VertexArray::onBufferChanged are same buffer The bufferBiningMask bits received from VertexArray::onBufferChanged() must point to the same buffer, in case of one buffer is bound to multiple binding points. We can do some minor optimization here when we loop the BufferBindingMask bits: We only need to calculate hasConflict once when we call updateCachedTransformFeedbackBindingValidation(). Bug: b/433331119 Change-Id: I9f7cfa543deb46cd369915293b97f5d3122e1708 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6826782 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao d63cff37 2025-08-06T13:31:02 Fix bug when rebind the same buffer not pick up the change Buffer is modified in one context and rebind the same buffer on the second context should pick up the buffer changes. Bug: b/433331119 Change-Id: I8085fe826c339692881f2d3d6515efb19bbc4a88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6825767 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao d8dc3cc2 2025-08-02T12:02:20 Remove shared context lock from glVertexAttrib{I}Format This CL removes shared context lock from glVertexAttribFormat() and glVertexAttribIFormat() APIs, since they no longer access anything outside VertexArrayPrivate. The main problem I had run into is validation code. Before this CL, ValidateIntegerVertexFormat() needs context's mStateCache for mCachedVertexAttribTypesValidation and mCachedIntegerVertexAttribTypesValidation. Given these two cached value are constant after initialization, in this CL, I have moved them to PrivateStateCache. PrivateStateCache argument is added to ValidateVertexAttribFormat() and ValidateVertexAttribIFormat() to get them access to mCachedIntegerVertexAttribTypesValidation. Bug: b/433331119 Change-Id: Ifc3fbed32b4d3722c335dd2c393bc6519ed0b544 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6822032 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao c39f1d0f 2025-08-01T15:44:11 Move updateCachedTransformFeedbackBindingVali* to VertexArray Since updateCachedTransformFeedbackBindingValidation needs buffer argument, this is now moved from VertexArrayPrivate to VertexArray class to make it obvious. Also mCachedTransformFeedbackConflictedBindingsMask is per bindingIndex, so I have changed it from AttributeMask to VertexArrayBufferBindingMask. Bug: b/433331119 Change-Id: I321267637ba661b18ef236260a17e6e8f7043eb9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6814158 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 328a205f 2025-08-07T11:02:12 Revert "Fix bug when reattach the same buffer not pick up the change" This reverts commit a93f4c8d29c8d214e4823032e6e2c061d5dab1b1. Reason for revert: https://issues.chromium.org/437092065 Bug: b/433331119 Original change's description: > Fix bug when reattach the same buffer not pick up the change > > Added a test that the same buffer is used in two contexts. Buffer is > modified in one context and reattached the same buffer on the second > context's vertex array should pick up the buffer changes. This test > exposed the bug and it is fixed in this CL. > > Bug: b/433331119 > Change-Id: Ia5675581857a642fe9727f196326da9af43d52cf > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6821923 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> > Commit-Queue: Charlie Lao <cclao@google.com> Bug: b/433331119 No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iaa14b5dbbdb02c69bb060d5073072ec6ddd473ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6827998 Auto-Submit: Charlie Lao <cclao@google.com> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Charlie Lao a93f4c8d 2025-08-05T16:45:21 Fix bug when reattach the same buffer not pick up the change Added a test that the same buffer is used in two contexts. Buffer is modified in one context and reattached the same buffer on the second context's vertex array should pick up the buffer changes. This test exposed the bug and it is fixed in this CL. Bug: b/433331119 Change-Id: Ia5675581857a642fe9727f196326da9af43d52cf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6821923 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 394df705 2025-08-01T14:03:17 Cache per bufferIndex buffer properties in VertexArrayPrivate This is another preparation CL. This CL caches per bindingIndex buffer properties in VertexArrayPrivate: mCachedBufferPropertyMapped and mCachedBufferPropertyMutableOrImpersistent. The only difference between these and mCachedMappedArrayBuffers / mCachedMutableOrImpersistentArrayBuffers is that one indexed by attribIndex and another is indexed by bindingIndex. With this, when attribute binding changes, we no longer need to make buffer access. With this, we can move setVertexAttribBinding and setVertexBindingDivisor from VertexArray into VertexArrayPrivate class and Context argument is also removed. Bug: b/433331119 Change-Id: I666544ee0585727ca92d640f372f5a64d1d85576 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6814156 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao eca5244d 2025-07-30T16:59:16 Remove buffer from VertexArrayState::setAttribBinding In later CLs we try to remove shared lock from glVertexAttribBinding(). One of the lockers for that is right now setAttribBinding() references "buffer" for size. This CL caches the per binding index bufferSize in VertexArrayPrivate (i.e, std::vector<size_t> mCachedBufferSize). setAttribBinding() moved from VertexArray to VertexArrayPrivate since it no longer needs buffer access, but uses mCachedBufferSize instead. This CL also changes std::vector to std::array for mVertexArrayBuffers Bug: b/433331119 Change-Id: Ie34aef82379af8f04099cdc20ebdf354d2787a65 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6803592 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao fa29f604 2025-07-02T13:23:31 Remove sharedContextLock from {Enable|Disable}VertexAttribArray VertexArray objects are per context objects. In theory they do not need to protected by shared context lock. The reason we are taking locks because all these functions end up accessing Buffer object which are shared. In prior CLs we have removed subject observer usage from VertexArray which means VertexArray no longer accessed from other thread. In prior CLs we also split VertexArray into two classes: VertexArrayPrivate which has no buffer, and VertexArray which is subclass from VertexArrayPrivate and owns buffer. In this CL, glEnableVertexAttribArray and glDisableVertexAttribArray calls no longer take shared context lock. ContextPrivateEnableVertexAttribArray and ContextPrivateDisableVertexAttribArray are called from these two APIs and they only have access to StatePrivate. State Private holds a VertexArrayPrivate pointer, which means they do not have anyway to access buffer objects. The main challenge I run into here is mCachedActiveClientAttribsMask, mCachedActiveBufferedAttribsMask, mCachedActiveDefaultAttribsMask, mCachedHasAnyEnabledClientAttrib, mCachedNonInstancedVertexElementLimit, mCachedInstancedVertexElementLimit. These StateCache variable needs to be updated when these two APIs are called, and calculating these variable needs access to buffer object. The solution here is adding a bool mIsCachedActiveAttribMasksValid in the PrivateStateCache so that instead of immediately update these mCached* variable, we just set mIsCachedActiveAttribMasksValid to false. Then whenever any of these mCached* variable is needed, we will check mIsCachedActiveAttribMasksValid and calculate these cached variables. It adds one if check when accessing these caches, but the other benefit is that we may have avoided duplicated calculation when multiple states changed. Bug: b/433331119 Change-Id: I3227c72bc40501712db93fb3d540b835f07150b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4514436 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao b4d84458 2025-05-23T18:08:19 Move Buffer from VertexBinding to VertexArray In later CL we will not taking shared context lock for certain VertexArray API calls. VertexArray itself is per context, so this sounds reasonable to do. The main challenge here is a lot of VertexArray function end up accessing gl::Buffer object, which could be modified by other shared contexts. In order to safely not taking the shared context lock, we need to separate out Buffer object out of VertexArray itself so that these lockless APIs will take VertexArray that does not have access to buffer. In this CL, VertexArray is split into two classes: VertexArrayPrivate is everything in VertexArray except buffers. VertexArray is a subclass of VertexArrayPrivate and owns all the buffers. Buffer is removed from gl::VertexBinding class. In order to let back end access to buffers, VertexArrayImpl holds a weak reference to VertexArray::mVertexArrayBuffers (which is a vector of buffers). Further, VertexArrayBufferBindingMask mBufferBindingMask is moved from VertexArrayState into VertexArray class well, since it tracks which index has a non-null buffer. The bulk of change are due to the VertexARrayImpl constructor change, since it now takes vertexArrayBuffers argument. Other bulk of changes are due to VertexBinding no long has the buffer, but you need to get it directly from VertexArray or VertexArrayImpl. This CL also reverts some of the change in crrev.com/c/6758215 that mVertexBindings no longer contains kElementArrayBufferIndex. BYPASS_LARGE_CHANGE_WARNING Bug: b/433331119 Change-Id: I15f4576f7c5c8d8f4d9c9c07d38a60ce539bfeea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6774702 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 8dca0efe 2025-07-21T15:29:10 Replace VertexArray::DIRTY_BIT_LOST_OBSERVATION with API call This dirty bit was added so that back end can inspect buffers and set proper VertexArray::DirtyBitType. The same thing can achieved by add a virtual function on VertexArrayImpl class. The advantage of virtual function on VertexArrayImpl is that all back end essentially have the same implementation and we can just implemented in VertexArrayImpl instead of duplicate in each back end. The other advantage is after this CL DIRTY_BIT_BINDING_n and DIRTY_BIT_BUFFER_DATA_n will be well aligned instead of offset by 1 caused by DIRTY_BIT_LOST_OBSERVATION. The other motivation of this change is in later CL I want to move mBufferBindingMask out of VertexArrayState, which means back end will not have access to it. By using VertexArrayImpl API, I can pass mBufferBindingMask directly to the back end via function parameter. So, this CL removed DIRTY_BIT_LOST_OBSERVATION, added VertexArrayImpl::checkBufferForDirtyBits(). Bug: b/433331119 Change-Id: I5c8cbc9bace63db416e86c2ae3631f74a12b20b8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6775986 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 40a2a912 2025-07-15T14:39:10 Track mElementArrayBuffer in std::vector<VertexBinding> Right now mElementArrayBuffer are treated a little bit differently from other vertex buffers, mainly because of elementBuffer does not have corresponding "attributeIndex" to bind to. But a lot of logic in VertexArray are same for mElementArrayBuffer and mVertexBindings. In recent CLs, we are using mBufferBindingMask to track both mElementArrayBuffer and mVertexBindings with kElementArrayBufferIndex represents element buffer. With that, some of logic handling buffers can be merged, with looping of mBufferBindingMask bits. In later CL, we are going to separate "binding" from "buffer" so that we can move buffer out of VertexArrayState class. So this is also a preparation CL so that when we move buffers out of VertexArrayState class, it does so for all buffers (both element buffer and vertex buffers). In order to track how many vertex buffers in mVertexBindings, a new variable mMaxVertexAttribBindings is added. In later CL when we move buffers out of VertexBinding, some of this CL's change will be reverted back, mVertexBindings will be reverted back to track only bindings and mMaxVertexAttribBindings will be deleted. Bug: b/433331119 Change-Id: Idd2cfe4ce64bb22923bac70abb752e132fe1abd3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6758215 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 9635df8e 2025-07-16T15:13:19 Move mCached*ArrayBuffers from VertexArrayState to VertexArray The three cached AttributeMasks variables are mCachedMappedArrayBuffers, mCachedMutableOrImpersistentArrayBuffers, mCachedInvalidMappedArrayBuffer. They are currently declared in VertexArrayState class. They are only accessed by VertexArray front end, back end does not use them, which means they do not need to be in VertexArrayState class. This CL moves these three variables to VertexArray class in preparation for later CLs that VertexArrayState will not have access to Buffer objects. This CL also removed unnecessary updateCachedMutableOrNonPersistentArrayBuffers call from VertexArray::enableAttribute, since mCachedMutableOrImpersistentArrayBuffers does not depend on any variables enableAttribute() is modifying. Bug: b/433331119 Change-Id: I8b1f0c7d511dbc6858d20f33863154e8fe3077f8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6762902 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 9a05a2b7 2025-06-23T16:24:13 Reland "Vulkan: Avoid some loops in VertexArray::onBufferChanged" This reverts commit 5df85793c602d64d47ef68e29542313be4116bc0. Reason for revert: the regression bug is fixed Some of the functionality related code has been merged into previous CL. This CL now mostly clean up. The old subject/observer code is been deleted from VertexArray. Bug: angleproject:400711938 Original change's description: > Revert "Vulkan: Avoid some loops in VertexArray::onBufferChanged" > > This reverts commit 8d6d127acc1072488e5b57ba4e7e93da2d94bfda. > > Reason for revert: https://issues.chromium.org/427064102 > > Bug: angleproject:400711938 > Original change's description: > > Vulkan: Avoid some loops in VertexArray::onBufferChanged > > > > Before this CL, VertexArray::onBufferChanged() loops over > > bufferBindingMask bits and calls onSubjectStateChange. In this CL, > > VertexArray::onSubjectStateChange is embedded into > > VertexArray::onBufferChanged(). DIRTY_BIT_ELEMENT_ARRAY_BUFFER and > > DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA is re-arranged so that we can map > > bufferBindingMask directly to VertexArray::mDirtyBits. This especially > > useful when one buffer is bound to multiple indices in the VertexArray. > > > > This CL also removes angle::ObserverInterface from VertexArray, since it > > no longer observes anything. > > > > ASSERT is added in gl::Buffer::mContentsObservers to ensure it only > > contains BufferTexture, since vertexArray is no longer using the > > subject/observer. > > > > Bug: angleproject:400711938 > > Change-Id: Ie6e7159d7a89f0da5e1b7ca0a9dbe60a1e6c682f > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6569638 > > Reviewed-by: Geoff Lang <geofflang@chromium.org> > > Commit-Queue: Charlie Lao <cclao@google.com> > > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > > Bug: angleproject:400711938 > Change-Id: I3b8e77db7b3d06b9ed875bfe7787904ac753da11 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6664161 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Bug: angleproject:400711938 Change-Id: If7989b26701dcccbb8e49c42d388c0217e2d0b7f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6663536 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 2ac49bb6 2025-07-01T12:11:12 Reland "Vulkan: Move VertexArray::ElementBuffer away from observer" This reverts commit 79ac1a8cd767a32cce6401203e20c4bd4ca4d539. Reason for revert: the regression bug is fixed in PS6 The regression bug with the original CL is caused by when we bind a vertex array without element buffer rebind, we missed to reset mIndexRangeInlineCache. The other bug is that VertexArray::mDiryBits is 64 bit but VertexArrayBufferBindingMask is 16 bit, in VertexArray::setDependentDirtyBits(), bufferBindingMask.to_ulong() << DIRTY_BIT_BUFFER_DATA_0 is only producing the 32 bit value on windows platform due to unsigned long is 32 bit value. bits() is used and bit shift is operated on to uint64_t here to avoid dropping high bits on windows. Two tests are added that reproduce the regression bug caused by the original CL. Bug: angleproject:400711938 Original change's description: > Revert "Vulkan: Move VertexArray::ElementBuffer away from observer" > > This reverts commit 3f012a43ee2c101543785720eedfeaa80708479d. > > Reason for revert: https://issues.chromium.org/427064102 > > Bug: angleproject:400711938 > Original change's description: > > Vulkan: Move VertexArray::ElementBuffer away from observer > > > > Right now, VertexArray's element buffer is always observing buffer's > > change. In previous CLs, we have moved vertex array away from > > subject/observer usage. This CL moves element buffer away from > > subject/observer as well. Since the gl::Buffer tracks buffer's binding > > to each context's current vertex array's binding point, > > kElementArrayBufferIndex is added to VertexArrayBufferBindingMask bits > > so that the element buffer is tracked exactly the same as other vertex > > array buffer bindings. The VerextArray code has been modified to handle > > this special bit, since element buffer has its own binding point > > VertexArrayState::mElementArrayBuffer as opposed to > > VertexArrayState::mVertexBindings. After this CL, VertexArray object > > should be completely off subject/observer usages. > > > > Bug: angleproject:400711938 > > Change-Id: I662ddfabc95034bdc7734939c944ab033f41801c > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6552160 > > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > > Reviewed-by: Geoff Lang <geofflang@chromium.org> > > Commit-Queue: Charlie Lao <cclao@google.com> > > Bug: angleproject:400711938 > Change-Id: I9487ba8b108baaeda1c8a27189dba64f77616774 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6663539 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Bug: angleproject:400711938 Change-Id: I3f47ad1238c41f12b5cbd7a59b84be3fce1e9562 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6664004 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 79ac1a8c 2025-06-23T11:11:10 Revert "Vulkan: Move VertexArray::ElementBuffer away from observer" This reverts commit 3f012a43ee2c101543785720eedfeaa80708479d. Reason for revert: https://issues.chromium.org/427064102 Bug: angleproject:400711938 Original change's description: > Vulkan: Move VertexArray::ElementBuffer away from observer > > Right now, VertexArray's element buffer is always observing buffer's > change. In previous CLs, we have moved vertex array away from > subject/observer usage. This CL moves element buffer away from > subject/observer as well. Since the gl::Buffer tracks buffer's binding > to each context's current vertex array's binding point, > kElementArrayBufferIndex is added to VertexArrayBufferBindingMask bits > so that the element buffer is tracked exactly the same as other vertex > array buffer bindings. The VerextArray code has been modified to handle > this special bit, since element buffer has its own binding point > VertexArrayState::mElementArrayBuffer as opposed to > VertexArrayState::mVertexBindings. After this CL, VertexArray object > should be completely off subject/observer usages. > > Bug: angleproject:400711938 > Change-Id: I662ddfabc95034bdc7734939c944ab033f41801c > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6552160 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Charlie Lao <cclao@google.com> Bug: angleproject:400711938 Change-Id: I9487ba8b108baaeda1c8a27189dba64f77616774 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6663539 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao 5df85793 2025-06-23T11:08:49 Revert "Vulkan: Avoid some loops in VertexArray::onBufferChanged" This reverts commit 8d6d127acc1072488e5b57ba4e7e93da2d94bfda. Reason for revert: https://issues.chromium.org/427064102 Bug: angleproject:400711938 Original change's description: > Vulkan: Avoid some loops in VertexArray::onBufferChanged > > Before this CL, VertexArray::onBufferChanged() loops over > bufferBindingMask bits and calls onSubjectStateChange. In this CL, > VertexArray::onSubjectStateChange is embedded into > VertexArray::onBufferChanged(). DIRTY_BIT_ELEMENT_ARRAY_BUFFER and > DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA is re-arranged so that we can map > bufferBindingMask directly to VertexArray::mDirtyBits. This especially > useful when one buffer is bound to multiple indices in the VertexArray. > > This CL also removes angle::ObserverInterface from VertexArray, since it > no longer observes anything. > > ASSERT is added in gl::Buffer::mContentsObservers to ensure it only > contains BufferTexture, since vertexArray is no longer using the > subject/observer. > > Bug: angleproject:400711938 > Change-Id: Ie6e7159d7a89f0da5e1b7ca0a9dbe60a1e6c682f > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6569638 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:400711938 Change-Id: I3b8e77db7b3d06b9ed875bfe7787904ac753da11 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6664161 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao 8d6d127a 2025-05-20T12:26:56 Vulkan: Avoid some loops in VertexArray::onBufferChanged Before this CL, VertexArray::onBufferChanged() loops over bufferBindingMask bits and calls onSubjectStateChange. In this CL, VertexArray::onSubjectStateChange is embedded into VertexArray::onBufferChanged(). DIRTY_BIT_ELEMENT_ARRAY_BUFFER and DIRTY_BIT_ELEMENT_ARRAY_BUFFER_DATA is re-arranged so that we can map bufferBindingMask directly to VertexArray::mDirtyBits. This especially useful when one buffer is bound to multiple indices in the VertexArray. This CL also removes angle::ObserverInterface from VertexArray, since it no longer observes anything. ASSERT is added in gl::Buffer::mContentsObservers to ensure it only contains BufferTexture, since vertexArray is no longer using the subject/observer. Bug: angleproject:400711938 Change-Id: Ie6e7159d7a89f0da5e1b7ca0a9dbe60a1e6c682f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6569638 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 3f012a43 2025-05-14T17:11:06 Vulkan: Move VertexArray::ElementBuffer away from observer Right now, VertexArray's element buffer is always observing buffer's change. In previous CLs, we have moved vertex array away from subject/observer usage. This CL moves element buffer away from subject/observer as well. Since the gl::Buffer tracks buffer's binding to each context's current vertex array's binding point, kElementArrayBufferIndex is added to VertexArrayBufferBindingMask bits so that the element buffer is tracked exactly the same as other vertex array buffer bindings. The VerextArray code has been modified to handle this special bit, since element buffer has its own binding point VertexArrayState::mElementArrayBuffer as opposed to VertexArrayState::mVertexBindings. After this CL, VertexArray object should be completely off subject/observer usages. Bug: angleproject:400711938 Change-Id: I662ddfabc95034bdc7734939c944ab033f41801c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6552160 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 937cf23c 2025-05-13T16:11:47 Vulkan: Remove VertexArrayBufferContentsObservers When vertex array needs to convert buffer's data, right now it uses Subject/Observer to subscribe notifications from buffers about the data change. Since we always dirty all binding point when we bind VertexArray, or app has to rebind buffer to vertex array if its on the other context, this notification really is only needed for the current context's vertex array. In prior CLs we already moved notification from buffer to the current context's vertex array away from Subject/Observer usage pattern. This CL did similar things to VertexArrayBufferContentsObservers::mContentsObservers. VertexArrayBufferContentsObservers has been deleted in this CL. Each VertexArrayImpl now tracks the need of content observer with a bit mask of each bindingIndex (which is tracked by mContentsObserverBindingsMask). When a buffer's content changes, gl::Buffer will retrieve this bit mask from backend and pass it to the current gl::Context, which sends to current VertexArray object, which then set proper DATA dirty bits on VertexArray based on the binding bit mask. If back end think it does not need any data conversion, then the bit mask is zero and nothing will be done. This further removes dependence on subject observer, which enables us to avoid taking shared context lock for glEnableVertexAttribArray and glDisableVertexAttribArray. Bug: angleproject:400711938 Change-Id: Ieb0c09c042a560dd121242b63ec24478482399b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6549157 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Charlie Lao f5f6704c 2025-03-27T13:58:14 Vulkan: Remove mArrayBufferObserverBindings Right now VertexArray observes gl::Buffer change. Buffer change will end up with many virtual function calls on VertexArray. GL spec says that when buffer changes, only the current context's vertex array have to pick up the changes without any GL API call. All other context's vertex array must issue bind calls to pick up the buffer's state change. This CL removes VertexArray::mArrayBufferObserverBindings as gl::Buffer's observer. The Buffer's change is directly applied to current context's vertexArray (Note that gl::VertexArray still have mContentsObservers which is not touched in this CL. Once the content observer also removed, there will be no observer calls into gl::VertexArray which allows us to do further optimizations on vertex arrays.) In order to further reduce the overhead, we also tracks vertex array's binding index in the buffer. When a buffer is bound to current vertex array, the bit is set at that index and bit is removed when buffer is unbound. When vertex array becomes un-current, all bits are cleared. Since a buffer could be bound to multiple context's current vertex array, that bitmask is tracked for multiple contexts with the contextID. Bug: angleproject:400711938 Change-Id: I9ad91573e101d7bf11a742a3d823bd8965f43395 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6419663 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 3b77a177 2025-04-23T15:47:07 Optimize vertex attribute and buffer state change Bug: angleproject:386749841 Change-Id: I25968902282f6a201510e2ee17ea85fd71ef57c7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6483915 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Roman Lavrov 12dd42b8 2025-04-04T09:54:12 Reduce number of function calls in glVertexAttribPointer Small but noticeable improvement in a synthetic test on Android Bug: b/383305597 Change-Id: I6e88a06f4d3bf2e0b51ee1fd3f4f26bf55d9364e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6432611 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Kimmo Kinnunen c2679dbc 2025-03-10T12:15:08 Key vertex array index range cache on restart Key vertex array index range cache on primitive restart enablement. Add the test to WebGLCompatibilityTest as otherwise the VertexArray::getIndexRange() is not testable. Currently WebGL compatibility contexts allow changing primitive restart. Bug: angleproject:401284933 Change-Id: I48a53770d7dcb2276b89fd743f4834c53c8d8d1e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6333538 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Geoff Lang da572160 2024-07-23T16:36:10 Reland: GL: Forward client-side arrays to the driver when possible The OpenGL driver can handle client-side arrays when the context is OpenGL ES or a desktop GL compatibility profile. When in these situations, use the driver default VAO for all frontend context VAOs and forward client-side data directly to the driver. Fix synchronizing the default VAO state for external contexts. There is no valid VertexArrayStateGL for external VAOs so make sure it's nulled and the VAO dirty bits are set so the correct VAO state is reapplied. Disable syncing to the default VAO for external contexts. The only VAO that they can share with ANGLE's internal state is the default VAO so avoid having to save and restore its state. Bug: angleproject:355034686 Change-Id: I015bbbc854938fe4bc1e92d0ca8fe04628d0db16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5743284 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Charlie Lao 9b06e003 2024-08-02T15:47:36 Vulkan: Avoid unnecessary observer changes for Buffers Noticed in black_desert_mobile hat it calls glVertexAttribPointer with some buffer. What we end up doing is remove observer from old buffer and add observer to new buffer. This CL checks if old and new buffer are the same and skip some of the logic if both buffers are the same. Also added check in VertexArrayBufferContentsObservers::disableForBuffer to early out if it was not enabled in the first place. Bug: b/356473483 Change-Id: I872dcee7d87b404f525d0323d2952c8249ef1c9a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5760652 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Geoff Lang a0a832de 2024-07-26T12:33:37 Revert "GL: Forward client-side arrays to the driver when possible" This reverts commit a6c2b4346516f228054b5bdd754bbc6f3ba1cba7. Reason for revert: Fails some Chrome tests on Android after rolling: https://chromium-review.googlesource.com/c/chromium/src/+/5742024 Original change's description: > GL: Forward client-side arrays to the driver when possible > > The OpenGL dirver can handle client-side arrays when the context is > OpenGL ES or a desktop GL compatability profile. When in these > sitatuions, use the driver default VAO for all frontend context VAOs > and forward client-side data directly to the driver. > > Bug: angleproject:355034868 > Change-Id: I21a4459c4f7db780b51441d76e63d17bf737c101 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5736058 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> > Commit-Queue: Geoff Lang <geofflang@chromium.org> Bug: angleproject:355034868 Change-Id: I76f95d66ca277bcbb67300179e49287b433c1ede No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5742647 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: Geoff Lang <geofflang@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Geoff Lang a6c2b434 2024-07-23T16:36:10 GL: Forward client-side arrays to the driver when possible The OpenGL dirver can handle client-side arrays when the context is OpenGL ES or a desktop GL compatability profile. When in these sitatuions, use the driver default VAO for all frontend context VAOs and forward client-side data directly to the driver. Bug: angleproject:355034868 Change-Id: I21a4459c4f7db780b51441d76e63d17bf737c101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5736058 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 5a062a39 2023-12-14T21:15:59 Do not update the vertex attribute limit on divisor change The effect of the divisor on the vertex attribute limit is accounted for in StateCache::updateVertexElementLimitsImpl since https://chromium-review.googlesource.com/c/angle/angle/+/5101508, and so the vertex attribute's mCachedElementLimit is now independent of the divisor. Bug: angleproject:8448 Change-Id: I3f76986d6b8d3ba6b0ebd955f9a26854ee8c20e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5122996 Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 76fa3806 2023-05-04T10:19:35 Vulkan: Expand BufferOnly path for VertexArray binding change VertexArrayVk has a fast code path for attribute change where the only change is buffer (i.e, no format or relativeOffset change). It will pass in bufferOnly to syncDirtyAttrib() call and will avoid invalidate graphics pipeline. This CL expands DIRTY_BIT_BINDING_n change and will also try to detect the bufferOnly case. This CL and crrev.com/c/4507978 together seeing Gfxbench driver overhead score improves 1.48% (from average 6804 before CLs to 6905 after CLs) on pixel 7 pro. Bug: b/277644512 Change-Id: I71da1b886bb26ba2629b83af3aeaba4d45c3d3c2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4504919 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Auto-Submit: Charlie Lao <cclao@google.com>
Charlie Lao 0561884e 2023-04-26T17:26:42 Vulkan: Dirty VertexArray binding bit if buffer storage change In crrev.com/c/3669603, we did optimization for black_desert_mobile that when vertex array is unbound, we remove vertex array from buffer's observer list to reduce overhead of observer notifications when buffer is been modified. To compensate for the lost notification, when vertex array is bound, we always assume every buffer that is bound to vertex array has been dirtied, for the simplicity at that time. This CL further the optimization of that CL. In this CL, I moved the dirty bit set into backend and improves vulkan backend by checking buffer's serial number and only dirty the binding if the serial has changed. Given this, now we can also remove all the non-current vertex array from buffer's observer list (previously it is heuristic based with a hard coded observer count limit). This and the previous CL improves asphalt_9 by ~1%. Bug: b/277644512 Change-Id: Ibc3f8e3df9fe70c6879e0b2bca86d8487a9dba73 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4481241 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 89a8ba7d 2023-04-25T17:08:42 Vulkan: Add bit mask vertex array buffer binding point. There are various places we are looping all vertex binding points. Right now it is always 16, even though most of them do not have any buffer bound. This CL adds mArrayBufferBindingBitMask, which is the bit mask tracking all binding index that has a buffer bound. Now we only need to loop for all bindings that actually have a buffer, which usually much less than 16. This CL also removes some redundant use of "gl::" name space. Bug: b/277644512 Change-Id: I30d053274839bfa7c56487651b95c62f2a2c67e3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4478229 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Mark Lobodzinski fb3e2def 2022-05-24T15:47:01 Extend labelObject functionality Modify interface to fully support labelObject return codes. Fix issues with texture implementation, including handling deferred Vulkan object creation. Bug: b/229105865 Change-Id: I0c64b72dd0b54642fb643ee7f5ccbb2a134c6787 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3703184 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Charlie Lao b186991a 2022-05-26T11:50:56 Vulkan: Remove non-current vertex array from buffer's observer list When app binds a buffer to many VAOs, any buffer modification have to loop over all VAOs that uses that buffer, even though all these VAOs are not current except one VAO. That causes significant CPU overhead. black_desert_mobile has this type of usage. This CL checks number of observers on each binding and if there are excessive observers, it removes VAO from the buffer's observer list when it becomes non-current and adds back to observer list when it becomes current. This CL reduces CPU overhead of black_desert_mobile (as measured with --offset --minimumgpuwork) from 21ms to 3.69ms, on par with native GLES driver. Note that this CL only touches glBindVertexArrayObject call code path, so no impact to apps not using VAOs. There is also no measurable CPU time regression on a few other app traces that uses VAOs. Bug: angleproject:6371 Change-Id: I6b1589f3e3c768d56c1c95cebdb577e3e256737f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3669603 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao ff011779 2022-05-13T12:36:24 Vulkan: Let texture buffer handle BufferVk's storage change When buffer's storage changed due to glBufferData call, texture buffer code should also respond to this and update the texture descriptor set. This CL merges BufferVkStorageChanged message into InternalMemoryAllocationChanged and removed BufferVkStorageChanged all together. Bug: angleproject:7283 Change-Id: I230ee7268634e747d06eab1954f5a76ecf84c9d6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3646955 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
SeongHwan Park a8cac005 2022-04-25T16:27:33 Remove observer when element array buffer is detached Fix an issue where the observer is not removed when the element array buffer is detached from the vertex array. This fixes use-after-free vulnerability. Bug: angleproject:7237 Change-Id: I7cf30322740edffccdba89d40c0d02cd351dad78 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3603007 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 37cdf93d 2022-04-15T12:49:09 Vulkan: Acquire a new buffer even when size is unchanged If a buffer is respecified using glBufferData with no changes to size but client data pointer is null, we need to acquire a new BufferHelper to avoid affecting the results of previously submitted draws. Test: BufferDataTestES3.BufferDataWithNullFollowedByMap*Vulkan Bug: angleproject:7211 Change-Id: Icc20fe3509f94098c7a15988a9ebc888b06fd3c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3588955 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Peng Huang 445bf9bd 2022-04-09T08:42:12 Use the real max vertex attrib index instead of MAX_VERTEX_ATTRIBS Bug: chromium:1258869 Change-Id: I7de23353fc6922be9b3201c87d33e0cfdc427569 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3580578 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Peng Huang 92e99653 2022-04-08T16:33:42 Fix crashes in gl::VertexArray::detachBuffer() and onDestory() The crashes is because gl::MAX_VERTEX_ATTRIB_BINDINGS(16) is used for iterating mState.mVertexBindings. However it's size is not always 16. It can be 8 for some PowerVR GPU with GLES 2 driver. Bug: chromium:1258869 Change-Id: I3b572d153cb16fb46920483612e3cdbc6ee57577 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3577813 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Lingfeng Yang a93a3930 2021-12-08T20:36:07 Vulkan: Track enabled in VertexArray Previously in sequences such as glEnableVertexAttribArray(0) glDrawElements() glDisableVertexAttribArray(0) glEnableVertexAttribArray(0) glDrawElements() the second glDrawElements() would always be called with dirty enable. On some backends like Vulkan this could result in unnecessary pipeline changes. Bug: angleproject:6796 Change-Id: Ib44877b6030e8d0acede7cf5c591936ba3844b69 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3325208 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Lingfeng Yang <lfy@google.com>
Amirali Abdolrashidi 89e11878 2021-12-06T09:42:46 Vulkan: Fix the UAF issue with BufferData * Fixed the use-after-free issue with stale buffer handles after calling BeginTransformFeedback. * Added an observer for TransformFeedbackVk to update the buffer handles when buffer's storage is changed and the buffer update type is StorageRedefined. * Added a function to TransformFeedbackVk::onDestroy() to release the counter buffers in order to avoid crash due to TransformFeedbackVk::end() not being called, e.g., as a result of no glEndTransformFeedback() calls. Bug: chromium:1274316 Change-Id: I8ed477f36e6ff89dd4764bb59af564c69efe33e2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3321789 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Steven Noonan 397a27bb 2021-10-20T20:33:20 VertexArray: on destroy, remove observer on element array buffer Otherwise there will be a null pointer dereference in gl::Buffer::onContentsChange(). Signed-off-by: Steven Noonan <steven@valvesoftware.com> Bug: angleproject:6599 Change-Id: I73388b6d0ccc357ca1944452a18ccf462dd8046c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3236206 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Mateusz Przybylski 076366cc 2021-10-01T23:42:04 Revert "VertexArray: Don't syncState on Buffer map/unmap." This reverts commit 3d429f597fde950e789ca3684abbabd540157773. Reason for revert: This change is causing crashes in ANGLE stack. Original change's description: > VertexArray: Don't syncState on Buffer map/unmap. > > Map/unmap calls are now treated like contents change events. Similar > to BufferSubData calls. > > Bug: angleproject:6371 > Change-Id: Ie0a4c521ffdedfa723d47eddd21c6f68dde044ac > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3187811 > Commit-Queue: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: angleproject:6371 Change-Id: I57480a18f3c70a1bf2a539e3047402c71802655d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3200288 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 3d429f59 2021-09-27T14:27:31 VertexArray: Don't syncState on Buffer map/unmap. Map/unmap calls are now treated like contents change events. Similar to BufferSubData calls. Bug: angleproject:6371 Change-Id: Ie0a4c521ffdedfa723d47eddd21c6f68dde044ac Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3187811 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill cf8c5678 2021-09-17T13:16:36 Vulkan: Don't sync VAOs after BufferSubData calls. We still need to syncState after buffers that contain converted attributes are updated. Includes a perf regression test. Bug: angleproject:6371 Change-Id: I54227fc43e7b3fe79072da7783dab0177ccb0486 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3182706 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 30878d2a 2021-09-24T09:23:56 Buffer: Notify contents changed in a separate observer list. Buffer contents changed will only notify VertexArray. Also this list is separated from the other observers because in the future most of the time we won't need to notify the VertexArrays when buffer contents changed, to avoid iterating over a large list of VertexArray observers on simple SubData calls. Bug: angleproject:6371 Change-Id: I6142a5757868caf33dc6594a1975f817f80553e8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3182701 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 49ac15a5 2021-09-20T11:29:01 Optimize VAO bindings. This CL makes the XFB binding tracking WebGL-only. That will speed up VAO binding changes in non-WebGL considerably. Also has a few inline micro-optimizations that may not have a large effect. Bug: angleproject:6371 Change-Id: Ib0a26a3b956dcd6ff78626e5cd6514b46270d882 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3170116 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten 68c0da83 2021-09-15T12:00:08 Vulkan: Inform frontend when new buffer is allocated When a buffer is mapped with GL_MAP_INVALIDATE_BUFFER_BIT while it's currently in use, the Vulkan backend will allocate a new buffer, map it, and return the pointer to the new buffer. This was missing a call to inform the frontend that a new buffer was allocated, causing the old buffer data to be accessed in subsequent draw calls. The fix is to add a onStateChange(angle::SubjectMessage::SubjectGhosted) call when the new buffer is allocated, to inform the frontend. Bug: angleproject:5971 Bug: angleproject:6396 Test: TextureBufferTestES31.MapTextureBufferInvalidateThenWrite Change-Id: I9984d1049ab4d6a2066f4440fc710c9b93ff6ab8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3163244 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 9158436e 2021-07-31T18:26:16 Vulkan: glMapBuffer(): Create new buffer (Buffer Ghosting) When glMapBuffer() is called, if the buffer is in use but not being written to by the GPU: 1.) Create a new buffer. 2.) Copy the contents of the old buffer into the new buffer. 3.) Map the new buffer and return the pointer. Creating a new buffer prevents ending the renderpass and flushing the commands to allow the in-use buffer to be mapped. This change increases Idle Heroes performance from 40FPS to 125FPS. Bug: angleproject:5971 Test: VulkanPerformanceCounterTest.MappingGpuReadOnlyBufferGhostsBuffer Test: BufferDataTest.MapWriteArrayBufferDataDrawQuad Test: BufferDataTest.MapWriteArrayBufferDataDrawArrays Change-Id: I1d433d179f9f5110a948f191c5aedda5397acac8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3065799 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Jamie Madill 7e040640 2021-08-16T08:43:17 libANGLE: Minor cleanups. Removes a couple duplicated cached members in gl::State. Also a few other small refactorings. Bug: angleproject:5133 Change-Id: I0c6cd4c6544ef1690a4ce95d40dac70c688c7092 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3097808 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Shahbaz Youssefi 4921e457 2021-01-22T22:36:13 Vulkan: Avoid unnecessary pipeline rebinds Bug: angleproject:5528 Change-Id: I5502498fa5d6767f55635fe9fff949d7fd644f4f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2645640 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tim Van Patten 220642a9 2020-12-16T21:10:37 Allow Drawing with Immutable Persistent Mapped Buffers From the EXT_buffer_storage overview: The GL_EXT_texture_storage extension added immutable storage for texture objects (and was subsequently incorporated into OpenGL ES 3.0). This extension further applies the concept of immutable storage to buffer objects. [T]his extension introduces the concept of persistent client mappings of buffer objects, which allow clients to retain pointers to a buffer's data store returned as the result of a mapping, and to issue drawing commands while those mappings are in place. The initial implementation of EXT_buffer_storage didn't enable this portion of the extension, so ANGLE is generating errors while attempting to draw with an immutable buffer mapped with the GL_MAP_PERSISTENT_BIT flag. This CL enables that functionality, since apps (e.g., FIFA Soccer) rely on it. Bug: angleproject:5473 Change-Id: Icf1c0597156044a342aac5e4d2abbc29b34f46b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2596957 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Jamie Madill 57d95828 2020-04-30T17:35:50 Revert "Add type for attribute locations." This reverts commit 9349c14344b2d1fd6bc357063b602bc2626c140f and commit d43b057435e6c9e3194dd20627681ffca0c0808e. It's no longer needed after we bind attribute locations before link. Original CL message: This will allow the capture/replay tool to easily intercept and label attribute locations for remapping. There's some inconsistency in implementation in the GL desktop front- end. This is a quick fix and the full implementation is left for when we implement the full desktop GL API set. Bug: angleproject:4598 Change-Id: Ic510159d4d1982eff41560503cabf983a1be0381 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2174076 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 9349c143 2020-04-29T16:36:17 Add type for attribute locations. This will allow the capture/replay tool to easily intercept and label attribute locations for remapping. There's some inconsistency in implementation in the GL desktop front- end. This is a quick fix and the full implementation is left for when we implement the full desktop GL API set. Bug: angleproject:4598 Change-Id: Ibf11bcb8669d27265ea376494a2e3124825cf3be Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2171933 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Jamie Madill f703443b 2019-09-21T14:10:35 Use Resource IDs in RefCountObject. This lets us use strongly typed IDs pretty much everywhere. Only one or two additional places still use GLuint IDs. Mostly for external queries and for Framebuffer Attachments. With some clever type reflection helpers lets us define a single template function for handling operator== and != for resource IDs. Refactor in preparation for more Capture/Replay work. Bug: angleproject:3611 Change-Id: I1c0c848e89eb8a4b769714d57686f816daf01634 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1815550 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tobin Ehlis <tobine@google.com>
Austin Kinross bf4268a3 2019-09-17T13:33:56 Fix misc VS2019 bool conversion warnings BUG=angleproject:3921 Change-Id: I06de5131f98b27c2556ed60dd7228c9cfa154802 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1811858 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiacheng Lu feb8507f 2019-09-03T13:22:04 Use VertexArrayID in place of GLuint handle Bug: angleproject:3804 Change-Id: I0454533eff13218a6aa1e1672ffcd0e76aedb399 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1769716 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jiacheng Lu 0136ac37 2019-07-17T17:29:52 Separate dirty bit for attrib's binding VBO change Make a separate dirty bit DIRTY_ATTRIB_POINTER_BUFFER for vertex attrib's binding buffer change. So in handling glVertexAttribPointer, ANGLE will only modify a vulkan graphics pipeline when attrib.format, attrib.stride or attrib.divisor change. If only the VBO pointer changes, then Vulkan can update the state via "vkCmdBindVertexBuffers()" without triggering a pipeline update. Bug: angleproject:3256 Change-Id: I01e02adde3708963b496a20050a5723e8eb57ab2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1707614 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jiacheng Lu <lujc@google.com>
James Darpinian 153f3c22 2019-08-16T15:24:30 Miscellaneous build fixes for WebKit Add a USE_SYSTEM_EGL define to allow compilation on Unix systems without X11. Feature detect __popcnt using Microsoft-specific _MSC_VER rather than _M_X64/_M_IX86, which can be set by the Dinkumware stdlib on non-Microsoft systems. Apple's clang is too old to have -Wextra-semi-stmt Ran generate_parser.sh using Cygwin64 bison 3.0.4, flex 2.6.4 Bug: 3439 Change-Id: Ie0d01a112a17f70ef60c120063a958b8f1a094f4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1759135 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
James Darpinian 7e48c9eb 2019-08-06T17:17:19 Add explicit integer casts WebKit uses the -Wshorten-64-to-32 flag which warns on these cases. Bug: 3439 Change-Id: I8c1de60da0f173ca2036e2120e79b857f5f2775f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1740866 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Jamie Madill fb5c581d 2019-07-19T14:48:53 Functional revert of "Signal different dirty bit for vertex buffer change." Seems to be causing rendering regressions in the Google Maps benchmark. Likely causing other serious regressions. Original CL: https://chromium-review.googlesource.com/c/angle/angle/+/1684294 Bug: angleproject:3256 Change-Id: I41608a3ce3c3267097b4c1c0a6f7450cf8a2f48f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1709756 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
James Dong a9ec8749 2019-07-11T11:31:47 Vulkan: override format for mismatched attribs Prevents Vulkan validation error by replacing the input format for any mismatched vertex attributes with a format compatible to what the shader expects. Bug: angleproject:3436 Change-Id: Ia52f29c084d82bbc4e9149102cd4b5fc25ccb9b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1698567 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 375ddfc5 2019-07-12T11:12:14 Signal different dirty bit for vertex buffer change. We use new logic to compare if the attribute format changes before setting dirty bits. This improves performance of VBO-only state changes significantly. On the VBO change Vulkan microbenchmark gives about a 30% improvement. Bug: angleproject:3256 Change-Id: Ifaf1c92ed7a09422156ef79b5983e7349de63346 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1684294 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill ee21a187 2019-07-04T08:51:34 Store angle::Format in gl::VertexAttribute. Instead of storing type/size/normalized/pureInteger we instead store a pointer to the angle::Format. This makes some code logic simpler and will let us more easily check if a vertex attribute format changes in calls to VertexAttribPointer or VertexAttribFormat. This CL adds extra information to angle::Format to represent the vertex format info needed. It also caches the channel count so that it can be queried faster. Also renames "Int" -> "Sint" in UtilsVk for consistency. Bug: angleproject:3256 Change-Id: I5ef9b983dad8a58c341113c802500b89ce081566 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1684293 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Jamie Madill 124f78c2 2019-06-18T11:48:24 Remove gl::Context parameter from Observer functions. It was only used in exactly one instance in VertexArray. Instead we can cache a bool and avoid needing to pass it around. Will make signaling dirty easier in the Vulkan back-end. Bug: angleproject:3539 Change-Id: Ia570aec051a24a5280df49edc4345c54022b46ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1663838 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill e4faae21 2019-05-10T08:27:00 Rename state change notification messages. This makes the style use CamelCase instead of ALL_CAPS. It also cleans up some of the naming. It also changes some uses of the messages in some of the objects to hopefully be more consistent. See the comments added to the enum SubjectMessage in Observer.h for more details. Bug: angleproject:3427 Change-Id: I6dff4f6d335ecf1a27e48df65743b1490bd3025a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1600411 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill f7f15ac2 2019-03-27T12:56:51 Fix deleting a buffer not updating VAO validation. Deleting a buffer that is bound to a VAO should act as if the application unbound the buffer. Unbinding the buffer should update relevant validation caches. But we were missing the logic that updates the validation caches. This CL adds the necessary cache updates. It does not include a regression test. The test was causing an unrelated regression that is going to be a bit longer. It should not block this fix. Bug: chromium:943538 Change-Id: Ib073cd07a230ca073a5b14bc054e961158a0097d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1536491 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill cf9383ed 2019-01-31T19:52:49 Optimize VertexArray::bindVertexBufferImpl. Reduces the buffer nullptr checks to a single location. Also optimizes how the transform feedback binding counter is changed. Improves the score of the draw call vertex array change test. Bug: angleproject:3014 Change-Id: I08ff341e08194a407c24143965a3d568e92b97b7 Reviewed-on: https://chromium-review.googlesource.com/c/1406891 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill d51fbe34 2019-01-25T15:03:39 Fold buffer access validation into extensions. We only need to perform vertex array buffer validation if the WebGL compatiblity extension is enabled and robust access is not available. Although sometimes the range checks are useful for determining undefined behaviour they are not required by the OpenGL spec. They also slow down state updates significantly. This migrates the OOR tests into specific WebGL tests. It also requires a change to a Chromium test on the passthrough decoder. Improves perf by about 10% in the Vulkan VBO state change test. Also fixes some robust resource access cases for D3D11. Bug: angleproject:3000 Change-Id: Ice37f38f01c2f27bf32ed55657a30e69d8508335 Reviewed-on: https://chromium-review.googlesource.com/c/1390362 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 6e18a238 2019-01-16T13:27:14 Optimize more front-end VertexArray binding. Improves perf slightly (1-2%) in the Vulkan VBO state change test. Bug: angleproject:3014 Change-Id: Ia8082b5b3f5e847a6b2775e896893fa8d38c1afd Reviewed-on: https://chromium-review.googlesource.com/c/1393904 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill dd34b3b9 2019-01-16T09:59:54 Pack VertexAttribType enum. This improves performance slightly in vertex array format checks. Instead of needing to switch on GLenum values we can use packed arrays and tables to determine the values we need. Does not significantly affect performance but will enable future work. Bug: angleproject:3074 Change-Id: I6f4821a463e9b41fe3f8c8967eb3ed4c1d6b84be Reviewed-on: https://chromium-review.googlesource.com/c/1393903 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill c759b8b4 2019-01-03T15:16:50 Vulkan: More Vertex Array optimizations. Inlines a number of Vulkan vertex array methods. Also changes the way vertex buffers are bound. Note that Vulkan doesn't support NULL buffer bindings. Thus we create an emulated NULL buffer to work around the problem of having gaps in the bound vertex buffers. This allows us to use a single bind call for ranges of vertex buffers even when there are gaps. Also changes how vertex array dirty bits are reset. Instead of calling memset to clear the affected buffers we pass a mutable pointer to the Vertex Array sync state. This allows us to only reset the dirty bits that we sync. This saves on the memory clearing time. Improves perf by about 10% in the Vulkan VBO state change test. Bug: angleproject:3014 Change-Id: Ib7b742dff7897fc891606a652ea0b64255a24c86 Reviewed-on: https://chromium-review.googlesource.com/c/1390360 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill c3dc5d48 2018-12-30T12:12:04 Merge gl::Context and gl::ContextState. This reduces the number of indrections when accessing the Extensions or Caps structures. It will provide a small speed-up to some methods. It also cleans up the code. Bug: angleproject:2966 Change-Id: Idddac70758c42c1c2b75c885d0cacc8a5c458685 Reviewed-on: https://chromium-review.googlesource.com/c/1392391 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Markus Tavenrath <matavenrath@nvidia.com>
Jamie Madill 1e853266 2018-12-21T09:07:38 Cache common DrawElements states. Similar to how we cache the base common draw states. This will improve DrawElements performance. Several state checks are optimized into a single 'if' check of a cached value. Also includes a regression test for mapping the element array buffer. Bug: angleproject:2966 Change-Id: Ia6e524a58ad6b7df2e455d67733e15d324b1b893 Reviewed-on: https://chromium-review.googlesource.com/c/1357150 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 7c985f5c 2018-11-29T18:16:17 Make angle::Result an enum. This moves away from a class type to a value type. This should improve performance when using angle::Result as a return value. Previously the generated code would return a pointer instead of a value. Improves performance in the most targeted microbenchmark by 10%. In more realistic scanarios it will have a smaller improvement. Also simplifies the class implementation and usage. Includes some unrelated code generation changes. Bug: angleproject:2491 Change-Id: Ifcf86870bf1c00a2f73c39ea6e4f05ca705050aa Reviewed-on: https://chromium-review.googlesource.com/c/1356139 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill e90d4ee9 2018-11-28T14:04:00 Pass Context to setLabel. This is useful for triggering a dirty state notification for Textures. It will lead to improvements for program and texture dirty bits. Bug: angleproject:2966 Change-Id: Iaba625da8a970a558f7d158bfa2f09c964f6761a Reviewed-on: https://chromium-review.googlesource.com/c/1347669 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 8dc27f99 2018-11-29T11:45:44 Use packed enum for DrawElementsType. The packing and unpacking take a few extra instructions. But it completely obviates the need for any switches in the validation code. Speed is slightly faster or the similar depending on the back-end. Also add gl_angle_ext.xml to GL entry point generator inputs. This was missing and would cause the code generation to miss certain changes. Bug: angleproject:2985 Change-Id: I1ea41a71db71135000166ead8305ec42d22ff7b3 Reviewed-on: https://chromium-review.googlesource.com/c/1351729 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill c1fd7376 2018-10-26T22:48:39 Move index range calculations into VertexArray. This is in preparation for removing the entire DrawCallParams struct. This struct was big enough to cause a performance hit on draw call perf tests just by virtue of initializing the fields. Also dereferencing the struct members is slower than reading function parameters since it adds an indirection. Also includes some error refactoring to enable moving code to a shared location. In total this patch series reduces overhead by up to 5%. Bug: angleproject:2933 Change-Id: Ib663f2538c14ac30d4c31fd10d6350be469626e2 Reviewed-on: https://chromium-review.googlesource.com/c/1298380 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill cd0a0a3c 2018-10-18T18:41:57 Introduce SubjectBindingPointer. We can share the same pointer for the subject binding and the binding pointer. This further allows us to optimize buffer re-binding. The shared memory increases cache coherency and reduces the number of instructions needed. Bug: angleproject:2891 Change-Id: Id3162fa79de203f75989e7289ea02cb2ea1bec73 Reviewed-on: https://chromium-review.googlesource.com/c/1270217 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Jamie Madill 472ddc82 2018-10-18T18:41:56 Make gl::Buffer an angle::Subject. This will allow us to share the BindingPointer and ObserverBinding. It also cleans up the code a little bit. Bug: angleproject:2891 Change-Id: Ib8e2c34ccd379dc5b5648bac324fa4ff22a5a1a0 Reviewed-on: https://chromium-review.googlesource.com/c/1270216 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Jamie Madill ca8eda41 2018-10-18T18:41:56 Use dispatch table to optimize buffer binding. Using a table of function pointers is faster than using a switch followed by a function call. Also more aggressively inline binding methods. Based on contribution by mtavenrath@nvidia.com. In total this patch sequence improves the performance of a buffer binding perf test by up to 27%. Test: BindingsBenchmark.Run/gl_100_objects_allocated_at_initialization Bug: angleproject:2891 Change-Id: Iaab1e2a135b635bd72736d7d1d4271562c3a4ece Reviewed-on: https://chromium-review.googlesource.com/c/1281783 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Jamie Madill 6f755b21 2018-10-09T12:48:54 Use angle::Result in front-end. (Part 1) This covers most of the hot paths used in draw calls. Gives in the order of a 5% reduction in draw call overhead. Bug: angleproject:2491 Change-Id: I2d53afb1163eaceed61fb9cd9ce6c1267c85c0fa Reviewed-on: https://chromium-review.googlesource.com/c/1258149 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill d84b6737 2018-09-06T15:54:35 Cache ValidateDrawStates. This improves performance of all draw call validation. The error that should be generated on the draw call is cached in the Context. The cache is updated in several places. Bug: angleproject:2747 Change-Id: I178617623731608e2e7166b53ab6489d8b742ff5 Reviewed-on: https://chromium-review.googlesource.com/1158612 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 7b2f0274 2018-08-27T10:16:08 Inline more buffer binding calls. This splits checkObjectAllocation into the inline part and the slow part. It uses ANGLE_INLINE to force the former to be inlined. Also inlines and optimizes a few other buffer binding related checks. Improves performance in a bindings performance test by about 20%. Includes contributions from matavenrath@nvidia.com. Test: Bindings_gl_100_objects_allocated_at_initialization Bug: angleproject:2777 Change-Id: I71b07d72a8e81db7a90140ef84eca599a29239ed Reviewed-on: https://chromium-review.googlesource.com/1190442 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 337bd698 2018-08-22T16:16:38 Disable vertex attributes if not active in program Even if explicitly enabled. Bug: angleproject:2138 Change-Id: I598d21296bb6843e05cdeab146c1ff3da3a1174b Reviewed-on: https://chromium-review.googlesource.com/1185743 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill bf5177d3 2018-08-21T12:58:20 Optimize element array binding. This inlines some methods and code that was regressing binding performance. Improves the score of a bindings benchmark by 15%. Based on contributions by matavenrath@nvidia.com. Test: bindings_gl_100_objects_allocated_at_initialization Bug: angleproject:2777 Change-Id: Ied5fdbc67ced862a36c5145fff5ac94f93b40c21 Reviewed-on: https://chromium-review.googlesource.com/1181865 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill d69a5f12 2018-08-01T11:34:48 Cache VertexArray::hasMappedBuffer. This can be updated in several places. Also adds a test which covers some of the paths. Bug: angleproject:2746 Change-Id: Id119e527fd0064998d7ad5011a9d8376e7b9dab0 Reviewed-on: https://chromium-review.googlesource.com/1153569 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill cc73f241 2018-08-01T11:34:48 Micro-optimize some validation checks. Prepares for caching hasMappedBuffer. Also inclines several checks for faster speed. Bug: angleproject:2746 Change-Id: I74f9408d7b41e245c3f58d367dd2cc8fbace4a7a Reviewed-on: https://chromium-review.googlesource.com/1150762 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill a2d1d2db 2018-08-01T11:34:46 Context: Cache VAO element limits. Cache the minimum value for non instanced and instanced active attributes. The cache is updated in the following places: 1. Context: bindVertexArray. 2. Context: any executable change (linkProgram/useProgram/programBinary). 3. Vertex Array: any state change call. 4. Buffer: a dependent buffer resize. This greatly reduces the time we're spending in ValidateDrawAttribs. Bug: angleproject:1391 Change-Id: I84bb222a1b9736e6165fe40e972cd4299ca1178d Reviewed-on: https://chromium-review.googlesource.com/1150516 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill a11819de 2018-07-30T10:26:01 Context: Use Observer pattern for container objects. Container objects in this case are the Vertex Array and Read and Draw Framebuffers. Instead of using a mutable dirty bit state with a const function to notify of dirty bits we can use the Observer/Subject pattern. This more cleanly allows us to do cache updates. Bug: angleproject:1391 Change-Id: I88f863894ec3efa00322038f323a84850166107d Reviewed-on: https://chromium-review.googlesource.com/1153399 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Frank Henigman <fjhenigman@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill bdc610ae 2018-07-30T10:26:00 VertexArray: Cache element limit for buffer checks. Uses checked math in VertexAttribute updates to store an element limit. This computes more when changing the vertex array rather than at draw call time. There may be a performance regression for workflows such as: loop() { VertexAttribPointer DrawArrays } It should improve performance in most other cases. Bug: angleproject:1391 Change-Id: I210d666d9dae9164a1c65f70f5e2151fb4f2d86d Reviewed-on: https://chromium-review.googlesource.com/1150514 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill ad63728b 2018-07-31T11:22:14 VertexArray: Store bound attributes mask in binding. Making the bound attributes mask part of the struct keeps the style a bit more consistent. It will also make updating the cache variable a bit easier. Bug: angleproject:1391 Change-Id: I2b0ba1161d2579d95ddfbae7a05e490c9644a126 Reviewed-on: https://chromium-review.googlesource.com/1150513 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill ac43aaa2 2018-07-31T11:22:13 Refactor client check from ValidateDrawAttribs. This moves out some shared logic into a more accessible place. We don't need to validate buffer overflows when using robust resource access but we do need to validate we are using client side data correctly. Bug: angleproject:1391 Change-Id: I7a3dca8409c5a1faf1ff7bc732d5ed1bd62eb3b1 Reviewed-on: https://chromium-review.googlesource.com/1148817 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill dc358af7 2018-07-31T11:22:13 Context: Cache attributes masks. This cache is updated in the following locations: 1. GLES1: clientActiveTexture. 2. GLES1: disableClientState/enableClientState. 3. Context: linkProgram/useProgram/programBinary. 4. Context: bindVertexArray. 5. Vertex Array: most state changes. Improves performance by about 6% in the GL no-op test. Also includes fixes for keeping the client memory attribs mask in sync. The cache also includes a boolean if there are any enabled client attributes. Bug: angleproject:1391 Change-Id: I93b6a2c8492355958fd5483f14b70535729091d6 Reviewed-on: https://chromium-review.googlesource.com/1147437 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jiawei Shao 6a5d98c4 2018-05-04T15:42:20 ES31: Implement Vertex Attrib Binding on D3D11 This patch implements Vertex Attrib Binding on D3D11 and enables all the test cases related to Vertex Attrib Binding on D3D11 back-ends. On D3D11 back-ends the information in both GL vertex attributes and bindings should be updated together. When a binding is dirty, we need to find out and update all the attributes that are using this binding. To speed up this process, this patch adds a map from each binding to all the attrib indexes that are using this binding. This map may be updated when VertexAttribBinding is implicitly or explicitly called. With this map we can easily get all the attributes that should be updated with the current dirty binding. This patch also removes some unused variables in VertexArray11.cpp. BUG=angleproject:2700 TEST=dEQP-GLES31.functional.vertex_attribute_binding.* angle_end2end_tests Change-Id: I9a28ec357fd3aba835812cecc410cfa4e3734f0c Reviewed-on: https://chromium-review.googlesource.com/1048980 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
James Darpinian 09303e44 2018-06-22T17:53:57 Treat transform feedback generic binding point specially The transform feedback generic binding point is not part of the transform feedback object and is not used for transform feedback. Only the indexed binding points are used. A buffer that is bound to the generic binding point should be usable for either transform feedback or non-transform-feedback purposes. Bug: 853978 Change-Id: I5b730212c65524188134ac34645328328664f0a4 Reviewed-on: https://chromium-review.googlesource.com/1112841 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 7267aa65 2018-04-17T15:28:21 Optimize ValidateDrawAttribs: Part 3. This is a small optimization for the WebGL compatibility mode. Instead of scanning the list of attributes for a Transform feedback conflict, it can quickly check a cached mask. This should save a lot of cycles on the fast path. Bug: angleproject:1391 Change-Id: Icb8d095493a629dbff0e93872357e5bf7c7458ae Reviewed-on: https://chromium-review.googlesource.com/1011236 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>