mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +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:
committed by
Commit Bot service account
parent
7a7d547381
commit
73d5bb57e6
@@ -18,13 +18,13 @@
|
||||
|
||||
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;
|
||||
if (platform == nullptr) {
|
||||
return &disabled;
|
||||
}
|
||||
|
||||
const unsigned char* categoryEnabledFlag = platform->GetTraceCategoryEnabledFlag(name);
|
||||
const unsigned char* categoryEnabledFlag = platform->GetTraceCategoryEnabledFlag(category);
|
||||
if (categoryEnabledFlag != nullptr) {
|
||||
return categoryEnabledFlag;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
namespace dawn_platform {
|
||||
|
||||
class Platform;
|
||||
enum class TraceCategory;
|
||||
|
||||
namespace tracing {
|
||||
|
||||
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.
|
||||
TraceEventHandle AddTraceEvent(Platform* platform,
|
||||
|
||||
@@ -156,12 +156,6 @@
|
||||
|
||||
#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
|
||||
// scope, with 0, 1 or 2 associated arguments. If the category is not
|
||||
// enabled, then this does nothing.
|
||||
@@ -679,35 +673,37 @@
|
||||
|
||||
// Implementation detail: internal macro to create static category and add
|
||||
// event if the category is enabled.
|
||||
#define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \
|
||||
do { \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
dawn_platform::TraceEvent::addTraceEvent( \
|
||||
platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||
dawn_platform::TraceEvent::noEventId, flags, ##__VA_ARGS__); \
|
||||
} \
|
||||
#define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \
|
||||
do { \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \
|
||||
::dawn_platform::TraceCategory::category); \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
dawn_platform::TraceEvent::addTraceEvent( \
|
||||
platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||
dawn_platform::TraceEvent::noEventId, flags, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Implementation detail: internal macro to create static category and add begin
|
||||
// event if the category is enabled. Also adds the end event when the scope
|
||||
// ends.
|
||||
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
||||
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
dawn_platform::TraceEvent::addTraceEvent( \
|
||||
platform, TRACE_EVENT_PHASE_BEGIN, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||
dawn_platform::TraceEvent::noEventId, TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \
|
||||
INTERNALTRACEEVENTUID(profileScope) \
|
||||
.initialize(platform, INTERNALTRACEEVENTUID(catstatic), name); \
|
||||
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category); \
|
||||
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
dawn_platform::TraceEvent::addTraceEvent( \
|
||||
platform, TRACE_EVENT_PHASE_BEGIN, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||
dawn_platform::TraceEvent::noEventId, TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \
|
||||
INTERNALTRACEEVENTUID(profileScope) \
|
||||
.initialize(platform, INTERNALTRACEEVENTUID(catstatic), name); \
|
||||
}
|
||||
|
||||
// Implementation detail: internal macro to create static category and add
|
||||
// event if the category is enabled.
|
||||
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(platform, phase, category, name, id, flags, ...) \
|
||||
do { \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, category); \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \
|
||||
::dawn_platform::TraceCategory::category); \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \
|
||||
dawn_platform::TraceEvent::TraceID traceEventTraceID(id, &traceEventFlags); \
|
||||
|
||||
Reference in New Issue
Block a user