src/libANGLE/renderer/vulkan/BufferVk.cpp


Log

Author Commit Date CI Message
Charlie Lao 6c894e82 2021-11-04T14:49:41 Vulkan: Replace BufferVk::getBufferAndOffset() with getBuffer() Now BufferHelper class already keeps offset information. There is no reason for BufferVk to have that information any more. Bug: b/205337962 Change-Id: I6e014fb480bfcd5018ef9231b0fb87a50021f179 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3266147 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 83a670ab 2021-10-29T09:12:26 Vulkan: Implement BufferPool using VMA's virtual allocator VMA's allocation calls used to be sub-allocating a pool of memory. What we really want is sub-allocate a VkBuffer object. VMA recently added support to expose the underlying range allocation algorithm via APIs, which user can use it to sub-allocate any object. This CL uses that new virtual allocation API to sub-allocate from a pool of VkBuffers. In this CL we only switched BufferVk::mBuffer to sub-allocate from the BufferPool object. Bug: b/205337962 Change-Id: Ia6ef00c22e58687e375b31bc12ac515fd89f3488 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3266146 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@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>
Hailin Zhang 7b13a9ac 2021-12-09T18:37:59 Vulkan: Fix dynamic partial update buffer data issue. add test case for dynamic update buffer data. Signed-off-by: Hailin Zhang<hailinzhang@google.com> Bug: b/207714894 Change-Id: I8c1e93d152847c3162c0e2dd49abe3d899c859a0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3328869 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Hailin Zhang <hailinzhang@google.com>
Hailin Zhang 3be551d7 2021-12-08T16:44:56 fix directUpdate buffer pointer issue. inside mapWithOffset already add the mBufferOffset Signed-off-by: Hailin Zhang<hailinzhang@google.com> Bug: b/207714894 Change-Id: Ia400bccbef1abc756cd8155e93a775338a30e8b9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3325025 Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Hailin Zhang <hailinzhang@google.com>
Lingfeng Yang 27bc56c6 2021-11-15T18:18:53 Vulkan: MAP_UNSYNCHRONIZED_BIT: Skip ghosting/idling Respect the following spec language: No GL error is generated if pending operations which source or modify the buffer overlap the mapped region, but the result of such previous and any subsequent operations is undefined Test: cpu time improves in unsync case in perf-tests/MapBufferRange.cpp Bug: angleproject:6680 Change-Id: I6133952546735aced6e6ee8468ef2ac695316fb6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3272018 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Lingfeng Yang 647a703e 2021-11-12T13:48:06 Vulkan: Reorder logic in BufferVk::mapRange This CL flattens the logic, ordering read case first, then write, and simpler cases before more complex ones. This is to prepare for an optimization where we ignore certain paths if MAP_UNSYNCHRONIZED_BIT is set. No change in functionality or performance is expected. Bug: angleproject:6680 Change-Id: I0a2e9ee969216c90353eac7af6dabf648dea2173 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3279615 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi dbc0c646 2021-11-06T01:09:26 Vulkan: Output the reason for RP closure in command buffer To make it easier when viewing the command buffer in a graphics debugger, this change inserts a marker just before closing the render pass that specifies why the render pass was closed. Bug: angleproject:2472 Change-Id: I862e500cd58332d6e199c853315c560fe6a73dc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3265609 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Lingfeng Yang cd822868 2021-10-28T13:00:09 Vulkan: MAP_INVALIDATE_RANGE_BIT: shadow or exclude One method of dealing with glMapBufferRange + range invalidation; treat it like bufferSubData and stage the update. Another method is to ghost the buffer but copy only memory outside the invalidated range. This CL pursues a policy where if less than half of the buffer is invalidated, we stage. Otherwise, we ghost and copy only memory outside the invalidated range. DynamicBuffer is chosen over DynamicShadowBuffer because it turns out to end up implicitly tracking all active invalidate ranges (through its freelist), and performs buffer copy on GPU. if we use a DynamicShadowBuffer and then BufferVk::stagedUpdate, it's the same thing but more work (an extra memcpy into the staging buffer). To make this clear, we split the logic of stagedUpdate into two parts, the allocation/map, and the flush, and reuse one half in glMapBufferRange, and the other half in glUnmapBuffer. Test: Faster performance in MapBufferRange perf test, no non-noisy regress in trace tests Bug: angleproject:6634 Change-Id: Ie2e6a9586824b8cb59a97419bb8052acd1de2033 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3251686 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Lingfeng Yang <lfy@google.com>
Charlie Lao bae19e06 2021-10-26T13:35:57 Vulkan: Avoid unnecessary wait if mapBufferRange indicates read only When we call BufferVk::mapRangeImpl(), both from internal code paths for data reads or due to glMapBufferRange call, we are not passing the access bit to the call. This CL passes the proper access bits to the call and only wait for GPU writes to finish if access is for read only. This CL also adds access bitfield to the BufferVk::mapImpl() API and have various callers pass in the proper access bits as well. Bug: b/203582620 Change-Id: Ica8493c902dbd7b15996266c81ce0fd4dbfc2520 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3245487 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 6b315a78 2021-10-26T19:04:06 Revert "Vulkan: Let BufferVk call into VMA for allocation when possible" This reverts commit 894ce75fb2f75e718ce76e466b8938524f65ac07. Reason for revert: crbug.com/1253325 Original change's description: > Vulkan: Let BufferVk call into VMA for allocation when possible > > Previously BufferVk class maintains a DynamicBuffer pool per BufferVk > object. This CL makes BufferVk skip DynamicBuffer pool in most cases and > do its own BufferHelper allocation directly. DynamicBuffer pool is only > used when desired, which is controled by a flag. With this CL, only > UBO/SSBO/AtomicBuffer will still use DynamicBuffer pool if the buffer > has to be allocated more than once. > > Bug: b/195588159 > Change-Id: I3aa08cef10ee9ee9f01f16403c6fbb99b37f4a8a > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2901241 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Tim Van Patten <timvp@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> Bug: b/195588159 Change-Id: Iecda3baa6bc887fa0caa86ab076994cae7c10f93 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244257 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Charlie Lao 894ce75f 2021-05-21T10:59:14 Vulkan: Let BufferVk call into VMA for allocation when possible Previously BufferVk class maintains a DynamicBuffer pool per BufferVk object. This CL makes BufferVk skip DynamicBuffer pool in most cases and do its own BufferHelper allocation directly. DynamicBuffer pool is only used when desired, which is controled by a flag. With this CL, only UBO/SSBO/AtomicBuffer will still use DynamicBuffer pool if the buffer has to be allocated more than once. Bug: b/195588159 Change-Id: I3aa08cef10ee9ee9f01f16403c6fbb99b37f4a8a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2901241 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 123ba58d 2021-10-14T11:56:35 Vulkan: Remove "last submitted serial". This fixes race conditions with the async command processor. Instead of querying specific serial numbers, we ask the command queue to either wait for idle, or return the answer to "are you busy" directly. Bug: b/172704839 Change-Id: I06a8268d9b58d8c33b783af00ca74979ee158316 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223641 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao ea580484 2021-10-05T13:40:01 Vulkan: Add feature flag to prefer CPU copy instead of staged update For ARM GPU, use GPU to do buffer to buffer copy has performance penalty due to potential bubble in the vertex pipeline. This CL adds a feature flag preferCPUForBufferDataSubData so that we can enable this behavior for ARM GPUs. This CL also tracks if GPU has referenced this BufferVk's storage since it got new storage. Due to sub-allocation, we may get a new sub-range of the same BufferHelper object when allocating new storage. But we currently do not have a way to track GPU progress of the sub-range of a buffer. So we will end up using BufferHelper's queueSerial to decide if it is still GPU busy or not. This CL adds mHasBeenReferencedByGPU boolean variable that will set to false when we got a new allocation and set to true as soon as buffer is been referenced by any GPU command. We use this to avoid checking queueSerial if it never been referenced by GPU. This is a temporary workaround for the bug, the full fix is tracked by https://issuetracker.google.com/201826021 Bug: b/200067929 Change-Id: I231fb0a678b0165a2ce1775d0aa4dbe7512fb4a8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3183398 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao 74b2886f 2021-09-22T13:49:57 Vulkan: Try to use CPU to copy when preserving old buffer data When glBufferSubData is called, we may acquire a new buffer if buffer is still GPU busy. When this happened, we have to preserve buffer content if old buffer has valid data in it. Instead of always use GPU to do copy, this CL will check if GPU is not writing to the buffer, we will just use CPU to do the copy form old buffer to new buffer from the ranges outside subData, controlled by the feature flag preferCPUWhenPreservingBufferData. Bug: b/200067929 Change-Id: I42053104b2be8da5f399cca92e934254988f2fd8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3177322 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao e437c4ad 2021-09-22T09:15:19 Vulkan: Only preserve buffer data when BufferVk has valid data When we receive glBufferSubData call and GPU is still accessing the buffer, we have two code paths to update data. If subData is more than half of the entire buffer range, we choose to acquire a new buffer and use DMA to copy the rest of buffer that outside of subData range from the old buffer back to the new buffer so that existing buffer data is being preserved. Otherwise we stage subData to use GPU buffer to buffer copy later on when buffer is been used. The reasoning behind is to minimize the amount of data copy. The improvement here is that if previously app called glBufferData with null pointer, we really do not have any valid data in the buffer and there is no need to preserve the existing buffer data. This CL tracks whether buffer has any valid data or not and also put this into consideration when we pick which code path to go. We also use this information to avoid preserve the existing data in BufferVk::acquireAndUpdate Bug: b/200067929 Change-Id: I266dd93bed2d3c07e3a5af3e4e613e7f6023b393 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3176500 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@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 cebca7c2 2021-09-24T07:55:38 Texture: Ignore buffer contents changed events. Texture doesn't need to care when its attached buffer gets different contents via a SubData call. This CL updates the BufferVk logic to ensure that SubData calls trigger a storage changed notification when there's a new storage, and otherwise Texture can ignore SubData calls. Will make it easier to split "contents" changed notifications to their own event, for optimizing Vertex Buffer updates. Bug: angleproject:6371 Change-Id: I4f15ad3ad2da5d838bd51fb065184b7344b188d8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3181562 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Tim Van Patten a1b829dd 2021-09-22T18:29:08 Vulkan: Retain src buffer in acquireAndUpdate() It's possible for acquireBufferHelper() to garbage collect the original (src) buffer before copyFromBuffer() has a chance to retain it, so it must be retained before then. Previously, we were relying on the retain calls in copyFromBuffer() to be sufficient. However, there is a race condition when the asynchronous CommandProcessor is enabled, since the garbage could be freed before copyFromBuffer() has a chance to retain the buffer (and allow destroyIfComplete() to skip destroying the object). For the full context, see the comment chain here: https://chromium-review.googlesource.com/c/angle/angle/+/3146319/16..24/src/libANGLE/renderer/vulkan/BufferVk.cpp#b833 Bug: angleproject:5971 Change-Id: I7c812069343fdad948189d696bfebab8da68c1a3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3179866 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
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>
Tim Van Patten 57d59e83 2021-09-07T17:41:11 Vulkan: Add ResourceWrite to track Read and Write Access vk::Resource currently only tracks accesses in general, not which type of access is being performed. This CL adds the new class ResourceWrite to track whether the access is a Read or Read/Write access and when the access completes. This allows a follow-on CL to know when a buffer is being written to by the GPU or if the GPU is only reading from a buffer. Tracking write accesses to buffers is required when attempting to "Ghost" (duplicate) GPU-read-only buffers to prevent breaking the render pass when the CPU maps the buffer memory. Bug: angleproject:5971 Test: ComputeShaderTest.ImageBufferMapWrite Change-Id: I965e3e75730719ccce77334744ae4feae33c6101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3146319 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi eaa6961d 2021-05-17T18:56:53 Revert "Vulkan: Disable BufferVk suballocation" This reverts commit 76181384075c6eb0a5788bf1b732a1e05f6d73bc. Reason for revert: Bug exposed by this is fixed in https://chromium-review.googlesource.com/c/angle/angle/+/2896168 Original change's description: > Vulkan: Disable BufferVk suballocation > > There are still unresolved bugs. > > Bug: angleproject:5719 > Bug: chromium:1209197 > Change-Id: I6a971c421d0ae266404d1ecbf8741a9747a4e809 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897545 > Reviewed-by: Cody Northrop <cnorthrop@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Tim Van Patten <timvp@google.com> Bug: angleproject:5719 Bug: chromium:1209197 Change-Id: I5c24b5f6476eab98ed5a7b90b3d1796ffc7ca106 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2896169 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 8bd3d7d5 2021-05-17T13:45:33 Vulkan: Fix a bug releasing DynamicBuffer-owned buffer There was one instance of BufferVk releasing a buffer it had allocated from a DynamicBuffer. This shouldn't have happened as the DynamicBuffer owns the buffers. Bug: angleproject:5720 Change-Id: I435512f4bb099130126bf3efb48a238fcd9f3ddb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2896168 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 76181384 2021-05-14T15:31:24 Vulkan: Disable BufferVk suballocation There are still unresolved bugs. Bug: angleproject:5719 Bug: chromium:1209197 Change-Id: I6a971c421d0ae266404d1ecbf8741a9747a4e809 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897545 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi e354ff1a 2021-03-05T04:07:21 Vulkan: Allow DynamicBuffer suballocation in BufferVk When allocations are made from DynamicBuffer, they suballocate from a possibly larger BufferHelper. In BufferVk, the offset of the suballocation was discarded, which limited the use of DynamicBuffer to a pool of small buffers. This change applies any such offset that may arise from suballocations everywhere, and makes BufferVk use a larger buffer size when the GL_DYNAMIC_* buffer usage hints are provided. Bug: angleproject:5719 Change-Id: I3df3317f7acff1b1b06a5e3e2bb707616a7d0512 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2738650 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 2d5df9d9 2021-05-01T12:50:55 Vulkan: Don't assume host visibility for external buffers When importing external buffers, Vulkan ICDs could choose to import the memory into a memoryType that doesn't support the VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT property. Account for this possibility. Bug: angleproject:5073 Bug: angleproject:5909 Change-Id: Ied063b38fa48d0c8508c4aaca9214cc526f393ad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2783669 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya cc3e7b5d 2021-04-26T14:26:29 Vulkan: Handle GL_MAP_PERSISTENT_BIT_EXT for external buffer When user specifies GL_MAP_PERSISTENT_BIT_EXT bit for an external buffer but we are unable to import it into a memoryType that supports host visibility, error out with GL_INVALID_OPERATION error. Bug: angleproject:5073 Bug: angleproject:5909 Change-Id: I03e5477266dfb705bfb0a1bce5ca003049ef4c7a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2862560 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya fc0c8d18 2021-04-27T16:58:50 Vulkan: Honor mapRangeImpl and unmapImpl abstraction All BufferVk methods need to honor the abstraction provided by mapRangeImpl and unmapImpl. Do not map BufferVk::mBuffer directly, this is needed for when we support device local buffers that cannot be CPU mapped. Bug: angleproject:5909 Change-Id: I520e5cc0994560a3784b8978e349550211dc2cde Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2862559 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Mohan Maiya 7fe44a53 2021-03-20T09:39:09 Vulkan: Don't acquire new BufferHelper for external buffers EXT_external_buffer spec - This extension allows the data store for an immutable buffer to be sourced from an external EGLClientBuffer, allowing sharing of EGL client buffers across APIs, across processes, and across different processing cores such as the GPU, CPU, and DSP. The intent is for a single backing memory to be reused across various processes and processors. Ensure that a glBuffer backed by external memory does not orphan the memory when glBuffer APIs like glBufferSubData or glMapBufferRangeEXT modify the glBuffer. Bug: angleproject:4380 Bug: angleproject:5073 Tests: ExternalBufferTestES31.*DoesNotCauseOrphaning*Vulkan Change-Id: I4e88f80d93ee1ba1208378121412926351d10af8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2776192 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 331640e5 2021-03-09T14:36:19 Vulkan: Pass in the correct size to acquireBufferHelper When BufferVk::acquireAndUpdate calls into acquireBufferHelper to allocate a new buffer helper we were passing in the update size instead of the full buffer size. Modified acquireAndUpdate's parameter to better reflect intent. Bug: angleproject:5689 Change-Id: Ic4fbc015651491ec028d747da5d45670264b93fa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2746066 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Mohan Maiya c054008f 2021-03-06T13:33:11 Vulkan: Check buffer usage before unmapping Buffers with dynamic usage will have frequent CPU updates. Don't CPU unmap such buffers after every update. Commits b5af8bde13 and 58c35d421 took care of performing an unmap when we release the buffer either to the renderer or mBufferFreeList. Bug: angleproject:5689 Change-Id: Ib6b8f6a7d0cb36583140e67bf164e074af098b8b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2741688 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi e366e2c3 2021-02-27T01:00:02 Vulkan: Keep dynamic buffer's free list trimmed ContextVk's staging buffer never gets a chance to free its free buffer list. During application load time, a large amount of memory may be allocated from this buffer to stage texture updates and they would remain throughout the life of the application. This change ensures that the free buffer list doesn't grow unbounded. In the Manhattan trace, this saves >1GB of memory on Linux. There are now three policies for vk::DynamicBuffer: - Always reuse buffers: This is useful for dynamic buffers that make frequent small allocations, such as default uniforms, driver uniforms, default vertex attributes and UBO updates. - Never reuse buffers: This is for situations where the buffer is unlikely to be used after some initial usage, such as texture data upload or vertex format emulation (as the conversion result is cached, so it's never redone). - Limited reuse of buffers: For the staging buffer in the context which is shared by all immutable texture data uploads, it's useful to keep a limited number of buffers (1 in this change) to support future texture streaming while allowing a large number of buffers allocated in a burst to be discarded. Bug: angleproject:5690 Change-Id: Ic39ce61e6beb3165dbce4b668e1d3984a2b35986 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2725499 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi d7037aa2 2021-02-11T14:35:30 Vulkan: noop glMemoryBarrier(CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT) CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT requires a memory barrier: shader buffer write -> host read. According to the spec, the data is only available after a call to glFinish or wait on sync: > The application must call MemoryBarrier with the > CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT set and then call FenceSync with > SYNC_GPU_COMMANDS_COMPLETE (or Finish). Then the CPU will see the > writes after the sync is complete. When a buffer is written to by the GPU, ANGLE calls onHostVisibleBufferWrite(), which ensures a "memory write -> host read" barrier is issued at the end of the command buffer. Additionally, persistently mapped buffers use VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, so there's no need for a call to vkInvalidateMappedMemoryRanges. As a result, there's nothing necessary in ANGLE to do for this barrier bit. Note that should persistenly mapped buffers start using non-coherent memory, this barrier should imply a call to vkInvalidateMappedMemoryRanges for the persistently mapped buffers. Bug: angleproject:5070 Change-Id: Iaeae019dadfa659a47d2dac41c0c09f1c15e584b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2689380 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao 0c5a55a5 2020-12-17T14:52:59 Vulkan: MapBufferRange should avoid wait if INVALIDATE_BUFFER is set If glMapBufferRange is called with GL_MAP_INVALIDATE_BUFFER_BIT bit set, caller indicates that it don't care about the previous content. If the buffer is busy, instead of wait for GPU to finish and then map the buffer, we should just allocate a new memory and return it. brawl_stars is hitting this case. With this CL, the frame time is cutting to half on the pixel device. Bug: b/175905404 Change-Id: If1220f07ebf53dd28fe6a4732eaba84e2e57598e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2597784 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 2ffff6d0 2020-11-12T10:56:06 Vulkan: Support image buffers This change does not support reinterpreted formats yet. Additionally, despite lack of support for RGB32 formats, EXT_texture_buffer is exposed by this extension. Those formats don't support the STORAGE_TEXEL_BUFFER feature on any known hardware. Bug: angleproject:3573 Change-Id: I85f45eb23f6a0aa533488bb98d9f226d59af4d76 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2534395 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya f197ebac 2020-11-16T15:16:56 Vulkan: Add EXT_external_buffer support Addition of buffer support for external memory Also adds new end2end tests for these usecases * SubData update * map/unmap buffer * dispatch compute with external buffer Bug: angleproject:5073 Test: ExternalBufferTestES31.*Vulkan Change-Id: Ib3cccaca77b76830effe49d3731782552e7424ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2525105 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 9e7f08fc 2020-11-06T16:55:51 Vulkan: Fix incorrect reordering of barriers Take the following situation, a simple copy from image to buffer: ANGLE_TRY(contextVk->onBufferTransferWrite(buffer)); ANGLE_TRY(contextVk->onImageTransferRead(aspectFlags, image)); CommandBuffer &commandBuffer = contextVk->getOutsideRenderPassCommandBuffer(); commandBuffer.copyImageToBuffer(imageHandle, layout, bufferHandle, 1, regions); Both `onBufferTransferWrite` and `onImageTransferRead` may flush either the outsideRP or insideRP command buffers. If buffer is not previously used, but image is used: - onBufferTransferWrite: buffer usage is recorded in outsideRP1 - onImageTransferREad: outsiderRP1 is flushed, outsideRP2 is started - copyImageToBuffer: recorded on outsideRP2, but buffer usage not recorded there - A following command that uses the buffer and requires barrier doesn't close outsideRP2 as it believes it was not used there Bug: angleproject:5319 Change-Id: Ib8994083fbc21969a538cda3784adee57b089415 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2523388 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Mohan Maiya a2d8bbb5 2020-09-18T18:18:34 Vulkan: Add GL_EXT_buffer_storage extension support Addition of support for immutable storage to buffer objects. Also adds new end2end tests for these usecases * Basic BufferStorage * SubData update * map/unmap buffer Bug: angleproject:5056 Tests: angle_end2end_tests --gtest_filter=BufferStorageTestES3*Vulkan Change-Id: Iba74b372ad033711927b63c6a04cec0eeb4db699 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2419952 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Jamie Madill 68a5baeb 2020-09-23T22:13:03 Revert "Vulkan: Implement a SharedResourceUse pool" This reverts commit de335c16855f11d1f0a6f0b37bee30c8a09a6c1d. Reason for revert: Might actually regress CPU overhead perf. Unsure but it's possible the reported perf improvement was due to variance. Original change's description: > Vulkan: Implement a SharedResourceUse pool > > When adding a Resource to the ResourceUseList of ContextVk > we constructed a new SharedResourceUse object for tracking > and update of the Resource's Serial. We would then delete > it after releasing the resource. This incurs repeated > memory operation costs. > > Instead we now allocate a pool of SharedResourceUse objects > and acquire and release from this pool as needed. > > VTune profile of the Manhattan 30 offscreen benchmark > shows the CPU occupancy of bufferRead decrease from an > average of 0.9% -> 0.6% and imageRead decreases from > an average of 0.4% -> 0.3%. The bottleneck for both > these methods is the retain() method that leverages > the new SharedResourceUse pool. > > Bug: angleproject:4950 > Change-Id: Ib4f67c6f101d4b2de118014546e6cc14ad108703 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396597 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> TBR=syoussefi@chromium.org,jmadill@chromium.org,m.maiya@samsung.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:4950 Change-Id: I40081551c3db67d6e55182fea40119946ed16ac3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2426479 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Mohan Maiya de335c16 2020-09-14T12:04:20 Vulkan: Implement a SharedResourceUse pool When adding a Resource to the ResourceUseList of ContextVk we constructed a new SharedResourceUse object for tracking and update of the Resource's Serial. We would then delete it after releasing the resource. This incurs repeated memory operation costs. Instead we now allocate a pool of SharedResourceUse objects and acquire and release from this pool as needed. VTune profile of the Manhattan 30 offscreen benchmark shows the CPU occupancy of bufferRead decrease from an average of 0.9% -> 0.6% and imageRead decreases from an average of 0.4% -> 0.3%. The bottleneck for both these methods is the retain() method that leverages the new SharedResourceUse pool. Bug: angleproject:4950 Change-Id: Ib4f67c6f101d4b2de118014546e6cc14ad108703 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396597 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi 295d2ccd 2020-08-24T14:46:31 Vulkan: Generate perf warnings on suboptimal paths Using KHR_debug features, this change creates a performance-warning-generation macro and employs it in a handful of locations to provide useful feedback to application developers. The warnings added in this change are not exhaustive. Bug: angleproject:3461 Bug: angleproject:4900 Change-Id: Id62435d170d90c5be9c1c5cab2d6779ccb58345e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2372628 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 027f0c38 2020-08-24T15:55:55 Vulkan: Remove Host->device availability barrier. vkQueueSubmit already performs this operation, so this barrier was unnecessary. The only place this is necessary is when the GPU is expected to receive updates from the CPU post-submit. ContextVk::synchronizeCpuGpuTime is the only such use-case in ANGLE. Bug: angleproject:4897 Change-Id: I7297fbd65d3faabd949dddb6bcaa181053a83193 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2372631 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 4909d08c 2020-08-19T12:21:44 Vulkan: Rename mStagingBufferStorage to mStagingBuffer Rename only to keep it consistency. Bug: b/164511310 Change-Id: I7b00c48010b76bff0b292e6e75b9aff154cdecc0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2364727 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill eb85c021 2020-08-05T15:07:15 Vulkan: Refactor Context CommandBuffer query. getOutsideRenderPassCommandBuffer returns the command buffer directly since it's now stateless and cannot throw an error. All the RenderPass begin/end and flushing are done by the dependency functions (buffer/ image read/write). Bug: angleproject:4911 Change-Id: I5e7806be9d0e1b5e358524bd485298d660fac942 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2339544 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill 23daea2f 2020-08-06T10:40:00 Vulkan: Rename CommandBuffer get method. This method will no longer end the RenderPass in a following CL. Renaming it in a split CL makes the review diff simple. Bug: angleproject:4911 Change-Id: Id48257884dccb7c86f7de2cc9ca95e651fb68df7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2340788 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill f9dd2c15 2020-08-02T18:03:16 Vulkan: Accumulate Buffer barriers. Uses an unordered_map in the CommandBufferHelper to track buffer reads and writes. Buffer barriers are tracked specially in the CommandBufferHelper class as a barrier we execute immediately when we execute the commands into the primary. So when we run into an incompatible buffer access we must start a new command buffer. The rules for an incompatible access are: - when we are reading a buffer, any prior write in the same command buffer is incompatible. - when we are writing a buffer, any prior read or write in the same command buffer is incopatible. Also adds a regression test using a new performance counter. Bug: angleproject:4429 Change-Id: I393a4ed87314f955eb998940b877ba76ea15a7b8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2334091 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Charlie Lao de309a42 2020-07-21T17:19:17 Vulkan: Make staging buffer per context Right now staging buffers are per BufferVk. This will make it per ContextVk so that it can be shared among all objects that needs a staging buffer. Bug: b/161846868 Change-Id: I9c436acdacaf429a43cbdfa216927df0796f7a28 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2310962 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Manh Nguyen dc9743fb 2020-07-14T11:33:29 Add buffer serialization capability Serializes buffers' states stored on CPU. Gets buffers contents on GPU by mapping buffers to CPU's address space, then copy their data. Unmap buffers after finish. Since this feature is for tests only, it is only implemented for the Vulkan backend. Adds buffer serialization to serializeContext method so that capture replay regresssion testing now compares the states of buffers too. Bug: angleproject:4817 Change-Id: Ic9b529701014d5ba8420023a021cd5ea381bd9a1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2295950 Commit-Queue: Manh Nguyen <nguyenmh@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 62ff54eb 2020-05-12T13:27:21 Vulkan: Featurize shadow buffers Shadow buffers help reduce the latency of glMap* operations at the cost of CPU overhead. It might not be desirable to incur such an overhead for all usecases. Featurize it but enable it by default. Bug: angleproject:4339 Change-Id: I6374618bf99677eef55fd50a139fb86f5ea70791 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2278102 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Tobin Ehlis b50541b2 2020-01-14T09:07:03 Vulkan:Adding key perf trace markers Adding trace markers in performance-critical functions. Primary areas of interest are command buffer processing and cleanup and memory mapping. Bug: b/156403378 Change-Id: Icba53024771711d79f7eee7085bf4dae0e033e63 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2002689 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Tobin Ehlis <tobine@google.com> Commit-Queue: Tobin Ehlis <tobine@google.com>
Mohan Maiya cf8422c2 2020-05-19T10:14:02 Vulkan: Acquire a new BufferHelper from the pool based on a threshold We acquire a new BufferHelper from the pool when the app updates the data of the entire buffer. In scenarios where the app updates say, 60% of the buffer it would still be benificial to acquire a new buffer and copy over the remaining 40% of data from the old buffer to the new one. This reduces the transfer workload from 60% to 40% of buffer size. Currently the threshold is set to 50% of buffer size. Bug: angleproject:4380 Change-Id: I12576c585230e771d4c1a4352fab93dd3db2ecef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2204655 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao 41f7bcce 2020-04-30T16:09:36 Vulkan: Add missing cache flush DynamicBuffer are not cache coherent, thus requires flush. Also adds a few assertion to ensure implementation matches expectation. Bug: b/155432713 Change-Id: Iaf28786168a3bb5d746b43e030f882c4b6d005ad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2174269 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao df31624e 2020-04-30T13:28:24 Vulkan: Reduce the onBufferRead/onBufferWrite API verbosity a bit This adds helper functions to handle common use case for onBufferRead and onBufferWrite to reduce the API verbosity a little bit. Also fix the transform feedback bug that we are passing in wrong access/stage flags when it is emulated by vertex shader. Bug: b/155122200 Change-Id: Id2549ca00cad184a90c6230dc3665aaff44dda08 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2174265 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao f07d0072 2020-04-27T16:51:05 Vulkan: use fine grain stage for buffer barriers We are using VK_PIPELINE_STAGE_ALL_COMMANDS_BIT for mGlobalMemoryBarrierStages, which is used for both src and dst. This will cause a full pipeline stall whenever a buffer object introduces a barrier. This CL will let the caller pass in the specific stage it will be used for, allowing us to track write and read stage dependencies separately and request the corresponding barriers. Bug: b/155122200 Change-Id: I8b8bd291a03b77d07cfbcbe7c3cda2d3771588b9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2169014 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Brandon Schade fa03eb9d 2020-02-05T15:25:52 Vulkan: Use DynamicBuffer for BufferVk When there is glBufferData API call, if the current VkBuffer is in use, we copy to a staging buffer to be gpu copied later. Instead of doing this second copy, write directly to a new buffer that will be used for subsequent gpu operations. BufferVk now has a DynamicBuffer to handle the logic of acquiring a new/free buffer to be used. Bug: angleproject:4380 Change-Id: I207f334013ae944090eb48c26c692a09e8815f74 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2040513 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Hyunchang Kim 6e0d718a 2020-03-31T18:41:57 Vulkan: Implement device memory sub-allocation Use AMD Vulkan Memory Allocator for device memory sub-allocation. We now have a mempool from which all glBuffer memory is allocated. The CPU overhead involved in repeated IOCTL calls to the kernel is reduced significantly. Bug: angleproject:2162 Change-Id: Id7681ffe2ac3d2853141ebe34c7df7b7fdd0d55e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2124519 Reviewed-by: Tobin Ehlis <tobine@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Mohan Maiya 745e0712 2020-03-21T17:46:05 Vulkan: Enable CPU only buffers for PBOs Add support for a CPU only buffer for PBOs that serve as the destination for all host operations like MapBuffer*. This removes the latency caused by waiting for the in-flight GPU commands to be complete before handing over the buffer to the app. This change removes a ~6ms wait/sleep on the first call to MapBuffer* in each frame of Manhattan Bug: angleproject:4339 Tests: angle_end2end_tests --gtest_filter=BufferDataTest*Vulkan Change-Id: I52016b160af8a670cc30f01c05e48f699521310f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2116874 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Tobin Ehlis <tobine@google.com>
Hyunchang Kim d30da072 2020-03-31T15:01:14 Vulkan: Request host uncached memory for some glBuffer objects Uncached memory is an optimal memory type for resources with write-only access from the CPU since it avoids polluting CPU caches with data the CPU will never use. Bug: angleproject:2162 Change-Id: I33d0d91830979990bcdcca3bd9eedde0345fb5a6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2131880 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 7daf31d8 2020-03-18T09:19:52 Vulkan: Use device local memory for conversion buffers that can be converted with the GPU When converting a vertex buffer by using GPU, the conversion buffer doesn't need to be host mappable. Hence the conversion buffer can be allocated on device local memory for faster GPU access times. Bug: angleproject:3534 Change-Id: I2efabec20186992479920bddd3abd36f9c13babc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2108706 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 78a85f2c 2020-03-16T10:28:59 Vulkan: Request device local memory for glBuffer with GL_STATIC* usage glBuffer objects with GL_STATIC_* usage patterns will now request the storage to be allocated in device local memory. For glBuffer objects with GL_DYNAMIC_* usage patterns we request a host cached memory. Bug: angleproject:4480 Change-Id: I7ca968f5ddfb59e4df3ecd07ae65df2bbf734190 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2102958 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill 916d204c 2020-02-25T14:18:38 Vulkan: Use new APIs in BufferHelper::copyFromBuffer. We shouldn't need to special case the barrier logic in this function any more. Instead use the 'onBufferRead' and 'onBufferWrite' APIs. Bug: angleproject:4029 Change-Id: I7f67b67aa312d9ae64172b40d73086b7772d49d2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2071143 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill aa09ca69 2020-02-24T13:33:30 Vulkan: Update ContextVk command buffer access methods. Use the following names: - flushAndBeginRenderPass - endRenderPassAndGetCommandBuffer - flushAndGetPrimaryCommandBuffer This clarifies that a flush is part of the method. Bug: angleproject:4029 Change-Id: I6c870761339ea7aa39c83142200781ba39ad6a4b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2068129 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill a741abb9 2020-02-21T16:37:37 Vulkan: Rename CommandGraphResource to Resource. Also renames the h and cpp files to ResourceVk (to keep distinct from other resource.h/cpp files) and renames 'onResourceAccess' to 'retain'. Cleans up a few remaining mentions of the command graph in comments. Bug: angleproject:4029 Change-Id: Ifc8e880c8cea3fc48a4aec4730191c88aa35a076 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2065920 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill c58458e6 2020-02-19T14:51:41 Vulkan: Remove CommandGraph code. Also updates relevant comments to no longer refer to a graph. Bug: angleproject:4029 Change-Id: Ic29716e9ae4926870f902947d49d8fee7af98662 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057804 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 20b1259a 2020-02-05T17:08:05 Vulkan: Command graph linearization (Step 2). ES 2.0 is feature complete. Passes all of the angle_end2end_tests with the new linear command recording method. Also runs the T-Rex benchmark without any obvious glitches. Likely has issues with creating too many RenderPasses. ES3 is mostly untouched. Bug: angleproject:4029 Change-Id: Ic5acf3d768495fbffd07b07bf0a6f2b5787c51f8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2012900 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 3712b2e4 2020-01-24T17:08:30 Vulkan: Command graph linearization (Step 1). This initial prototype introduces a new feature to the Vulkan back-end that disables the deferred command recording. The intent is to have a lower CPU overhead during submission calls which currently walk a DAG. The feature is not complete. Currently it only passes the ANGLE SimpleOperationTests. Moreover it is extremely simple and only allows use of one command buffer at a time. In the future we'll allow open command buffers for recording outside and inside render pass commands at the same time. We'll also support collapsing RenderPasses together for some use cases. Currently the prototype only passes "SimpleOperationTest". There are quite a few unimplemented features like queries, XFB, etc. Bug: angleproject:4029 Change-Id: I82760986683f55e37ac4ea559de6f4cffb6ef84e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1953485 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tobin Ehlis <tobine@google.com>
Jamie Madill 7d45184d 2020-01-22T08:34:48 Vulkan: Fix naming in CommandGraphResource. Accidentally submitted a patch set without requested changes. This corrects the function names to 'hasRecordedCommands' and 'hasRunningCommands'. Bug: angleproject:4029 Change-Id: I1cf3046052ace304594ef939566b0b36bae822df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2013924 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 579c5940 2020-01-17T13:20:21 Vulkan: Rename onGraphAccess to onResourceAccess. Clarifies the function for the upcoming command graph linearization. Bug: angleproject:4029 Change-Id: Ib50997c007053757de533f69c155a92d7555e0b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2003235 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 09a2d065 2020-01-17T13:20:20 Vulkan: Clean up naming of ResourceUse checks. Instead of referring to command graphs we can refer to if the resource is in use by "ANGLE" or the "Driver". This will make the methods more consistent when we switch away from the command graph. Bug: angleproject:4029 Change-Id: I3045a4eb2a38234ef331c0662694656065590ae1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2003234 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 441b72f0 2020-01-16T14:48:39 Vulkan: Make ContextVk own ResourceUseList. This moves the resource use tracking functionality out of CommandGraph. Making the list a separate class helps the implementation avoid tricky circular include problems. Bug: angleproject:4029 Change-Id: I3288fc685b21e949f12b0796109a2b7bb117c249 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2002931 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 4ff1651e 2020-01-16T12:42:27 Vulkan: Add ResourceUseList helper. This abstracts away the ResourceUse tracking from CommandGraph. Pulling it out will allow us to more easily swap resource use tracking into ContextVk. The command graph is eventually going away so we need to move functionality out of CommandGraph. Bug: angleproject:4029 Change-Id: Icc3bcc824510b03e91f8ff010a82751a81516bfa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2002930 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 01c0d6bd 2020-01-12T13:41:31 Vulkan: Use dynamic buffers for staged updates Dynamic buffers are used to perform staged updates to BufferVk objects instead of recreating staging buffers for each update. Bug: angleproject:4292 Change-Id: I0f64c821c97e0e6014e9df1d4f99e2f495838025 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2001461 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 5e33e647 2020-01-09T14:20:09 Vulkan: Optimize getIndexRange This function was unconditionally calling finishImpl(). This is changed to finishToSerial() to only wait until the serial that actually used the buffer. Bug: angleproject:3072 Change-Id: Ida89bb119b4ba6420f12404b911af0e3b4583a51 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1993407 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Hyunchang Kim caa6eccd 2019-10-27T13:46:56 Vulkan: Implement Transform Feedback support via extension Implemented transform feedback extension path. Where VK_EXT_transform_feedback is supported, extension path will be taken over an emulation path. Extension path has advantages in terms of performance. BUG=angleproject:3206 Test: dEQP-GLES3.functional.transform_feedback.* angle_end2end_tests --gtest_filter=TransformFeedbackTest* Change-Id: Ia07c23afb289d9c67073469a97b714ec96f5265a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1882767 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Shahbaz Youssefi 27c89d2b 2019-11-25T10:22:01 Vulkan: fix BufferVk::map() synchronization 4398b2b6a2ac13034dff249d8c049c4047b5fed2 made finishToSerial() in BufferVk::map() conditional to whether the serial is in use to work around a performance regression. Notes: - Prior to 087f1384f233792921d34c0ca5b5a90fac75b070, finishToSerial already did that, but that check was inadvertently removed. - finishToSerial waits for the smallest serial that's bigger than or equal to the requested serial. - The flush() call in BufferVk::map() was conditional to whether the serial is in use, but it really meant to check whether the buffer has pending commands in the graph. The end result is that there was an unnecessary flush in BufferVk::map() if we had to wait for a previous serial to finish. This change makes the flush conditional to whether the buffer has pending commands in the graph, and the finishToSerial call to whether the serial is not yet finished. Bug: angleproject:3994 Change-Id: Idca436ef2439bcc8c59396a07b2591c1dfadd669 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1932341 Reviewed-by: Brandon Schade <b.schade@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 61c6aecc 2019-11-28T14:30:18 Vulkan: Fold read access into write flags on buffer writes This could lead to a subtle bug: Say we use a buffer as a storage buffer and write to it. We then must issue a memory barrier before using it as a uniform buffer. However we would set the SHADER_READ bit as a read mask on a storage buffer access. This seems like it could lead to a missing barrier. Bug: angleproject:4178 Change-Id: I486002739b7fb000ffacc0a1e996784b7875e7ba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1943034 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Tim Van Patten 2ed547a6 2019-10-15T17:34:09 Vulkan: Mark destination buffers dirty after a copy When a user performs a copy between GL buffers, we need to mark the destination buffer dirty in case that buffer data is used as vertex data and requires another conversion to be done. Bug: angleproject:3544 Test: dEQP-GLES3.functional.buffer.copy.* Change-Id: Ie3196db4feb0f01d0b25c8799312c5f57c1095a2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1863007 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Brandon Schade 4398b2b6 2019-10-10T16:39:33 Vulkan: finishToSerial only if the buffer is in use The call to flushImpl() was conditioned on the buffer being used but the call to finishToSerial() was outside. This caused an unconditional wait and unnecessary pipeline stall. The fix is to make sure to perform a flush and wait only when the buffer is in use. Bug: angleproject:3994 Change-Id: I1b297cf11a67f7611d37808cb111d6b52ac16f90 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1854881 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill f10bf6bf 2019-09-26T10:27:18 Vulkan: Implement multi-threaded GL. The main component of this change is to make vk::BufferHelper, vk::ImageHelper and vk::SyncHelper use a common path. We introduce a new "vk::SharedGarbage" helper class that stores small lists of garbage from individual objects like an ImageHelper or BufferHelper. The SharedGarbage is stored in the RendererVk with the ResourceUse of the helper object. The ResourceUse tells RendererVk when it is safe to destroy the GarbageObjects. New "onGraphAccess" commands are added in a few places to enable the common garbage collection path. A couple Context-only resources like default attributes now are referenced where they were not before. Also reorganizes some functions so we can add a few helpful ASSERTs to our graph dependencies. Added "updateCurrentAccessNodes" for this. Also adds a "RendererScoped" helper to replace many uses of "ContextScoped". The multithreading EGL tests mostly pass but have some remaining flakiness so cannot yet be enabled. Bug: angleproject:2464 Change-Id: Ia3e3ae8848d731abf3f21ebe04c33e381e130be0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1808444 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 33ffed01 2019-09-26T10:19:35 Vulkan: Clean up garbage APIs. Instead of dumping resources to a context, we use the release APIs consistently. Refactoring/cleanup change only. Should have very litte impact on runtime behaviour. Bug: angleproject:2464 Change-Id: I2dc7f8316c466f7ccfad50a7b792ba0ee7bc2e49 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1804883 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill b540da89 2019-09-19T14:19:12 Vulkan: Use ResourceUse to track object lifetime. With the new resource tracking scheme the CommandGraph, tracking a "Context serial" aka "current" serial is no longer necessary for CommandGraphResources. Serial tracking has been moved to the shared ResourceUse struct that gets updated on a command submission. Thus we don't need to store the serial as a current separate piece of info in BufferHelper/ImageHelper. Will lead to further redesign for the multi-threading support for Vulkan. Bug: angleproject:2464 Change-Id: I1ae4bcc27fcfb93422b4ab4c9682a458e482f295 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785990 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill dd4a00a0 2019-09-19T14:19:11 Vulkan: Track resource usage via counter. This adds a small shared piece of memory that counts the number of times a resource is used in a command graph. This will enable more multi-threaded uses. The shared pointer is updated in the command graph during a submit and during graph construction. Bug: angleproject:2464 Change-Id: Id9d0319a6814825d02e865ba527c97b5f535ff31 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785989 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tobin Ehlis 1d83e1e8 2019-08-21T09:00:33 Vulkan: Handle new validation errors With updated validation layers Vulkan backend is hitting two new errors. This CL fixes one and works around (WA) another. Fixes issue where a Buffer used in vkCmdDispatchIndirect() did not have VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT set so now setting that usage bit for all buffers. WA issue where invalid topologies enabled primitiveRestart so ignoring that VUID initially until complete fix is implemented. Bug: angleproject:3832 Change-Id: Ie3f681eaf9e2051c27bdf00a35dc50d8ad4a2528 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1763196 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
Jiacheng Lu 3e493c48 2019-07-29T16:27:01 Vulkan: Optimize memory allocation offset rounding Use bit operation to compute memory alignment round up. Tested with T-Rex, hotspot in roundUp resolved. Bug: angleproject:3744 Change-Id: I55db941f588401a1d2d3d93f4d6b810e6b1aa95f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1725118 Commit-Queue: Jiacheng Lu <lujc@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
James Dong 020abb8b 2019-07-24T11:33:49 Vulkan: invalidate translation buffers for SSBOs Translation buffers weren't being marked dirty after running a compute shader in which they are bound as SSBOs. This change invalidates all SSBOs after a draw or compute call. Bug: angleproject:3739 Change-Id: I66b56df7e619b55afc7e3da6b5613b6d050e06bb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1717144 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: James Dong <dongja@google.com>
Shahbaz Youssefi f92fc916 2019-07-15T22:39:23 Vulkan: Compute shader support A DispatchHelper class is created as the equivalent of FramebufferHelper as a command graph resource. There's currently a single dispatcher and all dispatch calls are recorded on that. Context dirty bits are set up in such a way that graphics and compute workloads are independently handled, so that issuing a dispatch call wouldn't cause a framebuffer's render pass to rebind resources. Bug: angleproject:3562 Change-Id: Ib96db48297074d99b04324e44b067cfbfd43e333 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1688504 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 55efe37c 2019-07-03T11:52:21 Vulkan: Cleanup buffer dependencies onWrite now sets the dependency to make sure the order of setting dependency and adding memory barrier is correct. onReadByBuffer is added to handle buffer-to-buffer dependency and barrier setting correctly without causing a graph loop. onExternalWrite is added so that BufferVk doesn't have to track write access flags. Additionally, setting write dependencies now include both read and write flags. This is in preparation for SSBO support where the buffer can be used to read data in addition to write. Bug: angleproject:3561 Change-Id: I2028186ea14459cd159cf79f6d640df54538fc62 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1687119 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 7f2520f1 2019-06-26T11:18:33 Vulkan: Refactor DynamicBuffer::init. This will allow us to more easily create a white box test that sets a very small initial size for a dynamic buffer. Bug: angleproject:3082 Change-Id: Ic02bbee83ee8e0f4bfe182e9448c2ce60dea66d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1667645 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tobin Ehlis <tobine@google.com>
Shahbaz Youssefi 615ae1a7 2019-06-21T12:10:14 Vulkan: Improve copy buffer self-dependency The check in addReadDependency to avoid setting self-dependencies was causing the barrier set in `copySubData` to be potentially set earlier than the buffer's previous usage. This change allows buffer self-dependencies to be handled especially. Bug: angleproject:3194 Change-Id: I08f2c39f420f020ad5faa9735193e6b7142fa756 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1670952 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tim Van Patten 9420fa06 2019-06-07T17:09:22 Vulkan: Implement copyBufferSubData Implement BufferVk::copySubData(). Bug: angleproject:3194 Test: dEQP-GLES3.functional.buffer.copy.* Test: dEQP-GLES3.functional.negative_api.buffer.copy_buffer_sub_data Test: angle_end2end_tests BufferDataTestES3 Change-Id: I220cd490eb1eb799604e217b3e377af3fd431d97 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1648669 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 3ea463bf 2019-06-19T14:21:33 Move event tracer back into common. Requires that we update the TRACE_EVENT macros to accept a platform as an argument. The refactor isn't complete. In order to finish we'd need to ensure we have the Display's PlatformMethods available at all sites. Unblocks adding trace events directly in the perf tests. Bug: angleproject:1892 Bug: angleproject:3117 Change-Id: Iee0ca086ccfe23acab3fc186fb042f018711a94c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1664794 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b1c8dbf3 2019-06-14T23:57:26 Vulkan: Correct synchronization for buffer readback When mapping buffer memory, a flush is performed if the buffer has pending operations followed by a finishToSerial to make sure the buffer is no longer in use by the GPU. This also implements GLES 3.0 buffer mapping flags: GL_MAP_INVALIDATE_RANGE_BIT: No-op. Vulkan's vkMapMemory doesn't have such a feature. GL_MAP_INVALIDATE_BUFFER_BIT: Same GL_MAP_FLUSH_EXPLICIT_BIT: Vulkan automatically flushes host memory writes on vkQueueSubmit, so this is no-op as well. GL_MAP_UNSYNCHRONIZED_BIT: The flush+finishToSerial call is skipped in this case. Bug: angleproject:3213 Change-Id: I6bdb460dffbb57170649f4c9678afbfae331926c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1661252 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 44063c80 2019-06-04T15:20:30 Vulkan: Store array buffer conversions in BufferVk. The intent of this CL is to call convertVertexBuffer*PU only when we have new data to convert. If the app unbinds and rebinds a vertex buffer without changing the data we can now retrieve the cached vertex buffer info from the BufferVk class. Previously we would always reconvert the data on a rebind. This was slowing down applications and benchmarks. To achieve this we add a conversion cache to BufferVk. Each cache entry stores a key based on the vertex info. Also we store a ring buffer for each cache entry and a flag to indicate if the entry is dirty. The cache is dirtied on a bufffer data update or a map call. Improves performance in the T-Rex benchmark. Bug: angleproject:3495 Change-Id: Ia999c9187510748ba95bc98362eb332e1990d270 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1638903 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Shahbaz Youssefi d3e7a41b 2019-05-29T14:40:52 Vulkan: fix buffer copy barriers Bug: angleproject:3362 Change-Id: Ibf6520fb73bb1a9b76714cddd786569789c70430 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1635752 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang ee244c77 2019-05-06T10:30:18 Vulkan: Move command graph and garbage to ContextVk. To support multithreading, contexts should manage their own command graphs and garbage. This allows safe access to vulkan resources such as command pools without thread synchronization. BUG=angleproject:2464 Change-Id: I930149bc9f0793028761ee05ab50b8c0a4dec98a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1516515 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 216f73d0 2019-04-12T13:32:30 Vulkan: add uniform buffer object support Support for layout qualifiers in interface blocks are added. All interface blocks are adjusted to either be in std140 or std430. In the Vulkan backend, a new descriptor set is added for UBOs. A dirty bit is added for UBO updating and pipeline layouts and descriptor bindings are updated. Bug: angleproject:3199, angleproject:3220 Change-Id: I271fc34ac2e1e8b76dee75e54a7cff0fe15fe4ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1565061 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang 892d1805 2019-03-27T14:21:34 Vulkan: Have the WindowSurfaceVk own the submit semaphores. Chaining of submit semaphores is only needed for window surfaces because they are required for the first usage of the swap chain image and final present of the image. Move ownership of the submit semaphores from RendererVk to WindowSurfaceVk and update all calls to finish and flush to be piped through a ContextVk which tracks the currently bound window surface. BUG=angleproject:2464 Change-Id: I4b3083124d7910a5dee297afc219e3a3f28057f2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1542257 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 2660b503 2019-03-21T12:08:40 Vulkan: Restore CommandBuffer to namespace vk Moved vk::CommandBuffer and vk::SecondaryCommandBuffer to vk::priv:: and aliased vk::CommandBuffer to one or the other. This allows the rest of the classes to continue seeing vk::CommandBuffer as they used to do. Used a special alias for the primary command buffer that gets submitted (vk::PrimaryCommandBuffer). Bug: angleproject:3136 Change-Id: I61236fd182230991db7395d05e3da3be5e3f45be Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1534456 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tobin Ehlis 134425c7 2019-03-15T17:02:17 Vulkan:Integrate SecondaryCommandBuffers Integrate the custom SecondaryCommandBuffer type into the CommandGraph nodes by adding new ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS define that can be set in the BUILD gn args with angle_enable_custom_vulkan_cmd_buffers set to "true." Initially the custom cmd buffers are disabled by default. This adds some support functions to SecondaryCommandBuffer to make the integration easier by matching the wrapped cmd buffer interface: initialize(), end(), valid(). Bug: angleproject:3136 Change-Id: Ib910554583192550757bb8ce89914e3ea8737988 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1526556 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>