diff --git a/src/dawn/native/metal/MetalBackend.mm b/src/dawn/native/metal/MetalBackend.mm index 9bdf138125..0bbc2657a6 100644 --- a/src/dawn/native/metal/MetalBackend.mm +++ b/src/dawn/native/metal/MetalBackend.mm @@ -38,6 +38,7 @@ WGPUTexture WrapIOSurface(WGPUDevice device, const ExternalImageDescriptorIOSurf waitEvents.push_back( {static_cast>(waitEvent.sharedEvent), waitEvent.signaledValue}); } + auto deviceLock(backendDevice->GetScopedLock()); Ref texture = backendDevice->CreateTextureWrappingIOSurface( cDescriptor, cDescriptor->ioSurface, std::move(waitEvents)); return ToAPI(texture.Detach()); @@ -46,11 +47,15 @@ WGPUTexture WrapIOSurface(WGPUDevice device, const ExternalImageDescriptorIOSurf void IOSurfaceEndAccess(WGPUTexture cTexture, ExternalImageIOSurfaceEndAccessDescriptor* descriptor) { Texture* texture = ToBackend(FromAPI(cTexture)); + auto device = texture->GetDevice(); + auto deviceLock(device->GetScopedLock()); texture->IOSurfaceEndAccess(descriptor); } void WaitForCommandsToBeScheduled(WGPUDevice device) { - ToBackend(FromAPI(device))->WaitForCommandsToBeScheduled(); + Device* backendDevice = ToBackend(FromAPI(device)); + auto deviceLock(backendDevice->GetScopedLock()); + backendDevice->WaitForCommandsToBeScheduled(); } } // namespace dawn::native::metal