Vulkan: Remove inUseAndRespecifiedWithoutData from BufferVk

BufferVk::setDataWithMemoryType() has one optimization that it tries to
detect glBufferData(target, size, nullptr, usage) and if existing
storage is busy, it immediately reallocate storage. With the
optimization in previous CL (crrev.com/c/4317488), the storage reuse
logic should detect if we can reuse the storage or not. If the size
matches the existing storage's size, then there is no reason we can not
reuse existing storage. Later on when glBufferSubData or
glMapBufferRange is called, there are optimization in those calls that
will detect if we should reallocate storage or not as the further
optimization. This CL removes this check and replies on the other
optimization to handle the storage reallocate (shadowing) if necessary.
This simplifies code and also potentially avoids storage reallocation in
certain usage cases.

This CL also fixes a test bug in
BufferDataTestES3.BufferDataWithNullFollowedByMap that was calling
glMapBufferRange with MAP_UNSYNCHRONIZED_BIT but incorrectly expecting
GL to do synchronization.

Bug: b/271915956
Change-Id: I7901687b3e3e262e77699f14eb8602d8a57eda3e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4322048
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Charlie Lao <cclao@google.com>
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
This commit is contained in:
Charlie Lao 2023-03-08 14:31:33 -08:00 коммит произвёл Angle LUCI CQ
Родитель c3ffae10aa
Коммит 755bfe471d
2 изменённых файлов: 2 добавлений и 7 удалений

Просмотреть файл

@ -417,13 +417,9 @@ angle::Result BufferVk::setDataWithMemoryType(const gl::Context *context,
}
else
{
const bool inUseAndRespecifiedWithoutData = (data == nullptr && isCurrentlyInUse(renderer));
// Optimization: Lets figure out if we can reuse the existing storage.
bool redefineStorage = shouldRedefineStorage(renderer, usage, memoryPropertyFlags, size);
// The entire buffer is being respecified, possibly with null data.
// Release and init a new mBuffer with requested size.
if (redefineStorage || inUseAndRespecifiedWithoutData)
if (redefineStorage)
{
// Release and re-create the memory and buffer.
release(contextVk);

Просмотреть файл

@ -1219,8 +1219,7 @@ TEST_P(BufferDataTestES3, BufferDataWithNullFollowedByMap)
const std::vector<GLfloat> kZeros(6, 0.0f);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * kZeros.size(), nullptr, GL_STATIC_DRAW);
uint8_t *mapPtr = reinterpret_cast<uint8_t *>(
glMapBufferRange(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * kZeros.size(),
GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT));
glMapBufferRange(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * kZeros.size(), GL_MAP_WRITE_BIT));
ASSERT_NE(nullptr, mapPtr);
ASSERT_GL_NO_ERROR();
memcpy(mapPtr, kZeros.data(), sizeof(GLfloat) * kZeros.size());