[clang-format] Change-Id: I9f083823c2b3a74a459ac59dff692fbe69d04e67 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/177660 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index d2812c2..93fa3b6 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp
@@ -2296,27 +2296,27 @@ void DeviceBase::AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline, WGPUCreateRenderPipelineAsyncCallback callback, void* userdata) { - mCallbackTaskManager->AddCallbackTask([callback, pipeline = std::move(pipeline), - userdata]() mutable { - // TODO(dawn:529): call AddOrGetCachedRenderPipeline() asynchronously in - // CreateRenderPipelineAsyncTaskImpl::Run() when the front-end pipeline cache is - // thread-safe. - DAWN_ASSERT(pipeline != nullptr); - { - // This is called inside a callback, and no lock will be held by default so we have - // to lock now to protect the cache. - // Note: we don't lock inside AddOrGetCachedRenderPipeline() to avoid deadlock - // because many places calling that method might already have the lock held. For - // example, APICreateRenderPipeline() - DeviceBase* device = pipeline->GetDevice(); - auto deviceLock(device->GetScopedLock()); - if (device->GetState() == State::Alive) { - pipeline = device->AddOrGetCachedRenderPipeline(std::move(pipeline)); + mCallbackTaskManager->AddCallbackTask( + [callback, pipeline = std::move(pipeline), userdata]() mutable { + // TODO(dawn:529): call AddOrGetCachedRenderPipeline() asynchronously in + // CreateRenderPipelineAsyncTaskImpl::Run() when the front-end pipeline cache is + // thread-safe. + DAWN_ASSERT(pipeline != nullptr); + { + // This is called inside a callback, and no lock will be held by default so we have + // to lock now to protect the cache. + // Note: we don't lock inside AddOrGetCachedRenderPipeline() to avoid deadlock + // because many places calling that method might already have the lock held. For + // example, APICreateRenderPipeline() + DeviceBase* device = pipeline->GetDevice(); + auto deviceLock(device->GetScopedLock()); + if (device->GetState() == State::Alive) { + pipeline = device->AddOrGetCachedRenderPipeline(std::move(pipeline)); + } } - } - callback(WGPUCreatePipelineAsyncStatus_Success, ToAPI(ReturnToAPI(std::move(pipeline))), "", - userdata); - }); + callback(WGPUCreatePipelineAsyncStatus_Success, ToAPI(ReturnToAPI(std::move(pipeline))), + "", userdata); + }); } PipelineCompatibilityToken DeviceBase::GetNextPipelineCompatibilityToken() {
diff --git a/src/dawn/tests/unittests/wire/WireTest.cpp b/src/dawn/tests/unittests/wire/WireTest.cpp index 67ce338..1fb4be0 100644 --- a/src/dawn/tests/unittests/wire/WireTest.cpp +++ b/src/dawn/tests/unittests/wire/WireTest.cpp
@@ -93,32 +93,31 @@ MockCallback<WGPURequestAdapterCallback> adapterCb; wgpuInstanceRequestAdapter(instance, &adapterOpts, adapterCb.Callback(), adapterCb.MakeUserdata(this)); - EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _)) - .WillOnce([&]() { - EXPECT_CALL(api, AdapterHasFeature(apiAdapter, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(api, OnInstanceRequestAdapter(apiInstance, NotNull(), _)).WillOnce([&]() { + EXPECT_CALL(api, AdapterHasFeature(apiAdapter, _)).WillRepeatedly(Return(false)); - EXPECT_CALL(api, AdapterGetProperties(apiAdapter, NotNull())) - .WillOnce(WithArg<1>(Invoke([&](WGPUAdapterProperties* properties) { - *properties = {}; - properties->vendorName = ""; - properties->architecture = ""; - properties->name = ""; - properties->driverDescription = ""; - }))); + EXPECT_CALL(api, AdapterGetProperties(apiAdapter, NotNull())) + .WillOnce(WithArg<1>(Invoke([&](WGPUAdapterProperties* properties) { + *properties = {}; + properties->vendorName = ""; + properties->architecture = ""; + properties->name = ""; + properties->driverDescription = ""; + }))); - EXPECT_CALL(api, AdapterGetLimits(apiAdapter, NotNull())) - .WillOnce(WithArg<1>(Invoke([&](WGPUSupportedLimits* limits) { - *limits = {}; - return true; - }))); + EXPECT_CALL(api, AdapterGetLimits(apiAdapter, NotNull())) + .WillOnce(WithArg<1>(Invoke([&](WGPUSupportedLimits* limits) { + *limits = {}; + return true; + }))); - EXPECT_CALL(api, AdapterEnumerateFeatures(apiAdapter, nullptr)) - .WillOnce(Return(0)) - .WillOnce(Return(0)); + EXPECT_CALL(api, AdapterEnumerateFeatures(apiAdapter, nullptr)) + .WillOnce(Return(0)) + .WillOnce(Return(0)); - api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success, - apiAdapter, nullptr); - }); + api.CallInstanceRequestAdapterCallback(apiInstance, WGPURequestAdapterStatus_Success, + apiAdapter, nullptr); + }); FlushClient(); WGPUAdapter cAdapter = nullptr; EXPECT_CALL(adapterCb, Call(WGPURequestAdapterStatus_Success, NotNull(), nullptr, this)) @@ -133,28 +132,26 @@ MockCallback<WGPURequestDeviceCallback> deviceCb; wgpuAdapterRequestDevice(adapter.Get(), &deviceDesc, deviceCb.Callback(), deviceCb.MakeUserdata(this)); - EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _)) - .WillOnce([&]() { - // Set on device creation to forward callbacks to the client. - EXPECT_CALL(api, OnDeviceSetUncapturedErrorCallback(apiDevice, NotNull(), NotNull())) - .Times(1); - EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, NotNull(), NotNull())).Times(1); - EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(apiDevice, NotNull(), NotNull())) - .Times(1); + EXPECT_CALL(api, OnAdapterRequestDevice(apiAdapter, NotNull(), _)).WillOnce([&]() { + // Set on device creation to forward callbacks to the client. + EXPECT_CALL(api, OnDeviceSetUncapturedErrorCallback(apiDevice, NotNull(), NotNull())) + .Times(1); + EXPECT_CALL(api, OnDeviceSetLoggingCallback(apiDevice, NotNull(), NotNull())).Times(1); + EXPECT_CALL(api, OnDeviceSetDeviceLostCallback(apiDevice, NotNull(), NotNull())).Times(1); - EXPECT_CALL(api, DeviceGetLimits(apiDevice, NotNull())) - .WillOnce(WithArg<1>(Invoke([&](WGPUSupportedLimits* limits) { - *limits = {}; - return true; - }))); + EXPECT_CALL(api, DeviceGetLimits(apiDevice, NotNull())) + .WillOnce(WithArg<1>(Invoke([&](WGPUSupportedLimits* limits) { + *limits = {}; + return true; + }))); - EXPECT_CALL(api, DeviceEnumerateFeatures(apiDevice, nullptr)) - .WillOnce(Return(0)) - .WillOnce(Return(0)); + EXPECT_CALL(api, DeviceEnumerateFeatures(apiDevice, nullptr)) + .WillOnce(Return(0)) + .WillOnce(Return(0)); - api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success, - apiDevice, nullptr); - }); + api.CallAdapterRequestDeviceCallback(apiAdapter, WGPURequestDeviceStatus_Success, apiDevice, + nullptr); + }); FlushClient(); EXPECT_CALL(deviceCb, Call(WGPURequestDeviceStatus_Success, NotNull(), nullptr, this)) .WillOnce(SaveArg<1>(&device));