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/RenderPassEncoder.h"
|
||||
#include "dawn_native/RenderPipeline.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
#include <map>
|
||||
|
@ -706,8 +707,6 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
CommandBufferBase* CommandEncoderBase::Finish(const CommandBufferDescriptor* descriptor) {
|
||||
TRACE_EVENT0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"CommandEncoderBase::Finish");
|
||||
if (GetDevice()->ConsumedError(ValidateFinish(descriptor))) {
|
||||
// Even if finish validation fails, it is now invalid to call any encoding commands on
|
||||
// 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
|
||||
|
||||
MaybeError CommandEncoderBase::ValidateFinish(const CommandBufferDescriptor*) {
|
||||
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "CommandEncoderBase::ValidateFinish");
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
// 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/FenceSignalTracker.h"
|
||||
#include "dawn_native/Texture.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -33,7 +34,7 @@ namespace dawn_native {
|
|||
|
||||
void QueueBase::Submit(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||
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))) {
|
||||
return;
|
||||
}
|
||||
|
@ -69,6 +70,7 @@ namespace dawn_native {
|
|||
|
||||
MaybeError QueueBase::ValidateSubmit(uint32_t commandCount,
|
||||
CommandBufferBase* const* commands) {
|
||||
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation, "Queue::ValidateSubmit");
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "dawn_native/Format.h"
|
||||
#include "dawn_native/RenderPipeline.h"
|
||||
#include "dawn_native/ValidationUtils_autogen.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
|
@ -111,6 +113,8 @@ namespace dawn_native {
|
|||
}
|
||||
|
||||
MaybeError RenderBundleEncoderBase::ValidateFinish(const RenderBundleDescriptor* descriptor) {
|
||||
TRACE_EVENT0(GetDevice()->GetPlatform(), Validation,
|
||||
"RenderBundleEncoderBase::ValidateFinish");
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
// 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/D3D12Error.h"
|
||||
#include "dawn_native/d3d12/DeviceD3D12.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
|
@ -31,9 +33,13 @@ namespace dawn_native { namespace d3d12 {
|
|||
CommandRecordingContext* commandContext;
|
||||
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
|
||||
|
||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
||||
"CommandBufferD3D12::RecordCommands");
|
||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||
DAWN_TRY(ToBackend(commands[i])->RecordCommands(commandContext, i));
|
||||
}
|
||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording,
|
||||
"CommandBufferD3D12::RecordCommands");
|
||||
|
||||
DAWN_TRY(device->ExecutePendingCommandContext());
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "dawn_native/metal/StagingBufferMTL.h"
|
||||
#include "dawn_native/metal/SwapChainMTL.h"
|
||||
#include "dawn_native/metal/TextureMTL.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -180,8 +181,7 @@ namespace dawn_native { namespace metal {
|
|||
}
|
||||
|
||||
id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
|
||||
TRACE_EVENT0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"DeviceMTL::GetPendingCommandBuffer");
|
||||
TRACE_EVENT0(GetPlatform(), General, "DeviceMTL::GetPendingCommandBuffer");
|
||||
if (mPendingCommands == nil) {
|
||||
mPendingCommands = [mCommandQueue commandBuffer];
|
||||
[mPendingCommands retain];
|
||||
|
@ -228,14 +228,14 @@ namespace dawn_native { namespace metal {
|
|||
// mLastSubmittedSerial so it is captured by value.
|
||||
Serial pendingSerial = mLastSubmittedSerial;
|
||||
[mPendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
|
||||
TRACE_EVENT_ASYNC_END0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"DeviceMTL::SubmitPendingCommandBuffer", pendingSerial);
|
||||
TRACE_EVENT_ASYNC_END0(GetPlatform(), GPUWork, "DeviceMTL::SubmitPendingCommandBuffer",
|
||||
pendingSerial);
|
||||
ASSERT(pendingSerial > mCompletedSerial.load());
|
||||
this->mCompletedSerial = pendingSerial;
|
||||
}];
|
||||
|
||||
TRACE_EVENT_ASYNC_BEGIN0(GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"DeviceMTL::SubmitPendingCommandBuffer", pendingSerial);
|
||||
TRACE_EVENT_ASYNC_BEGIN0(GetPlatform(), GPUWork, "DeviceMTL::SubmitPendingCommandBuffer",
|
||||
pendingSerial);
|
||||
[mPendingCommands commit];
|
||||
mPendingCommands = nil;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "dawn_native/metal/CommandBufferMTL.h"
|
||||
#include "dawn_native/metal/DeviceMTL.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
|
@ -28,13 +29,11 @@ namespace dawn_native { namespace metal {
|
|||
device->Tick();
|
||||
id<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
|
||||
|
||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"CommandBufferMTL::FillCommands");
|
||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||
ToBackend(commands[i])->FillCommands(commandBuffer);
|
||||
}
|
||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), TRACE_DISABLED_BY_DEFAULT("gpu.dawn"),
|
||||
"CommandBufferMTL::FillCommands");
|
||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferMTL::FillCommands");
|
||||
|
||||
device->SubmitPendingCommandBuffer();
|
||||
return {};
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "dawn_native/opengl/CommandBufferGL.h"
|
||||
#include "dawn_native/opengl/DeviceGL.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
|
@ -25,9 +27,11 @@ namespace dawn_native { namespace opengl {
|
|||
MaybeError Queue::SubmitImpl(uint32_t commandCount, CommandBufferBase* const* commands) {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
|
||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||
ToBackend(commands[i])->Execute();
|
||||
}
|
||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferGL::Execute");
|
||||
|
||||
device->SubmitFenceSync();
|
||||
return {};
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "dawn_native/vulkan/CommandBufferVk.h"
|
||||
#include "dawn_native/vulkan/CommandRecordingContext.h"
|
||||
#include "dawn_native/vulkan/DeviceVk.h"
|
||||
#include "dawn_platform/DawnPlatform.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
||||
|
@ -33,10 +35,13 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
device->Tick();
|
||||
|
||||
TRACE_EVENT_BEGIN0(GetDevice()->GetPlatform(), Recording,
|
||||
"CommandBufferVk::RecordCommands");
|
||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||
for (uint32_t i = 0; i < commandCount; ++i) {
|
||||
DAWN_TRY(ToBackend(commands[i])->RecordCommands(recordingContext));
|
||||
}
|
||||
TRACE_EVENT_END0(GetDevice()->GetPlatform(), Recording, "CommandBufferVk::RecordCommands");
|
||||
|
||||
DAWN_TRY(device->SubmitPendingCommands());
|
||||
|
||||
|
|
|
@ -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); \
|
||||
|
|
|
@ -21,11 +21,18 @@
|
|||
|
||||
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 {
|
||||
public:
|
||||
virtual ~Platform() {
|
||||
}
|
||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(const char* name) = 0;
|
||||
virtual const unsigned char* GetTraceCategoryEnabledFlag(TraceCategory category) = 0;
|
||||
|
||||
virtual double MonotonicallyIncreasingTime() = 0;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "tests/perf_tests/DawnPerfTest.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
||||
#include "utils/Timer.h"
|
||||
|
@ -47,7 +48,22 @@ namespace {
|
|||
char phase[2] = {traceEvent.phase, '\0'};
|
||||
|
||||
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["id"] = traceEvent.id;
|
||||
value["ts"] = microseconds;
|
||||
|
@ -102,7 +118,6 @@ DawnPerfTestEnvironment::DawnPerfTestEnvironment(int argc, char** argv)
|
|||
<< " --calibration: Only run calibration. Calibration allows the perf test"
|
||||
" runner script to save some time.\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"
|
||||
<< std::endl;
|
||||
continue;
|
||||
|
@ -208,9 +223,9 @@ void DawnPerfTestBase::RunTest() {
|
|||
// We don't care about trace events during warmup and calibration.
|
||||
platform->EnableTraceEventRecording(true);
|
||||
{
|
||||
TRACE_EVENT0(platform, "dawn.perf_test", testName);
|
||||
TRACE_EVENT0(platform, General, testName);
|
||||
for (unsigned int trial = 0; trial < kNumTrials; ++trial) {
|
||||
TRACE_EVENT0(platform, "dawn.perf_test", "Trial");
|
||||
TRACE_EVENT0(platform, General, "Trial");
|
||||
DoRunLoop(kMaximumRunTimeSeconds);
|
||||
OutputResults();
|
||||
}
|
||||
|
@ -236,7 +251,7 @@ void DawnPerfTestBase::DoRunLoop(double maxRunTime) {
|
|||
while (signaledFenceValue - fence.GetCompletedValue() >= mMaxStepsInFlight) {
|
||||
mTest->WaitABit();
|
||||
}
|
||||
TRACE_EVENT0(platform, "dawn.perf_test", "Step");
|
||||
TRACE_EVENT0(platform, General, "Step");
|
||||
Step();
|
||||
mTest->queue.Signal(fence, ++signaledFenceValue);
|
||||
|
||||
|
|
|
@ -14,23 +14,30 @@
|
|||
|
||||
#include "tests/perf_tests/DawnPerfTestPlatform.h"
|
||||
|
||||
#include "common/Assert.h"
|
||||
#include "dawn_platform/tracing/TraceEvent.h"
|
||||
#include "tests/perf_tests/DawnPerfTest.h"
|
||||
#include "utils/Timer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
struct TraceCategory {
|
||||
struct TraceCategoryInfo {
|
||||
unsigned char enabled;
|
||||
const char* name;
|
||||
dawn_platform::TraceCategory category;
|
||||
};
|
||||
|
||||
constexpr TraceCategory gTraceCategories[2] = {
|
||||
// TODO(enga): Remove the use of this macro, but keep it disabled by default in Chromium.
|
||||
{1, TRACE_DISABLED_BY_DEFAULT("gpu.dawn")},
|
||||
{1, "dawn.perf_test"},
|
||||
constexpr TraceCategoryInfo gTraceCategories[4] = {
|
||||
{1, dawn_platform::TraceCategory::General},
|
||||
{1, dawn_platform::TraceCategory::Validation},
|
||||
{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
|
||||
|
||||
DawnPerfTestPlatform::DawnPerfTestPlatform()
|
||||
|
@ -39,15 +46,18 @@ DawnPerfTestPlatform::DawnPerfTestPlatform()
|
|||
|
||||
DawnPerfTestPlatform::~DawnPerfTestPlatform() = default;
|
||||
|
||||
const unsigned char* DawnPerfTestPlatform::GetTraceCategoryEnabledFlag(const char* name) {
|
||||
for (const TraceCategory& category : gTraceCategories) {
|
||||
if (strcmp(category.name, name) == 0) {
|
||||
return &category.enabled;
|
||||
}
|
||||
const unsigned char* DawnPerfTestPlatform::GetTraceCategoryEnabledFlag(
|
||||
dawn_platform::TraceCategory category) {
|
||||
switch (category) {
|
||||
case dawn_platform::TraceCategory::General:
|
||||
case dawn_platform::TraceCategory::Validation:
|
||||
case dawn_platform::TraceCategory::Recording:
|
||||
case dawn_platform::TraceCategory::GPUWork:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
constexpr static unsigned char kZero = 0;
|
||||
return &kZero;
|
||||
return &gTraceCategories[static_cast<uint32_t>(category)].enabled;
|
||||
}
|
||||
|
||||
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
|
||||
// parameter of TraceCategory, and corresponds to one of the entries in gTraceCategories.
|
||||
static_assert(offsetof(TraceCategory, enabled) == 0,
|
||||
"|enabled| must be the first field of the TraceCategory class.");
|
||||
const TraceCategory* category = reinterpret_cast<const TraceCategory*>(categoryGroupEnabled);
|
||||
static_assert(offsetof(TraceCategoryInfo, enabled) == 0,
|
||||
"|enabled| must be the first field of the TraceCategoryInfo class.");
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,15 @@ class DawnPerfTestPlatform : public dawn_platform::Platform {
|
|||
TraceEvent() {
|
||||
}
|
||||
TraceEvent(char phaseIn,
|
||||
const char* categoryNameIn,
|
||||
dawn_platform::TraceCategory categoryIn,
|
||||
const char* nameIn,
|
||||
uint64_t idIn,
|
||||
double timestampIn)
|
||||
: phase(phaseIn),
|
||||
categoryName(categoryNameIn),
|
||||
name(nameIn),
|
||||
id(idIn),
|
||||
timestamp(timestampIn) {
|
||||
: phase(phaseIn), category(categoryIn), name(nameIn), id(idIn), timestamp(timestampIn) {
|
||||
}
|
||||
|
||||
char phase = 0;
|
||||
const char* categoryName = nullptr;
|
||||
dawn_platform::TraceCategory category;
|
||||
const char* name = nullptr;
|
||||
uint64_t id = 0;
|
||||
double timestamp = 0;
|
||||
|
@ -58,7 +54,8 @@ class DawnPerfTestPlatform : public dawn_platform::Platform {
|
|||
std::vector<TraceEvent> AcquireTraceEventBuffer();
|
||||
|
||||
private:
|
||||
const unsigned char* GetTraceCategoryEnabledFlag(const char* name) override;
|
||||
const unsigned char* GetTraceCategoryEnabledFlag(
|
||||
dawn_platform::TraceCategory category) override;
|
||||
|
||||
double MonotonicallyIncreasingTime() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue