mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-09 08:03:31 +00:00
Use enums for trace event categories
Explicit enums are simpler to use in Dawn and allow only specific categories which the perf tests understand. Also adds trace events around command recording and validation on all backends. Bug: dawn:208 Change-Id: I7859ffd6668b20893780c6081bf2c9019a7115e0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12781 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
7a7d547381
commit
73d5bb57e6
@ -27,6 +27,7 @@
|
|||||||
#include "dawn_native/PassResourceUsageTracker.h"
|
#include "dawn_native/PassResourceUsageTracker.h"
|
||||||
#include "dawn_native/RenderPassEncoder.h"
|
#include "dawn_native/RenderPassEncoder.h"
|
||||||
#include "dawn_native/RenderPipeline.h"
|
#include "dawn_native/RenderPipeline.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -706,8 +707,6 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) {
|
CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) {
|
||||||
TRACE_EVENT0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
|
||||||
"CommandEncoderBase::Finish");
|
|
||||||
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
|
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
|
||||||
// Even if finish validation fails, it is now invalid to call any encoding commands on
|
// Even if finish validation fails, it is now invalid to call any encoding commands on
|
||||||
// this object, so we set its state to finished.
|
// this object, so we set its state to finished.
|
||||||
@ -721,6 +720,7 @@ namespace dawn_native {
|
|||||||
// Implementation of the command buffer validation that can be precomputed before submit
|
// Implementation of the command buffer validation that can be precomputed before submit
|
||||||
|
|
||||||
MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) {
|
MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) {
|
||||||
|
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "CommandEncoderBase::ValidateFinish");
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
// Even if Finish() validation fails, calling it will mutate the internal state of the
|
// Even if Finish() validation fails, calling it will mutate the internal state of the
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "dawn_native/Fence.h"
|
#include "dawn_native/Fence.h"
|
||||||
#include "dawn_native/FenceSignalTracker.h"
|
#include "dawn_native/FenceSignalTracker.h"
|
||||||
#include "dawn_native/Texture.h"
|
#include "dawn_native/Texture.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
@ -33,7 +34,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
DeviceBase* device = GetDevice();
|
DeviceBase* device = GetDevice();
|
||||||
TRACE_EVENT0(device->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"), "Queue::Submit");
|
TRACE_EVENT0(device->GetPlatform(), General, "Queue::Submit");
|
||||||
if (device->ConsumedError(ValidateSubmit(commandCount, commands))) {
|
if (device->ConsumedError(ValidateSubmit(commandCount, commands))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,6 +70,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError QueueBase::ValidateSubmit(uint32_t commandCount,
|
MaybeError QueueBase::ValidateSubmit(uint32_t commandCount,
|
||||||
CommandBufferBase* const* commands) {
|
CommandBufferBase* const* commands) {
|
||||||
|
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "Queue::ValidateSubmit");
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include "dawn_native/Format.h"
|
#include "dawn_native/Format.h"
|
||||||
#include "dawn_native/RenderPipeline.h"
|
#include "dawn_native/RenderPipeline.h"
|
||||||
#include "dawn_native/ValidationUtils_autogen.h"
|
#include "dawn_native/ValidationUtils_autogen.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
|
|
||||||
@ -111,6 +113,8 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaybeError RenderBundleEncoderBase::ValidateFinish(const RenderBundleDescriptor* descriptor) {
|
MaybeError RenderBundleEncoderBase::ValidateFinish(const RenderBundleDescriptor* descriptor) {
|
||||||
|
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation,
|
||||||
|
"RenderBundleEncoderBase::ValidateFinish");
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
// Even if Finish() validation fails, calling it will mutate the internal state of the
|
// Even if Finish() validation fails, calling it will mutate the internal state of the
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "dawn_native/d3d12/CommandBufferD3D12.h"
|
#include "dawn_native/d3d12/CommandBufferD3D12.h"
|
||||||
#include "dawn_native/d3d12/D3D12Error.h"
|
#include "dawn_native/d3d12/D3D12Error.h"
|
||||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
@ -31,9 +33,13 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
CommandRecordingContext* commandContext;
|
CommandRecordingContext* commandContext;
|
||||||
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
|
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
|
||||||
|
|
||||||
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
||||||
|
"CommandBufferD3D12::RecordCommands");
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
DAWN_TRY(ToBackend(commands[i])->RecordCommands(commandContext, i));
|
DAWN_TRY(ToBackend(commands[i])->RecordCommands(commandContext, i));
|
||||||
}
|
}
|
||||||
|
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording,
|
||||||
|
"CommandBufferD3D12::RecordCommands");
|
||||||
|
|
||||||
DAWN_TRY(device->ExecutePendingCommandContext());
|
DAWN_TRY(device->ExecutePendingCommandContext());
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "dawn_native/metal/StagingBufferMTL.h"
|
#include "dawn_native/metal/StagingBufferMTL.h"
|
||||||
#include "dawn_native/metal/SwapChainMTL.h"
|
#include "dawn_native/metal/SwapChainMTL.h"
|
||||||
#include "dawn_native/metal/TextureMTL.h"
|
#include "dawn_native/metal/TextureMTL.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -180,8 +181,7 @@ namespace dawn_native { namespace metal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
|
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
|
||||||
TRACE_EVENT0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT0(GetPlatform(), General, "DeviceMTL::GetPendingCommandBuffer");
|
||||||
"DeviceMTL::GetPendingCommandBuffer");
|
|
||||||
if (mPendingCommands == nil) {
|
if (mPendingCommands == nil) {
|
||||||
mPendingCommands = [mCommandQueue commandBuffer];
|
mPendingCommands = [mCommandQueue commandBuffer];
|
||||||
[mPendingCommands retain];
|
[mPendingCommands retain];
|
||||||
@ -228,14 +228,14 @@ namespace dawn_native { namespace metal {
|
|||||||
// mLastSubmittedSerial so it is captured by value.
|
// mLastSubmittedSerial so it is captured by value.
|
||||||
Serial pendingSerial = mLastSubmittedSerial;
|
Serial pendingSerial = mLastSubmittedSerial;
|
||||||
[mPendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
|
[mPendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
|
||||||
TRACE_EVENT_ASYNC_END0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT_ASYNC_END0(GetPlatform(), GPUWork, "DeviceMTL::SubmitPendingCommandBuffer",
|
||||||
"DeviceMTL::SubmitPendingCommandBuffer", pendingSerial);
|
pendingSerial);
|
||||||
ASSERT(pendingSerial > mCompletedSerial.load());
|
ASSERT(pendingSerial > mCompletedSerial.load());
|
||||||
this->mCompletedSerial = pendingSerial;
|
this->mCompletedSerial = pendingSerial;
|
||||||
}];
|
}];
|
||||||
|
|
||||||
TRACE_EVENT_ASYNC_BEGIN0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT_ASYNC_BEGIN0(GetPlatform(), GPUWork, "DeviceMTL::SubmitPendingCommandBuffer",
|
||||||
"DeviceMTL::SubmitPendingCommandBuffer", pendingSerial);
|
pendingSerial);
|
||||||
[mPendingCommands commit];
|
[mPendingCommands commit];
|
||||||
mPendingCommands = nil;
|
mPendingCommands = nil;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "dawn_native/metal/CommandBufferMTL.h"
|
#include "dawn_native/metal/CommandBufferMTL.h"
|
||||||
#include "dawn_native/metal/DeviceMTL.h"
|
#include "dawn_native/metal/DeviceMTL.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace metal {
|
namespace dawn_native { namespace metal {
|
||||||
@ -28,13 +29,11 @@ namespace dawn_native { namespace metal {
|
|||||||
device->Tick();
|
device->Tick();
|
||||||
id<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
|
id<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
|
||||||
|
|
||||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
||||||
"CommandBufferMTL::FillCommands");
|
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
ToBackend(commands[i])->FillCommands(commandBuffer);
|
ToBackend(commands[i])->FillCommands(commandBuffer);
|
||||||
}
|
}
|
||||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
||||||
"CommandBufferMTL::FillCommands");
|
|
||||||
|
|
||||||
device->SubmitPendingCommandBuffer();
|
device->SubmitPendingCommandBuffer();
|
||||||
return {};
|
return {};
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "dawn_native/opengl/CommandBufferGL.h"
|
#include "dawn_native/opengl/CommandBufferGL.h"
|
||||||
#include "dawn_native/opengl/DeviceGL.h"
|
#include "dawn_native/opengl/DeviceGL.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace opengl {
|
namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
@ -25,9 +27,11 @@ namespace dawn_native { namespace opengl {
|
|||||||
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
ToBackend(commands[i])->Execute();
|
ToBackend(commands[i])->Execute();
|
||||||
}
|
}
|
||||||
|
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
|
||||||
|
|
||||||
device->SubmitFenceSync();
|
device->SubmitFenceSync();
|
||||||
return {};
|
return {};
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "dawn_native/vulkan/CommandBufferVk.h"
|
#include "dawn_native/vulkan/CommandBufferVk.h"
|
||||||
#include "dawn_native/vulkan/CommandRecordingContext.h"
|
#include "dawn_native/vulkan/CommandRecordingContext.h"
|
||||||
#include "dawn_native/vulkan/DeviceVk.h"
|
#include "dawn_native/vulkan/DeviceVk.h"
|
||||||
|
#include "dawn_platform/DawnPlatform.h"
|
||||||
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
|
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
@ -33,10 +35,13 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
device->Tick();
|
device->Tick();
|
||||||
|
|
||||||
|
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
||||||
|
"CommandBufferVk::RecordCommands");
|
||||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||||
DAWN_TRY(ToBackend(commands[i])->RecordCommands(recordingContext));
|
DAWN_TRY(ToBackend(commands[i])->RecordCommands(recordingContext));
|
||||||
}
|
}
|
||||||
|
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferVk::RecordCommands");
|
||||||
|
|
||||||
DAWN_TRY(device->SubmitPendingCommands());
|
DAWN_TRY(device->SubmitPendingCommands());
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
|
|
||||||
namespace dawn_platform { namespace tracing {
|
namespace dawn_platform { namespace tracing {
|
||||||
|
|
||||||
const unsigned char* GetTraceCategoryEnabledFlag(Platform* platform, const char* name) {
|
const unsigned char* GetTraceCategoryEnabledFlag(Platform* platform, TraceCategory category) {
|
||||||
static unsigned char disabled = 0;
|
static unsigned char disabled = 0;
|
||||||
if (platform == nullptr) {
|
if (platform == nullptr) {
|
||||||
return &disabled;
|
return &disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char* categoryEnabledFlag = platform->GetTraceCategoryEnabledFlag(name);
|
const unsigned char* categoryEnabledFlag = platform->GetTraceCategoryEnabledFlag(category);
|
||||||
if (categoryEnabledFlag != nullptr) {
|
if (categoryEnabledFlag != nullptr) {
|
||||||
return categoryEnabledFlag;
|
return categoryEnabledFlag;
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
namespace dawn_platform {
|
namespace dawn_platform {
|
||||||
|
|
||||||
class Platform;
|
class Platform;
|
||||||
|
enum class TraceCategory;
|
||||||
|
|
||||||
namespace tracing {
|
namespace tracing {
|
||||||
|
|
||||||
using TraceEventHandle = uint64_t;
|
using TraceEventHandle = uint64_t;
|
||||||
|
|
||||||
const unsigned char* GetTraceCategoryEnabledFlag(Platform* platform, const char* name);
|
const unsigned char* GetTraceCategoryEnabledFlag(Platform* platform,
|
||||||
|
TraceCategory category);
|
||||||
|
|
||||||
// TODO(enga): Simplify this API.
|
// TODO(enga): Simplify this API.
|
||||||
TraceEventHandle AddTraceEvent(Platform* platform,
|
TraceEventHandle AddTraceEvent(Platform* platform,
|
||||||
|
@ -156,12 +156,6 @@
|
|||||||
|
|
||||||
#include "dawn_platform/tracing/EventTracer.h"
|
#include "dawn_platform/tracing/EventTracer.h"
|
||||||
|
|
||||||
#define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
|
|
||||||
|
|
||||||
// By default, const char* argument values are assumed to have long-lived scope
|
|
||||||
// and will not be copied. Use this macro to force a const char* to be copied.
|
|
||||||
#define TRACE_STR_COPY(str) WebCore::TraceEvent::TraceStringWithCopy(str)
|
|
||||||
|
|
||||||
// Records a pair of begin and end events called "name" for the current
|
// Records a pair of begin and end events called "name" for the current
|
||||||
// scope, with 0, 1 or 2 associated arguments. If the category is not
|
// scope, with 0, 1 or 2 associated arguments. If the category is not
|
||||||
// enabled, then this does nothing.
|
// enabled, then this does nothing.
|
||||||
@ -681,7 +675,8 @@
|
|||||||
// event if the category is enabled.
|
// event if the category is enabled.
|
||||||
#define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \
|
#define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \
|
||||||
do { \
|
do { \
|
||||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \
|
||||||
|
::dawn_platform::TraceCategory::category); \
|
||||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||||
dawn_platform::TraceEvent::addTraceEvent( \
|
dawn_platform::TraceEvent::addTraceEvent( \
|
||||||
platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \
|
platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||||
@ -693,7 +688,7 @@
|
|||||||
// event if the category is enabled. Also adds the end event when the scope
|
// event if the category is enabled. Also adds the end event when the scope
|
||||||
// ends.
|
// ends.
|
||||||
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
|
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
|
||||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category); \
|
||||||
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
|
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
|
||||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||||
dawn_platform::TraceEvent::addTraceEvent( \
|
dawn_platform::TraceEvent::addTraceEvent( \
|
||||||
@ -707,7 +702,8 @@
|
|||||||
// event if the category is enabled.
|
// event if the category is enabled.
|
||||||
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(platform, phase, category, name, id, flags, ...) \
|
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(platform, phase, category, name, id, flags, ...) \
|
||||||
do { \
|
do { \
|
||||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \
|
||||||
|
::dawn_platform::TraceCategory::category); \
|
||||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||||
unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \
|
unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \
|
||||||
dawn_platform::TraceEvent::TraceID traceEventTraceID(id, &traceEventFlags); \
|
dawn_platform::TraceEvent::TraceID traceEventTraceID(id, &traceEventFlags); \
|
||||||
|
@ -21,11 +21,18 @@
|
|||||||
|
|
||||||
namespace dawn_platform {
|
namespace dawn_platform {
|
||||||
|
|
||||||
|
enum class TraceCategory {
|
||||||
|
General, // General trace events
|
||||||
|
Validation, // Dawn validation
|
||||||
|
Recording, // Native command recording
|
||||||
|
GPUWork, // Actual GPU work
|
||||||
|
};
|
||||||
|
|
||||||
class DAWN_NATIVE_EXPORT Platform {
|
class DAWN_NATIVE_EXPORT Platform {
|
||||||
public:
|
public:
|
||||||
virtual ~Platform() {
|
virtual ~Platform() {
|
||||||
}
|
}
|
||||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(const char* name) = 0;
|
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category) = 0;
|
||||||
|
|
||||||
virtual double MonotonicallyIncreasingTime() = 0;
|
virtual double MonotonicallyIncreasingTime() = 0;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "tests/perf_tests/DawnPerfTest.h"
|
#include "tests/perf_tests/DawnPerfTest.h"
|
||||||
|
|
||||||
|
#include "common/Assert.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
||||||
#include "utils/Timer.h"
|
#include "utils/Timer.h"
|
||||||
@ -47,7 +48,22 @@ namespace {
|
|||||||
char phase[2] = {traceEvent.phase, '\0'};
|
char phase[2] = {traceEvent.phase, '\0'};
|
||||||
|
|
||||||
value["name"] = traceEvent.name;
|
value["name"] = traceEvent.name;
|
||||||
value["cat"] = traceEvent.categoryName;
|
switch (traceEvent.category) {
|
||||||
|
case dawn_platform::TraceCategory::General:
|
||||||
|
value["cat"] = "general";
|
||||||
|
break;
|
||||||
|
case dawn_platform::TraceCategory::Validation:
|
||||||
|
value["cat"] = "validation";
|
||||||
|
break;
|
||||||
|
case dawn_platform::TraceCategory::Recording:
|
||||||
|
value["cat"] = "recording";
|
||||||
|
break;
|
||||||
|
case dawn_platform::TraceCategory::GPUWork:
|
||||||
|
value["cat"] = "gpu";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
value["ph"] = &phase[0];
|
value["ph"] = &phase[0];
|
||||||
value["id"] = traceEvent.id;
|
value["id"] = traceEvent.id;
|
||||||
value["ts"] = microseconds;
|
value["ts"] = microseconds;
|
||||||
@ -102,7 +118,6 @@ DawnPerfTestEnvironment::DawnPerfTestEnvironment(int argc, char** argv)
|
|||||||
<< " --calibration: Only run calibration. Calibration allows the perf test"
|
<< " --calibration: Only run calibration. Calibration allows the perf test"
|
||||||
" runner script to save some time.\n"
|
" runner script to save some time.\n"
|
||||||
<< " --override-steps: Set a fixed number of steps to run for each test\n"
|
<< " --override-steps: Set a fixed number of steps to run for each test\n"
|
||||||
<< " --enable-tracing: Enable tracing of Dawn's internals.\n"
|
|
||||||
<< " --trace-file: The file to dump trace results.\n"
|
<< " --trace-file: The file to dump trace results.\n"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
continue;
|
continue;
|
||||||
@ -208,9 +223,9 @@ void DawnPerfTestBase::RunTest() {
|
|||||||
// We don't care about trace events during warmup and calibration.
|
// We don't care about trace events during warmup and calibration.
|
||||||
platform->EnableTraceEventRecording(true);
|
platform->EnableTraceEventRecording(true);
|
||||||
{
|
{
|
||||||
TRACE_EVENT0(platform, "dawn.perf_test", testName);
|
TRACE_EVENT0(platform, General, testName);
|
||||||
for (unsigned int trial = 0; trial < kNumTrials; ++trial) {
|
for (unsigned int trial = 0; trial < kNumTrials; ++trial) {
|
||||||
TRACE_EVENT0(platform, "dawn.perf_test", "Trial");
|
TRACE_EVENT0(platform, General, "Trial");
|
||||||
DoRunLoop(kMaximumRunTimeSeconds);
|
DoRunLoop(kMaximumRunTimeSeconds);
|
||||||
OutputResults();
|
OutputResults();
|
||||||
}
|
}
|
||||||
@ -236,7 +251,7 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) {
|
|||||||
while (signaledFenceValue - fence.GetCompletedValue() >= mMaxStepsInFlight) {
|
while (signaledFenceValue - fence.GetCompletedValue() >= mMaxStepsInFlight) {
|
||||||
mTest->WaitABit();
|
mTest->WaitABit();
|
||||||
}
|
}
|
||||||
TRACE_EVENT0(platform, "dawn.perf_test", "Step");
|
TRACE_EVENT0(platform, General, "Step");
|
||||||
Step();
|
Step();
|
||||||
mTest->queue.Signal(fence, ++signaledFenceValue);
|
mTest->queue.Signal(fence, ++signaledFenceValue);
|
||||||
|
|
||||||
|
@ -14,23 +14,30 @@
|
|||||||
|
|
||||||
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
||||||
|
|
||||||
|
#include "common/Assert.h"
|
||||||
#include "dawn_platform/tracing/TraceEvent.h"
|
#include "dawn_platform/tracing/TraceEvent.h"
|
||||||
#include "tests/perf_tests/DawnPerfTest.h"
|
#include "tests/perf_tests/DawnPerfTest.h"
|
||||||
#include "utils/Timer.h"
|
#include "utils/Timer.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TraceCategory {
|
struct TraceCategoryInfo {
|
||||||
unsigned char enabled;
|
unsigned char enabled;
|
||||||
const char* name;
|
dawn_platform::TraceCategory category;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr TraceCategory gTraceCategories[2] = {
|
constexpr TraceCategoryInfo gTraceCategories[4] = {
|
||||||
// TODO(enga): Remove the use of this macro, but keep it disabled by default in Chromium.
|
{1, dawn_platform::TraceCategory::General},
|
||||||
{1, TRACE_DISABLED_BY_DEFAULT("gpu.dawn")},
|
{1, dawn_platform::TraceCategory::Validation},
|
||||||
{1, "dawn.perf_test"},
|
{1, dawn_platform::TraceCategory::Recording},
|
||||||
|
{1, dawn_platform::TraceCategory::GPUWork},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(static_cast<uint32_t>(dawn_platform::TraceCategory::General) == 0, "");
|
||||||
|
static_assert(static_cast<uint32_t>(dawn_platform::TraceCategory::Validation) == 1, "");
|
||||||
|
static_assert(static_cast<uint32_t>(dawn_platform::TraceCategory::Recording) == 2, "");
|
||||||
|
static_assert(static_cast<uint32_t>(dawn_platform::TraceCategory::GPUWork) == 3, "");
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
DawnPerfTestPlatform::DawnPerfTestPlatform()
|
DawnPerfTestPlatform::DawnPerfTestPlatform()
|
||||||
@ -39,15 +46,18 @@ DawnPerfTestPlatform::DawnPerfTestPlatform()
|
|||||||
|
|
||||||
DawnPerfTestPlatform::~DawnPerfTestPlatform() = default;
|
DawnPerfTestPlatform::~DawnPerfTestPlatform() = default;
|
||||||
|
|
||||||
const unsigned char* DawnPerfTestPlatform::GetTraceCategoryEnabledFlag(const char* name) {
|
const unsigned char* DawnPerfTestPlatform::GetTraceCategoryEnabledFlag(
|
||||||
for (const TraceCategory& category : gTraceCategories) {
|
dawn_platform::TraceCategory category) {
|
||||||
if (strcmp(category.name, name) == 0) {
|
switch (category) {
|
||||||
return &category.enabled;
|
case dawn_platform::TraceCategory::General:
|
||||||
|
case dawn_platform::TraceCategory::Validation:
|
||||||
|
case dawn_platform::TraceCategory::Recording:
|
||||||
|
case dawn_platform::TraceCategory::GPUWork:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
return &gTraceCategories[static_cast<uint32_t>(category)].enabled;
|
||||||
|
|
||||||
constexpr static unsigned char kZero = 0;
|
|
||||||
return &kZero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double DawnPerfTestPlatform::MonotonicallyIncreasingTime() {
|
double DawnPerfTestPlatform::MonotonicallyIncreasingTime() {
|
||||||
@ -74,11 +84,13 @@ uint64_t DawnPerfTestPlatform::AddTraceEvent(char phase,
|
|||||||
|
|
||||||
// Discover the category name based on categoryGroupEnabled. This flag comes from the first
|
// Discover the category name based on categoryGroupEnabled. This flag comes from the first
|
||||||
// parameter of TraceCategory, and corresponds to one of the entries in gTraceCategories.
|
// parameter of TraceCategory, and corresponds to one of the entries in gTraceCategories.
|
||||||
static_assert(offsetof(TraceCategory, enabled) == 0,
|
static_assert(offsetof(TraceCategoryInfo, enabled) == 0,
|
||||||
"|enabled| must be the first field of the TraceCategory class.");
|
"|enabled| must be the first field of the TraceCategoryInfo class.");
|
||||||
const TraceCategory* category = reinterpret_cast<const TraceCategory*>(categoryGroupEnabled);
|
|
||||||
|
|
||||||
mTraceEventBuffer.emplace_back(phase, category->name, name, id, timestamp);
|
const TraceCategoryInfo* info =
|
||||||
|
reinterpret_cast<const TraceCategoryInfo*>(categoryGroupEnabled);
|
||||||
|
|
||||||
|
mTraceEventBuffer.emplace_back(phase, info->category, name, id, timestamp);
|
||||||
return static_cast<uint64_t>(mTraceEventBuffer.size());
|
return static_cast<uint64_t>(mTraceEventBuffer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,19 +33,15 @@ class DawnPerfTestPlatform : public dawn_platform::Platform {
|
|||||||
TraceEvent() {
|
TraceEvent() {
|
||||||
}
|
}
|
||||||
TraceEvent(char phaseIn,
|
TraceEvent(char phaseIn,
|
||||||
const char* categoryNameIn,
|
dawn_platform::TraceCategory categoryIn,
|
||||||
const char* nameIn,
|
const char* nameIn,
|
||||||
uint64_t idIn,
|
uint64_t idIn,
|
||||||
double timestampIn)
|
double timestampIn)
|
||||||
: phase(phaseIn),
|
: phase(phaseIn), category(categoryIn), name(nameIn), id(idIn), timestamp(timestampIn) {
|
||||||
categoryName(categoryNameIn),
|
|
||||||
name(nameIn),
|
|
||||||
id(idIn),
|
|
||||||
timestamp(timestampIn) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char phase = 0;
|
char phase = 0;
|
||||||
const char* categoryName = nullptr;
|
dawn_platform::TraceCategory category;
|
||||||
const char* name = nullptr;
|
const char* name = nullptr;
|
||||||
uint64_t id = 0;
|
uint64_t id = 0;
|
||||||
double timestamp = 0;
|
double timestamp = 0;
|
||||||
@ -58,7 +54,8 @@ class DawnPerfTestPlatform : public dawn_platform::Platform {
|
|||||||
std::vector<TraceEvent> AcquireTraceEventBuffer();
|
std::vector<TraceEvent> AcquireTraceEventBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned char* GetTraceCategoryEnabledFlag(const char* name) override;
|
const unsigned char* GetTraceCategoryEnabledFlag(
|
||||||
|
dawn_platform::TraceCategory category) override;
|
||||||
|
|
||||||
double MonotonicallyIncreasingTime() override;
|
double MonotonicallyIncreasingTime() override;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user