mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 04:11:25 +00:00
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>
70 lines
2.4 KiB
C++
70 lines
2.4 KiB
C++
// Copyright 2018 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "tests/unittests/validation/ValidationTest.h"
|
|
|
|
#include "utils/WGPUHelpers.h"
|
|
|
|
namespace {
|
|
|
|
class QueueSubmitValidationTest : public ValidationTest {
|
|
};
|
|
|
|
static void StoreTrueMapWriteCallback(WGPUBufferMapAsyncStatus status,
|
|
void*,
|
|
uint64_t,
|
|
void* userdata) {
|
|
*static_cast<bool*>(userdata) = true;
|
|
}
|
|
|
|
// Test submitting with a mapped buffer is disallowed
|
|
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
|
// Create a map-write buffer.
|
|
wgpu::BufferDescriptor descriptor;
|
|
descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
|
|
descriptor.size = 4;
|
|
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
|
|
|
// Create a fake copy destination buffer
|
|
descriptor.usage = wgpu::BufferUsage::CopyDst;
|
|
wgpu::Buffer targetBuffer = device.CreateBuffer(&descriptor);
|
|
|
|
// Create a command buffer that reads from the mappable buffer.
|
|
wgpu::CommandBuffer commands;
|
|
{
|
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
encoder.CopyBufferToBuffer(buffer, 0, targetBuffer, 0, 4);
|
|
commands = encoder.Finish();
|
|
}
|
|
|
|
wgpu::Queue queue = device.GetDefaultQueue();
|
|
|
|
// Submitting when the buffer has never been mapped should succeed
|
|
queue.Submit(1, &commands);
|
|
|
|
// Map the buffer, submitting when the buffer is mapped should fail
|
|
bool mapWriteFinished = false;
|
|
buffer.MapWriteAsync(StoreTrueMapWriteCallback, &mapWriteFinished);
|
|
queue.Submit(0, nullptr);
|
|
ASSERT_TRUE(mapWriteFinished);
|
|
|
|
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
|
|
|
// Unmap the buffer, queue submit should succeed
|
|
buffer.Unmap();
|
|
queue.Submit(1, &commands);
|
|
}
|
|
|
|
} // anonymous namespace
|