src/libANGLE/renderer/serial_utils.h


Log

Author Commit Date CI Message
Igor Nazarov 1904410a 2023-04-26T19:37:04 Vulkan: Add missing ASSERTs to QueueSerial relation operators Bug: b/255414841 Change-Id: I46203a6f51bd43818cc8c136b47ed4420e7dd184 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4481249 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Charlie Lao 3307e8d2 2023-02-16T10:26:20 Vulkan: Add ostream operator for ResourceUse/QueueSerial This is some debug logging code I have been using in the past. Want to land it for convenience. Bug: None Change-Id: Ife044dd7dc733d3d38283949bdfc11b203cbe429 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4177488 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao b96f3abd 2023-02-03T13:12:29 Vulkan: Make Context::mLastSubmittedSerial to QueueSerial Right now Context::mLastSubmittedSerial and mLastFlushedSerial are all Serial type instead of QueueSerial. Most places we do need QueueSerial. This CL changes them to QueueSerial type. This simplifies and improves code readability. No actual functional change is expected with this CL. Bug: b/267806287 Change-Id: Ib00cae2637ee9ed95e5fc00060c63017b04e26c5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4219944 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Kimmo Kinnunen ce8ce6f8 2023-01-31T13:06:47 Remove ASSERT from AtomicSerial, use static_assert ASSERT is not constexpr, while the AtomicSerial constructor was. This would cause compile errors. Bug: angleproject:7989 Change-Id: Ib6a438d4c055378d4f2f667285b0d2e99f2522ad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4205892 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao c4765732 2022-12-16T18:07:18 Revert "D3D: Remove ResourceSerial" This reverts commit 214742be91b89087dd26acbae09a070a91730ecc. Reason for revert: Regression https://bugs.chromium.org/p/chromium/issues/detail?id=1401503 Original change's description: > D3D: Remove ResourceSerial > > The only difference between ResourceSerial and UniqueueSerial (formerly > Serial) appears to be ResourceSerial is wrapper of object pointer. This > CL removes ResourceSerial class and switched it to UniqueSerial class > instead. (We may need to see why it needs to use pointer to initialize > the serial, that sounds like the exact thing serial try to avoid.) > > Bug: b/262047600 > Change-Id: Ic8e1b26d7da9304ff02fd9a7e1b584bb70efcb77 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4102107 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Charlie Lao <cclao@google.com> Bug: b/262047600 Change-Id: I757451a487839db17390dde18f1e2bc5eda36d37 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4114273 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao a703eea4 2022-12-09T15:55:03 Vulkan: Remove Serial::valid() check QueueSerial right now checks if serial is valid or not in various comparison. This CL removes valid() method from class Serial and rely on the fact that default constructor always constructs kZeroSerial and kZeroSerial is always smaller than any serial, i.e, always appears as flushed, submitted and completed. This removes one branch from critical code path where we try to detect if a buffer/image is used by a renderpass or not etc. Bug: b/262047600 Change-Id: Ic76fe1409d9911dc7eb86107c9a930d8bb5eaa05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4089848 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 214742be 2022-12-13T10:43:52 D3D: Remove ResourceSerial The only difference between ResourceSerial and UniqueueSerial (formerly Serial) appears to be ResourceSerial is wrapper of object pointer. This CL removes ResourceSerial class and switched it to UniqueSerial class instead. (We may need to see why it needs to use pointer to initialize the serial, that sounds like the exact thing serial try to avoid.) Bug: b/262047600 Change-Id: Ic8e1b26d7da9304ff02fd9a7e1b584bb70efcb77 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4102107 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao b19d17b8 2022-12-09T14:38:08 Vulkan: Split Serial class into UniqueSerial and Serial This CL splits Serial class into two classes: UniqueSerial and Serial. UniqueSerial supports the object unique serial usage where there is == and != operator but no > or < comparison. UniqueSerial can have invalid value, but Serial will not have invalid value (in next CL). The main reason is for next CL we can further optimize out the invalid value check in the QueueSerial comparison. Bug: b/262047600 Change-Id: Ieaed2a0d5546b012a6d63aa18b6006595e4aee1b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4093557 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Ivan Murashov 816505f9 2022-12-13T12:35:50 GCC: Make some operators of QueueSerial non constexpr Fix build breakage for GCC because of calling non constexpr function from a constexpr function. The error example: third_party/angle/src/libANGLE/renderer/serial_utils.h:214:40: error: call to non-'constexpr' function 'rx::Serial rx::AtomicQueueSerialFixedArray::operator[](rx::SerialIndex) const' Bug: chromium:819294 Change-Id: Ic09be54ce9418ab3f7d947eaa27c97b55c3c2bab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4098527 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 8181c056 2022-11-22T15:34:48 Vulkan: Remove RenderPassSerial RenderPassSerial was introduced to uniquely identify a RenderPassCommands. With the work of per current context queue serial, now every started RenderPassCommands already have a unique QueueSerial. This CL removes RenderPassSerial and use renderPass's queueSerial instead. Bug: b/255414841 Change-Id: Id0a87319a9132cdb74aba195f1f05aa31454592b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4049966 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Charlie Lao 2e5ca217 2022-11-18T10:44:49 Vulkan: Let each current context has its own QueueSerial. This CL makes every current context has its own queueSerial. At context creation time or when context becomes current, it allocates a QueueIndex from renderer. When it becomes non-current, it releases QueueIndex for others to reuse. This way we significantly reduces the max number of QueueIndexs for reasonable usage. Each CommandBuffer has its own unique QueueSerial and we use that to determine if a resource is being used by the given CommandBuffer. The QueueSerial for RenderPassCommands is deferred until renderPass starts, and when we generate queueSerial for renderPassCommands, we also reserve a range of serials for outsideRenderPassCommands so that we can do incremental submission of outsideRenderPassCommands without need to close renderPassCommands. In rare situation, if that reserved serials runs out, we also close renderPassCommands to ensure the ordering of serials matches ordering of command buffers. With per current context queue serial, this CL is able to set resource queue serial as it is being used. This CL completely removes usage of ResourceUseList class since it was introduced due to deferred setSerial. This CL also get rid of refCount from ResourceUse since there we no longer add it to a ResourceUseList. With that, we also able to remove SharedResourceUse class since access to ResourceUse itself is now thread safe since we are able to make a copy of it when we add it to GarbageList. Because RenderPassCommands now has its own unique QueueSerial as it encodes command, we can use it to detect if a resource is being used by it or not, thus this CL also removes usage of CommandBufferID. Bug: b/255414841 Change-Id: I36dcbeaa7bc996f04e6c04bf9ad44cd0d630f61a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4038096 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 7dd8478e 2022-11-17T10:11:02 Vulkan: Make ResourceUse::serial an FastVector of Serials In preparation for per context queue serial, this CL makes ResourceUse::serial a FastVector of Serial. Right now we still limited to one serial index so that it still work the same way as before. This CL adds necessary data type and change the function names to reflect that tracking GPU progress needs a ResourceUse object instead of a single Serial number. Bug: b/255414841 Change-Id: Ic60cdf5ec8da45d1821f65a55947f5c553f65737 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4034548 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Amirali Abdolrashidi b9cd542e 2022-09-15T17:31:35 Vulkan: Use serial to check which FBO has open RP In preparation for the scenario where an imageless framebuffer is shared, checking whether the started render pass belongs to a certain framebuffer is tweaked to use a serial-based method instead of checking the framebuffer handle. * Added the last render pass serial to ContextVk, which increments every time a render pass begins. The serial is also stored in the FramebufferVk object invoking it. * Added the type RenderPassSerial for this purpose. * Serials are generated through a serial factory in ContextVk. * Updated hasStartedRenderPassWithSerial() to match the serials instead of the handles. * Removed the getFramebuffer() calls from FramebufferVk and UtilsVk that are now unused. Bug: angleproject:7553 Change-Id: Id60dcbf7973558d35e55ff4af4c71e50c6853bba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3897970 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Charlie Lao 394fb0d3 2022-04-26T17:17:58 Vulkan: Don't take lock for getLastCompletedQueueSerial getLastCompletedQueueSerial() is simply returning a uint64_t serial number. There is no need to take a mutex lock. This CL uses atomic for mLastCompletedQueueSerial and removed the lock as well as removed the virtual function call. This also avoid the annoyance with mutex lock, that if you call getLastCompletedQueueSerial in places that has other lock held, you may end up with deadlock. This CL avoids that trouble all together other than improves performance. Bug: b/230759914 Change-Id: I9dc688d410e4c6bca7fc70ae4f9fe0c3acc2e005 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3607500 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Roman Lavrov 6e2ab29d 2022-01-11T22:39:05 Avoid data race in overflow check. `mSerial + 1 > mSerial` involves reading the value multiple times which results in a data race. Bug: angleproject:6633 Change-Id: Iae289ba2ee54190703f16f60319d10988da46cb9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3381854 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Roman Lavrov <romanl@google.com>
Jamie Madill 22e6fc03 2020-07-31T15:58:28 Vulkan: Move Resource Serial gen into Renderer. Putting Serial allocation in the Renderer allows the Helper classes to manage allocating its own Serial. The init functions for ImageViewHelper only have access to a vk::Context/RendererVk, not a ContextVk. This will be updated in a future CL. Re-uses the Serial Type X-Macro to do more code generation. Serial allocation now uses an atomic because of its now Renderer shared location. Bug: angleproject:4911 Change-Id: I2d5d3d0bbf613d5468de795a700f66164291bc79 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2332884 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao 67980f13 2020-07-08T08:51:02 Vulkan: add Buffer/Texture/ImageViewSerial class In a few places we need a unique ID to represent that object and use that to compute hash key. Right now we are using Serial for that purpose but it creates confusion with QueueSerial which we are using Serial to track GPU progress. This CL changes these usage of Serial to TextureSerial, SamplerSerial, ImageViewSerial type so that compiler can perform type checking. It also adds BufferSerial in preparation for next CL. Bug: b/159457348 Change-Id: I8e2da69c2029e4ddbcf163981ae46f85e19f751b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2287426 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 6328caf3 2020-03-24T19:31:02 Vulkan: Avoid renderpass break for occlusion query This ensures beginQuery and endQuery only get inserted into renderpasses and will not close renderpass because of query call Bug: angleproject:4381 Change-Id: I690f096b9e8e4b7ea9a67045d1be0fd7a319c98c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2119246 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Jamie Madill ce4918f1 2020-02-19T09:39:44 Vulkan: Sanitize Images & Buffers with non-zero values. Only enabled for specific tests at the moment. This CL allows our tests to sanitizes memory for the robust resource access extension. It is quite slow so should not be enabled by default. Only works for 1 level 2D color textures and buffers. Makes several flaky robust resource initialization tests consistently fail. Controlled via an angle::Feature in FeaturesVk. It works by initializing memory to an abitrary non-zero value: - if newly allocated memory is mappable, we map it in init and set it - if a buffer or texture can be a transfer destination, we use a staging resource - otherwise we don't attempt to initialize the resource. Bug: angleproject:4384 Change-Id: I9b4f347bfcddf3096f491ed0243bef86837feaa0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2043271 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Tobin Ehlis cf2ec3b1 2020-01-31T16:55:50 Vulkan:Add FramebufferVk cache This adds a FramebufferVk cache. Cache signature is based on unique Serial values that are assigned to ImageHelper objects backing all color and DS rendertargets as well as level/layer values unique to the imageView. Update the Serials and cache signature at FramebufferVk::syncState() time. L0 cache is a currently active framebuffer. L1 cache retrieves previously created framebuffer from new cache. If neither of those hit, create new FramebufferVk and add to L1. Bug: angleproject:4322 Change-Id: I3f585271798ddfb9e5f194020adca8cf8a6b19dd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2033869 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill d50151d3 2019-12-17T13:57:12 Move Serial utils to their own file. This will let the front-end access them without pulling in the rest of renderer_utils. The Serial class in particular will be useful for capture/replay. Also adds a very minimal unit test. Bug: angleproject:4223 Change-Id: I9e63b8a8227a245b20a8f024b960fcf60c7840db Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1954611 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>