Add trace events on the creation of shader module and pipeline

This patch adds trace events on the creation of shader module,
render pipeline and compute pipeline so that we can measure how
expensive these tasks are in chrome://tracing

BUG=dawn:1167

Change-Id: Iffc37adea49d7e04b9f757bc8b3679769085a428
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67880
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2021-11-02 03:07:52 +00:00 committed by Dawn LUCI CQ
parent 0040f77f0b
commit b78e8fb8f6
2 changed files with 20 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#include "dawn_native/ComputePipeline.h" #include "dawn_native/ComputePipeline.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
#include "dawn_native/RenderPipeline.h" #include "dawn_native/RenderPipeline.h"
#include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
namespace dawn_native { namespace dawn_native {
@ -112,6 +114,10 @@ namespace dawn_native {
} }
void CreateComputePipelineAsyncTask::Run() { void CreateComputePipelineAsyncTask::Run() {
TRACE_EVENT_FLOW_END0(mComputePipeline->GetDevice()->GetPlatform(), General,
"CreateComputePipelineAsyncTask::RunAsync", this);
TRACE_EVENT0(mComputePipeline->GetDevice()->GetPlatform(), General,
"CreateComputePipelineAsyncTask::Run");
MaybeError maybeError = mComputePipeline->Initialize(); MaybeError maybeError = mComputePipeline->Initialize();
std::string errorMessage; std::string errorMessage;
if (maybeError.IsError()) { if (maybeError.IsError()) {
@ -134,6 +140,8 @@ namespace dawn_native {
std::unique_ptr<CreateComputePipelineAsyncTask> innnerTaskPtr(taskPtr); std::unique_ptr<CreateComputePipelineAsyncTask> innnerTaskPtr(taskPtr);
innnerTaskPtr->Run(); innnerTaskPtr->Run();
}; };
TRACE_EVENT_FLOW_BEGIN0(device->GetPlatform(), General,
"CreateComputePipelineAsyncTask::RunAsync", task.get());
device->GetAsyncTaskManager()->PostTask(std::move(asyncTask)); device->GetAsyncTaskManager()->PostTask(std::move(asyncTask));
} }
@ -148,6 +156,10 @@ namespace dawn_native {
} }
void CreateRenderPipelineAsyncTask::Run() { void CreateRenderPipelineAsyncTask::Run() {
TRACE_EVENT_FLOW_END0(mRenderPipeline->GetDevice()->GetPlatform(), General,
"CreateRenderPipelineAsyncTask::RunAsync", this);
TRACE_EVENT0(mRenderPipeline->GetDevice()->GetPlatform(), General,
"CreateRenderPipelineAsyncTask::Run");
MaybeError maybeError = mRenderPipeline->Initialize(); MaybeError maybeError = mRenderPipeline->Initialize();
std::string errorMessage; std::string errorMessage;
if (maybeError.IsError()) { if (maybeError.IsError()) {
@ -170,6 +182,8 @@ namespace dawn_native {
std::unique_ptr<CreateRenderPipelineAsyncTask> innerTaskPtr(taskPtr); std::unique_ptr<CreateRenderPipelineAsyncTask> innerTaskPtr(taskPtr);
innerTaskPtr->Run(); innerTaskPtr->Run();
}; };
TRACE_EVENT_FLOW_BEGIN0(device->GetPlatform(), General,
"CreateRenderPipelineAsyncTask::RunAsync", task.get());
device->GetAsyncTaskManager()->PostTask(std::move(asyncTask)); device->GetAsyncTaskManager()->PostTask(std::move(asyncTask));
} }
} // namespace dawn_native } // namespace dawn_native

View File

@ -44,6 +44,7 @@
#include "dawn_native/Texture.h" #include "dawn_native/Texture.h"
#include "dawn_native/ValidationUtils_autogen.h" #include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_platform/DawnPlatform.h" #include "dawn_platform/DawnPlatform.h"
#include "dawn_platform/tracing/TraceEvent.h"
#include <array> #include <array>
#include <mutex> #include <mutex>
@ -897,6 +898,7 @@ namespace dawn_native {
} }
ComputePipelineBase* DeviceBase::APICreateComputePipeline( ComputePipelineBase* DeviceBase::APICreateComputePipeline(
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {
TRACE_EVENT0(GetPlatform(), General, "DeviceBase::APICreateComputePipeline");
Ref<ComputePipelineBase> result; Ref<ComputePipelineBase> result;
if (ConsumedError(CreateComputePipeline(descriptor), &result, if (ConsumedError(CreateComputePipeline(descriptor), &result,
"calling CreateComputePipeline(%s).", descriptor)) { "calling CreateComputePipeline(%s).", descriptor)) {
@ -907,6 +909,7 @@ namespace dawn_native {
void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor, void DeviceBase::APICreateComputePipelineAsync(const ComputePipelineDescriptor* descriptor,
WGPUCreateComputePipelineAsyncCallback callback, WGPUCreateComputePipelineAsyncCallback callback,
void* userdata) { void* userdata) {
TRACE_EVENT0(GetPlatform(), General, "DeviceBase::APICreateComputePipelineAsync");
MaybeError maybeResult = CreateComputePipelineAsync(descriptor, callback, userdata); MaybeError maybeResult = CreateComputePipelineAsync(descriptor, callback, userdata);
// Call the callback directly when a validation error has been found in the front-end // Call the callback directly when a validation error has been found in the front-end
@ -946,6 +949,7 @@ namespace dawn_native {
void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor, void DeviceBase::APICreateRenderPipelineAsync(const RenderPipelineDescriptor* descriptor,
WGPUCreateRenderPipelineAsyncCallback callback, WGPUCreateRenderPipelineAsyncCallback callback,
void* userdata) { void* userdata) {
TRACE_EVENT0(GetPlatform(), General, "DeviceBase::APICreateRenderPipelineAsync");
// TODO(dawn:563): Add validation error context. // TODO(dawn:563): Add validation error context.
MaybeError maybeResult = CreateRenderPipelineAsync(descriptor, callback, userdata); MaybeError maybeResult = CreateRenderPipelineAsync(descriptor, callback, userdata);
@ -969,6 +973,7 @@ namespace dawn_native {
} }
RenderPipelineBase* DeviceBase::APICreateRenderPipeline( RenderPipelineBase* DeviceBase::APICreateRenderPipeline(
const RenderPipelineDescriptor* descriptor) { const RenderPipelineDescriptor* descriptor) {
TRACE_EVENT0(GetPlatform(), General, "DeviceBase::APICreateRenderPipeline");
Ref<RenderPipelineBase> result; Ref<RenderPipelineBase> result;
if (ConsumedError(CreateRenderPipeline(descriptor), &result, if (ConsumedError(CreateRenderPipeline(descriptor), &result,
"calling CreateRenderPipeline(%s).", descriptor)) { "calling CreateRenderPipeline(%s).", descriptor)) {
@ -977,6 +982,7 @@ namespace dawn_native {
return result.Detach(); return result.Detach();
} }
ShaderModuleBase* DeviceBase::APICreateShaderModule(const ShaderModuleDescriptor* descriptor) { ShaderModuleBase* DeviceBase::APICreateShaderModule(const ShaderModuleDescriptor* descriptor) {
TRACE_EVENT0(GetPlatform(), General, "DeviceBase::APICreateShaderModule");
Ref<ShaderModuleBase> result; Ref<ShaderModuleBase> result;
std::unique_ptr<OwnedCompilationMessages> compilationMessages( std::unique_ptr<OwnedCompilationMessages> compilationMessages(
std::make_unique<OwnedCompilationMessages>()); std::make_unique<OwnedCompilationMessages>());