src/common/MemoryBuffer.cpp


Log

Author Commit Date CI Message
Mohan Maiya de5286fa 2025-01-14T10:59:17 Add missing include to MemoryBuffer.cpp Details can be found here - https://chromium-review.googlesource.com/c/angle/angle/+/6135238/11#message-d271191140cfc29498701cbbb5ee8c6dc20349d0 Bug: angleproject:386749841 Change-Id: I428a61bafcc2d65d7538e0d1c28ebe39ad40b7fa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6169566 Reviewed-by: Brian Johnson <hibrian@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Mohan Maiya b3af2e86 2024-12-31T08:51:37 Enhance MemoryBuffer API Add support for - 1. reserve - users can reserve sufficient capacity upfront to minimize subsequent reallocations due to resize 2. append - to append data from a source so user doesn't need to track offsets explicitly Bug: angleproject:386749841 Tests: MemoryBufferTest* Change-Id: Ibf2a3228d5a00ed34a7e0c5e3eb185e42677d676 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6135238 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Igor Nazarov 8469debb 2024-09-04T20:04:10 Vulkan: Add dual slots in CompressAndStorePipelineCacheVk() Change fixes following problem: Currently, each call to `CompressAndStorePipelineCacheVk()` stores chunks in order, starting from 0. This overrides previously stored chunks. In case of app termination (kill) in the middle of this process, the entire cache data will be corrupted, since it will partially contain chunks from the new and old caches. Solution: In order to fix this problem, this change introduces `slotIndex` into the `chunkCacheHash` calculation. Slot index is managed by `vk::Renderer::getNextPipelineCacheBlobCacheSlotIndex()` method, which will alternate between 0 and 1 when "useDualPipelineBlobCacheSlots" feature is enabled, and always 0 otherwise. Additionally, chunk storing order is reversed: last chunk is stored first and the first (0 chunk) - last. This is done because 0 chunk is the first that is loaded in `GetAndDecompressPipelineCacheVk()` and used as indication that there is data in the cache. Writing it last, ensures that other chunks will be also available. When "useDualPipelineBlobCacheSlots" is enabled, each call to `CompressAndStorePipelineCacheVk()` will use slot index opposed to the slot that is stored in the cache, avoiding damaging existing data. After writing all chunks for a brief moment there may be 2 instances of the data. However, data for the previous slot will be immediately erased (by writing 1/0-sized blobs) starting from the 0 chunk. To control if erasing of old pipeline cache data will be erased by using 0-sized or 1-sized blobs blobs, added `useEmptyBlobsToEraseOldPipelineCacheFromBlobCache` feature. The `GetAndDecompressPipelineCacheVk()` function will iterate over each available slot index checking only 0 chunk until data is found. In case of the OpenCL API, features will always have following values: - "useDualPipelineBlobCacheSlots" -> false - "useEmptyBlobsToEraseOldPipelineCacheFromBlobCache" -> true Note: this solution requires 2X pipeline cache size space in the blob cache to work as expected, otherwise it will exacerbate other problem: When blob cache is full, but still allows to store the current pipeline cache data, storing next chunk may trigger eviction of already stored items. Depending on the blob cache implementation, eviction process may choose to evict chunks from the current pipeline cache data. As the result: blob cache will not contain all chunks. The above problem will be addressed in the follow up CL. Bug: angleproject:4722 Change-Id: I2920bc3d89263280cdfe0466446fca26415e2b25 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5756576 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Mohan Maiya 9aa6d3da 2024-04-26T11:34:10 Add trim support to MemoryBuffer There are usecases where we need a MemoryBuffer to be trimmed to a smaller size. In such cases there is no need to perform a resize, which would trigger a reallocation. Instead just update MemoryBuffer's size. Bug: angleproject:4722 Change-Id: I5b6cca121977903ffa7663591eaec62f6ffda97a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5513269 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Manh Nguyen 900c7e87 2020-07-07T14:20:36 Serialize d/s buffers + use color buffers' impl format for readPixels Adds serialization of depth/stencil buffer contents Currently, readPixels on color buffers uses the gles front-end format, which can be different from the implementation format used in the backend. This can cause seg fault crashes when the number of bytes in a pixel differs between the two format. Changes so that readPixels for color buffers always use the backend format. Bug: angleproject:4817 Change-Id: I62d5deb1320ea38ee46143b2aa97f372ba01baeb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2284451 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Manh Nguyen <nguyenmh@google.com>
Geoff Lang aa6dd50d 2020-02-03T17:10:58 Share scratch buffers between contexts. The Display now owns scratch buffers and loans them out to contexts while they are current. This allows us to to only allocate one scratch buffer in a single-threaded use case. Tick the scratch buffers every time a new context is made current. Lower the lifetime from 1000 to 64 to ensure that in the worst case, the buffers are cleared after not being used for ~1 second. BUG=chromium:1030835 BUG=angleproject:4363 Change-Id: I83552424e2beac62b9e41152876b04fc84f53692 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2031698 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Geoff Lang a36f8bd4 2020-01-29T12:10:17 Mark MemoryBuffer allocation functions as NO_DISCARD Not all call sites were checking the return value of MemoryBuffer::resize, mark the return value as NO_DISCARD and fix all the warnings. BUG=chromium:1030835 Change-Id: I762796e3d11efc131a814069d78a195b0d4c9f8f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2028151 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@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>
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>
Shahbaz Youssefi 996628a4 2018-09-24T16:39:26 Vulkan: Add support for VkPipelineCache The cache is initialized from the application's blob cache and is occasionally written back to it for disk storage. Bug: angleproject:2516 Change-Id: I4cba4b00a7b9641c2983ef07159bc62cd10a5519 Reviewed-on: https://chromium-review.googlesource.com/1241373 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Rafael Cintron 05a449a7 2018-06-20T18:08:04 Replace reinterpret_cast with safer or no cast When casting types to one another in C++, the weaker the cast, the better. This change replaces instances of reinterpret_cast with static_cast or no cast where it safe and correct to do so. BUG=angleproject:2683 Change-Id: I99c9033614a65282ae1d78cf0f4b80fabd75877a Reviewed-on: https://chromium-review.googlesource.com/1109396 Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 44183cce 2017-08-01T12:48:34 Micro-optimizations to draw call entry point. Thanks to Markus from NVIDIA. This inlines some methods and optimizes the check if a uniform is a bool type. BUG=angleproject:2119 Change-Id: I6f2c2d22c577458b39de600d3c56ec8e1a456a7a Reviewed-on: https://chromium-review.googlesource.com/591699 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Jamie Madill b3f26b9e 2017-07-19T15:07:41 Add a zero-filled scratch buffer to Context. We need this in a few places for handling resource init. Centralize this in the context so we don't have to recreate and re-fill a large zero buffer. BUG=angleproject:2107 Change-Id: Icf9ce417e7ee3498f03e47741dfff89e81b49519 Reviewed-on: https://chromium-review.googlesource.com/576057 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 3244736a 2017-06-28T14:53:52 Use MemoryProgramCache. Add the member functions for saving and loading from the binary cache, and hook them into the Program class. Requires that the Renderer supports the program binary extension. BUG=angleproject:1897 Change-Id: I2dc8d21b02da705ded58c5cd1943562c9c97c49b Reviewed-on: https://chromium-review.googlesource.com/522874 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 231c7f56 2017-04-26T13:45:37 Apply clang-format to many files. This cleans up the formatting in many places. BUG=None Change-Id: I6c6652ebc042f1f0ffecced53582d09d66b4f384 Reviewed-on: https://chromium-review.googlesource.com/487884 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 9c9b40ac 2017-04-26T16:31:57 Use parameter cache to skip passing IndexRange. For DrawElements et al., we can use a simple design to store entry point parameters and compute index ranges lazily. This allows us to compute the index range outside of the validation layer. Fixing this will let us implement a few things, such as the no error extension. It will also allow auto-generation of the entry points, since we won't have to have special cases for certain entry points. It will also help fix the syncState layering problem. Now the cached parameter helper (which is owned by the Context) can make the impl layer calls, instead of the validation layer calling the impl directly. We use a small array in Context to gather parameters in a generic way without reallocation on call. We also check type safety by storing a type info struct which can handle inheritance between type classes. Optional variables for the cache determine when to re-compute values. The intent with gatherParams is to call this in every entry point, and have in most cases be a no-op. In some cases like for IndexRange, we store some parameters for later use. The inheritance scheme enables auto-generation of the entry points by keeping signatures similar. BUG=angleproject:747 Change-Id: I871e99e1334cf6e61ef8da62fde3ced094903f8a Reviewed-on: https://chromium-review.googlesource.com/474119 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 9f9b1d2d 2017-03-06T18:25:22 Make ScratchBuffer its own type. This helper tool in Renderer11 can be useful in other back-ends, or even in the front end. BUG=angleproject:1635 Change-Id: I18ec19a891a9bdfa7b80dea1b8e308abf206906b Reviewed-on: https://chromium-review.googlesource.com/450919 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 74ba76c4 2015-02-09T10:31:23 Move rx::MemoryBuffer to common library. This class is not D3D-specific so can be shared among other back-ends, or other parts of the ANGLE codebase. Change-Id: Ie00760eb5dae4db52e465ee7a2f97789bae8c0b0 Reviewed-on: https://chromium-review.googlesource.com/246500 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>