Deprecate fences.

The are replaced by Queue::OnSubmittedWorkDone. Only Queue::CreateFence
is deprecated since all other fence-related calls require a fence to
work.

Also ports a number of uses of fences in test harness to use
Queue::OnSubmittedWorkDone instead.

Bug: chromium:1177476

Change-Id: I479415f72b08158a3484013e00db8facd11e6f33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42660
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Corentin Wallez 2021-02-25 21:47:15 +00:00 committed by Commit Bot service account
parent 7124cc4e5d
commit 4165c1cd9c
11 changed files with 97 additions and 70 deletions

View File

@ -237,6 +237,10 @@ namespace dawn_native {
} }
Fence* QueueBase::CreateFence(const FenceDescriptor* descriptor) { Fence* QueueBase::CreateFence(const FenceDescriptor* descriptor) {
// TODO(chromium:1177476): Remove once the deprecation period is finished.
GetDevice()->EmitDeprecationWarning(
"Fences are deprecated, use Queue::OnSubmittedWorkDone instead.");
if (GetDevice()->ConsumedError(ValidateCreateFence(descriptor))) { if (GetDevice()->ConsumedError(ValidateCreateFence(descriptor))) {
return Fence::MakeError(GetDevice()); return Fence::MakeError(GetDevice());
} }

View File

@ -65,10 +65,6 @@ namespace {
return sOriginalDeviceCreateSwapChain(device, surface, &desc); return sOriginalDeviceCreateSwapChain(device, surface, &desc);
} }
void CommandsCompleteCallback(WGPUFenceCompletionStatus status, void* userdata) {
sCommandsComplete = true;
}
} // namespace } // namespace
int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) { int DawnWireServerFuzzer::Initialize(int* argc, char*** argv) {
@ -163,10 +159,8 @@ int DawnWireServerFuzzer::Run(const uint8_t* data,
// Wait for all previous commands before destroying the server. // Wait for all previous commands before destroying the server.
// TODO(enga): Improve this when we improve/finalize how processing events happens. // TODO(enga): Improve this when we improve/finalize how processing events happens.
{ {
wgpu::Queue queue = device.GetQueue(); device.GetQueue().OnSubmittedWorkDone(
wgpu::Fence fence = queue.CreateFence(); 0u, [](WGPUQueueWorkDoneStatus, void*) { sCommandsComplete = true; }, nullptr);
queue.Signal(fence, 1u);
fence.OnCompletion(1u, CommandsCompleteCallback, 0);
while (!sCommandsComplete) { while (!sCommandsComplete) {
device.Tick(); device.Tick();
utils::USleep(100); utils::USleep(100);

View File

@ -1080,12 +1080,11 @@ void DawnTestBase::FlushWire() {
} }
void DawnTestBase::WaitForAllOperations() { void DawnTestBase::WaitForAllOperations() {
wgpu::Queue queue = device.GetQueue(); bool done = false;
wgpu::Fence fence = queue.CreateFence(); device.GetQueue().OnSubmittedWorkDone(
0u, [](WGPUQueueWorkDoneStatus, void* userdata) { *static_cast<bool*>(userdata) = true; },
// Force the currently submitted operations to completed. &done);
queue.Signal(fence, 1); while (!done) {
while (fence.GetCompletedValue() < 1) {
WaitABit(); WaitABit();
} }
} }

View File

@ -164,6 +164,11 @@ TEST_P(DeprecationTests, GetDefaultQueueDeprecation) {
EXPECT_EQ(deprecatedQueue.Get(), queue.Get()); EXPECT_EQ(deprecatedQueue.Get(), queue.Get());
} }
// Test that fences are deprecated.
TEST_P(DeprecationTests, CreateFence) {
EXPECT_DEPRECATION_WARNING(queue.CreateFence());
}
DAWN_INSTANTIATE_TEST(DeprecationTests, DAWN_INSTANTIATE_TEST(DeprecationTests,
D3D12Backend(), D3D12Backend(),
MetalBackend(), MetalBackend(),

View File

@ -422,17 +422,13 @@ TEST_P(DeviceLostTest, CommandEncoderFinishFails) {
TEST_P(DeviceLostTest, CreateFenceFails) { TEST_P(DeviceLostTest, CreateFenceFails) {
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
wgpu::FenceDescriptor descriptor; EXPECT_DEPRECATION_WARNING(ASSERT_DEVICE_ERROR(queue.CreateFence()));
descriptor.initialValue = 0;
ASSERT_DEVICE_ERROR(queue.CreateFence(&descriptor));
} }
// Test that queue signal fails when device is lost // Test that queue signal fails when device is lost
TEST_P(DeviceLostTest, QueueSignalFenceFails) { TEST_P(DeviceLostTest, QueueSignalFenceFails) {
wgpu::FenceDescriptor descriptor; wgpu::Fence fence;
descriptor.initialValue = 0; EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
wgpu::Fence fence = queue.CreateFence(&descriptor);
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
@ -444,14 +440,13 @@ TEST_P(DeviceLostTest, QueueSignalFenceFails) {
ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionFails, nullptr)); ASSERT_DEVICE_ERROR(fence.OnCompletion(2u, ToMockFenceOnCompletionFails, nullptr));
// completed value should not have changed from initial value // completed value should not have changed from initial value
EXPECT_EQ(fence.GetCompletedValue(), descriptor.initialValue); EXPECT_EQ(fence.GetCompletedValue(), 0u);
} }
// Test that Fence On Completion fails after device is lost // Test that Fence On Completion fails after device is lost
TEST_P(DeviceLostTest, FenceOnCompletionFails) { TEST_P(DeviceLostTest, FenceOnCompletionFails) {
wgpu::FenceDescriptor descriptor; wgpu::Fence fence;
descriptor.initialValue = 0; EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 2); queue.Signal(fence, 2);
@ -469,9 +464,8 @@ TEST_P(DeviceLostTest, FenceOnCompletionFails) {
// Test that Fence::OnCompletion callbacks with device lost status when device is lost after calling // Test that Fence::OnCompletion callbacks with device lost status when device is lost after calling
// OnCompletion // OnCompletion
TEST_P(DeviceLostTest, FenceOnCompletionBeforeLossFails) { TEST_P(DeviceLostTest, FenceOnCompletionBeforeLossFails) {
wgpu::FenceDescriptor descriptor; wgpu::Fence fence;
descriptor.initialValue = 0; EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 2); queue.Signal(fence, 2);
@ -513,9 +507,8 @@ TEST_P(DeviceLostTest, QueueOnSubmittedWorkDoneBeforeLossFails) {
TEST_P(DeviceLostTest, AfterSubmitAndSerial) { TEST_P(DeviceLostTest, AfterSubmitAndSerial) {
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
wgpu::FenceDescriptor descriptor; wgpu::Fence fence;
descriptor.initialValue = 0; EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 1); queue.Signal(fence, 1);
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
@ -523,9 +516,8 @@ TEST_P(DeviceLostTest, AfterSubmitAndSerial) {
// Test that when you Signal, then Tick, then device lost, the fence completed value would be 2 // Test that when you Signal, then Tick, then device lost, the fence completed value would be 2
TEST_P(DeviceLostTest, FenceSignalTickOnCompletion) { TEST_P(DeviceLostTest, FenceSignalTickOnCompletion) {
wgpu::FenceDescriptor descriptor; wgpu::Fence fence;
descriptor.initialValue = 0; EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
wgpu::Fence fence = queue.CreateFence(&descriptor);
queue.Signal(fence, 2); queue.Signal(fence, 2);
WaitForAllOperations(); WaitForAllOperations();

View File

@ -83,7 +83,8 @@ class FenceTests : public DawnTest {
TEST_P(FenceTests, SimpleSignal) { TEST_P(FenceTests, SimpleSignal) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1u; descriptor.initialValue = 1u;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
// Completed value starts at initial value // Completed value starts at initial value
EXPECT_EQ(fence.GetCompletedValue(), 1u); EXPECT_EQ(fence.GetCompletedValue(), 1u);
@ -97,7 +98,8 @@ TEST_P(FenceTests, SimpleSignal) {
// Test callbacks are called in increasing order of fence completion value // Test callbacks are called in increasing order of fence completion value
TEST_P(FenceTests, OnCompletionOrdering) { TEST_P(FenceTests, OnCompletionOrdering) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 4); queue.Signal(fence, 4);
@ -131,7 +133,8 @@ TEST_P(FenceTests, OnCompletionOrdering) {
// Test callbacks still occur if Queue::Signal happens multiple times // Test callbacks still occur if Queue::Signal happens multiple times
TEST_P(FenceTests, MultipleSignalOnCompletion) { TEST_P(FenceTests, MultipleSignalOnCompletion) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
queue.Signal(fence, 4); queue.Signal(fence, 4);
@ -145,7 +148,8 @@ TEST_P(FenceTests, MultipleSignalOnCompletion) {
// Test callbacks still occur if Queue::Signal and fence::OnCompletion happens multiple times // Test callbacks still occur if Queue::Signal and fence::OnCompletion happens multiple times
TEST_P(FenceTests, SignalOnCompletionWait) { TEST_P(FenceTests, SignalOnCompletionWait) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
queue.Signal(fence, 6); queue.Signal(fence, 6);
@ -163,7 +167,8 @@ TEST_P(FenceTests, SignalOnCompletionWait) {
// Test callbacks still occur if Queue::Signal and fence::OnCompletion happens multiple times // Test callbacks still occur if Queue::Signal and fence::OnCompletion happens multiple times
TEST_P(FenceTests, SignalOnCompletionWaitStaggered) { TEST_P(FenceTests, SignalOnCompletionWaitStaggered) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
@ -182,7 +187,8 @@ TEST_P(FenceTests, SignalOnCompletionWaitStaggered) {
// Test all callbacks are called if they are added for the same fence value // Test all callbacks are called if they are added for the same fence value
TEST_P(FenceTests, OnCompletionMultipleCallbacks) { TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 4); queue.Signal(fence, 4);
@ -209,11 +215,13 @@ TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
// TODO(enga): Enable when fence is removed from fence signal tracker // TODO(enga): Enable when fence is removed from fence signal tracker
// Currently it holds a reference and is not destructed // Currently it holds a reference and is not destructed
TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) { TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
// The fence in this block will be deleted when it goes out of scope // The fence in this block will be deleted when it goes out of scope
{ {
wgpu::Fence testFence = queue.CreateFence(); wgpu::Fence testFence;
EXPECT_DEPRECATION_WARNING(testFence = queue.CreateFence());
queue.Signal(testFence, 4); queue.Signal(testFence, 4);
@ -247,7 +255,8 @@ TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
// Regression test that validation errors that are tracked client-side are captured // Regression test that validation errors that are tracked client-side are captured
// in error scopes. // in error scopes.
TEST_P(FenceTests, ClientValidationErrorInErrorScope) { TEST_P(FenceTests, ClientValidationErrorInErrorScope) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 4); queue.Signal(fence, 4);

View File

@ -85,7 +85,8 @@ TEST_P(QueueTimelineTests, MapReadSignalOnComplete) {
mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this); mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 1); queue.Signal(fence, 1);
fence.OnCompletion(1u, ToMockFenceOnCompletion, this); fence.OnCompletion(1u, ToMockFenceOnCompletion, this);
@ -119,7 +120,8 @@ TEST_P(QueueTimelineTests, SignalMapReadOnComplete) {
.Times(1); .Times(1);
EXPECT_CALL(*mockMapCallback, Call(WGPUBufferMapAsyncStatus_Success, this)).Times(1); EXPECT_CALL(*mockMapCallback, Call(WGPUBufferMapAsyncStatus_Success, this)).Times(1);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this); mMapReadBuffer.MapAsync(wgpu::MapMode::Read, 0, 0, ToMockMapCallback, this);
@ -154,7 +156,8 @@ TEST_P(QueueTimelineTests, SignalOnCompleteMapRead) {
.Times(1); .Times(1);
EXPECT_CALL(*mockMapCallback, Call(WGPUBufferMapAsyncStatus_Success, this)).Times(1); EXPECT_CALL(*mockMapCallback, Call(WGPUBufferMapAsyncStatus_Success, this)).Times(1);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
fence.OnCompletion(2u, ToMockFenceOnCompletion, this); fence.OnCompletion(2u, ToMockFenceOnCompletion, this);
@ -182,7 +185,8 @@ TEST_P(QueueTimelineTests, SurroundWithFenceSignals) {
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 8)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 8))
.Times(1); .Times(1);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 2); queue.Signal(fence, 2);
queue.Signal(fence, 4); queue.Signal(fence, 4);

View File

@ -237,24 +237,31 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) {
mCpuTime = 0; mCpuTime = 0;
mRunning = true; mRunning = true;
wgpu::FenceDescriptor desc = {}; uint64_t finishedIterations = 0;
uint64_t signaledFenceValue = 0; uint64_t submittedIterations = 0;
wgpu::Fence fence = mTest->queue.CreateFence(&desc);
mTimer->Start(); mTimer->Start();
// This loop can be canceled by calling AbortTest(). // This loop can be canceled by calling AbortTest().
while (mRunning) { while (mRunning) {
// Wait if there are too many steps in flight on the GPU. // Wait if there are too many steps in flight on the GPU.
while (signaledFenceValue - fence.GetCompletedValue() >= mMaxStepsInFlight) { while (submittedIterations - finishedIterations >= mMaxStepsInFlight) {
mTest->WaitABit(); mTest->WaitABit();
} }
TRACE_EVENT0(platform, General, "Step"); TRACE_EVENT0(platform, General, "Step");
double stepStart = mTimer->GetElapsedTime(); double stepStart = mTimer->GetElapsedTime();
Step(); Step();
mCpuTime += mTimer->GetElapsedTime() - stepStart; mCpuTime += mTimer->GetElapsedTime() - stepStart;
mTest->queue.Signal(fence, ++signaledFenceValue); submittedIterations++;
mTest->queue.OnSubmittedWorkDone(
0u,
[](WGPUQueueWorkDoneStatus, void* userdata) {
uint64_t* counter = static_cast<uint64_t*>(userdata);
(*counter)++;
},
&finishedIterations);
if (mRunning) { if (mRunning) {
++mNumStepsPerformed; ++mNumStepsPerformed;
@ -270,7 +277,7 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) {
// TODO(enga): When Dawn has multiple backgrounds threads, add a Device::WaitForIdleForTesting() // TODO(enga): When Dawn has multiple backgrounds threads, add a Device::WaitForIdleForTesting()
// which waits for all threads to stop doing work. When we output results, there should // which waits for all threads to stop doing work. When we output results, there should
// be no additional incoming trace events. // be no additional incoming trace events.
while (signaledFenceValue != fence.GetCompletedValue()) { while (submittedIterations != finishedIterations) {
mTest->WaitABit(); mTest->WaitABit();
} }

View File

@ -149,7 +149,8 @@ TEST_F(ErrorScopeValidationTest, EnclosedQueueSubmit) {
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 1); queue.Signal(fence, 1);
testing::Sequence seq; testing::Sequence seq;
@ -174,7 +175,8 @@ TEST_F(ErrorScopeValidationTest, EnclosedQueueSubmitNested) {
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory); device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
queue.Signal(fence, 1); queue.Signal(fence, 1);
testing::Sequence seq; testing::Sequence seq;

View File

@ -70,13 +70,14 @@ TEST_F(FenceValidationTest, CreationSuccess) {
{ {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 0; descriptor.initialValue = 0;
queue.CreateFence(&descriptor); EXPECT_DEPRECATION_WARNING(queue.CreateFence(&descriptor));
} }
} }
// Creation succeeds if no descriptor is provided // Creation succeeds if no descriptor is provided
TEST_F(FenceValidationTest, DefaultDescriptor) { TEST_F(FenceValidationTest, DefaultDescriptor) {
wgpu::Fence fence = queue.CreateFence(); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence());
EXPECT_EQ(fence.GetCompletedValue(), 0u); EXPECT_EQ(fence.GetCompletedValue(), 0u);
} }
@ -85,7 +86,8 @@ TEST_F(FenceValidationTest, GetCompletedValue) {
{ {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
EXPECT_EQ(fence.GetCompletedValue(), 1u); EXPECT_EQ(fence.GetCompletedValue(), 1u);
} }
} }
@ -99,7 +101,8 @@ TEST_F(FenceValidationTest, OnCompletionImmediate) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 0)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Success, this + 0))
.Times(1); .Times(1);
@ -114,7 +117,8 @@ TEST_F(FenceValidationTest, OnCompletionImmediate) {
TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) { TEST_F(FenceValidationTest, OnCompletionLargerThanSignaled) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
// Cannot signal for values > signaled value // Cannot signal for values > signaled value
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, nullptr)) EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_Error, nullptr))
@ -137,7 +141,8 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
queue.Signal(fence, 3); queue.Signal(fence, 3);
fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr); fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr);
@ -152,7 +157,8 @@ TEST_F(FenceValidationTest, GetCompletedValueInsideCallback) {
TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) { TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
queue.Signal(fence, 2); queue.Signal(fence, 2);
fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr); fence.OnCompletion(2u, ToMockFenceOnCompletion, nullptr);
@ -166,7 +172,8 @@ TEST_F(FenceValidationTest, GetCompletedValueAfterCallback) {
TEST_F(FenceValidationTest, SignalError) { TEST_F(FenceValidationTest, SignalError) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
// value < fence signaled value // value < fence signaled value
ASSERT_DEVICE_ERROR(queue.Signal(fence, 0)); ASSERT_DEVICE_ERROR(queue.Signal(fence, 0));
@ -178,7 +185,8 @@ TEST_F(FenceValidationTest, SignalError) {
TEST_F(FenceValidationTest, SignalSuccess) { TEST_F(FenceValidationTest, SignalSuccess) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
// Success // Success
queue.Signal(fence, 2); queue.Signal(fence, 2);
@ -198,7 +206,8 @@ TEST_F(FenceValidationTest, DISABLED_SignalWrongQueue) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2)); ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2));
} }
@ -210,7 +219,8 @@ TEST_F(FenceValidationTest, DISABLED_SignalWrongQueueDoesNotUpdateValue) {
wgpu::FenceDescriptor descriptor; wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1; descriptor.initialValue = 1;
wgpu::Fence fence = queue.CreateFence(&descriptor); wgpu::Fence fence;
EXPECT_DEPRECATION_WARNING(fence = queue.CreateFence(&descriptor));
ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2)); ASSERT_DEVICE_ERROR(queue2.Signal(fence, 2));

View File

@ -131,12 +131,13 @@ void ValidationTest::FlushWire() {
} }
void ValidationTest::WaitForAllOperations(const wgpu::Device& device) { void ValidationTest::WaitForAllOperations(const wgpu::Device& device) {
wgpu::Queue queue = device.GetQueue(); bool done = false;
wgpu::Fence fence = queue.CreateFence(); device.GetQueue().OnSubmittedWorkDone(
0u, [](WGPUQueueWorkDoneStatus, void* userdata) { *static_cast<bool*>(userdata) = true; },
&done);
// Force the currently submitted operations to completed. // Force the currently submitted operations to completed.
queue.Signal(fence, 1); while (!done) {
while (fence.GetCompletedValue() < 1) {
device.Tick(); device.Tick();
FlushWire(); FlushWire();
} }