Introduce Device::GetDefaultQueue and deprecate CreateQueue

This makes all backends register the default queue at device
initialization time, so that the same queue is returned by
each call to GetDefaultQueue.

All usages of CreateQueue are replaced by GetDefaultQueue
except a couple ones that could use the queue initialized by
DawnTest::SetUp.

A deprecation warning mechanism is added so that users of Dawn
can now that they should upgrade their usage of the API. It also
comes with a backdoor so we can test that they are emitted.

New DeprecatedAPITests are added that will contain tests for
deprecated APIs, and will also check that deprecation warnings
are produced.

The special casing of GetDefaultQueue in the wire will be done
in a follow-up CL to ease the review. It happens to work through
the regular wire mechanisms at the moment but returns a different
object on each GetDefaultQueue call.

Bug: dawn:22

Change-Id: I78dc1fa474769674278d30040e8d05c658b88360
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19724
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-17 16:45:17 +00:00
committed by Commit Bot service account
parent 9f5a1c5141
commit 8a437947a8
40 changed files with 206 additions and 106 deletions

View File

@@ -98,7 +98,7 @@ class BufferValidationTest : public ValidationTest {
mockBufferMapReadCallback = std::make_unique<MockBufferMapReadCallback>();
mockBufferMapWriteCallback = std::make_unique<MockBufferMapWriteCallback>();
queue = device.CreateQueue();
queue = device.GetDefaultQueue();
}
void TearDown() override {

View File

@@ -134,7 +134,7 @@ TEST_F(ErrorScopeValidationTest, PushPopBalanced) {
// Test that error scopes do not call their callbacks until after an enclosed Queue::Submit
// completes
TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmit) {
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = device.GetDefaultQueue();
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr);
@@ -149,7 +149,7 @@ TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmit) {
// Test that parent error scopes do not call their callbacks until after an enclosed Queue::Submit
// completes
TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmitNested) {
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = device.GetDefaultQueue();
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
@@ -167,7 +167,7 @@ TEST_F(ErrorScopeValidationTest, CallbackAfterQueueSubmitNested) {
// Test a callback that returns asynchronously followed by a synchronous one
TEST_F(ErrorScopeValidationTest, AsynchronousThenSynchronous) {
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = device.GetDefaultQueue();
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr);
@@ -187,7 +187,7 @@ TEST_F(ErrorScopeValidationTest, AsynchronousThenSynchronous) {
// Test that if the device is destroyed before the callback occurs, it is called with NoError
// because all previous operations are waited upon before the destruction returns.
TEST_F(ErrorScopeValidationTest, DeviceDestroyedBeforeCallback) {
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = device.GetDefaultQueue();
device.PushErrorScope(wgpu::ErrorFilter::OutOfMemory);
queue.Submit(0, nullptr);

View File

@@ -57,7 +57,7 @@ class FenceValidationTest : public ValidationTest {
ValidationTest::SetUp();
mockFenceOnCompletionCallback = std::make_unique<MockFenceOnCompletionCallback>();
queue = device.CreateQueue();
queue = device.GetDefaultQueue();
}
void TearDown() override {
@@ -182,8 +182,9 @@ TEST_F(FenceValidationTest, SignalSuccess) {
}
// Test it is invalid to signal a fence on a different queue than it was created on
TEST_F(FenceValidationTest, SignalWrongQueue) {
wgpu::Queue queue2 = device.CreateQueue();
// DISABLED until we have support for multiple queues
TEST_F(FenceValidationTest, DISABLED_SignalWrongQueue) {
wgpu::Queue queue2 = device.GetDefaultQueue();
wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1;
@@ -193,8 +194,9 @@ TEST_F(FenceValidationTest, SignalWrongQueue) {
}
// Test that signaling a fence on a wrong queue does not update fence signaled value
TEST_F(FenceValidationTest, SignalWrongQueueDoesNotUpdateValue) {
wgpu::Queue queue2 = device.CreateQueue();
// DISABLED until we have support for multiple queues
TEST_F(FenceValidationTest, DISABLED_SignalWrongQueueDoesNotUpdateValue) {
wgpu::Queue queue2 = device.GetDefaultQueue();
wgpu::FenceDescriptor descriptor;
descriptor.initialValue = 1;

View File

@@ -48,7 +48,7 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
commands = encoder.Finish();
}
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue = device.GetDefaultQueue();
// Submitting when the buffer has never been mapped should succeed
queue.Submit(1, &commands);

View File

@@ -23,6 +23,10 @@ namespace {
class TextureValidationTest : public ValidationTest {
protected:
void SetUp() override {
queue = device.GetDefaultQueue();
}
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
wgpu::TextureDescriptor descriptor;
descriptor.size.width = kWidth;
@@ -37,7 +41,7 @@ class TextureValidationTest : public ValidationTest {
return descriptor;
}
wgpu::Queue queue = device.CreateQueue();
wgpu::Queue queue;
private:
static constexpr uint32_t kWidth = 32;