mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
Nuke the ClientMatches hack for same-device validation
The wire now supports more than one device, and Chrome is updated to use the new code path. This fixes same-device validation for createReadyPipeline. Bug: dawn:565 Change-Id: Id05001ed1a7e535690c87f535da6f72a0e794c59 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40460 Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
fb2e77106a
commit
05d9e2cde2
80
src/tests/unittests/validation/MultipleDeviceTests.cpp
Normal file
80
src/tests/unittests/validation/MultipleDeviceTests.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright 2021 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 "tests/MockCallback.h"
|
||||
|
||||
using namespace testing;
|
||||
|
||||
class MultipleDeviceTest : public ValidationTest {};
|
||||
|
||||
// Test that it is invalid to submit a command buffer created on a different device.
|
||||
TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
|
||||
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
||||
wgpu::CommandBuffer commandBuffer = device2.CreateCommandEncoder().Finish();
|
||||
|
||||
ASSERT_DEVICE_ERROR(device.GetQueue().Submit(1, &commandBuffer));
|
||||
}
|
||||
|
||||
// Test that CreateReadyPipeline fails creation with an Error status if it uses
|
||||
// objects from a different device.
|
||||
TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreateReadyPipeline) {
|
||||
wgpu::ShaderModuleWGSLDescriptor wgslDesc = {};
|
||||
wgslDesc.source = R"(
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
}
|
||||
)";
|
||||
|
||||
wgpu::ShaderModuleDescriptor shaderModuleDesc = {};
|
||||
shaderModuleDesc.nextInChain = &wgslDesc;
|
||||
|
||||
// Base case: CreateReadyComputePipeline succeeds.
|
||||
{
|
||||
wgpu::ShaderModule shaderModule = device.CreateShaderModule(&shaderModuleDesc);
|
||||
|
||||
wgpu::ComputePipelineDescriptor pipelineDesc = {};
|
||||
pipelineDesc.computeStage.module = shaderModule;
|
||||
pipelineDesc.computeStage.entryPoint = "main";
|
||||
|
||||
StrictMock<MockCallback<WGPUCreateReadyComputePipelineCallback>> creationCallback;
|
||||
EXPECT_CALL(creationCallback,
|
||||
Call(WGPUCreateReadyPipelineStatus_Success, NotNull(), _, this))
|
||||
.WillOnce(WithArg<1>(Invoke(
|
||||
[](WGPUComputePipeline pipeline) { wgpu::ComputePipeline::Acquire(pipeline); })));
|
||||
device.CreateReadyComputePipeline(&pipelineDesc, creationCallback.Callback(),
|
||||
creationCallback.MakeUserdata(this));
|
||||
|
||||
WaitForAllOperations(device);
|
||||
}
|
||||
|
||||
// CreateReadyComputePipeline errors if the shader module is created on a different device.
|
||||
{
|
||||
wgpu::Device device2 = RegisterDevice(CreateTestDevice());
|
||||
wgpu::ShaderModule shaderModule = device2.CreateShaderModule(&shaderModuleDesc);
|
||||
|
||||
wgpu::ComputePipelineDescriptor pipelineDesc = {};
|
||||
pipelineDesc.computeStage.module = shaderModule;
|
||||
pipelineDesc.computeStage.entryPoint = "main";
|
||||
|
||||
StrictMock<MockCallback<WGPUCreateReadyComputePipelineCallback>> creationCallback;
|
||||
EXPECT_CALL(creationCallback,
|
||||
Call(WGPUCreateReadyPipelineStatus_Error, nullptr, _, this + 1))
|
||||
.Times(1);
|
||||
device.CreateReadyComputePipeline(&pipelineDesc, creationCallback.Callback(),
|
||||
creationCallback.MakeUserdata(this + 1));
|
||||
|
||||
WaitForAllOperations(device);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user