mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-08 07:33:33 +00:00
client: call pending GetCompilationInfo on Disconnect
Fixed: dawn:1090 Change-Id: Ia7cf692ea41ebe85aaac58e3f3aa6727e6cc8ba4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63002 Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Shrek Shao <shrekshao@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
ea487972d1
commit
52ad8f6768
@ -63,4 +63,14 @@ namespace dawn_wire { namespace client {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderModule::CancelCallbacksForDisconnect() {
|
||||||
|
for (auto& it : mCompilationInfoRequests) {
|
||||||
|
if (it.second.callback) {
|
||||||
|
it.second.callback(WGPUCompilationInfoRequestStatus_DeviceLost, nullptr,
|
||||||
|
it.second.userdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mCompilationInfoRequests.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace dawn_wire::client
|
}} // namespace dawn_wire::client
|
||||||
|
@ -32,6 +32,8 @@ namespace dawn_wire { namespace client {
|
|||||||
WGPUCompilationInfoRequestStatus status,
|
WGPUCompilationInfoRequestStatus status,
|
||||||
const WGPUCompilationInfo* info);
|
const WGPUCompilationInfo* info);
|
||||||
|
|
||||||
|
void CancelCallbacksForDisconnect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CompilationInfoRequest {
|
struct CompilationInfoRequest {
|
||||||
WGPUCompilationInfoCallback callback = nullptr;
|
WGPUCompilationInfoCallback callback = nullptr;
|
||||||
|
@ -118,3 +118,34 @@ TEST_F(WireShaderModuleTests, GetCompilationInfo) {
|
|||||||
.Times(1);
|
.Times(1);
|
||||||
FlushServer();
|
FlushServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that calling GetCompilationInfo then disconnecting the wire calls the callback with a device
|
||||||
|
// loss.
|
||||||
|
TEST_F(WireShaderModuleTests, GetCompilationInfoBeforeDisconnect) {
|
||||||
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
||||||
|
|
||||||
|
WGPUCompilationMessage message = {"Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
||||||
|
WGPUCompilationInfo compilationInfo;
|
||||||
|
compilationInfo.messageCount = 1;
|
||||||
|
compilationInfo.messages = &message;
|
||||||
|
|
||||||
|
EXPECT_CALL(api, OnShaderModuleGetCompilationInfo(apiShaderModule, _, _))
|
||||||
|
.WillOnce(InvokeWithoutArgs([&]() {
|
||||||
|
api.CallShaderModuleGetCompilationInfoCallback(
|
||||||
|
apiShaderModule, WGPUCompilationInfoRequestStatus_Success, &compilationInfo);
|
||||||
|
}));
|
||||||
|
FlushClient();
|
||||||
|
|
||||||
|
EXPECT_CALL(*mockCompilationInfoCallback,
|
||||||
|
Call(WGPUCompilationInfoRequestStatus_DeviceLost, nullptr, _));
|
||||||
|
GetWireClient()->Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that calling GetCompilationInfo after disconnecting the wire calls the callback with a
|
||||||
|
// device loss.
|
||||||
|
TEST_F(WireShaderModuleTests, GetCompilationInfoAfterDisconnect) {
|
||||||
|
GetWireClient()->Disconnect();
|
||||||
|
EXPECT_CALL(*mockCompilationInfoCallback,
|
||||||
|
Call(WGPUCompilationInfoRequestStatus_DeviceLost, nullptr, _));
|
||||||
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user