Ensure device mutex is locked for DynamicUploader

DynamicUploader::Reserve()/Deallocate() aren't thread safe.

Bug: 425472913
Change-Id: I0b5471999d950ff434edc38046a42cc99849947f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/289395
Commit-Queue: Kyle Charbonneau <kylechar@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/DynamicUploader.cpp b/src/dawn/native/DynamicUploader.cpp
index 398eb00..212b935 100644
--- a/src/dawn/native/DynamicUploader.cpp
+++ b/src/dawn/native/DynamicUploader.cpp
@@ -45,6 +45,8 @@
 
 ResultOrError<UploadReservation> DynamicUploader::Reserve(uint64_t allocationSize,
                                                           uint64_t offsetAlignment) {
+    DAWN_ASSERT(mDevice->IsLockedByCurrentThreadIfNeeded());
+
     // Disable further sub-allocation should the request be too large.
     if (allocationSize > kRingBufferSize) {
         BufferDescriptor bufferDesc = {};
@@ -156,6 +158,8 @@
 }
 
 void DynamicUploader::Deallocate(ExecutionSerial lastCompletedSerial, bool freeAll) {
+    DAWN_ASSERT(mDevice->IsLockedByCurrentThreadIfNeeded());
+
     // Reclaim memory within the ring buffers by ticking (or removing requests no longer
     // in-flight).
     size_t i = 0;