Double the size of the ring buffer only when it is not big enough

Currently Dawn always doubles the size of the largest ring buffer
everytime when DynamicUploader::Allocate() is called, which is not
necessary and will cause out-of-memory errors when this function is
called for too many times. This time fixes this behaviour by only
doubling the size of the largest ring buffer when it is not big enough
for the request buffer size.

BUG=dawn:108
TEST=dawn_end2end_tests

Change-Id: I734493dbc632ca8e9a30c1ceeb0b7b9e0474656b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9160
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2019-07-19 00:09:28 +00:00 committed by Commit Bot service account
parent 91ec571d17
commit 49aae0f3bd
2 changed files with 1 additions and 5 deletions

View File

@ -54,7 +54,7 @@ namespace dawn_native {
// request.
if (uploadHandle.mappedBuffer == nullptr) {
// Compute the new max size (in powers of two to preserve alignment).
size_t newMaxSize = largestRingBuffer->GetSize() * 2;
size_t newMaxSize = largestRingBuffer->GetSize();
while (newMaxSize < size) {
newMaxSize *= 2;
}

View File

@ -176,10 +176,6 @@ TEST_P(BufferSetSubDataTests, SmallDataAtOffset) {
// Stress test for many calls to SetSubData
TEST_P(BufferSetSubDataTests, ManySetSubData) {
// Test failing on Mac Metal Intel, maybe because Metal runs out of space to encode commands.
// See https://bugs.chromium.org/p/dawn/issues/detail?id=108
DAWN_SKIP_TEST_IF(IsMacOS() && IsMetal() && IsIntel());
// Test failing on Linux Vulkan Intel. It works on Ubuntu 14.04 but fails on
// 19.04.
// See https://bugs.chromium.org/p/chromium/issues/detail?id=980737