Don't clear staging buffer again in `BufferBase::MapAtCreation()`

This patch removes an unnecessary call of `memset()` on the memory
pointer got from the staging buffer. In `BufferBase::MapAtCreation()`,
we don't need to clear the staging buffer again because the staging
buffer is created with `mappedAtCreation == true` and has already been
cleared to 0 at its creation time.

Bug: chromium:42242066
Change-Id: I9b48b7494ab1c116e8bd91b7f598ffe8cabac5ab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/213195
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp
index c618f84..9241f5d 100644
--- a/src/dawn/native/Buffer.cpp
+++ b/src/dawn/native/Buffer.cpp
@@ -588,8 +588,14 @@
     DeviceBase* device = GetDevice();
     if (device->IsToggleEnabled(Toggle::LazyClearResourceOnFirstUse) &&
         !device->IsToggleEnabled(Toggle::DisableLazyClearForMappedAtCreationBuffer)) {
-        memset(ptr, uint8_t(0u), size);
-        device->IncrementLazyClearCountForTesting();
+        // The staging buffer is created with `MappedAtCreation == true` so we don't need to clear
+        // it again.
+        if (mStagingBuffer != nullptr) {
+            DAWN_ASSERT(!mStagingBuffer->NeedsInitialization());
+        } else {
+            memset(ptr, uint8_t(0u), size);
+            device->IncrementLazyClearCountForTesting();
+        }
     } else if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
         memset(ptr, uint8_t(1u), size);
     }
@@ -624,8 +630,6 @@
             stagingBufferDesc.size = Align(GetAllocatedSize(), 4);
             stagingBufferDesc.mappedAtCreation = true;
             stagingBufferDesc.label = "Dawn_MappedAtCreationStaging";
-
-            IgnoreLazyClearCountScope scope(GetDevice());
             DAWN_TRY_ASSIGN(mStagingBuffer, GetDevice()->CreateBuffer(&stagingBufferDesc));
         }
     }