mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
dawn_wire: Reject new callbacks if the client is disconnected
If the wire client is disconnected, it will not receive any messages from the server. Reject all callbacks that are created. Bug: dawn:556 Change-Id: I2eb2c449b1ca6c8ea3e74040ef095abfc46a9061 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31161 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
01e969da33
commit
7ceffe8511
@@ -692,3 +692,12 @@ TEST_F(WireBufferMappingTests, MapThenDisconnect) {
|
||||
EXPECT_CALL(*mockBufferMapCallback, Call(WGPUBufferMapAsyncStatus_DeviceLost, this)).Times(1);
|
||||
GetWireClient()->Disconnect();
|
||||
}
|
||||
|
||||
// Test that registering a callback after wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireBufferMappingTests, MapAfterDisconnect) {
|
||||
GetWireClient()->Disconnect();
|
||||
|
||||
EXPECT_CALL(*mockBufferMapCallback, Call(WGPUBufferMapAsyncStatus_DeviceLost, this)).Times(1);
|
||||
wgpuBufferMapAsync(buffer, WGPUMapMode_Read, 0, kBufferSize, ToMockBufferMapCallback, this);
|
||||
}
|
||||
|
||||
@@ -276,3 +276,55 @@ TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineThenDisconnect) {
|
||||
.Times(1);
|
||||
GetWireClient()->Disconnect();
|
||||
}
|
||||
|
||||
// Test that registering a callback after wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyRenderPipelineAfterDisconnect) {
|
||||
WGPUShaderModuleDescriptor vertexDescriptor = {};
|
||||
WGPUShaderModule vsModule = wgpuDeviceCreateShaderModule(device, &vertexDescriptor);
|
||||
WGPUShaderModule apiVsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
|
||||
|
||||
WGPUProgrammableStageDescriptor fragmentStage = {};
|
||||
fragmentStage.module = vsModule;
|
||||
fragmentStage.entryPoint = "main";
|
||||
|
||||
WGPURenderPipelineDescriptor pipelineDescriptor{};
|
||||
pipelineDescriptor.vertexStage.module = vsModule;
|
||||
pipelineDescriptor.vertexStage.entryPoint = "main";
|
||||
pipelineDescriptor.fragmentStage = &fragmentStage;
|
||||
|
||||
FlushClient();
|
||||
|
||||
GetWireClient()->Disconnect();
|
||||
|
||||
EXPECT_CALL(*mockCreateReadyRenderPipelineCallback,
|
||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, _, this))
|
||||
.Times(1);
|
||||
wgpuDeviceCreateReadyRenderPipeline(device, &pipelineDescriptor,
|
||||
ToMockCreateReadyRenderPipelineCallback, this);
|
||||
}
|
||||
|
||||
// Test that registering a callback after wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireCreateReadyPipelineTest, CreateReadyComputePipelineAfterDisconnect) {
|
||||
WGPUShaderModuleDescriptor csDescriptor{};
|
||||
WGPUShaderModule csModule = wgpuDeviceCreateShaderModule(device, &csDescriptor);
|
||||
WGPUShaderModule apiCsModule = api.GetNewShaderModule();
|
||||
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiCsModule));
|
||||
|
||||
WGPUComputePipelineDescriptor descriptor{};
|
||||
descriptor.computeStage.module = csModule;
|
||||
descriptor.computeStage.entryPoint = "main";
|
||||
|
||||
FlushClient();
|
||||
|
||||
GetWireClient()->Disconnect();
|
||||
|
||||
EXPECT_CALL(*mockCreateReadyComputePipelineCallback,
|
||||
Call(WGPUCreateReadyPipelineStatus_DeviceLost, nullptr, _, this))
|
||||
.Times(1);
|
||||
|
||||
wgpuDeviceCreateReadyComputePipeline(device, &descriptor,
|
||||
ToMockCreateReadyComputePipelineCallback, this);
|
||||
}
|
||||
|
||||
@@ -235,6 +235,22 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeThenDisconnect) {
|
||||
GetWireClient()->Disconnect();
|
||||
}
|
||||
|
||||
// Test that registering a callback after wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireErrorCallbackTests, PopErrorScopeAfterDisconnect) {
|
||||
wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
|
||||
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
|
||||
|
||||
FlushClient();
|
||||
|
||||
GetWireClient()->Disconnect();
|
||||
|
||||
EXPECT_CALL(*mockDevicePopErrorScopeCallback,
|
||||
Call(WGPUErrorType_DeviceLost, ValidStringMessage(), this))
|
||||
.Times(1);
|
||||
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
|
||||
}
|
||||
|
||||
// Test that PopErrorScope returns false if there are no error scopes.
|
||||
TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) {
|
||||
// Empty stack
|
||||
|
||||
@@ -160,6 +160,16 @@ TEST_F(WireFenceTests, OnCompletionThenDisconnect) {
|
||||
GetWireClient()->Disconnect();
|
||||
}
|
||||
|
||||
// Test that registering a callback after wire disconnect calls the callback with
|
||||
// DeviceLost.
|
||||
TEST_F(WireFenceTests, OnCompletionAfterDisconnect) {
|
||||
GetWireClient()->Disconnect();
|
||||
|
||||
EXPECT_CALL(*mockFenceOnCompletionCallback, Call(WGPUFenceCompletionStatus_DeviceLost, this))
|
||||
.Times(1);
|
||||
wgpuFenceOnCompletion(fence, 0, ToMockFenceOnCompletionCallback, this);
|
||||
}
|
||||
|
||||
// Without any flushes, it is valid to wait on a value less than or equal to
|
||||
// the last signaled value
|
||||
TEST_F(WireFenceTests, OnCompletionSynchronousValidationSuccess) {
|
||||
|
||||
Reference in New Issue
Block a user