Commit c9779e46 authored by Brandon Jones's avatar Brandon Jones Committed by Commit Bot

Avoid Polling Dawn When Possible

When Tick() returns false, it means there is no need to call tick
further. This commit changes chromium to only call tick when there
is polling work to be done.

Bug: dawn:119
Bug: chromium:940985
Change-Id: I792837b83f4d0da1d478e3876c9a2af8b1505c2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485037
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826740}
parent fdde6d10
...@@ -145,6 +145,7 @@ class DawnDeviceAndWireServer { ...@@ -145,6 +145,7 @@ class DawnDeviceAndWireServer {
~DawnDeviceAndWireServer(); ~DawnDeviceAndWireServer();
WGPUDevice GetWGPUDevice() const; WGPUDevice GetWGPUDevice() const;
bool HasPollingWork() const;
void PerformPollingWork(); void PerformPollingWork();
error::Error HandleDawnCommands(const volatile char* dawn_commands, error::Error HandleDawnCommands(const volatile char* dawn_commands,
size_t size); size_t size);
...@@ -176,6 +177,8 @@ class DawnDeviceAndWireServer { ...@@ -176,6 +177,8 @@ class DawnDeviceAndWireServer {
base::flat_map<std::tuple<uint32_t, uint32_t>, base::flat_map<std::tuple<uint32_t, uint32_t>,
std::unique_ptr<SharedImageRepresentationAndAccess>> std::unique_ptr<SharedImageRepresentationAndAccess>>
associated_shared_image_map_; associated_shared_image_map_;
bool has_polling_work_ = false;
}; };
DawnDeviceAndWireServer::DawnDeviceAndWireServer( DawnDeviceAndWireServer::DawnDeviceAndWireServer(
...@@ -215,7 +218,7 @@ WGPUDevice DawnDeviceAndWireServer::GetWGPUDevice() const { ...@@ -215,7 +218,7 @@ WGPUDevice DawnDeviceAndWireServer::GetWGPUDevice() const {
} }
void DawnDeviceAndWireServer::PerformPollingWork() { void DawnDeviceAndWireServer::PerformPollingWork() {
dawn_procs_.deviceTick(wgpu_device_); has_polling_work_ = dawn_native::DeviceTick(wgpu_device_);
wire_serializer_->Flush(); wire_serializer_->Flush();
} }
...@@ -226,6 +229,7 @@ error::Error DawnDeviceAndWireServer::HandleDawnCommands( ...@@ -226,6 +229,7 @@ error::Error DawnDeviceAndWireServer::HandleDawnCommands(
NOTREACHED(); NOTREACHED();
return error::kLostContext; return error::kLostContext;
} }
has_polling_work_ = dawn_native::DeviceTick(wgpu_device_);
wire_serializer_->Flush(); wire_serializer_->Flush();
return error::kNoError; return error::kNoError;
} }
...@@ -305,6 +309,10 @@ error::Error DawnDeviceAndWireServer::DissociateMailbox( ...@@ -305,6 +309,10 @@ error::Error DawnDeviceAndWireServer::DissociateMailbox(
return error::kNoError; return error::kNoError;
} }
bool DawnDeviceAndWireServer::HasPollingWork() const {
return has_polling_work_;
}
} // namespace } // namespace
class WebGPUDecoderImpl final : public WebGPUDecoder { class WebGPUDecoderImpl final : public WebGPUDecoder {
...@@ -383,9 +391,14 @@ class WebGPUDecoderImpl final : public WebGPUDecoder { ...@@ -383,9 +391,14 @@ class WebGPUDecoderImpl final : public WebGPUDecoder {
bool HasMoreIdleWork() const override { return false; } bool HasMoreIdleWork() const override { return false; }
void PerformIdleWork() override {} void PerformIdleWork() override {}
// TODO(crbug.com/940985): Optimize so that this only returns true when bool HasPollingWork() const override {
// deviceTick is needed. for (auto& iter : dawn_device_and_wire_servers_) {
bool HasPollingWork() const override { return true; } if (iter.second->HasPollingWork()) {
return true;
}
}
return false;
}
void PerformPollingWork() override { void PerformPollingWork() override {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.dawn"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment