Implement buffer lazy initialization before mapping

This patch implements buffer lazy initialization beffor MapAsync() and
buffer creation with BufferDescriptor.mappedAtCreation == true.

Note that this patch doesn't initialize buffers in MapReadAsyc() and
MapWriteAsync() because they are deprecated and will be removed soon.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: Ifea99833897081f599c45797e0829c57de1ac926
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24687
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao
2020-07-17 09:01:26 +00:00
committed by Commit Bot service account
parent 2733af5c75
commit 77eb64eb8c
5 changed files with 149 additions and 1 deletions

View File

@@ -99,6 +99,8 @@ namespace dawn_native { namespace opengl {
}
MaybeError Buffer::MapAtCreationImpl() {
EnsureDataInitialized();
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
mMappedData = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
@@ -137,6 +139,8 @@ namespace dawn_native { namespace opengl {
size = 4;
}
EnsureDataInitialized();
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
// version of OpenGL that would let us map the buffer unsynchronized.
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);